From bc08a919d2b58930c99818ec1d629c4c712c02ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Apr 2012 12:49:49 +1000 Subject: TONY: Created skeleton engine --- engines/configure.engines | 1 + engines/engines.mk | 5 +++ engines/plugins_table.h | 3 ++ engines/tony/detection.cpp | 93 +++++++++++++++++++++++++++++++++++++++++ engines/tony/detection_tables.h | 43 +++++++++++++++++++ engines/tony/module.mk | 13 ++++++ engines/tony/tony.cpp | 39 +++++++++++++++++ engines/tony/tony.h | 80 +++++++++++++++++++++++++++++++++++ 8 files changed, 277 insertions(+) create mode 100644 engines/tony/detection.cpp create mode 100644 engines/tony/detection_tables.h create mode 100644 engines/tony/module.mk create mode 100644 engines/tony/tony.cpp create mode 100644 engines/tony/tony.h (limited to 'engines') diff --git a/engines/configure.engines b/engines/configure.engines index 6e8db01e66..4d416381bf 100644 --- a/engines/configure.engines +++ b/engines/configure.engines @@ -43,5 +43,6 @@ add_engine tinsel "Tinsel" yes add_engine toltecs "3 Skulls of the Toltecs" no add_engine toon "Toonstruck" yes add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes +add_engine tony "Tony Tough and the Night of Roasted Moths" no add_engine tsage "TsAGE" yes add_engine tucker "Bud Tucker in Double Trouble" yes diff --git a/engines/engines.mk b/engines/engines.mk index 9939506b86..bf6fa7a09d 100644 --- a/engines/engines.mk +++ b/engines/engines.mk @@ -197,6 +197,11 @@ DEFINES += -DENABLE_TOLTECS=$(ENABLE_TOLTECS) MODULES += engines/toltecs endif +ifdef ENABLE_TONY +DEFINES += -DENABLE_TONY=$(ENABLE_TONY) +MODULES += engines/tony +endif + ifdef ENABLE_TOON DEFINES += -DENABLE_TOON=$(ENABLE_TOON) MODULES += engines/toon diff --git a/engines/plugins_table.h b/engines/plugins_table.h index fac956755e..d75c4a78b9 100644 --- a/engines/plugins_table.h +++ b/engines/plugins_table.h @@ -89,6 +89,9 @@ LINK_PLUGIN(TINSEL) #if PLUGIN_ENABLED_STATIC(TOLTECS) LINK_PLUGIN(TOLTECS) #endif +#if PLUGIN_ENABLED_STATIC(TONY) +LINK_PLUGIN(TONY) +#endif #if PLUGIN_ENABLED_STATIC(TOON) LINK_PLUGIN(TOON) #endif diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp new file mode 100644 index 0000000000..58d16842d4 --- /dev/null +++ b/engines/tony/detection.cpp @@ -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. + * + * + */ + +#include "base/plugins.h" + +#include "engines/advancedDetector.h" +#include "common/system.h" + +#include "tony/tony.h" + + +namespace Tony { + +struct TonyGameDescription { + ADGameDescription desc; +}; + +uint32 TonyEngine::getFeatures() const { + return _gameDescription->desc.flags; +} + +Common::Language TonyEngine::getLanguage() const { + return _gameDescription->desc.language; +} + +} + +static const PlainGameDescriptor tonyGames[] = { + {"tony", "Tony Tough and the Night of Roasted Moths"}, + {0, 0} +}; + +#include "tony/detection_tables.h" + +class TonyMetaEngine : public AdvancedMetaEngine { +public: + TonyMetaEngine() : AdvancedMetaEngine(Tony::gameDescriptions, sizeof(Tony::TonyGameDescription), tonyGames) { + } + + virtual const char *getName() const { + return "Tony Engine"; + } + + virtual const char *getOriginalCopyright() const { + return "Tony Engine (C) Protonic Interactive"; + } + + virtual bool hasFeature(MetaEngineFeature f) const; + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; +}; + +bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { + return false; +} + +bool Tony::TonyEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsRTL); +} + +bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + const Tony::TonyGameDescription *gd = (const Tony::TonyGameDescription *)desc; + if (gd) { + *engine = new Tony::TonyEngine(syst, gd); + } + return gd != 0; +} + +#if PLUGIN_ENABLED_DYNAMIC(TONY) + REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +#else + REGISTER_PLUGIN_STATIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +#endif diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h new file mode 100644 index 0000000000..bb660dd862 --- /dev/null +++ b/engines/tony/detection_tables.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 Tony { + +static const TonyGameDescription gameDescriptions[] = { + + { + // Tony Tough English Demo + { + "tony", + "Demo", + AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_DEMO, + GUIO1(GUIO_NONE) + }, + }, + + { AD_TABLE_END_MARKER } +}; + +} // End of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk new file mode 100644 index 0000000000..840fbc0dbf --- /dev/null +++ b/engines/tony/module.mk @@ -0,0 +1,13 @@ +MODULE := engines/tony + +MODULE_OBJS := \ + detection.o \ + tony.o + +# This module can be built as a plugin +ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp new file mode 100644 index 0000000000..523147c848 --- /dev/null +++ b/engines/tony/tony.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 "tony/tony.h" + +namespace Tony { + +TonyEngine *_vm; + +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { +} + +TonyEngine::~TonyEngine() { +} + +Common::Error TonyEngine::run() { + return Common::kNoError; +} + +} // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h new file mode 100644 index 0000000000..5aa0de95a3 --- /dev/null +++ b/engines/tony/tony.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. + * + */ + +#ifndef TONY_H +#define TONY_H + +#include "common/scummsys.h" +#include "common/system.h" +#include "common/error.h" +#include "common/events.h" +#include "common/keyboard.h" +#include "common/util.h" +#include "engines/engine.h" + +/** + * This is the namespace of the Tony engine. + * + * Status of this engine: In Development + * + * Games using this engine: + * - Tony Tough + */ +namespace Tony { + +enum { + kTonyDebugAnimations = 1 << 0, + kTonyDebugActions = 1 << 1, + kTonyDebugSound = 1 << 2, + kTonyDebugMusic = 2 << 3 +}; + +#define DEBUG_BASIC 1 +#define DEBUG_INTERMEDIATE 2 +#define DEBUG_DETAILED 3 + +struct TonyGameDescription; + +class TonyEngine : public Engine { +protected: + // Engine APIs + virtual Common::Error run(); + virtual bool hasFeature(EngineFeature f) const; +public: + TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); + virtual ~TonyEngine(); + + const TonyGameDescription *_gameDescription; + uint32 getGameID() const; + uint32 getFeatures() const; + Common::Language getLanguage() const; + uint16 getVersion() const; + uint32 getFlags() const; + Common::Platform getPlatform() const; +}; + +// Global reference to the TonyEngine object +extern TonyEngine *_vm; + +} // End of namespace Tony + +#endif /* TONY_H */ -- cgit v1.2.3 From 7003d4996a926d912816f19c3afd634e17cef095 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Apr 2012 17:06:26 +1000 Subject: TONY: Imported mpal.h file, and translated the comments --- engines/tony/mpal.h | 750 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 750 insertions(+) create mode 100644 engines/tony/mpal.h (limited to 'engines') diff --git a/engines/tony/mpal.h b/engines/tony/mpal.h new file mode 100644 index 0000000000..f0aa5e79e2 --- /dev/null +++ b/engines/tony/mpal.h @@ -0,0 +1,750 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: MPAL Main Include file. * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Main Include file for * + * 4> ^R$oue# d using MPAL.DLL......... * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + + +/****************************************************************************\ +* Copyright Notice +\****************************************************************************/ + +/* + * A Spyral Software Production: + * + * MPAL - MultiPurpose Adventure Language + * (C) 1997 Giovanni Bajo and Luca Giusti + * ALL RIGHTS RESERVED + * + * + */ + + +/****************************************************************************\ +* General Introduction +\****************************************************************************/ + +/* + * MPAL (MultiPurpose Adventure Language) is a high level language + * for the definition of adventure. Through the use of MPAL you can describe + * storyboard the adventure, and then use it with any user interface. + * In fact, unlike many other similar products, MPAL is not programmed through + * the whole adventure, but are defined only the locations, objects, as they may + * interact with each other, etc.. thus making MPAL useful for any type of adventure. + */ + +/****************************************************************************\ +* Structure +\****************************************************************************/ + +/* + * MPAL consists of two main files: MPAL.DLL and MPAL.H + * The first is the DLL that contains the code to interface with MPAL + * adventures, the second is the header that defines the prototypes + * functions. MPAL is compiled for Win32, and it can therefore be used with + * any compiler that supports Win32 DLL (Watcom C++, Visual C++, + * Delphi, etc.), and therefore compatible with both Windows 95 and Windows NT. + * + * To use the DLL, and 'obviously need to create a library for symbols to export. + * + */ + + +/****************************************************************************\ +* Custom Functions +\****************************************************************************/ + +/* + * A custom function and a function specified by the program that uses the + * library, to perform the particular code. The custom functions are + * retrieved from the library as specified in the source MPAL, and in particular + * in defining the behavior of an item with some action. + * + * To use the custom functions, you need to prepare an array of + * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, + * (defined below), and pass it as second parameter to mpalInit (). Note you + * must specify the size of the array, as elements of pointers and which do not + * contain the same: the library will call it only those functions specified in + * the source MPAL. It can be useful, for debugging reasons, do not bet + * the shares of arrays used to debugging function, to avoid unpleasant crash, + * if it has been made an error in source and / or some oversight in the code. + * + */ + +#ifndef __MPAL_H +#define __MPAL_H + +#include "common/rect.h" + +/****************************************************************************\ +* Macro definitions and structures +\****************************************************************************/ + +/* OK value for the error codes */ +#define OK 0 + +#define MAXFRAMES 400 // frame animation of an object +#define MAXPATTERN 40 // pattern of animation of an object + +#define MAXPOLLINGLOCATIONS 64 + +#define EXPORT +#define LPSTR char * + +/****************************************************************************\ +* enum QueryCoordinates +* --------------------- +* Description: Macro for use with queries that may refer to X and Y co-ordinates +\****************************************************************************/ + +enum QueryCoordinates { + MPQ_X, + MPQ_Y +}; + + +/****************************************************************************\ +* enum QueryTypes +* --------------- +* Description: Query can be used with mpalQuery (). In practice corresponds +* all claims that can do at the library +\****************************************************************************/ + +enum QueryTypes { + /* General Query */ + MPQ_VERSION=10, + + MPQ_GLOBAL_VAR=50, + MPQ_RESOURCE, + MPQ_MESSAGE, + + /* Query on leases */ + MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_SIZE, + + /* Queries about items */ + MPQ_ITEM_LIST=200, + MPQ_ITEM_DATA, + MPQ_ITEM_PATTERN, + MPQ_ITEM_NAME, + MPQ_ITEM_IS_ACTIVE, + + /* Query dialog */ + MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_WAITFORCHOICE, + MPQ_DIALOG_SELECTLIST, + MPQ_DIALOG_SELECTION, + + /* Query execution */ + MPQ_DO_ACTION=400, + MPQ_DO_DIALOG +}; + + +/****************************************************************************\ +* typedef ITEM +* ------------ +* Description: Framework to manage the animation of an item +\****************************************************************************/ + +typedef struct { + char *frames[MAXFRAMES]; + Common::Rect frameslocations[MAXFRAMES]; + Common::Rect bbox[MAXFRAMES]; + short pattern[MAXPATTERN][MAXFRAMES]; + short speed; + char numframe; + char numpattern; + char curframe; + char curpattern; + short destX, destY; + signed char Zvalue; + short objectID; + char TAG; +} ITEM; +typedef ITEM *LPITEM; + + +/****************************************************************************\ +* typedef LPCUSTOMFUNCTION +* ------------------------ +* Description: Define a custom function, to use the language MPAL +* to perform various controls as a result of an action +\****************************************************************************/ + +typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); +typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; + + +/****************************************************************************\ +* typedef LPITEMIRQFUNCTION +* ------------------------- +* Description: Define an IRQ of an item that is called when the +* pattern changes or the status of an item +\****************************************************************************/ + +typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); +typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; + + +/****************************************************************************\ +* Macrofunctions query +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: uint32 mpalQueryVersion(void); +* +* Description: Gets the current version of MPAL +* +* Return: Version number (0x1232 = 1.2.3b) +* +\****************************************************************************/ + +#define mpalQueryVersion() \ + (uint16)mpalQuery(MPQ_VERSION) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); +* +* Description: Gets the numerical value of a global variable +* +* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) +* +* Return: Valore della variabile +* +* Note: This query was implemented for debugging. The program, +* if well designed, should not need to access variables from +* within the library. +* +\****************************************************************************/ + +#define mpalQueryGlobalVar(lpszVarName) \ + (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryResource(uint32 dwResId); +* +* Description: Provides access to a resource inside the .MPC file +* +* Input: uint32 dwResId ID della risorsa +* +* Return: Handle to a memory area containing the resource, +* ready for use. +* +\****************************************************************************/ + +#define mpalQueryResource(dwResId) \ + (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryMessage(uint32 nMsg); +* +* Description: Returns a message. +* +* Input: uint32 nMsg Message number +* +* Return: ASCIIZ message +* +* Note: The returned pointer must be freed with GlobalFree() +* after use. The message will be in ASCIIZ format. +* +\****************************************************************************/ + +#define mpalQueryMessage(nMsg) \ + (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); +* +* Description: Provides a image image +* +* Input: uint32 nLoc Locazion number +* +* Return: Returns a picture handle +* +\****************************************************************************/ + +#define mpalQueryLocationImage(nLoc) \ + (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); +* +* Description: Request the x or y size of a location in pixels +* +* Input: uint32 nLoc Location number +* uint32 dwCoord MPQ_Xr o MPQ_Y +* +* Return: Size +* +\****************************************************************************/ + +#define mpalQueryLocationSize(nLoc,dwCoord) \ + (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + + + +/****************************************************************************\ +* +* Function: LPuint32 mpalQueryItemList(uint32 nLoc); +* +* Description: Provides the list of objects in the lease. +* +* Input: uint32 nLoc Location number +* +* Return: List of objects (accessible by Item [0], Item [1], etc.) +* +\****************************************************************************/ + +#define mpalQueryItemList(nLoc) \ + (LPuint32)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); +* +* Description: Provides information on an item +*e +* Input: uint32 nItem Item number +* +* Return: structure filled with requested information +* +\****************************************************************************/ + +#define mpalQueryItemData(nItem) \ + (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryItemPattern(uint32 nItem); +* +* Description: Provides the current pattern of an item +* +* Input: uint32 nItem Item number +* +* Return: Number of animation patterns to be executed. +* +* Note: By default, the pattern of 0 indicates that we should +* do nothing. +* +\****************************************************************************/ + +#define mpalQueryItemPattern(nItem) \ + (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryItemIsActive(uint32 nItem); +* +* Description: Returns true if an item is active +* +* Input: uint32 nItem Item number +* +* Return: TRUE if the item is active, FALSE otherwise +* +\****************************************************************************/ + +#define mpalQueryItemIsActive(nItem) \ + (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + + +/****************************************************************************\ +* +* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); +* +* Description: Returns the name of an item +* +* Input: uint32 nItem Item number +* LPSTR lpszName Pointer to a buffer of at least 33 bytes +* that will be filled with the name +* +* Note: If the item is not active (ie. if its status or number +* is less than or equal to 0), the string will be empty. +* +\****************************************************************************/ + +#define mpalQueryItemName(nItem,lpszName) \ + (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); +* +* Description: Returns a sentence of dialog. +* +* Input: uint32 nDialog Dialog number +* uint32 nPeriod Number of words +* +* Return: A pointer to the string of words, or NULL on failure. +* +* Note: The string must be freed after use by GlobalFree (). +* +* Unlike normal messages, the sentences of dialogue +* are formed by a single string terminated with 0. +* +\****************************************************************************/ + +#define mpalQueryDialogPeriod(nPeriod) \ + (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) + + + +/****************************************************************************\ +* +* Function: int mpalQueryDialogWaitForChoice(void); +* +* Description: Wait until the moment in which the need is signaled +* to make a choice by the user. +* +* Return: Number of choice to be made, or -1 if the dialogue is finished. +* +\****************************************************************************/ + +#define mpalQueryDialogWaitForChoice() \ + (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) + + + +/****************************************************************************\ +* +* Function: LPuint32 mpalQueryDialogSelectList(uint32 nChoice); +* +* Description: Requires a list of various options for some choice within +* the current dialog. + +* Input: uint32 nChoice Choice number +* +* Return: A pointer to an array containing the data matched to each option. +* +* Note: The figure 'a uint32 specified in the source to which MPAL +* You can 'assign meaning that the more' suits. +* +* The pointer msut be freed after use by GlobalFree(). +* +\****************************************************************************/ + +#define mpalQueryDialogSelectList(nChoice) \ + (LPuint32)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); +* +* Description: Warns the library that the user has selected, in a certain +* choice of the current dialog, corresponding option +* at a certain given. +* +* Input: uint32 nChoice Choice number of the choice that +* was in progress +* uint32 dwData Option that was selected by the user. +* +* Return: TRUE if all OK, FALSE on failure. +* +* Note: After execution of this query, MPAL continue +* Groups according to the execution of the dialogue. And necessary so the game +* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). +* +\****************************************************************************/ + +#define mpalQueryDialogSelection(nChoice,dwData) \ + (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, +* uint32 dwParam); +* +* Description: Warns the library an action was performed on a Object. +* The library will call 'custom functions, if necessary. +* +* Input: uint32 nAction Action number +* uint32 nItem Item number +* uint32 dwParam Action parameter +* +* Return: Handle to the thread that is performing the action, or +* INVALID_HANDLE_VALUE if the action is not 'defined for +* the item, or the item and 'off. +* +* Note: The parameter is used primarily to implement actions +* as "U.S." involving two objects together. The action will be executed only +* if the item is active, ie if its status is a positive number greater than 0. +* +\****************************************************************************/ + +#define mpalQueryDoAction(nAction,nItem,dwParam) \ + (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); +* +* Description: Warns the library a dialogue was required. +* +* Input: uint32 nDialog Dialog number +* uint32 nGroup Group number to use +* +* Return: Handle to the thread that is running the box, or +* INVALID_HANDLE_VALUE if the dialogue does not exist. +* +\****************************************************************************/ + +#define mpalQueryDoDialog(nDialog,nGroup) \ + (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) + + + +/****************************************************************************\ +* Functions exported DLL +\****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************\ +* +* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, +* LPLPCUSTOMFUNCTION lplpcfArray); +* +* Description: Initializes the MPAL library, and opens an .MPC file, which +* will be 'used for all queries +* +* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension +* LPSTR lpszMprFileName Name of the .MPR file, including extension +* LPLPCUSTOMFUNCTION Array of pointers to custom functions +* +* Return: TRUE if all OK, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, + LPLPCUSTOMFUNCTION lplpcfArray); + + + +/****************************************************************************\ +* +* Function: uint32 mpalQuery(uint16 wQueryType, ...); +* +* Description: This is the general function to communicate with the library, +* To request information about what is in the .MPC file +* +* Input: uint16 wQueryType Type of query. The list is in +* the QueryTypes enum. +* +* Return: 4 bytes depending on the type of query +* +* Note: I _strongly_ recommended to use macros defined above to use +* the query, since it helps avoid any unpleasant bugs due to +* forgeting parameters. +* +\****************************************************************************/ + +uint32 EXPORT mpalQuery(uint16 wQueryType, ...); + + + +/****************************************************************************\ +* +* Function: bool mpalExecuteScript(int nScript); +* +* Description: Execute a script. The script runs on multitasking by a thread. +* +* Input: int nScript Script number to run +* +* Return: TRUE if the script 'was launched, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalExecuteScript(int nScript); + + + +/****************************************************************************\ +* +* Function: uint32 mpalGetError(void); +* +* Description: Returns the current MPAL error code +* +* Return: Error code +* +\****************************************************************************/ + +uint32 EXPORT mpalGetError(void); + + + +/****************************************************************************\ +* +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* +* Description: Install a custom routine That will be called by MPAL +* every time the pattern of an item has-been changed. +* +* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* +\****************************************************************************/ + +void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); + + +/****************************************************************************\ +* +* Function: bool mpalStartIdlePoll(int nLoc); +* +* Description: Process the idle actions of the items on one location. +* +* Input: int nLoc Number of the location whose items +* must be processed for idle actions. +* +* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. +* +* Note: The maximum number of locations that can be polled +* simultaneously is defined defined by MAXPOLLINGFUNCIONS +* +\****************************************************************************/ + +bool EXPORT mpalStartIdlePoll(int nLoc); + + +/****************************************************************************\ +* +* Function: bool mpalEndIdlePoll(int nLoc); +* +* Description: Stop processing the idle actions of the items on one location. +* +* Input: int nLoc Number of the location +* +* Return: TRUE if all OK, FALSE if the specified location was not +* in the process of polling +* +\****************************************************************************/ + +bool EXPORT mpalEndIdlePoll(int nLoc); + + + +/****************************************************************************\ +* +* Function: int mpalLoadState(LPBYTE buf); +* +* Description: Load a save state from a buffer. +* +* Input: LPBYTE buf Buffer where to store the state +* +* Return: Length of the state in bytes +* +\****************************************************************************/ + +int EXPORT mpalLoadState(byte *buf); + + + +/****************************************************************************\ +* +* Function: void mpalSaveState(LPBYTE buf); +* +* Description: Store the save state into a buffer. The buffer must be +* length at least the size specified with mpalGetSaveStateSize +* +* Input: LPBYTE buf Buffer where to store the state +* +\****************************************************************************/ + +void EXPORT mpalSaveState(byte *buf); + + + +/****************************************************************************\ +* +* Function: int mpalGetSaveStateSize(void); +* +* Description: Acquire the length of a save state +* +* Return: Length in bytes +* +\****************************************************************************/ + +int EXPORT mpalGetSaveStateSize(void); + + +#ifdef __cplusplus +} +#endif + +#endif + -- cgit v1.2.3 From 637be83cf5b129b7e55de97c5988f4dfa3c397bf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 26 Apr 2012 09:43:55 +1000 Subject: TONY: Start of work converting over MPAL sub-system --- engines/tony/lzo/lzo1x.h | 198 +++ engines/tony/lzo/lzoconf.h | 398 ++++++ engines/tony/module.mk | 6 +- engines/tony/mpal.h | 23 +- engines/tony/mpal/expr.cpp | 471 +++++++ engines/tony/mpal/expr.h | 116 ++ engines/tony/mpal/loadmpc.cpp | 720 ++++++++++ engines/tony/mpal/loadmpc.h | 83 ++ engines/tony/mpal/lzo1x.h | 188 +++ engines/tony/mpal/mpal.cpp | 3071 +++++++++++++++++++++++++++++++++++++++++ engines/tony/mpal/mpal.h | 769 +++++++++++ engines/tony/mpal/mpaldll.h | 418 ++++++ engines/tony/mpal/stubs.cpp | 140 ++ engines/tony/mpal/stubs.h | 121 ++ engines/tony/tony.cpp | 45 +- engines/tony/tony.h | 14 +- 16 files changed, 6765 insertions(+), 16 deletions(-) create mode 100644 engines/tony/lzo/lzo1x.h create mode 100644 engines/tony/lzo/lzoconf.h create mode 100644 engines/tony/mpal/expr.cpp create mode 100644 engines/tony/mpal/expr.h create mode 100644 engines/tony/mpal/loadmpc.cpp create mode 100644 engines/tony/mpal/loadmpc.h create mode 100644 engines/tony/mpal/lzo1x.h create mode 100644 engines/tony/mpal/mpal.cpp create mode 100644 engines/tony/mpal/mpal.h create mode 100644 engines/tony/mpal/mpaldll.h create mode 100644 engines/tony/mpal/stubs.cpp create mode 100644 engines/tony/mpal/stubs.h (limited to 'engines') diff --git a/engines/tony/lzo/lzo1x.h b/engines/tony/lzo/lzo1x.h new file mode 100644 index 0000000000..e481b33fa4 --- /dev/null +++ b/engines/tony/lzo/lzo1x.h @@ -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. + * + */ +/* lzo1x.h -- public interface of the LZO1X compression algorithm + + This file is part of the LZO real-time data compression library. + + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html + */ + + +#ifndef __LZO1X_H +#define __LZO1X_H + +#ifndef __LZOCONF_H +#include "lzoconf.h" +#endif + +namespace Tony { + +namespace LZO { + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** +// +************************************************************************/ + +/* Memory required for the wrkmem parameter. + * When the required size is 0, you can also pass a NULL pointer. + */ + +#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS +#define LZO1X_MEM_DECOMPRESS (0) +#define LZO1X_MEM_OPTIMIZE (0) + + +/* decompression */ +LZO_EXTERN(int) +lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + +/* safe decompression with overrun testing */ +LZO_EXTERN(int) +lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + + +/*********************************************************************** +// +************************************************************************/ + +#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// special compressor versions +************************************************************************/ + +/* this version needs only 8 kB work memory */ +#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* this version needs 16 kB work memory */ +#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* use this version if you need a little more compression speed */ +#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// better compression ratio at the cost of more memory and time +************************************************************************/ + +#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); +#endif + + +/*********************************************************************** +// +************************************************************************/ + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + +LZO_EXTERN(int) +lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len, + lzo_progress_callback_t cb, + int compression_level ); +#endif + +LZO_EXTERN(int) +lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem /* NOT USED */, + const lzo_byte *dict, lzo_uint dict_len ); + + +/*********************************************************************** +// optimize a compressed data block +************************************************************************/ + +LZO_EXTERN(int) +lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem ); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +} // End of namespace LZO + +} // End of namespace Tony + +#endif /* already included */ + diff --git a/engines/tony/lzo/lzoconf.h b/engines/tony/lzo/lzoconf.h new file mode 100644 index 0000000000..9dfcfb0cbc --- /dev/null +++ b/engines/tony/lzo/lzoconf.h @@ -0,0 +1,398 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/* lzoconf.h -- configuration for the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html + */ + + +#ifndef __LZOCONF_H +#define __LZOCONF_H + +namespace Tony { + +namespace LZO { + +#define LZO_VERSION 0x1060 +#define LZO_VERSION_STRING "1.06" +#define LZO_VERSION_DATE "Nov 29 1999" + +/* internal Autoconf configuration file - only used when building LZO */ +#if defined(LZO_HAVE_CONFIG_H) +# include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** +// LZO requires a conforming +************************************************************************/ + +#if !defined(CHAR_BIT) || (CHAR_BIT != 8) +# error "invalid CHAR_BIT" +#endif +#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) +# error "check your compiler installation" +#endif +#if (USHRT_MAX < 1 ) || (UINT_MAX < 1) || (ULONG_MAX < 1) +# error "your limits.h macros are broken" +#endif + +/* workaround a cpp bug under hpux 10.20 */ +#define LZO_0xffffffffL 4294967295ul + + +/*********************************************************************** +// architecture defines +************************************************************************/ + +#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2) +# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) +# define __LZO_WIN +# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) +# define __LZO_WIN +# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) +# define __LZO_WIN +# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) +# define __LZO_DOS +# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) +# define __LZO_OS2 +# elif defined(__palmos__) +# define __LZO_PALMOS +# elif defined(__TOS__) || defined(__atarist__) +# define __LZO_TOS +# endif +#endif + +#if (UINT_MAX < LZO_0xffffffffL) +# if defined(__LZO_WIN) +# define __LZO_WIN16 +# elif defined(__LZO_DOS) +# define __LZO_DOS16 +# elif defined(__LZO_PALMOS) +# define __LZO_PALMOS16 +# elif defined(__LZO_TOS) +# define __LZO_TOS16 +# elif defined(__C166__) +# else +# error "16-bit target not supported - contact me for porting hints" +# endif +#endif + +#if !defined(__LZO_i386) +# if defined(__LZO_DOS) || defined(__LZO_WIN16) +# define __LZO_i386 +# elif defined(__i386__) || defined(__386__) || defined(_M_IX86) +# define __LZO_i386 +# endif +#endif + +#if defined(__LZO_STRICT_16BIT) +# if (UINT_MAX < LZO_0xffffffffL) +# include +# endif +#endif + + +/*********************************************************************** +// integral and pointer types +************************************************************************/ + +/* Integral types with 32 bits or more */ +#if !defined(LZO_UINT32_MAX) +# if (UINT_MAX >= LZO_0xffffffffL) + typedef unsigned int lzo_uint32; + typedef int lzo_int32; +# define LZO_UINT32_MAX UINT_MAX +# define LZO_INT32_MAX INT_MAX +# define LZO_INT32_MIN INT_MIN +# elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint32; + typedef long lzo_int32; +# define LZO_UINT32_MAX ULONG_MAX +# define LZO_INT32_MAX LONG_MAX +# define LZO_INT32_MIN LONG_MIN +# else +# error "lzo_uint32" +# endif +#endif + +/* lzo_uint is used like size_t */ +#if !defined(LZO_UINT_MAX) +# if (UINT_MAX >= LZO_0xffffffffL) + typedef unsigned int lzo_uint; + typedef int lzo_int; +# define LZO_UINT_MAX UINT_MAX +# define LZO_INT_MAX INT_MAX +# define LZO_INT_MIN INT_MIN +# elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint; + typedef long lzo_int; +# define LZO_UINT_MAX ULONG_MAX +# define LZO_INT_MAX LONG_MAX +# define LZO_INT_MIN LONG_MIN +# else +# error "lzo_uint" +# endif +#endif + + +/* Memory model that allows to access memory at offsets of lzo_uint. */ +#if !defined(__LZO_MMODEL) +# if (LZO_UINT_MAX <= UINT_MAX) +# define __LZO_MMODEL +# elif defined(__LZO_DOS16) || defined(__LZO_WIN16) +# define __LZO_MMODEL __huge +# define LZO_999_UNSUPPORTED +# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16) +# define __LZO_MMODEL +# else +# error "__LZO_MMODEL" +# endif +#endif + +/* no typedef here because of const-pointer issues */ +#define lzo_byte unsigned char __LZO_MMODEL +#define lzo_bytep unsigned char __LZO_MMODEL * +#define lzo_charp char __LZO_MMODEL * +#define lzo_voidp void __LZO_MMODEL * +#define lzo_shortp short __LZO_MMODEL * +#define lzo_ushortp unsigned short __LZO_MMODEL * +#define lzo_uint32p lzo_uint32 __LZO_MMODEL * +#define lzo_int32p lzo_int32 __LZO_MMODEL * +#define lzo_uintp lzo_uint __LZO_MMODEL * +#define lzo_intp lzo_int __LZO_MMODEL * +#define lzo_voidpp lzo_voidp __LZO_MMODEL * +#define lzo_bytepp lzo_bytep __LZO_MMODEL * + +typedef int lzo_bool; + +#ifndef lzo_sizeof_dict_t +# define lzo_sizeof_dict_t sizeof(lzo_bytep) +#endif + + +/*********************************************************************** +// function types +************************************************************************/ + +/* linkage */ +#if !defined(__LZO_EXTERN_C) +# ifdef __cplusplus +# define __LZO_EXTERN_C extern "C" +# else +# define __LZO_EXTERN_C extern +# endif +#endif + +/* calling conventions */ +#if !defined(__LZO_CDECL) +# if defined(__LZO_DOS16) || defined(__LZO_WIN16) +# define __LZO_CDECL __far __cdecl +# elif defined(__LZO_i386) && defined(_MSC_VER) +# define __LZO_CDECL __cdecl +# elif defined(__LZO_i386) && defined(__WATCOMC__) +# define __LZO_CDECL __near __cdecl +# else +# define __LZO_CDECL +# endif +#endif +#if !defined(__LZO_ENTRY) +# define __LZO_ENTRY __LZO_CDECL +#endif + +/* DLL export information */ +#if !defined(__LZO_EXPORT1) +# define __LZO_EXPORT1 +#endif +#if !defined(__LZO_EXPORT2) +# define __LZO_EXPORT2 +#endif + +/* calling convention for C functions */ +#if !defined(LZO_PUBLIC) +# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY +#endif +#if !defined(LZO_EXTERN) +# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) +#endif +#if !defined(LZO_PRIVATE) +# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY +#endif + +/* cdecl calling convention for assembler functions */ +#if !defined(LZO_PUBLIC_CDECL) +# define LZO_PUBLIC_CDECL(_rettype) \ + __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL +#endif +#if !defined(LZO_EXTERN_CDECL) +# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype) +#endif + + +typedef int +(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + +typedef int +(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + + +/* a progress indicator callback function */ +typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint); + + +/*********************************************************************** +// error codes and prototypes +************************************************************************/ + +/* Error codes for the compression/decompression functions. Negative + * values are errors, positive values will be used for special but + * normal events. + */ +#define LZO_E_OK 0 +#define LZO_E_ERROR (-1) +#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */ +#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */ +#define LZO_E_INPUT_OVERRUN (-4) +#define LZO_E_OUTPUT_OVERRUN (-5) +#define LZO_E_LOOKBEHIND_OVERRUN (-6) +#define LZO_E_EOF_NOT_FOUND (-7) +#define LZO_E_INPUT_NOT_CONSUMED (-8) + + +/* lzo_init() should be the first function you call. + * Check the return code ! + * + * lzo_init() is a macro to allow checking that the library and the + * compiler's view of various types are consistent. + */ +#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ + (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ + (int)sizeof(lzo_compress_t)) +LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int); + +/* version functions (useful for shared libraries) */ +LZO_EXTERN(unsigned) lzo_version(void); +LZO_EXTERN(const char *) lzo_version_string(void); +LZO_EXTERN(const char *) lzo_version_date(void); +LZO_EXTERN(const lzo_charp) _lzo_version_string(void); +LZO_EXTERN(const lzo_charp) _lzo_version_date(void); + +/* string functions */ +LZO_EXTERN(int) +lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); + +/* checksum functions */ +LZO_EXTERN(lzo_uint32) +lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len); +LZO_EXTERN(lzo_uint32) +lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len); + +/* memory allocation functions */ +LZO_EXTERN(lzo_bytep) lzo_alloc(lzo_uint _nelems, lzo_uint _size); +LZO_EXTERN(lzo_bytep) lzo_malloc(lzo_uint _size); +LZO_EXTERN(void) lzo_free(lzo_voidp _ptr); + +extern lzo_bytep (__LZO_ENTRY *lzo_alloc_hook) (lzo_uint,lzo_uint); +extern void (__LZO_ENTRY *lzo_free_hook) (lzo_voidp); + +/* misc. */ +LZO_EXTERN(lzo_bool) lzo_assert(int _expr); +LZO_EXTERN(int) _lzo_config_check(void); +typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; +typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; + +/* align a char pointer on a boundary that is a multiple of `size' */ +LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); +#define LZO_PTR_ALIGN_UP(_ptr,_size) \ + ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) + +/* deprecated - only for backward compatibility */ +#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif /* already included */ + diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 840fbc0dbf..d592fac68b 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,7 +2,11 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ - tony.o + tony.o \ + mpal\expr.o \ + mpal\loadmpc.o \ + mpal\mpal.o \ + mpal\stubs.o # This module can be built as a plugin ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) diff --git a/engines/tony/mpal.h b/engines/tony/mpal.h index f0aa5e79e2..0c15ef5b50 100644 --- a/engines/tony/mpal.h +++ b/engines/tony/mpal.h @@ -120,6 +120,10 @@ #include "common/rect.h" +namespace Tony { + +namespace MPAL { + /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ @@ -197,10 +201,10 @@ typedef struct { Common::Rect bbox[MAXFRAMES]; short pattern[MAXPATTERN][MAXFRAMES]; short speed; - char numframe; - char numpattern; - char curframe; - char curpattern; + uint8 numframe; + uint8 numpattern; + uint8 curframe; + uint8 curpattern; short destX, destY; signed char Zvalue; short objectID; @@ -568,13 +572,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; /****************************************************************************\ -* Functions exported DLL +* MPAL Interface Functions \****************************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif - /****************************************************************************\ * * Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, @@ -741,10 +741,9 @@ void EXPORT mpalSaveState(byte *buf); int EXPORT mpalGetSaveStateSize(void); +} // end of namespace MPAL -#ifdef __cplusplus -} -#endif +} // end of namespace #endif diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp new file mode 100644 index 0000000000..0faf91744c --- /dev/null +++ b/engines/tony/mpal/expr.cpp @@ -0,0 +1,471 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor...... * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Gestisce le espressioni * + * 4> ^R$oue# d matematiche............ * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#include "mpal.h" +#include "mpaldll.h" +#include "stubs.h" + +/* +#include "lzo1x.h" +*/ + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Operazioni matematiche gestite +\****************************************************************************/ + +#define OP_MUL ((1<<4)|0) +#define OP_DIV ((1<<4)|1) +#define OP_MODULE ((1<<4)|2) +#define OP_ADD ((2<<4)|0) +#define OP_SUB ((2<<4)|1) +#define OP_SHL ((3<<4)|0) +#define OP_SHR ((3<<4)|1) +#define OP_MINOR ((4<<4)|0) +#define OP_MAJOR ((4<<4)|1) +#define OP_MINEQ ((4<<4)|2) +#define OP_MAJEQ ((4<<4)|3) +#define OP_EQUAL ((5<<4)|0) +#define OP_NOEQUAL ((5<<4)|1) +#define OP_BITAND ((6<<4)|0) +#define OP_BITXOR ((7<<4)|0) +#define OP_BITOR ((8<<4)|0) +#define OP_AND ((9<<4)|0) +#define OP_OR ((10<<4)|0) + + +/****************************************************************************\ +* enum ExprListTypes +* ------------------ +* Description: Tipi di oggetto che possono essere contenuti in una struttura +* EXPRESSION. +\****************************************************************************/ + +enum ExprListTypes +{ + ELT_NUMBER=1, + ELT_VAR=2, + ELT_PARENTH=3, + ELT_PARENTH2=4 +}; + + +/****************************************************************************\ +* Structures +\****************************************************************************/ + +/****************************************************************************\ +* typedef EXPRESSION +* ------------------ +* Description: Struttura per gestire le operazioni matematiche +\****************************************************************************/ + +typedef struct { + byte type; // Tipo di oggetto (vedi enum ExprListTypes) + byte unary; // Unary operatore (NON SUPPORTATO) + + union { + int num; // Numero (se type==ELT_NUMBER) + char *name; // Nome variabile (se type==ELT_VAR) + HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) + byte *pson; // Handle lockato (type==ELT_PARENTH2) + } val; + + byte symbol; // Simbolo matematico (vedi #define OP_*) + +} EXPRESSION; +typedef EXPRESSION* LPEXPRESSION; + + +/****************************************************************************\ +* +* Function: LPEXPRESSION DuplicateExpression(HGLOBAL h); +* +* Description: Duplica un'espressione matematica. L'espressione duplicata +* sara' formata da memoria non swappabile. +* +* Input: HGLOBAL h Handle dell'espressione originale +* +* Return: Pointer all'espressione clone della prima +* +\****************************************************************************/ + +static byte *DuplicateExpression(HGLOBAL h) { + int i, num; + byte *orig, *clone; + LPEXPRESSION one, two; + + orig=(byte *)GlobalLock(h); + + num=*(byte *)orig; + one=(LPEXPRESSION)(orig+1); + + clone=GlobalAlloc(GMEM_FIXED,sizeof(EXPRESSION)*num+1); + two=(LPEXPRESSION)(clone+1); + + CopyMemory(clone,orig,sizeof(EXPRESSION)*num+1); + + for (i=0;itype==ELT_PARENTH) { + two->type=ELT_PARENTH2; + two->val.pson=DuplicateExpression(two->val.son); + } + + one++; + two++; + } + + GlobalUnlock(h); + return clone; +} + +static int Compute(int a, int b, byte symbol) { + switch (symbol) { + case OP_MUL: + return a*b; + case OP_DIV: + return a/b; + case OP_MODULE: + return a%b; + case OP_ADD: + return a+b; + case OP_SUB: + return a-b; + case OP_SHL: + return a<>b; + case OP_MINOR: + return ab; + case OP_MINEQ: + return a<=b; + case OP_MAJEQ: + return a>=b; + case OP_EQUAL: + return a==b; + case OP_NOEQUAL: + return a!=b; + case OP_BITAND: + return a&b; + case OP_BITXOR: + return a^b; + case OP_BITOR: + return a|b; + case OP_AND: + return a&&b; + case OP_OR: + return a||b; + default: + mpalError=1; + break; + } + + return 0; +} + +static void Solve(LPEXPRESSION one, int num) { + LPEXPRESSION two, three; + int j; + + while (num>1) { + two=one+1; + if ((two->symbol==0) || (one->symbol&0xF0) <= (two->symbol&0xF0)) { + two->val.num=Compute(one->val.num,two->val.num,one->symbol); + CopyMemory(one,two,(num-1)*sizeof(EXPRESSION)); + num--; + } else { + j=1; + three=two+1; + while ((three->symbol!=0) && (two->symbol&0xF0)>(three->symbol&0xF0)) { + two++; + three++; + j++; + } + + three->val.num=Compute(two->val.num,three->val.num,two->symbol); + CopyMemory(two,three,(num-j-1)*sizeof(EXPRESSION)); + num--; + } + } +} + + +/****************************************************************************\ +* +* Function: int EvaluateAndFreeExpression(byte *expr); +* +* Description: Calcola il risultato di una espressione matematica, sosti- +* tuendo ad eventuali variabili il valore corrente. +* +* Input: byte *expr Pointer all'espressione duplicata +* tramite DuplicateExpression +* +* Return: Valore dell'espressione +* +\****************************************************************************/ + +static int EvaluateAndFreeExpression(byte *expr) { + int i,num,val; + LPEXPRESSION one,cur; + + num=*expr; + one=(LPEXPRESSION)(expr+1); + + // 1) Sostituzioni delle variabili + for (i=0,cur=one;itype==ELT_VAR) { + cur->type=ELT_NUMBER; + cur->val.num=varGetValue(cur->val.name); + } + } + + // 2) Sostituzioni delle parentesi (tramite ricorsione) + for (i=0,cur=one;itype==ELT_PARENTH2) { + cur->type=ELT_NUMBER; + cur->val.num=EvaluateAndFreeExpression(cur->val.pson); + } + } + + // 3) Risoluzione algebrica + Solve(one,num); + val=one->val.num; + GlobalFree(expr); + + return val; +} + +/****************************************************************************\ +* +* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); +* +* Description: Esegue il parsing da file .MPC di un'espressione matematica. +* +* Input: byte *buf Buffer contenente l'espressione +* compilata. +* HGLOBAL *h Pointer a un handle che, alla fine +* dell'esecuzione, puntera' alla +* zona di memoria contenete l'espres- +* sione parsata +* +* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso +* di errore. +* +\****************************************************************************/ + +byte *ParseExpression(byte *lpBuf, HGLOBAL *h) { + LPEXPRESSION cur; + byte *start; + uint32 num, i; + + num=*lpBuf; + lpBuf++; + + if (num==0) + return NULL; + + *h=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,num*sizeof(EXPRESSION)+1); + if (*h==NULL) + return NULL; + + start=(byte *)GlobalLock(*h); + *start=(byte)num; + + cur=(LPEXPRESSION)(start+1); + + for (i=0;itype=*(lpBuf); + cur->unary=*(lpBuf+1); + lpBuf+=2; + switch (cur->type) { + case ELT_NUMBER: + cur->val.num=*(int *)lpBuf; + lpBuf+=4; + break; + + case ELT_VAR: + cur->val.name=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,(*lpBuf)+1); + if (cur->val.name==NULL) + return NULL; + CopyMemory(cur->val.name,lpBuf+1,*lpBuf); + lpBuf+=*lpBuf+1; + break; + + case ELT_PARENTH: + lpBuf=ParseExpression(lpBuf,&cur->val.son); + if (lpBuf==NULL) + return NULL; + break; + + default: + return NULL; + } + + cur->symbol=*lpBuf; + lpBuf++; + + cur++; + } + + if (*lpBuf!=0) + return NULL; + + lpBuf++; + + return lpBuf; +} + + +/****************************************************************************\ +* +* Function: int EvaluateExpression(HGLOBAL h); +* +* Description: Calcola il valore di un'espressione matematica +* +* Input: HGLOBAL h Handle all'espressione +* +* Return: Valore numerico +* +\****************************************************************************/ + +int EvaluateExpression(HGLOBAL h) { + int ret; + + LockVar(); + ret=EvaluateAndFreeExpression(DuplicateExpression(h)); + UnlockVar(); + + return ret; +} + + +/****************************************************************************\ +* +* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); +* +* Description: Confronta due espressioni matematiche tra loro +* +* Input: HGLOBAL h1,h2 Espressioni da confrontare +* +* Return: true se sono uguali, false se sono diverse +* +\****************************************************************************/ + +bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { + int i,num1,num2; + byte *e1, *e2; + LPEXPRESSION one, two; + + e1=(byte *)GlobalLock(h1); + e2=(byte *)GlobalLock(h2); + + num1=*(byte *)e1; + num2=*(byte *)e2; + + if (num1 != num2) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + + one=(LPEXPRESSION)(e1+1); + two=(LPEXPRESSION)(e2+1); + + for (i=0;itype!=two->type || (i!=num1-1 && one->symbol!=two->symbol)) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + + switch (one->type) { + case ELT_NUMBER: + if (one->val.num != two->val.num) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + break; + + case ELT_VAR: + if (strcmp(one->val.name, two->val.name)!=0) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + break; + + case ELT_PARENTH: + if (!CompareExpressions(one->val.son,two->val.son)) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + break; + } + + one++; + two++; + } + + GlobalUnlock(h1); + GlobalUnlock(h2); + + return true; +} + + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h new file mode 100644 index 0000000000..d54f17b088 --- /dev/null +++ b/engines/tony/mpal/expr.h @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor heade * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Gestisce le espressioni * + * 4> ^R$oue# d matematiche............ * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#ifndef MPAL_EXPR_H +#define MPAL_EXPR_H + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Prototipi di funzione +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); +* +* Description: Esegue il parsing da file .MPC di un'espressione matematica. +* +* Input: byte *buf Buffer contenente l'espressione +* compilata. +* HGLOBAL *h Pointer a un handle che, alla fine +* dell'esecuzione, puntera' alla +* zona di memoria contenete l'espres- +* sione parsata +* +* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso +* di errore. +* +\****************************************************************************/ + +byte *ParseExpression(byte *lpBuf, HGLOBAL *h); + + +/****************************************************************************\ +* +* Function: int EvaluateExpression(HGLOBAL h); +* +* Description: Calcola il valore di un'espressione matematica +* +* Input: HGLOBAL h Handle all'espressione +* +* Return: Valore numerico +* +\****************************************************************************/ + +int EvaluateExpression(HGLOBAL h); + + +/****************************************************************************\ +* +* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); +* +* Description: Confronta due espressioni matematiche tra loro +* +* Input: HGLOBAL h1,h2 Espressioni da confrontare +* +* Return: TRUE se sono uguali, FALSE se sono diverse +* +\****************************************************************************/ + +bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); + + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp new file mode 100644 index 0000000000..f9426c8d58 --- /dev/null +++ b/engines/tony/mpal/loadmpc.cpp @@ -0,0 +1,720 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: MPC Loader............. * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Legge un file compilato * + * 4> ^R$oue# d di MPAL................ * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +/* +#include "lzo1x.h" +*/ +#include "mpal.h" +#include "mpaldll.h" + +namespace Tony { + +namespace MPAL { + + +/****************************************************************************\ +* Funzioni statiche +\****************************************************************************/ + +static bool CompareCommands(struct command *cmd1, struct command *cmd2) { + if (cmd1->type == 2 && cmd2->type == 2) { + if (strcmp(cmd1->lpszVarName,cmd2->lpszVarName)==0 && + CompareExpressions(cmd1->expr,cmd2->expr)) + return true; + else + return false; + } else + return (memcmp(cmd1,cmd2,sizeof(struct command))==0); +} + + +/****************************************************************************\ +* +* Function: LPBTYE ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript); +* +* Description: Esegue il parsing da file .MPC di uno script e inserisce il +* tutto dentro una struttura +* +* Input: byte *lpBuf Buffer contenente lo script compilato +* LPMPALSCRIPT lpmsScript Puntatore a una struttura che verra' +* riempita con i dati dello script +* lato +* +* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore +* +\****************************************************************************/ + +static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { + int curCmd,j,len; + uint i; + + lpmsScript->nObj=*(int *)lpBuf; + lpBuf+=4; + + lpmsScript->nMoments=*(uint16 *)lpBuf; + lpBuf+=2; + + curCmd=0; + + for (i=0;inMoments;i++) { + lpmsScript->Moment[i].dwTime=*(int *)lpBuf; lpBuf+=4; + lpmsScript->Moment[i].nCmds=*lpBuf; lpBuf++; + + for (j=0;jMoment[i].nCmds;j++) { + lpmsScript->Command[curCmd].type=*lpBuf; lpBuf++; + switch (lpmsScript->Command[curCmd].type) { + case 1: + lpmsScript->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; + lpmsScript->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + break; + + case 2: // Variable assign + len=*lpBuf; lpBuf++; + lpmsScript->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmsScript->Command[curCmd].lpszVarName==NULL) + return NULL; + CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); + lpBuf+=len; + + lpBuf=ParseExpression(lpBuf,&lpmsScript->Command[curCmd].expr); + if (lpBuf==NULL) + return NULL; + break; + + default: + return NULL; + } + + lpmsScript->Moment[i].CmdNum[j]=curCmd; + curCmd++; + } + } + + return lpBuf; +} + + +/****************************************************************************\ +* +* Function: byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog); +* +* Description: Esegue il parsing da file .MPC di un dialog, e inserisce il +* tutto dentro una struttura +* +* Input: byte *lpBuf Buffer contenente il dialogo compi- +* lato +* LPMPALDIALOG lpmdDialog Puntatore a una struttura che verra' +* riempita con i dati del dialogo +* compilato +* +* Return: Puntatore al buffer dopo il dialogo, o NULL in caso di errore +* +\****************************************************************************/ + +static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { + uint32 i,j,z,kk; + uint32 num,num2,num3; + byte *lpLock; + uint32 curCmd; + uint32 len; + + lpmdDialog->nObj=*(int *)lpBuf; + lpBuf+=4; + + /* Periodi */ + num=*(uint16 *)lpBuf; lpBuf+=2; + + if (num >= MAX_PERIODS_PER_DIALOG-1) { + Common::String msg = Common::String::format("Too much periods in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + for (i=0;iPeriodNums[i]=*(uint16 *)lpBuf; lpBuf+=2; + lpmdDialog->Periods[i]=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,*lpBuf+1); + lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); + CopyMemory(lpLock,lpBuf+1,*lpBuf); + GlobalUnlock(lpmdDialog->Periods[i]); + lpBuf+=(*lpBuf)+1; + } + + lpmdDialog->PeriodNums[i]=0; + lpmdDialog->Periods[i]=NULL; + + /* Gruppi */ + num=*(uint16 *)lpBuf; lpBuf+=2; + curCmd=0; + + if (num >= MAX_GROUPS_PER_DIALOG) { + Common::String msg = Common::String::format("Too much groups in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + for (i=0;iGroup[i].num=*(uint16 *)lpBuf; lpBuf+=2; + lpmdDialog->Group[i].nCmds=*lpBuf; lpBuf++; + + if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) { + Common::String msg = Common::String::format("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); + MessageBox(msg); + } + + for (j=0;jGroup[i].nCmds;j++) { + lpmdDialog->Command[curCmd].type=*lpBuf; + lpBuf++; + + switch (lpmdDialog->Command[curCmd].type) { + // Call custom function + case 1: + lpmdDialog->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; + lpmdDialog->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + break; + + // Variable assign + case 2: + len=*lpBuf; + lpBuf++; + lpmdDialog->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmdDialog->Command[curCmd].lpszVarName==NULL) + return NULL; + CopyMemory(lpmdDialog->Command[curCmd].lpszVarName,lpBuf,len); + lpBuf+=len; + + lpBuf=ParseExpression(lpBuf,&lpmdDialog->Command[curCmd].expr); + if (lpBuf==NULL) + return NULL; + break; + + // Do Choice + case 3: + lpmdDialog->Command[curCmd].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + break; + + default: + return NULL; + } + + for (kk=0;kkCommand[kk],&lpmdDialog->Command[curCmd])) { + lpmdDialog->Group[i].CmdNum[j]=kk; + break; + } + } + + if (kk==curCmd) { + lpmdDialog->Group[i].CmdNum[j]=curCmd; + curCmd++; + } + } + } + + if (curCmd >= MAX_COMMANDS_PER_DIALOG) { + Common::String msg = Common::String::format("Too much commands in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + /* Choices */ + num=*(uint16 *)lpBuf; lpBuf+=2; + + if (num >= MAX_CHOICES_PER_DIALOG) { + Common::String msg = Common::String::format("Too much choices in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + for (i=0;iChoice[i].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + + num2=*lpBuf++; + + if (num2 >= MAX_SELECTS_PER_CHOICE) { + Common::String msg = Common::String::format("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + MessageBox(msg); + } + + for (j=0;jChoice[i].Select[j].when=NULL; + break; + + case 1: + lpBuf=ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); + if (lpBuf==NULL) + return NULL; + break; + + case 2: + return NULL; + } + + // Attrib + lpmdDialog->Choice[i].Select[j].attr=*lpBuf++; + + // Data + lpmdDialog->Choice[i].Select[j].dwData=*(uint32 *)lpBuf; lpBuf+=4; + + // PlayGroup + num3=*lpBuf; *lpBuf++; + + if (num3 >= MAX_PLAYGROUPS_PER_SELECT) { + Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d",j,lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + MessageBox(msg); + } + + for (z=0;zChoice[i].Select[j].wPlayGroup[z]=*(uint16 *)lpBuf; lpBuf+=2; + } + + lpmdDialog->Choice[i].Select[j].wPlayGroup[num3]=0; + } + + // Segna l'ultimo select + lpmdDialog->Choice[i].Select[num2].dwData=0; + } + + lpmdDialog->Choice[num].nChoice=0; + + return lpBuf; +} + +/****************************************************************************\ +* +* Function: byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem); +* +* Description: Esegue il parsing da file .MPC di un item, e inserisce il +* tutto dentro una struttura +* +* Input: byte *lpBuf Buffer contenete l'item compilato +* LPMPALITEM lpmiItem Puntatore a una struttura che verra' +* riempita con i dati dell'item +* compilato +* +* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore +* +* Note: E' necessario che la struttura passata come parametro sia +* stata completamente inizializzata a 0 (con una ZeroMemory, +* ad esempio). +* +\****************************************************************************/ + +static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { + byte len; + uint32 i,j,kk; + uint32 curCmd; + + lpmiItem->nObj=*(int *)lpBuf; + lpBuf+=4; + + len=*lpBuf; + lpBuf++; + CopyMemory(lpmiItem->lpszDescribe,lpBuf, MIN((byte)127, len)); + lpBuf+=len; + + if (len >= MAX_DESCRIBE_SIZE) { + Common::String msg = Common::String::format("Describe too long in item #%d",lpmiItem->nObj); + MessageBox(msg); + } + + lpmiItem->nActions=*lpBuf; + lpBuf++; + + /* Alloca le azioni */ + if (lpmiItem->nActions>0) + lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(struct ItemAction)*(int)lpmiItem->nActions); + + curCmd=0; + + for (i=0;inActions;i++) { + lpmiItem->Action[i].num=*lpBuf; + lpBuf++; + + lpmiItem->Action[i].wParm=*(uint16 *)lpBuf; + lpBuf+=2; + + if (lpmiItem->Action[i].num==0xFF) { + lpmiItem->Action[i].wTime=*(uint16 *)lpBuf; + lpBuf+=2; + + lpmiItem->Action[i].perc=*lpBuf; + lpBuf++; + } + + + if (*lpBuf==0) { + lpBuf++; + lpmiItem->Action[i].when=NULL; + } else { + lpBuf++; + lpBuf=ParseExpression(lpBuf,&lpmiItem->Action[i].when); + if (lpBuf==NULL) + return NULL; + } + + lpmiItem->Action[i].nCmds=*lpBuf; + lpBuf++; + + if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) { + Common::String msg = Common::String::format("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); + MessageBox(msg); + } + + for (j=0;jAction[i].nCmds;j++) { + lpmiItem->Command[curCmd].type=*lpBuf; + lpBuf++; + switch (lpmiItem->Command[curCmd].type) { + case 1: // Call custom function + lpmiItem->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; + lpmiItem->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + break; + + case 2: // Variable assign + len=*lpBuf; + lpBuf++; + lpmiItem->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmiItem->Command[curCmd].lpszVarName==NULL) + return NULL; + CopyMemory(lpmiItem->Command[curCmd].lpszVarName,lpBuf,len); + lpBuf+=len; + + lpBuf=ParseExpression(lpBuf,&lpmiItem->Command[curCmd].expr); + if (lpBuf==NULL) + return NULL; + break; + + default: + return NULL; + } + + for (kk=0;kkCommand[kk],&lpmiItem->Command[curCmd])) { + lpmiItem->Action[i].CmdNum[j]=kk; + break; + } + } + + if (kk==curCmd) { + lpmiItem->Action[i].CmdNum[j]=curCmd; + curCmd++; + + if (curCmd >= MAX_COMMANDS_PER_ITEM) { + Common::String msg = Common::String::format("Too much commands in item #%d",lpmiItem->nObj); + MessageBox(msg); + curCmd=0; + } + } + } + } + + lpmiItem->dwRes=*(uint32 *)lpBuf; lpBuf+=4; + + return lpBuf; +} + + +/****************************************************************************\ +* +* Function: byte *ParseLocation(byte *buf, LPMPALLOCATIONN lpmlLocation) +* +* Description: Esegue il parsing da file .MPC di una locazione, riempendo +* una struttura +* +* Input: byte *buf Buffer contenente la locazione +* compilata +* LPMPALLOCATION +* lpmlLocation Pointer alla struttura che verra' +* riempita con i dati sulla locazione +* +* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore +* +\****************************************************************************/ + +static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { + lpmlLocation->nObj=*(int *)lpBuf; + lpBuf+=4; + lpmlLocation->dwXlen=*(uint16 *)lpBuf; + lpBuf+=2; + lpmlLocation->dwYlen=*(uint16 *)lpBuf; + lpBuf+=2; + lpmlLocation->dwPicRes=*(uint32 *)lpBuf; + lpBuf+=4; + + return lpBuf; +} + +/*static int CompareMoments(int * a, int * b) { + if (*a<*b) + return -1; + else if (*a>*b) + return 1; + else + return 0; +}*/ + +/****************************************************************************\ +* Funzioni globali +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: bool ParseMpc(byte *lpBuf); +* +* Description: Legge e interpreta un file MPC, e crea le strutture per le +* varie direttive nelle variabili globali +* +* Input: byte *lpBuf Immagine in memoria del file MPC, +* escluso l'header +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool ParseMpc(byte *lpBuf) { + uint16 i,j; + uint16 wLen; + byte *lpTemp, *lpTemp2; + + // Oggetti dummy. Definiti static per evitare stack overflow + static MPALITEM dummyitem; + static MPALLOCATION dummylocation; + static MPALSCRIPT dummyscript; + static MPALDIALOG dummydialog; + + /* 1. Variabili */ + if (lpBuf[0]!='V' || lpBuf[1]!='A' || lpBuf[2]!='R' || lpBuf[3]!='S') + return false; + + lpBuf+=4; + nVars=*(uint16 *)lpBuf; + lpBuf+=2; + + hVars=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALVAR)*(uint32)nVars); + if (hVars==NULL) + return false; + + lpmvVars=(LPMPALVAR)GlobalLock(hVars); + + for (i=0;ilpszVarName,lpBuf,MIN(wLen, (uint16)32)); + lpBuf+=wLen; + lpmvVars->dwVal=*(int *)lpBuf; + lpBuf+=4; + + lpBuf++; // Salta 'ext' + lpmvVars++; + } + + GlobalUnlock(hVars); + + /* 2. Messaggi */ + if (lpBuf[0]!='M' || lpBuf[1]!='S' || lpBuf[2]!='G' || lpBuf[3]!='S') + return false; + + lpBuf+=4; + nMsgs=*(uint16 *)lpBuf; + lpBuf+=2; + +#ifdef NEED_LOCK_MSGS + hMsgs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); + if (hMsgs==NULL) + return false; + + lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); +#else + lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); + if (lpmmMsgs==NULL) + return false; +#endif + + for (i=0;iwNum=*(uint16 *)lpBuf; + lpBuf+=2; + + for (j=0;lpBuf[j]!=0;) + j+=lpBuf[j]+1; + + lpmmMsgs->hText=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,j+1); + lpTemp2=lpTemp=(byte *)GlobalLock(lpmmMsgs->hText); + + for (j=0;lpBuf[j]!=0;) { + CopyMemory(lpTemp,&lpBuf[j+1],lpBuf[j]); + lpTemp+=lpBuf[j]; + *lpTemp++='\0'; + j+=lpBuf[j]+1; + } + + lpBuf+=j+1; + *lpTemp='\0'; + + GlobalUnlock(lpmmMsgs->hText); + lpmmMsgs++; + } + +#ifdef NEED_LOCK_MSGS + GlobalUnlock(hMsgs); +#endif + + /* 3. Oggetti */ + if (lpBuf[0]!='O' || lpBuf[1]!='B' || lpBuf[2]!='J' || lpBuf[3]!='S') + return false; + + lpBuf+=4; + nObjs=*(uint16 *)lpBuf; + lpBuf+=2; + + // Controlla i dialoghi + nDialogs=0; + hDialogs=lpmdDialogs=NULL; + if (*((const char *)lpBuf+2)==6 && strncmp((const char *)lpBuf+3,"Dialog",6)==0) { + nDialogs=*(uint16 *)lpBuf; lpBuf+=2; + + hDialogs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,(uint32)nDialogs*sizeof(MPALDIALOG)); + if (hDialogs==NULL) + return false; + + lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); + + for (i=0;i '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Legge un file compilato * + * 4> ^R$oue# d MPC.................... * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#ifndef __LOADMPC_H +#define __LOADMPC_H + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Prototipi di funzione +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: BOOL ParseMpc(LPBYTE lpBuf); +* +* Description: Legge e interpreta un file MPC, e crea le strutture per le +* varie direttive nelle variabili globali +* +* Input: LPBYTE lpBuf Immagine in memoria del file MPC, +* escluso l'header +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + +bool ParseMpc(const byte *lpBuf); + + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif + diff --git a/engines/tony/mpal/lzo1x.h b/engines/tony/mpal/lzo1x.h new file mode 100644 index 0000000000..83b547428c --- /dev/null +++ b/engines/tony/mpal/lzo1x.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. + * + * + */ +/* lzo1x.h -- public interface of the LZO1X compression algorithm + + This file is part of the LZO real-time data compression library. + + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html + */ + + +#ifndef __LZO1X_H +#define __LZO1X_H + +#ifndef __LZOCONF_H +#include "lzoconf.h" +#endif + +namespace Tony { + +namespace MPAL { + +/*********************************************************************** +// +************************************************************************/ + +/* Memory required for the wrkmem parameter. + * When the required size is 0, you can also pass a NULL pointer. + */ + +#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS +#define LZO1X_MEM_DECOMPRESS (0) +#define LZO1X_MEM_OPTIMIZE (0) + + +/* decompression */ +LZO_EXTERN(int) +lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + +/* safe decompression with overrun testing */ +LZO_EXTERN(int) +lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + + +/*********************************************************************** +// +************************************************************************/ + +#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// special compressor versions +************************************************************************/ + +/* this version needs only 8 kB work memory */ +#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* this version needs 16 kB work memory */ +#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* use this version if you need a little more compression speed */ +#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// better compression ratio at the cost of more memory and time +************************************************************************/ + +#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); +#endif + + +/*********************************************************************** +// +************************************************************************/ + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + +LZO_EXTERN(int) +lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len, + lzo_progress_callback_t cb, + int compression_level ); +#endif + +LZO_EXTERN(int) +lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem /* NOT USED */, + const lzo_byte *dict, lzo_uint dict_len ); + + +/*********************************************************************** +// optimize a compressed data block +************************************************************************/ + +LZO_EXTERN(int) +lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem ); + + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif /* already included */ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp new file mode 100644 index 0000000000..2fd9f3b9c3 --- /dev/null +++ b/engines/tony/mpal/mpal.cpp @@ -0,0 +1,3071 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: Mpal Query Library..... * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Libreria principale di * + * 4> ^R$oue# d MPAL, contenente il * + * '$ "" @ codice per le query.... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#include "common/scummsys.h" +#include "common/file.h" +#include "common/savefile.h" +#include "common/system.h" +#include "mpal.h" +#include "mpaldll.h" +#include "stubs.h" +#include "tony/tony.h" +#include "tony/lzo/lzo1x.h" + +namespace Tony { + +namespace MPAL { + +using namespace Tony::LZO; + +/****************************************************************************\ +* Copyright +\****************************************************************************/ + +const char *mpalCopyright = + "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n" + "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n" + "ALL RIGHTS RESERVED\n" + "\n" + "\n"; + +/****************************************************************************\ +* Structures +\****************************************************************************/ + +/****************************************************************************\ +* typedef CFCALL +* -------------- +* Description: Descrizione di una chiamata a una custom function +\****************************************************************************/ + +typedef struct { + int nCf; + + int arg1, arg2, arg3, arg4; +} CFCALL; +typedef CFCALL* LPCFCALL; +typedef LPCFCALL* LPLPCFCALL; + + +/****************************************************************************\ +* Global variables +\****************************************************************************/ + +uint32 mpalError; + +static bool bInit=false; +static byte * lpMpcImage; + +LPITEMIRQFUNCTION lpiifCustom=NULL; + +LPLPCUSTOMFUNCTION lplpFunctions=NULL; +uint16 nObjs; + +uint16 nVars; +HGLOBAL hVars; +LPMPALVAR lpmvVars; + +uint16 nMsgs; +HGLOBAL hMsgs; +LPMPALMSG lpmmMsgs; + +uint16 nDialogs; +HGLOBAL hDialogs; +LPMPALDIALOG lpmdDialogs; + +uint16 nItems; +HGLOBAL hItems; +LPMPALITEM lpmiItems; + +uint16 nLocations; +HGLOBAL hLocations; +LPMPALLOCATION lpmlLocations; + +uint16 nScripts; +HGLOBAL hScripts; +LPMPALSCRIPT lpmsScripts; + +Common::File hMpr; +uint16 nResources; +uint32 * lpResources; + +bool bExecutingAction; +bool bExecutingDialog; + +uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; +HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; +HANDLE PollingThreads[MAXPOLLINGLOCATIONS]; + +HANDLE hAskChoice; +HANDLE hDoneChoice; + +uint32 nExecutingAction; + +uint32 nExecutingDialog; +uint32 nExecutingChoice; +uint32 nSelectedChoice; + + +/****************************************************************************\ +* Static functions +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: void LockVar(void); +* +* Description: Locka le variabili per accederci +* +\****************************************************************************/ + +void LockVar(void) { + lpmvVars=(LPMPALVAR)GlobalLock(hVars); +} + +/****************************************************************************\ +* +* Function: void UnlockVar(void); +* +* Description: Unlocka le variabili dopo l'uso +* +\****************************************************************************/ + +void UnlockVar(void) { + GlobalUnlock(hVars); +} + + +/****************************************************************************\ +* +* Function: void LockMsg(void); +* +* Description: Locka i messaggi per accederci +* +\****************************************************************************/ + +static void LockMsg(void) { +#ifdef NEED_LOCK_MSGS + lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); +#endif +} + + +/****************************************************************************\ +* +* Function: void UnlockMsg(void); +* +* Description: Unlocka i messaggi dopo l'uso +* +\****************************************************************************/ + +static void UnlockMsg(void) { +#ifdef NEED_LOCK_MSGS + GlobalUnlock(hMsgs); +#endif +} + + +/****************************************************************************\ +* +* Function: void LockDialogs(void); +* +* Description: Locka i dialoghi per accederci +* +\****************************************************************************/ + +static void LockDialogs(void) { + lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); +} + + +/****************************************************************************\ +* +* Function: void UnlockDialogs(void); +* +* Description: Unlocka i dialoghi dopo l'uso +* +\****************************************************************************/ + +static void UnlockDialogs(void) { + GlobalUnlock(hDialogs); +} + + +/****************************************************************************\ +* +* Function: void LockLocations(void); +* +* Description: Locka le strutture di dati sulle locazioni +* +\****************************************************************************/ + +static void LockLocations(void) { + lpmlLocations=(LPMPALLOCATION)GlobalLock(hLocations); +} + + +/****************************************************************************\ +* +* Function: void UnlockLocations(void); +* +* Description: Unlocka le strutture di dati sulle locazioni +* +\****************************************************************************/ + +static void UnlockLocations(void) { + GlobalUnlock(hLocations); +} + + +/****************************************************************************\ +* +* Function: void LockItems(void); +* +* Description: Locka le strutture di dati sugli item +* +\****************************************************************************/ + +static void LockItems(void) { + lpmiItems=(LPMPALITEM)GlobalLock(hItems); +} + + +/****************************************************************************\ +* +* Function: void UnlockItems(void); +* +* Description: Unlocka le strutture di dati sugli item +* +\****************************************************************************/ + +static void UnlockItems(void) { + GlobalUnlock(hItems); +} + +/****************************************************************************\ +* +* Function: void LockScripts(void); +* +* Description: Locka le strutture di dati sugli script +* +\****************************************************************************/ + +static void LockScripts(void) { + lpmsScripts=(LPMPALSCRIPT)GlobalLock(hScripts); +} + + +/****************************************************************************\ +* +* Function: void UnlockScripts(void); +* +* Description: Unlocka le strutture di dati sugli script +* +\****************************************************************************/ + +static void UnlockScripts(void) { + GlobalUnlock(hScripts); +} + + + + + +/****************************************************************************\ +* +* Function: int varGetValue(char * lpszVarName); +* +* Description: Restituisce il valore corrente di una variabile globale +* +* Input: char * lpszVarName Nome della variabile +* +* Return: Valore corrente +* +* Note: Prima di questa funzione, bisogna richiamare LockVar() che +* locka le variabili globali per l'utilizzo. Dopo inoltre bi- +* sogna ricordarsi di chiamare UnlockVar() +* +\****************************************************************************/ + +int32 varGetValue(const char *lpszVarName) { + int i; + LPMPALVAR v=lpmvVars; + + for (i=0;ilpszVarName)==0) + return v->dwVal; + + mpalError=1; + return 0; +} + + +/****************************************************************************\ +* +* Function: void varSetValue(char * lpszVarName, int val); +* +* Description: Setta un nuovo valore per una variabile globale di MPAL +* +* Input: char * lpszVarName Nome della variabile +* int val Valore da settare +* +\****************************************************************************/ + +void varSetValue(const char *lpszVarName, int32 val) { + int i; + LPMPALVAR v=lpmvVars; + + for (i=0;ilpszVarName)==0) { + v->dwVal=val; + if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8)==0) { + i=0; + sscanf(v->lpszVarName,"Pattern.%u",&i); + lpiifCustom(i,val,-1); + } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Status.",7)==0) { + i=0; + sscanf(v->lpszVarName,"Status.%u",&i); + lpiifCustom(i,-1,val); + } + return; + } + + mpalError=1; + return; +} + + +/****************************************************************************\ +* +* Function: int locGetOrderFromNum(uint32 nLoc); +* +* Description: Trova l'indice della locazione #nLoc all'interno dell'array +* delle strutture delle locazioni +* +* Input: uint32 nLoc Numero della locazione da cercare +* +* Return: Indice, o -1 se la locazione non e' presente +* +* Note: Per funzionare, la funzione necessita che le locazioni siano +* state lockate con LockLoc() +* +\****************************************************************************/ + +static int locGetOrderFromNum(uint32 nLoc) { + int i; + LPMPALLOCATION loc=lpmlLocations; + + for (i=0;inObj==nLoc) + return i; + + return -1; +} + +/****************************************************************************\ +* +* Function: int msgGetOrderFromNum(uint32 nMsg); +* +* Description: Trova l'indice del messaggio #nMsg all'interno dell'array +* delle strutture dei messaggi +* +* Input: uint32 nMsg Numero del messaggio da cercare +* +* Return: Indice, o -1 se il messaggio non e' presente +* +* Note: Per funzionare, la funzione necessita che i messaggi siano +* stati lockati con LockMsg() +* +\****************************************************************************/ + +static int msgGetOrderFromNum(uint32 nMsg) { + int i; + LPMPALMSG msg=lpmmMsgs; + + for (i=0;iwNum==nMsg) + return i; + + return -1; +} + + +/****************************************************************************\ +* +* Function: int itemGetOrderFromNum(uint32 nItem); +* +* Description: Trova l'indice dell'item #nItem all'interno dell'array delle +* strutture degli item +* +* Input: uint32 nItem Numero dell'item da cercare +* +* Return: Indice, o -1 se l'item non e' presente +* +* Note: Per funzionare, questa funzione necessita che gli item siano +* stati lockati tramite LockItem() +* +\****************************************************************************/ + +static int itemGetOrderFromNum(uint32 nItem) { + int i; + LPMPALITEM item=lpmiItems; + + for (i=0;inObj==nItem) + return i; + + return -1; +} + + +/****************************************************************************\ +* +* Function: int scriptGetOrderFromNum(uint32 nScript); +* +* Description: Trova l'indice dello script #nScript all'interno dell'array +* delle strutture degli script +* +* Input: uint32 nScript Numero dello script da cercare +* +* Return: Indice, o -1 se lo script non e' presente +* +* Note: Per funzionare, questa funzione necessita che gli script siano +* stati lockati tramite LockScript() +* +\****************************************************************************/ + +static int scriptGetOrderFromNum(uint32 nScript) { + int i; + LPMPALSCRIPT script=lpmsScripts; + + for (i=0;inObj==nScript) + return i; + + return -1; +} + + +/****************************************************************************\ +* +* Function: int dialogGetOrderFromNum(uint32 nDialog); +* +* Description: Trova l'indice del dialog #nDialog all'interno dell'array +* delle strutture dei dialog +* +* Input: uint32 nDialog Numero del dialog da cercare +* +* Return: Indice, o -1 se il dialog non e' presente +* +* Note: Per funzionare, questa funzione necessita che i dialog siano +* stati lockati tramite LockDialogs() +* +\****************************************************************************/ + +static int dialogGetOrderFromNum(uint32 nDialog) { + int i; + LPMPALDIALOG dialog=lpmdDialogs; + + for (i=0;inObj==nDialog) + return i; + + return -1; +} + + + +/****************************************************************************\ +* +* Function: char * DuplicateMessage(uint32 nMsgOrd); +* +* Description: Duplica un messaggio +* +* Input: uint32 nMsgOrd Indice del messaggio dentro l'array +* di strutture dei messaggi +* +* Return: Pointer al messaggio duplicato (che puo' essere liberato +* con GlobalFree()). +* +\****************************************************************************/ + +static char *DuplicateMessage(uint32 nMsgOrd) { + const char *origmsg; + char *clonemsg; + int j; + + if (nMsgOrd == (uint32)-1) + return NULL; + + origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); + + j=0; + while (origmsg[j]!='\0' || origmsg[j+1]!='\0') + j++; + j+=2; + + clonemsg=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,j); + if (clonemsg==NULL) + return NULL; + + CopyMemory(clonemsg, origmsg, j); + GlobalUnlock(lpmmMsgs[nMsgOrd].hText); + + return clonemsg; +} + + +/****************************************************************************\ +* +* Function: char * DuplicateDialogPeriod(uint32 nDlgOrd, uint32 nPeriod); +* +* Description: Duplica una frase di un dialog +* +* Input: uint32 nDlgOrd Indice del dialogo dentro l'array di +* strutture dei dialoghi +* +* uint32 nPeriod Numero della frase da duplicare +* +* Return: Pointer alla frase duplicata (che puo' essere liberata con +* GlobalFree()). +* +\****************************************************************************/ + +static char *DuplicateDialogPeriod(uint32 nPeriod) { + const char *origmsg; + char *clonemsg; + LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + int i,j; + + for (j=0;dialog->Periods[j]!=NULL;j++) + if (dialog->PeriodNums[j]==nPeriod) { + /* Trovata la frase, va duplicata */ + origmsg = (const char *)GlobalLock(dialog->Periods[j]); + + /* Calcola la lunghezza e alloca la memoria */ + i=0; + while (origmsg[i]!='\0') i++; + + clonemsg = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,i+1); + if (clonemsg==NULL) + return NULL; + + CopyMemory(clonemsg, origmsg, i); + + GlobalUnlock(dialog->Periods[j]); + + return clonemsg; + } + + return NULL; +} + + + +/****************************************************************************\ +* +* Function: HGLOBAL resLoad(uint32 dwId); +* +* Description: Carica una risorsa dal file MPR +* +* Input: uint32 dwId ID della risorsa da caricare +* +* Return: Handle alla memoria in cui si trova la risorsa +* +\****************************************************************************/ + +HGLOBAL resLoad(uint32 dwId) { + int i; + HGLOBAL h; + char head[4]; + uint32 nBytesRead; + uint32 nSizeComp, nSizeDecomp; + byte *temp, *buf; + + for (i=0;iChoice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].curActive) + num++; + + /* Se sono 0, e' un errore */ + if (num==0) + return NULL; + + sl= (uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); + if (sl==NULL) + return NULL; + + /* Copia il dato di ogni select attivo dentro la lista */ + k=0; + for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].curActive) + sl[k++]=dialog->Choice[i].Select[j].dwData; + + sl[k] = (uint32)NULL; + return sl; +} + +static uint32 *GetItemList(uint32 nLoc) { + uint32 *il; + uint32 num,i,j; + LPMPALVAR v=lpmvVars; + + num=0; + for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) + num++; + } + + il=(uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); + if (il==NULL) + return NULL; + + v=lpmvVars; + j=0; + for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) { + sscanf(v->lpszVarName,"Location.%u",&il[j]); + j++; + } + } + + il[j] = (uint32)NULL; + return il; +} + +static LPITEM GetItemData(uint32 nOrdItem) { + LPMPALITEM curitem=lpmiItems+nOrdItem; + LPITEM ret; + HGLOBAL hDat; + char *dat; + int i,j; + char *patlength; + uint32 dim; + + // Lo zeroinit e' obbligatorio!!!! + ret = (LPITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(ITEM)); + if (ret==NULL) + return NULL; + ret->speed=150; + + hDat = resLoad(curitem->dwRes); + dat = (char *)GlobalLock(hDat); + + if (dat[0]=='D' && dat[1]=='A' && dat[2]=='T') { + i=dat[3]; // Versione!! Per ora 1.0 + dat+=4; + + if (i>=0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto + ret->destX=*(uint16 *)dat; + ret->destY=*(uint16 *)(dat+2); + dat+=4; + } + + if (i>=0x11) {// Dalla 1.1 c'e' la velocita' di animazione + ret->speed=*(uint16 *)dat; + dat+=2; + } else + ret->speed=150; + } + + ret->numframe=*dat++; + ret->numpattern=*dat++; + ret->Zvalue=*dat++; + + // Carica le coordinate left&top di ogni frame + for (i=0;inumframe;i++) { + ret->frameslocations[i].left=*(short*)(dat); + ret->frameslocations[i].top=*(short*)(dat+2); + dat+=4; + } + + // Carica le dimensioni di ogni frame e calcola right&bottom + for (i=0;inumframe;i++) { + ret->frameslocations[i].right=*(uint16 *)(dat)+ret->frameslocations[i].left; + ret->frameslocations[i].bottom=*(uint16 *)(dat+2)+ret->frameslocations[i].top; + dat+=4; + } + + // Carica i bounding box di ogni frame + for (i=0;inumframe;i++) { + ret->bbox[i].left=*(uint16 *)(dat); + ret->bbox[i].top=*(uint16 *)(dat+2); + ret->bbox[i].right=*(uint16 *)(dat+4); + ret->bbox[i].bottom=*(uint16 *)(dat+6); + dat+=8; + } + + // Carica i pattern di animazione + patlength = dat; + dat+=ret->numpattern; + + for (i=1;inumpattern;i++) { + for (j=0;jpattern[i][j]=dat[j]; + ret->pattern[i][patlength[i]]=255; // Termina i pattern + dat+=patlength[i]; + } + + // Carica i singoli frame di animazione + for (i=1;inumframe;i++) { + dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left)* + (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); + ret->frames[i]=(char *)GlobalAlloc(GMEM_FIXED,dim); + + if (ret->frames[i]==NULL) + return NULL; + CopyMemory(ret->frames[i], dat, dim); + dat+=dim; + } + + // Controlla se siamo arrivati fino alla fine del file + i=*(uint16 *)dat; + if (i!=0xABCD) + return NULL; + + GlobalUnlock(hDat); + GlobalFree(hDat); + + return ret; +} + + +/****************************************************************************\ +* +* Function: void PASCAL CustomThread(LPCFCALL p); +* +* Description: Thread che richiama una funzione custom. Viene usato negli +* script, in modo che ciascuna funzione venga eseguita senza +* ritardare le altre +* +* Input: LPCFCALL p Struttura che definisce la chiamata +* +* Note: La struttura passata come parametro viene freeata con +* GlobalFree() alla fine dell'esecuzione. +* +\****************************************************************************/ + +void PASCAL CustomThread(LPCFCALL p) { + lplpFunctions[p->nCf](p->arg1,p->arg2,p->arg3,p->arg4); + GlobalFree(p); + ExitThread(1); +// _endthread(); +} + + +/****************************************************************************\ +* +* Function: void PASCAL ScriptThread(LPMPALSCRIPT s); +* +* Description: Esegue uno script. Questa funzione e' pensata come starting +* point per un thread +* +* Input: LPMPALSCRIPT s Script da eseguire +* +* Note: Lo script passato come parametro viene, alla fine dell'ese- +* cuzione, freeato con una GlobalFree() +* +\****************************************************************************/ + +void PASCAL ScriptThread(LPMPALSCRIPT s) { + uint i,j,k; + uint32 dwStartTime = timeGetTime(); + uint32 dwCurTime; + uint32 dwId; + static HANDLE cfHandles[MAX_COMMANDS_PER_MOMENT]; + int numHandles; + LPCFCALL p; + +// warning("PlayScript(): Moments: %u\n",s->nMoments); + for (i=0;inMoments;i++) { + // Dorme il tempo necessario per arrivare al momento successivo + if (s->Moment[i].dwTime==-1) { + WaitForMultipleObjects(numHandles,cfHandles,true,INFINITE); + dwStartTime=timeGetTime(); + } else { + dwCurTime=timeGetTime(); + if (dwCurTime < dwStartTime+(s->Moment[i].dwTime*100)) { + // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); + Sleep(dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); + } + } + + numHandles=0; + for (j=0;jMoment[i].nCmds;j++) { + k=s->Moment[i].CmdNum[j]; + + switch (s->Command[k].type) { + case 1: + p=(LPCFCALL)GlobalAlloc(GMEM_FIXED,sizeof(CFCALL)); + if (p==NULL) { + mpalError=1; + ExitThread(0); +// _endthread(); + } + + p->nCf=s->Command[k].nCf; + p->arg1=s->Command[k].arg1; + p->arg2=s->Command[k].arg2; + p->arg3=s->Command[k].arg3; + p->arg4=s->Command[k].arg4; + + // !!! Nuova gestione dei thread + if ((cfHandles[numHandles++]=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)CustomThread,(void *)p,0,&dwId))==NULL) { + //if ((cfHandles[numHandles++]=(void*)_beginthread(CustomThread, 10240, (void *)p))==(void*)-1) + mpalError=1; + ExitThread(0); +// _endthread(); + } + break; + + case 2: + LockVar(); + varSetValue( + s->Command[k].lpszVarName, + EvaluateExpression(s->Command[k].expr) + ); + UnlockVar(); + break; + + default: + mpalError=1; + GlobalFree(s); + ExitThread(0); +// _endthread(); + } + } + } + + GlobalFree(s); + ExitThread(1); + //_endthread(); +} + + +/****************************************************************************\ +* +* Function: void PASCAL ActionThread(LPMPALITEM item); +* +* Description: Thread che esegue una azione su un item. Il thread +* esegue sempre l'azione 0, per cui e' necessario creare +* un item nuovo in cui l'azione 0 sia quella richiesta. +* Inoltre non viene controllata l'espressione when, ma viene +* sempre eseguita l'azione. +* +* Input: LPMPALITEM item Item che contiene l'azione +* +\****************************************************************************/ + +void PASCAL ActionThread(LPMPALITEM item) { + int j,k; + + for (j=0;jAction[item->dwRes].nCmds;j++) { + k=item->Action[item->dwRes].CmdNum[j]; + + switch (item->Command[k].type) { + case 1: + // Funzione custom + lplpFunctions[item->Command[k].nCf]( + item->Command[k].arg1, + item->Command[k].arg2, + item->Command[k].arg3, + item->Command[k].arg4 + ); + break; + + case 2: + // Variable assign + LockVar(); + varSetValue(item->Command[k].lpszVarName,EvaluateExpression(item->Command[k].expr)); + UnlockVar(); + break; + + default: + mpalError=1; + ExitThread(0); +// _endthread(); + } + } + + GlobalFree(item); + //bExecutingAction=false; + + ExitThread(1); +// _endthread(); +} + +void PASCAL ShutUpActionThread(HANDLE hThread) { + WaitForSingleObject(hThread,INFINITE); + bExecutingAction=false; + + ExitThread(1); +// _endthread(); +} + +/****************************************************************************\ +* +* Function: void PASCAL LocationPollThread(uint32 id); +* +* Description: Esegue il polling di una locazione (starting point di un +* thread). +* +* Input: uint32 id Indice per gli array relativi ai +* polling degli item delle locazioni +* +\****************************************************************************/ + +void PASCAL LocationPollThread(uint32 id) { + uint32 *il; + int i,j,k; + int numitems; + int nRealItems; + LPMPALITEM curItem,newItem; + int nIdleActions; + uint32 curTime; + uint32 dwSleepTime; + uint32 dwId; + + typedef struct { + uint32 nItem, nAction; + + uint16 wTime; + byte perc; + HGLOBAL when; + byte nCmds; + uint16 CmdNum[MAX_COMMANDS_PER_ACTION]; + + uint32 dwLastTime; + } MYACTION; + + typedef struct { + uint32 nItem; + HANDLE hThread; + } MYTHREAD; + + MYACTION *MyActions; + MYTHREAD *MyThreads; + + /* Tanto per cominciare, e' necessario richiedere la lista degli item + presenti nella locazione. */ + il = mpalQueryItemList(nPollingLocations[id]); + + /* Contiamo gli items */ + for (numitems=0;il[numitems]!=0;numitems++) + ; + + /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo + dalla lista */ + LockItems(); + nIdleActions=0; + nRealItems=0; + for (i=0;inActions;j++) + if (curItem->Action[j].num==0xFF) + k++; + + nIdleActions+=k; + + if (k==0) + /* Possiamo eliminare questo item dalla lista */ + il[i] = (uint32)NULL; + else + nRealItems++; + } + UnlockItems(); + + /* Se non e' rimasto nessuno possiamo uscire */ + if (nRealItems==0) { + GlobalFree(il); + ExitThread(0); +// _endthread(); + } + + MyThreads=(MYTHREAD*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nRealItems*sizeof(MYTHREAD)); + if (MyThreads==NULL) { + GlobalFree(il); + ExitThread(0); +// _endthread(); + } + + /* Inizializziamo le routine random */ + //curTime=timeGetTime(); + //srand(curTime); + + + /* Abbiamo appurato che esiste almeno un item che contiene idle actions. + Ora creaiamo le copie speculari delle idle actions */ + MyActions=(MYACTION*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nIdleActions*sizeof(MYACTION)); + if (MyActions==NULL) { + GlobalFree(MyThreads); + GlobalFree(il); + ExitThread(0); +// _endthread(); + } + + LockItems(); + k=0; + + for (i=0;inActions;j++) + if (curItem->Action[j].num==0xFF) { + MyActions[k].nItem=il[i]; + MyActions[k].nAction=j; + + MyActions[k].wTime=curItem->Action[j].wTime; + MyActions[k].perc=curItem->Action[j].perc; + MyActions[k].when=curItem->Action[j].when; + MyActions[k].nCmds=curItem->Action[j].nCmds; + CopyMemory(MyActions[k].CmdNum, curItem->Action[j].CmdNum, + MAX_COMMANDS_PER_ACTION*sizeof(uint16)); + + MyActions[k].dwLastTime=timeGetTime(); + k++; + } + } + + UnlockItems(); + + /* La item list non ci serve piu' */ + GlobalFree(il); + + + /* Eccoci al ciclo principale. */ + while (1) { + /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per + l'esecuzione */ + curTime=timeGetTime(); + dwSleepTime=(uint32)-1L; + + for (k=0;k=MyActions[k].dwLastTime+MyActions[k].wTime) { + dwSleepTime=0; + break; + } else + dwSleepTime=MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); + + /* Ci addormentiamo, ma controllando sempre l'evento che viene settato + quando viene richiesta la nostra chiusura */ + k=WaitForSingleObject(hEndPollingLocations[id],dwSleepTime); + if (k==WAIT_OBJECT_0) + break; + + for (i=0;i=MyActions[k].dwLastTime+MyActions[k].wTime) { + MyActions[k].dwLastTime+=MyActions[k].wTime; + + /* E' il momento di tirare il nostro dado virtuale, e controllare + se la sorte e' dalla parte della idle action */ + byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); + if (randomVal < MyActions[k].perc) { + /* Controlliamo se c'e' una action in esecuzione sull'item */ + if ((bExecutingAction) && (nExecutingAction==MyActions[k].nItem)) + continue; + + /* Controlliamo se c'e' gia' un'altra idle function in esecuzione + sullo stesso item */ + for (i=0;iAction[j].when!=NULL) + if (!EvaluateExpression(curItem->Action[j].when)) { + UnlockItems(); + continue; + } + + /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in + un nuovo thread */ + newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); + if (newItem==false) { + GlobalFree(MyThreads); + GlobalFree(MyActions); + ExitThread(0); +// _endthread(); + } + + CopyMemory(newItem,curItem,sizeof(MPALITEM)); + UnlockItems(); + + /* Copiamo l'azione nella #0 */ +// newItem->Action[0].nCmds=curItem->Action[j].nCmds; +// CopyMemory(newItem->Action[0].CmdNum,curItem->Action[j].CmdNum,newItem->Action[0].nCmds*sizeof(newItem->Action[0].CmdNum[0])); + newItem->dwRes=j; + + /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria + allocata per il nuovo item */ + for (i=0;iGroup[i].num!=0;i++) + if (dialog->Group[i].num==nGroup) { + /* Cicla eseguendo i comandi del gruppo */ + for (j=0;jGroup[i].nCmds;j++) { + k=dialog->Group[i].CmdNum[j]; + + switch (dialog->Command[k].type) { + /* Funzione custom: la richiama */ + case 1: + lplpFunctions[dialog->Command[k].nCf]( + dialog->Command[k].arg1, + dialog->Command[k].arg2, + dialog->Command[k].arg3, + dialog->Command[k].arg4 + ); + break; + + /* Variabile: la setta */ + case 2: + LockVar(); + varSetValue(dialog->Command[k].lpszVarName,EvaluateExpression(dialog->Command[k].expr)); + UnlockVar(); + break; + + /* DoChoice: richiama la funzione di scelta */ + case 3: + DoChoice((uint32)dialog->Command[k].nChoice); + break; + + default: + mpalError=1; + UnlockDialogs(); + ExitThread(0); +// _endthread(); + } + } + + /* Abbiamo eseguito il gruppo. Possiamo uscire alla funzione chiamante. + Se il gruppo era il primo chiamato, allora automaticamente il + thread viene chiuso, altrimenti si ritorno al gruppo chiamante. */ + UnlockDialogs(); + return; + } + + /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ + mpalError=1; + UnlockDialogs(); + ExitThread(0); +// _endthread(); +} + + +/****************************************************************************\ +* +* Function: void DoChoice(uint32 nChoice); +* +* Description: Esegue una scelta nel dialogo corrente +* +* Input: uint32 nChoice Numero della scelta da eseguire +* +\****************************************************************************/ + +void DoChoice(uint32 nChoice) { + LPMPALDIALOG dialog; + int i,j,k; + + /* Locka i dialoghi */ + LockDialogs(); + + /* Trova il puntatore al dialogo corrente */ + dialog=lpmdDialogs+nExecutingDialog; + + /* Cerca la scelta richiesta tra quelle nel dialogo */ + for (i=0;dialog->Choice[i].nChoice!=0;i++) + if (dialog->Choice[i].nChoice==nChoice) + break; + + /* Se non l'ha trovata, esce con errore */ + if (dialog->Choice[i].nChoice==0) { + /* Se siamo qui, non abbiamo trovato la choice richiesta */ + mpalError=1; + UnlockDialogs(); + ExitThread(0); +// _endthread(); + } + + /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella + variabile globale */ + nExecutingChoice=i; + + while (1) { + nExecutingChoice=i; + + k=0; + /* Calcoliamo le when expression di ciascun select, per vedere se sono + attivi o disattivi */ + for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].when==NULL) { + dialog->Choice[i].Select[j].curActive=1; + k++; + } else if (EvaluateExpression(dialog->Choice[i].Select[j].when)) { + dialog->Choice[i].Select[j].curActive=1; + k++; + } else + dialog->Choice[i].Select[j].curActive=0; + + /* Se non ci sono scelte attivate, la scelta e' finita */ + if (k==0) { + UnlockDialogs(); + break; + } + + /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, + e restiamo in attesa della risposta */ + ResetEvent(hDoneChoice); + SetEvent(hAskChoice); + WaitForSingleObject(hDoneChoice,INFINITE); + + /* Ora che la scelta e' stata effettuata, possiamo eseguire i gruppi + associati con la scelta */ + j=nSelectedChoice; + for (k=0;dialog->Choice[i].Select[j].wPlayGroup[k]!=0;k++) + GroupThread(dialog->Choice[i].Select[j].wPlayGroup[k]); + + /* Controllo sugli attributi */ + if (dialog->Choice[i].Select[j].attr&(1<<0)) { + /* Bit 0 settato: fine della scelta */ + UnlockDialogs(); + break; + } + + if (dialog->Choice[i].Select[j].attr&(1<<1)) { + /* Bit 1 settato: fine del dialogo */ + UnlockDialogs(); + ExitThread(1); +// _endthread(); + } + + /* Fine della scelta senza attributi: bisogna rifarla */ + } + + /* Se siamo qui, abbiamo trovato un end choice. Ritorna al gruppo chiamante */ + return; +} + + + +/****************************************************************************\ +* +* Function: HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam); +* +* Description: Esegue una azione su un certo item +* +* Input: uint32 nAction Numero dell'azione +* uint32 ordItem Indice dell'item nelle strutture +* degli item +* uint32 dwParam Eventuale parametro per l'azione +* +* Return: Handle del thread che sta eseguendo l'azione, oppure +* INVALID_HANDLE_VALUE se l'azione non e' definita, o l'item +* e' disattivato. +* +* Note: Si puo' ottenere l'indice dell'item a partire dal suo numero +* tramite la funzione itemGetOrderFromNum(). +* Gli item devono essere lockati, perche' questa funzione +* funzioni, tramite LockItem(); +* +\****************************************************************************/ + +static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { + LPMPALITEM item=lpmiItems; + int i; + LPMPALITEM newitem; + uint32 dwId; + HANDLE h; + + item+=ordItem; + Common::String buf = Common::String::format("Status.%u", item->nObj); + if (varGetValue(buf.c_str())<=0) + return INVALID_HANDLE_VALUE; + + for (i=0;inActions;i++) { + if (item->Action[i].num!=nAction) + continue; + + if (item->Action[i].wParm!=dwParam) + continue; + + if (item->Action[i].when!=NULL) { + if (!EvaluateExpression(item->Action[i].when)) + continue; + } + + // Ora abbiamo trova l'azione giusta che deve essere eseguita. + // Duplichiamo l'item corrente e copiamo la azione #i nella #0 + newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); + if (newitem==NULL) + return INVALID_HANDLE_VALUE; + + // Nella nuova versione scriviamo il numero dell'azione in dwRes + CopyMemory(newitem,item,sizeof(MPALITEM)); +/* newitem->Action[0].nCmds=item->Action[i].nCmds; + CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); +*/ + newitem->dwRes=i; + + // E finalmente possiamo richiamare il thread, che eseguira' l'azione + // 0 dell'item, e poi liberera' la memoria con la GlobalFree() + +/* !!! Nuova gestione dei thread +*/ + if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ActionThread,(void *)newitem,0,&dwId))==NULL) + return INVALID_HANDLE_VALUE; + + if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread,(void *)h,0,&dwId))==NULL) + return INVALID_HANDLE_VALUE; + +/* + if ((h=(void*)_beginthread(ActionThread,10240,(void *)newitem))==(void*)-1) + return INVALID_HANDLE_VALUE; + + if ((h=(void*)_beginthread(ShutUpActionThread,10240,(void *)h))==(void*)-1) + return INVALID_HANDLE_VALUE; + +*/ + nExecutingAction=item->nObj; + bExecutingAction=true; + + return h; + } + + return INVALID_HANDLE_VALUE; +} + + +/****************************************************************************\ +* +* Function: HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup); +* +* Description: Esegue un dialogo in un thread +* +* Input: uint32 nDlgOrd Indice del dialogo da eseguire +* all'interno dell'array di strutture +* dei dialoghi +* uint32 nGroup Numero del gruppo da eseguire +* +* Return: Handle del thread che sta eseguendo il dialogo, o +* INVALID_HANDLE_VALUE in caso di errore +* +* Note: Il dialogo viene eseguito in un thread creato apposta, che +* deve informa tramite un evento quando e' necessario far +* fare una scelta all'utente. I dati sulle scelte possono +* essere richiesti tramite le varie query. +* +\****************************************************************************/ + +static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { +// LPMPALDIALOG dialog=lpmdDialogs+nDlgOrd; + uint32 dwId; + HANDLE h; + + /* Si ricorda nella variabile globale qual e' il dialogo in esecuzione */ + nExecutingDialog=nDlgOrd; + + /* Attiva la flag per indicare che c'e' un dialogo in esecuzione */ + bExecutingDialog=true; + + ResetEvent(hAskChoice); + ResetEvent(hDoneChoice); + + /* Crea un thread in cui esegue un gruppo del dialogo */ + + // !!! Nuova gestione dei thread + if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)GroupThread,(void *)nGroup,0,&dwId))==NULL) + // if ((h=(void*)_beginthread(GroupThread,10240,(void *)nGroup))==(void*)-1) + return INVALID_HANDLE_VALUE; + + /* Crea un thread che attende la fine del dialogo e rimette a posto le + variabili globali */ + // !!! Nuova gestione dei thread + if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h,0,&dwId)==NULL) { + //if ((h=(void*)_beginthread(ShutUpDialogThread,10240,(void *)h))==(void*)-1) + TerminateThread(h,0); + CloseHandle(h); + return INVALID_HANDLE_VALUE; + } + + return h; +} + + +/****************************************************************************\ +* +* Function: bool DoSelection(uint32 nChoice, uint32 dwData); +* +* Description: Prende nota del select scelto dall'utente, e avverte il +* thread che stava eseguendo il dialogo che puo' continuare. +* +* Input: uint32 nChoice Numero della scelta che era in corso +* uint32 dwData Dato abbinato al select selezionato +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool DoSelection(uint32 i, uint32 dwData) { + LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + int j; + + for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].dwData==dwData && dialog->Choice[i].Select[j].curActive!=0) + break; + + if (dialog->Choice[i].Select[j].dwData==0) + return false; + + nSelectedChoice=j; + SetEvent(hDoneChoice); + return true; +} + + + +/****************************************************************************\ +* Exported functions +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, +* LPLPCUSTOMFUNCTION lplpcfArray); +* +* Description: Inizializza la libreria MPAL, e apre un file .MPC, che +* verra' utilizzato per tutte le query +* +* Input: char * lpszMpcFileName Nome del file .MPC, comprensivo di +* estensione +* char * lpszMprFileName Nome del file .MPR, comprensivo di +* estensione +* LPLPCUSTOMFUNCTION +* lplpcfArray Array di pointer a funzioni custom +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { + Common::File hMpc; + byte buf[5]; + uint32 nBytesRead; + bool bCompress; + uint32 dwSizeDecomp, dwSizeComp; + byte *cmpbuf; + + //printf("Item: %lu\n",sizeof(MPALITEM)); + //printf("Script: %lu\n",sizeof(MPALSCRIPT)); + //printf("Dialog: %lu\n",sizeof(MPALDIALOG)); + + /* Si salva l'array delle funzioni custom */ + lplpFunctions=lplpcfArray; + + /* Apre il file MPC in lettura */ + if (!hMpc.open(lpszMpcFileName)) + return false; + + /* Legge e controlla l'header */ + nBytesRead = hMpc.read(buf, 5); + if (nBytesRead !=5) + return false; + + if (buf[0]!='M' || buf[1]!='P' || buf[2]!='C' || buf[3]!=0x20) + return false; + + bCompress=buf[4]; + + /* Legge la dimensione del file decompresso, e alloca la memoria */ + dwSizeDecomp = hMpc.readUint32LE(); + if (hMpc.err()) + return false; + + lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); + if (lpMpcImage==NULL) + return false; + + if (bCompress) { + /* Se il file e' compresso, guarda quanto e' grande e alloca la + memoria temporanea per la decompressione */ + dwSizeComp = hMpc.readUint32LE(); + if (nBytesRead != 4) + return false; + + cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); + if (cmpbuf==NULL) + return false; + + nBytesRead = hMpc.read(cmpbuf, dwSizeComp); + if (nBytesRead != dwSizeComp) + return false; + + /* Decomprime l'immagine */ + lzo1x_decompress(cmpbuf,dwSizeComp,lpMpcImage,(lzo_uint*)&nBytesRead,NULL); + if (nBytesRead != dwSizeDecomp) + return false; + + GlobalFree(cmpbuf); + } else { + /* Se il file non e' compresso, lo legge all'interno della memoria gia' + allocata */ + nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); + if (nBytesRead != dwSizeDecomp) + return false; + } + + /* Chiude il file */ + hMpc.close(); + + /* Parsa l'immagine */ + if (ParseMpc(lpMpcImage)==false) + return false; + + GlobalFree(lpMpcImage); + + /* Calcola utilizzo di memoria */ + /* + { + char errbuf[256]; + wsprintf(errbuf,"Utilizzo in RAM: VAR %lu, MSG %lu, DLG %lu, ITM %lu, LOC %lu, SCR %lu", + nVars*sizeof(MPALVAR), + nMsgs*sizeof(MPALMSG), + nDialogs*sizeof(MPALDIALOG), + nItems*sizeof(MPALITEM), + nLocations*sizeof(MPALLOCATION), + nScripts*sizeof(MPALSCRIPT)); + MessageBox(NULL,errbuf,"Dump",MB_OK); + } +*/ + + /* Apre il file MPR in lettura */ + if (!hMpr.open(lpszMprFileName)) + return false; + + /* Si posiziona a 8 byte dalla fine del file */ + hMpr.seek(-12, SEEK_END); + + dwSizeComp = hMpr.readUint32LE(); + if (hMpr.err()) + return false; + + nResources = hMpr.readUint32LE(); + if (hMpr.err()) + return false; + + nBytesRead = hMpr.read(buf, 4); + if (hMpr.err()) + return false; + + if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') + return false; + + /* Si posiziona all'inizio dell'header delle risorse */ + hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); + + lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nResources * 8); + if (lpResources==NULL) + return false; + + cmpbuf = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); + if (cmpbuf==NULL) + return false; + + nBytesRead = hMpr.read(cmpbuf, dwSizeComp); + if (nBytesRead != dwSizeComp) + return false; + + lzo1x_decompress((byte *)cmpbuf,dwSizeComp,(byte *)lpResources, (uint32 *)&nBytesRead, NULL); + if (nBytesRead != (uint32)nResources*8) + return false; + + GlobalFree(cmpbuf); + + /* Si riposiziona all'inizio lasciando il file di risorse aperto */ + hMpr.seek(0, SEEK_SET); + + /* Non c'e' nessuna azione ne' dialogo in esecuzione */ + bExecutingAction = false; + bExecutingDialog = false; + + /* Non c'e' nessuna locazione in polling */ + Common::fill(nPollingLocations, nPollingLocations + MAXPOLLINGLOCATIONS, 0); + + /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' + da effettuare una scelta */ + hAskChoice=CreateEvent(NULL, true, false, NULL); + hDoneChoice=CreateEvent(NULL, true, false, NULL); + + return true; +} + +/****************************************************************************\ +* +* Function: uint32 mpalQuery(uint16 wQueryType, ...); +* +* Description: Questa e' la funzione generale per comunicare con la libreria, +* per richiedere informazioni riguardo a quanto si trova nel +* file .MPC +* +* Input: uint16 wQueryType Tipo di query. La lista e' in +* enum QueryTypes +* +* Return: 4 bytes che dipendono dal tipo di query +* +* Note: E' _FORTEMENTE_ consigliato utilizzare le macro +* definite sopra per utilizzare le query, dato che +* permettono di evitare spiacevoli bug dovuti a dimenticanze +* di parametri. +* +\****************************************************************************/ + +#define GETARG(type) va_arg(v,type) + +uint32 mpalQuery(uint16 wQueryType, ...) { + uint32 dwRet; int x,y,z; char * n; + va_list v; + Common::String buf; + + mpalError=OK; + va_start(v,wQueryType); + + switch (wQueryType) { + /* + * uint32 mpalQuery(MPQ_VERSION); + */ + case MPQ_VERSION: + dwRet = HEX_VERSION; + break; + + /* + * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); + */ + case MPQ_GLOBAL_VAR: + LockVar(); + dwRet=(uint32)varGetValue(GETARG(char *)); + UnlockVar(); + break; + + /* + * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); + */ + case MPQ_MESSAGE: + LockMsg(); + dwRet=(uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + UnlockMsg(); + break; + + /* + * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); + */ + case MPQ_ITEM_PATTERN: + LockVar(); + buf = Common::String::format("Pattern.%u", GETARG(uint32)); + dwRet = (uint32)varGetValue(buf.c_str()); + UnlockVar(); + break; + + /* + * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); + */ + case MPQ_LOCATION_SIZE: + LockLocations(); + x=locGetOrderFromNum(GETARG(uint32)); + y=GETARG(uint32); + if (x!=-1) { + if (y==MPQ_X) + dwRet=lpmlLocations[x].dwXlen; + else if (y==MPQ_Y) + dwRet=lpmlLocations[x].dwYlen; + else + mpalError=1; + } else + mpalError=1; + UnlockLocations(); + break; + + /* + * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); + */ + case MPQ_LOCATION_IMAGE: + LockLocations(); + x=locGetOrderFromNum(GETARG(uint32)); + dwRet=(uint32)resLoad(lpmlLocations[x].dwPicRes); + UnlockLocations(); + break; + + /* + * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); + */ + case MPQ_RESOURCE: + dwRet=(uint32)resLoad(GETARG(uint32)); + break; + + /* + * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); + */ + case MPQ_ITEM_LIST: + LockVar(); + dwRet=(uint32)GetItemList(GETARG(uint32)); + LockVar(); + break; + + /* + * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + */ + case MPQ_ITEM_DATA: + LockItems(); + dwRet=(uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); + UnlockItems(); + break; + + /* + * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); + */ + case MPQ_ITEM_IS_ACTIVE: + LockVar(); + x=GETARG(uint32); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + dwRet = (uint32)false; + else + dwRet = (uint32)true; + UnlockVar(); + break; + + + /* + * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); + */ + case MPQ_ITEM_NAME: + LockVar(); + x=GETARG(uint32); + n=GETARG(char *); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + n[0]='\0'; + else { + LockItems(); + y=itemGetOrderFromNum(x); + CopyMemory(n, (char *)(lpmiItems+y)->lpszDescribe, MAX_DESCRIBE_SIZE); + UnlockItems(); + } + + UnlockVar(); + break; + + + /* + * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + */ + case MPQ_DIALOG_PERIOD: + LockDialogs(); + y=GETARG(uint32); + dwRet=(uint32)DuplicateDialogPeriod(y); + UnlockDialogs(); + break; + + + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ + case MPQ_DIALOG_WAITFORCHOICE: + WaitForSingleObject(hAskChoice,INFINITE); + ResetEvent(hAskChoice); + + if (bExecutingDialog) + dwRet=(uint32)nExecutingChoice; + else + dwRet=(uint32)((int)-1); + break; + + + /* + * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); + */ + case MPQ_DIALOG_SELECTLIST: + LockDialogs(); + dwRet=(uint32)GetSelectList(GETARG(uint32)); + UnlockDialogs(); + break; + + /* + * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); + */ + case MPQ_DIALOG_SELECTION: + LockDialogs(); + x=GETARG(uint32); + y=GETARG(uint32); + dwRet=(uint32)DoSelection(x,y); + UnlockDialogs(); + break; + + + /* + * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); + */ + case MPQ_DO_ACTION: + /* + if (bExecutingAction) + { + dwRet=(uint32)INVALID_HANDLE_VALUE; + break; + } + */ + + LockItems(); + LockVar(); + x=GETARG(uint32); + z=GETARG(uint32); + y=itemGetOrderFromNum(z); + if (y!=-1) { + dwRet=(uint32)DoAction(x,y,GETARG(uint32)); + } else { + dwRet=(uint32)INVALID_HANDLE_VALUE; + mpalError=1; + } + UnlockVar(); + UnlockItems(); + break; + + /* + * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); + */ + case MPQ_DO_DIALOG: + if (bExecutingDialog) + break; + + LockDialogs(); + + x=dialogGetOrderFromNum(GETARG(uint32)); + y=GETARG(uint32); + dwRet=(uint32)DoDialog(x,y); + UnlockDialogs(); + break; + + /* + * DEFAULT -> ERROR + */ + default: + mpalError=1; + break; + } + + va_end(v); + + return dwRet; +} + + +/****************************************************************************\ +* +* Function: uint32 mpalGetError(void); +* +* Description: Ritorna il codice di errore corrente di MPAL +* +* Return: Codice di errore +* +\****************************************************************************/ + +uint32 mpalGetError(void) { + return mpalError; +} + + +/****************************************************************************\ +* +* Function: void mpalExecuteScript(int nScript); +* +* Description: Esegue uno script. Lo script viene eseguito in multitasking +* tramite un thread. +* +* Input: int nScript Numero dello script da eseguire +* +* Return: true se lo script e' stato avviato, false in caso di errore +* +\****************************************************************************/ + +bool EXPORT mpalExecuteScript(int nScript) { + int n; + LPMPALSCRIPT s; + uint32 dwId; + + LockScripts(); + n=scriptGetOrderFromNum(nScript); + s=(LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALSCRIPT)); + if (s==NULL) + return false; + + CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); + UnlockScripts(); + +// !!! Nuova gestione dei thread + if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s,0,&dwId)==NULL) + //if ((void*)_beginthread(ScriptThread,10240,(void *)s)==(void*)-1) + return false; + + return true; +} + + +/****************************************************************************\ +* +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* +* Description: Install a custom routine that will be called by MPAL every +* time the pattern of an item has been changed. +* +* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* +\****************************************************************************/ + +void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { + lpiifCustom=lpiifCus; +} + + +/****************************************************************************\ +* +* Function: bool mpalStartIdlePoll(int nLoc); +* +* Description: Process the idle actions of the items on one location. +* +* Input: int nLoc Number of the location whose items +* must be processed for idle actions. +* +* Return: true se tutto OK, false se si e' superato il limite massimo. +* +* Note: Il numero massimo delle locazione che e' possibile pollare +* contemporaneamente e' contenuto nel define MAXPOLLINGFUNCIONS +* +\****************************************************************************/ + +bool EXPORT mpalStartIdlePoll(int nLoc) { + uint32 i; + uint32 dwId; + + for (i=0;iwriteString("\n

\n

\n"); + + if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { + f->writeString(Common::String::format("%s\n", MsgComments[i].pComment)); + f->writeString("

\n

\n\n"); + } else + bDontOutput=true; + return; + } +} + +void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { + int i; + + for (i=0;MsgComments[i].wEnd!=0;i++) + if (MsgComments[i].wEnd == wNum) { +warning("End: %d\n", wNum); + + if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { + f->writeString("
\n

\n"); + } else + bDontOutput=false; + + f->writeString("

\n

\n\n"); + return; + } +} + + +int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { + int i; + + for (i=0;MsgComments[i].wStart!=0;i++) + if (MsgComments[i].wStart <= wNum && MsgComments[i].wEnd >= wNum) { + if (strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { + if (MsgComments[i].wStart == wNum) { + f->writeString(Common::String::format("%s\n", MsgComments[i].pComment+4)); + f->writeString("

\n

\n

\n"); + } + + return 1; + } + } + + return 0; +} + + +void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { + int i; + + for (i=0;MsgComments[i].wStart!=0;i++) + if (MsgComments[i].wEnd == wNum && strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { + f->writeString("
\n

\n"); + break; + } +} + + +void mpalDumpMessages(void) { + int i,j; + char *lpMessage; + char *p; + char *lpPeriods[30]; + char fname[64]; + char frase[2048]; + int nPeriods; + Common::OutSaveFile *f, *v1; + + v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); + + LockMsg(); + + bDontOutput=false; + + warning("Dumping MESSAGES.HTM...\n"); + + f = g_system->getSavefileManager()->openForSaving("Messages.htm"); + f->writeString("\n\n\n"); + + for (i=0;iwriteString(Common::String::format("%s\n", fname)); + f->writeString("\t\n"); + f->writeString(Common::String::format("\t\t\n", fname)); + f->writeString(Common::String::format("\t\t\n", frase)); + f->writeString("\t\n"); + } + } + + OutputEndMsgComment(lpmmMsgs[i].wNum, f); + + GlobalUnlock(lpmmMsgs[i].hText); + } + } + + f->writeString("
%s %s
\n\n\n"); + + f->finalize(); + v1->finalize(); + delete f; + delete v1; + + UnlockMsg(); +} + + + +void mpalDumpOthers(void) { + int i,j; + char *lpMessage; + char *p; + char *lpPeriods[30]; + char fname[64]; + char frase[2048]; + int nPeriods; + + Common::OutSaveFile *f, *v1; + + v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); + f = g_system->getSavefileManager()->openForSaving("Others.htm"); + LockMsg(); + + bDontOutput=false; + + warning("Dumping OTHERS.HTM...\n"); + + f->writeString("\n\n"); + + for (i=0;iwriteString(Common::String::format("%s\n", fname)); + f->writeString("\t\n"); + f->writeString(Common::String::format("\t\t %s \n", fname)); + f->writeString(Common::String::format("\t\t %s \n", frase)); + f->writeString("\t\n"); + } + } + } + + OutputEndOther(lpmmMsgs[i].wNum, f); + + GlobalUnlock(lpmmMsgs[i].hText); + } + } + + f->writeString("\n\n"); + + f->finalize(); + v1->finalize(); + + delete f; + delete v1; + UnlockMsg(); +} + + +#if 0 // English names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Old lady 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; +char *DLG90[] = { "Tony", "Bearded lady", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Piranha", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG160[] = { "Tony", "Shmiley", NULL }; +char *DLG161[] = { "Tony", "Shmiley", NULL }; +char *DLG162[] = { "Tony", "Shmiley", NULL }; +char *DLG163[] = { "Tony", "Shmiley", NULL }; +char *DLG180[] = { "Tony", "Beast", NULL }; +char *DLG190[] = { "Tony", "Beast", NULL }; +char *DLG191[] = { "Tony", "Beast", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer", NULL }; +char *DLG211[] = { "Tony", "Mortimer", NULL }; +char *DLG212[] = { "Tony", "Mortimer", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; +char *DLG270[] = { "Tony", "Egghead", NULL }; +char *DLG271[] = { "Tony", "Egghead", NULL }; +char *DLG272[] = { "Tony", "Egghead", NULL }; +char *DLG290[] = { "Tony", "Old lady 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Gatekeeper", NULL }; +char *DLG371[] = { "Tony", "Gatekeeper", NULL }; +char *DLG372[] = { "Tony", "Gatekeeper", NULL }; +char *DLG373[] = { "Tony", "Gatekeeper", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; +char *DLG560[] = { "Tony", "Superintendent", NULL }; +char *DLG590[] = { "Tony", "Pantagruel", NULL }; +char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; +#endif + +#if 0 // Polish names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Staruszka 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; +char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Pirania", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG160[] = { "Tony", "miechozol", NULL }; +char *DLG161[] = { "Tony", "miechozol", NULL }; +char *DLG162[] = { "Tony", "miechozol", NULL }; +char *DLG163[] = { "Tony", "miechozol", NULL }; +char *DLG180[] = { "Tony", "Wycz", NULL }; +char *DLG190[] = { "Tony", "Wycz", NULL }; +char *DLG191[] = { "Tony", "Wycz", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; +char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; +char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; +char *DLG270[] = { "Tony", "Jajogowy", NULL }; +char *DLG271[] = { "Tony", "Jajogowy", NULL }; +char *DLG272[] = { "Tony", "Jajogowy", NULL }; +char *DLG290[] = { "Tony", "Staruszka 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Stranik", NULL }; +char *DLG371[] = { "Tony", "Stranik", NULL }; +char *DLG372[] = { "Tony", "Stranik", NULL }; +char *DLG373[] = { "Tony", "Stranik", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; +char *DLG560[] = { "Tony", "Inspektor", NULL }; +char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; +char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; +#endif // Polish + + +#if 0 // Russian +char *DLG10[] = { "呷辷", NULL }; +char *DLG51[] = { "呷辷", "蒼", "釣粳" }; +char *DLG52[] = { "呷辷", NULL }; +char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; +char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; +char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; +char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; +char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; +char *DLG130[] = { "呷辷", "蒡琿", NULL }; +char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG160[] = { "呷辷", "懋珸謌", NULL }; +char *DLG161[] = { "呷辷", "懋珸謌", NULL }; +char *DLG162[] = { "呷辷", "懋珸謌", NULL }; +char *DLG163[] = { "呷辷", "懋珸謌", NULL }; +char *DLG180[] = { "呷辷", "恣粮礦", NULL }; +char *DLG190[] = { "呷辷", "恣粮礦", NULL }; +char *DLG191[] = { "呷辷", "恣粮礦", NULL }; +char *DLG201[] = { "呷辷", NULL }; +char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; +char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; +char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; +char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; +char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; +char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; +char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; +char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; +char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; +char *DLG310[] = { "呷辷", "嚴諡", NULL }; +char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; +char *DLG340[] = { "呷辷", "傴辟琺", NULL }; +char *DLG360[] = { "呷辷", NULL }; +char *DLG361[] = { "呷辷", NULL }; +char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG380[] = { "呷辷", NULL }; +char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; +char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "呷辷", NULL }; +char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "呷辷", "Pin-up", NULL }; +char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; +char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; +char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; +char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; +char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; +char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; +#endif // Russian + + +#if 0 // Czech names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Star pan 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; +char *DLG90[] = { "Tony", "Vousat ena", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Piraa", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG160[] = { "Tony", "Shmiley", NULL }; +char *DLG161[] = { "Tony", "Shmiley", NULL }; +char *DLG162[] = { "Tony", "Shmiley", NULL }; +char *DLG163[] = { "Tony", "Shmiley", NULL }; +char *DLG180[] = { "Tony", "Zv逖e", NULL }; +char *DLG190[] = { "Tony", "Zv逖e", NULL }; +char *DLG191[] = { "Tony", "Zv逖e", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer", NULL }; +char *DLG211[] = { "Tony", "Mortimer", NULL }; +char *DLG212[] = { "Tony", "Mortimer", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; +char *DLG270[] = { "Tony", "Intelektul", NULL }; +char *DLG271[] = { "Tony", "Intelektul", NULL }; +char *DLG272[] = { "Tony", "Intelektul", NULL }; +char *DLG290[] = { "Tony", "Star pan 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Strn", NULL }; +char *DLG371[] = { "Tony", "Strn", NULL }; +char *DLG372[] = { "Tony", "Strn", NULL }; +char *DLG373[] = { "Tony", "Strn", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; +char *DLG560[] = { "Tony", "Sprvce", NULL }; +char *DLG590[] = { "Tony", "Pantagruel", NULL }; +char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; +#endif // Czech names + +#if 1 // Deutsch names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; +char *DLG90[] = { "Tony", "Brtige Dame", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Piranha", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG160[] = { "Tony", "Shmiley", NULL }; +char *DLG161[] = { "Tony", "Shmiley", NULL }; +char *DLG162[] = { "Tony", "Shmiley", NULL }; +char *DLG163[] = { "Tony", "Shmiley", NULL }; +char *DLG180[] = { "Tony", "Biest", NULL }; +char *DLG190[] = { "Tony", "Biest", NULL }; +char *DLG191[] = { "Tony", "Biest", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer", NULL }; +char *DLG211[] = { "Tony", "Mortimer", NULL }; +char *DLG212[] = { "Tony", "Mortimer", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; +char *DLG270[] = { "Tony", "Eierkopf", NULL }; +char *DLG271[] = { "Tony", "Eierkopf", NULL }; +char *DLG272[] = { "Tony", "Eierkopf", NULL }; +char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Pfrtner", NULL }; +char *DLG371[] = { "Tony", "Pfrtner", NULL }; +char *DLG372[] = { "Tony", "Pfrtner", NULL }; +char *DLG373[] = { "Tony", "Pfrtner", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; +char *DLG560[] = { "Tony", "Verwalter", NULL }; +char *DLG590[] = { "Tony", "Pantagruel", NULL }; +char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; +#endif + + +#define HANDLE_DIALOG(num) \ +case num: \ + if (nPers >= sizeof(DLG##num) / sizeof(char*) || DLG##num[nPers]==NULL) \ + { \ + warning("ERROR: Il personaggio #%d non esiste nel dialogo %d!\n", nPers, nDlg); \ + return "ERROR"; \ + } \ + else \ + return DLG##num[nPers]; + + +char *GetPersonName(uint16 nDlg, int nPers) +{ + switch (nDlg) + { + HANDLE_DIALOG(10); + HANDLE_DIALOG(51); + HANDLE_DIALOG(52); + HANDLE_DIALOG(61); + HANDLE_DIALOG(71); + HANDLE_DIALOG(90); + HANDLE_DIALOG(110); + HANDLE_DIALOG(111); + HANDLE_DIALOG(130); + HANDLE_DIALOG(150); + HANDLE_DIALOG(151); + HANDLE_DIALOG(152); + HANDLE_DIALOG(153); + HANDLE_DIALOG(154); + HANDLE_DIALOG(160); + HANDLE_DIALOG(161); + HANDLE_DIALOG(162); + HANDLE_DIALOG(163); + HANDLE_DIALOG(180); + HANDLE_DIALOG(190); + HANDLE_DIALOG(191); + HANDLE_DIALOG(201); + HANDLE_DIALOG(210); + HANDLE_DIALOG(211); + HANDLE_DIALOG(212); + HANDLE_DIALOG(240); + HANDLE_DIALOG(250); + HANDLE_DIALOG(251); + HANDLE_DIALOG(260); + HANDLE_DIALOG(270); + HANDLE_DIALOG(271); + HANDLE_DIALOG(272); + HANDLE_DIALOG(290); + HANDLE_DIALOG(310); + HANDLE_DIALOG(330); + HANDLE_DIALOG(340); + HANDLE_DIALOG(360); + HANDLE_DIALOG(361); + HANDLE_DIALOG(370); + HANDLE_DIALOG(371); + HANDLE_DIALOG(372); + HANDLE_DIALOG(373); + HANDLE_DIALOG(380); + HANDLE_DIALOG(410); + HANDLE_DIALOG(430); + HANDLE_DIALOG(460); + HANDLE_DIALOG(470); + HANDLE_DIALOG(471); + HANDLE_DIALOG(472); + HANDLE_DIALOG(473); + HANDLE_DIALOG(474); + HANDLE_DIALOG(480); + HANDLE_DIALOG(490); + HANDLE_DIALOG(530); + HANDLE_DIALOG(550); + HANDLE_DIALOG(560); + HANDLE_DIALOG(590); + HANDLE_DIALOG(600); + + default: + warning("ERROR: Il dialogo %d non esiste!\n", nDlg); + return "ERROR"; + } +} + +void mpalDumpDialog(LPMPALDIALOG dlg) { + char dfn[64]; + char fname[64]; + int g,c,j; + struct command* curCmd; + char *frase; char *p; + char copia[2048]; + bool bAtLeastOne; + Common::OutSaveFile *f, *v1; + + v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); + + sprintf(dfn,"DIALOG%03d.HTM",dlg->nObj); + warning("Dumping %s...\n", dfn); + + f = g_system->getSavefileManager()->openForSaving(dfn); + + f->writeString("\n\n"); + + for (g=0;dlg->Group[g].num != 0; g++) { + bAtLeastOne = false; + + for (c=0;cGroup[g].nCmds; c++) { + curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + if (curCmd->type == 1 && curCmd->nCf == 71) { + bAtLeastOne=true; + break; + } + } + + if (!bAtLeastOne) + continue; + + f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); + f->writeString("\n"); + + for (c=0;cGroup[g].nCmds; c++) { + curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + + // Se una funzione custom, e richiama la SendDialogMessage(nPers, nMsg) + if (curCmd->type == 1 && curCmd->nCf == 71) { + sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); + + for (j=0;dlg->Periods[j]!=NULL;j++) + if (dlg->PeriodNums[j] == curCmd->arg2) + break; + + if (dlg->Periods[j]==NULL) + warning("ERROR: Dialogo %d, Periodo %d non trovato!\n", (int)dlg->nObj, (int)curCmd->arg2); + else { + frase = (char *)GlobalLock(dlg->Periods[j]); + strcpy(copia, frase); + GlobalUnlock(dlg->Periods[j]); + + while ((p=strchr(copia,'^')) != NULL) + *p = '\"'; + + p = frase; + while (*p == ' ') p++; + if (*p == '\0') + continue; + + v1->writeString(Common::String::format("%s\n", fname)); + f->writeString("\t\n"); + f->writeString(Common::String::format("\t\t\n", fname)); + f->writeString(Common::String::format("\t\t\n", + GetPersonName(dlg->nObj, curCmd->arg1))); + f->writeString(Common::String::format("\t\t\n",copia)); + f->writeString("\t\n"); + //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); + } + } + } + + f->writeString("
%s %s %s

\n"); + //fprintf(f,"\n\n\n\n"); + } + + f->finalize(); + v1->finalize(); + delete f; + delete v1; +} + +void mpalDumpDialogs(void) { + int i; + + LockDialogs(); + + for (i=0;i '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Main Include file for * + * 4> ^R$oue# d using MPAL.DLL......... * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + + +/****************************************************************************\ +* Copyright Notice +\****************************************************************************/ + +/* + * A Spyral Software Production: + * + * MPAL - MultiPurpose Adventure Language + * (C) 1997 Giovanni Bajo and Luca Giusti + * ALL RIGHTS RESERVED + * + * + */ + + +/****************************************************************************\ +* General Introduction +\****************************************************************************/ + +/* + * MPAL (MultiPurpose Adventure Language) is a high level language + * for the definition of adventure. Through the use of MPAL you can describe + * storyboard the adventure, and then use it with any user interface. + * In fact, unlike many other similar products, MPAL is not programmed through + * the whole adventure, but are defined only the locations, objects, as they may + * interact with each other, etc.. thus making MPAL useful for any type of adventure. + */ + +/****************************************************************************\ +* Structure +\****************************************************************************/ + +/* + * MPAL consists of two main files: MPAL.DLL and MPAL.H + * The first is the DLL that contains the code to interface with MPAL + * adventures, the second is the header that defines the prototypes + * functions. MPAL is compiled for Win32, and it can therefore be used with + * any compiler that supports Win32 DLL (Watcom C++, Visual C++, + * Delphi, etc.), and therefore compatible with both Windows 95 and Windows NT. + * + * To use the DLL, and 'obviously need to create a library for symbols to export. + * + */ + + +/****************************************************************************\ +* Custom Functions +\****************************************************************************/ + +/* + * A custom function and a function specified by the program that uses the + * library, to perform the particular code. The custom functions are + * retrieved from the library as specified in the source MPAL, and in particular + * in defining the behavior of an item with some action. + * + * To use the custom functions, you need to prepare an array of + * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, + * (defined below), and pass it as second parameter to mpalInit (). Note you + * must specify the size of the array, as elements of pointers and which do not + * contain the same: the library will call it only those functions specified in + * the source MPAL. It can be useful, for debugging reasons, do not bet + * the shares of arrays used to debugging function, to avoid unpleasant crash, + * if it has been made an error in source and / or some oversight in the code. + * + */ + +#ifndef __MPAL_H +#define __MPAL_H + +#include "common/scummsys.h" +#include "common/rect.h" + +/****************************************************************************\ +* Macro definitions and structures +\****************************************************************************/ + +/* OK value for the error codes */ +#define OK 0 + +#define MAXFRAMES 400 // frame animation of an object +#define MAXPATTERN 40 // pattern of animation of an object + +#define MAXPOLLINGLOCATIONS 64 + +#define EXPORT +#define LPSTR char * + +/****************************************************************************\ +* enum QueryCoordinates +* --------------------- +* Description: Macro for use with queries that may refer to X and Y co-ordinates +\****************************************************************************/ + +enum QueryCoordinates { + MPQ_X, + MPQ_Y +}; + + +/****************************************************************************\ +* enum QueryTypes +* --------------- +* Description: Query can be used with mpalQuery (). In practice corresponds +* all claims that can do at the library +\****************************************************************************/ + +enum QueryTypes { + /* General Query */ + MPQ_VERSION=10, + + MPQ_GLOBAL_VAR=50, + MPQ_RESOURCE, + MPQ_MESSAGE, + + /* Query on leases */ + MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_SIZE, + + /* Queries about items */ + MPQ_ITEM_LIST=200, + MPQ_ITEM_DATA, + MPQ_ITEM_PATTERN, + MPQ_ITEM_NAME, + MPQ_ITEM_IS_ACTIVE, + + /* Query dialog */ + MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_WAITFORCHOICE, + MPQ_DIALOG_SELECTLIST, + MPQ_DIALOG_SELECTION, + + /* Query execution */ + MPQ_DO_ACTION=400, + MPQ_DO_DIALOG +}; + + +/****************************************************************************\ +* typedef ITEM +* ------------ +* Description: Framework to manage the animation of an item +\****************************************************************************/ + +typedef struct { + char *frames[MAXFRAMES]; + Common::Rect frameslocations[MAXFRAMES]; + Common::Rect bbox[MAXFRAMES]; + short pattern[MAXPATTERN][MAXFRAMES]; + short speed; + char numframe; + char numpattern; + char curframe; + char curpattern; + short destX, destY; + signed char Zvalue; + short objectID; + char TAG; +} ITEM; +typedef ITEM *LPITEM; + + +/****************************************************************************\ +* typedef LPCUSTOMFUNCTION +* ------------------------ +* Description: Define a custom function, to use the language MPAL +* to perform various controls as a result of an action +\****************************************************************************/ + +typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); +typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; + + +/****************************************************************************\ +* typedef LPITEMIRQFUNCTION +* ------------------------- +* Description: Define an IRQ of an item that is called when the +* pattern changes or the status of an item +\****************************************************************************/ + +typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); +typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; + + +/****************************************************************************\ +* Macrofunctions query +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: uint32 mpalQueryVersion(void); +* +* Description: Gets the current version of MPAL +* +* Return: Version number (0x1232 = 1.2.3b) +* +\****************************************************************************/ + +#define mpalQueryVersion() \ + (uint16)mpalQuery(MPQ_VERSION) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); +* +* Description: Gets the numerical value of a global variable +* +* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) +* +* Return: Valore della variabile +* +* Note: This query was implemented for debugging. The program, +* if well designed, should not need to access variables from +* within the library. +* +\****************************************************************************/ + +#define mpalQueryGlobalVar(lpszVarName) \ + (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryResource(uint32 dwResId); +* +* Description: Provides access to a resource inside the .MPC file +* +* Input: uint32 dwResId ID della risorsa +* +* Return: Handle to a memory area containing the resource, +* ready for use. +* +\****************************************************************************/ + +#define mpalQueryResource(dwResId) \ + (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryMessage(uint32 nMsg); +* +* Description: Returns a message. +* +* Input: uint32 nMsg Message number +* +* Return: ASCIIZ message +* +* Note: The returned pointer must be freed with GlobalFree() +* after use. The message will be in ASCIIZ format. +* +\****************************************************************************/ + +#define mpalQueryMessage(nMsg) \ + (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); +* +* Description: Provides a image image +* +* Input: uint32 nLoc Locazion number +* +* Return: Returns a picture handle +* +\****************************************************************************/ + +#define mpalQueryLocationImage(nLoc) \ + (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); +* +* Description: Request the x or y size of a location in pixels +* +* Input: uint32 nLoc Location number +* uint32 dwCoord MPQ_Xr o MPQ_Y +* +* Return: Size +* +\****************************************************************************/ + +#define mpalQueryLocationSize(nLoc,dwCoord) \ + (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + + + +/****************************************************************************\ +* +* Function: uint32 * mpalQueryItemList(uint32 nLoc); +* +* Description: Provides the list of objects in the lease. +* +* Input: uint32 nLoc Location number +* +* Return: List of objects (accessible by Item [0], Item [1], etc.) +* +\****************************************************************************/ + +#define mpalQueryItemList(nLoc) \ + (uint32 *)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); +* +* Description: Provides information on an item +*e +* Input: uint32 nItem Item number +* +* Return: structure filled with requested information +* +\****************************************************************************/ + +#define mpalQueryItemData(nItem) \ + (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryItemPattern(uint32 nItem); +* +* Description: Provides the current pattern of an item +* +* Input: uint32 nItem Item number +* +* Return: Number of animation patterns to be executed. +* +* Note: By default, the pattern of 0 indicates that we should +* do nothing. +* +\****************************************************************************/ + +#define mpalQueryItemPattern(nItem) \ + (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryItemIsActive(uint32 nItem); +* +* Description: Returns true if an item is active +* +* Input: uint32 nItem Item number +* +* Return: TRUE if the item is active, FALSE otherwise +* +\****************************************************************************/ + +#define mpalQueryItemIsActive(nItem) \ + (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + + +/****************************************************************************\ +* +* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); +* +* Description: Returns the name of an item +* +* Input: uint32 nItem Item number +* LPSTR lpszName Pointer to a buffer of at least 33 bytes +* that will be filled with the name +* +* Note: If the item is not active (ie. if its status or number +* is less than or equal to 0), the string will be empty. +* +\****************************************************************************/ + +#define mpalQueryItemName(nItem,lpszName) \ + (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); +* +* Description: Returns a sentence of dialog. +* +* Input: uint32 nDialog Dialog number +* uint32 nPeriod Number of words +* +* Return: A pointer to the string of words, or NULL on failure. +* +* Note: The string must be freed after use by GlobalFree (). +* +* Unlike normal messages, the sentences of dialogue +* are formed by a single string terminated with 0. +* +\****************************************************************************/ + +#define mpalQueryDialogPeriod(nPeriod) \ + (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) + + + +/****************************************************************************\ +* +* Function: int mpalQueryDialogWaitForChoice(void); +* +* Description: Wait until the moment in which the need is signaled +* to make a choice by the user. +* +* Return: Number of choice to be made, or -1 if the dialogue is finished. +* +\****************************************************************************/ + +#define mpalQueryDialogWaitForChoice() \ + (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) + + + +/****************************************************************************\ +* +* Function: uint32 * mpalQueryDialogSelectList(uint32 nChoice); +* +* Description: Requires a list of various options for some choice within +* the current dialog. + +* Input: uint32 nChoice Choice number +* +* Return: A pointer to an array containing the data matched to each option. +* +* Note: The figure 'a uint32 specified in the source to which MPAL +* You can 'assign meaning that the more' suits. +* +* The pointer msut be freed after use by GlobalFree(). +* +\****************************************************************************/ + +#define mpalQueryDialogSelectList(nChoice) \ + (uint32 *)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); +* +* Description: Warns the library that the user has selected, in a certain +* choice of the current dialog, corresponding option +* at a certain given. +* +* Input: uint32 nChoice Choice number of the choice that +* was in progress +* uint32 dwData Option that was selected by the user. +* +* Return: TRUE if all OK, FALSE on failure. +* +* Note: After execution of this query, MPAL continue +* Groups according to the execution of the dialogue. And necessary so the game +* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). +* +\****************************************************************************/ + +#define mpalQueryDialogSelection(nChoice,dwData) \ + (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, +* uint32 dwParam); +* +* Description: Warns the library an action was performed on a Object. +* The library will call 'custom functions, if necessary. +* +* Input: uint32 nAction Action number +* uint32 nItem Item number +* uint32 dwParam Action parameter +* +* Return: Handle to the thread that is performing the action, or +* INVALID_HANDLE_VALUE if the action is not 'defined for +* the item, or the item and 'off. +* +* Note: The parameter is used primarily to implement actions +* as "U.S." involving two objects together. The action will be executed only +* if the item is active, ie if its status is a positive number greater than 0. +* +\****************************************************************************/ + +#define mpalQueryDoAction(nAction,nItem,dwParam) \ + (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); +* +* Description: Warns the library a dialogue was required. +* +* Input: uint32 nDialog Dialog number +* uint32 nGroup Group number to use +* +* Return: Handle to the thread that is running the box, or +* INVALID_HANDLE_VALUE if the dialogue does not exist. +* +\****************************************************************************/ + +#define mpalQueryDoDialog(nDialog,nGroup) \ + (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) + + + +/****************************************************************************\ +* Functions exported DLL +\****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************\ +* +* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, +* LPLPCUSTOMFUNCTION lplpcfArray); +* +* Description: Initializes the MPAL library, and opens an .MPC file, which +* will be 'used for all queries +* +* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension +* LPSTR lpszMprFileName Name of the .MPR file, including extension +* LPLPCUSTOMFUNCTION Array of pointers to custom functions +* +* Return: TRUE if all OK, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, + LPLPCUSTOMFUNCTION lplpcfArray); + + + +/****************************************************************************\ +* +* Function: uint32 mpalQuery(uint16 wQueryType, ...); +* +* Description: This is the general function to communicate with the library, +* To request information about what is in the .MPC file +* +* Input: uint16 wQueryType Type of query. The list is in +* the QueryTypes enum. +* +* Return: 4 bytes depending on the type of query +* +* Note: I _strongly_ recommended to use macros defined above to use +* the query, since it helps avoid any unpleasant bugs due to +* forgeting parameters. +* +\****************************************************************************/ + +uint32 EXPORT mpalQuery(uint16 wQueryType, ...); + + + +/****************************************************************************\ +* +* Function: bool mpalExecuteScript(int nScript); +* +* Description: Execute a script. The script runs on multitasking by a thread. +* +* Input: int nScript Script number to run +* +* Return: TRUE if the script 'was launched, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalExecuteScript(int nScript); + + + +/****************************************************************************\ +* +* Function: uint32 mpalGetError(void); +* +* Description: Returns the current MPAL error code +* +* Return: Error code +* +\****************************************************************************/ + +uint32 EXPORT mpalGetError(void); + + + +/****************************************************************************\ +* +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* +* Description: Install a custom routine That will be called by MPAL +* every time the pattern of an item has-been changed. +* +* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* +\****************************************************************************/ + +void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); + + +/****************************************************************************\ +* +* Function: bool mpalStartIdlePoll(int nLoc); +* +* Description: Process the idle actions of the items on one location. +* +* Input: int nLoc Number of the location whose items +* must be processed for idle actions. +* +* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. +* +* Note: The maximum number of locations that can be polled +* simultaneously is defined defined by MAXPOLLINGFUNCIONS +* +\****************************************************************************/ + +bool EXPORT mpalStartIdlePoll(int nLoc); + + +/****************************************************************************\ +* +* Function: bool mpalEndIdlePoll(int nLoc); +* +* Description: Stop processing the idle actions of the items on one location. +* +* Input: int nLoc Number of the location +* +* Return: TRUE if all OK, FALSE if the specified location was not +* in the process of polling +* +\****************************************************************************/ + +bool EXPORT mpalEndIdlePoll(int nLoc); + + + +/****************************************************************************\ +* +* Function: int mpalLoadState(LPBYTE buf); +* +* Description: Load a save state from a buffer. +* +* Input: LPBYTE buf Buffer where to store the state +* +* Return: Length of the state in bytes +* +\****************************************************************************/ + +int EXPORT mpalLoadState(byte *buf); + + + +/****************************************************************************\ +* +* Function: void mpalSaveState(LPBYTE buf); +* +* Description: Store the save state into a buffer. The buffer must be +* length at least the size specified with mpalGetSaveStateSize +* +* Input: LPBYTE buf Buffer where to store the state +* +\****************************************************************************/ + +void EXPORT mpalSaveState(byte *buf); + + + +/****************************************************************************\ +* +* Function: int mpalGetSaveStateSize(void); +* +* Description: Acquire the length of a save state +* +* Return: Length in bytes +* +\****************************************************************************/ + +int EXPORT mpalGetSaveStateSize(void); + +#ifdef __cplusplus +} +#endif + +/****************************************************************************\ +* +* Function: void LockVar(void); +* +* Description: Locka le variabili per accederci +* +\****************************************************************************/ + +extern void LockVar(void); + +/****************************************************************************\ +* +* Function: void UnlockVar(void); +* +* Description: Unlocka le variabili dopo l'uso +* +\****************************************************************************/ + +extern void UnlockVar(void); + +#endif + diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h new file mode 100644 index 0000000000..8a52f1ed90 --- /dev/null +++ b/engines/tony/mpal/mpaldll.h @@ -0,0 +1,418 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: MPAL DLL Header........ * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Header per i moduli per * + * 4> ^R$oue# d la DLL di query di MPAL * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#ifndef __MPALDLL_H +#define __MPALDLL_H + +#include "common/file.h" +#include "stubs.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Defines +\****************************************************************************/ + +#define HEX_VERSION 0x0170 + +/* + SICURA + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 256 +#define MAX_COMMANDS_PER_ACTION 64 +#define MAX_DESCRIBE_SIZE 128 +*/ + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 128 +#define MAX_COMMANDS_PER_ACTION 128 +#define MAX_DESCRIBE_SIZE 64 + + + +#define MAX_MOMENTS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_MOMENT 32 + + + + + +/* + Versione sicura! + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 640 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 33 +#define MAX_PLAYGROUPS_PER_SELECT 9 +#define MAX_PERIODS_PER_DIALOG 640 + +*/ + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 480 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 64 +#define MAX_PLAYGROUPS_PER_SELECT 9 +#define MAX_PERIODS_PER_DIALOG 400 + +/* + Prima di Rufus: + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 512 +#define MAX_COMMANDS_PER_GROUP 32 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 32 +#define MAX_PLAYGROUPS_PER_SELECT 4 +#define MAX_PERIODS_PER_DIALOG 512 +*/ + +#define NEED_LOCK_MSGS + + +/****************************************************************************\ +* Strutture +\****************************************************************************/ + +#include "common/pack-start.h" + +/****************************************************************************\ +* typedef MPALVAR +* --------------- +* Description: Variabile globale di MPAL +\****************************************************************************/ + +struct MPALVAR { + uint32 dwVal; // Valore della variabile + char lpszVarName[33]; // Nome della variabile +} PACKED_STRUCT; +typedef MPALVAR* LPMPALVAR; +typedef LPMPALVAR* LPLPMPALVAR; + + +/****************************************************************************\ +* typedef MPALMSG +* --------------- +* Description: Messaggio di MPAL +\****************************************************************************/ + +struct MPALMSG { + HGLOBAL hText; // Handle al testo del messaggio + uint16 wNum; // Numero del messaggio +} PACKED_STRUCT; +typedef MPALMSG* LPMPALMSG; +typedef LPMPALMSG* LPLPMPALMSG; + + +/****************************************************************************\ +* typedef MPALLOCATION +* -------------------- +* Description: Locazione di MPAL +\****************************************************************************/ + +struct MPALLOCATION { + uint32 nObj; // Numero della locazione + uint32 dwXlen, dwYlen; // Dimensione + uint32 dwPicRes; // Risorsa che contiene l'immagine +} PACKED_STRUCT; +typedef MPALLOCATION* LPMPALLOCATION; +typedef LPMPALLOCATION* LPLPMPALLOCATION; + + +/****************************************************************************\ +* struct command +* -------------- +* Description: Gestisce un comando, cioe' le tag utilizzate dalle OnAction +* negli item, dalle Time negli script e dai Group nei Dialog +\****************************************************************************/ + +struct command { + /* + * Tipi di comandi riconosciuti: + * + * #1 -> Chiamata a funzione custom (ITEM, SCRIPT, DIALOG) + * #2 -> Assegnazione di variabile (ITEM, SCRIPT, DIALOG) + * #3 -> Esecuzione di una scelta (DIALOG) + * + */ + byte type; // Tipo di comando + + union { + int32 nCf; // Numero funzione custom [#1] + char *lpszVarName; // Nome variabile [#2] + int32 nChoice; // Numero di scelta da fare [#3] + }; + + union { + int32 arg1; // Argomento 1 funzione custom [#1] + HGLOBAL expr; // Espressione da assegnare alla + // variabile [#2] + }; + + int32 arg2,arg3,arg4; // Argomenti per funzione custom [#1] +} PACKED_STRUCT; + +/****************************************************************************\ +* typedef MPALDIALOG +* ------------------ +* Description: Dialog di MPAL +\****************************************************************************/ + +struct MPALDIALOG { + uint32 nObj; // Numero dialog + + struct command Command[MAX_COMMANDS_PER_DIALOG]; + + struct { + uint16 num; + + byte nCmds; + uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; + + } Group[MAX_GROUPS_PER_DIALOG]; + + struct { + // L'ultima choice ha nChoice==0 + uint16 nChoice; + + // Non c'e' il numero di Select (siamo abbastanza avari di RAM). L'ultimo + // select ha dwData==0 + struct { + HGLOBAL when; + uint32 dwData; + uint16 wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; + + // Bit 0=endchoice Bit 1=enddialog + byte attr; + + // Modificata a run-time: 0 se il select e' correntemente disabilitato, + // 1 se e' correntemente attivato + byte curActive; + } Select[MAX_SELECTS_PER_CHOICE]; + + } Choice[MAX_CHOICES_PER_DIALOG]; + + uint16 PeriodNums[MAX_PERIODS_PER_DIALOG]; + HGLOBAL Periods[MAX_PERIODS_PER_DIALOG]; + +} PACKED_STRUCT; +typedef MPALDIALOG* LPMPALDIALOG; +typedef LPMPALDIALOG* LPLPMPALDIALOG; + +/****************************************************************************\ +* typedef MPALITEM +* ---------------- +* Description: Item di MPAL +\****************************************************************************/ + +struct ItemAction { + byte num; // Numero dell'azione + uint16 wTime; // In caso di idle, il tempo che deve passare + byte perc; // Percentuale di eseguire l'idle + HGLOBAL when; // Espressione da calcolare: se !=0, allora + // l'azione puo' essere eseguita + uint16 wParm; // Parametro per l'azione + + byte nCmds; // Numero comandi da eseguire + uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire +} PACKED_STRUCT; + +struct MPALITEM { + uint32 nObj; // Numero item + + byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Nome + byte nActions; // Numero delle azioni gestite + uint32 dwRes; // Risorsa che contiene frame e pattern + + struct command Command[MAX_COMMANDS_PER_ITEM]; + + // Array di strutture contenenti le varie azioni gestite. In pratica, di + // ogni azione sappiamo quali comandi eseguire, tra quelli definiti nella + // struttura qui sopra +/* + struct + { + byte num; // Numero dell'azione + uint16 wTime; // In caso di idle, il tempo che deve passare + byte perc; // Percentuale di eseguire l'idle + HGLOBAL when; // Espressione da calcolare: se !=0, allora + // l'azione puo' essere eseguita + uint16 wParm; // Parametro per l'azione + + byte nCmds; // Numero comandi da eseguire + uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire + + } Action[MAX_ACTIONS_PER_ITEM]; + */ + struct ItemAction *Action; + +} PACKED_STRUCT; +typedef MPALITEM* LPMPALITEM; +typedef LPMPALITEM* LPLPMPALITEM; + + +/****************************************************************************\ +* typedef MPALSCRIPT +* ------------------ +* Description: Script di MPAL +\****************************************************************************/ + +struct MPALSCRIPT { + uint32 nObj; + + uint32 nMoments; + + struct command Command[MAX_COMMANDS_PER_SCRIPT]; + + struct { + int32 dwTime; + + byte nCmds; + uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; + + } Moment[MAX_MOMENTS_PER_SCRIPT]; + +} PACKED_STRUCT; +typedef MPALSCRIPT* LPMPALSCRIPT; +typedef LPMPALSCRIPT* LPLPMPALSCRIPT; + +#include "common/pack-end.h" + +/****************************************************************************\ +* Variabili globali +\****************************************************************************/ + +extern uint32 mpalError; +extern LPLPCUSTOMFUNCTION lplpFunctions; +extern uint16 nObjs; + +extern uint16 nVars; +extern HGLOBAL hVars; +extern LPMPALVAR lpmvVars; + +extern uint16 nMsgs; +extern HGLOBAL hMsgs; +extern LPMPALMSG lpmmMsgs; + +extern uint16 nDialogs; +extern HGLOBAL hDialogs; +extern LPMPALDIALOG lpmdDialogs; + +extern uint16 nItems; +extern HGLOBAL hItems; +extern LPMPALITEM lpmiItems; + +extern uint16 nLocations; +extern HGLOBAL hLocations; +extern LPMPALLOCATION lpmlLocations; + +extern uint16 nScripts; +extern HGLOBAL hScripts; +extern LPMPALSCRIPT lpmsScripts; + +extern Common::File hMpr; +extern uint16 nResources; +extern uint32 * lpResources; + +/****************************************************************************\ +* Prototipi di funzione +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: int32 varGetValue(const char *lpszVarName); +* +* Description: Restituisce il valore corrente di una variabile globale +* +* Input: const char *lpszVarName Nome della variabile +* +* Return: Valore corrente +* +* Note: Prima di questa funzione, bisogna richiamare LockVar() che +* locka le variabili globali per l'utilizzo. Dopo inoltre bi- +* sogna ricordarsi di chiamare UnlockVar() +* +\****************************************************************************/ + +int32 varGetValue(const char *lpszVarName); + + +/****************************************************************************\ +* +* Function: void varSetValue(const char *lpszVarName, int32 val); +* +* Description: Setta un nuovo valore per una variabile globale di MPAL +* +* Input: const char *lpszVarName Nome della variabile +* int32 val Valore da settare +* +\****************************************************************************/ + +void varSetValue(const char *lpszVarName, int32 val); + +/****************************************************************************\ +* Includes the various modules +\****************************************************************************/ + +} // end of namespace MPAL + +} // end of namespace Tony + +#include "loadmpc.h" +#include "expr.h" + +#endif + diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp new file mode 100644 index 0000000000..342678b856 --- /dev/null +++ b/engines/tony/mpal/stubs.cpp @@ -0,0 +1,140 @@ +e/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 TONY_MPAL_STUBS +#define TONY_MPAL_STUBS + +/****************************************************************************\ +* This file contains stubs and mappings for things used by the MPAL +* library that are handled differently under ScummVM +\****************************************************************************/ + +#include "common/algorithm.h" +#include "common/system.h" +#include "engines/engine.h" +#include "tony/tony.h" +#include "stubs.h" + +namespace Tony { + +namespace MPAL { + +/** + * Allocates a memory block + */ +byte *GlobalAlloc(uint16 flags, int size) { + byte *result = (byte *)malloc(size); + + if (flags & GMEM_ZEROINIT) + Common::fill(result, result + size, 0); + + return result; +} + +/** + * Lock a global handle + * @param h Global handle + * @remarks Since HGLOBALs are directly representing the pointers anyway, + * simply return it + */ +void *GlobalLock(HGLOBAL h) { + return h; +} + +/** + * Unlock a global handle + * @param h Global handle + * @remarks Since HGLOBALs are directly representing the pointers anyway, + * the unlock method doesn't need to do anything + */ +void GlobalUnlock(HGLOBAL h) { +} + +/** + * Free a globally allocated memory block + * @param h Global handle + */ +void GlobalFree(HGLOBAL h) { + free(h); +} + +/** + * Display a message + * @param msg Message to display + */ +void MessageBox(const Common::String &msg) { + + _vm->GUIError(msg); +} + +/** + * Gets the current time in milliseconds + */ +uint32 timeGetTime() { + return g_system->getMillis(); +} + +HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, + uint32 dwCreationFlags, uint32 *lpThreadId) { + *lpThreadId = 0; + return 0; +} + +void ExitThread(HANDLE ThreadId) { +} + +void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { + +} + +void CloseHandle(HANDLE ThreadId) { + +} + +void Sleep(uint32 time) { +} + +int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime) { + return 0; +} + +uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds) { + return 0; +} + +HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName) { + return 0; +} + +void SetEvent(HANDLE hEvent) { +} + +void ResetEvent(HANDLE hEvent) { +} + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h new file mode 100644 index 0000000000..d66e12d00d --- /dev/null +++ b/engines/tony/mpal/stubs.h @@ -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 contains stubs and mappings for things used by the MPAL +* library that are handled differently under ScummVM +\****************************************************************************/ + +#ifndef MPAL_STUBS +#define MPAL_STUBS + +#include "common/scummsys.h" +#include "common/algorithm.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Types +\****************************************************************************/ + +typedef void *HGLOBAL; +typedef void *HANDLE; + +typedef uint32 (__stdcall *LPTHREAD_START_ROUTINE)(void *lpThreadParameter); + +/****************************************************************************\ +* Defines +\****************************************************************************/ + +#define GMEM_FIXED 1 +#define GMEM_MOVEABLE 2 +#define GMEM_ZEROINIT 4 + +#define MB_OK 1 + +#define PASCAL + +/****************************************************************************\ +* Templates +\****************************************************************************/ + +/** + * Copies data from the range [first, last) to [dst, dst + (last - first)). + * It requires the range [dst, dst + (last - first)) to be valid. + * It also requires dst not to be in the range [first, last). + */ +template +Out CopyMemory(Out dst, In first, int size) { + return Common::copy(first, first + size, dst); +} + +/****************************************************************************\ +* Methods +\****************************************************************************/ + +extern byte *GlobalAlloc(uint16 flags, int size); + +extern void *GlobalLock(HGLOBAL h); + +extern void GlobalUnlock(HGLOBAL h); + +extern void GlobalFree(HGLOBAL h); + +extern void MessageBox(const Common::String &msg); + +extern uint32 timeGetTime(); + +#define INFINITE 0xffffffff +#define WAIT_OBJECT_0 -2 +// Horrendously bad cast +#define INVALID_HANDLE_VALUE (void *)-3 + +extern HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, + uint32 dwCreationFlags, uint32 *lpThreadId); + +extern void ExitThread(int ThreadId); + +extern void TerminateThread(HANDLE ThreadId, uint32 dwExitCode); + +extern void CloseHandle(HANDLE ThreadId); + +extern void Sleep(uint32 time); + +extern int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime); + +extern uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds); + +extern HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName); + +extern void SetEvent(HANDLE hEvent); + +extern void ResetEvent(HANDLE hEvent); + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 523147c848..2d4385a5e6 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -20,20 +20,63 @@ * */ +#include "common/scummsys.h" +#include "common/algorithm.h" +#include "common/file.h" #include "tony/tony.h" +#include "tony/mpal/mpal.h" namespace Tony { TonyEngine *_vm; -TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), + _gameDescription(gameDesc), _randomSource("tony") { + _vm = this; } TonyEngine::~TonyEngine() { } +/** + * Run the game + */ Common::Error TonyEngine::run() { + Common::ErrorCode result = Init(); + if (result != Common::kNoError) + return result; + + /* + Play(); + Close(); +*/ + return Common::kNoError; +} + +/** + * Initialise the game + */ +Common::ErrorCode TonyEngine::Init() { + // Initialise the function list + Common::fill(FuncList, FuncList + sizeof(FuncList), (LPCUSTOMFUNCTION)NULL); + + // Initializes MPAL system, passing the custom functions list + Common::File f; + if (!f.open("ROASTED.MPC")) + return Common::kReadingFailed; + f.close(); + + if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList)) + return Common::kUnknownError; + return Common::kNoError; } +/** + * Display an error message + */ +void TonyEngine::GUIError(const Common::String &msg) { + GUIErrorMessage(msg); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 5aa0de95a3..cfb6748716 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -26,11 +26,12 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/error.h" -#include "common/events.h" -#include "common/keyboard.h" +#include "common/random.h" #include "common/util.h" #include "engines/engine.h" +#include "tony/mpal.h" + /** * This is the namespace of the Tony engine. * @@ -41,6 +42,8 @@ */ namespace Tony { +using namespace MPAL; + enum { kTonyDebugAnimations = 1 << 0, kTonyDebugActions = 1 << 1, @@ -55,10 +58,15 @@ enum { struct TonyGameDescription; class TonyEngine : public Engine { +private: + Common::ErrorCode Init(); protected: // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; +public: + LPCUSTOMFUNCTION FuncList[300]; + Common::RandomSource _randomSource; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); @@ -70,6 +78,8 @@ public: uint16 getVersion() const; uint32 getFlags() const; Common::Platform getPlatform() const; + + void GUIError(const Common::String &msg); }; // Global reference to the TonyEngine object -- cgit v1.2.3 From f955745ebf9aba0525de8196dc90de99fce6eab3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Apr 2012 01:32:46 +1000 Subject: TONY: Extra compilation changes and stubs so core MPAL code compiles --- engines/tony/lzo/stubs.cpp | 41 +++ engines/tony/module.mk | 1 + engines/tony/mpal.h | 749 -------------------------------------------- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/mpal.cpp | 2 +- engines/tony/mpal/mpal.h | 12 +- engines/tony/mpal/stubs.cpp | 9 +- engines/tony/tony.h | 2 +- 8 files changed, 57 insertions(+), 761 deletions(-) create mode 100644 engines/tony/lzo/stubs.cpp delete mode 100644 engines/tony/mpal.h (limited to 'engines') diff --git a/engines/tony/lzo/stubs.cpp b/engines/tony/lzo/stubs.cpp new file mode 100644 index 0000000000..4a27f8cc18 --- /dev/null +++ b/engines/tony/lzo/stubs.cpp @@ -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 contains temporary stubs for LZO functions +\****************************************************************************/ + +#include "lzo1x.h" + +namespace Tony { + +namespace LZO { + +int lzo1x_decompress( const lzo_byte *src, lzo_uint src_len, lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ) { + return 0; +} + +} // end of namespace LZO + +} // end of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk index d592fac68b..1b67312d39 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,6 +3,7 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ + lzo\stubs.o \ mpal\expr.o \ mpal\loadmpc.o \ mpal\mpal.o \ diff --git a/engines/tony/mpal.h b/engines/tony/mpal.h deleted file mode 100644 index 0c15ef5b50..0000000000 --- a/engines/tony/mpal.h +++ /dev/null @@ -1,749 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * - */ - -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPAL Main Include file. * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Main Include file for * - * 4> ^R$oue# d using MPAL.DLL......... * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ - - -/****************************************************************************\ -* Copyright Notice -\****************************************************************************/ - -/* - * A Spyral Software Production: - * - * MPAL - MultiPurpose Adventure Language - * (C) 1997 Giovanni Bajo and Luca Giusti - * ALL RIGHTS RESERVED - * - * - */ - - -/****************************************************************************\ -* General Introduction -\****************************************************************************/ - -/* - * MPAL (MultiPurpose Adventure Language) is a high level language - * for the definition of adventure. Through the use of MPAL you can describe - * storyboard the adventure, and then use it with any user interface. - * In fact, unlike many other similar products, MPAL is not programmed through - * the whole adventure, but are defined only the locations, objects, as they may - * interact with each other, etc.. thus making MPAL useful for any type of adventure. - */ - -/****************************************************************************\ -* Structure -\****************************************************************************/ - -/* - * MPAL consists of two main files: MPAL.DLL and MPAL.H - * The first is the DLL that contains the code to interface with MPAL - * adventures, the second is the header that defines the prototypes - * functions. MPAL is compiled for Win32, and it can therefore be used with - * any compiler that supports Win32 DLL (Watcom C++, Visual C++, - * Delphi, etc.), and therefore compatible with both Windows 95 and Windows NT. - * - * To use the DLL, and 'obviously need to create a library for symbols to export. - * - */ - - -/****************************************************************************\ -* Custom Functions -\****************************************************************************/ - -/* - * A custom function and a function specified by the program that uses the - * library, to perform the particular code. The custom functions are - * retrieved from the library as specified in the source MPAL, and in particular - * in defining the behavior of an item with some action. - * - * To use the custom functions, you need to prepare an array of - * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, - * (defined below), and pass it as second parameter to mpalInit (). Note you - * must specify the size of the array, as elements of pointers and which do not - * contain the same: the library will call it only those functions specified in - * the source MPAL. It can be useful, for debugging reasons, do not bet - * the shares of arrays used to debugging function, to avoid unpleasant crash, - * if it has been made an error in source and / or some oversight in the code. - * - */ - -#ifndef __MPAL_H -#define __MPAL_H - -#include "common/rect.h" - -namespace Tony { - -namespace MPAL { - -/****************************************************************************\ -* Macro definitions and structures -\****************************************************************************/ - -/* OK value for the error codes */ -#define OK 0 - -#define MAXFRAMES 400 // frame animation of an object -#define MAXPATTERN 40 // pattern of animation of an object - -#define MAXPOLLINGLOCATIONS 64 - -#define EXPORT -#define LPSTR char * - -/****************************************************************************\ -* enum QueryCoordinates -* --------------------- -* Description: Macro for use with queries that may refer to X and Y co-ordinates -\****************************************************************************/ - -enum QueryCoordinates { - MPQ_X, - MPQ_Y -}; - - -/****************************************************************************\ -* enum QueryTypes -* --------------- -* Description: Query can be used with mpalQuery (). In practice corresponds -* all claims that can do at the library -\****************************************************************************/ - -enum QueryTypes { - /* General Query */ - MPQ_VERSION=10, - - MPQ_GLOBAL_VAR=50, - MPQ_RESOURCE, - MPQ_MESSAGE, - - /* Query on leases */ - MPQ_LOCATION_IMAGE=100, - MPQ_LOCATION_SIZE, - - /* Queries about items */ - MPQ_ITEM_LIST=200, - MPQ_ITEM_DATA, - MPQ_ITEM_PATTERN, - MPQ_ITEM_NAME, - MPQ_ITEM_IS_ACTIVE, - - /* Query dialog */ - MPQ_DIALOG_PERIOD=300, - MPQ_DIALOG_WAITFORCHOICE, - MPQ_DIALOG_SELECTLIST, - MPQ_DIALOG_SELECTION, - - /* Query execution */ - MPQ_DO_ACTION=400, - MPQ_DO_DIALOG -}; - - -/****************************************************************************\ -* typedef ITEM -* ------------ -* Description: Framework to manage the animation of an item -\****************************************************************************/ - -typedef struct { - char *frames[MAXFRAMES]; - Common::Rect frameslocations[MAXFRAMES]; - Common::Rect bbox[MAXFRAMES]; - short pattern[MAXPATTERN][MAXFRAMES]; - short speed; - uint8 numframe; - uint8 numpattern; - uint8 curframe; - uint8 curpattern; - short destX, destY; - signed char Zvalue; - short objectID; - char TAG; -} ITEM; -typedef ITEM *LPITEM; - - -/****************************************************************************\ -* typedef LPCUSTOMFUNCTION -* ------------------------ -* Description: Define a custom function, to use the language MPAL -* to perform various controls as a result of an action -\****************************************************************************/ - -typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); -typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; - - -/****************************************************************************\ -* typedef LPITEMIRQFUNCTION -* ------------------------- -* Description: Define an IRQ of an item that is called when the -* pattern changes or the status of an item -\****************************************************************************/ - -typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); -typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; - - -/****************************************************************************\ -* Macrofunctions query -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: uint32 mpalQueryVersion(void); -* -* Description: Gets the current version of MPAL -* -* Return: Version number (0x1232 = 1.2.3b) -* -\****************************************************************************/ - -#define mpalQueryVersion() \ - (uint16)mpalQuery(MPQ_VERSION) - - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); -* -* Description: Gets the numerical value of a global variable -* -* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) -* -* Return: Valore della variabile -* -* Note: This query was implemented for debugging. The program, -* if well designed, should not need to access variables from -* within the library. -* -\****************************************************************************/ - -#define mpalQueryGlobalVar(lpszVarName) \ - (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) - - - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryResource(uint32 dwResId); -* -* Description: Provides access to a resource inside the .MPC file -* -* Input: uint32 dwResId ID della risorsa -* -* Return: Handle to a memory area containing the resource, -* ready for use. -* -\****************************************************************************/ - -#define mpalQueryResource(dwResId) \ - (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) - - - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryMessage(uint32 nMsg); -* -* Description: Returns a message. -* -* Input: uint32 nMsg Message number -* -* Return: ASCIIZ message -* -* Note: The returned pointer must be freed with GlobalFree() -* after use. The message will be in ASCIIZ format. -* -\****************************************************************************/ - -#define mpalQueryMessage(nMsg) \ - (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) - - - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); -* -* Description: Provides a image image -* -* Input: uint32 nLoc Locazion number -* -* Return: Returns a picture handle -* -\****************************************************************************/ - -#define mpalQueryLocationImage(nLoc) \ - (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) - - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); -* -* Description: Request the x or y size of a location in pixels -* -* Input: uint32 nLoc Location number -* uint32 dwCoord MPQ_Xr o MPQ_Y -* -* Return: Size -* -\****************************************************************************/ - -#define mpalQueryLocationSize(nLoc,dwCoord) \ - (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) - - - -/****************************************************************************\ -* -* Function: LPuint32 mpalQueryItemList(uint32 nLoc); -* -* Description: Provides the list of objects in the lease. -* -* Input: uint32 nLoc Location number -* -* Return: List of objects (accessible by Item [0], Item [1], etc.) -* -\****************************************************************************/ - -#define mpalQueryItemList(nLoc) \ - (LPuint32)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) - - - -/****************************************************************************\ -* -* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); -* -* Description: Provides information on an item -*e -* Input: uint32 nItem Item number -* -* Return: structure filled with requested information -* -\****************************************************************************/ - -#define mpalQueryItemData(nItem) \ - (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) - - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryItemPattern(uint32 nItem); -* -* Description: Provides the current pattern of an item -* -* Input: uint32 nItem Item number -* -* Return: Number of animation patterns to be executed. -* -* Note: By default, the pattern of 0 indicates that we should -* do nothing. -* -\****************************************************************************/ - -#define mpalQueryItemPattern(nItem) \ - (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) - - - -/****************************************************************************\ -* -* Function: bool mpalQueryItemIsActive(uint32 nItem); -* -* Description: Returns true if an item is active -* -* Input: uint32 nItem Item number -* -* Return: TRUE if the item is active, FALSE otherwise -* -\****************************************************************************/ - -#define mpalQueryItemIsActive(nItem) \ - (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) - - -/****************************************************************************\ -* -* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); -* -* Description: Returns the name of an item -* -* Input: uint32 nItem Item number -* LPSTR lpszName Pointer to a buffer of at least 33 bytes -* that will be filled with the name -* -* Note: If the item is not active (ie. if its status or number -* is less than or equal to 0), the string will be empty. -* -\****************************************************************************/ - -#define mpalQueryItemName(nItem,lpszName) \ - (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) - - - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); -* -* Description: Returns a sentence of dialog. -* -* Input: uint32 nDialog Dialog number -* uint32 nPeriod Number of words -* -* Return: A pointer to the string of words, or NULL on failure. -* -* Note: The string must be freed after use by GlobalFree (). -* -* Unlike normal messages, the sentences of dialogue -* are formed by a single string terminated with 0. -* -\****************************************************************************/ - -#define mpalQueryDialogPeriod(nPeriod) \ - (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) - - - -/****************************************************************************\ -* -* Function: int mpalQueryDialogWaitForChoice(void); -* -* Description: Wait until the moment in which the need is signaled -* to make a choice by the user. -* -* Return: Number of choice to be made, or -1 if the dialogue is finished. -* -\****************************************************************************/ - -#define mpalQueryDialogWaitForChoice() \ - (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) - - - -/****************************************************************************\ -* -* Function: LPuint32 mpalQueryDialogSelectList(uint32 nChoice); -* -* Description: Requires a list of various options for some choice within -* the current dialog. - -* Input: uint32 nChoice Choice number -* -* Return: A pointer to an array containing the data matched to each option. -* -* Note: The figure 'a uint32 specified in the source to which MPAL -* You can 'assign meaning that the more' suits. -* -* The pointer msut be freed after use by GlobalFree(). -* -\****************************************************************************/ - -#define mpalQueryDialogSelectList(nChoice) \ - (LPuint32)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) - - - -/****************************************************************************\ -* -* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); -* -* Description: Warns the library that the user has selected, in a certain -* choice of the current dialog, corresponding option -* at a certain given. -* -* Input: uint32 nChoice Choice number of the choice that -* was in progress -* uint32 dwData Option that was selected by the user. -* -* Return: TRUE if all OK, FALSE on failure. -* -* Note: After execution of this query, MPAL continue -* Groups according to the execution of the dialogue. And necessary so the game -* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). -* -\****************************************************************************/ - -#define mpalQueryDialogSelection(nChoice,dwData) \ - (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) - - - -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, -* uint32 dwParam); -* -* Description: Warns the library an action was performed on a Object. -* The library will call 'custom functions, if necessary. -* -* Input: uint32 nAction Action number -* uint32 nItem Item number -* uint32 dwParam Action parameter -* -* Return: Handle to the thread that is performing the action, or -* INVALID_HANDLE_VALUE if the action is not 'defined for -* the item, or the item and 'off. -* -* Note: The parameter is used primarily to implement actions -* as "U.S." involving two objects together. The action will be executed only -* if the item is active, ie if its status is a positive number greater than 0. -* -\****************************************************************************/ - -#define mpalQueryDoAction(nAction,nItem,dwParam) \ - (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) - - - -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); -* -* Description: Warns the library a dialogue was required. -* -* Input: uint32 nDialog Dialog number -* uint32 nGroup Group number to use -* -* Return: Handle to the thread that is running the box, or -* INVALID_HANDLE_VALUE if the dialogue does not exist. -* -\****************************************************************************/ - -#define mpalQueryDoDialog(nDialog,nGroup) \ - (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) - - - -/****************************************************************************\ -* MPAL Interface Functions -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, -* LPLPCUSTOMFUNCTION lplpcfArray); -* -* Description: Initializes the MPAL library, and opens an .MPC file, which -* will be 'used for all queries -* -* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension -* LPSTR lpszMprFileName Name of the .MPR file, including extension -* LPLPCUSTOMFUNCTION Array of pointers to custom functions -* -* Return: TRUE if all OK, FALSE on failure -* -\****************************************************************************/ - -bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, - LPLPCUSTOMFUNCTION lplpcfArray); - - - -/****************************************************************************\ -* -* Function: uint32 mpalQuery(uint16 wQueryType, ...); -* -* Description: This is the general function to communicate with the library, -* To request information about what is in the .MPC file -* -* Input: uint16 wQueryType Type of query. The list is in -* the QueryTypes enum. -* -* Return: 4 bytes depending on the type of query -* -* Note: I _strongly_ recommended to use macros defined above to use -* the query, since it helps avoid any unpleasant bugs due to -* forgeting parameters. -* -\****************************************************************************/ - -uint32 EXPORT mpalQuery(uint16 wQueryType, ...); - - - -/****************************************************************************\ -* -* Function: bool mpalExecuteScript(int nScript); -* -* Description: Execute a script. The script runs on multitasking by a thread. -* -* Input: int nScript Script number to run -* -* Return: TRUE if the script 'was launched, FALSE on failure -* -\****************************************************************************/ - -bool EXPORT mpalExecuteScript(int nScript); - - - -/****************************************************************************\ -* -* Function: uint32 mpalGetError(void); -* -* Description: Returns the current MPAL error code -* -* Return: Error code -* -\****************************************************************************/ - -uint32 EXPORT mpalGetError(void); - - - -/****************************************************************************\ -* -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); -* -* Description: Install a custom routine That will be called by MPAL -* every time the pattern of an item has-been changed. -* -* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install -* -\****************************************************************************/ - -void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); - - -/****************************************************************************\ -* -* Function: bool mpalStartIdlePoll(int nLoc); -* -* Description: Process the idle actions of the items on one location. -* -* Input: int nLoc Number of the location whose items -* must be processed for idle actions. -* -* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. -* -* Note: The maximum number of locations that can be polled -* simultaneously is defined defined by MAXPOLLINGFUNCIONS -* -\****************************************************************************/ - -bool EXPORT mpalStartIdlePoll(int nLoc); - - -/****************************************************************************\ -* -* Function: bool mpalEndIdlePoll(int nLoc); -* -* Description: Stop processing the idle actions of the items on one location. -* -* Input: int nLoc Number of the location -* -* Return: TRUE if all OK, FALSE if the specified location was not -* in the process of polling -* -\****************************************************************************/ - -bool EXPORT mpalEndIdlePoll(int nLoc); - - - -/****************************************************************************\ -* -* Function: int mpalLoadState(LPBYTE buf); -* -* Description: Load a save state from a buffer. -* -* Input: LPBYTE buf Buffer where to store the state -* -* Return: Length of the state in bytes -* -\****************************************************************************/ - -int EXPORT mpalLoadState(byte *buf); - - - -/****************************************************************************\ -* -* Function: void mpalSaveState(LPBYTE buf); -* -* Description: Store the save state into a buffer. The buffer must be -* length at least the size specified with mpalGetSaveStateSize -* -* Input: LPBYTE buf Buffer where to store the state -* -\****************************************************************************/ - -void EXPORT mpalSaveState(byte *buf); - - - -/****************************************************************************\ -* -* Function: int mpalGetSaveStateSize(void); -* -* Description: Acquire the length of a save state -* -* Return: Length in bytes -* -\****************************************************************************/ - -int EXPORT mpalGetSaveStateSize(void); - -} // end of namespace MPAL - -} // end of namespace - -#endif - diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 8763fbf95b..fc03e43b40 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -72,7 +72,7 @@ namespace MPAL { * \****************************************************************************/ -bool ParseMpc(const byte *lpBuf); +bool ParseMpc(byte *lpBuf); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 2fd9f3b9c3..f068f0fabf 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -153,7 +153,7 @@ uint32 nSelectedChoice; /****************************************************************************\ -* Static functions +* Internal functions \****************************************************************************/ /****************************************************************************\ diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 73e2dec50f..70b49a1fd9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -114,12 +114,16 @@ * */ -#ifndef __MPAL_H -#define __MPAL_H +#ifndef TONY_MPAL_H +#define TONY_MPAL_H #include "common/scummsys.h" #include "common/rect.h" +namespace Tony { + +namespace MPAL { + /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ @@ -765,5 +769,9 @@ extern void LockVar(void); extern void UnlockVar(void); +} // end of namespace MPAL + +} // end of namespace Tony + #endif diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 342678b856..c25dd2ab43 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -1,4 +1,4 @@ -e/* ScummVM - Graphic Adventure Engine +/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT @@ -21,9 +21,6 @@ e/* ScummVM - Graphic Adventure Engine * */ -#ifndef TONY_MPAL_STUBS -#define TONY_MPAL_STUBS - /****************************************************************************\ * This file contains stubs and mappings for things used by the MPAL * library that are handled differently under ScummVM @@ -101,7 +98,7 @@ HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, return 0; } -void ExitThread(HANDLE ThreadId) { +void ExitThread(int ThreadId) { } void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { @@ -136,5 +133,3 @@ void ResetEvent(HANDLE hEvent) { } // end of namespace MPAL } // end of namespace Tony - -#endif diff --git a/engines/tony/tony.h b/engines/tony/tony.h index cfb6748716..804e489d82 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -30,7 +30,7 @@ #include "common/util.h" #include "engines/engine.h" -#include "tony/mpal.h" +#include "tony/mpal/mpal.h" /** * This is the namespace of the Tony engine. -- cgit v1.2.3 From f0d4b200d7b10a1f4a32e24459c9ed97e1484d2b Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Fri, 27 Apr 2012 00:35:53 +0200 Subject: TONY: Change backslash to slash I assume slash works in Windows (since we use it in other engines), and I know backslash doesn't work in Linux because it failed for me. --- engines/tony/module.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 1b67312d39..578f58090c 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,11 +3,11 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ - lzo\stubs.o \ - mpal\expr.o \ - mpal\loadmpc.o \ - mpal\mpal.o \ - mpal\stubs.o + lzo/stubs.o \ + mpal/expr.o \ + mpal/loadmpc.o \ + mpal/mpal.o \ + mpal/stubs.o # This module can be built as a plugin ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) -- cgit v1.2.3 From ff71cda42448efaa50f7e98473087fec9c8ddb8d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 09:14:45 +1000 Subject: TONY: Further work on LZO integration --- engines/tony/lzo/lzo1x.h | 198 ------------------ engines/tony/lzo/lzoconf.h | 398 ----------------------------------- engines/tony/lzo/stubs.cpp | 41 ---- engines/tony/module.mk | 1 + engines/tony/mpal/lzo.cpp | 509 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/mpal/lzo.h | 100 +++++++++ engines/tony/mpal/lzo1x.h | 188 ----------------- engines/tony/mpal/mpal.cpp | 14 +- engines/tony/tony.cpp | 2 +- 9 files changed, 617 insertions(+), 834 deletions(-) delete mode 100644 engines/tony/lzo/lzo1x.h delete mode 100644 engines/tony/lzo/lzoconf.h delete mode 100644 engines/tony/lzo/stubs.cpp create mode 100644 engines/tony/mpal/lzo.cpp create mode 100644 engines/tony/mpal/lzo.h delete mode 100644 engines/tony/mpal/lzo1x.h (limited to 'engines') diff --git a/engines/tony/lzo/lzo1x.h b/engines/tony/lzo/lzo1x.h deleted file mode 100644 index e481b33fa4..0000000000 --- a/engines/tony/lzo/lzo1x.h +++ /dev/null @@ -1,198 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ -/* lzo1x.h -- public interface of the LZO1X compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - - http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html - */ - - -#ifndef __LZO1X_H -#define __LZO1X_H - -#ifndef __LZOCONF_H -#include "lzoconf.h" -#endif - -namespace Tony { - -namespace LZO { - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_MEM_DECOMPRESS (0) -#define LZO1X_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// special compressor versions -************************************************************************/ - -/* this version needs only 8 kB work memory */ -#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* this version needs 16 kB work memory */ -#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* use this version if you need a little more compression speed */ -#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); -#endif - - -/*********************************************************************** -// -************************************************************************/ - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len, - lzo_progress_callback_t cb, - int compression_level ); -#endif - -LZO_EXTERN(int) -lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_byte *dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -} // End of namespace LZO - -} // End of namespace Tony - -#endif /* already included */ - diff --git a/engines/tony/lzo/lzoconf.h b/engines/tony/lzo/lzoconf.h deleted file mode 100644 index 9dfcfb0cbc..0000000000 --- a/engines/tony/lzo/lzoconf.h +++ /dev/null @@ -1,398 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ -/* lzoconf.h -- configuration for the LZO real-time data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - - http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html - */ - - -#ifndef __LZOCONF_H -#define __LZOCONF_H - -namespace Tony { - -namespace LZO { - -#define LZO_VERSION 0x1060 -#define LZO_VERSION_STRING "1.06" -#define LZO_VERSION_DATE "Nov 29 1999" - -/* internal Autoconf configuration file - only used when building LZO */ -#if defined(LZO_HAVE_CONFIG_H) -# include -#endif -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// LZO requires a conforming -************************************************************************/ - -#if !defined(CHAR_BIT) || (CHAR_BIT != 8) -# error "invalid CHAR_BIT" -#endif -#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -# error "check your compiler installation" -#endif -#if (USHRT_MAX < 1 ) || (UINT_MAX < 1) || (ULONG_MAX < 1) -# error "your limits.h macros are broken" -#endif - -/* workaround a cpp bug under hpux 10.20 */ -#define LZO_0xffffffffL 4294967295ul - - -/*********************************************************************** -// architecture defines -************************************************************************/ - -#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2) -# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# define __LZO_WIN -# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) -# define __LZO_WIN -# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) -# define __LZO_WIN -# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) -# define __LZO_DOS -# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) -# define __LZO_OS2 -# elif defined(__palmos__) -# define __LZO_PALMOS -# elif defined(__TOS__) || defined(__atarist__) -# define __LZO_TOS -# endif -#endif - -#if (UINT_MAX < LZO_0xffffffffL) -# if defined(__LZO_WIN) -# define __LZO_WIN16 -# elif defined(__LZO_DOS) -# define __LZO_DOS16 -# elif defined(__LZO_PALMOS) -# define __LZO_PALMOS16 -# elif defined(__LZO_TOS) -# define __LZO_TOS16 -# elif defined(__C166__) -# else -# error "16-bit target not supported - contact me for porting hints" -# endif -#endif - -#if !defined(__LZO_i386) -# if defined(__LZO_DOS) || defined(__LZO_WIN16) -# define __LZO_i386 -# elif defined(__i386__) || defined(__386__) || defined(_M_IX86) -# define __LZO_i386 -# endif -#endif - -#if defined(__LZO_STRICT_16BIT) -# if (UINT_MAX < LZO_0xffffffffL) -# include -# endif -#endif - - -/*********************************************************************** -// integral and pointer types -************************************************************************/ - -/* Integral types with 32 bits or more */ -#if !defined(LZO_UINT32_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint32; - typedef int lzo_int32; -# define LZO_UINT32_MAX UINT_MAX -# define LZO_INT32_MAX INT_MAX -# define LZO_INT32_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint32; - typedef long lzo_int32; -# define LZO_UINT32_MAX ULONG_MAX -# define LZO_INT32_MAX LONG_MAX -# define LZO_INT32_MIN LONG_MIN -# else -# error "lzo_uint32" -# endif -#endif - -/* lzo_uint is used like size_t */ -#if !defined(LZO_UINT_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint; - typedef int lzo_int; -# define LZO_UINT_MAX UINT_MAX -# define LZO_INT_MAX INT_MAX -# define LZO_INT_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -# define LZO_UINT_MAX ULONG_MAX -# define LZO_INT_MAX LONG_MAX -# define LZO_INT_MIN LONG_MIN -# else -# error "lzo_uint" -# endif -#endif - - -/* Memory model that allows to access memory at offsets of lzo_uint. */ -#if !defined(__LZO_MMODEL) -# if (LZO_UINT_MAX <= UINT_MAX) -# define __LZO_MMODEL -# elif defined(__LZO_DOS16) || defined(__LZO_WIN16) -# define __LZO_MMODEL __huge -# define LZO_999_UNSUPPORTED -# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16) -# define __LZO_MMODEL -# else -# error "__LZO_MMODEL" -# endif -#endif - -/* no typedef here because of const-pointer issues */ -#define lzo_byte unsigned char __LZO_MMODEL -#define lzo_bytep unsigned char __LZO_MMODEL * -#define lzo_charp char __LZO_MMODEL * -#define lzo_voidp void __LZO_MMODEL * -#define lzo_shortp short __LZO_MMODEL * -#define lzo_ushortp unsigned short __LZO_MMODEL * -#define lzo_uint32p lzo_uint32 __LZO_MMODEL * -#define lzo_int32p lzo_int32 __LZO_MMODEL * -#define lzo_uintp lzo_uint __LZO_MMODEL * -#define lzo_intp lzo_int __LZO_MMODEL * -#define lzo_voidpp lzo_voidp __LZO_MMODEL * -#define lzo_bytepp lzo_bytep __LZO_MMODEL * - -typedef int lzo_bool; - -#ifndef lzo_sizeof_dict_t -# define lzo_sizeof_dict_t sizeof(lzo_bytep) -#endif - - -/*********************************************************************** -// function types -************************************************************************/ - -/* linkage */ -#if !defined(__LZO_EXTERN_C) -# ifdef __cplusplus -# define __LZO_EXTERN_C extern "C" -# else -# define __LZO_EXTERN_C extern -# endif -#endif - -/* calling conventions */ -#if !defined(__LZO_CDECL) -# if defined(__LZO_DOS16) || defined(__LZO_WIN16) -# define __LZO_CDECL __far __cdecl -# elif defined(__LZO_i386) && defined(_MSC_VER) -# define __LZO_CDECL __cdecl -# elif defined(__LZO_i386) && defined(__WATCOMC__) -# define __LZO_CDECL __near __cdecl -# else -# define __LZO_CDECL -# endif -#endif -#if !defined(__LZO_ENTRY) -# define __LZO_ENTRY __LZO_CDECL -#endif - -/* DLL export information */ -#if !defined(__LZO_EXPORT1) -# define __LZO_EXPORT1 -#endif -#if !defined(__LZO_EXPORT2) -# define __LZO_EXPORT2 -#endif - -/* calling convention for C functions */ -#if !defined(LZO_PUBLIC) -# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY -#endif -#if !defined(LZO_EXTERN) -# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) -#endif -#if !defined(LZO_PRIVATE) -# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY -#endif - -/* cdecl calling convention for assembler functions */ -#if !defined(LZO_PUBLIC_CDECL) -# define LZO_PUBLIC_CDECL(_rettype) \ - __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL -#endif -#if !defined(LZO_EXTERN_CDECL) -# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype) -#endif - - -typedef int -(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - -typedef int -(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - - -/* a progress indicator callback function */ -typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint); - - -/*********************************************************************** -// error codes and prototypes -************************************************************************/ - -/* Error codes for the compression/decompression functions. Negative - * values are errors, positive values will be used for special but - * normal events. - */ -#define LZO_E_OK 0 -#define LZO_E_ERROR (-1) -#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */ -#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */ -#define LZO_E_INPUT_OVERRUN (-4) -#define LZO_E_OUTPUT_OVERRUN (-5) -#define LZO_E_LOOKBEHIND_OVERRUN (-6) -#define LZO_E_EOF_NOT_FOUND (-7) -#define LZO_E_INPUT_NOT_CONSUMED (-8) - - -/* lzo_init() should be the first function you call. - * Check the return code ! - * - * lzo_init() is a macro to allow checking that the library and the - * compiler's view of various types are consistent. - */ -#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ - (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_compress_t)) -LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int); - -/* version functions (useful for shared libraries) */ -LZO_EXTERN(unsigned) lzo_version(void); -LZO_EXTERN(const char *) lzo_version_string(void); -LZO_EXTERN(const char *) lzo_version_date(void); -LZO_EXTERN(const lzo_charp) _lzo_version_string(void); -LZO_EXTERN(const lzo_charp) _lzo_version_date(void); - -/* string functions */ -LZO_EXTERN(int) -lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); -LZO_EXTERN(lzo_voidp) -lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); -LZO_EXTERN(lzo_voidp) -lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); -LZO_EXTERN(lzo_voidp) -lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); - -/* checksum functions */ -LZO_EXTERN(lzo_uint32) -lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len); -LZO_EXTERN(lzo_uint32) -lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len); - -/* memory allocation functions */ -LZO_EXTERN(lzo_bytep) lzo_alloc(lzo_uint _nelems, lzo_uint _size); -LZO_EXTERN(lzo_bytep) lzo_malloc(lzo_uint _size); -LZO_EXTERN(void) lzo_free(lzo_voidp _ptr); - -extern lzo_bytep (__LZO_ENTRY *lzo_alloc_hook) (lzo_uint,lzo_uint); -extern void (__LZO_ENTRY *lzo_free_hook) (lzo_voidp); - -/* misc. */ -LZO_EXTERN(lzo_bool) lzo_assert(int _expr); -LZO_EXTERN(int) _lzo_config_check(void); -typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; -typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; - -/* align a char pointer on a boundary that is a multiple of `size' */ -LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); -#define LZO_PTR_ALIGN_UP(_ptr,_size) \ - ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) - -/* deprecated - only for backward compatibility */ -#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -} // end of namespace MPAL - -} // end of namespace Tony - -#endif /* already included */ - diff --git a/engines/tony/lzo/stubs.cpp b/engines/tony/lzo/stubs.cpp deleted file mode 100644 index 4a27f8cc18..0000000000 --- a/engines/tony/lzo/stubs.cpp +++ /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 contains temporary stubs for LZO functions -\****************************************************************************/ - -#include "lzo1x.h" - -namespace Tony { - -namespace LZO { - -int lzo1x_decompress( const lzo_byte *src, lzo_uint src_len, lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ) { - return 0; -} - -} // end of namespace LZO - -} // end of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 578f58090c..ba32a97e56 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ mpal/expr.o \ mpal/loadmpc.o \ mpal/mpal.o \ + mpal/lzo.o \ mpal/stubs.o # This module can be built as a plugin diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp new file mode 100644 index 0000000000..5f4b2d40f1 --- /dev/null +++ b/engines/tony/mpal/lzo.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. + * + * + */ +/* minilzo.c -- mini subset of the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Markus F.X.J. Oberhumer + + http://www.oberhumer.com/opensource/lzo/ + */ + +#include "lzo.h" + +namespace Tony { + +namespace MPAL { + +#define pd(a,b) ((uint32) ((a)-(b))) + +#define TEST_IP (ip < ip_end) +#define TEST_OP 1 +#define NEED_IP(x) ((void) 0) +#define NEED_OP(x) ((void) 0) +#define TEST_LB(m_pos) ((void) 0) + +#define M2_MAX_OFFSET 0x0800 + +/** + * Decompresses an LZO compressed resource + */ +int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) { + register byte *op; + register const byte *ip; + register uint32 t = 0; +#if defined(COPY_DICT) + uint32 m_off; + const byte *dict_end; +#else + register const byte *m_pos; +#endif + + const byte * const ip_end = in + in_len; +#if defined(HAVE_ANY_OP) + byte * const op_end = out + *out_len; +#endif +#if defined(LZO1Z) + uint32 last_m_off = 0; +#endif + +#if defined(COPY_DICT) + if (dict) + { + if (dict_len > M4_MAX_OFFSET) + { + dict += dict_len - M4_MAX_OFFSET; + dict_len = M4_MAX_OFFSET; + } + dict_end = dict + dict_len; + } + else + { + dict_len = 0; + dict_end = NULL; + } +#endif + + *out_len = 0; + + op = out; + ip = in; + + if (*ip > 17) + { + t = *ip++ - 17; + if (t < 4) + goto match_next; + assert(t > 0); NEED_OP(t); NEED_IP(t+1); + do *op++ = *ip++; while (--t > 0); + goto first_literal_run; + } + + while (TEST_IP && TEST_OP) + { + t = *ip++; + if (t >= 16) + goto match; + if (t == 0) + { + NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; + NEED_IP(1); + } + t += 15 + *ip++; + } + assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); +#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) + t += 3; + if (t >= 8) do + { + UA_COPY64(op,ip); + op += 8; ip += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { + UA_COPY32(op,ip); + op += 4; ip += 4; t -= 4; + } + if (t > 0) + { + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + } +#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +#if !defined(LZO_UNALIGNED_OK_4) + if (PTR_ALIGNED2_4(op,ip)) + { +#endif + UA_COPY32(op,ip); + op += 4; ip += 4; + if (--t > 0) + { + if (t >= 4) + { + do { + UA_COPY32(op,ip); + op += 4; ip += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *ip++; while (--t > 0); + } + else + do *op++ = *ip++; while (--t > 0); + } +#if !defined(LZO_UNALIGNED_OK_4) + } + else +#endif +#endif +#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) + { + *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; + do *op++ = *ip++; while (--t > 0); + } +#endif + +first_literal_run: + + t = *ip++; + if (t >= 16) + goto match; +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); + last_m_off = m_off; +#else + m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); +#endif + NEED_OP(3); + t = 3; COPY_DICT(t,m_off) +#else +#if defined(LZO1Z) + t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); + m_pos = op - t; + last_m_off = t; +#else + m_pos = op - (1 + M2_MAX_OFFSET); + m_pos -= t >> 2; + m_pos -= *ip++ << 2; +#endif + TEST_LB(m_pos); NEED_OP(3); + *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; +#endif + goto match_done; + + do { +match: + if (t >= 64) + { +#if defined(COPY_DICT) +#if defined(LZO1X) + m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); + t = (t >> 5) - 1; +#elif defined(LZO1Y) + m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); + t = (t >> 4) - 3; +#elif defined(LZO1Z) + m_off = t & 0x1f; + if (m_off >= 0x1c) + m_off = last_m_off; + else + { + m_off = 1 + (m_off << 6) + (*ip++ >> 2); + last_m_off = m_off; + } + t = (t >> 5) - 1; +#endif +#else +#if defined(LZO1X) + m_pos = op - 1; + m_pos -= (t >> 2) & 7; + m_pos -= *ip++ << 3; + t = (t >> 5) - 1; +#elif defined(LZO1Y) + m_pos = op - 1; + m_pos -= (t >> 2) & 3; + m_pos -= *ip++ << 2; + t = (t >> 4) - 3; +#elif defined(LZO1Z) + { + uint32 off = t & 0x1f; + m_pos = op; + if (off >= 0x1c) + { + assert(last_m_off > 0); + m_pos -= last_m_off; + } + else + { + off = 1 + (off << 6) + (*ip++ >> 2); + m_pos -= off; + last_m_off = off; + } + } + t = (t >> 5) - 1; +#endif + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); + goto copy_match; +#endif + } + else if (t >= 32) + { + t &= 31; + if (t == 0) + { + NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; + NEED_IP(1); + } + t += 31 + *ip++; + } +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); + last_m_off = m_off; +#else + m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); +#endif +#else +#if defined(LZO1Z) + { + uint32 off = 1 + (ip[0] << 6) + (ip[1] >> 2); + m_pos = op - off; + last_m_off = off; + } +#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) + m_pos = op - 1; + m_pos -= UA_GET16(ip) >> 2; +#else + m_pos = op - 1; + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +#endif +#endif + ip += 2; + } + else if (t >= 16) + { +#if defined(COPY_DICT) + m_off = (t & 8) << 11; +#else + m_pos = op; + m_pos -= (t & 8) << 11; +#endif + t &= 7; + if (t == 0) + { + NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; + NEED_IP(1); + } + t += 7 + *ip++; + } +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off += (ip[0] << 6) + (ip[1] >> 2); +#else + m_off += (ip[0] >> 2) + (ip[1] << 6); +#endif + ip += 2; + if (m_off == 0) + goto eof_found; + m_off += 0x4000; +#if defined(LZO1Z) + last_m_off = m_off; +#endif +#else +#if defined(LZO1Z) + m_pos -= (ip[0] << 6) + (ip[1] >> 2); +#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) + m_pos -= UA_GET16(ip) >> 2; +#else + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +#endif + ip += 2; + if (m_pos == op) + goto eof_found; + m_pos -= 0x4000; +#if defined(LZO1Z) + last_m_off = pd((const byte *)op, m_pos); +#endif +#endif + } + else + { +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off = 1 + (t << 6) + (*ip++ >> 2); + last_m_off = m_off; +#else + m_off = 1 + (t >> 2) + (*ip++ << 2); +#endif + NEED_OP(2); + t = 2; COPY_DICT(t,m_off) +#else +#if defined(LZO1Z) + t = 1 + (t << 6) + (*ip++ >> 2); + m_pos = op - t; + last_m_off = t; +#else + m_pos = op - 1; + m_pos -= t >> 2; + m_pos -= *ip++ << 2; +#endif + TEST_LB(m_pos); NEED_OP(2); + *op++ = *m_pos++; *op++ = *m_pos; +#endif + goto match_done; + } + +#if defined(COPY_DICT) + + NEED_OP(t+3-1); + t += 3-1; COPY_DICT(t,m_off) + +#else + + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); +#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) + if (op - m_pos >= 8) + { + t += (3 - 1); + if (t >= 8) do + { + UA_COPY64(op,m_pos); + op += 8; m_pos += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { + UA_COPY32(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } + if (t > 0) + { + *op++ = m_pos[0]; + if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } } + } + } + else +#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +#if !defined(LZO_UNALIGNED_OK_4) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + { + assert((op - m_pos) >= 4); +#else + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) + { +#endif + UA_COPY32(op,m_pos); + op += 4; m_pos += 4; t -= 4 - (3 - 1); + do { + UA_COPY32(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *m_pos++; while (--t > 0); + } + else +#endif + { +copy_match: + *op++ = *m_pos++; *op++ = *m_pos++; + do *op++ = *m_pos++; while (--t > 0); + } + +#endif + +match_done: +#if defined(LZO1Z) + t = ip[-1] & 3; +#else + t = ip[-2] & 3; +#endif + if (t == 0) + break; + +match_next: + assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); +#if 0 + do *op++ = *ip++; while (--t > 0); +#else + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } +#endif + t = *ip++; + } while (TEST_IP && TEST_OP); + } + +#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) + *out_len = pd(op, out); + return LZO_E_EOF_NOT_FOUND; +#endif + +eof_found: + assert(t == 1); + *out_len = pd(op, out); + return (ip == ip_end ? LZO_E_OK : + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); + +#if defined(HAVE_NEED_IP) +input_overrun: + *out_len = pd(op, out); + return LZO_E_INPUT_OVERRUN; +#endif + +#if defined(HAVE_NEED_OP) +output_overrun: + *out_len = pd(op, out); + return LZO_E_OUTPUT_OVERRUN; +#endif + +#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) +lookbehind_overrun: + *out_len = pd(op, out); + return LZO_E_LOOKBEHIND_OVERRUN; +#endif +} + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/lzo.h b/engines/tony/mpal/lzo.h new file mode 100644 index 0000000000..1d20c8e96e --- /dev/null +++ b/engines/tony/mpal/lzo.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. + * + * + */ +/* minilzo.c -- mini subset of the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Markus F.X.J. Oberhumer + + http://www.oberhumer.com/opensource/lzo/ + */ + +#ifndef TONY_MPAL_LZO_H +#define TONY_MPAL_LZO_H + +#include "common/scummsys.h" + +namespace Tony { + +namespace MPAL { + +/* Error codes for the compression/decompression functions. Negative + * values are errors, positive values will be used for special but + * normal events. + */ +#define LZO_E_OK 0 +#define LZO_E_ERROR (-1) +#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */ +#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ +#define LZO_E_INPUT_OVERRUN (-4) +#define LZO_E_OUTPUT_OVERRUN (-5) +#define LZO_E_LOOKBEHIND_OVERRUN (-6) +#define LZO_E_EOF_NOT_FOUND (-7) +#define LZO_E_INPUT_NOT_CONSUMED (-8) +#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ +#define LZO_E_INVALID_ARGUMENT (-10) + + +/** + * Decompresses an LZO compressed resource + */ +int lzo1x_decompress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len); + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif /* already included */ diff --git a/engines/tony/mpal/lzo1x.h b/engines/tony/mpal/lzo1x.h deleted file mode 100644 index 83b547428c..0000000000 --- a/engines/tony/mpal/lzo1x.h +++ /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. - * - * - */ -/* lzo1x.h -- public interface of the LZO1X compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - - http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html - */ - - -#ifndef __LZO1X_H -#define __LZO1X_H - -#ifndef __LZOCONF_H -#include "lzoconf.h" -#endif - -namespace Tony { - -namespace MPAL { - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_MEM_DECOMPRESS (0) -#define LZO1X_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// special compressor versions -************************************************************************/ - -/* this version needs only 8 kB work memory */ -#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* this version needs 16 kB work memory */ -#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* use this version if you need a little more compression speed */ -#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); -#endif - - -/*********************************************************************** -// -************************************************************************/ - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len, - lzo_progress_callback_t cb, - int compression_level ); -#endif - -LZO_EXTERN(int) -lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_byte *dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem ); - - -} // end of namespace MPAL - -} // end of namespace Tony - -#endif /* already included */ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index f068f0fabf..e07669849e 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -51,18 +51,16 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" +#include "tony/tony.h" +#include "lzo.h" #include "mpal.h" #include "mpaldll.h" #include "stubs.h" -#include "tony/tony.h" -#include "tony/lzo/lzo1x.h" namespace Tony { namespace MPAL { -using namespace Tony::LZO; - /****************************************************************************\ * Copyright \****************************************************************************/ @@ -653,7 +651,7 @@ HGLOBAL resLoad(uint32 dwId) { if (nBytesRead != nSizeComp) return NULL; - lzo1x_decompress(temp, nSizeComp, buf, (lzo_uint*)&nBytesRead, NULL); + lzo1x_decompress(temp, nSizeComp, buf, &nBytesRead); if (nBytesRead != nSizeDecomp) return NULL; @@ -1709,7 +1707,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION /* Se il file e' compresso, guarda quanto e' grande e alloca la memoria temporanea per la decompressione */ dwSizeComp = hMpc.readUint32LE(); - if (nBytesRead != 4) + if (hMpc.err()) return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); @@ -1721,7 +1719,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION return false; /* Decomprime l'immagine */ - lzo1x_decompress(cmpbuf,dwSizeComp,lpMpcImage,(lzo_uint*)&nBytesRead,NULL); + lzo1x_decompress(cmpbuf, dwSizeComp, lpMpcImage, &nBytesRead); if (nBytesRead != dwSizeDecomp) return false; @@ -1795,7 +1793,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION if (nBytesRead != dwSizeComp) return false; - lzo1x_decompress((byte *)cmpbuf,dwSizeComp,(byte *)lpResources, (uint32 *)&nBytesRead, NULL); + lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)lpResources, (uint32 *)&nBytesRead); if (nBytesRead != (uint32)nResources*8) return false; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2d4385a5e6..04e1a881ec 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -58,7 +58,7 @@ Common::Error TonyEngine::run() { */ Common::ErrorCode TonyEngine::Init() { // Initialise the function list - Common::fill(FuncList, FuncList + sizeof(FuncList), (LPCUSTOMFUNCTION)NULL); + Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); // Initializes MPAL system, passing the custom functions list Common::File f; -- cgit v1.2.3 From a2c4b4ca68aa15a763281ce7092178d78603d161 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 10:16:56 +1000 Subject: TONY: LZO decompression now working correctly --- engines/tony/mpal/lzo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 5f4b2d40f1..6cd755fc93 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -77,6 +77,7 @@ namespace MPAL { #define TEST_LB(m_pos) ((void) 0) #define M2_MAX_OFFSET 0x0800 +#define LZO1X /** * Decompresses an LZO compressed resource -- cgit v1.2.3 From 40680deaa5f94b1644cf277b8c9a89796a1ff815 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 10:49:14 +1000 Subject: TONY: Removed deprecated lzo/stubs.o from makefile --- engines/tony/module.mk | 1 - engines/tony/tony.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/module.mk b/engines/tony/module.mk index ba32a97e56..b4d0d7321d 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,7 +3,6 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ - lzo/stubs.o \ mpal/expr.o \ mpal/loadmpc.o \ mpal/mpal.o \ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 04e1a881ec..0708b45497 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -69,6 +69,9 @@ Common::ErrorCode TonyEngine::Init() { if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList)) return Common::kUnknownError; + // Initialise the update resources + _resUpdate.Init("ROASTED.MPU"); + return Common::kNoError; } -- cgit v1.2.3 From f21bfe1c41148368f30b0602a8e8820fbd543543 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 11:01:40 +1000 Subject: TONY: Added resource update manager --- engines/tony/module.mk | 1 + engines/tony/tony.h | 2 + engines/tony/utils.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/utils.h | 54 +++++++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 engines/tony/utils.cpp create mode 100644 engines/tony/utils.h (limited to 'engines') diff --git a/engines/tony/module.mk b/engines/tony/module.mk index b4d0d7321d..0ec4563207 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,6 +3,7 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ + utils.o \ mpal/expr.o \ mpal/loadmpc.o \ mpal/mpal.o \ diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 804e489d82..9bf5f4cb98 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -31,6 +31,7 @@ #include "engines/engine.h" #include "tony/mpal/mpal.h" +#include "tony/utils.h" /** * This is the namespace of the Tony engine. @@ -67,6 +68,7 @@ protected: public: LPCUSTOMFUNCTION FuncList[300]; Common::RandomSource _randomSource; + RMResUpdate _resUpdate; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp new file mode 100644 index 0000000000..1368111a05 --- /dev/null +++ b/engines/tony/utils.cpp @@ -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. + * + */ + +#include "tony/utils.h" +#include "mpal/lzo.h" + +namespace Tony { + +/****************************************************************************\ +* Resource Update +\****************************************************************************/ + +RMResUpdate::RMResUpdate() { + _infos = NULL; +} + +RMResUpdate::~RMResUpdate() { + if (_infos) { + delete[] _infos; + _infos = NULL; + } + + if (_hFile.isOpen()) + _hFile.close(); +} + +void RMResUpdate::Init(const Common::String &fileName) { + // Open the resource update file + if (!_hFile.open(fileName)) + // It doesn't exist, so exit immediately + return; + + uint8 version; + uint32 i; + + version = _hFile.readByte(); + _numUpd = _hFile.readUint32LE(); + + _infos = new ResUpdInfo[_numUpd]; + + // Load the index of the resources in the file + for (i=0; i<_numUpd; ++i) { + ResUpdInfo &info = _infos[i]; + + info.dwRes = _hFile.readUint32LE(); + info.offset = _hFile.readUint32LE(); + info.size = _hFile.readUint32LE(); + info.cmpSize = _hFile.readUint32LE(); + } +} + +const byte *RMResUpdate::QueryResource(uint32 dwRes) { + // If there isn't an update file, return NULL + if (!_hFile.isOpen()) + return NULL; + + uint32 i; + for (i=0; i < _numUpd; ++i) + if (_infos[i].dwRes == dwRes) + // Found the index + break; + + if (i==_numUpd) + // Couldn't find a matching resource, so return NULL + return NULL; + + const ResUpdInfo &info = _infos[i]; + byte *cmpBuf = new byte[info.cmpSize]; + uint32 dwRead; + + // Move to the correct offset and read in the compressed data + _hFile.seek(info.offset); + dwRead = _hFile.read(cmpBuf, info.cmpSize); + + if (info.cmpSize > dwRead) { + // Error occurred reading data, so return NULL + delete[] cmpBuf; + return NULL; + } + + // Allocate space for the output resource + byte *lpDestBuf = new byte[info.size]; + uint32 dwSize; + + // Decompress the data + MPAL::lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + + // Delete buffer for compressed data + delete [] cmpBuf; + + // Return the resource + return lpDestBuf; +} + +} // End of namespace Tony diff --git a/engines/tony/utils.h b/engines/tony/utils.h new file mode 100644 index 0000000000..b1afcca074 --- /dev/null +++ b/engines/tony/utils.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. + * + */ + +#ifndef TONY_UTILS_H +#define TONY_UTILS_H + +#include "common/scummsys.h" +#include "common/file.h" +#include "common/str.h" + +namespace Tony { + +class RMResUpdate { + struct ResUpdInfo { + uint32 dwRes; + uint32 offset; + uint32 size; + uint32 cmpSize; + }; + + uint32 _numUpd; + ResUpdInfo *_infos; + Common::File _hFile; + +public: + RMResUpdate(); + ~RMResUpdate(); + + void Init(const Common::String &fileName); + const byte *QueryResource(uint32 dwRes); +}; + +} // End of namespace Tony + +#endif /* TONY_H */ -- cgit v1.2.3 From dd89597f880b9119ef0174cf9c61e662c129e266 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 11:23:02 +1000 Subject: TONY: Added voice database initialisation, as well as stubs for music init --- engines/tony/tony.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/tony.h | 17 ++++++++++++ 2 files changed, 88 insertions(+) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 0708b45497..0eacbb5ff4 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "common/config-manager.h" #include "common/file.h" #include "tony/tony.h" #include "tony/mpal/mpal.h" @@ -36,6 +37,8 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng } TonyEngine::~TonyEngine() { + // Close the voice database + CloseVoiceDatabase(); } /** @@ -72,6 +75,12 @@ Common::ErrorCode TonyEngine::Init() { // Initialise the update resources _resUpdate.Init("ROASTED.MPU"); + // Initialise the music + InitMusic(); + + if (!OpenVoiceDatabase()) + return Common::kReadingFailed; + return Common::kNoError; } @@ -82,4 +91,66 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } +void TonyEngine::InitMusic() { + warning("TODO: TonyEngine::InitMusic"); +} + +void TonyEngine::CloseMusic() { + warning("TODO: TonyEngine::CloseMusic"); +} + +void TonyEngine::PauseSound(bool bPause) { +} + +void TonyEngine::SetMusicVolume(int nChannel, int volume) { +} + +int TonyEngine::GetMusicVolume(int nChannel) { + return 255; +} + +bool TonyEngine::OpenVoiceDatabase() { + char id[4]; + uint32 numfiles; + + // Add the voices folder to the search directory list + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "voices"); + + // Open the voices database + if (!_vdbFP.open("voices.vdb")) + return false; + + _vdbFP.seek(-8, SEEK_END); + numfiles = _vdbFP.readUint32LE(); + _vdbFP.read(id, 4); + + if (id[0] != 'V' || id[1] != 'D' || id[2] != 'B' || id[3] != '1') { + _vdbFP.close(); + return false; + } + + // Read in the index + _vdbFP.seek(-8 - (numfiles * VOICE_HEADER_SIZE), SEEK_END); + + for (uint32 i = 0; i < numfiles; ++i) { + VoiceHeader vh; + vh.offset = _vdbFP.readUint32LE(); + vh.code = _vdbFP.readUint32LE(); + vh.parts = _vdbFP.readUint32LE(); + + _voices.push_back(vh); + } + + return true; +} + +void TonyEngine::CloseVoiceDatabase() { + if (_vdbFP.isOpen()) + _vdbFP.close(); + + if (_voices.size() > 0) + _voices.clear(); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 9bf5f4cb98..77b1596112 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/system.h" +#include "common/array.h" #include "common/error.h" #include "common/random.h" #include "common/util.h" @@ -58,9 +59,23 @@ enum { struct TonyGameDescription; +struct VoiceHeader { + int offset; + int code; + int parts; +}; +#define VOICE_HEADER_SIZE 12 + class TonyEngine : public Engine { private: Common::ErrorCode Init(); + void InitMusic(); + void CloseMusic(); + void PauseSound(bool bPause); + void SetMusicVolume(int nChannel, int volume); + int GetMusicVolume(int nChannel); + bool OpenVoiceDatabase(); + void CloseVoiceDatabase(); protected: // Engine APIs virtual Common::Error run(); @@ -69,6 +84,8 @@ public: LPCUSTOMFUNCTION FuncList[300]; Common::RandomSource _randomSource; RMResUpdate _resUpdate; + Common::File _vdbFP; + Common::Array _voices; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); -- cgit v1.2.3 From 4784367debbaeae656f3bdec5a146b821150a2d0 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sun, 29 Apr 2012 08:44:15 +0200 Subject: TONY: Remove __stdcall to make it build on Linux --- engines/tony/mpal/stubs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index d66e12d00d..f41d222b8a 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -43,7 +43,7 @@ namespace MPAL { typedef void *HGLOBAL; typedef void *HANDLE; -typedef uint32 (__stdcall *LPTHREAD_START_ROUTINE)(void *lpThreadParameter); +typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); /****************************************************************************\ * Defines -- cgit v1.2.3 From 118f5ca0102144b5c282f012def6c96c69052bc1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 23:19:30 +1000 Subject: TONY: Implemented RMGameBoxes class and all dependent classes --- engines/tony/loc.cpp | 269 ++++++++++++ engines/tony/loc.h | 127 ++++++ engines/tony/module.mk | 3 + engines/tony/mpal/expr.cpp | 4 +- engines/tony/mpal/loadmpc.cpp | 2 + engines/tony/mpal/memory.cpp | 145 +++++++ engines/tony/mpal/memory.h | 82 ++++ engines/tony/mpal/mpal.cpp | 12 +- engines/tony/mpal/mpaldll.h | 1 + engines/tony/mpal/mpalutils.cpp | 106 +++++ engines/tony/mpal/mpalutils.h | 69 ++++ engines/tony/mpal/stubs.cpp | 39 -- engines/tony/mpal/stubs.h | 12 +- engines/tony/tony.cpp | 4 + engines/tony/tony.h | 5 + engines/tony/utils.cpp | 885 +++++++++++++++++++++++++++++++++++++++- engines/tony/utils.h | 247 ++++++++++- 17 files changed, 1952 insertions(+), 60 deletions(-) create mode 100644 engines/tony/loc.cpp create mode 100644 engines/tony/loc.h create mode 100644 engines/tony/mpal/memory.cpp create mode 100644 engines/tony/mpal/memory.h create mode 100644 engines/tony/mpal/mpalutils.cpp create mode 100644 engines/tony/mpal/mpalutils.h (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp new file mode 100644 index 0000000000..a40248f57d --- /dev/null +++ b/engines/tony/loc.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/loc.h" +#include "tony/utils.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/mpalutils.h" + +namespace Tony { + +using namespace ::Tony::MPAL; + +/****************************************************************************\ +* RMBox Methods +\****************************************************************************/ + +void RMBox::ReadFromStream(RMDataStream &ds) { + uint16 w; + int i; + byte b; + + // Bbox + ds >> left; + ds >> top; + ds >> right; + ds >> bottom; + + // Adiacenza + for (i = 0; i < MAXBOXES; i++) + { + ds >> adj[i]; + } + + // Misc + ds >> numhotspot; + ds >> Zvalue; + ds >> b; + attivo = b; + ds >> b; + bReversed = b; + + // Spazio di espansione + ds+=30; + + // Hotspots + for (i = 0; i < numhotspot; i++) { + ds >> w; hotspot[i].hotx = w; + ds >> w; hotspot[i].hoty = w; + ds >> w; hotspot[i].destination = w; + } +} + +RMDataStream& operator>>(RMDataStream &ds, RMBox &box) { + box.ReadFromStream(ds); + + return ds; +} + +/****************************************************************************\ +* RMBoxLoc Methods +\****************************************************************************/ + +void RMBoxLoc::ReadFromStream(RMDataStream& ds) { + int i; + char buf[2]; + byte ver; + + // ID and versione + ds >> buf[0] >> buf[1] >> ver; + assert(buf[0] == 'B' && buf[1] == 'X'); + assert(ver == 3); + + // Numero dei box + ds >> numbbox; + + // Alloca la memoria per i box + boxes = new RMBox[numbbox]; + + // Li legge da disco + for (i = 0; i < numbbox; i++) + ds >> boxes[i]; +} + + +void RMBoxLoc::RecalcAllAdj(void) { + int i, j; + + for (i = 0; i < numbbox; i++) { + Common::fill(boxes[i].adj, boxes[i].adj + MAXBOXES, 0); + + for (j=0; j < boxes[i].numhotspot; j++) + if (boxes[boxes[i].hotspot[j].destination].attivo) + boxes[i].adj[boxes[i].hotspot[j].destination] = 1; + } +} + +RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { + bl.ReadFromStream(ds); + + return ds; +} + +/****************************************************************************\ +* RMGameBoxes methods +\****************************************************************************/ + +void RMGameBoxes::Init(void) { + int i; + RMString fn; + RMDataStream ds; + + // Load boxes from disk + m_nLocBoxes = 130; + for (i=1; i <= m_nLocBoxes; i++) { + RMRes res(10000 + i); + + ds.OpenBuffer(res); + + m_allBoxes[i] = new RMBoxLoc(); + ds >> *m_allBoxes[i]; + + m_allBoxes[i]->RecalcAllAdj(); + + ds.Close(); + } +} + +void RMGameBoxes::Close(void) { +} + +RMBoxLoc *RMGameBoxes::GetBoxes(int nLoc) { + return m_allBoxes[nLoc]; +} + +bool RMGameBoxes::IsInBox(int nLoc, int nBox, RMPoint pt) { + RMBoxLoc *cur = GetBoxes(nLoc); + + if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && + (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + return true; + else + return false; +} + +int RMGameBoxes::WhichBox(int nLoc, RMPoint punto) { + int i; + RMBoxLoc *cur = GetBoxes(nLoc); + + if (!cur) return -1; + + for (i=0; inumbbox; i++) + if (cur->boxes[i].attivo) + if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && + (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + return i; + + return -1; +} + +void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { + m_allBoxes[nLoc]->boxes[nBox].attivo=status; + m_allBoxes[nLoc]->RecalcAllAdj(); +} + + +int RMGameBoxes::GetSaveStateSize(void) { + int size; + int i; + + size=4; + + for (i=1; i <= m_nLocBoxes; i++) { + size += 4; + size += m_allBoxes[i]->numbbox; + } + + return size; +} + +void RMGameBoxes::SaveState(byte *state) { + int i,j; + + // Save the number of locations with boxes + WRITE_LE_UINT32(state, m_nLocBoxes); + state += 4; + + // For each location, write out the number of boxes and their status + for (i=1; i <= m_nLocBoxes; i++) { + WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); + state+=4; + + for (j=0; j < m_allBoxes[i]->numbbox; j++) + *state++ = m_allBoxes[i]->boxes[j].attivo; + } +} + +void RMGameBoxes::LoadState(byte *state) { + int i,j; + int nloc,nbox; + + // Load number of locations with box + nloc = *(int*)state; + state+=4; + + // Controlla che siano meno di quelli correnti + assert(nloc <= m_nLocBoxes); + + // Per ogni locazione, salva il numero di box e il loro stato + for (i = 1; i <= nloc; i++) { + nbox = READ_LE_UINT32(state); + state += 4; + + for (j=0; jnumbbox) + m_allBoxes[i]->boxes[j].attivo = *state; + + state++; + } + + m_allBoxes[i]->RecalcAllAdj(); + } +} + +} // End of namespace Tony diff --git a/engines/tony/loc.h b/engines/tony/loc.h new file mode 100644 index 0000000000..e09a7389d9 --- /dev/null +++ b/engines/tony/loc.h @@ -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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_LOC_H +#define TONY_LOC_H + +#include "common/scummsys.h" +#include "utils.h" + +namespace Tony { + +#define MAXBOXES 50 // Non si puo' cambiare, comanda cosi' il boxed +#define MAXHOTSPOT 20 // Idem + +class RMBox { +public: + struct T_HOTSPOT { + int hotx, hoty; // coordinate HotSpot + int destination; // destinazione HotSpot + }; + +public: + int left,top,right,bottom; // Vertici BoundingBox + int adj[MAXBOXES]; // Lista di adjacenza + int numhotspot; // Numero HotSpot + uint8 Zvalue; // Zvalue per quel BoundingBox + T_HOTSPOT hotspot[MAXHOTSPOT]; // Lista degli HotSpot + + bool attivo; + bool bReversed; + +private: + void ReadFromStream(RMDataStream &ds); + +public: + friend RMDataStream &operator>>(RMDataStream &ds, RMBox &box); +}; + + +class RMBoxLoc { +public: + int numbbox; + RMBox *boxes; + +private: + void ReadFromStream(RMDataStream& ds); + +public: + friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); + void RecalcAllAdj(void); +}; + + +class RMGameBoxes { +protected: + RMBoxLoc *m_allBoxes[200]; + int m_nLocBoxes; + +public: + void Init(void); + void Close(void); + + // Prende i box di una locazione + RMBoxLoc *GetBoxes(int nLoc); + + // Calcola in quale box si trova il punto + int WhichBox(int nLoc, RMPoint pt); + + // Controlla che il punto sia dentro un certo box + bool IsInBox(int nLoc, int nBox, RMPoint pt); + + // Cambia lo stato di un box + void ChangeBoxStatus(int nLoc, int nBox, int status); + + // Salvataggi + int GetSaveStateSize(void); + void SaveState(byte *buf); + void LoadState(byte *buf); +}; + +} // End of namespace Tony + +#endif /* TONY_H */ diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 0ec4563207..6aeb0a1583 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,11 +2,14 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ + loc.o \ tony.o \ utils.o \ mpal/expr.o \ mpal/loadmpc.o \ + mpal/memory.o \ mpal/mpal.o \ + mpal/mpalutils.o \ mpal/lzo.o \ mpal/stubs.o diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 0faf91744c..2f0e890af9 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -48,8 +48,10 @@ **************************************************************************/ #include "mpal.h" +#include "memory.h" #include "mpaldll.h" #include "stubs.h" +#include "tony/tony.h" /* #include "lzo1x.h" @@ -149,7 +151,7 @@ static byte *DuplicateExpression(HGLOBAL h) { num=*(byte *)orig; one=(LPEXPRESSION)(orig+1); - clone=GlobalAlloc(GMEM_FIXED,sizeof(EXPRESSION)*num+1); + clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION)*num+1); two=(LPEXPRESSION)(clone+1); CopyMemory(clone,orig,sizeof(EXPRESSION)*num+1); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index f9426c8d58..ff94dbae8d 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -52,6 +52,8 @@ */ #include "mpal.h" #include "mpaldll.h" +#include "memory.h" +#include "tony/tony.h" namespace Tony { diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp new file mode 100644 index 0000000000..604e61ed24 --- /dev/null +++ b/engines/tony/mpal/memory.cpp @@ -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. + * + * + */ + +#include "common/textconsole.h" +#include "tony/mpal/memory.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* MemoryItem methods +\****************************************************************************/ + +/** + * Constructor + * @param Data sizee + */ +MemoryItem::MemoryItem(uint32 size) { + _size = size; + _buffer = (size == 0) ? NULL : new byte[size]; +} + +/** + * Destructor + */ +MemoryItem::~MemoryItem() { + delete[] _buffer; +} + +/** + * Returns a pointer to the resource + */ +MemoryItem::operator void *() { + return DataPointer(); +} + +/****************************************************************************\ +* MemoryManager methods +\****************************************************************************/ + +MemoryManager::MemoryManager() { +} + +/** + * Destructor + */ +MemoryManager::~MemoryManager() { + Common::List::iterator i; + for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { + MemoryItem *item = *i; + delete item; + } +} + +/** + * Allocates a new memory block + * @returns Returns a MemoryItem instance for the new block + */ +MemoryItem &MemoryManager::allocate(uint32 size) { + MemoryItem *newItem = new MemoryItem(size); + _memoryBlocks.push_back(newItem); + + return *newItem; +} + +/** + * Allocates a new memory block and returns it's data pointer + * @returns Data pointer to allocated block + */ +HGLOBAL MemoryManager::alloc(uint32 size) { + MemoryItem &newItem = allocate(size); + return (HGLOBAL)newItem.DataPointer(); +} + +/** + * Returns a reference to the MemoryItem for a gien byte pointer + * @param block Byte pointer + */ +MemoryItem &MemoryManager::getItem(HGLOBAL handle) { + Common::List::iterator i; + for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { + MemoryItem *item = *i; + if (item->DataPointer() == handle) + return *item; + } + + error("Could not locate a memory block"); +} + +/** + * Square bracketes operator + * @param block Byte pointer + */ +MemoryItem &MemoryManager::operator[](HGLOBAL handle) { + return getItem(handle); +} + +/** + * Returns a size of a memory block given it's pointer + */ +uint32 MemoryManager::getSize(HGLOBAL handle) { + MemoryItem &item = getItem(handle); + return item.Size(); +} + +/** + * Erases a given item + */ +void MemoryManager::erase(MemoryItem &item) { + delete item; + _memoryBlocks.remove(&item); +} + +/** + * Erases a given item + */ +void MemoryManager::erase(HGLOBAL handle) { + MemoryItem &item = getItem(handle); + erase(item); +} + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h new file mode 100644 index 0000000000..dde2e8908c --- /dev/null +++ b/engines/tony/mpal/memory.h @@ -0,0 +1,82 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 TONY_MPAL_MEMORY +#define TONY_MPAL_MEMORY + +#include "common/scummsys.h" +#include "common/list.h" + +namespace Tony { + +namespace MPAL { + +typedef void *HANDLE; +typedef HANDLE HGLOBAL; + +class MemoryItem { +protected: + void *_buffer; + uint32 _size; +public: + MemoryItem(uint32 size); + virtual ~MemoryItem(); + + uint32 Size() { return _size; } + void *DataPointer() { return _buffer; } + bool IsValid() { return _buffer != NULL; } + + // Casting for access to data + operator void *(); +}; + +class MemoryManager { +private: + Common::List _memoryBlocks; +public: + MemoryManager(); + virtual ~MemoryManager(); + + MemoryItem &allocate(uint32 size); + HGLOBAL alloc(uint32 size); + MemoryItem &getItem(HGLOBAL handle); + MemoryItem &operator[](HGLOBAL handle); + void erase(MemoryItem &item); + void erase(HGLOBAL handle); + + uint32 getSize(HANDLE handle); +}; + +// defines +#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size) +#define GlobalAllocate(size) _vm->_memoryManager.allocate(size) +#define GlobalFree(handle) _vm->_memoryManager.erase(handle) +#define GlobalLock(handle) (_vm->_memoryManager.getItem(handle).DataPointer()) +#define GlobalUnlock(handle) {} +#define GlobalSize(handle) (_vm->_memoryManager.getItem(handle).Size()) + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index e07669849e..b4b37e7723 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -860,7 +860,7 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { uint32 dwCurTime; uint32 dwId; static HANDLE cfHandles[MAX_COMMANDS_PER_MOMENT]; - int numHandles; + int numHandles = 0; LPCFCALL p; // warning("PlayScript(): Moments: %u\n",s->nMoments); @@ -1785,7 +1785,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION if (lpResources==NULL) return false; - cmpbuf = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); + cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf==NULL) return false; @@ -1840,12 +1840,14 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION #define GETARG(type) va_arg(v,type) uint32 mpalQuery(uint16 wQueryType, ...) { - uint32 dwRet; int x,y,z; char * n; + uint32 dwRet = 0; + int x,y,z; + char *n; va_list v; Common::String buf; - mpalError=OK; - va_start(v,wQueryType); + mpalError = OK; + va_start(v, wQueryType); switch (wQueryType) { /* diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 8a52f1ed90..ee3820531a 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -51,6 +51,7 @@ #define __MPALDLL_H #include "common/file.h" +#include "memory.h" #include "stubs.h" namespace Tony { diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp new file mode 100644 index 0000000000..2e3bd07383 --- /dev/null +++ b/engines/tony/mpal/mpalutils.cpp @@ -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. + * + * + */ + +#include "tony/mpal/mpalutils.h" +#include "tony/tony.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* RMRes methods +\****************************************************************************/ + +/** + * Constructor + * @param resId MPAL resource to open + */ +RMRes::RMRes(uint32 resID) { + m_h = _vm->_resUpdate.QueryResource(resID); + if (m_h == NULL) + m_h = mpalQueryResource(resID); + if (m_h != NULL) + m_buf = (byte *)GlobalLock(m_h); +} + +/** + * Destructor + */ +RMRes::~RMRes() { + if (m_h != NULL) { + GlobalUnlock(m_h); + GlobalFree(m_h); + } +} + +/** + * Returns a pointer to the resource + */ +const byte *RMRes::DataPointer() { + return m_buf; +} + +/** + * Returns a pointer to the resource + */ +RMRes::operator const byte *() { + return DataPointer(); +} + +/** + * Returns the size of the resource + */ +unsigned int RMRes::Size() { + return GlobalSize(m_h); +} + +/****************************************************************************\ +* RMResRaw methods +\****************************************************************************/ + +RMResRaw::RMResRaw(uint32 resID) : RMRes(resID) { +} + +RMResRaw::~RMResRaw() { +} + +const byte *RMResRaw::DataPointer() { + return m_buf + 8; +} + +RMResRaw::operator const byte *() { + return DataPointer(); +} + +int RMResRaw::Width() { + return READ_LE_UINT16(m_buf + 4); +} + +int RMResRaw::Height() { + return READ_LE_UINT16(m_buf + 6); +} + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h new file mode 100644 index 0000000000..cb8d4ec97d --- /dev/null +++ b/engines/tony/mpal/mpalutils.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. + * + * + */ + +#ifndef TONY_MPAL_MPALUTILS +#define TONY_MPAL_MPALUTILS + +#include "common/scummsys.h" +#include "memory.h" +#include "stubs.h" + +namespace Tony { + +namespace MPAL { + +class RMRes { +protected: + HGLOBAL m_h; + byte *m_buf; + +public: + RMRes(uint32 resID); + virtual ~RMRes(); + + // Attributes + unsigned int Size(); + const byte *DataPointer(); + bool IsValid() { return m_h != NULL; } + + // Casting for access to data + operator const byte*(); +}; + +class RMResRaw : public RMRes { +public: + RMResRaw(uint32 resID); + virtual ~RMResRaw(); + + const byte *DataPointer(); + operator const byte*(); + + int Width(); + int Height(); +}; + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index c25dd2ab43..054ed55c68 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -36,45 +36,6 @@ namespace Tony { namespace MPAL { -/** - * Allocates a memory block - */ -byte *GlobalAlloc(uint16 flags, int size) { - byte *result = (byte *)malloc(size); - - if (flags & GMEM_ZEROINIT) - Common::fill(result, result + size, 0); - - return result; -} - -/** - * Lock a global handle - * @param h Global handle - * @remarks Since HGLOBALs are directly representing the pointers anyway, - * simply return it - */ -void *GlobalLock(HGLOBAL h) { - return h; -} - -/** - * Unlock a global handle - * @param h Global handle - * @remarks Since HGLOBALs are directly representing the pointers anyway, - * the unlock method doesn't need to do anything - */ -void GlobalUnlock(HGLOBAL h) { -} - -/** - * Free a globally allocated memory block - * @param h Global handle - */ -void GlobalFree(HGLOBAL h) { - free(h); -} - /** * Display a message * @param msg Message to display diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index f41d222b8a..be856790bc 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -31,6 +31,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "tony/mpal/memory.h" namespace Tony { @@ -40,9 +41,6 @@ namespace MPAL { * Types \****************************************************************************/ -typedef void *HGLOBAL; -typedef void *HANDLE; - typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); /****************************************************************************\ @@ -75,14 +73,6 @@ Out CopyMemory(Out dst, In first, int size) { * Methods \****************************************************************************/ -extern byte *GlobalAlloc(uint16 flags, int size); - -extern void *GlobalLock(HGLOBAL h); - -extern void GlobalUnlock(HGLOBAL h); - -extern void GlobalFree(HGLOBAL h); - extern void MessageBox(const Common::String &msg); extern uint32 timeGetTime(); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 0eacbb5ff4..d5a5e467df 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -78,9 +78,13 @@ Common::ErrorCode TonyEngine::Init() { // Initialise the music InitMusic(); + // Initialise the voices database if (!OpenVoiceDatabase()) return Common::kReadingFailed; + // Initialise the boxes + _theBoxes.Init(); + return Common::kNoError; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 77b1596112..384b7a1f4c 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -32,6 +32,8 @@ #include "engines/engine.h" #include "tony/mpal/mpal.h" +#include "tony/mpal/memory.h" +#include "tony/loc.h" #include "tony/utils.h" /** @@ -83,9 +85,12 @@ protected: public: LPCUSTOMFUNCTION FuncList[300]; Common::RandomSource _randomSource; + MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; Common::File _vdbFP; Common::Array _voices; + // Bounding box list manager + RMGameBoxes _theBoxes; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 1368111a05..76d168e27a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -19,12 +19,889 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ #include "tony/utils.h" -#include "mpal/lzo.h" +#include "tony/tony.h" +#include "tony/mpal/lzo.h" namespace Tony { +/****************************************************************************\ +* RMString methods +\****************************************************************************/ + +/** + * Constructor + */ +RMString::RMString() { + m_string=NULL; + m_length=0; + m_realLength=0; +} + +/** + * Destructor + */ +RMString::~RMString() { + if (m_string != NULL) + delete[] m_string; +} + +/** + * Copy constructor + */ +RMString::RMString(const RMString &str) { + // Richiama l'overload su '=' per copiare + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = str; +} + +/** + * Constructor from a char * + */ +RMString::RMString(const char* str) { + // Use the overloaded '=' when copying + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = str; +} + +/** + * Constructor with a single passed character + */ +RMString::RMString(const int ch) { + // Use the overloaded '=' when copying + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = ch; +} + +/** + * Returns the length of the string + * @returns Length + */ +int RMString::Length() { + return m_length; +} + +/** + * Gets the character at the given index + * @param nIndex Position of the character to return + * @returns Character + */ +char RMString::GetAt(int nIndex) { + assert(nIndex < m_length); + return m_string[nIndex]; +} + +/** + * Sets the character at the given index + * @param nIndex Position of the character to change + * @param c Character + */ +void RMString::SetAt(int nIndex, char c) { + assert(nIndex < m_length); + m_string[nIndex] = c; +} + +/** + * Overloaded square brackets operator for accessing characters within the string + * @param nIndex Position of the charactre to reference + * @params Reference to the character + */ +char &RMString::operator[](int nIndex) { + assert(nIndex < m_length); + return m_string[nIndex]; +} + +/** + * Copies a string + * @param str String to copy + * @returns Refrence to our string + */ +const RMString &RMString::operator=(const RMString &str) { + // Set the new length + m_length = str.m_length; + + // If the source is empty, then destroy the current string buffer + if (m_length == 0) { + if (m_realLength > 0) { + delete[] m_string; + m_string = NULL; + m_realLength = 0; + } + } else { + // Resize if necessary + Resize(m_length + 1); + + // Copy the string + Common::copy(str.m_string, str.m_string + m_length + 1, m_string); + } + + return *this; +} + +/** + * Copies a char * string + * @param str String to copy + * @returns Refrence to our string + */ +const RMString& RMString::operator=(const char* str) { + // If the source is empty, then destroy the current string buffer + if (str == NULL) { + if (m_realLength > 0) { + delete[] m_string; + m_string = NULL; + m_realLength = m_length = 0; + } + } else { + // Calculate the new length + m_length = strlen(str); + + // Resize if necessary + Resize(m_length + 1); + + // Copy the string + Common::copy(str, str + m_length + 1, m_string); + } + + return *this; +} + +/** + * Forms a string from a passed character + * @param ch Character to copy + * @returns Refrence to our string + */ +const RMString& RMString::operator=(const int ch) { + if (ch=='\0') { + // Destroy the current string + if (m_realLength > 0) { + delete [] m_string; + m_string=NULL; + m_length=m_realLength=0; + } + } else { + // Resize if necessary + Resize(2); + + m_string[0] = ch; + m_string[1] = '\0'; + m_length = 1; + } + + return *this; +} + +/** + * Concatenate a string into the current one + * @param str String to concatenate + * @param size Length of the string + */ +void RMString::Connect(const char *str, int size) { + int nlen; + + if (size > 0) { + // Calculate the new lenght + nlen=m_length+size; + + // Resize + Resize(nlen + 1, true); + + // Linkage with '\0' + Common::copy(str, str + size + 1, m_string + m_length); + + // Save the new length + m_length = nlen; + } +} + +/** + * Concatenate a string + * @param str String to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(RMString &str) { + Connect(str,str.Length()); + return *this; +} + +/** + * Concatenate a string + * @param str String to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(const char *str) { + Connect(str,strlen(str)); + return *this; +} + +/** + * Concatenate a character + * @param ch Character to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(const int ch) { + char str[2]; + + // Create a simple string buffer to hold the single character + str[0] = ch; + str[1] = '\0'; + + Connect(str, 1); + return *this; +} + +/** + * Casts a string as char * + * @returns char * reference to string + */ +RMString::operator char*() const { + return m_string; +} + +/** + * Resize a string as necessary + * @param size New size necessary (in bytes) + * @param bMaintain If TRUE we must keep the original string, + if FALSE we can destroy. + */ +void RMString::Resize(int size, bool bMantain) { + if (m_realLength == 0) { + m_string = new char[size]; + m_realLength = size; + } else if (size > m_realLength) { + if (bMantain) { + char* app; + + app = new char[size]; + Common::copy(m_string, m_string + m_length + 1, app); + delete[] m_string; + m_string = app; + } else { + delete[] m_string; + m_string = new char[size]; + } + } +} + +/** + * Compacts the string to occupy less memory if possible. + */ +void RMString::Compact(void) { + if (m_realLength + 1 > m_length) { + char *app; + + app = new char[m_length + 1]; + Common::copy(m_string, m_string + m_length + 1, app); + + delete[] m_string; + m_string = app; + } +} + +/** + * Operator to concatenate two strings + */ +RMString operator+(const RMString &str1, const RMString &str2) { + RMString ret(str1); + + return (ret += str2); +} + +/** + * Operator to concatenate a character to a string + */ +RMString operator+(RMString &str, const int ch) { + RMString ret(str); + + return (ret += ch); +} + +RMString operator+(const int ch, RMString &str) { + RMString ret(ch); + + return (ret += str); +} + +/** + * Operator to concatenate a char * string to an RMString + */ +RMString operator+(RMString &str, const char *s) { + RMString ret(str); + + return (ret += s); +} + +RMString operator+(const char *s, RMString &str) { + RMString ret(s); + + return (ret+=str); +} + +/** + * Extracts a string from a data stream + * @param df data stream + * @param var String + */ +RMDataStream &operator>>(RMDataStream &df, RMString &var) { + uint8 len; + int i; + + df >> len; + var.Resize(len + 1); + var.m_length=len+1; + + for (i = 0; i < len; i++) + df >> var[i]; + + var[i] = '\0'; + var.m_length = len; + + return df; +} + +/** + * Formats a string + */ +void RMString::Format(char* str, ...) { + warning("TODO: Refactor RMString::Format if needed"); + /* + static char buf[2048]; + va_list argList; + + va_start(argList,str); + wvsprintf(buf,str,argList); + va_end(argList); + *this = buf; +*/ +} + +/****************************************************************************\ +* RMDataStream methods +\****************************************************************************/ + +/** + * Constructor + */ +RMDataStream::RMDataStream() { + m_length = 0; + m_pos = 0; + m_bError = false; +} + +/** + * Destructor + */ +RMDataStream::~RMDataStream() { + Close(); +} + +/** + * Close a stream + */ +void RMDataStream::Close(void) { + m_length = 0; + m_pos = 0; +} + +/** + * Takes the address of the buffer from which will be read the data. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. + */ +void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { + m_length = size; + m_buf = lpBuf; + m_bError = false; + m_pos = 0; +} + +/** + * Returns the length of the stream + * @returns Stream length + */ +int RMDataStream::Length() { + return m_length; +} + +/** + * Determines if the end of the stream has been reached + * @returns TRUE if end of stream reached, FALSE if not + */ +bool RMDataStream::IsEOF() { + return (m_pos >= m_length); +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, char &var) { + df.Read(&var, 1); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint8 &var) { + df.Read(&var, 1); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint16 &var) { + uint16 v; + df.Read(&v, 2); + + var = FROM_LE_16(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, int16 &var) { + uint16 v; + df.Read(&v, 2); + + var = (int16)FROM_LE_16(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, int &var) { + uint32 v; + df.Read(&v, 4); + + var = (int)FROM_LE_32(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint32 &var) { + uint32 v; + df.Read(&v, 4); + + var = FROM_LE_32(v); + return df; +} + +/** + * Reads a series of data from the stream in a buffer + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns TRUE if we have reached the end, FALSE if not + */ +bool RMDataStream::Read(void *lpBuf, int size) { + byte *dest = (byte *)lpBuf; + + if ((m_pos + size) > m_length) { + Common::copy(m_buf + m_pos, m_buf + m_pos + (m_length - m_pos), dest); + + return true; + } else { + Common::copy(m_buf + m_pos, m_buf + m_pos + size, dest); + + m_pos += size; + return false; + } +} + +/** + * Skips a number of bytes in the stream + * @param nBytres Number of bytes to skip + * @returns The stream + */ +RMDataStream &RMDataStream::operator+=(int nBytes) { + m_pos+=nBytes; + return *this; +} + +/** + * Seeks to a position within the stream + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes + */ +int RMDataStream::Seek(int nBytes, RMDSPos origin) { + switch (origin) { + case CUR: + break; + + case START: + m_pos=0; + break; + + case END: + if (m_length == SIZENOTKNOWN) + return m_pos; + m_pos=m_length; + break; + } + + m_pos+=nBytes; + return m_pos; +} + +/** + * Returns the current position of the stream + * @returns The current position + */ +int RMDataStream::Pos() { + return m_pos; +} + +/** + * Check if an error occurred during reading the stream + * @returns TRUE if there was an error, false otherwise + */ +bool RMDataStream::IsError() { + return m_bError; +} + +/** + * Sets an error code for the stream + * @param code Error code + */ +void RMDataStream::SetError(int code) { + m_bError = true; + m_ecode = code; +} + +/** + * Returns the error code for the stream + * @returns Error code + */ +int RMDataStream::GetError() { + return m_ecode; +} + +/****************************************************************************\ +* RMPoint methods +\****************************************************************************/ + +/** + * Constructor + */ +RMPoint::RMPoint() { + x = y = 0; +} + +/** + * Copy constructor + */ +RMPoint::RMPoint(const RMPoint &p) { + x=p.x; + y=p.y; +} + +/** + * Constructor with integer parameters + */ +RMPoint::RMPoint(int x1, int y1) { + x = x1; + y = y1; +} + +/** + * Copy operator + */ +RMPoint &RMPoint::operator=(RMPoint p) { + x = p.x; + y = p.y; + + return *this; +} + +/** + * Offsets the point by another point + */ +void RMPoint::Offset(RMPoint p) { + x += p.x; + y += p.y; +} + +/** + * Offsets the point by a specified offset + */ +void RMPoint::Offset(int xOff, int yOff) { + x += xOff; + y += yOff; +} + +/** + * Sums together two points + */ +RMPoint operator+(RMPoint p1, RMPoint p2) { + RMPoint p(p1); + + return (p += p2); +} + +/** + * Subtracts two points + */ +RMPoint operator-(RMPoint p1, RMPoint p2) { + RMPoint p(p1); + + return (p -= p2); +} + +/** + * Sum (offset) of a point + */ +RMPoint &RMPoint::operator+=(RMPoint p) { + Offset(p); + return *this; +} + +/** + * Subtract (offset) of a point + */ +RMPoint& RMPoint::operator-=(RMPoint p) { + Offset(-p); + return *this; +} + +/** + * Inverts a point + */ +RMPoint RMPoint::operator-() { + RMPoint p; + + p.x = -x; + p.y = -y; + + return p; +} + +/** + * Equality operator + */ +bool RMPoint::operator==(RMPoint p) { + return ((x == p.x) && (y == p.y)); +} + +/** + * Not equal operator + */ +bool RMPoint::operator!=(RMPoint p) { + return ((x != p.x) || (y != p.y)); +} + +/** + * Reads a point from a stream + */ +RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { + ds >> p.x >> p.y; + return ds; +} + +/****************************************************************************\ +* RMRect methods +\****************************************************************************/ + +RMRect::RMRect() { + SetEmpty(); +} + +void RMRect::SetEmpty(void) { + x1 = y1 = x2 = y2 = 0; +} + +RMRect::RMRect(RMPoint p1, RMPoint p2) { + SetRect(p1, p2); +} + +RMRect::RMRect(int X1, int Y1, int X2, int Y2) { + SetRect(X1, Y1, X2, Y2); +} + +RMRect::RMRect(const RMRect &rc) { + CopyRect(rc); +} + +void RMRect::SetRect(RMPoint p1, RMPoint p2) { + x1 = p1.x; + y1 = p1.y; + x2 = p2.x; + y2 = p2.y; +} + +void RMRect::SetRect(int X1, int Y1, int X2, int Y2) { + x1 = X1; + y1 = Y1; + x2 = X2; + y2 = Y2; +} + +void RMRect::SetRect(const RMRect &rc) { + CopyRect(rc); +} + +void RMRect::CopyRect(const RMRect &rc) { + x1 = rc.x1; + y1 = rc.y1; + x2 = rc.x2; + y2 = rc.y2; +} + +RMPoint &RMRect::TopLeft() { + // FIXME: This seems very bad + return *((RMPoint *)this); +} + +RMPoint& RMRect::BottomRight() { + // FIXME: This seems very bad + return *((RMPoint*)this + 1); +} + +RMPoint RMRect::Center() { + return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); +} + +int RMRect::Width() { + return x2 - x1; +} + +int RMRect::Height() { + return y2 - y1; +} + +int RMRect::Size() { + return Width() * Height(); +} + +bool RMRect::IsEmpty() { + return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); +} + +const RMRect& RMRect::operator=(const RMRect &rc) { + CopyRect(rc); + return *this; +} + +void RMRect::Offset(int xOff, int yOff) { + x1 += xOff; + y1 += yOff; + x2 += xOff; + y2 += yOff; +} + +void RMRect::Offset(RMPoint p) { + x1 += p.x; + y1 += p.y; + x2 += p.x; + y2 += p.y; +} + +const RMRect &RMRect::operator+=(RMPoint p) { + Offset(p); + return *this; +} + +const RMRect &RMRect::operator-=(RMPoint p) { + Offset(-p); + return *this; +} + +RMRect operator+(const RMRect &rc, RMPoint p) { + RMRect r(rc); + return (r += p); +} + +RMRect operator-(const RMRect& rc, RMPoint p) { + RMRect r(rc); + + return (r -= p); +} + +RMRect operator+(RMPoint p, const RMRect& rc) { + RMRect r(rc); + + return (r+=p); +} + +RMRect operator-(RMPoint p, const RMRect& rc) { + RMRect r(rc); + + return (r+=p); +} + +bool RMRect::operator==(const RMRect& rc) { + return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); +} + +bool RMRect::operator!=(const RMRect& rc) { + return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); +} + +void RMRect::NormalizeRect(void) { + SetRect(MIN(x1,x2), MIN(y1,y2), MAX(x1,x2), MAX(y1,y2)); +} + +RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { + ds >> rc.x1 >> rc.y1 >> rc.x2 >> rc.y2; + return ds; +} + + /****************************************************************************\ * Resource Update \****************************************************************************/ @@ -68,7 +945,7 @@ void RMResUpdate::Init(const Common::String &fileName) { } } -const byte *RMResUpdate::QueryResource(uint32 dwRes) { +HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; @@ -98,7 +975,8 @@ const byte *RMResUpdate::QueryResource(uint32 dwRes) { } // Allocate space for the output resource - byte *lpDestBuf = new byte[info.size]; + HGLOBAL destBuf = GlobalAllocate(info.size); + byte *lpDestBuf = (byte *)GlobalLock(destBuf); uint32 dwSize; // Decompress the data @@ -108,6 +986,7 @@ const byte *RMResUpdate::QueryResource(uint32 dwRes) { delete [] cmpBuf; // Return the resource + GlobalUnlock(destBuf); return lpDestBuf; } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index b1afcca074..bec42b343b 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -19,16 +19,261 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ #ifndef TONY_UTILS_H #define TONY_UTILS_H #include "common/scummsys.h" #include "common/file.h" +#include "common/rect.h" #include "common/str.h" +#include "tony/mpal/memory.h" namespace Tony { +using namespace ::Tony::MPAL; + +/** + * Data stream for reading data + */ +class RMDataStream { +protected: + const byte *m_buf; + int m_length; + int m_pos; + bool m_bError; + int m_ecode; + +public: + enum RMDSPos { + CUR, + START, + END + }; + +private: + enum { + SIZENOTKNOWN = 0x7FFFFFFF + }; + +public: + // Constructor and destructor + RMDataStream(); + virtual ~RMDataStream(); + + // Loading buffer + void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); + void Close(void); + + // Attributi + int Length(); + virtual int Pos(); + + // EOF + virtual bool IsEOF(); + + // Read methods + friend RMDataStream &operator>>(RMDataStream &df, char &var); + friend RMDataStream &operator>>(RMDataStream &df, byte &var); + friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int &var); + friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); + + // Lettura generica + virtual bool Read(void *buf, int size); + + // Skipping & Seeking + virtual RMDataStream &operator+=(int nBytes); + virtual int Seek(int nBytes, RMDSPos origin = CUR); + + // Gestione errori + void SetError(int ecode); + int GetError(); + bool IsError(); +}; + +/** + * String class + */ +class RMString { +private: + char *m_string; + int m_length; + int m_realLength; + +public: + RMString(); + ~RMString(); + + // Assignment constructors + RMString(const RMString &str); + RMString(const char *str); + RMString(const int ch); + + // Metodi generici + int Length(); + void Compact(); + + // Access characters within string + char GetAt(int nIndex); + void SetAt(int nIndex, char c); + char& operator[](int nIndex); + + // String cast + operator char*() const; + + // String assignments + const RMString &operator=(const RMString &str); + const RMString &operator=(const char *str); + const RMString &operator=(const int ch); + + // String concatenation + const RMString &operator+=(RMString &str); + const RMString &operator+=(const char *str); + const RMString &operator+=(const int ch); + + // Concatentation of string or character + friend RMString operator+(const RMString &str1, const RMString &str2); + + friend RMString operator+(RMString& str, const int ch); + friend RMString operator+(const int ch, RMString &str); + + friend RMString operator+(RMString &str, const char *s); + friend RMString operator+(const char *s, RMString &str); + + // Estrazione da data stream + friend RMDataStream& operator>>(RMDataStream& df, RMString &var); + + // Formattazione di stringa + void Format(char *str, ...); + +private: + void Resize(int size, bool bMantain = false); + void Connect(const char* str, int size); +}; + +/** + * Point class + */ +class RMPoint { +public: + int x, y; + +public: + // Constructor + RMPoint(); + RMPoint(const RMPoint &p); + RMPoint(int x1, int y1); + + // Copia + RMPoint& operator=(RMPoint p); + + // Set + void Set(int x1, int y1) { x=x1; y=y1; } + + // Offset + void Offset(int xOff, int yOff); + void Offset(RMPoint p); + friend RMPoint operator+(RMPoint p1, RMPoint p2); + friend RMPoint operator-(RMPoint p1, RMPoint p2); + RMPoint &operator+=(RMPoint p); + RMPoint &operator-=(RMPoint p); + RMPoint operator-(); + + // Confronti + bool operator==(RMPoint p); + bool operator!=(RMPoint p); + + // Casting a POINT + operator Common::Point() const; + + // Extraction from data streams + friend RMDataStream& operator>>(RMDataStream &ds, RMPoint &p); +}; + +class RMRect { +public: + int x1,y1; + int x2,y2; + +public: + RMRect(); + RMRect(int x1, int y1, int x2, int y2); + RMRect(RMPoint p1, RMPoint p2); + RMRect(const RMRect &rc); + + // Attributes + RMPoint &TopLeft(); + RMPoint &BottomRight(); + RMPoint Center(); + int Width(); + int Height(); + bool IsEmpty(); + int Size(); + + // Set + void SetRect(int x1, int y1, int x2, int y2); + void SetRect(RMPoint p1, RMPoint p2); + void SetEmpty(void); + + // Copiers + void SetRect(const RMRect &rc); + void CopyRect(const RMRect &rc); + const RMRect &operator=(const RMRect &rc); + + // Offset + void Offset(int xOff, int yOff); + void Offset(RMPoint p); + friend RMRect operator+(const RMRect &rc, RMPoint p); + friend RMRect operator-(const RMRect &rc, RMPoint p); + friend RMRect operator+(RMPoint p, const RMRect &rc); + friend RMRect operator-(RMPoint p, const RMRect &rc); + const RMRect &operator+=(RMPoint p); + const RMRect &operator-=(RMPoint p); + + // Comparison + bool operator==(const RMRect &rc); + bool operator!=(const RMRect &rc); + + // Normalise + void NormalizeRect(); + + // Point in rect + bool PtInRect(RMPoint pt) { return (pt.x>=x1 && pt.x<=x2 && pt.y>=y1 && pt.y<=y2); } + + // Extract from data stream + friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); +}; + +/** + * Resource update manager + */ class RMResUpdate { struct ResUpdInfo { uint32 dwRes; @@ -46,7 +291,7 @@ public: ~RMResUpdate(); void Init(const Common::String &fileName); - const byte *QueryResource(uint32 dwRes); + HGLOBAL QueryResource(uint32 dwRes); }; } // End of namespace Tony -- cgit v1.2.3 From b0eef829728183b7ea170b30a33eca091bcc4574 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 09:27:12 +1000 Subject: TONY: Added include files for graphics engine and all dependent classes --- engines/tony/adv.h | 70 ++++++ engines/tony/font.h | 399 +++++++++++++++++++++++++++++++++ engines/tony/game.cpp | 54 +++++ engines/tony/game.h | 285 +++++++++++++++++++++++ engines/tony/gfxcore.cpp | 54 +++++ engines/tony/gfxcore.h | 547 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/gfxengine.cpp | 53 +++++ engines/tony/gfxengine.h | 167 ++++++++++++++ engines/tony/input.cpp | 54 +++++ engines/tony/input.h | 116 ++++++++++ engines/tony/inventory.h | 212 ++++++++++++++++++ engines/tony/loc.cpp | 8 +- engines/tony/loc.h | 488 +++++++++++++++++++++++++++++++++++++++- engines/tony/module.mk | 5 + engines/tony/mpal/memory.h | 4 + engines/tony/mpal/stubs.h | 4 - engines/tony/resid.h | 76 +++++++ engines/tony/sound.cpp | 54 +++++ engines/tony/sound.h | 254 +++++++++++++++++++++ engines/tony/tony.cpp | 3 + engines/tony/tony.h | 2 + engines/tony/tonychar.h | 448 +++++++++++++++++++++++++++++++++++++ engines/tony/utils.cpp | 10 +- engines/tony/utils.h | 10 +- 24 files changed, 3354 insertions(+), 23 deletions(-) create mode 100644 engines/tony/adv.h create mode 100644 engines/tony/font.h create mode 100644 engines/tony/game.cpp create mode 100644 engines/tony/game.h create mode 100644 engines/tony/gfxcore.cpp create mode 100644 engines/tony/gfxcore.h create mode 100644 engines/tony/gfxengine.cpp create mode 100644 engines/tony/gfxengine.h create mode 100644 engines/tony/input.cpp create mode 100644 engines/tony/input.h create mode 100644 engines/tony/inventory.h create mode 100644 engines/tony/resid.h create mode 100644 engines/tony/sound.cpp create mode 100644 engines/tony/sound.h create mode 100644 engines/tony/tonychar.h (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h new file mode 100644 index 0000000000..b29e4eb0cd --- /dev/null +++ b/engines/tony/adv.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: ADV.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_ADV_H +#define TONY_ADV_H + +namespace Tony { + +// Tony's actions +enum RMTonyAction { + TA_GOTO = 0, + TA_TAKE, + TA_USE, + TA_EXAMINE, + TA_TALK, + TA_PALESATI, + + TA_COMBINE = 10, + TA_RECEIVECOMBINE, + TA_COMBINEGIVE, + TA_RECEIVECOMBINEGIVE +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/font.h b/engines/tony/font.h new file mode 100644 index 0000000000..348e7618ea --- /dev/null +++ b/engines/tony/font.h @@ -0,0 +1,399 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_FONT_H +#define TONY_FONT_H + +#include "common/system.h" +#include "tony/gfxcore.h" +#include "tony/resid.h" + +namespace Tony { + +class RMInventory; + +/** + * Gestisce un font, in cui ha varie surface per ogni lettera + */ +class RMFont : public RMGfxTaskSetPrior { +protected: + int nLetters; + RMGfxSourceBuffer8RLEByte *m_letter; +public: + int m_fontDimx,m_fontDimy; + +private: + int m_dimx,m_dimy; + + class RMFontPrimitive : public RMGfxPrimitive { + public: + RMFontPrimitive() : RMGfxPrimitive() {} + RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} + + virtual RMGfxPrimitive* Duplicate() { return new RMFontPrimitive(*this); } + + int m_nChar; + }; + +protected: + // Caricamento del font + void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + + // Scaricamente del font (anche da distruttore) + void Unload(void); + +protected: + // Conversione (da overloadare) + virtual int ConvertToLetter(int nChar) = 0; + + // Lunghezza dei caratteri (da overloadare) + virtual int LetterLength(int nChar, int nNext=0) = 0; + +public: + virtual int LetterHeight(void) = 0; + +public: + RMFont(); + virtual ~RMFont(); + + // Inizializzazione e chiusura + virtual void Init(void) = 0; + virtual void Close(void); + + // Funzione del task da overloadare + void Draw(RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + + // Crea una primitiva per una lettera + RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); + + // Lunghezza in pixel di una stringa con il font corrente + int StringLen(RMString text); + int StringLen(char bChar, char bNext=0); +}; + + +class RMFontColor : public virtual RMFont { +private: + byte m_r,m_g,m_b; + +public: + RMFontColor(); + virtual ~RMFontColor(); + virtual void SetBaseColor(byte r, byte g, byte b); +}; + + +class RMFontWithTables : public virtual RMFont { +protected: + int cTable[256]; + int lTable[256]; + int lDefault; + int hDefault; + signed char l2Table[256][256]; + +protected: + // Overload dei metodi + int ConvertToLetter(int nChar) { return cTable[nChar]; } + int LetterLength(int nChar, int nNext=0) { return (nChar!=-1 ? lTable[nChar]+l2Table[nChar][nNext] : lDefault); } + +public: + int LetterHeight() { return hDefault; } + virtual ~RMFontWithTables() {} +}; + + +class RMFontParla : public RMFontColor, public RMFontWithTables { +public: + void Init(void); + virtual ~RMFontParla() {} +}; + +class RMFontObj : public RMFontColor, public RMFontWithTables { +private: + void SetBothCase(int nChar, int nNext, signed char spiazz); + +public: + void Init(void); + virtual ~RMFontObj() {} +}; + +class RMFontMacc : public RMFontColor, public RMFontWithTables { +public: + void Init(void); + virtual ~RMFontMacc() {} +}; + +class RMFontCredits : public RMFontColor, public RMFontWithTables { +public: + void Init(void); + virtual ~RMFontCredits() {} + virtual void SetBaseColor(byte r, byte g, byte b) {} +}; + +/** + * Gestisce una scritta su schermo, con tutte le possibilita' di formattazione disponibile + */ +class RMText : public RMGfxWoodyBuffer { +private: + static RMFontColor *m_fonts[4]; + static RMGfxClearTask m_clear; + static OSystem::MutexRef m_cs; + int maxLineLength; + +public: + enum HORALIGN { + HLEFT, + HLEFTPAR, + HCENTER, + HRIGHT + }; + + enum VERALIGN { + VTOP, + VCENTER, + VBOTTOM + }; + +private: + HORALIGN aHorType; + VERALIGN aVerType; + byte m_r,m_g,m_b; + +protected: + virtual void ClipOnScreen(RMGfxPrimitive* prim); + +public: + RMText(); + virtual ~RMText(); + + // Setta il tipo di allineamento + void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; } + + // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) + void SetMaxLineLength(int max); + + // Scrive un testo + void WriteText(RMString text, int font, int *time = NULL); + void WriteText(RMString text, RMFontColor* font, int *time = NULL); + + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual bool RemoveThis(void); + + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + // Setta il colore di base + void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } +}; + +/** + * Gestisce il testo di un dialogo + */ +class RMTextDialog : public RMText +{ + protected: + int m_startTime; + int m_time; + bool m_bSkipStatus; + RMPoint dst; + HANDLE hEndDisplay; + bool m_bShowed; + bool m_bForceTime; + bool m_bForceNoTime; + HANDLE hCustomSkip; + HANDLE hCustomSkip2; + RMInput* m_input; + bool m_bAlwaysDisplay; + bool m_bNoTab; + + public: + RMTextDialog(); + virtual ~RMTextDialog(); + + // Scrive un testo + void WriteText(RMString text, int font, int *time=NULL); + void WriteText(RMString text, RMFontColor* font, int *time=NULL); + + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual bool RemoveThis(void); + + // Overloading della funzione di deregistrazione, utilizzata per capire + // quando ci leviamo di torno + virtual void Unregister(void); + + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + // Setta la posizione + void SetPosition(RMPoint pt) { dst=pt; } + + // Aspetta che venga finita la visualizzazione + void WaitForEndDisplay(void); + void SetCustomSkipHandle(HANDLE hCustomSkip); + void SetCustomSkipHandle2(HANDLE hCustomSkip); + void SetSkipStatus(bool bEnabled); + void SetForcedTime(uint32 dwTime); + void SetNoTab(void); + void ForceTime(void); + void ForceNoTime(void); + void SetAlwaysDisplay(void); + + // Setta il dispositivo di input, per permettere skip da mouse + void SetInput(RMInput* input); + + void Show(void); + void Hide(void); +}; + +class RMTextDialogScrolling : public RMTextDialog { +protected: + RMLocation* curLoc; + RMPoint startScroll; + + virtual void ClipOnScreen(RMGfxPrimitive* prim); + +public: + RMTextDialogScrolling(); + RMTextDialogScrolling(RMLocation* loc); + virtual ~RMTextDialogScrolling(); + + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); +}; + + +/****************************************************************************\ +* class RMTextItemName +* -------------------- +* Description: Gestisce il nome dell'oggetto selezionato su schermo +\****************************************************************************/ + +class RMTextItemName : protected RMText { +protected: + RMPoint m_mpos; + RMPoint m_curscroll; + RMItem* m_item; + RMString m_itemName; + +public: + RMTextItemName(); + virtual ~RMTextItemName(); + + void SetMouseCoord(RMPoint m) { m_mpos=m; } + + void DoFrame(RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + RMPoint GetHotspot() { if (m_item==NULL) return m_mpos+m_curscroll; else return m_item->Hotspot(); } + RMItem* GetSelectedItem() { return m_item; } + bool IsItemSelected() { return m_item!=NULL; } + bool IsNormalItemSelected() { return m_item!=NULL && m_itemName.Length()>0; } + + virtual bool RemoveThis() { return true; } +}; + + +/** + * Gestisce la schermata di scelta delle voci di un dialogo + */ +class RMDialogChoice : public RMGfxWoodyBuffer { +private: + int m_curSelection; + int m_numChoices; + RMText* m_drawedStrings; + RMPoint *m_ptDrawStrings; + int m_curAdded; + bool m_bShow; + RMGfxSourceBuffer8 DlgText; + RMGfxSourceBuffer8 DlgTextLine; + RMPoint m_ptDrawPos; + HANDLE hUnreg; + bool bRemoveFromOT; + +protected: + void Prepare(void); + void SetSelected(int pos); + +public: + bool RemoveThis(void); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + void Unregister(void); + +public: + // Inizializzazione + RMDialogChoice(); + virtual ~RMDialogChoice(); + + // Inizializzazione e chiusura + void Init(void); + void Close(void); + + // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte + // con AddChoice() + void SetNumChoices(int num); + + // Aggiunge una stringa con la scelta + void AddChoice(RMString string); + + // Mostra e nasconde la scelta, con eventuali animazioni + // NOTA: Se non viene passato parametro alla Show(), obbligo del + // chiamante assicurarsi che la classe venga inserita alla OTlist + void Show(RMGfxTargetBuffer* bigBuf = NULL); + void Hide(void); + + // Polling di aggiornamento + void DoFrame(RMPoint ptMousePos); + + // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata + int GetSelection(void); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp new file mode 100644 index 0000000000..48827cbc2a --- /dev/null +++ b/engines/tony/game.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/game.h" + +namespace Tony { + + + +} // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h new file mode 100644 index 0000000000..28f9489267 --- /dev/null +++ b/engines/tony/game.h @@ -0,0 +1,285 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Game.CPP............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_GAME_H +#define TONY_GAME_H + +#include "tony/adv.h" +#include "tony/gfxcore.h" +#include "tony/input.h" +#include "tony/loc.h" +#include "tony/utils.h" + +namespace Tony { + +class RMPointer : public RMGfxTask { +private: + RMGfxSourceBuffer8 *m_pointer[16]; + RMPoint m_hotspot[16]; + RMPoint m_pos; + + RMItem *m_specialPointer[16]; + + int m_nCurPointer; + int m_nCurSpecialPointer; + + RMGfxSourceBuffer8 *m_nCurCustomPointer; + +public: + enum POINTER { + PTR_NONE = 0, + PTR_FRECCIASU, + PTR_FRECCIAGIU, + PTR_FRECCIASINISTRA, + PTR_FRECCIADESTRA, + PTR_FRECCIAMAPPA, + PTR_CUSTOM + }; + +public: + // Constructor & destructor + RMPointer(); + virtual ~RMPointer(); + + // Initialisation + void Init(void); + + // Deinitialisation + void Close(void); + + // Process a frame + void DoFrame(RMGfxTargetBuffer *bigBuf); + + // Overloading of priorities + int Priority(); + + // Overloading draw method + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Sets the current co-ordinates + void SetCoord(RMPoint pt) { m_pos = pt; } + + // Overloading of the method to see if rising from the list + bool RemoveThis(); + + // Sets a new action as current + void SetAction(RMTonyAction action) { m_nCurPointer = action; } + + // Sets a new pointer + void SetSpecialPointer(POINTER ptr) { + m_nCurSpecialPointer=ptr; + if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[ptr-1]->SetPattern(1); + } + POINTER GetSpecialPointer(void) { return (POINTER)m_nCurSpecialPointer; } + + // Set the new custom pointer + void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { m_nCurCustomPointer = ptr; } + + // Return the current action to be applied according to the pointer + int CurAction(void); +}; + +class RMOptionButton: public RMGfxTaskSetPrior { +public: + RMRect m_rect; + RMGfxSourceBuffer16 *m_buf; + bool m_bActive; + bool m_bHasGfx; + bool m_bDoubleState; + +public: + RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false); + RMOptionButton(RMRect pt); + virtual ~RMOptionButton(); + + bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void AddToList(RMGfxTargetBuffer &bigBuf); + bool IsActive() { return m_bActive; } + void SetActiveState(bool bState) { m_bActive=bState; } +}; + +class RMOptionSlide : public RMGfxTaskSetPrior { +private: + RMOptionButton* m_PushLeft; + RMOptionButton* m_PushRight; + RMGfxSourceBuffer16* m_SliderCenter; + RMGfxSourceBuffer16* m_SliderLeft; + RMGfxSourceBuffer16* m_SliderRight; + RMGfxSourceBuffer16* m_SliderSingle; + int m_nSlideSize; + RMPoint m_pos; + int m_nValue; + int m_nMax; + int m_nStep; + +public: + RMOptionSlide(RMPoint pt, int m_nRange=100, int m_nStartValue=0, int slideSize=300); + virtual ~RMOptionSlide(); + + bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + void AddToList(RMGfxTargetBuffer& bigBuf); + + int GetValue() { return m_nValue; } +}; + +class RMOptionScreen : public RMGfxWoodyBuffer { +private: + RMGfxSourceBuffer16 *m_menu; + RMGfxSourceBuffer16 *m_QuitConfirm; + RMGfxSourceBuffer16 *m_HideLoadSave; + RMOptionButton *m_ButtonQuitYes; + RMOptionButton *m_ButtonQuitNo; + RMOptionButton *m_ButtonExit; + RMOptionButton *m_ButtonQuit; + RMOptionButton *m_ButtonLoad; + RMOptionButton *m_ButtonSave; + RMOptionButton *m_ButtonGameMenu; + RMOptionButton *m_ButtonGfxMenu; + RMOptionButton *m_ButtonSoundMenu; + RMGfxSourceBuffer8 *m_SaveEasy; + RMGfxSourceBuffer8 *m_SaveHard; + RMGfxSourceBuffer16 *m_curThumb[6]; + RMString m_curThumbName[6]; + byte m_curThumbDiff[6]; + RMOptionButton *m_ButtonSave_States[6]; + RMOptionButton *m_ButtonSave_ArrowLeft; + RMOptionButton *m_ButtonSave_ArrowRight; + RMOptionButton *m_ButtonGfx_Tips; + + RMOptionButton *m_ButtonSound_DubbingOn; + RMOptionButton *m_ButtonSound_MusicOn; + RMOptionButton *m_ButtonSound_SFXOn; + + RMOptionSlide *m_SlideTonySpeed; + RMOptionSlide *m_SlideTextSpeed; + + + int m_statePos; + bool m_bEditSaveName; + int m_nEditPos; + char m_EditName[256]; + + union { + RMOptionButton *m_ButtonGame_Lock; + RMOptionButton *m_ButtonGfx_Anni30; + RMOptionSlide *m_SliderSound_Music; + }; + union { + RMOptionButton *m_ButtonGame_TimerizedText; + RMOptionButton *m_ButtonGfx_AntiAlias; + RMOptionSlide *m_SliderSound_SFX; + }; + union { + RMOptionButton *m_ButtonGame_Scrolling; + RMOptionButton *m_ButtonGfx_Sottotitoli; + RMOptionSlide *m_SliderSound_Dubbing; + }; + union { + RMOptionButton *m_ButtonGame_InterUp; + RMOptionButton *m_ButtonGfx_Trans; + }; + + int m_FadeStep; + bool m_bExit; + bool m_bQuitConfirm; + int m_FadeY; + int m_FadeTime; + bool m_bLoadMenuOnly; + bool m_bNoLoadSave; + bool m_bAlterGfx; + + enum STATE { + MENUGAME, + MENUGFX, + MENUSOUND, + MENULOAD, + MENUSAVE + }; + + STATE m_nState; + STATE m_nLastState; + +public: + RMOptionScreen(); + virtual ~RMOptionScreen(); + + bool Init(RMGfxTargetBuffer& bigBuf); + bool InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); + bool InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); + bool InitNoLoadSave(RMGfxTargetBuffer &bigBuf); + void ReInit(RMGfxTargetBuffer &bigBuf); + bool Close(); + bool IsClosing(); + + // Metodi in overloading da RMGfxTask + int Priority(); + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + bool RemoveThis(); + + // Polling per l'option screen + void DoFrame(RMInput *m_input); + +protected: + + // Inizializza tutto per il nuovo stato + void InitState(void); + void CloseState(void); + void ChangeState(STATE newState); + + // Ridisegna tutto il menu delle opzioni + void RefreshAll(void); + void RefreshThumbnails(void); + + // Carica lo screenshot per il salvataggio + bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp new file mode 100644 index 0000000000..731521832f --- /dev/null +++ b/engines/tony/gfxcore.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/gfxEngine.h" + +namespace Tony { + + + +} // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h new file mode 100644 index 0000000000..313e471cdf --- /dev/null +++ b/engines/tony/gfxcore.h @@ -0,0 +1,547 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_GFXCORE_H +#define TONY_GFXCORE_H + +#include "common/system.h" +#include "tony/utils.h" + +namespace Tony { + +/****************************************************************************\ +* Prototipi di classi +\****************************************************************************/ + +// Nome della classe Albero genealogico Astratto? +class RMGfxTask; // Si +class RMGfxTaskSetPrior; // Task Si +class RMGfxBuffer; // +class RMGfxSourceBuffer; // TaskP+[Buffer] Si +class RMGfxTargetBuffer; // [Buffer] +class RMGfxSourceBufferPal; // Source Si +class RMGfxSourceBuffer4; // SourcePal +class RMGfxSourceBuffer8; // SourcePal +class RMGfxSourceBuffer16; // Source +class RMGfxWoodyBuffer; // Source16+Target +class RMGfxClearTask; // Task + + +/** + * Graphics buffer + */ +class RMGfxBuffer { +protected: + int m_dimx, m_dimy; + byte *m_buf; + byte *m_origBuf; + bool m_bUseDDraw; + +public: + RMGfxBuffer(); + RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual ~RMGfxBuffer(); + + // Attributes + int Dimx() { return m_dimx; } + int Dimy() { return m_dimy; } + + // Creation + virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void Destroy(void); + + // Buffer access + void Lock(void); + void Unlock(void); + + // These are valid only if the buffer is locked + operator byte *(); + operator void *(); + + // Getting the offset for a given Y position + void OffsetY(int nLines, int nBpp); +}; + +/** + * Graphics primitive + */ +class RMGfxPrimitive { +public: + RMGfxTask *m_task; + +protected: + RMRect m_src; + RMRect m_dst; + +bool m_bStretch; + byte m_bFlag; + +public: + RMGfxPrimitive() { m_bFlag = 0; m_task = NULL; m_src.SetEmpty(); m_dst.SetEmpty(); } + + RMGfxPrimitive(RMGfxTask *task) { + m_task = task; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMRect &dst) { + m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; + m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); + } + + RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMRect &dst) { + m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMPoint &dst) { + m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMPoint &dst) { + m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMRect &dst) { + m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMPoint &dst) { + m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; + } + + void SetFlag(byte bFlag) { m_bFlag=bFlag; } + void SetTask(RMGfxTask *task) { m_task = task; } + void SetSrc(RMRect &src) { m_src = src; } + void SetSrc(RMPoint &src) { m_src.TopLeft() = src; } + void SetDst(RMRect &dst) { m_dst = dst; } + void SetDst(RMPoint &dst) { m_dst.TopLeft() = dst; } + void SetStrecth(bool bStretch) { m_bStretch = bStretch; } + + bool HaveDst() { return !m_dst.IsEmpty(); } + RMRect &Dst() { return m_dst; } + + bool HaveSrc() { return !m_src.IsEmpty(); } + RMRect &Src() { return m_src; } + + // Flags + bool IsFlipped() { return m_bFlag&1; } + + // Duplicate + virtual RMGfxPrimitive* Duplicate() { return new RMGfxPrimitive(*this); } +}; + + +/** + * Graphic drawing task + */ +class RMGfxTask { +protected: + int m_nPrior; + int m_nInList; + +public: + // Costruttore standard + RMGfxTask(); + + virtual int Priority(); + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual bool RemoveThis(); + + // Registration + virtual void Register(void) { m_nInList++; } + virtual void Unregister(void) { m_nInList--; assert(m_nInList>=0); } +}; + + +/** + * Graphic drawing with priority + */ +class RMGfxTaskSetPrior : public RMGfxTask { +public: + void SetPriority(int nPrior); +}; + + +/** + * Task that cleans the destination buffer + */ +class RMGfxClearTask : public RMGfxTask { +public: + int Priority(); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + bool RemoveThis(); +}; + + +/** + * Task that draws a coloured box + */ +class RMGfxBox : public RMGfxTaskSetPrior { +protected: + uint16 wFillColor; + +public: + void SetColor(byte r, byte g, byte b); + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + bool RemoveThis(); +}; + + +/** + * Buffer source for the design, which is a task. This is an abstract base. + */ +class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { +public: + // Carica i dati della surface a basso livello + virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + + virtual ~RMGfxSourceBuffer(); + +protected: + virtual void PrepareImage(void); + bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); + void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines,Bpp()); } + +public: + virtual int Bpp() = 0; +}; + + +/** + * 16-bit colour source + */ +class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { +protected: + virtual void PrepareImage(void); + bool m_bTrasp0; + +public: + RMGfxSourceBuffer16(bool bUseTrasp = false); + RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); + virtual ~RMGfxSourceBuffer16(); + + // Inizializzazione + void Create(int dimx, int dimy, bool bUseDDraw = false); + + int Bpp(); + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); +}; + + +/** + * Buffer source with palette + */ +class RMGfxSourceBufferPal : public RMGfxSourceBuffer { +protected: + // The size of the palette is (1<MpalCode()); return *this; } + RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } + RMInventory& operator+=(int code) { AddItem(code); return *this; } + + // Rimozione di oggetto + void RemoveItem(int code); + + // Siamo sopra un oggetto? + RMItem* WhichItemIsIn(RMPoint mpt); + bool ItemInFocus(RMPoint mpt); + + // Cambia l'icona di un oggetto + void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); + + // Salvataggio + int GetSaveStateSize(void); + void SaveState(byte *state); + int LoadState(byte *state); +}; + + +class RMInterface : public RMGfxSourceBuffer8RLEByte { +private: + bool m_bActive; + RMPoint m_mpos; + RMPoint m_openPos; + RMPoint m_openStart; + RMText m_hints[5]; + RMGfxSourceBuffer8RLEByte m_hotzone[5]; + RMRect m_hotbbox[5]; + bool m_bPalesati; + int m_lastHotZone; + +protected: + // Dice su quale zona calda si trova il punto + int OnWhichBox(RMPoint pt); + +public: + virtual ~RMInterface(); + + // Il solito DoFrame (polling del motore grafico) + void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); + + // TRUE se attiva (non si pu selezionare oggetti) + bool Active(); + + // Inizializzazione + void Init(void); + void Close(void); + + // Resetta l'interfaccia + void Reset(void); + + // Avverte dei click e rilasci del mouse + void Clicked(RMPoint mousepos); + bool Released(RMPoint mousepos, RMTonyAction &action); + + // Attiva o disattiva il quinto verbo + void SetPalesati(bool bOn); + bool GetPalesati(void); + + // Overloading del Draw per il posizionamente + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a40248f57d..83c48bb938 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -32,10 +32,10 @@ * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * diff --git a/engines/tony/loc.h b/engines/tony/loc.h index e09a7389d9..1cae9edb1e 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -32,10 +32,10 @@ * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * @@ -49,10 +49,269 @@ #define TONY_LOC_H #include "common/scummsys.h" -#include "utils.h" +#include "common/system.h" +#include "tony/mpal/stubs.h" +#include "tony/sound.h" +#include "tony/utils.h" namespace Tony { +/****************************************************************************\ +* Various defines +\****************************************************************************/ + +/** + * Valid colour modes + */ +typedef enum { + CM_256, + CM_65K +} RMColorMode; + + +/****************************************************************************\ +* Class declarations +\****************************************************************************/ + +/** + * Generic palette + */ +class RMPalette { +public: + byte m_data[1024]; + +public: + friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); +}; + + +/** + * Sound effect of an object + */ +class RMSfx { +public: + RMString m_name; + FPSFX *m_fx; + bool m_bPlayingLoop; + +public: + RMSfx(); + virtual ~RMSfx(); + + friend RMDataStream& operator>>(RMDataStream &ds, RMSfx &sfx); + + void Play(bool bLoop = false); + void SetVolume(int vol); + void Pause(bool bPause); + void Stop(void); + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); +}; + + +/** + * Object pattern + */ +class RMPattern { +public: + // Type of slot + enum RMSlotType { + DUMMY1 = 0, + DUMMY2, + SPRITE, + SOUND, + COMMAND, + SPECIAL + }; + + // Class slot + class RMSlot { + private: + RMPoint m_pos; // Child co-ordinates + + public: + RMSlotType m_type; + int m_data; + byte m_flag; + + public: + friend RMDataStream& operator>>(RMDataStream& ds, RMSlot& slot); + + RMPoint Pos() { return m_pos; } + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); + }; + +public: + RMString m_name; + +private: + int m_speed; + RMPoint m_pos; // Coordinate babbo + RMPoint m_curPos; // Coordinate babbo+figlio + int m_bLoop; + int m_nSlots; + int m_nCurSlot; + int m_nCurSprite; + + RMSlot *m_slots; + + uint32 m_nStartTime; + +public: + RMPattern(); + virtual ~RMPattern(); + + friend RMDataStream& operator>>(RMDataStream& ds, RMPattern& pat); + + // A warning that the pattern now and the current + int Init(RMSfx* sfx, bool bPlayP0=false, byte* bFlag=NULL); + + // Update the pattern, checking to see if it's time to change slot and executing + // any associated commands + int Update(HANDLE hEndPattern, byte& bFlag, RMSfx* sfx); + + // Stop a sound effect + void StopSfx(RMSfx *sfx); + + // Reads the position of the pattern + RMPoint Pos() { return m_curPos; } + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); + +private: + void UpdateCoord(void); +}; + + +/** + * Sprite (frame) animation of an item + */ +class RMSprite : public RMGfxTask { +public: + RMString m_name; + RMRect m_rcBox; + +protected: + RMGfxSourceBuffer* m_buf; + +public: + RMSprite(); + virtual ~RMSprite(); + + void Init(RMGfxSourceBuffer* buf); + friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + void SetPalette(byte *lpBuf); + void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); +}; + + +/** + * Data on an item + */ +class RMItem : public RMGfxTask { +public: + RMString m_name; + +protected: + int m_z; + RMPoint m_pos; // Coordinate nonno + RMColorMode m_cm; + RMPoint m_curScroll; + + byte m_FX; + byte m_FXparm; + + virtual int GetCurPattern() { return m_nCurPattern; } + +private: + int m_nCurPattern; + int m_mpalCode; + RMPoint m_hot; + RMRect m_rcBox; + int m_nSprites,m_nSfx,m_nPatterns; + byte m_bPal; + RMPalette m_pal; + + RMSprite *m_sprites; + RMSfx *m_sfx; + RMPattern *m_patterns; + + byte m_bCurFlag; + int m_nCurSprite; + bool m_bIsActive; + HANDLE m_hEndPattern; + bool m_bInitCurPattern; + +public: + RMPoint CalculatePos(void); + +public: + RMItem(); + virtual ~RMItem(); + + friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); + + // Processa l'oggetto per fare andare avanti eventuale animazioni. Ritorna TRUE se dovr + // essere ridisegnato il prossimo frame + bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); + + // Setta la posizione corrente di scrolling + void SetScrollPosition(RMPoint scroll); + + // Overloading della funzione per la rimozione da ot list + virtual bool RemoveThis(); + + // Overloading del draw + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Overloading della priorit: la Z + virtual int Priority() { return m_z; } + + // Numero di pattern + int NumPattern() { return m_nPatterns; } + + // Setta un nuovo pattern di animazione, cambiando bruscamente da quello corrente + virtual void SetPattern(int nPattern, bool bPlayP0 = false); + + // Setta un nuovo status. + void SetStatus(int nStatus); + + bool IsIn(RMPoint pt, int* size=NULL); + RMPoint Hotspot() { return m_hot; } + bool GetName(RMString& name); + int MpalCode() { return m_mpalCode; } + + // Scarica l'item + void Unload(void); + + // Aspetta la fine del pattern in play + void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE); + + // Setta un nuovo hotspot per l'oggetto + void ChangeHotspot(RMPoint pt); + + void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } + + void PlaySfx(int nSfx); + +void ReadFromStream(RMDataStream& ds, bool bLOX=false); + + void PauseSound(bool bPause); + +protected: + // Crea una primitiva che ha come task l'item stesso + virtual RMGfxPrimitive *NewItemPrimitive(); + + // Alloca la memoria per gli sprites + virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); +}; + + #define MAXBOXES 50 // Non si puo' cambiare, comanda cosi' il boxed #define MAXHOTSPOT 20 // Idem @@ -122,6 +381,225 @@ public: void LoadState(byte *buf); }; +class RMCharacter : protected RMItem { +public: + enum PATTERNS { + PAT_STANDUP = 1, + PAT_STANDDOWN, + PAT_STANDLEFT, + PAT_STANDRIGHT, + PAT_WALKUP, + PAT_WALKDOWN, + PAT_WALKLEFT, + PAT_WALKRIGHT + }; + +private: + enum STATUS { + STAND, + WALK + }; + + signed short walkcount; + int dx, dy, olddx, olddy; + float fx, fy, slope; + RMPoint linestart, lineend, pathend; + signed char walkspeed, walkstatus; + char minpath; + short nextbox; + short path[MAXBOXES]; + short pathlenght, pathcount; + int curbox; + + STATUS status; + int curSpeed; + bool bEndOfPath; + HANDLE hEndOfPath; + OSystem::MutexRef csMove; + int curLocation; + bool bRemoveFromOT; + bool bMovingWithoutMinpath; + RMGameBoxes *theBoxes; + + RMPoint m_fixedScroll; + +private: + int InWhichBox(RMPoint pt); + + short FindPath(short source, short destination); + RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); + RMPoint NearestPoint(RMPoint punto); + + void GoTo(RMPoint destcoord, bool bReversed=false); + short ScanLine(RMPoint punto); + RMPoint InvScanLine(RMPoint punto); + RMPoint NearestHotSpot(int sourcebox, int destbox); + + void NewBoxEntered(int nBox); + +protected: + bool bMoving; + bool bDrawNow; + bool bNeedToStop; +// virtual RMGfxPrimitive* NewItemPrimitive(); + +public: + RMCharacter(); + virtual ~RMCharacter(); + + void LinkToBoxes(RMGameBoxes* theBoxes); + + virtual bool RemoveThis(void); + + // Aggiorna la posizione del personaggio + void DoFrame(RMGfxTargetBuffer* bigBuf, int loc); + + // Overloading del Draw + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + // TRUE se si appena fermato + bool EndOfPath() { return bEndOfPath; } + + // Cambia il pattern del personaggio per fermarlo + virtual void Stop(void); + + // Controlla se il personaggio si sta muovendo + bool IsMoving() { return bMoving; } + + // Muove il personaggio a una certa posizione + bool Move(RMPoint pt); + + // Posiziona il personaggio a una certa posizione SENZA farlo muovere + void SetPosition(RMPoint pt, int newloc=-1); + + // Aspetta la fine del movimento + void WaitForEndMovement(void) { if (bMoving) WaitForSingleObject(hEndOfPath, INFINITE); } + + void SetFixedScroll(RMPoint fix) { m_fixedScroll = fix; } + void SetSpeed(int speed) { curSpeed=speed; } +}; + + +class RMWipe : public RMGfxTask { +private: + bool m_bFading; + bool m_bEndFade; + bool m_bUnregister; + HANDLE m_hUnregistered; + int m_nFadeStep; + HANDLE m_hEndOfFade; + bool m_bMustRegister; + + RMItem m_wip0r; + +public: + RMWipe(); + virtual ~RMWipe(); + + void DoFrame(RMGfxTargetBuffer& bigBuf); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + void InitFade(int type); + void CloseFade(void); + void WaitForFadeEnd(void); + + virtual void Unregister(void); + virtual bool RemoveThis(void); + virtual int Priority(void); +}; + + +/** + * Location + */ +class RMLocation : public RMGfxTaskSetPrior { +public: + RMString m_name; // Nome + + private: + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer* m_buf; // Immagine della locazione + + int m_nItems; // Numero oggetti +RMItem* m_items; // Oggetti + + RMPoint m_curScroll; // Posizione corrente di scroll + RMPoint m_fixedScroll; + +public: + // @@@@@@@@@@@@@@@@@@@@@@@ + RMPoint TEMPTonyStart; + RMPoint TEMPGetTonyStart() { return TEMPTonyStart; } + + int TEMPNumLoc; + int TEMPGetNumLoc() { return TEMPNumLoc; } + +public: + RMLocation(); + virtual ~RMLocation(); + + // Caricamento da disco + bool Load(char *lpszFileName); + bool Load(HANDLE hFile); + bool Load(byte *buf); + bool Load(RMDataStream &ds); + bool LoadLOX(RMDataStream &ds); + + // Scaricamento + void Unload(void); + + // Overloading del Draw + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Prepara un frame disegnando la locazione e tutti i suoi item + void DoFrame(RMGfxTargetBuffer *bigBuf); + + // Si fa dare il numero dell'item + RMItem* WhichItemIsIn(RMPoint pt); + + // Si fa dare un elemento dal suo codice MPAL + RMItem* GetItemFromCode(uint32 dwCode); + + // Setta la posizione corrente di scrolling + void SetScrollPosition(RMPoint &scroll); + + // Setta un offset aggiuntivo di scrolling da aggiungere sempre + void SetFixedScroll(RMPoint &scroll); + + // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito + void UpdateScrolling(RMPoint ptShowThis); + + // Legge la posizione di scrolling corrente + RMPoint ScrollPosition() { return m_curScroll; } + + // Pausa sonoro + void PauseSound(bool bPause); +}; + + +/** + * MPAL message, composed of more ASCIIZ + */ +class RMMessage { +private: + char *lpMessage; + char *lpPeriods[256]; + int nPeriods; + +private: + void ParseMessage(void); + +public: + RMMessage(uint32 dwId); + virtual ~RMMessage(); + + bool IsValid() { return lpMessage != NULL; } + int NumPeriods() { return nPeriods; } + char *Period(int num) { return lpPeriods[num]; } + char *operator[](int num) { return lpPeriods[num]; } +}; + + } // End of namespace Tony #endif /* TONY_H */ diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 6aeb0a1583..cbc07d27b7 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,7 +2,12 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ + game.o \ + gfxcore.o \ + gfxengine.o \ + input.o \ loc.o \ + sound.o \ tony.o \ utils.o \ mpal/expr.o \ diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index dde2e8908c..fde0d33b3e 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -75,6 +75,10 @@ public: #define GlobalUnlock(handle) {} #define GlobalSize(handle) (_vm->_memoryManager.getItem(handle).Size()) +#define GMEM_FIXED 1 +#define GMEM_MOVEABLE 2 +#define GMEM_ZEROINIT 4 + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index be856790bc..a8d3253ddb 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -47,10 +47,6 @@ typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); * Defines \****************************************************************************/ -#define GMEM_FIXED 1 -#define GMEM_MOVEABLE 2 -#define GMEM_ZEROINIT 4 - #define MB_OK 1 #define PASCAL diff --git a/engines/tony/resid.h b/engines/tony/resid.h new file mode 100644 index 0000000000..01ed9b9bd2 --- /dev/null +++ b/engines/tony/resid.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. + * + */ +/* + * ResID.H - Include per le risorse MPAL + * + * Coded by Giovanni Bajo - Nayma/Prograph + * + * (C) 1997-98, Nayma Software + * (C) 1998, Prograph Research srl + * + */ + +/* + Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli +*/ +#ifndef TONY_RESID_H +#define TONY_RESID_H + + +#define RES_I_INTERFACE 10300 +#define RES_I_INTERPAL 10301 +#define RES_I_INTERPPAL 10302 +#define RES_I_INTERP1 10303 +#define RES_I_INTERP2 10304 +#define RES_I_INTERP3 10305 +#define RES_I_INTERP4 10306 +#define RES_I_INTERP5 10307 + +#define RES_I_DLGTEXT 10350 +#define RES_I_DLGTEXTLINE 10351 +#define RES_I_DLGTEXTPAL 10352 + +#define RES_I_MINIINTER 10360 + +#define RES_P_PAL 10410 +#define RES_P_GO 10400 +#define RES_P_TAKE 10401 +#define RES_P_USE 10402 +#define RES_P_EXAM 10403 +#define RES_P_TALK 10404 + +#define RES_P_PAP1 10420 +#define RES_P_PAP2 10421 +#define RES_P_PAP3 10422 +#define RES_P_PAP4 10423 +#define RES_P_FRMAP 10424 + +#define RES_F_PAL 10700 +#define RES_F_PARL 10701 +#define RES_F_OBJ 10702 +#define RES_F_MACC 10703 +#define RES_F_CREDITS 10704 +#define RES_F_CPAL 10705 + +#define RES_W_CERCHIO 10800 + +#endif diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp new file mode 100644 index 0000000000..5d940b3145 --- /dev/null +++ b/engines/tony/sound.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/game.h" + +namespace Tony { + + + +} // End of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h new file mode 100644 index 0000000000..75a70553ef --- /dev/null +++ b/engines/tony/sound.h @@ -0,0 +1,254 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_SOUND_H +#define TONY_SOUND_H + +#include "tony/gfxcore.h" +#include "tony/loc.h" +#include "tony/utils.h" + +namespace Tony { + +class FPSFX; + +enum CODECS { + FPCODEC_RAW, + FPCODEC_ADPCM, + FPCODEC_WAV +}; + +class FPSFX { + +/****************************************************************************\ +* Attributi +\****************************************************************************/ + +private: +/* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound +*/ + bool bSoundSupported; // TRUE se il suono e' attivo + bool bFileLoaded; // TRUE se e' stato aperto un file + bool bLoop; // TRUE se bisogna loopare l'effetto sonoro + bool bPaused; + int lastVolume; + + bool bStereo; // TRUE se stereo + bool b16bit; // TRUE se 16 bit + uint32 dwFreq; // Frequenza originale di campionamento + +// CODEC* lpCodec; // CODEC da utilizzare. + bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro + + bool bIsVoice; + +// LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer +// DSBPOSITIONNOTIFY dspnHot[2]; + +public: +// HANDLE hEndOfBuffer; + +private: + + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() +* +\****************************************************************************/ + + FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + + +/****************************************************************************\ +* +* Function: ~FPSFX(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare il sound +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. +* +\****************************************************************************/ + + ~FPSFX(); + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + + void Release(); + + +/****************************************************************************\ +* +* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di effetto sonoro e lo carica. +* +* Input: char *lpszFile Nome del file di sfx da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +\****************************************************************************/ + + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool LoadVoiceFromVDB(HANDLE hvdb); + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo sfx caricato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Play(); + + +/****************************************************************************\ +* +* Function: bool Stop(); +* +* Description: Ferma il play dello sfx. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Stop(); + + +/****************************************************************************\ +* +* Function: void Pause(bool bPause); +* +* Description: Pause dell'effetto sonoro +* +\****************************************************************************/ + + void Pause(bool bPause); + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello sfx. +* +* Input: bool bLoop TRUE per attivare il loop, FALSE per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello sfx. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo sfx non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + + void SetLoop(bool bLoop); + + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello sfx +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetVolume(int dwVolume); + + + +/****************************************************************************\ +* +* Function: void GetVolume(int * lpdwVolume); +* +* Description: Chiede il volume dello sfx +* +* Input: int * lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + + void GetVolume(int * lpdwVolume); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d5a5e467df..a370c8efaf 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -85,6 +85,9 @@ Common::ErrorCode TonyEngine::Init() { // Initialise the boxes _theBoxes.Init(); + // Link to the custom graphics engine + + return Common::kNoError; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 384b7a1f4c..a372260c34 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -33,6 +33,7 @@ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" +#include "tony/gfxEngine.h" #include "tony/loc.h" #include "tony/utils.h" @@ -91,6 +92,7 @@ public: Common::Array _voices; // Bounding box list manager RMGameBoxes _theBoxes; + RMGfxEngine _theEngine; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h new file mode 100644 index 0000000000..9d3c0202d0 --- /dev/null +++ b/engines/tony/tonychar.h @@ -0,0 +1,448 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_TONYCHAR_H +#define TONY_TONYCHAR_H + +#include "tony/mpal/stubs.h" + +namespace Tony { + +class RMTony : public RMCharacter { +private: + enum DIRECTION { + UP, DOWN, LEFT, RIGHT + }; + +public: + enum TALKTYPE { + TALK_NORMAL, + TALK_FIANCHI, + TALK_CANTA, + TALK_RIDE, + TALK_SIINDICA, + TALK_SPAVENTATO, + TALK_SPAVENTATO2, + TALK_CONBICCHIERE, + TALK_CONMARTELLO, + TALK_CONVERME, + TALK_CONCORDA, + TALK_CONCONIGLIO, + TALK_CONRICETTA, + TALK_CONCARTE, + TALK_CONPUPAZZO, + TALK_CONPUPAZZOSTATIC, + TALK_CONCONIGLIOSTATIC, + TALK_CONRICETTASTATIC, + TALK_CONCARTESTATIC, + TALK_CONTACCUINOSTATIC, + TALK_CONMEGAFONOSTATIC, + TALK_CONBARBASTATIC, + TALK_RIDE2, + TALK_SCHIFATO, + TALK_NAAH, + TALK_MACBETH1, + TALK_MACBETH2, + TALK_MACBETH3, + TALK_MACBETH4, + TALK_MACBETH5, + TALK_MACBETH6, + TALK_MACBETH7, + TALK_MACBETH8, + TALK_MACBETH9, + TALK_SPAVENTATOSTATIC, + TALK_CONSEGRETARIA + }; + +private: + bool m_bShow; + bool m_bShowOmbra; + bool m_bCorpoDavanti; + RMGfxSourceBuffer8AB m_ombra; + bool m_bActionPending; + RMItem *m_ActionItem; + int m_Action; + int m_ActionParm; + static bool m_bAction; + + bool m_bPastorella; + + bool m_bIsStaticTalk; + bool m_bIsTalking; + int m_nPatB4Talking; + TALKTYPE m_nTalkType; + DIRECTION m_TalkDirection; + RMPoint m_nBodyOffset; + + int m_nTimeLastStep; + + RMItem m_body; + HANDLE hActionThread; + +protected: + // Overload dell'allocazione degli sprites per cambiare il tipo + virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + + // Thread che aspetta la fine di un azione + static uint32 WaitEndOfAction(HANDLE hThread); + +public: // per farlo rialzare, altrimenti private + enum PATTERNS { + PAT_TAKEUP_UP1 = 9, + PAT_TAKEUP_UP2, + PAT_TAKEUP_MID1, + PAT_TAKEUP_MID2, + PAT_TAKEUP_DOWN1, + PAT_TAKEUP_DOWN2, + + PAT_TAKELEFT_UP1, + PAT_TAKELEFT_UP2, + PAT_TAKELEFT_MID1, + PAT_TAKELEFT_MID2, + PAT_TAKELEFT_DOWN1, + PAT_TAKELEFT_DOWN2, + + PAT_TAKERIGHT_UP1, + PAT_TAKERIGHT_UP2, + PAT_TAKERIGHT_MID1, + PAT_TAKERIGHT_MID2, + PAT_TAKERIGHT_DOWN1, + PAT_TAKERIGHT_DOWN2, + + PAT_SIRIALZALEFT, + PAT_PERTERRALEFT, + PAT_SIRIALZARIGHT, + PAT_PERTERRARIGHT, + + // Pastorella! + PAT_PAST_WALKUP, + PAT_PAST_WALKDOWN, + PAT_PAST_WALKLEFT, + PAT_PAST_WALKRIGHT, + + PAT_PAST_STANDUP, + PAT_PAST_STANDDOWN, + PAT_PAST_STANDLEFT, + PAT_PAST_STANDRIGHT, + + // Parlata + PAT_TALK_UP, + PAT_TALK_DOWN, + PAT_TALK_LEFT, + PAT_TALK_RIGHT, + + // Testa statica + PAT_TESTA_UP, + PAT_TESTA_DOWN, + PAT_TESTA_LEFT, + PAT_TESTA_RIGHT, + + // Risata + PAT_RIDELEFT_START, + PAT_RIDELEFT_LOOP, + PAT_RIDELEFT_END, + PAT_RIDERIGHT_START, + PAT_RIDERIGHT_LOOP, + PAT_RIDERIGHT_END, + + // Parlata da pastorella + PAT_PAST_TALKUP, + PAT_PAST_TALKDOWN, + PAT_PAST_TALKLEFT, + PAT_PAST_TALKRIGHT, + + // Spavento + PAT_SPAVENTOLEFT_START, + PAT_SPAVENTOLEFT_LOOP, + PAT_SPAVENTOLEFT_END, + PAT_SPAVENTORIGHT_START, + PAT_SPAVENTORIGHT_LOOP, + PAT_SPAVENTORIGHT_END, + PAT_SPAVENTODOWN_START, + PAT_SPAVENTODOWN_LOOP, + PAT_SPAVENTODOWN_END, + + // Con oggetti: corpo completo + PAT_CONBICCHIERE, + PAT_CONCORDA, + PAT_CONVERME, + PAT_CONMARTELLO, + + // Suona il fischietto + PAT_FISCHIETTORIGHT, + + // Testa con barba + PAT_TALKBARBA_LEFT, + PAT_TALKBARBA_RIGHT, + + // Sniff + PAT_SNIFFA_LEFT, + PAT_SNIFFA_RIGHT, + + // Schifato + PAT_SCHIFATOLEFT_START, + PAT_SCHIFATOLEFT_LOOP, + PAT_SCHIFATOLEFT_END, + PAT_SCHIFATORIGHT_START, + PAT_SCHIFATORIGHT_LOOP, + PAT_SCHIFATORIGHT_END, + PAT_NAAHLEFT_START, + PAT_NAAHLEFT_LOOP, + PAT_NAAHLEFT_END, + PAT_NAAHRIGHT_START, + PAT_NAAHRIGHT_LOOP, + PAT_NAAHRIGHT_END, + + // Stand spaventato + PAT_SPAVENTOLEFT_STAND, + PAT_SPAVENTORIGHT_STAND, + PAT_SPAVENTODOWN_STAND, + + PAT_PUTLEFT_UP1, + PAT_PUTLEFT_UP2, + PAT_PUTRIGHT_UP1, + PAT_PUTRIGHT_UP2, + PAT_PUTLEFT_MID1, + PAT_PUTLEFT_MID2, + PAT_PUTRIGHT_MID1, + PAT_PUTRIGHT_MID2, + PAT_PUTLEFT_DOWN1, + PAT_PUTLEFT_DOWN2, + PAT_PUTRIGHT_DOWN1, + PAT_PUTRIGHT_DOWN2, + PAT_PUTUP_UP1, + PAT_PUTUP_UP2, + PAT_PUTUP_MID1, + PAT_PUTUP_MID2, + PAT_PUTUP_DOWN1, + PAT_PUTUP_DOWN2, + + PAT_CONSEGRETARIA + }; + + enum BODYPATTERNS { + BPAT_STANDUP = 1, + BPAT_STANDDOWN, + BPAT_STANDLEFT, + BPAT_STANDRIGHT, + + BPAT_MARTELLO, + BPAT_PUPAZZO, + BPAT_VERME, + BPAT_BICCHIERE, + + BPAT_CANTALEFT_START, + BPAT_CANTALEFT_LOOP, + BPAT_CANTALEFT_END, + + BPAT_FIANCHILEFT_START, + BPAT_FIANCHILEFT_LOOP, + BPAT_FIANCHILEFT_END, + BPAT_FIANCHIRIGHT_START, + BPAT_FIANCHIRIGHT_LOOP, + BPAT_FIANCHIRIGHT_END, + BPAT_FIANCHIUP_START, + BPAT_FIANCHIUP_LOOP, + BPAT_FIANCHIUP_END, + BPAT_FIANCHIDOWN_START, + BPAT_FIANCHIDOWN_LOOP, + BPAT_FIANCHIDOWN_END, + + BPAT_RIDELEFT, + BPAT_RIDERIGHT, + + BPAT_SIINDICALEFT, + BPAT_SIINDICARIGHT, + + BPAT_SPAVENTODOWN_START, + BPAT_SPAVENTODOWN_LOOP, + BPAT_SPAVENTODOWN_END, + BPAT_SPAVENTOLEFT_START, + BPAT_SPAVENTOLEFT_LOOP, + BPAT_SPAVENTOLEFT_END, + BPAT_SPAVENTORIGHT_START, + BPAT_SPAVENTORIGHT_LOOP, + BPAT_SPAVENTORIGHT_END, + BPAT_SPAVENTOUP_START, + BPAT_SPAVENTOUP_LOOP, + BPAT_SPAVENTOUP_END, + + BPAT_CORDA, + + BPAT_CONCONIGLIOLEFT_START, + BPAT_CONCONIGLIOLEFT_LOOP, + BPAT_CONCONIGLIOLEFT_END, + BPAT_CONCONIGLIORIGHT_START, + BPAT_CONCONIGLIORIGHT_LOOP, + BPAT_CONCONIGLIORIGHT_END, + + BPAT_CONRICETTALEFT_START, + BPAT_CONRICETTALEFT_LOOP, + BPAT_CONRICETTALEFT_END, + BPAT_CONRICETTARIGHT_START, + BPAT_CONRICETTARIGHT_LOOP, + BPAT_CONRICETTARIGHT_END, + + BPAT_CONCARTELEFT_START, + BPAT_CONCARTELEFT_LOOP, + BPAT_CONCARTELEFT_END, + BPAT_CONCARTERIGHT_START, + BPAT_CONCARTERIGHT_LOOP, + BPAT_CONCARTERIGHT_END, + + BPAT_CONPUPAZZOLEFT_START, + BPAT_CONPUPAZZOLEFT_LOOP, + BPAT_CONPUPAZZOLEFT_END, + BPAT_CONPUPAZZORIGHT_START, + BPAT_CONPUPAZZORIGHT_LOOP, + BPAT_CONPUPAZZORIGHT_END, + + BPAT_CONTACCUINOLEFT_START, + BPAT_CONTACCUINOLEFT_LOOP, + BPAT_CONTACCUINOLEFT_END, + BPAT_CONTACCUINORIGHT_START, + BPAT_CONTACCUINORIGHT_LOOP, + BPAT_CONTACCUINORIGHT_END, + + BPAT_CONMEGAFONOLEFT_START, + BPAT_CONMEGAFONOLEFT_LOOP, + BPAT_CONMEGAFONOLEFT_END, + BPAT_CONMEGAFONORIGHT_START, + BPAT_CONMEGAFONORIGHT_LOOP, + BPAT_CONMEGAFONORIGHT_END, + + BPAT_CONBARBALEFT_START, + BPAT_CONBARBALEFT_END, + BPAT_CONBARBARIGHT_START, + BPAT_CONBARBARIGHT_END, + BPAT_CONBARBALEFT_STATIC, + BPAT_CONBARBARIGHT_STATIC, + + BPAT_MACBETH1, + BPAT_MACBETH2, + BPAT_MACBETH3, + BPAT_MACBETH4, + BPAT_MACBETH5, + BPAT_MACBETH6, + BPAT_MACBETH7, + BPAT_MACBETH8, + BPAT_MACBETH9, + + BPAT_CONSEGRETARIA + }; + +public: + // Inizializza Tony + void Init(void); + + // Libera tutta la memoria + void Close(void); + + // Fa un frame di Tony, aggiornando il movimento, etc + void DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc); + + // Metodi di Draw, che controlla la variabile di show + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Mostra o nascondi + void Show(void); + void Hide(bool bShowOmbra = false); + + // Si muove e fa un azione, se necessario + void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); + + // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) + virtual void Stop(void); + void StopNoAction(void); + + // Setta un pattern + void SetPattern(int npatt, bool bPlayP0 = false); + + // Legge il pattern corrente + int GetCurPattern(); + + // Attende la fine di un pattern + void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { RMCharacter::WaitForEndPattern(hCustomSkip);} + + // Controlla se si trova in azione + bool InAction() { return (m_bActionPending&&m_Action != 0) | m_bAction; } + + // Controlla se c' da aggiornare il movimento di scrolling + bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } + + // Prende la posizione di Tony + RMPoint Position() { return m_pos; } + + // Setta la posizione di scrolling + void SetScrollPosition(RMPoint pt) { RMCharacter::SetScrollPosition(pt); } + + // Setta l'animazione di Take + void Take(int nWhere, int nPart); + void Put(int nWhere, int nPart); + + // Start e End Talk + void StartTalk(TALKTYPE nTalkType); + void EndTalk(void); + + // Start e End Static + void StartStatic(TALKTYPE nTalkType); + void EndStatic(TALKTYPE nTalkType); + + // Tony si traveste! + void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } + int GetPastorella(void) { return m_bPastorella; } + + // Esegue una azione + void ExecuteAction(int nAction, int nActionItem, int nParm); + + void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } +}; + + +} // End of namespace Tony + +#endif diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 76d168e27a..48dcb9392a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -28,14 +28,14 @@ * .z$* d$$$$$$$L ^*$c. * * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * diff --git a/engines/tony/utils.h b/engines/tony/utils.h index bec42b343b..54e4cd0eae 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -28,14 +28,14 @@ * .z$* d$$$$$$$L ^*$c. * * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * -- cgit v1.2.3 From 68bcaa61b9eb1108028b3db072ade95431b9f14f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 23:16:19 +1000 Subject: TONY: More header files and functionality added --- engines/tony/adv.h | 35 + engines/tony/custom.cpp | 2511 +++++++++++++++++++++++++++++++++++++++++++ engines/tony/custom.h | 106 ++ engines/tony/detection.cpp | 4 + engines/tony/font.h | 12 +- engines/tony/game.cpp | 1148 ++++++++++++++++++++ engines/tony/gfxcore.h | 2 +- engines/tony/gfxengine.h | 4 +- engines/tony/input.h | 2 +- engines/tony/loc.h | 6 +- engines/tony/module.mk | 1 + engines/tony/mpal/lzo.cpp | 14 + engines/tony/mpal/lzo.h | 11 + engines/tony/mpal/stubs.cpp | 10 + engines/tony/mpal/stubs.h | 8 + engines/tony/sound.h | 365 ++++++- engines/tony/tony.cpp | 68 +- engines/tony/tony.h | 94 +- engines/tony/tonychar.h | 1 + engines/tony/utils.cpp | 2 +- engines/tony/window.h | 134 +++ 21 files changed, 4512 insertions(+), 26 deletions(-) create mode 100644 engines/tony/custom.cpp create mode 100644 engines/tony/custom.h create mode 100644 engines/tony/window.h (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index b29e4eb0cd..aab7df24af 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -48,8 +48,24 @@ #ifndef TONY_ADV_H #define TONY_ADV_H +#include "tony/mpal/memory.h" +#include "tony/gfxcore.h" + + namespace Tony { +// X & Y dimensions of the adventure +#define RM_SX 640 +#define RM_SY 480 + +// Dimensioni X&Y del bigbuf +#define RM_BBX (RM_SX) +#define RM_BBY (RM_SY) + +// Skipping X&Y +#define RM_SKIPY ((RM_BBY - RM_SY) / 2) +#define RM_SKIPX 0 + // Tony's actions enum RMTonyAction { TA_GOTO = 0, @@ -65,6 +81,25 @@ enum RMTonyAction { TA_RECEIVECOMBINEGIVE }; +// Funzioni globali +HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); +HANDLE MainUnloadLocation(bool bDoOnExit); +void MainLinkGraphicTask(RMGfxTask *task); +void MainFreeze(void); +void MainUnfreeze(void); +void MainWaitFrame(void); +void MainShowMouse(void); +void MainHideMouse(void); +void MainEnableInput(void); +void MainDisableInput(void); +void MainPlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); +void MainInitWipe(int type); +void MainCloseWipe(void); +void MainWaitWipeEnd(void); +void MainEnableGUI(void); +void MainDisableGUI(void); +void MainSetPalesati(bool bPalesati); + } // End of namespace Tony #endif diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp new file mode 100644 index 0000000000..55f6cbe77d --- /dev/null +++ b/engines/tony/custom.cpp @@ -0,0 +1,2511 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Custom functions..... * + * z$$beu .ue=" $ "=e.. .zed$$c ..................... * + * "#$e z$*" . `. ^*Nc e$"" ..................... * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + ************************************************************************** + */ + +#include "common/system.h" +#include "common/savefile.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/memory.h" +#include "tony/adv.h" +#include "tony/custom.h" +#include "tony/font.h" +#include "tony/game.h" +#include "tony/gfxcore.h" +#include "tony/tony.h" +#include "tony/tonychar.h" +#include "tony/utils.h" + +namespace Tony { + +extern bool bPatIrqFreeze; + +RMTony *Tony; +RMPointer *Pointer; +RMGameBoxes *Boxes; +RMLocation *Loc; +RMInventory *Inventory; +RMInput *Input; + +HANDLE (*LoadLocation)(int, RMPoint, RMPoint start); +HANDLE (*UnloadLocation)(bool bDoOnExit); +void (*LinkGraphicTask)(RMGfxTask *task); +void (*Freeze)(void); +void (*Unfreeze)(void); +void (*WaitFrame)(void); +void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); +void (*WaitWipeEnd)(void); +void (*CloseWipe)(void); +void (*InitWipe)(int type); +void (*EnableGUI)(void); +void (*DisableGUI)(void); +void (*SetPalesati)(bool bpal); + +uint32 dwTonyNumTexts = 0; +bool bTonyInTexts = false; +bool bStaticTalk = false; +RMTony::TALKTYPE nTonyNextTalkType; + +RMPoint StartLocPos[256]; +OSystem::MutexRef cs[10]; +OSystem::MutexRef vdb; +HANDLE mut[10]; + +bool bSkipIdle = false; +HANDLE hSkipIdle; + +int lastMusic = 0, lastTappeto = 0; + +int tappeti[200]; + +#define T_GRILLI 1 +#define T_GRILLIOV 2 +#define T_GRILLIVENTO 3 +#define T_GRILLIVENTO1 4 +#define T_VENTO 5 +#define T_MARE 6 +#define T_MAREMETA 7 + +char* tappetiFile[] = { + "None", + "1.ADP", // Grilli.WAV + "2.ADP", // Grilli-Ovattati.WAV + "3.ADP", // Grilli-Vento.WAV + "3.ADP", // Grilli-Vento1.WAV + "5.ADP", // Vento1.WAV + "4.ADP", // Mare1.WAV + "6.ADP" // Mare1.WAV met volume +}; + +struct { + uint32 code; + RMItem *item; + byte r, g, b; + int talkpattern; + int standpattern; + int starttalkpattern, endtalkpattern; + int numtexts; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(talkpattern); + f->writeUint32LE(standpattern); + f->writeUint32LE(starttalkpattern); + f->writeUint32LE(endtalkpattern); + f->writeUint32LE(numtexts); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + talkpattern = f->readUint32LE(); + standpattern = f->readUint32LE(); + starttalkpattern = f->readUint32LE(); + endtalkpattern = f->readUint32LE(); + numtexts = f->readUint32LE(); + } +} Character[16]; + +struct { + uint32 code; + RMItem *item; + byte r, g, b; + int x, y; + int numtalks[10]; + int curgroup; + int numtexts; + bool bInTexts; + int curTalk; + bool bAlwaysBack; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(x); + f->writeUint32LE(y); + for (int i = 0; i < 10; ++i) + f->writeUint32LE(numtalks[i]); + f->writeUint32LE(curgroup); + f->writeUint32LE(numtexts); + f->writeByte(bInTexts); + f->writeUint32LE(curTalk); + f->writeByte(bAlwaysBack); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + x = f->readUint32LE(); + y = f->readUint32LE(); + for (int i = 0; i < 10; ++i) + numtalks[i] = f->readUint32LE(); + curgroup = f->readUint32LE(); + numtexts = f->readUint32LE(); + bInTexts = f->readByte(); + curTalk = f->readUint32LE(); + bAlwaysBack = f->readByte(); + } +} MCharacter[10]; + +bool IsMChar[16]; + +bool bAlwaysDisplay; + +RMPoint saveTonyPos; +int saveTonyLoc; + +RMTextDialog *curBackText = NULL; +bool bTonyIsSpeaking = false; + +int curChangedHotspot = 0; + +struct { + uint32 dwCode; + uint32 nX,nY; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(dwCode); + f->writeUint32LE(nX); + f->writeUint32LE(nY); + } + void Load(Common::InSaveFile *f) { + dwCode = f->readUint32LE(); + nX = f->readUint32LE(); + nY = f->readUint32LE(); + } +} ChangedHotspot[256]; + +void ReapplyChangedHotspot(void) { + int i; + for (i = 0; iGetItemFromCode(ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(ChangedHotspot[i].nX, ChangedHotspot[i].nY)); +} + +void SaveChangedHotspot(Common::OutSaveFile *f) { + f->writeByte(curChangedHotspot); + if (curChangedHotspot > 0) { + for (int i = 0; i < curChangedHotspot; ++i) + ChangedHotspot[i].Save(f); + } +} + +void LoadChangedHotspot(Common::InSaveFile *f) { + curChangedHotspot = f->readByte(); + + if (curChangedHotspot > 0) { + for (int i = 0; i < curChangedHotspot; ++i) + ChangedHotspot[i].Load(f); + } +} + + +/* + Classi richieste per le funzioni custom! + + Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s + + SendMessage -> Direi che basta theEngine.SendMessage() + ChangeLocation -> theEngine.ChangeLocation() + AddInventory -> theEngine.AddInventory() +*/ + +void MCharResetCodes(void) { + for (int i = 0; i < 10; i++) + MCharacter[i].item = Loc->GetItemFromCode(MCharacter[i].code); + for (int i = 0; i < 10; i++) + Character[i].item = Loc->GetItemFromCode(Character[i].code); +} + +void CharsSaveAll(Common::OutSaveFile *f) { + for (int i = 0; i < 10; i++) { + f->writeByte(IsMChar[i]); + if (IsMChar[i]) { + MCharacter[i].Save(f); + } else { + Character[i].Save(f); + } + } +} + +void CharsLoadAll(Common::InSaveFile *f) { + for (int i = 0; i < 10; i++) { + IsMChar[i] = f->readByte(); + if (IsMChar[i]) + MCharacter[i].Load(f); + else + Character[i].Load(f); + } +} + +DECLARE_CUSTOM_FUNCTION(FaceToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDDOWN); +} + +DECLARE_CUSTOM_FUNCTION(BackToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDUP); +} + +DECLARE_CUSTOM_FUNCTION(LeftToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDLEFT); +} + +DECLARE_CUSTOM_FUNCTION(RightToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDRIGHT); +} + + +DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(uint32 bStatus, uint32, uint32, uint32) { + SetPalesati(bStatus); +} + +DECLARE_CUSTOM_FUNCTION(MySleep)(uint32 dwTime, uint32, uint32, uint32) { + if (bSkipIdle) return; + Sleep(dwTime); +} + +DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(uint32 val, uint32, uint32, uint32) { + bAlwaysDisplay = (val != 0); +} + + +DECLARE_CUSTOM_FUNCTION(SetPointer)(uint32 dwPointer, uint32, uint32, uint32) { + switch (dwPointer) { + case 1: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASU); + break; + case 2: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAGIU); + break; + case 3: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASINISTRA); + break; + case 4: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIADESTRA); + break; + case 5: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAMAPPA); + break; + + default: + Pointer->SetSpecialPointer(Pointer->PTR_NONE); + break; + } +} + +VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { + uint i; + int code; + + code = (codehi << 16) | codelo; + + if (_vm->_voices.size() == 0) + return NULL; + + for (i = 0; i < _vm->_voices.size(); i++) + if (_vm->_voices[i].code == code) + return &_vm->_voices[i]; + + return NULL; +} + + +DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(uint32 dwMessage, uint32 nX, uint32 nY, uint32) { + RMMessage msg(dwMessage); + int i; + int curOffset = 0; + + if (bSkipIdle) return; + + if (!msg.IsValid()) + return; + + VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); + FPSFX *voice = NULL; + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima + curOffset = curVoc->offset; + + // PRIMA VOLTA PREALLOCA + g_system->lockMutex(vdb); + //fseek(_vm->m_vdbFP, curOffset, SEEK_SET); + _vm->_vdbFP.seek(curOffset); + _vm->_theSound.CreateSfx(&voice); + voice->LoadVoiceFromVDB(_vm->_vdbFP); +// curOffset = ftell(_vm->m_vdbFP); + curOffset = _vm->_vdbFP.pos(); + + voice->SetLoop(false); + g_system->unlockMutex(vdb); + } + + if (nTonyNextTalkType != Tony->TALK_NORMAL) { + Tony->StartTalk(nTonyNextTalkType); + if (!bStaticTalk) + nTonyNextTalkType = Tony->TALK_NORMAL; + } else { + if (msg.NumPeriods() > 1) + Tony->StartTalk(Tony->TALK_FIANCHI); + else + Tony->StartTalk(Tony->TALK_NORMAL); + } + + if (curBackText) + curBackText->Hide(); + bTonyIsSpeaking = true; + + for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + RMTextDialog text; + + text.SetInput(Input); + + // Allineamento + text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + + // Colore + text.SetColor(0,255,0); + + // Scrive il testo + text.WriteText(msg[i],0); + + // Setta la posizione + if (nX == 0 && nY == 0) + text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); + else + text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); + + // Setta l'always display + if (bAlwaysDisplay) { text.SetAlwaysDisplay(); text.ForceTime(); } + + // Registra il testo + LinkGraphicTask(&text); + + if (curVoc) { + if (i == 0) { + voice->Play(); + text.SetCustomSkipHandle2(voice->hEndOfBuffer); + } else { + g_system->lockMutex(vdb); + // fseek(_vm->m_vdbFP, curOffset, SEEK_SET); + _vm->_vdbFP.seek(curOffset); + _vm->_theSound.CreateSfx(&voice); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + // curOffset = ftell(_vm->m_vdbFP); + curOffset = _vm->_vdbFP.pos(); + voice->SetLoop(false); + voice->Play(); + text.SetCustomSkipHandle2(voice->hEndOfBuffer); + g_system->unlockMutex(vdb); + } + } + + // Aspetta la fine della visualizzazione + text.SetCustomSkipHandle(hSkipIdle); + text.WaitForEndDisplay(); + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + } + + bTonyIsSpeaking = false; + if (curBackText) + curBackText->Show(); + + Tony->EndTalk(); +} + +DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { + Boxes->ChangeBoxStatus(nLoc,nBox,nStatus); +} + + +DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { + HANDLE h; + + Freeze(); + + curChangedHotspot = 0; + if (bUseStartPos != 0) + LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + else + LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + + Unfreeze(); + h = mpalQueryDoAction(0, nLoc, 0); + + // On Enter? + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h, INFINITE); +} + + +RMPoint SFM_pt; +int SFM_nLoc; + +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(uint32 nMsg, uint32 nFont, uint32, uint32) { + RMMessage msg(nMsg); + RMGfxClearTask clear; + int i; + + SFM_nLoc = Loc->TEMPGetNumLoc(); + SFM_pt = Tony->Position(); + + if (bSkipIdle) return; + + UnloadLocation(false); + Tony->Hide(); + Unfreeze(); + + for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + RMTextDialog text; + + text.SetInput(Input); + + // Allineamento + text.SetAlignType(RMText::HCENTER,RMText::VCENTER); + + // Forza il testo a scomparire a tempo + text.ForceTime(); + + // Colore + text.SetColor(255,255,255); + + // Scrive il testo + if (nFont== 0) + text.WriteText(msg[i],1); + else if (nFont==1) + text.WriteText(msg[i],0); + + // Setta la posizione + text.SetPosition(RMPoint(320,240)); + + text.SetAlwaysDisplay(); + text.ForceTime(); + + // Registra il testo + LinkGraphicTask(&clear); + LinkGraphicTask(&text); + + // Aspetta la fine della visualizzazione + text.SetCustomSkipHandle(hSkipIdle); + text.WaitForEndDisplay(); + } +} + +DECLARE_CUSTOM_FUNCTION(ClearScreen)(uint32, uint32, uint32, uint32) { + RMGfxClearTask clear; + + LinkGraphicTask(&clear); + WaitFrame(); +} + +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(uint32 bNotEnableTony, uint32, uint32, uint32) { + Freeze(); + LoadLocation(SFM_nLoc,RMPoint(SFM_pt.x,SFM_pt.y),RMPoint(-1,-1)); + if (!bNotEnableTony) + Tony->Show(); + Unfreeze(); + + MCharResetCodes(); + ReapplyChangedHotspot(); +} + + +DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(uint32 nMsg, uint32 nFont, uint32, uint32) { + SendFullscreenMsgStart(nMsg,nFont,0,0); + SendFullscreenMsgEnd(0, 0, 0, 0); +} + +bool bNoOcchioDiBue = false; + +DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(uint32, uint32, uint32, uint32) { + bNoOcchioDiBue = true; +} + +DECLARE_CUSTOM_FUNCTION(CloseLocation)(uint32, uint32, uint32, uint32) { + if (!bNoOcchioDiBue) { + InitWipe(1); + WaitWipeEnd(); + } + + _vm->StopMusic(4); + + // On Exit e lascia freezzato + UnloadLocation(true); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { + HANDLE h; + + if (!bNoOcchioDiBue) { + InitWipe(1); + WaitWipeEnd(); + } + + if (lastTappeto != tappeti[nLoc]) { + _vm->StopMusic(4); + } + + // On Exit e lascia freezzato + UnloadLocation(true); + + curChangedHotspot = 0; + if (bUseStartPos != 0) + LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + else + LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + + if (lastTappeto != tappeti[nLoc]) { + lastTappeto = tappeti[nLoc]; + if (lastTappeto != 0) + _vm->PlayMusic(4, tappetiFile[lastTappeto], 0, true, 2000); + } + + if (!bNoOcchioDiBue) { + InitWipe(2); + } + + Unfreeze(); + + + h = mpalQueryDoAction(0,nLoc,0); + + if (!bNoOcchioDiBue) { + WaitWipeEnd(); + CloseWipe(); + } + + bNoOcchioDiBue = false; + + // On Enter? + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + +} + +DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(uint32 nLoc, uint32 lX, uint32 lY, uint32) { + StartLocPos[nLoc].Set(lX,lY); +} + +DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(uint32, uint32, uint32, uint32) { + saveTonyPos = Tony->Position(); + saveTonyLoc = Loc->TEMPGetNumLoc(); +} + +DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(uint32, uint32, uint32, uint32) { + ChangeLocation(saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); + MCharResetCodes(); +} + + +DECLARE_CUSTOM_FUNCTION(DisableInput)(uint32, uint32, uint32, uint32) { + MainDisableInput(); +} + + +DECLARE_CUSTOM_FUNCTION(EnableInput)(uint32, uint32, uint32, uint32) { + MainEnableInput(); +} + +DECLARE_CUSTOM_FUNCTION(StopTony)(uint32, uint32, uint32, uint32) { + Tony->StopNoAction(); +} + + +DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(uint32, uint32, uint32, uint32) { + EnableGUI(); +} + +DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(uint32, uint32, uint32, uint32) +{ + DisableGUI(); +} + + +void TonyGenericTake1(uint32 nDirection) { + Freeze(); + Tony->Take(nDirection,0); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); +} + +void TonyGenericTake2(uint32 nDirection) { + Freeze(); + Tony->Take(nDirection,1); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); + + Freeze(); + Tony->Take(nDirection,2); + Unfreeze(); +} + +void TonyGenericPut1(uint32 nDirection) { + Freeze(); + Tony->Put(nDirection,0); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); +} + +void TonyGenericPut2(uint32 nDirection) { + Freeze(); + Tony->Put(nDirection,1); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); + + Freeze(); + Tony->Put(nDirection,2); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(uint32, uint32, uint32, uint32) { + TonyGenericTake1(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(uint32, uint32, uint32, uint32) { + TonyGenericTake1(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(uint32, uint32, uint32, uint32) { + TonyGenericTake1(2); +} + + + +DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(uint32, uint32, uint32, uint32) { + TonyGenericTake2(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(uint32, uint32, uint32, uint32) { + TonyGenericTake2(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(uint32, uint32, uint32, uint32) { + TonyGenericTake2(2); +} + + + + + + + +DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(uint32, uint32, uint32, uint32) { + TonyGenericPut1(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(uint32, uint32, uint32, uint32) { + TonyGenericPut1(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(uint32, uint32, uint32, uint32) { + TonyGenericPut1(2); +} + +DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(uint32, uint32, uint32, uint32) { + TonyGenericPut2(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(uint32, uint32, uint32, uint32) { + TonyGenericPut2(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(uint32, uint32, uint32, uint32) { + TonyGenericPut2(2); +} + + + +DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(uint32 dwParte, uint32, uint32, uint32) { + if (dwParte== 0) + Tony->SetPattern(Tony->PAT_PERTERRALEFT); + else + Tony->SetPattern(Tony->PAT_PERTERRARIGHT); +} + +DECLARE_CUSTOM_FUNCTION(TonySiRialza)(uint32 dwParte, uint32, uint32, uint32) { + if (dwParte== 0) + Tony->SetPattern(Tony->PAT_SIRIALZALEFT); + else + Tony->SetPattern(Tony->PAT_SIRIALZARIGHT); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); +} + +DECLARE_CUSTOM_FUNCTION(TonyPastorella)(uint32 bIsPast, uint32, uint32, uint32) { + Tony->SetPastorella(bIsPast); +} + +DECLARE_CUSTOM_FUNCTION(TonyFischietto)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); + if (!bSkipIdle) + Tony->WaitForEndPattern(); + Tony->SetPattern(Tony->PAT_STANDRIGHT); +} + + +void TonySetNumTexts(uint32 dwText) { + dwTonyNumTexts=dwText; + bTonyInTexts = false; +} + +DECLARE_CUSTOM_FUNCTION(TonyRide)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_RIDE; +} + +DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_RIDE2; +} + +DECLARE_CUSTOM_FUNCTION(TonyFianchi)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_FIANCHI; +} + +DECLARE_CUSTOM_FUNCTION(TonyCanta)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CANTA; +} + +DECLARE_CUSTOM_FUNCTION(TonySiIndica)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SIINDICA; +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SPAVENTATO; +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SPAVENTATO2; +} + +DECLARE_CUSTOM_FUNCTION(TonyConMartello)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONMARTELLO; + Tony->SetPattern(Tony->PAT_CONMARTELLO); +} + +DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONBICCHIERE; + Tony->SetPattern(Tony->PAT_CONBICCHIERE); +} + +DECLARE_CUSTOM_FUNCTION(TonyConVerme)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONVERME; + Tony->SetPattern(Tony->PAT_CONVERME); +} + +DECLARE_CUSTOM_FUNCTION(TonyConCorda)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONCORDA; + Tony->SetPattern(Tony->PAT_CONCORDA); +} + +DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONSEGRETARIA; + Tony->SetPattern(Tony->PAT_CONSEGRETARIA); +} + +DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONCONIGLIO; +} + +DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONRICETTA; +} + +DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONCARTE; +} + +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONPUPAZZO; +} + +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONPUPAZZOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONPUPAZZOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONCONIGLIOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONCONIGLIOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONRICETTASTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONRICETTASTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONCARTESTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONCARTESTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONTACCUINOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONTACCUINOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONMEGAFONOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONMEGAFONOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONBARBASTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONBARBASTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_SPAVENTATOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_SPAVENTATOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + + + +DECLARE_CUSTOM_FUNCTION(TonySchifato)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SCHIFATO; +} + +DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); + Tony->WaitForEndPattern(); + LeftToMe(0, 0, 0, 0); +} + +DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); + Tony->WaitForEndPattern(); + RightToMe(0, 0, 0, 0); +} + +DECLARE_CUSTOM_FUNCTION(TonyNaah)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_NAAH; +} + +DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(uint32 nPos, uint32, uint32, uint32) { + switch (nPos) { + case 1: + nTonyNextTalkType = Tony->TALK_MACBETH1; + break; + case 2: + nTonyNextTalkType = Tony->TALK_MACBETH2; + break; + case 3: + nTonyNextTalkType = Tony->TALK_MACBETH3; + break; + case 4: + nTonyNextTalkType = Tony->TALK_MACBETH4; + break; + case 5: + nTonyNextTalkType = Tony->TALK_MACBETH5; + break; + case 6: + nTonyNextTalkType = Tony->TALK_MACBETH6; + break; + case 7: + nTonyNextTalkType = Tony->TALK_MACBETH7; + break; + case 8: + nTonyNextTalkType = Tony->TALK_MACBETH8; + break; + case 9: + nTonyNextTalkType = Tony->TALK_MACBETH9; + break; + } +} + + +DECLARE_CUSTOM_FUNCTION(EnableTony)(uint32, uint32, uint32, uint32) { + Tony->Show(); +} + +DECLARE_CUSTOM_FUNCTION(DisableTony)(uint32 bShowOmbra, uint32, uint32, uint32) { + Tony->Hide(bShowOmbra); +} + +DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) { + RMItem *item = Loc->GetItemFromCode(nItem); + + if (!bSkipIdle && item != NULL) + item->WaitForEndPattern(hSkipIdle); +} + + +DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(uint32 nX, uint32 nY, uint32 nLoc, uint32) { + Tony->SetPosition(RMPoint(nX,nY),nLoc); +} + +DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(uint32 nX, uint32 nY, uint32, uint32) { + Tony->Move(RMPoint(nX,nY)); + + if (!bSkipIdle) + Tony->WaitForEndMovement(); +} + +DECLARE_CUSTOM_FUNCTION(MoveTony)(uint32 nX, uint32 nY, uint32, uint32) { + Tony->Move(RMPoint(nX,nY)); +} + +DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { + int lx, ly; + RMPoint pt; + + // Prende le coordinate di quanto scrollare + lx=*((int*)&nX); + ly=*((int*)&nY); + + pt=Loc->ScrollPosition(); + + while ((lx != 0 || ly != 0) && !bSkipIdle) { + if (lx>0) { + lx -= (int32)sX; if (lx<0) lx = 0; + pt.Offset((int32)sX, 0); + } else if (lx<0) { + lx += (int32)sX; if (lx>0) lx = 0; + pt.Offset(-(int32)sX, 0); + } + + if (ly > 0) { + ly-=sY; if (ly<0) ly = 0; + pt.Offset(0,sY); + } + else if (ly<0) + { + ly+=sY; if (ly>0) ly = 0; + pt.Offset(0, -(int32)sY); + } + + WaitFrame(); + + Freeze(); + Loc->SetScrollPosition(pt); + Tony->SetScrollPosition(pt); + Unfreeze(); + + } +} + +DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { + int lx, ly; + RMPoint pt,startpt; + uint32 dwStartTime,dwCurTime,dwTotalTime; + uint32 stepX, stepY; + int dimx,dimy; + + // Prende le coordinate di quanto scrollare + lx=*((int*)&nX); + ly=*((int*)&nY); + dimx=lx; + dimy=ly; + if (lx<0) dimx = -lx; + if (ly<0) dimy = -ly; + + stepX = sX; + stepY = sY; + + startpt = Loc->ScrollPosition(); + + dwStartTime = timeGetTime(); + + if (sX) + dwTotalTime = dimx*(1000/35)/sX; + else + dwTotalTime = dimy*(1000/35)/sY; + + while ((lx != 0 || ly != 0) && !bSkipIdle) + { + dwCurTime=timeGetTime()-dwStartTime; + if (dwCurTime>dwTotalTime) + break; + + pt = startpt; + + if (sX) { + if (lx > 0) + pt.x += (dimx * dwCurTime) / dwTotalTime; + else + pt.x -= (dimx * dwCurTime) / dwTotalTime; + } else { + if (ly > 0) + pt.y += (dimy*dwCurTime) / dwTotalTime; + else + pt.y -= (dimy*dwCurTime) / dwTotalTime; + + } + +/* + sX = stepX * (dwCurTime-dwLastTime) / (1000/35); + sY = stepY * (dwCurTime-dwLastTime) / (1000/35); + + if (lx>0) + { + lx-=sX; if (lx<0) lx = 0; + pt.Offset(sX,0); + } + else if (lx<0) + { + lx+=sX; if (lx>0) lx = 0; + pt.Offset(-sX,0); + } + + if (ly>0) + { + ly-=sY; if (ly<0) ly = 0; + pt.Offset(0,sY); + } + else if (ly<0) + { + ly+=sY; if (ly>0) ly = 0; + pt.Offset(0,-sY); + } +*/ + WaitFrame(); + + Freeze(); + Loc->SetScrollPosition(pt); + Tony->SetScrollPosition(pt); + Unfreeze(); + + } + + + // Setta la posizione finale + if (sX) { + if (lx>0) + pt.x = startpt.x + dimx; + else + pt.x = startpt.x - dimx; + } else { + if (ly>0) + pt.y = startpt.y + dimy; + else + pt.y = startpt.y - dimy; + + } + + Freeze(); + Loc->SetScrollPosition(pt); + Tony->SetScrollPosition(pt); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint32) { + int i; + + for (i = 0; i < curChangedHotspot; i++) + if (ChangedHotspot[i].dwCode == dwCode) { + ChangedHotspot[i].nX=nX; + ChangedHotspot[i].nY=nY; + break; + } + + if (i == curChangedHotspot) { + ChangedHotspot[i].dwCode=dwCode; + ChangedHotspot[i].nX=nX; + ChangedHotspot[i].nY=nY; + curChangedHotspot++; + } + + Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX,nY)); +} + + +DECLARE_CUSTOM_FUNCTION(AutoSave)(uint32, uint32, uint32, uint32) { + _vm->AutoSave(); +} + +DECLARE_CUSTOM_FUNCTION(Abort)(uint32, uint32, uint32, uint32) { + _vm->Abort(); +} + +DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { + uint32 i; + uint32 curTime = _vm->GetTime(); + int dirx,diry; + + dirx = 1; + diry = 1; + + while (_vm->GetTime() < curTime + nScosse) { + WaitFrame(); + + Freeze(); + Loc->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); + Tony->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); + Unfreeze(); + + i = _vm->_randomSource.getRandomNumber(2); + + if (i == 0 || i == 2) + dirx = -dirx; + else if (i == 1 || i == 2) + diry = -diry; + } + + Freeze(); + Loc->SetFixedScroll(RMPoint(0, 0)); + Tony->SetFixedScroll(RMPoint(0, 0)); + Unfreeze(); +} + + + +/* + * Personaggi + */ + +DECLARE_CUSTOM_FUNCTION(CharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { + assert(nChar < 16); + Character[nChar].code = nCode; + Character[nChar].item = Loc->GetItemFromCode(nCode); + Character[nChar].r = 255; + Character[nChar].g = 255; + Character[nChar].b = 255; + Character[nChar].talkpattern = 0; + Character[nChar].starttalkpattern = 0; + Character[nChar].endtalkpattern = 0; + Character[nChar].standpattern = 0; + + IsMChar[nChar] = false; +} + +DECLARE_CUSTOM_FUNCTION(CharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { + assert(nChar<16); + Character[nChar].r = r; + Character[nChar].g = g; + Character[nChar].b = b; +} + +DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(uint32 nChar, uint32 tp, uint32 sp, uint32) { + assert(nChar<16); + Character[nChar].talkpattern = tp; + Character[nChar].standpattern = sp; +} + +DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(uint32 nChar, uint32 sp, uint32 ep, uint32) { + assert(nChar<16); + Character[nChar].starttalkpattern=sp; + Character[nChar].endtalkpattern=ep; +} + +DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { + RMMessage msg(dwMessage); + int i; + RMPoint pt; + RMTextDialog *text; + int curOffset = 0; + + assert(nChar<16); + pt=Character[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + + if (Character[nChar].starttalkpattern != 0) { + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].starttalkpattern); + Unfreeze(); + Character[nChar].item->WaitForEndPattern(); + } + + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].talkpattern); + Unfreeze(); + + VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); + FPSFX *voice = NULL; + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima +// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + g_system->lockMutex(vdb); + _vm->_vdbFP.seek(curVoc->offset); + curOffset = curVoc->offset; + g_system->unlockMutex(vdb); + } + + for (i = 0; iHide(); + } else + text = new RMTextDialog; + + text->SetInput(Input); + + // Skipping + text->SetSkipStatus(!bIsBack); + + // Allineamento + text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + + // Colore + text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); + + // Scrive il testo + text->WriteText(msg[i],0); + + // Setta la posizione + text->SetPosition(pt); + + // Setta l'always display + if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + + // Registra il testo + LinkGraphicTask(text); + + if (curVoc) { + g_system->lockMutex(vdb); + _vm->_theSound.CreateSfx(&voice); + _vm->_vdbFP.seek(curOffset); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + voice->SetLoop(false); + if (bIsBack) voice->SetVolume(55); + voice->Play(); + text->SetCustomSkipHandle2(voice->hEndOfBuffer); + curOffset = _vm->_vdbFP.pos(); + g_system->unlockMutex(vdb); + } + + // Aspetta la fine della visualizzazione + text->SetCustomSkipHandle(hSkipIdle); + text->WaitForEndDisplay(); + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + + + curBackText=NULL; + delete text; + } + + if (Character[nChar].endtalkpattern != 0) { + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].endtalkpattern); + Unfreeze(); + Character[nChar].item->WaitForEndPattern(); + } + + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].standpattern); + Unfreeze(); +} + +DECLARE_CUSTOM_FUNCTION(AddInventory)(uint32 dwCode, uint32, uint32, uint32) { + Inventory->AddItem(dwCode); +} + +DECLARE_CUSTOM_FUNCTION(RemoveInventory)(uint32 dwCode, uint32, uint32, uint32) { + Inventory->RemoveItem(dwCode); +} + +DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(uint32 dwCode, uint32 dwStatus, uint32, uint32) { + Inventory->ChangeItemStatus(dwCode,dwStatus); +} + + + + +/* + * Mastri Personaggi + */ + +DECLARE_CUSTOM_FUNCTION(MCharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { + assert(nChar < 10); + MCharacter[nChar].code=nCode; + if (nCode== 0) + MCharacter[nChar].item=NULL; + else + MCharacter[nChar].item=Loc->GetItemFromCode(nCode); + MCharacter[nChar].r=255; + MCharacter[nChar].g=255; + MCharacter[nChar].b=255; + MCharacter[nChar].x=-1; + MCharacter[nChar].y=-1; + MCharacter[nChar].bAlwaysBack = 0; + + for (int i = 0; i < 10; i++) + MCharacter[nChar].numtalks[i] = 1; + + MCharacter[nChar].curgroup = 0; + + IsMChar[nChar] = true; +} + +DECLARE_CUSTOM_FUNCTION(MCharResetCode)(uint32 nChar, uint32, uint32, uint32) { + MCharacter[nChar].item=Loc->GetItemFromCode(MCharacter[nChar].code); +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(uint32 nChar, uint32 nX, uint32 nY, uint32) { + assert(nChar < 10); + MCharacter[nChar].x=nX; + MCharacter[nChar].y=nY; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { + assert(nChar < 10); + MCharacter[nChar].r=r; + MCharacter[nChar].g=g; + MCharacter[nChar].b=b; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { + assert(nChar < 10); + assert(nGroup < 10); + + MCharacter[nChar].numtalks[nGroup]=nTalks; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(uint32 nChar, uint32 nGroup, uint32, uint32) +{ + assert(nChar < 10); + assert(nGroup < 10); + + MCharacter[nChar].curgroup = nGroup; +} + +DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(uint32 nChar, uint32 nTexts, uint32, uint32) { + assert(nChar < 10); + + MCharacter[nChar].numtexts=nTexts-1; + MCharacter[nChar].bInTexts = false; +} + +DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { + assert(nChar < 10); + + MCharacter[nChar].bAlwaysBack=bAlwaysBack; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { + RMMessage msg(dwMessage); + int i; + int parm; + RMPoint pt; + HANDLE h; + RMTextDialog *text; + int curOffset = 0; + + assert(nChar < 10); + + bIsBack |= MCharacter[nChar].bAlwaysBack ? 1 : 0; + + // Calcola la posizione del testo in base al frame corrente + if (MCharacter[nChar].x==-1) + pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + else + pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); + + // Parametro per le azioni speciali: random tra le parlate + parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( + MCharacter[nChar].numtalks[MCharacter[nChar].curgroup] - 1) + 1; + + // Cerca di eseguire la funzione custom per inizializzare la parlata + if (MCharacter[nChar].item) { + h = mpalQueryDoAction(30,MCharacter[nChar].item->MpalCode(), parm); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + } + + VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); + FPSFX *voice = NULL; + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima + g_system->lockMutex(vdb); + // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + _vm->_vdbFP.seek(curVoc->offset); + curOffset = curVoc->offset; + g_system->unlockMutex(vdb); + } + + for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + // Crea l'oggetto diverso se back o no + if (bIsBack) { + curBackText=text = new RMTextDialogScrolling(Loc); + if (bTonyIsSpeaking) + curBackText->Hide(); + } + else + text = new RMTextDialog; + + text->SetInput(Input); + + // Skipping + text->SetSkipStatus(!bIsBack); + + // Allineamento + text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + + // Colore + text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); + + // Scrive il testo + text->WriteText(msg[i],nFont); + + // Setta la posizione + text->SetPosition(pt); + + // Setta l'always display + if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + + // Registra il testo + LinkGraphicTask(text); + + if (curVoc) { + g_system->lockMutex(vdb); + _vm->_theSound.CreateSfx(&voice); + _vm->_vdbFP.seek(curOffset); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + voice->SetLoop(false); + if (bIsBack) voice->SetVolume(55); + voice->Play(); + text->SetCustomSkipHandle2(voice->hEndOfBuffer); + curOffset = _vm->_vdbFP.pos(); + g_system->unlockMutex(vdb); + } + + // Aspetta la fine della visualizzazione + text->SetCustomSkipHandle(hSkipIdle); + text->WaitForEndDisplay(); + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + + curBackText=NULL; + delete text; + } + + + // Cerca di eseguire la funzione custom per chiudere la parlata + if (MCharacter[nChar].item) { + h=mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); + if (h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + } +} + + + + + + +/* + * Dialoghi + */ + +int curDialog; + +DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, uint32) { + LPSTR string; + RMTextDialog* text; + int parm; + HANDLE h; + bool bIsBack = false; + + // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato + // con la SetAlwaysBack + if (nPers != 0 && IsMChar[nPers] && MCharacter[nPers].bAlwaysBack) + bIsBack = true; + + VoiceHeader *curVoc = SearchVoiceHeader(curDialog, nMsg); + FPSFX *voice = NULL; + + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima + g_system->lockMutex(vdb); +// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + _vm->_vdbFP.seek(curVoc->offset); + _vm->_theSound.CreateSfx(&voice); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + voice->SetLoop(false); + if (bIsBack) voice->SetVolume(55); + g_system->unlockMutex(vdb); + } + + string=mpalQueryDialogPeriod(nMsg); + + if (nPers == 0) { + text = new RMTextDialog; + text->SetColor(0,255,0); + text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); + text->WriteText(string,0); + + if (dwTonyNumTexts > 0) { + if (!bTonyInTexts) { + if (nTonyNextTalkType != Tony->TALK_NORMAL) { + Tony->StartTalk(nTonyNextTalkType); + if (!bStaticTalk) + nTonyNextTalkType = Tony->TALK_NORMAL; + } else + Tony->StartTalk(Tony->TALK_NORMAL); + + bTonyInTexts = true; + } + dwTonyNumTexts--; + } else { + Tony->StartTalk(nTonyNextTalkType); + if (!bStaticTalk) + nTonyNextTalkType = Tony->TALK_NORMAL; + } + } else if (!IsMChar[nPers]) { + RMPoint pt; + + text = new RMTextDialog; + + pt=Character[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + + if (Character[nPers].starttalkpattern != 0) { + Freeze(); + Character[nPers].item->SetPattern(Character[nPers].starttalkpattern); + Unfreeze(); + Character[nPers].item->WaitForEndPattern(); + } + + Character[nPers].item->SetPattern(Character[nPers].talkpattern); + + text->SetColor(Character[nPers].r,Character[nPers].g,Character[nPers].b); + text->WriteText(string,0); + text->SetPosition(pt); + } else { + RMPoint pt; + + if (MCharacter[nPers].x==-1) + pt=MCharacter[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + else + pt=RMPoint(MCharacter[nPers].x,MCharacter[nPers].y); + + // Parametro per le azioni speciali: random tra le parlate + parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( + MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; + + if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { + MCharacter[nPers].numtexts--; + } else { + // Cerca di eseguire la funzione custom per inizializzare la parlata + h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), parm); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + + MCharacter[nPers].curTalk = parm; + + if (MCharacter[nPers].numtexts != 0) { + MCharacter[nPers].bInTexts = true; + MCharacter[nPers].numtexts--; + } + } + + if (MCharacter[nPers].bAlwaysBack) { + text = curBackText = new RMTextDialogScrolling(Loc); + if (bTonyIsSpeaking) + curBackText->Hide(); + bIsBack = true; + } else + text = new RMTextDialog; + + text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); + text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); + text->WriteText(string,0); + text->SetPosition(pt); + } + + if (!bSkipIdle) { + text->SetInput(Input); + if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + LinkGraphicTask(text); + + if (curVoc) { + voice->Play(); + text->SetCustomSkipHandle2(voice->hEndOfBuffer); + } + + // Aspetta la fine della visualizzazione + text->SetCustomSkipHandle(hSkipIdle); + text->WaitForEndDisplay(); + } + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + + if (nPers != 0) { + if (!IsMChar[nPers]) { + if (Character[nPers].endtalkpattern != 0) { + Freeze(); + Character[nPers].item->SetPattern(Character[nPers].endtalkpattern); + Unfreeze(); + Character[nPers].item->WaitForEndPattern(); + } + + Character[nPers].item->SetPattern(Character[nPers].standpattern); + delete text; + } else { + if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { + // Cerca di eseguire la funzione custom per chiudere la parlata + MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; + h=mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + if (h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + + MCharacter[nPers].bInTexts = false; + MCharacter[nPers].numtexts = 0; + } + + curBackText = NULL; + delete text; + } + } else { + if ((dwTonyNumTexts== 0 && bTonyInTexts) || !bTonyInTexts) { + Tony->EndTalk(); + dwTonyNumTexts = 0; + bTonyInTexts = false; + } + + delete text; + } + + GlobalFree(string); +} + + +// @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!! + +DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, uint32) { + int nChoice; + uint32 *sl; + int i,num; + char* string; + RMDialogChoice dc; + int sel; + + curDialog = nDialog; + + // Chiama l'MPAL per iniziare il dialogo + mpalQueryDoDialog(nDialog,nStartGroup); + + // Aspetta che una scelta si presenti + while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) { + // Si fa dare la lista di opzioni e le conta + sl=mpalQueryDialogSelectList(nChoice); + for (num = 0; sl[num] != 0; num++) + ; + + // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta + if (num==1) + { + mpalQueryDialogSelection(nChoice,sl[0]); + GlobalFree(sl); + continue; + } + + // Crea una scelta per il dialogo + dc.Init(); + dc.SetNumChoices(num); + + // Scrive tutte le possibili opzioni + for (i = 0;i < num; i++) { + string = mpalQueryDialogPeriod(sl[i]); + assert(string != NULL); + dc.AddChoice(string); + GlobalFree(string); + } + + // Attiva l'oggetto + LinkGraphicTask(&dc); + dc.Show(); + + // Disegna il puntatore + Pointer->SetSpecialPointer(Pointer->PTR_NONE); + MainShowMouse(); + + while (!(Input->MouseLeftClicked() && ((sel = dc.GetSelection()) != -1))) { + WaitFrame(); + Freeze(); + dc.DoFrame(Input->MousePos()); + Unfreeze(); + } + + // Nascondi il puntatore + MainHideMouse(); + + dc.Hide(); + mpalQueryDialogSelection(nChoice, sl[sel]); + + // Chiude la scelta + dc.Close(); + + GlobalFree(sl); + } +} + + + + + +/* + * Sync tra idle e mpal + */ + +DECLARE_CUSTOM_FUNCTION(TakeOwnership)(uint32 num, uint32, uint32, uint32) { +// EnterCriticalSection(&cs[num]); + WaitForSingleObject(mut[num],INFINITE); +} + +DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(uint32 num, uint32, uint32, uint32) { +// LeaveCriticalSection(&cs[num]); +// g_system->unlockMutex(mut[num]); + warning("TODO: ReleaseOwnership"); +} + + + + + + + + + + + +/* + * Musica + * ------ + * + * Effetti di fade supportati: + * + * nFX = 0 - La nuova musica si sostituisce a quella vecchia + * nFX=1 - La nuova musica si interfade con quella vecchia + * nFX=2 - La nuova musica subentra a tempo con quella vecchia + * + */ + +int curSonoriz = 0; + +bool bFadeOutStop; + +void ThreadFadeInMusic(void *nMusic) { + int i; + int nChannel = (int)nMusic; + + debug("Start FadeIn Music\n"); + + for (i = 0; i < 16; i++) { + _vm->SetMusicVolume(nChannel, i * 4); + Sleep(100); + } + _vm->SetMusicVolume(nChannel, 64); + + debug("End FadeIn Music\n"); + _endthread(); +} + +void ThreadFadeOutMusic(void *nMusic) { + int i; + int nChannel = (int)nMusic; + int startVolume = _vm->GetMusicVolume(nChannel); + + debug("Start FadeOut Music\n"); + + for (i = 16; i > 0 && !bFadeOutStop; i--) { + if (i * 4 < startVolume) + _vm->SetMusicVolume(nChannel, i * 4); + Sleep(100); + } + + if (!bFadeOutStop) + _vm->SetMusicVolume(nChannel, 0); + + // Se uno stacchetto ferma tutto + if (nChannel == 2) + _vm->StopMusic(2); + + debug("End FadeOut Music\n"); + + _endthread(); +} + +DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(uint32, uint32, uint32, uint32) { + _beginthread(ThreadFadeInMusic, 10240, (void*)curSonoriz); +} + +DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(uint32, uint32, uint32, uint32) { + bFadeOutStop = false; + _beginthread(ThreadFadeOutMusic, 10240, (void *)curSonoriz); +} + +DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(uint32, uint32, uint32, uint32) { + bFadeOutStop = false; + _beginthread(ThreadFadeOutMusic, 10240, (void*)2); +} + +DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(uint32, uint32, uint32, uint32) { + _beginthread(ThreadFadeInMusic, 10240, (void*)2); +} + +DECLARE_CUSTOM_FUNCTION(StopSonoriz)(uint32, uint32, uint32, uint32) { + _vm->StopMusic(curSonoriz); +} + +DECLARE_CUSTOM_FUNCTION(StopStacchetto)(uint32, uint32, uint32, uint32) { + _vm->StopMusic(2); +} + +DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(uint32, uint32, uint32, uint32) { + _vm->SetMusicVolume(curSonoriz, 0); +} + +DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(uint32, uint32, uint32, uint32) { + bFadeOutStop = true; + _vm->SetMusicVolume(curSonoriz, 64); +} + +DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(uint32, uint32, uint32, uint32) { + _vm->SetMusicVolume(2, 0); +} + +DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(uint32, uint32, uint32, uint32) { + _vm->SetMusicVolume(2, 64); +} + +struct { + const char *name; + int sync; +} musicFiles[] = +{ +/* + { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, + { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, + { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, + { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, + { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, +*/ + { "00.ADP", 0 }, { "01.ADP", 0 }, + { "02.ADP", 0 }, { "03.ADP", 0 }, + { "04.ADP",0 }, { "05.ADP", 0 }, + { "06.ADP", 0 }, { "07.ADP", 0 }, + { "08.ADP", 2450 }, { "09.ADP", 0 }, + +/* + { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, + { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, + { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, + { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, + { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, +*/ + { "10.ADP", 0 }, { "11.ADP", 0 }, + { "12.ADP", 0 }, { "13.ADP", 0 }, + { "14.ADP", 0 }, { "15.ADP", 0 }, + { "16.ADP", 0 }, { "17.ADP", 0 }, + { "18.ADP", 0 }, { "19.ADP", 0 }, +/* + { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, + { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, + { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, + { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, + { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, +*/ + { "20.ADP", 0 }, { "21.ADP", 0 }, + { "22.ADP", 0 }, { "23.ADP", 0 }, + { "24.ADP", 0 }, { "25.ADP", 0 }, + { "26.ADP", 0 }, { "27.ADP", 0 }, + { "28.ADP", 1670 }, { "29.ADP", 0 }, +/* + { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, + { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, + { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, + { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, + { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, +*/ + { "30.ADP", 0 }, { "31.ADP", 0 }, + { "32.ADP", 2900 }, { "33.ADP", 0 }, + { "34.ADP", 0 }, { "35.ADP", 0 }, + { "36.ADP", 0 }, { "37.ADP", 0 }, + { "38.ADP", 0 }, { "39.ADP", 0 }, +/* + { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, + { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, + { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, + { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, + { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, +*/ + { "40.ADP", 0 }, { "41.ADP", 1920 }, + { "42.ADP", 1560 }, { "43.ADP", 1920 }, + { "44.ADP", 1920 }, { "45.ADP", 1920 }, + { "46.ADP", 1920 }, { "47.ADP", 1920 }, + { "48.ADP", 1920 }, { "49.ADP", 1920 }, + +/* + { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, + { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, + { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, + { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, + { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } +*/ + + { "50.ADP", 1920 }, { "51.ADP", 1920 }, + { "52.ADP", 1920 }, { "53.ADP", 0 }, + { "54.ADP", 0 }, { "55.ADP", 0 }, + { "56.ADP", 0 }, { "57.ADP", 0 }, + { "58.ADP", 0 }, { "59.ADP", 0 } + +}; + + +const char *staccFileNames[] = { +/* + "05-MUCCA.ADP", "06-HALOW.ADP", + "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", + "LETTERAFINE.ADP", "PREGAME2.ADP", + "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", + "15-SHOTTONY.ADP", "27-ZUCC2.ADP", +*/ + "S00.ADP", "S01.ADP", + "S02.ADP", "S03.ADP", + "S04.ADP", "S05.ADP", + "S06.ADP", "S07.ADP", + "S08.ADP", "S09.ADP", + +/* + "53-DLOGO.ADP", "16-DIALOG1.ADP", + "TORRE1.ADP", "GARG1.ADP", + "LORENZ1.ADP", "24-FIGHT.ADP", + "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", + "GATTO1.ADP" +*/ + "S10.ADP", "S11.ADP", + "S12.ADP", "S13.ADP", + "S14.ADP", "S15.ADP", + "S16.ADP", "S17.ADP", + "S18.ADP" +}; + + +void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { + if (nSync == 0) + nSync = 2000; + debug("Start CustPlayMusic\n"); + PlayMusic(nChannel, mFN, nFX, bLoop, nSync); + debug("End CustPlayMusic\n"); +} + +DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { + if (nFX == 0 || nFX == 1 || nFX==2) { + debug("PlaySonoriz stop fadeout\n"); + bFadeOutStop = true; + } + + lastMusic = nMusic; + CustPlayMusic(curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); +} + +DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { + CustPlayMusic(2,staccFileNames[nMusic],nFX,bLoop); +} + +DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(uint32 nItem, uint32 nSFX, uint32, uint32) { + if (nItem== 0) { + Tony->PlaySfx(nSFX); + } else { + RMItem *item = Loc->GetItemFromCode(nItem); + if (item) + item->PlaySfx(nSFX); + } +} + + +void RestoreMusic(void) { + PlaySonoriz(lastMusic, 0, 0, 0); + if (lastTappeto != 0) + CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); +} + +void SaveMusic(Common::OutSaveFile *f) { + f->writeByte(lastMusic); + f->writeByte(lastTappeto); +} + +void LoadMusic(Common::InSaveFile *f) { + lastMusic = f->readByte(); + lastTappeto = f->readByte(); +} + + +DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(uint32 nStacc, uint32 bLoop, uint32, uint32) { + FadeOutSonoriz(0, 0, 0, 0); + MuteStacchetto(0, 0, 0, 0); + PlayStacchetto(nStacc, 0, bLoop, 0); + FadeInStacchetto(0, 0, 0, 0); +} + +DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(uint32 nStacc, uint32 bLoop, uint32, uint32) { + FadeOutStacchetto(0, 0, 0, 0); + FadeInSonoriz(0, 0, 0, 0); +} + + + + +DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(uint32, uint32, uint32, uint32) { + bSkipIdle = true; + SetEvent(hSkipIdle); +} + +DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(uint32, uint32, uint32, uint32) { + bSkipIdle = false; + ResetEvent(hSkipIdle); +} + +DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(uint32 bStatus, uint32, uint32, uint32) { + bPatIrqFreeze = bStatus; +} + +DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(uint32 , uint32, uint32, uint32) { + Freeze(); + _vm->OpenInitLoadMenu(); + Unfreeze(); +} + +DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(uint32 , uint32, uint32, uint32) { + Freeze(); + _vm->OpenInitOptions(); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(DoCredits)(uint32 nMsg, uint32 dwTime, uint32, uint32) { + RMMessage msg(nMsg); + RMTextDialog *text; + HANDLE hDisable = CreateEvent(NULL, true, false, NULL); + int i; + uint32 startTime; + + text = new RMTextDialog[msg.NumPeriods()]; + + for (i = 0; i < msg.NumPeriods(); i++) { + text[i].SetInput(Input); + + // Allineamento + if (msg[i][0] == '@') { + text[i].SetAlignType(RMText::HCENTER, RMText::VTOP); + text[i].WriteText(&msg[i][1], 3); + text[i].SetPosition(RMPoint(414, 70 + i * 26)); // 70 + } else { + text[i].SetAlignType(RMText::HLEFT,RMText::VTOP); + text[i].WriteText(msg[i], 3); + text[i].SetPosition(RMPoint(260, 70 + i * 26)); + } + + + // Setta la posizione + text[i].SetAlwaysDisplay(); + text[i].SetForcedTime(dwTime * 1000); + text[i].SetNoTab(); + + // Aspetta la fine della visualizzazione + text[i].SetCustomSkipHandle(hDisable); + + // Registra il testo + LinkGraphicTask(&text[i]); + } + + startTime = _vm->GetTime(); + + while (startTime + dwTime * 1000 > _vm->GetTime()) { + WaitFrame(); + if (Input->MouseLeftClicked() || Input->MouseRightClicked()) + break; + if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + break; + } + + SetEvent(hDisable); + + WaitFrame(); + WaitFrame(); + + delete[] text; +} + + + +BEGIN_CUSTOM_FUNCTION_MAP() + + ASSIGN( 1, CustLoadLocation) + ASSIGN( 2, MySleep) + ASSIGN( 3, SetPointer) + ASSIGN( 5, MoveTony) + ASSIGN( 6, FaceToMe) + ASSIGN( 7, BackToMe) + ASSIGN( 8, LeftToMe) + ASSIGN( 9, RightToMe) + ASSIGN( 10, SendTonyMessage) + ASSIGN( 11, ChangeBoxStatus) + ASSIGN( 12, ChangeLocation) + ASSIGN( 13, DisableTony) + ASSIGN( 14, EnableTony) + ASSIGN( 15, WaitForPatternEnd) + ASSIGN( 16, SetLocStartPosition) + ASSIGN( 17, ScrollLocation) + ASSIGN( 18, MoveTonyAndWait) + ASSIGN( 19, ChangeHotspot) + ASSIGN( 20, AddInventory) + ASSIGN( 21, RemoveInventory) + ASSIGN( 22, ChangeInventoryStatus) + ASSIGN( 23, SetTonyPosition) + ASSIGN( 24, SendFullscreenMessage) + ASSIGN( 25, SaveTonyPosition) + ASSIGN( 26, RestoreTonyPosition) + ASSIGN( 27, DisableInput) + ASSIGN( 28, EnableInput) + ASSIGN( 29, StopTony) + + ASSIGN( 30, TonyTakeUp1) + ASSIGN( 31, TonyTakeMid1) + ASSIGN( 32, TonyTakeDown1) + ASSIGN( 33, TonyTakeUp2) + ASSIGN( 34, TonyTakeMid2) + ASSIGN( 35, TonyTakeDown2) + + ASSIGN( 72, TonyPutUp1) + ASSIGN( 73, TonyPutMid1) + ASSIGN( 74, TonyPutDown1) + ASSIGN( 75, TonyPutUp2) + ASSIGN( 76, TonyPutMid2) + ASSIGN( 77, TonyPutDown2) + + ASSIGN( 36, TonyPerTerra) + ASSIGN( 37, TonySiRialza) + ASSIGN( 38, TonyPastorella) + ASSIGN( 39, TonyFischietto) + + ASSIGN( 40, TonyRide) + ASSIGN( 41, TonyFianchi) + ASSIGN( 42, TonyCanta) + ASSIGN( 43, TonySiIndica) + ASSIGN( 44, TonySpaventatoConMani) + ASSIGN( 49, TonySpaventatoSenzaMani) + ASSIGN( 45, TonyConBicchiere) + ASSIGN( 46, TonyConVerme) + ASSIGN( 47, TonyConMartello) + ASSIGN( 48, TonyConCorda) + ASSIGN( 90, TonyConConiglioANIM) + ASSIGN( 91, TonyConRicettaANIM) + ASSIGN( 92, TonyConCarteANIM) + ASSIGN( 93, TonyConPupazzoANIM) + ASSIGN( 94, TonyConPupazzoStart) + ASSIGN( 95, TonyConPupazzoEnd) + ASSIGN( 96, TonyConConiglioStart) + ASSIGN( 97, TonyConConiglioEnd) + ASSIGN( 98, TonyConRicettaStart) + ASSIGN( 99, TonyConRicettaEnd) + ASSIGN(100, TonyConCarteStart) + ASSIGN(101, TonyConCarteEnd) + ASSIGN(102, TonyConTaccuinoStart) + ASSIGN(103, TonyConTaccuinoEnd) + ASSIGN(104, TonyConMegafonoStart) + ASSIGN(105, TonyConMegafonoEnd) + ASSIGN(106, TonyConBarbaStart) + ASSIGN(107, TonyConBarbaEnd) + ASSIGN(108, TonyRidacchia) + ASSIGN(109, TonySchifato) + ASSIGN(110, TonyNaah) + ASSIGN(111, TonyMacbeth) + ASSIGN(112, TonySniffaLeft) + ASSIGN(113, TonySniffaRight) + ASSIGN(114, TonySpaventatoStart) + ASSIGN(115, TonySpaventatoEnd) + ASSIGN(116, TonyConSegretaria) + + ASSIGN( 50, CharSetCode) + ASSIGN( 51, CharSetColor) + ASSIGN( 52, CharSetTalkPattern) + ASSIGN( 53, CharSendMessage) + ASSIGN( 54, CharSetStartEndTalkPattern) + + ASSIGN( 60, MCharSetCode) + ASSIGN( 61, MCharSetColor) + ASSIGN( 62, MCharSetCurrentGroup) + ASSIGN( 63, MCharSetNumTalksInGroup) + ASSIGN( 64, MCharSetNumTexts) + ASSIGN( 65, MCharSendMessage) + ASSIGN( 66, MCharSetPosition) + ASSIGN( 67, MCharSetAlwaysBack) + ASSIGN( 68, MCharResetCode) + + ASSIGN( 70, StartDialog) + ASSIGN( 71, SendDialogMessage) + + ASSIGN( 80, TakeOwnership) + ASSIGN( 81, ReleaseOwnership) + + ASSIGN( 86, PlaySonoriz) + ASSIGN( 87, PlayStacchetto) + ASSIGN( 88, FadeInSonoriz) + ASSIGN( 89, FadeOutSonoriz) + ASSIGN(123, FadeInStacchetto) + ASSIGN(124, FadeOutStacchetto) + ASSIGN(125, MuteSonoriz) + ASSIGN(126, DemuteSonoriz) + ASSIGN(127, MuteStacchetto) + ASSIGN(128, DemuteStacchetto) + ASSIGN( 84, StopSonoriz) + ASSIGN( 85, StopStacchetto) + ASSIGN( 83, PlayItemSfx) + ASSIGN(129, StacchettoFadeStart) + ASSIGN(130, StacchettoFadeEnd) + + ASSIGN(120, TremaSchermo) + ASSIGN(121, AutoSave) + ASSIGN(122, Abort) + ASSIGN(131, NoOcchioDiBue) + ASSIGN(132, SendFullscreenMsgStart) + ASSIGN(133, SendFullscreenMsgEnd) + ASSIGN(134, CustEnableGUI) + ASSIGN(135, CustDisableGUI) + ASSIGN(136, ClearScreen) + ASSIGN(137, PatIrqFreeze) + ASSIGN(138, TonySetPalesati) + ASSIGN(139, OpenInitLoadMenu) + ASSIGN(140, OpenInitOptions) + ASSIGN(141, SyncScrollLocation) + ASSIGN(142, CloseLocation) + ASSIGN(143, SetAlwaysDisplay) + ASSIGN(144, DoCredits) + + ASSIGN( 200, MustSkipIdleStart); + ASSIGN( 201, MustSkipIdleEnd); + +END_CUSTOM_FUNCTION_MAP() + +void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { + Tony = tony; + Pointer = ptr; + Boxes = box; + Loc = loc; + Inventory = inv; + Input = input; + + LoadLocation = MainLoadLocation; + UnloadLocation = MainUnloadLocation; + LinkGraphicTask = MainLinkGraphicTask; + Freeze = MainFreeze; + Unfreeze = MainUnfreeze; + WaitFrame = MainWaitFrame; + PlayMusic = MainPlayMusic; + InitWipe = MainInitWipe; + CloseWipe = MainCloseWipe; + WaitWipeEnd = MainWaitWipeEnd; + DisableGUI = MainDisableGUI; + EnableGUI = MainEnableGUI; + SetPalesati = MainSetPalesati; + + g_system->lockMutex(vdb); + + bAlwaysDisplay = false; + int i; +/* + for (i = 0;i < 10; i++) + InitializeCriticalSection(&cs[i]); + for (i = 0;i < 10; i++) + mut[i] = CreateMutex(NULL, false, NULL); +*/ + for (i = 0; i < 200; i++) + tappeti[i] = 0; + + tappeti[6] = T_GRILLI; + tappeti[7] = T_GRILLI; + tappeti[8] = T_GRILLIOV; + tappeti[10] = T_GRILLI; + tappeti[12] = T_GRILLI; + tappeti[13] = T_GRILLIOV; + tappeti[15] = T_GRILLI; + tappeti[16] = T_GRILLIVENTO; + tappeti[18] = T_GRILLI; + tappeti[19] = T_GRILLIVENTO; + tappeti[20] = T_GRILLI; + tappeti[23] = T_GRILLI; + tappeti[26] = T_MAREMETA; + tappeti[27] = T_GRILLI; + tappeti[28] = T_GRILLIVENTO; + tappeti[31] = T_GRILLI; + tappeti[33] = T_MARE; + tappeti[35] = T_MARE; + tappeti[36] = T_GRILLI; + tappeti[37] = T_GRILLI; + tappeti[40] = T_GRILLI; + tappeti[41] = T_GRILLI; + tappeti[42] = T_GRILLI; + tappeti[45] = T_GRILLI; + tappeti[51] = T_GRILLI; + tappeti[52] = T_GRILLIVENTO1; + tappeti[53] = T_GRILLI; + tappeti[54] = T_GRILLI; + tappeti[57] = T_VENTO; + tappeti[58] = T_VENTO; + tappeti[60] = T_VENTO; + + + + // Crea l'evento per skippare le idle + hSkipIdle = CreateEvent(NULL, true, false, NULL); +} + +} // end of namespace Tony diff --git a/engines/tony/custom.h b/engines/tony/custom.h new file mode 100644 index 0000000000..ee85c8dd41 --- /dev/null +++ b/engines/tony/custom.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. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Custom functions..... * + * z$$beu .ue=" $ "=e.. .zed$$c ..................... * + * "#$e z$*" . `. ^*Nc e$"" ..................... * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + ************************************************************************** + +/** RCS + * + * $Id: $ + * + **/ + +#ifndef TONY_CUSTOM_H +#define TONY_CUSTOM_H + +#include "tony/mpal/mpal.h" + +namespace Tony { + +using namespace MPAL; + +/* + * Defines + */ + +typedef uint32 HWND; + +typedef void __declspec(dllexport) (*INIT_CUSTOM_FUNCTION_TYPE)(HWND, LPCUSTOMFUNCTION *); + +#define INIT_CUSTOM_FUNCTION MapCustomFunctions +#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" + +#define DECLARE_CUSTOM_FUNCTION(x) void x + +#define BEGIN_CUSTOM_FUNCTION_MAP() \ + static void AssignError(HWND hWnd, int num) { \ + error("Custom function %u has been already assigned!", num); \ + } \ + void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap) \ + { + + +#define END_CUSTOM_FUNCTION_MAP() \ + } + + +#define ASSIGN(num,func) \ + if (lpMap[num]!=NULL) \ + AssignError(hWnd,num); \ + lpMap[num]=func; + +class RMTony; +class RMPointer; +class RMGameBoxes; +class RMLocation; +class RMInventory; +class RMInput; + +void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap); +void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); + +#endif + +} // end of namespace Tony diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 58d16842d4..6be0ca302c 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -43,6 +43,10 @@ Common::Language TonyEngine::getLanguage() const { return _gameDescription->desc.language; } +bool TonyEngine::getIsDemo() const { + return _gameDescription->desc.flags & ADGF_DEMO; +} + } static const PlainGameDescriptor tonyGames[] = { diff --git a/engines/tony/font.h b/engines/tony/font.h index 348e7618ea..57a8b1c4fb 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -55,6 +55,8 @@ namespace Tony { class RMInventory; +class RMLoc; +class RMItem; /** * Gestisce un font, in cui ha varie surface per ogni lettera @@ -318,7 +320,7 @@ class RMTextItemName : protected RMText { protected: RMPoint m_mpos; RMPoint m_curscroll; - RMItem* m_item; + RMItem *m_item; RMString m_itemName; public: @@ -330,10 +332,10 @@ public: void DoFrame(RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - RMPoint GetHotspot() { if (m_item==NULL) return m_mpos+m_curscroll; else return m_item->Hotspot(); } - RMItem* GetSelectedItem() { return m_item; } - bool IsItemSelected() { return m_item!=NULL; } - bool IsNormalItemSelected() { return m_item!=NULL && m_itemName.Length()>0; } + RMPoint GetHotspot(); + RMItem *GetSelectedItem(); + bool IsItemSelected(); + bool IsNormalItemSelected(); virtual bool RemoveThis() { return true; } }; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 48827cbc2a..d759ef510a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -45,10 +45,1158 @@ * * **************************************************************************/ +#include "common/file.h" +#include "common/savefile.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/memory.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/mpalutils.h" +#include "tony/mpal/stubs.h" +#include "tony/custom.h" #include "tony/game.h" +#include "tony/gfxengine.h" +#include "tony/tony.h" namespace Tony { +using namespace MPAL; +/****************************************/ +/* Variabili globali di configurazione */ +/****************************************/ + +// FIXME: Move into a class instance +bool bCfgInvLocked; +bool bCfgInvNoScroll; +bool bCfgTimerizedText; +bool bCfgInvUp; +bool bCfgAnni30; +bool bCfgAntiAlias; +bool bCfgSottotitoli; +bool bCfgTransparence; +bool bCfgInterTips; +bool bCfgDubbing; +bool bCfgMusic; +bool bCfgSFX; +int nCfgTonySpeed; +int nCfgTextSpeed; +int nCfgDubbingVolume; +int nCfgMusicVolume; +int nCfgSFXVolume; +bool bSkipSfxNoLoop; + +bool bPatIrqFreeze; + +/****************************************/ +/* Funzioni globali per la DLL Custom */ +/****************************************/ + +static char path_buffer[_MAX_PATH]; +static char drive[_MAX_DRIVE]; +static char dir[_MAX_DIR]; +static char fname[_MAX_FNAME]; +static char ext[_MAX_EXT]; + +HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { + return _vm->GetEngine()->LoadLocation(nLoc,pt,start); +} + +HANDLE MainUnloadLocation(bool bDoOnExit) { + return _vm->GetEngine()->UnloadLocation(bDoOnExit); +} + +void MainLinkGraphicTask(RMGfxTask *task) { + _vm->GetEngine()->LinkGraphicTask(task); +} + +void MainFreeze(void) { + _vm->GetEngine()->Freeze(); +} + +void MainUnfreeze(void) { + _vm->GetEngine()->Unfreeze(); +} + +void MainWaitFrame(void) { + WaitForSingleObject(_vm->m_hEndOfFrame, INFINITE); +} + +void MainShowMouse(void) { + _vm->GetEngine()->EnableMouse(); +} + +void MainHideMouse(void) { + _vm->GetEngine()->DisableMouse(); +} + +void MainPlayMusic(int nChannel, char* filename, int nFX, bool bLoop, int nSync) { + _vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync); +} + +void MainDisableInput(void) { + _vm->GetEngine()->DisableInput(); +} + +void MainEnableInput(void) { + _vm->GetEngine()->EnableInput(); +} + +void MainInitWipe(int type) { + _vm->GetEngine()->InitWipe(type); +} + +void MainCloseWipe(void) { + _vm->GetEngine()->CloseWipe(); +} + +void MainWaitWipeEnd(void) { + _vm->GetEngine()->WaitWipeEnd(); +} + +void MainEnableGUI(void) { + _vm->GetEngine()->m_bGUIInterface = true; + _vm->GetEngine()->m_bGUIInventory = true; + _vm->GetEngine()->m_bGUIOption = true; +} + +void MainDisableGUI(void) { + _vm->GetEngine()->m_bGUIInterface = false; + _vm->GetEngine()->m_bGUIInventory = false; + _vm->GetEngine()->m_bGUIOption = false; +} + +void MainSetPalesati(bool bPalesati) { + _vm->GetEngine()->SetPalesati(bPalesati); +} + +/****************************************************************************\ +* Metodi di RMOptionButton +\****************************************************************************/ + +RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { + RMResRaw raw(dwRes); + assert(raw.IsValid()); + m_buf = new RMGfxSourceBuffer16(false); + m_buf->Init(raw, raw.Width(), raw.Height()); + + m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); + m_bActive = false; + m_bHasGfx = true; + m_bDoubleState = bDoubleState; +} + +RMOptionButton::RMOptionButton(RMRect pt) { + m_rect = pt; + m_bActive = false; + m_bHasGfx = false; + m_bDoubleState = false; +} + +RMOptionButton::~RMOptionButton() { + if (m_bHasGfx) + delete m_buf; +} + +bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { + if (!m_bDoubleState) { + if (m_rect.PtInRect(mousePos)) { + if (!m_bActive) { + m_bActive=true; + return true; + } + } else { + if (m_bActive) { + m_bActive=false; + return true; + } + } + } else { + if (bLeftClick && m_rect.PtInRect(mousePos)) { + m_bActive = !m_bActive; + return true; + } + } + + return false; +} + + + +void RMOptionButton::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (!m_bActive) + return; + + if (m_bHasGfx) + m_buf->Draw(bigBuf,prim); +} + +void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { + if (m_bHasGfx) + bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); +} + + +/****************************************************************************\ +* RMOptionSlide methods +\****************************************************************************/ + +#define INIT_GFX16_FROMRAW(dwRes, buf16) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf16) == NULL); \ + (buf16) = new RMGfxSourceBuffer16(false); \ + (buf16)->Init(*raw,raw->Width(),raw->Height()); \ + delete raw; + +#define INIT_GFX8_FROMRAW(dwRes, buf8) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf8) == NULL); \ + (buf8) = new RMGfxSourceBuffer8RLEByte(); \ + (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ + delete raw; + +/****************************************************************************\ +* Metodi di RMGfxEngine +\****************************************************************************/ + +bool bIdleExited; + +void ExitAllIdles(int nCurLoc) { + // Chiude le idle + bSkipSfxNoLoop = true; + mpalEndIdlePoll(nCurLoc); + bIdleExited = true; + bSkipSfxNoLoop = false; + ExitThread(0); +} + + +RMGfxEngine::RMGfxEngine() { + // Crea il big buffer dove verranno disegnati i frame + m_bigBuf.Create(RM_BBX, RM_BBY, 16); + m_bigBuf.OffsetY(RM_SKIPY); +} + +RMGfxEngine::~RMGfxEngine() { + // Chiude il buffer + m_bigBuf.Destroy(); +} + +void RMGfxEngine::OpenOptionScreen(int type) { + bool bRes; + + switch (type) { + case 0: + bRes=m_opt.Init(m_bigBuf); + break; + case 1: + bRes=m_opt.InitLoadMenuOnly(m_bigBuf, true); + break; + case 2: + bRes=m_opt.InitNoLoadSave(m_bigBuf); + break; + case 3: + bRes=m_opt.InitLoadMenuOnly(m_bigBuf, false); + break; + case 4: + bRes=m_opt.InitSaveMenuOnly(m_bigBuf, false); + break; + } + + if (bRes) { + _vm->PauseSound(true); + + DisableInput(); + m_inv.EndCombine(); + m_curActionObj=0; + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetCustomPointer(NULL); + EnableMouse(); + _vm->GrabThumbnail(); + + // Esce la IDLE onde evitare la morte prematura in caricamento + m_bMustEnterMenu = true; + if (type == 1 || type == 2) { + bIdleExited = true; + } else { + m_tony.StopNoAction(); + + uint32 id; + bIdleExited = false; + CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); + } + } +} + +void RMGfxEngine::DoFrame(bool bDrawLocation) { + g_system->lockMutex(csMainLoop); + + // Poll dei dispositivi di input + m_input.Poll(); + + if (m_bMustEnterMenu && bIdleExited) { + m_bOption = true; + m_bMustEnterMenu = false; + bIdleExited = false; + } + + if (m_bOption) { + m_opt.DoFrame(&m_input); + m_bOption = !m_opt.IsClosing(); + if (!m_bOption) { + DisableMouse(); + EnableInput(); + mpalStartIdlePoll(m_nCurLoc); + _vm->PauseSound(false); + } + } + + if (bDrawLocation && m_bLocationLoaded) { + // Locazione e oggetti + m_loc.DoFrame(&m_bigBuf); + + // Controlla gli input del mouse + if (m_bInput && !m_tony.InAction()) { + // Se siamo sull'inventario, lui che controlla tutti gli input + if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + // Left click attiva il combine, se siamo su un oggetto + if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { + m_curAction=TA_COMBINE; + m_point.SetAction(m_curAction); + } + } + else + + // CLICK DESTRO + // ************ + if (m_input.MouseRightClicked()) { + if(m_itemName.IsItemSelected()) { + m_curActionObj=0; + m_inv.RightClick(m_input.MousePos()); + } else + m_inv.RightClick(m_input.MousePos()); + } else + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } else { + // Menu Opzioni + // ************ + if (m_bGUIOption) { + if (!m_tony.InAction() && m_bInput) { + if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { + OpenOptionScreen(0); + goto SKIPCLICKSINISTRO; + } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE) & 0x8001) == 0x8001) + OpenOptionScreen(0); + else if (!_vm->getIsDemo()) { + if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001)==0x8001) + OpenOptionScreen(3); + else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001)==0x8001) + OpenOptionScreen(4); + } + } + } + + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked() && !m_inter.Active()) { + // Se clicko dentro un oggetto, esegui l'azione + //if (m_itemName.IsItemSelected()) + { + if (m_curAction!=TA_COMBINE) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + else if (m_itemName.GetSelectedItem() != NULL) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + } + + if (m_curAction==TA_COMBINE) { + m_inv.EndCombine(); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + } + +SKIPCLICKSINISTRO: + // CLICK DESTRO + // ************ + if (m_curAction == TA_COMBINE) { + // Durante il combine, lo annulla. + if (m_input.MouseRightClicked()) { + m_inv.EndCombine(); + m_curActionObj = 0; + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { + if (m_bGUIInterface) { + // Prima di aprire l'interfaccia, rimette GOTO + m_curAction = TA_GOTO; + m_curActionObj = 0; + m_point.SetAction(m_curAction); + m_inter.Clicked(m_input.MousePos()); + } + } + + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_bGUIInterface) { + if (m_inter.Released(m_input.MousePos(), m_curAction)) { + m_point.SetAction(m_curAction); + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } + } + + // Aggiorna il nome sotto il puntatore del mouse + m_itemName.SetMouseCoord(m_input.MousePos()); + if (!m_inter.Active() && !m_inv.MiniActive()) + m_itemName.DoFrame(m_bigBuf, m_loc, m_point, m_inv); + } + + // Inventario & interfaccia + m_inter.DoFrame(m_bigBuf, m_input.MousePos()); + m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + } + + // Anima Tony + m_tony.DoFrame(&m_bigBuf, m_nCurLoc); + + // Aggiorna lo scrolling per tenere Tony dentro lo schermo + if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { + RMPoint showThis=m_tony.Position(); + showThis.y -= 60; + m_loc.UpdateScrolling(showThis); + } + + if (m_bLocationLoaded) + m_tony.SetScrollPosition(m_loc.ScrollPosition()); + + if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { + m_point.SetCoord(m_input.MousePos()); + m_point.DoFrame(&m_bigBuf); + } + + // ********************** + // Disegna la lista di OT + // ********************** + m_bigBuf.DrawOT(); + +#define FSTEP (480/32) + + // Wipe + if (m_bWiping) + { + switch (m_nWipeType) { + case 1: + if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top>=FSTEP*2)) { + SetEvent(m_hWipeEvent); + m_nWipeType=3; + break; + } + + m_rcWipeEllipse.top+=FSTEP; + m_rcWipeEllipse.left+=FSTEP; + m_rcWipeEllipse.right-=FSTEP; + m_rcWipeEllipse.bottom-=FSTEP; + break; + + case 2: + if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top<480-FSTEP)) { + SetEvent(m_hWipeEvent); + m_nWipeType=3; + break; + } + + m_rcWipeEllipse.top-=FSTEP; + m_rcWipeEllipse.left-=FSTEP; + m_rcWipeEllipse.right+=FSTEP; + m_rcWipeEllipse.bottom+=FSTEP; + break; + } + } + + g_system->unlockMutex(csMainLoop); +} + + +void RMGfxEngine::InitCustomDll(void) { + SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); +} + +void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { + static RMGfxEngine *This = NULL; + RMItem *item; + + // Inizializzazione! + if ((int)dwItem == -1) + { + This=(RMGfxEngine*)nPattern; + return; + } + + if (This->m_bLocationLoaded) { + item = This->m_loc.GetItemFromCode(dwItem); + if (item != NULL) { + if (nPattern != -1) { + if (bPatIrqFreeze) + MainFreeze(); + item->SetPattern(nPattern, true); + if (bPatIrqFreeze) + MainUnfreeze(); + } + if (nStatus!=-1) + item->SetStatus(nStatus); + } + } +} + +/* + // WINBUG: This is a special case for the file open/save dialog, + // which sometimes pumps while it is coming up but before it has + // disabled the main window. + HWND hWndFocus = ::GetFocus(); + bool bEnableParent = false; + m_ofn.hwndOwner = PreModal(); + AfxUnhookWindowCreate(); + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) + { + bEnableParent = true; + ::EnableWindow(m_ofn.hwndOwner, false); + } + + _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); + assert(pThreadState->m_pAlternateWndInit == NULL); + + if (m_ofn.Flags & OFN_EXPLORER) + pThreadState->m_pAlternateWndInit = this; + else + AfxHookWindowCreate(this); + + int nResult; + if (m_bOpenFileDialog) + nResult = ::GetOpenFileName(&m_ofn); + else + nResult = ::GetSaveFileName(&m_ofn); + + if (nResult) + assert(pThreadState->m_pAlternateWndInit == NULL); + pThreadState->m_pAlternateWndInit = NULL; + + // WINBUG: Second part of special case for file open/save dialog. + if (bEnableParent) + ::EnableWindow(m_ofn.hwndOwner, true); + if (::IsWindow(hWndFocus)) + ::SetFocus(hWndFocus); +*/ + + +void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { +#if 0 + OPENFILENAME ofn; + char lpszFileName[512]; + + // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione + + // Sceglie la locazione + ZeroMemory(lpszFileName,512); + ZeroMemory(&ofn,sizeof(ofn)); + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner=NULL; + ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; + ofn.lpstrCustomFilter=NULL; + ofn.nFilterIndex=1; + ofn.lpstrFile=lpszFileName; + ofn.nMaxFile=512; + ofn.lpstrInitialDir=NULL; + ofn.lpstrTitle="Load Location"; + ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; + + if (!GetOpenFileName(&ofn)) + assert(0); + + // Carica la locazione + m_loc.Load(lpszFileName); + m_bLocationLoaded = true; + m_nCurLoc=m_loc.TEMPGetNumLoc(); + + if (ptTonyStart.x==-1 && ptTonyStart.y==-1) + InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); + else + InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); +#endif +} + +void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + if (start.x == -1 || start.y == -1) { + start.x = ptTonyStart.x-RM_SX/2; + start.y = ptTonyStart.y-RM_SY/2; + } + + m_loc.SetScrollPosition(start); + + if (ptTonyStart.x==0 && ptTonyStart.y==0) { + } else { + m_tony.SetPosition(ptTonyStart, nLoc); + m_tony.SetScrollPosition(start); + } + + m_curAction=TA_GOTO; + m_point.SetCustomPointer(NULL); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetAction(m_curAction); + m_inter.Reset(); + m_inv.Reset(); + + mpalStartIdlePoll(m_nCurLoc); +} + +HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + bool bLoaded; + int i; + + m_nCurLoc=nLoc; + + bLoaded = false; + for (i = 0; i < 5; i++) { + // Retry sul loading della locazione + RMRes res(m_nCurLoc); + if (!res.IsValid()) + continue; +#if 0 + // codice per dumpare una locazione in caso serva una modifica + if (nLoc == 106) + { + FILE *f = fopen("loc106.lox", "wb"); + fwrite(res.DataPointer(), res.Size(), 1, f); + fclose(f); + } +#endif + m_loc.Load(res); + InitForNewLocation(nLoc, ptTonyStart, start); + bLoaded = true; + break; + } + + if (!bLoaded) + SelectLocation(ptTonyStart, start); + + if (m_bOption) + m_opt.ReInit(m_bigBuf); + + m_bLocationLoaded = true; + + // On Enter per la locazion + return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0, m_nCurLoc, 0); +} + +HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { + HANDLE h; + + // Scarica tutta la memoria della locazione + mpalEndIdlePoll(m_nCurLoc); + + // On Exit? + if (bDoOnExit) { + h = mpalQueryDoAction(1, m_nCurLoc, 0); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h, INFINITE); + } + + MainFreeze(); + + m_bLocationLoaded = false; + + m_bigBuf.ClearOT(); + m_loc.Unload(); + + return INVALID_HANDLE_VALUE; +} + +void RMGfxEngine::Init() { + // Screen loading + RMResRaw *raw; + RMGfxSourceBuffer16 *load = NULL; + INIT_GFX16_FROMRAW(20038, load); + m_bigBuf.AddPrim(new RMGfxPrimitive(load)); + m_bigBuf.DrawOT(); + m_bigBuf.ClearOT(); + delete load; + _vm->m_wnd.GetNewFrame(*this, NULL); + + + + bPatIrqFreeze = true; + + // GUI attivabile + m_bGUIOption = true; + m_bGUIInterface = true; + m_bGUIInventory = true; + + bSkipSfxNoLoop = false; + m_bMustEnterMenu = false; + bIdleExited = false; + m_bOption = false; + m_bWiping = false; + m_hWipeEvent=CreateEvent(NULL, false, false, NULL); + + // Crea l'evento di freeze + g_system->lockMutex(csMainLoop); + + // Inizializza la funzione di IRQ di Item per l'MPAL + ItemIrq((uint32)-1, (uint32)this, 0); + mpalInstallItemIrq(ItemIrq); + + // Inizializza DirectInput + m_input.Init(/*hInst*/); + + // Inizializza il puntatore del mouse + m_point.Init(); + + // Inizializza Tony + m_tony.Init(); + m_tony.LinkToBoxes(&_vm->_theBoxes); + + // Inizializza l'inventario e l'interfaccia + m_inv.Init(); + m_inter.Init(); + + // Carica la locazione e setta le priorit @@@@@ + m_bLocationLoaded = false; +/* + m_nCurLoc=1; + RMRes res(m_nCurLoc); + m_loc.Load(res); + m_loc.SetPriority(1); + m_tony.SetPosition(RMPoint(201,316),1); + //m_tony.SetPosition(RMPoint(522,305),2); + //m_tony.SetPosition(RMPoint(158,398),4); + m_tony.SetPattern(m_tony.PAT_STANDDOWN); + m_curAction=TA_GOTO; +*/ + EnableInput(); + + // Inizio del gioco + //m_tony.ExecuteAction(4,1,0); //PREGAME + + m_tony.ExecuteAction(20,1,0); + +// theLog << "Seleziona la locazione\n"; + //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); + //SelectLocation(); + //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); + //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); + //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); + //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); + //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); + //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); + //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); + + // CASTELLO + + //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); +} + +void RMGfxEngine::Close(void) { + m_bigBuf.ClearOT(); + + m_inter.Close(); + m_inv.Close(); + m_tony.Close(); + m_point.Close(); + m_input.Close(); +} + +void RMGfxEngine::SwitchFullscreen(bool bFull) { + m_input.SwitchFullscreen(bFull); +} + +void RMGfxEngine::GDIControl(bool bCon) +{ + m_input.GDIControl(bCon); +} + +/* +void RMGfxEngine::OptionScreen(void) +{ + if (!m_bOption) + { + if (m_opt.Init(m_bigBuf)) + { + m_bOption = true; + DisableInput(); + EnableMouse(); + } + } + else + { + if (m_opt.Close()) + { + m_bOption = false; + DisableMouse(); + EnableInput(); + } + } +} +*/ + +void RMGfxEngine::EnableInput(void) { + m_bInput = true; +} + +void RMGfxEngine::DisableInput(void) { + m_bInput = false; + m_inter.Reset(); +} + +void RMGfxEngine::EnableMouse(void) { + m_bAlwaysDrawMouse = true; +} + +void RMGfxEngine::DisableMouse(void) { + m_bAlwaysDrawMouse = false; +} + +void RMGfxEngine::Freeze(void) { + g_system->lockMutex(csMainLoop); +} + +void RMGfxEngine::Unfreeze(void) { + g_system->unlockMutex(csMainLoop); +} + +void CharsSaveAll(Common::OutSaveFile *fp); +void CharsLoadAll(Common::InSaveFile *fp); +void MCharResetCodes(void); +void SaveChangedHotspot(Common::OutSaveFile *f); +void LoadChangedHotspot(Common::InSaveFile *f); +void ReapplyChangedHotspot(void); + +void RestoreMusic(void); +void SaveMusic(Common::OutSaveFile *f); +void LoadMusic(Common::InSaveFile *f); + +unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; + +void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { + Common::OutSaveFile *f; + byte *state, *statecmp; + byte *thumbcmp; + uint32 thumbsizecmp, thumbsize; + uint32 size, sizecmp; + int i; + char buf[4]; + RMPoint tp = m_tony.Position(); + + // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario + + // Per ora salviamo solo lo stato MPAL + size = mpalGetSaveStateSize(); + state = new byte[size]; + statecmp = new byte[size*2]; + mpalSaveState(state); + + thumbcmp = new byte[160*120*4]; + thumbsize = 160*120*2; + + if (bFastCompress) { + lzo1x_1_compress(state, size, statecmp, &sizecmp, wrkmem); + lzo1x_1_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); + } else { + lzo1x_999_compress(state, size, statecmp, &sizecmp, wrkmem); + lzo1x_999_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); + } + + buf[0] = 'R'; + buf[1] = 'M'; + buf[2] = 'S'; + buf[3] = 0x7; + + f = g_system->getSavefileManager()->openForSaving(fn); + if (f == NULL) + return; + + f->write(buf, 4); + f->writeUint32LE(thumbsizecmp); + f->write(thumbcmp, thumbsizecmp); + + // Livello di difficolt + i = mpalQueryGlobalVar("VERSIONEFACILE"); + f->writeByte(i); + + i = strlen(name); + f->writeByte(i); + f->write(name, i); + + f->writeUint32LE(m_nCurLoc); + f->writeUint32LE(tp.x); + f->writeUint32LE(tp.y); + f->writeUint32LE(size); + f->writeUint32LE(sizecmp); + + f->write(statecmp, sizecmp); + + delete [] state; + delete [] statecmp; + delete [] thumbcmp; + + // inventario + size = m_inv.GetSaveStateSize(); + state = new byte[size]; + m_inv.SaveState(state); + + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // boxes + size = _vm->_theBoxes.GetSaveStateSize(); + state = new byte[size]; + _vm->_theBoxes.SaveState(state); + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // New Ver5 + bool bStat; + + // Salva lo stato della pastorella e del palesati + bStat = m_tony.GetPastorella(); + f->writeByte(bStat); + bStat = m_inter.GetPalesati(); + f->writeByte(bStat); + + // Salva gli mchar + CharsSaveAll(f); + + // Salva le opzioni + f->writeByte(bCfgInvLocked); + f->writeByte(bCfgInvNoScroll); + f->writeByte(bCfgTimerizedText); + f->writeByte(bCfgInvUp); + f->writeByte(bCfgAnni30); + f->writeByte(bCfgAntiAlias); + f->writeByte(bCfgSottotitoli); + f->writeByte(bCfgTransparence); + f->writeByte(bCfgInterTips); + f->writeByte(bCfgDubbing); + f->writeByte(bCfgMusic); + f->writeByte(bCfgSFX); + f->writeByte(nCfgTonySpeed); + f->writeByte(nCfgTextSpeed); + f->writeByte(nCfgDubbingVolume); + f->writeByte(nCfgMusicVolume); + f->writeByte(nCfgSFXVolume); + + // Salva gli hotspot + SaveChangedHotspot(f); + + // Salva la musica + SaveMusic(f); + + f->finalize(); + delete f; +} + +void RMGfxEngine::LoadState(const char *fn) { + // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... + Common::InSaveFile *f; + byte *state, *statecmp; + uint32 size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; + + f = g_system->getSavefileManager()->openForLoading(fn); + if (f == NULL) + return; + + f->read(buf, 4); + if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { + delete f; + return; + } + + ver = buf[3]; + + if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { + delete f; + return; + } + + if (ver >= 0x3) { + // C' il thumbnail. Se ver >= 5, compresso + if (ver >= 0x5) { + i = 0; + i = f->readUint32LE(); + f->seek(i, SEEK_CUR); + } else + f->seek(160 * 120 * 2, SEEK_CUR); + } + + if (ver >= 0x5) { + // Skip del livello di difficolt + f->seek(1, SEEK_CUR); + } + + if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno + i = f->readByte(); + f->seek(i, SEEK_CUR); + } + + loc = f->readUint32LE(); + tp.x = f->readUint32LE(); + tp.y = f->readUint32LE(); + size = f->readUint32LE(); + + if (ver >= 0x5) { + // Stato MPAL compresso! + sizecmp = f->readUint32LE(); + state = new byte[size]; + statecmp = new byte[sizecmp]; + f->read(statecmp, sizecmp); + lzo1x_decompress(statecmp, sizecmp, state, &size); + + delete[] statecmp; + } else { + state = new byte[size]; + f->read(state, size); + } + + mpalLoadState(state); + delete[] state; + + + // inventario + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + + m_inv.LoadState(state); + delete[] state; + + if (ver >= 0x2) { // Versione 2: box please + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + _vm->_theBoxes.LoadState(state); + delete[] state; + } + + if (ver >= 5) { + // Versione 5: + bool bStat = false; + + bStat = f->readByte(); + m_tony.SetPastorella(bStat); + bStat = f->readByte(); + m_inter.SetPalesati(bStat); + + CharsLoadAll(f); + } + + if (ver >= 6) { + // Carica le opzioni + bCfgInvLocked = f->readByte(); + bCfgInvNoScroll = f->readByte(); + bCfgTimerizedText = f->readByte(); + bCfgInvUp = f->readByte(); + bCfgAnni30 = f->readByte(); + bCfgAntiAlias = f->readByte(); + bCfgSottotitoli = f->readByte(); + bCfgTransparence = f->readByte(); + bCfgInterTips = f->readByte(); + bCfgDubbing = f->readByte(); + bCfgMusic = f->readByte(); + bCfgSFX = f->readByte(); + nCfgTonySpeed = f->readByte(); + nCfgTextSpeed = f->readByte(); + nCfgDubbingVolume = f->readByte(); + nCfgMusicVolume = f->readByte(); + nCfgSFXVolume = f->readByte(); + + // Carica gli hotspot + LoadChangedHotspot(f); + } + + if (ver >= 7) { + LoadMusic(f); + } + + delete f; + + UnloadLocation(false); + LoadLocation(loc, tp, RMPoint(-1, -1)); + m_tony.SetPattern(RMTony::PAT_STANDRIGHT); + MainUnfreeze(); + + // Le versioni vecchie necessitano di On enter + if (ver < 5) + mpalQueryDoAction(0, loc, 0); + else { + // In quelle nuove, ci basta resettare gli mcode + MCharResetCodes(); + } + + if (ver >= 6) + ReapplyChangedHotspot(); + + RestoreMusic(); + + m_bGUIInterface = true; + m_bGUIInventory = true; + m_bGUIOption = true; +} + +void RMGfxEngine::PauseSound(bool bPause) { + if (m_bLocationLoaded) + m_loc.PauseSound(bPause); +} + +void RMGfxEngine::InitWipe(int type) { + m_bWiping = true; + m_nWipeType=type; + m_nWipeStep=0; + + if (m_nWipeType==1) + m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); + else if (m_nWipeType == 2) + m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); +} + +void RMGfxEngine::CloseWipe(void) { + m_bWiping = false; +} + +void RMGfxEngine::WaitWipeEnd(void) { + WaitForSingleObject(m_hWipeEvent, INFINITE); +} } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 313e471cdf..f5553d21c6 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -237,7 +237,7 @@ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: // Carica i dati della surface a basso livello virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 317056315e..2019cf01c9 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -145,8 +145,8 @@ public: void Unfreeze(void); // State management - void SaveState(char *fn, byte *curThumb, char *name, bool bFastCompress = false); - void LoadState(char *fn); + void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false); + void LoadState(const char *fn); // Selects a location void SelectLocation(RMPoint ptTonyStart=RMPoint(-1,-1), RMPoint start=RMPoint(-1,-1)); diff --git a/engines/tony/input.h b/engines/tony/input.h index 6ea56024a9..554b10628b 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -75,7 +75,7 @@ public: ~RMInput(); // Class initialisation - void Init(uint32 hInst); + void Init(/*uint32 hInst*/); // Closes the class void Close(void); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 1cae9edb1e..73effc85c1 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -541,7 +541,7 @@ public: // Caricamento da disco bool Load(char *lpszFileName); bool Load(HANDLE hFile); - bool Load(byte *buf); + bool Load(const byte *buf); bool Load(RMDataStream &ds); bool LoadLOX(RMDataStream &ds); @@ -561,10 +561,10 @@ public: RMItem* GetItemFromCode(uint32 dwCode); // Setta la posizione corrente di scrolling - void SetScrollPosition(RMPoint &scroll); + void SetScrollPosition(const RMPoint &scroll); // Setta un offset aggiuntivo di scrolling da aggiungere sempre - void SetFixedScroll(RMPoint &scroll); + void SetFixedScroll(const RMPoint &scroll); // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito void UpdateScrolling(RMPoint ptShowThis); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index cbc07d27b7..7c2c7928a8 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -1,6 +1,7 @@ MODULE := engines/tony MODULE_OBJS := \ + custom.o \ detection.o \ game.o \ gfxcore.o \ diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 6cd755fc93..17b059455c 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -63,6 +63,7 @@ */ #include "lzo.h" +#include "common/textconsole.h" namespace Tony { @@ -505,6 +506,19 @@ lookbehind_overrun: #endif } +int lzo1x_1_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { + warning("TODO: lzo1x_1_compress"); + return 0; +} + +/** + * better compression ratio at the cost of more memory and time + */ +int lzo1x_999_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { + warning("TODO: lzo1x_999_compress"); + return 0; +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/lzo.h b/engines/tony/mpal/lzo.h index 1d20c8e96e..ebb1c4b516 100644 --- a/engines/tony/mpal/lzo.h +++ b/engines/tony/mpal/lzo.h @@ -87,12 +87,23 @@ namespace MPAL { #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ #define LZO_E_INVALID_ARGUMENT (-10) +#define LZO1X_999_MEM_COMPRESS ((uint32) (14 * 16384L * sizeof(uint16))) /** * Decompresses an LZO compressed resource */ int lzo1x_decompress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len); +/** + * Comrpess a data block into an LZO stream + */ +int lzo1x_1_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem); + +/** + * better compression ratio at the cost of more memory and time + */ +int lzo1x_999_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 054ed55c68..ea93265ec9 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -59,9 +59,15 @@ HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, return 0; } +void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter) { +} + void ExitThread(int ThreadId) { } +void _endthread() { +} + void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { } @@ -91,6 +97,10 @@ void SetEvent(HANDLE hEvent) { void ResetEvent(HANDLE hEvent) { } +uint16 GetAsyncKeyState(Common::KeyCode kc) { + return 0; +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index a8d3253ddb..9a22b65b7a 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -31,6 +31,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "common/keyboard.h" #include "tony/mpal/memory.h" namespace Tony { @@ -42,6 +43,7 @@ namespace MPAL { \****************************************************************************/ typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); +typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); /****************************************************************************\ * Defines @@ -82,8 +84,12 @@ extern HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, uint32 dwCreationFlags, uint32 *lpThreadId); +extern void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter); + extern void ExitThread(int ThreadId); +extern void _endthread(); + extern void TerminateThread(HANDLE ThreadId, uint32 dwExitCode); extern void CloseHandle(HANDLE ThreadId); @@ -100,6 +106,8 @@ extern void SetEvent(HANDLE hEvent); extern void ResetEvent(HANDLE hEvent); +extern uint16 GetAsyncKeyState(Common::KeyCode kc); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 75a70553ef..c966c93888 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -54,7 +54,9 @@ namespace Tony { +class FPSTREAM; class FPSFX; +class CODEC; enum CODECS { FPCODEC_RAW, @@ -62,6 +64,144 @@ enum CODECS { FPCODEC_WAV }; + +/****************************************************************************\ +***************************************************************************** +* class FPSound +* ------------- +* Description: Sound driver per Falling Pumpkins +***************************************************************************** +\****************************************************************************/ + +class FPSOUND { + +private: + + bool bSoundSupported; +/* + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBPrimary; + DSCAPS dscaps; + HWND hwnd; +*/ + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSOUND::FPSOUND(); +* +* Description: Costruttore di default. Inizializza gli attributi. +* +\****************************************************************************/ + + FPSOUND(); + + +/****************************************************************************\ +* +* Function: FPSOUND::~FPSOUND(); +* +* Description: Deinizializza l'oggetto, disallocando la memoria. +* +\****************************************************************************/ + + ~FPSOUND(); + + +/****************************************************************************\ +* +* Function: bool FPSOUND::Init(HWND hWnd); +* +* Description: Inizializza l'oggetto, e prepara tutto il necessario per +* creare stream e effetti sonori. +* +* Input: HWND hWnd Handle della finestra principale +* +* Return: True se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + + bool Init(/*HWND hWnd*/); + + +/****************************************************************************\ +* +* Function: bool CreateStream(FPSTREAM** lplpStream); +* +* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* appena creato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), +* sono dovute al fatto che i costruttori delle classi FPSTREAM +* e FPSFX richiedono che DirectSound sia gia' stato +* inzializzato. In questo modo quindi si evitano dei bugs +* che si verrebbero a creare se venisse dichiarata un oggetto +* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* inizializzazione di DirectSound). +* +\****************************************************************************/ + + bool CreateStream(FPSTREAM **lplpStream); + + + +/****************************************************************************\ +* +* Function: bool CreateSfx(FPSFX** lplpSfx); +* +* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* appena creato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +* Note: Vedi le note di CreateStream() +* +\****************************************************************************/ + + bool CreateSfx(FPSFX **lplpSfx); + + + +/****************************************************************************\ +* +* Function: void SetMasterVolume(int dwVolume); +* +* Description: Setta il volume generale +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetMasterVolume(int dwVolume); + + +/****************************************************************************\ +* +* Function: void GetMasterVolume(LPINT lpdwVolume); +* +* Description: Richiede il volume generale +* +* Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) +* +\****************************************************************************/ + + void GetMasterVolume(int *lpdwVolume); +}; + class FPSFX { /****************************************************************************\ @@ -93,7 +233,7 @@ private: // DSBPOSITIONNOTIFY dspnHot[2]; public: -// HANDLE hEndOfBuffer; + HANDLE hEndOfBuffer; private: @@ -159,9 +299,9 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); - bool LoadFile(byte *lpBuf, uint32 dwCodec); - bool LoadVoiceFromVDB(HANDLE hvdb); + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool LoadVoiceFromVDB(Common::File &hvdb); /****************************************************************************\ @@ -249,6 +389,223 @@ public: void GetVolume(int * lpdwVolume); }; +class FPSTREAM { + +/****************************************************************************\ +* Attributi +\****************************************************************************/ + +private: + +/* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer +*/ + byte *lpTempBuffer; // Buffer temporaneo per decompressione + + uint32 dwBufferSize; // Dimensione del buffer in bytes + uint32 dwSize; // Dimensione dello stream in bytes + uint32 dwCodec; // CODEC utilizzato + + HANDLE hThreadEnd; // Evento per chiudere il thread + HANDLE hFile; // Handle del file di stream + HANDLE hPlayThread; // Handle del thread di play + HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify + HANDLE hPlayThread_PlayFast; + HANDLE hPlayThread_PlayNormal; + + bool bSoundSupported; // TRUE se il suono e' attivo + bool bFileLoaded; // TRUE se e' stato aperto un file + bool bLoop; // TRUE se bisogna loopare lo stream + bool bDoFadeOut; // TRUE se bisogna fare un fade out + bool bSyncExit; + bool bPaused; + int lastVolume; + FPSTREAM *SyncToPlay; +// DSBPOSITIONNOTIFY dspnHot[3]; + + CODEC *lpCodec; // CODEC da utilizzare. + bool CreateBuffer(int nBufSize); + +public: + bool bIsPlaying; // TRUE se si sta playando lo stream + +private: + + static void PlayThread(FPSTREAM *This); + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* +\****************************************************************************/ + + FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); + + +/****************************************************************************\ +* +* Function: ~FPSTREAM(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare stream +* eventualmente in esecuzione, e disallocare la memoria da +* essi occupata. +* +\****************************************************************************/ + + ~FPSTREAM(); + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + + void Release(); + + +/****************************************************************************\ +* +* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di stream. +* +* Input: char *lpszFile Nome del file di stream da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +\****************************************************************************/ + + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + + + +/****************************************************************************\ +* +* Function: UnloadFile(); +* +* Description: Chiude un file di stream eventualmente aperto. E' necessario +* richiamare questa funzione per disallocare la memoria +* occupata dallo stream. +* +* Return: Il distruttore della classe per sicurezza richiama la +* UnloadFile() se non e' stata richiamata esplicitamente. +* +\****************************************************************************/ + + bool UnloadFile(); + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo stream caricato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Play(); + void PlayFast(void); + void Prefetch(void); + + +/****************************************************************************\ +* +* Function: bool Stop(); +* +* Description: Ferma il play dello stream. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Stop(bool bSync = false); + void WaitForSync(FPSTREAM* toplay); + + +/****************************************************************************\ +* +* Function: void Pause(bool bPause); +* +* Description: Pause dell'effetto sonoro +* +\****************************************************************************/ + + void Pause(bool bPause); + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello stream. +* +* Input: bool bLoop TRUE per attivare il loop, FALSE per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello stream. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo stream non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + + void SetLoop(bool bLoop); + + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello stream +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetVolume(int dwVolume); + + + +/****************************************************************************\ +* +* Function: void GetVolume(LPINT lpdwVolume); +* +* Description: Chiede il volume dello stream +* +* Input: LPINT lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + + void GetVolume(int *lpdwVolume); +}; + + } // End of namespace Tony #endif diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a370c8efaf..e27cb6d9d3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -49,10 +49,9 @@ Common::Error TonyEngine::run() { if (result != Common::kNoError) return result; - /* Play(); Close(); -*/ + return Common::kNoError; } @@ -60,6 +59,12 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { + m_hEndOfFrame = CreateEvent(NULL, false, false, NULL); + + m_bPaused = false; + m_bDrawLocation = true; + m_startTime = g_system->getMillis(); + // Initialise the function list Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); @@ -98,6 +103,60 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } +char nextMusic[_MAX_PATH]; +bool nextLoop; +int nextChannel; +int nextSync; +int curChannel; +int flipflop=0; +OSystem::MutexRef csMusic; + + +void TonyEngine::PlayMusic(int nChannel, char* fn, int nFX, bool bLoop, int nSync) { + warning("TonyEngine::PlayMusic"); +} + +void TonyEngine::PlaySFX(int nChannel, int nFX) { + warning("TonyEngine::PlaySFX"); +} + +void TonyEngine::StopMusic(int nChannel) { + warning("TonyEngine::StopMusic"); +} + +void TonyEngine::StopSFX(int nChannel) { + warning("TonyEngine::StopSFX"); +} + +void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { + warning("TonyEngine::PlayUtilSFX"); +} + +void TonyEngine::StopUtilSFX(int nChannel) { + warning("TonyEngine::StopUtilSFX"); +} + +void TonyEngine::PreloadSFX(int nChannel, char* fn) { + warning("TonyEngine::PreloadSFX"); +} + +FPSFX *TonyEngine::CreateSFX(byte *buf) { + warning("TonyEngine::CreateSFX"); + return NULL; +} + +void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) { + warning("TonyEngine::PreloadUtilSFX"); +} + +void TonyEngine::UnloadAllSFX(void) { + warning("TonyEngine::UnloadAllSFX"); +} + +void TonyEngine::UnloadAllUtilSFX(void) { + warning("TonyEngine::UnloadAllUtilSFX"); +} + void TonyEngine::InitMusic() { warning("TODO: TonyEngine::InitMusic"); } @@ -160,4 +219,9 @@ void TonyEngine::CloseVoiceDatabase() { _voices.clear(); } +void TonyEngine::GrabThumbnail(void) { + //m_wnd.GrabThumbnail(m_curThumbnail); + warning("TODO: TonyEngine::GrabThumbnail"); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index a372260c34..f3b840faf5 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -36,6 +36,7 @@ #include "tony/gfxEngine.h" #include "tony/loc.h" #include "tony/utils.h" +#include "tony/window.h" /** * This is the namespace of the Tony engine. @@ -72,11 +73,9 @@ struct VoiceHeader { class TonyEngine : public Engine { private: Common::ErrorCode Init(); + void InitMusic(); void CloseMusic(); - void PauseSound(bool bPause); - void SetMusicVolume(int nChannel, int volume); - int GetMusicVolume(int nChannel); bool OpenVoiceDatabase(); void CloseVoiceDatabase(); protected: @@ -88,24 +87,105 @@ public: Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; + HANDLE m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; + FPSOUND _theSound; // Bounding box list manager RMGameBoxes _theBoxes; RMGfxEngine _theEngine; + RMWindow m_wnd; + bool m_bPaused; + bool m_bDrawLocation; + int m_startTime; + uint16 *m_curThumbnail; + + bool m_bQuitNow; + bool m_bTimeFreezed; + int m_nTimeFreezed; + + enum DATADIR { + DD_BASE = 1, + DD_SAVE, + DD_SHOTS, + DD_MUSIC, + DD_LAYER, + DD_UTILSFX, + DD_VOICES, + DD_BASE2 + }; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); const TonyGameDescription *_gameDescription; - uint32 getGameID() const; uint32 getFeatures() const; Common::Language getLanguage() const; uint16 getVersion() const; - uint32 getFlags() const; - Common::Platform getPlatform() const; - + bool getIsDemo() const; + RMGfxEngine *GetEngine() { return &_theEngine; } void GUIError(const Common::String &msg); + + void Play(); + void Close(); + void Abort(); + + void GetDataDirectory(DATADIR dir, char *path); + + void SwitchFullscreen(bool bFull); + void OptionScreen(void); + + void ShowLocation(void) { m_bDrawLocation = true; } + void HideLocation(void) { m_bDrawLocation = false; } + + // Mette o leva la pausa + void Pause(bool bPause); + bool IsPaused() { return m_bPaused; } + + // Reads the time + uint32 GetTime(void); + void FreezeTime(void); + void UnfreezeTime(void); + + // Music + // ****** + void PlayMusic(int nChannel, char *fn, int nFX, bool bLoop, int nSync); + void StopMusic(int nChannel); + + void PlaySFX(int nSfx, int nFX = 0); + void StopSFX(int nSfx); + + void PlayUtilSFX(int nSfx, int nFX = 0); + void StopUtilSFX(int nSfx); + + FPSFX *CreateSFX(byte *buf); + + void PreloadSFX(int nSfx, char *fn); + void UnloadAllSFX(void); + + void PreloadUtilSFX(int nSfx, char *fn); + void UnloadAllUtilSFX(void); + + // Ferma tutta la parte audio + void PauseSound(bool bPause); + + void SetMusicVolume(int nChannel, int volume); + int GetMusicVolume(int nChannel); + + // Salvataggio + void AutoSave(void); + void SaveState(int n, char *name); + void LoadState(int n); + void GetSaveStateFileName(int n, char* buf); + + // Prende il thumbnail + void GrabThumbnail(void); + uint16 *GetThumbnail(void) { return m_curThumbnail; } + + void Quit(void) { m_bQuitNow = true; } + + void OpenInitLoadMenu(void); + void OpenInitOptions(void); }; // Global reference to the TonyEngine object diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 9d3c0202d0..9806fd5e58 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -49,6 +49,7 @@ #define TONY_TONYCHAR_H #include "tony/mpal/stubs.h" +#include "tony/loc.h" namespace Tony { diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 48dcb9392a..360b7a6f32 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -980,7 +980,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { uint32 dwSize; // Decompress the data - MPAL::lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); // Delete buffer for compressed data delete [] cmpBuf; diff --git a/engines/tony/window.h b/engines/tony/window.h new file mode 100644 index 0000000000..d248ffb871 --- /dev/null +++ b/engines/tony/window.h @@ -0,0 +1,134 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi per la gestione * + * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct + * "#$e z$*" . `. ^*Nc e$"" Draw................. * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_WINDOW_H +#define TONY_WINDOW_H + +#include "common/scummsys.h" +#include "common/rect.h" + +namespace Tony { + +typedef uint32 HWND; + +class RMWindow { +private: + bool Lock(/*DDSURFACEDESC& ddsd */); + void Unlock(/*DDSURFACEDESC& ddsd */); + + // Inizializza DirectDraw + void DDInit(void); + + // Chiude DirectDraw + void DDClose(void); + + // Repaint grafico tramite DirectDraw + void Repaint(void); + + // Window Proc principale che richiama la WindowProc dentro la classe +// friend LRESULT CALLBACK GlobalWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + + // Procedura di gestione messaggi +// LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam); + +protected: + HWND m_hWnd; + bool m_bFullscreen; + + void * /*LPDIRECTDRAW*/ m_DD; + void * /*LPDIRECTDRAWSURFACE*/ m_Primary; + void * /*LPDIRECTDRAWSURFACE*/ m_Back; + void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; + void * /*LPDIRECTDRAWCLIPPER*/ m_BackClipper; + + int fps, fcount; + int lastsecond, lastfcount; + + int mskRed, mskGreen, mskBlue; + + bool m_bGrabScreenshot; + bool m_bGrabThumbnail; + bool m_bGrabMovie; + uint16 *m_wThumbBuf; + + void CreateBWPrecalcTable(void); + void UpdatePixelFormat(void); + void WipeEffect(Common::Rect &rcBoundEllipse); + + public: + RMWindow() { m_Primary = NULL; m_Back = NULL; }; + ~RMWindow() { Close(); } + + // Inizializzazione + void Init(/*HINSTANCE hInst*/); + void InitDirectDraw(void); + void Close(void); + + // Switch tra windowed e fullscreen + void SwitchFullscreen(bool bFull); + + // Legge il prossimo frame + void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + + // Avverte di grabbare un thumbnail per il salvataggio +// void GrabThumbnail(uint16 *buf); + + operator HWND() { return m_hWnd; } + + // Modi pixel format + // MODE1: 1555 + // MODE2: 5515 + // MODE3: 5551 + bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } + bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } + bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } + bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } +}; + +} // End of namespace Tony + +#endif /* TONY_WINDOW_H */ -- cgit v1.2.3 From 7d9156b12faf36197e8c3e97532675dcb9094f19 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 1 May 2012 23:00:03 +1000 Subject: TONY: Implemented GfxEngine code --- engines/tony/game.cpp | 32 +- engines/tony/game.h | 37 ++ engines/tony/gfxengine.cpp | 949 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/tony.cpp | 29 +- 4 files changed, 1020 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d759ef510a..acafbbf7c8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -236,26 +236,6 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { } -/****************************************************************************\ -* RMOptionSlide methods -\****************************************************************************/ - -#define INIT_GFX16_FROMRAW(dwRes, buf16) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf16) == NULL); \ - (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->Init(*raw,raw->Width(),raw->Height()); \ - delete raw; - -#define INIT_GFX8_FROMRAW(dwRes, buf8) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf8) == NULL); \ - (buf8) = new RMGfxSourceBuffer8RLEByte(); \ - (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ - delete raw; - /****************************************************************************\ * Metodi di RMGfxEngine \****************************************************************************/ @@ -284,23 +264,23 @@ RMGfxEngine::~RMGfxEngine() { } void RMGfxEngine::OpenOptionScreen(int type) { - bool bRes; + bool bRes = false; switch (type) { case 0: - bRes=m_opt.Init(m_bigBuf); + bRes = m_opt.Init(m_bigBuf); break; case 1: - bRes=m_opt.InitLoadMenuOnly(m_bigBuf, true); + bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); break; case 2: - bRes=m_opt.InitNoLoadSave(m_bigBuf); + bRes = m_opt.InitNoLoadSave(m_bigBuf); break; case 3: - bRes=m_opt.InitLoadMenuOnly(m_bigBuf, false); + bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); break; case 4: - bRes=m_opt.InitSaveMenuOnly(m_bigBuf, false); + bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); break; } diff --git a/engines/tony/game.h b/engines/tony/game.h index 28f9489267..593203e443 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -56,6 +56,43 @@ namespace Tony { +#define INIT_GFX16_FROMRAW(dwRes, buf16) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf16) == NULL); \ + (buf16) = new RMGfxSourceBuffer16(false); \ + (buf16)->Init(*raw,raw->Width(),raw->Height()); \ + delete raw; + +#define INIT_GFX8_FROMRAW(dwRes, buf8) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf8) == NULL); \ + (buf8) = new RMGfxSourceBuffer8RLEByte(); \ + (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ + delete raw; + +extern bool bCfgInvLocked; +extern bool bCfgInvNoScroll; +extern bool bCfgTimerizedText; +extern bool bCfgInvUp; +extern bool bCfgAnni30; +extern bool bCfgAntiAlias; +extern bool bCfgSottotitoli; +extern bool bCfgTransparence; +extern bool bCfgInterTips; +extern bool bCfgDubbing; +extern bool bCfgMusic; +extern bool bCfgSFX; +extern int nCfgTonySpeed; +extern int nCfgTextSpeed; +extern int nCfgDubbingVolume; +extern int nCfgMusicVolume; +extern int nCfgSFXVolume; +extern bool bSkipSfxNoLoop; + +extern bool bPatIrqFreeze; + class RMPointer : public RMGfxTask { private: RMGfxSourceBuffer8 *m_pointer[16]; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 02ee7c8e8e..b8accda7c6 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -45,9 +45,958 @@ * * **************************************************************************/ +#include "common/savefile.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/mpalutils.h" +#include "tony/custom.h" #include "tony/gfxEngine.h" +#include "tony/tony.h" namespace Tony { +extern bool bIdleExited; +extern bool bPatIrqFreeze; +extern bool bSkipSfxNoLoop; + +extern void ExitAllIdles(int nCurLoc); + +/****************************************************************************\ +* Metodi di RMGfxEngine +\****************************************************************************/ + +RMGfxEngine::RMGfxEngine() { + // Crea il big buffer dove verranno disegnati i frame + m_bigBuf.Create(RM_BBX,RM_BBY,16); + m_bigBuf.OffsetY(RM_SKIPY); +} + +RMGfxEngine::~RMGfxEngine() { + // Chiude il buffer + m_bigBuf.Destroy(); +} + +void RMGfxEngine::OpenOptionScreen(int type) { + bool bRes = false; + + switch (type) { + case 0: + bRes = m_opt.Init(m_bigBuf); + break; + case 1: + bRes = m_opt.InitLoadMenuOnly(m_bigBuf,true); + break; + case 2: + bRes = m_opt.InitNoLoadSave(m_bigBuf); + break; + case 3: + bRes = m_opt.InitLoadMenuOnly(m_bigBuf,false); + break; + case 4: + bRes = m_opt.InitSaveMenuOnly(m_bigBuf,false); + break; + } + + if (bRes) { + _vm->PauseSound(true); + + DisableInput(); + m_inv.EndCombine(); + m_curActionObj = 0; + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetCustomPointer(NULL); + EnableMouse(); + _vm->GrabThumbnail(); + + // Esce la IDLE onde evitare la morte prematura in caricamento + m_bMustEnterMenu = true; + if (type == 1 || type == 2) { + bIdleExited = true; + } else { + m_tony.StopNoAction(); + + uint32 id; + bIdleExited = false; + CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); + } + } +} + +void RMGfxEngine::DoFrame(bool bDrawLocation) { + g_system->lockMutex(csMainLoop); + + // Poll dei dispositivi di input + m_input.Poll(); + + if (m_bMustEnterMenu && bIdleExited) { + m_bOption = true; + m_bMustEnterMenu = false; + bIdleExited = false; + } + + if (m_bOption) { + m_opt.DoFrame(&m_input); + m_bOption = !m_opt.IsClosing(); + if (!m_bOption) { + DisableMouse(); + EnableInput(); + mpalStartIdlePoll(m_nCurLoc); + _vm->PauseSound(false); + } + } + + if (bDrawLocation && m_bLocationLoaded) { + // Locazione e oggetti + m_loc.DoFrame(&m_bigBuf); + + // Controlla gli input del mouse + if (m_bInput && !m_tony.InAction()) { + // Se siamo sull'inventario, lui che controlla tutti gli input + if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + // Left click attiva il combine, se siamo su un oggetto + if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { + m_curAction = TA_COMBINE; + m_point.SetAction(m_curAction); + } + } + else + + // CLICK DESTRO + // ************ + if (m_input.MouseRightClicked()) { + if(m_itemName.IsItemSelected()) { + m_curActionObj=0; + m_inv.RightClick(m_input.MousePos()); + } else + m_inv.RightClick(m_input.MousePos()); + } else + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(),m_curAction); + + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } else { + // Menu Opzioni + // ************ + if (m_bGUIOption) { + if (!m_tony.InAction() && m_bInput) { + if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { + OpenOptionScreen(0); + goto SKIPCLICKSINISTRO; + } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) + OpenOptionScreen(0); + else if (_vm->getIsDemo()) { + if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) + OpenOptionScreen(3); + else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) + OpenOptionScreen(4); + } + } + } + + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked() && !m_inter.Active()) + { + // Se clicko dentro un oggetto, esegui l'azione + //if (m_itemName.IsItemSelected()) + { + if (m_curAction != TA_COMBINE) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + else if (m_itemName.GetSelectedItem() != NULL) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + } + + if (m_curAction == TA_COMBINE) { + m_inv.EndCombine(); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + +SKIPCLICKSINISTRO: + // CLICK DESTRO + // ************ + if (m_curAction == TA_COMBINE) { + // Durante il combine, lo annulla. + if (m_input.MouseRightClicked()) { + m_inv.EndCombine(); + m_curActionObj = 0; + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { + if (m_bGUIInterface) { + // Prima di aprire l'interfaccia, rimette GOTO + m_curAction = TA_GOTO; + m_curActionObj = 0; + m_point.SetAction(m_curAction); + m_inter.Clicked(m_input.MousePos()); + } + } + + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_bGUIInterface) { + if (m_inter.Released(m_input.MousePos(),m_curAction)) { + m_point.SetAction(m_curAction); + m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(), m_curAction); + + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } + } + + // Aggiorna il nome sotto il puntatore del mouse + m_itemName.SetMouseCoord(m_input.MousePos()); + if (!m_inter.Active() && !m_inv.MiniActive()) + m_itemName.DoFrame(m_bigBuf,m_loc,m_point,m_inv); + } + + // Inventario & interfaccia + m_inter.DoFrame(m_bigBuf, m_input.MousePos()); + m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + } + + // Anima Tony + m_tony.DoFrame(&m_bigBuf,m_nCurLoc); + + // Aggiorna lo scrolling per tenere Tony dentro lo schermo + if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { + RMPoint showThis = m_tony.Position(); + showThis.y -= 60; + m_loc.UpdateScrolling(showThis); + } + + if (m_bLocationLoaded) + m_tony.SetScrollPosition(m_loc.ScrollPosition()); + + if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { + m_point.SetCoord(m_input.MousePos()); + m_point.DoFrame(&m_bigBuf); + } + + // ********************** + // Disegna la lista di OT + // ********************** + m_bigBuf.DrawOT(); + +#define FSTEP (480/32) + + // Wipe + if (m_bWiping) { + switch (m_nWipeType) { + case 1: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { + SetEvent(m_hWipeEvent); + m_nWipeType = 3; + break; + } + + m_rcWipeEllipse.top += FSTEP; + m_rcWipeEllipse.left += FSTEP; + m_rcWipeEllipse.right -= FSTEP; + m_rcWipeEllipse.bottom -= FSTEP; + break; + + case 2: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { + SetEvent(m_hWipeEvent); + m_nWipeType = 3; + break; + } + + m_rcWipeEllipse.top -= FSTEP; + m_rcWipeEllipse.left -= FSTEP; + m_rcWipeEllipse.right += FSTEP; + m_rcWipeEllipse.bottom += FSTEP; + break; + } + } + + g_system->unlockMutex(csMainLoop); +} + + +void RMGfxEngine::InitCustomDll(void) { + SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); +} + +void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { + static RMGfxEngine *This = NULL; + RMItem *item; + + // Inizializzazione! + if ((int)dwItem == -1) { + This = (RMGfxEngine*)nPattern; + return; + } + + if (This->m_bLocationLoaded) { + item=This->m_loc.GetItemFromCode(dwItem); + if (item != NULL) { + if (nPattern!=-1) { + if (bPatIrqFreeze) + MainFreeze(); + item->SetPattern(nPattern,true); + if (bPatIrqFreeze) + MainUnfreeze(); + } + if (nStatus!=-1) + item->SetStatus(nStatus); + } + } +} + +/* + // WINBUG: This is a special case for the file open/save dialog, + // which sometimes pumps while it is coming up but before it has + // disabled the main window. + HWND hWndFocus = ::GetFocus(); + bool bEnableParent = false; + m_ofn.hwndOwner = PreModal(); + AfxUnhookWindowCreate(); + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) + { + bEnableParent = true; + ::EnableWindow(m_ofn.hwndOwner, false); + } + + _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + + if (m_ofn.Flags & OFN_EXPLORER) + pThreadState->m_pAlternateWndInit = this; + else + AfxHookWindowCreate(this); + + int nResult; + if (m_bOpenFileDialog) + nResult = ::GetOpenFileName(&m_ofn); + else + nResult = ::GetSaveFileName(&m_ofn); + + if (nResult) + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + pThreadState->m_pAlternateWndInit = NULL; + + // WINBUG: Second part of special case for file open/save dialog. + if (bEnableParent) + ::EnableWindow(m_ofn.hwndOwner, true); + if (::IsWindow(hWndFocus)) + ::SetFocus(hWndFocus); +*/ + + +void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { +#if 0 + OPENFILENAME ofn; + char lpszFileName[512]; + + // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione + + // Sceglie la locazione + ZeroMemory(lpszFileName,512); + ZeroMemory(&ofn,sizeof(ofn)); + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner=NULL; + ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; + ofn.lpstrCustomFilter=NULL; + ofn.nFilterIndex=1; + ofn.lpstrFile=lpszFileName; + ofn.nMaxFile=512; + ofn.lpstrInitialDir=NULL; + ofn.lpstrTitle="Load Location"; + ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; + + if (!GetOpenFileName(&ofn)) + ASSERT(0); + + // Carica la locazione + m_loc.Load(lpszFileName); + m_bLocationLoaded = true; + m_nCurLoc=m_loc.TEMPGetNumLoc(); + + if (ptTonyStart.x==-1 && ptTonyStart.y==-1) + InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); + else + InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); +#endif +} + +void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + if (start.x == -1 || start.y == -1) { + start.x = ptTonyStart.x-RM_SX / 2; + start.y = ptTonyStart.y-RM_SY / 2; + } + + m_loc.SetScrollPosition(start); + + if (ptTonyStart.x==0 && ptTonyStart.y == 0) { + } else { + m_tony.SetPosition(ptTonyStart,nLoc); + m_tony.SetScrollPosition(start); + } + + m_curAction = TA_GOTO; + m_point.SetCustomPointer(NULL); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetAction(m_curAction); + m_inter.Reset(); + m_inv.Reset(); + + mpalStartIdlePoll(m_nCurLoc); +} + +HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + bool bLoaded; + int i; + + m_nCurLoc=nLoc; + + bLoaded = false; + for (i=0; i < 5; i++) { + // Retry sul loading della locazione + RMRes res(m_nCurLoc); + if (!res.IsValid()) + continue; +#if 0 + // codice per dumpare una locazione in caso serva una modifica + if (nLoc == 106) + { + FILE *f = fopen("loc106.lox", "wb"); + fwrite(res.DataPointer(), res.Size(), 1, f); + fclose(f); + } +#endif + m_loc.Load(res); + InitForNewLocation(nLoc,ptTonyStart,start); + bLoaded = true; + break; + } + + if (!bLoaded) + SelectLocation(ptTonyStart,start); + + if (m_bOption) + m_opt.ReInit(m_bigBuf); + + m_bLocationLoaded = true; + + // On Enter per la locazion + return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); +} + +HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) +{ + HANDLE h; + + // Scarica tutta la memoria della locazione + mpalEndIdlePoll(m_nCurLoc); + + // On Exit? + if (bDoOnExit) + { + h=mpalQueryDoAction(1,m_nCurLoc,0); + if (h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + } + + MainFreeze(); + + m_bLocationLoaded = false; + + m_bigBuf.ClearOT(); + m_loc.Unload(); + + return INVALID_HANDLE_VALUE; +} + +void RMGfxEngine::Init(/*HINSTANCE hInst*/) { +/* + //RECUPERARE UNA LOCAZIONE: + + RMRes res(5); + ASSERT(res.IsValid()); + FILE *f; + f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); + fwrite(res,1,5356900,f); + fclose(f); +*/ + + // Schermata di loading + RMResRaw *raw; + RMGfxSourceBuffer16 *load = NULL; + INIT_GFX16_FROMRAW(20038, load); + m_bigBuf.AddPrim(new RMGfxPrimitive(load)); + m_bigBuf.DrawOT(); + m_bigBuf.ClearOT(); + delete load; + _vm->m_wnd.GetNewFrame(*this, NULL); + + + + bPatIrqFreeze = true; + + // GUI attivabile + m_bGUIOption = true; + m_bGUIInterface = true; + m_bGUIInventory = true; + + bSkipSfxNoLoop = false; + m_bMustEnterMenu = false; + bIdleExited = false; + m_bOption = false; + m_bWiping = false; + m_hWipeEvent = CreateEvent(NULL, false, false, NULL); + + // Inizializza la funzione di IRQ di Item per l'MPAL + ItemIrq((uint32)-1, (uint32)this, 0); + mpalInstallItemIrq(ItemIrq); + + // Inizializza DirectInput + m_input.Init(/*hInst*/); + + // Inizializza il puntatore del mouse + m_point.Init(); + + // Inizializza Tony + m_tony.Init(); + m_tony.LinkToBoxes(&_vm->_theBoxes); + + // Inizializza l'inventario e l'interfaccia + m_inv.Init(); + m_inter.Init(); + + // Carica la locazione e setta le priorit @@@@@ + m_bLocationLoaded = false; +/* + m_nCurLoc=1; + RMRes res(m_nCurLoc); + m_loc.Load(res); + m_loc.SetPriority(1); + m_tony.SetPosition(RMPoint(201,316),1); + //m_tony.SetPosition(RMPoint(522,305),2); + //m_tony.SetPosition(RMPoint(158,398),4); + m_tony.SetPattern(m_tony.PAT_STANDDOWN); + m_curAction=TA_GOTO; +*/ + EnableInput(); + + // Inizio del gioco + //m_tony.ExecuteAction(4,1,0); //PREGAME + + m_tony.ExecuteAction(20,1,0); + +// theLog << "Seleziona la locazione\n"; + //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); + //SelectLocation(); + //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); + //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); + //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); + //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); + //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); + //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); + //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); + + // CASTELLO + + //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); +} + +void RMGfxEngine::Close(void) +{ + m_bigBuf.ClearOT(); + + m_inter.Close(); + m_inv.Close(); + m_tony.Close(); + m_point.Close(); + m_input.Close(); +} + +void RMGfxEngine::SwitchFullscreen(bool bFull) +{ + m_input.SwitchFullscreen(bFull); +} + +void RMGfxEngine::GDIControl(bool bCon) +{ + m_input.GDIControl(bCon); +} + +/* +void RMGfxEngine::OptionScreen(void) +{ + if (!m_bOption) + { + if (m_opt.Init(m_bigBuf)) + { + m_bOption = true; + DisableInput(); + EnableMouse(); + } + } + else + { + if (m_opt.Close()) + { + m_bOption = false; + DisableMouse(); + EnableInput(); + } + } +} +*/ + +void RMGfxEngine::EnableInput(void) +{ + m_bInput = true; +} + +void RMGfxEngine::DisableInput(void) +{ + m_bInput = false; + m_inter.Reset(); +} + +void RMGfxEngine::EnableMouse(void) +{ + m_bAlwaysDrawMouse = true; +} + +void RMGfxEngine::DisableMouse(void) +{ + m_bAlwaysDrawMouse = false; +} + +void RMGfxEngine::Freeze(void) +{ + g_system->lockMutex(csMainLoop); +} + +void RMGfxEngine::Unfreeze(void) +{ + g_system->unlockMutex(csMainLoop); +} + +void CharsSaveAll(Common::OutSaveFile *f); +void CharsLoadAll(Common::InSaveFile *f); +void MCharResetCodes(void); +void SaveChangedHotspot(Common::OutSaveFile *f); +void LoadChangedHotspot(Common::InSaveFile *f); +void ReapplyChangedHotspot(void); + +void RestoreMusic(void); +void SaveMusic(Common::OutSaveFile *f); +void LoadMusic(Common::InSaveFile *f); + +unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; + +void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { + Common::OutSaveFile *f; + byte *state, *statecmp; + byte *thumbcmp; + uint thumbsizecmp, thumbsize; + uint size, sizecmp; + int i; + char buf[4]; + RMPoint tp = m_tony.Position(); + + // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario + + // Per ora salviamo solo lo stato MPAL + size=mpalGetSaveStateSize(); + state = new byte[size]; + statecmp = new byte[size*2]; + mpalSaveState(state); + + thumbcmp = new byte[160 * 120 * 4]; + thumbsize = 160 * 120 * 2; + + if (bFastCompress) { + lzo1x_1_compress(state,size,statecmp,&sizecmp,wrkmem); + lzo1x_1_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); + } else { + lzo1x_999_compress(state,size,statecmp,&sizecmp,wrkmem); + lzo1x_999_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); + } + + buf[0] = 'R'; + buf[1] = 'M'; + buf[2] = 'S'; + buf[3] = 0x7; + + f = g_system->getSavefileManager()->openForSaving(fn); + if (f==NULL) return; + f->write(buf, 4); + f->writeUint32LE(thumbsizecmp); + f->write(thumbcmp, thumbsizecmp); + + // Livello di difficolt + i = mpalQueryGlobalVar("VERSIONEFACILE"); + f->writeByte(i); + + i=strlen(name); + f->writeByte(i); + f->write(name, i); + f->writeUint32LE(m_nCurLoc); + f->writeUint32LE(tp.x); + f->writeUint32LE(tp.y); + f->writeUint32LE(size); + f->writeUint32LE(sizecmp); + f->write(statecmp, sizecmp); + delete[] state; + delete[] statecmp; + delete[] thumbcmp; + + // inventario + size = m_inv.GetSaveStateSize(); + state = new byte[size]; + m_inv.SaveState(state); + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // boxes + size = _vm->_theBoxes.GetSaveStateSize(); + state = new byte[size]; + _vm->_theBoxes.SaveState(state); + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // New Ver5 + bool bStat; + + // Salva lo stato della pastorella e del palesati + bStat = m_tony.GetPastorella(); + f->writeByte(bStat); + bStat = m_inter.GetPalesati(); + f->writeByte(bStat); + + // Salva gli mchar + CharsSaveAll(f); + + // Salva le opzioni + f->writeByte(bCfgInvLocked); + f->writeByte(bCfgInvNoScroll); + f->writeByte(bCfgTimerizedText); + f->writeByte(bCfgInvUp); + f->writeByte(bCfgAnni30); + f->writeByte(bCfgAntiAlias); + f->writeByte(bCfgSottotitoli); + f->writeByte(bCfgTransparence); + f->writeByte(bCfgInterTips); + f->writeByte(bCfgDubbing); + f->writeByte(bCfgMusic); + f->writeByte(bCfgSFX); + f->writeByte(nCfgTonySpeed); + f->writeByte(nCfgTextSpeed); + f->writeByte(nCfgDubbingVolume); + f->writeByte(nCfgMusicVolume); + f->writeByte(nCfgSFXVolume); + + // Salva gli hotspot + SaveChangedHotspot(f); + + // Salva la musica + SaveMusic(f); + + f->finalize(); + delete f; +} + +void RMGfxEngine::LoadState(const char *fn) { + // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... + Common::InSaveFile *f; + byte *state, *statecmp; + uint size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; + + f = g_system->getSavefileManager()->openForLoading(fn); + if (f == NULL) return; + f->read(buf, 4); + if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { + delete f; + return; + } + + ver = buf[3]; + + if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { + delete f; + return; + } + + if (ver >= 0x3) { + // C' il thumbnail. Se ver >= 5, compresso + if (ver >= 0x5) { + i = 0; + i = f->readUint32LE(); + f->seek(i); + } else + f->seek(160 * 120 * 2, SEEK_CUR); + } + + if (ver >= 0x5) { + // Skip del livello di difficolt + f->seek(1, SEEK_CUR); + } + + if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno + i = f->readByte(); + f->seek(i, SEEK_CUR); + } + + loc = f->readUint32LE(); + loc = f->readUint32LE(); + tp.x = f->readUint32LE(); + tp.y = f->readUint32LE(); + size = f->readUint32LE(); + + if (ver >= 0x5) { + // Stato MPAL compresso! + sizecmp = f->readUint32LE(); + state = new byte[size]; + statecmp = new byte[sizecmp]; + f->read(statecmp, sizecmp); + lzo1x_decompress(statecmp,sizecmp,state,&size); + delete[] statecmp; + } else { + state = new byte[size]; + f->read(state, size); + } + + mpalLoadState(state); + delete[] state; + + + // inventario + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + m_inv.LoadState(state); + delete[] state; + + if (ver >= 0x2) { // Versione 2: box please + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + _vm->_theBoxes.LoadState(state); + delete[] state; + } + + if (ver >= 5) { + // Versione 5: + bool bStat = false; + + bStat = f->readByte(); + m_tony.SetPastorella(bStat); + bStat = f->readByte(); + m_inter.SetPalesati(bStat); + + CharsLoadAll(f); + } + + if (ver >= 6) { + // Carica le opzioni + bCfgInvLocked = f->readByte(); + bCfgInvNoScroll = f->readByte(); + bCfgTimerizedText = f->readByte(); + bCfgInvUp = f->readByte(); + bCfgAnni30 = f->readByte(); + bCfgAntiAlias = f->readByte(); + bCfgSottotitoli = f->readByte(); + bCfgTransparence = f->readByte(); + bCfgInterTips = f->readByte(); + bCfgDubbing = f->readByte(); + bCfgMusic = f->readByte(); + bCfgSFX = f->readByte(); + nCfgTonySpeed = f->readByte(); + nCfgTextSpeed = f->readByte(); + nCfgDubbingVolume = f->readByte(); + nCfgMusicVolume = f->readByte(); + nCfgSFXVolume = f->readByte(); + + // Carica gli hotspot + LoadChangedHotspot(f); + } + + if (ver >= 7) { + LoadMusic(f); + } + + delete f; + + UnloadLocation(false); + LoadLocation(loc,tp,RMPoint(-1, -1)); + m_tony.SetPattern(RMTony::PAT_STANDRIGHT); + MainUnfreeze(); + + // Le versioni vecchie necessitano di On enter + if (ver < 5) + mpalQueryDoAction(0,loc,0); + else { + // In quelle nuove, ci basta resettare gli mcode + MCharResetCodes(); + } + + if (ver >= 6) + ReapplyChangedHotspot(); + + RestoreMusic(); + + m_bGUIInterface = true; + m_bGUIInventory = true; + m_bGUIOption = true; +} + +void RMGfxEngine::PauseSound(bool bPause) { + if (m_bLocationLoaded) + m_loc.PauseSound(bPause); +} + +void RMGfxEngine::InitWipe(int type) { + m_bWiping = true; + m_nWipeType=type; + m_nWipeStep=0; + + if (m_nWipeType == 1) + m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); + else if (m_nWipeType == 2) + m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); +} + +void RMGfxEngine::CloseWipe(void) { + m_bWiping = false; +} + +void RMGfxEngine::WaitWipeEnd(void) { + WaitForSingleObject(m_hWipeEvent,INFINITE); +} } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e27cb6d9d3..edad3690e9 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -25,6 +25,7 @@ #include "common/config-manager.h" #include "common/file.h" #include "tony/tony.h" +#include "tony/game.h" #include "tony/mpal/mpal.h" namespace Tony { @@ -91,7 +92,33 @@ Common::ErrorCode TonyEngine::Init() { _theBoxes.Init(); // Link to the custom graphics engine - + _theEngine.InitCustomDll(); + + // Inizializza il gfxEngine + _theEngine.Init(); + + // Memoria per il thumbnail + m_curThumbnail = new uint16[160 * 120]; + + // Configurazione di default + bCfgInvLocked = false; + bCfgInvNoScroll = false; + bCfgTimerizedText = true; + bCfgInvUp = false; + bCfgAnni30 = false; + bCfgAntiAlias = false; + bCfgTransparence = true; + bCfgInterTips = true; + bCfgSottotitoli = true; + nCfgTonySpeed = 3; + nCfgTextSpeed = 5; + bCfgDubbing = true; + bCfgMusic = true; + bCfgSFX = true; + nCfgDubbingVolume = 10; + nCfgMusicVolume = 7; + nCfgSFXVolume = 10; + m_bQuitNow = false; return Common::kNoError; } -- cgit v1.2.3 From c831248e652a892fe49f8ab7778ea5f5e1aa1ee8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 1 May 2012 23:44:02 +1000 Subject: TONY: Cleanup of GfxEngine, and added RMTony class methods --- engines/tony/game.cpp | 944 ----------------------- engines/tony/module.mk | 1 + engines/tony/tony.cpp | 94 +++ engines/tony/tony.h | 9 + engines/tony/tonychar.cpp | 1813 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1917 insertions(+), 944 deletions(-) create mode 100644 engines/tony/tonychar.cpp (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index acafbbf7c8..109eefab24 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -235,948 +235,4 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); } - -/****************************************************************************\ -* Metodi di RMGfxEngine -\****************************************************************************/ - -bool bIdleExited; - -void ExitAllIdles(int nCurLoc) { - // Chiude le idle - bSkipSfxNoLoop = true; - mpalEndIdlePoll(nCurLoc); - bIdleExited = true; - bSkipSfxNoLoop = false; - ExitThread(0); -} - - -RMGfxEngine::RMGfxEngine() { - // Crea il big buffer dove verranno disegnati i frame - m_bigBuf.Create(RM_BBX, RM_BBY, 16); - m_bigBuf.OffsetY(RM_SKIPY); -} - -RMGfxEngine::~RMGfxEngine() { - // Chiude il buffer - m_bigBuf.Destroy(); -} - -void RMGfxEngine::OpenOptionScreen(int type) { - bool bRes = false; - - switch (type) { - case 0: - bRes = m_opt.Init(m_bigBuf); - break; - case 1: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); - break; - case 2: - bRes = m_opt.InitNoLoadSave(m_bigBuf); - break; - case 3: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); - break; - case 4: - bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); - break; - } - - if (bRes) { - _vm->PauseSound(true); - - DisableInput(); - m_inv.EndCombine(); - m_curActionObj=0; - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetCustomPointer(NULL); - EnableMouse(); - _vm->GrabThumbnail(); - - // Esce la IDLE onde evitare la morte prematura in caricamento - m_bMustEnterMenu = true; - if (type == 1 || type == 2) { - bIdleExited = true; - } else { - m_tony.StopNoAction(); - - uint32 id; - bIdleExited = false; - CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); - } - } -} - -void RMGfxEngine::DoFrame(bool bDrawLocation) { - g_system->lockMutex(csMainLoop); - - // Poll dei dispositivi di input - m_input.Poll(); - - if (m_bMustEnterMenu && bIdleExited) { - m_bOption = true; - m_bMustEnterMenu = false; - bIdleExited = false; - } - - if (m_bOption) { - m_opt.DoFrame(&m_input); - m_bOption = !m_opt.IsClosing(); - if (!m_bOption) { - DisableMouse(); - EnableInput(); - mpalStartIdlePoll(m_nCurLoc); - _vm->PauseSound(false); - } - } - - if (bDrawLocation && m_bLocationLoaded) { - // Locazione e oggetti - m_loc.DoFrame(&m_bigBuf); - - // Controlla gli input del mouse - if (m_bInput && !m_tony.InAction()) { - // Se siamo sull'inventario, lui che controlla tutti gli input - if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { - // CLICK SINISTRO - // ************** - if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { - // Left click attiva il combine, se siamo su un oggetto - if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { - m_curAction=TA_COMBINE; - m_point.SetAction(m_curAction); - } - } - else - - // CLICK DESTRO - // ************ - if (m_input.MouseRightClicked()) { - if(m_itemName.IsItemSelected()) { - m_curActionObj=0; - m_inv.RightClick(m_input.MousePos()); - } else - m_inv.RightClick(m_input.MousePos()); - } else - - // RILASCIO DESTRO - // *************** - if (m_input.MouseRightReleased()) { - if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - } - } - } else { - // Menu Opzioni - // ************ - if (m_bGUIOption) { - if (!m_tony.InAction() && m_bInput) { - if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { - OpenOptionScreen(0); - goto SKIPCLICKSINISTRO; - } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE) & 0x8001) == 0x8001) - OpenOptionScreen(0); - else if (!_vm->getIsDemo()) { - if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001)==0x8001) - OpenOptionScreen(3); - else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001)==0x8001) - OpenOptionScreen(4); - } - } - } - - // CLICK SINISTRO - // ************** - if (m_input.MouseLeftClicked() && !m_inter.Active()) { - // Se clicko dentro un oggetto, esegui l'azione - //if (m_itemName.IsItemSelected()) - { - if (m_curAction!=TA_COMBINE) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); - else if (m_itemName.GetSelectedItem() != NULL) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); - } - - if (m_curAction==TA_COMBINE) { - m_inv.EndCombine(); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - } - - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - } - -SKIPCLICKSINISTRO: - // CLICK DESTRO - // ************ - if (m_curAction == TA_COMBINE) { - // Durante il combine, lo annulla. - if (m_input.MouseRightClicked()) { - m_inv.EndCombine(); - m_curActionObj = 0; - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - } - } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { - if (m_bGUIInterface) { - // Prima di aprire l'interfaccia, rimette GOTO - m_curAction = TA_GOTO; - m_curActionObj = 0; - m_point.SetAction(m_curAction); - m_inter.Clicked(m_input.MousePos()); - } - } - - - // RILASCIO DESTRO - // *************** - if (m_input.MouseRightReleased()) { - if (m_bGUIInterface) { - if (m_inter.Released(m_input.MousePos(), m_curAction)) { - m_point.SetAction(m_curAction); - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - } - } - } - } - - // Aggiorna il nome sotto il puntatore del mouse - m_itemName.SetMouseCoord(m_input.MousePos()); - if (!m_inter.Active() && !m_inv.MiniActive()) - m_itemName.DoFrame(m_bigBuf, m_loc, m_point, m_inv); - } - - // Inventario & interfaccia - m_inter.DoFrame(m_bigBuf, m_input.MousePos()); - m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); - } - - // Anima Tony - m_tony.DoFrame(&m_bigBuf, m_nCurLoc); - - // Aggiorna lo scrolling per tenere Tony dentro lo schermo - if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { - RMPoint showThis=m_tony.Position(); - showThis.y -= 60; - m_loc.UpdateScrolling(showThis); - } - - if (m_bLocationLoaded) - m_tony.SetScrollPosition(m_loc.ScrollPosition()); - - if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { - m_point.SetCoord(m_input.MousePos()); - m_point.DoFrame(&m_bigBuf); - } - - // ********************** - // Disegna la lista di OT - // ********************** - m_bigBuf.DrawOT(); - -#define FSTEP (480/32) - - // Wipe - if (m_bWiping) - { - switch (m_nWipeType) { - case 1: - if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top>=FSTEP*2)) { - SetEvent(m_hWipeEvent); - m_nWipeType=3; - break; - } - - m_rcWipeEllipse.top+=FSTEP; - m_rcWipeEllipse.left+=FSTEP; - m_rcWipeEllipse.right-=FSTEP; - m_rcWipeEllipse.bottom-=FSTEP; - break; - - case 2: - if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top<480-FSTEP)) { - SetEvent(m_hWipeEvent); - m_nWipeType=3; - break; - } - - m_rcWipeEllipse.top-=FSTEP; - m_rcWipeEllipse.left-=FSTEP; - m_rcWipeEllipse.right+=FSTEP; - m_rcWipeEllipse.bottom+=FSTEP; - break; - } - } - - g_system->unlockMutex(csMainLoop); -} - - -void RMGfxEngine::InitCustomDll(void) { - SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); -} - -void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { - static RMGfxEngine *This = NULL; - RMItem *item; - - // Inizializzazione! - if ((int)dwItem == -1) - { - This=(RMGfxEngine*)nPattern; - return; - } - - if (This->m_bLocationLoaded) { - item = This->m_loc.GetItemFromCode(dwItem); - if (item != NULL) { - if (nPattern != -1) { - if (bPatIrqFreeze) - MainFreeze(); - item->SetPattern(nPattern, true); - if (bPatIrqFreeze) - MainUnfreeze(); - } - if (nStatus!=-1) - item->SetStatus(nStatus); - } - } -} - -/* - // WINBUG: This is a special case for the file open/save dialog, - // which sometimes pumps while it is coming up but before it has - // disabled the main window. - HWND hWndFocus = ::GetFocus(); - bool bEnableParent = false; - m_ofn.hwndOwner = PreModal(); - AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) - { - bEnableParent = true; - ::EnableWindow(m_ofn.hwndOwner, false); - } - - _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); - assert(pThreadState->m_pAlternateWndInit == NULL); - - if (m_ofn.Flags & OFN_EXPLORER) - pThreadState->m_pAlternateWndInit = this; - else - AfxHookWindowCreate(this); - - int nResult; - if (m_bOpenFileDialog) - nResult = ::GetOpenFileName(&m_ofn); - else - nResult = ::GetSaveFileName(&m_ofn); - - if (nResult) - assert(pThreadState->m_pAlternateWndInit == NULL); - pThreadState->m_pAlternateWndInit = NULL; - - // WINBUG: Second part of special case for file open/save dialog. - if (bEnableParent) - ::EnableWindow(m_ofn.hwndOwner, true); - if (::IsWindow(hWndFocus)) - ::SetFocus(hWndFocus); -*/ - - -void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { -#if 0 - OPENFILENAME ofn; - char lpszFileName[512]; - - // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione - - // Sceglie la locazione - ZeroMemory(lpszFileName,512); - ZeroMemory(&ofn,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner=NULL; - ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; - ofn.lpstrCustomFilter=NULL; - ofn.nFilterIndex=1; - ofn.lpstrFile=lpszFileName; - ofn.nMaxFile=512; - ofn.lpstrInitialDir=NULL; - ofn.lpstrTitle="Load Location"; - ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; - - if (!GetOpenFileName(&ofn)) - assert(0); - - // Carica la locazione - m_loc.Load(lpszFileName); - m_bLocationLoaded = true; - m_nCurLoc=m_loc.TEMPGetNumLoc(); - - if (ptTonyStart.x==-1 && ptTonyStart.y==-1) - InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); - else - InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); -#endif -} - -void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { - if (start.x == -1 || start.y == -1) { - start.x = ptTonyStart.x-RM_SX/2; - start.y = ptTonyStart.y-RM_SY/2; - } - - m_loc.SetScrollPosition(start); - - if (ptTonyStart.x==0 && ptTonyStart.y==0) { - } else { - m_tony.SetPosition(ptTonyStart, nLoc); - m_tony.SetScrollPosition(start); - } - - m_curAction=TA_GOTO; - m_point.SetCustomPointer(NULL); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetAction(m_curAction); - m_inter.Reset(); - m_inv.Reset(); - - mpalStartIdlePoll(m_nCurLoc); -} - -HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { - bool bLoaded; - int i; - - m_nCurLoc=nLoc; - - bLoaded = false; - for (i = 0; i < 5; i++) { - // Retry sul loading della locazione - RMRes res(m_nCurLoc); - if (!res.IsValid()) - continue; -#if 0 - // codice per dumpare una locazione in caso serva una modifica - if (nLoc == 106) - { - FILE *f = fopen("loc106.lox", "wb"); - fwrite(res.DataPointer(), res.Size(), 1, f); - fclose(f); - } -#endif - m_loc.Load(res); - InitForNewLocation(nLoc, ptTonyStart, start); - bLoaded = true; - break; - } - - if (!bLoaded) - SelectLocation(ptTonyStart, start); - - if (m_bOption) - m_opt.ReInit(m_bigBuf); - - m_bLocationLoaded = true; - - // On Enter per la locazion - return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0, m_nCurLoc, 0); -} - -HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { - HANDLE h; - - // Scarica tutta la memoria della locazione - mpalEndIdlePoll(m_nCurLoc); - - // On Exit? - if (bDoOnExit) { - h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h, INFINITE); - } - - MainFreeze(); - - m_bLocationLoaded = false; - - m_bigBuf.ClearOT(); - m_loc.Unload(); - - return INVALID_HANDLE_VALUE; -} - -void RMGfxEngine::Init() { - // Screen loading - RMResRaw *raw; - RMGfxSourceBuffer16 *load = NULL; - INIT_GFX16_FROMRAW(20038, load); - m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(); - m_bigBuf.ClearOT(); - delete load; - _vm->m_wnd.GetNewFrame(*this, NULL); - - - - bPatIrqFreeze = true; - - // GUI attivabile - m_bGUIOption = true; - m_bGUIInterface = true; - m_bGUIInventory = true; - - bSkipSfxNoLoop = false; - m_bMustEnterMenu = false; - bIdleExited = false; - m_bOption = false; - m_bWiping = false; - m_hWipeEvent=CreateEvent(NULL, false, false, NULL); - - // Crea l'evento di freeze - g_system->lockMutex(csMainLoop); - - // Inizializza la funzione di IRQ di Item per l'MPAL - ItemIrq((uint32)-1, (uint32)this, 0); - mpalInstallItemIrq(ItemIrq); - - // Inizializza DirectInput - m_input.Init(/*hInst*/); - - // Inizializza il puntatore del mouse - m_point.Init(); - - // Inizializza Tony - m_tony.Init(); - m_tony.LinkToBoxes(&_vm->_theBoxes); - - // Inizializza l'inventario e l'interfaccia - m_inv.Init(); - m_inter.Init(); - - // Carica la locazione e setta le priorit @@@@@ - m_bLocationLoaded = false; -/* - m_nCurLoc=1; - RMRes res(m_nCurLoc); - m_loc.Load(res); - m_loc.SetPriority(1); - m_tony.SetPosition(RMPoint(201,316),1); - //m_tony.SetPosition(RMPoint(522,305),2); - //m_tony.SetPosition(RMPoint(158,398),4); - m_tony.SetPattern(m_tony.PAT_STANDDOWN); - m_curAction=TA_GOTO; -*/ - EnableInput(); - - // Inizio del gioco - //m_tony.ExecuteAction(4,1,0); //PREGAME - - m_tony.ExecuteAction(20,1,0); - -// theLog << "Seleziona la locazione\n"; - //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); - //SelectLocation(); - //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); - //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); - //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); - //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); - //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); - //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); - //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); - - // CASTELLO - - //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); -} - -void RMGfxEngine::Close(void) { - m_bigBuf.ClearOT(); - - m_inter.Close(); - m_inv.Close(); - m_tony.Close(); - m_point.Close(); - m_input.Close(); -} - -void RMGfxEngine::SwitchFullscreen(bool bFull) { - m_input.SwitchFullscreen(bFull); -} - -void RMGfxEngine::GDIControl(bool bCon) -{ - m_input.GDIControl(bCon); -} - -/* -void RMGfxEngine::OptionScreen(void) -{ - if (!m_bOption) - { - if (m_opt.Init(m_bigBuf)) - { - m_bOption = true; - DisableInput(); - EnableMouse(); - } - } - else - { - if (m_opt.Close()) - { - m_bOption = false; - DisableMouse(); - EnableInput(); - } - } -} -*/ - -void RMGfxEngine::EnableInput(void) { - m_bInput = true; -} - -void RMGfxEngine::DisableInput(void) { - m_bInput = false; - m_inter.Reset(); -} - -void RMGfxEngine::EnableMouse(void) { - m_bAlwaysDrawMouse = true; -} - -void RMGfxEngine::DisableMouse(void) { - m_bAlwaysDrawMouse = false; -} - -void RMGfxEngine::Freeze(void) { - g_system->lockMutex(csMainLoop); -} - -void RMGfxEngine::Unfreeze(void) { - g_system->unlockMutex(csMainLoop); -} - -void CharsSaveAll(Common::OutSaveFile *fp); -void CharsLoadAll(Common::InSaveFile *fp); -void MCharResetCodes(void); -void SaveChangedHotspot(Common::OutSaveFile *f); -void LoadChangedHotspot(Common::InSaveFile *f); -void ReapplyChangedHotspot(void); - -void RestoreMusic(void); -void SaveMusic(Common::OutSaveFile *f); -void LoadMusic(Common::InSaveFile *f); - -unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; - -void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { - Common::OutSaveFile *f; - byte *state, *statecmp; - byte *thumbcmp; - uint32 thumbsizecmp, thumbsize; - uint32 size, sizecmp; - int i; - char buf[4]; - RMPoint tp = m_tony.Position(); - - // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario - - // Per ora salviamo solo lo stato MPAL - size = mpalGetSaveStateSize(); - state = new byte[size]; - statecmp = new byte[size*2]; - mpalSaveState(state); - - thumbcmp = new byte[160*120*4]; - thumbsize = 160*120*2; - - if (bFastCompress) { - lzo1x_1_compress(state, size, statecmp, &sizecmp, wrkmem); - lzo1x_1_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); - } else { - lzo1x_999_compress(state, size, statecmp, &sizecmp, wrkmem); - lzo1x_999_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); - } - - buf[0] = 'R'; - buf[1] = 'M'; - buf[2] = 'S'; - buf[3] = 0x7; - - f = g_system->getSavefileManager()->openForSaving(fn); - if (f == NULL) - return; - - f->write(buf, 4); - f->writeUint32LE(thumbsizecmp); - f->write(thumbcmp, thumbsizecmp); - - // Livello di difficolt - i = mpalQueryGlobalVar("VERSIONEFACILE"); - f->writeByte(i); - - i = strlen(name); - f->writeByte(i); - f->write(name, i); - - f->writeUint32LE(m_nCurLoc); - f->writeUint32LE(tp.x); - f->writeUint32LE(tp.y); - f->writeUint32LE(size); - f->writeUint32LE(sizecmp); - - f->write(statecmp, sizecmp); - - delete [] state; - delete [] statecmp; - delete [] thumbcmp; - - // inventario - size = m_inv.GetSaveStateSize(); - state = new byte[size]; - m_inv.SaveState(state); - - f->writeUint32LE(size); - f->write(state, size); - delete[] state; - - // boxes - size = _vm->_theBoxes.GetSaveStateSize(); - state = new byte[size]; - _vm->_theBoxes.SaveState(state); - f->writeUint32LE(size); - f->write(state, size); - delete[] state; - - // New Ver5 - bool bStat; - - // Salva lo stato della pastorella e del palesati - bStat = m_tony.GetPastorella(); - f->writeByte(bStat); - bStat = m_inter.GetPalesati(); - f->writeByte(bStat); - - // Salva gli mchar - CharsSaveAll(f); - - // Salva le opzioni - f->writeByte(bCfgInvLocked); - f->writeByte(bCfgInvNoScroll); - f->writeByte(bCfgTimerizedText); - f->writeByte(bCfgInvUp); - f->writeByte(bCfgAnni30); - f->writeByte(bCfgAntiAlias); - f->writeByte(bCfgSottotitoli); - f->writeByte(bCfgTransparence); - f->writeByte(bCfgInterTips); - f->writeByte(bCfgDubbing); - f->writeByte(bCfgMusic); - f->writeByte(bCfgSFX); - f->writeByte(nCfgTonySpeed); - f->writeByte(nCfgTextSpeed); - f->writeByte(nCfgDubbingVolume); - f->writeByte(nCfgMusicVolume); - f->writeByte(nCfgSFXVolume); - - // Salva gli hotspot - SaveChangedHotspot(f); - - // Salva la musica - SaveMusic(f); - - f->finalize(); - delete f; -} - -void RMGfxEngine::LoadState(const char *fn) { - // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... - Common::InSaveFile *f; - byte *state, *statecmp; - uint32 size, sizecmp; - char buf[4]; - RMPoint tp; - int loc; - int ver; - int i; - - f = g_system->getSavefileManager()->openForLoading(fn); - if (f == NULL) - return; - - f->read(buf, 4); - if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { - delete f; - return; - } - - ver = buf[3]; - - if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { - delete f; - return; - } - - if (ver >= 0x3) { - // C' il thumbnail. Se ver >= 5, compresso - if (ver >= 0x5) { - i = 0; - i = f->readUint32LE(); - f->seek(i, SEEK_CUR); - } else - f->seek(160 * 120 * 2, SEEK_CUR); - } - - if (ver >= 0x5) { - // Skip del livello di difficolt - f->seek(1, SEEK_CUR); - } - - if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno - i = f->readByte(); - f->seek(i, SEEK_CUR); - } - - loc = f->readUint32LE(); - tp.x = f->readUint32LE(); - tp.y = f->readUint32LE(); - size = f->readUint32LE(); - - if (ver >= 0x5) { - // Stato MPAL compresso! - sizecmp = f->readUint32LE(); - state = new byte[size]; - statecmp = new byte[sizecmp]; - f->read(statecmp, sizecmp); - lzo1x_decompress(statecmp, sizecmp, state, &size); - - delete[] statecmp; - } else { - state = new byte[size]; - f->read(state, size); - } - - mpalLoadState(state); - delete[] state; - - - // inventario - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - - m_inv.LoadState(state); - delete[] state; - - if (ver >= 0x2) { // Versione 2: box please - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - _vm->_theBoxes.LoadState(state); - delete[] state; - } - - if (ver >= 5) { - // Versione 5: - bool bStat = false; - - bStat = f->readByte(); - m_tony.SetPastorella(bStat); - bStat = f->readByte(); - m_inter.SetPalesati(bStat); - - CharsLoadAll(f); - } - - if (ver >= 6) { - // Carica le opzioni - bCfgInvLocked = f->readByte(); - bCfgInvNoScroll = f->readByte(); - bCfgTimerizedText = f->readByte(); - bCfgInvUp = f->readByte(); - bCfgAnni30 = f->readByte(); - bCfgAntiAlias = f->readByte(); - bCfgSottotitoli = f->readByte(); - bCfgTransparence = f->readByte(); - bCfgInterTips = f->readByte(); - bCfgDubbing = f->readByte(); - bCfgMusic = f->readByte(); - bCfgSFX = f->readByte(); - nCfgTonySpeed = f->readByte(); - nCfgTextSpeed = f->readByte(); - nCfgDubbingVolume = f->readByte(); - nCfgMusicVolume = f->readByte(); - nCfgSFXVolume = f->readByte(); - - // Carica gli hotspot - LoadChangedHotspot(f); - } - - if (ver >= 7) { - LoadMusic(f); - } - - delete f; - - UnloadLocation(false); - LoadLocation(loc, tp, RMPoint(-1, -1)); - m_tony.SetPattern(RMTony::PAT_STANDRIGHT); - MainUnfreeze(); - - // Le versioni vecchie necessitano di On enter - if (ver < 5) - mpalQueryDoAction(0, loc, 0); - else { - // In quelle nuove, ci basta resettare gli mcode - MCharResetCodes(); - } - - if (ver >= 6) - ReapplyChangedHotspot(); - - RestoreMusic(); - - m_bGUIInterface = true; - m_bGUIInventory = true; - m_bGUIOption = true; -} - -void RMGfxEngine::PauseSound(bool bPause) { - if (m_bLocationLoaded) - m_loc.PauseSound(bPause); -} - -void RMGfxEngine::InitWipe(int type) { - m_bWiping = true; - m_nWipeType=type; - m_nWipeStep=0; - - if (m_nWipeType==1) - m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); - else if (m_nWipeType == 2) - m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); -} - -void RMGfxEngine::CloseWipe(void) { - m_bWiping = false; -} - -void RMGfxEngine::WaitWipeEnd(void) { - WaitForSingleObject(m_hWipeEvent, INFINITE); -} - } // End of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 7c2c7928a8..cbd44d467e 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -10,6 +10,7 @@ MODULE_OBJS := \ loc.o \ sound.o \ tony.o \ + tonychar.o \ utils.o \ mpal/expr.o \ mpal/loadmpc.o \ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index edad3690e9..ea555972d0 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -251,4 +251,98 @@ void TonyEngine::GrabThumbnail(void) { warning("TODO: TonyEngine::GrabThumbnail"); } +void TonyEngine::Play(void) { + warning("TODO TonyEngine::Play"); + +#if 0 + MSG msg; + + do { + // Se siamo in pausa, entra nel loop appropriato + if (m_bPaused) + PauseLoop(); + + // Redraw del graphic engine + theEngine.DoFrame(m_bDrawLocation); + + // Avverte che finito un frame + PulseEvent(m_hEndOfFrame); + + // Passa il buffer dall'engine alla finestra + if (!m_bPaused) { + if (!theEngine.m_bWiping) + m_wnd.GetNewFrame(theEngine, NULL); + else + m_wnd.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); + } + + // Loop minchia dei messaggi + if (PeekMessage(&msg, m_wnd, 0, 0, true)) { + if (!TranslateAccelerator(m_wnd, m_hacc, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } while (msg.message != WM_QUIT && !m_bQuitNow); +#endif +} + + + +void TonyEngine::Close(void) { + CloseMusic(); + CloseHandle(m_hEndOfFrame); + _theBoxes.Close(); + _theEngine.Close(); + m_wnd.Close(); +} + +void TonyEngine::SwitchFullscreen(bool bFull) { + m_wnd.SwitchFullscreen(bFull); + _theEngine.SwitchFullscreen(bFull); +} + +void TonyEngine::GDIControl(bool bCon) { + _theEngine.GDIControl(bCon); +} + + +void TonyEngine::PauseLoop(void) { + warning("TODO: TonyEngine::PauseLoop"); + +#if 0 + MSG msg; + int st,et; + + st = timeGetTime(); + + while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + et = timeGetTime(); + + m_startTime += et - st; +#endif +} + +void TonyEngine::Pause(bool bPause) { + // Se non e' cambiato lo stato di pausing, non fare nulla + if (m_bPaused == bPause) + return; + +warning("TODO: TonyEninge::Pause"); +/* + m_bPaused = bPause; + theEngine.GDIControl(m_bPaused); + + if (m_bPaused) { + SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths - PAUSED"); + } else { + SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths"); + } +*/ +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f3b840faf5..dd7e558820 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -126,6 +126,15 @@ public: RMGfxEngine *GetEngine() { return &_theEngine; } void GUIError(const Common::String &msg); + // Avverte che siamo guidati dal GDI + void GDIControl(bool bCon); + + // Loop che gestisce i messaggi quando siamo in pausa + void PauseLoop(void); + + // Carica un modulo e le sue funzioni custom + void InitCustomDll(LPCUSTOMFUNCTION *FuncList); + void Play(); void Close(); void Abort(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp new file mode 100644 index 0000000000..493f10ef29 --- /dev/null +++ b/engines/tony/tonychar.cpp @@ -0,0 +1,1813 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/mpal/memory.h" +#include "tony/mpal/mpalutils.h" +#include "tony/game.h" +#include "tony/tonychar.h" +#include "tony/tony.h" + +namespace Tony { + +/****************************************************************************\ +* Metodi di RMTony +\****************************************************************************/ + +bool RMTony::m_bAction = false; + +uint32 RMTony::WaitEndOfAction(HANDLE hThread) { + WaitForSingleObject(hThread, INFINITE); + m_bAction = false; + + return 1; +} + +RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { + RMGfxSourceBuffer8RLE *spr; + + assert(m_cm == CM_256); + spr = new RMGfxSourceBuffer8RLEByteAA; + spr->SetAlphaBlendColor(1); + if (bPreRLE) + spr->SetAlreadyCompressed(); + return spr; +} + +void RMTony::Init(void) { + RMRes tony(0); + RMRes body(9999); + RMDataStream ds; + + // Apre il buffer + ds.OpenBuffer(tony); + + // Legge dallo stream l'oggetto corrente (cio Tony) + ReadFromStream(ds, true); // da OGX + + // Chiude il buffer + ds.Close(); + + // Legge il corpo di Tony + ds.OpenBuffer(body); + m_body.ReadFromStream(ds, true); // da OGX + ds.Close(); + m_body.SetPattern(0); + + // Mostra Tony di default + m_bShow=m_bShowOmbra = true; + + // Nessuna azione in attesa + m_bActionPending = false; + m_bAction = false; + + m_bPastorella = false; + m_bIsTalking = false; + m_bIsStaticTalk = false; + + m_nTimeLastStep = _vm->GetTime(); +} + + +void RMTony::Close(void) { + // Disalloca @@@ Manca la disallocazione di un item + m_ombra.Destroy(); +} + +void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { + if (!m_nInList && m_bShow) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + SetSpeed(nCfgTonySpeed); + + // Esegue il movimento normale del personaggio + int time = _vm->GetTime(); + + do { + m_nTimeLastStep += (1000 / 40); + RMCharacter::DoFrame(bigBuf, curLoc); + + } while (time > m_nTimeLastStep + (1000 / 40)); + + // Controlla se siamo alla fine del percorso + if (EndOfPath() && m_bActionPending) { + // Bisogna eseguire l'azione sulla quale abbiamo clickato + m_bActionPending = false; + } + + if (m_bIsTalking || m_bIsStaticTalk) + m_body.DoFrame(bigBuf, false); +} + +void RMTony::Show(void) { + m_bShow = true; + m_bShowOmbra = true; +} + +void RMTony::Hide(bool bShowOmbra) { + m_bShow = false; + m_bShowOmbra = bShowOmbra; +} + + +void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Richiama il Draw() della classe madre se tony visibile + if (m_bShow && bDrawNow) { + if (m_bCorpoDavanti) { + prim->Dst().SetEmpty(); + prim->Dst().Offset(-44, -134); + if (m_bPastorella) + prim->Dst().Offset(1, 4); + RMCharacter::Draw(bigBuf, prim); + } + + if (m_bIsTalking || m_bIsStaticTalk) { + // Offset inverso per lo scrolling + prim->Dst().SetEmpty(); + prim->Dst().Offset(-m_curScroll); + prim->Dst().Offset(m_pos); + prim->Dst().Offset(-44, -134); + prim->Dst() += m_nBodyOffset; + m_body.Draw(bigBuf, prim); + } + + if (!m_bCorpoDavanti) { + prim->Dst().SetEmpty(); + prim->Dst().Offset(-44, -134); + if (m_bPastorella) + prim->Dst().Offset(0, 3); + RMCharacter::Draw(bigBuf, prim); + } + } +} + +void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm) { + // Fa il movimento normale, ma si ricorda se deve poi eseguire un azione + if (item == NULL) { + m_bActionPending = false; + m_ActionItem = NULL; + } else { + m_ActionItem = item; + m_Action = nAction; + m_ActionParm = nActionParm; + m_bActionPending = true; + } + + if (!RMCharacter::Move(dst)) { + m_bActionPending = false; + m_ActionItem = NULL; + } +} + + +void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { + HANDLE hThread; + + if (nAction == TA_COMBINE) { + hThread = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); + + // Se fallito il combine, proviamo con il ReceiveCombine + if (hThread == INVALID_HANDLE_VALUE) { + hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + + // Se fallito il receive, andiamo con quelli generici + // @@@ CombineGive! + if (hThread == INVALID_HANDLE_VALUE) { + hThread = mpalQueryDoAction(TA_COMBINE, nParm, 0); + + if (hThread == INVALID_HANDLE_VALUE){ + hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); + } + } + } + } else { + // Esegue l'azione + hThread = mpalQueryDoAction(nAction, nActionItem, 0); + } + + if (hThread != INVALID_HANDLE_VALUE) { + uint32 id; + m_bAction = true; + CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + hActionThread = hThread; + } else if (nAction != TA_GOTO) { + uint32 id; + + if (nAction == TA_TALK) { + hThread = mpalQueryDoAction(6, 1, 0); + m_bAction = true; + CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread,0,&id); + hActionThread=hThread; + } else if (nAction == TA_PALESATI) { + hThread = mpalQueryDoAction(7, 1, 0); + m_bAction = true; + CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction,(void *)hThread, 0, &id); + hActionThread=hThread; + } else { + hThread = mpalQueryDoAction(5, 1, 0); + m_bAction = true; + CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + hActionThread = hThread; + } + } +} + + +void RMTony::StopNoAction(void) { + if (m_bAction) + WaitForSingleObject(hActionThread, INFINITE); + + m_bActionPending = false; + m_ActionItem = NULL; + Stop(); +} + +void RMTony::Stop(void) { + HANDLE hThread; + + if (m_ActionItem != NULL) { + // Richiama l'MPAL per scegliere la direzione + hThread = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); + + if (hThread==INVALID_HANDLE_VALUE) + RMCharacter::Stop(); + else { + bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() + bMoving = false; + WaitForSingleObject(hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi + } + } else { + RMCharacter::Stop(); + } + + if (!m_bActionPending) + return; + + m_bActionPending = false; + + ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); + + m_ActionItem=NULL; +} + + +int RMTony::GetCurPattern(void) { + int nPatt=RMCharacter::GetCurPattern(); + + if (!m_bPastorella) + return nPatt; + + switch (nPatt) { + case PAT_PAST_STANDUP: + return PAT_STANDUP; + case PAT_PAST_STANDDOWN: + return PAT_STANDDOWN; + case PAT_PAST_STANDLEFT: + return PAT_STANDLEFT; + case PAT_PAST_STANDRIGHT: + return PAT_STANDRIGHT; + + case PAT_PAST_WALKUP: + return PAT_WALKUP; + case PAT_PAST_WALKDOWN: + return PAT_WALKDOWN; + case PAT_PAST_WALKLEFT: + return PAT_WALKLEFT; + case PAT_PAST_WALKRIGHT: + return PAT_WALKRIGHT; + } + + return nPatt; +} + +void RMTony::SetPattern(int nPatt, bool bPlayP0) { + if (m_bPastorella) { + switch (nPatt) { + case PAT_STANDUP: + nPatt=PAT_PAST_STANDUP; + break; + case PAT_STANDDOWN: + nPatt=PAT_PAST_STANDDOWN; + break; + case PAT_STANDLEFT: + nPatt=PAT_PAST_STANDLEFT; + break; + case PAT_STANDRIGHT: + nPatt=PAT_PAST_STANDRIGHT; + break; + case PAT_WALKUP: + nPatt=PAT_PAST_WALKUP; + break; + case PAT_WALKDOWN: + nPatt=PAT_PAST_WALKDOWN; + break; + case PAT_WALKLEFT: + nPatt=PAT_PAST_WALKLEFT; + break; + case PAT_WALKRIGHT: + nPatt=PAT_PAST_WALKRIGHT; + break; + } + } + + RMCharacter::SetPattern(nPatt, bPlayP0); +} + + +void RMTony::Take(int nWhere, int nPart) { + if (nPart == 0) { + switch (GetCurPattern()) { + case PAT_STANDDOWN: + assert(0); // Non esiste il prende mentre sei in StandDown + break; + + case PAT_STANDUP: + switch (nWhere) { + case 0: + SetPattern(PAT_TAKEUP_UP1); + break; + case 1: + SetPattern(PAT_TAKEUP_MID1); + break; + case 2: + SetPattern(PAT_TAKEUP_DOWN1); + break; + } + break; + + case PAT_STANDRIGHT: + switch (nWhere) { + case 0: + SetPattern(PAT_TAKERIGHT_UP1); + break; + case 1: + SetPattern(PAT_TAKERIGHT_MID1); + break; + case 2: + SetPattern(PAT_TAKERIGHT_DOWN1); + break; + } + break; + + + case PAT_STANDLEFT: + switch (nWhere) { + case 0: + SetPattern(PAT_TAKELEFT_UP1); + break; + case 1: + SetPattern(PAT_TAKELEFT_MID1); + break; + case 2: + SetPattern(PAT_TAKELEFT_DOWN1); + break; + } + break; + } + } else if (nPart == 1) { + SetPattern(GetCurPattern()+1); + } else if (nPart == 2) { + switch (GetCurPattern()) { + case PAT_TAKEUP_UP2: + case PAT_TAKEUP_MID2: + case PAT_TAKEUP_DOWN2: + SetPattern(PAT_STANDUP); + break; + + case PAT_TAKELEFT_UP2: + case PAT_TAKELEFT_MID2: + case PAT_TAKELEFT_DOWN2: + SetPattern(PAT_STANDLEFT); + break; + + case PAT_TAKERIGHT_UP2: + case PAT_TAKERIGHT_MID2: + case PAT_TAKERIGHT_DOWN2: + SetPattern(PAT_STANDRIGHT); + break; + } + } +} + + +void RMTony::Put(int nWhere, int nPart) { + if (nPart == 0) { + switch (GetCurPattern()) { + case PAT_STANDDOWN: + //assert(0); // Non esiste il prende mentre sei in StandDown + break; + + case PAT_STANDUP: + switch (nWhere) { + case 0: + SetPattern(PAT_PUTUP_UP1); + break; + case 1: + SetPattern(PAT_PUTUP_MID1); + break; + case 2: + SetPattern(PAT_PUTUP_DOWN1); + break; + } + break; + + case PAT_STANDRIGHT: + switch (nWhere) { + case 0: + SetPattern(PAT_PUTRIGHT_UP1); + break; + case 1: + SetPattern(PAT_PUTRIGHT_MID1); + break; + case 2: + SetPattern(PAT_PUTRIGHT_DOWN1); + break; + } + break; + + + case PAT_STANDLEFT: + switch (nWhere) { + case 0: + SetPattern(PAT_PUTLEFT_UP1); + break; + case 1: + SetPattern(PAT_PUTLEFT_MID1); + break; + case 2: + SetPattern(PAT_PUTLEFT_DOWN1); + break; + } + break; + } + } else if (nPart == 1) { + SetPattern(GetCurPattern()+1); + } else if (nPart == 2) { + switch (GetCurPattern()) { + case PAT_PUTUP_UP2: + case PAT_PUTUP_MID2: + case PAT_PUTUP_DOWN2: + SetPattern(PAT_STANDUP); + break; + + case PAT_PUTLEFT_UP2: + case PAT_PUTLEFT_MID2: + case PAT_PUTLEFT_DOWN2: + SetPattern(PAT_STANDLEFT); + break; + + case PAT_PUTRIGHT_UP2: + case PAT_PUTRIGHT_MID2: + case PAT_PUTRIGHT_DOWN2: + SetPattern(PAT_STANDRIGHT); + break; + } + } +} + + +void RMTony::StartTalk(TALKTYPE nTalkType) { + int headStartPat = 0, bodyStartPat = 0; + int headLoopPat = 0, bodyLoopPat = 0; + + assert(!m_bIsTalking); + + m_bIsTalking = true; + m_nPatB4Talking = GetCurPattern(); + m_nTalkType = nTalkType; + + // Setta la direzione di parlata SOLO se non siamo in una static animation (perch l'ha gi fatto) + if (!m_bIsStaticTalk) { + switch (m_nPatB4Talking) { + case PAT_STANDDOWN: + m_TalkDirection=DOWN; + break; + + case PAT_TAKELEFT_UP2: + case PAT_TAKELEFT_MID2: + case PAT_TAKELEFT_DOWN2: + case PAT_SIRIALZALEFT: + case PAT_STANDLEFT: + m_TalkDirection=LEFT; + break; + + case PAT_TAKERIGHT_UP2: + case PAT_TAKERIGHT_MID2: + case PAT_TAKERIGHT_DOWN2: + case PAT_SIRIALZARIGHT: + case PAT_STANDRIGHT: + m_TalkDirection=RIGHT; + break; + + case PAT_TAKEUP_UP2: + case PAT_TAKEUP_MID2: + case PAT_TAKEUP_DOWN2: + case PAT_STANDUP: + m_TalkDirection=UP; + break; + } + + // Mette davanti il corpo di default + m_bCorpoDavanti = true; + } + + if (m_bPastorella) { + // Da pastorella, c' un solo parlato + MainFreeze(); + switch (m_TalkDirection) { + case UP: + SetPattern(PAT_PAST_TALKUP); + break; + + case DOWN: + SetPattern(PAT_PAST_TALKDOWN); + break; + + case LEFT: + SetPattern(PAT_PAST_TALKLEFT); + break; + + case RIGHT: + SetPattern(PAT_PAST_TALKRIGHT); + break; + } + MainUnfreeze(); + return; + } + + headStartPat = bodyStartPat = 0; + bodyLoopPat = 0; + + switch (nTalkType) { + case TALK_NORMAL: + m_bCorpoDavanti = false; + headStartPat = 0; + bodyStartPat = 0; + + switch (m_TalkDirection) { + case DOWN: + headLoopPat = PAT_TALK_DOWN; + bodyLoopPat = BPAT_STANDDOWN; + m_nBodyOffset.Set(4, 53); + break; + + case LEFT: + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + break; + + case RIGHT: + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + break; + + case UP: + headLoopPat = PAT_TALK_UP; + bodyLoopPat = BPAT_STANDUP; + m_nBodyOffset.Set(6, 53); + break; + } + break; + + case TALK_FIANCHI: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + m_nBodyOffset.Set(2, 42); + headStartPat = PAT_TESTA_UP; + bodyStartPat = BPAT_FIANCHIUP_START; + headLoopPat = PAT_TALK_UP; + bodyLoopPat = BPAT_FIANCHIUP_LOOP; + break; + + case DOWN: + m_nBodyOffset.Set(2, 48); + headStartPat = PAT_TESTA_DOWN; + bodyStartPat = BPAT_FIANCHIDOWN_START; + headLoopPat = PAT_TALK_DOWN; + bodyLoopPat = BPAT_FIANCHIDOWN_LOOP; + break; + + case LEFT: + m_nBodyOffset.Set(-3, 53); + headStartPat = PAT_TESTA_LEFT; + bodyStartPat = BPAT_FIANCHILEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_FIANCHILEFT_LOOP; + break; + + case RIGHT: + m_nBodyOffset.Set(2, 53); + headStartPat = PAT_TESTA_RIGHT; + bodyStartPat = BPAT_FIANCHIRIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_FIANCHIRIGHT_LOOP; + break; + } + break; + + + case TALK_CANTA: + m_nBodyOffset.Set(-10, 25); + headStartPat = PAT_TESTA_LEFT; + bodyStartPat = BPAT_CANTALEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CANTALEFT_LOOP; + break; + + case TALK_RIDE: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + case DOWN: + case LEFT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDELEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_RIDELEFT_LOOP; + bodyLoopPat = BPAT_RIDELEFT; + break; + + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDERIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_RIDERIGHT_LOOP; + bodyLoopPat = BPAT_RIDERIGHT; + break; + } + break; + + case TALK_RIDE2: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + case DOWN: + case LEFT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDELEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_RIDELEFT_LOOP; + break; + + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDERIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_RIDERIGHT_LOOP; + bodyLoopPat = BPAT_RIDERIGHT; + break; + } + break; + + + case TALK_SIINDICA: + switch (m_TalkDirection) { + case UP: + case DOWN: + case LEFT: + m_nBodyOffset.Set(-4, 40); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_SIINDICALEFT; + break; + + case RIGHT: + m_nBodyOffset.Set(5, 40); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_SIINDICARIGHT; + break; + } + break; + + case TALK_SPAVENTATO: + switch (m_TalkDirection) { + case UP: + m_nBodyOffset.Set(-4, -11); + headStartPat = PAT_TESTA_UP; + bodyStartPat = BPAT_SPAVENTOUP_START; + headLoopPat = PAT_TALK_UP; + bodyLoopPat = BPAT_SPAVENTOUP_LOOP; + break; + + case DOWN: + m_nBodyOffset.Set(-5, 45); + headStartPat = PAT_SPAVENTODOWN_START; + bodyStartPat = BPAT_SPAVENTODOWN_START; + headLoopPat = PAT_SPAVENTODOWN_LOOP; + bodyLoopPat = BPAT_SPAVENTODOWN_LOOP; + break; + + case RIGHT: + m_nBodyOffset.Set(-4, 41); + headStartPat = PAT_SPAVENTORIGHT_START; + bodyStartPat = BPAT_SPAVENTORIGHT_START; + headLoopPat = PAT_SPAVENTORIGHT_LOOP; + bodyLoopPat = BPAT_SPAVENTORIGHT_LOOP; + break; + + case LEFT: + m_nBodyOffset.Set(-10, 41); + headStartPat = PAT_SPAVENTOLEFT_START; + bodyStartPat = BPAT_SPAVENTOLEFT_START; + headLoopPat = PAT_SPAVENTOLEFT_LOOP; + bodyLoopPat = BPAT_SPAVENTOLEFT_LOOP; + break; + } + break; + + case TALK_SPAVENTATO2: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + bodyStartPat = BPAT_STANDUP; + bodyLoopPat = BPAT_STANDUP; + m_nBodyOffset.Set(6, 53); + + headStartPat = PAT_TESTA_UP; + headLoopPat = PAT_TALK_UP; + break; + + case DOWN: + bodyStartPat = BPAT_STANDDOWN; + bodyLoopPat = BPAT_STANDDOWN; + m_nBodyOffset.Set(4, 53); + + headStartPat = PAT_SPAVENTODOWN_START; + headLoopPat = PAT_SPAVENTODOWN_LOOP; + break; + + case RIGHT: + bodyStartPat = BPAT_STANDRIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTORIGHT_START; + headLoopPat = PAT_SPAVENTORIGHT_LOOP; + break; + + case LEFT: + bodyStartPat = BPAT_STANDLEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTOLEFT_START; + headLoopPat = PAT_SPAVENTOLEFT_LOOP; + break; + } + break; + + case TALK_CONBICCHIERE: + m_nBodyOffset.Set(4, 53); + headLoopPat = PAT_TALK_DOWN; + bodyLoopPat = BPAT_BICCHIERE; + break; + case TALK_CONVERME: + m_nBodyOffset.Set(9, 56); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_VERME; + break; + case TALK_CONMARTELLO: + m_nBodyOffset.Set(6, 56); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MARTELLO; + break; + case TALK_CONCORDA: + m_nBodyOffset.Set(-3, 38); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CORDA; + break; + case TALK_CONSEGRETARIA: + m_nBodyOffset.Set(-17, 12); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONSEGRETARIA; + break; + + case TALK_CONCONIGLIO: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-21, -5); + bodyStartPat = BPAT_CONCONIGLIOLEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -5); + bodyStartPat = BPAT_CONCONIGLIORIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + break; + } + break; + + case TALK_CONRICETTA: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-61, -7); + bodyStartPat = BPAT_CONRICETTALEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-5, -7); + bodyStartPat = BPAT_CONRICETTARIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + break; + } + break; + + case TALK_CONCARTE: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-34, -2); + bodyStartPat = BPAT_CONCARTELEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -2); + bodyStartPat = BPAT_CONCARTERIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + break; + } + break; + + case TALK_CONPUPAZZO: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-35, 2); + bodyStartPat = BPAT_CONPUPAZZOLEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-14, 2); + bodyStartPat = BPAT_CONPUPAZZORIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + break; + } + break; + + case TALK_CONPUPAZZOSTATIC: + case TALK_CONRICETTASTATIC: + case TALK_CONCONIGLIOSTATIC: + case TALK_CONCARTESTATIC: + case TALK_CONTACCUINOSTATIC: + case TALK_CONMEGAFONOSTATIC: + switch (m_TalkDirection) { + case LEFT: + case UP: + headLoopPat = PAT_TALK_LEFT; + break; + + case DOWN: + case RIGHT: + headLoopPat = PAT_TALK_RIGHT; + break; + } + break; + + // La barba l'unico caso in cui la testa animata a parte + // mentre il corpo quello standard + case TALK_CONBARBASTATIC: + switch (m_TalkDirection) { + case LEFT: + case UP: + headLoopPat = PAT_TALKBARBA_LEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + break; + + case DOWN: + case RIGHT: + headLoopPat = PAT_TALKBARBA_RIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + break; + } + break; + + case TALK_SCHIFATO: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_SCHIFATOLEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_SCHIFATOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_SCHIFATORIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_SCHIFATORIGHT_LOOP; + break; + } + break; + + case TALK_NAAH: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_NAAHLEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_NAAHLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_NAAHRIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_NAAHRIGHT_LOOP; + break; + } + break; + + case TALK_MACBETH1: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH1; + break; + case TALK_MACBETH2: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH2; + break; + case TALK_MACBETH3: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH3; + break; + case TALK_MACBETH4: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH4; + break; + case TALK_MACBETH5: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH5; + break; + case TALK_MACBETH6: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH6; + break; + case TALK_MACBETH7: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH7; + break; + case TALK_MACBETH8: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH8; + break; + case TALK_MACBETH9: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH9; + break; + + case TALK_SPAVENTATOSTATIC: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case DOWN: + bodyStartPat = BPAT_STANDDOWN; + bodyLoopPat = BPAT_STANDDOWN; + m_nBodyOffset.Set(4, 53); + + headStartPat = PAT_SPAVENTODOWN_STAND; + headLoopPat = PAT_SPAVENTODOWN_LOOP; + break; + + case RIGHT: + bodyStartPat = BPAT_STANDRIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTORIGHT_STAND; + headLoopPat = PAT_SPAVENTORIGHT_LOOP; + break; + + case LEFT: + bodyStartPat = BPAT_STANDLEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTOLEFT_STAND; + headLoopPat = PAT_SPAVENTOLEFT_LOOP; + break; + } + break; + } + + // Esegue il set dei pattern vero e proprio + if (headStartPat != 0 || bodyStartPat != 0) { + MainFreeze(); + SetPattern(headStartPat); + m_body.SetPattern(bodyStartPat); + MainUnfreeze(); + + if (bodyStartPat!=0) + m_body.WaitForEndPattern(); + if (headStartPat!=0) + WaitForEndPattern(); + } + + MainFreeze(); + SetPattern(headLoopPat); + if (bodyLoopPat) + m_body.SetPattern(bodyLoopPat); + MainUnfreeze(); +} + + +void RMTony::EndTalk(void) { + int headStandPat = 0; + int headEndPat = 0; + int bodyEndPat = 0; + int finalPat = 0; + bool bStatic = false; + + bodyEndPat = 0; + headEndPat = 0; + + switch (m_TalkDirection) { + case UP: + finalPat = PAT_STANDUP; + headStandPat = PAT_TESTA_UP; + break; + + case DOWN: + finalPat = PAT_STANDDOWN; + headStandPat = PAT_TESTA_DOWN; + break; + + case LEFT: + finalPat = PAT_STANDLEFT; + headStandPat = PAT_TESTA_LEFT; + break; + + case RIGHT: + finalPat = PAT_STANDRIGHT; + headStandPat = PAT_TESTA_RIGHT; + break; + } + + if (m_bPastorella) { + MainFreeze(); + SetPattern(finalPat); + MainUnfreeze(); + m_bIsTalking = false; + return; + } + + + bStatic = false; + switch (m_nTalkType) { + case TALK_NORMAL: + bodyEndPat = 0; + break; + + case TALK_FIANCHI: + switch (m_TalkDirection) { + case UP: + bodyEndPat = BPAT_FIANCHIUP_END; + break; + + case DOWN: + bodyEndPat = BPAT_FIANCHIDOWN_END; + break; + + case LEFT: + bodyEndPat = BPAT_FIANCHILEFT_END; + break; + + case RIGHT: + bodyEndPat = BPAT_FIANCHIRIGHT_END; + break; + } + break; + + case TALK_CANTA: + bodyEndPat = BPAT_CANTALEFT_END; + break; + + case TALK_RIDE: + case TALK_RIDE2: + if (m_TalkDirection==LEFT) + headEndPat = PAT_RIDELEFT_END; + else if (m_TalkDirection==RIGHT) + headEndPat = PAT_RIDERIGHT_END; + + bodyEndPat = 0; + break; + + case TALK_SCHIFATO: + switch (m_TalkDirection) { + case UP: + case LEFT: + headEndPat = PAT_SCHIFATOLEFT_END; + break; + + case DOWN: + case RIGHT: + headEndPat = PAT_SCHIFATORIGHT_END; + break; + } + + bodyEndPat = 0; + break; + + case TALK_NAAH: + switch (m_TalkDirection) { + case UP: + case LEFT: + headEndPat = PAT_NAAHLEFT_END; + break; + + case DOWN: + case RIGHT: + headEndPat = PAT_NAAHRIGHT_END; + break; + } + + bodyEndPat = 0; + break; + + case TALK_SIINDICA: + break; + + case TALK_SPAVENTATO: + switch (m_TalkDirection) { + case UP: + bodyEndPat = BPAT_SPAVENTOUP_END; + break; + + case DOWN: + headEndPat = PAT_SPAVENTODOWN_END; + bodyEndPat = BPAT_SPAVENTODOWN_END; + break; + + case RIGHT: + headEndPat = PAT_SPAVENTORIGHT_END; + bodyEndPat = BPAT_SPAVENTORIGHT_END; + break; + + case LEFT: + headEndPat = PAT_SPAVENTOLEFT_END; + bodyEndPat = BPAT_SPAVENTOLEFT_END; + break; + } + break; + + case TALK_SPAVENTATO2: + switch (m_TalkDirection) { + case UP: + bodyEndPat = 0; + break; + + case DOWN: + headEndPat = PAT_SPAVENTODOWN_END; + bodyEndPat = 0; + break; + + case RIGHT: + headEndPat = PAT_SPAVENTORIGHT_END; + bodyEndPat = 0; + break; + + case LEFT: + headEndPat = PAT_SPAVENTOLEFT_END; + bodyEndPat = 0; + break; + } + break; + + case TALK_CONCONIGLIO: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + break; + } + break; + + case TALK_CONRICETTA: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONRICETTALEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONRICETTARIGHT_END; + break; + } + break; + + case TALK_CONCARTE: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONCARTELEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONCARTERIGHT_END; + break; + } + break; + + case TALK_CONPUPAZZO: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + break; + } + break; + + case TALK_CONVERME: + finalPat = PAT_CONVERME; + break; + case TALK_CONCORDA: + finalPat = PAT_CONCORDA; + break; + case TALK_CONSEGRETARIA: + finalPat = PAT_CONSEGRETARIA; + break; + case TALK_CONMARTELLO: + finalPat = PAT_CONMARTELLO; + break; + case TALK_CONBICCHIERE: + finalPat = PAT_CONBICCHIERE; + break; + + case TALK_MACBETH1: + case TALK_MACBETH2: + case TALK_MACBETH3: + case TALK_MACBETH4: + case TALK_MACBETH5: + case TALK_MACBETH6: + case TALK_MACBETH7: + case TALK_MACBETH8: + finalPat = 0; + break; + + case TALK_SPAVENTATOSTATIC: + switch (m_TalkDirection) { + case DOWN: + headStandPat = PAT_SPAVENTODOWN_STAND; + bodyEndPat = 0; + break; + + case RIGHT: + headStandPat = PAT_SPAVENTORIGHT_STAND; + bodyEndPat = 0; + break; + + case LEFT: + headStandPat = PAT_SPAVENTOLEFT_STAND; + bodyEndPat = 0; + break; + } + break; + } + + // Gestisce la fine di una animazione static lasciando tutto invariato + if (m_bIsStaticTalk) { + if (m_nTalkType == TALK_CONBARBASTATIC) { + MainFreeze(); + SetPattern(0); + if (m_TalkDirection == UP || m_TalkDirection == LEFT) { + m_body.SetPattern(BPAT_CONBARBALEFT_STATIC); + m_nBodyOffset.Set(-41, -14); + } else if (m_TalkDirection == DOWN || m_TalkDirection == RIGHT) { + m_body.SetPattern(BPAT_CONBARBARIGHT_STATIC); + m_nBodyOffset.Set(-26, -14); + } + MainUnfreeze(); + } else { + MainFreeze(); + SetPattern(headStandPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + } + + m_bIsTalking = false; + return; + } + + // Set dei pattern + if (headEndPat != 0 && bodyEndPat != 0) { + MainFreeze(); + SetPattern(headEndPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + + MainFreeze(); + m_body.SetPattern(bodyEndPat); + MainUnfreeze(); + + WaitForEndPattern(); + m_body.WaitForEndPattern(); + } else if (bodyEndPat != 0) { + MainFreeze(); + SetPattern(headStandPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + + MainFreeze(); + m_body.SetPattern(bodyEndPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + } else if (headEndPat != 0) { + m_body.WaitForEndPattern(); + + MainFreeze(); + SetPattern(headEndPat); + MainUnfreeze(); + + WaitForEndPattern(); + } else { + m_body.WaitForEndPattern(); + } + + if (finalPat != 0) { + MainFreeze(); + m_body.SetPattern(0); + SetPattern(finalPat); + MainUnfreeze(); + } + + m_bIsTalking = false; +} + +void RMTony::StartStatic(TALKTYPE nTalk) { + int nPat = 0; + int headPat = 0, headLoopPat = 0; + int bodyStartPat = 0; + int bodyLoopPat = 0; + + nPat = GetCurPattern(); + + headLoopPat = -1; + + switch (nPat) { + case PAT_STANDDOWN: + m_TalkDirection=DOWN; + headPat = PAT_TESTA_RIGHT; + break; + + case PAT_TAKELEFT_UP2: + case PAT_TAKELEFT_MID2: + case PAT_TAKELEFT_DOWN2: + case PAT_SIRIALZALEFT: + case PAT_STANDLEFT: + m_TalkDirection=LEFT; + headPat = PAT_TESTA_LEFT; + break; + + case PAT_TAKERIGHT_UP2: + case PAT_TAKERIGHT_MID2: + case PAT_TAKERIGHT_DOWN2: + case PAT_SIRIALZARIGHT: + case PAT_STANDRIGHT: + m_TalkDirection=RIGHT; + headPat = PAT_TESTA_RIGHT; + break; + + case PAT_TAKEUP_UP2: + case PAT_TAKEUP_MID2: + case PAT_TAKEUP_DOWN2: + case PAT_STANDUP: + m_TalkDirection=UP; + headPat = PAT_TESTA_LEFT; + break; + } + + m_bCorpoDavanti = true; + + switch (nTalk) { + case TALK_CONCONIGLIOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-21, -5); + bodyStartPat = BPAT_CONCONIGLIOLEFT_START; + bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -5); + bodyStartPat = BPAT_CONCONIGLIORIGHT_START; + bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + break; + } + break; + + case TALK_CONCARTESTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-34, -2); + bodyStartPat = BPAT_CONCARTELEFT_START; + bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -2); + bodyStartPat = BPAT_CONCARTERIGHT_START; + bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + break; + } + break; + + case TALK_CONRICETTASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-61, -7); + bodyStartPat = BPAT_CONRICETTALEFT_START; + bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-5, -7); + bodyStartPat = BPAT_CONRICETTARIGHT_START; + bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + break; + } + break; + + case TALK_CONPUPAZZOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-35, 2); + bodyStartPat = BPAT_CONPUPAZZOLEFT_START; + bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-14, 2); + bodyStartPat = BPAT_CONPUPAZZORIGHT_START; + bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + break; + } + break; + + case TALK_CONTACCUINOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-16, -9); + bodyStartPat = BPAT_CONTACCUINOLEFT_START; + bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-6, -9); + bodyStartPat = BPAT_CONTACCUINORIGHT_START; + bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; + break; + } + break; + + case TALK_CONMEGAFONOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-41, -8); + bodyStartPat = BPAT_CONMEGAFONOLEFT_START; + bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-14, -8); + bodyStartPat = BPAT_CONMEGAFONORIGHT_START; + bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; + break; + } + break; + + case TALK_CONBARBASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-41, -14); + bodyStartPat = BPAT_CONBARBALEFT_START; + bodyLoopPat = BPAT_STANDLEFT; + headLoopPat = PAT_TALKBARBA_LEFT; + headPat = 0; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-26, -14); + bodyStartPat = BPAT_CONBARBARIGHT_START; + bodyLoopPat = BPAT_STANDRIGHT; + headLoopPat = PAT_TALKBARBA_RIGHT; + headPat = 0; + break; + } + break; + + case TALK_SPAVENTATOSTATIC: + switch (m_TalkDirection) { + case DOWN: + headPat = PAT_SPAVENTODOWN_START; + bodyLoopPat = BPAT_STANDDOWN; + bodyStartPat = BPAT_STANDDOWN; + headLoopPat = PAT_SPAVENTODOWN_STAND; + m_nBodyOffset.Set(4, 53); + break; + + case LEFT: + headPat = PAT_SPAVENTOLEFT_START; + bodyLoopPat = BPAT_STANDLEFT; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_SPAVENTOLEFT_STAND; + m_nBodyOffset.Set(6, 56); + break; + + case RIGHT: + headPat = PAT_SPAVENTORIGHT_START; + bodyLoopPat = BPAT_STANDRIGHT; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_SPAVENTORIGHT_STAND; + m_nBodyOffset.Set(6, 56); + break; + } + } + + // e vai con i pattern + m_bIsStaticTalk = true; + + MainFreeze(); + SetPattern(headPat); + m_body.SetPattern(bodyStartPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + WaitForEndPattern(); + + MainFreeze(); + if (headLoopPat != -1) + SetPattern(headLoopPat); + m_body.SetPattern(bodyLoopPat); + MainUnfreeze(); +} + + +void RMTony::EndStatic(TALKTYPE nTalk) { + int bodyEndPat = 0; + int finalPat = 0; + int headEndPat = 0; + + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + break; + } + + switch (nTalk) { + case TALK_CONPUPAZZOSTATIC: + switch (m_TalkDirection) { + case UP: case LEFT: + bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + break; + } + break; + + case TALK_CONRICETTASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONRICETTALEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONRICETTARIGHT_END; + break; + } + break; + + case TALK_CONCONIGLIOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + break; + } + break; + + case TALK_CONCARTESTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONCARTELEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONCARTERIGHT_END; + break; + } + break; + + case TALK_CONTACCUINOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONTACCUINOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONTACCUINORIGHT_END; + break; + } + break; + + case TALK_CONMEGAFONOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONMEGAFONOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONMEGAFONORIGHT_END; + break; + } + break; + + case TALK_CONBARBASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONBARBALEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONBARBARIGHT_END; + break; + } + break; + + case TALK_SPAVENTATOSTATIC: + switch (m_TalkDirection) { + case LEFT: + headEndPat = PAT_SPAVENTOLEFT_END; + break; + + case DOWN: + headEndPat = PAT_SPAVENTODOWN_END; + break; + + case RIGHT: + headEndPat = PAT_SPAVENTORIGHT_END; + break; + } + break; + } + + if (headEndPat != 0) { + MainFreeze(); + SetPattern(headEndPat); + MainUnfreeze(); + + WaitForEndPattern(); + } else { + // Play please + MainFreeze(); + m_body.SetPattern(bodyEndPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + } + + MainFreeze(); + SetPattern(finalPat); + m_body.SetPattern(0); + MainUnfreeze(); + + m_bIsStaticTalk = false; +} + +} // End of namespace Tony -- cgit v1.2.3 From bc2b9449869088be4f6c55ff03ccfa9a267a8c6a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 May 2012 00:23:41 +1000 Subject: TONY: Added code from Inventory.cpp --- engines/tony/font.h | 12 +- engines/tony/gfxcore.h | 28 +- engines/tony/inventory.cpp | 943 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/inventory.h | 5 +- engines/tony/module.mk | 1 + engines/tony/utils.cpp | 8 +- engines/tony/utils.h | 8 +- 7 files changed, 976 insertions(+), 29 deletions(-) create mode 100644 engines/tony/inventory.cpp (limited to 'engines') diff --git a/engines/tony/font.h b/engines/tony/font.h index 57a8b1c4fb..a8a9aabb19 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -54,9 +54,12 @@ namespace Tony { +class RMInput; class RMInventory; -class RMLoc; class RMItem; +class RMLoc; +class RMLocation; +class RMPointer; /** * Gestisce un font, in cui ha varie surface per ogni lettera @@ -237,8 +240,7 @@ public: /** * Gestisce il testo di un dialogo */ -class RMTextDialog : public RMText -{ +class RMTextDialog : public RMText { protected: int m_startTime; int m_time; @@ -250,7 +252,7 @@ class RMTextDialog : public RMText bool m_bForceNoTime; HANDLE hCustomSkip; HANDLE hCustomSkip2; - RMInput* m_input; + RMInput *m_input; bool m_bAlwaysDisplay; bool m_bNoTab; @@ -296,7 +298,7 @@ class RMTextDialog : public RMText class RMTextDialogScrolling : public RMTextDialog { protected: - RMLocation* curLoc; + RMLocation *curLoc; RMPoint startScroll; virtual void ClipOnScreen(RMGfxPrimitive* prim); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index f5553d21c6..2e4f9830ed 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -127,37 +127,37 @@ public: m_task = task; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMRect &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); } - RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMRect &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMPoint &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMPoint &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMRect &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMPoint &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; } void SetFlag(byte bFlag) { m_bFlag=bFlag; } void SetTask(RMGfxTask *task) { m_task = task; } - void SetSrc(RMRect &src) { m_src = src; } - void SetSrc(RMPoint &src) { m_src.TopLeft() = src; } - void SetDst(RMRect &dst) { m_dst = dst; } - void SetDst(RMPoint &dst) { m_dst.TopLeft() = dst; } + void SetSrc(const RMRect &src) { m_src = src; } + void SetSrc(const RMPoint &src) { m_src.TopLeft() = src; } + void SetDst(const RMRect &dst) { m_dst = dst; } + void SetDst(const RMPoint &dst) { m_dst.TopLeft() = dst; } void SetStrecth(bool bStretch) { m_bStretch = bStretch; } bool HaveDst() { return !m_dst.IsEmpty(); } @@ -292,7 +292,7 @@ public: virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); int LoadPaletteWA(uint32 resID, bool bSwapped = false); - int LoadPaletteWA(byte *buf, bool bSwapped = false); + int LoadPaletteWA(const byte *buf, bool bSwapped = false); int LoadPalette(uint32 resID); int LoadPalette(byte *buf); }; @@ -365,7 +365,7 @@ public: // Overload of the initialization method virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); @@ -447,8 +447,8 @@ public: void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); // Overloaded initialisation methods - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp new file mode 100644 index 0000000000..2ce88b1cec --- /dev/null +++ b/engines/tony/inventory.cpp @@ -0,0 +1,943 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Inventory.CPP........ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "common/textconsole.h" +#include "tony/mpal/mpalutils.h" +#include "tony/inventory.h" +#include "tony/game.h" +#include "tony/tony.h" + +namespace Tony { + + +/****************************************************************************\ +* RMInventory Methods +\****************************************************************************/ + +RMInventory::RMInventory() { + m_items = NULL; + m_state = CLOSED; + m_bCombining = false; +} + +RMInventory::~RMInventory() { + Close(); +} + +bool RMInventory::CheckPointInside(RMPoint &pt) { + if (!bCfgInvUp) + return pt.y > RM_SY - 70; + else + return pt.y < 70; +} + + + +void RMInventory::Init(void) { + int i,j; + int curres; + + // Crea il buffer principale + Create(RM_SX, 68); + SetPriority(185); + + // Pulisce l'inventario + m_nInv = 0; + m_curPos = 0; + m_bCombining = false; + + // Nuovi oggetti + m_nItems = 78; // @@@ Numero di oggetti prendibili + m_items = new RMInventoryItem[m_nItems+1]; + + curres = 10500; + + // Loop sugli oggetti + for (i = 0; i <= m_nItems; i++) { + // Carica l'oggetto da risorsa + RMRes res(curres); + RMDataStream ds; + + assert(res.IsValid()); + + // Non deve inizializzare il cur pattern dell'oggetto dell'inventario leggendolo da MPAL! + // Glelo mettiamo noi a MANO, e non c'entra nulla con l'oggetto in MPAL + m_items[i].icon.SetInitCurPattern(false); + ds.OpenBuffer(res); + ds >> m_items[i].icon; + ds.Close(); + + // Mette di default a pattern 1 + m_items[i].status=1; + m_items[i].icon.SetPattern(1); + m_items[i].icon.DoFrame(this, false); + + curres++; + if (i == 0 || i == 28 || i == 29) continue; + + m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; + + for (j=0;j> miniInterface; + miniInterface.SetPattern(1); + ds.Close(); + + // Crea il testo per gli hints sulla mini interfaccia + m_hints[0].SetAlignType(RMText::HCENTER,RMText::VTOP); + m_hints[1].SetAlignType(RMText::HCENTER,RMText::VTOP); + m_hints[2].SetAlignType(RMText::HCENTER,RMText::VTOP); + + // Il testo viene preso da MPAL per la traduzione + RMMessage msg1(15); + RMMessage msg2(13); + RMMessage msg3(14); + + m_hints[0].WriteText(msg1[0],1); + m_hints[1].WriteText(msg2[0],1); + m_hints[2].WriteText(msg3[0],1); + +/* + m_hints[0].WriteText("Examine",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); +*/ + + // Prepara il primo inventario + Prepare(); + DrawOT(); + ClearOT(); +} + +void RMInventory::Close(void) { + // Ciao memoria + if (m_items != NULL) { + delete[] m_items; + m_items = NULL; + } + + Destroy(); +} + +void RMInventory::Reset(void) { + m_state = CLOSED; + EndCombine(); +} + +void RMInventory::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_state == OPENING || m_state == CLOSING) + prim->SetDst(RMPoint(0, m_curPutY)); + else + prim->SetDst(RMPoint(0, m_curPutY)); + + g_system->lockMutex(m_csModifyInterface); + RMGfxWoodyBuffer::Draw(bigBuf, prim); + g_system->unlockMutex(m_csModifyInterface); + + if (m_state == SELECTING) { + RMPoint pos; + RMPoint pos2; + + if (!bCfgInvUp) { + pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); + pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + } else { + pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( + pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + } + + RMGfxPrimitive p(prim->m_task, pos); + RMGfxPrimitive p2(prim->m_task, pos2); + + // Disegna l'interfaccina stupida + miniInterface.Draw(bigBuf,&p); + + if (bCfgInterTips) { + if (miniAction == 1) // Esamina + m_hints[0].Draw(bigBuf, &p2); + else if (miniAction == 2) // Parla + m_hints[1].Draw(bigBuf, &p2); + else if (miniAction == 3) // Usa + m_hints[2].Draw(bigBuf, &p2); + } + } +} + +bool RMInventory::RemoveThis(void) { + if (m_state == CLOSED) + return true; + + return false; +} + +void RMInventory::RemoveItem(int code) { + int i; + + for (i=0;ilockMutex(m_csModifyInterface); + + Common::copy_backward(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); +// m_inv[m_nInv-1]=0; + m_nInv--; + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + return; + } + + //MessageBox(NULL,"Specified object is not in the inventory","INTERNAL ERROR",MB_OK|MB_ICONEXCLAMATION); +} + +void RMInventory::AddItem(int code) { + if (code <= 10000 && code >= 10101) + { + // Se siamo qui, vuol dire che stiamo aggiungendo un oggetto che non dovrebbe essere + // nell'inventario + warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); + } else { + g_system->lockMutex(m_csModifyInterface); + if (m_curPos+8 == m_nInv) + { + // Sfondiamo l'inventario! Attivo il pattern di lampeggio + m_items[28].icon.SetPattern(2); + } + + m_inv[m_nInv++]=code-10000; + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } +}; + +void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { + if (code <= 10000 && code >= 10101) { + error("Specified object code is not valid"); + } else { + g_system->lockMutex(m_csModifyInterface); + m_items[code - 10000].icon.SetPattern(dwStatus); + m_items[code - 10000].status = dwStatus; + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } +} + + +void RMInventory::Prepare(void) +{ + int i; + + for (i = 1; i < RM_SX / 64 - 1; i++) { + if (i - 1 + m_curPos < m_nInv) + AddPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); + else + AddPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); + } + + // Frecce + AddPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); + AddPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); + + //AddPrim(new RMGfxPrimitive(&m_items[0].icon,RMPoint(0,0))); +} + +bool RMInventory::MiniActive(void) { + return m_state == SELECTING; +} + +bool RMInventory::HaveFocus(RMPoint mpos) { + // In fase di combine abbiamo il focus solo se siamo su una freccia (per poter scrollare) + if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) + return true; + + // Se l'inventario aperto, abbiamo il focus quando ci andiamo sopra + if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) + return true; + + // Se stiamo selezionando un verbo (quindi tasto destro premuto), abbiamo il focus alltime + if (m_state == SELECTING) + return true; + + return false; +} + +void RMInventory::EndCombine(void) { + m_bCombining = false; +} + +bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { + int n; + + // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo + n=mpos.x / 64; + + if (m_state == OPENED) { + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { + m_bCombining = true; //m_state=COMBINING; + m_nCombine = m_inv[n - 1 + m_curPos]; + nCombineObj = m_nCombine + 10000; + + _vm->PlayUtilSFX(1); + return true; + } + } + + // Click sulla freccia destra + if ((m_state == OPENED) && m_bBlinkingRight) + { + g_system->lockMutex(m_csModifyInterface); + m_curPos++; + + if (m_curPos+8 >= m_nInv) { + m_bBlinkingRight = false; + m_items[28].icon.SetPattern(1); + } + + if (m_curPos > 0) { + m_bBlinkingLeft = true; + m_items[29].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } + // Click sulla freccia sinistra + else if ((m_state == OPENED) && m_bBlinkingLeft) { + assert(m_curPos>0); + g_system->lockMutex(m_csModifyInterface); + m_curPos--; + + if (m_curPos == 0) { + m_bBlinkingLeft = false; + m_items[29].icon.SetPattern(1); + } + + if (m_curPos + 8 < m_nInv) { + m_bBlinkingRight = true; + m_items[28].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } + + + return false; +} + + +void RMInventory::RightClick(RMPoint mpos) { + int n; + + assert(CheckPointInside(mpos)); + + if (m_state == OPENED && !m_bCombining) { + // Apre l'interfaccina contestuale + n = mpos.x / 64; + + if (n > 0 && n < RM_SX / 64-1 && m_inv[n-1+m_curPos]!=0) + { + m_state=SELECTING; + miniAction=0; + m_nSelectObj=n-1; + + _vm->PlayUtilSFX(0); + } + } + + if ((m_state == OPENED) && m_bBlinkingRight) { + g_system->lockMutex(m_csModifyInterface); + m_curPos += 7; + if (m_curPos + 8 > m_nInv) + m_curPos = m_nInv - 8; + + if (m_curPos + 8 <= m_nInv) { + m_bBlinkingRight = false; + m_items[28].icon.SetPattern(1); + } + + if (m_curPos>0) { + m_bBlinkingLeft = true; + m_items[29].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } else if ((m_state == OPENED) && m_bBlinkingLeft) { + assert(m_curPos > 0); + g_system->lockMutex(m_csModifyInterface); + m_curPos -= 7; + if (m_curPos < 0) m_curPos = 0; + + if (m_curPos == 0) { + m_bBlinkingLeft = false; + m_items[29].icon.SetPattern(1); + } + + if (m_curPos + 8 < m_nInv) { + m_bBlinkingRight = true; + m_items[28].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } +} + +bool RMInventory::RightRelease(RMPoint mpos, RMTonyAction& curAction) { + if (m_state == SELECTING) { + m_state = OPENED; + + if (miniAction == 1) { // Esamina + curAction = TA_EXAMINE; + return true; + } else if (miniAction == 2) { // Parla + curAction = TA_TALK; + return true; + } else if (miniAction == 3) { // Usa + curAction = TA_USE; + return true; + } + } + + return false; +} + +#define INVSPEED 20 + +void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { + int i; + bool bNeedRedraw = false; + + if (m_state != CLOSED) { + // Pulisce l'OTList + g_system->lockMutex(m_csModifyInterface); + ClearOT(); + + // Fa il DoFrame di tutti gli oggetti contenuti attualmente nell'inventario + // @@@ forse bisognerebbe farlo di tutti gli oggetti takeable? Probabilmente non serve a nulla + for (i = 0; i < m_nInv; i++) + if (m_items[m_inv[i]].icon.DoFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) + bNeedRedraw = true; + + if ((m_state == CLOSING || m_state == OPENING || m_state == OPENED) && CheckPointInside(mpos)) { + if (mpos.x > RM_SX - 64) { + if (m_curPos + 8 < m_nInv && !m_bBlinkingRight) { + m_items[28].icon.SetPattern(3); + m_bBlinkingRight = true; + bNeedRedraw = true; + } + } else if (m_bBlinkingRight) { + m_items[28].icon.SetPattern(2); + m_bBlinkingRight = false; + bNeedRedraw = true; + } + + if (mpos.x < 64) { + if (m_curPos > 0 && !m_bBlinkingLeft) { + m_items[29].icon.SetPattern(3); + m_bBlinkingLeft = true; + bNeedRedraw = true; + } + } else if (m_bBlinkingLeft) { + m_items[29].icon.SetPattern(2); + m_bBlinkingLeft = false; + bNeedRedraw = true; + } + } + + if (m_items[28].icon.DoFrame(this, false)) + bNeedRedraw = true; + + if (m_items[29].icon.DoFrame(this, false)) + bNeedRedraw = true; + + if (bNeedRedraw) + Prepare(); + + g_system->unlockMutex(m_csModifyInterface); + } + + if ((GetAsyncKeyState(Common::KEYCODE_i) & 0x8001) == 0x8001) { + bCfgInvLocked = !bCfgInvLocked; + } + + if (m_bCombining) {//m_state == COMBINING) + ptr.SetCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); + ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); + } + + if (!bCfgInvUp) { + if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || bCfgInvLocked) && bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = OPENING; + m_curPutY = RM_SY - 1; + m_curPutTime=_vm->GetTime(); + } else { + m_state = OPENED; + m_curPutY = RM_SY - 68; + } + } else if (m_state == OPENED) { + if ((mpos.y < RM_SY - 70 && !bCfgInvLocked) || !bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = CLOSING; + m_curPutY = RM_SY - 68; + m_curPutTime = _vm->GetTime(); + } else { + m_state = CLOSED; + } + } + } else if (m_state == OPENING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY -= 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY <= RM_SY - 68) { + m_state = OPENED; + m_curPutY = RM_SY - 68; + } + + } else if (m_state == CLOSING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY += 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY > 480) + m_state = CLOSED; + } + } else { + if ((m_state == CLOSED) && (mpos.y<10 || bCfgInvLocked) && bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = OPENING; + m_curPutY =- 68; + m_curPutTime = _vm->GetTime(); + } else { + m_state = OPENED; + m_curPutY = 0; + } + } + else if (m_state == OPENED) { + if ((mpos.y>70 && !bCfgInvLocked) || !bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = CLOSING; + m_curPutY = -2; + m_curPutTime = _vm->GetTime(); + } else { + m_state = CLOSED; + } + } + } else if (m_state == OPENING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY += 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY >= 0) { + m_state = OPENED; + m_curPutY = 0; + } + } else if (m_state == CLOSING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY -= 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY < -68) + m_state = CLOSED; + } + } + + if (m_state == SELECTING) { + int startx = (m_nSelectObj + 1) * 64 - 20; + int starty; + + if (!bCfgInvUp) + starty=RM_SY-109; + else + starty=70; + + // Controlla se si trova su uno dei verbi + if (mpos.y > starty && mpos.y < starty + 45) { + if (mpos.x > startx && mpos.x < startx + 40) { + if (miniAction !=1 ) { + miniInterface.SetPattern(2); + miniAction = 1; + _vm->PlayUtilSFX(1); + } + } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { + if (miniAction != 2) { + miniInterface.SetPattern(3); + miniAction = 2; + _vm->PlayUtilSFX(1); + } + } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { + if (miniAction != 3) { + miniInterface.SetPattern(4); + miniAction = 3; + _vm->PlayUtilSFX(1); + } + } else { + miniInterface.SetPattern(1); + miniAction = 0; + } + } else { + miniInterface.SetPattern(1); + miniAction = 0; + } + + // Aggiorna la miniinterface + miniInterface.DoFrame(&bigBuf, false); + } + + if ((m_state!= CLOSED) && !m_nInList) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); + } +} + + +bool RMInventory::ItemInFocus(RMPoint mpt) { + if ((m_state == OPENED || m_state == OPENING) && CheckPointInside(mpt)) + return true; + else + return false; +} + +RMItem *RMInventory::WhichItemIsIn(RMPoint mpt) { + int n; + + if (m_state == OPENED) { + if (CheckPointInside(mpt)) { + n=mpt.x / 64; + if (n>0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) + return &m_items[m_inv[n - 1 + m_curPos]].icon; + } + } + + return NULL; +} + + + +int RMInventory::GetSaveStateSize(void) { + // m_inv pattern m_nInv + return 256*4 + 256*4 + 4 ; +} + +void RMInventory::SaveState(byte *state) { + int i, x; + + WRITE_LE_UINT32(state, m_nInv); state += 4; + Common::copy(m_inv, m_inv + 256, (uint32 *)state); state += 256 * 4; + + for (i = 0; i < 256; i++) { + if (i < m_nItems) + x = m_items[i].status; + else + x = 0; + + WRITE_LE_UINT32(state, x); state += 4; + } +} + +int RMInventory::LoadState(byte *state) { + int i, x; + + m_nInv = READ_LE_UINT32(state); state += 4; + Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); state += 256 * 4; + + for (i = 0; i < 256; i++) { + x = READ_LE_UINT32(state); state += 4; + + if (i < m_nItems) { + m_items[i].status = x; + m_items[i].icon.SetPattern(x); + } + } + + m_curPos = 0; + m_bCombining = false; + + m_items[29].icon.SetPattern(1); + + if (m_nInv > 8) + m_items[28].icon.SetPattern(2); + else + m_items[28].icon.SetPattern(1); + + Prepare(); + DrawOT(); + ClearOT(); + + return GetSaveStateSize(); +} + + +/****************************************************************************\ +* RMInterface methods +\****************************************************************************/ + +RMInterface::~RMInterface() { + +} + +bool RMInterface::Active() { + return m_bActive; +} + +int RMInterface::OnWhichBox(RMPoint pt) { + int max, i; + + pt -= m_openStart; + + // Controlla quanti verbi bisogna considerare + max = 4; if (m_bPalesati) max = 5; + + // Cerca il verbo + for (i = 0; i < max; i++) + if (m_hotbbox[i].PtInRect(pt)) + return i; + + // Nessun verbo trovato + return -1; +} + +void RMInterface::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int h; + + prim->Dst().TopLeft() = m_openStart; + RMGfxSourceBuffer8RLEByte::Draw(bigBuf, prim); + + // Controlla se c'e' da disegnare una zona calda + h = OnWhichBox(m_mpos); + if (h != -1) { + prim->Dst().TopLeft() = m_openStart; + m_hotzone[h].Draw(bigBuf, prim); + + if (m_lastHotZone != h) { + m_lastHotZone = h; + _vm->PlayUtilSFX(1); + } + + if (bCfgInterTips) { + prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); + m_hints[h].Draw(bigBuf,prim); + } + } else + m_lastHotZone = -1; + +} + + +void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { + // Se c' bisogna, schedula nella OT list + if (!m_nInList && m_bActive) + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_mpos = mousepos; +} + +void RMInterface::Clicked(RMPoint mousepos) { + m_bActive = true; + m_openPos = mousepos; + + // Calcola l'angolo in alto a sinistra dell'interfaccia + m_openStart = m_openPos - RMPoint(m_dimx / 2, m_dimy / 2); + m_lastHotZone = -1; + + // La tiene dentro lo schermo + if (m_openStart.x < 0) m_openStart.x = 0; + if (m_openStart.y < 0) m_openStart.y = 0; + if (m_openStart.x+m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; + if (m_openStart.y+m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; + + // Play dell'effetto sonoro + _vm->PlayUtilSFX(0); +} + +bool RMInterface::Released(RMPoint mousepos, RMTonyAction &action) { + if (!m_bActive) + return false; + + m_bActive = false; + + switch (OnWhichBox(mousepos)) { + case 0: + action = TA_TAKE; + break; + + case 1: + action = TA_TALK; + break; + + case 2: + action = TA_USE; + break; + + case 3: + action = TA_EXAMINE; + break; + + case 4: + action = TA_PALESATI; + break; + + default: // Nessun verbo + return false; + } + + return true; +} + +void RMInterface::Reset(void) { + m_bActive = false; +} + +void RMInterface::SetPalesati(bool bOn) { + m_bPalesati=bOn; +} + +bool RMInterface::GetPalesati(void) { + return m_bPalesati; +} + +void RMInterface::Init(void) { + int i; + RMResRaw inter(RES_I_INTERFACE); + RMRes pal(RES_I_INTERPPAL); + + SetPriority(191); + + RMGfxSourceBuffer::Init(inter, inter.Width(), inter.Height()); + LoadPaletteWA(RES_I_INTERPAL); + + for (i = 0; i < 5; i++) { + RMResRaw part(RES_I_INTERP1 + i); + + m_hotzone[i].Init(part, part.Width(), part.Height()); + m_hotzone[i].LoadPaletteWA(pal); + } + + m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi + m_hotbbox[1].SetRect(90, 130, 125, 186); // parla + m_hotbbox[2].SetRect(110, 60, 152, 125); + m_hotbbox[3].SetRect(56, 51, 93, 99); + m_hotbbox[4].SetRect(51, 105, 82, 172); + + m_hints[0].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[1].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[2].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[3].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[4].SetAlignType(RMText::HRIGHT, RMText::VTOP); + + // Il testo viene preso da MPAL per la traduzione + RMMessage msg0(12); + RMMessage msg1(13); + RMMessage msg2(14); + RMMessage msg3(15); + RMMessage msg4(16); + + m_hints[0].WriteText(msg0[0], 1); + m_hints[1].WriteText(msg1[0], 1); + m_hints[2].WriteText(msg2[0], 1); + m_hints[3].WriteText(msg3[0], 1); + m_hints[4].WriteText(msg4[0], 1); +/* + m_hints[0].WriteText("Take",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); + m_hints[3].WriteText("Examine",1); + m_hints[4].WriteText("Palesati",1); +*/ + m_bActive = false; + m_bPalesati = false; +} + +void RMInterface::Close(void) { + int i; + + Destroy(); + + for (i = 0; i < 5; i++) + m_hotzone[i].Destroy(); +} + +} // End of namespace Tony diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 5ec67f6228..3d8650773f 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -51,6 +51,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "tony/font.h" +#include "tony/game.h" #include "tony/gfxcore.h" #include "tony/loc.h" @@ -79,7 +80,7 @@ protected: int m_inv[256]; int m_nInv; int m_curPutY; - int m_curPutTime; + uint32 m_curPutTime; int m_curPos; STATE m_state; @@ -134,7 +135,7 @@ public: // Gestisce il tasto destro del mouse (solo quando c'ha focus) void RightClick(RMPoint mpos); - bool RightRelease(RMPoint mpos, RMTonyAction& curAction); + bool RightRelease(RMPoint mpos, RMTonyAction &curAction); // Avverte che finito il combine void EndCombine(void); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index cbd44d467e..f7d8b1e8c1 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ gfxcore.o \ gfxengine.o \ input.o \ + inventory.o \ loc.o \ sound.o \ tony.o \ diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 360b7a6f32..43a129b92a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -816,19 +816,19 @@ RMPoint RMRect::Center() { return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); } -int RMRect::Width() { +int RMRect::Width() const { return x2 - x1; } -int RMRect::Height() { +int RMRect::Height() const { return y2 - y1; } -int RMRect::Size() { +int RMRect::Size() const { return Width() * Height(); } -bool RMRect::IsEmpty() { +bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 54e4cd0eae..bd4b152f1f 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -232,10 +232,10 @@ public: RMPoint &TopLeft(); RMPoint &BottomRight(); RMPoint Center(); - int Width(); - int Height(); - bool IsEmpty(); - int Size(); + int Width() const; + int Height() const; + bool IsEmpty() const; + int Size() const; // Set void SetRect(int x1, int y1, int x2, int y2); -- cgit v1.2.3 From 4300db9ee4798d43eb2214db87b575ed12640458 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 May 2012 23:35:32 +1000 Subject: TONY: Implemented font.cpp methods --- engines/tony/gfxcore.h | 2 +- engines/tony/module.mk | 1 + engines/tony/mpal/stubs.cpp | 3 +++ engines/tony/mpal/stubs.h | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 2e4f9830ed..b6a10ab778 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -288,7 +288,7 @@ protected: public: virtual ~RMGfxSourceBufferPal(); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); int LoadPaletteWA(uint32 resID, bool bSwapped = false); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index f7d8b1e8c1..690b1f4713 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,6 +3,7 @@ MODULE := engines/tony MODULE_OBJS := \ custom.o \ detection.o \ + font.o \ game.o \ gfxcore.o \ gfxengine.o \ diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index ea93265ec9..9d4a87d61c 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -97,6 +97,9 @@ void SetEvent(HANDLE hEvent) { void ResetEvent(HANDLE hEvent) { } +void PulseEvent(HANDLE hEvent) { +} + uint16 GetAsyncKeyState(Common::KeyCode kc) { return 0; } diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index 9a22b65b7a..5c50b76db1 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -106,6 +106,8 @@ extern void SetEvent(HANDLE hEvent); extern void ResetEvent(HANDLE hEvent); +extern void PulseEvent(HANDLE hEvent); + extern uint16 GetAsyncKeyState(Common::KeyCode kc); } // end of namespace MPAL -- cgit v1.2.3 From 2eb9ebd8aa28fabfc443b85507d3c85b6525684e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 00:49:59 +1000 Subject: TONY: Implemented loc.cpp and font.cpp methods --- engines/tony/font.cpp | 2510 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/loc.cpp | 2071 +++++++++++++++++++++++++++++++++++++++- engines/tony/loc.h | 5 +- engines/tony/utils.h | 50 + 4 files changed, 4622 insertions(+), 14 deletions(-) create mode 100644 engines/tony/font.cpp (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp new file mode 100644 index 0000000000..2996b30f04 --- /dev/null +++ b/engines/tony/font.cpp @@ -0,0 +1,2510 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "common/textconsole.h" +#include "tony/mpal/mpalutils.h" +#include "tony/mpal/stubs.h" +#include "tony/font.h" +#include "tony/input.h" +#include "tony/inventory.h" +#include "tony/loc.h" +#include "tony/tony.h" + +namespace Tony { + +/****************************************************************************\ +* Metodi di RMFont +\****************************************************************************/ + +RMFont::RMFont() { + m_letter = NULL; +} + +RMFont::~RMFont() { + Unload(); +} + +/****************************************************************************\ +* +* Function: void RMFont::Load(byte *buf, int nChars, int dimx, int dimy); +* +* Description: Carica un font da buffer +* +* Input: byte *buf Buffer contenente il font +* int nChars Numero di caratteri (max 256) +* int dimx,dimy Dimensione in pixel di un carattere +* +\****************************************************************************/ + +void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, int charY, byte *pal) { + error("DumpFontBMP not supported in ScummVM"); +} + + +void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { + m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; + +#if 0 + if (nChars == 112 && palResID == RES_F_PAL) + { + // Font parla + DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } + else if (nChars == 102 && palResID == RES_F_PAL) + { + // Font macc + DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } + else if (nChars == 85 && palResID == RES_F_PAL) + { + // Font obj + DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } + else if (nChars == 112 && palResID == RES_F_CPAL) + { + // Font credits + DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } +#endif + + // Carichiamoce 'sto font + for (int i = 0; i < nChars; i++) + { + // Inizializza il buffer con le lettere + m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); + m_letter[i].LoadPaletteWA(palResID); + } + + m_fontDimx = dimx; + m_fontDimy = dimy; + + nLetters=nChars; +} + + +void RMFont::Unload(void) { + if (m_letter != NULL) { + delete[] m_letter; + m_letter = NULL; + } +} + + +RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { + RMFontPrimitive *prim; + int nLett; + + // Converte da carattere a lettera + nLett = ConvertToLetter(bChar); + + // Crea la primitiva per il font + prim = new RMFontPrimitive(this); + prim->m_nChar = nLett; + + // Si fa' dare la lunghezza della lettera in pixel + nLength = LetterLength(bChar); + + return prim; +} + +void RMFont::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { + RMFontPrimitive *prim = (RMFontPrimitive *)prim2; + + // Richiama la Draw della lettera assegnata alla primitiva + if (prim->m_nChar != -1) + m_letter[prim->m_nChar].Draw(bigBuf,prim); +} + +void RMFont::Close(void) { + Unload(); +} + +int RMFont::StringLen(RMString text) { + int len, i; + + len = 0; + for (i = 0; i < text.Length() - 1; i++) + len += LetterLength(text[i], text[i + 1]); + len += LetterLength(text[i]); + + return len; +} + +int RMFont::StringLen(char bChar, char bNext) { + return LetterLength(bChar, bNext); +} + +/****************************************************************************\ +* Metodi di RMFontColor +\****************************************************************************/ + +RMFontColor::RMFontColor() : RMFont() { + m_r = m_g = m_b = 255; +} + +RMFontColor::~RMFontColor() { + +} + +void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { + int r = (int)r1 << 16; + int g = (int)g1 << 16; + int b = (int)b1 << 16; + + int rstep = r / 14; + int gstep = g / 14; + int bstep = b / 14; + + int i; + byte pal[768*3]; + + // Controlla se siamo gia' sul colore giusto + if (m_r == r1 && m_g == g1 && m_b == b1) + return; + + m_r = r1; + m_g = g1; + m_b = b1; + + // Costruisce la nuova palette per il font + for (i = 1; i < 16; i++) { + pal[i * 3 + 0] = r >> 16; + pal[i * 3 + 1] = g >> 16; + pal[i * 3 + 2] = b >> 16; + + r -= rstep; + g -= gstep; + b -= bstep; + } + + pal[15*3 + 0] += 8; + pal[15*3 + 1] += 8; + pal[15*3 + 2] += 8; + + // La mette in tutte le lettere + for (i = 0; i < nLetters; i++) + m_letter[i].LoadPaletteWA(pal); +} + + +/***************************************************************************\ +* Metodi di RMFontParla +\****************************************************************************/ + +void RMFontParla::Init(void) { + int i; + + // bernie: numero di caratteri nel font + int nchars = + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 5; // deutsch + + Load(RES_F_PARL, nchars, 20, 20); + + // Inizializziamo le tabelline del cazzo + lDefault = 13; + hDefault = 18; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + for (i = 0; i < 256; i++) + { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + cTable['A' + i] = i + 0; + + for (i = 0; i < 26; i++) + cTable['a' + i] = i + 26; + + for (i = 0; i < 10; i++) + cTable['0' + i] = i + 52; + + cTable[';'] = 62; + cTable[','] = 63; + cTable['.'] = 64; + cTable[':'] = 65; + cTable['-'] = 66; + cTable['_'] = 67; + cTable['+'] = 68; + cTable['<'] = 69; + cTable['>'] = 70; + cTable['!'] = 71; + //cTable['!'] = 72; Esclamativo alla rovescia + cTable['?'] = 73; + //cTable['?'] = 74; Interrogativo alla rovescia + cTable['('] = 75; + cTable[')'] = 76; + cTable['\"'] = 77; + cTable['^'] = 77; + cTable['/'] = 78; + cTable[''] = 79; + cTable['$'] = 80; + cTable['%'] = 81; + cTable['&'] = 82; + cTable['='] = 83; + cTable[''] = 84; + cTable[''] = 85; + cTable[''] = 86; + cTable[''] = 87; + cTable[''] = 88; + cTable[''] = 89; + cTable[''] = 89; + cTable[''] = 90; + cTable[''] = 91; + cTable[''] = 92; + cTable[''] = 93; + cTable[''] = 94; + cTable[''] = 95; + cTable[''] = 96; + cTable[''] = 97; + cTable[''] = 98; + cTable[''] = 99; + //cTable[' '] = 100; e cerchietto + //cTable[' '] = 101; i cerchietto + //cTable[' '] = 102; o cerchietto + //cTable[' '] = 103; u cerchietto + cTable[''] = 104; + cTable[''] = 105; + cTable[''] = 106; + cTable[''] = 107; + cTable[''] = 108; + cTable[''] = 109; + //cTable[''] = 110; integrale + cTable['\''] = 111; + + // Un po' di lunghezze + lTable[' '] = 9; + lTable['\''] = 5; + lTable['.'] = 5; + lTable[','] = 5; + lTable[':'] = 5; + lTable[';'] = 5; + lTable['!'] = 5; + lTable['?'] = 10; + lTable['\"'] = 5; + lTable['^'] = 5; + lTable['('] = 7; + lTable[')'] = 7; + + lTable['4'] = 10; + + lTable['a'] = 14; + lTable['b'] = 15; + lTable['c'] = 12; + lTable['e'] = 12; + lTable['i'] = 6; + lTable[''] = 6; + lTable['l'] = 5; + lTable['m'] = 16; + lTable['n'] = 12; + lTable['o'] = 11; + lTable['p'] = 11; + lTable['s'] = 12; + lTable['u'] = 12; + + lTable['E'] = 10; + lTable['F'] = 11; + + + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[''] = 112; + cTable[''] = 113; + cTable[''] = 114; + cTable[''] = 115; + cTable[''] = 116; + cTable[''] = 117; + cTable[''] = 118; + cTable[''] = 119; + cTable[''] = 120; + cTable[''] = 121; + cTable[''] = 122; + cTable[''] = 123; + cTable[''] = 124; + cTable[''] = 125; + cTable[''] = 126; + cTable[''] = 127; + cTable[''] = 128; + cTable[''] = 129; + + lTable[''] = 14; + lTable[''] = 16; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 13; + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = 130; + cTable[''] = 131; + cTable[''] = 132; + cTable[''] = 133; + cTable[''] = 134; + cTable[''] = 135; + cTable[''] = 136; + cTable[''] = 137; + cTable[''] = 138; + cTable[''] = 139; + cTable[''] = 140; + cTable[''] = 141; + cTable[''] = 142; + cTable[''] = 143; + cTable[''] = 144; + cTable[''] = 145; + cTable[''] = 146; + cTable[''] = 147; + cTable[''] = 148; + cTable[''] = 149; + cTable[''] = 150; + cTable[''] = 151; + cTable[''] = 152; + cTable[''] = 153; + cTable[''] = 154; + cTable[''] = 155; + cTable[''] = 156; + cTable[''] = 157; + cTable[''] = 158; + cTable[''] = 159; + cTable[''] = 160; + cTable[''] = 161; + cTable[''] = 162; + + cTable[''] = 163; + cTable[''] = 164; + cTable[''] = 165; + cTable[''] = 166; + cTable[''] = 167; + cTable[''] = 168; + cTable[''] = 169; + cTable[''] = 170; + cTable[''] = 171; + cTable[''] = 172; + cTable[''] = 173; + cTable[''] = 174; + cTable[''] = 175; + cTable[''] = 176; + cTable[''] = 177; + cTable[''] = 178; + cTable[''] = 179; + cTable[''] = 180; + cTable[''] = 181; + cTable[''] = 182; + cTable[''] = 183; + cTable[''] = 184; + cTable[''] = 185; + cTable[''] = 186; + cTable[''] = 187; + cTable[''] = 188; + cTable[''] = 189; + cTable[''] = 190; + cTable[''] = 191; + cTable[''] = 192; + cTable[''] = 193; + cTable[''] = 194; + cTable[''] = 195; + + lTable[''] = 13; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 14; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 18; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 17; + lTable[''] = 18; + lTable[''] = 16; + lTable[''] = 18; + lTable[''] = 19; + lTable[''] = 11; + lTable[''] = 16; + lTable[''] = 14; + + lTable[''] = 14; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 14; + lTable[''] = 8; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 16; + lTable[''] = 14; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 9; + lTable[''] = 15; + lTable[''] = 14; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + + cTable[''] = 196; + cTable[''] = 197; + cTable[''] = 198; + cTable[''] = 199; + cTable[''] = 200; + cTable[''] = 201; + cTable[''] = 202; + cTable[''] = 203; + cTable[''] = 204; + cTable[''] = 205; + cTable[''] = 206; + cTable[''] = 207; + cTable[''] = 208; + cTable[''] = 209; + cTable[''] = 210; + + cTable[''] = 211; + cTable[''] = 212; + cTable[''] = 213; + cTable[''] = 214; + cTable[''] = 215; + cTable[''] = 216; + cTable[''] = 217; + cTable[''] = 218; + cTable[''] = 219; + cTable[''] = 220; + cTable[''] = 221; + cTable[''] = 222; + cTable[''] = 223; + cTable[''] = 224; + cTable[''] = 225; + + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 19; + lTable[''] = 10; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 13; + + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 7; + lTable[''] = 12; + lTable[''] = 17; + lTable[''] = 16; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 13; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + cTable[''] = 226; + cTable[''] = 227; + cTable[''] = 228; + cTable[''] = 229; + cTable[''] = 230; + cTable[''] = 231; + cTable[''] = 232; + cTable[''] = 233; + + lTable[''] = 15; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 9; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 234; + // 'SS' = 235 + cTable[''] = 236; + cTable[''] = 237; + cTable[''] = 238; + + lTable[''] = 15; + +#endif // FONT_GERMAN +} + + +/***************************************************************************\ +* Metodi di RMFontMacc +\****************************************************************************/ + +void RMFontMacc::Init(void) { + int i; + + // bernie: numero di caratteri nel font + int nchars = + 102 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // francais + + 5; // deutsch + + + Load(RES_F_MACC, nchars, 11, 16); + + // Default + lDefault = 10; + hDefault = 17; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + + for (i = 0; i < 256; i++) { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + cTable['A'+i] = i + 0; + + for (i = 0; i < 26; i++) + cTable['a'+i] = i + 26; + + for (i = 0; i < 10; i++) + cTable['0'+i] = i + 52; + + cTable['!'] = 62; + //cTable['!'] = 63; // ! rovescia + cTable['\"'] = 64; + cTable['$'] = 65; + cTable['%'] = 66; + cTable['&'] = 67; + cTable['/'] = 68; + cTable['('] = 69; + cTable[')'] = 70; + cTable['='] = 71; + cTable['?'] = 72; + //cTable['?'] = 73; // ? rovescia + cTable['*'] = 74; + cTable['+'] = 75; + cTable[''] = 76; + cTable[';'] = 77; + cTable[','] = 78; + cTable['.'] = 79; + cTable[':'] = 80; + cTable['-'] = 81; + cTable['<'] = 82; + cTable[' > '] = 83; + cTable['/'] = 84; + cTable[''] = 85; + cTable[''] = 86; + cTable[''] = 87; + cTable[''] = 88; + cTable[''] = 89; + cTable[''] = 90; + //cTable[''] = 91; // e col pallino + cTable[''] = 92; + cTable[''] = 93; + //cTable[''] = 94; // i col pallino + cTable[''] = 95; + cTable[''] = 96; + //cTable[''] = 97; // o col pallino + cTable[''] = 98; + cTable[''] = 99; + //cTable[''] = 100; // u col pallino + cTable[''] = 101; + + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[''] = 102; + cTable[''] = 103; + cTable[''] = 104; + cTable[''] = 105; + cTable[''] = 106; + cTable[''] = 107; + cTable[''] = 108; + cTable[''] = 109; + cTable[''] = 110; + cTable[''] = 111; + cTable[''] = 112; + cTable[''] = 113; + cTable[''] = 114; + cTable[''] = 115; + cTable[''] = 116; + cTable[''] = 117; + cTable[''] = 118; + cTable[''] = 119; + + lTable[''] = 14; + lTable[''] = 16; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 13; + + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = 120; + cTable[''] = 121; + cTable[''] = 122; + cTable[''] = 123; + cTable[''] = 124; + cTable[''] = 125; + cTable[''] = 126; + cTable[''] = 127; + cTable[''] = 128; + cTable[''] = 129; + cTable[''] = 130; + cTable[''] = 131; + cTable[''] = 132; + cTable[''] = 133; + cTable[''] = 134; + cTable[''] = 135; + cTable[''] = 136; + cTable[''] = 137; + cTable[''] = 138; + cTable[''] = 139; + cTable[''] = 140; + cTable[''] = 141; + cTable[''] = 142; + cTable[''] = 143; + cTable[''] = 144; + cTable[''] = 145; + cTable[''] = 146; + cTable[''] = 147; + cTable[''] = 148; + cTable[''] = 149; + cTable[''] = 150; + cTable[''] = 151; + cTable[''] = 152; + + cTable[''] = 153; + cTable[''] = 154; + cTable[''] = 155; + cTable[''] = 156; + cTable[''] = 157; + cTable[''] = 158; + cTable[''] = 159; + cTable[''] = 160; + cTable[''] = 161; + cTable[''] = 162; + cTable[''] = 163; + cTable[''] = 164; + cTable[''] = 165; + cTable[''] = 166; + cTable[''] = 167; + cTable[''] = 168; + cTable[''] = 169; + cTable[''] = 170; + cTable[''] = 171; + cTable[''] = 172; + cTable[''] = 173; + cTable[''] = 174; + cTable[''] = 175; + cTable[''] = 176; + cTable[''] = 177; + cTable[''] = 178; + cTable[''] = 179; + cTable[''] = 180; + cTable[''] = 181; + cTable[''] = 182; + cTable[''] = 183; + cTable[''] = 184; + cTable[''] = 185; + + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 8; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + + cTable[''] = 186; + cTable[''] = 187; + cTable[''] = 188; + cTable[''] = 189; + cTable[''] = 190; + cTable[''] = 191; + cTable[''] = 192; + cTable[''] = 193; + cTable[''] = 194; + cTable[''] = 195; + cTable[''] = 196; + cTable[''] = 197; + cTable[''] = 198; + cTable[''] = 199; + cTable[''] = 200; + + cTable[''] = 201; + cTable[''] = 202; + cTable[''] = 203; + cTable[''] = 204; + cTable[''] = 205; + cTable[''] = 206; + cTable[''] = 207; + cTable[''] = 208; + cTable[''] = 209; + cTable[''] = 210; + cTable[''] = 211; + cTable[''] = 212; + cTable[''] = 213; + cTable[''] = 214; + cTable[''] = 215; + + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + + cTable[''] = 226; + cTable[''] = 227; + cTable[''] = 228; + cTable[''] = 229; + cTable[''] = 230; + cTable[''] = 231; + cTable[''] = 232; + cTable[''] = 233; + + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 8; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 234; + // 'SS' = 235 + cTable[''] = 236; + cTable[''] = 237; + cTable[''] = 238; + + lTable[''] = 11; +#endif // FONT_GERMAN +} + +/***************************************************************************\ +* Metodi di RMFontCredits +\****************************************************************************/ + +void RMFontCredits::Init(void) { + int i; + + // bernie: numero di caratteri nel font + int nchars = + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 2; // deutsch + + + Load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); + + // Default + lDefault=10; + hDefault=28; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + + for (i = 0; i < 256; i++) + { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + cTable['A' + i] = i + 0; + + for (i = 0; i < 26; i++) + cTable['a' + i] = i + 26; + + + + cTable[''] = 52; + cTable[''] = 53; +// cTable[''] = 54; // a ^ +// cTable[''] = 55; // a pallini + cTable[''] = 56; + cTable[''] = 57; +// cTable[''] = 58; // e ^ +// cTable[''] = 59; // e pallini + cTable[''] = 60; + cTable[''] = 61; +// cTable[''] = 62; // i ^ +// cTable[''] = 63; // i pallini + cTable[''] = 64; + cTable[''] = 65; +// cTable[''] = 66; // o ^ +// cTable[''] = 67; // o pallini + cTable[''] = 68; + cTable[''] = 69; +// cTable[''] = 70; // u ^ +// cTable[''] = 71; // u pallini +// cTable[''] = 72; // y pallini + cTable[''] = 73; + cTable[''] = 74; +// cTable[''] = 75; // o barrato +// cTable[''] = 76; // ac + cTable[''] = 77; +// cTable[''] = 78; // ? rovesciato + cTable['?'] = 79; +// cTable[''] = 80; // ! rovesciato + cTable['!'] = 81; +// cTable[''] = 82; // 1/2 +// cTable[''] = 83; // 1/4 + cTable['('] = 84; + cTable[')'] = 85; + cTable[''] = 86; + cTable[''] = 87; +// cTable[''] = 88; // AE + cTable[':'] = 89; + cTable['%'] = 90; + cTable['&'] = 91; + cTable['/'] = 92; + cTable['+'] = 93; + cTable[';'] = 94; + cTable[','] = 95; + cTable['^'] = 96; + cTable['='] = 97; + cTable['_'] = 98; + cTable['*'] = 99; + cTable['.'] = 100; + + for (i = 0; i < 10; i++) + cTable['0'+i] = i+101; + cTable['\''] = 111; + + lTable[' '] = 11; + lTable[''] = lTable['A'] = 19; + lTable['B'] = 15; + lTable['C'] = 14; + lTable['D'] = 13; + lTable['E'] = 14; + lTable['F'] = 13; + lTable['G'] = 16; + lTable['H'] = 15; + lTable['I'] = 5; + lTable['J'] = 8; + lTable['K'] = 15; + lTable['L'] = 13; + lTable['M'] = 17; + lTable['N'] = 15; + lTable[''] = lTable['O'] = 14; + lTable['P'] = 12; + lTable['Q'] = 14; + lTable['R'] = 14; + lTable['S'] = 15; + lTable['T'] = 11; + lTable[''] = lTable['U'] = 12; + lTable['V'] = 12; + lTable['W'] = 16; + lTable['X'] = 12; + lTable['Y'] = 13; + lTable['Z'] = 14; + + lTable['a'] = 11; + lTable['b'] = 9; + lTable['c'] = 9; + lTable['d'] = 10; + lTable['e'] = 9; + lTable['f'] = 8; + lTable['g'] = 9; + lTable['h'] = 10; + lTable['i'] = 5; + lTable['j'] = 6; + lTable['k'] = 12; + lTable['l'] = 6; + lTable['m'] = 14; + lTable['n'] = 10; + lTable['o'] = 11; + lTable['p'] = 11; + lTable['q'] = 9; + lTable['r'] = 9; + lTable['s'] = 9; + lTable['t'] = 6; + lTable['u'] = 9; + lTable['v'] = 10; + lTable['w'] = 14; + lTable['x'] = 9; + lTable['y'] = 10; + lTable['z'] = 9; + + lTable['0'] = 12; + lTable['1'] = 8; + lTable['2'] = 10; + lTable['3'] = 11; + lTable['4'] = 12; + lTable['5'] = 11; + lTable['6'] = 12; + lTable['7'] = 10; + lTable['8'] = 11; + lTable['9'] = 10; + + lTable['/'] = 10; + lTable['^'] = 9; + lTable[','] = 5; + lTable['.'] = 5; + lTable[';'] = 5; + lTable[':'] = 5; + lTable['\''] = 5; + + + + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[''] = 112; + cTable[''] = 113; + cTable[''] = 114; + cTable[''] = 115; + cTable[''] = 116; + cTable[''] = 117; + cTable[''] = 118; + cTable[''] = 119; + cTable[''] = 120; + cTable[''] = 121; + cTable[''] = 122; + cTable[''] = 123; + cTable[''] = 124; + cTable[''] = 125; + cTable[''] = 126; + cTable[''] = 127; + cTable[''] = 128; + cTable[''] = 129; + + lTable[''] = 20; + lTable[''] = 12; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 14; + lTable[''] = 11; + lTable[''] = 16; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 10; + + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = 130; + cTable[''] = 131; + cTable[''] = 132; + cTable[''] = 133; + cTable[''] = 134; + cTable[''] = 135; + cTable[''] = 136; + cTable[''] = 137; + cTable[''] = 138; + cTable[''] = 139; + cTable[''] = 140; + cTable[''] = 141; + cTable[''] = 142; + cTable[''] = 143; + cTable[''] = 144; + cTable[''] = 145; + cTable[''] = 146; + cTable[''] = 147; + cTable[''] = 148; + cTable[''] = 149; + cTable[''] = 150; + cTable[''] = 151; + cTable[''] = 152; + cTable[''] = 153; + cTable[''] = 154; + cTable[''] = 155; + cTable[''] = 156; + cTable[''] = 157; + cTable[''] = 158; + cTable[''] = 159; + cTable[''] = 160; + cTable[''] = 161; + cTable[''] = 162; + + cTable[''] = 163; + cTable[''] = 164; + cTable[''] = 165; + cTable[''] = 166; + cTable[''] = 167; + cTable[''] = 168; + cTable[''] = 169; + cTable[''] = 170; + cTable[''] = 171; + cTable[''] = 172; + cTable[''] = 173; + cTable[''] = 174; + cTable[''] = 175; + cTable[''] = 176; + cTable[''] = 177; + cTable[''] = 178; + cTable[''] = 179; + cTable[''] = 180; + cTable[''] = 181; + cTable[''] = 182; + cTable[''] = 183; + cTable[''] = 184; + cTable[''] = 185; + cTable[''] = 186; + cTable[''] = 187; + cTable[''] = 188; + cTable[''] = 189; + cTable[''] = 190; + cTable[''] = 191; + cTable[''] = 192; + cTable[''] = 193; + cTable[''] = 194; + cTable[''] = 195; + + lTable[''] = 20; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 14; + lTable[''] = 22; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 20; + lTable[''] = 12; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 22; + lTable[''] = 18; + lTable[''] = 16; + lTable[''] = 15; + lTable[''] = 14; + lTable[''] = 13; + lTable[''] = 15; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 15; + lTable[''] = 13; + lTable[''] = 16; + lTable[''] = 14; + lTable[''] = 23; + lTable[''] = 23; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 16; + lTable[''] = 12; + lTable[''] = 20; + lTable[''] = 15; + + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 16; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 16; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + + cTable[''] = 196; + cTable[''] = 197; + cTable[''] = 198; + cTable[''] = 199; + cTable[''] = 200; + cTable[''] = 201; + cTable[''] = 202; + cTable[''] = 203; + cTable[''] = 204; + cTable[''] = 205; + cTable[''] = 206; + cTable[''] = 207; + cTable[''] = 208; + cTable[''] = 209; + cTable[''] = 210; + + cTable[''] = 211; + cTable[''] = 212; + cTable[''] = 213; + cTable[''] = 214; + cTable[''] = 215; + cTable[''] = 216; + cTable[''] = 217; + cTable[''] = 218; + cTable[''] = 219; + cTable[''] = 220; + cTable[''] = 221; + cTable[''] = 222; + cTable[''] = 223; + cTable[''] = 224; + cTable[''] = 225; + + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 14; + lTable[''] = 20; + lTable[''] = 7; + lTable[''] = 15; + lTable[''] = 20; + lTable[''] = 19; + lTable[''] = 16; + lTable[''] = 15; + lTable[''] = 13; + lTable[''] = 13; + + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 6; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 12; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + + cTable[''] = 226; + cTable[''] = 227; + cTable[''] = 228; + cTable[''] = 229; + cTable[''] = 230; + cTable[''] = 231; + cTable[''] = 232; + cTable[''] = 233; + + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 6; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 234; + // 'SS' = 235 + + // old chars overrides + cTable[''] = cTable[''] = 55; + cTable[''] = cTable[''] = 67; + cTable[''] = cTable[''] = 71; + + lTable[''] = 11; + +#endif // FONT_GERMAN +} + + + +/***************************************************************************\ +* Metodi di RMFontObj +\****************************************************************************/ + +#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) +#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) + +void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { + l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; + l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; + l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; + l2Table[TOLOWER(nChar)][TOLOWER(nNext)] = spiazz; +} + + +void RMFontObj::Init(void) { + int i; + + //bernie: numero di caratteri nel font (solo maiuscolo) + int nchars = + 85 // base + + 9 // polish + + 33 // russian + + 15 // czech + + 0 // francais (no uppercase chars) + + 1; // deutsch + + + Load(RES_F_OBJ, nchars, 25, 30); + + // Inizializziamo le tabelline del cazzo + lDefault = 26; + hDefault = 30; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + + for (i = 0; i < 256; i++) + { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + { + cTable['A'+i] = i+0; + cTable['a'+i] = i+0; + } + + for (i = 0; i < 10; i++) + cTable['0'+i] = i+26; + + cTable[','] = 36; + cTable[';'] = 37; + cTable['.'] = 38; + cTable[':'] = 39; + cTable['-'] = 40; + cTable['+'] = 41; + cTable['!'] = 42; + // cTable['!'] = 43; Esclamativo alla rovescia + cTable['?'] = 44; + //cTable['?'] = 45; Interrogativo alla rovescia + cTable['/'] = 46; + cTable['('] = 47; + cTable[')'] = 48; + cTable['='] = 49; + cTable['\''] = 50; + cTable['\"'] = 51; + cTable[''] = 52; + cTable['$'] = 53; + cTable['%'] = 54; + cTable['&'] = 55; + cTable['^'] = 56; + cTable['*'] = 57; + cTable['<'] = 58; + cTable[' > '] = 59; + cTable[''] = 60; + cTable[''] = 61; + cTable[''] = 62; + cTable[''] = 63; + //cTable[''] = 64; integrale + cTable[''] = 65; + cTable[''] = 66; + cTable[''] = 67; + cTable[''] = 68; + cTable[''] = 69; + cTable[''] = cTable[''] = 70; + cTable[''] = 71; + cTable[''] = 72; + cTable[''] = 73; + //cTable[' '] = 74; e cerchietto + cTable[''] = 75; + cTable[''] = 76; + //cTable[' '] = 77; i cerchietto + cTable[''] = 78; + cTable[''] = cTable[''] = 79; + //cTable[' '] = 80; o cerchietto + cTable[''] = 81; + cTable[''] = cTable[''] = 82; + //cTable[' '] = 83; u cerchietto + //cTable[' '] = 84; y dieresi + + /* Un po' di lunghezze */ + lTable[' '] = 11; + lTable['.'] = 8; + lTable['-'] = 12; + lTable['\''] = 8; + lTable['0'] = 20; + lTable['1'] = 20; + lTable['2'] = 15; + lTable['3'] = 20; + lTable['4'] = 20; + lTable['5'] = 20; + lTable['6'] = 20; + lTable['7'] = 20; + lTable['8'] = 20; + lTable['9'] = 20; + + + lTable['a'] = lTable['A'] = lTable[''] = lTable[''] = 17; + lTable['b'] = lTable['B'] = 17; + lTable['c'] = lTable['C'] = 19; + lTable['d'] = lTable['D'] = 17; + lTable['e'] = lTable['E'] = 15; + lTable['f'] = lTable['F'] = 17; + lTable['g'] = lTable['G'] = 19; + lTable['i'] = lTable['I'] = 16; + lTable['h'] = lTable['H'] = 17; + lTable['k'] = lTable['K'] = 17; + lTable['l'] = lTable['L'] = 14; + lTable['m'] = lTable['M'] = 19; + lTable['n'] = lTable['N'] = 17; + lTable['o'] = lTable['O'] = lTable[''] = lTable[''] = 19; + lTable['p'] = lTable['P'] = 17; + lTable['q'] = lTable['Q'] = 19; + lTable['r'] = lTable['R'] = 14; + lTable['s'] = lTable['S'] = 13; + lTable['t'] = lTable['T'] = 15; + lTable['u'] = lTable['U'] = lTable[''] = lTable[''] = 15; + lTable['v'] = lTable['V'] = 13; + lTable['x'] = lTable['X'] = 15; + lTable['y'] = lTable['Y'] = 13; + lTable['w'] = lTable['W'] = 19; + lTable['z'] = lTable['Z'] = 20; + lTable[''] = 17; + + /* Casi particolari */ + SetBothCase('C','C',2); + SetBothCase('A','T',-2); + SetBothCase('R','S',2); + SetBothCase('H','I',-2); + SetBothCase('T','S',2); + SetBothCase('O','R',2); + SetBothCase('O','L',2); + SetBothCase('O','G',2); + SetBothCase('Z','A',-1); + SetBothCase('R','R',1); + SetBothCase('R','U',3); + + + // Polish characters + //ス謎戊3剔囀 + //AaCcEeLlNnOoSsZzZz + cTable[''] = cTable[''] = 85; + lTable[''] = lTable[''] = 20; + + cTable[''] = cTable[''] = 86; + lTable[''] = lTable[''] = 22; + + cTable[''] = cTable[''] = 87; + lTable[''] = lTable[''] = 17; + + cTable[''] = cTable[''] = 88; + lTable[''] = lTable[''] = 19; + + cTable[''] = cTable[''] = 89; + lTable[''] = lTable[''] = 17; + + cTable[''] = cTable[''] = 90; + lTable[''] = lTable[''] = 22; + + cTable[''] = cTable[''] = 91; + lTable[''] = lTable[''] = 15; + + cTable[''] = cTable[''] = 92; + lTable[''] = lTable[''] = 21; + + cTable[''] = cTable[''] = 93; + lTable[''] = lTable[''] = 21; + + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = cTable[''] = 85; + lTable[''] = lTable[''] = 20; + + cTable[''] = cTable[''] =94; + cTable[''] = cTable[''] =95; + cTable[''] = cTable[''] =96; + cTable[''] = cTable[''] =97; + cTable[''] = cTable[''] =98; + cTable[''] = cTable[''] =99; + cTable[''] = cTable[''] =100; + cTable[''] = cTable[''] =101; + cTable[''] = cTable[''] =102; + cTable[''] = cTable[''] =103; + cTable[''] = cTable[''] =104; + cTable[''] = cTable[''] =105; + cTable[''] = cTable[''] =106; + cTable[''] = cTable[''] =107; + cTable[''] = cTable[''] =108; + cTable[''] = cTable[''] =109; + cTable[''] = cTable[''] =110; + cTable[''] = cTable[''] =111; + cTable[''] = cTable[''] =112; + cTable[''] = cTable[''] =113; + cTable[''] = cTable[''] =114; + cTable[''] = cTable[''] =115; + cTable[''] = cTable[''] =116; + cTable[''] = cTable[''] =117; + cTable[''] = cTable[''] =118; + cTable[''] = cTable[''] =119; + cTable[''] = cTable[''] =120; + cTable[''] = cTable[''] =121; + cTable[''] = cTable[''] =122; + cTable[''] = cTable[''] =123; + cTable[''] = cTable[''] =124; + cTable[''] = cTable[''] =125; + cTable[''] = cTable[''] =126; + + + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 17; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 20; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 15; + lTable[''] = lTable[''] = 22; + lTable[''] = lTable[''] = 15; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 22; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 21; + lTable[''] = lTable[''] = 20; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 22; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 15; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + // rep. ceca characters + + cTable[''] = cTable[''] = 127; + cTable[''] = cTable[''] = 128; + cTable[''] = cTable[''] = 129; + cTable[''] = cTable[''] = 130; + cTable[''] = cTable[''] = 131; + cTable[''] = cTable[''] = 132; + cTable[''] = cTable[''] = 133; + cTable[''] = cTable[''] = 134; + cTable[''] = cTable[''] = 135; + cTable[''] = cTable[''] = 136; + cTable[''] = cTable[''] = 137; + cTable[''] = cTable[''] = 138; + cTable[''] = cTable[''] = 139; + cTable[''] = cTable[''] = 140; + cTable[''] = cTable[''] = 141; + + lTable[''] = lTable[''] =17; + lTable[''] = lTable[''] =15; + lTable[''] = lTable[''] =22; + lTable[''] = lTable[''] =18; + lTable[''] = lTable[''] =21; + lTable[''] = lTable[''] =16; + lTable[''] = lTable[''] =18; + lTable[''] = lTable[''] =19; + lTable[''] = lTable[''] =17; + lTable[''] = lTable[''] =23; + lTable[''] = lTable[''] =24; + lTable[''] = lTable[''] =17; + lTable[''] = lTable[''] =22; + lTable[''] = lTable[''] =16; + lTable[''] = lTable[''] =16; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + + // traduci le lettere accentate in lettere normali + + cTable[''] = cTable[''] = cTable[''] = 0; // a + lTable[''] = lTable[''] = lTable[''] = 17; + + cTable[''] = cTable[''] = 4; // e + lTable[''] = lTable[''] = 15; + + cTable[''] = cTable[''] = cTable[''] = 8; // i + lTable[''] = lTable[''] = lTable[''] = 16; + + cTable[''] = cTable[''] = cTable[''] = cTable[''] = 14; // o + lTable[''] = lTable[''] = lTable[''] = lTable[''] = 19; + + cTable[''] = cTable[''] = 20; // u + lTable[''] = lTable[''] = 15; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 142; + // SS = 143 + + lTable[''] = 24; +#endif // FONT_GERMAN +} + + +/****************************************************************************\ +* Metodi di RMText +\****************************************************************************/ + +RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; +OSystem::MutexRef RMText::m_cs; +RMGfxClearTask RMText::m_clear; + +RMText::RMText() { + // Colore di default: bianco + m_r = m_g = m_b = 255; + + // Lunghezza di default + maxLineLength = 350; + + m_bTrasp0 = true; + aHorType = HCENTER; + aVerType = VTOP; + SetPriority(150); +} + +RMText::~RMText() { + +} + +void RMText::SetMaxLineLength(int max) { + maxLineLength = max; +} + +bool RMText::RemoveThis() { + // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso + // etc. + return true; +} + + +void RMText::WriteText(RMString text, int nFont, int *time) { + // Inizializza i font (una volta sola) + if (m_fonts[0] == NULL) { + m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); + m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); + m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); + m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); + } + + g_system->lockMutex(m_cs); + WriteText(text,m_fonts[nFont],time); + g_system->unlockMutex(m_cs); +} + + +void RMText::WriteText(RMString text, RMFontColor *font, int *time) { + RMGfxPrimitive *prim; + char *p, *old_p; + int i, j, x, y; + int len; + int numchar; + int width, height; + char *string; + int numlines; + + // Setta il colore di base + font->SetBaseColor(m_r, m_g, m_b); + + // Si autodistrugge il buffer prima di iniziare + Destroy(); + + // Se la stringa vuota, non fare nulla + if (text == NULL || text[0] == '\0') + return; + + // Divide la frase in linee. In questo ciclo, X contiene la lunghezza massima raggiunta da una linea + // e I il numero delle linee + string=p = text; + i = j = x = 0; + while (*p != '\0') { + j += font->StringLen(*p); + if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { + j -= font->StringLen(*p, p[1]); + if (j > x) x = j; + + // Torna indietro al primo spazio utile + // + // BERNIE: nella versione originale le frasi contenenti + // parole che superano la larghezza di una riga causavano + // l'interruzione dell'intera frase. + // Questo workaround e' parziale: la parola troppo lunga + // viene spezzata bruscamente e si perde una lettera. + // Oltre allo spazio e' ammesso il wrap sul carattere '-'. + // + old_p = p; + while (*p != ' ' && *p != '-' && p > string) p--; + + if (p == string) + p = old_p; + + // Controlla se sono tutti spazi fino alla fine + while (*p == ' ' && *p != '\0') p++; + if (*p == '\0') + break; + p--; + i++; + *p = '\0'; + j = 0; + } + p++; + } + + if (j > x) x = j; + + i++; + numlines = i; + + // X=Lunghezza della linea piu' lunga. Controlla se puo' essere puttata a X1 + //x+=font->StringLen(-1)+1; // Meglio esagerare per sicurezza + x += 8; + + // Posizione di partenza per la surface: X1,Y + width = x; + height = (numlines - 1) * font->LetterHeight() + font->m_fontDimy; + + // Crea la surface + Create(width, height); + //AddPrim(new RMGfxPrimitive(&m_clear)); + Common::fill(m_buf, m_buf + width * height * 2, 0); + + p = string; + + y = 0; + numchar = 0; + for (; i > 0; i--) { + // Misura la lunghezza della linea + x = 0; + j = font->StringLen(RMString(p)); + + switch (aHorType) { + case HLEFT: + x = 0; + break; + + case HLEFTPAR: + if (i == numlines) + x=0; + else + x = 25; + break; + + case HCENTER: + x = width / 2 - j / 2; + break; + + case HRIGHT: + x = width - j - 1; + break; + } + + while (*p != '\0') { + if (*p == ' ') { + x += font->StringLen(*p); + p++; + continue; + } + + prim = font->MakeLetterPrimitive(*p, len); + prim->Dst().x1 = x; + prim->Dst().y1 = y; + AddPrim(prim); + + numchar++; + + x += font->StringLen(*p, p[1]); + p++; + } + p++; + y += font->LetterHeight(); + } + + if (time != NULL) + *time = 1000 + numchar * (11 - nCfgTextSpeed) * 14; +} + +void RMText::ClipOnScreen(RMGfxPrimitive *prim) { + // Cerca di non farlo uscire dallo schermo + if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; + if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; + if (prim->Dst().x1+m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; +} + +void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Allinea orizzontalmente + if (aHorType == HCENTER) + prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); + else if (aHorType == HRIGHT) + prim->Dst().TopLeft() -= RMPoint(m_dimx, 0); + + + // Alinea verticalemente + switch (aVerType) { + case VTOP: + break; + + case VCENTER: + prim->Dst().y1-=m_dimy/2; + break; + + case VBOTTOM: + prim->Dst().y1-=m_dimy; + break; + } + + ClipOnScreen(prim); + + RMGfxWoodyBuffer::Draw(bigBuf,prim); +} + +/****************************************************************************\ +* Metodi di RMTextDialog +\****************************************************************************/ + +RMTextDialog::RMTextDialog() : RMText() { + m_startTime = 0; + dst = RMPoint(0,0); + + m_bSkipStatus = true; + m_bShowed = true; + m_bForceTime = false; + m_bForceNoTime = false; + m_bAlwaysDisplay = false; + m_bNoTab = false; + hCustomSkip = INVALID_HANDLE_VALUE; + hCustomSkip2 = INVALID_HANDLE_VALUE; + m_input = NULL; + + // Crea l'evento di fine displaying + hEndDisplay = CreateEvent(NULL, false, false, NULL); +} + +RMTextDialog::~RMTextDialog() { + CloseHandle(hEndDisplay); +} + +void RMTextDialog::Show(void) { + m_bShowed = true; +} + +void RMTextDialog::Hide(void) { + m_bShowed = false; +} + +void RMTextDialog::WriteText(RMString text, int font, int *time) { + RMText::WriteText(text,font,&m_time); + + if (time != NULL) + *time = m_time; +} + +void RMTextDialog::WriteText(RMString text, RMFontColor *font, int *time) { + RMText::WriteText(text,font,&m_time); + + if (time != NULL) + *time = m_time; +} + + +void RMTextDialog::SetSkipStatus(bool bEnabled) { + m_bSkipStatus=bEnabled; +} + +void RMTextDialog::ForceTime(void) { + m_bForceTime = true; +} + +void RMTextDialog::ForceNoTime(void) { + m_bForceNoTime = true; +} + +void RMTextDialog::SetNoTab(void) { + m_bNoTab = true; +} + +void RMTextDialog::SetForcedTime(uint32 dwTime) { + m_time = dwTime; +} + +void RMTextDialog::SetAlwaysDisplay(void) { + m_bAlwaysDisplay = true; +} + +bool RMTextDialog::RemoveThis(void) { + // Frase NON di background + if (m_bSkipStatus) { + if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (bCfgTimerizedText) { + if (!m_bForceNoTime) + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return true; + } + + if (!m_bNoTab) + if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + return true; + + if (!m_bNoTab) + if (m_input) + if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) + return true; + } + // Frase di background + else { + if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (!m_bForceNoTime) + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return true; + } + + // Se il tempo forzato + if (m_bForceTime) + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return true; + + if (hCustomSkip != INVALID_HANDLE_VALUE) + if (WaitForSingleObject(hCustomSkip, 0) == WAIT_OBJECT_0) + return true; + + if (bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE) + if (WaitForSingleObject(hCustomSkip2,0) == WAIT_OBJECT_0) + return true; + + return false; +} + +void RMTextDialog::Unregister(void) { + RMGfxTask::Unregister(); + assert(m_nInList == 0); + SetEvent(hEndDisplay); +} + +void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_startTime == 0) + m_startTime = _vm->GetTime(); + + if (m_bShowed) { + if (bCfgSottotitoli || m_bAlwaysDisplay) { + prim->Dst().TopLeft() = dst; + RMText::Draw(bigBuf, prim); + } + } +} + +void RMTextDialog::SetCustomSkipHandle(HANDLE hCustom) { + hCustomSkip = hCustom; +} + +void RMTextDialog::SetCustomSkipHandle2(HANDLE hCustom) { + hCustomSkip2 = hCustom; +} + +void RMTextDialog::WaitForEndDisplay(void) { + WaitForSingleObject(hEndDisplay, INFINITE); +} + +void RMTextDialog::SetInput(RMInput *input) { + m_input = input; +} + +/****************************************************************************\ +* Metodi di RMTextDialogScrolling +\****************************************************************************/ + +RMTextDialogScrolling::RMTextDialogScrolling() { + curLoc = NULL; +} + +RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { + curLoc = loc; + startScroll = loc->ScrollPosition(); +} + +RMTextDialogScrolling::~RMTextDialogScrolling() { +} + +void RMTextDialogScrolling::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMPoint curDst; + + curDst = dst; + + if (curLoc != NULL) + dst -= curLoc->ScrollPosition() - startScroll; + + RMTextDialog::Draw(bigBuf, prim); + + dst = curDst; +} + +void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { + // Non dobbiamo fare nulla! +} + + +/****************************************************************************\ +* Metodi di RMTextItemName +\****************************************************************************/ + +RMTextItemName::RMTextItemName() : RMText() { + m_item = NULL; + SetPriority(220); +} + +RMTextItemName::~RMTextItemName() { + +} + +void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { + RMString itemName; + RMItem *lastItem = m_item; + + // Si aggiunge alla lista se c'e' bisogno + if (!m_nInList) + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + // Aggiorna le coordinate di scrolling + m_curscroll = loc.ScrollPosition(); + + // Controlla se siamo sopra l'inventario + if (inv.ItemInFocus(m_mpos)) + m_item = inv.WhichItemIsIn(m_mpos); + else + m_item = loc.WhichItemIsIn(m_mpos); + + itemName = ""; + + // Si fa dare il nuovo nome + if (m_item != NULL) + m_item->GetName(itemName); + + // Se lo scrive + WriteText(itemName, 1); + + // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer + if (lastItem != m_item) + { + if (m_item == NULL) + ptr.SetSpecialPointer(RMPointer::PTR_NONE); + else { + HANDLE hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); + if (hThread == INVALID_HANDLE_VALUE) + ptr.SetSpecialPointer(RMPointer::PTR_NONE); + else + WaitForSingleObject(hThread,INFINITE); + } + } +} + + +void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Se non c'e' testo, e' inutile continuare + if (m_buf == NULL) + return; + + // Setta come coordinate destinazione quelle del mouse + prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); + + RMText::Draw(bigBuf,prim); +} + + +/****************************************************************************\ +* Metodi di RMDialogChoice +\****************************************************************************/ + +RMDialogChoice::RMDialogChoice() { + RMResRaw dlg1(RES_I_DLGTEXT); + RMResRaw dlg2(RES_I_DLGTEXTLINE); + RMRes dlgpal(RES_I_DLGTEXTPAL); + + DlgText.Init(dlg1, dlg1.Width(), dlg1.Height()); + DlgTextLine.Init(dlg2, dlg2.Width(), dlg2.Height()); + + DlgText.LoadPaletteWA(dlgpal); + DlgTextLine.LoadPaletteWA(dlgpal); + + hUnreg=CreateEvent(NULL, false, false, NULL); + bRemoveFromOT = false; +} + +RMDialogChoice::~RMDialogChoice() { + CloseHandle(hUnreg); +} + +void RMDialogChoice::Unregister(void) { + RMGfxWoodyBuffer::Unregister(); + assert(!m_nInList); + PulseEvent(hUnreg); + + bRemoveFromOT = false; +} + +void RMDialogChoice::Init(void) +{ + m_numChoices = 0; + m_drawedStrings = NULL; + m_ptDrawStrings = NULL; + m_curSelection = -1; + + Create(640, 477); + SetPriority(140); +} + + +void RMDialogChoice::Close(void) { + if (m_drawedStrings != NULL) { + delete[] m_drawedStrings; + m_drawedStrings = NULL; + } + + if (m_ptDrawStrings != NULL) { + delete[] m_ptDrawStrings; + m_ptDrawStrings = NULL; + } + + Destroy(); +} + +void RMDialogChoice::SetNumChoices(int num) { + int i; + + m_numChoices = num; + m_curAdded = 0; + + // Alloca lo spazio per le stringhe disegnate + m_drawedStrings = new RMText[num]; + m_ptDrawStrings = new RMPoint[num]; + + // Le inizializza + for (i = 0; i < m_numChoices; i++) { + m_drawedStrings[i].SetColor(0, 255, 0); + m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); + m_drawedStrings[i].SetMaxLineLength(600); + m_drawedStrings[i].SetPriority(10); + } +} + +void RMDialogChoice::AddChoice(RMString string) { + // Si disegna la stringa + assert(m_curAdded < m_numChoices); + m_drawedStrings[m_curAdded++].WriteText(string,0); +} + +void RMDialogChoice::Prepare(void) { + int i; + RMPoint ptPos; + + AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); + + ptPos.Set(20,90); + + for (i = 0; i < m_numChoices; i++) { + AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); + m_ptDrawStrings[i] = ptPos; + ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); + } + + DrawOT(); + ClearOT(); + + m_ptDrawPos.Set(0,480-ptPos.y); +} + +void RMDialogChoice::SetSelected(int pos) { + //uint16 * buf = (uint16 *)m_buf; + RMGfxBox box; + RMRect rc; + + if (pos == m_curSelection) + return; + + box.SetPriority(5); + + if (m_curSelection != -1) { + box.SetColor(0xCC, 0xCC, 0xFF); + rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + rc.BottomRight() = rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); + AddPrim(new RMGfxPrimitive(&box, rc)); + + AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); + DrawOT(); + ClearOT(); + } + + if (pos != -1) { + box.SetColor(100, 100, 100); + rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); + rc.BottomRight() = rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + AddPrim(new RMGfxPrimitive(&box, rc)); + AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); + } + + DrawOT(); + ClearOT(); + + m_curSelection = pos; +} + +void RMDialogChoice::Show(RMGfxTargetBuffer *bigBuf) { + Prepare(); + m_bShow = false; + + if (!m_nInList && bigBuf != NULL) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + if (0) { + m_bShow = true; + } else { + RMPoint destpt; + int deltay; + int starttime = _vm->GetTime(); + int elaps; + + deltay=480 - m_ptDrawPos.y; + destpt = m_ptDrawPos; + m_ptDrawPos.Set(0, 480); + + if (!m_nInList && bigBuf != NULL) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + m_bShow = true; + + elaps = 0; + while (elaps < 700) { + MainWaitFrame(); + MainFreeze(); + elaps = _vm->GetTime() - starttime; + m_ptDrawPos.y = 480 - ((deltay * 100) / 700 * elaps) / 100; + MainUnfreeze(); + } + + m_ptDrawPos.y = destpt.y; + } +} + +void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_bShow == false) + return; + + prim->SetDst(m_ptDrawPos); + RMGfxSourceBuffer16::Draw(bigBuf, prim); +} + + +void RMDialogChoice::Hide(void) { + if (1) { + int deltay; + int starttime = _vm->GetTime(); + int elaps; + + deltay=480 - m_ptDrawPos.y; + elaps = 0; + while (elaps < 700) { + MainWaitFrame(); + MainFreeze(); + elaps=_vm->GetTime()-starttime; + m_ptDrawPos.y=480-((deltay*100)/700*(700-elaps))/100; + MainUnfreeze(); + } + } + + m_bShow = false; + bRemoveFromOT = true; + WaitForSingleObject(hUnreg, INFINITE); +} + + +bool RMDialogChoice::RemoveThis(void) { + return bRemoveFromOT; +} + +void RMDialogChoice::DoFrame(RMPoint ptMousePos) { + int i; + + if (ptMousePos.y > m_ptDrawPos.y) { + for (i = 0; i < m_numChoices; i++) { + if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[i].y+m_drawedStrings[i].Dimy())) { + SetSelected(i); + break; + } + } + + if (i == m_numChoices) + SetSelected(-1); + } +} + +int RMDialogChoice::GetSelection(void) { + return m_curSelection; +} + +} // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 83c48bb938..141b993714 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -45,14 +45,1615 @@ * * **************************************************************************/ -#include "tony/loc.h" -#include "tony/utils.h" -#include "tony/mpal/lzo.h" +#include "common/scummsys.h" #include "tony/mpal/mpalutils.h" +#include "tony/adv.h" +#include "tony/loc.h" +#include "tony/tony.h" + +namespace Tony { + +using namespace ::Tony::MPAL; + +static char rcsid[] = "$Id: $"; + +extern bool bSkipSfxNoLoop; + + +/****************************************************************************\ +* Metodi di RMPalette +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMPalette& pal); +* +* Description: Operatore di estrazione di palette da data stream +* +* Input: RMDataStream &ds Data stream +* RMPalette& pal Palette di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { + ds.Read(pal.m_data,1024); + return ds; +} + +/****************************************************************************\ +* Metodi di RMSlot +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMSlot& slot) +* +* Description: Operatore per estrarre uno slot di un pattern da un data +* stream +* +* Input: RMDataStream &ds Data stream +* RMSlot& slot Slot di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { + slot.ReadFromStream(ds); + return ds; +} + + +void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { + byte type; + + // Type + ds >> type; + m_type = (RMPattern::RMSlotType)type; + + // Dati + ds >> m_data; + + // Posizione + ds >> m_pos; + + // Flag generica + ds >> m_flag; +} + + +/****************************************************************************\ +* Metodi di RMPattern +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMPattern& pat) +* +* Description: Operatore per estrarre un pattern da un data stream +* +* Input: RMDataStream &ds Data stream +* RMPattern& pat Pattern di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { + pat.ReadFromStream(ds); + return ds; +} + +void RMPattern::ReadFromStream(RMDataStream &ds, bool bLOX) { + int i; + + // Nome del pattern + if (!bLOX) + ds >> m_name; + + // Velocita' + ds >> m_speed; + + // Posizione + ds >> m_pos; + + // Flag di loop del pattern + ds >> m_bLoop; + + // Numero di slot + ds >> m_nSlots; + + // Creazione e lettura degli slot + m_slots = new RMSlot[m_nSlots]; + + for (i = 0; i < m_nSlots && !ds.IsError(); i++) { + if (bLOX) + m_slots[i].ReadFromStream(ds, true); + else + m_slots[i].ReadFromStream(ds, false); + } +} + +void RMPattern::UpdateCoord(void) { + m_curPos = m_pos + m_slots[m_nCurSlot].Pos(); +} + +void RMPattern::StopSfx(RMSfx *sfx) { + for (int i = 0; i < m_nSlots; i++) { + if (m_slots[i].m_type == SOUND) { + if (sfx[m_slots[i].m_data].m_name[0] == '_') + sfx[m_slots[i].m_data].Stop(); + else if (bSkipSfxNoLoop) + sfx[m_slots[i].m_data].Stop(); + } + } +} + +int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { + int i; + + // Prendiamo il tempo corrente + m_nStartTime = _vm->GetTime(); + m_nCurSlot = 0; + + // Cerca il primo frame nel pattern + i = 0; + while (m_slots[i].m_type != SPRITE) { + assert(i + 1 < m_nSlots); + i++; + } + + m_nCurSlot = i; + m_nCurSprite = m_slots[i].m_data; + if (bFlag) + *bFlag = m_slots[i].m_flag; + + // Calcola le coordinate correnti + UpdateCoord(); + + // Controlla per il sonoro: + // Se sta alla slot 0, lo playa + // Se speed = 0, deve suonare solo se va in loop '_', oppure se specificato dal parametro + // Se speed! = 0, suona solo quelli in loop + for (i = 0;i < m_nSlots; i++) { + if (m_slots[i].m_type == SOUND) { + if (i == 0) + { + if (sfx[m_slots[i].m_data].m_name[0]=='_') + { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(true); + } + else + { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(); + } + } + else if (m_speed == 0) { + if (bPlayP0) { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(); + } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(true); + } + } else { + if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(true); + } + } + } + } + + return m_nCurSprite; +} + +int RMPattern::Update(HANDLE hEndPattern, byte &bFlag, RMSfx *sfx) { + int CurTime = _vm->GetTime(); + + // Se la speed e' 0, il pattern non avanza mai + if (m_speed == 0) { + PulseEvent(hEndPattern); + bFlag=m_slots[m_nCurSlot].m_flag; + return m_nCurSprite; + } + + // E' arrivato il momento di cambiare slot? + while (m_nStartTime + m_speed <= (uint32)CurTime) { + m_nStartTime += m_speed; + if (m_slots[m_nCurSlot].m_type == SPRITE) + m_nCurSlot++; + if (m_nCurSlot == m_nSlots) { + m_nCurSlot = 0; + bFlag = m_slots[m_nCurSlot].m_flag; + PulseEvent(hEndPattern); + + // @@@ Se non c'e' loop avverte che il pattern e' finito + // Se non c'e' loop rimane sull'ultimo frame + if (!m_bLoop) { + m_nCurSlot = m_nSlots - 1; + bFlag = m_slots[m_nCurSlot].m_flag; + return m_nCurSprite; + } + } + + for (;;) { + switch (m_slots[m_nCurSlot].m_type) { + case SPRITE: + // Legge il prossimo sprite + m_nCurSprite = m_slots[m_nCurSlot].m_data; + + // Aggiorna le coordinate babbo+figlio + UpdateCoord(); + break; + + case SOUND: + if (sfx != NULL) { + sfx[m_slots[m_nCurSlot].m_data].SetVolume(m_slots[m_nCurSlot].Pos().x); + + if (sfx[m_slots[m_nCurSlot].m_data].m_name[0] != '_') + sfx[m_slots[m_nCurSlot].m_data].Play(false); + else + sfx[m_slots[m_nCurSlot].m_data].Play(true); + } + break; + + case COMMAND: + assert(0); + break; + + default: + assert(0); + break; + } + + if (m_slots[m_nCurSlot].m_type == SPRITE) + break; + m_nCurSlot++; + } + } + + // Ritorna lo sprite corrente + bFlag=m_slots[m_nCurSlot].m_flag; + return m_nCurSprite; +} + +RMPattern::RMPattern() { + m_slots = NULL; +} + +RMPattern::~RMPattern() { + if (m_slots != NULL) + { + delete[] m_slots; + m_slots = NULL; + } +} + + + + +/****************************************************************************\ +* Metodi di RMSprite +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMSprite& sprite) +* +* Description: Operatore per estrarre uno sprite da un data stream +* +* Input: RMDataStream &ds Data stream +* RMItem &item Sprite di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { + sprite.ReadFromStream(ds); + return ds; +} + +void RMSprite::Init(RMGfxSourceBuffer *buf) { + m_buf = buf; +} + +void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { + int pos = ds.Pos(); + + ds >> *dimx >> *dimy; + + ds.Seek(pos, ds.START); +} + +void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { + int pos = ds.Pos(); + + ds >> m_name; + ds >> *dimx >> *dimy; + + ds.Seek(pos, ds.START); +} + +void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { + int dimx,dimy; + + // Nome dello sprite + if (!bLOX) + ds >> m_name; + + // Dimensioni + ds >> dimx >> dimy; + + // Bouding box + ds >> m_rcBox; + + // Spazio inutilizzato + if (!bLOX) + ds+=32; + + // Crezione del buffer e lettura + m_buf->Init(ds, dimx,dimy); +} + +void RMSprite::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->Draw(bigBuf, prim); +} + +void RMSprite::SetPalette(byte *buf) { + ((RMGfxSourceBufferPal*)m_buf)->LoadPalette(buf); +} + +RMSprite::RMSprite() { + m_buf= NULL; +} + +RMSprite::~RMSprite() { + if (m_buf) { + delete m_buf; + m_buf = NULL; + } +} + + +/****************************************************************************\ +* Metodi di RMSfx +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMSfx &sfx) +* +* Description: Operatore per estrarre uno sfx da un data stream +* +* Input: RMDataStream &ds Data stream +* RMSfx &sfx Sfx di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { + sfx.ReadFromStream(ds); + return ds; +} + +void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { + char id[4]; + int size; + byte *raw; + + // Nome dello sfx + ds >> m_name; + + ds >> size; + + // Carica l'effetto sonoro dal buffer + ds.Read(id,4); + + // Controlla che sia un riff + assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); + + // Legge la dimensione + ds >> size; + + // Carica il wav + raw = new byte[size]; + ds.Read(raw, size); + + // Crea l'effetto sonoro + m_fx = _vm->CreateSFX(raw); + m_fx->SetLoop(false); + + // Cancella il buffer che non serve pi a nessuno + delete[] raw; +} + +RMSfx::RMSfx() { + m_fx = NULL; + m_bPlayingLoop = false; +} + +RMSfx::~RMSfx() { + if (m_fx) { + m_fx->Release(); + m_fx = NULL; + } +} + +void RMSfx::Play(bool bLoop) { + if (m_fx && !m_bPlayingLoop) { + m_fx->SetLoop(bLoop); + m_fx->Play(); + + if (bLoop) + m_bPlayingLoop=true; + } +} + +void RMSfx::SetVolume(int vol) { + if (m_fx) { + m_fx->SetVolume(vol); + } +} + +void RMSfx::Pause(bool bPause) { + if (m_fx) { + m_fx->Pause(bPause); + } +} + +void RMSfx::Stop(void) { + if (m_fx) { + m_fx->Stop(); + m_bPlayingLoop = false; + } +} + + + +/****************************************************************************\ +* Metodi di RMItem +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMItem &item) +* +* Description: Operatore per estrarre un item da un data stream +* +* Input: RMDataStream &ds Data stream +* RMItem &item Item di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { + item.ReadFromStream(ds); + return ds; +} + + +RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { + if (m_cm == CM_256) { + RMGfxSourceBuffer8RLE *spr; + + if (m_FX == 2) { // AB + spr = new RMGfxSourceBuffer8RLEWordAB; + } else if (m_FX == 1) { // OMBRA+AA + if (dimx == -1 || dimx > 255) + spr = new RMGfxSourceBuffer8RLEWordAA; + else + spr = new RMGfxSourceBuffer8RLEByteAA; + + spr->SetAlphaBlendColor(m_FXparm); + if (bPreRLE) + spr->SetAlreadyCompressed(); + } else { + if (dimx == -1 || dimx > 255) + spr = new RMGfxSourceBuffer8RLEWord; + else + spr = new RMGfxSourceBuffer8RLEByte; + + if (bPreRLE) + spr->SetAlreadyCompressed(); + } + + return spr; + } else + return new RMGfxSourceBuffer16; +} + +bool RMItem::IsIn(RMPoint pt, int *size) { + RMRect rc; + + if (!m_bIsActive) + return false; + + // Cerca il rettangolo giusto da usare, che quello dello sprite se ce l'ha, altrimenti + // quello generico dell'oggeto + if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) + rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); + else if (!m_rcBox.IsEmpty()) + rc = m_rcBox; + // Se non ha box, esce subito + else + return false; + + if (size != NULL) + *size = rc.Size(); + + return rc.PtInRect(pt + m_curScroll); +} + + +void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { + int i, dimx, dimy; + byte cm; + + // Codice mpal + ds >> m_mpalCode; + + // Nome dell'oggetto + ds >> m_name; + + // Z (signed) + ds >> m_z; + + // Posizione nonno + ds >> m_pos; + + // Hotspot + ds >> m_hot; + + // Bounding box + ds >> m_rcBox; + + // Numero sprite, effetti sonori e pattern + ds >> m_nSprites >> m_nSfx >> m_nPatterns; + + // Color mode + ds >> cm; m_cm=(RMColorMode)cm; + + // Flag di presenza della palette differnziata + ds >> m_bPal; + + if (m_cm == CM_256) { + // Se c'e' la palette, leggiamola + if (m_bPal) + ds >> m_pal; + } + + // Dati MPAL + if (!bLOX) + ds += 20; + + ds >> m_FX; + ds >> m_FXparm; + + if (!bLOX) + ds += 106; + + // Creazione delle classi + if (m_nSprites > 0) + m_sprites = new RMSprite[m_nSprites]; + if (m_nSfx > 0) + m_sfx = new RMSfx[m_nSfx]; + m_patterns = new RMPattern[m_nPatterns+1]; + + // Lettura delle classi + if (!ds.IsError()) + for (i = 0; i < m_nSprites && !ds.IsError(); i++) { + // Carica lo sprite + if (bLOX) { + m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); + m_sprites[i].ReadFromStream(ds, true); + } else { + m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); + m_sprites[i].ReadFromStream(ds, false); + } + + if (m_cm == CM_256 && m_bPal) + m_sprites[i].SetPalette(m_pal.m_data); + } + + if (!ds.IsError()) + for (i = 0;i < m_nSfx && !ds.IsError(); i++) { + if (bLOX) + m_sfx[i].ReadFromStream(ds, true); + else + m_sfx[i].ReadFromStream(ds, false); + } + + // Leggiamo i pattern a partire dal pattern 1 + if (!ds.IsError()) + for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { + if (bLOX) + m_patterns[i].ReadFromStream(ds, true); + else + m_patterns[i].ReadFromStream(ds, false); + } + + // Inizializza il curpattern + if (m_bInitCurPattern) + SetPattern(mpalQueryItemPattern(m_mpalCode)); + + // Inizializza lo stato di attivazione + m_bIsActive=mpalQueryItemIsActive(m_mpalCode); +} + + +RMGfxPrimitive *RMItem::NewItemPrimitive() { + return new RMGfxPrimitive(this); +} + +void RMItem::SetScrollPosition(RMPoint scroll) { + m_curScroll = scroll; +} + +bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { + int oldSprite = m_nCurSprite; + + // Pattern 0 = Non disegnare nulla! + if (m_nCurPattern == 0) + return false; + + // Facciamo un update del pattern, che ci ritorna anche il frame corrente + if (m_nCurPattern != 0) + m_nCurSprite=m_patterns[m_nCurPattern].Update(m_hEndPattern,m_bCurFlag, m_sfx); + + // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito + if (m_nCurSprite == -1) { + // Mettiamo il pattern 0, e usciamo. La classe si auto-deregistrera' della OT list + m_nCurPattern = 0; + return false; + } + + // Se non siamo in OT list, mettiamoci + if (!m_nInList && bAddToList) + bigBuf->AddPrim(NewItemPrimitive()); + + return oldSprite != m_nCurSprite; +} + +RMPoint RMItem::CalculatePos(void) { + return m_pos + m_patterns[m_nCurPattern].Pos(); +} + +void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Se CurSprite == -1, allora e' finito il pattern + if (m_nCurSprite == -1) + return; + + // Settiamo la flag + prim->SetFlag(m_bCurFlag); + + // Offset inverso per lo scrolling + prim->Dst().Offset(-m_curScroll); + + // Dobbiamo sparaflashare le coordinate dell'item dentro la primitiva. + // Si calcola nonno+(babbo+figlio) + prim->Dst().Offset(CalculatePos()); + + // No stretching, please + prim->SetStrecth(false); + + // Ora la passiamo alla routine di drawing generica per surface + m_sprites[m_nCurSprite].Draw(bigBuf, prim); +} + + +bool RMItem::RemoveThis() { + // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) + return (m_nCurSprite == -1); +} + + +void RMItem::SetStatus(int nStatus) { + m_bIsActive = (nStatus>0); +} + +void RMItem::SetPattern(int nPattern, bool bPlayP0) { + int i; + + assert(nPattern >= 0 && nPattern <= m_nPatterns); + + if (m_sfx) + if (m_nCurPattern>0) + m_patterns[m_nCurPattern].StopSfx(m_sfx); + + // Si ricorda il pattern corrente + m_nCurPattern = nPattern; + + // Inizia il pattern per cominciare l'animazione + if (m_nCurPattern != 0) + m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); + else { + m_nCurSprite = -1; + + // Cerca l'effetto sonoro per il pattern 0 + if (bPlayP0) + for (i = 0;i < m_nSfx; i++) + if (strcmp(m_sfx[i].m_name, "p0") == 0) + m_sfx[i].Play(); + } +} + + +bool RMItem::GetName(RMString& name) +{ + char buf[256]; + + mpalQueryItemName(m_mpalCode, buf); + name = buf; + if (buf[0] == '\0') + return false; + return true; +} + + +void RMItem::Unload(void) { + if (m_patterns != NULL) + { + delete[] m_patterns; + m_patterns = NULL; + } + + if (m_sprites != NULL) { + delete[] m_sprites; + m_sprites = NULL; + } + + if (m_sfx != NULL) { + delete[] m_sfx; + m_sfx = NULL; + } +} + +RMItem::RMItem() { + m_bCurFlag = 0; + m_patterns = NULL; + m_sprites = NULL; + m_sfx= NULL; + m_curScroll.Set(0, 0); + m_bInitCurPattern=true; + m_nCurPattern = 0; + + m_hEndPattern = CreateEvent(NULL, false, false, NULL); +} + +RMItem::~RMItem() { + Unload(); + CloseHandle(m_hEndPattern); +} + +void RMItem::WaitForEndPattern(HANDLE hCustomSkip) { + if (m_nCurPattern != 0) { + if (hCustomSkip == INVALID_HANDLE_VALUE) + WaitForSingleObject(m_hEndPattern,INFINITE); + else { + HANDLE h[2]; + + h[0] = hCustomSkip; + h[1] = m_hEndPattern; + WaitForMultipleObjects(2, h, false, INFINITE); + } + } +} + +void RMItem::ChangeHotspot(RMPoint pt) { + m_hot = pt; +} + +void RMItem::PlaySfx(int nSfx) { + if (nSfx < m_nSfx) + m_sfx[nSfx].Play(); +} + +void RMItem::PauseSound(bool bPause) { + int i; + + for (i = 0; i < m_nSfx; i++) + m_sfx[i].Pause(bPause); +} + + + +/****************************************************************************\ +* Metodi di RMWipe +\****************************************************************************/ + + +RMWipe::RMWipe() { + m_hUnregistered=CreateEvent(NULL,false,false,NULL); + m_hEndOfFade=CreateEvent(NULL,false,false,NULL); +} + +RMWipe::~RMWipe() { + CloseHandle(m_hUnregistered); + CloseHandle(m_hEndOfFade); +} + +int RMWipe::Priority(void) { + return 200; +} + +void RMWipe::Unregister(void) { + RMGfxTask::Unregister(); + assert(m_nInList == 0); + SetEvent(m_hUnregistered); +} + +bool RMWipe::RemoveThis(void) { + return m_bUnregister; +} + +void RMWipe::WaitForFadeEnd(void) { + WaitForSingleObject(m_hEndOfFade, INFINITE); + m_bEndFade = true; + m_bFading = false; + MainWaitFrame(); + MainWaitFrame(); +} + +void RMWipe::CloseFade(void) { +// m_bUnregister=true; +// WaitForSingleObject(m_hUnregistered,INFINITE); + m_wip0r.Unload(); +} + +void RMWipe::InitFade(int type) { + // Attiva il fade + m_bUnregister = false; + m_bEndFade = false; + + m_nFadeStep = 0; + + m_bMustRegister = true; + + RMRes res(RES_W_CERCHIO); + RMDataStream ds; + + ds.OpenBuffer(res); + ds >> m_wip0r; + ds.Close(); + + m_wip0r.SetPattern(1); + + m_bFading = true; +} + +void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { + if (m_bMustRegister) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); + m_bMustRegister = false; + } + + if (m_bFading) + { + m_wip0r.DoFrame(&bigBuf, false); + + m_nFadeStep++; + + if (m_nFadeStep == 10) { + SetEvent(m_hEndOfFade); + } + } +} + +void RMWipe::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_bFading) { + m_wip0r.Draw(bigBuf, prim); + } + + if (m_bEndFade) + Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); +} + + + +/****************************************************************************\ +* Metodi di RMCharacter +\****************************************************************************/ + +/***************************************************************************/ +/* Cerca il percorso minimo tra due nodi del grafo di connessione dei BOX */ +/* Restituisce il percorso lungo pathlenght nel vettore path[] */ +/***************************************************************************/ + +short RMCharacter::FindPath(short source, short destination) { + // FIXME: Refactor + static RMBox BOX[MAXBOXES]; // Matrice di Adjacenza + static short COSTO[MAXBOXES]; // Costi per Nodo + static short VALIDO[MAXBOXES]; // 0:non valido 1:valido 2:saturo + static short NEXT[MAXBOXES]; // Prossimo Nodo + short i, j, k, costominimo, fine, errore = 0; + RMBoxLoc *cur; + + g_system->lockMutex(csMove); + + if (source == -1 || destination == -1) { + g_system->unlockMutex(csMove); + return 0; + } + + // Si fa dare i box + cur = theBoxes->GetBoxes(curLocation); + + // Effettua una copia di riserva per lavorarci + for (i = 0; i < cur->numbbox; i++) + memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); + + // Invalida tutti i Nodi + for (i = 0; i < cur->numbbox; i++) + VALIDO[i] = 0; + + // Prepara sorgente e variabili globali alla procedura + COSTO[source] = 0; + VALIDO[source] = 1; + fine = 0; + + // Ricerca del percorso minimo + while(!fine) { + costominimo = 32000; // risetta il costo minimo + errore = 1; // errore possibile + + // 1 ciclo : ricerca di possibili nuovi nodi + for (i = 0; i < cur->numbbox; i++) + if (VALIDO[i] == 1) { + errore = 0; // errore sfatato + j = 0; + while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + j++; + + if (j >= cur->numbbox) + VALIDO[i] = 2; // nodo saturo? + else { + NEXT[i] = j; + if (COSTO[i] + 1 < costominimo) + costominimo = COSTO[i] + 1; + } + } + + if (errore) + fine = 1; // tutti i nodi saturi + + // 2 ciclo : aggiunta nuovi nodi trovati , saturazione nodi vecchi + for (i = 0; i < cur->numbbox; i++) + if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { + BOX[i].adj[NEXT[i]] = 2; + COSTO[NEXT[i]] = costominimo; + VALIDO[NEXT[i]] = 1; + for (j = 0; j < cur->numbbox; j++) + if (BOX[j].adj[NEXT[i]] == 1) + BOX[j].adj[NEXT[i]] = 0; + + if (NEXT[i] == destination) + fine = 1; + } + } + + // Estrazione del percorso dalla matrice di adiacenza modificata + if (!errore) { + pathlenght = COSTO[destination]; + k = pathlenght; + path[k] = destination; + + while (path[k] != source) { + i = 0; + while (BOX[i].adj[path[k]] != 2) + i++; + k--; + path[k] = i; + } + + pathlenght++; + } + + g_system->unlockMutex(csMove); + + return !errore; +} + + +void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { + if (m_pos == destcoord) { + if (minpath == 0) { + Stop(); + PulseEvent(hEndOfPath); + return; + } + } + + status = WALK; + linestart = m_pos; + lineend = destcoord; + dx = linestart.x - lineend.x; + dy = linestart.y - lineend.y; + fx = dx; + fy = dy; + dx = ABS(dx); + dy = ABS(dy); + walkspeed = curSpeed; + walkcount = 0; + + if (bReversed) { + while (0) ; + } + + int nPatt = GetCurPattern(); + + if (dx > dy) { + slope = fy / fx; + if (lineend.x < linestart.x) + walkspeed = -walkspeed; + walkstatus = 1; + + // Cambia il proprio pattern per la nuova direzione + bNeedToStop = true; + if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + if (nPatt != PAT_WALKLEFT) + SetPattern(PAT_WALKLEFT); + } else { + if (nPatt != PAT_WALKRIGHT) + SetPattern(PAT_WALKRIGHT); + } + } else { + slope = fx / fy; + if (lineend.y < linestart.y) + walkspeed = -walkspeed; + walkstatus = 0; + + bNeedToStop=true; + if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + if (nPatt != PAT_WALKUP) + SetPattern(PAT_WALKUP); + } else { + if (nPatt != PAT_WALKDOWN) + SetPattern(PAT_WALKDOWN); + } + } + + olddx = dx; + olddy = dy; + + // ResetEvent(hTonyEndMovement); @@@ +} + + +RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto) { + short passi, minimo; + RMPoint nuovo, trovato; + minimo = 32000; + + if (UP) { + nuovo = punto; + passi = 0; + while((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo)&& + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.y--; // to avoid error? + trovato = nuovo; + } + } + + if (DOWN) { + nuovo = punto; + passi = 0; + while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.y++; // to avoid error? + trovato = nuovo; + } + } + + if (RIGHT) { + nuovo = punto; + passi = 0; + while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.x++; // to avoid error? + trovato = nuovo; + } + } + + if (LEFT) { + nuovo = punto; + passi = 0; + while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.x--; // to avoid error? + trovato = nuovo; + } + } + + if (minimo == 32000) trovato = punto; + return trovato; +} + + +RMPoint RMCharacter::NearestPoint(RMPoint punto) { +/* + RMPoint tofind; + signed short difx,dify; + + difx = m_pos.x-punto.x; + dify = m_pos.y-punto.y; + + if ((difx>0) && (dify>0)) tofind=Searching(0,1,1,0,punto); + if ((difx>0) && (dify<0)) tofind=Searching(1,0,1,0,punto); + if ((difx<0) && (dify>0)) tofind=Searching(0,1,0,1,punto); + if ((difx<0) && (dify<0)) tofind=Searching(1,0,0,1,punto); + + // potrebbero essere tolti? Pensaci @@@@ + if ((difx= = 0) && (dify>0)) tofind=Searching(0,1,1,1,punto); + if ((difx= = 0) && (dify<0)) tofind=Searching(1,0,1,1,punto); + if ((dify= = 0) && (difx>0)) tofind=Searching(1,1,1,0,punto); + if ((dify= = 0) && (difx<0)) tofind=Searching(1,1,0,1,punto); + + if ((dify= = 0) && (difx= = 0)) tofind=punto; + + return tofind; +*/ + return Searching(1, 1, 1, 1, punto); +} + + +short RMCharacter::ScanLine(RMPoint punto) { + int Ldx, Ldy, Lcount; + float Lfx, Lfy, Lslope; + RMPoint Lstart, Lend, Lscan; + signed char Lspeed, Lstatus; + + Lstart = m_pos; + Lend = punto; + Ldx = Lstart.x-Lend.x; + Ldy = Lstart.y-Lend.y; + Lfx = Ldx; + Lfy = Ldy; + Ldx = ABS(Ldx); + Ldy = ABS(Ldy); + Lspeed = 1; + Lcount = 0; + + if (Ldx > Ldy) { + Lslope = Lfy / Lfx; + if (Lend.x < Lstart.x) Lspeed = -Lspeed; + Lstatus = 1; + } else { + Lslope = Lfx / Lfy; + if (Lend.y < Lstart.y) Lspeed =- Lspeed; + Lstatus = 0; + } + + Lscan = Lstart; // Inizio scansione + while (InWhichBox(Lscan) != -1) { + Lcount++; + if (Lstatus) { + Ldx = Lspeed * Lcount; + Ldy = Lslope * Ldx; + } else { + Ldy = Lspeed * Lcount; + Ldx = Lslope * Ldy; + } + + Lscan.x = Lstart.x + Ldx; + Lscan.y = Lstart.y + Ldy; + + if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; + } + + return 0; +} -namespace Tony { +// Calcola intersezioni tra la traiettoria rettilinea ed il pi vicino BBOX +RMPoint RMCharacter::InvScanLine(RMPoint punto) { + int Ldx, Ldy, Lcount; + float Lfx, Lfy, Lslope; + RMPoint Lstart, Lend, Lscan; + signed char Lspeed, Lstatus, Lbox = -1; -using namespace ::Tony::MPAL; + Lstart = punto; // Exchange! + Lend = m_pos; // :-) + Ldx = Lstart.x - Lend.x; + Ldy = Lstart.y - Lend.y; + Lfx = Ldx; + Lfy = Ldy; + Ldx = ABS(Ldx); + Ldy = ABS(Ldy); + Lspeed = 1; + Lcount = 0; + + if (Ldx > Ldy) { + Lslope = Lfy / Lfx; + if (Lend.x < Lstart.x) Lspeed = -Lspeed; + Lstatus=1; + } else { + Lslope = Lfx / Lfy; + if (Lend.y < Lstart.y) Lspeed = -Lspeed; + Lstatus = 0; + } + Lscan = Lstart; + + for (;;) { + if (InWhichBox(Lscan) != -1) { + if (InWhichBox(Lscan) != Lbox) { + if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos),InWhichBox(Lscan))) + return Lscan; + else + Lbox = InWhichBox(Lscan); + } + } + + Lcount++; + if (Lstatus) { + Ldx = Lspeed * Lcount; + Ldy = Lslope * Ldx; + } else { + Ldy = Lspeed * Lcount; + Ldx = Lslope * Ldy; + } + Lscan.x = Lstart.x + Ldx; + Lscan.y = Lstart.y + Ldy; + } +} + + +/***************************************************************************/ +/* Ritorna la coordinata dell'HotSpot di uscita pi vicino al giocatore */ +/***************************************************************************/ + +RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { + RMPoint puntocaldo; + short cc; + int x, y, distanzaminima; + distanzaminima = 10000000; + RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + + for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) + if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { + x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); + y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); + + if ((x * x + y * y) < distanzaminima) { + distanzaminima = x * x + y * y; + puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; + puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; + } + } + + return puntocaldo; +} + +void RMCharacter::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (bDrawNow) { + prim->Dst() += m_fixedScroll; + + RMItem::Draw(bigBuf, prim); + } +} + +void RMCharacter::NewBoxEntered(int nBox) { + RMBoxLoc *cur; + bool bOldReverse; + + // Richiama la On ExitBox + mpalQueryDoAction(3, curLocation, curbox); + + cur = theBoxes->GetBoxes(curLocation); + bOldReverse = cur->boxes[curbox].bReversed; + curbox = nBox; + + // Se cambiata la Z, dobbiamo rimuoverlo dalla OT + if (cur->boxes[curbox].Zvalue != m_z) { + bRemoveFromOT = true; + m_z = cur->boxes[curbox].Zvalue; + } + + // Gestisce l'inversione del movimento SOLO se non siamo nel percorso minimo: se siamo in percorso + // minimo direttamente la DoFrame a farlo + if (bMovingWithoutMinpath) { + if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { + switch (GetCurPattern()) { + case PAT_WALKUP: + SetPattern(PAT_WALKDOWN); + break; + case PAT_WALKDOWN: + SetPattern(PAT_WALKUP); + break; + case PAT_WALKRIGHT: + SetPattern(PAT_WALKLEFT); + break; + case PAT_WALKLEFT: + SetPattern(PAT_WALKRIGHT); + break; + } + } + } + + // Richiama la On EnterBox + mpalQueryDoAction(2, curLocation, curbox); +} + +void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { + bool bEndNow; + + bEndNow = false; + bEndOfPath = false; + bDrawNow = (curLocation == loc); + + g_system->lockMutex(csMove); + + // Se stiamo camminando... + if (status != STAND) { + // Se stiamo andando in orizzontale + if (walkstatus == 1) { + dx = walkspeed * walkcount; + dy = slope * dx; + m_pos.x = linestart.x + dx; + m_pos.y = linestart.y + dy; + + // Destra + if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { + m_pos = lineend; + status = STAND; + bEndNow = true; + } + } + + // Se stiamo andando in verticale + if (walkstatus == 0) { + dy = walkspeed * walkcount; + dx = slope * dy; + m_pos.x = linestart.x + dx; + m_pos.y = linestart.y + dy; + + // Basso + if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { + m_pos = lineend; + status = STAND; + bEndNow = true; + } + } + + // Controlla se il personaggio uscito dai BOX per errore, nel qual caso + // lo fa rientrare subito + if (InWhichBox(m_pos) == -1) { + m_pos.x = linestart.x + olddx; + m_pos.y = linestart.y + olddy; + } + + // Se siamo appena arrivati alla destinazione temporanea ed finito il percorso minimo, + // ci fermiamo definitivamente + if (bEndNow && minpath == 0) { + if (!bEndOfPath) + Stop(); + bEndOfPath = true; + PulseEvent(hEndOfPath); + } + + walkcount++; + + // Aggiorna la Z del personaggio @@@ bisognerebbe rimuoverlo solo se cambiata la Z + + // Controlla se abbiamo cambiato box + if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) + NewBoxEntered(InWhichBox(m_pos)); + + // Aggiorna le vecchie coordinate + olddx = dx; + olddy = dy; + } + + // Se siamo fermi + if (status == STAND) { + // Controlliamo se c' ancora percorso minimo da calcolare + if (minpath == 1) { + RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + + // Se dobbiamo ancora attraversare un box + if (pathcount < pathlenght) { + // Controlliamo che il box su cui stiamo entrando sia attivo + if (cur->boxes[path[pathcount-1]].attivo) { + // Muoviti in linea retta verso l'hotspot pi vicino, tenendo conto del reversing please + // NEWBOX = path[pathcount-1] + GoTo(NearestHotSpot(path[pathcount-1], path[pathcount]), cur->boxes[path[pathcount-1]].bReversed); + pathcount++; + } else { + // Se il box disattivato, possiamo solo bloccare tutto + // @@@ Questo non dovrebbe pi avvenire, dato che abbiamo migliorato + // la ricerca del percorso minimo + minpath = 0; + if (!bEndOfPath) + Stop(); + bEndOfPath = true; + PulseEvent(hEndOfPath); + } + } else { + // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il + // punto di arrivo + // NEWBOX = InWhichBox(pathend) + minpath = 0; + GoTo(pathend, cur->boxes[InWhichBox(pathend)].bReversed); + } + } + } + + g_system->unlockMutex(csMove); + + // Richiama il DoFrame dell'item + RMItem::DoFrame(bigBuf); +} + +void RMCharacter::Stop(void) { + bMoving = false; + + // Non si sa mai... + status = STAND; + minpath = 0; + + if (!bNeedToStop) + return; + + bNeedToStop = false; + + switch (GetCurPattern()) { + case PAT_WALKUP: + SetPattern(PAT_STANDUP); + break; + + case PAT_WALKDOWN: + SetPattern(PAT_STANDDOWN); + break; + + case PAT_WALKLEFT: + SetPattern(PAT_STANDLEFT); + break; + + case PAT_WALKRIGHT: + SetPattern(PAT_STANDRIGHT); + break; + + default: +// assert(0); +// MessageBox(NULL,"E' lo stesso errore di prima, ma non crasha","Ehi!",MB_OK); + SetPattern(PAT_STANDDOWN); + break; + } +} + +inline int RMCharacter::InWhichBox(RMPoint pt) { + return theBoxes->WhichBox(curLocation,pt); +} + + +bool RMCharacter::Move(RMPoint pt) { + RMPoint dest; + int numbox; + + bMoving = true; + + // Se 0,0, non fare nulla, anzi fermati + if (pt.x == 0 && pt.y == 0) { + minpath = 0; + status = STAND; + Stop(); + return true; + } + + // Se clicko fuori dai box + numbox = InWhichBox(pt); + if (numbox == -1) { + // Trova il punto pi vicino dentro i box + dest = NearestPoint(pt); + + // ???!?? + if (dest == pt) + dest = InvScanLine(pt); + + pt = dest; + numbox = InWhichBox(pt); + } + + RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + + minpath = 0; + status = STAND; + bMovingWithoutMinpath = true; + if (ScanLine(pt)) + GoTo(pt, cur->boxes[numbox].bReversed); + else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + bMovingWithoutMinpath = false; + minpath = 1; + pathcount = 1; + pathend = pt; + } else { + // @@@ Questo caso se un hotspot dentro un box + // ma non c' un path per arrivarci. Usiamo quindi + // la invscanline per cercare un punto intorno + dest = InvScanLine(pt); + pt = dest; + + if (ScanLine(pt)) + GoTo(pt,cur->boxes[numbox].bReversed); + else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + bMovingWithoutMinpath = false; + minpath = 1; + pathcount = 1; + pathend = pt; + return true; + } else + return false; + } + + return true; +} + +void RMCharacter::SetPosition(RMPoint pt, int newloc) { + RMBoxLoc *box; + + minpath = 0; + status = STAND; + m_pos = pt; + + if (newloc != -1) + curLocation = newloc; + + // Aggiorna la Z del personaggio + box = theBoxes->GetBoxes(curLocation); + curbox = InWhichBox(m_pos); + assert(curbox != -1); + m_z = box->boxes[curbox].Zvalue; + bRemoveFromOT = true; +} + +bool RMCharacter::RemoveThis(void) { + if (bRemoveFromOT) + return true; + + return RMItem::RemoveThis(); +} + +RMCharacter::RMCharacter() { +// InitializeCriticalSection(&csMove); + hEndOfPath = CreateEvent(NULL, false, false, NULL); + minpath = 0; + curSpeed = 3; + bRemoveFromOT = false; + bMoving = false; + + m_pos.Set(0, 0); +} + +RMCharacter::~RMCharacter() { +// DeleteCriticalSection(&csMove); + CloseHandle(hEndOfPath); +} + +void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { + theBoxes = boxes; +} /****************************************************************************\ * RMBox Methods @@ -94,7 +1695,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { } } -RMDataStream& operator>>(RMDataStream &ds, RMBox &box) { +RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { box.ReadFromStream(ds); return ds; @@ -104,7 +1705,7 @@ RMDataStream& operator>>(RMDataStream &ds, RMBox &box) { * RMBoxLoc Methods \****************************************************************************/ -void RMBoxLoc::ReadFromStream(RMDataStream& ds) { +void RMBoxLoc::ReadFromStream(RMDataStream &ds) { int i; char buf[2]; byte ver; @@ -132,7 +1733,7 @@ void RMBoxLoc::RecalcAllAdj(void) { for (i = 0; i < numbbox; i++) { Common::fill(boxes[i].adj, boxes[i].adj + MAXBOXES, 0); - for (j=0; j < boxes[i].numhotspot; j++) + for (j = 0; j < boxes[i].numhotspot; j++) if (boxes[boxes[i].hotspot[j].destination].attivo) boxes[i].adj[boxes[i].hotspot[j].destination] = 1; } @@ -192,7 +1793,7 @@ int RMGameBoxes::WhichBox(int nLoc, RMPoint punto) { if (!cur) return -1; - for (i=0; inumbbox; i++) + for (i = 0; inumbbox; i++) if (cur->boxes[i].attivo) if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) @@ -233,7 +1834,7 @@ void RMGameBoxes::SaveState(byte *state) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); state+=4; - for (j=0; j < m_allBoxes[i]->numbbox; j++) + for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; } } @@ -254,8 +1855,7 @@ void RMGameBoxes::LoadState(byte *state) { nbox = READ_LE_UINT32(state); state += 4; - for (j=0; jnumbbox) m_allBoxes[i]->boxes[j].attivo = *state; @@ -266,4 +1866,451 @@ void RMGameBoxes::LoadState(byte *state) { } } +/****************************************************************************\ +* Metodi di RMLocation +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: RMLocation::RMLocation(); +* +* Description: Costruttore standard +* +\****************************************************************************/ + +RMLocation::RMLocation() { + m_nItems = 0; + m_items = NULL; + m_buf = NULL; +} + + +/****************************************************************************\ +* +* Function: bool RMLocation::Load(char *lpszFileName); +* +* Description: Carica una locazione (.LOC) da un file di cui viene fornito +* il pathname. +* +* Input: char *lpszFileName Nome del file di dati +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool RMLocation::Load(const char *lpszFileName) { + Common::File f; + bool bRet; + + // Apre il file in lettura + if (!f.open(lpszFileName)) + return false; + + // Lo passa alla routine di loading da file aperto + bRet = Load(f); + + // Chiude il file + f.close(); + + return bRet; +} + + +/****************************************************************************\ +* +* Function: bool RMLocation::Load(HANDLE hFile); +* +* Description: Carica una locazione (.LOC) da un handle di file aperto +* +* Input: HANDLE hFile Handle del file +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool RMLocation::Load(Common::File &file) { + int size; +// byte *buf; +// uint32 dwReadBytes; + bool bRet; + + // Calcola la lunghezza del file + size = file.size(); + file.seek(0); + +/* + // Alloca la memoria per caricare il file in memoria + buf=(LPBYTE)GlobalAlloc(GMEM_FIXED,size); + + // Legge il file in memoria + ReadFile(hFile,buf,size,&dwReadBytes,0); + + // Parsing del file, utilizzando la funzione di load da memorira + bRet=Load(buf); + + // Free della memoria + GlobalFree(buf); +*/ + + RMFileStreamSlow fs; + + fs.OpenFile(file); + bRet = Load(fs); + fs.Close(); + + return bRet; +} + + +bool RMLocation::Load(const byte *buf) { + RMDataStream ds; + bool bRet; + + ds.OpenBuffer(buf); + bRet = Load(ds); + ds.Close(); + return bRet; +} + + + +/****************************************************************************\ +* +* Function: bool RMLocation::Load(byte *buf); +* +* Description: Carica una locazione (.LOC) parsando il file gia' caricato +* in memoria. +* +* Input: byte *buf Buffer con il file caricato +* +* Return: true se ok, false in caso di errore +* +\****************************************************************************/ + +bool RMLocation::Load(RMDataStream &ds) { + char id[3]; + int dimx, dimy; + byte ver; + byte cm; + int i; + + // Controlla l'ID + ds >> id[0] >> id[1] >> id[2]; + + // Controlla se siamo in un LOX + if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') + return LoadLOX(ds); + + // Altrimenti, controlla che sia un LOC normale + if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') + return false; + + // Versione + ds >> ver; + assert(ver == 6); + + // Nome della locazione + ds >> m_name; + + // Skippa i salvataggi MPAL (64 bytes) + ds >> TEMPNumLoc; + ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + ds += 64 - 4 * 3; + + // Skippa il flag di background associato (?!) + ds += 1; + + // Dimensioni della locazione + ds >> dimx >> dimy; + m_curScroll.Set(0, 0); + + // Legge il color mode + ds >> cm; m_cmode = (RMColorMode)cm; + + // Inizializza il source buffer e leggi la locazione dentro + switch (m_cmode) { + case CM_256: + m_buf = new RMGfxSourceBuffer8; + break; + + case CM_65K: + m_buf = new RMGfxSourceBuffer16; + break; + + default: + assert(0); + break; + }; + + // Inizializza la surface, caricando anche la palette se necessario + m_buf->Init(ds, dimx, dimy, true); + + // Controlla le dimensioni della locazione +// assert(dimy!=512); + + // Numero oggetti + ds >> m_nItems; + + // Creazione e lettura degli oggetti + if (m_nItems > 0) + m_items = new RMItem[m_nItems]; + + + _vm->FreezeTime(); + for (i = 0;i < m_nItems && !ds.IsError(); i++) + ds >> m_items[i]; + _vm->UnfreezeTime(); + + // Setta i pattern iniziali @@@ doppione!! + //for (i = 0;i> ver; + assert(ver == 1); + + // Nome locazione + ds >> m_name; + + // Numero loc + ds >> TEMPNumLoc; + ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + + // Dimensioni + ds >> dimx >> dimy; + m_curScroll.Set(0, 0); + + // Color mode sempre 65K + m_cmode = CM_65K; + m_buf = new RMGfxSourceBuffer16; + + // Inizializza la surface, caricando anche la palette se necessario + m_buf->Init(ds, dimx, dimy, true); + + // Controlla le dimensioni della locazione +// assert(dimy!=512); + + // Numero oggetti + ds >> m_nItems; + + // Creazione e lettura degli oggetti + if (m_nItems > 0) + m_items = new RMItem[m_nItems]; + + for (i = 0; i < m_nItems && !ds.IsError(); i++) + m_items[i].ReadFromStream(ds, true); + + return ds.IsError(); +} + + + +/****************************************************************************\ +* +* Function: void RMLocation::Draw(RMGfxTargetBuffer* bigBuf, +* RMGfxPrimitive* prim); +* +* Description: Metodo di drawing in overloading da RMGfxSourceBuffer8 +* +\****************************************************************************/ + +void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Setta la posizione sorgente dello scrolling + if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { + prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); + } + + prim->SetDst(m_fixedScroll); + + // Richiama il metodo di drawing della classe dell'immagine, che disegner il background + // della locazione + m_buf->Draw(bigBuf, prim); +} + + +/****************************************************************************\ +* +* Function: void RMLocation::DoFrame(void); +* +* Description: Prepara un frame, aggiungendo alla OTList la locazione stessa +* e tutti gli item che hanno cambiato frame di animazione +* +\****************************************************************************/ + +void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { + int i; + + // Se la locazione non e' in OT list, la aggiunge + if (!m_nInList) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + // Processa tutti gli item della locazione + for (i = 0;i < m_nItems; i++) + m_items[i].DoFrame(bigBuf); +} + + +RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { + int i; + + for (i = 0; i < m_nItems; i++) + if (m_items[i].MpalCode() == (int)dwCode) + return &m_items[i]; + + return NULL; +} + +RMItem *RMLocation::WhichItemIsIn(RMPoint pt) { + int found = -1; + int foundSize = 0; + int size; + + for (int i = 0; i < m_nItems; i++) { + size = 0; + if (m_items[i].IsIn(pt, &size)) { + if (found == -1 || size < foundSize) { + foundSize = size; + found = i; + } + } + } + + if (found == -1) + return NULL; + else + return &m_items[found]; +} + + +RMLocation::~RMLocation() { + Unload(); +} + +void RMLocation::Unload(void) { + // Cancella la memoria + if (m_items) { + delete[] m_items; + m_items = NULL; + } + + // Cancella il buffer + if (m_buf) { + delete m_buf; + m_buf = NULL; + } +} + +void RMLocation::UpdateScrolling(RMPoint ptShowThis) { + RMPoint oldScroll = m_curScroll; + + if (m_curScroll.x + 250 > ptShowThis.x) { + m_curScroll.x = ptShowThis.x - 250; + } else if (m_curScroll.x + RM_SX - 250 < ptShowThis.x) { + m_curScroll.x = ptShowThis.x + 250 - RM_SX; + } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->Dimx() > RM_SX) { + if (m_curScroll.x + RM_SX / 2 < ptShowThis.x) + m_curScroll.x++; + else + m_curScroll.x--; + } + + if (m_curScroll.y + 180 > ptShowThis.y) { + m_curScroll.y = ptShowThis.y - 180; + } else if (m_curScroll.y + RM_SY - 180 < ptShowThis.y) { + m_curScroll.y = ptShowThis.y + 180 - RM_SY; + } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->Dimy() > RM_SY) { + if (m_curScroll.y + RM_SY / 2 < ptShowThis.y) + m_curScroll.y++; + else + m_curScroll.y--; + } + + if (m_curScroll.x < 0) m_curScroll.x = 0; + if (m_curScroll.y < 0) m_curScroll.y = 0; + if (m_curScroll.x + RM_SX > m_buf->Dimx()) m_curScroll.x = m_buf->Dimx() - RM_SX; + if (m_curScroll.y + RM_SY > m_buf->Dimy()) m_curScroll.y = m_buf->Dimy() - RM_SY; + + if (oldScroll != m_curScroll) + for (int i = 0; i < m_nItems; i++) + m_items[i].SetScrollPosition(m_curScroll); +} + +void RMLocation::SetFixedScroll(const RMPoint &scroll) { + m_fixedScroll = scroll; + + for (int i = 0; i < m_nItems; i++) + m_items[i].SetScrollPosition(m_curScroll - m_fixedScroll); +} + +void RMLocation::SetScrollPosition(const RMPoint &scroll) { + RMPoint pt = scroll; + if (pt.x < 0) pt.x = 0; + if (pt.y < 0) pt.y = 0; + if (pt.x + RM_SX>m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; + if (pt.y + RM_SY>m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + + m_curScroll = pt; + + for (int i = 0; i < m_nItems; i++) + m_items[i].SetScrollPosition(m_curScroll); +} + + +void RMLocation::PauseSound(bool bPause) { + int i; + + for (i = 0; i < m_nItems; i++) + m_items[i].PauseSound(bPause); +} + + +/****************************************************************************\ +* Metodi di RMMessage +\****************************************************************************/ + +RMMessage::RMMessage(uint32 dwId) { + lpMessage=mpalQueryMessage(dwId); + assert(lpMessage != NULL); + + if (lpMessage) + ParseMessage(); +} + +RMMessage::~RMMessage() { + if (lpMessage) + GlobalFree(lpMessage); +} + +void RMMessage::ParseMessage(void) { + char *p; + + assert(lpMessage != NULL); + + nPeriods = 1; + p = lpPeriods[0] = lpMessage; + + for (;;) { + // Trova la fine del periodo corrente + while (*p != '\0') + p++; + + // Se c'e' un altro '\0' siamo alla fine del messaggio + p++; + if (*p == '\0') + break; + + // Altrimenti c'e' un altro periodo, e ci ricordiamo il suo inizio + lpPeriods[nPeriods++] = p; + } +} + } // End of namespace Tony diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 73effc85c1..c5c7859e73 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -50,6 +50,7 @@ #include "common/scummsys.h" #include "common/system.h" +#include "common/file.h" #include "tony/mpal/stubs.h" #include "tony/sound.h" #include "tony/utils.h" @@ -539,8 +540,8 @@ public: virtual ~RMLocation(); // Caricamento da disco - bool Load(char *lpszFileName); - bool Load(HANDLE hFile); + bool Load(const char *lpszFileName); + bool Load(Common::File &file); bool Load(const byte *buf); bool Load(RMDataStream &ds); bool LoadLOX(RMDataStream &ds); diff --git a/engines/tony/utils.h b/engines/tony/utils.h index bd4b152f1f..f9c9e614ac 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -118,6 +118,56 @@ public: bool IsError(); }; + +/** + * Data stream per lettura di dati aperto da file + */ +class RMFileStream : public RMDataStream { +private: + byte *m_buf; + +public: + RMFileStream(); + virtual ~RMFileStream(); + + // Apre lo stream da file + bool OpenFile(const char *lpFN); + bool OpenFile(Common::File &file); + + void Close(void); +}; + + +class RMFileStreamSlow : public RMDataStream { +private: + Common::File f; + bool bMustClose; + +public: + RMFileStreamSlow(); + virtual ~RMFileStreamSlow(); + + bool OpenFile(const char *lpFN); + bool OpenFile(Common::File &file); + + void Close(void); + + RMDataStream& operator+=(int nBytes); + int Seek(int nBytes, RMDSPos where = CUR); + + int Pos(); + virtual bool IsEOF(); + + bool Read(void *buf, int size); + + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, char &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, byte &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint16 &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int16 &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint32 &var); +}; + /** * String class */ -- cgit v1.2.3 From 4ec3ccaf8af41dae15e4bc9a93299e70a4010dad Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 01:36:08 +1000 Subject: TONY: Implemented other classes in game.cpp --- engines/tony/game.cpp | 1249 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1247 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 109eefab24..d5047766bb 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,6 +47,7 @@ #include "common/file.h" #include "common/savefile.h" +#include "common/textconsole.h" #include "tony/mpal/lzo.h" #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" @@ -98,7 +99,7 @@ static char fname[_MAX_FNAME]; static char ext[_MAX_EXT]; HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->GetEngine()->LoadLocation(nLoc,pt,start); + return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } HANDLE MainUnloadLocation(bool bDoOnExit) { @@ -201,7 +202,7 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick if (!m_bDoubleState) { if (m_rect.PtInRect(mousePos)) { if (!m_bActive) { - m_bActive=true; + m_bActive = true; return true; } } else { @@ -235,4 +236,1248 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); } +/****************************************************************************\ +* Metodi di RMOptionSlide +\****************************************************************************/ + +RMOptionSlide::RMOptionSlide(RMPoint pt, int nRange, int nStartValue, int slideSize) { + RMResRaw *raw; + + m_pos = pt; + m_nSlideSize = slideSize; + m_nMax = nRange; + m_nStep = 100 / m_nMax; + m_nValue = nStartValue; + + m_SliderCenter = NULL; + m_SliderLeft = NULL; + m_SliderRight = NULL; + m_SliderSingle = NULL; + + // Sliders + INIT_GFX16_FROMRAW(20029, m_SliderCenter); + INIT_GFX16_FROMRAW(20030, m_SliderLeft); + INIT_GFX16_FROMRAW(20031, m_SliderRight); + INIT_GFX16_FROMRAW(20032, m_SliderSingle); + + // Buttons + m_PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); + m_PushRight = new RMOptionButton(RMRect(pt.x + m_nSlideSize, pt.y, pt.x + m_nSlideSize + 5 + 22, pt.y + 26)); +} + + +RMOptionSlide::~RMOptionSlide() { + delete m_SliderCenter; + m_SliderCenter = NULL; + delete m_SliderLeft; + m_SliderLeft = NULL; + delete m_SliderRight; + m_SliderRight = NULL; + delete m_SliderSingle; + m_SliderSingle = NULL; + + delete m_PushLeft; + m_PushLeft = NULL; + delete m_PushRight; + m_PushRight = NULL; +} + +bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { + bool bRefresh = false; + + // Doframe dei bottoni + m_PushLeft->DoFrame(mousePos, bLeftClick, bRightClick); + m_PushRight->DoFrame(mousePos, bLeftClick, bRightClick); + + if (m_PushLeft->IsActive()) { + if (bLeftClick) { + bRefresh = true; + m_nValue--; + } else if (bRightClick) { + bRefresh = true; + m_nValue -= 3; + } + if (m_nValue < 1) + m_nValue = 1; + } else if (m_PushRight->IsActive()) { + bRefresh = true; + + if (bLeftClick) { + bRefresh = true; + m_nValue++; + } else if (bRightClick) { + bRefresh = true; + m_nValue += 3; + } + if (m_nValue > m_nMax) + m_nValue = m_nMax; + } + + return bRefresh; +} + +void RMOptionSlide::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int i; + int val; + + RMPoint pos; + pos = m_pos; + pos.x += 4; + pos.y += 4; + + val = m_nValue * m_nStep; + if (val < 1) val = 1; + else if (val > 100) val = 100; + + if (val == 1) { + prim->SetDst(pos); + m_SliderSingle->Draw(bigBuf, prim); + } else { + prim->SetDst(pos); + m_SliderLeft->Draw(bigBuf, prim); + pos.x += 3; + + for (i = 1; i < val - 1; i++) { + prim->SetDst(pos); + m_SliderCenter->Draw(bigBuf, prim); + pos.x += 3; + } + + prim->SetDst(pos); + m_SliderRight->Draw(bigBuf, prim); + pos.x += 3; + } +} + +void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); +} + + + +/****************************************************************************\ +* Metodi di RMOptionScreen +\****************************************************************************/ + +RMOptionScreen::RMOptionScreen(void) { + m_nState = MENUGAME; + m_menu = NULL; + m_HideLoadSave = NULL; + m_QuitConfirm = NULL; + + Create(RM_SX, RM_SY); + + m_ButtonExit = NULL; + m_ButtonLoad = NULL; + m_ButtonSave = NULL; + m_ButtonGameMenu = NULL; + m_ButtonGfxMenu = NULL; + m_ButtonSoundMenu = NULL; + m_ButtonSave_ArrowLeft = NULL; + m_ButtonSave_ArrowRight = NULL; + m_bEditSaveName = false; + + int i; + + for (i = 0; i < 6; i++) { + m_curThumb[i] = NULL; + m_ButtonSave_States[i] = NULL; + } + + m_statePos = 0; +} + +RMOptionScreen::~RMOptionScreen(void) { +} + +void RMOptionScreen::RefreshAll(void) { + ClearOT(); + + AddPrim(new RMGfxPrimitive(m_menu)); + + if (m_bNoLoadSave) + AddPrim(new RMGfxPrimitive(m_HideLoadSave,RMPoint(0, 401))); + + if (m_bQuitConfirm) + { + AddPrim(new RMGfxPrimitive(m_QuitConfirm,RMPoint(270, 200))); + m_ButtonQuitYes->AddToList(*this); + m_ButtonQuitNo->AddToList(*this); + } + + m_ButtonExit->AddToList(*this); + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + m_ButtonQuit->AddToList(*this); + m_ButtonLoad->AddToList(*this); + m_ButtonSave->AddToList(*this); + } + + if (m_nState == MENUGAME) { + m_ButtonGame_Lock->AddToList(*this); + m_ButtonGame_TimerizedText->AddToList(*this); + m_ButtonGame_Scrolling->AddToList(*this); + m_ButtonGame_InterUp->AddToList(*this); + m_SlideTextSpeed->AddToList(*this); + m_SlideTonySpeed->AddToList(*this); + } else if (m_nState == MENUGFX) { + m_ButtonGfx_Anni30->AddToList(*this); + m_ButtonGfx_AntiAlias->AddToList(*this); + m_ButtonGfx_Sottotitoli->AddToList(*this); + m_ButtonGfx_Trans->AddToList(*this); + m_ButtonGfx_Tips->AddToList(*this); + } else if (m_nState == MENUSOUND) { + m_SliderSound_Dubbing->AddToList(*this); + m_SliderSound_Music->AddToList(*this); + m_SliderSound_SFX->AddToList(*this); + m_ButtonSound_DubbingOn->AddToList(*this); + m_ButtonSound_MusicOn->AddToList(*this); + m_ButtonSound_SFXOn->AddToList(*this); + } + + RMGfxSourceBuffer16 *thumb = NULL; + RMText* title = NULL; + RMText* num[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; + int i; + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + title = new RMText; + if (m_nState == MENULOAD) { + RMMessage msg(10); + title->WriteText(msg[0], 1); + } else { + RMMessage msg(11); + title->WriteText(msg[0], 1); + } + + AddPrim(new RMGfxPrimitive(title, RMPoint(320, 10))); + + if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); + else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); + if (m_curThumbDiff[1] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); + else if (m_curThumbDiff[1] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 57))); + if (m_curThumbDiff[2] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 57))); + else if (m_curThumbDiff[2] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 57))); + if (m_curThumbDiff[3] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(48, 239))); + else if (m_curThumbDiff[3] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(48, 239))); + if (m_curThumbDiff[4] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(240, 239))); + else if (m_curThumbDiff[4] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 239))); + if (m_curThumbDiff[5] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 239))); + else if (m_curThumbDiff[5] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 239))); + + if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); + if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); + if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); + if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); + if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); + if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); + + if (m_bEditSaveName) { + thumb = new RMGfxSourceBuffer16; + thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + + switch (m_nEditPos) { + case 0: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 57))); break; + case 1: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 57))); break; + case 2: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 57))); break; + case 3: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 239))); break; + case 4: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 239))); break; + case 5: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 239))); break; + } + } + + for (i = 0; i < 6; i++) { + RMString s; + + if (m_bEditSaveName && m_nEditPos == i) + s.Format("%02d)%s*", m_statePos + i, m_EditName); + else { + if (m_statePos == 0 && i == 0) + s.Format("Autosave"); + else + s.Format("%02d)%s", m_statePos + i, m_curThumbName[i]); + } + + num[i] = new RMText; + num[i]->SetAlignType(RMText::HLEFT, RMText::VTOP); + num[i]->WriteText(s, 2); + } + + AddPrim(new RMGfxPrimitive(num[0], RMPoint(55 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(num[1], RMPoint(247 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(num[2],RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(num[3],RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(num[4],RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(num[5],RMPoint(439 - 3, 362 + 14))); + + m_ButtonSave_ArrowLeft->AddToList(*this); + m_ButtonSave_ArrowRight->AddToList(*this); + } + + DrawOT(); + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (thumb) delete thumb; + if (title) delete title; + + for (i = 0; i < 6; i++) + if (num[i]) delete num[i]; + } +} + +void RMOptionScreen::RefreshThumbnails(void) { + int i; + + for (i = 0; i < 6; i++) { + if (m_curThumb[i]) + delete m_curThumb[i]; + + m_curThumb[i] = new RMGfxSourceBuffer16; + m_curThumb[i]->Create(640 / 4, 480 / 4); + if (!LoadThumbnailFromSaveState(m_statePos + i, *m_curThumb[i], m_curThumbName[i], m_curThumbDiff[i])) { + delete m_curThumb[i]; + m_curThumb[i] = NULL; + m_curThumbName[i] = ""; + m_curThumbDiff[i] = 11; + } + } +} + + +void RMOptionScreen::InitState(void) { + RMResRaw *raw; + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) + raw = new RMResRaw(20000 + m_nState); + else if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (m_bAlterGfx) + raw = new RMResRaw(20024); + else + raw = new RMResRaw(20003); + } else { + error("Invalid state"); + } + + assert(raw->IsValid()); + assert(m_menu == NULL); + m_menu = new RMGfxSourceBuffer16(false); + m_menu->Init(*raw, raw->Width(), raw->Height()); + delete raw; + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (m_bAlterGfx) { + assert(m_ButtonExit == NULL); + m_ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); + } + else + { + assert(m_ButtonExit == NULL); + m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); + } + + INIT_GFX8_FROMRAW(20036, m_SaveEasy); + INIT_GFX8_FROMRAW(20037, m_SaveHard); + + RefreshThumbnails(); + + assert(m_ButtonSave_States[0] == NULL); + m_ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); + assert(m_ButtonSave_States[1] == NULL); + m_ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); + assert(m_ButtonSave_States[2] == NULL); + m_ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); + assert(m_ButtonSave_States[3] == NULL); + m_ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); + assert(m_ButtonSave_States[4] == NULL); + m_ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); + assert(m_ButtonSave_States[5] == NULL); + m_ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); + + if (m_bAlterGfx) { + assert(m_ButtonSave_ArrowLeft == NULL); + m_ButtonSave_ArrowLeft = new RMOptionButton(20026,RMPoint(3,196)); + assert(m_ButtonSave_ArrowRight == NULL); + m_ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); + } else { + assert(m_ButtonSave_ArrowLeft == NULL); + m_ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); + assert(m_ButtonSave_ArrowRight == NULL); + m_ButtonSave_ArrowRight = new RMOptionButton(20014,RMPoint(601, 197)); + } + } else if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + assert(m_ButtonExit == NULL); + m_ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); + assert(m_ButtonQuit == NULL); + m_ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); + assert(m_ButtonLoad == NULL); + m_ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); + assert(m_ButtonSave == NULL); + m_ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); + + assert(m_ButtonGameMenu == NULL); + m_ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); + assert(m_ButtonGfxMenu == NULL); + m_ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); + assert(m_ButtonSoundMenu == NULL); + m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); + + raw = new RMResRaw(20021); + assert(raw->IsValid()); + assert(m_QuitConfirm == NULL); + m_QuitConfirm = new RMGfxSourceBuffer16(false); + m_QuitConfirm->Init(*raw, raw->Width(), raw->Height()); + delete raw; + + assert(m_ButtonQuitYes == NULL); + m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); + m_ButtonQuitYes->SetPriority(30); + assert(m_ButtonQuitNo == NULL); + m_ButtonQuitNo = new RMOptionButton(20023,RMPoint(337, 264)); + m_ButtonQuitNo->SetPriority(30); + + if (m_bNoLoadSave) { + raw = new RMResRaw(20028); + assert(raw->IsValid()); + assert(m_HideLoadSave == NULL); + m_HideLoadSave = new RMGfxSourceBuffer16(false); + m_HideLoadSave->Init(*raw, raw->Width(), raw->Height()); + delete raw; + } + + // Menu GAME + if (m_nState == MENUGAME) { + assert(m_ButtonGame_Lock == NULL); + m_ButtonGame_Lock = new RMOptionButton(20008,RMPoint(176, 262), true); + m_ButtonGame_Lock->SetActiveState(bCfgInvLocked); + assert(m_ButtonGame_TimerizedText == NULL); + m_ButtonGame_TimerizedText = new RMOptionButton(20009,RMPoint(463, 273), true); + m_ButtonGame_TimerizedText->SetActiveState(!bCfgTimerizedText); + assert(m_ButtonGame_Scrolling == NULL); + m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); + m_ButtonGame_Scrolling->SetActiveState(bCfgInvNoScroll); + assert(m_ButtonGame_InterUp == NULL); + m_ButtonGame_InterUp = new RMOptionButton(20011,RMPoint(36, 258), true); + m_ButtonGame_InterUp->SetActiveState(bCfgInvUp); + + assert(m_SlideTextSpeed == NULL); + m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, nCfgTextSpeed); + assert(m_SlideTonySpeed == NULL); + m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, nCfgTonySpeed); + } + // Menu Graphics + else if (m_nState == MENUGFX) { + assert(m_ButtonGfx_Anni30 == NULL); + m_ButtonGfx_Anni30 = new RMOptionButton(20015,RMPoint(247, 178), true); + m_ButtonGfx_Anni30->SetActiveState(bCfgAnni30); + assert(m_ButtonGfx_AntiAlias == NULL); + m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); + m_ButtonGfx_AntiAlias->SetActiveState(!bCfgAntiAlias); + assert(m_ButtonGfx_Sottotitoli == NULL); + m_ButtonGfx_Sottotitoli = new RMOptionButton(20017,RMPoint(98, 82), true); + m_ButtonGfx_Sottotitoli->SetActiveState(!bCfgSottotitoli); + assert(m_ButtonGfx_Tips == NULL); + m_ButtonGfx_Tips = new RMOptionButton(20018,RMPoint(431, 246), true); + m_ButtonGfx_Tips->SetActiveState(bCfgInterTips); + assert(m_ButtonGfx_Trans == NULL); + m_ButtonGfx_Trans = new RMOptionButton(20019,RMPoint(126, 271), true); + m_ButtonGfx_Trans->SetActiveState(!bCfgTransparence); + + } else if (m_nState == MENUSOUND) { + assert(m_SliderSound_Dubbing == NULL); + m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, nCfgDubbingVolume); + assert(m_SliderSound_Music == NULL); + m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, nCfgMusicVolume); + assert(m_SliderSound_SFX == NULL); + m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, nCfgSFXVolume); + + assert(m_ButtonSound_DubbingOn == NULL); + m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); + m_ButtonSound_DubbingOn->SetActiveState(bCfgDubbing); + assert(m_ButtonSound_MusicOn == NULL); + m_ButtonSound_MusicOn = new RMOptionButton(20034,RMPoint(338, 179), true); + m_ButtonSound_MusicOn->SetActiveState(bCfgMusic); + assert(m_ButtonSound_SFXOn == NULL); + m_ButtonSound_SFXOn = new RMOptionButton(20035,RMPoint(338, 283), true); + m_ButtonSound_SFXOn->SetActiveState(bCfgSFX); + } + } + + RefreshAll(); +} + +void RMOptionScreen::CloseState(void) { + delete m_menu; + m_menu = NULL; + + delete m_ButtonExit; + m_ButtonExit = false; + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + int i; + + for (i = 0; i < 6; i++) { + if (m_curThumb[i] != NULL) { + delete m_curThumb[i]; + m_curThumb[i] = NULL; + } + + delete m_ButtonSave_States[i]; + m_ButtonSave_States[i] = NULL; + } + + delete m_ButtonSave_ArrowLeft; + m_ButtonSave_ArrowLeft = NULL; + delete m_ButtonSave_ArrowRight; + m_ButtonSave_ArrowRight = NULL; + + delete m_SaveEasy; + m_SaveEasy = NULL; + delete m_SaveHard; + m_SaveHard = NULL; + } + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + delete m_ButtonQuit; + m_ButtonQuit = NULL; + delete m_ButtonLoad; + m_ButtonLoad = NULL; + delete m_ButtonSave; + m_ButtonSave = NULL; + delete m_ButtonGameMenu; + m_ButtonGameMenu = NULL; + delete m_ButtonGfxMenu; + m_ButtonGfxMenu = NULL; + delete m_ButtonSoundMenu; + m_ButtonSoundMenu = NULL; + delete m_QuitConfirm; + m_QuitConfirm = NULL; + delete m_ButtonQuitYes; + m_ButtonQuitYes = NULL; + delete m_ButtonQuitNo; + m_ButtonQuitNo = NULL; + + if (m_bNoLoadSave) { + delete m_HideLoadSave; + m_HideLoadSave = NULL; + } + + if (m_nState == MENUGAME) { + bCfgInvLocked = m_ButtonGame_Lock->IsActive(); + delete m_ButtonGame_Lock; + m_ButtonGame_Lock = NULL; + + bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); + delete m_ButtonGame_TimerizedText; + m_ButtonGame_TimerizedText = NULL; + + bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); + delete m_ButtonGame_Scrolling; + m_ButtonGame_Scrolling = NULL; + + bCfgInvUp = m_ButtonGame_InterUp->IsActive(); + delete m_ButtonGame_InterUp; + m_ButtonGame_InterUp = NULL; + + nCfgTextSpeed = m_SlideTextSpeed->GetValue(); + delete m_SlideTextSpeed; + m_SlideTextSpeed = NULL; + + nCfgTonySpeed = m_SlideTonySpeed->GetValue(); + delete m_SlideTonySpeed; + m_SlideTonySpeed = NULL; + } else if (m_nState == MENUGFX) { + bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); + delete m_ButtonGfx_Anni30; + m_ButtonGfx_Anni30 = NULL; + + bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); + delete m_ButtonGfx_AntiAlias; + m_ButtonGfx_AntiAlias = NULL; + + bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); + delete m_ButtonGfx_Sottotitoli; + m_ButtonGfx_Sottotitoli = NULL; + + bCfgInterTips = m_ButtonGfx_Tips->IsActive(); + delete m_ButtonGfx_Tips; + m_ButtonGfx_Tips = NULL; + + bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); + delete m_ButtonGfx_Trans; + m_ButtonGfx_Trans = NULL; + } else if (m_nState == MENUSOUND) { + nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); + delete m_SliderSound_Dubbing; + m_SliderSound_Dubbing = NULL; + + nCfgMusicVolume = m_SliderSound_Music->GetValue(); + delete m_SliderSound_Music; + m_SliderSound_Music = NULL; + + nCfgSFXVolume = m_SliderSound_SFX->GetValue(); + delete m_SliderSound_SFX; + m_SliderSound_SFX = NULL; + + bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); + delete m_ButtonSound_DubbingOn; + m_ButtonSound_DubbingOn = NULL; + + bCfgMusic = m_ButtonSound_MusicOn->IsActive(); + delete m_ButtonSound_MusicOn; + m_ButtonSound_MusicOn = NULL; + + bCfgSFX = m_ButtonSound_SFXOn->IsActive(); + delete m_ButtonSound_SFXOn; + m_ButtonSound_SFXOn = NULL; + } + } +} + +void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); +} + +bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = false; + m_bNoLoadSave = false; + m_bAlterGfx = false; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + if (m_nState == MENULOAD || m_nState == MENUSAVE) + m_nState = MENUGAME; + InitState(); + + return true; +} + +bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = true; + m_bNoLoadSave = false; + m_bAlterGfx = bAlternateGfx; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_nState = MENULOAD; + InitState(); + + return true; +} + +bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = true; + m_bNoLoadSave = false; + m_bAlterGfx = bAlternateGfx; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_nState = MENUSAVE; + InitState(); + + return true; +} + +bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = false; + m_bNoLoadSave = true; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_nState = MENUGAME; + InitState(); + + return true; +} + +bool RMOptionScreen::Close(void) { + if (m_FadeStep != 6) + return false; + + // Inizia il fade out + m_FadeStep++; + m_FadeTime = _vm->GetTime(); + return true; +} + +bool RMOptionScreen::IsClosing(void) { + return m_bExit; +} + +int RMOptionScreen::Priority() { + // Appena sotto il mouse + return 190; +} + +void RMOptionScreen::ChangeState(STATE newState) { + CloseState(); + m_nLastState = m_nState; + m_nState = newState; + InitState(); +} + +void RMOptionScreen::DoFrame(RMInput *input) { + bool bLeftClick, bRightClick; + RMPoint mousePos; + bool bRefresh; + int i; + + // Se non completamente aperto, non fare nulla + if (m_FadeStep != 6) + return; + + // Legge l'input + mousePos = input->MousePos(); + bLeftClick = input->MouseLeftClicked(); + bRightClick = input->MouseRightClicked(); + + bRefresh = false; + + if (m_bQuitConfirm) { + bRefresh |= m_ButtonQuitYes->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonQuitNo->DoFrame(mousePos, bLeftClick, bRightClick); + } else { + bRefresh |= m_ButtonExit->DoFrame(mousePos, bLeftClick, bRightClick); + + // Controlla se ha clickato sull'uscita + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + // bottoni senza grafica... + m_ButtonGameMenu->DoFrame(mousePos, bLeftClick, bRightClick); + m_ButtonGfxMenu->DoFrame(mousePos, bLeftClick, bRightClick); + m_ButtonSoundMenu->DoFrame(mousePos, bLeftClick, bRightClick); + + // bottoni con grafica + if (!m_bNoLoadSave) + { +#ifndef DEMO + bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); +#endif + bRefresh |= m_ButtonQuit->DoFrame(mousePos, bLeftClick, bRightClick); + } + } + + switch (m_nState) { + case MENUGAME: + bRefresh |= m_ButtonGame_Lock->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGame_TimerizedText->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGame_Scrolling->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGame_InterUp->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SlideTextSpeed->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SlideTonySpeed->DoFrame(mousePos, bLeftClick, bRightClick); + break; + + case MENUGFX: + bRefresh |= m_ButtonGfx_Anni30->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_Tips->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_Trans->DoFrame(mousePos, bLeftClick, bRightClick); + break; + + case MENUSOUND: + bRefresh |= m_SliderSound_Dubbing->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SliderSound_Music->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SliderSound_SFX->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSound_DubbingOn->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSound_MusicOn->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSound_SFXOn->DoFrame(mousePos, bLeftClick, bRightClick); + break; + + case MENULOAD: + case MENUSAVE: + for (i=0;i<6;i++) + m_ButtonSave_States[i]->DoFrame(mousePos, bLeftClick, bRightClick); + + if (m_statePos > 0) + bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(mousePos, bLeftClick, bRightClick); + if (m_statePos < 90) + bRefresh |= m_ButtonSave_ArrowRight->DoFrame(mousePos, bLeftClick, bRightClick); + break; + } + } + +#define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) +#define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ + m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; bRefresh = true; } + + /**************** STATO BOTTONI **************/ + if (m_bEditSaveName) { + if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { + if (m_EditName[0] != '\0') { + m_EditName[strlen(m_EditName) - 1] = '\0'; + bRefresh = true; + } + } + + for (i=0;i<26 && strlen(m_EditName)<12;i++) + if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || + (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { + PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'A'); + } else { + PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'a'); + } + + for (i = 0; i < 10 && strlen(m_EditName) < 12; i++) + PROCESS_CHAR((Common::KeyCode)((int)'0' + i), i + '0'); + + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_SPACE,' '); + + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); + + // ANNULLA + if (KEYPRESS(Common::KEYCODE_ESCAPE)) { + m_bEditSaveName = false; + bRefresh = true; + } + + // OK + if (KEYPRESS(Common::KEYCODE_RETURN)) { + m_bEditSaveName = false; + _vm->SaveState(m_statePos + m_nEditPos, m_EditName); + Close(); + } + + } else if (bLeftClick) { + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (m_ButtonExit->IsActive()) { + if (m_bLoadMenuOnly) { + // Se solo il menu di loading, chiudiamo + Close(); + } else { + ChangeState(m_nLastState); + bRefresh = true; + } + } else if (m_ButtonSave_ArrowLeft->IsActive()) { + if (m_statePos > 0) { + m_statePos -= 6; + if (m_statePos < 0) m_statePos = 0; + m_ButtonSave_ArrowLeft->SetActiveState(false); + bRefresh = true; + RefreshThumbnails(); + } + } else if (m_ButtonSave_ArrowRight->IsActive()) { + if (m_statePos < 90) { + m_statePos += 6; + if (m_statePos > 90) m_statePos = 90; + m_ButtonSave_ArrowRight->SetActiveState(false); + bRefresh = true; + RefreshThumbnails(); + } + } else { + for (i = 0; i < 6; i++) + if (m_ButtonSave_States[i]->IsActive()) { + // C' da effettuare il salvataggio o il caricamento!!!! + if (m_nState == MENULOAD && m_curThumb[i] != NULL) { + // Caricamento + _vm->LoadState(m_statePos+i); + Close(); + } else if (m_nState == MENUSAVE && (m_statePos != 0 || i != 0)) { + // Attiva la modalit di editing + m_bEditSaveName = true; + m_nEditPos = i; + strcpy(m_EditName, m_curThumbName[i]); + bRefresh = true; + + //_vm->SaveState(m_statePos+i,"No name"); + //Close(); + } + + break; + } + } + } + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + if (m_bQuitConfirm) { + if (m_ButtonQuitNo->IsActive()) { + m_bQuitConfirm = false; + bRefresh = true; + } else if (m_ButtonQuitYes->IsActive()) { + m_bQuitConfirm = false; + bRefresh = true; + + _vm->Quit(); + } + } else { + if (m_ButtonQuit->IsActive()) { + m_bQuitConfirm = true; + m_ButtonQuitNo->SetActiveState(false); + m_ButtonQuitYes->SetActiveState(false); + bRefresh = true; + } else if (m_ButtonExit->IsActive()) + Close(); + else if (m_ButtonLoad->IsActive()) { + ChangeState(MENULOAD); + bRefresh = true; + } else if (m_ButtonSave->IsActive()) { + ChangeState(MENUSAVE); + bRefresh = true; + } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { + ChangeState(MENUGAME); + bRefresh = true; + } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { + ChangeState(MENUGFX); + bRefresh = true; + } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { + ChangeState(MENUSOUND); + bRefresh = true; + } + + if (m_nState == MENUGFX) { + // Queste opzioni hanno effetto immediato + if (m_ButtonGfx_Anni30->IsActive()) + bCfgAnni30 = true; + else + bCfgAnni30 = false; + + if (m_ButtonGfx_AntiAlias->IsActive()) + bCfgAntiAlias = false; + else + bCfgAntiAlias = true; + + if (m_ButtonGfx_Trans->IsActive()) + bCfgTransparence = false; + else + bCfgTransparence = true; + } + } + } + } + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) + if (!m_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) + Close(); + + if (bRefresh) + RefreshAll(); +} + + +void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int curTime = _vm->GetTime(); + +#define FADE_SPEED 20 +#define SYNC (curTime-m_FadeTime) / 25 + + if (m_bExit) + return; + + switch (m_FadeStep) { + // Discesa veloce + case 1: + if (m_FadeTime == -1) + m_FadeY += FADE_SPEED; + else + m_FadeY += FADE_SPEED*SYNC; + if (m_FadeY > 480) + { + m_FadeY = 480; + m_FadeStep++; + } + + // Setta la parte da disegnare per lo scrolling + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Rimbalzo 1 + case 2: + m_FadeY -= FADE_SPEED / 2 * SYNC; + if (m_FadeY < 400) { + m_FadeY = 400; + m_FadeStep++; + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + case 3: + m_FadeY -= FADE_SPEED / 4 * SYNC; + if (m_FadeY < 380) { + m_FadeY = 380; + m_FadeStep++; + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Rimbalzo 1 - 2 + case 4: + m_FadeY += FADE_SPEED / 3 * SYNC; + if (m_FadeY > 420) { + m_FadeY = 420; + m_FadeStep++; + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + case 5: + m_FadeY += FADE_SPEED / 2 * SYNC; + if (m_FadeY > 480) { + m_FadeY = 480; + m_FadeStep++; + _vm->HideLocation(); + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Menu ON + case 6: + break; + + // Menu OFF + case 7: + _vm->ShowLocation(); + m_FadeStep++; + break; + + case 8: + m_FadeY -= FADE_SPEED * SYNC; + if (m_FadeY < 0) { + m_FadeY = 0; + m_FadeStep++; + } + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Ciao ciao! + case 9: + m_bExit = true; + m_FadeStep = 0; + + // Libera la memoria + CloseState(); + return; + + default: + m_FadeStep = 0; + break; + } + + m_FadeTime = curTime; + + RMGfxWoodyBuffer::Draw(bigBuf,prim); +} + +bool RMOptionScreen::RemoveThis() { + if (m_bExit) + return true; + + return false; +} + + +bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString& name, byte &diff) { + char buf[256]; + char namebuf[256]; int i; + Common::File f; + char id[4]; + + // Pulisce la destinazione + Common::fill(lpDestBuf, lpDestBuf + 160 * 120 * 2, 0); + name = "No name"; + diff = 10; + + // Si fa dare il nome del salvataggio + _vm->GetSaveStateFileName(nState, buf); + + // Guarda se esiste + if (f.open(buf)) + return false; + + // Controlla se giusto l'header + f.read(id, 4); + if (id[0] != 'R' || id[1] != 'M' || id[2] != 'S') { + f.close(); + return false; + } + + if (id[3] < 0x3) { + // Versione vecchia, niente screenshot + f.close(); + return true; + } + + // legge lo screenshot + if (id[3] >= 0x5) { + byte *cmpbuf; + uint32 cmpsize, size; + + cmpbuf = new byte[160 * 120 * 4]; + + // Se la versione >= 5, compresso! + cmpsize = f.readUint32LE(); + f.read(cmpbuf, cmpsize); + + lzo1x_decompress(cmpbuf,cmpsize,lpDestBuf,&size); + + delete[] cmpbuf; + } else + f.read(lpDestBuf, 160 * 120 * 2); + + if (id[3] >= 0x5) { + // Legge il livello di difficolt + diff = f.readByte(); + } + + if (id[3] < 0x4) { + // Versione vecchia, niente nome + f.close(); + return true; + } + + i = f.readByte(); + f.read(namebuf, i); + namebuf[i] = '\0'; + name = namebuf; + + f.close(); + return true; +} + + +/****************************************************************************\ +* Metodi di RMPointer +\****************************************************************************/ + +RMPointer::RMPointer() { + Common::fill(m_pointer, m_pointer + 16, (RMGfxSourceBuffer8 *)NULL); +} + +RMPointer::~RMPointer() { + Close(); +} + +void RMPointer::Init(void) { + int i; + + for (i = 0; i < 5; i++) { + RMResRaw res(RES_P_GO + i); + + m_pointer[i] = new RMGfxSourceBuffer8RLEByteAA; + m_pointer[i]->Init(res, res.Width(), res.Height(), false); + m_pointer[i]->LoadPaletteWA(RES_P_PAL); + } + + for (i = 0; i < 5; i++) { + RMRes res(RES_P_PAP1 + i); + RMDataStream ds; + + ds.OpenBuffer(res); + m_specialPointer[i] = new RMItem; + ds >> *m_specialPointer[i]; + } + + //m_hotspot[0].Set(19,5); + m_hotspot[0].Set(5, 1); + m_hotspot[1].Set(32, 28); + m_hotspot[2].Set(45, 23); + m_hotspot[3].Set(35, 25); + m_hotspot[4].Set(32, 28); + + // Default=GO + m_nCurPointer = 0; + m_nCurSpecialPointer = 0; +} + +void RMPointer::Close(void) { + int i; + + for (i = 0; i < 1; i++) + if (m_pointer[i] != NULL) + delete m_pointer[i], m_pointer[i] = NULL; +} + + +int RMPointer::Priority() { + // Priorita' minima: davanti a tutto + return 200; +} + +void RMPointer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int n; + + // Controlla il pointer + n = m_nCurPointer; + if (n == TA_COMBINE) n = TA_USE; + + // Copia le coordinate di destinazione nella primitiva + prim->SetDst(m_pos); + + if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { + // Richiama il draw del puntatore + prim->Dst()-=m_hotspot[n]; + + if (m_nCurSpecialPointer == 0) { + m_pointer[n]->Draw(bigBuf,prim); + } else { + if (m_nCurSpecialPointer == PTR_CUSTOM) + m_nCurCustomPointer->Draw(bigBuf, prim); + else + // Richiama il draw sul puntatore speciale + m_specialPointer[m_nCurSpecialPointer-1]->Draw(bigBuf, prim); + } + } +} + +void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { + // Si aggiunge alla lista delle primitive + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + // Se c'e' un puntatore speciale, fa la DoFrame + if (m_nCurSpecialPointer!=0 && m_nCurSpecialPointer!=PTR_CUSTOM) + m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); +} + +bool RMPointer::RemoveThis() { + // Si leva sempre dalla lista di OT, per supportare la DisableInput + return true; +} + +int RMPointer::CurAction(void) { + if (m_nCurSpecialPointer != 0) + return 0; + + return m_nCurPointer; +} + } // End of namespace Tony -- cgit v1.2.3 From 07a16ab2f38c6993addcd659a15dd054f776fa85 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 09:23:54 +1000 Subject: TONY: Implemented gfxcore.cpp methods --- engines/tony/gfxcore.cpp | 1809 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1809 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 731521832f..dfdee30ac6 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -49,6 +49,1815 @@ namespace Tony { +static char rcsid[] = "$Id: $"; +/****************************************************************************\ +* Metodi di RMGfxTask +\****************************************************************************/ + +RMGfxTask::RMGfxTask() { + m_nPrior = 0; + m_nInList = 0; +} + +int RMGfxTask::Priority() { + return m_nPrior; +} + +bool RMGfxTask::RemoveThis() { + return true; +} + + +/****************************************************************************\ +* Metodi di RMGfxTaskSetPrior +\****************************************************************************/ + +void RMGfxTaskSetPrior::SetPriority(int nPrior) { + m_nPrior = nPrior; +} + + +/****************************************************************************\ +* Metodi di RMGfxBuffer +\****************************************************************************/ + +RMGfxBuffer::RMGfxBuffer() { + m_dimx = m_dimy = 0; + m_bUseDDraw = false; + m_origBuf = m_buf = NULL; +} + +RMGfxBuffer::~RMGfxBuffer() { + Destroy(); +} + +void RMGfxBuffer::Create(int dimx, int dimy, int nBpp, bool bUseDDraw) { + // Distruggi il buffer se esiste di gia' + if (m_buf != NULL) + Destroy(); + + // Copia i parametri nei membri privati + m_dimx = dimx; + m_dimy = dimy; + m_bUseDDraw = bUseDDraw; + + if (!m_bUseDDraw) { + // Alloca il buffer + m_origBuf = m_buf = new byte[m_dimx * m_dimy * nBpp / 8]; + assert(m_buf != NULL); + Common::fill(m_origBuf, m_origBuf + m_dimx * m_dimy * nBpp / 8, 0); + } +} + +void RMGfxBuffer::Destroy(void) { + if (!m_bUseDDraw) { + if (m_origBuf != NULL && m_origBuf == m_buf) { + delete[] m_origBuf; + m_origBuf = m_buf = NULL; + } + } +} + +void RMGfxBuffer::Lock(void) { + if (m_bUseDDraw) { + // Gestisce l'accelerazione + } +} + +void RMGfxBuffer::Unlock(void) { + if (m_bUseDDraw) { + // Gestisce l'accelerazione + } +} + +void RMGfxBuffer::OffsetY(int nLines, int nBpp) { + m_buf += nLines*Dimx() * nBpp / 8; +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: +* +* Description: +* +* Input: +* +* Return: +* +\****************************************************************************/ + +int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + Create(dimx, dimy, Bpp()); + CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); + + // Richiama la funzione di preparazione della surface (ereditata) + PrepareImage(); + + return dimx * dimy * Bpp() / 8; +} + + +void RMGfxSourceBuffer::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { + Create(dimx, dimy,Bpp()); + ds.Read(m_buf, dimx * dimy*Bpp() / 8); + + // Richiama la funzione di preparazione della surface (ereditata) + PrepareImage(); +} + +RMGfxSourceBuffer::~RMGfxSourceBuffer() { +} + +void RMGfxSourceBuffer::PrepareImage(void) { + // Non fa nulla: puo' essere overloadata se necessaria +} + +bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer* buf) { + int destw, desth; + +/* + OBSOLETE CODE: + + if (buf == NULL) + { + destw=RM_SX; + desth=RM_SY; + } + else + { + destw = buf->Dimx(); + desth = buf->Dimy(); + } +*/ + destw = buf->Dimx(); + desth = buf->Dimy(); + + if (!bUseSrc) { + u = v = 0; + width = m_dimx; + height = m_dimy; + } + + if (x1 > destw - 1) return false; + if (y1 > desth - 1) return false; + + if (x1 < 0) { + width += x1; + if (width < 0) return false; + u -= x1; + x1 = 0; + } + + if (y1 < 0) { + height += y1; + if (height < 0) return false; + v -= y1; + y1 = 0; + } + + if (x1 + width - 1 > destw - 1) + width = destw - x1; + + if (y1 + height - 1 > desth - 1) + height = desth - y1; + + return true; +} + + +/****************************************************************************\ +* Metodi di RMGfxWoodyBuffer +\****************************************************************************/ + +RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { + +} + +void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Prima si fa disegnare tramite la propria OT list + DrawOT(); + + // Poi disegna se stesso nel target buffer + RMGfxSourceBuffer16::Draw(bigBuf, prim); +} + + + +/****************************************************************************\ +* Metodi di RMGfxTargetBuffer +\****************************************************************************/ + +RMGfxClearTask RMGfxTargetBuffer::taskClear; + +RMGfxTargetBuffer::RMGfxTargetBuffer() { + otlist = NULL; +// InitializeCriticalSection(&csModifyingOT); +} + +RMGfxTargetBuffer::~RMGfxTargetBuffer() { + ClearOT(); +// DeleteCriticalSection(&csModifyingOT); +} + + +void RMGfxTargetBuffer::ClearOT(void) { + OTList *cur, *n; + + g_system->lockMutex(csModifyingOT); + + cur = otlist; + + while (cur != NULL) { + cur->prim->m_task->Unregister(); + delete cur->prim; + n = cur->next; + delete cur; + cur = n; + } + + otlist = NULL; + + g_system->unlockMutex(csModifyingOT); +} + +void RMGfxTargetBuffer::DrawOT(void) { + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + + prev = NULL; + cur = otlist; + + // Lock del buffer per accederci + Lock(); + g_system->lockMutex(csModifyingOT); + + while (cur != NULL) { + // Richiama la draw sul task, passandogli una copia della primitiva + myprim=cur->prim->Duplicate(); + cur->prim->m_task->Draw(*this, myprim); + delete myprim; + + // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist + if (cur->prim->m_task->RemoveThis()) { + // Deregistra il task + cur->prim->m_task->Unregister(); + + // Cancella il task liberando la memoria + delete cur->prim; + next=cur->next; + delete cur; + + // Se era il primo elemento, aggiorna la testa della lista + if (prev == NULL) + otlist = next; + // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente + else + prev->next = next; + + cur = next; + } else { + // Aggiorna il puntatore al precedente e scorre la lista + prev = cur; + cur = cur->next; + } + } + + g_system->unlockMutex(csModifyingOT); + + // Unlock dopo la scrittura + Unlock(); +} + +void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { + int nPrior; + OTList *cur, *n; + + g_system->lockMutex(csModifyingOT); + + // Avverte che e' in lista di OT + prim->m_task->Register(); + + // Controlla la sua priorita' + nPrior = prim->m_task->Priority(); + n = new OTList(prim); + + // Lista vuota + if (otlist == NULL) { + otlist = n; + otlist->next = NULL; + } + // Inserimento in testa + else if (nPrior < otlist->prim->m_task->Priority()) + { + n->next = otlist; + otlist = n; + } else { + cur = otlist; + while (cur->next != NULL && nPrior > cur->next->prim->m_task->Priority()) + cur=cur->next; + + n->next = cur->next; + cur->next = n; + } + + g_system->unlockMutex(csModifyingOT); +} + +/****************************************************************************\ +* Metodi di RMGfxSourceBufferPal +\****************************************************************************/ + +RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { + +} + +int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { + int i; + + if (bSwapped) + for (i = 0; i < (1 << Bpp()); i++) { + m_pal[i * 3 + 0] = buf[i * 3 + 2]; + m_pal[i * 3 + 1] = buf[i * 3 + 1]; + m_pal[i * 3 + 2] = buf[i * 3 + 0]; + } + else + CopyMemory(m_pal,buf,(1<> 3) << 10) | + (((int)m_pal[i * 3 + 1] >> 3) << 5) | + (((int)m_pal[i * 3 + 2] >> 3) << 0); + } +} + +int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + int read; + + // Carica l'immagine RAW + read = RMGfxSourceBuffer::Init(buf, dimx, dimy); + + // Carica la palette se necessario + if (bLoadPalette) + read += LoadPaletteWA(&buf[read]); + + return read; +} + +void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + // Carica l'immagine RAW + RMGfxSourceBuffer::Init(ds, dimx, dimy); + + // Carica la palette se necessario + if (bLoadPalette) { + byte *suxpal = new byte[256 * 3]; + ds.Read(suxpal, 256 * 3); + LoadPaletteWA(suxpal); + delete[] suxpal; + } +} + + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer4 +\****************************************************************************/ + +void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +} + + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8 +\****************************************************************************/ + +RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { + +} + +void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int x, y, width, height, u, v; + int bufx = bigBuf.Dimx(); + uint16 *buf = bigBuf; + byte *raw = m_buf; + + // Destination nel buffer + RMRect dst; + if (prim->HaveDst()) + dst=prim->Dst(); + + // Esegue il clip + if (prim->HaveSrc()) { + u = prim->Src().x1; + v = prim->Src().y1; + + width = prim->Src().Width(); + height = prim->Src().Height(); + } + + if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + return; + + // Offset iniziale nel buffer + buf += dst.y1 * bufx + dst.x1; + + // Passaggio normale + if (m_bTrasp0) { + for (y = 0; y < height; y++) { + raw = m_buf + (y + v) * m_dimx + u; + + for (x = 0; x < width; x++) { + if (*raw) *buf = m_palFinal[*raw]; + buf++; + raw++; + } + + buf += bufx - width; + } + } else { + for (y = 0; y < height; y++) { + raw = m_buf + (y + v) * m_dimx + u; + + for (x = 0;x> 10) & 0x1F) +#define GETGREEN(x) (((x) >> 5) & 0x1F) +#define GETBLUE(x) ((x) & 0x1F) + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8AB +\****************************************************************************/ + +RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { + +} + +inline int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) +{ + int r,g,b; + + r = (GETRED(fore) >> 2) + (GETRED(back) >> 1); + g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1); + b = (GETBLUE(fore) >> 2) + (GETBLUE(back) >> 1); + + if (r > 0x1F) r = 0x1F; + if (g > 0x1F) g = 0x1F; + if (b > 0x1F) b = 0x1F; + + return (r<<10)|(g<<5)|b; +} + + +void RMGfxSourceBuffer8AB::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int x, y, width, height, u, v; + int bufx=bigBuf.Dimx(); + uint16 *buf = bigBuf; + byte *raw = m_buf; + + // Destination nel buffer + RMRect dst; + if (prim->HaveDst()) + dst = prim->Dst(); + + // Esegue il clip + if (prim->HaveSrc()) { + u=prim->Src().x1; + v=prim->Src().y1; + + width = prim->Src().Width(); + height = prim->Src().Height(); + } + + if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + return; + + // Offset iniziale nel buffer + buf += dst.y1 * bufx + dst.x1; + + // Passaggio normale + if (m_bTrasp0) { + for (y = 0; y < height; y++) { + raw = m_buf + (y + v) * m_dimx + u; + + for (x = 0; x < width; x++) { + if (*raw) *buf = CalcTrasp(m_palFinal[*raw], *buf); + buf++; + raw++; + } + + buf += bufx - width; + } + } else { + for (y = 0; y < height; y++) { + raw = m_buf + (y+v) * m_dimx + u; + + for (x = 0; x < width; x += 2) { + buf[0] = CalcTrasp(m_palFinal[raw[0]], buf[0]); + buf[1] = CalcTrasp(m_palFinal[raw[1]], buf[1]); + + buf += 2; + raw += 2; + } + + buf += bufx - width; + } + } + + return; +} + + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLE +\****************************************************************************/ + +byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; + +void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) { + alphaBlendColor = color; +} + +RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { + alphaBlendColor = -1; + bNeedRLECompress = true; +} + +RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { + if (m_buf != NULL) { + delete m_buf; + m_buf = NULL; + } +} + + +int RMGfxSourceBuffer8RLE::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBufferPal::Init(buf, dimx, dimy, bLoadPalette); +} + +void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + if (bNeedRLECompress) { + RMGfxSourceBufferPal::Init(ds, dimx, dimy,bLoadPalette); + } else { + int size; + + ds >> size; + m_buf = new byte[size]; + ds.Read(m_buf, size); + + m_dimx = dimx; + m_dimy = dimy; + } +} + +void RMGfxSourceBuffer8RLE::PreparePalette(void) { + // Richiama il metodo padre + RMGfxSourceBuffer8::PreparePalette(); + + // Si salva gli RGB di alpha blending + if (alphaBlendColor != -1) { + alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; + alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; + alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; + } +} + +void RMGfxSourceBuffer8RLE::PrepareImage(void) { + // Richiama il metodo padre + RMGfxSourceBuffer::PrepareImage(); + + // Comprime + CompressRLE(); +} + +void RMGfxSourceBuffer8RLE::SetAlreadyCompressed(void) { + bNeedRLECompress = false; +} + + +void RMGfxSourceBuffer8RLE::CompressRLE(void) { + int x, y; + byte *startline; + byte *cur; + byte curdata; + byte *src; + byte *startsrc; + int rep; + + // Esegue la compressione RLE, per linee + cur = MegaRLEBuf; + src = m_buf; + for (y = 0;y < m_dimy; y++) { + // Si salva l'inizio della linea + startline = cur; + + // Lascia lo spazio per la lunghezza della linea + cur += 2; + + // Si parte dallo spazio vuoto + curdata = 0; + rep = 0; + startsrc = src; + for (x = 0; x < m_dimx;) { + if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) + || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { + src++; + rep++; + x++; + } else { + if (curdata == 0) { + RLEWriteTrasp(cur, rep); + curdata++; + } + else if (curdata == 1) { + RLEWriteAlphaBlend(cur, rep); + curdata++; + } else { + RLEWriteData(cur, rep, startsrc); + curdata = 0; + } + + rep = 0; + startsrc = src; + } + } + + // Dati in sospeso? + if (curdata == 1) { + RLEWriteAlphaBlend(cur, rep); + RLEWriteData(cur, 0, NULL); + } + + if (curdata == 2) { + RLEWriteData(cur, rep, startsrc); + } + + // Fine linea + RLEWriteEOL(cur); + + // Scrive la lunghezza della linea + WRITE_LE_UINT16(startline, (uint16)(cur - startline)); + } + + // Cancella l'immagine originale + delete[] m_buf; + + // Ci copia l'immagine compressa + x = cur - MegaRLEBuf; + m_buf = new byte[x]; + CopyMemory(m_buf, MegaRLEBuf, x); +} + +void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int y; + byte *src; + uint16 *buf = bigBuf; + int x1, y1, u, v, width, height; + + // Clippiamo lo sprite + x1=prim->Dst().x1; + y1=prim->Dst().y1; + if (!Clip2D(x1,y1,u,v,width,height,false,&bigBuf)) + return; + + // Andiamo avanti di V linee nell'immagine RLE + src = m_buf; + for (y = 0;yIsFlipped()) + { +// Annulliamo il clipping orizzontale +// width = m_dimx; +// x1=prim->Dst().x1; + + // Flippiamo il clipping + u = m_dimx - (width+u); + x1 = (prim->Dst().x1 + m_dimx - 1) - u; + + for (y = 0;y 0) { + CopyMemory(cur, src, rep); + cur += rep; + src += rep; + } + + return; +} + +void RMGfxSourceBuffer8RLEByte::RLEWriteEOL(byte *&cur) { + *cur ++= 0xFF; +} + +void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b; + + if (nStartSkip == 0) + goto RLEByteDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = *src++; + if (n == 0xFF) + return; + + if (n >= nStartSkip) { + dst += n - nStartSkip; + nLength -= n - nStartSkip; + if (nLength > 0) + goto RLEByteDoAlpha; + else + return; + } + nStartSkip -= n; + + + assert(nStartSkip > 0); + + // ALPHA + n = *src++; + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEByteDoAlpha2; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // DATA + n = *src++; + if (n >= nStartSkip) { + src += nStartSkip; + n -= nStartSkip; + goto RLEByteDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEByteDoTrasp: + // Via il trasp di merda + n = *src++; + + // EOL? + if (n == 0xFF) + return; + + dst += n; + nLength -= n; + if (nLength <= 0) + return; + +RLEByteDoAlpha: + // Alpha + n = *src++; + +RLEByteDoAlpha2: + if (n > nLength) + n = nLength; + for (i = 0; i < n; i++) + { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst++=(r<<10)|(g<<5)|b; + } + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + +//RLEByteDoCopy: + // Copia la roba + n = *src++; + +RLEByteDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) + *dst ++= m_palFinal[*src++]; + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + } +} + +void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b; + + if (nStartSkip == 0) + goto RLEByteFlippedDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = *src++; + if (n == 0xFF) + return; + + if (n >= nStartSkip) { + dst -= n - nStartSkip; + nLength -= n - nStartSkip; + if (nLength > 0) + goto RLEByteFlippedDoAlpha; + else + return; + } + nStartSkip -= n; + + + assert(nStartSkip > 0); + + // ALPHA + n = *src++; + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEByteFlippedDoAlpha2; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // DATA + n = *src++; + if (n >= nStartSkip){ + src += nStartSkip; + n -= nStartSkip; + goto RLEByteFlippedDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEByteFlippedDoTrasp: + // Via il trasp di merda + n = *src++; + + // EOL? + if (n == 0xFF) + return; + + dst -= n; + nLength -= n; + if (nLength <= 0) + return; + +RLEByteFlippedDoAlpha: + // Alpha + n = *src++; + +RLEByteFlippedDoAlpha2: + if (n > nLength) + n = nLength; + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst--=(r << 10) | (g << 5) | b; + } + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + +//RLEByteFlippedDoCopy: + // Copia la roba + n = *src++; + +RLEByteFlippedDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) + *dst --= m_palFinal[*src++]; + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + } +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLEWord +\****************************************************************************/ + +RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord(){ + +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteTrasp(byte *&cur, int rep) { + WRITE_LE_UINT16(cur, rep); + cur += 2; +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteAlphaBlend(byte *&cur, int rep) { + WRITE_LE_UINT16(cur, rep); + cur += 2; +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { + WRITE_LE_UINT16(cur, rep); + cur += 2; + + if (rep > 0) { + CopyMemory(cur, src,rep); + cur += rep; + src +=rep; + } +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteEOL(byte *&cur) { + *cur ++= 0xFF; + *cur ++= 0xFF; +} + +void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b; + + if (nStartSkip == 0) + goto RLEWordDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = READ_LE_UINT16(src); + src += 2; + + if (n == 0xFFFF) + return; + + if (n >= nStartSkip) { + dst += n - nStartSkip; + nLength -= n - nStartSkip; + + if (nLength > 0) + goto RLEWordDoAlpha; + else + return; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // ALPHA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEWordDoAlpha2; + } + nStartSkip -= n; + + // DATA + n = READ_LE_UINT16(src); + src += 2; + + if (n>=nStartSkip) + { + src += nStartSkip; + n -= nStartSkip; + goto RLEWordDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) + { +RLEWordDoTrasp: + // Via il trasp di merda + n = READ_LE_UINT16(src); + src += 2; + + // EOL? + if (n == 0xFFFF) + return; + + dst += n; + + nLength -= n; + if (nLength <= 0) + return; + +RLEWordDoAlpha: + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoAlpha2: + + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst++=(r<<10)|(g<<5)|b; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + +//RLEWordDoCopy: + // Copia la roba + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) + *dst ++= m_palFinal[*src++]; + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + + } +} + +void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i,n; + int r,g,b; + + if (nStartSkip == 0) + goto RLEWordFlippedDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = READ_LE_UINT16(src); + src += 2; + + if (n == 0xFFFF) + return; + + if (n>=nStartSkip) + { + dst -= n - nStartSkip; + nLength -= n - nStartSkip; + + if (nLength > 0) + goto RLEWordFlippedDoAlpha; + else + return; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // ALPHA + n = READ_LE_UINT16(src); + src += 2; + + if (n>=nStartSkip) + { + n -= nStartSkip; + goto RLEWordFlippedDoAlpha2; + } + nStartSkip -= n; + + // DATA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) { + src += nStartSkip; + n -= nStartSkip; + goto RLEWordFlippedDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEWordFlippedDoTrasp: + // Via il trasp di merda + n = READ_LE_UINT16(src); + src += 2; + + // EOL? + if (n == 0xFFFF) + return; + + dst -= n; + + nLength -= n; + if (nLength <= 0) + return; + +RLEWordFlippedDoAlpha: + n = READ_LE_UINT16(src); + src += 2; + +RLEWordFlippedDoAlpha2: + + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst--=(r << 10) | (g << 5) | b; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + +//RLEWordFlippedDoCopy: + // Copia la roba + n = READ_LE_UINT16(src); + src += 2; + +RLEWordFlippedDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0;i 0); + } +} + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLEWord +\****************************************************************************/ + +RMGfxSourceBuffer8RLEWordAB::~RMGfxSourceBuffer8RLEWordAB() { + +} + +void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b, r2, g2, b2; + + if (!bCfgTransparence) { + RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); + return; + } + + if (nStartSkip == 0) + goto RLEWordDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = READ_LE_UINT16(src); + src += 2; + + if (n == 0xFFFF) + return; + + if (n >= nStartSkip) { + dst += n - nStartSkip; + nLength -= n - nStartSkip; + + if (nLength > 0) + goto RLEWordDoAlpha; + else + return; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // ALPHA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEWordDoAlpha2; + } + nStartSkip -= n; + + // DATA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) + { + src += nStartSkip; + n -= nStartSkip; + goto RLEWordDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEWordDoTrasp: + // Via il trasp di merda + n = READ_LE_UINT16(src); + src += 2; + + // EOL? + if (n == 0xFFFF) + return; + + dst += n; + + nLength -= n; + if (nLength <= 0) + return; + +RLEWordDoAlpha: + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoAlpha2: + + if (n > nLength) + n = nLength; + + // @@@ NON DOVREBBE ESSERCI!!!!! + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst++=(r<<10)|(g<<5)|b; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + +//RLEWordDoCopy: + // Copia la roba + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r2=(m_palFinal[*src] >> 10) & 0x1F; + g2=(m_palFinal[*src] >> 5) & 0x1F; + b2 = m_palFinal[*src] & 0x1F; + + r=(r >> 1) + (r2 >> 1); + g=(g >> 1) + (g2 >> 1); + b=(b >> 1) + (b2 >> 1); + + *dst ++= (r << 10) | (g << 5) | b; + src++; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + + } +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8AA +\****************************************************************************/ + +byte RMGfxSourceBuffer8AA::MegaAABuf[256*1024]; +byte RMGfxSourceBuffer8AA::MegaAABuf2[64*1024]; + +void RMGfxSourceBuffer8AA::PrepareImage(void) { + // Richiama il metodo padre + RMGfxSourceBuffer::PrepareImage(); + + // Prepara il buffer di antialiasing + CalculateAA(); +} + + +void RMGfxSourceBuffer8AA::CalculateAA(void) { + // Io suxo tu suxi egli suxa noi suxiamo voi suxate essi suxano ---> ANTI ALIASING SUX! + // ************************************************************ + + int x,y; + byte *src, *srcaa; + + /* Prima passata: cerchiamo i bordi */ + Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); + + src = m_buf; + srcaa=MegaAABuf; + for (y = 0;y < m_dimy; y++) { + for (x = 0; x < m_dimx; x++) { + if (*src == 0) { + if ((y > 0 && src[-m_dimx] != 0) || + (y 0 && src[-1] != 0) || + (x 0 && srcaa[-m_dimx]==1) || + (y 0 && srcaa[-1]==1) || + (xDst().x1; + y1 = prim->Dst().y1; + if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) + return; + + // Andiamo avanti di V linee nell'immagine RLE + src = m_buf; + for (y = 0; y < v; y++) + src += READ_LE_UINT16(src); + + // Annulliamo il clipping orizzontale + + // Flippiamo il clipping + if (prim->IsFlipped()) { + u = m_dimx - (width + u); + x1 = (prim->Dst().x1 + m_dimx - 1) - u; + } +// width = m_dimx; +// x1=prim->Dst().x1; + + + // Posizionamoci nel buffer di destinazione + buf = bigBuf; + buf += y1 * bigBuf.Dimx(); + + if (prim->IsFlipped()) + step = -1; + else + step = 1; + + // Looppone + buf += bigBuf.Dimx(); // skippa la prima linea + for (y = 1; y < height - 1; y++) { +/* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else +*/ + mybuf=&buf[x1]; + + for (x = 0; x < width; x++, mybuf += step) + if (m_aabuf[(y + v) * m_dimx + x + u] == 2 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + + r += GETRED(mybuf[0]); + g += GETGREEN(mybuf[0]); + b += GETBLUE(mybuf[0]); + + r /= 5; + g /= 5; + b /= 5; + + if (r > 31) r = 31; + if (g > 31) g = 31; + if (b > 31) b = 31; + + mybuf[0]=(r<<10)|(g<<5)|b; + } + + // Skippa alla linea successiva + buf += bigBuf.Dimx(); + } + +// Posizionamoci nel buffer di destinazione + buf = bigBuf; + buf += y1*bigBuf.Dimx(); + + // Looppone + buf+=bigBuf.Dimx(); + for (y = 1; y < height - 1; y++) { +/* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else +*/ + mybuf=&buf[x1]; + + for (x = 0;x < width; x++, mybuf += step) + if (m_aabuf[(y + v) * m_dimx + x + u] == 1 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + + r += GETRED(mybuf[0]) * 2; + g += GETGREEN(mybuf[0]) * 2; + b += GETBLUE(mybuf[0]) * 2; + + r /= 6; + g /= 6; + b /= 6; + + if (r > 31) r = 31; + if (g > 31) g = 31; + if (b > 31) b = 31; + + mybuf[0]=(r<<10)|(g<<5)|b; + } + + // Skippa alla linea successiva + buf += bigBuf.Dimx(); + } +} + + + +void RMGfxSourceBuffer8AA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMGfxSourceBuffer8::Draw(bigBuf, prim); + DrawAA(bigBuf, prim); +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLEAA +\****************************************************************************/ + +RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { + +} + +void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { + RMGfxSourceBuffer::PrepareImage(); + CalculateAA(); + CompressRLE(); +} + +void RMGfxSourceBuffer8RLEByteAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); + if (bCfgAntiAlias) + DrawAA(bigBuf,prim); +} + +int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); +} + +void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); + + if (!bNeedRLECompress) { + // Carica la maschera di antialiasing + m_aabuf = new byte[dimx * dimy]; + ds.Read(m_aabuf, dimx * dimy); + } +} + + +RMGfxSourceBuffer8RLEWordAA::~RMGfxSourceBuffer8RLEWordAA() { + +} + +void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { + RMGfxSourceBuffer::PrepareImage(); + CalculateAA(); + CompressRLE(); +} + +void RMGfxSourceBuffer8RLEWordAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); + if (bCfgAntiAlias) + DrawAA(bigBuf,prim); +} + +int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy,bLoadPalette); +} + +void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); + + if (!bNeedRLECompress) { + // Carica la maschera di antialiasing + m_aabuf = new byte[dimx * dimy]; + ds.Read(m_aabuf, dimx * dimy); + } +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer16 +\****************************************************************************/ + +RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { + m_bTrasp0=bTrasp0; +} + +RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { +} + +void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int x,y; + uint16 *buf = bigBuf; + uint16 *raw = (uint16*)m_buf; + int dimx, dimy; + int u,v; + int x1,y1; + + dimx = m_dimx; + dimy = m_dimy; + u = 0; + v = 0; + x1 = 0; + y1 = 0; + + if (prim->HaveSrc()) { + u = prim->Src().x1; + v = prim->Src().y1; + dimx = prim->Src().Width(); + dimy = prim->Src().Height(); + } + + if (prim->HaveDst()) { + x1 = prim->Dst().x1; + y1 = prim->Dst().y1; + } + + if (!Clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) + return; + + raw += v * m_dimx+u; + buf += y1 * bigBuf.Dimx() + x1; + + if (m_bTrasp0) { + for (y = 0; y < dimy; y++) { + for (x = 0; x < dimx;) { + while (x>= 3; + g >>= 3; + b >>= 3; + wFillColor = (r << 10) | (g << 5) | b; +} + +void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int i, j; + uint16 *buf = bigBuf; + RMRect rcDst; + + // Prende il rettangolo di destinazione + rcDst = prim->Dst(); + buf += rcDst.y1*bigBuf.Dimx() + rcDst.x1; + + // Fa il suo bravo loop di put + for (j = 0; j < rcDst.Height(); j++) { + for (i = 0; i < rcDst.Width(); i++) + *buf ++= wFillColor; + + buf += bigBuf.Dimx() - rcDst.Width(); + } +} + } // End of namespace Tony -- cgit v1.2.3 From cb1b1c453d133104511afaecad28434231a7be24 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 13:14:46 +1000 Subject: TONY: Added GfxCoreInline.hpp methods --- engines/tony/gfxcore.cpp | 143 +++++++++++++++++++++++++++++++++++++++++++++-- engines/tony/gfxcore.h | 2 +- 2 files changed, 140 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index dfdee30ac6..4842126c59 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -46,6 +46,7 @@ **************************************************************************/ #include "tony/gfxEngine.h" +#include "tony/mpal/mpalutils.h" namespace Tony { @@ -133,10 +134,22 @@ void RMGfxBuffer::Unlock(void) { } void RMGfxBuffer::OffsetY(int nLines, int nBpp) { - m_buf += nLines*Dimx() * nBpp / 8; + m_buf += nLines* Dimx() * nBpp / 8; } +inline RMGfxBuffer::operator byte *() { + return m_buf; +} + +inline RMGfxBuffer::operator void *() { + return (void *)m_buf; +} + +inline RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { + Create(dimx, dimy, nBpp, bUseDDraw); +} + /****************************************************************************\ * Metodi di RMGfxSourceBuffer \****************************************************************************/ @@ -231,6 +244,20 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int return true; } +/****************************************************************************\ +* +* Function: void RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy); +* +* Description: Carica una surface partendo dall'ID della risorsa +* +* Input: uint32 resID ID della risorsa +* int dimx, dimy Dimensione del buffer +* +\****************************************************************************/ + +inline int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { + return Init(RMRes(resID), dimx, dimy, bLoadPalette); +} /****************************************************************************\ * Metodi di RMGfxWoodyBuffer @@ -248,6 +275,14 @@ void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMGfxSourceBuffer16::Draw(bigBuf, prim); } +inline RMGfxWoodyBuffer::RMGfxWoodyBuffer() { + +} + +inline RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) + : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { + +} /****************************************************************************\ @@ -372,6 +407,11 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { g_system->unlockMutex(csModifyingOT); } +inline void RMGfxTargetBuffer::AddClearTask(void) { + AddPrim(new RMGfxPrimitive(&taskClear)); +} + + /****************************************************************************\ * Metodi di RMGfxSourceBufferPal \****************************************************************************/ @@ -397,8 +437,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { return (1<> 10) & 0x1F) @@ -1827,6 +1919,29 @@ void RMGfxSourceBuffer16::PrepareImage(void) { } +inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) + : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { + SetPriority(0); +} + +/****************************************************************************\ +* +* Function: int RMGfxSourceBuffer16::Bpp(); +* +* Description: Ritorna il numero di bit per pixel della surface +* +* Return: Bit per pixel +* +\****************************************************************************/ + +inline int RMGfxSourceBuffer16::Bpp() { + return 16; +} + +inline void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { + RMGfxBuffer::Create(dimx,dimy,16,bUseDDraw); +} + /****************************************************************************\ * Metodi di RMGfxBox \****************************************************************************/ @@ -1860,4 +1975,24 @@ void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } + +/****************************************************************************\ +* Metodi di RMGfxClearTask +\****************************************************************************/ + +inline int RMGfxClearTask::Priority() { + // Priorita' massima (deve essere fatto per primo) + return 1; +} + +inline void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { + // Pulisce tutto il target buffer + Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); +} + +inline bool RMGfxClearTask::RemoveThis() { + // Il task di clear si disattiva sempre + return true; +} + } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index b6a10ab778..708e3adfa8 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -294,7 +294,7 @@ public: int LoadPaletteWA(uint32 resID, bool bSwapped = false); int LoadPaletteWA(const byte *buf, bool bSwapped = false); int LoadPalette(uint32 resID); - int LoadPalette(byte *buf); + int LoadPalette(const byte *buf); }; -- cgit v1.2.3 From fde1f13676273405cd2d686f1e0ae53834c049ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 13:32:09 +1000 Subject: TONY: Implemented stubs for Input.cpp methods --- engines/tony/input.cpp | 253 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 367317bd88..72c7bf06f7 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,6 +49,259 @@ namespace Tony { +#define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } +void RMInput::DIInit(/*HINSTANCE hInst*/) { +#ifdef REFACTOR_ME + HRESULT err; + + // Crea l'oggetto madre + err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Crea il device del mouse + // ************************ + err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il data format + err=m_DIDMouse->SetDataFormat(&c_dfDIMouse); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il cooperative level + err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Crea il device della tastiera + // ***************************** + err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il data format + err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il cooperative level + err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } +#endif +} + +void RMInput::SwitchFullscreen(bool bFull) { +#ifdef REFACTOR_ME + HRESULT err; + + // Il camping del mouse e' attivo solo in fullscreen + m_bClampMouse=bFull; + + // Prima di tutto leviamo l'acquiring ai device, altrimenti non possiamo cambiare il + // cooperative level + Unacquire(); + + if (bFull) + { + // Setta il cooperative level + err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } + } + else + { + // Setta il cooperative level + err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } + } +#endif +} + +void RMInput::DIClose(void) +{ +#ifdef REFACTOR_ME + DIRELEASE(m_DIDMouse); + DIRELEASE(m_DI); +#endif +} + + +bool RMInput::Acquire(void) { +#ifdef REFACTOR_ME + HRESULT err; + + if (m_DIDMouse == NULL) + return true; + + // Inizializza la posizione del mouse + POINT pt; + RECT rc; + GetWindowRect(theGame.m_wnd,&rc); + GetCursorPos(&pt); + m_mX=pt.x-rc.left-GetSystemMetrics(SM_CXDLGFRAME); + m_mY=pt.y-rc.top-(GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION)); + + err=m_DIDMouse->Acquire(); + if (err!=DI_OK) + return false; + + err=m_DIDKeyboard->Acquire(); + if (err!=DI_OK) + return false; +#endif + return true; +} + +void RMInput::Unacquire(void) { +#ifdef REFACTOR_ME + if (m_DIDMouse!=NULL) + m_DIDMouse->Unacquire(); + + if (m_DIDKeyboard!=NULL) + m_DIDKeyboard->Unacquire(); +#endif +} + + +void RMInput::GDIControl(bool bCon) { +#ifdef REFACTOR_ME + if (bCon) + { + Unacquire(); + ShowCursor(true); + } + else + { + ShowCursor(false); + Acquire(); + } +#endif +} + +void RMInput::Poll(void) { +#ifdef REFACTOR_ME + HRESULT err; + bool mLastLeft, mLastRight; + + mLastLeft=MouseLeft(); + mLastRight=MouseRight(); + m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; + + // Legge lo stato del mouse + while (1) + { + ZeroMemory(&m_mState,sizeof(m_mState)); + err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); + if (err==DI_OK) + break; + else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) + { + ZeroMemory(&m_mState,sizeof(m_mState)); + // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere + if (!Acquire()) + return; + } + else + break; + } + + // Aggiorna le coordinate del mouse + m_mX+=m_mState.lX; + m_mY+=m_mState.lY; + + // Clamp dei valori sui bordi della finestra + if (m_bClampMouse) + { + if (m_mX<0) m_mX=0; + if (m_mY<0) m_mY=0; + if (m_mX>=640) m_mX=639; + if (m_mY>=480) m_mY=479; + } + + // Controlla se e' cambiato lo stato dei bottoni + if (mLastLeft && !MouseLeft()) + m_bLeftReleaseMouse=true; + + if (!mLastLeft && MouseLeft()) + m_bLeftClickMouse=true; + + if (mLastRight && !MouseRight()) + m_bRightReleaseMouse=true; + + if (!mLastRight && MouseRight()) + m_bRightClickMouse=true; +#endif +} + + +RMInput::RMInput() { + m_bClampMouse = false; +} + +RMInput::~RMInput() { + +} + +void RMInput::Init(/*HINSTANCE hInst*/) { +#ifdef REFACTOR_ME + DIInit(hInst); +#ifdef STARTFULLSCREEN + SwitchFullscreen(true); +#endif + Acquire(); +#endif +} + +void RMInput::Close(void) { + Unacquire(); + DIClose(); +} + + +bool RMInput::MouseLeft() { + return false; +#ifdef REFACTOR_ME + return (m_mState.rgbButtons[0] & 0x80); +#endif +} + +bool RMInput::MouseRight() { + return false; +#ifdef REFACTOR_ME + return (m_mState.rgbButtons[1] & 0x80); +#endif +} } // End of namespace Tony -- cgit v1.2.3 From ba2711b5e39e495c4cfb1187710605bb9fbf10b1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 21:43:00 +1000 Subject: TONY: Implemented methods of sound.cpp (mostly stubbed out) --- engines/tony/input.h | 2 +- engines/tony/sound.cpp | 2230 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/sound.h | 17 +- 3 files changed, 2243 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/input.h b/engines/tony/input.h index 554b10628b..bff6dcd396 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -65,7 +65,7 @@ private: private: // Inizializza DirectInput - void DIInit(uint32 hInst); + void DIInit(/*uint32 hInst*/); // Deinizializza DirectInput void DIClose(void); diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 5d940b3145..e757ac4115 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -45,10 +45,2240 @@ * * **************************************************************************/ +#include "common/textconsole.h" #include "tony/game.h" +#include "tony/tony.h" namespace Tony { +extern bool bCfgMusic; +extern bool bCfgSFX; +extern bool bCfgDubbing; +extern int nCfgSFXVolume; +extern int nCfgMusicVolume; +extern int nCfgDubbingVolume; +/****************************************************************************\ +* Defines +\****************************************************************************/ + +/* Massimo numero di bytes da decodificare in una singola chiamata a CODEC */ +#define MAXDECODESIZE (44100 * 2 * 2) + +#define RELEASE(x) {if ((x) != NULL) { (x)->Release(); x = NULL; }} + +/****************************************************************************\ +***************************************************************************** +* class CODEC (ABSTRACT) +* ----------- +* Description: classe base per CODEC. +***************************************************************************** +\****************************************************************************/ + +class CODEC { +protected: + bool bEndReached; + +public: + bool bLoop; + CODEC(bool bLoop = true); + virtual ~CODEC(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; + virtual void LoopReset() = 0; + bool EndOfStream(); +}; + + +/****************************************************************************\ +***************************************************************************** +* class CODECRAW +* -------------- +* Description: CODEC di play da disco di campioni puri +***************************************************************************** +\****************************************************************************/ + +class CODECRAW : public CODEC { +public: + CODECRAW(bool bLoop = true); + virtual ~CODECRAW(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); + virtual void LoopReset(); +}; + + +/****************************************************************************\ +***************************************************************************** +* class CODECADPCM +* ---------------- +* Description: CODEC per play di compressione ADPCM +***************************************************************************** +\****************************************************************************/ + +class CODECADPCM : public CODECRAW { +protected: + byte *lpTemp; + static int indexTable[16]; + static int stepSizeTable[89]; + +public: + CODECADPCM(bool bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCM(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; + virtual void LoopReset() = 0; +}; + +class CODECADPCMSTEREO : public CODECADPCM { +protected: + int valpred[2], index[2]; + +public: + CODECADPCMSTEREO(bool bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMSTEREO(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); + virtual void LoopReset(); +}; + +class CODECADPCMMONO : public CODECADPCM { +protected: + int valpred, index; + +public: + CODECADPCMMONO(bool bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMMONO(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); + virtual void LoopReset(); +}; + +/****************************************************************************\ +* Metodi per CODEC +\****************************************************************************/ + + +/****************************************************************************\ +* +* Function: CODEC::CODEC(bool loop = true); +* +* Description: Costruttore standard. E' possibile specificare se si vuole +* attivare o disattivare il loop (che di default e' attivo). +* +* Input: bool loop true se si vuole attivare il loop, +* false per disattivarlo +* +\****************************************************************************/ + +CODEC::CODEC(bool loop) { + bLoop = loop; + bEndReached = false; +} + +CODEC::~CODEC() +{ + +} + +/****************************************************************************\ +* +* Function: bool CODEC::EndOfStream() +* +* Description: Informa se abbiamo raggiunto la fine dello stream +* +* Return: true se siamo arrivati alla fine, false altrimenti +* +\****************************************************************************/ + +bool CODEC::EndOfStream() { + return bEndReached; +} + + +/****************************************************************************\ +* Metodi per CODECRAW +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: CODECRAW::CODECRAW(bool loop = true); +* +* Description: Costruttore standard. Richiama solamente il costruttore della +* classe astratta CODEC. +* +* Input: bool loop true se si vuole attivare il loop, +* false per disattivarlo +* +\****************************************************************************/ + +CODECRAW::CODECRAW(bool loop) : CODEC(loop) { +} + +CODECRAW::~CODECRAW() { + +} + +/****************************************************************************\ +* +* Function: CODECRAW::LoopReset(); +* +* Description: Resetta il playing prima di iniziare di nuovo il file. +* Nel caso dei file RAW non fa nulla. +* +\****************************************************************************/ + +void CODECRAW::LoopReset() { +} + +/****************************************************************************\ +* +* Function: uint32 CODECRAW::Decompress(HANDLE hStream, void *lpBuf, +* uint32 dwSize) +* +* Description: Gestisce il formato RAW: semplicemente copia dal file +* stream nel buffer. +* +* Return: Se e' stata raggiunta la fine del file, indica quale byte, +* tra quelli letti, e' l'inizio del nuovo loop. Altrimenti +* il valore non e' determinato. +* +\****************************************************************************/ + +uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { +#if 0 + byte *lpBuf = (byte *)buf; + uint32 dwRead; + uint32 dwEOF; + + bEndReached = false; + dwEOF = 0; + ReadFile(hStream,lpBuf,dwSize, &dwRead, NULL); + + if (dwRead>4)&0xF; + } + else + delta=cache&0xF; + + /* Trova il nuovo indice */ + index+=indexTable[delta]; + if (index<0) index = 0; + if (index>88) index=88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign=delta&8; + delta=delta&7; + + /* Trova la differenza dal valore precedente */ + vpdiff=step>>3; + if (delta&4) vpdiff+=step; + if (delta&2) vpdiff+=step>>1; + if (delta&1) vpdiff+=step>>2; + + if (sign) + valpred-=vpdiff; + else + valpred+=vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred<-32768) + valpred=-32768; + + /* Aggiorna lo step */ + step=stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf++ = (signed short)valpred; + + bufferstep=!bufferstep; + } + + return eof/2; +#endif + return 0; +} + +uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + + bufferstep = 1; + step = stepSizeTable[index]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0;i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep=1; + step = stepSizeTable[index]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = (cache>>4)&0xF; + } else + delta=cache&0xF; + + /* Trova il nuovo indice */ + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index=88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta&8; + delta = delta&7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step >> 3; + if (delta&4) vpdiff+=step; + if (delta&2) vpdiff+=step >> 1; + if (delta&1) vpdiff+=step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred =- 32768; + + /* Aggiorna lo step */ + step = stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf ++= (signed short)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + +uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step[2]; + + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep=1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = cache & 0xF; + } else + delta = (cache >> 4) & 0xF; + + /* Trova il nuovo indice */ + index[bufferstep]+=indexTable[delta]; + if (index[bufferstep] < 0) index[bufferstep] = 0; + if (index[bufferstep] > 88) index[bufferstep] = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step[bufferstep] >> 3; + if (delta & 4) vpdiff += step[bufferstep]; + if (delta & 2) vpdiff += step[bufferstep]>>1; + if (delta & 1) vpdiff += step[bufferstep]>>2; + + if (sign) + valpred[bufferstep]-=vpdiff; + else + valpred[bufferstep]+=vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred[bufferstep] > 32767) + valpred[bufferstep] = 32767; + else if (valpred[bufferstep] < -32768) + valpred[bufferstep] = -32768; + + /* Aggiorna lo step */ + step[bufferstep] = stepSizeTable[index[bufferstep]]; + + /* Scrive il valore trovato */ + *lpBuf ++= (signed short)valpred[bufferstep]; + + bufferstep=!bufferstep; + } + + return eof / 2; +} + + +uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof,i; + int step[2]; + + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i==eof) { + LoopReset(); + bufferstep=1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = cache & 0xF; + } else + delta = (cache >> 4) & 0xF; + + /* Trova il nuovo indice */ + index[bufferstep] += indexTable[delta]; + if (index[bufferstep] < 0) index[bufferstep] = 0; + if (index[bufferstep] > 88) index[bufferstep] = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step[bufferstep]>>3; + if (delta & 4) vpdiff += step[bufferstep]; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; + + if (sign) + valpred[bufferstep]-=vpdiff; + else + valpred[bufferstep]+=vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred[bufferstep] > 32767) + valpred[bufferstep] = 32767; + else if (valpred[bufferstep] < -32768) + valpred[bufferstep] = -32768; + + /* Aggiorna lo step */ + step[bufferstep] = stepSizeTable[index[bufferstep]]; + + /* Scrive il valore trovato */ + *lpBuf ++= (signed short)valpred[bufferstep]; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + + +/****************************************************************************\ +* Metodi per FPSOUND +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: FPSOUND::FPSOUND(); +* +* Description: Costruttore di default. Inizializza gli attributi. +* +\****************************************************************************/ + +FPSOUND::FPSOUND() { + lpDS = NULL; + lpDSBPrimary = NULL; +} + + +/****************************************************************************\ +* +* Function: bool FPSOUND::Init(HWND hWnd); +* +* Description: Inizializza l'oggetto, e prepara tutto il necessario per +* creare stream e effetti sonori. +* +* Input: HWND hWnd Handle della finestra principale +* +* Return: True se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSOUND::Init(/*HWND hWnd*/) { +#ifdef REFACTOR_ME + HRESULT err; + static DSBUFFERDESC dsbdesc; + static PCMWAVEFORMAT pcmwf; + static char errbuf[128]; + + /* Salva l'handle della finestra nella variabile globale. DirectSound ha + bisogno dell'handle per effetuare il multitasking sonoro. */ + hwnd = hWnd; + + /* Di default, disabilita il sonoro. Se non troveremo problemi, lo + riabiliteremo alla fine della routine */ + bSoundSupported = false; + + /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. + In realta' sarebbe possibile richiedere una lista delle schede sonore + presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra + una perdita di tempo. */ + if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { + return false; + } + + /* Richiede le caratteristiche del driver sonoro */ + dscaps.dwSize = sizeof(dscaps); + lpDS->GetCaps(&dscaps); + + /* Controlla se siamo in emulazione, e in caso affermativo avverte l'utente */ + if ((dscaps.dwFlags & DSCAPS_EMULDRIVER)) + error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); + + /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco + sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed + eventuali player in background saranno automaticamente stoppati. + Inoltre in questo modo e' possibile settare il formato di output sonoro + del primary buffer */ + if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { + MessageBox(hwnd,"Cannot set exclusive mode!","soundInit()", MB_OK); + return false; + } + + + /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, + ma noi vogliamo il pointer al primary perche' dobbiamo settare il + formato di output */ + ZeroMemory(&dsbdesc,sizeof(dsbdesc)); + dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwFlags=DSBCAPS_CTRLVOLUME|DSBCAPS_PRIMARYBUFFER; + if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { + MessageBox(hwnd,"Cannot create primary buffer!","soundInit()", MB_OK); + return false; + } + + /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz + stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda + sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. + Inoltre in seguito sara' possibile lasciare scegliere all'utente il + formato da utilizzare */ + pcmwf.wBitsPerSample = ((dscaps.dwFlags&DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = ((dscaps.dwFlags&DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); + pcmwf.wf.nSamplesPerSec = 44100; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { + wsprintf(errbuf,"Error setting the output format (%lx)",err); + MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + return false; + } + + /* Controlla che il driver DirectSound supporti buffer secondari con + play di stream 16bit, 44khz stereo */ + if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { + wsprintf(errbuf,"Driver does not support 16bit 44khz stereo mixing! (%lu)",dscaps.dwMaxSecondarySampleRate); + MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + return false; + } + + /* Tutto OK. */ + bSoundSupported = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: FPSOUND::~FPSOUND(); +* +* Description: Deinizializza l'oggetto, disallocando la memoria. +* +\****************************************************************************/ + +FPSOUND::~FPSOUND() { +#ifdef REFACTOR_ME + RELEASE(lpDSBPrimary); + RELEASE(lpDS); +#endif +} + + +/****************************************************************************\ +* +* Function: bool CreateStream(FPSTREAM** lplpStream); +* +* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* appena creato. +* +* Return: true se tutto OK, false in caso di errore +* +* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), +* sono dovute al fatto che i costruttori delle classi FPSTREAM +* e FPSFX richiedono che DirectSound sia gia' stato +* inzializzato. In questo modo quindi si evitano dei bugs +* che si verrebbero a creare se venisse dichiarata un oggetto +* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* inizializzazione di DirectSound). +* +\****************************************************************************/ + +bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { + (*lplpStream) = new FPSTREAM(lpDS, hwnd, bSoundSupported); + + return (*lplpStream != NULL); +} + + + +/****************************************************************************\ +* +* Function: bool CreateSfx(FPSFX** lplpSfx); +* +* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* appena creato. +* +* Return: true se tutto OK, false in caso di errore +* +* Note: Vedi le note di CreateStream() +* +\****************************************************************************/ + +bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { + (*lplpSfx) = new FPSFX(lpDS, hwnd, bSoundSupported); + + return (*lplpSfx != NULL); +} + + + +/****************************************************************************\ +* +* Function: void SetMasterVolume(int dwVolume); +* +* Description: Setta il volume generale +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + +void FPSOUND::SetMasterVolume(int dwVolume) { +#ifdef REFACTOR_ME + + if (!bSoundSupported) + return; + + if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; + + lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); +#endif +} + + +/****************************************************************************\ +* +* Function: void GetMasterVolume(int *lpdwVolume); +* +* Description: Richiede il volume generale +* +* Input: int *lpdwVolume Variabile che conterra' il volume (0-63) +* +\****************************************************************************/ + +void FPSOUND::GetMasterVolume(int *lpdwVolume) { +#ifdef REFACTOR_ME + if (!bSoundSupported) + return; + + lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); + *lpdwVolume -= (DSBVOLUME_MIN); + *lpdwVolume *= 64; + *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); +#endif +} + + +/****************************************************************************\ +* Metodi di FPSFX +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() +* +\****************************************************************************/ + +FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { +#ifdef REFACTOR_ME + + static char errbuf[128]; + + //hwnd=hWnd; + bSoundSupported = bSoundOn; + bFileLoaded = false; + bIsPlaying = false; + bPaused = false; + lpDSBuffer = NULL; + lpDSNotify = NULL; + lpDS = lpds; + lastVolume = 63; + hEndOfBuffer = INVALID_HANDLE_VALUE; + bIsVoice = false; + + if (bSoundSupported == false) + return; + + /* Poich non abbiamo ancora nessun dato sull'effetto sonoro, non possiamo fare nulla */ +#endif +} + + +/****************************************************************************\ +* +* Function: ~FPSFX(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare il sound +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. +* +\****************************************************************************/ + +FPSFX::~FPSFX() { +#ifdef REFACTOR_ME + + if (!bSoundSupported) + return; + + if (bIsPlaying) + Stop(); + + RELEASE(lpDSNotify); + + if (hEndOfBuffer != INVALID_HANDLE_VALUE) + CloseHandle(hEndOfBuffer); + + RELEASE(lpDSBuffer); +#endif +} + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + +void FPSFX::Release() { + delete this; +// return NULL; +} + + + +/****************************************************************************\ +* +* Function: bool LoadFile(byte *lpBuf); +* +* Description: Apre un file di effetto sonoro e lo carica. +* +* Input: byte *lpBuf Buffer dove si trova l'sfx +* uint32 dwCoded CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { +#ifdef REFACTOR_ME + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + static HRESULT err; + static char errbuf[128]; + uint32 dwHi; + struct WAVH { + int nChunckSize; + uint16 wFormatTag; + uint16 nChannels; + int nSamplesPerSec; + int nAvgBytesPerSec; + uint16 nBlockAlign; + uint16 nBitsPerSample; + } *WAVHeader; + uint32 dwSize; + void *lpLock; + + if (!bSoundSupported) + return true; + + /* Nel buffer troviamo un file WAV completo, almeno per ora */ + if (dwCodec != FPCODEC_WAV) + return false; + + if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') + return false; + if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') + return false; + + WAVHeader = (WAVH*)(lpBuf+8); + lpBuf += 8 + sizeof(WAVH); + + if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') + return false; + lpBuf += 4; + + dwSize = *(uint32*)lpBuf; + lpBuf += 4; + + b16bit = (WAVHeader->nBitsPerSample == 16); + bStereo = (WAVHeader->nChannels == 2); + dwFreq = WAVHeader->nSamplesPerSec; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. + Proviamo a buttarlo in sound ram. */ + pcmwf.wBitsPerSample = (b16bit ? 16 : 8); + pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = (bStereo ? 2 : 1); + pcmwf.wf.nSamplesPerSec = dwFreq; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwBufferBytes = dwSize; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + return false; + } + + // Riempie il buffer + if ((err = lpDSBuffer->Lock(0,dwSize, &lpLock,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + return false; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + CopyMemory(lpLock, lpBuf, dwSize); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpLock, dwSize, NULL, NULL); + + /* Setta volume iniziale */ + SetVolume(lastVolume); + + bFileLoaded = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool LoadFile(LPSTR lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di effetto sonoro e lo carica. +* +* Input: LPSTR lpszFile Nome del file di sfx da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { +#ifdef REFACTOR_ME + uint32 dwSize; + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + byte *lpTempBuffer; + static HRESULT err; + uint32 dwHi; + void *lpBuf; + static char errbuf[128]; + + if (!bSoundSupported) + return true; + + b16bit = true; + bStereo = false; + bIsVoice = true; + +// fread(&dwSize,1,4,vdbFP); +// fread(&dwFreq,1,4,vdbFP); + ReadFile(vdbFP, &dwSize,4, &dwHi, NULL); + ReadFile(vdbFP, &dwFreq,4, &dwHi, NULL); + + dwSize *= 4; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. + Proviamo a buttarlo in sound ram. */ + pcmwf.wBitsPerSample = (b16bit ? 16 : 8); + pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = (bStereo ? 2 : 1); + pcmwf.wf.nSamplesPerSec = dwFreq; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwBufferBytes = dwSize; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + return false; + } + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); + if (lpTempBuffer == NULL) + return false; + + lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); + + /* Riempie il buffer */ + if ((err = lpDSBuffer->Lock(0,dwSize, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + return false; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(vdbFP, lpBuf, dwSize); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); + + delete lpCodec; + + /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + if (FAILED(err)) { + wsprintf(errbuf,"Error creating notify object! (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::LoadVoiceFromVDB()", MB_OK); + return false; + } + + hEndOfBuffer = CreateEvent(NULL, false, false, NULL); + + dspnHot[0].dwOffset = DSBPN_OFFSETSTOP; + dspnHot[0].hEventNotify = hEndOfBuffer; + + lpDSNotify->SetNotificationPositions(1, dspnHot); + + /* Tutto a posto, possiamo uscire */ + bFileLoaded = true; + SetVolume(62); + +#endif + return true; +} + + +bool FPSFX::LoadFile(LPSTR lpszFileName, uint32 dwCodec) { +#ifdef REFACTOR_ME + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + static HRESULT err; + static char errbuf[128]; + Common::File file; + uint32 dwSize; + byte *lpTempBuffer; + void *lpBuf; + uint32 dwHi; + struct { + char id[4]; + int freq; + int nChan; + } ADPHead; + + if (!bSoundSupported) + return true; + + /* Apre il file di stream in lettura */ + if (!file.open(lpszFileName)) { + warning("FPSFX::LoadFile() : Cannot open sfx file!"); + return false; + } + + /* Leggiamo l'header */ + file.read(ADPHead.id, 4); + ADPHead.freq = file.readUint32LE(); + ADPHead.nChan = file.readUint32LE(); + + if (ADPHead.id[0] != 'A' || ADPHead.id[1] != 'D' || ADPHead.id[2] != 'P' || ADPHead.id[3] != 0x10) { + warning("FPSFX::LoadFile() : Invalid ADP header!"); + file.close(); + return false; + } + + b16bit = true; + bStereo = (ADPHead.nChan == 2); + dwFreq = ADPHead.freq; + + /* Si salva la lunghezza dello stream */ + dwSize = file.size() - 12 /*sizeof(ADPHead)*/; + file.seek(0); + + if (dwCodec == FPCODEC_ADPCM) + dwSize *= 4; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. + Proviamo a buttarlo in sound ram. */ + pcmwf.wBitsPerSample = (b16bit ? 16 : 8); + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = (bStereo ? 2 : 1); + pcmwf.wf.nSamplesPerSec = dwFreq; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwBufferBytes = dwSize; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + return false; + } + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); + if (lpTempBuffer == NULL) + return false; + + switch (dwCodec) { + case FPCODEC_RAW: + lpCodec = new CODECRAW(bLoop); + break; + + case FPCODEC_ADPCM: + if (bStereo) + lpCodec = new CODECADPCMSTEREO(bLoop,lpTempBuffer); + else + lpCodec = new CODECADPCMMONO(bLoop,lpTempBuffer); + break; + + default: + return false;G + } + + /* Riempie il buffer */ + if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + return false; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(file, lpBuf, dwSize); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); + + delete lpCodec; + file.close(); + + /* Tutto a posto, possiamo uscire */ + bFileLoaded = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo sfx caricato. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSFX::Play() { +#ifdef REFACTOR_ME + if (bFileLoaded) { + if (hEndOfBuffer != INVALID_HANDLE_VALUE) + ResetEvent(hEndOfBuffer); + + lpDSBuffer->SetCurrentPosition(0); + bIsPlaying = true; + + if (!bPaused) { + lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); + } + } +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool Stop(void); +* +* Description: Ferma il play dello sfx. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSFX::Stop(void) { +#ifdef REFACTOR_ME + if (bFileLoaded) { + if (bPaused || bIsPlaying) { + lpDSBuffer->Stop(); + } + + bIsPlaying = false; + bPaused = false; + } +#endif + return true; +} + + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello sfx. +* +* Input: bool bLoop true per attivare il loop, false per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello sfx. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo sfx non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + +void FPSFX::SetLoop(bool bLop) { + bLoop = bLop; +} + +void FPSFX::Pause(bool bPause) { +#ifdef REFACTOR_ME + if (bFileLoaded) { + if (bPause && bIsPlaying) { + lpDSBuffer->Stop(); + } else if (!bPause && bPaused) { + if (bIsPlaying && bLoop) + lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); + } + + // Trucchetto per risettare il volume secondo le + // possibili nuove configurazioni sonore + SetVolume(lastVolume); + bPaused = bPause; + } +#endif +} + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello sfx +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + +void FPSFX::SetVolume(int dwVolume) { + if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; + + lastVolume = dwVolume; + + if (bIsVoice) { + if (!bCfgDubbing) dwVolume = 0; + else { + dwVolume -= (10 - nCfgDubbingVolume) * 2; + if (dwVolume<0) dwVolume = 0; + } + } else { + if (!bCfgSFX) dwVolume = 0; + else { + dwVolume -= (10 - nCfgSFXVolume) * 2; + if (dwVolume < 0) dwVolume = 0; + } + } +#ifdef REFACTOR_ME + if (bFileLoaded) + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX-DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); +#endif +} + + + +/****************************************************************************\ +* +* Function: void GetVolume(int *lpdwVolume); +* +* Description: Chiede il volume dello sfx +* +* Input: int *lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + +void FPSFX::GetVolume(int *lpdwVolume) { +#ifdef REFACTOR_ME + if (bFileLoaded) + lpDSBuffer->GetVolume((uint32 *)lpdwVolume); + + *lpdwVolume -= (DSBVOLUME_MIN); + *lpdwVolume *= 64; + *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); +#endregion +} + + + + +/****************************************************************************\ +* Metodi di FPSTREAM +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* +\****************************************************************************/ + +FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { + //hwnd=hWnd; + lpDS=LPDS; + bSoundSupported = bSoundOn; + bFileLoaded = false; + bIsPlaying = false; + bPaused = false; + bSyncExit = false; + lpDSBuffer = NULL; + lpDSNotify = NULL; + hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL; +} + +bool FPSTREAM::CreateBuffer(int nBufSize) { +#ifdef REFACTOR_ME + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + static HRESULT err; + static char errbuf[128]; + + if (bSoundSupported == false) + return true; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre + il controllo del volume, in modo da poter abbassare e alzare il volume + della musica indipendentemente da quello generale. Ovviamente si tratta + di un buffer in RAM */ + pcmwf.wBitsPerSample = 16; + pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = 2; + pcmwf.wf.nSamplesPerSec = 44100; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dwBufferSize=dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + bSoundSupported = false; + return false; + } + SetVolume(63); + + + /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave + all'interno dello stream. Le posizioni chiave si trovano rispettivamente + subito dopo l'inizio e subito dopo la meta' del buffer */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + + if (FAILED(err)) { + wsprintf(errbuf,"Error creating notify object! (%lx)",err); + MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + bSoundSupported = false; + return false; + } + + hHot1=CreateEvent(NULL, false, false, NULL); + hHot2=CreateEvent(NULL, false, false, NULL); + hHot3=CreateEvent(NULL, false, false, NULL); + hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + lpDSNotify->SetNotificationPositions(3,dspnHot); +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: ~FPSTREAM(); +* +* Description: Distruttore di default. Richiama anche la CloseFile() se ce +* ne e' bisogno. +* +\****************************************************************************/ + +FPSTREAM::~FPSTREAM() { + if (!bSoundSupported) + return; + + if (bIsPlaying) + Stop(); + + if (bFileLoaded) + UnloadFile(); + + if (hHot1) { + CloseHandle(hHot1); + hHot1 = NULL; + } + if (hHot2) { + CloseHandle(hHot2); + hHot2 = NULL; + } + if (hHot3) { + CloseHandle(hHot3); + hHot3 = NULL; + } + if (hPlayThread_PlayFast) { + CloseHandle(hPlayThread_PlayFast); + hPlayThread_PlayFast = NULL; + } + if (hPlayThread_PlayNormal) { + CloseHandle(hPlayThread_PlayNormal); + hPlayThread_PlayNormal = NULL; + } + + SyncToPlay = NULL; + + RELEASE(lpDSNotify); + RELEASE(lpDSBuffer); +} + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + +FPSTREAM::Release() { + delete this; + return NULL; +} + + +/****************************************************************************\ +* +* Function: bool LoadFile(LPSTREAM lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di stream. +* +* Input: LPSTR lpszFile Nome del file di stream da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { +#ifdef REFACTOR_ME + HRESULT err; + void *lpBuf; + uint32 dwHi; + + if (!bSoundSupported) + return true; + + /* Si salva il tipo di codec */ + dwCodec = dwCodType; + + /* Crea il buffer */ + if (!CreateBuffer(nBufSize)) + return true; + + /* Apre il file di stream in lettura */ + if (!_file.open(lpszFileName)) + //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); + return false; + } + + /* Si salva la lunghezza dello stream */ + dwSize = _file.size(); + _file.seek(0); + + /* Tutto a posto, possiamo uscire */ + bFileLoaded = true; + bIsPlaying = false; + bPaused = false; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: UnloadFile(); +* +* Description: Chiude un file di stream eventualmente aperto. E' necessario +* richiamare questa funzione per disallocare la memoria +* occupata dallo stream. +* +* Return: Il distruttore della classe per sicurezza richiama la +* UnloadFile() se non e' stata richiamata esplicitamente. +* +\****************************************************************************/ + +bool FPSTREAM::UnloadFile() { + if (!bSoundSupported || !bFileLoaded) + return true; + + /* Chiude gli handle del file di stream */ + _file.close(); + + RELEASE(lpDSNotify); + RELEASE(lpDSBuffer); + + /* Si ricorda che non c'e' piu' nessun file in memoria */ + bFileLoaded = false; + + return true; +} + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo stream caricato. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +void FPSTREAM::Prefetch(void) { +#ifdef REFACTOR_ME + uint32 dwId; + void *lpBuf; + uint32 dwHi; + HRESULT err; + + if (!bSoundSupported || !bFileLoaded) + return; + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); + if (lpTempBuffer == NULL) + return; + + switch (dwCodec) { + case FPCODEC_RAW: + lpCodec = new CODECRAW(bLoop); + break; + + case FPCODEC_ADPCM: + lpCodec = new CODECADPCMSTEREO(bLoop); + break; + + default: + return; + } + + /* Posiziona lo stream file all'inizio */ + _file.seek(0); + + /* Riempie il buffer per avere i dati gia' pronti */ + if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock stream buffer!","soundLoadStream()", MB_OK); + return; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); + + /* Crea il thread che fa il play dello stream */ + hThreadEnd = CreateEvent(NULL, false, false, NULL); + hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); + SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); + + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + bIsPlaying = true; + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + int a=1; + } +#endif +} + +void FPSTREAM::PlayFast(void) { +#ifdef REFACTOR_ME + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + lpDSBuffer->Stop(); + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + warning("PlayFast SNP failed!"); + } + + if (FAILED(lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING))) { + warning("PlayFast failed!\n"); + } +#endif +} + +bool FPSTREAM::Play() { +#ifdef REFACTOR_ME + uint32 dwId; + void *lpBuf; + uint32 dwHi; + HRESULT err; + + if (!bSoundSupported || !bFileLoaded) + return false; + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); + if (lpTempBuffer == NULL) + return false; + + switch (dwCodec) { + case FPCODEC_RAW: + lpCodec = new CODECRAW(bLoop); + break; + + case FPCODEC_ADPCM: + lpCodec = new CODECADPCMSTEREO(bLoop); + break; + + default: + return false; + } + + /* Posiziona lo stream file all'inizio */ + _file.seek(0); + lpDSBuffer->Stop(); + lpDSBuffer->SetCurrentPosition(0); + + /* Riempie il buffer per avere i dati gia' pronti */ + if ((err = lpDSBuffer->Lock(0,dwBufferSize/2, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + error("Cannot lock stream buffer!","soundLoadStream()"); + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); + + /* Crea il thread che fa il play dello stream */ + hThreadEnd = CreateEvent(NULL, false, false, NULL); + hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); + SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); + + SetEvent(hPlayThread_PlayFast); + +#if 0 + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize/2+32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) + { + int a=1; + } + + + lpDSBuffer->Play(0, 0,DSBPLAY_LOOPING); +#endif + + bIsPlaying = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool Stop(bool bSync); +* +* Description: Ferma il play dello stream. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSTREAM::Stop(bool bSync) { + if (!bSoundSupported) + return true; + + if (!bFileLoaded) + return false; + + if (!bIsPlaying) + return false; + + if (bSync) { +// bSyncExit = true; +// lpDSBuffer->Stop(); +// lpDSBuffer->Play(0, 0, 0); + return true; + } else { + /* Ferma il buffer DirectSound */ + lpDSBuffer->Stop(); + + /* Avverte il thread che deve uscire e aspetta che si chiuda */ + SetEvent(hThreadEnd); + WaitForSingleObject(hPlayThread, INFINITE); + + /* Chiude l'handle del thread e disalloca la memoria temporanea */ + CloseHandle(hPlayThread); + CloseHandle(hThreadEnd); + GlobalFree(lpTempBuffer); + + /* Disalloca e chiude il CODEC */ + delete lpCodec; + + bIsPlaying = false; + bPaused = false; + } + + return true; +} + +void FPSTREAM::WaitForSync(FPSTREAM *toplay) { +#ifdef REFACTOR_ME + if (!bSoundSupported) + return; + + if (!bFileLoaded) + return; + + if (!bIsPlaying) + return; + + SyncToPlay = toplay; + bSyncExit = true; + + char buf[1024]; + sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", + this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); + warning(buf); + + WaitForSingleObject(hPlayThread, INFINITE); + + /* Chiude l'handle del thread e disalloca la memoria temporanea */ + CloseHandle(hPlayThread); + CloseHandle(hThreadEnd); + GlobalFree(lpTempBuffer); + + /* Disalloca e chiude il CODEC */ + delete lpCodec; +#endif + bIsPlaying = false; +} + +/****************************************************************************\ +* +* Function: void FPSTREAM::PlayThread(); +* +* Description: Thread che si occupa del play dello stream +* +\****************************************************************************/ + +void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { +#ifdef REFACTOR_ME + byte *lpLockBuf; + uint32 dwResult; + byte *lpLockBuf2; + uint32 dwResult2; + bool cicla = true; + uint32 countEnd; + bool bPrecache; + char buf[1024]; + + /* Eventi che segnalano quando bisogna eseguire qualcosa */ + HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; + + bPrecache = true; + countEnd = 0; + while (cicla) { + if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { + countEnd++; + if (countEnd==3) + break; + } + + /* Decomprime i dati che stanno per essere scritti dentro il buffer temporaneo */ + if (This->lastVolume == 0) + ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); + else if (bPrecache) + This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); + + bPrecache = false; + + /* Attende il set di un evento. Dato che sono tutti in automatic reset, + non c'e' bisogno di resettarlo dopo */ + +// uint32 dwBufStatus; +// This->lpDSBuffer->GetStatus(&dwBufStatus); + + +// sprintf(buf, "WFMO: %x (buf status: %x) MyThread: 0x%x\n", This->lpDSBuffer, dwBufStatus, GetCurrentThreadId()); +// warning(buf); + dwResult = WaitForMultipleObjects(5, hList, false, INFINITE); + +/* uint32 dwPlay, dwWrite; + This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); + sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); + warning(buf); */ + + /* Fa uno switch per stabilire quale evento e' stato settato */ + switch (dwResult - WAIT_OBJECT_0) { + case 0: + /* Bisogna uscire dal thread */ + cicla = false; + break; + + case 1: + /* Bisogna riempire la seconda meta' del buffer */ +// if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) + { +// sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); +// warning(buf); + This->lpDSBuffer->Lock(This->dwBufferSize/2,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult,(void **)&lpLockBuf2, &dwResult2, 0); + // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); + // warning(buf); + CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); + This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2,lpLockBuf2, 0); + bPrecache = true; + } + break; + + case 2: + /* Bisogna riempire la prima meta' del buffer */ +// if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) + { +// sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); +// warning(buf); + This->lpDSBuffer->Lock(0,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult, NULL, NULL, 0); + CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); + This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2, NULL, NULL); + bPrecache = true; + } + break; + + case 3: + { +// sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); +// warning(buf); + if (This->bSyncExit) { +// sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); +// warning(buf); + //This->SyncToPlay->PlayFast(); + SetEvent(This->SyncToPlay->hPlayThread_PlayFast); + // Transfer immediatly control to the other threads + Sleep(0); + This->bSyncExit = false; + cicla = false; + break; + } + } + break; + + case 4: + This->PlayFast(); + break; + } + } + + /* Ferma il buffer DirectSound */ +// sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); +// warning(buf); + This->lpDSBuffer->Stop(); +#endif + ExitThread(0); +} + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello stream. +* +* Input: bool bLoop true per attivare il loop, false per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello stream. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo stream non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + +void FPSTREAM::SetLoop(bool loop) { + bLoop = loop; +} + + +void FPSTREAM::Pause(bool bPause) { + if (bFileLoaded) { + if (bPause && bIsPlaying) { + lpDSBuffer->Stop(); + bIsPlaying = false; + bPaused = true; + } else if (!bPause && bPaused) { + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + int a = 1; + } + + lpDSBuffer->Play(0, 0, bLoop); + bIsPlaying = true; + bPaused = false; + + // Trucchetto per risettare il volume secondo le + // possibili nuove configurazioni sonore + SetVolume(lastVolume); + } + } +} + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello stream +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + +void FPSTREAM::SetVolume(int dwVolume) { +#ifdef REFACTOR_ME + if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; + + lastVolume = dwVolume; + + if (!bCfgMusic) dwVolume = 0; + else { + dwVolume -= (10 - nCfgMusicVolume) * 2; + if (dwVolume<0) dwVolume = 0; + } + + if (lpDSBuffer) + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); +#endif +} + + + +/****************************************************************************\ +* +* Function: void GetVolume(int *lpdwVolume); +* +* Description: Chiede il volume dello stream +* +* Input: int *lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + +void FPSTREAM::GetVolume(int *lpdwVolume) { +#ifdef REFACTOR_ME + if (lpDSBuffer) + lpDSBuffer->GetVolume((uint32 *)lpdwVolume); + *lpdwVolume -= (DSBVOLUME_MIN); + *lpdwVolume *= 64; + *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); +#endregion +} + } // End of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h index c966c93888..7ed8f97b3e 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -48,12 +48,21 @@ #ifndef TONY_SOUND_H #define TONY_SOUND_H +#include "common/file.h" #include "tony/gfxcore.h" #include "tony/loc.h" #include "tony/utils.h" namespace Tony { +// Dummy type declarations +typedef void *LPDIRECTSOUND; +typedef void *LPDIRECTSOUNDBUFFER; +typedef uint32 HWND; +struct DSCAPS { +}; + + class FPSTREAM; class FPSFX; class CODEC; @@ -78,12 +87,10 @@ class FPSOUND { private: bool bSoundSupported; -/* LPDIRECTSOUND lpDS; LPDIRECTSOUNDBUFFER lpDSBPrimary; DSCAPS dscaps; HWND hwnd; -*/ /****************************************************************************\ * Metodi @@ -301,7 +308,7 @@ public: bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); - bool LoadVoiceFromVDB(Common::File &hvdb); + bool LoadVoiceFromVDB(Common::File &vdbFP); /****************************************************************************\ @@ -410,7 +417,7 @@ private: uint32 dwCodec; // CODEC utilizzato HANDLE hThreadEnd; // Evento per chiudere il thread - HANDLE hFile; // Handle del file di stream + Common::File _file; // Handle del file di stream HANDLE hPlayThread; // Handle del thread di play HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify HANDLE hPlayThread_PlayFast; @@ -497,7 +504,7 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); -- cgit v1.2.3 From a2982a0b20027f658c9b47266a8ddbec74a15878 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 22:49:30 +1000 Subject: TONY: Engine is now compiling and linking again --- engines/tony/adv.h | 2 +- engines/tony/font.cpp | 27 + engines/tony/game.cpp | 2 +- engines/tony/gfxcore.cpp | 46 +- engines/tony/gfxengine.cpp | 14 +- engines/tony/module.mk | 1 + engines/tony/sound.cpp | 38 +- engines/tony/tony.cpp | 79 ++- engines/tony/tony.h | 4 +- engines/tony/utils.cpp | 130 ++++- engines/tony/utils.h | 4 +- engines/tony/window.cpp | 1255 ++++++++++++++++++++++++++++++++++++++++++++ engines/tony/window.h | 27 +- 13 files changed, 1570 insertions(+), 59 deletions(-) create mode 100644 engines/tony/window.cpp (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index aab7df24af..9a5ecd5072 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -92,7 +92,7 @@ void MainShowMouse(void); void MainHideMouse(void); void MainEnableInput(void); void MainDisableInput(void); -void MainPlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); +void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); void MainInitWipe(int type); void MainCloseWipe(void); void MainWaitWipeEnd(void); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 2996b30f04..a0500047b6 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -125,6 +125,14 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes nLetters=nChars; } +void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { + RMRes res(resID); + + if ((int)res.Size() < nChars * (dimy * dimx + 8)) + nChars = res.Size() / (dimy * dimx + 8); + + Load(res, nChars, dimx, dimy, palResID); +} void RMFont::Unload(void) { if (m_letter != NULL) { @@ -2273,6 +2281,25 @@ void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMText::Draw(bigBuf,prim); } +RMPoint RMTextItemName::GetHotspot() { + if (m_item == NULL) + return m_mpos + m_curscroll; + else + return m_item->Hotspot(); +} + +RMItem *RMTextItemName::GetSelectedItem() { + return m_item; +} + +bool RMTextItemName::IsItemSelected() { + return m_item != NULL; +} + +bool RMTextItemName::IsNormalItemSelected() { + return m_item != NULL && m_itemName.Length() > 0; +} + /****************************************************************************\ * Metodi di RMDialogChoice diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d5047766bb..00bb81dcf4 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -130,7 +130,7 @@ void MainHideMouse(void) { _vm->GetEngine()->DisableMouse(); } -void MainPlayMusic(int nChannel, char* filename, int nFX, bool bLoop, int nSync) { +void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { _vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync); } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 4842126c59..1d289fbecc 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -138,15 +138,15 @@ void RMGfxBuffer::OffsetY(int nLines, int nBpp) { } -inline RMGfxBuffer::operator byte *() { +RMGfxBuffer::operator byte *() { return m_buf; } -inline RMGfxBuffer::operator void *() { +RMGfxBuffer::operator void *() { return (void *)m_buf; } -inline RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { +RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { Create(dimx, dimy, nBpp, bUseDDraw); } @@ -255,7 +255,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int * \****************************************************************************/ -inline int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } @@ -275,11 +275,11 @@ void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMGfxSourceBuffer16::Draw(bigBuf, prim); } -inline RMGfxWoodyBuffer::RMGfxWoodyBuffer() { +RMGfxWoodyBuffer::RMGfxWoodyBuffer() { } -inline RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) +RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { } @@ -407,7 +407,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { g_system->unlockMutex(csModifyingOT); } -inline void RMGfxTargetBuffer::AddClearTask(void) { +void RMGfxTargetBuffer::AddClearTask(void) { AddPrim(new RMGfxPrimitive(&taskClear)); } @@ -486,11 +486,11 @@ void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoad } } -inline int RMGfxSourceBufferPal::LoadPalette(uint32 resID) { +int RMGfxSourceBufferPal::LoadPalette(uint32 resID) { return LoadPalette(RMRes(resID)); } -inline int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { +int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { return LoadPaletteWA(RMRes(resID), bSwapped); } @@ -501,7 +501,7 @@ inline int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -inline RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) +RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,4,bUseDDraw) { SetPriority(0); } @@ -516,11 +516,11 @@ inline RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw * \****************************************************************************/ -inline int RMGfxSourceBuffer4::Bpp() { +int RMGfxSourceBuffer4::Bpp() { return 4; } -inline void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx,dimy,4,bUseDDraw); } @@ -589,12 +589,12 @@ void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } -inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) +RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,8,bUseDDraw) { SetPriority(0); } -inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { +RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { m_bTrasp0=bTrasp0; } @@ -609,11 +609,11 @@ inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { * \****************************************************************************/ -inline int RMGfxSourceBuffer8::Bpp() { +int RMGfxSourceBuffer8::Bpp() { return 8; } -inline void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw); } @@ -630,7 +630,7 @@ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { } -inline int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) +int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { int r,g,b; @@ -1919,7 +1919,7 @@ void RMGfxSourceBuffer16::PrepareImage(void) { } -inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) +RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { SetPriority(0); } @@ -1934,11 +1934,11 @@ inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDr * \****************************************************************************/ -inline int RMGfxSourceBuffer16::Bpp() { +int RMGfxSourceBuffer16::Bpp() { return 16; } -inline void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx,dimy,16,bUseDDraw); } @@ -1980,17 +1980,17 @@ void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { * Metodi di RMGfxClearTask \****************************************************************************/ -inline int RMGfxClearTask::Priority() { +int RMGfxClearTask::Priority() { // Priorita' massima (deve essere fatto per primo) return 1; } -inline void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Pulisce tutto il target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } -inline bool RMGfxClearTask::RemoveThis() { +bool RMGfxClearTask::RemoveThis() { // Il task di clear si disattiva sempre return true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b8accda7c6..d4ea8ee821 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -58,15 +58,25 @@ extern bool bIdleExited; extern bool bPatIrqFreeze; extern bool bSkipSfxNoLoop; -extern void ExitAllIdles(int nCurLoc); /****************************************************************************\ * Metodi di RMGfxEngine \****************************************************************************/ +bool bIdleExited; + +void ExitAllIdles(int nCurLoc) { + // Chiude le idle + bSkipSfxNoLoop = true; + mpalEndIdlePoll(nCurLoc); + bIdleExited = true; + bSkipSfxNoLoop = false; + ExitThread(0); +} + RMGfxEngine::RMGfxEngine() { // Crea il big buffer dove verranno disegnati i frame - m_bigBuf.Create(RM_BBX,RM_BBY,16); + m_bigBuf.Create(RM_BBX, RM_BBY, 16); m_bigBuf.OffsetY(RM_SKIPY); } diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 690b1f4713..af0b3acd2c 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS := \ tony.o \ tonychar.o \ utils.o \ + window.o \ mpal/expr.o \ mpal/loadmpc.o \ mpal/memory.o \ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e757ac4115..a5293eecb2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -505,7 +505,7 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -545,12 +545,12 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { cache = *inp++; delta = (cache>>4)&0xF; } else - delta=cache&0xF; + delta = cache & 0xF; /* Trova il nuovo indice */ index += indexTable[delta]; if (index < 0) index = 0; - if (index > 88) index=88; + if (index > 88) index = 88; /* Legge il segno e lo separa dall'ampliamento */ sign = delta&8; @@ -558,9 +558,9 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { /* Trova la differenza dal valore precedente */ vpdiff = step >> 3; - if (delta&4) vpdiff+=step; - if (delta&2) vpdiff+=step >> 1; - if (delta&1) vpdiff+=step >> 2; + if (delta&4) vpdiff += step; + if (delta&2) vpdiff += step >> 1; + if (delta&1) vpdiff += step >> 2; if (sign) valpred -= vpdiff; @@ -1551,12 +1551,10 @@ void FPSFX::GetVolume(int *lpdwVolume) { *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endregion +#endif } - - /****************************************************************************\ * Metodi di FPSTREAM \****************************************************************************/ @@ -1571,6 +1569,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { \****************************************************************************/ FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { +#ifdef REFACTOR_ME //hwnd=hWnd; lpDS=LPDS; bSoundSupported = bSoundOn; @@ -1581,6 +1580,7 @@ FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { lpDSBuffer = NULL; lpDSNotify = NULL; hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL; +#endif } bool FPSTREAM::CreateBuffer(int nBufSize) { @@ -1661,6 +1661,8 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { \****************************************************************************/ FPSTREAM::~FPSTREAM() { +#ifdef REFACTOR_ME + if (!bSoundSupported) return; @@ -1695,6 +1697,7 @@ FPSTREAM::~FPSTREAM() { RELEASE(lpDSNotify); RELEASE(lpDSBuffer); +#endif } @@ -1711,9 +1714,9 @@ FPSTREAM::~FPSTREAM() { * \****************************************************************************/ -FPSTREAM::Release() { +void FPSTREAM::Release() { delete this; - return NULL; +// return NULL; } @@ -1780,6 +1783,8 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize \****************************************************************************/ bool FPSTREAM::UnloadFile() { +#ifdef REFACTOR_ME + if (!bSoundSupported || !bFileLoaded) return true; @@ -1791,7 +1796,7 @@ bool FPSTREAM::UnloadFile() { /* Si ricorda che non c'e' piu' nessun file in memoria */ bFileLoaded = false; - +#endif return true; } @@ -1985,6 +1990,8 @@ bool FPSTREAM::Play() { \****************************************************************************/ bool FPSTREAM::Stop(bool bSync) { +#ifdef REFACTOR_ME + if (!bSoundSupported) return true; @@ -2018,7 +2025,7 @@ bool FPSTREAM::Stop(bool bSync) { bIsPlaying = false; bPaused = false; } - +#endif return true; } @@ -2199,6 +2206,8 @@ void FPSTREAM::SetLoop(bool loop) { void FPSTREAM::Pause(bool bPause) { +#ifdef REFACTOR_ME + if (bFileLoaded) { if (bPause && bIsPlaying) { lpDSBuffer->Stop(); @@ -2227,6 +2236,7 @@ void FPSTREAM::Pause(bool bPause) { SetVolume(lastVolume); } } +#endif } @@ -2278,7 +2288,7 @@ void FPSTREAM::GetVolume(int *lpdwVolume) { *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endregion +#endif } } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ea555972d0..0a2143ba8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -139,7 +139,7 @@ int flipflop=0; OSystem::MutexRef csMusic; -void TonyEngine::PlayMusic(int nChannel, char* fn, int nFX, bool bLoop, int nSync) { +void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { warning("TonyEngine::PlayMusic"); } @@ -202,6 +202,46 @@ int TonyEngine::GetMusicVolume(int nChannel) { return 255; } + +void TonyEngine::GetSaveStateFileName(int n, char *buf) { + RMString name; + + if (n > 0) + name.Format("%02d", n); + else + name.Format("autosave"); + + name += ".sav"; +} + +void TonyEngine::AutoSave(void) { + char buf[256]; + + GrabThumbnail(); + MainWaitFrame(); + MainWaitFrame(); + MainFreeze(); + GetSaveStateFileName(0,buf); + _theEngine.SaveState(buf, (byte *)m_curThumbnail, "Autosave", true); + MainUnfreeze(); +} + + +void TonyEngine::SaveState(int n, const char *name) { + char buf[256]; + + GetSaveStateFileName(n, buf); + _theEngine.SaveState(buf,(byte *)m_curThumbnail, name); +} + + +void TonyEngine::LoadState(int n) { + char buf[256]; + + GetSaveStateFileName(n, buf); + _theEngine.LoadState(buf); +} + bool TonyEngine::OpenVoiceDatabase() { char id[4]; uint32 numfiles; @@ -251,6 +291,21 @@ void TonyEngine::GrabThumbnail(void) { warning("TODO: TonyEngine::GrabThumbnail"); } +void TonyEngine::OptionScreen(void) { +} + +void TonyEngine::OpenInitLoadMenu(void) { + _theEngine.OpenOptionScreen(1); +} + +void TonyEngine::OpenInitOptions(void) { + _theEngine.OpenOptionScreen(2); +} + +void TonyEngine::Abort(void) { + m_bQuitNow = true; +} + void TonyEngine::Play(void) { warning("TODO TonyEngine::Play"); @@ -314,14 +369,14 @@ void TonyEngine::PauseLoop(void) { MSG msg; int st,et; - st = timeGetTime(); + st = GetTime(); while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } - et = timeGetTime(); + et = GetTime(); m_startTime += et - st; #endif @@ -345,4 +400,22 @@ warning("TODO: TonyEninge::Pause"); */ } +void TonyEngine::FreezeTime(void) { + m_bTimeFreezed = true; + m_nTimeFreezed = GetTime() - m_startTime; +} + +void TonyEngine::UnfreezeTime(void) +{ + m_bTimeFreezed = false; +} + + +/** + * Returns the millisecond timer + */ +uint32 TonyEngine::GetTime() { + return g_system->getMillis(); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index dd7e558820..06fe357c0d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -158,7 +158,7 @@ public: // Music // ****** - void PlayMusic(int nChannel, char *fn, int nFX, bool bLoop, int nSync); + void PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); void StopMusic(int nChannel); void PlaySFX(int nSfx, int nFX = 0); @@ -183,7 +183,7 @@ public: // Salvataggio void AutoSave(void); - void SaveState(int n, char *name); + void SaveState(int n, const char *name); void LoadState(int n); void GetSaveStateFileName(int n, char* buf); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 43a129b92a..69ad5633d7 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -292,8 +292,8 @@ RMString::operator char*() const { /** * Resize a string as necessary * @param size New size necessary (in bytes) - * @param bMaintain If TRUE we must keep the original string, - if FALSE we can destroy. + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -406,6 +406,122 @@ void RMString::Format(char* str, ...) { */ } +/****************************************************************************\ +* Metodi di RMFileStreamSlow +\****************************************************************************/ + +RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { + _stream = NULL; +} + +RMFileStreamSlow::~RMFileStreamSlow() { + Close(); +} + +void RMFileStreamSlow::Close() { + delete _stream; +} + +bool RMFileStreamSlow::OpenFile(Common::File &file) { + _stream = file.readStream(file.size()); + + m_length = _stream->pos(); + + return true; +} + + +bool RMFileStreamSlow::OpenFile(const char *lpFN) { + // Apre il file in lettura + Common::File f; + if (!f.open(lpFN)) + return false; + + m_length = f.size(); + _stream = f.readStream(f.size()); + + return true; +} + + +RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { + Seek(nBytes); + return *this; +} + +int RMFileStreamSlow::Pos() { + return _stream->pos(); +} + +bool RMFileStreamSlow::IsEOF() { + return (Pos() >= m_length); +} + + +int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { + switch (where) { + case START: + return _stream->seek(nBytes); + + case END: + return _stream->seek(nBytes, SEEK_END); + + case CUR: + return _stream->seek(nBytes, SEEK_CUR); + + default: + return 0; + } +} + + +bool RMFileStreamSlow::Read(void *buf, int size) { + uint32 dwRead; + + dwRead = _stream->read(buf, size); + return ((int)dwRead == size); +} + + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { + df.Read(&var, 1); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { + df.Read(&var,1); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { + uint16 v; + df.Read(&v, 2); + v = FROM_LE_16(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { + uint16 v; + df.Read(&v, 2); + var = (int16)FROM_LE_16(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { + int v; + df.Read(&v,4); + var = FROM_LE_32(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { + uint32 v; + df.Read(&v, 4); + var = FROM_LE_32(v); + return df; +} + + /****************************************************************************\ * RMDataStream methods \****************************************************************************/ @@ -458,7 +574,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns TRUE if end of stream reached, FALSE if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -546,7 +662,7 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { * Reads a series of data from the stream in a buffer * @param lpBuf Data buffer * @param size Size of the buffer - * @returns TRUE if we have reached the end, FALSE if not + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -609,7 +725,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns TRUE if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -714,7 +830,7 @@ RMPoint &RMPoint::operator+=(RMPoint p) { /** * Subtract (offset) of a point */ -RMPoint& RMPoint::operator-=(RMPoint p) { +RMPoint &RMPoint::operator-=(RMPoint p) { Offset(-p); return *this; } @@ -807,7 +923,7 @@ RMPoint &RMRect::TopLeft() { return *((RMPoint *)this); } -RMPoint& RMRect::BottomRight() { +RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad return *((RMPoint*)this + 1); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index f9c9e614ac..0ce4e83f27 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -140,9 +140,7 @@ public: class RMFileStreamSlow : public RMDataStream { private: - Common::File f; - bool bMustClose; - + Common::SeekableReadStream *_stream; public: RMFileStreamSlow(); virtual ~RMFileStreamSlow(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp new file mode 100644 index 0000000000..ab68030b90 --- /dev/null +++ b/engines/tony/window.cpp @@ -0,0 +1,1255 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi per la gestione * + * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct + * "#$e z$*" . `. ^*Nc e$"" Draw................. * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/window.h" +#include "tony/game.h" +#include "tony/tony.h" + +namespace Tony { + +#define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } + +// Tabella per il b&w. Globale per accederci dalla roba ASM +static uint16 m_wPrecalcTable[0x10000]; + +/****************************************************************************\ +* Metodi di RMWindow +\****************************************************************************/ + +#ifdef REFACTOR_ME +LRESULT CALLBACK GlobalWindowProc(HWND hWnd, uint32 msg, uint16 wParam, int32 lParam) { + if ((HWND)theGame.m_wnd == NULL) + return DefWindowProc(hWnd, msg, wParam, lParam); + + switch (msg) { + case WM_CREATE: + return 0; + + case WM_CLOSE: + PostQuitMessage(0); + return 0; + + default: + return theGame.m_wnd.WindowProc(msg, wParam, lParam); + } +} +#endif + +#ifdef REFACTOR_ME +LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { + switch (msg) { + case WM_ACTIVATE: + if (LOWORD(wParam)!=WA_INACTIVE) + theGame.Pause(false); + else + theGame.Pause(true); + return 0; + + case WM_ENTERMENULOOP: + case WM_ENTERSIZEMOVE: + if (!m_bFullscreen) + theGame.Pause(true); + return 0; + + case WM_EXITMENULOOP: + case WM_EXITSIZEMOVE: + if (!m_bFullscreen) + theGame.Pause(false); + return 0; +/* + case WM_KEYDOWN: + switch (wParam) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (GetAsyncKeyState(VK_CONTROL)&0x8000) + theGame.SaveState(wParam-'0'); + else if (GetAsyncKeyState(VK_SHIFT)&0x8000) + theGame.LoadState(wParam-'0'); + return 0; + } + return 0; +*/ + + case WM_PAINT: +// Repaint(); + ValidateRect(m_hWnd, NULL); + return 0; + + case WM_COMMAND: + switch LOWORD(wParam) { +/* + case ID_OPTIONS: + theGame.OptionScreen(); + break; +*/ + + case ID_FULLSCREEN: + theGame.SwitchFullscreen(!m_bFullscreen); + break; +/* + case ID_ENABLEINPUT: + theGame.GetEngine()->EnableInput(); + break; +*/ + case ID_SCREENSHOT: + m_bGrabScreenshot = true; +// m_bGrabMovie = !m_bGrabMovie; + break; + + case ID_MOVIE: +// m_bGrabMovie = !m_bGrabMovie; + break; +/* + case ID_BLACKWHITE: + m_bBlackWhite = !m_bBlackWhite; + break; +*/ + default: + return DefWindowProc(m_hWnd, msg, wParam, lParam); + } + return 0; + + case WM_SYSKEYDOWN: + if (m_bFullscreen) + return 0; + else + return DefWindowProc(m_hWnd ,msg, wParam, lParam); + + default: + if (m_hWnd != NULL) // Fix del bug visto da BoundsChecker + return DefWindowProc(m_hWnd, msg, wParam, lParam); + return 0; + } +} +#endif + +/* +HANDLE hWaitFlip; +bool bExitThread; + +void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) +{ + bExitThread=false; + + while (1) + { + WaitForSingleObject(hWaitFlip,INFINITE); + if (bExitThread) _endthread(); + lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); + } +} +*/ + +void RMWindow::InitDirectDraw(void) { +#ifdef REFACTOR_ME + DDInit(); + + ShowCursor(false); + ShowWindow(m_hWnd, SW_SHOW); + UpdateWindow(m_hWnd); +#endif +} + +void RMWindow::Init(/*HINSTANCE hInst*/) { +#ifdef REFACTOR_ME + WNDCLASS wc; + + // Registra la classe di finestra + wc.style = CS_HREDRAW|CS_VREDRAW; + wc.lpfnWndProc = GlobalWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInst; + wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_ICON1)); + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "RMClass"; + RegisterClass(&wc); + + m_hWnd = CreateWindow( + "RMClass", + "Tony Tough and the night of Roasted Moths", + WS_OVERLAPPEDWINDOW & (~WS_THICKFRAME) & (~WS_BORDER) & (~WS_MAXIMIZEBOX), + 50, 50, + RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, + RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION), + NULL, + NULL, + hInst, + NULL + ); + + if (m_hWnd == NULL) { + int err = GetLastError(); + RMString str; + + str.Format("error: %u",err); + MessageBox(NULL,str,"sux",MB_OK); + + assert(0); + } + + // Inizializza la finestra directdraw + //DDInit(); + + // Inizializza i conteggi degli FPS + fps = lastfcount = fcount = lastsecond = 0; + + m_bGrabScreenshot = false; + m_bGrabThumbnail = false; + m_bGrabMovie = false; + + //hWaitFlip = CreateEvent(NULL,false,false, NULL); +#endif +}; + +void RMWindow::Close(void) { + DDClose(); +#ifdef REFACTOR_ME + DestroyWindow(m_hWnd); +#endif +} + +void RMWindow::GrabThumbnail(uint16 *thumbmem) { + m_bGrabThumbnail = true; + m_wThumbBuf = thumbmem; +} + +float RGB_to_HSL(float r,float g, float b, float *h, float *s, float *l) { + float v; + float m; + float vm; + float r2, g2, b2; + + if (r > g) v = r; else v = g; + if (v > b) v = v; else v = b; + if (r < b) m = r; else m = b; + if (m < b) m = m; else m = b; + + if ((*l = (m + v) / 2.0f) <= 0.0f) return *l; + if ((*s = vm = v - m) > 0.0f) { + *s /= (*l <= 0.5f) ? (v + m) : (2.0f - v - m) ; + } else + return *l; + + r2 = (v - r) / vm; + g2 = (v - g) / vm; + b2 = (v - b) / vm; + + if (r == v) + *h = (g == m ? 5.0f + b2 : 1.0f - g2); + else if (g == v) + *h = (b == m ? 1.0f + r2 : 3.0f - b2); + else + *h = (r == m ? 3.0f + g2 : 5.0f - r2); + + *h /= 6; + + return *l; +} + +#define ITOF(val) (float)((float)(val) / 31.0f) +#define FTOI(val) (int)(((float)(val) * 31.0f + 0.5f)) + +void RMWindow::CreateBWPrecalcTable(void) { +#define CLAMP(var, min, max) var = (var < min ? min : (var > max ? max : var)); + + int i; + int r, g, b; + int min, max; + int shiftR, shiftG, shiftB; + + // Calcola i valori di shift in base alle maschere + for (shiftR = 15; (mskRed & (1 << shiftR)) == 0; shiftR--) + ; + for (shiftG = 15; (mskGreen & (1 << shiftG)) == 0; shiftG--) + ; + for (shiftB = 15; (mskBlue & (1 << shiftB)) == 0; shiftB--) + ; + + shiftR -= 4; + shiftG -= 4; + shiftB -= 4; + + // @@@ CLAMP inutile (in teoria) + CLAMP(shiftR, 0, 15); + CLAMP(shiftG, 0, 15); + CLAMP(shiftB, 0, 15); + + for (i = 0;i<0x10000;i++) + { + r=(i >> shiftR) & 0x1F; + g=(i >> shiftG) & 0x1F; + b=(i >> shiftB) & 0x1F; + +#if 1 + if (r < g) min=r; else min = g; + if (b < min) min = b; + if (r > g) max = r; else max = g; + if (b > max) max = b; + min = (min + max) / 2; +#else + // Nuova formula B&W. L'immagine pi fedele all'originale, ma l'effetto peggiore + float fr, fg, fb; + + fr = (float)r / 63.0f; + fg = (float)g / 63.0f; + fb = (float)b / 63.0f; + + min = (int)((fr*0.11f + fg*0.69f + fb*0.33f)*63.f); +#endif + + /* + RGB_to_HSL(ITOF(r), ITOF(g), ITOF(b), &h, &s, &l); + min = FTOI(l); + */ + + r = min + 8 - 8; + g = min + 5 - 8; + b = min + 0 - 8; + + CLAMP(r, 0, 31); + CLAMP(g, 0, 31); + CLAMP(b, 0, 31); + + m_wPrecalcTable[i] = (b << shiftB) | (g << shiftG) | (r << shiftR); + } +} + + +void RMWindow::DDClose(void) { +#ifdef REFACTOR_ME + DDRELEASE(m_Back); + DDRELEASE(m_Primary); + DDRELEASE(m_MainClipper); + DDRELEASE(m_BackClipper); + DDRELEASE(m_DD); +#endif +} + +void RMWindow::DDInit(void) { +#ifdef REFACTOR_ME + HRESULT err; + + // Crea DirectDraw + err = DirectDrawCreate(NULL, &m_DD, NULL); + assert(err == DD_OK); + + // Crea il clipper + err = DirectDrawCreateClipper(0, &m_MainClipper, NULL); + err=DirectDrawCreateClipper(0, &m_BackClipper, NULL); + + // Lo associa alla finestra + m_MainClipper->SetHWnd(0, m_hWnd); + + // Setta la cooperazione a normal + m_DD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL); + +#ifdef STARTFULLSCREEN + // Di default in fullscreen + m_bFullscreen=false; // Fa finta, per obbligarlo a cambiare + m_Primary=m_Back=NULL; + SwitchFullscreen(true); +#else + // Di default in finestra + m_bFullscreen = true; // Fa finta, per obbligarlo a cambiare + m_Primary = m_Back = NULL; + SwitchFullscreen(false); +#endif + +/* + if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) + { + RMString str; + str.Format("Graphic mode not supported: %04x %04x %04x",mskRed,mskGreen,mskBlue); + MessageBox(m_hWnd,str,"Debug",MB_OK); + } +*/ +#endif +} + + +void RMWindow::SwitchFullscreen(bool bFull) { +#ifdef REFACTOR_ME + HRESULT err; + DDSURFACEDESC ddsd; + DDSCAPS ddscaps; + DDBLTFX ddbltfx; + Common::Rect rcWin; + + // Se non c'e' niente da fare, esci + if (bFull == m_bFullscreen) + return; + + // Termina il thread di flipping + //bExitThread = true; + + // Rilascia le superfici create in precedenza (se ce n'erano) + DDRELEASE(m_Back); + DDRELEASE(m_Primary); + + // Legge le coordinate della finestra + if (m_bFullscreen) { + rcWin.left = 50; + rcWin.top = 50; + } else { + GetWindowRect(m_hWnd, &rcWin); + } + + if (bFull) { + // Setta la risoluzione + m_DD->SetCooperativeLevel(m_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT); + m_DD->SetDisplayMode(RM_SX, RM_SY, 16); + + // A tutto schermo, possiamo creare una catena di flipping + ZeroMemory(&ddsd, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; + ddsd.dwBackBufferCount = 1; + if ((err=m_DD->CreateSurface(&ddsd, &m_Primary, NULL)) != DD_OK) { + //wsprintf(errbuf,"Error creating primary surface2 (%lx)",err); + //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); + assert(0); + } + + ddscaps.dwCaps = DDSCAPS_BACKBUFFER; + if ((err=m_Primary->GetAttachedSurface(&ddscaps, &m_Back)) != DD_OK) { + //wsprintf(errbuf,"Error getting attached surface2 (%lx)",err); + //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); + assert(0); + } + + // Pulisce i buffer + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Back->Blt(NULL, NULL, NULL,DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + + ddbltfx.dwSize=sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Primary->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + + // Inizializza il thread + //_beginthread((void (*)(void*))DoFlipThread,10240,(void*)m_Primary); + } else { + // In windowed, non possiamo fare flipping (purtroppo) + m_DD->RestoreDisplayMode(); + m_DD->SetCooperativeLevel(m_hWnd,DDSCL_NORMAL); + + ZeroMemory(&ddsd,sizeof(ddsd)); + ddsd.dwSize=sizeof(ddsd); + ddsd.dwFlags=DDSD_CAPS; + ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE; + if ((err=m_DD->CreateSurface(&ddsd,&m_Primary, NULL)) != DD_OK) { + //wsprintf(errbuf,"Error creating primary surface (%lx)",err); + //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); + assert(0); + } + + ZeroMemory(&ddsd,sizeof(ddsd)); + ddsd.dwSize=sizeof(ddsd); + ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN; // se puo', in video memory + ddsd.dwWidth=RM_SX; + ddsd.dwHeight=RM_SY; + if ((err=m_DD->CreateSurface(&ddsd,&m_Back, NULL)) != DD_OK) { + //wsprintf(errbuf,"Error creating backbuffer surface (%lx)",err); + //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); + assert(0); + } + + // Pulizia per favore + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + } + + // Posiziona e ridimensiona la finestra + if (bFull) { + SetWindowPos(m_hWnd, HWND_TOP, 0, 0, RM_SX, RM_SY, 0); + + // Disabilita il clipper (non necessario) + m_Primary->SetClipper(NULL); + } else { + SetWindowPos(m_hWnd, HWND_TOP, rcWin.left, rcWin.top, RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, + RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), 0); + + m_Primary->SetClipper(m_MainClipper); + //m_Primary->SetClipper(NULL); + } + + // Si ricorda il nuovo stato + m_bFullscreen = bFull; + InvalidateRect(m_hWnd, NULL, false); + + // Legge il nuovo pixel format + UpdatePixelFormat(); +#endif +} + +void RMWindow::UpdatePixelFormat(void) { +#ifdef REFACTOR_ME + DDPIXELFORMAT ddpf; + + // Si fa ridare il nuovo pixel format + ddpf.dwSize = sizeof(ddpf); + m_Primary->GetPixelFormat(&ddpf); + + // Copia le componenti dei colori + mskRed = ddpf.dwRBitMask; + mskGreen = ddpf.dwGBitMask; + mskBlue = ddpf.dwBBitMask; + + // Ricalcola la tabella per l'effetto b&w + CreateBWPrecalcTable(); +#endif +} + + +void RMWindow::Repaint(void) { +#ifdef REFACTOR_ME + Common::Rect rcWin; + HRESULT err; + + if (m_Primary==NULL) + return; + + // Se siamo a tutto schermo, basta un flip + if (m_bFullscreen) { + m_DD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); + + // Flippa flappa + while (1) { + //err=m_Primary->Flip(NULL,DDFLIP_WAIT); + err = m_Primary->BltFast(0, 0, m_Back, NULL, DDBLTFAST_WAIT); + + if (err==DD_OK) + break; + else if (err == DDERR_SURFACELOST) { + //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); + m_Primary->Restore(); + return; + } + } + } + // Altrimenti bisogna andare di blit + else { + // Si calcola il rettangolo effettivamente visibile + GetWindowRect(m_hWnd, &rcWin); + OffsetRect(&rcWin, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION)); + + // Aggiusta le dimensioni del rettangolo + rcWin.right = rcWin.left + RM_SX; + rcWin.bottom = rcWin.top + RM_SY; + + // Blit del back nel primary + while (1) { + err = m_Primary->Blt(&rcWin, m_Back, NULL,DDBLT_WAIT, NULL); + if (err == DD_OK) + break; + else if (err == DDERR_SURFACELOST) { + //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); + m_Primary->Restore(); + return; + } + } + } +#endif +} + + +void RMWindow::Unlock(DDSURFACEDESC &ddsd) { +#ifdef REFACTOR_ME + m_Back->Unlock(ddsd.lpSurface); +#endif +} + +void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { +#ifdef REFACTOR_ME + Common::Rect rcScreen; + HRGN hrgnCombined; + HRGN hrgnScreen; + HRGN hrgnEllipse; + uint32 dwDataSize; + RGNDATA *rgnData; + + SetRect(&rcScreen, 0, 0, 640, 480); + + hrgnScreen = CreateRectRgnIndirect(&rcScreen); + hrgnEllipse = CreateEllipticRgnIndirect(&rcBoundEllipse); + hrgnCombined = CreateRectRgnIndirect(&rcScreen); + + CombineRgn(hrgnCombined, hrgnScreen, hrgnEllipse, RGN_DIFF); + + dwDataSize = GetRegionData(hrgnCombined, 0, NULL); + rgnData = (RGNDATA *)new char[dwDataSize]; + GetRegionData(hrgnCombined, dwDataSize, rgnData); + + m_BackClipper->SetClipList(rgnData, 0); + m_Back->SetClipper(m_BackClipper); + + DDBLTFX ddbltfx; + ddbltfx.dwSize=sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + + m_Back->SetClipper(NULL); + delete [] rgnData; + DeleteObject(hrgnCombined); + DeleteObject(hrgnEllipse); + DeleteObject(hrgnScreen); +#endif +} + +bool RMWindow::Lock(DDSURFACEDESC &ddsd) { +#ifdef REFACTOR_ME + HRESULT err; + + // Lock della surface + ddsd.dwSize = sizeof(ddsd); + while (1) { + err = m_Back->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_NOSYSLOCK, NULL); + if (err==DD_OK) + break; + else if (err==DDERR_SURFACELOST) { +// MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); + m_Back->Restore(); + return false; + } + } +#endif + return true; +} + +void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { +#ifdef REFACTOR_ME + HRESULT err; + DDSURFACEDESC ddsd; + int x,y; + byte *dest; + uint16 *destw; + RMString s; + uint16 *src,src2; + + if (GetAsyncKeyState(VK_F7)&0x8001) + goto DOFRAMERATE; + + if (!Lock(ddsd)) + return; + + // Copia del buffer + src = (uint16 *)lpBuf; + dest = (byte *)ddsd.lpSurface; +// src+=RM_SKIPY*RM_BBX; Lo skipY e' integrato nell'offseting del bigbuffer + + if (ISMODE2()) { + // 565 RGB, Marco - Matrox G200 + int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; + destw = (uint16 *)dest; + + if (bCfgAnni30) { + __asm { + pushad + + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + line30: + mov x,RM_SX + add esi,RM_SKIPX*2 + + line302: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + mov ecx,eax ; U 2 + mov edx,ebx ; V + and eax,0x7FE07FE0 ; U 3 + and ebx,0x7FE07FE0 ; V + and ecx,0x001F001F ; U 4 + and edx,0x001F001F ; V + shl eax,1 ; U 5 + shl ebx,1 ; V + or eax,ecx ; U 6 + or ebx,edx ; V + + // Codice B&W - Pairato + mov ecx,eax + mov edx,ebx + and eax,0xFFFF + and ebx,0xFFFF + shr ecx,16 + shr edx,16 + mov eax,[offset m_wPrecalcTable + eax*2] + mov ebx,[offset m_wPrecalcTable + ebx*2] + mov ecx,[offset m_wPrecalcTable + ecx*2] + mov edx,[offset m_wPrecalcTable + edx*2] + shl ecx,16 + shl edx,16 + and eax,0xFFFF + and ebx,0xFFFF + or eax,ecx + or ebx,edx + + mov [edi],eax ; U 7 + mov [edi+4],ebx ; V + add esi,8 ; U 8 + add edi,8 ; V + sub x,4 ; U 9 + jnz line302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz line30 + + popad + } + + } else { + __asm { + pushad + + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + line: + mov x,RM_SX + add esi,RM_SKIPX*2 + + line2: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + mov ecx,eax ; U 2 + mov edx,ebx ; V + and eax,0x7FE07FE0 ; U 3 + and ebx,0x7FE07FE0 ; V + and ecx,0x001F001F ; U 4 + and edx,0x001F001F ; V + shl eax,1 ; U 5 + shl ebx,1 ; V + or eax,ecx ; U 6 + or ebx,edx ; V + mov [edi],eax ; U 7 + mov [edi+4],ebx ; V + add esi,8 ; U 8 + add edi,8 ; V + sub x,4 ; U 9 + jnz line2 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz line + + popad + } + } + } else if (ISMODE3()) { + // 5551 RGB + int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; + destw=(uint16 *)dest; + + if (bCfgAnni30) { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + aline30: + mov x,RM_SX + add esi,RM_SKIPX*2 + + aline302: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + shl eax,1 ; U 2 + shl ebx,1 ; V + + // Codice B&W - Pairato + mov ecx,eax + mov edx,ebx + and eax,0xFFFF + and ebx,0xFFFF + shr ecx,16 + shr edx,16 + mov eax,[offset m_wPrecalcTable + eax*2] + mov ebx,[offset m_wPrecalcTable + ebx*2] + mov ecx,[offset m_wPrecalcTable + ecx*2] + mov edx,[offset m_wPrecalcTable + edx*2] + shl ecx,16 + shl edx,16 + and eax,0xFFFF + and ebx,0xFFFF + or eax,ecx + or ebx,edx + + mov [edi],eax ; U 3 + mov [edi+4],ebx ; V + add esi,8 ; U 4 + add edi,8 ; V + sub x,4 ; U 5 + jnz aline302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz aline30 + } + } else { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + aline: + mov x,RM_SX + add esi,RM_SKIPX*2 + + aline2: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + shl eax,1 ; U 2 + shl ebx,1 ; V + mov [edi],eax ; U 3 + mov [edi+4],ebx ; V + add esi,8 ; U 4 + add edi,8 ; V + sub x,4 ; U 5 + jnz aline2 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz aline + } + } + } else if (ISMODE4()) { + // 565 BGR - Intergraph + int lineinc=(ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2=(RM_BBX - RM_SKIPX - RM_SX) * 2; + destw=(uint16 *)dest; + + if (bCfgAnni30) // Manca supporto per Intergraph ... non so pairarlo!!! :) + { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + intersux30: + mov ecx,RM_SX + add esi,RM_SKIPX*2 + + intersux302: + mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + add esi,4 ; V + mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 + and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 + and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 + and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 + shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB + add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 + or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB + add edi,4 ; V + or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB + sub ecx,2 ; V + mov [edi-4],eax ; U 8 + jnz intersux302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz intersux30 + } + } else { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + intersux: + mov ecx,RM_SX + add esi,RM_SKIPX*2 + + intersux2: + mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + add esi,4 ; V + mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 + and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 + and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 + and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 + shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB + add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 + or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB + add edi,4 ; V + or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB + sub ecx,2 ; V + mov [edi-4],eax ; U 8 + jnz intersux2 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz intersux + } + } + } else { + // 555 RGB - Computer di Bagio, nVidia Riva 128 + int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; + destw=(uint16 *)dest; + + if (bCfgAnni30) { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + bagioline30: + mov x,RM_SX + add esi,RM_SKIPX*2 + + bagioline302: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + + // Codice B&W - Pairato + mov ecx,eax + mov edx,ebx + and eax,0xFFFF + and ebx,0xFFFF + shr ecx,16 + shr edx,16 + mov eax,[offset m_wPrecalcTable + eax*2] + mov ebx,[offset m_wPrecalcTable + ebx*2] + mov ecx,[offset m_wPrecalcTable + ecx*2] + mov edx,[offset m_wPrecalcTable + edx*2] + shl ecx,16 + shl edx,16 + and eax,0xFFFF + and ebx,0xFFFF + or eax,ecx + or ebx,edx + + mov [edi],eax ; U 3 + mov [edi+4],ebx ; V + add esi,8 ; U 4 + add edi,8 ; V + sub x,4 ; U 5 + jnz bagioline302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz bagioline30 + } + } else { + for (y = 0; y < RM_SY; y++) { + CopyMemory(dest, src + RM_SKIPX, RM_SX * 2); + dest += ddsd.lPitch; + src += RM_BBX; + } + } + } + + + // Unlock + Unlock(ddsd); + + // Effetto di wipe + if (rcBoundEllipse) { + WipeEffect(*rcBoundEllipse); + } + + // Repaint + Repaint(); + +DOFRAMERATE: + + // Conteggio per gli FPS + fcount++; + + if (lastsecond + 1000 < _vm->GetTime()) { + lastsecond = _vm->GetTime(); + fps=fcount - lastfcount; + lastfcount = fcount; + + if (!m_bFullscreen) { + s.Format("Tony Tough and the night of Roasted Moths - %u FPS",fps); + SetWindowText(m_hWnd,s); + } + } if (!_vm->getIsDemo()) { + if (m_bGrabScreenshot || m_bGrabMovie) { + RMSnapshot snapshot; + + snapshot.GrabScreenshot(lpBuf); + m_bGrabScreenshot = false; + } + + if (m_bGrabThumbnail) { + RMSnapshot snapshot; + + snapshot.GrabScreenshot(lpBuf, 4, m_wThumbBuf); + m_bGrabThumbnail = false; + } + } +#endif +} + + +/****************************************************************************\ +* Metodi di RMSnapshot +\****************************************************************************/ + +char RMSnapshot::bufDrive[_MAX_DRIVE]; +char RMSnapshot::bufDir[_MAX_DIR]; +char RMSnapshot::bufName[_MAX_FNAME]; +char RMSnapshot::bufExt[_MAX_EXT]; +char RMSnapshot::filename[512]; +byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; + +bool RMSnapshot::GetFreeSnapName(char *fn) { +#ifdef REFACTOR_ME + int i, j, k; + HANDLE h; + + theGame.GetDataDirectory(RMGame::DD_SHOTS, fn); + _splitpath(fn, bufDrive, bufDir, NULL, NULL); + + for (i = 1; i < 10; i++) { + wsprintf(bufName,"rm%d00",i); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) + break; + CloseHandle(h); + } + + i--; + + for (j = 1; j < 10; j++) { + wsprintf(bufName,"rm%d%d0",i,j); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + if (h==INVALID_HANDLE_VALUE) + break; + CloseHandle(h); + } + + j--; + + for (k = 0; k < 10; k++) { + wsprintf(bufName,"rm%d%d%d",i,j,k); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + if (h==INVALID_HANDLE_VALUE) + break; + CloseHandle(h); + } + + if (k == 10) { + k = 0; + j++; + if (j == 10) { + j = 0; + i++; + if (i == 10) + return false; + } + + wsprintf(bufName,"rm%d%d%d",i,j,k); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + } +#endif + return true; +} + +void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { +#ifdef REFACTOR_ME + uint16 *src = (uint16 *)lpBuf; + + int dimx = RM_SX / dezoom; + int dimy = RM_SY / dezoom; + + int u, v, curv; + + uint16 appo; + uint32 k = 0; + int sommar, sommab, sommag; + uint16 *cursrc; + + if (lpDestBuf == NULL) + src += (RM_SY - 1) * RM_BBX; + + if (dezoom == 1 && 0) { // @@@ NON E' TESTATA MOLTO BENE!!! + byte *curOut = rgb; + + for (int y = 0; y < dimy; y++) { + for (int x = 0; x < dimx; x++) { + cursrc = &src[RM_SKIPX + x]; + + *curOut++ = ((*cursrc) & 0x1F) << 3; + *curOut++ = (((*cursrc) >> 5) & 0x1F) << 3; + *curOut++ = (((*cursrc) >> 10) & 0x1F) << 3; + + if (lpDestBuf) + *lpDestBuf++ = *cursrc; + } + + if (lpDestBuf == NULL) + src -= RM_BBX; + else + src += RM_BBX; + } + } else { + for (int y = 0; y < dimy; y++) { + for(int x = 0; x < dimx; x++) { + cursrc = &src[RM_SKIPX + x * dezoom]; + sommar = sommab = sommag = 0; + + for (v = 0; v < dezoom; v++) + for (u = 0; u < dezoom; u++) { + if (lpDestBuf == NULL) + curv = -v; + else + curv = v; + + sommab += cursrc[curv*RM_BBX + u] & 0x1F; + sommag += (cursrc[curv*RM_BBX + u] >> 5) & 0x1F; + sommar += (cursrc[curv*RM_BBX + u] >> 10) & 0x1F; + } + + rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); + + if (lpDestBuf!=NULL) + lpDestBuf[k/3] = ((int)rgb[k+0]>>3) | (((int)rgb[k+1]>>3)<<5) | (((int)rgb[k+2]>>3)<<10); + + k+=3; + } + + if (lpDestBuf == NULL) + src -= RM_BBX * dezoom; + else + src += RM_BBX * dezoom; + } + } + + + if (lpDestBuf == NULL) { + if (!GetFreeSnapName(filename)) + return; + + HANDLE hFile = CreateFile(filename, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, + NULL); + + BITMAPFILEHEADER bmfHeader; + bmfHeader.bfType = ((uint16) ('M' << 8) | 'B'); + bmfHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dimx * dimy * 3; + bmfHeader.bfReserved1 = 0; + bmfHeader.bfReserved2 = 0; + bmfHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + + BITMAPINFOHEADER bmiHeader; + bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmiHeader.biWidth = dimx; + bmiHeader.biHeight = dimy; + bmiHeader.biPlanes = 1; + bmiHeader.biBitCount = 24; + bmiHeader.biCompression = BI_RGB; + bmiHeader.biSizeImage = dimx * dimy * 3; + bmiHeader.biXPelsPerMeter = 0xB12; + bmiHeader.biYPelsPerMeter = 0xB12; + bmiHeader.biClrUsed = 0; + bmiHeader.biClrImportant = 0; + + uint32 dwWritten; + WriteFile(hFile, &bmfHeader, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); + WriteFile(hFile, &bmiHeader, sizeof(BITMAPINFOHEADER), &dwWritten, NULL); + + WriteFile(hFile, rgb, dimx * dimy * 3, &dwWritten, NULL); + CloseHandle(hFile); + } +#endif +} + +} // End of namespace Tony diff --git a/engines/tony/window.h b/engines/tony/window.h index d248ffb871..25aef5c619 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -50,15 +50,36 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "tony/adv.h" namespace Tony { typedef uint32 HWND; +struct DDSURFACEDESC { +}; + +class RMSnapshot { +private: + // Buffer per la creazione dei path + static char bufDrive[_MAX_DRIVE], bufDir[_MAX_DIR], bufName[_MAX_FNAME], bufExt[_MAX_EXT]; + static char filename[512]; + + // Buffer per la conversione a RGB + static byte rgb[RM_SX * RM_SY * 3]; + +private: + bool GetFreeSnapName(char *fn); + +public: + // Prende uno screenshot + void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); +}; + class RMWindow { private: - bool Lock(/*DDSURFACEDESC& ddsd */); - void Unlock(/*DDSURFACEDESC& ddsd */); + bool Lock(DDSURFACEDESC &ddsd); + void Unlock(DDSURFACEDESC &ddsd); // Inizializza DirectDraw void DDInit(void); @@ -115,7 +136,7 @@ protected: void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); // Avverte di grabbare un thumbnail per il salvataggio -// void GrabThumbnail(uint16 *buf); + void GrabThumbnail(uint16 *buf); operator HWND() { return m_hWnd; } -- cgit v1.2.3 From 6d0f1fca46c8bd9b5b4e7ccaf6631850c29d1447 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 23:08:19 +1000 Subject: TONY: Formatting fixes --- engines/tony/custom.cpp | 94 +++++++++++++++++++++------------------------- engines/tony/font.cpp | 40 +++++++------------- engines/tony/game.cpp | 22 +++++------ engines/tony/gfxcore.cpp | 87 +++++++++++++++++------------------------- engines/tony/gfxengine.cpp | 74 +++++++++--------------------------- engines/tony/input.cpp | 50 ++++++++---------------- engines/tony/inventory.cpp | 24 +++++------- engines/tony/loc.cpp | 29 +++++--------- engines/tony/mpal/mpal.cpp | 6 +-- engines/tony/tonychar.cpp | 6 +-- engines/tony/window.cpp | 15 +++----- 11 files changed, 163 insertions(+), 284 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 55f6cbe77d..209fc11212 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -218,7 +218,7 @@ int curChangedHotspot = 0; struct { uint32 dwCode; - uint32 nX,nY; + uint32 nX, nY; void Save(Common::OutSaveFile *f) { f->writeUint32LE(dwCode); @@ -629,7 +629,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint3 Unfreeze(); - h = mpalQueryDoAction(0,nLoc,0); + h = mpalQueryDoAction(0, nLoc,0); if (!bNoOcchioDiBue) { WaitWipeEnd(); @@ -1079,18 +1079,18 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(uint32 nX, uint32 nY, uint32 nLoc, uint32) { - Tony->SetPosition(RMPoint(nX,nY),nLoc); + Tony->SetPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(RMPoint(nX,nY)); + Tony->Move(RMPoint(nX, nY)); if (!bSkipIdle) Tony->WaitForEndMovement(); } DECLARE_CUSTOM_FUNCTION(MoveTony)(uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(RMPoint(nX,nY)); + Tony->Move(RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1103,22 +1103,20 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 pt=Loc->ScrollPosition(); - while ((lx != 0 || ly != 0) && !bSkipIdle) { - if (lx>0) { - lx -= (int32)sX; if (lx<0) lx = 0; + while ((lx != 0 || ly != 0) && !bSkipIdle) { + if (lx > 0) { + lx -= (int32)sX; if (lx < 0) lx = 0; pt.Offset((int32)sX, 0); - } else if (lx<0) { - lx += (int32)sX; if (lx>0) lx = 0; + } else if (lx < 0) { + lx += (int32)sX; if (lx > 0) lx = 0; pt.Offset(-(int32)sX, 0); } if (ly > 0) { - ly-=sY; if (ly<0) ly = 0; - pt.Offset(0,sY); - } - else if (ly<0) - { - ly+=sY; if (ly>0) ly = 0; + ly -= sY; if (ly < 0) ly = 0; + pt.Offset(0, sY); + } else if (ly < 0) { + ly += sY; if (ly > 0) ly = 0; pt.Offset(0, -(int32)sY); } @@ -1134,18 +1132,18 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { int lx, ly; - RMPoint pt,startpt; - uint32 dwStartTime,dwCurTime,dwTotalTime; + RMPoint pt, startpt; + uint32 dwStartTime, dwCurTime, dwTotalTime; uint32 stepX, stepY; - int dimx,dimy; + int dimx, dimy; // Prende le coordinate di quanto scrollare lx=*((int*)&nX); ly=*((int*)&nY); - dimx=lx; - dimy=ly; - if (lx<0) dimx = -lx; - if (ly<0) dimy = -ly; + dimx = lx; + dimy = ly; + if (lx < 0) dimx = -lx; + if (ly < 0) dimy = -ly; stepX = sX; stepY = sY; @@ -1155,13 +1153,12 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin dwStartTime = timeGetTime(); if (sX) - dwTotalTime = dimx*(1000/35)/sX; + dwTotalTime = dimx * (1000 / 35) / sX; else - dwTotalTime = dimy*(1000/35)/sY; + dwTotalTime = dimy * (1000 / 35) / sY; - while ((lx != 0 || ly != 0) && !bSkipIdle) - { - dwCurTime=timeGetTime()-dwStartTime; + while ((lx != 0 || ly != 0) && !bSkipIdle) { + dwCurTime = _vm->GetTime() - dwStartTime; if (dwCurTime>dwTotalTime) break; @@ -1181,28 +1178,22 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin } /* - sX = stepX * (dwCurTime-dwLastTime) / (1000/35); - sY = stepY * (dwCurTime-dwLastTime) / (1000/35); + sX = stepX * (dwCurTime-dwLastTime) / (1000 / 35); + sY = stepY * (dwCurTime-dwLastTime) / (1000 / 35); - if (lx>0) - { - lx-=sX; if (lx<0) lx = 0; + if (lx > 0) { + lx-=sX; if (lx < 0) lx = 0; pt.Offset(sX,0); - } - else if (lx<0) - { - lx+=sX; if (lx>0) lx = 0; + } else if (lx < 0) { + lx+=sX; if (lx > 0) lx = 0; pt.Offset(-sX,0); } - if (ly>0) - { + if (ly > 0) { ly-=sY; if (ly<0) ly = 0; pt.Offset(0,sY); - } - else if (ly<0) - { - ly+=sY; if (ly>0) ly = 0; + } else if (ly<0) { + ly+=sY; if (ly > 0) ly = 0; pt.Offset(0,-sY); } */ @@ -1218,12 +1209,12 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin // Setta la posizione finale if (sX) { - if (lx>0) + if (lx > 0) pt.x = startpt.x + dimx; else pt.x = startpt.x - dimx; } else { - if (ly>0) + if (ly > 0) pt.y = startpt.y + dimy; else pt.y = startpt.y - dimy; @@ -1254,7 +1245,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint curChangedHotspot++; } - Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX,nY)); + Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); } @@ -1274,7 +1265,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { dirx = 1; diry = 1; - while (_vm->GetTime() < curTime + nScosse) { + while (_vm->GetTime() < curTime + nScosse) { WaitFrame(); Freeze(); @@ -1359,7 +1350,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); FPSFX *voice = NULL; - if (curVoc) { + if (curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); g_system->lockMutex(vdb); @@ -1734,7 +1725,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, ui parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; - if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { + if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata @@ -1849,9 +1840,8 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, ; // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta - if (num==1) - { - mpalQueryDialogSelection(nChoice,sl[0]); + if (num == 1) { + mpalQueryDialogSelection(nChoice, sl[0]); GlobalFree(sl); continue; } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a0500047b6..4bfddc8d68 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -89,31 +89,24 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; #if 0 - if (nChars == 112 && palResID == RES_F_PAL) - { + if (nChars == 112 && palResID == RES_F_PAL) { // Font parla DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } - else if (nChars == 102 && palResID == RES_F_PAL) - { + else if (nChars == 102 && palResID == RES_F_PAL) { // Font macc DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } - else if (nChars == 85 && palResID == RES_F_PAL) - { + } else if (nChars == 85 && palResID == RES_F_PAL) { // Font obj DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } - else if (nChars == 112 && palResID == RES_F_CPAL) - { + } else if (nChars == 112 && palResID == RES_F_CPAL) { // Font credits DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } #endif // Carichiamoce 'sto font - for (int i = 0; i < nChars; i++) - { + for (int i = 0; i < nChars; i++) { // Inizializza il buffer con le lettere m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); m_letter[i].LoadPaletteWA(palResID); @@ -261,8 +254,7 @@ void RMFontParla::Init(void) { lDefault = 13; hDefault = 18; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } @@ -1042,8 +1034,7 @@ void RMFontCredits::Init(void) { hDefault=28; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } @@ -1514,20 +1505,18 @@ void RMFontObj::Init(void) { hDefault = 30; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } - for (i = 0; i < 26; i++) - { - cTable['A'+i] = i+0; - cTable['a'+i] = i+0; + for (i = 0; i < 26; i++) { + cTable['A' + i] = i+0; + cTable['a' + i] = i+0; } for (i = 0; i < 10; i++) - cTable['0'+i] = i+26; + cTable['0' + i] = i + 26; cTable[','] = 36; cTable[';'] = 37; @@ -2255,8 +2244,7 @@ void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPoint WriteText(itemName, 1); // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer - if (lastItem != m_item) - { + if (lastItem != m_item) { if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { @@ -2395,7 +2383,7 @@ void RMDialogChoice::Prepare(void) { ptPos.Set(20,90); - for (i = 0; i < m_numChoices; i++) { + for (i = 0; i < m_numChoices; i++) { AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); m_ptDrawStrings[i] = ptPos; ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00bb81dcf4..6853c53bf0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -398,8 +398,7 @@ void RMOptionScreen::RefreshAll(void) { if (m_bNoLoadSave) AddPrim(new RMGfxPrimitive(m_HideLoadSave,RMPoint(0, 401))); - if (m_bQuitConfirm) - { + if (m_bQuitConfirm) { AddPrim(new RMGfxPrimitive(m_QuitConfirm,RMPoint(270, 200))); m_ButtonQuitYes->AddToList(*this); m_ButtonQuitNo->AddToList(*this); @@ -568,9 +567,7 @@ void RMOptionScreen::InitState(void) { if (m_bAlterGfx) { assert(m_ButtonExit == NULL); m_ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); - } - else - { + } else { assert(m_ButtonExit == NULL); m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } @@ -974,12 +971,12 @@ void RMOptionScreen::DoFrame(RMInput *input) { m_ButtonSoundMenu->DoFrame(mousePos, bLeftClick, bRightClick); // bottoni con grafica - if (!m_bNoLoadSave) - { -#ifndef DEMO - bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); -#endif + if (!m_bNoLoadSave) { + if (!_vm->getIsDemo()) { + bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); + } + bRefresh |= m_ButtonQuit->DoFrame(mousePos, bLeftClick, bRightClick); } } @@ -1207,8 +1204,7 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { m_FadeY += FADE_SPEED; else m_FadeY += FADE_SPEED*SYNC; - if (m_FadeY > 480) - { + if (m_FadeY > 480) { m_FadeY = 480; m_FadeStep++; } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 1d289fbecc..a25c28a03d 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -198,13 +198,10 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int /* OBSOLETE CODE: - if (buf == NULL) - { + if (buf == NULL) { destw=RM_SX; desth=RM_SY; - } - else - { + } else { destw = buf->Dimx(); desth = buf->Dimy(); } @@ -391,8 +388,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { otlist->next = NULL; } // Inserimento in testa - else if (nPrior < otlist->prim->m_task->Priority()) - { + else if (nPrior < otlist->prim->m_task->Priority()) { n->next = otlist; otlist = n; } else { @@ -452,8 +448,7 @@ int RMGfxSourceBufferPal::LoadPalette(const byte *buf) { void RMGfxSourceBufferPal::PreparePalette(void) { int i; - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { m_palFinal[i] = (((int)m_pal[i * 3 + 0] >> 3) << 10) | (((int)m_pal[i * 3 + 1] >> 3) << 5) | (((int)m_pal[i * 3 + 2] >> 3) << 0); @@ -575,16 +570,15 @@ void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { for (y = 0; y < height; y++) { raw = m_buf + (y + v) * m_dimx + u; - for (x = 0;xIsFlipped()) - { + if (prim->IsFlipped()) { // Annulliamo il clipping orizzontale // width = m_dimx; // x1=prim->Dst().x1; @@ -877,30 +870,26 @@ void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim u = m_dimx - (width+u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; - for (y = 0;y= nStartSkip) { + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; if (nLength > 0) @@ -1012,8 +1001,7 @@ RLEByteDoAlpha: RLEByteDoAlpha2: if (n > nLength) n = nLength; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { r=(*dst >> 10) & 0x1F; g=(*dst >> 5) & 0x1F; b=*dst & 0x1F; @@ -1022,7 +1010,7 @@ RLEByteDoAlpha2: g=(g >> 2) + (alphaG >> 1); b=(b >> 2) + (alphaB >> 1); - *dst++=(r<<10)|(g<<5)|b; + *dst ++= (r << 10) | (g << 5) | b; } nLength -= n; @@ -1233,8 +1221,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS n = READ_LE_UINT16(src); src += 2; - if (n>=nStartSkip) - { + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; goto RLEWordDoCopy2; @@ -1244,8 +1231,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS } - while (1) - { + while (1) { RLEWordDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); @@ -1326,8 +1312,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, if (n == 0xFFFF) return; - if (n>=nStartSkip) - { + if (n >= nStartSkip) { dst -= n - nStartSkip; nLength -= n - nStartSkip; @@ -1344,8 +1329,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, n = READ_LE_UINT16(src); src += 2; - if (n>=nStartSkip) - { + if (n >= nStartSkip) { n -= nStartSkip; goto RLEWordFlippedDoAlpha2; } @@ -1440,7 +1424,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int int i, n; int r, g, b, r2, g2, b2; - if (!bCfgTransparence) { + if (!bCfgTransparence) { RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); return; } @@ -1485,8 +1469,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int n = READ_LE_UINT16(src); src += 2; - if (n >= nStartSkip) - { + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; goto RLEWordDoCopy2; @@ -1549,18 +1532,18 @@ RLEWordDoCopy2: if (n > nLength) n = nLength; - for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + for (i = 0; i < n; i++) { + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r2=(m_palFinal[*src] >> 10) & 0x1F; - g2=(m_palFinal[*src] >> 5) & 0x1F; + r2 = (m_palFinal[*src] >> 10) & 0x1F; + g2 = (m_palFinal[*src] >> 5) & 0x1F; b2 = m_palFinal[*src] & 0x1F; - r=(r >> 1) + (r2 >> 1); - g=(g >> 1) + (g2 >> 1); - b=(b >> 1) + (b2 >> 1); + r = (r >> 1) + (r2 >> 1); + g = (g >> 1) + (g2 >> 1); + b = (b >> 1) + (b2 >> 1); *dst ++= (r << 10) | (g << 5) | b; src++; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index d4ea8ee821..77a196f853 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -139,7 +139,7 @@ void RMGfxEngine::DoFrame(bool bDrawLocation) { // Poll dei dispositivi di input m_input.Poll(); - if (m_bMustEnterMenu && bIdleExited) { + if (m_bMustEnterMenu && bIdleExited) { m_bOption = true; m_bMustEnterMenu = false; bIdleExited = false; @@ -216,8 +216,7 @@ void RMGfxEngine::DoFrame(bool bDrawLocation) { // CLICK SINISTRO // ************** - if (m_input.MouseLeftClicked() && !m_inter.Active()) - { + if (m_input.MouseLeftClicked() && !m_inter.Active()) { // Se clicko dentro un oggetto, esegui l'azione //if (m_itemName.IsItemSelected()) { @@ -383,8 +382,7 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { bool bEnableParent = false; m_ofn.hwndOwner = PreModal(); AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) - { + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { bEnableParent = true; ::EnableWindow(m_ofn.hwndOwner, false); } @@ -489,8 +487,7 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { continue; #if 0 // codice per dumpare una locazione in caso serva una modifica - if (nLoc == 106) - { + if (nLoc == 106) { FILE *f = fopen("loc106.lox", "wb"); fwrite(res.DataPointer(), res.Size(), 1, f); fclose(f); @@ -514,19 +511,17 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) -{ +HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { HANDLE h; // Scarica tutta la memoria della locazione mpalEndIdlePoll(m_nCurLoc); // On Exit? - if (bDoOnExit) - { - h=mpalQueryDoAction(1,m_nCurLoc,0); - if (h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + if (bDoOnExit) { + h = mpalQueryDoAction(1, m_nCurLoc, 0); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h, INFINITE); } MainFreeze(); @@ -633,8 +628,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); } -void RMGfxEngine::Close(void) -{ +void RMGfxEngine::Close(void) { m_bigBuf.ClearOT(); m_inter.Close(); @@ -644,68 +638,36 @@ void RMGfxEngine::Close(void) m_input.Close(); } -void RMGfxEngine::SwitchFullscreen(bool bFull) -{ +void RMGfxEngine::SwitchFullscreen(bool bFull) { m_input.SwitchFullscreen(bFull); } -void RMGfxEngine::GDIControl(bool bCon) -{ +void RMGfxEngine::GDIControl(bool bCon) { m_input.GDIControl(bCon); } -/* -void RMGfxEngine::OptionScreen(void) -{ - if (!m_bOption) - { - if (m_opt.Init(m_bigBuf)) - { - m_bOption = true; - DisableInput(); - EnableMouse(); - } - } - else - { - if (m_opt.Close()) - { - m_bOption = false; - DisableMouse(); - EnableInput(); - } - } -} -*/ - -void RMGfxEngine::EnableInput(void) -{ +void RMGfxEngine::EnableInput(void) { m_bInput = true; } -void RMGfxEngine::DisableInput(void) -{ +void RMGfxEngine::DisableInput(void) { m_bInput = false; m_inter.Reset(); } -void RMGfxEngine::EnableMouse(void) -{ +void RMGfxEngine::EnableMouse(void) { m_bAlwaysDrawMouse = true; } -void RMGfxEngine::DisableMouse(void) -{ +void RMGfxEngine::DisableMouse(void) { m_bAlwaysDrawMouse = false; } -void RMGfxEngine::Freeze(void) -{ +void RMGfxEngine::Freeze(void) { g_system->lockMutex(csMainLoop); } -void RMGfxEngine::Unfreeze(void) -{ +void RMGfxEngine::Unfreeze(void) { g_system->unlockMutex(csMainLoop); } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 72c7bf06f7..25f271d7eb 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -57,8 +57,7 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea l'oggetto madre err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); assert(0); } @@ -66,24 +65,21 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea il device del mouse // ************************ err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il data format err=m_DIDMouse->SetDataFormat(&c_dfDIMouse); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -91,24 +87,21 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea il device della tastiera // ***************************** err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il data format err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il cooperative level err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -126,22 +119,17 @@ void RMInput::SwitchFullscreen(bool bFull) { // cooperative level Unacquire(); - if (bFull) - { + if (bFull) { // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } - } - else - { + } else { // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -197,13 +185,10 @@ void RMInput::Unacquire(void) { void RMInput::GDIControl(bool bCon) { #ifdef REFACTOR_ME - if (bCon) - { + if (bCon) { Unacquire(); ShowCursor(true); - } - else - { + } else { ShowCursor(false); Acquire(); } @@ -220,14 +205,12 @@ void RMInput::Poll(void) { m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; // Legge lo stato del mouse - while (1) - { + while (1) { ZeroMemory(&m_mState,sizeof(m_mState)); err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); if (err==DI_OK) break; - else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) - { + else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) { ZeroMemory(&m_mState,sizeof(m_mState)); // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere if (!Acquire()) @@ -242,8 +225,7 @@ void RMInput::Poll(void) { m_mY+=m_mState.lY; // Clamp dei valori sui bordi della finestra - if (m_bClampMouse) - { + if (m_bClampMouse) { if (m_mX<0) m_mX=0; if (m_mY<0) m_mY=0; if (m_mX>=640) m_mX=639; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 2ce88b1cec..50969afca8 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -121,8 +121,7 @@ void RMInventory::Init(void) { m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; - for (j=0;jlockMutex(m_csModifyInterface); Common::copy_backward(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); @@ -254,15 +252,13 @@ void RMInventory::RemoveItem(int code) { } void RMInventory::AddItem(int code) { - if (code <= 10000 && code >= 10101) - { + if (code <= 10000 && code >= 10101) { // Se siamo qui, vuol dire che stiamo aggiungendo un oggetto che non dovrebbe essere // nell'inventario warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { g_system->lockMutex(m_csModifyInterface); - if (m_curPos+8 == m_nInv) - { + if (m_curPos + 8 == m_nInv) { // Sfondiamo l'inventario! Attivo il pattern di lampeggio m_items[28].icon.SetPattern(2); } @@ -352,8 +348,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } // Click sulla freccia destra - if ((m_state == OPENED) && m_bBlinkingRight) - { + if ((m_state == OPENED) && m_bBlinkingRight) { g_system->lockMutex(m_csModifyInterface); m_curPos++; @@ -408,11 +403,10 @@ void RMInventory::RightClick(RMPoint mpos) { // Apre l'interfaccina contestuale n = mpos.x / 64; - if (n > 0 && n < RM_SX / 64-1 && m_inv[n-1+m_curPos]!=0) - { - m_state=SELECTING; - miniAction=0; - m_nSelectObj=n-1; + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { + m_state = SELECTING; + miniAction = 0; + m_nSelectObj = n - 1; _vm->PlayUtilSFX(0); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 141b993714..3d86b78f31 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -222,20 +222,15 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { // Se speed! = 0, suona solo quelli in loop for (i = 0;i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { - if (i == 0) - { - if (sfx[m_slots[i].m_data].m_name[0]=='_') - { + if (i == 0) { + if (sfx[m_slots[i].m_data].m_name[0] == '_') { sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); - } - else - { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + } else { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } - } - else if (m_speed == 0) { + } else if (m_speed == 0) { if (bPlayP0) { sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); @@ -330,8 +325,7 @@ RMPattern::RMPattern() { } RMPattern::~RMPattern() { - if (m_slots != NULL) - { + if (m_slots != NULL) { delete[] m_slots; m_slots = NULL; } @@ -807,8 +801,7 @@ bool RMItem::GetName(RMString& name) void RMItem::Unload(void) { - if (m_patterns != NULL) - { + if (m_patterns != NULL) { delete[] m_patterns; m_patterns = NULL; } @@ -943,8 +936,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { m_bMustRegister = false; } - if (m_bFading) - { + if (m_bFading) { m_wip0r.DoFrame(&bigBuf, false); m_nFadeStep++; @@ -1671,8 +1663,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { ds >> bottom; // Adiacenza - for (i = 0; i < MAXBOXES; i++) - { + for (i = 0; i < MAXBOXES; i++) { ds >> adj[i]; } @@ -2174,7 +2165,7 @@ RMItem *RMLocation::WhichItemIsIn(RMPoint pt) { int foundSize = 0; int size; - for (int i = 0; i < m_nItems; i++) { + for (int i = 0; i < m_nItems; i++) { size = 0; if (m_items[i].IsIn(pt, &size)) { if (found == -1 || size < foundSize) { diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index b4b37e7723..74dbedd90f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -2902,10 +2902,8 @@ case num: \ return DLG##num[nPers]; -char *GetPersonName(uint16 nDlg, int nPers) -{ - switch (nDlg) - { +char *GetPersonName(uint16 nDlg, int nPers) { + switch (nDlg) { HANDLE_DIALOG(10); HANDLE_DIALOG(51); HANDLE_DIALOG(52); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 493f10ef29..7809d9c080 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -126,7 +126,7 @@ void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { // Esegue il movimento normale del personaggio int time = _vm->GetTime(); - do { + do { m_nTimeLastStep += (1000 / 40); RMCharacter::DoFrame(bigBuf, curLoc); @@ -155,8 +155,8 @@ void RMTony::Hide(bool bShowOmbra) { void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Richiama il Draw() della classe madre se tony visibile - if (m_bShow && bDrawNow) { - if (m_bCorpoDavanti) { + if (m_bShow && bDrawNow) { + if (m_bCorpoDavanti) { prim->Dst().SetEmpty(); prim->Dst().Offset(-44, -134); if (m_bPastorella) diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index ab68030b90..a6dd20b875 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -102,8 +102,7 @@ LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { return 0; /* case WM_KEYDOWN: - switch (wParam) - { + switch (wParam) { case '0': case '1': case '2': @@ -180,12 +179,10 @@ LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { HANDLE hWaitFlip; bool bExitThread; -void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) -{ +void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) { bExitThread=false; - while (1) - { + while (1) { WaitForSingleObject(hWaitFlip,INFINITE); if (bExitThread) _endthread(); lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); @@ -330,8 +327,7 @@ void RMWindow::CreateBWPrecalcTable(void) { CLAMP(shiftG, 0, 15); CLAMP(shiftB, 0, 15); - for (i = 0;i<0x10000;i++) - { + for (i = 0; i < 0x10000; i++) { r=(i >> shiftR) & 0x1F; g=(i >> shiftG) & 0x1F; b=(i >> shiftB) & 0x1F; @@ -412,8 +408,7 @@ void RMWindow::DDInit(void) { #endif /* - if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) - { + if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) { RMString str; str.Format("Graphic mode not supported: %04x %04x %04x",mskRed,mskGreen,mskBlue); MessageBox(m_hWnd,str,"Debug",MB_OK); -- cgit v1.2.3 From 5b2c69b1f291b1ee3d7f3be4ffd40e427b437ac6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 00:11:38 +1000 Subject: TONY: Implemented some missing and incorrect init code --- engines/tony/custom.cpp | 7 ++-- engines/tony/font.cpp | 6 ++-- engines/tony/gfxcore.cpp | 5 ++- engines/tony/gfxengine.cpp | 3 ++ engines/tony/inventory.cpp | 2 ++ engines/tony/loc.cpp | 4 +-- engines/tony/mpal/mpal.cpp | 8 ++--- engines/tony/tony.cpp | 82 ++++++++++++++++++++++++++++++++++++++++------ engines/tony/tony.h | 33 ++++++++++++------- 9 files changed, 114 insertions(+), 36 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 209fc11212..6f6e7a1534 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2447,13 +2447,14 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation EnableGUI = MainEnableGUI; SetPalesati = MainSetPalesati; - g_system->lockMutex(vdb); + vdb = g_system->createMutex(); bAlwaysDisplay = false; int i; -/* + for (i = 0;i < 10; i++) - InitializeCriticalSection(&cs[i]); + cs[i] = g_system->createMutex(); +/* for (i = 0;i < 10; i++) mut[i] = CreateMutex(NULL, false, NULL); */ diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 4bfddc8d68..ec5a78731b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -702,7 +702,7 @@ void RMFontMacc::Init(void) { cTable[':'] = 80; cTable['-'] = 81; cTable['<'] = 82; - cTable[' > '] = 83; + cTable['>'] = 83; cTable['/'] = 84; cTable[''] = 85; cTable[''] = 86; @@ -1541,7 +1541,7 @@ void RMFontObj::Init(void) { cTable['^'] = 56; cTable['*'] = 57; cTable['<'] = 58; - cTable[' > '] = 59; + cTable['>'] = 59; cTable[''] = 60; cTable[''] = 61; cTable[''] = 62; @@ -1847,6 +1847,8 @@ void RMText::WriteText(RMString text, int nFont, int *time) { m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); + + m_cs = g_system->createMutex(); } g_system->lockMutex(m_cs); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index a25c28a03d..b5dc79687a 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -290,15 +290,14 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; -// InitializeCriticalSection(&csModifyingOT); + csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { ClearOT(); -// DeleteCriticalSection(&csModifyingOT); + g_system->deleteMutex(csModifyingOT); } - void RMGfxTargetBuffer::ClearOT(void) { OTList *cur, *n; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 77a196f853..940fb2afe8 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -572,6 +572,9 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_bWiping = false; m_hWipeEvent = CreateEvent(NULL, false, false, NULL); + // Crea l'evento di freeze + csMainLoop = g_system->createMutex(); + // Inizializza la funzione di IRQ di Item per l'MPAL ItemIrq((uint32)-1, (uint32)this, 0); mpalInstallItemIrq(ItemIrq); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 50969afca8..1442708d56 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -62,10 +62,12 @@ RMInventory::RMInventory() { m_items = NULL; m_state = CLOSED; m_bCombining = false; + m_csModifyInterface = g_system->createMutex(); } RMInventory::~RMInventory() { Close(); + g_system->deleteMutex(m_csModifyInterface); } bool RMInventory::CheckPointInside(RMPoint &pt) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 3d86b78f31..c6a54aa1ef 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1628,7 +1628,7 @@ bool RMCharacter::RemoveThis(void) { } RMCharacter::RMCharacter() { -// InitializeCriticalSection(&csMove); + csMove = g_system->createMutex(); hEndOfPath = CreateEvent(NULL, false, false, NULL); minpath = 0; curSpeed = 3; @@ -1639,7 +1639,7 @@ RMCharacter::RMCharacter() { } RMCharacter::~RMCharacter() { -// DeleteCriticalSection(&csMove); + g_system->deleteMutex(csMove); CloseHandle(hEndOfPath); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 74dbedd90f..610dd59984 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -626,13 +626,13 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i=0;iSetLoop(false); + break; + + case 1: + m_sfx[nChannel]->SetLoop(true); + break; + } + + m_sfx[nChannel]->Play(); } void TonyEngine::StopMusic(int nChannel) { - warning("TonyEngine::StopMusic"); + warning("TODO TonyEngine::StopMusic"); } void TonyEngine::StopSFX(int nChannel) { - warning("TonyEngine::StopSFX"); + warning("TODO TonyEngine::StopSFX"); } void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - warning("TonyEngine::PlayUtilSFX"); + warning("TODO TonyEngine::PlayUtilSFX"); } void TonyEngine::StopUtilSFX(int nChannel) { - warning("TonyEngine::StopUtilSFX"); + warning("TODO TonyEngine::StopUtilSFX"); } void TonyEngine::PreloadSFX(int nChannel, char* fn) { - warning("TonyEngine::PreloadSFX"); + if (m_sfx[nChannel] != NULL) { + m_sfx[nChannel]->Stop(); + m_sfx[nChannel]->Release(); + m_sfx[nChannel] = NULL; + } + + _theSound.CreateSfx(&m_sfx[nChannel]); + +/* + // Mette il path giusto + GetDataDirectory(DD_UTILSFX, path_buffer); + _splitpath(path_buffer,drive,dir,NULL,NULL); + _splitpath(fn,NULL,NULL,fname,ext); + _makepath(path_buffer,drive,dir,fname,ext); + + m_sfx[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM); +*/ + m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } FPSFX *TonyEngine::CreateSFX(byte *buf) { - warning("TonyEngine::CreateSFX"); - return NULL; + FPSFX *sfx; + + _theSound.CreateSfx(&sfx); + sfx->LoadFile(buf,FPCODEC_WAV); + return sfx; } void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) { @@ -185,11 +218,40 @@ void TonyEngine::UnloadAllUtilSFX(void) { } void TonyEngine::InitMusic() { - warning("TODO: TonyEngine::InitMusic"); + int i; + + _theSound.Init(/*m_wnd*/); + _theSound.SetMasterVolume(63); + + for (i = 0; i < 6; i++) + _theSound.CreateStream(&m_stream[i]); + + for (i = 0; i < MAX_SFX_CHANNELS; i++) { + m_sfx[i] = m_utilSfx[i] = NULL; + } + + // Crea la critical section per la musica + csMusic = g_system->createMutex(); + + // Carica effetti sonori +// PreloadUtilSFX(0,"AccendiOpzione.ADP"); +// PreloadUtilSFX(1,"ApriInterfaccia.ADP"); + + PreloadUtilSFX(0, "U01.ADP"); // invertiti!! + PreloadUtilSFX(1, "U02.ADP"); } void TonyEngine::CloseMusic() { - warning("TODO: TonyEngine::CloseMusic"); + for (int i = 0; i < 6; i++) { + m_stream[i]->Stop(); + m_stream[i]->UnloadFile(); + m_stream[i]->Release(); + } + + g_system->deleteMutex(csMusic); + + UnloadAllSFX(); + UnloadAllUtilSFX(); } void TonyEngine::PauseSound(bool bPause) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 06fe357c0d..1c08028b91 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -63,6 +63,8 @@ enum { struct TonyGameDescription; +#define MAX_SFX_CHANNELS 32 + struct VoiceHeader { int offset; int code; @@ -91,18 +93,6 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; - // Bounding box list manager - RMGameBoxes _theBoxes; - RMGfxEngine _theEngine; - RMWindow m_wnd; - bool m_bPaused; - bool m_bDrawLocation; - int m_startTime; - uint16 *m_curThumbnail; - - bool m_bQuitNow; - bool m_bTimeFreezed; - int m_nTimeFreezed; enum DATADIR { DD_BASE = 1, @@ -114,6 +104,25 @@ public: DD_VOICES, DD_BASE2 }; + + FPSTREAM *m_stream[6]; + FPSFX *m_sfx[MAX_SFX_CHANNELS]; + FPSFX *m_utilSfx[MAX_SFX_CHANNELS]; + RMGfxEngine theEngine; + RMFont *fonts[2]; + bool m_bPaused; + bool m_bDrawLocation; + int m_startTime; + uint16 *m_curThumbnail; + + // Bounding box list manager + RMGameBoxes _theBoxes; + RMGfxEngine _theEngine; + RMWindow m_wnd; + + bool m_bQuitNow; + bool m_bTimeFreezed; + int m_nTimeFreezed; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); -- cgit v1.2.3 From a75b873fdedd2167b4b6a47b1dd2988ce2e5d11c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 21:30:45 +1000 Subject: TONY: Added virtual destructors to classes using virtual methods --- engines/tony/custom.h | 10 +--------- engines/tony/font.h | 4 ++-- engines/tony/gfxcore.h | 8 ++++++++ engines/tony/tony.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.h b/engines/tony/custom.h index ee85c8dd41..57d726f70e 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -44,13 +44,7 @@ * * * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * * * - ************************************************************************** - -/** RCS - * - * $Id: $ - * - **/ + **************************************************************************/ #ifndef TONY_CUSTOM_H #define TONY_CUSTOM_H @@ -67,8 +61,6 @@ using namespace MPAL; typedef uint32 HWND; -typedef void __declspec(dllexport) (*INIT_CUSTOM_FUNCTION_TYPE)(HWND, LPCUSTOMFUNCTION *); - #define INIT_CUSTOM_FUNCTION MapCustomFunctions #define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" diff --git a/engines/tony/font.h b/engines/tony/font.h index a8a9aabb19..33332db9f0 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -78,8 +78,8 @@ private: public: RMFontPrimitive() : RMGfxPrimitive() {} RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} - - virtual RMGfxPrimitive* Duplicate() { return new RMFontPrimitive(*this); } + virtual ~RMFontPrimitive() { } + virtual RMGfxPrimitive *Duplicate() { return new RMFontPrimitive(*this); } int m_nChar; }; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 708e3adfa8..0f2c2553ec 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -152,6 +152,8 @@ public: m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; } + virtual ~RMGfxPrimitive() { } + void SetFlag(byte bFlag) { m_bFlag=bFlag; } void SetTask(RMGfxTask *task) { m_task = task; } void SetSrc(const RMRect &src) { m_src = src; } @@ -185,6 +187,7 @@ protected: public: // Costruttore standard RMGfxTask(); + virtual ~RMGfxTask() { } virtual int Priority(); virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; @@ -201,6 +204,7 @@ public: */ class RMGfxTaskSetPrior : public RMGfxTask { public: + virtual ~RMGfxTaskSetPrior() { } void SetPriority(int nPrior); }; @@ -210,6 +214,8 @@ public: */ class RMGfxClearTask : public RMGfxTask { public: + virtual ~RMGfxClearTask() { } + int Priority(); void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); bool RemoveThis(); @@ -224,6 +230,8 @@ protected: uint16 wFillColor; public: + virtual ~RMGfxBox() { } + void SetColor(byte r, byte g, byte b); void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); bool RemoveThis(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 1c08028b91..95cd4fbbdc 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -33,7 +33,7 @@ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" #include "tony/loc.h" #include "tony/utils.h" #include "tony/window.h" -- cgit v1.2.3 From 557c43c2dbd6d830332be8c8b69c7660d53d665f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 21:40:44 +1000 Subject: TONY: Converted anonymous structs to have explicit names --- engines/tony/adv.h | 7 +++++++ engines/tony/custom.cpp | 23 +++++++++++++---------- engines/tony/game.cpp | 8 ++++---- engines/tony/window.cpp | 8 ++++---- engines/tony/window.h | 2 +- 5 files changed, 29 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 9a5ecd5072..bcf62a0c24 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -66,6 +66,13 @@ namespace Tony { #define RM_SKIPY ((RM_BBY - RM_SY) / 2) #define RM_SKIPX 0 +// Name lengths +// FIXME: Some of these can likely be removed when refactoring is completed +#define MAX_DRIVE 10 +#define MAX_DIR 255 +#define MAX_FNAME 100 +#define MAX_EXT 10 + // Tony's actions enum RMTonyAction { TA_GOTO = 0, diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6f6e7a1534..d710667db6 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -110,7 +110,7 @@ int tappeti[200]; #define T_MARE 6 #define T_MAREMETA 7 -char* tappetiFile[] = { +const char *tappetiFile[] = { "None", "1.ADP", // Grilli.WAV "2.ADP", // Grilli-Ovattati.WAV @@ -121,7 +121,7 @@ char* tappetiFile[] = { "6.ADP" // Mare1.WAV met volume }; -struct { +struct CharacterStruct { uint32 code; RMItem *item; byte r, g, b; @@ -155,9 +155,10 @@ struct { endtalkpattern = f->readUint32LE(); numtexts = f->readUint32LE(); } -} Character[16]; +}; +CharacterStruct Character[16]; -struct { +struct MCharacterStruct { uint32 code; RMItem *item; byte r, g, b; @@ -202,7 +203,8 @@ struct { curTalk = f->readUint32LE(); bAlwaysBack = f->readByte(); } -} MCharacter[10]; +}; +MCharacterStruct MCharacter[10]; bool IsMChar[16]; @@ -216,7 +218,7 @@ bool bTonyIsSpeaking = false; int curChangedHotspot = 0; -struct { +struct ChangedHotspotStruct { uint32 dwCode; uint32 nX, nY; @@ -230,7 +232,8 @@ struct { nX = f->readUint32LE(); nY = f->readUint32LE(); } -} ChangedHotspot[256]; +}; +ChangedHotspotStruct ChangedHotspot[256]; void ReapplyChangedHotspot(void) { int i; @@ -2015,11 +2018,11 @@ DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(2, 64); } -struct { +struct MusicFileEntry { const char *name; int sync; -} musicFiles[] = -{ +}; +const MusicFileEntry musicFiles[] = { /* { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 6853c53bf0..a1737cb089 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -93,10 +93,10 @@ bool bPatIrqFreeze; /****************************************/ static char path_buffer[_MAX_PATH]; -static char drive[_MAX_DRIVE]; -static char dir[_MAX_DIR]; -static char fname[_MAX_FNAME]; -static char ext[_MAX_EXT]; +static char drive[MAX_DRIVE]; +static char dir[MAX_DIR]; +static char fname[MAX_FNAME]; +static char ext[MAX_EXT]; HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index a6dd20b875..248542ada6 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -1069,10 +1069,10 @@ DOFRAMERATE: * Metodi di RMSnapshot \****************************************************************************/ -char RMSnapshot::bufDrive[_MAX_DRIVE]; -char RMSnapshot::bufDir[_MAX_DIR]; -char RMSnapshot::bufName[_MAX_FNAME]; -char RMSnapshot::bufExt[_MAX_EXT]; +char RMSnapshot::bufDrive[MAX_DRIVE]; +char RMSnapshot::bufDir[MAX_DIR]; +char RMSnapshot::bufName[MAX_FNAME]; +char RMSnapshot::bufExt[MAX_EXT]; char RMSnapshot::filename[512]; byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; diff --git a/engines/tony/window.h b/engines/tony/window.h index 25aef5c619..da8c5dc824 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -61,7 +61,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer per la creazione dei path - static char bufDrive[_MAX_DRIVE], bufDir[_MAX_DIR], bufName[_MAX_FNAME], bufExt[_MAX_EXT]; + static char bufDrive[MAX_DRIVE], bufDir[MAX_DIR], bufName[MAX_FNAME], bufExt[MAX_EXT]; static char filename[512]; // Buffer per la conversione a RGB -- cgit v1.2.3 From 5498f9a0b770ed8985ace1da232b505c650d70a7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:03:03 +1000 Subject: TONY: Fix invalid casts and remove some unused variables --- engines/tony/adv.h | 1 + engines/tony/game.cpp | 8 ++------ engines/tony/tony.cpp | 2 +- engines/tony/utils.cpp | 9 +++------ engines/tony/utils.h | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index bcf62a0c24..6d675c2bbe 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -70,6 +70,7 @@ namespace Tony { // FIXME: Some of these can likely be removed when refactoring is completed #define MAX_DRIVE 10 #define MAX_DIR 255 +#define MAX_PATH 255 #define MAX_FNAME 100 #define MAX_EXT 10 diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index a1737cb089..884dda5587 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -92,11 +92,7 @@ bool bPatIrqFreeze; /* Funzioni globali per la DLL Custom */ /****************************************/ -static char path_buffer[_MAX_PATH]; -static char drive[MAX_DRIVE]; -static char dir[MAX_DIR]; -static char fname[MAX_FNAME]; -static char ext[MAX_EXT]; +static char path_buffer[MAX_PATH]; HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); @@ -494,7 +490,7 @@ void RMOptionScreen::RefreshAll(void) { if (m_statePos == 0 && i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + i, m_curThumbName[i]); + s.Format("%02d)%s", m_statePos + i, (const char *)m_curThumbName[i]); } num[i] = new RMText; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9dda1b9d4d..1415b86ef8 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -130,7 +130,7 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -char nextMusic[_MAX_PATH]; +char nextMusic[MAX_PATH]; bool nextLoop; int nextChannel; int nextSync; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 69ad5633d7..7a750c2975 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -393,17 +393,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { /** * Formats a string */ -void RMString::Format(char* str, ...) { - warning("TODO: Refactor RMString::Format if needed"); - /* +void RMString::Format(const char *str, ...) { static char buf[2048]; va_list argList; - va_start(argList,str); - wvsprintf(buf,str,argList); + va_start(argList, str); + vsprintf(buf, str, argList); va_end(argList); *this = buf; -*/ } /****************************************************************************\ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 0ce4e83f27..c8ffe062ea 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -219,7 +219,7 @@ public: friend RMDataStream& operator>>(RMDataStream& df, RMString &var); // Formattazione di stringa - void Format(char *str, ...); + void Format(const char *str, ...); private: void Resize(int size, bool bMantain = false); -- cgit v1.2.3 From 9482eac1f2fc7202eb4aaa72f63552bd35f5c66e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:09:24 +1000 Subject: TONY: Some formatting fixes --- engines/tony/gfxcore.cpp | 5 +--- engines/tony/gfxengine.cpp | 4 +-- engines/tony/loc.cpp | 2 -- engines/tony/mpal/mpal.cpp | 70 +++++++++++++++++++++++----------------------- engines/tony/mpal/mpal.h | 2 +- 5 files changed, 39 insertions(+), 44 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index b5dc79687a..9f725f2523 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -45,14 +45,11 @@ * * **************************************************************************/ -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" #include "tony/mpal/mpalutils.h" namespace Tony { -static char rcsid[] = "$Id: $"; - - /****************************************************************************\ * Metodi di RMGfxTask \****************************************************************************/ diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 940fb2afe8..dd557efafd 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -49,7 +49,7 @@ #include "tony/mpal/lzo.h" #include "tony/mpal/mpalutils.h" #include "tony/custom.h" -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" #include "tony/tony.h" namespace Tony { @@ -934,7 +934,7 @@ void RMGfxEngine::LoadState(const char *fn) { // Le versioni vecchie necessitano di On enter if (ver < 5) - mpalQueryDoAction(0,loc,0); + mpalQueryDoAction(0, loc, 0); else { // In quelle nuove, ci basta resettare gli mcode MCharResetCodes(); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index c6a54aa1ef..84e56a108d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -55,8 +55,6 @@ namespace Tony { using namespace ::Tony::MPAL; -static char rcsid[] = "$Id: $"; - extern bool bSkipSfxNoLoop; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 610dd59984..6ec08f9d26 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -868,9 +868,9 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { // Dorme il tempo necessario per arrivare al momento successivo if (s->Moment[i].dwTime==-1) { WaitForMultipleObjects(numHandles,cfHandles,true,INFINITE); - dwStartTime=timeGetTime(); + dwStartTime = timeGetTime(); } else { - dwCurTime=timeGetTime(); + dwCurTime = timeGetTime(); if (dwCurTime < dwStartTime+(s->Moment[i].dwTime*100)) { // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); Sleep(dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); @@ -1043,23 +1043,23 @@ void PASCAL LocationPollThread(uint32 id) { /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo dalla lista */ LockItems(); - nIdleActions=0; - nRealItems=0; - for (i=0;inActions;j++) - if (curItem->Action[j].num==0xFF) + for (j = 0; j < curItem->nActions; j++) + if (curItem->Action[j].num == 0xFF) k++; - nIdleActions+=k; + nIdleActions += k; - if (k==0) + if (k == 0) /* Possiamo eliminare questo item dalla lista */ il[i] = (uint32)NULL; else @@ -1068,28 +1068,28 @@ void PASCAL LocationPollThread(uint32 id) { UnlockItems(); /* Se non e' rimasto nessuno possiamo uscire */ - if (nRealItems==0) { + if (nRealItems == 0) { GlobalFree(il); ExitThread(0); // _endthread(); } - MyThreads=(MYTHREAD*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nRealItems*sizeof(MYTHREAD)); - if (MyThreads==NULL) { + MyThreads=(MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nRealItems * sizeof(MYTHREAD)); + if (MyThreads == NULL) { GlobalFree(il); ExitThread(0); // _endthread(); } /* Inizializziamo le routine random */ - //curTime=timeGetTime(); + //curTime = timeGetTime(); //srand(curTime); /* Abbiamo appurato che esiste almeno un item che contiene idle actions. Ora creaiamo le copie speculari delle idle actions */ - MyActions=(MYACTION*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nIdleActions*sizeof(MYACTION)); - if (MyActions==NULL) { + MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nIdleActions * sizeof(MYACTION)); + if (MyActions == NULL) { GlobalFree(MyThreads); GlobalFree(il); ExitThread(0); @@ -1097,27 +1097,27 @@ void PASCAL LocationPollThread(uint32 id) { } LockItems(); - k=0; + k = 0; - for (i=0;inActions;j++) - if (curItem->Action[j].num==0xFF) { - MyActions[k].nItem=il[i]; - MyActions[k].nAction=j; + for (j = 0; j < curItem->nActions; j++) + if (curItem->Action[j].num == 0xFF) { + MyActions[k].nItem = il[i]; + MyActions[k].nAction = j; - MyActions[k].wTime=curItem->Action[j].wTime; - MyActions[k].perc=curItem->Action[j].perc; - MyActions[k].when=curItem->Action[j].when; - MyActions[k].nCmds=curItem->Action[j].nCmds; + MyActions[k].wTime = curItem->Action[j].wTime; + MyActions[k].perc = curItem->Action[j].perc; + MyActions[k].when = curItem->Action[j].when; + MyActions[k].nCmds = curItem->Action[j].nCmds; CopyMemory(MyActions[k].CmdNum, curItem->Action[j].CmdNum, - MAX_COMMANDS_PER_ACTION*sizeof(uint16)); + MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - MyActions[k].dwLastTime=timeGetTime(); + MyActions[k].dwLastTime = timeGetTime(); k++; } } @@ -1132,7 +1132,7 @@ void PASCAL LocationPollThread(uint32 id) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - curTime=timeGetTime(); + curTime = timeGetTime(); dwSleepTime=(uint32)-1L; for (k=0;kAction[0].nCmds=curItem->Action[j].nCmds; +// newItem->Action[0].nCmds = curItem->Action[j].nCmds; // CopyMemory(newItem->Action[0].CmdNum,curItem->Action[j].CmdNum,newItem->Action[0].nCmds*sizeof(newItem->Action[0].CmdNum[0])); newItem->dwRes=j; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 70b49a1fd9..26c4283018 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -271,7 +271,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryGlobalVar(lpszVarName) \ - (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) + (uint32)mpalQuery(MPQ_GLOBAL_VAR,(const char *)(lpszVarName)) -- cgit v1.2.3 From 23cd3b7730c292539649578d1aea373812e6b4ce Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:28:51 +1000 Subject: TONY: Fixed many warnings identified by gcc --- engines/tony/game.cpp | 2 - engines/tony/input.cpp | 5 +- engines/tony/inventory.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 8 +- engines/tony/mpal/mpal.cpp | 609 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 2 +- engines/tony/sound.cpp | 6 +- engines/tony/sound.h | 2 +- engines/tony/tony.cpp | 4 +- engines/tony/tony.h | 6 +- engines/tony/tonychar.cpp | 12 + 11 files changed, 331 insertions(+), 327 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 884dda5587..b4b4253d08 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -92,8 +92,6 @@ bool bPatIrqFreeze; /* Funzioni globali per la DLL Custom */ /****************************************/ -static char path_buffer[MAX_PATH]; - HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 25f271d7eb..09b15fa127 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -45,7 +45,7 @@ * * **************************************************************************/ -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" namespace Tony { @@ -137,8 +137,7 @@ void RMInput::SwitchFullscreen(bool bFull) { #endif } -void RMInput::DIClose(void) -{ +void RMInput::DIClose(void) { #ifdef REFACTOR_ME DIRELEASE(m_DIDMouse); DIRELEASE(m_DI); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 1442708d56..ade9c0eb34 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -272,7 +272,7 @@ void RMInventory::AddItem(int code) { ClearOT(); g_system->unlockMutex(m_csModifyInterface); } -}; +} void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { if (code <= 10000 && code >= 10101) { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index ff94dbae8d..484f1ad2a0 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -527,16 +527,10 @@ static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { \****************************************************************************/ bool ParseMpc(byte *lpBuf) { - uint16 i,j; + uint16 i, j; uint16 wLen; byte *lpTemp, *lpTemp2; - // Oggetti dummy. Definiti static per evitare stack overflow - static MPALITEM dummyitem; - static MPALLOCATION dummylocation; - static MPALSCRIPT dummyscript; - static MPALDIALOG dummydialog; - /* 1. Variabili */ if (lpBuf[0]!='V' || lpBuf[1]!='A' || lpBuf[2]!='R' || lpBuf[3]!='S') return false; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 6ec08f9d26..d767dbe381 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -356,20 +356,20 @@ int32 varGetValue(const char *lpszVarName) { \****************************************************************************/ void varSetValue(const char *lpszVarName, int32 val) { - int i; + uint i; LPMPALVAR v=lpmvVars; for (i=0;ilpszVarName)==0) { v->dwVal=val; - if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8)==0) { - i=0; - sscanf(v->lpszVarName,"Pattern.%u",&i); + if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8) == 0) { + i = 0; + sscanf(v->lpszVarName, "Pattern.%u", &i); lpiifCustom(i,val,-1); - } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Status.",7)==0) { - i=0; - sscanf(v->lpszVarName,"Status.%u",&i); - lpiifCustom(i,-1,val); + } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + i = 0; + sscanf(v->lpszVarName,"Status.%u", &i); + lpiifCustom(i, -1, val); } return; } @@ -1648,7 +1648,7 @@ bool DoSelection(uint32 i, uint32 dwData) { /****************************************************************************\ * -* Function: bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, +* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, * LPLPCUSTOMFUNCTION lplpcfArray); * * Description: Inizializza la libreria MPAL, e apre un file .MPC, che @@ -1665,7 +1665,7 @@ bool DoSelection(uint32 i, uint32 dwData) { * \****************************************************************************/ -bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { +bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { Common::File hMpc; byte buf[5]; uint32 nBytesRead; @@ -2281,11 +2281,12 @@ int mpalLoadState(byte *buf) { bool bDontOutput; -struct { +struct MsgCommentsStruct { uint16 wStart; uint16 wEnd; char *pComment; -} MsgComments[] = { +}; +MsgCommentsStruct MsgComments[] = { { 10, 16, "###" }, { 560, 563, "@@@ BUTCH & DUDLEY:" }, { 551, 553, "@@@ JACK'S LETTER (JACK'S VOICE):" }, @@ -2584,310 +2585,310 @@ void mpalDumpOthers(void) { #if 0 // English names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Old lady 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; -char *DLG90[] = { "Tony", "Bearded lady", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Piranha", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG160[] = { "Tony", "Shmiley", NULL }; -char *DLG161[] = { "Tony", "Shmiley", NULL }; -char *DLG162[] = { "Tony", "Shmiley", NULL }; -char *DLG163[] = { "Tony", "Shmiley", NULL }; -char *DLG180[] = { "Tony", "Beast", NULL }; -char *DLG190[] = { "Tony", "Beast", NULL }; -char *DLG191[] = { "Tony", "Beast", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer", NULL }; -char *DLG211[] = { "Tony", "Mortimer", NULL }; -char *DLG212[] = { "Tony", "Mortimer", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; -char *DLG270[] = { "Tony", "Egghead", NULL }; -char *DLG271[] = { "Tony", "Egghead", NULL }; -char *DLG272[] = { "Tony", "Egghead", NULL }; -char *DLG290[] = { "Tony", "Old lady 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Gatekeeper", NULL }; -char *DLG371[] = { "Tony", "Gatekeeper", NULL }; -char *DLG372[] = { "Tony", "Gatekeeper", NULL }; -char *DLG373[] = { "Tony", "Gatekeeper", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; -char *DLG560[] = { "Tony", "Superintendent", NULL }; -char *DLG590[] = { "Tony", "Pantagruel", NULL }; -char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Old lady 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; +const char *DLG90[] = { "Tony", "Bearded lady", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Piranha", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG160[] = { "Tony", "Shmiley", NULL }; +const char *DLG161[] = { "Tony", "Shmiley", NULL }; +const char *DLG162[] = { "Tony", "Shmiley", NULL }; +const char *DLG163[] = { "Tony", "Shmiley", NULL }; +const char *DLG180[] = { "Tony", "Beast", NULL }; +const char *DLG190[] = { "Tony", "Beast", NULL }; +const char *DLG191[] = { "Tony", "Beast", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer", NULL }; +const char *DLG211[] = { "Tony", "Mortimer", NULL }; +const char *DLG212[] = { "Tony", "Mortimer", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; +const char *DLG270[] = { "Tony", "Egghead", NULL }; +const char *DLG271[] = { "Tony", "Egghead", NULL }; +const char *DLG272[] = { "Tony", "Egghead", NULL }; +const char *DLG290[] = { "Tony", "Old lady 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG371[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG372[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG373[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; +const char *DLG560[] = { "Tony", "Superintendent", NULL }; +const char *DLG590[] = { "Tony", "Pantagruel", NULL }; +const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; #endif #if 0 // Polish names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Staruszka 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; -char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Pirania", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG160[] = { "Tony", "miechozol", NULL }; -char *DLG161[] = { "Tony", "miechozol", NULL }; -char *DLG162[] = { "Tony", "miechozol", NULL }; -char *DLG163[] = { "Tony", "miechozol", NULL }; -char *DLG180[] = { "Tony", "Wycz", NULL }; -char *DLG190[] = { "Tony", "Wycz", NULL }; -char *DLG191[] = { "Tony", "Wycz", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; -char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; -char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; -char *DLG270[] = { "Tony", "Jajogowy", NULL }; -char *DLG271[] = { "Tony", "Jajogowy", NULL }; -char *DLG272[] = { "Tony", "Jajogowy", NULL }; -char *DLG290[] = { "Tony", "Staruszka 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Stranik", NULL }; -char *DLG371[] = { "Tony", "Stranik", NULL }; -char *DLG372[] = { "Tony", "Stranik", NULL }; -char *DLG373[] = { "Tony", "Stranik", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; -char *DLG560[] = { "Tony", "Inspektor", NULL }; -char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; -char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Staruszka 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; +const char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Pirania", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG160[] = { "Tony", "miechozol", NULL }; +const char *DLG161[] = { "Tony", "miechozol", NULL }; +const char *DLG162[] = { "Tony", "miechozol", NULL }; +const char *DLG163[] = { "Tony", "miechozol", NULL }; +const char *DLG180[] = { "Tony", "Wycz", NULL }; +const char *DLG190[] = { "Tony", "Wycz", NULL }; +const char *DLG191[] = { "Tony", "Wycz", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; +const char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; +const char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; +const char *DLG270[] = { "Tony", "Jajogowy", NULL }; +const char *DLG271[] = { "Tony", "Jajogowy", NULL }; +const char *DLG272[] = { "Tony", "Jajogowy", NULL }; +const char *DLG290[] = { "Tony", "Staruszka 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Stranik", NULL }; +const char *DLG371[] = { "Tony", "Stranik", NULL }; +const char *DLG372[] = { "Tony", "Stranik", NULL }; +const char *DLG373[] = { "Tony", "Stranik", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; +const char *DLG560[] = { "Tony", "Inspektor", NULL }; +const char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; +const char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; #endif // Polish #if 0 // Russian -char *DLG10[] = { "呷辷", NULL }; -char *DLG51[] = { "呷辷", "蒼", "釣粳" }; -char *DLG52[] = { "呷辷", NULL }; -char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; -char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; -char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; -char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; -char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; -char *DLG130[] = { "呷辷", "蒡琿", NULL }; -char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG160[] = { "呷辷", "懋珸謌", NULL }; -char *DLG161[] = { "呷辷", "懋珸謌", NULL }; -char *DLG162[] = { "呷辷", "懋珸謌", NULL }; -char *DLG163[] = { "呷辷", "懋珸謌", NULL }; -char *DLG180[] = { "呷辷", "恣粮礦", NULL }; -char *DLG190[] = { "呷辷", "恣粮礦", NULL }; -char *DLG191[] = { "呷辷", "恣粮礦", NULL }; -char *DLG201[] = { "呷辷", NULL }; -char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; -char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; -char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; -char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; -char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; -char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; -char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; -char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; -char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; -char *DLG310[] = { "呷辷", "嚴諡", NULL }; -char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; -char *DLG340[] = { "呷辷", "傴辟琺", NULL }; -char *DLG360[] = { "呷辷", NULL }; -char *DLG361[] = { "呷辷", NULL }; -char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG380[] = { "呷辷", NULL }; -char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; -char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "呷辷", NULL }; -char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "呷辷", "Pin-up", NULL }; -char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; -char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; -char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; -char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; -char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; -char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; +const char *DLG10[] = { "呷辷", NULL }; +const char *DLG51[] = { "呷辷", "蒼", "釣粳" }; +const char *DLG52[] = { "呷辷", NULL }; +const char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; +const char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; +const char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; +const char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; +const char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; +const char *DLG130[] = { "呷辷", "蒡琿", NULL }; +const char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG160[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG161[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG162[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG163[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG180[] = { "呷辷", "恣粮礦", NULL }; +const char *DLG190[] = { "呷辷", "恣粮礦", NULL }; +const char *DLG191[] = { "呷辷", "恣粮礦", NULL }; +const char *DLG201[] = { "呷辷", NULL }; +const char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; +const char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; +const char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; +const char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; +const char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +const char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +const char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; +const char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; +const char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; +const char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; +const char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; +const char *DLG310[] = { "呷辷", "嚴諡", NULL }; +const char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; +const char *DLG340[] = { "呷辷", "傴辟琺", NULL }; +const char *DLG360[] = { "呷辷", NULL }; +const char *DLG361[] = { "呷辷", NULL }; +const char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG380[] = { "呷辷", NULL }; +const char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; +const char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "呷辷", NULL }; +const char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "呷辷", "Pin-up", NULL }; +const char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; +const char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; +const char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; +const char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; +const char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; +const char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; #endif // Russian #if 0 // Czech names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Star pan 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; -char *DLG90[] = { "Tony", "Vousat ena", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Piraa", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG160[] = { "Tony", "Shmiley", NULL }; -char *DLG161[] = { "Tony", "Shmiley", NULL }; -char *DLG162[] = { "Tony", "Shmiley", NULL }; -char *DLG163[] = { "Tony", "Shmiley", NULL }; -char *DLG180[] = { "Tony", "Zv逖e", NULL }; -char *DLG190[] = { "Tony", "Zv逖e", NULL }; -char *DLG191[] = { "Tony", "Zv逖e", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer", NULL }; -char *DLG211[] = { "Tony", "Mortimer", NULL }; -char *DLG212[] = { "Tony", "Mortimer", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; -char *DLG270[] = { "Tony", "Intelektul", NULL }; -char *DLG271[] = { "Tony", "Intelektul", NULL }; -char *DLG272[] = { "Tony", "Intelektul", NULL }; -char *DLG290[] = { "Tony", "Star pan 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Strn", NULL }; -char *DLG371[] = { "Tony", "Strn", NULL }; -char *DLG372[] = { "Tony", "Strn", NULL }; -char *DLG373[] = { "Tony", "Strn", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; -char *DLG560[] = { "Tony", "Sprvce", NULL }; -char *DLG590[] = { "Tony", "Pantagruel", NULL }; -char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Star pan 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; +const char *DLG90[] = { "Tony", "Vousat ena", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Piraa", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG160[] = { "Tony", "Shmiley", NULL }; +const char *DLG161[] = { "Tony", "Shmiley", NULL }; +const char *DLG162[] = { "Tony", "Shmiley", NULL }; +const char *DLG163[] = { "Tony", "Shmiley", NULL }; +const char *DLG180[] = { "Tony", "Zv逖e", NULL }; +const char *DLG190[] = { "Tony", "Zv逖e", NULL }; +const char *DLG191[] = { "Tony", "Zv逖e", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer", NULL }; +const char *DLG211[] = { "Tony", "Mortimer", NULL }; +const char *DLG212[] = { "Tony", "Mortimer", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; +const char *DLG270[] = { "Tony", "Intelektul", NULL }; +const char *DLG271[] = { "Tony", "Intelektul", NULL }; +const char *DLG272[] = { "Tony", "Intelektul", NULL }; +const char *DLG290[] = { "Tony", "Star pan 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Strn", NULL }; +const char *DLG371[] = { "Tony", "Strn", NULL }; +const char *DLG372[] = { "Tony", "Strn", NULL }; +const char *DLG373[] = { "Tony", "Strn", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; +const char *DLG560[] = { "Tony", "Sprvce", NULL }; +const char *DLG590[] = { "Tony", "Pantagruel", NULL }; +const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; #endif // Czech names #if 1 // Deutsch names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; -char *DLG90[] = { "Tony", "Brtige Dame", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Piranha", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG160[] = { "Tony", "Shmiley", NULL }; -char *DLG161[] = { "Tony", "Shmiley", NULL }; -char *DLG162[] = { "Tony", "Shmiley", NULL }; -char *DLG163[] = { "Tony", "Shmiley", NULL }; -char *DLG180[] = { "Tony", "Biest", NULL }; -char *DLG190[] = { "Tony", "Biest", NULL }; -char *DLG191[] = { "Tony", "Biest", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer", NULL }; -char *DLG211[] = { "Tony", "Mortimer", NULL }; -char *DLG212[] = { "Tony", "Mortimer", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; -char *DLG270[] = { "Tony", "Eierkopf", NULL }; -char *DLG271[] = { "Tony", "Eierkopf", NULL }; -char *DLG272[] = { "Tony", "Eierkopf", NULL }; -char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Pfrtner", NULL }; -char *DLG371[] = { "Tony", "Pfrtner", NULL }; -char *DLG372[] = { "Tony", "Pfrtner", NULL }; -char *DLG373[] = { "Tony", "Pfrtner", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; -char *DLG560[] = { "Tony", "Verwalter", NULL }; -char *DLG590[] = { "Tony", "Pantagruel", NULL }; -char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; +const char *DLG90[] = { "Tony", "Brtige Dame", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Piranha", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG160[] = { "Tony", "Shmiley", NULL }; +const char *DLG161[] = { "Tony", "Shmiley", NULL }; +const char *DLG162[] = { "Tony", "Shmiley", NULL }; +const char *DLG163[] = { "Tony", "Shmiley", NULL }; +const char *DLG180[] = { "Tony", "Biest", NULL }; +const char *DLG190[] = { "Tony", "Biest", NULL }; +const char *DLG191[] = { "Tony", "Biest", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer", NULL }; +const char *DLG211[] = { "Tony", "Mortimer", NULL }; +const char *DLG212[] = { "Tony", "Mortimer", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; +const char *DLG270[] = { "Tony", "Eierkopf", NULL }; +const char *DLG271[] = { "Tony", "Eierkopf", NULL }; +const char *DLG272[] = { "Tony", "Eierkopf", NULL }; +const char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Pfrtner", NULL }; +const char *DLG371[] = { "Tony", "Pfrtner", NULL }; +const char *DLG372[] = { "Tony", "Pfrtner", NULL }; +const char *DLG373[] = { "Tony", "Pfrtner", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; +const char *DLG560[] = { "Tony", "Verwalter", NULL }; +const char *DLG590[] = { "Tony", "Pantagruel", NULL }; +const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; #endif @@ -2902,7 +2903,7 @@ case num: \ return DLG##num[nPers]; -char *GetPersonName(uint16 nDlg, int nPers) { +const char *GetPersonName(uint16 nDlg, int nPers) { switch (nDlg) { HANDLE_DIALOG(10); HANDLE_DIALOG(51); @@ -2964,7 +2965,7 @@ char *GetPersonName(uint16 nDlg, int nPers) { HANDLE_DIALOG(600); default: - warning("ERROR: Il dialogo %d non esiste!\n", nDlg); + warning("ERROR: Il dialogo %d non esiste!\n", (int)nDlg); return "ERROR"; } } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 26c4283018..d800be60b8 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -595,7 +595,7 @@ extern "C" { * \****************************************************************************/ -bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, +bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray); diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index a5293eecb2..7c340be86e 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -589,7 +589,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -677,7 +677,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -1289,7 +1289,7 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { } -bool FPSFX::LoadFile(LPSTR lpszFileName, uint32 dwCodec) { +bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 7ed8f97b3e..8853e1a344 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -306,7 +306,7 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); bool LoadVoiceFromVDB(Common::File &vdbFP); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 1415b86ef8..45545875e1 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -176,7 +176,7 @@ void TonyEngine::StopUtilSFX(int nChannel) { warning("TODO TonyEngine::StopUtilSFX"); } -void TonyEngine::PreloadSFX(int nChannel, char* fn) { +void TonyEngine::PreloadSFX(int nChannel, const char *fn) { if (m_sfx[nChannel] != NULL) { m_sfx[nChannel]->Stop(); m_sfx[nChannel]->Release(); @@ -205,7 +205,7 @@ FPSFX *TonyEngine::CreateSFX(byte *buf) { return sfx; } -void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) { +void TonyEngine::PreloadUtilSFX(int nChannel, const char *fn) { warning("TonyEngine::PreloadUtilSFX"); } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 95cd4fbbdc..51cfdf74f3 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -178,10 +178,10 @@ public: FPSFX *CreateSFX(byte *buf); - void PreloadSFX(int nSfx, char *fn); + void PreloadSFX(int nSfx, const char *fn); void UnloadAllSFX(void); - void PreloadUtilSFX(int nSfx, char *fn); + void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); // Ferma tutta la parte audio @@ -194,7 +194,7 @@ public: void AutoSave(void); void SaveState(int n, const char *name); void LoadState(int n); - void GetSaveStateFileName(int n, char* buf); + void GetSaveStateFileName(int n, char *buf); // Prende il thumbnail void GrabThumbnail(void); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 7809d9c080..b7ecb3c0d4 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -1357,6 +1357,9 @@ void RMTony::EndTalk(void) { break; } break; + + default: + break; } // Gestisce la fine di una animazione static lasciando tutto invariato @@ -1634,6 +1637,9 @@ void RMTony::StartStatic(TALKTYPE nTalk) { m_nBodyOffset.Set(6, 56); break; } + + default: + break; } // e vai con i pattern @@ -1783,8 +1789,14 @@ void RMTony::EndStatic(TALKTYPE nTalk) { case RIGHT: headEndPat = PAT_SPAVENTORIGHT_END; break; + + default: + break; } break; + + default: + break; } if (headEndPat != 0) { -- cgit v1.2.3 From 9c2ccc4f9c0f4e27209ac876bf2112fd2a6e2987 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:39:30 +1000 Subject: TONY: Further bugfixes for gcc warnings --- engines/tony/mpal/mpal.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d767dbe381..55d70b2e18 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -97,7 +97,6 @@ typedef LPCFCALL* LPLPCFCALL; uint32 mpalError; -static bool bInit=false; static byte * lpMpcImage; LPITEMIRQFUNCTION lpiifCustom=NULL; @@ -786,11 +785,11 @@ static LPITEM GetItemData(uint32 nOrdItem) { patlength = dat; dat+=ret->numpattern; - for (i=1;inumpattern;i++) { - for (j=0;jpattern[i][j]=dat[j]; - ret->pattern[i][patlength[i]]=255; // Termina i pattern - dat+=patlength[i]; + for (i = 1; i < ret->numpattern; i++) { + for (j = 0; j < patlength[i]; j++) + ret->pattern[i][j] = dat[j]; + ret->pattern[i][(int)patlength[i]] = 255; // Termina i pattern + dat += patlength[i]; } // Carica i singoli frame di animazione @@ -2284,9 +2283,9 @@ bool bDontOutput; struct MsgCommentsStruct { uint16 wStart; uint16 wEnd; - char *pComment; + const char *pComment; }; -MsgCommentsStruct MsgComments[] = { +const MsgCommentsStruct MsgComments[] = { { 10, 16, "###" }, { 560, 563, "@@@ BUTCH & DUDLEY:" }, { 551, 553, "@@@ JACK'S LETTER (JACK'S VOICE):" }, @@ -2894,7 +2893,7 @@ const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, #define HANDLE_DIALOG(num) \ case num: \ - if (nPers >= sizeof(DLG##num) / sizeof(char*) || DLG##num[nPers]==NULL) \ + if (nPers >= (int)(sizeof(DLG##num) / sizeof(const char *)) || DLG##num[nPers] == NULL) \ { \ warning("ERROR: Il personaggio #%d non esiste nel dialogo %d!\n", nPers, nDlg); \ return "ERROR"; \ -- cgit v1.2.3 From 3184a5a874f3cfaa75424e7efb21f1cca3702988 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:58:42 +1000 Subject: TONY: Fix warnings about return values not being used --- engines/tony/custom.cpp | 6 +++--- engines/tony/loc.cpp | 4 ++-- engines/tony/mpal/mpal.h | 11 ++++++++--- engines/tony/tonychar.cpp | 10 ++++++++++ engines/tony/window.cpp | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d710667db6..3400235563 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1833,7 +1833,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, curDialog = nDialog; // Chiama l'MPAL per iniziare il dialogo - mpalQueryDoDialog(nDialog,nStartGroup); + mpalQueryDoDialogU32(nDialog, nStartGroup); // Aspetta che una scelta si presenti while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) { @@ -1844,7 +1844,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta if (num == 1) { - mpalQueryDialogSelection(nChoice, sl[0]); + mpalQueryDialogSelectionU32(nChoice, sl[0]); GlobalFree(sl); continue; } @@ -1880,7 +1880,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, MainHideMouse(); dc.Hide(); - mpalQueryDialogSelection(nChoice, sl[sel]); + mpalQueryDialogSelectionU32(nChoice, sl[sel]); // Chiude la scelta dc.Close(); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 84e56a108d..62249da255 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1349,7 +1349,7 @@ void RMCharacter::NewBoxEntered(int nBox) { bool bOldReverse; // Richiama la On ExitBox - mpalQueryDoAction(3, curLocation, curbox); + mpalQueryDoActionU32(3, curLocation, curbox); cur = theBoxes->GetBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; @@ -1383,7 +1383,7 @@ void RMCharacter::NewBoxEntered(int nBox) { } // Richiama la On EnterBox - mpalQueryDoAction(2, curLocation, curbox); + mpalQueryDoActionU32(2, curLocation, curbox); } void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index d800be60b8..e66f1fdb7e 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -523,7 +523,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelection(nChoice,dwData) \ (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) - +#define mpalQueryDialogSelectionU32(nChoice, dwData) \ + mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) /****************************************************************************\ * @@ -547,9 +548,11 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * \****************************************************************************/ -#define mpalQueryDoAction(nAction,nItem,dwParam) \ - (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) +#define mpalQueryDoAction(nAction, nItem, dwParam) \ + (HANDLE)mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) +#define mpalQueryDoActionU32(nAction, nItem, dwParam) \ + mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) /****************************************************************************\ @@ -569,6 +572,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoDialog(nDialog,nGroup) \ (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) +#define mpalQueryDoDialogU32(nDialog, nGroup) \ + mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) /****************************************************************************\ diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index b7ecb3c0d4..12a8c8eabb 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -1061,6 +1061,9 @@ void RMTony::StartTalk(TALKTYPE nTalkType) { headStartPat = PAT_SPAVENTOLEFT_STAND; headLoopPat = PAT_SPAVENTOLEFT_LOOP; break; + + default: + break; } break; } @@ -1355,6 +1358,10 @@ void RMTony::EndTalk(void) { headStandPat = PAT_SPAVENTOLEFT_STAND; bodyEndPat = 0; break; + + + default: + break; } break; @@ -1636,6 +1643,9 @@ void RMTony::StartStatic(TALKTYPE nTalk) { headLoopPat = PAT_SPAVENTORIGHT_STAND; m_nBodyOffset.Set(6, 56); break; + + default: + break; } default: diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 248542ada6..41821ccacc 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -252,7 +252,7 @@ void RMWindow::Init(/*HINSTANCE hInst*/) { //hWaitFlip = CreateEvent(NULL,false,false, NULL); #endif -}; +} void RMWindow::Close(void) { DDClose(); -- cgit v1.2.3 From e628da0cccbba04c9d19b28b46e97107ab66beb7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 23:20:01 +1000 Subject: TONY: Fix some inconsistent allocation/deallocations --- engines/tony/mpal/memory.cpp | 6 +++--- engines/tony/mpal/memory.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 604e61ed24..de6e918a38 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -127,9 +127,9 @@ uint32 MemoryManager::getSize(HGLOBAL handle) { /** * Erases a given item */ -void MemoryManager::erase(MemoryItem &item) { +void MemoryManager::erase(MemoryItem *item) { delete item; - _memoryBlocks.remove(&item); + _memoryBlocks.remove(item); } /** @@ -137,7 +137,7 @@ void MemoryManager::erase(MemoryItem &item) { */ void MemoryManager::erase(HGLOBAL handle) { MemoryItem &item = getItem(handle); - erase(item); + erase(&item); } } // end of namespace MPAL diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index fde0d33b3e..ebf42b6207 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -36,14 +36,14 @@ typedef HANDLE HGLOBAL; class MemoryItem { protected: - void *_buffer; + byte *_buffer; uint32 _size; public: MemoryItem(uint32 size); virtual ~MemoryItem(); uint32 Size() { return _size; } - void *DataPointer() { return _buffer; } + void *DataPointer() { return (void *)_buffer; } bool IsValid() { return _buffer != NULL; } // Casting for access to data @@ -61,7 +61,7 @@ public: HGLOBAL alloc(uint32 size); MemoryItem &getItem(HGLOBAL handle); MemoryItem &operator[](HGLOBAL handle); - void erase(MemoryItem &item); + void erase(MemoryItem *item); void erase(HGLOBAL handle); uint32 getSize(HANDLE handle); -- cgit v1.2.3 From 5ab27cdacd0b93e4c1de613833edf1894820d2b4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 23:38:34 +1000 Subject: TONY: Fix Valgrind identified leaks in memory allocator and dialog parsing --- engines/tony/mpal/loadmpc.cpp | 115 ++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 56 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 484f1ad2a0..c88f485b95 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -66,7 +66,7 @@ namespace MPAL { static bool CompareCommands(struct command *cmd1, struct command *cmd2) { if (cmd1->type == 2 && cmd2->type == 2) { - if (strcmp(cmd1->lpszVarName,cmd2->lpszVarName)==0 && + if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && CompareExpressions(cmd1->expr,cmd2->expr)) return true; else @@ -169,94 +169,97 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; - lpmdDialog->nObj=*(int *)lpBuf; - lpBuf+=4; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpBuf += 4; /* Periodi */ - num=*(uint16 *)lpBuf; lpBuf+=2; + num = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (num >= MAX_PERIODS_PER_DIALOG-1) { - Common::String msg = Common::String::format("Too much periods in dialog #%d",lpmdDialog->nObj); + if (num >= MAX_PERIODS_PER_DIALOG - 1) { + Common::String msg = Common::String::format("Too much periods in dialog #%d", lpmdDialog->nObj); MessageBox(msg); } - for (i=0;iPeriodNums[i]=*(uint16 *)lpBuf; lpBuf+=2; - lpmdDialog->Periods[i]=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,*lpBuf+1); + for (i = 0; i < num; i++) { + lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); - CopyMemory(lpLock,lpBuf+1,*lpBuf); + Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); + lpLock[*lpBuf] = '\0'; GlobalUnlock(lpmdDialog->Periods[i]); - lpBuf+=(*lpBuf)+1; + lpBuf += (*lpBuf) + 1; } - lpmdDialog->PeriodNums[i]=0; - lpmdDialog->Periods[i]=NULL; + lpmdDialog->PeriodNums[i] = 0; + lpmdDialog->Periods[i] = NULL; /* Gruppi */ - num=*(uint16 *)lpBuf; lpBuf+=2; - curCmd=0; + num = READ_LE_UINT16(lpBuf); lpBuf += 2; + curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) { - Common::String msg = Common::String::format("Too much groups in dialog #%d",lpmdDialog->nObj); + Common::String msg = Common::String::format("Too much groups in dialog #%d", lpmdDialog->nObj); MessageBox(msg); } - for (i=0;iGroup[i].num=*(uint16 *)lpBuf; lpBuf+=2; - lpmdDialog->Group[i].nCmds=*lpBuf; lpBuf++; + for (i = 0; i < num; i++) { + lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) { Common::String msg = Common::String::format("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); MessageBox(msg); } - for (j=0;jGroup[i].nCmds;j++) { - lpmdDialog->Command[curCmd].type=*lpBuf; + for (j = 0; j < lpmdDialog->Group[i].nCmds; j++) { + lpmdDialog->Command[curCmd].type = *lpBuf; lpBuf++; switch (lpmdDialog->Command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; - lpmdDialog->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; - lpmdDialog->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; - lpmdDialog->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; - lpmdDialog->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; break; // Variable assign case 2: - len=*lpBuf; + len = *lpBuf; lpBuf++; - lpmdDialog->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); - if (lpmdDialog->Command[curCmd].lpszVarName==NULL) + lpmdDialog->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->Command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmdDialog->Command[curCmd].lpszVarName,lpBuf,len); - lpBuf+=len; - lpBuf=ParseExpression(lpBuf,&lpmdDialog->Command[curCmd].expr); - if (lpBuf==NULL) + Common::copy(lpBuf, lpBuf + len, lpmdDialog->Command[curCmd].lpszVarName); + lpmdDialog->Command[curCmd].lpszVarName[len] = '\0'; + lpBuf += len; + + lpBuf=ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); + if (lpBuf == NULL) return NULL; break; // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; default: return NULL; } - for (kk=0;kkCommand[kk],&lpmdDialog->Command[curCmd])) { - lpmdDialog->Group[i].CmdNum[j]=kk; + for (kk = 0;kk < curCmd; kk++) { + if (CompareCommands(&lpmdDialog->Command[kk], &lpmdDialog->Command[curCmd])) { + lpmdDialog->Group[i].CmdNum[j] = kk; break; } } - if (kk==curCmd) { - lpmdDialog->Group[i].CmdNum[j]=curCmd; + if (kk == curCmd) { + lpmdDialog->Group[i].CmdNum[j] = curCmd; curCmd++; } } @@ -268,33 +271,33 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { } /* Choices */ - num=*(uint16 *)lpBuf; lpBuf+=2; + num=*(uint16 *)lpBuf; lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) { Common::String msg = Common::String::format("Too much choices in dialog #%d",lpmdDialog->nObj); MessageBox(msg); } - for (i=0;iChoice[i].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + for (i = 0; i < num; i++) { + lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; - num2=*lpBuf++; + num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) { Common::String msg = Common::String::format("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); MessageBox(msg); } - for (j=0;jChoice[i].Select[j].when=NULL; + lpmdDialog->Choice[i].Select[j].when = NULL; break; case 1: - lpBuf=ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); - if (lpBuf==NULL) + lpBuf = ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); + if (lpBuf == NULL) return NULL; break; @@ -303,31 +306,31 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->Choice[i].Select[j].attr=*lpBuf++; + lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData=*(uint32 *)lpBuf; lpBuf+=4; + lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup - num3=*lpBuf; *lpBuf++; + num3 = *lpBuf; *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) { - Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d",j,lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); MessageBox(msg); } - for (z=0;zChoice[i].Select[j].wPlayGroup[z]=*(uint16 *)lpBuf; lpBuf+=2; + for (z = 0; z < num3; z++) { + lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->Choice[i].Select[j].wPlayGroup[num3]=0; + lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; } // Segna l'ultimo select - lpmdDialog->Choice[i].Select[num2].dwData=0; + lpmdDialog->Choice[i].Select[num2].dwData = 0; } - lpmdDialog->Choice[num].nChoice=0; + lpmdDialog->Choice[num].nChoice = 0; return lpBuf; } -- cgit v1.2.3 From a511b828e416c657e01a86e931016d4a4b7d49b9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 00:29:44 +1000 Subject: TONY: Initial fixes for some of the Valgrind reported errors --- engines/tony/mpal/expr.cpp | 10 +-- engines/tony/mpal/expr.h | 2 +- engines/tony/mpal/loadmpc.cpp | 173 ++++++++++++++++++++---------------------- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/memory.cpp | 12 ++- engines/tony/mpal/memory.h | 8 +- engines/tony/mpal/mpal.cpp | 2 +- 7 files changed, 105 insertions(+), 104 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 2f0e890af9..0ca02d2931 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -306,18 +306,18 @@ static int EvaluateAndFreeExpression(byte *expr) { * \****************************************************************************/ -byte *ParseExpression(byte *lpBuf, HGLOBAL *h) { +const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; uint32 num, i; - num=*lpBuf; + num = *lpBuf; lpBuf++; - if (num==0) + if (num == 0) return NULL; - *h=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,num*sizeof(EXPRESSION)+1); + *h = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h==NULL) return NULL; @@ -441,7 +441,7 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_VAR: - if (strcmp(one->val.name, two->val.name)!=0) { + if (strcmp(one->val.name, two->val.name) != 0) { GlobalUnlock(h1); GlobalUnlock(h2); return false; diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index d54f17b088..582f6d381d 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -76,7 +76,7 @@ namespace MPAL { * \****************************************************************************/ -byte *ParseExpression(byte *lpBuf, HGLOBAL *h); +const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); /****************************************************************************\ diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index c88f485b95..b08a5f2b3d 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -67,12 +67,12 @@ namespace MPAL { static bool CompareCommands(struct command *cmd1, struct command *cmd2) { if (cmd1->type == 2 && cmd2->type == 2) { if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - CompareExpressions(cmd1->expr,cmd2->expr)) + CompareExpressions(cmd1->expr, cmd2->expr)) return true; else return false; } else - return (memcmp(cmd1,cmd2,sizeof(struct command))==0); + return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); } @@ -92,7 +92,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { * \****************************************************************************/ -static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { +static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { int curCmd,j,len; uint i; @@ -127,7 +127,7 @@ static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); lpBuf+=len; - lpBuf=ParseExpression(lpBuf,&lpmsScript->Command[curCmd].expr); + lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); if (lpBuf==NULL) return NULL; break; @@ -162,16 +162,13 @@ static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { * \****************************************************************************/ -static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 i,j,z,kk; uint32 num,num2,num3; byte *lpLock; uint32 curCmd; uint32 len; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); - lpBuf += 4; - /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -185,7 +182,6 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); - lpLock[*lpBuf] = '\0'; GlobalUnlock(lpmdDialog->Periods[i]); lpBuf += (*lpBuf) + 1; } @@ -234,10 +230,9 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { return NULL; Common::copy(lpBuf, lpBuf + len, lpmdDialog->Command[curCmd].lpszVarName); - lpmdDialog->Command[curCmd].lpszVarName[len] = '\0'; lpBuf += len; - lpBuf=ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); + lpBuf = ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); if (lpBuf == NULL) return NULL; break; @@ -355,7 +350,7 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { * \****************************************************************************/ -static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { +static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; uint32 i,j,kk; uint32 curCmd; @@ -403,8 +398,8 @@ static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].when=NULL; } else { lpBuf++; - lpBuf=ParseExpression(lpBuf,&lpmiItem->Action[i].when); - if (lpBuf==NULL) + lpBuf = ParseExpression(lpBuf,&lpmiItem->Action[i].when); + if (lpBuf == NULL) return NULL; } @@ -489,7 +484,7 @@ static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { * \****************************************************************************/ -static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { +static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { lpmlLocation->nObj=*(int *)lpBuf; lpBuf+=4; lpmlLocation->dwXlen=*(uint16 *)lpBuf; @@ -529,32 +524,32 @@ static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { * \****************************************************************************/ -bool ParseMpc(byte *lpBuf) { +bool ParseMpc(const byte *lpBuf) { uint16 i, j; uint16 wLen; byte *lpTemp, *lpTemp2; /* 1. Variabili */ - if (lpBuf[0]!='V' || lpBuf[1]!='A' || lpBuf[2]!='R' || lpBuf[3]!='S') + if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') return false; - lpBuf+=4; - nVars=*(uint16 *)lpBuf; - lpBuf+=2; + lpBuf += 4; + nVars = READ_LE_UINT16(lpBuf); + lpBuf += 2; - hVars=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALVAR)*(uint32)nVars); - if (hVars==NULL) + hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)nVars); + if (hVars == NULL) return false; - lpmvVars=(LPMPALVAR)GlobalLock(hVars); + lpmvVars = (LPMPALVAR)GlobalLock(hVars); - for (i=0;ilpszVarName,lpBuf,MIN(wLen, (uint16)32)); - lpBuf+=wLen; - lpmvVars->dwVal=*(int *)lpBuf; - lpBuf+=4; + CopyMemory(lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + lpBuf += wLen; + lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + lpBuf += 4; lpBuf++; // Salta 'ext' lpmvVars++; @@ -563,44 +558,44 @@ bool ParseMpc(byte *lpBuf) { GlobalUnlock(hVars); /* 2. Messaggi */ - if (lpBuf[0]!='M' || lpBuf[1]!='S' || lpBuf[2]!='G' || lpBuf[3]!='S') + if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; - lpBuf+=4; - nMsgs=*(uint16 *)lpBuf; - lpBuf+=2; + lpBuf += 4; + nMsgs = READ_LE_UINT16(lpBuf); + lpBuf += 2; #ifdef NEED_LOCK_MSGS - hMsgs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); - if (hMsgs==NULL) + hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)nMsgs); + if (hMsgs == NULL) return false; - lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); + lpmmMsgs = (LPMPALMSG)GlobalLock(hMsgs); #else lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); if (lpmmMsgs==NULL) return false; #endif - for (i=0;iwNum=*(uint16 *)lpBuf; - lpBuf+=2; + for (i = 0; i < nMsgs; i++) { + lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); + lpBuf += 2; - for (j=0;lpBuf[j]!=0;) - j+=lpBuf[j]+1; + for (j = 0; lpBuf[j] != 0;) + j += lpBuf[j] + 1; - lpmmMsgs->hText=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,j+1); - lpTemp2=lpTemp=(byte *)GlobalLock(lpmmMsgs->hText); + lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)GlobalLock(lpmmMsgs->hText); - for (j=0;lpBuf[j]!=0;) { - CopyMemory(lpTemp,&lpBuf[j+1],lpBuf[j]); - lpTemp+=lpBuf[j]; - *lpTemp++='\0'; - j+=lpBuf[j]+1; + for (j = 0; lpBuf[j] != 0;) { + CopyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); + lpTemp += lpBuf[j]; + *lpTemp ++= '\0'; + j += lpBuf[j] + 1; } - lpBuf+=j+1; - *lpTemp='\0'; + lpBuf += j + 1; + *lpTemp = '\0'; GlobalUnlock(lpmmMsgs->hText); lpmmMsgs++; @@ -611,87 +606,87 @@ bool ParseMpc(byte *lpBuf) { #endif /* 3. Oggetti */ - if (lpBuf[0]!='O' || lpBuf[1]!='B' || lpBuf[2]!='J' || lpBuf[3]!='S') + if (lpBuf[0] != 'O' || lpBuf[1] != 'B' || lpBuf[2] != 'J' || lpBuf[3] != 'S') return false; - lpBuf+=4; - nObjs=*(uint16 *)lpBuf; - lpBuf+=2; + lpBuf += 4; + nObjs = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Controlla i dialoghi - nDialogs=0; - hDialogs=lpmdDialogs=NULL; - if (*((const char *)lpBuf+2)==6 && strncmp((const char *)lpBuf+3,"Dialog",6)==0) { - nDialogs=*(uint16 *)lpBuf; lpBuf+=2; + nDialogs = 0; + hDialogs = lpmdDialogs = NULL; + if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { + nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - hDialogs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,(uint32)nDialogs*sizeof(MPALDIALOG)); - if (hDialogs==NULL) + hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nDialogs * sizeof(MPALDIALOG)); + if (hDialogs == NULL) return false; - lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); + lpmdDialogs = (LPMPALDIALOG)GlobalLock(hDialogs); - for (i=0;iDataPointer(); + Common::fill(dataP, dataP + size, 0); + } + _memoryBlocks.push_back(newItem); return *newItem; @@ -88,8 +94,8 @@ MemoryItem &MemoryManager::allocate(uint32 size) { * Allocates a new memory block and returns it's data pointer * @returns Data pointer to allocated block */ -HGLOBAL MemoryManager::alloc(uint32 size) { - MemoryItem &newItem = allocate(size); +HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { + MemoryItem &newItem = allocate(size, flags); return (HGLOBAL)newItem.DataPointer(); } diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index ebf42b6207..6fd55e7ce5 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -57,8 +57,8 @@ public: MemoryManager(); virtual ~MemoryManager(); - MemoryItem &allocate(uint32 size); - HGLOBAL alloc(uint32 size); + MemoryItem &allocate(uint32 size, uint flags); + HGLOBAL alloc(uint32 size, uint flags); MemoryItem &getItem(HGLOBAL handle); MemoryItem &operator[](HGLOBAL handle); void erase(MemoryItem *item); @@ -68,8 +68,8 @@ public: }; // defines -#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size) -#define GlobalAllocate(size) _vm->_memoryManager.allocate(size) +#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) +#define GlobalAllocate(size) _vm->_memoryManager.allocate(size, 0) #define GlobalFree(handle) _vm->_memoryManager.erase(handle) #define GlobalLock(handle) (_vm->_memoryManager.getItem(handle).DataPointer()) #define GlobalUnlock(handle) {} diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 55d70b2e18..ec38083a76 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1735,7 +1735,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU hMpc.close(); /* Parsa l'immagine */ - if (ParseMpc(lpMpcImage)==false) + if (ParseMpc(lpMpcImage) == false) return false; GlobalFree(lpMpcImage); -- cgit v1.2.3 From fe0fa0f86b44d6f6766386fa070c84c6f358ccb9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 00:35:16 +1000 Subject: TONY: Added accidentally cut line --- engines/tony/mpal/loadmpc.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index b08a5f2b3d..cdcf91abc4 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -169,6 +169,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; + /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; -- cgit v1.2.3 From 3454a0a9c3738b09ac8de417297cb1f8adb0d2da Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 00:40:23 +1000 Subject: TONY: A few more compiler warning fixes --- engines/tony/gfxengine.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index dd557efafd..6b5105bc35 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -934,7 +934,7 @@ void RMGfxEngine::LoadState(const char *fn) { // Le versioni vecchie necessitano di On enter if (ver < 5) - mpalQueryDoAction(0, loc, 0); + mpalQueryDoActionU32(0, loc, 0); else { // In quelle nuove, ci basta resettare gli mcode MCharResetCodes(); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index cdcf91abc4..27ef3f99c5 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -546,7 +546,7 @@ bool ParseMpc(const byte *lpBuf) { lpmvVars = (LPMPALVAR)GlobalLock(hVars); for (i = 0; i < nVars; i++) { - wLen=*(byte *)lpBuf; + wLen = *(const byte *)lpBuf; lpBuf++; CopyMemory(lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; -- cgit v1.2.3 From 657d93ea8f5e123024c4618b8a3dc441a9f45cbc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:31:21 +1000 Subject: TONY: Fix some Valgrind identified warnings --- engines/tony/font.cpp | 562 +++++++++++++++++++++++----------------------- engines/tony/gfxcore.cpp | 4 +- engines/tony/tonychar.cpp | 22 +- 3 files changed, 294 insertions(+), 294 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index ec5a78731b..c4f589a21d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -286,38 +286,38 @@ void RMFontParla::Init(void) { cTable['\"'] = 77; cTable['^'] = 77; cTable['/'] = 78; - cTable[''] = 79; + cTable[(byte)''] = 79; cTable['$'] = 80; cTable['%'] = 81; cTable['&'] = 82; cTable['='] = 83; - cTable[''] = 84; - cTable[''] = 85; - cTable[''] = 86; - cTable[''] = 87; - cTable[''] = 88; - cTable[''] = 89; - cTable[''] = 89; - cTable[''] = 90; - cTable[''] = 91; - cTable[''] = 92; - cTable[''] = 93; - cTable[''] = 94; - cTable[''] = 95; - cTable[''] = 96; - cTable[''] = 97; - cTable[''] = 98; - cTable[''] = 99; + cTable[(byte)''] = 84; + cTable[(byte)''] = 85; + cTable[(byte)''] = 86; + cTable[(byte)''] = 87; + cTable[(byte)''] = 88; + cTable[(byte)''] = 89; + cTable[(byte)''] = 89; + cTable[(byte)''] = 90; + cTable[(byte)''] = 91; + cTable[(byte)''] = 92; + cTable[(byte)''] = 93; + cTable[(byte)''] = 94; + cTable[(byte)''] = 95; + cTable[(byte)''] = 96; + cTable[(byte)''] = 97; + cTable[(byte)''] = 98; + cTable[(byte)''] = 99; //cTable[' '] = 100; e cerchietto //cTable[' '] = 101; i cerchietto //cTable[' '] = 102; o cerchietto //cTable[' '] = 103; u cerchietto - cTable[''] = 104; - cTable[''] = 105; - cTable[''] = 106; - cTable[''] = 107; - cTable[''] = 108; - cTable[''] = 109; + cTable[(byte)''] = 104; + cTable[(byte)''] = 105; + cTable[(byte)''] = 106; + cTable[(byte)''] = 107; + cTable[(byte)''] = 108; + cTable[(byte)''] = 109; //cTable[''] = 110; integrale cTable['\''] = 111; @@ -359,43 +359,43 @@ void RMFontParla::Init(void) { //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[''] = 112; - cTable[''] = 113; - cTable[''] = 114; - cTable[''] = 115; - cTable[''] = 116; - cTable[''] = 117; - cTable[''] = 118; - cTable[''] = 119; - cTable[''] = 120; - cTable[''] = 121; - cTable[''] = 122; - cTable[''] = 123; - cTable[''] = 124; - cTable[''] = 125; - cTable[''] = 126; - cTable[''] = 127; - cTable[''] = 128; - cTable[''] = 129; - - lTable[''] = 14; - lTable[''] = 16; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 13; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; #ifdef FONT_RUSSIAN // Russian Characters @@ -403,241 +403,241 @@ void RMFontParla::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = 130; - cTable[''] = 131; - cTable[''] = 132; - cTable[''] = 133; - cTable[''] = 134; - cTable[''] = 135; - cTable[''] = 136; - cTable[''] = 137; - cTable[''] = 138; - cTable[''] = 139; - cTable[''] = 140; - cTable[''] = 141; - cTable[''] = 142; - cTable[''] = 143; - cTable[''] = 144; - cTable[''] = 145; - cTable[''] = 146; - cTable[''] = 147; - cTable[''] = 148; - cTable[''] = 149; - cTable[''] = 150; - cTable[''] = 151; - cTable[''] = 152; - cTable[''] = 153; - cTable[''] = 154; - cTable[''] = 155; - cTable[''] = 156; - cTable[''] = 157; - cTable[''] = 158; - cTable[''] = 159; - cTable[''] = 160; - cTable[''] = 161; - cTable[''] = 162; - - cTable[''] = 163; - cTable[''] = 164; - cTable[''] = 165; - cTable[''] = 166; - cTable[''] = 167; - cTable[''] = 168; - cTable[''] = 169; - cTable[''] = 170; - cTable[''] = 171; - cTable[''] = 172; - cTable[''] = 173; - cTable[''] = 174; - cTable[''] = 175; - cTable[''] = 176; - cTable[''] = 177; - cTable[''] = 178; - cTable[''] = 179; - cTable[''] = 180; - cTable[''] = 181; - cTable[''] = 182; - cTable[''] = 183; - cTable[''] = 184; - cTable[''] = 185; - cTable[''] = 186; - cTable[''] = 187; - cTable[''] = 188; - cTable[''] = 189; - cTable[''] = 190; - cTable[''] = 191; - cTable[''] = 192; - cTable[''] = 193; - cTable[''] = 194; - cTable[''] = 195; - - lTable[''] = 13; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 14; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 18; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 17; - lTable[''] = 18; - lTable[''] = 16; - lTable[''] = 18; - lTable[''] = 19; - lTable[''] = 11; - lTable[''] = 16; - lTable[''] = 14; - - lTable[''] = 14; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 14; - lTable[''] = 8; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 16; - lTable[''] = 14; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 9; - lTable[''] = 15; - lTable[''] = 14; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 18; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 18; + lTable[(byte)''] = 19; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 9; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; #endif // FONT_RUSSIAN #ifdef FONT_CZECH - cTable[''] = 196; - cTable[''] = 197; - cTable[''] = 198; - cTable[''] = 199; - cTable[''] = 200; - cTable[''] = 201; - cTable[''] = 202; - cTable[''] = 203; - cTable[''] = 204; - cTable[''] = 205; - cTable[''] = 206; - cTable[''] = 207; - cTable[''] = 208; - cTable[''] = 209; - cTable[''] = 210; - - cTable[''] = 211; - cTable[''] = 212; - cTable[''] = 213; - cTable[''] = 214; - cTable[''] = 215; - cTable[''] = 216; - cTable[''] = 217; - cTable[''] = 218; - cTable[''] = 219; - cTable[''] = 220; - cTable[''] = 221; - cTable[''] = 222; - cTable[''] = 223; - cTable[''] = 224; - cTable[''] = 225; - - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 19; - lTable[''] = 10; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 13; - - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 7; - lTable[''] = 12; - lTable[''] = 17; - lTable[''] = 16; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 13; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 19; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 7; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; #endif // FONT_CZECH #ifdef FONT_FRENCH - cTable[''] = 226; - cTable[''] = 227; - cTable[''] = 228; - cTable[''] = 229; - cTable[''] = 230; - cTable[''] = 231; - cTable[''] = 232; - cTable[''] = 233; - - lTable[''] = 15; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 9; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 9; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_FRENCH #ifdef FONT_GERMAN - cTable[''] = 234; + cTable[(byte)''] = 234; // 'SS' = 235 - cTable[''] = 236; - cTable[''] = 237; - cTable[''] = 238; + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; - lTable[''] = 15; + lTable[(byte)''] = 15; #endif // FONT_GERMAN } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 9f725f2523..5737a6af45 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1832,7 +1832,7 @@ RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int x,y; + int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16*)m_buf; int dimx, dimy; @@ -1881,7 +1881,7 @@ void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) } } else { for (y = 0; y < dimy; y++) { - CopyMemory(buf, raw, dimx * 2); + Common::copy(raw, raw + dimx, buf); buf += bigBuf.Dimx(); raw += m_dimx; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 12a8c8eabb..a2648318fe 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -82,6 +82,17 @@ void RMTony::Init(void) { RMRes body(9999); RMDataStream ds; + // Mostra Tony di default + m_bShow=m_bShowOmbra = true; + + // Nessuna azione in attesa + m_bActionPending = false; + m_bAction = false; + + m_bPastorella = false; + m_bIsTalking = false; + m_bIsStaticTalk = false; + // Apre il buffer ds.OpenBuffer(tony); @@ -97,17 +108,6 @@ void RMTony::Init(void) { ds.Close(); m_body.SetPattern(0); - // Mostra Tony di default - m_bShow=m_bShowOmbra = true; - - // Nessuna azione in attesa - m_bActionPending = false; - m_bAction = false; - - m_bPastorella = false; - m_bIsTalking = false; - m_bIsStaticTalk = false; - m_nTimeLastStep = _vm->GetTime(); } -- cgit v1.2.3 From 0b249c042f8c3f70188d3ce97516fe1290c30504 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:38:22 +1000 Subject: TONY: Correct some initialisation of the character arrays --- engines/tony/font.cpp | 324 +++++++++++++++++++++++++------------------------- 1 file changed, 162 insertions(+), 162 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index c4f589a21d..f28d4f6eea 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1534,37 +1534,37 @@ void RMFontObj::Init(void) { cTable['='] = 49; cTable['\''] = 50; cTable['\"'] = 51; - cTable[''] = 52; - cTable['$'] = 53; - cTable['%'] = 54; - cTable['&'] = 55; - cTable['^'] = 56; - cTable['*'] = 57; - cTable['<'] = 58; - cTable['>'] = 59; - cTable[''] = 60; - cTable[''] = 61; - cTable[''] = 62; - cTable[''] = 63; - //cTable[''] = 64; integrale - cTable[''] = 65; - cTable[''] = 66; - cTable[''] = 67; - cTable[''] = 68; - cTable[''] = 69; - cTable[''] = cTable[''] = 70; - cTable[''] = 71; - cTable[''] = 72; - cTable[''] = 73; - //cTable[' '] = 74; e cerchietto - cTable[''] = 75; - cTable[''] = 76; - //cTable[' '] = 77; i cerchietto - cTable[''] = 78; - cTable[''] = cTable[''] = 79; - //cTable[' '] = 80; o cerchietto - cTable[''] = 81; - cTable[''] = cTable[''] = 82; + cTable[(byte)''] = 52; + cTable[(byte)'$'] = 53; + cTable[(byte)'%'] = 54; + cTable[(byte)'&'] = 55; + cTable[(byte)'^'] = 56; + cTable[(byte)'*'] = 57; + cTable[(byte)'<'] = 58; + cTable[(byte)'>'] = 59; + cTable[(byte)''] = 60; + cTable[(byte)''] = 61; + cTable[(byte)''] = 62; + cTable[(byte)''] = 63; + //cTable[(byte)''] = 64; integrale + cTable[(byte)''] = 65; + cTable[(byte)''] = 66; + cTable[(byte)''] = 67; + cTable[(byte)''] = 68; + cTable[(byte)''] = 69; + cTable[(byte)''] = cTable[(byte)''] = 70; + cTable[(byte)''] = 71; + cTable[(byte)''] = 72; + cTable[(byte)''] = 73; + //cTable[(byte)' '] = 74; e cerchietto + cTable[(byte)''] = 75; + cTable[(byte)''] = 76; + //cTable[(byte)' '] = 77; i cerchietto + cTable[(byte)''] = 78; + cTable[(byte)''] = cTable[(byte)''] = 79; + //cTable[(byte)' '] = 80; o cerchietto + cTable[(byte)''] = 81; + cTable[(byte)''] = cTable[(byte)''] = 82; //cTable[' '] = 83; u cerchietto //cTable[' '] = 84; y dieresi @@ -1610,7 +1610,7 @@ void RMFontObj::Init(void) { lTable['y'] = lTable['Y'] = 13; lTable['w'] = lTable['W'] = 19; lTable['z'] = lTable['Z'] = 20; - lTable[''] = 17; + lTable[(byte)''] = 17; /* Casi particolari */ SetBothCase('C','C',2); @@ -1629,32 +1629,32 @@ void RMFontObj::Init(void) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz - cTable[''] = cTable[''] = 85; - lTable[''] = lTable[''] = 20; + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; - cTable[''] = cTable[''] = 86; - lTable[''] = lTable[''] = 22; + cTable[(byte)''] = cTable[(byte)''] = 86; + lTable[(byte)''] = lTable[(byte)''] = 22; - cTable[''] = cTable[''] = 87; - lTable[''] = lTable[''] = 17; + cTable[(byte)''] = cTable[(byte)''] = 87; + lTable[(byte)''] = lTable[(byte)''] = 17; - cTable[''] = cTable[''] = 88; - lTable[''] = lTable[''] = 19; + cTable[(byte)''] = cTable[(byte)''] = 88; + lTable[(byte)''] = lTable[(byte)''] = 19; - cTable[''] = cTable[''] = 89; - lTable[''] = lTable[''] = 17; + cTable[(byte)''] = cTable[(byte)''] = 89; + lTable[(byte)''] = lTable[(byte)''] = 17; - cTable[''] = cTable[''] = 90; - lTable[''] = lTable[''] = 22; + cTable[(byte)''] = cTable[(byte)''] = 90; + lTable[(byte)''] = lTable[(byte)''] = 22; - cTable[''] = cTable[''] = 91; - lTable[''] = lTable[''] = 15; + cTable[(byte)''] = cTable[(byte)''] = 91; + lTable[(byte)''] = lTable[(byte)''] = 15; - cTable[''] = cTable[''] = 92; - lTable[''] = lTable[''] = 21; + cTable[(byte)''] = cTable[(byte)''] = 92; + lTable[(byte)''] = lTable[(byte)''] = 21; - cTable[''] = cTable[''] = 93; - lTable[''] = lTable[''] = 21; + cTable[(byte)''] = cTable[(byte)''] = 93; + lTable[(byte)''] = lTable[(byte)''] = 21; #ifdef FONT_RUSSIAN @@ -1663,114 +1663,114 @@ void RMFontObj::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = cTable[''] = 85; - lTable[''] = lTable[''] = 20; - - cTable[''] = cTable[''] =94; - cTable[''] = cTable[''] =95; - cTable[''] = cTable[''] =96; - cTable[''] = cTable[''] =97; - cTable[''] = cTable[''] =98; - cTable[''] = cTable[''] =99; - cTable[''] = cTable[''] =100; - cTable[''] = cTable[''] =101; - cTable[''] = cTable[''] =102; - cTable[''] = cTable[''] =103; - cTable[''] = cTable[''] =104; - cTable[''] = cTable[''] =105; - cTable[''] = cTable[''] =106; - cTable[''] = cTable[''] =107; - cTable[''] = cTable[''] =108; - cTable[''] = cTable[''] =109; - cTable[''] = cTable[''] =110; - cTable[''] = cTable[''] =111; - cTable[''] = cTable[''] =112; - cTable[''] = cTable[''] =113; - cTable[''] = cTable[''] =114; - cTable[''] = cTable[''] =115; - cTable[''] = cTable[''] =116; - cTable[''] = cTable[''] =117; - cTable[''] = cTable[''] =118; - cTable[''] = cTable[''] =119; - cTable[''] = cTable[''] =120; - cTable[''] = cTable[''] =121; - cTable[''] = cTable[''] =122; - cTable[''] = cTable[''] =123; - cTable[''] = cTable[''] =124; - cTable[''] = cTable[''] =125; - cTable[''] = cTable[''] =126; - - - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 17; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 20; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 15; - lTable[''] = lTable[''] = 22; - lTable[''] = lTable[''] = 15; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 22; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 21; - lTable[''] = lTable[''] = 20; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 22; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 15; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; + + cTable[(byte)''] = cTable[(byte)''] =94; + cTable[(byte)''] = cTable[(byte)''] =95; + cTable[(byte)''] = cTable[(byte)''] =96; + cTable[(byte)''] = cTable[(byte)''] =97; + cTable[(byte)''] = cTable[(byte)''] =98; + cTable[(byte)''] = cTable[(byte)''] =99; + cTable[(byte)''] = cTable[(byte)''] =100; + cTable[(byte)''] = cTable[(byte)''] =101; + cTable[(byte)''] = cTable[(byte)''] =102; + cTable[(byte)''] = cTable[(byte)''] =103; + cTable[(byte)''] = cTable[(byte)''] =104; + cTable[(byte)''] = cTable[(byte)''] =105; + cTable[(byte)''] = cTable[(byte)''] =106; + cTable[(byte)''] = cTable[(byte)''] =107; + cTable[(byte)''] = cTable[(byte)''] =108; + cTable[(byte)''] = cTable[(byte)''] =109; + cTable[(byte)''] = cTable[(byte)''] =110; + cTable[(byte)''] = cTable[(byte)''] =111; + cTable[(byte)''] = cTable[(byte)''] =112; + cTable[(byte)''] = cTable[(byte)''] =113; + cTable[(byte)''] = cTable[(byte)''] =114; + cTable[(byte)''] = cTable[(byte)''] =115; + cTable[(byte)''] = cTable[(byte)''] =116; + cTable[(byte)''] = cTable[(byte)''] =117; + cTable[(byte)''] = cTable[(byte)''] =118; + cTable[(byte)''] = cTable[(byte)''] =119; + cTable[(byte)''] = cTable[(byte)''] =120; + cTable[(byte)''] = cTable[(byte)''] =121; + cTable[(byte)''] = cTable[(byte)''] =122; + cTable[(byte)''] = cTable[(byte)''] =123; + cTable[(byte)''] = cTable[(byte)''] =124; + cTable[(byte)''] = cTable[(byte)''] =125; + cTable[(byte)''] = cTable[(byte)''] =126; + + + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; #endif // FONT_RUSSIAN #ifdef FONT_CZECH // rep. ceca characters - cTable[''] = cTable[''] = 127; - cTable[''] = cTable[''] = 128; - cTable[''] = cTable[''] = 129; - cTable[''] = cTable[''] = 130; - cTable[''] = cTable[''] = 131; - cTable[''] = cTable[''] = 132; - cTable[''] = cTable[''] = 133; - cTable[''] = cTable[''] = 134; - cTable[''] = cTable[''] = 135; - cTable[''] = cTable[''] = 136; - cTable[''] = cTable[''] = 137; - cTable[''] = cTable[''] = 138; - cTable[''] = cTable[''] = 139; - cTable[''] = cTable[''] = 140; - cTable[''] = cTable[''] = 141; - - lTable[''] = lTable[''] =17; - lTable[''] = lTable[''] =15; - lTable[''] = lTable[''] =22; - lTable[''] = lTable[''] =18; - lTable[''] = lTable[''] =21; - lTable[''] = lTable[''] =16; - lTable[''] = lTable[''] =18; - lTable[''] = lTable[''] =19; - lTable[''] = lTable[''] =17; - lTable[''] = lTable[''] =23; - lTable[''] = lTable[''] =24; - lTable[''] = lTable[''] =17; - lTable[''] = lTable[''] =22; - lTable[''] = lTable[''] =16; - lTable[''] = lTable[''] =16; + cTable[(byte)''] = cTable[(byte)''] = 127; + cTable[(byte)''] = cTable[(byte)''] = 128; + cTable[(byte)''] = cTable[(byte)''] = 129; + cTable[(byte)''] = cTable[(byte)''] = 130; + cTable[(byte)''] = cTable[(byte)''] = 131; + cTable[(byte)''] = cTable[(byte)''] = 132; + cTable[(byte)''] = cTable[(byte)''] = 133; + cTable[(byte)''] = cTable[(byte)''] = 134; + cTable[(byte)''] = cTable[(byte)''] = 135; + cTable[(byte)''] = cTable[(byte)''] = 136; + cTable[(byte)''] = cTable[(byte)''] = 137; + cTable[(byte)''] = cTable[(byte)''] = 138; + cTable[(byte)''] = cTable[(byte)''] = 139; + cTable[(byte)''] = cTable[(byte)''] = 140; + cTable[(byte)''] = cTable[(byte)''] = 141; + + lTable[(byte)''] = lTable[(byte)''] =17; + lTable[(byte)''] = lTable[(byte)''] =15; + lTable[(byte)''] = lTable[(byte)''] =22; + lTable[(byte)''] = lTable[(byte)''] =18; + lTable[(byte)''] = lTable[(byte)''] =21; + lTable[(byte)''] = lTable[(byte)''] =16; + lTable[(byte)''] = lTable[(byte)''] =18; + lTable[(byte)''] = lTable[(byte)''] =19; + lTable[(byte)''] = lTable[(byte)''] =17; + lTable[(byte)''] = lTable[(byte)''] =23; + lTable[(byte)''] = lTable[(byte)''] =24; + lTable[(byte)''] = lTable[(byte)''] =17; + lTable[(byte)''] = lTable[(byte)''] =22; + lTable[(byte)''] = lTable[(byte)''] =16; + lTable[(byte)''] = lTable[(byte)''] =16; #endif // FONT_CZECH @@ -1778,20 +1778,20 @@ void RMFontObj::Init(void) { // traduci le lettere accentate in lettere normali - cTable[''] = cTable[''] = cTable[''] = 0; // a - lTable[''] = lTable[''] = lTable[''] = 17; + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; - cTable[''] = cTable[''] = 4; // e - lTable[''] = lTable[''] = 15; + cTable[(byte)''] = cTable[(byte)''] = 4; // e + lTable[(byte)''] = lTable[(byte)''] = 15; - cTable[''] = cTable[''] = cTable[''] = 8; // i - lTable[''] = lTable[''] = lTable[''] = 16; + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; - cTable[''] = cTable[''] = cTable[''] = cTable[''] = 14; // o - lTable[''] = lTable[''] = lTable[''] = lTable[''] = 19; + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; - cTable[''] = cTable[''] = 20; // u - lTable[''] = lTable[''] = 15; + cTable[(byte)''] = cTable[(byte)''] = 20; // u + lTable[(byte)''] = lTable[(byte)''] = 15; #endif // FONT_FRENCH -- cgit v1.2.3 From bff40634924d809a549e79890d5e7f37f51fd432 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:42:26 +1000 Subject: TONY: Correct some more chararcter array initialisations --- engines/tony/font.cpp | 546 +++++++++++++++++++++++++------------------------- 1 file changed, 273 insertions(+), 273 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index f28d4f6eea..59a2e8cfc4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -695,7 +695,7 @@ void RMFontMacc::Init(void) { //cTable['?'] = 73; // ? rovescia cTable['*'] = 74; cTable['+'] = 75; - cTable[''] = 76; + cTable[(byte)''] = 76; cTable[';'] = 77; cTable[','] = 78; cTable['.'] = 79; @@ -704,65 +704,65 @@ void RMFontMacc::Init(void) { cTable['<'] = 82; cTable['>'] = 83; cTable['/'] = 84; - cTable[''] = 85; - cTable[''] = 86; - cTable[''] = 87; - cTable[''] = 88; - cTable[''] = 89; - cTable[''] = 90; - //cTable[''] = 91; // e col pallino - cTable[''] = 92; - cTable[''] = 93; - //cTable[''] = 94; // i col pallino - cTable[''] = 95; - cTable[''] = 96; - //cTable[''] = 97; // o col pallino - cTable[''] = 98; - cTable[''] = 99; - //cTable[''] = 100; // u col pallino - cTable[''] = 101; + cTable[(byte)''] = 85; + cTable[(byte)''] = 86; + cTable[(byte)''] = 87; + cTable[(byte)''] = 88; + cTable[(byte)''] = 89; + cTable[(byte)''] = 90; + //cTable[(byte)''] = 91; // e col pallino + cTable[(byte)''] = 92; + cTable[(byte)''] = 93; + //cTable[(byte)''] = 94; // i col pallino + cTable[(byte)''] = 95; + cTable[(byte)''] = 96; + //cTable[(byte)''] = 97; // o col pallino + cTable[(byte)''] = 98; + cTable[(byte)''] = 99; + //cTable[(byte)''] = 100; // u col pallino + cTable[(byte)''] = 101; // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[''] = 102; - cTable[''] = 103; - cTable[''] = 104; - cTable[''] = 105; - cTable[''] = 106; - cTable[''] = 107; - cTable[''] = 108; - cTable[''] = 109; - cTable[''] = 110; - cTable[''] = 111; - cTable[''] = 112; - cTable[''] = 113; - cTable[''] = 114; - cTable[''] = 115; - cTable[''] = 116; - cTable[''] = 117; - cTable[''] = 118; - cTable[''] = 119; + cTable[(byte)''] = 102; + cTable[(byte)''] = 103; + cTable[(byte)''] = 104; + cTable[(byte)''] = 105; + cTable[(byte)''] = 106; + cTable[(byte)''] = 107; + cTable[(byte)''] = 108; + cTable[(byte)''] = 109; + cTable[(byte)''] = 110; + cTable[(byte)''] = 111; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; - lTable[''] = 14; - lTable[''] = 16; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; #ifdef FONT_RUSSIAN @@ -771,242 +771,242 @@ void RMFontMacc::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = 120; - cTable[''] = 121; - cTable[''] = 122; - cTable[''] = 123; - cTable[''] = 124; - cTable[''] = 125; - cTable[''] = 126; - cTable[''] = 127; - cTable[''] = 128; - cTable[''] = 129; - cTable[''] = 130; - cTable[''] = 131; - cTable[''] = 132; - cTable[''] = 133; - cTable[''] = 134; - cTable[''] = 135; - cTable[''] = 136; - cTable[''] = 137; - cTable[''] = 138; - cTable[''] = 139; - cTable[''] = 140; - cTable[''] = 141; - cTable[''] = 142; - cTable[''] = 143; - cTable[''] = 144; - cTable[''] = 145; - cTable[''] = 146; - cTable[''] = 147; - cTable[''] = 148; - cTable[''] = 149; - cTable[''] = 150; - cTable[''] = 151; - cTable[''] = 152; - - cTable[''] = 153; - cTable[''] = 154; - cTable[''] = 155; - cTable[''] = 156; - cTable[''] = 157; - cTable[''] = 158; - cTable[''] = 159; - cTable[''] = 160; - cTable[''] = 161; - cTable[''] = 162; - cTable[''] = 163; - cTable[''] = 164; - cTable[''] = 165; - cTable[''] = 166; - cTable[''] = 167; - cTable[''] = 168; - cTable[''] = 169; - cTable[''] = 170; - cTable[''] = 171; - cTable[''] = 172; - cTable[''] = 173; - cTable[''] = 174; - cTable[''] = 175; - cTable[''] = 176; - cTable[''] = 177; - cTable[''] = 178; - cTable[''] = 179; - cTable[''] = 180; - cTable[''] = 181; - cTable[''] = 182; - cTable[''] = 183; - cTable[''] = 184; - cTable[''] = 185; - - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 8; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 8; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_RUSSIAN #ifdef FONT_CZECH - cTable[''] = 186; - cTable[''] = 187; - cTable[''] = 188; - cTable[''] = 189; - cTable[''] = 190; - cTable[''] = 191; - cTable[''] = 192; - cTable[''] = 193; - cTable[''] = 194; - cTable[''] = 195; - cTable[''] = 196; - cTable[''] = 197; - cTable[''] = 198; - cTable[''] = 199; - cTable[''] = 200; - - cTable[''] = 201; - cTable[''] = 202; - cTable[''] = 203; - cTable[''] = 204; - cTable[''] = 205; - cTable[''] = 206; - cTable[''] = 207; - cTable[''] = 208; - cTable[''] = 209; - cTable[''] = 210; - cTable[''] = 211; - cTable[''] = 212; - cTable[''] = 213; - cTable[''] = 214; - cTable[''] = 215; - - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_CZECH #ifdef FONT_FRENCH - cTable[''] = 226; - cTable[''] = 227; - cTable[''] = 228; - cTable[''] = 229; - cTable[''] = 230; - cTable[''] = 231; - cTable[''] = 232; - cTable[''] = 233; + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 8; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; #endif // FONT_FRENCH #ifdef FONT_GERMAN - cTable[''] = 234; + cTable[(byte)''] = 234; // 'SS' = 235 - cTable[''] = 236; - cTable[''] = 237; - cTable[''] = 238; + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; - lTable[''] = 11; + lTable[(byte)''] = 11; #endif // FONT_GERMAN } -- cgit v1.2.3 From cd41c55799d8fa1df83b0cee07169f23b0db27a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:47:45 +1000 Subject: TONY: More corrections for font initislisations --- engines/tony/font.cpp | 540 +++++++++++++++++++++++++------------------------- 1 file changed, 270 insertions(+), 270 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 59a2e8cfc4..60c7b8d525 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1047,32 +1047,32 @@ void RMFontCredits::Init(void) { - cTable[''] = 52; - cTable[''] = 53; + cTable[(byte)''] = 52; + cTable[(byte)''] = 53; // cTable[''] = 54; // a ^ // cTable[''] = 55; // a pallini - cTable[''] = 56; - cTable[''] = 57; + cTable[(byte)''] = 56; + cTable[(byte)''] = 57; // cTable[''] = 58; // e ^ // cTable[''] = 59; // e pallini cTable[''] = 60; cTable[''] = 61; // cTable[''] = 62; // i ^ // cTable[''] = 63; // i pallini - cTable[''] = 64; - cTable[''] = 65; + cTable[(byte)''] = 64; + cTable[(byte)''] = 65; // cTable[''] = 66; // o ^ // cTable[''] = 67; // o pallini - cTable[''] = 68; - cTable[''] = 69; + cTable[(byte)''] = 68; + cTable[(byte)''] = 69; // cTable[''] = 70; // u ^ // cTable[''] = 71; // u pallini // cTable[''] = 72; // y pallini - cTable[''] = 73; - cTable[''] = 74; + cTable[(byte)''] = 73; + cTable[(byte)''] = 74; // cTable[''] = 75; // o barrato // cTable[''] = 76; // ac - cTable[''] = 77; + cTable[(byte)''] = 77; // cTable[''] = 78; // ? rovesciato cTable['?'] = 79; // cTable[''] = 80; // ! rovesciato @@ -1081,8 +1081,8 @@ void RMFontCredits::Init(void) { // cTable[''] = 83; // 1/4 cTable['('] = 84; cTable[')'] = 85; - cTable[''] = 86; - cTable[''] = 87; + cTable[(byte)''] = 86; + cTable[(byte)''] = 87; // cTable[''] = 88; // AE cTable[':'] = 89; cTable['%'] = 90; @@ -1102,7 +1102,7 @@ void RMFontCredits::Init(void) { cTable['\''] = 111; lTable[' '] = 11; - lTable[''] = lTable['A'] = 19; + lTable[(byte)''] = lTable['A'] = 19; lTable['B'] = 15; lTable['C'] = 14; lTable['D'] = 13; @@ -1181,43 +1181,43 @@ void RMFontCredits::Init(void) { //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[''] = 112; - cTable[''] = 113; - cTable[''] = 114; - cTable[''] = 115; - cTable[''] = 116; - cTable[''] = 117; - cTable[''] = 118; - cTable[''] = 119; - cTable[''] = 120; - cTable[''] = 121; - cTable[''] = 122; - cTable[''] = 123; - cTable[''] = 124; - cTable[''] = 125; - cTable[''] = 126; - cTable[''] = 127; - cTable[''] = 128; - cTable[''] = 129; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; - lTable[''] = 20; - lTable[''] = 12; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 14; - lTable[''] = 11; - lTable[''] = 16; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 10; + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; #ifdef FONT_RUSSIAN @@ -1226,244 +1226,244 @@ void RMFontCredits::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = 130; - cTable[''] = 131; - cTable[''] = 132; - cTable[''] = 133; - cTable[''] = 134; - cTable[''] = 135; - cTable[''] = 136; - cTable[''] = 137; - cTable[''] = 138; - cTable[''] = 139; - cTable[''] = 140; - cTable[''] = 141; - cTable[''] = 142; - cTable[''] = 143; - cTable[''] = 144; - cTable[''] = 145; - cTable[''] = 146; - cTable[''] = 147; - cTable[''] = 148; - cTable[''] = 149; - cTable[''] = 150; - cTable[''] = 151; - cTable[''] = 152; - cTable[''] = 153; - cTable[''] = 154; - cTable[''] = 155; - cTable[''] = 156; - cTable[''] = 157; - cTable[''] = 158; - cTable[''] = 159; - cTable[''] = 160; - cTable[''] = 161; - cTable[''] = 162; - - cTable[''] = 163; - cTable[''] = 164; - cTable[''] = 165; - cTable[''] = 166; - cTable[''] = 167; - cTable[''] = 168; - cTable[''] = 169; - cTable[''] = 170; - cTable[''] = 171; - cTable[''] = 172; - cTable[''] = 173; - cTable[''] = 174; - cTable[''] = 175; - cTable[''] = 176; - cTable[''] = 177; - cTable[''] = 178; - cTable[''] = 179; - cTable[''] = 180; - cTable[''] = 181; - cTable[''] = 182; - cTable[''] = 183; - cTable[''] = 184; - cTable[''] = 185; - cTable[''] = 186; - cTable[''] = 187; - cTable[''] = 188; - cTable[''] = 189; - cTable[''] = 190; - cTable[''] = 191; - cTable[''] = 192; - cTable[''] = 193; - cTable[''] = 194; - cTable[''] = 195; - - lTable[''] = 20; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 14; - lTable[''] = 22; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 20; - lTable[''] = 12; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 22; - lTable[''] = 18; - lTable[''] = 16; - lTable[''] = 15; - lTable[''] = 14; - lTable[''] = 13; - lTable[''] = 15; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 15; - lTable[''] = 13; - lTable[''] = 16; - lTable[''] = 14; - lTable[''] = 23; - lTable[''] = 23; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 16; - lTable[''] = 12; - lTable[''] = 20; - lTable[''] = 15; - - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 16; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 16; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 20; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 22; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 22; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 23; + lTable[(byte)''] = 23; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 20; + lTable[(byte)''] = 15; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; #endif // FONT_RUSSIAN #ifdef FONT_CZECH - cTable[''] = 196; - cTable[''] = 197; - cTable[''] = 198; - cTable[''] = 199; - cTable[''] = 200; - cTable[''] = 201; - cTable[''] = 202; - cTable[''] = 203; - cTable[''] = 204; - cTable[''] = 205; - cTable[''] = 206; - cTable[''] = 207; - cTable[''] = 208; - cTable[''] = 209; - cTable[''] = 210; - - cTable[''] = 211; - cTable[''] = 212; - cTable[''] = 213; - cTable[''] = 214; - cTable[''] = 215; - cTable[''] = 216; - cTable[''] = 217; - cTable[''] = 218; - cTable[''] = 219; - cTable[''] = 220; - cTable[''] = 221; - cTable[''] = 222; - cTable[''] = 223; - cTable[''] = 224; - cTable[''] = 225; - - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 14; - lTable[''] = 20; - lTable[''] = 7; - lTable[''] = 15; - lTable[''] = 20; - lTable[''] = 19; - lTable[''] = 16; - lTable[''] = 15; - lTable[''] = 13; - lTable[''] = 13; - - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 6; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 12; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 20; + lTable[(byte)''] = 7; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 19; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; #endif // FONT_CZECH #ifdef FONT_FRENCH - cTable[''] = 226; - cTable[''] = 227; - cTable[''] = 228; - cTable[''] = 229; - cTable[''] = 230; - cTable[''] = 231; - cTable[''] = 232; - cTable[''] = 233; - - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 6; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_FRENCH #ifdef FONT_GERMAN - cTable[''] = 234; + cTable[(byte)''] = 234; // 'SS' = 235 // old chars overrides - cTable[''] = cTable[''] = 55; - cTable[''] = cTable[''] = 67; - cTable[''] = cTable[''] = 71; + cTable[(byte)''] = cTable[(byte)''] = 55; + cTable[(byte)''] = cTable[(byte)''] = 67; + cTable[(byte)''] = cTable[(byte)''] = 71; - lTable[''] = 11; + lTable[(byte)''] = 11; #endif // FONT_GERMAN } -- cgit v1.2.3 From 91328fce56144caf15abc8995b68a5a5a0562f0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:56:06 +1000 Subject: TONY: Fixed some more Valgrid identified errors --- engines/tony/font.cpp | 4 ++-- engines/tony/mpal/mpal.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 60c7b8d525..42540a2620 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1055,8 +1055,8 @@ void RMFontCredits::Init(void) { cTable[(byte)''] = 57; // cTable[''] = 58; // e ^ // cTable[''] = 59; // e pallini - cTable[''] = 60; - cTable[''] = 61; + cTable[(byte)''] = 60; + cTable[(byte)''] = 61; // cTable[''] = 62; // i ^ // cTable[''] = 63; // i pallini cTable[(byte)''] = 64; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index ec38083a76..5f88eef268 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1518,7 +1518,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { return INVALID_HANDLE_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes - CopyMemory(newitem,item,sizeof(MPALITEM)); + Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ -- cgit v1.2.3 From 734fae9193fdabd6dcac5f40f765d904c030f7d1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 10:32:43 +1000 Subject: TONY: Fixed some memory leaks identified by Valgrind --- engines/tony/gfxcore.cpp | 5 +++-- engines/tony/gfxengine.cpp | 3 +++ engines/tony/inventory.cpp | 13 ++++++++++--- engines/tony/loc.cpp | 8 ++++++++ engines/tony/loc.h | 3 +++ 5 files changed, 27 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 5737a6af45..de78b51a4e 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -709,11 +709,12 @@ void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) { RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { alphaBlendColor = -1; bNeedRLECompress = true; + m_buf = NULL; } RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { if (m_buf != NULL) { - delete m_buf; + delete[] m_buf; m_buf = NULL; } } @@ -833,7 +834,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { // Ci copia l'immagine compressa x = cur - MegaRLEBuf; m_buf = new byte[x]; - CopyMemory(m_buf, MegaRLEBuf, x); + Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); } void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 6b5105bc35..7f2515af7b 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -78,11 +78,14 @@ RMGfxEngine::RMGfxEngine() { // Crea il big buffer dove verranno disegnati i frame m_bigBuf.Create(RM_BBX, RM_BBY, 16); m_bigBuf.OffsetY(RM_SKIPY); + + csMainLoop = NULL; } RMGfxEngine::~RMGfxEngine() { // Chiude il buffer m_bigBuf.Destroy(); + g_system->deleteMutex(csMainLoop); } void RMGfxEngine::OpenOptionScreen(int type) { diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index ade9c0eb34..50e4dd9411 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -63,6 +63,7 @@ RMInventory::RMInventory() { m_state = CLOSED; m_bCombining = false; m_csModifyInterface = g_system->createMutex(); + m_nItems = 0; } RMInventory::~RMInventory() { @@ -94,7 +95,7 @@ void RMInventory::Init(void) { // Nuovi oggetti m_nItems = 78; // @@@ Numero di oggetti prendibili - m_items = new RMInventoryItem[m_nItems+1]; + m_items = new RMInventoryItem[m_nItems + 1]; curres = 10500; @@ -114,14 +115,15 @@ void RMInventory::Init(void) { ds.Close(); // Mette di default a pattern 1 - m_items[i].status=1; + m_items[i].pointer = NULL; + m_items[i].status = 1; m_items[i].icon.SetPattern(1); m_items[i].icon.DoFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; - m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; + m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; for (j = 0; j < m_items[i].icon.NumPattern(); j++) { RMResRaw raw(curres); @@ -174,6 +176,11 @@ void RMInventory::Init(void) { void RMInventory::Close(void) { // Ciao memoria if (m_items != NULL) { + // Delete the item pointers + for (int i = 0; i <= m_nItems; i++) + delete[] m_items[i].pointer; + + // Delete the items array delete[] m_items; m_items = NULL; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 62249da255..b5a233391a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1694,6 +1694,14 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { * RMBoxLoc Methods \****************************************************************************/ +RMBoxLoc::RMBoxLoc() { + boxes = NULL; +} + +RMBoxLoc::~RMBoxLoc() { + delete[] boxes; +} + void RMBoxLoc::ReadFromStream(RMDataStream &ds) { int i; char buf[2]; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index c5c7859e73..c176367cd4 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -350,6 +350,9 @@ private: void ReadFromStream(RMDataStream& ds); public: + RMBoxLoc(); + virtual ~RMBoxLoc(); + friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); void RecalcAllAdj(void); }; -- cgit v1.2.3 From 046620054f3b2817b366e3e3bc01b4a84206dd6f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 10:56:56 +1000 Subject: TONY: Fix some Valgrind identified memory leaks --- engines/tony/font.cpp | 12 ++++++++++++ engines/tony/font.h | 1 + engines/tony/loc.cpp | 12 +++++++++++- engines/tony/loc.h | 6 +++++- engines/tony/tony.cpp | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 42540a2620..28e8f14d38 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1829,6 +1829,18 @@ RMText::~RMText() { } +void RMText::Unload() { + if (m_fonts[0] != NULL) { + delete m_fonts[0]; + delete m_fonts[1]; + delete m_fonts[2]; + delete m_fonts[3]; + m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0; + + g_system->unlockMutex(m_cs); + } +} + void RMText::SetMaxLineLength(int max) { maxLineLength = max; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 33332db9f0..3012502d4c 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -215,6 +215,7 @@ protected: public: RMText(); virtual ~RMText(); + static void Unload(); // Setta il tipo di allineamento void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b5a233391a..4bb1832102 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1746,6 +1746,16 @@ RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { * RMGameBoxes methods \****************************************************************************/ +RMGameBoxes::RMGameBoxes() { + m_nLocBoxes = 0; + Common::fill(m_allBoxes, m_allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL); +} + +RMGameBoxes::~RMGameBoxes() { + for (int i = 1; i <= m_nLocBoxes; ++i) + delete m_allBoxes[i]; +} + void RMGameBoxes::Init(void) { int i; RMString fn; @@ -1753,7 +1763,7 @@ void RMGameBoxes::Init(void) { // Load boxes from disk m_nLocBoxes = 130; - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { RMRes res(10000 + i); ds.OpenBuffer(res); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index c176367cd4..9ed1a284d1 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -357,13 +357,17 @@ public: void RecalcAllAdj(void); }; +#define GAME_BOXES_SIZE 200 class RMGameBoxes { protected: - RMBoxLoc *m_allBoxes[200]; + RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; int m_nLocBoxes; public: + RMGameBoxes(); + ~RMGameBoxes(); + void Init(void); void Close(void); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 45545875e1..9ff306ca46 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -410,6 +410,7 @@ void TonyEngine::Close(void) { CloseMusic(); CloseHandle(m_hEndOfFrame); _theBoxes.Close(); + RMText::Unload(); _theEngine.Close(); m_wnd.Close(); } -- cgit v1.2.3 From e0a7b421857636d5cad2e74c971a676733e48c5b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 11:15:38 +1000 Subject: TONY: Fixed some more Valgrind identified memory leaks --- engines/tony/game.cpp | 9 ++++++--- engines/tony/tony.cpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index b4b4253d08..1fe5956ffe 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1412,9 +1412,12 @@ void RMPointer::Init(void) { void RMPointer::Close(void) { int i; - for (i = 0; i < 1; i++) - if (m_pointer[i] != NULL) - delete m_pointer[i], m_pointer[i] = NULL; + for (i = 0; i < 5; i++) { + if (m_pointer[i] != NULL) { + delete m_pointer[i]; + m_pointer[i] = NULL; + } + } } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9ff306ca46..f4e2f9f1c6 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -413,6 +413,7 @@ void TonyEngine::Close(void) { RMText::Unload(); _theEngine.Close(); m_wnd.Close(); + delete[] m_curThumbnail; } void TonyEngine::SwitchFullscreen(bool bFull) { -- cgit v1.2.3 From fbee927c6a648ee1e3f162f0ec6b9d298619dd9f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 11:56:59 +1000 Subject: TONY: Fix another memory leak identified by Valgrind --- engines/tony/game.cpp | 6 ++++++ engines/tony/gfxcore.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1fe5956ffe..03cc80d93d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1371,6 +1371,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS RMPointer::RMPointer() { Common::fill(m_pointer, m_pointer + 16, (RMGfxSourceBuffer8 *)NULL); + Common::fill(m_specialPointer, m_specialPointer + 16, (RMItem *)NULL); } RMPointer::~RMPointer() { @@ -1417,6 +1418,11 @@ void RMPointer::Close(void) { delete m_pointer[i]; m_pointer[i] = NULL; } + + if (m_specialPointer[i] != NULL) { + delete m_specialPointer[i]; + m_specialPointer[i] = NULL; + } } } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 0f2c2553ec..88f2d6ed22 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -195,7 +195,7 @@ public: // Registration virtual void Register(void) { m_nInList++; } - virtual void Unregister(void) { m_nInList--; assert(m_nInList>=0); } + virtual void Unregister(void) { m_nInList--; assert(m_nInList >= 0); } }; -- cgit v1.2.3 From aa603d5a6719764e785e4bd096f16493f7ec7f6c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 20:29:37 +1000 Subject: TONY: Fix a crash from objects being destroyed in the wrong order --- engines/tony/tony.cpp | 1 - engines/tony/tony.h | 3 +-- engines/tony/window.cpp | 11 ++++++++++- engines/tony/window.h | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index f4e2f9f1c6..457ba57153 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -410,7 +410,6 @@ void TonyEngine::Close(void) { CloseMusic(); CloseHandle(m_hEndOfFrame); _theBoxes.Close(); - RMText::Unload(); _theEngine.Close(); m_wnd.Close(); delete[] m_curThumbnail; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 51cfdf74f3..c64bc884d6 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -108,7 +108,6 @@ public: FPSTREAM *m_stream[6]; FPSFX *m_sfx[MAX_SFX_CHANNELS]; FPSFX *m_utilSfx[MAX_SFX_CHANNELS]; - RMGfxEngine theEngine; RMFont *fonts[2]; bool m_bPaused; bool m_bDrawLocation; @@ -117,8 +116,8 @@ public: // Bounding box list manager RMGameBoxes _theBoxes; - RMGfxEngine _theEngine; RMWindow m_wnd; + RMGfxEngine _theEngine; bool m_bQuitNow; bool m_bTimeFreezed; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 41821ccacc..ae8d3612c3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -57,9 +57,18 @@ namespace Tony { static uint16 m_wPrecalcTable[0x10000]; /****************************************************************************\ -* Metodi di RMWindow +* RMWindow Methods \****************************************************************************/ +RMWindow::RMWindow() { + m_Primary = NULL; m_Back = NULL; +} + +RMWindow::~RMWindow() { + Close(); + RMText::Unload(); +} + #ifdef REFACTOR_ME LRESULT CALLBACK GlobalWindowProc(HWND hWnd, uint32 msg, uint16 wParam, int32 lParam) { if ((HWND)theGame.m_wnd == NULL) diff --git a/engines/tony/window.h b/engines/tony/window.h index da8c5dc824..5949450e8f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -121,8 +121,8 @@ protected: void WipeEffect(Common::Rect &rcBoundEllipse); public: - RMWindow() { m_Primary = NULL; m_Back = NULL; }; - ~RMWindow() { Close(); } + RMWindow(); + ~RMWindow(); // Inizializzazione void Init(/*HINSTANCE hInst*/); -- cgit v1.2.3 From 07c1369f98009a2d9f8b49a9f68ace7354469cba Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 20:54:21 +1000 Subject: TONY: Created dummy event loop and started work on converting RMWindow class --- engines/tony/gfxengine.cpp | 2 +- engines/tony/tony.cpp | 38 ++-- engines/tony/tony.h | 2 +- engines/tony/window.cpp | 538 +-------------------------------------------- engines/tony/window.h | 67 ++---- 5 files changed, 60 insertions(+), 587 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 7f2515af7b..27db5c18bf 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -557,7 +557,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_bigBuf.DrawOT(); m_bigBuf.ClearOT(); delete load; - _vm->m_wnd.GetNewFrame(*this, NULL); + _vm->_window.GetNewFrame(*this, NULL); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 457ba57153..293646e3f8 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" #include "common/config-manager.h" +#include "common/events.h" #include "common/file.h" #include "tony/tony.h" #include "tony/game.h" @@ -66,6 +67,9 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); + // Initialise the graphics window + _window.Init(); + // Initialise the function list Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); @@ -220,7 +224,7 @@ void TonyEngine::UnloadAllUtilSFX(void) { void TonyEngine::InitMusic() { int i; - _theSound.Init(/*m_wnd*/); + _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); for (i = 0; i < 6; i++) @@ -349,7 +353,7 @@ void TonyEngine::CloseVoiceDatabase() { } void TonyEngine::GrabThumbnail(void) { - //m_wnd.GrabThumbnail(m_curThumbnail); + //_window.GrabThumbnail(m_curThumbnail); warning("TODO: TonyEngine::GrabThumbnail"); } @@ -369,8 +373,16 @@ void TonyEngine::Abort(void) { } void TonyEngine::Play(void) { - warning("TODO TonyEngine::Play"); - + // Main game loop + while (!shouldQuit() && !m_bQuitNow) { + g_system->delayMillis(50); + _window.Repaint(); + + Common::Event evt; + while (g_system->getEventManager()->pollEvent(evt)) + ; + } + #if 0 MSG msg; @@ -388,14 +400,14 @@ void TonyEngine::Play(void) { // Passa il buffer dall'engine alla finestra if (!m_bPaused) { if (!theEngine.m_bWiping) - m_wnd.GetNewFrame(theEngine, NULL); + _window.GetNewFrame(theEngine, NULL); else - m_wnd.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); + _window.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); } // Loop minchia dei messaggi - if (PeekMessage(&msg, m_wnd, 0, 0, true)) { - if (!TranslateAccelerator(m_wnd, m_hacc, &msg)) { + if (PeekMessage(&msg, _window, 0, 0, true)) { + if (!TranslateAccelerator(_window, m_hacc, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -411,12 +423,12 @@ void TonyEngine::Close(void) { CloseHandle(m_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); - m_wnd.Close(); + _window.Close(); delete[] m_curThumbnail; } void TonyEngine::SwitchFullscreen(bool bFull) { - m_wnd.SwitchFullscreen(bFull); + _window.SwitchFullscreen(bFull); _theEngine.SwitchFullscreen(bFull); } @@ -434,7 +446,7 @@ void TonyEngine::PauseLoop(void) { st = GetTime(); - while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) { + while (m_bPaused && GetMessage(&msg,_window,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -456,9 +468,9 @@ warning("TODO: TonyEninge::Pause"); theEngine.GDIControl(m_bPaused); if (m_bPaused) { - SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths - PAUSED"); + SetWindowText(_window, "Tony Tough and the night of Roasted Moths - PAUSED"); } else { - SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths"); + SetWindowText(_window, "Tony Tough and the night of Roasted Moths"); } */ } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c64bc884d6..e1526db026 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -116,7 +116,7 @@ public: // Bounding box list manager RMGameBoxes _theBoxes; - RMWindow m_wnd; + RMWindow _window; RMGfxEngine _theEngine; bool m_bQuitNow; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index ae8d3612c3..c05af6b5e0 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -45,6 +45,8 @@ * * **************************************************************************/ +#include "common/scummsys.h" +#include "util.h" #include "tony/window.h" #include "tony/game.h" #include "tony/tony.h" @@ -61,7 +63,7 @@ static uint16 m_wPrecalcTable[0x10000]; \****************************************************************************/ RMWindow::RMWindow() { - m_Primary = NULL; m_Back = NULL; + } RMWindow::~RMWindow() { @@ -69,188 +71,9 @@ RMWindow::~RMWindow() { RMText::Unload(); } -#ifdef REFACTOR_ME -LRESULT CALLBACK GlobalWindowProc(HWND hWnd, uint32 msg, uint16 wParam, int32 lParam) { - if ((HWND)theGame.m_wnd == NULL) - return DefWindowProc(hWnd, msg, wParam, lParam); - - switch (msg) { - case WM_CREATE: - return 0; - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - default: - return theGame.m_wnd.WindowProc(msg, wParam, lParam); - } -} -#endif - -#ifdef REFACTOR_ME -LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { - switch (msg) { - case WM_ACTIVATE: - if (LOWORD(wParam)!=WA_INACTIVE) - theGame.Pause(false); - else - theGame.Pause(true); - return 0; - - case WM_ENTERMENULOOP: - case WM_ENTERSIZEMOVE: - if (!m_bFullscreen) - theGame.Pause(true); - return 0; - - case WM_EXITMENULOOP: - case WM_EXITSIZEMOVE: - if (!m_bFullscreen) - theGame.Pause(false); - return 0; -/* - case WM_KEYDOWN: - switch (wParam) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (GetAsyncKeyState(VK_CONTROL)&0x8000) - theGame.SaveState(wParam-'0'); - else if (GetAsyncKeyState(VK_SHIFT)&0x8000) - theGame.LoadState(wParam-'0'); - return 0; - } - return 0; -*/ - - case WM_PAINT: -// Repaint(); - ValidateRect(m_hWnd, NULL); - return 0; - - case WM_COMMAND: - switch LOWORD(wParam) { -/* - case ID_OPTIONS: - theGame.OptionScreen(); - break; -*/ - - case ID_FULLSCREEN: - theGame.SwitchFullscreen(!m_bFullscreen); - break; -/* - case ID_ENABLEINPUT: - theGame.GetEngine()->EnableInput(); - break; -*/ - case ID_SCREENSHOT: - m_bGrabScreenshot = true; -// m_bGrabMovie = !m_bGrabMovie; - break; - - case ID_MOVIE: -// m_bGrabMovie = !m_bGrabMovie; - break; -/* - case ID_BLACKWHITE: - m_bBlackWhite = !m_bBlackWhite; - break; -*/ - default: - return DefWindowProc(m_hWnd, msg, wParam, lParam); - } - return 0; - - case WM_SYSKEYDOWN: - if (m_bFullscreen) - return 0; - else - return DefWindowProc(m_hWnd ,msg, wParam, lParam); - - default: - if (m_hWnd != NULL) // Fix del bug visto da BoundsChecker - return DefWindowProc(m_hWnd, msg, wParam, lParam); - return 0; - } -} -#endif - -/* -HANDLE hWaitFlip; -bool bExitThread; - -void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) { - bExitThread=false; - while (1) { - WaitForSingleObject(hWaitFlip,INFINITE); - if (bExitThread) _endthread(); - lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); - } -} -*/ - -void RMWindow::InitDirectDraw(void) { -#ifdef REFACTOR_ME - DDInit(); - - ShowCursor(false); - ShowWindow(m_hWnd, SW_SHOW); - UpdateWindow(m_hWnd); -#endif -} - -void RMWindow::Init(/*HINSTANCE hInst*/) { -#ifdef REFACTOR_ME - WNDCLASS wc; - - // Registra la classe di finestra - wc.style = CS_HREDRAW|CS_VREDRAW; - wc.lpfnWndProc = GlobalWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInst; - wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_ICON1)); - wc.hCursor = LoadCursor(NULL,IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = "RMClass"; - RegisterClass(&wc); - - m_hWnd = CreateWindow( - "RMClass", - "Tony Tough and the night of Roasted Moths", - WS_OVERLAPPEDWINDOW & (~WS_THICKFRAME) & (~WS_BORDER) & (~WS_MAXIMIZEBOX), - 50, 50, - RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, - RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION), - NULL, - NULL, - hInst, - NULL - ); - - if (m_hWnd == NULL) { - int err = GetLastError(); - RMString str; - - str.Format("error: %u",err); - MessageBox(NULL,str,"sux",MB_OK); - - assert(0); - } - - // Inizializza la finestra directdraw - //DDInit(); +void RMWindow::Init() { + initGraphics(RM_SX, RM_SY, false); // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; @@ -258,361 +81,20 @@ void RMWindow::Init(/*HINSTANCE hInst*/) { m_bGrabScreenshot = false; m_bGrabThumbnail = false; m_bGrabMovie = false; - - //hWaitFlip = CreateEvent(NULL,false,false, NULL); -#endif } void RMWindow::Close(void) { - DDClose(); -#ifdef REFACTOR_ME - DestroyWindow(m_hWnd); -#endif } void RMWindow::GrabThumbnail(uint16 *thumbmem) { - m_bGrabThumbnail = true; - m_wThumbBuf = thumbmem; -} - -float RGB_to_HSL(float r,float g, float b, float *h, float *s, float *l) { - float v; - float m; - float vm; - float r2, g2, b2; - - if (r > g) v = r; else v = g; - if (v > b) v = v; else v = b; - if (r < b) m = r; else m = b; - if (m < b) m = m; else m = b; - - if ((*l = (m + v) / 2.0f) <= 0.0f) return *l; - if ((*s = vm = v - m) > 0.0f) { - *s /= (*l <= 0.5f) ? (v + m) : (2.0f - v - m) ; - } else - return *l; - - r2 = (v - r) / vm; - g2 = (v - g) / vm; - b2 = (v - b) / vm; - - if (r == v) - *h = (g == m ? 5.0f + b2 : 1.0f - g2); - else if (g == v) - *h = (b == m ? 1.0f + r2 : 3.0f - b2); - else - *h = (r == m ? 3.0f + g2 : 5.0f - r2); - - *h /= 6; - - return *l; -} - -#define ITOF(val) (float)((float)(val) / 31.0f) -#define FTOI(val) (int)(((float)(val) * 31.0f + 0.5f)) - -void RMWindow::CreateBWPrecalcTable(void) { -#define CLAMP(var, min, max) var = (var < min ? min : (var > max ? max : var)); - - int i; - int r, g, b; - int min, max; - int shiftR, shiftG, shiftB; - - // Calcola i valori di shift in base alle maschere - for (shiftR = 15; (mskRed & (1 << shiftR)) == 0; shiftR--) - ; - for (shiftG = 15; (mskGreen & (1 << shiftG)) == 0; shiftG--) - ; - for (shiftB = 15; (mskBlue & (1 << shiftB)) == 0; shiftB--) - ; - - shiftR -= 4; - shiftG -= 4; - shiftB -= 4; - - // @@@ CLAMP inutile (in teoria) - CLAMP(shiftR, 0, 15); - CLAMP(shiftG, 0, 15); - CLAMP(shiftB, 0, 15); - - for (i = 0; i < 0x10000; i++) { - r=(i >> shiftR) & 0x1F; - g=(i >> shiftG) & 0x1F; - b=(i >> shiftB) & 0x1F; - -#if 1 - if (r < g) min=r; else min = g; - if (b < min) min = b; - if (r > g) max = r; else max = g; - if (b > max) max = b; - min = (min + max) / 2; -#else - // Nuova formula B&W. L'immagine pi fedele all'originale, ma l'effetto peggiore - float fr, fg, fb; - - fr = (float)r / 63.0f; - fg = (float)g / 63.0f; - fb = (float)b / 63.0f; - - min = (int)((fr*0.11f + fg*0.69f + fb*0.33f)*63.f); -#endif - - /* - RGB_to_HSL(ITOF(r), ITOF(g), ITOF(b), &h, &s, &l); - min = FTOI(l); - */ - - r = min + 8 - 8; - g = min + 5 - 8; - b = min + 0 - 8; - - CLAMP(r, 0, 31); - CLAMP(g, 0, 31); - CLAMP(b, 0, 31); - - m_wPrecalcTable[i] = (b << shiftB) | (g << shiftG) | (r << shiftR); - } -} - - -void RMWindow::DDClose(void) { -#ifdef REFACTOR_ME - DDRELEASE(m_Back); - DDRELEASE(m_Primary); - DDRELEASE(m_MainClipper); - DDRELEASE(m_BackClipper); - DDRELEASE(m_DD); -#endif -} - -void RMWindow::DDInit(void) { -#ifdef REFACTOR_ME - HRESULT err; - - // Crea DirectDraw - err = DirectDrawCreate(NULL, &m_DD, NULL); - assert(err == DD_OK); - - // Crea il clipper - err = DirectDrawCreateClipper(0, &m_MainClipper, NULL); - err=DirectDrawCreateClipper(0, &m_BackClipper, NULL); - - // Lo associa alla finestra - m_MainClipper->SetHWnd(0, m_hWnd); - - // Setta la cooperazione a normal - m_DD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL); - -#ifdef STARTFULLSCREEN - // Di default in fullscreen - m_bFullscreen=false; // Fa finta, per obbligarlo a cambiare - m_Primary=m_Back=NULL; - SwitchFullscreen(true); -#else - // Di default in finestra - m_bFullscreen = true; // Fa finta, per obbligarlo a cambiare - m_Primary = m_Back = NULL; - SwitchFullscreen(false); -#endif - -/* - if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) { - RMString str; - str.Format("Graphic mode not supported: %04x %04x %04x",mskRed,mskGreen,mskBlue); - MessageBox(m_hWnd,str,"Debug",MB_OK); - } -*/ -#endif + warning("TODO: RMWindow::GrabThumbnail"); } - -void RMWindow::SwitchFullscreen(bool bFull) { -#ifdef REFACTOR_ME - HRESULT err; - DDSURFACEDESC ddsd; - DDSCAPS ddscaps; - DDBLTFX ddbltfx; - Common::Rect rcWin; - - // Se non c'e' niente da fare, esci - if (bFull == m_bFullscreen) - return; - - // Termina il thread di flipping - //bExitThread = true; - - // Rilascia le superfici create in precedenza (se ce n'erano) - DDRELEASE(m_Back); - DDRELEASE(m_Primary); - - // Legge le coordinate della finestra - if (m_bFullscreen) { - rcWin.left = 50; - rcWin.top = 50; - } else { - GetWindowRect(m_hWnd, &rcWin); - } - - if (bFull) { - // Setta la risoluzione - m_DD->SetCooperativeLevel(m_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT); - m_DD->SetDisplayMode(RM_SX, RM_SY, 16); - - // A tutto schermo, possiamo creare una catena di flipping - ZeroMemory(&ddsd, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; - ddsd.dwBackBufferCount = 1; - if ((err=m_DD->CreateSurface(&ddsd, &m_Primary, NULL)) != DD_OK) { - //wsprintf(errbuf,"Error creating primary surface2 (%lx)",err); - //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); - assert(0); - } - - ddscaps.dwCaps = DDSCAPS_BACKBUFFER; - if ((err=m_Primary->GetAttachedSurface(&ddscaps, &m_Back)) != DD_OK) { - //wsprintf(errbuf,"Error getting attached surface2 (%lx)",err); - //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); - assert(0); - } - - // Pulisce i buffer - ddbltfx.dwSize = sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL,DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - ddbltfx.dwSize=sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Primary->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - // Inizializza il thread - //_beginthread((void (*)(void*))DoFlipThread,10240,(void*)m_Primary); - } else { - // In windowed, non possiamo fare flipping (purtroppo) - m_DD->RestoreDisplayMode(); - m_DD->SetCooperativeLevel(m_hWnd,DDSCL_NORMAL); - - ZeroMemory(&ddsd,sizeof(ddsd)); - ddsd.dwSize=sizeof(ddsd); - ddsd.dwFlags=DDSD_CAPS; - ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE; - if ((err=m_DD->CreateSurface(&ddsd,&m_Primary, NULL)) != DD_OK) { - //wsprintf(errbuf,"Error creating primary surface (%lx)",err); - //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); - assert(0); - } - - ZeroMemory(&ddsd,sizeof(ddsd)); - ddsd.dwSize=sizeof(ddsd); - ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT; - ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN; // se puo', in video memory - ddsd.dwWidth=RM_SX; - ddsd.dwHeight=RM_SY; - if ((err=m_DD->CreateSurface(&ddsd,&m_Back, NULL)) != DD_OK) { - //wsprintf(errbuf,"Error creating backbuffer surface (%lx)",err); - //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); - assert(0); - } - - // Pulizia per favore - ddbltfx.dwSize = sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - } - - // Posiziona e ridimensiona la finestra - if (bFull) { - SetWindowPos(m_hWnd, HWND_TOP, 0, 0, RM_SX, RM_SY, 0); - - // Disabilita il clipper (non necessario) - m_Primary->SetClipper(NULL); - } else { - SetWindowPos(m_hWnd, HWND_TOP, rcWin.left, rcWin.top, RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, - RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), 0); - - m_Primary->SetClipper(m_MainClipper); - //m_Primary->SetClipper(NULL); - } - - // Si ricorda il nuovo stato - m_bFullscreen = bFull; - InvalidateRect(m_hWnd, NULL, false); - - // Legge il nuovo pixel format - UpdatePixelFormat(); -#endif -} - -void RMWindow::UpdatePixelFormat(void) { -#ifdef REFACTOR_ME - DDPIXELFORMAT ddpf; - - // Si fa ridare il nuovo pixel format - ddpf.dwSize = sizeof(ddpf); - m_Primary->GetPixelFormat(&ddpf); - - // Copia le componenti dei colori - mskRed = ddpf.dwRBitMask; - mskGreen = ddpf.dwGBitMask; - mskBlue = ddpf.dwBBitMask; - - // Ricalcola la tabella per l'effetto b&w - CreateBWPrecalcTable(); -#endif -} - - +/** + * Repaint the screen + */ void RMWindow::Repaint(void) { -#ifdef REFACTOR_ME - Common::Rect rcWin; - HRESULT err; - - if (m_Primary==NULL) - return; - - // Se siamo a tutto schermo, basta un flip - if (m_bFullscreen) { - m_DD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); - - // Flippa flappa - while (1) { - //err=m_Primary->Flip(NULL,DDFLIP_WAIT); - err = m_Primary->BltFast(0, 0, m_Back, NULL, DDBLTFAST_WAIT); - - if (err==DD_OK) - break; - else if (err == DDERR_SURFACELOST) { - //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Primary->Restore(); - return; - } - } - } - // Altrimenti bisogna andare di blit - else { - // Si calcola il rettangolo effettivamente visibile - GetWindowRect(m_hWnd, &rcWin); - OffsetRect(&rcWin, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION)); - - // Aggiusta le dimensioni del rettangolo - rcWin.right = rcWin.left + RM_SX; - rcWin.bottom = rcWin.top + RM_SY; - - // Blit del back nel primary - while (1) { - err = m_Primary->Blt(&rcWin, m_Back, NULL,DDBLT_WAIT, NULL); - if (err == DD_OK) - break; - else if (err == DDERR_SURFACELOST) { - //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Primary->Restore(); - return; - } - } - } -#endif + g_system->updateScreen(); } diff --git a/engines/tony/window.h b/engines/tony/window.h index 5949450e8f..2edf409ad0 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -81,28 +81,7 @@ private: bool Lock(DDSURFACEDESC &ddsd); void Unlock(DDSURFACEDESC &ddsd); - // Inizializza DirectDraw - void DDInit(void); - - // Chiude DirectDraw - void DDClose(void); - - // Repaint grafico tramite DirectDraw - void Repaint(void); - - // Window Proc principale che richiama la WindowProc dentro la classe -// friend LRESULT CALLBACK GlobalWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - // Procedura di gestione messaggi -// LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam); - protected: - HWND m_hWnd; - bool m_bFullscreen; - - void * /*LPDIRECTDRAW*/ m_DD; - void * /*LPDIRECTDRAWSURFACE*/ m_Primary; - void * /*LPDIRECTDRAWSURFACE*/ m_Back; void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; void * /*LPDIRECTDRAWCLIPPER*/ m_BackClipper; @@ -117,37 +96,37 @@ protected: uint16 *m_wThumbBuf; void CreateBWPrecalcTable(void); - void UpdatePixelFormat(void); void WipeEffect(Common::Rect &rcBoundEllipse); - public: - RMWindow(); - ~RMWindow(); +public: + RMWindow(); + ~RMWindow(); - // Inizializzazione - void Init(/*HINSTANCE hInst*/); - void InitDirectDraw(void); - void Close(void); + // Inizializzazione + void Init(/*HINSTANCE hInst*/); + void InitDirectDraw(void); + void Close(void); - // Switch tra windowed e fullscreen - void SwitchFullscreen(bool bFull); + // Repaint grafico tramite DirectDraw + void Repaint(void); - // Legge il prossimo frame - void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + // Switch tra windowed e fullscreen + void SwitchFullscreen(bool bFull) {} - // Avverte di grabbare un thumbnail per il salvataggio - void GrabThumbnail(uint16 *buf); + // Legge il prossimo frame + void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); - operator HWND() { return m_hWnd; } + // Avverte di grabbare un thumbnail per il salvataggio + void GrabThumbnail(uint16 *buf); - // Modi pixel format - // MODE1: 1555 - // MODE2: 5515 - // MODE3: 5551 - bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } - bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } - bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } - bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } + // Modi pixel format + // MODE1: 1555 + // MODE2: 5515 + // MODE3: 5551 + bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } + bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } + bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } + bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } }; } // End of namespace Tony -- cgit v1.2.3 From 5625846bf2a0015e212ea2f1d97543cbba81e0c7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:32:40 +1000 Subject: TONY: Further conversion work on window conversion --- engines/tony/window.cpp | 480 ++++-------------------------------------------- engines/tony/window.h | 13 +- 2 files changed, 34 insertions(+), 459 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c05af6b5e0..8e23ec8aa5 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -55,9 +55,6 @@ namespace Tony { #define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } -// Tabella per il b&w. Globale per accederci dalla roba ASM -static uint16 m_wPrecalcTable[0x10000]; - /****************************************************************************\ * RMWindow Methods \****************************************************************************/ @@ -71,7 +68,9 @@ RMWindow::~RMWindow() { RMText::Unload(); } - +/** + * Initialises the graphics window + */ void RMWindow::Init() { initGraphics(RM_SX, RM_SY, false); @@ -83,6 +82,9 @@ void RMWindow::Init() { m_bGrabMovie = false; } +/** + * Close the window + */ void RMWindow::Close(void) { } @@ -97,467 +99,47 @@ void RMWindow::Repaint(void) { g_system->updateScreen(); } - -void RMWindow::Unlock(DDSURFACEDESC &ddsd) { -#ifdef REFACTOR_ME - m_Back->Unlock(ddsd.lpSurface); -#endif +bool RMWindow::Lock() { + return true; } -void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { -#ifdef REFACTOR_ME - Common::Rect rcScreen; - HRGN hrgnCombined; - HRGN hrgnScreen; - HRGN hrgnEllipse; - uint32 dwDataSize; - RGNDATA *rgnData; - - SetRect(&rcScreen, 0, 0, 640, 480); - - hrgnScreen = CreateRectRgnIndirect(&rcScreen); - hrgnEllipse = CreateEllipticRgnIndirect(&rcBoundEllipse); - hrgnCombined = CreateRectRgnIndirect(&rcScreen); - - CombineRgn(hrgnCombined, hrgnScreen, hrgnEllipse, RGN_DIFF); - - dwDataSize = GetRegionData(hrgnCombined, 0, NULL); - rgnData = (RGNDATA *)new char[dwDataSize]; - GetRegionData(hrgnCombined, dwDataSize, rgnData); - - m_BackClipper->SetClipList(rgnData, 0); - m_Back->SetClipper(m_BackClipper); - - DDBLTFX ddbltfx; - ddbltfx.dwSize=sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - m_Back->SetClipper(NULL); - delete [] rgnData; - DeleteObject(hrgnCombined); - DeleteObject(hrgnEllipse); - DeleteObject(hrgnScreen); -#endif +void RMWindow::Unlock() { } -bool RMWindow::Lock(DDSURFACEDESC &ddsd) { -#ifdef REFACTOR_ME - HRESULT err; +/** + * Wipes an area of the screen + */ +void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { + if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && + (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { + // Full screen clear wanted, so use shortcut method + g_system->fillScreen(0); + } else { + // Clear the designated area a line at a time + byte line[RM_SX]; + Common::fill(line, line + RM_SX, 0); - // Lock della surface - ddsd.dwSize = sizeof(ddsd); - while (1) { - err = m_Back->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_NOSYSLOCK, NULL); - if (err==DD_OK) - break; - else if (err==DDERR_SURFACELOST) { -// MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Back->Restore(); - return false; + // Loop through each line + for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { + g_system->copyRectToScreen(line, RM_SX, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } -#endif - return true; } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { -#ifdef REFACTOR_ME - HRESULT err; - DDSURFACEDESC ddsd; - int x,y; - byte *dest; - uint16 *destw; - RMString s; - uint16 *src,src2; - - if (GetAsyncKeyState(VK_F7)&0x8001) - goto DOFRAMERATE; - - if (!Lock(ddsd)) - return; - - // Copia del buffer - src = (uint16 *)lpBuf; - dest = (byte *)ddsd.lpSurface; -// src+=RM_SKIPY*RM_BBX; Lo skipY e' integrato nell'offseting del bigbuffer - - if (ISMODE2()) { - // 565 RGB, Marco - Matrox G200 - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw = (uint16 *)dest; - - if (bCfgAnni30) { - __asm { - pushad - - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - line30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - line302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - mov ecx,eax ; U 2 - mov edx,ebx ; V - and eax,0x7FE07FE0 ; U 3 - and ebx,0x7FE07FE0 ; V - and ecx,0x001F001F ; U 4 - and edx,0x001F001F ; V - shl eax,1 ; U 5 - shl ebx,1 ; V - or eax,ecx ; U 6 - or ebx,edx ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 7 - mov [edi+4],ebx ; V - add esi,8 ; U 8 - add edi,8 ; V - sub x,4 ; U 9 - jnz line302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz line30 - - popad - } - - } else { - __asm { - pushad - - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - line: - mov x,RM_SX - add esi,RM_SKIPX*2 - - line2: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - mov ecx,eax ; U 2 - mov edx,ebx ; V - and eax,0x7FE07FE0 ; U 3 - and ebx,0x7FE07FE0 ; V - and ecx,0x001F001F ; U 4 - and edx,0x001F001F ; V - shl eax,1 ; U 5 - shl ebx,1 ; V - or eax,ecx ; U 6 - or ebx,edx ; V - mov [edi],eax ; U 7 - mov [edi+4],ebx ; V - add esi,8 ; U 8 - add edi,8 ; V - sub x,4 ; U 9 - jnz line2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz line - - popad - } - } - } else if (ISMODE3()) { - // 5551 RGB - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - aline30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - aline302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - shl eax,1 ; U 2 - shl ebx,1 ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz aline302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz aline30 - } - } else { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - aline: - mov x,RM_SX - add esi,RM_SKIPX*2 - - aline2: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - shl eax,1 ; U 2 - shl ebx,1 ; V - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz aline2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz aline - } - } - } else if (ISMODE4()) { - // 565 BGR - Intergraph - int lineinc=(ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2=(RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) // Manca supporto per Intergraph ... non so pairarlo!!! :) - { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - intersux30: - mov ecx,RM_SX - add esi,RM_SKIPX*2 - - intersux302: - mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - add esi,4 ; V - mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 - and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 - and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 - and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 - shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB - add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 - or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB - add edi,4 ; V - or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB - sub ecx,2 ; V - mov [edi-4],eax ; U 8 - jnz intersux302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz intersux30 - } - } else { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - intersux: - mov ecx,RM_SX - add esi,RM_SKIPX*2 - - intersux2: - mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - add esi,4 ; V - mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 - and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 - and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 - and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 - shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB - add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 - or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB - add edi,4 ; V - or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB - sub ecx,2 ; V - mov [edi-4],eax ; U 8 - jnz intersux2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz intersux - } - } + if (rcBoundEllipse == NULL) { + // Full screen update + g_system->copyRectToScreen(lpBuf, RM_SX, 0, 0, RM_SX, RM_SY); } else { - // 555 RGB - Computer di Bagio, nVidia Riva 128 - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - bagioline30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - bagioline302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz bagioline302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz bagioline30 - } - } else { - for (y = 0; y < RM_SY; y++) { - CopyMemory(dest, src + RM_SKIPX, RM_SX * 2); - dest += ddsd.lPitch; - src += RM_BBX; - } - } - } - - - // Unlock - Unlock(ddsd); - - // Effetto di wipe - if (rcBoundEllipse) { - WipeEffect(*rcBoundEllipse); - } - - // Repaint - Repaint(); - -DOFRAMERATE: - - // Conteggio per gli FPS - fcount++; - - if (lastsecond + 1000 < _vm->GetTime()) { - lastsecond = _vm->GetTime(); - fps=fcount - lastfcount; - lastfcount = fcount; - - if (!m_bFullscreen) { - s.Format("Tony Tough and the night of Roasted Moths - %u FPS",fps); - SetWindowText(m_hWnd,s); - } - } if (!_vm->getIsDemo()) { - if (m_bGrabScreenshot || m_bGrabMovie) { - RMSnapshot snapshot; - - snapshot.GrabScreenshot(lpBuf); - m_bGrabScreenshot = false; - } - - if (m_bGrabThumbnail) { - RMSnapshot snapshot; - - snapshot.GrabScreenshot(lpBuf, 4, m_wThumbBuf); - m_bGrabThumbnail = false; - } + // Update a screen section + g_system->copyRectToScreen(lpBuf, RM_SX, rcBoundEllipse->left, rcBoundEllipse->top, + rcBoundEllipse->width(), rcBoundEllipse->height()); } -#endif } /****************************************************************************\ -* Metodi di RMSnapshot +* RMSnapshot Methods \****************************************************************************/ char RMSnapshot::bufDrive[MAX_DRIVE]; diff --git a/engines/tony/window.h b/engines/tony/window.h index 2edf409ad0..5190fc4d16 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -78,8 +78,8 @@ public: class RMWindow { private: - bool Lock(DDSURFACEDESC &ddsd); - void Unlock(DDSURFACEDESC &ddsd); + bool Lock(); + void Unlock(); protected: void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; @@ -119,14 +119,7 @@ public: // Avverte di grabbare un thumbnail per il salvataggio void GrabThumbnail(uint16 *buf); - // Modi pixel format - // MODE1: 1555 - // MODE2: 5515 - // MODE3: 5551 - bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } - bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } - bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } - bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } + int getFps() const { return fps; } }; } // End of namespace Tony -- cgit v1.2.3 From 4fc57f13491781893edf4b4aa6e477b0e0fc02b8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:33:13 +1000 Subject: TONY: Added some class field initialisations --- engines/tony/gfxengine.cpp | 2 +- engines/tony/loc.cpp | 25 +++++++++++++++++++++++-- engines/tony/tony.cpp | 40 ++++++++++++++-------------------------- 3 files changed, 38 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 27db5c18bf..f98942403d 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -288,7 +288,7 @@ SKIPCLICKSINISTRO: } // Anima Tony - m_tony.DoFrame(&m_bigBuf,m_nCurLoc); + m_tony.DoFrame(&m_bigBuf, m_nCurLoc); // Aggiorna lo scrolling per tenere Tony dentro lo schermo if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 4bb1832102..9a2f4cfe6a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -819,10 +819,21 @@ RMItem::RMItem() { m_bCurFlag = 0; m_patterns = NULL; m_sprites = NULL; - m_sfx= NULL; + m_sfx = NULL; m_curScroll.Set(0, 0); - m_bInitCurPattern=true; + m_bInitCurPattern = true; m_nCurPattern = 0; + m_z = 0; + m_cm = CM_256; + m_FX = 0; + m_FXparm = 0; + m_mpalCode = 0; + m_nSprites = 0; + m_nSfx = 0; + m_nPatterns = 0; + m_hEndPattern = 0; + m_bPal = 0; + m_nCurSprite = 0; m_hEndPattern = CreateEvent(NULL, false, false, NULL); } @@ -1632,6 +1643,16 @@ RMCharacter::RMCharacter() { curSpeed = 3; bRemoveFromOT = false; bMoving = false; + curLocation = 0; + curbox = 0; + dx = dy = 0; + olddx = olddy = 0; + fx = fy = slope = 0; + walkspeed = walkstatus = 0; + nextbox = 0; + pathlenght = pathcount = 0; + status = STAND; + theBoxes = NULL; m_pos.Set(0, 0); } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 293646e3f8..cf746dc978 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -375,45 +375,33 @@ void TonyEngine::Abort(void) { void TonyEngine::Play(void) { // Main game loop while (!shouldQuit() && !m_bQuitNow) { + // Se siamo in pausa, entra nel loop appropriato + if (m_bPaused) + PauseLoop(); + g_system->delayMillis(50); - _window.Repaint(); Common::Event evt; while (g_system->getEventManager()->pollEvent(evt)) ; - } -#if 0 - MSG msg; + // Call the engine to handle the next frame + _theEngine.DoFrame(m_bDrawLocation); - do { - // Se siamo in pausa, entra nel loop appropriato - if (m_bPaused) - PauseLoop(); - - // Redraw del graphic engine - theEngine.DoFrame(m_bDrawLocation); - - // Avverte che finito un frame + // Warns that a frame is finished PulseEvent(m_hEndOfFrame); - // Passa il buffer dall'engine alla finestra + // Handle drawing the frame if (!m_bPaused) { - if (!theEngine.m_bWiping) - _window.GetNewFrame(theEngine, NULL); + if (!_theEngine.m_bWiping) + _window.GetNewFrame(_theEngine, NULL); else - _window.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); + _window.GetNewFrame(_theEngine, &_theEngine.m_rcWipeEllipse); } - // Loop minchia dei messaggi - if (PeekMessage(&msg, _window, 0, 0, true)) { - if (!TranslateAccelerator(_window, m_hacc, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } while (msg.message != WM_QUIT && !m_bQuitNow); -#endif + // Paint the frame onto the screen + _window.Repaint(); + } } -- cgit v1.2.3 From 162cc47c71767b264f157e3ebf9d61eea1f6bd97 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:45:57 +1000 Subject: TONY: Fix screen initialisation to be in 16-bit mode --- engines/tony/window.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 8e23ec8aa5..d5c9925111 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -72,7 +72,8 @@ RMWindow::~RMWindow() { * Initialises the graphics window */ void RMWindow::Init() { - initGraphics(RM_SX, RM_SY, false); + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + initGraphics(RM_SX, RM_SY, false, &pixelFormat); // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; -- cgit v1.2.3 From f7fd9e3d23260e5bab2750b37ef3b154b12ba232 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 23:21:38 +1000 Subject: TONY: Fix display of the initial loading screen --- engines/tony/window.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index d5c9925111..36278a4f05 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -117,25 +117,21 @@ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { g_system->fillScreen(0); } else { // Clear the designated area a line at a time - byte line[RM_SX]; + uint16 line[RM_SX]; Common::fill(line, line + RM_SX, 0); // Loop through each line for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { - g_system->copyRectToScreen(line, RM_SX, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + g_system->copyRectToScreen((const byte *)&line[0], RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { - if (rcBoundEllipse == NULL) { - // Full screen update - g_system->copyRectToScreen(lpBuf, RM_SX, 0, 0, RM_SX, RM_SY); - } else { - // Update a screen section - g_system->copyRectToScreen(lpBuf, RM_SX, rcBoundEllipse->left, rcBoundEllipse->top, - rcBoundEllipse->width(), rcBoundEllipse->height()); - } + Common::Rect bounds = (rcBoundEllipse) ? *rcBoundEllipse : Common::Rect(0, 0, RM_SX, RM_SY); + + // Update a screen section + g_system->copyRectToScreen(lpBuf, RM_SX * 2, bounds.left, bounds.top, bounds.width(), bounds.height()); } -- cgit v1.2.3 From 607855cfbc892d4ecfa34f2c469a10e310e51124 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 23:51:04 +1000 Subject: TONY: Formatting and endian fixes --- engines/tony/mpal/mpal.cpp | 629 ++++++++++++++++++++++----------------------- 1 file changed, 313 insertions(+), 316 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 5f88eef268..b977feb03b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -311,9 +311,6 @@ static void UnlockScripts(void) { } - - - /****************************************************************************\ * * Function: int varGetValue(char * lpszVarName); @@ -334,11 +331,11 @@ int32 varGetValue(const char *lpszVarName) { int i; LPMPALVAR v=lpmvVars; - for (i=0;ilpszVarName)==0) + for (i = 0; i < nVars; v++, i++) + if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; - mpalError=1; + mpalError = 1; return 0; } @@ -356,16 +353,16 @@ int32 varGetValue(const char *lpszVarName) { void varSetValue(const char *lpszVarName, int32 val) { uint i; - LPMPALVAR v=lpmvVars; + LPMPALVAR v = lpmvVars; - for (i=0;ilpszVarName)==0) { - v->dwVal=val; - if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8) == 0) { + for (i = 0; i < nVars; v++, i++) + if (strcmp(lpszVarName, v->lpszVarName) == 0) { + v->dwVal = val; + if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { i = 0; sscanf(v->lpszVarName, "Pattern.%u", &i); - lpiifCustom(i,val,-1); - } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + lpiifCustom(i, val, -1); + } else if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { i = 0; sscanf(v->lpszVarName,"Status.%u", &i); lpiifCustom(i, -1, val); @@ -373,7 +370,7 @@ void varSetValue(const char *lpszVarName, int32 val) { return; } - mpalError=1; + mpalError = 1; return; } @@ -396,10 +393,10 @@ void varSetValue(const char *lpszVarName, int32 val) { static int locGetOrderFromNum(uint32 nLoc) { int i; - LPMPALLOCATION loc=lpmlLocations; + LPMPALLOCATION loc = lpmlLocations; - for (i=0;inObj==nLoc) + for (i = 0; i < nLocations; i++,loc++) + if (loc->nObj == nLoc) return i; return -1; @@ -425,8 +422,8 @@ static int msgGetOrderFromNum(uint32 nMsg) { int i; LPMPALMSG msg=lpmmMsgs; - for (i=0;iwNum==nMsg) + for (i = 0; i < nMsgs; i++, msg++) + if (msg->wNum == nMsg) return i; return -1; @@ -453,8 +450,8 @@ static int itemGetOrderFromNum(uint32 nItem) { int i; LPMPALITEM item=lpmiItems; - for (i=0;inObj==nItem) + for (i = 0; i < nItems; i++, item++) + if (item->nObj == nItem) return i; return -1; @@ -479,10 +476,10 @@ static int itemGetOrderFromNum(uint32 nItem) { static int scriptGetOrderFromNum(uint32 nScript) { int i; - LPMPALSCRIPT script=lpmsScripts; + LPMPALSCRIPT script = lpmsScripts; - for (i=0;inObj==nScript) + for (i = 0; i < nScripts; i++,script++) + if (script->nObj == nScript) return i; return -1; @@ -509,8 +506,8 @@ static int dialogGetOrderFromNum(uint32 nDialog) { int i; LPMPALDIALOG dialog=lpmdDialogs; - for (i=0;inObj==nDialog) + for (i = 0; i < nDialogs; i++, dialog++) + if (dialog->nObj == nDialog) return i; return -1; @@ -542,13 +539,13 @@ static char *DuplicateMessage(uint32 nMsgOrd) { origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); - j=0; - while (origmsg[j]!='\0' || origmsg[j+1]!='\0') + j = 0; + while (origmsg[j] != '\0' || origmsg[j+1] != '\0') j++; - j+=2; + j += 2; - clonemsg=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,j); - if (clonemsg==NULL) + clonemsg=(char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); + if (clonemsg == NULL) return NULL; CopyMemory(clonemsg, origmsg, j); @@ -580,17 +577,17 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; int i,j; - for (j=0;dialog->Periods[j]!=NULL;j++) - if (dialog->PeriodNums[j]==nPeriod) { + for (j = 0; dialog->Periods[j] != NULL; j++) + if (dialog->PeriodNums[j] == nPeriod) { /* Trovata la frase, va duplicata */ origmsg = (const char *)GlobalLock(dialog->Periods[j]); /* Calcola la lunghezza e alloca la memoria */ - i=0; - while (origmsg[i]!='\0') i++; + i = 0; + while (origmsg[i] != '\0') i++; - clonemsg = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,i+1); - if (clonemsg==NULL) + clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); + if (clonemsg == NULL) return NULL; CopyMemory(clonemsg, origmsg, i); @@ -644,7 +641,7 @@ HGLOBAL resLoad(uint32 dwId) { h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)GlobalLock(h); - temp = (byte *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nSizeComp); + temp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); nBytesRead = hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -668,24 +665,24 @@ static uint32 *GetSelectList(uint32 i) { LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; /* Conta quanti select attivi ci sono */ - num=0; - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + num = 0; + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) num++; /* Se sono 0, e' un errore */ - if (num==0) + if (num == 0) return NULL; - sl= (uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); - if (sl==NULL) + sl= (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + if (sl == NULL) return NULL; /* Copia il dato di ogni select attivo dentro la lista */ - k=0; - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + k = 0; + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) - sl[k++]=dialog->Choice[i].Select[j].dwData; + sl[k++] = dialog->Choice[i].Select[j].dwData; sl[k] = (uint32)NULL; return sl; @@ -694,23 +691,23 @@ static uint32 *GetSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; uint32 num,i,j; - LPMPALVAR v=lpmvVars; + LPMPALVAR v = lpmvVars; - num=0; - for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) + num = 0; + for (i = 0; i < nVars; i++,v++) { + if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } - il=(uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); - if (il==NULL) + il=(uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + if (il == NULL) return NULL; - v=lpmvVars; - j=0; - for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) { - sscanf(v->lpszVarName,"Location.%u",&il[j]); + v = lpmvVars; + j = 0; + for (i = 0; i < nVars; i++,v++) { + if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { + sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; } } @@ -720,38 +717,38 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM GetItemData(uint32 nOrdItem) { - LPMPALITEM curitem=lpmiItems+nOrdItem; + LPMPALITEM curitem = lpmiItems+nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; - int i,j; + int i, j; char *patlength; uint32 dim; // Lo zeroinit e' obbligatorio!!!! - ret = (LPITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(ITEM)); - if (ret==NULL) + ret = (LPITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); + if (ret == NULL) return NULL; - ret->speed=150; + ret->speed = 150; hDat = resLoad(curitem->dwRes); dat = (char *)GlobalLock(hDat); - if (dat[0]=='D' && dat[1]=='A' && dat[2]=='T') { - i=dat[3]; // Versione!! Per ora 1.0 - dat+=4; + if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { + i = dat[3]; // Versione!! Per ora 1.0 + dat += 4; - if (i>=0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto - ret->destX=*(uint16 *)dat; - ret->destY=*(uint16 *)(dat+2); + if (i >= 0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto + ret->destX = (int16)READ_LE_UINT16(dat); + ret->destY = (int16)READ_LE_UINT16(dat + 2); dat+=4; } - if (i>=0x11) {// Dalla 1.1 c'e' la velocita' di animazione - ret->speed=*(uint16 *)dat; - dat+=2; + if (i >= 0x11) {// Dalla 1.1 c'e' la velocita' di animazione + ret->speed = READ_LE_UINT16(dat); + dat += 2; } else - ret->speed=150; + ret->speed = 150; } ret->numframe=*dat++; @@ -759,25 +756,25 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->Zvalue=*dat++; // Carica le coordinate left&top di ogni frame - for (i=0;inumframe;i++) { - ret->frameslocations[i].left=*(short*)(dat); - ret->frameslocations[i].top=*(short*)(dat+2); - dat+=4; + for (i = 0; i < ret->numframe; i++) { + ret->frameslocations[i].left = (int16)READ_LE_UINT16(dat); + ret->frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); + dat += 4; } // Carica le dimensioni di ogni frame e calcola right&bottom - for (i=0;inumframe;i++) { - ret->frameslocations[i].right=*(uint16 *)(dat)+ret->frameslocations[i].left; - ret->frameslocations[i].bottom=*(uint16 *)(dat+2)+ret->frameslocations[i].top; + for (i = 0; i < ret->numframe; i++) { + ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; + ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; dat+=4; } // Carica i bounding box di ogni frame - for (i=0;inumframe;i++) { - ret->bbox[i].left=*(uint16 *)(dat); - ret->bbox[i].top=*(uint16 *)(dat+2); - ret->bbox[i].right=*(uint16 *)(dat+4); - ret->bbox[i].bottom=*(uint16 *)(dat+6); + for (i = 0; i < ret->numframe; i++) { + ret->bbox[i].left = (int16)READ_LE_UINT16(dat); + ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); + ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); + ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); dat+=8; } @@ -793,20 +790,20 @@ static LPITEM GetItemData(uint32 nOrdItem) { } // Carica i singoli frame di animazione - for (i=1;inumframe;i++) { - dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left)* + for (i = 1; i < ret->numframe; i++) { + dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); ret->frames[i]=(char *)GlobalAlloc(GMEM_FIXED,dim); - if (ret->frames[i]==NULL) + if (ret->frames[i] == NULL) return NULL; CopyMemory(ret->frames[i], dat, dim); - dat+=dim; + dat += dim; } // Controlla se siamo arrivati fino alla fine del file - i=*(uint16 *)dat; - if (i!=0xABCD) + i = READ_LE_UINT16(dat); + if (i != 0xABCD) return NULL; GlobalUnlock(hDat); @@ -832,7 +829,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { \****************************************************************************/ void PASCAL CustomThread(LPCFCALL p) { - lplpFunctions[p->nCf](p->arg1,p->arg2,p->arg3,p->arg4); + lplpFunctions[p->nCf](p->arg1, p->arg2, p->arg3, p->arg4); GlobalFree(p); ExitThread(1); // _endthread(); @@ -863,28 +860,28 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { LPCFCALL p; // warning("PlayScript(): Moments: %u\n",s->nMoments); - for (i=0;inMoments;i++) { + for (i = 0; i < s->nMoments; i++) { // Dorme il tempo necessario per arrivare al momento successivo - if (s->Moment[i].dwTime==-1) { - WaitForMultipleObjects(numHandles,cfHandles,true,INFINITE); + if (s->Moment[i].dwTime == -1) { + WaitForMultipleObjects(numHandles, cfHandles, true, INFINITE); dwStartTime = timeGetTime(); } else { dwCurTime = timeGetTime(); - if (dwCurTime < dwStartTime+(s->Moment[i].dwTime*100)) { + if (dwCurTime < dwStartTime + (s->Moment[i].dwTime * 100)) { // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); - Sleep(dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); + Sleep(dwStartTime+(s->Moment[i].dwTime * 100) - dwCurTime); } } - numHandles=0; - for (j=0;jMoment[i].nCmds;j++) { + numHandles = 0; + for (j = 0;jMoment[i].nCmds; j++) { k=s->Moment[i].CmdNum[j]; switch (s->Command[k].type) { case 1: - p=(LPCFCALL)GlobalAlloc(GMEM_FIXED,sizeof(CFCALL)); - if (p==NULL) { - mpalError=1; + p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + if (p == NULL) { + mpalError = 1; ExitThread(0); // _endthread(); } @@ -896,9 +893,9 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { p->arg4=s->Command[k].arg4; // !!! Nuova gestione dei thread - if ((cfHandles[numHandles++]=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)CustomThread,(void *)p,0,&dwId))==NULL) { + if ((cfHandles[numHandles++] = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)CustomThread,(void *)p, 0, &dwId)) == NULL) { //if ((cfHandles[numHandles++]=(void*)_beginthread(CustomThread, 10240, (void *)p))==(void*)-1) - mpalError=1; + mpalError = 1; ExitThread(0); // _endthread(); } @@ -914,7 +911,7 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { break; default: - mpalError=1; + mpalError = 1; GlobalFree(s); ExitThread(0); // _endthread(); @@ -943,9 +940,9 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { \****************************************************************************/ void PASCAL ActionThread(LPMPALITEM item) { - int j,k; + int j, k; - for (j=0;jAction[item->dwRes].nCmds;j++) { + for (j = 0;jAction[item->dwRes].nCmds; j++) { k=item->Action[item->dwRes].CmdNum[j]; switch (item->Command[k].type) { @@ -962,27 +959,27 @@ void PASCAL ActionThread(LPMPALITEM item) { case 2: // Variable assign LockVar(); - varSetValue(item->Command[k].lpszVarName,EvaluateExpression(item->Command[k].expr)); + varSetValue(item->Command[k].lpszVarName, EvaluateExpression(item->Command[k].expr)); UnlockVar(); break; default: - mpalError=1; + mpalError = 1; ExitThread(0); // _endthread(); } } GlobalFree(item); - //bExecutingAction=false; + //bExecutingAction = false; ExitThread(1); // _endthread(); } void PASCAL ShutUpActionThread(HANDLE hThread) { - WaitForSingleObject(hThread,INFINITE); - bExecutingAction=false; + WaitForSingleObject(hThread, INFINITE); + bExecutingAction = false; ExitThread(1); // _endthread(); @@ -1036,7 +1033,7 @@ void PASCAL LocationPollThread(uint32 id) { il = mpalQueryItemList(nPollingLocations[id]); /* Contiamo gli items */ - for (numitems=0;il[numitems]!=0;numitems++) + for (numitems = 0; il[numitems] != 0; numitems++) ; /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo @@ -1051,7 +1048,7 @@ void PASCAL LocationPollThread(uint32 id) { curItem = lpmiItems + ord; - k=0; + k = 0; for (j = 0; j < curItem->nActions; j++) if (curItem->Action[j].num == 0xFF) k++; @@ -1132,49 +1129,49 @@ void PASCAL LocationPollThread(uint32 id) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ curTime = timeGetTime(); - dwSleepTime=(uint32)-1L; + dwSleepTime=(uint32) - 1L; - for (k=0;k=MyActions[k].dwLastTime+MyActions[k].wTime) { - dwSleepTime=0; + for (k = 0;k= MyActions[k].dwLastTime + MyActions[k].wTime) { + dwSleepTime = 0; break; } else - dwSleepTime=MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); + dwSleepTime = MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - k=WaitForSingleObject(hEndPollingLocations[id],dwSleepTime); - if (k==WAIT_OBJECT_0) + k = WaitForSingleObject(hEndPollingLocations[id], dwSleepTime); + if (k == WAIT_OBJECT_0) break; - for (i=0;i=MyActions[k].dwLastTime+MyActions[k].wTime) { - MyActions[k].dwLastTime+=MyActions[k].wTime; + for (k = 0; k < nIdleActions; k++) + if (curTime >= MyActions[k].dwLastTime + MyActions[k].wTime) { + MyActions[k].dwLastTime += MyActions[k].wTime; /* E' il momento di tirare il nostro dado virtuale, e controllare se la sorte e' dalla parte della idle action */ byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < MyActions[k].perc) { /* Controlliamo se c'e' una action in esecuzione sull'item */ - if ((bExecutingAction) && (nExecutingAction==MyActions[k].nItem)) + if ((bExecutingAction) && (nExecutingAction == MyActions[k].nItem)) continue; /* Controlliamo se c'e' gia' un'altra idle function in esecuzione sullo stesso item */ - for (i=0;iAction[j].when!=NULL) + if (curItem->Action[j].when != NULL) if (!EvaluateExpression(curItem->Action[j].when)) { UnlockItems(); continue; @@ -1191,15 +1188,15 @@ void PASCAL LocationPollThread(uint32 id) { /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in un nuovo thread */ - newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); - if (newItem==false) { + newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + if (newItem == false) { GlobalFree(MyThreads); GlobalFree(MyActions); ExitThread(0); // _endthread(); } - CopyMemory(newItem,curItem,sizeof(MPALITEM)); + CopyMemory(newItem,curItem, sizeof(MPALITEM)); UnlockItems(); /* Copiamo l'azione nella #0 */ @@ -1209,15 +1206,15 @@ void PASCAL LocationPollThread(uint32 id) { /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria allocata per il nuovo item */ - for (i=0;iGroup[i].num!=0;i++) + for (i = 0; dialog->Group[i].num != 0; i++) if (dialog->Group[i].num==nGroup) { /* Cicla eseguendo i comandi del gruppo */ - for (j=0;jGroup[i].nCmds;j++) { + for (j = 0; j < dialog->Group[i].nCmds; j++) { k=dialog->Group[i].CmdNum[j]; switch (dialog->Command[k].type) { @@ -1348,7 +1345,7 @@ void PASCAL GroupThread(uint32 nGroup) { break; default: - mpalError=1; + mpalError = 1; UnlockDialogs(); ExitThread(0); // _endthread(); @@ -1363,7 +1360,7 @@ void PASCAL GroupThread(uint32 nGroup) { } /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ - mpalError=1; + mpalError = 1; UnlockDialogs(); ExitThread(0); // _endthread(); @@ -1391,14 +1388,14 @@ void DoChoice(uint32 nChoice) { dialog=lpmdDialogs+nExecutingDialog; /* Cerca la scelta richiesta tra quelle nel dialogo */ - for (i=0;dialog->Choice[i].nChoice!=0;i++) - if (dialog->Choice[i].nChoice==nChoice) + for (i = 0; dialog->Choice[i].nChoice != 0; i++) + if (dialog->Choice[i].nChoice == nChoice) break; /* Se non l'ha trovata, esce con errore */ - if (dialog->Choice[i].nChoice==0) { + if (dialog->Choice[i].nChoice == 0) { /* Se siamo qui, non abbiamo trovato la choice richiesta */ - mpalError=1; + mpalError = 1; UnlockDialogs(); ExitThread(0); // _endthread(); @@ -1406,26 +1403,26 @@ void DoChoice(uint32 nChoice) { /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella variabile globale */ - nExecutingChoice=i; + nExecutingChoice = i; while (1) { - nExecutingChoice=i; + nExecutingChoice = i; - k=0; + k = 0; /* Calcoliamo le when expression di ciascun select, per vedere se sono attivi o disattivi */ - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) - if (dialog->Choice[i].Select[j].when==NULL) { - dialog->Choice[i].Select[j].curActive=1; + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) + if (dialog->Choice[i].Select[j].when == NULL) { + dialog->Choice[i].Select[j].curActive = 1; k++; } else if (EvaluateExpression(dialog->Choice[i].Select[j].when)) { - dialog->Choice[i].Select[j].curActive=1; + dialog->Choice[i].Select[j].curActive = 1; k++; } else - dialog->Choice[i].Select[j].curActive=0; + dialog->Choice[i].Select[j].curActive = 0; /* Se non ci sono scelte attivate, la scelta e' finita */ - if (k==0) { + if (k == 0) { UnlockDialogs(); break; } @@ -1434,22 +1431,22 @@ void DoChoice(uint32 nChoice) { e restiamo in attesa della risposta */ ResetEvent(hDoneChoice); SetEvent(hAskChoice); - WaitForSingleObject(hDoneChoice,INFINITE); + WaitForSingleObject(hDoneChoice, INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire i gruppi associati con la scelta */ j=nSelectedChoice; - for (k=0;dialog->Choice[i].Select[j].wPlayGroup[k]!=0;k++) + for (k = 0; dialog->Choice[i].Select[j].wPlayGroup[k] != 0; k++) GroupThread(dialog->Choice[i].Select[j].wPlayGroup[k]); /* Controllo sugli attributi */ - if (dialog->Choice[i].Select[j].attr&(1<<0)) { + if (dialog->Choice[i].Select[j].attr & (1 << 0)) { /* Bit 0 settato: fine della scelta */ UnlockDialogs(); break; } - if (dialog->Choice[i].Select[j].attr&(1<<1)) { + if (dialog->Choice[i].Select[j].attr & (1 << 1)) { /* Bit 1 settato: fine del dialogo */ UnlockDialogs(); ExitThread(1); @@ -1488,7 +1485,7 @@ void DoChoice(uint32 nChoice) { \****************************************************************************/ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item=lpmiItems; + LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; uint32 dwId; @@ -1496,25 +1493,25 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); - if (varGetValue(buf.c_str())<=0) + if (varGetValue(buf.c_str()) <= 0) return INVALID_HANDLE_VALUE; - for (i=0;inActions;i++) { - if (item->Action[i].num!=nAction) + for (i = 0; i < item->nActions; i++) { + if (item->Action[i].num != nAction) continue; - if (item->Action[i].wParm!=dwParam) + if (item->Action[i].wParm != dwParam) continue; - if (item->Action[i].when!=NULL) { + if (item->Action[i].when != NULL) { if (!EvaluateExpression(item->Action[i].when)) continue; } // Ora abbiamo trova l'azione giusta che deve essere eseguita. // Duplichiamo l'item corrente e copiamo la azione #i nella #0 - newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); - if (newitem==NULL) + newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + if (newitem == NULL) return INVALID_HANDLE_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes @@ -1522,29 +1519,29 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { /* newitem->Action[0].nCmds=item->Action[i].nCmds; CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ - newitem->dwRes=i; + newitem->dwRes = i; // E finalmente possiamo richiamare il thread, che eseguira' l'azione // 0 dell'item, e poi liberera' la memoria con la GlobalFree() /* !!! Nuova gestione dei thread */ - if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ActionThread,(void *)newitem,0,&dwId))==NULL) + if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ActionThread, (void *)newitem, 0, &dwId)) == NULL) return INVALID_HANDLE_VALUE; - if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread,(void *)h,0,&dwId))==NULL) + if ((h = CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread, (void *)h, 0, &dwId)) == NULL) return INVALID_HANDLE_VALUE; /* - if ((h=(void*)_beginthread(ActionThread,10240,(void *)newitem))==(void*)-1) + if ((h=(void*)_beginthread(ActionThread, 10240,(void *)newitem))==(void*)-1) return INVALID_HANDLE_VALUE; - if ((h=(void*)_beginthread(ShutUpActionThread,10240,(void *)h))==(void*)-1) + if ((h=(void*)_beginthread(ShutUpActionThread, 10240,(void *)h))==(void*)-1) return INVALID_HANDLE_VALUE; */ - nExecutingAction=item->nObj; - bExecutingAction=true; + nExecutingAction = item->nObj; + bExecutingAction = true; return h; } @@ -1580,10 +1577,10 @@ static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { HANDLE h; /* Si ricorda nella variabile globale qual e' il dialogo in esecuzione */ - nExecutingDialog=nDlgOrd; + nExecutingDialog = nDlgOrd; /* Attiva la flag per indicare che c'e' un dialogo in esecuzione */ - bExecutingDialog=true; + bExecutingDialog = true; ResetEvent(hAskChoice); ResetEvent(hDoneChoice); @@ -1591,16 +1588,16 @@ static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { /* Crea un thread in cui esegue un gruppo del dialogo */ // !!! Nuova gestione dei thread - if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)GroupThread,(void *)nGroup,0,&dwId))==NULL) - // if ((h=(void*)_beginthread(GroupThread,10240,(void *)nGroup))==(void*)-1) + if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)GroupThread, (void *)nGroup, 0, &dwId)) == NULL) + // if ((h=(void*)_beginthread(GroupThread, 10240,(void *)nGroup))==(void*)-1) return INVALID_HANDLE_VALUE; /* Crea un thread che attende la fine del dialogo e rimette a posto le variabili globali */ // !!! Nuova gestione dei thread - if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h,0,&dwId)==NULL) { - //if ((h=(void*)_beginthread(ShutUpDialogThread,10240,(void *)h))==(void*)-1) - TerminateThread(h,0); + if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h, 0, &dwId) == NULL) { + //if ((h=(void*)_beginthread(ShutUpDialogThread, 10240,(void *)h))==(void*)-1) + TerminateThread(h, 0); CloseHandle(h); return INVALID_HANDLE_VALUE; } @@ -1627,14 +1624,14 @@ bool DoSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; int j; - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) - if (dialog->Choice[i].Select[j].dwData==dwData && dialog->Choice[i].Select[j].curActive!=0) + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) + if (dialog->Choice[i].Select[j].dwData == dwData && dialog->Choice[i].Select[j].curActive != 0) break; - if (dialog->Choice[i].Select[j].dwData==0) + if (dialog->Choice[i].Select[j].dwData == 0) return false; - nSelectedChoice=j; + nSelectedChoice = j; SetEvent(hDoneChoice); return true; } @@ -1664,7 +1661,7 @@ bool DoSelection(uint32 i, uint32 dwData) { * \****************************************************************************/ -bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { +bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { Common::File hMpc; byte buf[5]; uint32 nBytesRead; @@ -1672,9 +1669,9 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU uint32 dwSizeDecomp, dwSizeComp; byte *cmpbuf; - //printf("Item: %lu\n",sizeof(MPALITEM)); - //printf("Script: %lu\n",sizeof(MPALSCRIPT)); - //printf("Dialog: %lu\n",sizeof(MPALDIALOG)); + //printf("Item: %lu\n", sizeof(MPALITEM)); + //printf("Script: %lu\n", sizeof(MPALSCRIPT)); + //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Si salva l'array delle funzioni custom */ lplpFunctions=lplpcfArray; @@ -1685,13 +1682,13 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU /* Legge e controlla l'header */ nBytesRead = hMpc.read(buf, 5); - if (nBytesRead !=5) + if (nBytesRead != 5) return false; - if (buf[0]!='M' || buf[1]!='P' || buf[2]!='C' || buf[3]!=0x20) + if (buf[0] != 'M' || buf[1] != 'P' || buf[2] != 'C' || buf[3] != 0x20) return false; - bCompress=buf[4]; + bCompress = buf[4]; /* Legge la dimensione del file decompresso, e alloca la memoria */ dwSizeDecomp = hMpc.readUint32LE(); @@ -1699,7 +1696,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU return false; lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); - if (lpMpcImage==NULL) + if (lpMpcImage == NULL) return false; if (bCompress) { @@ -1710,7 +1707,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); - if (cmpbuf==NULL) + if (cmpbuf == NULL) return false; nBytesRead = hMpc.read(cmpbuf, dwSizeComp); @@ -1781,11 +1778,11 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nResources * 8); - if (lpResources==NULL) + if (lpResources == NULL) return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); - if (cmpbuf==NULL) + if (cmpbuf == NULL) return false; nBytesRead = hMpr.read(cmpbuf, dwSizeComp); @@ -1810,8 +1807,8 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice=CreateEvent(NULL, true, false, NULL); - hDoneChoice=CreateEvent(NULL, true, false, NULL); + hAskChoice = CreateEvent(NULL, true, false, NULL); + hDoneChoice = CreateEvent(NULL, true, false, NULL); return true; } @@ -1840,7 +1837,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU uint32 mpalQuery(uint16 wQueryType, ...) { uint32 dwRet = 0; - int x,y,z; + int x, y, z; char *n; va_list v; Common::String buf; @@ -1861,7 +1858,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_GLOBAL_VAR: LockVar(); - dwRet=(uint32)varGetValue(GETARG(char *)); + dwRet = (uint32)varGetValue(GETARG(char *)); UnlockVar(); break; @@ -1870,7 +1867,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_MESSAGE: LockMsg(); - dwRet=(uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); UnlockMsg(); break; @@ -1889,17 +1886,17 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_LOCATION_SIZE: LockLocations(); - x=locGetOrderFromNum(GETARG(uint32)); - y=GETARG(uint32); - if (x!=-1) { - if (y==MPQ_X) - dwRet=lpmlLocations[x].dwXlen; - else if (y==MPQ_Y) - dwRet=lpmlLocations[x].dwYlen; + x = locGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + if (x != -1) { + if (y == MPQ_X) + dwRet = lpmlLocations[x].dwXlen; + else if (y == MPQ_Y) + dwRet = lpmlLocations[x].dwYlen; else - mpalError=1; + mpalError = 1; } else - mpalError=1; + mpalError = 1; UnlockLocations(); break; @@ -1908,8 +1905,8 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_LOCATION_IMAGE: LockLocations(); - x=locGetOrderFromNum(GETARG(uint32)); - dwRet=(uint32)resLoad(lpmlLocations[x].dwPicRes); + x = locGetOrderFromNum(GETARG(uint32)); + dwRet = (uint32)resLoad(lpmlLocations[x].dwPicRes); UnlockLocations(); break; @@ -1917,7 +1914,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); */ case MPQ_RESOURCE: - dwRet=(uint32)resLoad(GETARG(uint32)); + dwRet = (uint32)resLoad(GETARG(uint32)); break; /* @@ -1925,7 +1922,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_LIST: LockVar(); - dwRet=(uint32)GetItemList(GETARG(uint32)); + dwRet = (uint32)GetItemList(GETARG(uint32)); LockVar(); break; @@ -1934,7 +1931,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_DATA: LockItems(); - dwRet=(uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); + dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); UnlockItems(); break; @@ -1943,7 +1940,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_IS_ACTIVE: LockVar(); - x=GETARG(uint32); + x = GETARG(uint32); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) dwRet = (uint32)false; @@ -1958,14 +1955,14 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_NAME: LockVar(); - x=GETARG(uint32); + x = GETARG(uint32); n=GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0]='\0'; else { LockItems(); - y=itemGetOrderFromNum(x); + y = itemGetOrderFromNum(x); CopyMemory(n, (char *)(lpmiItems+y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -1979,8 +1976,8 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_DIALOG_PERIOD: LockDialogs(); - y=GETARG(uint32); - dwRet=(uint32)DuplicateDialogPeriod(y); + y = GETARG(uint32); + dwRet = (uint32)DuplicateDialogPeriod(y); UnlockDialogs(); break; @@ -1989,13 +1986,13 @@ uint32 mpalQuery(uint16 wQueryType, ...) { * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ case MPQ_DIALOG_WAITFORCHOICE: - WaitForSingleObject(hAskChoice,INFINITE); + WaitForSingleObject(hAskChoice, INFINITE); ResetEvent(hAskChoice); if (bExecutingDialog) - dwRet=(uint32)nExecutingChoice; + dwRet = (uint32)nExecutingChoice; else - dwRet=(uint32)((int)-1); + dwRet = (uint32)((int)-1); break; @@ -2004,7 +2001,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_DIALOG_SELECTLIST: LockDialogs(); - dwRet=(uint32)GetSelectList(GETARG(uint32)); + dwRet = (uint32)GetSelectList(GETARG(uint32)); UnlockDialogs(); break; @@ -2013,9 +2010,9 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_DIALOG_SELECTION: LockDialogs(); - x=GETARG(uint32); - y=GETARG(uint32); - dwRet=(uint32)DoSelection(x,y); + x = GETARG(uint32); + y = GETARG(uint32); + dwRet = (uint32)DoSelection(x,y); UnlockDialogs(); break; @@ -2027,21 +2024,21 @@ uint32 mpalQuery(uint16 wQueryType, ...) { /* if (bExecutingAction) { - dwRet=(uint32)INVALID_HANDLE_VALUE; + dwRet = (uint32)INVALID_HANDLE_VALUE; break; } */ LockItems(); LockVar(); - x=GETARG(uint32); - z=GETARG(uint32); - y=itemGetOrderFromNum(z); + x = GETARG(uint32); + z = GETARG(uint32); + y = itemGetOrderFromNum(z); if (y!=-1) { - dwRet=(uint32)DoAction(x,y,GETARG(uint32)); + dwRet = (uint32)DoAction(x, y, GETARG(uint32)); } else { - dwRet=(uint32)INVALID_HANDLE_VALUE; - mpalError=1; + dwRet = (uint32)INVALID_HANDLE_VALUE; + mpalError = 1; } UnlockVar(); UnlockItems(); @@ -2056,9 +2053,9 @@ uint32 mpalQuery(uint16 wQueryType, ...) { LockDialogs(); - x=dialogGetOrderFromNum(GETARG(uint32)); - y=GETARG(uint32); - dwRet=(uint32)DoDialog(x,y); + x = dialogGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + dwRet = (uint32)DoDialog(x, y); UnlockDialogs(); break; @@ -2066,7 +2063,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { * DEFAULT -> ERROR */ default: - mpalError=1; + mpalError = 1; break; } @@ -2110,17 +2107,17 @@ bool EXPORT mpalExecuteScript(int nScript) { uint32 dwId; LockScripts(); - n=scriptGetOrderFromNum(nScript); - s=(LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALSCRIPT)); - if (s==NULL) + n = scriptGetOrderFromNum(nScript); + s = (LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + if (s == NULL) return false; CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); UnlockScripts(); // !!! Nuova gestione dei thread - if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s,0,&dwId)==NULL) - //if ((void*)_beginthread(ScriptThread,10240,(void *)s)==(void*)-1) + if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s, 0, &dwId) == NULL) + //if ((void*)_beginthread(ScriptThread, 10240,(void *)s)==(void*)-1) return false; return true; @@ -2139,7 +2136,7 @@ bool EXPORT mpalExecuteScript(int nScript) { \****************************************************************************/ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { - lpiifCustom=lpiifCus; + lpiifCustom = lpiifCus; } @@ -2163,18 +2160,18 @@ bool EXPORT mpalStartIdlePoll(int nLoc) { uint32 i; uint32 dwId; - for (i=0;iwriteString("\n

\n

\n"); if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { f->writeString(Common::String::format("%s\n", MsgComments[i].pComment)); - f->writeString("

\n

\n\n"); + f->writeString("

\n

\n

\n"); } else - bDontOutput=true; + bDontOutput = true; return; } } @@ -2360,16 +2357,16 @@ warning("Start: %d\n", wNum); void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { int i; - for (i=0;MsgComments[i].wEnd!=0;i++) + for (i = 0; MsgComments[i].wEnd != 0; i++) if (MsgComments[i].wEnd == wNum) { warning("End: %d\n", wNum); if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { f->writeString("
\n

\n"); } else - bDontOutput=false; + bDontOutput = false; - f->writeString("

\n

\n\n"); + f->writeString("

\n

\n

\n"); return; } } @@ -2378,12 +2375,12 @@ warning("End: %d\n", wNum); int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { int i; - for (i=0;MsgComments[i].wStart!=0;i++) + for (i = 0; MsgComments[i].wStart != 0; i++) if (MsgComments[i].wStart <= wNum && MsgComments[i].wEnd >= wNum) { if (strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { if (MsgComments[i].wStart == wNum) { - f->writeString(Common::String::format("%s\n", MsgComments[i].pComment+4)); - f->writeString("

\n

\n

\n"); + f->writeString(Common::String::format("%s\n", MsgComments[i].pComment + 4)); + f->writeString("

\n

\n

\n"); } return 1; @@ -2397,7 +2394,7 @@ int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { int i; - for (i=0;MsgComments[i].wStart!=0;i++) + for (i = 0; MsgComments[i].wStart != 0; i++) if (MsgComments[i].wEnd == wNum && strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { f->writeString("
\n

\n"); break; @@ -2406,7 +2403,7 @@ void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { void mpalDumpMessages(void) { - int i,j; + int i, j; char *lpMessage; char *p; char *lpPeriods[30]; @@ -2419,50 +2416,50 @@ void mpalDumpMessages(void) { LockMsg(); - bDontOutput=false; + bDontOutput = false; warning("Dumping MESSAGES.HTM...\n"); f = g_system->getSavefileManager()->openForSaving("Messages.htm"); - f->writeString("\n\n\n"); + f->writeString("\n\n
\n"); - for (i=0;igetSavefileManager()->openForSaving("Others.htm"); LockMsg(); - bDontOutput=false; + bDontOutput = false; warning("Dumping OTHERS.HTM...\n"); f->writeString("\n\n"); - for (i=0;igetSavefileManager()->openForSaving("voicelist.txt"); - sprintf(dfn,"DIALOG%03d.HTM",dlg->nObj); + sprintf(dfn,"DIALOG%03d.HTM", dlg->nObj); warning("Dumping %s...\n", dfn); f = g_system->getSavefileManager()->openForSaving(dfn); f->writeString("\n\n"); - for (g=0;dlg->Group[g].num != 0; g++) { + for (g = 0;dlg->Group[g].num != 0; g++) { bAtLeastOne = false; - for (c=0;cGroup[g].nCmds; c++) { + for (c = 0; cGroup[g].nCmds; c++) { curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; if (curCmd->type == 1 && curCmd->nCf == 71) { - bAtLeastOne=true; + bAtLeastOne = true; break; } } @@ -3003,27 +3000,27 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { continue; f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); - f->writeString("

\n"); + f->writeString("
\n"); - for (c=0;cGroup[g].nCmds; c++) { + for (c = 0;cGroup[g].nCmds; c++) { curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; // Se una funzione custom, e richiama la SendDialogMessage(nPers, nMsg) if (curCmd->type == 1 && curCmd->nCf == 71) { sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); - for (j=0;dlg->Periods[j]!=NULL;j++) + for (j = 0; dlg->Periods[j] != NULL; j++) if (dlg->PeriodNums[j] == curCmd->arg2) break; - if (dlg->Periods[j]==NULL) + if (dlg->Periods[j] == NULL) warning("ERROR: Dialogo %d, Periodo %d non trovato!\n", (int)dlg->nObj, (int)curCmd->arg2); else { frase = (char *)GlobalLock(dlg->Periods[j]); strcpy(copia, frase); GlobalUnlock(dlg->Periods[j]); - while ((p=strchr(copia,'^')) != NULL) + while ((p = strchr(copia,'^')) != NULL) *p = '\"'; p = frase; @@ -3034,7 +3031,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { v1->writeString(Common::String::format("%s\n", fname)); f->writeString("\t\n"); f->writeString(Common::String::format("\t\t\n", fname)); - f->writeString(Common::String::format("\t\t\n", + f->writeString(Common::String::format("\t\t\n", GetPersonName(dlg->nObj, curCmd->arg1))); f->writeString(Common::String::format("\t\t\n",copia)); f->writeString("\t\n"); @@ -3058,7 +3055,7 @@ void mpalDumpDialogs(void) { LockDialogs(); - for (i=0;i CoroHashMap; +static CoroHashMap *s_coroFuncs = 0; + +static void changeCoroStats(const char *func, int change) { + if (!s_coroFuncs) + s_coroFuncs = new CoroHashMap(); + + (*s_coroFuncs)[func] += change; +} + +static void displayCoroStats() { + debug("%d active coros", s_coroCount); + + // Loop over s_coroFuncs and print info about active coros + if (!s_coroFuncs) + return; + for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); + it != s_coroFuncs->end(); ++it) { + if (it->_value != 0) + debug(" %3d x %s", it->_value, it->_key.c_str()); + } +} + +} +#endif + +CoroBaseContext::CoroBaseContext(const char *func) + : _line(0), _sleep(0), _subctx(0) { +#if COROUTINE_DEBUG + _funcName = func; + changeCoroStats(_funcName, +1); + s_coroCount++; +#endif +} + +CoroBaseContext::~CoroBaseContext() { +#if COROUTINE_DEBUG + s_coroCount--; + changeCoroStats(_funcName, -1); + debug("Deleting coro in %s at %p (subctx %p)", + _funcName, (void *)this, (void *)_subctx); + displayCoroStats(); +#endif + delete _subctx; +} + +} // End of namespace Tony diff --git a/engines/tony/coroutine.h b/engines/tony/coroutine.h new file mode 100644 index 0000000000..24742a22f9 --- /dev/null +++ b/engines/tony/coroutine.h @@ -0,0 +1,271 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 TONY_COROUTINE_H +#define TONY_COROUTINE_H + +#include "common/scummsys.h" +#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION + +namespace Tony { + +/** + * @defgroup TonyCoroutines Coroutine support for Tony engine + * + * The following is loosely based on an article by Simon Tatham: + * . + * However, many improvements and tweaks have been made, in particular + * by taking advantage of C++ features not available in C. + */ +//@{ + + +// Enable this macro to enable some debugging support in the coroutine code. +//#define COROUTINE_DEBUG 1 + +/** + * The core of any coroutine context which captures the 'state' of a coroutine. + * Private use only. + */ +struct CoroBaseContext { + int _line; + int _sleep; + CoroBaseContext *_subctx; +#if COROUTINE_DEBUG + const char *_funcName; +#endif + CoroBaseContext(const char *func); + ~CoroBaseContext(); +}; + +typedef CoroBaseContext *CoroContext; + + +// FIXME: Document this! +extern CoroContext nullContext; + +/** + * Wrapper class which holds a pointer to a pointer to a CoroBaseContext. + * The interesting part is the destructor, which kills the context being held, + * but ONLY if the _sleep val of that context is zero. This way, a coroutine + * can just 'return' w/o having to worry about freeing the allocated context + * (in Simon Tatham's original code, one had to use a special macro to + * return from a coroutine). + */ +class CoroContextHolder { + CoroContext &_ctx; +public: + CoroContextHolder(CoroContext &ctx) : _ctx(ctx) { + assert(ctx); + assert(ctx->_sleep >= 0); + ctx->_sleep = 0; + } + ~CoroContextHolder() { + if (_ctx && _ctx->_sleep == 0) { + delete _ctx; + _ctx = 0; + } + } +}; + + +#define CORO_PARAM CoroContext &coroParam + + +/** + * Begin the declaration of a coroutine context. + * This allows declaring variables which are 'persistent' during the + * lifetime of the coroutine. An example use would be: + * + * CORO_BEGIN_CONTEXT; + * int var; + * char *foo; + * CORO_END_CONTEXT(_ctx); + * + * It is not possible to initialize variables here, due to the way this + * macro is implemented. Furthermore, to use the variables declared in + * the coroutine context, you have to access them via the context variable + * name that was specified as parameter to CORO_END_CONTEXT, e.g. + * _ctx->var = 0; + * + * @see CORO_END_CONTEXT + * + * @note We declare a variable 'DUMMY' to allow the user to specify an 'empty' + * context, and so compilers won't complain about ";" following the macro. + */ +#define CORO_BEGIN_CONTEXT \ + struct CoroContextTag : CoroBaseContext { \ + CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ + int DUMMY + +/** + * End the declaration of a coroutine context. + * @param x name of the coroutine context + * @see CORO_BEGIN_CONTEXT + */ +#define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam + +/** + * Begin the code section of a coroutine. + * @param x name of the coroutine context + * @see CORO_BEGIN_CODE + */ +#define CORO_BEGIN_CODE(x) \ + if (&coroParam == &nullContext) assert(!nullContext);\ + if (!x) {coroParam = x = new CoroContextTag();}\ + CoroContextHolder tmpHolder(coroParam);\ + switch (coroParam->_line) { case 0:; + +/** + * End the code section of a coroutine. + * @see CORO_END_CODE + */ +#define CORO_END_CODE \ + if (&coroParam == &nullContext) { \ + delete nullContext; \ + nullContext = NULL; \ + } \ + } + +/** + * Sleep for the specified number of scheduler cycles. + */ +#define CORO_SLEEP(delay) do {\ + coroParam->_line = __LINE__;\ + coroParam->_sleep = delay;\ + assert(&coroParam != &nullContext);\ + return; case __LINE__:;\ + } while (0) + +#define CORO_GIVE_WAY do { g_scheduler->giveWay(); CORO_SLEEP(1); } while (0) +#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0) + +/** + * Stop the currently running coroutine and all calling coroutines. + * + * This sets _sleep to -1 rather than 0 so that the context doesn't get + * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to + * propogate the _sleep value and return immediately (the scheduler will + * then delete the entire coroutine's state, including all subcontexts). + */ +#define CORO_KILL_SELF() \ + do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0) + + +/** + * This macro is to be used in conjunction with CORO_INVOKE_ARGS and + * similar macros for calling coroutines-enabled subroutines. + */ +#define CORO_SUBCTX coroParam->_subctx + +/** + * Invoke another coroutine. + * + * If the subcontext still exists after the coroutine is invoked, it has + * either yielded/slept or killed itself, and so we copy the _sleep value + * to our own context and return (execution will continue at the case + * statement below, where we loop and call the coroutine again). + * If the subcontext is null, the coroutine ended normally, and we can + * simply break out of the loop and continue execution. + * + * @param subCoro name of the coroutine-enabled function to invoke + * @param ARGS list of arguments to pass to subCoro + * + * @note ARGS must be surrounded by parentheses, and the first argument + * in this list must always be CORO_SUBCTX. For example, the + * regular function call + * myFunc(a, b); + * becomes the following: + * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); + */ +#define CORO_INVOKE_ARGS(subCoro, ARGS) \ + do {\ + coroParam->_line = __LINE__;\ + coroParam->_subctx = 0;\ + do {\ + subCoro ARGS;\ + if (!coroParam->_subctx) break;\ + coroParam->_sleep = coroParam->_subctx->_sleep;\ + assert(&coroParam != &nullContext);\ + return; case __LINE__:;\ + } while (1);\ + } while (0) + +/** + * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, + * but allows specifying a return value which is returned + * if invoked coroutine yields (thus causing the current + * coroutine to yield, too). + */ +#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ + do {\ + coroParam->_line = __LINE__;\ + coroParam->_subctx = 0;\ + do {\ + subCoro ARGS;\ + if (!coroParam->_subctx) break;\ + coroParam->_sleep = coroParam->_subctx->_sleep;\ + assert(&coroParam != &nullContext);\ + return RESULT; case __LINE__:;\ + } while (1);\ + } while (0) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with no parameters. + */ +#define CORO_INVOKE_0(subCoroutine) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with one parameter. + */ +#define CORO_INVOKE_1(subCoroutine, a0) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with two parameters. + */ +#define CORO_INVOKE_2(subCoroutine, a0,a1) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with three parameters. + */ +#define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with four parameters. + */ +#define CORO_INVOKE_4(subCoroutine, a0,a1,a2,a3) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2,a3)) + +//@} + +} // End of namespace Tony + +#endif // TONY_COROUTINE_H diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3400235563..1d28fa9ece 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -297,38 +297,38 @@ void CharsLoadAll(Common::InSaveFile *f) { } } -DECLARE_CUSTOM_FUNCTION(FaceToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDDOWN); } -DECLARE_CUSTOM_FUNCTION(BackToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDUP); } -DECLARE_CUSTOM_FUNCTION(LeftToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDLEFT); } -DECLARE_CUSTOM_FUNCTION(RightToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDRIGHT); } -DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(uint32 bStatus, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { SetPalesati(bStatus); } -DECLARE_CUSTOM_FUNCTION(MySleep)(uint32 dwTime, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { if (bSkipIdle) return; Sleep(dwTime); } -DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(uint32 val, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { bAlwaysDisplay = (val != 0); } -DECLARE_CUSTOM_FUNCTION(SetPointer)(uint32 dwPointer, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASU); @@ -369,7 +369,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { } -DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(uint32 dwMessage, uint32 nX, uint32 nY, uint32) { +DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { RMMessage msg(dwMessage); int i; int curOffset = 0; @@ -476,12 +476,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(uint32 dwMessage, uint32 nX, uint32 nY, Tony->EndTalk(); } -DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { +DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { Boxes->ChangeBoxStatus(nLoc,nBox,nStatus); } -DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { +DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { HANDLE h; Freeze(); @@ -504,7 +504,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(uint32 nLoc, uint32 tX, uint32 tY, uin RMPoint SFM_pt; int SFM_nLoc; -DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(uint32 nMsg, uint32 nFont, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { RMMessage msg(nMsg); RMGfxClearTask clear; int i; @@ -554,14 +554,14 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(uint32 nMsg, uint32 nFont, uint3 } } -DECLARE_CUSTOM_FUNCTION(ClearScreen)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { RMGfxClearTask clear; LinkGraphicTask(&clear); WaitFrame(); } -DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(uint32 bNotEnableTony, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { Freeze(); LoadLocation(SFM_nLoc,RMPoint(SFM_pt.x,SFM_pt.y),RMPoint(-1,-1)); if (!bNotEnableTony) @@ -573,18 +573,25 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(uint32 bNotEnableTony, uint32, uin } -DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(uint32 nMsg, uint32 nFont, uint32, uint32) { - SendFullscreenMsgStart(nMsg,nFont,0,0); - SendFullscreenMsgEnd(0, 0, 0, 0); +DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(SendFullscreenMsgStart, nMsg, nFont, 0, 0); + CORO_INVOKE_4(SendFullscreenMsgEnd, 0, 0, 0, 0); + + CORO_END_CODE; } bool bNoOcchioDiBue = false; -DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(uint32, uint32, uint32, uint32) { - bNoOcchioDiBue = true; +DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { + bNoOcchioDiBue = true; } -DECLARE_CUSTOM_FUNCTION(CloseLocation)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { if (!bNoOcchioDiBue) { InitWipe(1); WaitWipeEnd(); @@ -598,7 +605,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(uint32, uint32, uint32, uint32) { } -DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { +DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { HANDLE h; if (!bNoOcchioDiBue) { @@ -647,40 +654,48 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint3 } -DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(uint32 nLoc, uint32 lX, uint32 lY, uint32) { +DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { StartLocPos[nLoc].Set(lX,lY); } -DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { saveTonyPos = Tony->Position(); saveTonyLoc = Loc->TEMPGetNumLoc(); } -DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(uint32, uint32, uint32, uint32) { - ChangeLocation(saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); +DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(ChangeLocation, saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); + MCharResetCodes(); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(DisableInput)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DisableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { MainDisableInput(); } -DECLARE_CUSTOM_FUNCTION(EnableInput)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { MainEnableInput(); } -DECLARE_CUSTOM_FUNCTION(StopTony)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->StopNoAction(); } -DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { EnableGUI(); } -DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(uint32, uint32, uint32, uint32) +DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { DisableGUI(); } @@ -731,31 +746,31 @@ void TonyGenericPut2(uint32 nDirection) { } -DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake1(0); } -DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake1(1); } -DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake1(2); } -DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake2(0); } -DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake2(1); } -DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake2(2); } @@ -765,42 +780,42 @@ DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(uint32, uint32, uint32, uint32) { -DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut1(0); } -DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut1(1); } -DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut1(2); } -DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut2(0); } -DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut2(1); } -DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut2(2); } -DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte== 0) Tony->SetPattern(Tony->PAT_PERTERRALEFT); else Tony->SetPattern(Tony->PAT_PERTERRARIGHT); } -DECLARE_CUSTOM_FUNCTION(TonySiRialza)(uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte== 0) Tony->SetPattern(Tony->PAT_SIRIALZALEFT); else @@ -810,11 +825,11 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(uint32 dwParte, uint32, uint32, uint32) { Tony->WaitForEndPattern(); } -DECLARE_CUSTOM_FUNCTION(TonyPastorella)(uint32 bIsPast, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { Tony->SetPastorella(bIsPast); } -DECLARE_CUSTOM_FUNCTION(TonyFischietto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); if (!bSkipIdle) Tony->WaitForEndPattern(); @@ -827,182 +842,182 @@ void TonySetNumTexts(uint32 dwText) { bTonyInTexts = false; } -DECLARE_CUSTOM_FUNCTION(TonyRide)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_RIDE; } -DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_RIDE2; } -DECLARE_CUSTOM_FUNCTION(TonyFianchi)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_FIANCHI; } -DECLARE_CUSTOM_FUNCTION(TonyCanta)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CANTA; } -DECLARE_CUSTOM_FUNCTION(TonySiIndica)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SIINDICA; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SPAVENTATO; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SPAVENTATO2; } -DECLARE_CUSTOM_FUNCTION(TonyConMartello)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONMARTELLO; Tony->SetPattern(Tony->PAT_CONMARTELLO); } -DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONBICCHIERE; Tony->SetPattern(Tony->PAT_CONBICCHIERE); } -DECLARE_CUSTOM_FUNCTION(TonyConVerme)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONVERME; Tony->SetPattern(Tony->PAT_CONVERME); } -DECLARE_CUSTOM_FUNCTION(TonyConCorda)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONCORDA; Tony->SetPattern(Tony->PAT_CONCORDA); } -DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONSEGRETARIA; Tony->SetPattern(Tony->PAT_CONSEGRETARIA); } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONCONIGLIO; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONRICETTA; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONCARTE; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONPUPAZZO; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONPUPAZZOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONPUPAZZOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONCONIGLIOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONCONIGLIOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONRICETTASTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONRICETTASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONCARTESTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONCARTESTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONTACCUINOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONTACCUINOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONMEGAFONOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONMEGAFONOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONBARBASTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONBARBASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_SPAVENTATOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_SPAVENTATOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; @@ -1010,29 +1025,43 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(uint32, uint32, uint32, uint32) { -DECLARE_CUSTOM_FUNCTION(TonySchifato)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SCHIFATO; } -DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); Tony->WaitForEndPattern(); - LeftToMe(0, 0, 0, 0); + CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); Tony->WaitForEndPattern(); - RightToMe(0, 0, 0, 0); + CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyNaah)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_NAAH; } -DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(uint32 nPos, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { switch (nPos) { case 1: nTonyNextTalkType = Tony->TALK_MACBETH1; @@ -1065,15 +1094,15 @@ DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(uint32 nPos, uint32, uint32, uint32) { } -DECLARE_CUSTOM_FUNCTION(EnableTony)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->Show(); } -DECLARE_CUSTOM_FUNCTION(DisableTony)(uint32 bShowOmbra, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { Tony->Hide(bShowOmbra); } -DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { RMItem *item = Loc->GetItemFromCode(nItem); if (!bSkipIdle && item != NULL) @@ -1081,22 +1110,22 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) } -DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(uint32 nX, uint32 nY, uint32 nLoc, uint32) { +DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { Tony->SetPosition(RMPoint(nX, nY), nLoc); } -DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(uint32 nX, uint32 nY, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { Tony->Move(RMPoint(nX, nY)); if (!bSkipIdle) Tony->WaitForEndMovement(); } -DECLARE_CUSTOM_FUNCTION(MoveTony)(uint32 nX, uint32 nY, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { Tony->Move(RMPoint(nX, nY)); } -DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { +DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { int lx, ly; RMPoint pt; @@ -1133,7 +1162,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 } } -DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { +DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { int lx, ly; RMPoint pt, startpt; uint32 dwStartTime, dwCurTime, dwTotalTime; @@ -1231,7 +1260,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin } -DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint32) { +DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; for (i = 0; i < curChangedHotspot; i++) @@ -1252,15 +1281,15 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint } -DECLARE_CUSTOM_FUNCTION(AutoSave)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->AutoSave(); } -DECLARE_CUSTOM_FUNCTION(Abort)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->Abort(); } -DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { uint32 i; uint32 curTime = _vm->GetTime(); int dirx,diry; @@ -1296,7 +1325,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { * Personaggi */ -DECLARE_CUSTOM_FUNCTION(CharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); Character[nChar].code = nCode; Character[nChar].item = Loc->GetItemFromCode(nCode); @@ -1311,26 +1340,26 @@ DECLARE_CUSTOM_FUNCTION(CharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) IsMChar[nChar] = false; } -DECLARE_CUSTOM_FUNCTION(CharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { +DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar<16); Character[nChar].r = r; Character[nChar].g = g; Character[nChar].b = b; } -DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(uint32 nChar, uint32 tp, uint32 sp, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { assert(nChar<16); Character[nChar].talkpattern = tp; Character[nChar].standpattern = sp; } -DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(uint32 nChar, uint32 sp, uint32 ep, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { assert(nChar<16); Character[nChar].starttalkpattern=sp; Character[nChar].endtalkpattern=ep; } -DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { RMMessage msg(dwMessage); int i; RMPoint pt; @@ -1433,15 +1462,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 Unfreeze(); } -DECLARE_CUSTOM_FUNCTION(AddInventory)(uint32 dwCode, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { Inventory->AddItem(dwCode); } -DECLARE_CUSTOM_FUNCTION(RemoveInventory)(uint32 dwCode, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { Inventory->RemoveItem(dwCode); } -DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(uint32 dwCode, uint32 dwStatus, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { Inventory->ChangeItemStatus(dwCode,dwStatus); } @@ -1452,7 +1481,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(uint32 dwCode, uint32 dwStatus, u * Mastri Personaggi */ -DECLARE_CUSTOM_FUNCTION(MCharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); MCharacter[nChar].code=nCode; if (nCode== 0) @@ -1474,19 +1503,19 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32 IsMChar[nChar] = true; } -DECLARE_CUSTOM_FUNCTION(MCharResetCode)(uint32 nChar, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { MCharacter[nChar].item=Loc->GetItemFromCode(MCharacter[nChar].code); } -DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(uint32 nChar, uint32 nX, uint32 nY, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); MCharacter[nChar].x=nX; MCharacter[nChar].y=nY; } -DECLARE_CUSTOM_FUNCTION(MCharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { +DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); MCharacter[nChar].r=r; MCharacter[nChar].g=g; @@ -1494,7 +1523,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 } -DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { assert(nChar < 10); assert(nGroup < 10); @@ -1502,7 +1531,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(uint32 nChar, uint32 nGroup, ui } -DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(uint32 nChar, uint32 nGroup, uint32, uint32) +DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32, uint32) { assert(nChar < 10); assert(nGroup < 10); @@ -1510,21 +1539,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(uint32 nChar, uint32 nGroup, uint3 MCharacter[nChar].curgroup = nGroup; } -DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(uint32 nChar, uint32 nTexts, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); MCharacter[nChar].numtexts=nTexts-1; MCharacter[nChar].bInTexts = false; } -DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); MCharacter[nChar].bAlwaysBack=bAlwaysBack; } -DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { +DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { RMMessage msg(dwMessage); int i; int parm; @@ -1645,7 +1674,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 int curDialog; -DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { LPSTR string; RMTextDialog* text; int parm; @@ -1822,7 +1851,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, ui // @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!! -DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { int nChoice; uint32 *sl; int i,num; @@ -1897,12 +1926,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, * Sync tra idle e mpal */ -DECLARE_CUSTOM_FUNCTION(TakeOwnership)(uint32 num, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); WaitForSingleObject(mut[num],INFINITE); } -DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(uint32 num, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // LeaveCriticalSection(&cs[num]); // g_system->unlockMutex(mut[num]); warning("TODO: ReleaseOwnership"); @@ -1975,46 +2004,46 @@ void ThreadFadeOutMusic(void *nMusic) { _endthread(); } -DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { _beginthread(ThreadFadeInMusic, 10240, (void*)curSonoriz); } -DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; _beginthread(ThreadFadeOutMusic, 10240, (void *)curSonoriz); } -DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; _beginthread(ThreadFadeOutMusic, 10240, (void*)2); } -DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _beginthread(ThreadFadeInMusic, 10240, (void*)2); } -DECLARE_CUSTOM_FUNCTION(StopSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->StopMusic(curSonoriz); } -DECLARE_CUSTOM_FUNCTION(StopStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->StopMusic(2); } -DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(curSonoriz, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = true; _vm->SetMusicVolume(curSonoriz, 64); } -DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(2, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(2, 64); } @@ -2139,7 +2168,7 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int debug("End CustPlayMusic\n"); } -DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { +DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX==2) { debug("PlaySonoriz stop fadeout\n"); bFadeOutStop = true; @@ -2149,11 +2178,11 @@ DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(uint32 nMusic, uint32 nFX, uint32 bNoLoop, CustPlayMusic(curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } -DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { +DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { CustPlayMusic(2,staccFileNames[nMusic],nFX,bLoop); } -DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(uint32 nItem, uint32 nSFX, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem== 0) { Tony->PlaySfx(nSFX); } else { @@ -2165,7 +2194,7 @@ DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(uint32 nItem, uint32 nSFX, uint32, uint32) void RestoreMusic(void) { - PlaySonoriz(lastMusic, 0, 0, 0); + PlaySonoriz(nullContext, lastMusic, 0, 0, 0); if (lastTappeto != 0) CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); } @@ -2181,49 +2210,63 @@ void LoadMusic(Common::InSaveFile *f) { } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(uint32 nStacc, uint32 bLoop, uint32, uint32) { - FadeOutSonoriz(0, 0, 0, 0); - MuteStacchetto(0, 0, 0, 0); - PlayStacchetto(nStacc, 0, bLoop, 0); - FadeInStacchetto(0, 0, 0, 0); +DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(FadeOutSonoriz, 0, 0, 0, 0); + CORO_INVOKE_4(MuteStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(PlayStacchetto, nStacc, 0, bLoop, 0); + CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(uint32 nStacc, uint32 bLoop, uint32, uint32) { - FadeOutStacchetto(0, 0, 0, 0); - FadeInSonoriz(0, 0, 0, 0); +DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(FadeOutStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(FadeInSonoriz, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = true; SetEvent(hSkipIdle); } -DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = false; ResetEvent(hSkipIdle); } -DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(uint32 bStatus, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { bPatIrqFreeze = bStatus; } -DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(uint32 , uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { Freeze(); _vm->OpenInitLoadMenu(); Unfreeze(); } -DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(uint32 , uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uint32) { Freeze(); _vm->OpenInitOptions(); Unfreeze(); } -DECLARE_CUSTOM_FUNCTION(DoCredits)(uint32 nMsg, uint32 dwTime, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint32, uint32) { RMMessage msg(nMsg); RMTextDialog *text; HANDLE hDisable = CreateEvent(NULL, true, false, NULL); diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 57d726f70e..a9f4ac2aab 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -67,10 +67,10 @@ typedef uint32 HWND; #define DECLARE_CUSTOM_FUNCTION(x) void x #define BEGIN_CUSTOM_FUNCTION_MAP() \ - static void AssignError(HWND hWnd, int num) { \ + static void AssignError(int num) { \ error("Custom function %u has been already assigned!", num); \ } \ - void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap) \ + void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap) \ { @@ -78,10 +78,10 @@ typedef uint32 HWND; } -#define ASSIGN(num,func) \ - if (lpMap[num]!=NULL) \ - AssignError(hWnd,num); \ - lpMap[num]=func; +#define ASSIGN(num, func) \ + if (lpMap[num] != NULL) \ + AssignError(num); \ + lpMap[num] = func; class RMTony; class RMPointer; @@ -90,7 +90,7 @@ class RMLocation; class RMInventory; class RMInput; -void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap); +void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap); void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); #endif diff --git a/engines/tony/module.mk b/engines/tony/module.mk index af0b3acd2c..24e7f70557 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -1,6 +1,7 @@ MODULE := engines/tony MODULE_OBJS := \ + coroutine.o \ custom.o \ detection.o \ font.o \ @@ -10,6 +11,7 @@ MODULE_OBJS := \ input.o \ inventory.o \ loc.o \ + sched.o \ sound.o \ tony.o \ tonychar.o \ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index b977feb03b..3757cdddcf 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -51,11 +51,12 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" +#include "tony/sched.h" #include "tony/tony.h" -#include "lzo.h" -#include "mpal.h" -#include "mpaldll.h" -#include "stubs.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/mpaldll.h" +#include "tony/mpal/stubs.h" namespace Tony { @@ -829,7 +830,10 @@ static LPITEM GetItemData(uint32 nOrdItem) { \****************************************************************************/ void PASCAL CustomThread(LPCFCALL p) { - lplpFunctions[p->nCf](p->arg1, p->arg2, p->arg3, p->arg4); + // FIXME: Convert to proper corotuine call + warning("FIXME: CustomThread call"); + + lplpFunctions[p->nCf](nullContext, p->arg1, p->arg2, p->arg3, p->arg4); GlobalFree(p); ExitThread(1); // _endthread(); @@ -939,50 +943,69 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { * \****************************************************************************/ -void PASCAL ActionThread(LPMPALITEM item) { - int j, k; +void ActionThread(CORO_PARAM, const void *param) { + // COROUTINE + CORO_BEGIN_CONTEXT; + int j, k; + CORO_END_CONTEXT(_ctx); - for (j = 0;jAction[item->dwRes].nCmds; j++) { - k=item->Action[item->dwRes].CmdNum[j]; + const LPMPALITEM item = *(const LPMPALITEM *)param; - switch (item->Command[k].type) { - case 1: - // Funzione custom - lplpFunctions[item->Command[k].nCf]( - item->Command[k].arg1, - item->Command[k].arg2, - item->Command[k].arg3, - item->Command[k].arg4 - ); - break; + CORO_BEGIN_CODE(_ctx); + + mpalError = 0; + for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { + _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; + + if (item->Command[_ctx->k].type == 1) { + // Custom function + CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf], + item->Command[_ctx->k].arg1, + item->Command[_ctx->k].arg2, + item->Command[_ctx->k].arg3, + item->Command[_ctx->k].arg4 - case 2: + ); + } else if (item->Command[_ctx->k].type == 2) { // Variable assign LockVar(); - varSetValue(item->Command[k].lpszVarName, EvaluateExpression(item->Command[k].expr)); + varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); UnlockVar(); break; - default: + } else { mpalError = 1; - ExitThread(0); -// _endthread(); + break; } } GlobalFree(item); - //bExecutingAction = false; + + CORO_KILL_SELF(); - ExitThread(1); -// _endthread(); + CORO_END_CODE; } -void PASCAL ShutUpActionThread(HANDLE hThread) { +/** + * This thread monitors a created action to detect when it ends. + * @remarks Since actions can spawn sub-actions, this needs to be a + * separate thread to determine when the outer action is done + */ +void ShutUpActionThread(CORO_PARAM, const void *param) { + // COROUTINE + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + HANDLE hThread = *(const HANDLE *)param; + + CORO_BEGIN_CODE(_ctx); + WaitForSingleObject(hThread, INFINITE); bExecutingAction = false; - ExitThread(1); -// _endthread(); + CORO_KILL_SELF(); + + CORO_END_CODE; } /****************************************************************************\ @@ -1241,7 +1264,8 @@ void PASCAL LocationPollThread(uint32 id) { */ // Set idle skip on - lplpFunctions[200](0, 0, 0, 0); + // FIXME: Convert to co-routine + lplpFunctions[200](nullContext, 0, 0, 0, 0); for (i = 0; i < nRealItems; i++) if (MyThreads[i].nItem != 0) { @@ -1252,7 +1276,8 @@ void PASCAL LocationPollThread(uint32 id) { } // Set idle skip off - lplpFunctions[201](0, 0, 0, 0); + // FIXME: Convert to co-routine + lplpFunctions[201](nullContext, 0, 0, 0, 0); /* Abbiamo finito */ GlobalFree(MyThreads); @@ -1324,7 +1349,9 @@ void PASCAL GroupThread(uint32 nGroup) { switch (dialog->Command[k].type) { /* Funzione custom: la richiama */ case 1: + // FIXME: Convert to co-routine lplpFunctions[dialog->Command[k].nCf]( + nullContext, dialog->Command[k].arg1, dialog->Command[k].arg2, dialog->Command[k].arg3, @@ -1488,8 +1515,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; - uint32 dwId; - HANDLE h; + PROCESS *h; item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); @@ -1510,7 +1536,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // Ora abbiamo trova l'azione giusta che deve essere eseguita. // Duplichiamo l'item corrente e copiamo la azione #i nella #0 - newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) return INVALID_HANDLE_VALUE; @@ -1524,12 +1550,11 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // E finalmente possiamo richiamare il thread, che eseguira' l'azione // 0 dell'item, e poi liberera' la memoria con la GlobalFree() -/* !!! Nuova gestione dei thread -*/ - if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ActionThread, (void *)newitem, 0, &dwId)) == NULL) + // !!! New thread management + if ((h = g_scheduler->createProcess(ActionThread, newitem)) == NULL) return INVALID_HANDLE_VALUE; - if ((h = CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread, (void *)h, 0, &dwId)) == NULL) + if ((h = g_scheduler->createProcess(0, ShutUpActionThread, &h, sizeof(PROCESS *))) == NULL) return INVALID_HANDLE_VALUE; /* @@ -1543,7 +1568,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { nExecutingAction = item->nObj; bExecutingAction = true; - return h; + return (HANDLE)h; } return INVALID_HANDLE_VALUE; @@ -1674,7 +1699,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUST //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Si salva l'array delle funzioni custom */ - lplpFunctions=lplpcfArray; + lplpFunctions = lplpcfArray; /* Apre il file MPC in lettura */ if (!hMpc.open(lpszMpcFileName)) diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index e66f1fdb7e..3c2e62d992 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -119,6 +119,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "tony/coroutine.h" namespace Tony { @@ -220,7 +221,7 @@ typedef ITEM *LPITEM; * to perform various controls as a result of an action \****************************************************************************/ -typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); +typedef void (*LPCUSTOMFUNCTION)(CORO_PARAM, uint32, uint32, uint32, uint32); typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp new file mode 100644 index 0000000000..7f259b7a5b --- /dev/null +++ b/engines/tony/sched.cpp @@ -0,0 +1,498 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Process scheduler. + */ + +#include "common/textconsole.h" +#include "common/util.h" +#include "tony/sched.h" + +namespace Tony { + +Scheduler *g_scheduler = 0; + +//--------------------- FUNCTIONS ------------------------ + +Scheduler::Scheduler() { + processList = NULL; + pFreeProcesses = NULL; + pCurrent = NULL; + +#ifdef DEBUG + // diagnostic process counters + numProcs = 0; + maxProcs = 0; +#endif + + pRCfunction = 0; + + active = new PROCESS; + active->pPrevious = NULL; + active->pNext = NULL; + + g_scheduler = this; // FIXME HACK +} + +Scheduler::~Scheduler() { + // Kill all running processes (i.e. free memory allocated for their state). + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + delete pProc->state; + pProc->state = 0; + pProc = pProc->pNext; + } + + free(processList); + processList = NULL; + + delete active; + active = 0; +} + +/** + * Kills all processes and places them on the free list. + */ +void Scheduler::reset() { + +#ifdef DEBUG + // clear number of process in use + numProcs = 0; +#endif + + if (processList == NULL) { + // first time - allocate memory for process list + processList = (PROCESS *)calloc(MAX_PROCESSES, sizeof(PROCESS)); + + // make sure memory allocated + if (processList == NULL) { + error("Cannot allocate memory for process data"); + } + + // fill with garbage + memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); + } + + // Kill all running processes (i.e. free memory allocated for their state). + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + delete pProc->state; + pProc->state = 0; + pProc = pProc->pNext; + } + + // no active processes + pCurrent = active->pNext = NULL; + + // place first process on free list + pFreeProcesses = processList; + + // link all other processes after first + for (int i = 1; i <= NUM_PROCESS; i++) { + processList[i - 1].pNext = (i == NUM_PROCESS) ? NULL : processList + i; + processList[i - 1].pPrevious = (i == 1) ? active : processList + (i - 2); + } +} + + +#ifdef DEBUG +/** + * Shows the maximum number of process used at once. + */ +void Scheduler::printStats() { + debug("%i process of %i used", maxProcs, NUM_PROCESS); +} +#endif + +#ifdef DEBUG +/** + * Checks both the active and free process list to insure all the links are valid, + * and that no processes have been lost + */ +void Scheduler::CheckStack() { + Common::List pList; + + // Check both the active and free process lists + for (int i = 0; i < 2; ++i) { + PROCESS *p = (i == 0) ? active : pFreeProcesses; + + if (p != NULL) { + // Make sure the linkages are correct + while (p->pNext != NULL) { + assert(p->pNext->pPrevious == p); + pList.push_back(p); + p = p->pNext; + } + pList.push_back(p); + } + } + + // Make sure all processes are accounted for + for (int idx = 0; idx < NUM_PROCESS; idx++) { + bool found = false; + for (Common::List::iterator i = pList.begin(); i != pList.end(); ++i) { + PROCESS *pTemp = *i; + if (*i == &processList[idx]) { + found = true; + break; + } + } + + assert(found); + } +} +#endif + +/** + * Give all active processes a chance to run + */ +void Scheduler::schedule() { + // start dispatching active process list + PROCESS *pNext; + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + pNext = pProc->pNext; + + if (--pProc->sleepTime <= 0) { + // process is ready for dispatch, activate it + pCurrent = pProc; + pProc->coroAddr(pProc->state, pProc->param); + + if (!pProc->state || pProc->state->_sleep <= 0) { + // Coroutine finished + pCurrent = pCurrent->pPrevious; + killProcess(pProc); + } else { + pProc->sleepTime = pProc->state->_sleep; + } + + // pCurrent may have been changed + pNext = pCurrent->pNext; + pCurrent = NULL; + } + + pProc = pNext; + } +} + +/** + * Reschedules all the processes to run again this query + */ +void Scheduler::rescheduleAll() { + assert(pCurrent); + + // Unlink current process + pCurrent->pPrevious->pNext = pCurrent->pNext; + if (pCurrent->pNext) + pCurrent->pNext->pPrevious = pCurrent->pPrevious; + + // Add process to the start of the active list + pCurrent->pNext = active->pNext; + active->pNext->pPrevious = pCurrent; + active->pNext = pCurrent; + pCurrent->pPrevious = active; +} + +/** + * If the specified process has already run on this tick, make it run + * again on the current tick. + */ +void Scheduler::reschedule(PPROCESS pReSchedProc) { + // If not currently processing the schedule list, then no action is needed + if (!pCurrent) + return; + + if (!pReSchedProc) + pReSchedProc = pCurrent; + + PPROCESS pEnd; + + // Find the last process in the list. + // But if the target process is down the list from here, do nothing + for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) { + if (pEnd->pNext == pReSchedProc) + return; + } + + assert(pEnd->pNext == NULL); + + // Could be in the middle of a KillProc()! + // Dying process was last and this process was penultimate + if (pReSchedProc->pNext == NULL) + return; + + // If we're moving the current process, move it back by one, so that the next + // schedule() iteration moves to the now next one + if (pCurrent == pReSchedProc) + pCurrent = pCurrent->pPrevious; + + // Unlink the process, and add it at the end + pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; + pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; + pEnd->pNext = pReSchedProc; + pReSchedProc->pPrevious = pEnd; + pReSchedProc->pNext = NULL; +} + +/** + * Moves the specified process to the end of the dispatch queue + * allowing it to run again within the current game cycle. + * @param pGiveProc Which process + */ +void Scheduler::giveWay(PPROCESS pReSchedProc) { + // If not currently processing the schedule list, then no action is needed + if (!pCurrent) + return; + + if (!pReSchedProc) + pReSchedProc = pCurrent; + + // If the process is already at the end of the queue, nothing has to be done + if (!pReSchedProc->pNext) + return; + + PPROCESS pEnd; + + // Find the last process in the list. + for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) + ; + assert(pEnd->pNext == NULL); + + + // If we're moving the current process, move it back by one, so that the next + // schedule() iteration moves to the now next one + if (pCurrent == pReSchedProc) + pCurrent = pCurrent->pPrevious; + + // Unlink the process, and add it at the end + pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; + pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; + pEnd->pNext = pReSchedProc; + pReSchedProc->pPrevious = pEnd; + pReSchedProc->pNext = NULL; +} + +/** + * Creates a new process. + * + * @param pid process identifier + * @param CORO_ADDR coroutine start address + * @param pParam process specific info + * @param sizeParam size of process specific info + */ +PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { + PROCESS *pProc; + + // get a free process + pProc = pFreeProcesses; + + // trap no free process + assert(pProc != NULL); // Out of processes + +#ifdef DEBUG + // one more process in use + if (++numProcs > maxProcs) + maxProcs = numProcs; +#endif + + // get link to next free process + pFreeProcesses = pProc->pNext; + if (pFreeProcesses) + pFreeProcesses->pPrevious = NULL; + + if (pCurrent != NULL) { + // place new process before the next active process + pProc->pNext = pCurrent->pNext; + if (pProc->pNext) + pProc->pNext->pPrevious = pProc; + + // make this new process the next active process + pCurrent->pNext = pProc; + pProc->pPrevious = pCurrent; + + } else { // no active processes, place process at head of list + pProc->pNext = active->pNext; + pProc->pPrevious = active; + + if (pProc->pNext) + pProc->pNext->pPrevious = pProc; + active->pNext = pProc; + + } + + // set coroutine entry point + pProc->coroAddr = coroAddr; + + // clear coroutine state + pProc->state = 0; + + // wake process up as soon as possible + pProc->sleepTime = 1; + + // set new process id + pProc->pid = pid; + + // set new process specific info + if (sizeParam) { + assert(sizeParam > 0 && sizeParam <= PARAM_SIZE); + + // set new process specific info + memcpy(pProc->param, pParam, sizeParam); + } + + // return created process + return pProc; +} + +/** + * Kills the specified process. + * + * @param pKillProc which process to kill + */ +void Scheduler::killProcess(PROCESS *pKillProc) { + // make sure a valid process pointer + assert(pKillProc >= processList && pKillProc <= processList + NUM_PROCESS - 1); + + // can not kill the current process using killProcess ! + assert(pCurrent != pKillProc); + +#ifdef DEBUG + // one less process in use + --numProcs; + assert(numProcs >= 0); +#endif + + // Free process' resources + if (pRCfunction != NULL) + (pRCfunction)(pKillProc); + + delete pKillProc->state; + pKillProc->state = 0; + + // Take the process out of the active chain list + pKillProc->pPrevious->pNext = pKillProc->pNext; + if (pKillProc->pNext) + pKillProc->pNext->pPrevious = pKillProc->pPrevious; + + // link first free process after pProc + pKillProc->pNext = pFreeProcesses; + if (pFreeProcesses) + pKillProc->pNext->pPrevious = pKillProc; + pKillProc->pPrevious = NULL; + + // make pKillProc the first free process + pFreeProcesses = pKillProc; +} + + + +/** + * Returns a pointer to the currently running process. + */ +PROCESS *Scheduler::getCurrentProcess() { + return pCurrent; +} + +/** + * Returns the process identifier of the specified process. + * + * @param pProc which process + */ +int Scheduler::getCurrentPID() const { + PROCESS *pProc = pCurrent; + + // make sure a valid process pointer + assert(pProc >= processList && pProc <= processList + NUM_PROCESS - 1); + + // return processes PID + return pProc->pid; +} + +/** + * Kills any process matching the specified PID. The current + * process cannot be killed. + * + * @param pidKill process identifier of process to kill + * @param pidMask mask to apply to process identifiers before comparison + * @return The number of processes killed is returned. + */ +int Scheduler::killMatchingProcess(int pidKill, int pidMask) { + int numKilled = 0; + PROCESS *pProc, *pPrev; // process list pointers + + for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { + if ((pProc->pid & pidMask) == pidKill) { + // found a matching process + + // dont kill the current process + if (pProc != pCurrent) { + // kill this process + numKilled++; + + // Free the process' resources + if (pRCfunction != NULL) + (pRCfunction)(pProc); + + delete pProc->state; + pProc->state = 0; + + // make prev point to next to unlink pProc + pPrev->pNext = pProc->pNext; + if (pProc->pNext) + pPrev->pNext->pPrevious = pPrev; + + // link first free process after pProc + pProc->pNext = pFreeProcesses; + pProc->pPrevious = NULL; + pFreeProcesses->pPrevious = pProc; + + // make pProc the first free process + pFreeProcesses = pProc; + + // set to a process on the active list + pProc = pPrev; + } + } + } + +#ifdef DEBUG + // adjust process in use + numProcs -= numKilled; + assert(numProcs >= 0); +#endif + + // return number of processes killed + return numKilled; +} + +/** + * Set pointer to a function to be called by killProcess(). + * + * May be called by a resource allocator, the function supplied is + * called by killProcess() to allow the resource allocator to free + * resources allocated to the dying process. + * + * @param pFunc Function to be called by killProcess() + */ +void Scheduler::setResourceCallback(VFPTRPP pFunc) { + pRCfunction = pFunc; +} + +} // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h new file mode 100644 index 0000000000..9bc6d052da --- /dev/null +++ b/engines/tony/sched.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. + * + * Data structures used by the process scheduler + */ + +#ifndef TONY_SCHED_H +#define TONY_SCHED_H + +#include "tony/coroutine.h" + +namespace Tony { + +// the size of process specific info +#define PARAM_SIZE 32 + +// the maximum number of processes +#define NUM_PROCESS 100 +#define MAX_PROCESSES 100 + +typedef void (*CORO_ADDR)(CoroContext &, const void *); + +/** process structure */ +struct PROCESS { + PROCESS *pNext; ///< pointer to next process in active or free list + PROCESS *pPrevious; ///< pointer to previous process in active or free list + + CoroContext state; ///< the state of the coroutine + CORO_ADDR coroAddr; ///< the entry point of the coroutine + + int sleepTime; ///< number of scheduler cycles to sleep + int pid; ///< process ID + char param[PARAM_SIZE]; ///< process specific info +}; +typedef PROCESS *PPROCESS; + +struct INT_CONTEXT; + +/** + * Create and manage "processes" (really coroutines). + */ +class Scheduler { +public: + /** Pointer to a function of the form "void function(PPROCESS)" */ + typedef void (*VFPTRPP)(PROCESS *); + +private: + + /** list of all processes */ + PROCESS *processList; + + /** active process list - also saves scheduler state */ + PROCESS *active; + + /** pointer to free process list */ + PROCESS *pFreeProcesses; + + /** the currently active process */ + PROCESS *pCurrent; + +#ifdef DEBUG + // diagnostic process counters + int numProcs; + int maxProcs; + + void CheckStack(); +#endif + + /** + * Called from killProcess() to enable other resources + * a process may be allocated to be released. + */ + VFPTRPP pRCfunction; + + +public: + + Scheduler(); + ~Scheduler(); + + void reset(); + + #ifdef DEBUG + void printStats(); + #endif + + void schedule(); + void rescheduleAll(); + void reschedule(PPROCESS pReSchedProc = NULL); + void giveWay(PPROCESS pReSchedProc = NULL); + + PROCESS *createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); + PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam) { + return createProcess(0, coroAddr, &pParam, sizeof(void *)); + } + void killProcess(PROCESS *pKillProc); + + PROCESS *getCurrentProcess(); + int getCurrentPID() const; + int killMatchingProcess(int pidKill, int pidMask = -1); + + + void setResourceCallback(VFPTRPP pFunc); + +}; + +extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied + +} // End of namespace Tony + +#endif // TONY_SCHED_H diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index cf746dc978..ab6592342d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -26,6 +26,7 @@ #include "common/events.h" #include "common/file.h" #include "tony/tony.h" +#include "tony/custom.h" #include "tony/game.h" #include "tony/mpal/mpal.h" @@ -67,11 +68,15 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); + // Reset the scheduler + _scheduler.reset(); + // Initialise the graphics window _window.Init(); // Initialise the function list Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); + InitCustomFunctionMap(); // Initializes MPAL system, passing the custom functions list Common::File f; @@ -127,6 +132,10 @@ Common::ErrorCode TonyEngine::Init() { return Common::kNoError; } +void TonyEngine::InitCustomFunctionMap() { + INIT_CUSTOM_FUNCTION(FuncList); +} + /** * Display an error message */ @@ -385,6 +394,9 @@ void TonyEngine::Play(void) { while (g_system->getEventManager()->pollEvent(evt)) ; + // Call any scheduled processes + _scheduler.schedule(); + // Call the engine to handle the next frame _theEngine.DoFrame(m_bDrawLocation); @@ -468,8 +480,7 @@ void TonyEngine::FreezeTime(void) { m_nTimeFreezed = GetTime() - m_startTime; } -void TonyEngine::UnfreezeTime(void) -{ +void TonyEngine::UnfreezeTime(void) { m_bTimeFreezed = false; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index e1526db026..1eafe54afb 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -35,6 +35,7 @@ #include "tony/mpal/memory.h" #include "tony/gfxengine.h" #include "tony/loc.h" +#include "tony/sched.h" #include "tony/utils.h" #include "tony/window.h" @@ -80,6 +81,7 @@ private: void CloseMusic(); bool OpenVoiceDatabase(); void CloseVoiceDatabase(); + void InitCustomFunctionMap(); protected: // Engine APIs virtual Common::Error run(); @@ -93,6 +95,7 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; + Scheduler _scheduler; enum DATADIR { DD_BASE = 1, @@ -140,9 +143,6 @@ public: // Loop che gestisce i messaggi quando siamo in pausa void PauseLoop(void); - // Carica un modulo e le sue funzioni custom - void InitCustomDll(LPCUSTOMFUNCTION *FuncList); - void Play(); void Close(); void Abort(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index a2648318fe..e4f334d0e5 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -224,7 +224,7 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { } } } else { - // Esegue l'azione + // Perform the action hThread = mpalQueryDoAction(nAction, nActionItem, 0); } -- cgit v1.2.3 From 4c8ce3bec99db9d0b63dd65f1c7a89cbe41a679b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 12:54:57 +1000 Subject: TONY: Implemented Scheduler::waitForSingleObject method This will be the coroutine version of the threading method. With this, the main menu of the demo is now shown. --- engines/tony/mpal/mpal.cpp | 7 ++++--- engines/tony/sched.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- engines/tony/sched.h | 11 +++++++++-- 3 files changed, 52 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 3757cdddcf..78111753ce 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -996,11 +996,12 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); - HANDLE hThread = *(const HANDLE *)param; + int pid = *(const int *)param; CORO_BEGIN_CODE(_ctx); - WaitForSingleObject(hThread, INFINITE); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + bExecutingAction = false; CORO_KILL_SELF(); @@ -1554,7 +1555,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { if ((h = g_scheduler->createProcess(ActionThread, newitem)) == NULL) return INVALID_HANDLE_VALUE; - if ((h = g_scheduler->createProcess(0, ShutUpActionThread, &h, sizeof(PROCESS *))) == NULL) + if ((h = g_scheduler->createProcess(ShutUpActionThread, &h->pid, sizeof(int))) == NULL) return INVALID_HANDLE_VALUE; /* diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 7f259b7a5b..0f397316f6 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -21,6 +21,7 @@ * Process scheduler. */ +#include "common/system.h" #include "common/textconsole.h" #include "common/util.h" #include "tony/sched.h" @@ -42,7 +43,8 @@ Scheduler::Scheduler() { maxProcs = 0; #endif - pRCfunction = 0; + pRCfunction = NULL; + pidCounter = 0; active = new PROCESS; active->pPrevious = NULL; @@ -289,6 +291,40 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { pReSchedProc->pNext = NULL; } +/** + * Continously makes a given process wait for another process to finish + * + * @param pid Process identifier + * @param duration Duration in milliseconds + */ +void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { + CORO_BEGIN_CONTEXT; + uint32 endTime; + PROCESS *pProc; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; + + // Outer loop for doing checks until expiry + while (g_system->getMillis() < _ctx->endTime) { + // Check to see if a process with the given Id exists + _ctx->pProc = active->pNext; + while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid)) + _ctx->pProc = _ctx->pProc->pNext; + + if (_ctx->pProc == NULL) + // No match process found, so it's okay to break out of loop + break; + + // Sleep until the next cycle + CORO_SLEEP(1); + } + + CORO_END_CODE; +} + /** * Creates a new process. * @@ -297,7 +333,7 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { * @param pParam process specific info * @param sizeParam size of process specific info */ -PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { +PROCESS *Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc; // get a free process @@ -347,7 +383,7 @@ PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pPara pProc->sleepTime = 1; // set new process id - pProc->pid = pid; + pProc->pid = ++pidCounter; // set new process specific info if (sizeParam) { diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 9bc6d052da..cffa0f9328 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -35,6 +35,8 @@ namespace Tony { #define NUM_PROCESS 100 #define MAX_PROCESSES 100 +#define INFINITE 0xffffffff + typedef void (*CORO_ADDR)(CoroContext &, const void *); /** process structure */ @@ -75,6 +77,10 @@ private: /** the currently active process */ PROCESS *pCurrent; + /** Auto-incrementing process Id */ + int pidCounter; + + #ifdef DEBUG // diagnostic process counters int numProcs; @@ -105,10 +111,11 @@ public: void rescheduleAll(); void reschedule(PPROCESS pReSchedProc = NULL); void giveWay(PPROCESS pReSchedProc = NULL); + void waitForSingleObject(CORO_PARAM, int pid, int duration); - PROCESS *createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); + PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam) { - return createProcess(0, coroAddr, &pParam, sizeof(void *)); + return createProcess(coroAddr, &pParam, sizeof(void *)); } void killProcess(PROCESS *pKillProc); -- cgit v1.2.3 From 20a47ff7c9bba866ccfb0df232de58c9cc8d6880 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 12:55:20 +1000 Subject: TONY: Default Tony screen to 1x scaler --- engines/tony/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 36278a4f05..8ac36a5693 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -73,7 +73,7 @@ RMWindow::~RMWindow() { */ void RMWindow::Init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - initGraphics(RM_SX, RM_SY, false, &pixelFormat); + initGraphics(RM_SX, RM_SY, true, &pixelFormat); // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; -- cgit v1.2.3 From 770e55d06578f7f51959ea331da7baaaaa0e360d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 15:18:03 +1000 Subject: TONY: Further conversion of initially launched threads to processes. This includes all the dependent routines that they call. --- engines/tony/adv.h | 3 +- engines/tony/custom.cpp | 61 ++++++--- engines/tony/game.cpp | 4 +- engines/tony/gfxengine.cpp | 37 ++++-- engines/tony/gfxengine.h | 2 +- engines/tony/mpal/mpal.cpp | 310 ++++++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 3 +- engines/tony/sched.cpp | 19 ++- engines/tony/sched.h | 8 +- engines/tony/tonychar.cpp | 32 +++-- engines/tony/tonychar.h | 5 +- 11 files changed, 284 insertions(+), 200 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 6d675c2bbe..056934e932 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -49,6 +49,7 @@ #define TONY_ADV_H #include "tony/mpal/memory.h" +#include "tony/coroutine.h" #include "tony/gfxcore.h" @@ -91,7 +92,7 @@ enum RMTonyAction { // Funzioni globali HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -HANDLE MainUnloadLocation(bool bDoOnExit); +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); void MainLinkGraphicTask(RMGfxTask *task); void MainFreeze(void); void MainUnfreeze(void); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 1d28fa9ece..2683634012 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -72,7 +72,7 @@ RMInventory *Inventory; RMInput *Input; HANDLE (*LoadLocation)(int, RMPoint, RMPoint start); -HANDLE (*UnloadLocation)(bool bDoOnExit); +void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, HANDLE *result); void (*LinkGraphicTask)(RMGfxTask *task); void (*Freeze)(void); void (*Unfreeze)(void); @@ -505,20 +505,27 @@ RMPoint SFM_pt; int SFM_nLoc; DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { - RMMessage msg(nMsg); - RMGfxClearTask clear; - int i; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + RMGfxClearTask clear; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(nMsg); SFM_nLoc = Loc->TEMPGetNumLoc(); SFM_pt = Tony->Position(); - if (bSkipIdle) return; + if (bSkipIdle) + return; - UnloadLocation(false); + CORO_INVOKE_2(UnloadLocation, false, NULL); Tony->Hide(); Unfreeze(); - for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { RMTextDialog text; text.SetInput(Input); @@ -533,25 +540,29 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 text.SetColor(255,255,255); // Scrive il testo - if (nFont== 0) - text.WriteText(msg[i],1); - else if (nFont==1) - text.WriteText(msg[i],0); + if (nFont == 0) + text.WriteText((*_ctx->msg)[_ctx->i], 1); + else if (nFont == 1) + text.WriteText((*_ctx->msg)[_ctx->i], 0); // Setta la posizione - text.SetPosition(RMPoint(320,240)); + text.SetPosition(RMPoint(320, 240)); text.SetAlwaysDisplay(); text.ForceTime(); // Registra il testo - LinkGraphicTask(&clear); + LinkGraphicTask(&_ctx->clear); LinkGraphicTask(&text); // Aspetta la fine della visualizzazione text.SetCustomSkipHandle(hSkipIdle); text.WaitForEndDisplay(); } + + delete _ctx->msg; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -592,6 +603,11 @@ DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint3 } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!bNoOcchioDiBue) { InitWipe(1); WaitWipeEnd(); @@ -600,13 +616,19 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 _vm->StopMusic(4); // On Exit e lascia freezzato - UnloadLocation(true); + CORO_INVOKE_2(UnloadLocation, true, NULL); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { - HANDLE h; + CORO_BEGIN_CONTEXT; + HANDLE h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (!bNoOcchioDiBue) { InitWipe(1); @@ -618,7 +640,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } // On Exit e lascia freezzato - UnloadLocation(true); + CORO_INVOKE_2(UnloadLocation, true, NULL); curChangedHotspot = 0; if (bUseStartPos != 0) @@ -639,7 +661,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint Unfreeze(); - h = mpalQueryDoAction(0, nLoc,0); + _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!bNoOcchioDiBue) { WaitWipeEnd(); @@ -649,9 +671,10 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint bNoOcchioDiBue = false; // On Enter? - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + if (_ctx->h != INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h, INFINITE); + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 03cc80d93d..4eef8b0c96 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -96,8 +96,8 @@ HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } -HANDLE MainUnloadLocation(bool bDoOnExit) { - return _vm->GetEngine()->UnloadLocation(bDoOnExit); +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { + _vm->GetEngine()->UnloadLocation(coroParam, bDoOnExit, result); } void MainLinkGraphicTask(RMGfxTask *task) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index f98942403d..1858221350 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -65,13 +65,21 @@ extern bool bSkipSfxNoLoop; bool bIdleExited; -void ExitAllIdles(int nCurLoc) { +void ExitAllIdles(CORO_PARAM, int nCurLoc) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Chiude le idle bSkipSfxNoLoop = true; - mpalEndIdlePoll(nCurLoc); + + CORO_INVOKE_2(mpalEndIdlePoll, nCurLoc, NULL); + bIdleExited = true; bSkipSfxNoLoop = false; - ExitThread(0); + + CORO_END_CODE; } RMGfxEngine::RMGfxEngine() { @@ -514,17 +522,21 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { - HANDLE h; +void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { + CORO_BEGIN_CONTEXT; + HANDLE h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Scarica tutta la memoria della locazione - mpalEndIdlePoll(m_nCurLoc); + CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); // On Exit? if (bDoOnExit) { - h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h, INFINITE); + _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); + if (_ctx->h != INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h, INFINITE); } MainFreeze(); @@ -534,7 +546,10 @@ HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { m_bigBuf.ClearOT(); m_loc.Unload(); - return INVALID_HANDLE_VALUE; + if (result != NULL) + *result = INVALID_HANDLE_VALUE; + + CORO_END_CODE; } void RMGfxEngine::Init(/*HINSTANCE hInst*/) { @@ -930,7 +945,7 @@ void RMGfxEngine::LoadState(const char *fn) { delete f; - UnloadLocation(false); + UnloadLocation(nullContext, false, NULL); LoadLocation(loc,tp,RMPoint(-1, -1)); m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2019cf01c9..42b2050046 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -138,7 +138,7 @@ public: // Manage a location HANDLE LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); - HANDLE UnloadLocation(bool bDoOnExit=true); + void UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); // Freeze and unfreeze void Freeze(void); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 78111753ce..851de7cb0c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -138,7 +138,7 @@ bool bExecutingDialog; uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; -HANDLE PollingThreads[MAXPOLLINGLOCATIONS]; +uint32 PollingThreads[MAXPOLLINGLOCATIONS]; HANDLE hAskChoice; HANDLE hDoneChoice; @@ -996,7 +996,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); - int pid = *(const int *)param; + uint32 pid = *(const uint32 *)param; CORO_BEGIN_CODE(_ctx); @@ -1021,17 +1021,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { * \****************************************************************************/ -void PASCAL LocationPollThread(uint32 id) { - uint32 *il; - int i,j,k; - int numitems; - int nRealItems; - LPMPALITEM curItem,newItem; - int nIdleActions; - uint32 curTime; - uint32 dwSleepTime; - uint32 dwId; - +void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { uint32 nItem, nAction; @@ -1046,59 +1036,77 @@ void PASCAL LocationPollThread(uint32 id) { typedef struct { uint32 nItem; - HANDLE hThread; + uint32 hThread; } MYTHREAD; - MYACTION *MyActions; - MYTHREAD *MyThreads; + CORO_BEGIN_CONTEXT; + uint32 *il; + int i, j, k; + int numitems; + int nRealItems; + LPMPALITEM curItem,newItem; + int nIdleActions; + uint32 curTime; + uint32 dwSleepTime; + uint32 dwId; + int ord; + bool delayExpired; + + MYACTION *MyActions; + MYTHREAD *MyThreads; + CORO_END_CONTEXT(_ctx); + + uint32 id = *((const uint32 *)param); + + CORO_BEGIN_CODE(_ctx); /* Tanto per cominciare, e' necessario richiedere la lista degli item presenti nella locazione. */ - il = mpalQueryItemList(nPollingLocations[id]); + _ctx->il = mpalQueryItemList(nPollingLocations[id]); /* Contiamo gli items */ - for (numitems = 0; il[numitems] != 0; numitems++) + for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) ; /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo dalla lista */ LockItems(); - nIdleActions = 0; - nRealItems = 0; - for (i = 0; i < numitems; i++) { - int ord = itemGetOrderFromNum(il[i]); + _ctx->nIdleActions = 0; + _ctx->nRealItems = 0; + for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { + _ctx->ord = itemGetOrderFromNum(_ctx->il[_ctx->i]); - if (ord == -1) continue; + if (_ctx->ord == -1) continue; - curItem = lpmiItems + ord; + _ctx->curItem = lpmiItems + _ctx->ord; - k = 0; - for (j = 0; j < curItem->nActions; j++) - if (curItem->Action[j].num == 0xFF) - k++; + _ctx->k = 0; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + if (_ctx->curItem->Action[_ctx->j].num == 0xFF) + _ctx->k++; - nIdleActions += k; + _ctx->nIdleActions += _ctx->k; - if (k == 0) + if (_ctx->k == 0) /* Possiamo eliminare questo item dalla lista */ - il[i] = (uint32)NULL; + _ctx->il[_ctx->i] = (uint32)NULL; else - nRealItems++; + _ctx->nRealItems++; } UnlockItems(); /* Se non e' rimasto nessuno possiamo uscire */ - if (nRealItems == 0) { - GlobalFree(il); - ExitThread(0); -// _endthread(); + if (_ctx->nRealItems == 0) { + GlobalFree(_ctx->il); + CORO_KILL_SELF(); + return; } - MyThreads=(MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nRealItems * sizeof(MYTHREAD)); - if (MyThreads == NULL) { - GlobalFree(il); - ExitThread(0); -// _endthread(); + _ctx->MyThreads = (MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + if (_ctx->MyThreads == NULL) { + GlobalFree(_ctx->il); + CORO_KILL_SELF(); + return; } /* Inizializziamo le routine random */ @@ -1108,142 +1116,147 @@ void PASCAL LocationPollThread(uint32 id) { /* Abbiamo appurato che esiste almeno un item che contiene idle actions. Ora creaiamo le copie speculari delle idle actions */ - MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nIdleActions * sizeof(MYACTION)); - if (MyActions == NULL) { - GlobalFree(MyThreads); - GlobalFree(il); - ExitThread(0); -// _endthread(); + _ctx->MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + if (_ctx->MyActions == NULL) { + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->il); + CORO_KILL_SELF(); + return; } LockItems(); - k = 0; + _ctx->k = 0; - for (i = 0; i < numitems; i++) { - if (il[i] == 0) + for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { + if (_ctx->il[_ctx->i] == 0) continue; - curItem = lpmiItems + itemGetOrderFromNum(il[i]); + _ctx->curItem = lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (j = 0; j < curItem->nActions; j++) - if (curItem->Action[j].num == 0xFF) { - MyActions[k].nItem = il[i]; - MyActions[k].nAction = j; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { + _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; + _ctx->MyActions[_ctx->k].nAction = _ctx->j; - MyActions[k].wTime = curItem->Action[j].wTime; - MyActions[k].perc = curItem->Action[j].perc; - MyActions[k].when = curItem->Action[j].when; - MyActions[k].nCmds = curItem->Action[j].nCmds; - CopyMemory(MyActions[k].CmdNum, curItem->Action[j].CmdNum, + _ctx->MyActions[_ctx->k].wTime = _ctx->curItem->Action[_ctx->j].wTime; + _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; + _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; + _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; + CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - MyActions[k].dwLastTime = timeGetTime(); - k++; + _ctx->MyActions[_ctx->k].dwLastTime = timeGetTime(); + _ctx->k++; } } UnlockItems(); /* La item list non ci serve piu' */ - GlobalFree(il); + GlobalFree(_ctx->il); /* Eccoci al ciclo principale. */ while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - curTime = timeGetTime(); - dwSleepTime=(uint32) - 1L; + _ctx->curTime = timeGetTime(); + _ctx->dwSleepTime = (uint32)-1L; - for (k = 0;k= MyActions[k].dwLastTime + MyActions[k].wTime) { - dwSleepTime = 0; + for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) + if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + _ctx->dwSleepTime = 0; break; } else - dwSleepTime = MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); + _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - k = WaitForSingleObject(hEndPollingLocations[id], dwSleepTime); - if (k == WAIT_OBJECT_0) + _ctx->k = WaitForSingleObject(hEndPollingLocations[id], _ctx->dwSleepTime); + if (_ctx->k == WAIT_OBJECT_0) break; - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem != 0) { - if (WaitForSingleObject(MyThreads[i].hThread, 0) == WAIT_OBJECT_0) - MyThreads[i].nItem = 0; + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem != 0) { + CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + + // if result ) == WAIT_OBJECT_0) + if (!_ctx->delayExpired) + _ctx->MyThreads[_ctx->i].nItem = 0; } - curTime = timeGetTime(); + _ctx->curTime = timeGetTime(); /* Cerchiamo all'interno delle idle actions quale e' necessario eseguire */ - for (k = 0; k < nIdleActions; k++) - if (curTime >= MyActions[k].dwLastTime + MyActions[k].wTime) { - MyActions[k].dwLastTime += MyActions[k].wTime; + for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) + if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; - /* E' il momento di tirare il nostro dado virtuale, e controllare + /* E' _ctx->il momento di tirare _ctx->il nostro dado virtuale, e controllare se la sorte e' dalla parte della idle action */ byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); - if (randomVal < MyActions[k].perc) { + if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Controlliamo se c'e' una action in esecuzione sull'item */ - if ((bExecutingAction) && (nExecutingAction == MyActions[k].nItem)) + if ((bExecutingAction) && (nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; /* Controlliamo se c'e' gia' un'altra idle function in esecuzione sullo stesso item */ - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem == MyActions[k].nItem) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; - if (i < nRealItems) + if (_ctx->i < _ctx->nRealItems) continue; /* Ok, siamo gli unici :) */ LockItems(); - curItem=lpmiItems+itemGetOrderFromNum(MyActions[k].nItem); + _ctx->curItem=lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Controlliamo se c'e' un esperessione WhenExecute */ - j=MyActions[k].nAction; - if (curItem->Action[j].when != NULL) - if (!EvaluateExpression(curItem->Action[j].when)) { + _ctx->j=_ctx->MyActions[_ctx->k].nAction; + if (_ctx->curItem->Action[_ctx->j].when != NULL) + if (!EvaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { UnlockItems(); continue; } /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in un nuovo thread */ - newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); - if (newItem == false) { - GlobalFree(MyThreads); - GlobalFree(MyActions); - ExitThread(0); -// _endthread(); + _ctx->newItem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + if (_ctx->newItem == false) { + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->MyActions); + + CORO_KILL_SELF(); + return; } - CopyMemory(newItem,curItem, sizeof(MPALITEM)); + CopyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); UnlockItems(); /* Copiamo l'azione nella #0 */ -// newItem->Action[0].nCmds = curItem->Action[j].nCmds; -// CopyMemory(newItem->Action[0].CmdNum,curItem->Action[j].CmdNum,newItem->Action[0].nCmds*sizeof(newItem->Action[0].CmdNum[0])); - newItem->dwRes=j; +// _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; +// CopyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); + _ctx->newItem->dwRes=_ctx->j; /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria - allocata per il nuovo item */ - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem == 0) + allocata per _ctx->il nuovo item */ + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem == 0) break; - MyThreads[i].nItem=MyActions[k].nItem; + _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; // !!! Nuova gestione dei thread - if ((MyThreads[i].hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ActionThread,(void *)newItem, 0, &dwId)) == NULL) { - //if ((MyThreads[i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)newItem))==(void*)-1) - GlobalFree(newItem); - GlobalFree(MyThreads); - GlobalFree(MyActions); - ExitThread(0); -// _endthread(); + if ((_ctx->MyThreads[_ctx->i].hThread = _vm->_scheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) + GlobalFree(_ctx->newItem); + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->MyActions); + + CORO_KILL_SELF(); + return; } /* Skippa tutte le idle action dello stesso item */ @@ -1251,16 +1264,16 @@ void PASCAL LocationPollThread(uint32 id) { } } - /* Chiude tutti i thread interni */ + /* Chiude tutti _ctx->i thread interni */ /* CODICE OBSOLETO: ANDIAMO DI SKIP CHE RULLA - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem != 0) { - TerminateThread(MyThreads[i].hThread, 0); - CloseHandle(MyThreads[i].hThread); + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem != 0) { + TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); + CloseHandle(_ctx->MyThreads[_ctx->i].hThread); } */ @@ -1268,23 +1281,28 @@ void PASCAL LocationPollThread(uint32 id) { // FIXME: Convert to co-routine lplpFunctions[200](nullContext, 0, 0, 0, 0); - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem != 0) { - if (WaitForSingleObject(MyThreads[i].hThread,5000) != WAIT_OBJECT_0) - TerminateThread(MyThreads[i].hThread, 0); + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem != 0) { + CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); - CloseHandle(MyThreads[i].hThread); +/* + //if (result != WAIT_OBJECT_0) + if (_ctx->delayExpired) + TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); +*/ + _vm->_scheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } // Set idle skip off - // FIXME: Convert to co-routine - lplpFunctions[201](nullContext, 0, 0, 0, 0); + CORO_INVOKE_4(lplpFunctions[201], 0, 0, 0, 0); /* Abbiamo finito */ - GlobalFree(MyThreads); - GlobalFree(MyActions); - ExitThread(1); -//endthread(); + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->MyActions); + + CORO_KILL_SELF(); + + CORO_END_CODE; } @@ -1516,7 +1534,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; - PROCESS *h; + uint32 h; item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); @@ -1552,10 +1570,10 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // 0 dell'item, e poi liberera' la memoria con la GlobalFree() // !!! New thread management - if ((h = g_scheduler->createProcess(ActionThread, newitem)) == NULL) + if ((h = g_scheduler->createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) return INVALID_HANDLE_VALUE; - if ((h = g_scheduler->createProcess(ShutUpActionThread, &h->pid, sizeof(int))) == NULL) + if ((h = g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32))) == NULL) return INVALID_HANDLE_VALUE; /* @@ -2182,7 +2200,7 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { * \****************************************************************************/ -bool EXPORT mpalStartIdlePoll(int nLoc) { +bool mpalStartIdlePoll(int nLoc) { uint32 i; uint32 dwId; @@ -2196,7 +2214,7 @@ bool EXPORT mpalStartIdlePoll(int nLoc) { hEndPollingLocations[i] = CreateEvent(NULL, true, false, NULL); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)LocationPollThread,(void *)i, 0, &dwId)) == NULL) + if ((PollingThreads[i] = _vm->_scheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2222,22 +2240,32 @@ bool EXPORT mpalStartIdlePoll(int nLoc) { * \****************************************************************************/ -bool EXPORT mpalEndIdlePoll(int nLoc) { - uint32 i; +void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) - if (nPollingLocations[i] == (uint32)nLoc) { - SetEvent(hEndPollingLocations[i]); + CORO_BEGIN_CODE(_ctx); + + for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { + if (nPollingLocations[_ctx->i] == (uint32)nLoc) { + SetEvent(hEndPollingLocations[_ctx->i]); - WaitForSingleObject(PollingThreads[i], INFINITE); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, PollingThreads[_ctx->i], INFINITE); - CloseHandle(hEndPollingLocations[i]); - nPollingLocations[i] = 0; + CloseHandle(hEndPollingLocations[_ctx->i]); + nPollingLocations[_ctx->i] = 0; - return true; + if (result) + *result = true; + return; + } } - return false; + if (result) + *result = false; + + CORO_END_CODE; } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 3c2e62d992..9da963d39e 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -704,8 +704,7 @@ bool EXPORT mpalStartIdlePoll(int nLoc); * \****************************************************************************/ -bool EXPORT mpalEndIdlePoll(int nLoc); - +void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); /****************************************************************************\ diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 0f397316f6..421f4d1ac7 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -294,10 +294,11 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { /** * Continously makes a given process wait for another process to finish * - * @param pid Process identifier - * @param duration Duration in milliseconds + * @param pid Process identifier + * @param duration Duration in milliseconds + * @param expired Set to true if delay period expired */ -void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { +void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *expired) { CORO_BEGIN_CONTEXT; uint32 endTime; PROCESS *pProc; @@ -306,6 +307,8 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { CORO_BEGIN_CODE(_ctx); _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; + if (expired) + *expired = false; // Outer loop for doing checks until expiry while (g_system->getMillis() < _ctx->endTime) { @@ -314,9 +317,13 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid)) _ctx->pProc = _ctx->pProc->pNext; - if (_ctx->pProc == NULL) + if (_ctx->pProc == NULL) { // No match process found, so it's okay to break out of loop + if (expired) + *expired = true; + break; + } // Sleep until the next cycle CORO_SLEEP(1); @@ -333,7 +340,7 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { * @param pParam process specific info * @param sizeParam size of process specific info */ -PROCESS *Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { +uint32 Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc; // get a free process @@ -394,7 +401,7 @@ PROCESS *Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int si } // return created process - return pProc; + return pProc->pid; } /** diff --git a/engines/tony/sched.h b/engines/tony/sched.h index cffa0f9328..54f44aa5fd 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -41,7 +41,7 @@ typedef void (*CORO_ADDR)(CoroContext &, const void *); /** process structure */ struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list + PROCESS *pNext; ///< pointer to next process in active or free list PROCESS *pPrevious; ///< pointer to previous process in active or free list CoroContext state; ///< the state of the coroutine @@ -111,10 +111,10 @@ public: void rescheduleAll(); void reschedule(PPROCESS pReSchedProc = NULL); void giveWay(PPROCESS pReSchedProc = NULL); - void waitForSingleObject(CORO_PARAM, int pid, int duration); + void waitForSingleObject(CORO_PARAM, int pid, int duration, bool *delay = NULL); - PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); - PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam) { + uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); + uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { return createProcess(coroAddr, &pParam, sizeof(void *)); } void killProcess(PROCESS *pKillProc); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index e4f334d0e5..de6189876b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -59,11 +59,19 @@ namespace Tony { bool RMTony::m_bAction = false; -uint32 RMTony::WaitEndOfAction(HANDLE hThread) { - WaitForSingleObject(hThread, INFINITE); +void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 pid = *(const uint32 *)param; + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + m_bAction = false; - return 1; + CORO_END_CODE; } RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { @@ -205,6 +213,7 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { HANDLE hThread; + uint32 pid; if (nAction == TA_COMBINE) { hThread = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); @@ -229,27 +238,28 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { } if (hThread != INVALID_HANDLE_VALUE) { - uint32 id; m_bAction = true; - CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } else if (nAction != TA_GOTO) { - uint32 id; - if (nAction == TA_TALK) { hThread = mpalQueryDoAction(6, 1, 0); m_bAction = true; - CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread,0,&id); - hActionThread=hThread; + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + hActionThread = hThread; } else if (nAction == TA_PALESATI) { hThread = mpalQueryDoAction(7, 1, 0); m_bAction = true; - CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction,(void *)hThread, 0, &id); + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread=hThread; } else { hThread = mpalQueryDoAction(5, 1, 0); m_bAction = true; - CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 9806fd5e58..266b34e697 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -49,6 +49,7 @@ #define TONY_TONYCHAR_H #include "tony/mpal/stubs.h" +#include "tony/coroutine.h" #include "tony/loc.h" namespace Tony { @@ -128,8 +129,8 @@ protected: // Overload dell'allocazione degli sprites per cambiare il tipo virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); - // Thread che aspetta la fine di un azione - static uint32 WaitEndOfAction(HANDLE hThread); + // Thread which waits for the end of an action + static void WaitEndOfAction(CORO_PARAM, const void *param); public: // per farlo rialzare, altrimenti private enum PATTERNS { -- cgit v1.2.3 From 8bfc60f5c9bdba4b1f37fcf42df4b0aa360c325f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 16:39:42 +1000 Subject: TONY: Refactored RMInput class to use ScummVM event loop --- engines/tony/gfxengine.cpp | 2 - engines/tony/input.cpp | 254 ++++++++------------------------------------- engines/tony/input.h | 37 +++---- engines/tony/mpal/mpal.cpp | 1 - engines/tony/tony.cpp | 4 - 5 files changed, 55 insertions(+), 243 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 1858221350..acf6339e73 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -660,11 +660,9 @@ void RMGfxEngine::Close(void) { } void RMGfxEngine::SwitchFullscreen(bool bFull) { - m_input.SwitchFullscreen(bFull); } void RMGfxEngine::GDIControl(bool bCon) { - m_input.GDIControl(bCon); } void RMGfxEngine::EnableInput(void) { diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 09b15fa127..b6793695f3 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -51,238 +51,68 @@ namespace Tony { #define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } -void RMInput::DIInit(/*HINSTANCE hInst*/) { -#ifdef REFACTOR_ME - HRESULT err; - - // Crea l'oggetto madre - err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Crea il device del mouse - // ************************ - err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il data format - err=m_DIDMouse->SetDataFormat(&c_dfDIMouse); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il cooperative level - err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Crea il device della tastiera - // ***************************** - err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il data format - err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il cooperative level - err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } -#endif -} - -void RMInput::SwitchFullscreen(bool bFull) { -#ifdef REFACTOR_ME - HRESULT err; - - // Il camping del mouse e' attivo solo in fullscreen - m_bClampMouse=bFull; - - // Prima di tutto leviamo l'acquiring ai device, altrimenti non possiamo cambiare il - // cooperative level - Unacquire(); - - if (bFull) { - // Setta il cooperative level - err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } - } else { - // Setta il cooperative level - err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } - } -#endif -} - -void RMInput::DIClose(void) { -#ifdef REFACTOR_ME - DIRELEASE(m_DIDMouse); - DIRELEASE(m_DI); -#endif -} - - -bool RMInput::Acquire(void) { -#ifdef REFACTOR_ME - HRESULT err; - - if (m_DIDMouse == NULL) - return true; - - // Inizializza la posizione del mouse - POINT pt; - RECT rc; - GetWindowRect(theGame.m_wnd,&rc); - GetCursorPos(&pt); - m_mX=pt.x-rc.left-GetSystemMetrics(SM_CXDLGFRAME); - m_mY=pt.y-rc.top-(GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION)); - - err=m_DIDMouse->Acquire(); - if (err!=DI_OK) - return false; - - err=m_DIDKeyboard->Acquire(); - if (err!=DI_OK) - return false; -#endif - return true; -} +RMInput::RMInput() { + _clampMouse = false; + _mousePos.Set(0, 0); + _leftButton = _rightButton = false;; -void RMInput::Unacquire(void) { -#ifdef REFACTOR_ME - if (m_DIDMouse!=NULL) - m_DIDMouse->Unacquire(); - - if (m_DIDKeyboard!=NULL) - m_DIDKeyboard->Unacquire(); -#endif + _leftClickMouse = _leftReleaseMouse = false; + _rightClickMouse = _rightReleaseMouse = false; } +RMInput::~RMInput() { -void RMInput::GDIControl(bool bCon) { -#ifdef REFACTOR_ME - if (bCon) { - Unacquire(); - ShowCursor(true); - } else { - ShowCursor(false); - Acquire(); - } -#endif } void RMInput::Poll(void) { -#ifdef REFACTOR_ME - HRESULT err; - bool mLastLeft, mLastRight; - - mLastLeft=MouseLeft(); - mLastRight=MouseRight(); - m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; - - // Legge lo stato del mouse - while (1) { - ZeroMemory(&m_mState,sizeof(m_mState)); - err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); - if (err==DI_OK) + _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; + + // Get pending events + while (g_system->getEventManager()->pollEvent(_event)) { + switch (_event.type) { + case Common::EVENT_MOUSEMOVE: + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONDOWN: + case Common::EVENT_RBUTTONUP: + _mousePos.Set(_event.mouse.x, _event.mouse.y); + + if (_event.type == Common::EVENT_LBUTTONDOWN) { + _leftButton = true; + _leftClickMouse = true; + } else if (_event.type == Common::EVENT_LBUTTONUP) { + _leftButton = false; + _leftReleaseMouse = true; + } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + _rightButton = true; + _rightClickMouse = true; + } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + _rightButton = false; + _rightReleaseMouse = true; + } else + continue; + + // Since a mouse button has changed, don't do any further event processing this frame + return; + + default: break; - else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) { - ZeroMemory(&m_mState,sizeof(m_mState)); - // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere - if (!Acquire()) - return; } - else - break; - } - - // Aggiorna le coordinate del mouse - m_mX+=m_mState.lX; - m_mY+=m_mState.lY; - - // Clamp dei valori sui bordi della finestra - if (m_bClampMouse) { - if (m_mX<0) m_mX=0; - if (m_mY<0) m_mY=0; - if (m_mX>=640) m_mX=639; - if (m_mY>=480) m_mY=479; - } - - // Controlla se e' cambiato lo stato dei bottoni - if (mLastLeft && !MouseLeft()) - m_bLeftReleaseMouse=true; - - if (!mLastLeft && MouseLeft()) - m_bLeftClickMouse=true; - - if (mLastRight && !MouseRight()) - m_bRightReleaseMouse=true; - - if (!mLastRight && MouseRight()) - m_bRightClickMouse=true; -#endif + } } - -RMInput::RMInput() { - m_bClampMouse = false; -} - -RMInput::~RMInput() { - -} - -void RMInput::Init(/*HINSTANCE hInst*/) { -#ifdef REFACTOR_ME - DIInit(hInst); -#ifdef STARTFULLSCREEN - SwitchFullscreen(true); -#endif - Acquire(); -#endif +void RMInput::Init() { } void RMInput::Close(void) { - Unacquire(); - DIClose(); } - bool RMInput::MouseLeft() { - return false; -#ifdef REFACTOR_ME - return (m_mState.rgbButtons[0] & 0x80); -#endif + return _leftButton; } bool RMInput::MouseRight() { - return false; -#ifdef REFACTOR_ME - return (m_mState.rgbButtons[1] & 0x80); -#endif + return _rightButton; } } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index bff6dcd396..dce35141c5 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -48,25 +48,23 @@ #ifndef TONY_INPUT_H #define TONY_INPUT_H +#include "common/events.h" #include "tony/utils.h" namespace Tony { class RMInput { private: -// LPDIRECTINPUT m_DI; -// LPDIRECTINPUTDEVICE m_DIDKeyboard, m_DIDMouse; + Common::Event _event; + RMPoint _mousePos; // DIMOUSESTATE m_mState; - int m_mX, m_mY; - bool m_bClampMouse; + bool _clampMouse; + bool _leftButton, _rightButton; - bool m_bLeftClickMouse, m_bLeftReleaseMouse, m_bRightClickMouse, m_bRightReleaseMouse; + bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse; private: - // Inizializza DirectInput - void DIInit(/*uint32 hInst*/); - // Deinizializza DirectInput void DIClose(void); @@ -83,29 +81,20 @@ public: // Polling (must be performed once per frame) void Poll(void); - // Aquire the DirectInput device - bool Acquire(void); - - // Deacquires the device - void Unacquire(void); - // Reading of the mouse - RMPoint MousePos() { return RMPoint(m_mX, m_mY); } + RMPoint MousePos() { return _mousePos; } // Current status of the mouse buttons bool MouseLeft(); bool MouseRight(); // Events of mouse clicks - bool MouseLeftClicked() { return m_bLeftClickMouse; } - bool MouseRightClicked() { return m_bRightClickMouse; } - bool MouseBothClicked() { return m_bLeftClickMouse&&m_bRightClickMouse; } - bool MouseLeftReleased() { return m_bLeftReleaseMouse; } - bool MouseRightReleased() { return m_bRightReleaseMouse; } - bool MouseBothReleased() { return m_bLeftReleaseMouse&&m_bRightReleaseMouse; } - - // Warns when changing from full screen to windowed - void SwitchFullscreen(bool bFull); + bool MouseLeftClicked() { return _leftClickMouse; } + bool MouseRightClicked() { return _rightClickMouse; } + bool MouseBothClicked() { return _leftClickMouse && _rightClickMouse; } + bool MouseLeftReleased() { return _leftReleaseMouse; } + bool MouseRightReleased() { return _rightReleaseMouse; } + bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } // Warns when we are in the GDI loop void GDIControl(bool bCon); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 851de7cb0c..9000693292 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -2202,7 +2202,6 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { bool mpalStartIdlePoll(int nLoc) { uint32 i; - uint32 dwId; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) if (nPollingLocations[i] == (uint32)nLoc) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ab6592342d..01d0cf9add 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -390,10 +390,6 @@ void TonyEngine::Play(void) { g_system->delayMillis(50); - Common::Event evt; - while (g_system->getEventManager()->pollEvent(evt)) - ; - // Call any scheduled processes _scheduler.schedule(); -- cgit v1.2.3 From 156d8cdb733fe03688da9e2e9844b722681bed7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 21:24:55 +1000 Subject: TONY: Bugfix for waitForSingleObject, and added action process debug information --- engines/tony/custom.cpp | 14 +++++++------- engines/tony/custom.h | 16 +++++++++------- engines/tony/mpal/mpal.cpp | 18 ++++++++++++++++-- engines/tony/mpal/mpal.h | 3 ++- engines/tony/sched.cpp | 2 +- engines/tony/tony.cpp | 10 ++++++++-- engines/tony/tony.h | 1 + 7 files changed, 44 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 2683634012..dadc84e606 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1680,7 +1680,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { - h=mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); + h = mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); if (h!=INVALID_HANDLE_VALUE) WaitForSingleObject(h,INFINITE); } @@ -1724,7 +1724,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg g_system->unlockMutex(vdb); } - string=mpalQueryDialogPeriod(nMsg); + string = mpalQueryDialogPeriod(nMsg); if (nPers == 0) { text = new RMTextDialog; @@ -1847,7 +1847,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - h=mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); if (h!=INVALID_HANDLE_VALUE) WaitForSingleObject(h,INFINITE); @@ -1872,7 +1872,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } -// @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!! +// @@@@ This cannot be skipped!!!!!!!!!!!!!!!!!!! DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { int nChoice; @@ -1888,9 +1888,9 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr mpalQueryDoDialogU32(nDialog, nStartGroup); // Aspetta che una scelta si presenti - while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) { + while ((nChoice = mpalQueryDialogWaitForChoice()) != -1) { // Si fa dare la lista di opzioni e le conta - sl=mpalQueryDialogSelectList(nChoice); + sl = mpalQueryDialogSelectList(nChoice); for (num = 0; sl[num] != 0; num++) ; @@ -1906,7 +1906,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr dc.SetNumChoices(num); // Scrive tutte le possibili opzioni - for (i = 0;i < num; i++) { + for (i = 0; i < num; i++) { string = mpalQueryDialogPeriod(sl[i]); assert(string != NULL); dc.AddChoice(string); diff --git a/engines/tony/custom.h b/engines/tony/custom.h index a9f4ac2aab..4b9701cec4 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -49,6 +49,7 @@ #ifndef TONY_CUSTOM_H #define TONY_CUSTOM_H +#include "common/str.h" #include "tony/mpal/mpal.h" namespace Tony { @@ -70,18 +71,19 @@ typedef uint32 HWND; static void AssignError(int num) { \ error("Custom function %u has been already assigned!", num); \ } \ - void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap) \ + void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap) \ { -#define END_CUSTOM_FUNCTION_MAP() \ +#define END_CUSTOM_FUNCTION_MAP() \ } -#define ASSIGN(num, func) \ - if (lpMap[num] != NULL) \ - AssignError(num); \ - lpMap[num] = func; +#define ASSIGN(num, func) \ + if (lpMap[num] != NULL) \ + AssignError(num); \ + lpMap[num] = func; \ + lpStrMap[num] = #func; class RMTony; class RMPointer; @@ -90,7 +92,7 @@ class RMLocation; class RMInventory; class RMInput; -void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap); +void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap); void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); #endif diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 9000693292..26cbf3652d 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -102,7 +102,8 @@ static byte * lpMpcImage; LPITEMIRQFUNCTION lpiifCustom=NULL; -LPLPCUSTOMFUNCTION lplpFunctions=NULL; +LPLPCUSTOMFUNCTION lplpFunctions = NULL; +Common::String * lplpFunctionStrings = NULL; uint16 nObjs; uint16 nVars; @@ -959,6 +960,12 @@ void ActionThread(CORO_PARAM, const void *param) { if (item->Command[_ctx->k].type == 1) { // Custom function + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", + _vm->_scheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, + item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 + ); + CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf], item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, @@ -968,6 +975,9 @@ void ActionThread(CORO_PARAM, const void *param) { ); } else if (item->Command[_ctx->k].type == 2) { // Variable assign + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", + _vm->_scheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); + LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); UnlockVar(); @@ -981,6 +991,8 @@ void ActionThread(CORO_PARAM, const void *param) { GlobalFree(item); + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", _vm->_scheduler.getCurrentPID()); + CORO_KILL_SELF(); CORO_END_CODE; @@ -1705,7 +1717,8 @@ bool DoSelection(uint32 i, uint32 dwData) { * \****************************************************************************/ -bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { +bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, + LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) { Common::File hMpc; byte buf[5]; uint32 nBytesRead; @@ -1719,6 +1732,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUST /* Si salva l'array delle funzioni custom */ lplpFunctions = lplpcfArray; + lplpFunctionStrings = lpcfStrings; /* Apre il file MPC in lettura */ if (!hMpc.open(lpszMpcFileName)) diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 9da963d39e..c9f8625744 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -119,6 +119,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "common/str.h" #include "tony/coroutine.h" namespace Tony { @@ -602,7 +603,7 @@ extern "C" { \****************************************************************************/ bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, - LPLPCUSTOMFUNCTION lplpcfArray); + LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 421f4d1ac7..f8a7fd2538 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -314,7 +314,7 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *exp while (g_system->getMillis() < _ctx->endTime) { // Check to see if a process with the given Id exists _ctx->pProc = active->pNext; - while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid)) + while ((_ctx->pProc != NULL) && (_ctx->pProc->pid != pid)) _ctx->pProc = _ctx->pProc->pNext; if (_ctx->pProc == NULL) { diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 01d0cf9add..a4a478d40d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/file.h" #include "tony/tony.h" @@ -37,6 +38,11 @@ TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { _vm = this; + + DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); + DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); + DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); + DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); } TonyEngine::~TonyEngine() { @@ -84,7 +90,7 @@ Common::ErrorCode TonyEngine::Init() { return Common::kReadingFailed; f.close(); - if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList)) + if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList, FuncListStrings)) return Common::kUnknownError; // Initialise the update resources @@ -133,7 +139,7 @@ Common::ErrorCode TonyEngine::Init() { } void TonyEngine::InitCustomFunctionMap() { - INIT_CUSTOM_FUNCTION(FuncList); + INIT_CUSTOM_FUNCTION(FuncList, FuncListStrings); } /** diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 1eafe54afb..3c7e8fe6b2 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -88,6 +88,7 @@ protected: virtual bool hasFeature(EngineFeature f) const; public: LPCUSTOMFUNCTION FuncList[300]; + Common::String FuncListStrings[300]; Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; -- cgit v1.2.3 From 0b8974ec4ab37ef056ac50c098d3fe8045ec172b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 23:51:11 +1000 Subject: TONY: Beginnings of converting dialog processes to coroutines --- engines/tony/custom.cpp | 70 +++--- engines/tony/mpal/mpal.cpp | 585 ++++++++++++++++++++++---------------------- engines/tony/mpal/mpal.h | 8 +- engines/tony/mpal/stubs.cpp | 2 + engines/tony/sched.cpp | 3 + 5 files changed, 335 insertions(+), 333 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index dadc84e606..e7878c5a5d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1699,7 +1699,7 @@ int curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { LPSTR string; - RMTextDialog* text; + RMTextDialog *text; int parm; HANDLE h; bool bIsBack = false; @@ -1875,70 +1875,80 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // @@@@ This cannot be skipped!!!!!!!!!!!!!!!!!!! DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { - int nChoice; - uint32 *sl; - int i,num; - char* string; - RMDialogChoice dc; - int sel; + CORO_BEGIN_CONTEXT; + uint32 nChoice; + uint32 *sl; + int i, num; + char *string; + RMDialogChoice dc; + int sel; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); curDialog = nDialog; - // Chiama l'MPAL per iniziare il dialogo + // Call MPAL to start the dialog mpalQueryDoDialogU32(nDialog, nStartGroup); - // Aspetta che una scelta si presenti - while ((nChoice = mpalQueryDialogWaitForChoice()) != -1) { + // Wait until a choice is selected + mpalQueryDialogWaitForChoice(&_ctx->nChoice); + while (_ctx->nChoice != -1) { // Si fa dare la lista di opzioni e le conta - sl = mpalQueryDialogSelectList(nChoice); - for (num = 0; sl[num] != 0; num++) + _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); + for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) ; // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta - if (num == 1) { - mpalQueryDialogSelectionU32(nChoice, sl[0]); - GlobalFree(sl); + if (_ctx->num == 1) { + mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[0]); + GlobalFree(_ctx->sl); continue; } // Crea una scelta per il dialogo - dc.Init(); - dc.SetNumChoices(num); + _ctx->dc.Init(); + _ctx->dc.SetNumChoices(_ctx->num); // Scrive tutte le possibili opzioni - for (i = 0; i < num; i++) { - string = mpalQueryDialogPeriod(sl[i]); - assert(string != NULL); - dc.AddChoice(string); - GlobalFree(string); + for (_ctx->i = 0; _ctx->i < _ctx->num; _ctx->i++) { + _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); + assert(_ctx->string != NULL); + _ctx->dc.AddChoice(_ctx->string); + GlobalFree(_ctx->string); } // Attiva l'oggetto - LinkGraphicTask(&dc); - dc.Show(); + LinkGraphicTask(&_ctx->dc); + _ctx->dc.Show(); // Disegna il puntatore Pointer->SetSpecialPointer(Pointer->PTR_NONE); MainShowMouse(); - while (!(Input->MouseLeftClicked() && ((sel = dc.GetSelection()) != -1))) { + while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { WaitFrame(); Freeze(); - dc.DoFrame(Input->MousePos()); + _ctx->dc.DoFrame(Input->MousePos()); Unfreeze(); } // Nascondi il puntatore MainHideMouse(); - dc.Hide(); - mpalQueryDialogSelectionU32(nChoice, sl[sel]); + _ctx->dc.Hide(); + mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta - dc.Close(); + _ctx->dc.Close(); + + GlobalFree(_ctx->sl); - GlobalFree(sl); + // Wait for the next choice to be made + mpalQueryDialogWaitForChoice(&_ctx->nChoice); } + + CORO_END_CODE; } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 26cbf3652d..592c4788df 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1335,93 +1335,101 @@ void LocationPollThread(CORO_PARAM, const void *param) { * \****************************************************************************/ -void PASCAL ShutUpDialogThread(HANDLE hThread) { - WaitForSingleObject(hThread, INFINITE); +void ShutUpDialogThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 pid = *(const uint32 *)param; + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); bExecutingDialog = false; nExecutingDialog = 0; nExecutingChoice = 0; SetEvent(hAskChoice); - ExitThread(1); -// _endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } +void DoChoice(CORO_PARAM, uint32 nChoice); -/****************************************************************************\ -* -* Function: void GroupThread(uint32 nGroup); -* -* Description: Esegue un gruppo del dialogo corrente. Puo' essere lo -* starting point di un thread. -* -* Input: uint32 nGroup Numero del gruppo da eseguire -* -\****************************************************************************/ -void DoChoice(uint32 nChoice); +/** + * Executes a group of the current dialog. Can 'be the Starting point of a process. + * @parm nGroup Number of the group to perform + */ +void GroupThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + LPMPALDIALOG dialog; + int i, j, k; + int type; + CORO_END_CONTEXT(_ctx); -void PASCAL GroupThread(uint32 nGroup) { - LPMPALDIALOG dialog; - int i, j, k; + uint32 nGroup = *(const uint32 *)param; + + CORO_BEGIN_CODE(_ctx); - /* Locka i dialoghi */ + // Lock the _ctx->dialog LockDialogs(); - /* Trova il puntatore al dialogo corrente */ - dialog = lpmdDialogs+nExecutingDialog; - - /* Cerca il gruppo richiesto all'interno del dialogo */ - for (i = 0; dialog->Group[i].num != 0; i++) - if (dialog->Group[i].num==nGroup) { - /* Cicla eseguendo i comandi del gruppo */ - for (j = 0; j < dialog->Group[i].nCmds; j++) { - k=dialog->Group[i].CmdNum[j]; - - switch (dialog->Command[k].type) { - /* Funzione custom: la richiama */ - case 1: - // FIXME: Convert to co-routine - lplpFunctions[dialog->Command[k].nCf]( - nullContext, - dialog->Command[k].arg1, - dialog->Command[k].arg2, - dialog->Command[k].arg3, - dialog->Command[k].arg4 + // Find the pointer to the current _ctx->dialog + _ctx->dialog = lpmdDialogs + nExecutingDialog; + + // Search inside the group requesting the _ctx->dialog + for (_ctx->i = 0; _ctx->dialog->Group[_ctx->i].num != 0; _ctx->i++) { + if (_ctx->dialog->Group[_ctx->i].num == nGroup) { + // Cycle through executing the commands of the group + for (_ctx->j = 0; _ctx->j < _ctx->dialog->Group[_ctx->i].nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->Group[_ctx->i].CmdNum[_ctx->j]; + + _ctx->type = _ctx->dialog->Command[_ctx->k].type; + if (_ctx->type == 1) { + // Call custom function + CORO_INVOKE_4(lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], + _ctx->dialog->Command[_ctx->k].arg1, + _ctx->dialog->Command[_ctx->k].arg2, + _ctx->dialog->Command[_ctx->k].arg3, + _ctx->dialog->Command[_ctx->k].arg4 ); - break; - /* Variabile: la setta */ - case 2: + } else if (_ctx->type == 2) { + // Set a variable LockVar(); - varSetValue(dialog->Command[k].lpszVarName,EvaluateExpression(dialog->Command[k].expr)); + varSetValue(_ctx->dialog->Command[_ctx->k].lpszVarName, EvaluateExpression(_ctx->dialog->Command[_ctx->k].expr)); UnlockVar(); - break; - - /* DoChoice: richiama la funzione di scelta */ - case 3: - DoChoice((uint32)dialog->Command[k].nChoice); - break; - - default: + + } else if (_ctx->type == 3) { + // DoChoice: call the chosen function + CORO_INVOKE_1(DoChoice, (uint32)_ctx->dialog->Command[_ctx->k].nChoice); + + } else { mpalError = 1; UnlockDialogs(); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; + } } - } - /* Abbiamo eseguito il gruppo. Possiamo uscire alla funzione chiamante. - Se il gruppo era il primo chiamato, allora automaticamente il - thread viene chiuso, altrimenti si ritorno al gruppo chiamante. */ - UnlockDialogs(); - return; + /* The gruop is finished, so we can return to the calling function. + * If the group was the first called, then the process will automatically + * end. Otherwise it returns to the caller method + */ + return; + } } /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ mpalError = 1; UnlockDialogs(); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } @@ -1435,52 +1443,58 @@ void PASCAL GroupThread(uint32 nGroup) { * \****************************************************************************/ -void DoChoice(uint32 nChoice) { - LPMPALDIALOG dialog; - int i,j,k; +void DoChoice(CORO_PARAM, uint32 nChoice) { + CORO_BEGIN_CONTEXT; + LPMPALDIALOG dialog; + int i, j, k; + uint32 nGroup; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - /* Locka i dialoghi */ + /* Locka _ctx->i dialoghi */ LockDialogs(); /* Trova il puntatore al dialogo corrente */ - dialog=lpmdDialogs+nExecutingDialog; + _ctx->dialog=lpmdDialogs+nExecutingDialog; /* Cerca la scelta richiesta tra quelle nel dialogo */ - for (i = 0; dialog->Choice[i].nChoice != 0; i++) - if (dialog->Choice[i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) + if (_ctx->dialog->Choice[_ctx->i].nChoice == nChoice) break; /* Se non l'ha trovata, esce con errore */ - if (dialog->Choice[i].nChoice == 0) { + if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { /* Se siamo qui, non abbiamo trovato la choice richiesta */ mpalError = 1; UnlockDialogs(); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; } /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella variabile globale */ - nExecutingChoice = i; + nExecutingChoice = _ctx->i; while (1) { - nExecutingChoice = i; + nExecutingChoice = _ctx->i; - k = 0; + _ctx->k = 0; /* Calcoliamo le when expression di ciascun select, per vedere se sono attivi o disattivi */ - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].when == NULL) { - dialog->Choice[i].Select[j].curActive = 1; - k++; - } else if (EvaluateExpression(dialog->Choice[i].Select[j].when)) { - dialog->Choice[i].Select[j].curActive = 1; - k++; + for (_ctx->j = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].dwData != 0; _ctx->j++) + if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when == NULL) { + _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + _ctx->k++; + } else if (EvaluateExpression(_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when)) { + _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + _ctx->k++; } else - dialog->Choice[i].Select[j].curActive = 0; + _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 0; /* Se non ci sono scelte attivate, la scelta e' finita */ - if (k == 0) { + if (_ctx->k == 0) { UnlockDialogs(); break; } @@ -1491,31 +1505,36 @@ void DoChoice(uint32 nChoice) { SetEvent(hAskChoice); WaitForSingleObject(hDoneChoice, INFINITE); - /* Ora che la scelta e' stata effettuata, possiamo eseguire i gruppi + /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ - j=nSelectedChoice; - for (k = 0; dialog->Choice[i].Select[j].wPlayGroup[k] != 0; k++) - GroupThread(dialog->Choice[i].Select[j].wPlayGroup[k]); + _ctx->j = nSelectedChoice; + for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; + CORO_INVOKE_1(GroupThread, &_ctx->nGroup); + } /* Controllo sugli attributi */ - if (dialog->Choice[i].Select[j].attr & (1 << 0)) { + if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 0)) { /* Bit 0 settato: fine della scelta */ UnlockDialogs(); break; } - if (dialog->Choice[i].Select[j].attr & (1 << 1)) { + if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 1)) { /* Bit 1 settato: fine del dialogo */ UnlockDialogs(); - ExitThread(1); -// _endthread(); + + CORO_KILL_SELF(); + return; } /* Fine della scelta senza attributi: bisogna rifarla */ } - /* Se siamo qui, abbiamo trovato un end choice. Ritorna al gruppo chiamante */ + // If we're here, we found an end choice. Return to the caller group return; + + CORO_END_CODE; } @@ -1605,57 +1624,40 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { return INVALID_HANDLE_VALUE; } +/** + * Shows a dialog in a separate process. + * + * @param nDlgOrd The index of the dialog in the dialog list + * @param nGroup Number of the group to perform + * @returns The process Id of the process running the dialog + * or INVALID_HANDLE_VALUE on error + * @remarks The dialogue runs in a thread created on purpose, + * so that must inform through an event and when 'necessary to you make a choice. + * The data on the choices may be obtained through various queries. + */ +static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { + uint32 h; -/****************************************************************************\ -* -* Function: HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup); -* -* Description: Esegue un dialogo in un thread -* -* Input: uint32 nDlgOrd Indice del dialogo da eseguire -* all'interno dell'array di strutture -* dei dialoghi -* uint32 nGroup Numero del gruppo da eseguire -* -* Return: Handle del thread che sta eseguendo il dialogo, o -* INVALID_HANDLE_VALUE in caso di errore -* -* Note: Il dialogo viene eseguito in un thread creato apposta, che -* deve informa tramite un evento quando e' necessario far -* fare una scelta all'utente. I dati sulle scelte possono -* essere richiesti tramite le varie query. -* -\****************************************************************************/ - -static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { -// LPMPALDIALOG dialog=lpmdDialogs+nDlgOrd; - uint32 dwId; - HANDLE h; - - /* Si ricorda nella variabile globale qual e' il dialogo in esecuzione */ + // Store the running dialog in a global variable nExecutingDialog = nDlgOrd; - /* Attiva la flag per indicare che c'e' un dialogo in esecuzione */ + // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; ResetEvent(hAskChoice); ResetEvent(hDoneChoice); - /* Crea un thread in cui esegue un gruppo del dialogo */ + // Create a thread that performs the dialogue group - // !!! Nuova gestione dei thread - if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)GroupThread, (void *)nGroup, 0, &dwId)) == NULL) - // if ((h=(void*)_beginthread(GroupThread, 10240,(void *)nGroup))==(void*)-1) - return INVALID_HANDLE_VALUE; + // Create the process + if ((h = _vm->_scheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) + return 0; - /* Crea un thread che attende la fine del dialogo e rimette a posto le - variabili globali */ - // !!! Nuova gestione dei thread - if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h, 0, &dwId) == NULL) { - //if ((h=(void*)_beginthread(ShutUpDialogThread, 10240,(void *)h))==(void*)-1) - TerminateThread(h, 0); - CloseHandle(h); - return INVALID_HANDLE_VALUE; + // Create a thread that waits until the end of the dialog process, and will restore the global variables + if (_vm->_scheduler.createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { + // Something went wrong, so kill the previously started dialog process + _vm->_scheduler.killMatchingProcess(h); + return 0; } return h; @@ -1893,243 +1895,230 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, #define GETARG(type) va_arg(v,type) -uint32 mpalQuery(uint16 wQueryType, ...) { - uint32 dwRet = 0; - int x, y, z; - char *n; - va_list v; - Common::String buf; +void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { + CORO_BEGIN_CONTEXT; + int x, y, z; + char *n; + Common::String buf; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); mpalError = OK; - va_start(v, wQueryType); - switch (wQueryType) { - /* - * uint32 mpalQuery(MPQ_VERSION); - */ - case MPQ_VERSION: - dwRet = HEX_VERSION; - break; + if (wQueryType == MPQ_VERSION) { + /* + * uint32 mpalQuery(MPQ_VERSION); + */ + *dwRet = HEX_VERSION; - /* - * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); - */ - case MPQ_GLOBAL_VAR: + } else if (wQueryType == MPQ_GLOBAL_VAR) { + /* + * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); + */ LockVar(); - dwRet = (uint32)varGetValue(GETARG(char *)); + *dwRet = (uint32)varGetValue(GETARG(char *)); UnlockVar(); - break; - /* - * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); - */ - case MPQ_MESSAGE: + } else if (wQueryType == MPQ_MESSAGE) { + /* + * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); + */ LockMsg(); - dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + *dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); UnlockMsg(); - break; - - /* - * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); - */ - case MPQ_ITEM_PATTERN: + + } else if (wQueryType == MPQ_ITEM_PATTERN) { + /* + * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); + */ LockVar(); - buf = Common::String::format("Pattern.%u", GETARG(uint32)); - dwRet = (uint32)varGetValue(buf.c_str()); + _ctx->buf = Common::String::format("Pattern.%u", GETARG(uint32)); + *dwRet = (uint32)varGetValue(_ctx->buf.c_str()); UnlockVar(); - break; - - /* - * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); - */ - case MPQ_LOCATION_SIZE: + + } else if (wQueryType == MPQ_LOCATION_SIZE) { + /* + * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); + */ LockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); - if (x != -1) { - if (y == MPQ_X) - dwRet = lpmlLocations[x].dwXlen; - else if (y == MPQ_Y) - dwRet = lpmlLocations[x].dwYlen; + _ctx->x = locGetOrderFromNum(GETARG(uint32)); + _ctx->y = GETARG(uint32); + if (_ctx->x != -1) { + if (_ctx->y == MPQ_X) + *dwRet = lpmlLocations[_ctx->x].dwXlen; + else if (_ctx->y == MPQ_Y) + *dwRet = lpmlLocations[_ctx->x].dwYlen; else mpalError = 1; } else mpalError = 1; UnlockLocations(); - break; - - /* - * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); - */ - case MPQ_LOCATION_IMAGE: + + } else if (wQueryType == MPQ_LOCATION_IMAGE) { + /* + * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); + */ LockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); - dwRet = (uint32)resLoad(lpmlLocations[x].dwPicRes); + _ctx->x = locGetOrderFromNum(GETARG(uint32)); + *dwRet = (uint32)resLoad(lpmlLocations[_ctx->x].dwPicRes); UnlockLocations(); - break; - /* - * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); - */ - case MPQ_RESOURCE: - dwRet = (uint32)resLoad(GETARG(uint32)); - break; + } else if (wQueryType == MPQ_RESOURCE) { + /* + * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); + */ + *dwRet = (uint32)resLoad(GETARG(uint32)); - /* - * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); - */ - case MPQ_ITEM_LIST: + } else if (wQueryType == MPQ_ITEM_LIST) { + /* + * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); + */ LockVar(); - dwRet = (uint32)GetItemList(GETARG(uint32)); + *dwRet = (uint32)GetItemList(GETARG(uint32)); LockVar(); - break; - /* - * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); - */ - case MPQ_ITEM_DATA: + } else if (wQueryType == MPQ_ITEM_DATA) { + /* + * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + */ LockItems(); - dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); + *dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); UnlockItems(); - break; - /* - * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); - */ - case MPQ_ITEM_IS_ACTIVE: + } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { + /* + * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); + */ LockVar(); - x = GETARG(uint32); - buf = Common::String::format("Status.%u", x); - if (varGetValue(buf.c_str()) <= 0) - dwRet = (uint32)false; + _ctx->x = GETARG(uint32); + _ctx->buf = Common::String::format("Status.%u", _ctx->x); + if (varGetValue(_ctx->buf.c_str()) <= 0) + *dwRet = (uint32)false; else - dwRet = (uint32)true; + *dwRet = (uint32)true; UnlockVar(); - break; - - /* - * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); - */ - case MPQ_ITEM_NAME: + } else if (wQueryType == MPQ_ITEM_NAME) { + /* + * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); + */ LockVar(); - x = GETARG(uint32); - n=GETARG(char *); - buf = Common::String::format("Status.%u", x); - if (varGetValue(buf.c_str()) <= 0) - n[0]='\0'; + _ctx->x = GETARG(uint32); + _ctx->n = GETARG(char *); + _ctx->buf = Common::String::format("Status.%u", _ctx->x); + if (varGetValue(_ctx->buf.c_str()) <= 0) + _ctx->n[0]='\0'; else { LockItems(); - y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(lpmiItems+y)->lpszDescribe, MAX_DESCRIBE_SIZE); + _ctx->y = itemGetOrderFromNum(_ctx->x); + CopyMemory(_ctx->n, (char *)(lpmiItems+_ctx->y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } UnlockVar(); - break; - - /* - * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); - */ - case MPQ_DIALOG_PERIOD: + } else if (wQueryType == MPQ_DIALOG_PERIOD) { + /* + * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + */ LockDialogs(); - y = GETARG(uint32); - dwRet = (uint32)DuplicateDialogPeriod(y); + _ctx->y = GETARG(uint32); + *dwRet = (uint32)DuplicateDialogPeriod(_ctx->y); UnlockDialogs(); - break; - - /* - * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); - */ - case MPQ_DIALOG_WAITFORCHOICE: + } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ WaitForSingleObject(hAskChoice, INFINITE); ResetEvent(hAskChoice); if (bExecutingDialog) - dwRet = (uint32)nExecutingChoice; + *dwRet = (uint32)nExecutingChoice; else - dwRet = (uint32)((int)-1); - break; - + *dwRet = (uint32)((int)-1); - /* - * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); - */ - case MPQ_DIALOG_SELECTLIST: + } else if (wQueryType == MPQ_DIALOG_SELECTLIST) { + /* + * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); + */ LockDialogs(); - dwRet = (uint32)GetSelectList(GETARG(uint32)); + *dwRet = (uint32)GetSelectList(GETARG(uint32)); UnlockDialogs(); break; - /* - * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); - */ - case MPQ_DIALOG_SELECTION: + } else if (wQueryType == MPQ_DIALOG_SELECTION) { + /* + * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); + */ LockDialogs(); - x = GETARG(uint32); - y = GETARG(uint32); - dwRet = (uint32)DoSelection(x,y); + _ctx->x = GETARG(uint32); + _ctx->y = GETARG(uint32); + *dwRet = (uint32)DoSelection(_ctx->x,_ctx->y); UnlockDialogs(); - break; - - - /* - * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); - */ - case MPQ_DO_ACTION: - /* - if (bExecutingAction) - { - dwRet = (uint32)INVALID_HANDLE_VALUE; - break; - } - */ + } else if (wQueryType == MPQ_DO_ACTION) { + /* + * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); + */ LockItems(); LockVar(); - x = GETARG(uint32); - z = GETARG(uint32); - y = itemGetOrderFromNum(z); - if (y!=-1) { - dwRet = (uint32)DoAction(x, y, GETARG(uint32)); + _ctx->x = GETARG(uint32); + _ctx->z = GETARG(uint32); + _ctx->y = itemGetOrderFromNum(_ctx->z); + if (_ctx->y!=-1) { + *dwRet = (uint32)DoAction(_ctx->x, _ctx->y, GETARG(uint32)); } else { - dwRet = (uint32)INVALID_HANDLE_VALUE; + *dwRet = (uint32)INVALID_HANDLE_VALUE; mpalError = 1; } UnlockVar(); UnlockItems(); - break; - /* - * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); - */ - case MPQ_DO_DIALOG: - if (bExecutingDialog) - break; + } else if (wQueryType == MPQ_DO_DIALOG) { + /* + * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); + */ + if (!bExecutingDialog) { + LockDialogs(); - LockDialogs(); - - x = dialogGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); - dwRet = (uint32)DoDialog(x, y); - UnlockDialogs(); - break; - - /* - * DEFAULT -> ERROR - */ - default: + _ctx->x = dialogGetOrderFromNum(GETARG(uint32)); + _ctx->y = GETARG(uint32); + *dwRet = DoDialog(_ctx->x, _ctx->y); + UnlockDialogs(); + } + } else { + /* + * DEFAULT -> ERROR + */ mpalError = 1; - break; } + CORO_END_CODE; +} + +uint32 mpalQuery(uint16 wQueryType, ...) { + uint32 dwRet; + va_list v; + va_start(v, wQueryType); + + mpalQueryInner(nullContext, wQueryType, &dwRet, v); + va_end(v); return dwRet; } +void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...) { + va_list v; + va_start(v, wQueryType); + + mpalQueryInner(coroParam, wQueryType, dwRet, v); + + va_end(v); +} + /****************************************************************************\ * diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index c9f8625744..5517a6518c 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -474,10 +474,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * \****************************************************************************/ -#define mpalQueryDialogWaitForChoice() \ - (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) - - +#define mpalQueryDialogWaitForChoice(dwRet) \ + CORO_INVOKE_2(mpalQueryCoro, dwRet, MPQ_DIALOG_WAITFORCHOICE) /****************************************************************************\ * @@ -627,7 +625,7 @@ bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, uint32 EXPORT mpalQuery(uint16 wQueryType, ...); - +void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...); /****************************************************************************\ * diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 9d4a87d61c..0fc01d4d07 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -80,10 +80,12 @@ void Sleep(uint32 time) { } int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime) { + warning("TODO: Old style WaitForSingleObject"); return 0; } uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds) { + warning("TODO: Old style WaitForMultipleObjects"); return 0; } diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index f8a7fd2538..41531bf225 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -299,6 +299,9 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { * @param expired Set to true if delay period expired */ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *expired) { + if (!pCurrent) + error("Called Scheduler::waitForSingleObject from the main process"); + CORO_BEGIN_CONTEXT; uint32 endTime; PROCESS *pProc; -- cgit v1.2.3 From 8527302057052e784c3ea32ca8eebb0220bf15e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 May 2012 08:25:33 +1000 Subject: TONY: Added support for threading events to scheduler, converted more procs to coroutines --- engines/tony/custom.cpp | 610 +++++++++++++++++++++++++++++--------------- engines/tony/loc.cpp | 31 ++- engines/tony/loc.h | 5 +- engines/tony/mpal/mpal.cpp | 27 +- engines/tony/mpal/stubs.cpp | 4 + engines/tony/sched.cpp | 182 ++++++++++++- engines/tony/sched.h | 25 +- engines/tony/tonychar.cpp | 194 +++++++++----- engines/tony/tonychar.h | 18 +- 9 files changed, 771 insertions(+), 325 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e7878c5a5d..800b5d8d50 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -370,50 +370,62 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { - RMMessage msg(dwMessage); - int i; - int curOffset = 0; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + int i; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curOffset = 0; if (bSkipIdle) return; - if (!msg.IsValid()) + _ctx->msg = new RMMessage(dwMessage); + if (!_ctx->msg->IsValid()) { + delete _ctx->msg; return; + } - VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); - FPSFX *voice = NULL; - if (curVoc) { + _ctx->curVoc = SearchVoiceHeader(0, dwMessage); + _ctx->voice = NULL; + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima - curOffset = curVoc->offset; + _ctx->curOffset = _ctx->curVoc->offset; // PRIMA VOLTA PREALLOCA g_system->lockMutex(vdb); - //fseek(_vm->m_vdbFP, curOffset, SEEK_SET); - _vm->_vdbFP.seek(curOffset); - _vm->_theSound.CreateSfx(&voice); - voice->LoadVoiceFromVDB(_vm->_vdbFP); -// curOffset = ftell(_vm->m_vdbFP); - curOffset = _vm->_vdbFP.pos(); - - voice->SetLoop(false); + //fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + _vm->_vdbFP.seek(_ctx->curOffset); + _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); +// _ctx->curOffset = ftell(_vm->m_vdbFP); + _ctx->curOffset = _vm->_vdbFP.pos(); + + _ctx->voice->SetLoop(false); g_system->unlockMutex(vdb); } if (nTonyNextTalkType != Tony->TALK_NORMAL) { - Tony->StartTalk(nTonyNextTalkType); + CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); + if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } else { - if (msg.NumPeriods() > 1) - Tony->StartTalk(Tony->TALK_FIANCHI); + if (_ctx->msg->NumPeriods() > 1) + CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_FIANCHI); else - Tony->StartTalk(Tony->TALK_NORMAL); + CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); } if (curBackText) curBackText->Hide(); bTonyIsSpeaking = true; - for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { RMTextDialog text; text.SetInput(Input); @@ -425,7 +437,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX text.SetColor(0,255,0); // Scrive il testo - text.WriteText(msg[i],0); + text.WriteText((*_ctx->msg)[_ctx->i],0); // Setta la posizione if (nX == 0 && nY == 0) @@ -439,21 +451,21 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Registra il testo LinkGraphicTask(&text); - if (curVoc) { - if (i == 0) { - voice->Play(); - text.SetCustomSkipHandle2(voice->hEndOfBuffer); + if (_ctx->curVoc) { + if (_ctx->i == 0) { + _ctx->voice->Play(); + text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(vdb); - // fseek(_vm->m_vdbFP, curOffset, SEEK_SET); - _vm->_vdbFP.seek(curOffset); - _vm->_theSound.CreateSfx(&voice); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - // curOffset = ftell(_vm->m_vdbFP); - curOffset = _vm->_vdbFP.pos(); - voice->SetLoop(false); - voice->Play(); - text.SetCustomSkipHandle2(voice->hEndOfBuffer); + // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + _vm->_vdbFP.seek(_ctx->curOffset); + _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + // _ctx->curOffset = ftell(_vm->m_vdbFP); + _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->voice->SetLoop(false); + _ctx->voice->Play(); + text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); g_system->unlockMutex(vdb); } } @@ -462,10 +474,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX text.SetCustomSkipHandle(hSkipIdle); text.WaitForEndDisplay(); - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice=NULL; } } @@ -473,7 +485,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (curBackText) curBackText->Show(); - Tony->EndTalk(); + CORO_INVOKE_0(Tony->EndTalk); + delete _ctx->msg; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { @@ -718,134 +733,164 @@ DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint3 EnableGUI(); } -DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) -{ - DisableGUI(); +DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { + DisableGUI(); } -void TonyGenericTake1(uint32 nDirection) { + +void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - Tony->Take(nDirection,0); + Tony->Take(nDirection, 0); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + + CORO_END_CODE; } -void TonyGenericTake2(uint32 nDirection) { +void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - Tony->Take(nDirection,1); + Tony->Take(nDirection, 1); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); Freeze(); Tony->Take(nDirection,2); Unfreeze(); + + CORO_END_CODE; } -void TonyGenericPut1(uint32 nDirection) { +void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - Tony->Put(nDirection,0); + Tony->Put(nDirection, 0); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + + CORO_END_CODE; } -void TonyGenericPut2(uint32 nDirection) { +void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); Tony->Put(nDirection,1); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); Freeze(); Tony->Put(nDirection,2); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake1(0); + TonyGenericTake1(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake1(1); + TonyGenericTake1(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake1(2); + TonyGenericTake1(coroParam, 2); } DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake2(0); + TonyGenericTake2(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake2(1); + TonyGenericTake2(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake2(2); + TonyGenericTake2(coroParam, 2); } - - - - DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut1(0); + TonyGenericPut1(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut1(1); + TonyGenericPut1(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut1(2); + TonyGenericPut1(coroParam, 2); } DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut2(0); + TonyGenericPut2(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut2(1); + TonyGenericPut2(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut2(2); + TonyGenericPut2(coroParam, 2); } - DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { - if (dwParte== 0) + if (dwParte == 0) Tony->SetPattern(Tony->PAT_PERTERRALEFT); else Tony->SetPattern(Tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { - if (dwParte== 0) + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (dwParte == 0) Tony->SetPattern(Tony->PAT_SIRIALZALEFT); else Tony->SetPattern(Tony->PAT_SIRIALZARIGHT); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { @@ -853,10 +898,18 @@ DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + Tony->SetPattern(Tony->PAT_STANDRIGHT); + + CORO_END_CODE; } @@ -951,101 +1004,212 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, u } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONPUPAZZOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONPUPAZZOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONPUPAZZOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCONIGLIOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONCONIGLIOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCONIGLIOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONRICETTASTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONRICETTASTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONRICETTASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCARTESTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONCARTESTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCARTESTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONTACCUINOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONTACCUINOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONTACCUINOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONMEGAFONOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONMEGAFONOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONMEGAFONOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONBARBASTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONBARBASTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONBARBASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_SPAVENTATOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_SPAVENTATOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_SPAVENTATOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; -} + CORO_END_CODE; +} DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -1060,7 +1224,7 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1073,7 +1237,7 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1126,10 +1290,18 @@ DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { - RMItem *item = Loc->GetItemFromCode(nItem); + CORO_BEGIN_CONTEXT; + RMItem *item; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->item = Loc->GetItemFromCode(nItem); - if (!bSkipIdle && item != NULL) - item->WaitForEndPattern(hSkipIdle); + if (!bSkipIdle && _ctx->item != NULL) + CORO_INVOKE_1(_ctx->item->WaitForEndPattern, hSkipIdle); + + CORO_END_CODE; } @@ -1383,106 +1555,119 @@ DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, ui } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { - RMMessage msg(dwMessage); - int i; - RMPoint pt; - RMTextDialog *text; - int curOffset = 0; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + int i; + RMPoint pt; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + CORO_END_CONTEXT(_ctx); - assert(nChar<16); - pt=Character[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(dwMessage); + _ctx->curOffset = 0; + + assert(nChar < 16); + _ctx->pt = Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); if (Character[nChar].starttalkpattern != 0) { Freeze(); Character[nChar].item->SetPattern(Character[nChar].starttalkpattern); Unfreeze(); - Character[nChar].item->WaitForEndPattern(); + + CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); } Freeze(); Character[nChar].item->SetPattern(Character[nChar].talkpattern); Unfreeze(); - VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); - FPSFX *voice = NULL; - if (curVoc) { + _ctx->curVoc = SearchVoiceHeader(0, dwMessage); + _ctx->voice = NULL; + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima -// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); +// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(vdb); - _vm->_vdbFP.seek(curVoc->offset); - curOffset = curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->offset); + _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(vdb); } - for (i = 0; ii = 0; _ctx->i<_ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { if (bIsBack) { - curBackText = text = new RMTextDialogScrolling(Loc); + curBackText = _ctx->text = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) curBackText->Hide(); } else - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - text->SetInput(Input); + _ctx->text->SetInput(Input); // Skipping - text->SetSkipStatus(!bIsBack); + _ctx->text->SetSkipStatus(!bIsBack); // Allineamento - text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); + _ctx->text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); // Scrive il testo - text->WriteText(msg[i],0); + _ctx->text->WriteText((*_ctx->msg)[_ctx->i],0); // Setta la posizione - text->SetPosition(pt); + _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(text); + LinkGraphicTask(_ctx->text); - if (curVoc) { + if (_ctx->curVoc) { g_system->lockMutex(vdb); - _vm->_theSound.CreateSfx(&voice); - _vm->_vdbFP.seek(curOffset); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - voice->SetLoop(false); - if (bIsBack) voice->SetVolume(55); - voice->Play(); - text->SetCustomSkipHandle2(voice->hEndOfBuffer); - curOffset = _vm->_vdbFP.pos(); + _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->SetLoop(false); + if (bIsBack) _ctx->voice->SetVolume(55); + _ctx->voice->Play(); + _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->curOffset = _vm->_vdbFP.pos(); g_system->unlockMutex(vdb); } // Aspetta la fine della visualizzazione - text->SetCustomSkipHandle(hSkipIdle); - text->WaitForEndDisplay(); + _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->WaitForEndDisplay(); - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice=NULL; } curBackText=NULL; - delete text; + delete _ctx->text; } if (Character[nChar].endtalkpattern != 0) { Freeze(); Character[nChar].item->SetPattern(Character[nChar].endtalkpattern); Unfreeze(); - Character[nChar].item->WaitForEndPattern(); + CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); } Freeze(); Character[nChar].item->SetPattern(Character[nChar].standpattern); Unfreeze(); + delete _ctx->msg; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { @@ -1698,97 +1883,104 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes int curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { - LPSTR string; - RMTextDialog *text; - int parm; - HANDLE h; - bool bIsBack = false; + CORO_BEGIN_CONTEXT; + LPSTR string; + RMTextDialog *text; + int parm; + HANDLE h; + bool bIsBack; + VoiceHeader *curVoc; + FPSFX *voice; + RMPoint pt; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->bIsBack = false; // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato // con la SetAlwaysBack if (nPers != 0 && IsMChar[nPers] && MCharacter[nPers].bAlwaysBack) - bIsBack = true; + _ctx->bIsBack = true; - VoiceHeader *curVoc = SearchVoiceHeader(curDialog, nMsg); - FPSFX *voice = NULL; + _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); + _ctx->voice = NULL; - if (curVoc) { + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(vdb); -// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(curVoc->offset); - _vm->_theSound.CreateSfx(&voice); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - voice->SetLoop(false); - if (bIsBack) voice->SetVolume(55); +// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); + _vm->_vdbFP.seek(_ctx->curVoc->offset); + _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->SetLoop(false); + if (_ctx->bIsBack) _ctx->voice->SetVolume(55); g_system->unlockMutex(vdb); } - string = mpalQueryDialogPeriod(nMsg); + _ctx->string = mpalQueryDialogPeriod(nMsg); if (nPers == 0) { - text = new RMTextDialog; - text->SetColor(0,255,0); - text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); - text->WriteText(string,0); + _ctx->text = new RMTextDialog; + _ctx->text->SetColor(0,255,0); + _ctx->text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); + _ctx->text->WriteText(_ctx->string,0); if (dwTonyNumTexts > 0) { if (!bTonyInTexts) { if (nTonyNextTalkType != Tony->TALK_NORMAL) { - Tony->StartTalk(nTonyNextTalkType); + CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } else - Tony->StartTalk(Tony->TALK_NORMAL); + CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); bTonyInTexts = true; } dwTonyNumTexts--; } else { - Tony->StartTalk(nTonyNextTalkType); + CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } } else if (!IsMChar[nPers]) { - RMPoint pt; - - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - pt=Character[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + _ctx->pt = Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); if (Character[nPers].starttalkpattern != 0) { Freeze(); Character[nPers].item->SetPattern(Character[nPers].starttalkpattern); Unfreeze(); - Character[nPers].item->WaitForEndPattern(); + CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); } Character[nPers].item->SetPattern(Character[nPers].talkpattern); - text->SetColor(Character[nPers].r,Character[nPers].g,Character[nPers].b); - text->WriteText(string,0); - text->SetPosition(pt); + _ctx->text->SetColor(Character[nPers].r, Character[nPers].g,Character[nPers].b); + _ctx->text->WriteText(_ctx->string, 0); + _ctx->text->SetPosition(_ctx->pt); } else { RMPoint pt; - if (MCharacter[nPers].x==-1) - pt=MCharacter[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + if (MCharacter[nPers].x == -1) + pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); else - pt=RMPoint(MCharacter[nPers].x,MCharacter[nPers].y); + pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); // Parametro per le azioni speciali: random tra le parlate - parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), parm); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h,INFINITE); - MCharacter[nPers].curTalk = parm; + MCharacter[nPers].curTalk = _ctx->parm; if (MCharacter[nPers].numtexts != 0) { MCharacter[nPers].bInTexts = true; @@ -1797,39 +1989,39 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (MCharacter[nPers].bAlwaysBack) { - text = curBackText = new RMTextDialogScrolling(Loc); + _ctx->text = curBackText = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) curBackText->Hide(); - bIsBack = true; + _ctx->bIsBack = true; } else - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); - text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); - text->WriteText(string,0); - text->SetPosition(pt); + _ctx->text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); + _ctx->text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); + _ctx->text->WriteText(_ctx->string,0); + _ctx->text->SetPosition(pt); } if (!bSkipIdle) { - text->SetInput(Input); - if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } - text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - LinkGraphicTask(text); - - if (curVoc) { - voice->Play(); - text->SetCustomSkipHandle2(voice->hEndOfBuffer); + _ctx->text->SetInput(Input); + if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + LinkGraphicTask(_ctx->text); + + if (_ctx->curVoc) { + _ctx->voice->Play(); + _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } // Aspetta la fine della visualizzazione - text->SetCustomSkipHandle(hSkipIdle); - text->WaitForEndDisplay(); + _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->WaitForEndDisplay(); } - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice=NULL; } if (nPers != 0) { @@ -1838,37 +2030,39 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg Freeze(); Character[nPers].item->SetPattern(Character[nPers].endtalkpattern); Unfreeze(); - Character[nPers].item->WaitForEndPattern(); + CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); } Character[nPers].item->SetPattern(Character[nPers].standpattern); - delete text; + delete _ctx->text; } else { if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); - if (h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + if (_ctx->h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h,INFINITE); MCharacter[nPers].bInTexts = false; MCharacter[nPers].numtexts = 0; } curBackText = NULL; - delete text; + delete _ctx->text; } } else { if ((dwTonyNumTexts== 0 && bTonyInTexts) || !bTonyInTexts) { - Tony->EndTalk(); + CORO_INVOKE_0(Tony->EndTalk); dwTonyNumTexts = 0; bTonyInTexts = false; } - delete text; + delete _ctx->text; } - GlobalFree(string); + GlobalFree(_ctx->string); + + CORO_END_CODE; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 9a2f4cfe6a..e6914ebc87 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -705,8 +705,9 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return false; // Facciamo un update del pattern, che ci ritorna anche il frame corrente + // FIXME: Get rid of HANDLE cast if (m_nCurPattern != 0) - m_nCurSprite=m_patterns[m_nCurPattern].Update(m_hEndPattern,m_bCurFlag, m_sfx); + m_nCurSprite = m_patterns[m_nCurPattern].Update((HANDLE)m_hEndPattern, m_bCurFlag, m_sfx); // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito if (m_nCurSprite == -1) { @@ -831,30 +832,36 @@ RMItem::RMItem() { m_nSprites = 0; m_nSfx = 0; m_nPatterns = 0; - m_hEndPattern = 0; m_bPal = 0; m_nCurSprite = 0; - m_hEndPattern = CreateEvent(NULL, false, false, NULL); + m_hEndPattern = _vm->_scheduler.createEvent(false, false); } RMItem::~RMItem() { - Unload(); - CloseHandle(m_hEndPattern); + Unload(); + _vm->_scheduler.closeEvent(m_hEndPattern); } -void RMItem::WaitForEndPattern(HANDLE hCustomSkip) { +//FIXME: Pass uint32 directly for hCustomSkip +void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { + CORO_BEGIN_CONTEXT; + uint32 h[2]; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_nCurPattern != 0) { if (hCustomSkip == INVALID_HANDLE_VALUE) - WaitForSingleObject(m_hEndPattern,INFINITE); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, m_hEndPattern, INFINITE); else { - HANDLE h[2]; - - h[0] = hCustomSkip; - h[1] = m_hEndPattern; - WaitForMultipleObjects(2, h, false, INFINITE); + _ctx->h[0] = (uint32)hCustomSkip; + _ctx->h[1] = m_hEndPattern; + CORO_INVOKE_4(_vm->_scheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); } } + + CORO_END_CODE; } void RMItem::ChangeHotspot(RMPoint pt) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 9ed1a284d1..3a312a0d3c 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -52,6 +52,7 @@ #include "common/system.h" #include "common/file.h" #include "tony/mpal/stubs.h" +#include "tony/sched.h" #include "tony/sound.h" #include "tony/utils.h" @@ -245,7 +246,7 @@ private: byte m_bCurFlag; int m_nCurSprite; bool m_bIsActive; - HANDLE m_hEndPattern; + uint32 m_hEndPattern; bool m_bInitCurPattern; public: @@ -291,7 +292,7 @@ public: void Unload(void); // Aspetta la fine del pattern in play - void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE); + void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE); // Setta un nuovo hotspot per l'oggetto void ChangeHotspot(RMPoint pt); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 592c4788df..c5ded67c81 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -141,8 +141,8 @@ uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; uint32 PollingThreads[MAXPOLLINGLOCATIONS]; -HANDLE hAskChoice; -HANDLE hDoneChoice; +uint32 hAskChoice; +uint32 hDoneChoice; uint32 nExecutingAction; @@ -1349,7 +1349,7 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { nExecutingDialog = 0; nExecutingChoice = 0; - SetEvent(hAskChoice); + _vm->_scheduler.setEvent(hAskChoice); CORO_KILL_SELF(); @@ -1501,9 +1501,9 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - ResetEvent(hDoneChoice); - SetEvent(hAskChoice); - WaitForSingleObject(hDoneChoice, INFINITE); + _vm->_scheduler.resetEvent(hDoneChoice); + _vm->_scheduler.setEvent(hAskChoice); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hDoneChoice, INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ @@ -1644,8 +1644,8 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; - ResetEvent(hAskChoice); - ResetEvent(hDoneChoice); + _vm->_scheduler.resetEvent(hAskChoice); + _vm->_scheduler.resetEvent(hDoneChoice); // Create a thread that performs the dialogue group @@ -1690,7 +1690,7 @@ bool DoSelection(uint32 i, uint32 dwData) { return false; nSelectedChoice = j; - SetEvent(hDoneChoice); + _vm->_scheduler.setEvent(hDoneChoice); return true; } @@ -1867,8 +1867,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = CreateEvent(NULL, true, false, NULL); - hDoneChoice = CreateEvent(NULL, true, false, NULL); + hAskChoice = _vm->_scheduler.createEvent(true, false); + hDoneChoice = _vm->_scheduler.createEvent(true, false); return true; } @@ -2031,8 +2031,9 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - WaitForSingleObject(hAskChoice, INFINITE); - ResetEvent(hAskChoice); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hAskChoice, INFINITE); + + _vm->_scheduler.resetEvent(hAskChoice); if (bExecutingDialog) *dwRet = (uint32)nExecutingChoice; diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 0fc01d4d07..58ecc6d6d9 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -90,16 +90,20 @@ uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWait } HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName) { + warning("TODO: Refactor call to old style CreateEvent method"); return 0; } void SetEvent(HANDLE hEvent) { + warning("TODO: Refactor call to old style SetEvent method"); } void ResetEvent(HANDLE hEvent) { + warning("TODO: Refactor call to old style ResetEvent method"); } void PulseEvent(HANDLE hEvent) { + warning("TODO: Refactor call to old style PulseEvent method"); } uint16 GetAsyncKeyState(Common::KeyCode kc) { diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 41531bf225..199f5991ce 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -67,6 +67,11 @@ Scheduler::~Scheduler() { delete active; active = 0; + + // Clear the event list + Common::List::iterator i; + for (i = _events.begin(); i != _events.end(); ++i) + delete (*i); } /** @@ -292,39 +297,52 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { } /** - * Continously makes a given process wait for another process to finish + * Continously makes a given process wait for another process to finish or event to signal. * - * @param pid Process identifier + * @param pid Process/Event identifier * @param duration Duration in milliseconds - * @param expired Set to true if delay period expired + * @param expired If specified, set to true if delay period expired */ -void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *expired) { +void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired) { if (!pCurrent) error("Called Scheduler::waitForSingleObject from the main process"); CORO_BEGIN_CONTEXT; uint32 endTime; - PROCESS *pProc; + PROCESS *pProcess; + EVENT *pEvent; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; if (expired) - *expired = false; + // Presume it will expire + *expired = true; // Outer loop for doing checks until expiry while (g_system->getMillis() < _ctx->endTime) { - // Check to see if a process with the given Id exists - _ctx->pProc = active->pNext; - while ((_ctx->pProc != NULL) && (_ctx->pProc->pid != pid)) - _ctx->pProc = _ctx->pProc->pNext; + // Check to see if a process or event with the given Id exists + _ctx->pProcess = getProcess(pid); + _ctx->pEvent = !_ctx->pProcess ? getEvent(pid) : NULL; - if (_ctx->pProc == NULL) { - // No match process found, so it's okay to break out of loop + // If there's no active process or event, presume it's a process that's finished, + // so the waiting can immediately exit + if ((_ctx->pProcess == NULL) && (_ctx->pEvent == NULL)) { if (expired) - *expired = true; + *expired = false; + break; + } + + // If a process was found, don't go into the if statement, and keep waiting. + // Likewise if it's an event that's not yet signalled + if ((_ctx->pEvent != NULL) && _ctx->pEvent->signalled) { + // Unless the event is flagged for manual reset, reset it now + if (!_ctx->pEvent->manualReset) + _ctx->pEvent->signalled = false; + if (expired) + *expired = false; break; } @@ -335,6 +353,76 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *exp CORO_END_CODE; } +/** + * Continously makes a given process wait for given prcesses to finished or events to be set + * + * @param nCount Number of Id's being passed + * @param evtList List of pids to wait for + * @param bWaitAll Specifies whether all or any of the processes/events + * @param duration Duration in milliseconds + * @param expired Set to true if delay period expired + */ +void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, + uint32 duration, bool *expired) { + if (!pCurrent) + error("Called Scheduler::waitForMultipleEvents from the main process"); + + CORO_BEGIN_CONTEXT; + uint32 endTime; + bool signalled; + bool pidSignalled; + int i; + PROCESS *pProcess; + EVENT *pEvent; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; + if (expired) + // Presume that delay will expire + *expired = true; + + // Outer loop for doing checks until expiry + while (g_system->getMillis() < _ctx->endTime) { + _ctx->signalled = bWaitAll; + + for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { + _ctx->pProcess = getProcess(pidList[_ctx->i]); + _ctx->pEvent = !_ctx->pProcess ? getEvent(pidList[_ctx->i]) : NULL; + + // Determine the signalled state + _ctx->pidSignalled = (_ctx->pProcess) || !_ctx->pEvent ? false : _ctx->pEvent->signalled; + + if (bWaitAll && _ctx->pidSignalled) + _ctx->signalled = false; + else if (!bWaitAll & _ctx->pidSignalled) + _ctx->signalled = true; + } + + // At this point, if the signalled variable is set, waiting is finished + if (_ctx->signalled) { + // Automatically reset any events not flagged for manual reset + for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { + _ctx->pEvent = getEvent(pidList[_ctx->i]); + + if (_ctx->pEvent->manualReset) + _ctx->pEvent->signalled = false; + } + + if (expired) + *expired = false; + break; + } + + // Sleep until the next cycle + CORO_SLEEP(1); + } + + CORO_END_CODE; +} + + /** * Creates a new process. * @@ -541,4 +629,72 @@ void Scheduler::setResourceCallback(VFPTRPP pFunc) { pRCfunction = pFunc; } +PROCESS *Scheduler::getProcess(uint32 pid) { + PROCESS *pProc = active->pNext; + while ((pProc != NULL) && (pProc->pid != pid)) + pProc = pProc->pNext; + + return pProc; +} + +EVENT *Scheduler::getEvent(uint32 pid) { + Common::List::iterator i; + for (i = _events.begin(); i != _events.end(); ++i) { + EVENT *evt = *i; + if (evt->pid == pid) + return evt; + } + + return NULL; +} + + +/** + * Creates a new event object + * @param bManualReset Events needs to be manually reset. Otherwise, events + * will be automatically reset after a process waits on the event finishes + * @param bInitialState Specifies whether the event is signalled or not initially + */ +uint32 Scheduler::createEvent(bool bManualReset, bool bInitialState) { + EVENT *evt = new EVENT(); + evt->pid = ++pidCounter; + evt->manualReset = bManualReset; + evt->signalled = bInitialState; + + _events.push_back(evt); + return evt->pid; +} + +/** + * Destroys the given event + * @param pidEvent Event PID + */ +void Scheduler::closeEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (evt) { + _events.remove(evt); + delete evt; + } +} + +/** + * Sets the event + * @param pidEvent Event PID + */ +void Scheduler::setEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (evt) + evt->signalled = true; +} + +/** + * Resets the event + * @param pidEvent Event PID + */ +void Scheduler::resetEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (evt) + evt->signalled = false; +} + } // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 54f44aa5fd..80df1eb942 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -24,6 +24,7 @@ #ifndef TONY_SCHED_H #define TONY_SCHED_H +#include "common/list.h" #include "tony/coroutine.h" namespace Tony { @@ -48,13 +49,20 @@ struct PROCESS { CORO_ADDR coroAddr; ///< the entry point of the coroutine int sleepTime; ///< number of scheduler cycles to sleep - int pid; ///< process ID + uint32 pid; ///< process ID char param[PARAM_SIZE]; ///< process specific info }; typedef PROCESS *PPROCESS; struct INT_CONTEXT; +/** Event structure */ +struct EVENT { + uint32 pid; + bool manualReset; + bool signalled; +}; + /** * Create and manage "processes" (really coroutines). */ @@ -80,6 +88,8 @@ private: /** Auto-incrementing process Id */ int pidCounter; + /** Event list */ + Common::List _events; #ifdef DEBUG // diagnostic process counters @@ -95,7 +105,8 @@ private: */ VFPTRPP pRCfunction; - + PROCESS *getProcess(uint32 pid); + EVENT *getEvent(uint32 pid); public: Scheduler(); @@ -111,7 +122,9 @@ public: void rescheduleAll(); void reschedule(PPROCESS pReSchedProc = NULL); void giveWay(PPROCESS pReSchedProc = NULL); - void waitForSingleObject(CORO_PARAM, int pid, int duration, bool *delay = NULL); + void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); + void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, + uint32 duration, bool *expired = NULL); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { @@ -123,9 +136,13 @@ public: int getCurrentPID() const; int killMatchingProcess(int pidKill, int pidMask = -1); - void setResourceCallback(VFPTRPP pFunc); + /* Event methods */ + uint32 createEvent(bool bManualReset, bool bInitialState); + void closeEvent(uint32 pidEvent); + void setEvent(uint32 pidEvent); + void resetEvent(uint32 pidEvent); }; extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index de6189876b..073ebf2be4 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -519,10 +519,8 @@ void RMTony::Put(int nWhere, int nPart) { } -void RMTony::StartTalk(TALKTYPE nTalkType) { - int headStartPat = 0, bodyStartPat = 0; - int headLoopPat = 0, bodyLoopPat = 0; - +bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + int &headLoopPat, int &bodyLoopPat) { assert(!m_bIsTalking); m_bIsTalking = true; @@ -585,7 +583,7 @@ void RMTony::StartTalk(TALKTYPE nTalkType) { break; } MainUnfreeze(); - return; + return false; } headStartPat = bodyStartPat = 0; @@ -1077,35 +1075,47 @@ void RMTony::StartTalk(TALKTYPE nTalkType) { } break; } +} + +void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { + CORO_BEGIN_CONTEXT; + int headStartPat, bodyStartPat; + int headLoopPat, bodyLoopPat; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->headStartPat = _ctx->bodyStartPat = 0; + _ctx->headLoopPat = _ctx->bodyLoopPat = 0; + + if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, + _ctx->headLoopPat, _ctx->bodyLoopPat)) + return; // Esegue il set dei pattern vero e proprio - if (headStartPat != 0 || bodyStartPat != 0) { + if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { MainFreeze(); - SetPattern(headStartPat); - m_body.SetPattern(bodyStartPat); + SetPattern(_ctx->headStartPat); + m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - if (bodyStartPat!=0) - m_body.WaitForEndPattern(); - if (headStartPat!=0) - WaitForEndPattern(); + if (_ctx->bodyStartPat != 0) + CORO_INVOKE_0(m_body.WaitForEndPattern); + if (_ctx->headStartPat != 0) + CORO_INVOKE_0(WaitForEndPattern); } MainFreeze(); - SetPattern(headLoopPat); - if (bodyLoopPat) - m_body.SetPattern(bodyLoopPat); + SetPattern(_ctx->headLoopPat); + if (_ctx->bodyLoopPat) + m_body.SetPattern(_ctx->bodyLoopPat); MainUnfreeze(); -} + CORO_END_CODE; +} -void RMTony::EndTalk(void) { - int headStandPat = 0; - int headEndPat = 0; - int bodyEndPat = 0; - int finalPat = 0; - bool bStatic = false; +bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; @@ -1136,7 +1146,7 @@ void RMTony::EndTalk(void) { SetPattern(finalPat); MainUnfreeze(); m_bIsTalking = false; - return; + return false; } @@ -1379,6 +1389,28 @@ void RMTony::EndTalk(void) { break; } + return true; +} + +void RMTony::EndTalk(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + int headStandPat, headEndPat; + int bodyEndPat, finalPat; + bool bStatic; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->headStandPat = _ctx->headEndPat = 0; + _ctx->bodyEndPat = _ctx->finalPat = 0; + _ctx->bStatic = false; + + _ctx->bodyEndPat = 0; + _ctx->headEndPat = 0; + + if (!EndTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) + return; + // Gestisce la fine di una animazione static lasciando tutto invariato if (m_bIsStaticTalk) { if (m_nTalkType == TALK_CONBARBASTATIC) { @@ -1394,10 +1426,10 @@ void RMTony::EndTalk(void) { MainUnfreeze(); } else { MainFreeze(); - SetPattern(headStandPat); + SetPattern(_ctx->headStandPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); } m_bIsTalking = false; @@ -1405,60 +1437,58 @@ void RMTony::EndTalk(void) { } // Set dei pattern - if (headEndPat != 0 && bodyEndPat != 0) { + if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { MainFreeze(); - SetPattern(headEndPat); + SetPattern(_ctx->headEndPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); MainFreeze(); - m_body.SetPattern(bodyEndPat); + m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - WaitForEndPattern(); - m_body.WaitForEndPattern(); - } else if (bodyEndPat != 0) { + CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); + } else if (_ctx->bodyEndPat != 0) { MainFreeze(); - SetPattern(headStandPat); + SetPattern(_ctx->headStandPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); MainFreeze(); - m_body.SetPattern(bodyEndPat); + m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - m_body.WaitForEndPattern(); - } else if (headEndPat != 0) { - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); + } else if (_ctx->headEndPat != 0) { + CORO_INVOKE_0(m_body.WaitForEndPattern); MainFreeze(); - SetPattern(headEndPat); + SetPattern(_ctx->headEndPat); MainUnfreeze(); - WaitForEndPattern(); + CORO_INVOKE_0(WaitForEndPattern); } else { - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); } - if (finalPat != 0) { + if (_ctx->finalPat != 0) { MainFreeze(); m_body.SetPattern(0); - SetPattern(finalPat); + SetPattern(_ctx->finalPat); MainUnfreeze(); } m_bIsTalking = false; -} -void RMTony::StartStatic(TALKTYPE nTalk) { - int nPat = 0; - int headPat = 0, headLoopPat = 0; - int bodyStartPat = 0; - int bodyLoopPat = 0; + CORO_END_CODE; +} - nPat = GetCurPattern(); +void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + int &bodyStartPat, int &bodyLoopPat) { + int nPat = GetCurPattern(); headLoopPat = -1; @@ -1661,31 +1691,41 @@ void RMTony::StartStatic(TALKTYPE nTalk) { default: break; } +} + +void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { + CORO_BEGIN_CONTEXT; + int headPat, headLoopPat; + int bodyStartPat, bodyLoopPat; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->headPat = _ctx->headLoopPat = 0; + _ctx->bodyStartPat = _ctx->bodyLoopPat = 0; // e vai con i pattern m_bIsStaticTalk = true; MainFreeze(); - SetPattern(headPat); - m_body.SetPattern(bodyStartPat); + SetPattern(_ctx->headPat); + m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - m_body.WaitForEndPattern(); - WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(WaitForEndPattern); MainFreeze(); - if (headLoopPat != -1) - SetPattern(headLoopPat); - m_body.SetPattern(bodyLoopPat); + if (_ctx->headLoopPat != -1) + SetPattern(_ctx->headLoopPat); + m_body.SetPattern(_ctx->bodyLoopPat); MainUnfreeze(); -} + CORO_END_CODE; +} -void RMTony::EndStatic(TALKTYPE nTalk) { - int bodyEndPat = 0; - int finalPat = 0; - int headEndPat = 0; +void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { switch (m_TalkDirection) { case UP: case LEFT: @@ -1818,28 +1858,46 @@ void RMTony::EndStatic(TALKTYPE nTalk) { default: break; } +} + +void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { + CORO_BEGIN_CONTEXT; + int bodyEndPat; + int finalPat; + int headEndPat; + CORO_END_CONTEXT(_ctx); - if (headEndPat != 0) { + CORO_BEGIN_CODE(_ctx); + + _ctx->bodyEndPat = 0; + _ctx->finalPat = 0; + _ctx->headEndPat = 0; + + EndStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); + + if (_ctx->headEndPat != 0) { MainFreeze(); - SetPattern(headEndPat); + SetPattern(_ctx->headEndPat); MainUnfreeze(); - WaitForEndPattern(); + CORO_INVOKE_0(WaitForEndPattern); } else { // Play please MainFreeze(); - m_body.SetPattern(bodyEndPat); + m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); } MainFreeze(); - SetPattern(finalPat); + SetPattern(_ctx->finalPat); m_body.SetPattern(0); MainUnfreeze(); m_bIsStaticTalk = false; + + CORO_END_CODE; } } // End of namespace Tony diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 266b34e697..2cbcf60a00 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -408,7 +408,9 @@ public: int GetCurPattern(); // Attende la fine di un pattern - void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { RMCharacter::WaitForEndPattern(hCustomSkip);} + void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { + RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); + } // Controlla se si trova in azione bool InAction() { return (m_bActionPending&&m_Action != 0) | m_bAction; } @@ -427,12 +429,18 @@ public: void Put(int nWhere, int nPart); // Start e End Talk - void StartTalk(TALKTYPE nTalkType); - void EndTalk(void); + bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + int &headLoopPat, int &bodyLoopPat); + void StartTalk(CORO_PARAM, TALKTYPE nTalkType); + bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); + void EndTalk(CORO_PARAM); // Start e End Static - void StartStatic(TALKTYPE nTalkType); - void EndStatic(TALKTYPE nTalkType); + void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + int &bodyStartPat, int &bodyLoopPat); + void StartStatic(CORO_PARAM, TALKTYPE nTalkType); + void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); + void EndStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony si traveste! void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } -- cgit v1.2.3 From a254f100253bda1b23f280226b7b4d909206d49c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 May 2012 09:32:21 +1000 Subject: TONY: Added support for Windows-style threading events to scheduler --- engines/tony/custom.cpp | 9 +++++- engines/tony/loc.cpp | 30 ++++++++++++++------ engines/tony/loc.h | 4 +-- engines/tony/mpal/mpal.cpp | 50 ++++++++++++++++---------------- engines/tony/sched.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++-- engines/tony/sched.h | 4 ++- engines/tony/tony.cpp | 2 +- engines/tony/tonychar.cpp | 14 +++++---- 8 files changed, 137 insertions(+), 47 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 800b5d8d50..18a92899df 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1310,10 +1310,17 @@ DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint3 } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->Move(RMPoint(nX, nY)); if (!bSkipIdle) - Tony->WaitForEndMovement(); + CORO_INVOKE_0(Tony->WaitForEndMovement); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e6914ebc87..4eced3fbd5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -835,12 +835,12 @@ RMItem::RMItem() { m_bPal = 0; m_nCurSprite = 0; - m_hEndPattern = _vm->_scheduler.createEvent(false, false); + m_hEndPattern = g_scheduler->createEvent(false, false); } RMItem::~RMItem() { Unload(); - _vm->_scheduler.closeEvent(m_hEndPattern); + g_scheduler->closeEvent(m_hEndPattern); } //FIXME: Pass uint32 directly for hCustomSkip @@ -853,11 +853,11 @@ void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { if (m_nCurPattern != 0) { if (hCustomSkip == INVALID_HANDLE_VALUE) - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, m_hEndPattern, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndPattern, INFINITE); else { _ctx->h[0] = (uint32)hCustomSkip; _ctx->h[1] = m_hEndPattern; - CORO_INVOKE_4(_vm->_scheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); + CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); } } @@ -1082,7 +1082,7 @@ void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { if (m_pos == destcoord) { if (minpath == 0) { Stop(); - PulseEvent(hEndOfPath); + g_scheduler->pulseEvent(hEndOfPath); return; } } @@ -1458,7 +1458,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) Stop(); bEndOfPath = true; - PulseEvent(hEndOfPath); + g_scheduler->pulseEvent(hEndOfPath); } walkcount++; @@ -1496,7 +1496,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) Stop(); bEndOfPath = true; - PulseEvent(hEndOfPath); + g_scheduler->pulseEvent(hEndOfPath); } } else { // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il @@ -1636,6 +1636,18 @@ void RMCharacter::SetPosition(RMPoint pt, int newloc) { bRemoveFromOT = true; } +void RMCharacter::WaitForEndMovement(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (bMoving) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hEndOfPath, INFINITE); + + CORO_END_CODE; +} + bool RMCharacter::RemoveThis(void) { if (bRemoveFromOT) return true; @@ -1645,7 +1657,7 @@ bool RMCharacter::RemoveThis(void) { RMCharacter::RMCharacter() { csMove = g_system->createMutex(); - hEndOfPath = CreateEvent(NULL, false, false, NULL); + hEndOfPath = g_scheduler->createEvent(false, false); minpath = 0; curSpeed = 3; bRemoveFromOT = false; @@ -1666,7 +1678,7 @@ RMCharacter::RMCharacter() { RMCharacter::~RMCharacter() { g_system->deleteMutex(csMove); - CloseHandle(hEndOfPath); + g_scheduler->closeEvent(hEndOfPath); } void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 3a312a0d3c..153ef7f18c 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -423,7 +423,7 @@ private: STATUS status; int curSpeed; bool bEndOfPath; - HANDLE hEndOfPath; + uint32 hEndOfPath; OSystem::MutexRef csMove; int curLocation; bool bRemoveFromOT; @@ -482,7 +482,7 @@ public: void SetPosition(RMPoint pt, int newloc=-1); // Aspetta la fine del movimento - void WaitForEndMovement(void) { if (bMoving) WaitForSingleObject(hEndOfPath, INFINITE); } + void WaitForEndMovement(CORO_PARAM); void SetFixedScroll(RMPoint fix) { m_fixedScroll = fix; } void SetSpeed(int speed) { curSpeed=speed; } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index c5ded67c81..0cea50a3d3 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -961,7 +961,7 @@ void ActionThread(CORO_PARAM, const void *param) { if (item->Command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - _vm->_scheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + g_scheduler->getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 ); @@ -976,7 +976,7 @@ void ActionThread(CORO_PARAM, const void *param) { } else if (item->Command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - _vm->_scheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); + g_scheduler->getCurrentPID(), item->Command[_ctx->k].lpszVarName); LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); @@ -991,7 +991,7 @@ void ActionThread(CORO_PARAM, const void *param) { GlobalFree(item); - debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", _vm->_scheduler.getCurrentPID()); + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", g_scheduler->getCurrentPID()); CORO_KILL_SELF(); @@ -1012,7 +1012,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); bExecutingAction = false; @@ -1190,7 +1190,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); // if result ) == WAIT_OBJECT_0) if (!_ctx->delayExpired) @@ -1261,7 +1261,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; // !!! Nuova gestione dei thread - if ((_ctx->MyThreads[_ctx->i].hThread = _vm->_scheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + if ((_ctx->MyThreads[_ctx->i].hThread = g_scheduler->createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); @@ -1295,14 +1295,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); /* //if (result != WAIT_OBJECT_0) if (_ctx->delayExpired) TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); */ - _vm->_scheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + g_scheduler->killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } // Set idle skip off @@ -1343,13 +1343,13 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); bExecutingDialog = false; nExecutingDialog = 0; nExecutingChoice = 0; - _vm->_scheduler.setEvent(hAskChoice); + g_scheduler->setEvent(hAskChoice); CORO_KILL_SELF(); @@ -1501,9 +1501,9 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - _vm->_scheduler.resetEvent(hDoneChoice); - _vm->_scheduler.setEvent(hAskChoice); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hDoneChoice, INFINITE); + g_scheduler->resetEvent(hDoneChoice); + g_scheduler->setEvent(hAskChoice); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hDoneChoice, INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ @@ -1644,19 +1644,19 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; - _vm->_scheduler.resetEvent(hAskChoice); - _vm->_scheduler.resetEvent(hDoneChoice); + g_scheduler->resetEvent(hAskChoice); + g_scheduler->resetEvent(hDoneChoice); // Create a thread that performs the dialogue group // Create the process - if ((h = _vm->_scheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) + if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) return 0; // Create a thread that waits until the end of the dialog process, and will restore the global variables - if (_vm->_scheduler.createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { + if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { // Something went wrong, so kill the previously started dialog process - _vm->_scheduler.killMatchingProcess(h); + g_scheduler->killMatchingProcess(h); return 0; } @@ -1690,7 +1690,7 @@ bool DoSelection(uint32 i, uint32 dwData) { return false; nSelectedChoice = j; - _vm->_scheduler.setEvent(hDoneChoice); + g_scheduler->setEvent(hDoneChoice); return true; } @@ -1867,8 +1867,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = _vm->_scheduler.createEvent(true, false); - hDoneChoice = _vm->_scheduler.createEvent(true, false); + hAskChoice = g_scheduler->createEvent(true, false); + hDoneChoice = g_scheduler->createEvent(true, false); return true; } @@ -2031,9 +2031,9 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hAskChoice, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); - _vm->_scheduler.resetEvent(hAskChoice); + g_scheduler->resetEvent(hAskChoice); if (bExecutingDialog) *dwRet = (uint32)nExecutingChoice; @@ -2217,7 +2217,7 @@ bool mpalStartIdlePoll(int nLoc) { hEndPollingLocations[i] = CreateEvent(NULL, true, false, NULL); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = _vm->_scheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) + if ((PollingThreads[i] = g_scheduler->createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2254,7 +2254,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { if (nPollingLocations[_ctx->i] == (uint32)nLoc) { SetEvent(hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, PollingThreads[_ctx->i], INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, PollingThreads[_ctx->i], INFINITE); CloseHandle(hEndPollingLocations[_ctx->i]); nPollingLocations[_ctx->i] = 0; diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 199f5991ce..2671b01b7f 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -51,6 +51,8 @@ Scheduler::Scheduler() { active->pNext = NULL; g_scheduler = this; // FIXME HACK + + reset(); } Scheduler::~Scheduler() { @@ -102,6 +104,7 @@ void Scheduler::reset() { while (pProc != NULL) { delete pProc->state; pProc->state = 0; + pProc->waiting = false; pProc = pProc->pNext; } @@ -315,6 +318,9 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool * CORO_BEGIN_CODE(_ctx); + // Signal as waiting + pCurrent->waiting = true; + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; if (expired) // Presume it will expire @@ -350,6 +356,9 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool * CORO_SLEEP(1); } + // Signal waiting is done + pCurrent->waiting = false; + CORO_END_CODE; } @@ -378,6 +387,9 @@ void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, CORO_BEGIN_CODE(_ctx); + // Signal as waiting + pCurrent->waiting = true; + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; if (expired) // Presume that delay will expire @@ -419,6 +431,9 @@ void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, CORO_SLEEP(1); } + // Signal waiting is done + pCurrent->waiting = false; + CORO_END_CODE; } @@ -567,12 +582,12 @@ int Scheduler::getCurrentPID() const { * @param pidMask mask to apply to process identifiers before comparison * @return The number of processes killed is returned. */ -int Scheduler::killMatchingProcess(int pidKill, int pidMask) { +int Scheduler::killMatchingProcess(uint32 pidKill, int pidMask) { int numKilled = 0; PROCESS *pProc, *pPrev; // process list pointers for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { - if ((pProc->pid & pidMask) == pidKill) { + if ((pProc->pid & (uint32)pidMask) == pidKill) { // found a matching process // dont kill the current process @@ -697,4 +712,56 @@ void Scheduler::resetEvent(uint32 pidEvent) { evt->signalled = false; } +/** + * Temporarily sets a given event to true, and then runs all waiting processes, allowing any + * processes waiting on the event to be fired. It then immediately resets the event again. + * @param pidEvent Event PID + * + * @remarks Should not be run inside of another process + */ +void Scheduler::pulseEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (!evt) + return; + + // Set the event as true + evt->signalled = true; + + // start dispatching active process list for any processes that are currently waiting + PROCESS *pOriginal = pCurrent; + PROCESS *pNext; + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + pNext = pProc->pNext; + + // Only call processes that are currently waiting (either in waitForSingleObject or + // waitForMultipleObjects). If one is found, execute it immediately + if (pProc->waiting) { + // Dispatch the process + pCurrent = pProc; + pProc->coroAddr(pProc->state, pProc->param); + + if (!pProc->state || pProc->state->_sleep <= 0) { + // Coroutine finished + pCurrent = pCurrent->pPrevious; + killProcess(pProc); + } else { + pProc->sleepTime = pProc->state->_sleep; + } + + // pCurrent may have been changed + pNext = pCurrent->pNext; + pCurrent = NULL; + } + + pProc = pNext; + } + + // Restore the original current process (if one was active) + pCurrent = pOriginal; + + // Reset the event back to non-signalled + evt->signalled = false; +} + } // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 80df1eb942..3997cb2c47 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -50,6 +50,7 @@ struct PROCESS { int sleepTime; ///< number of scheduler cycles to sleep uint32 pid; ///< process ID + bool waiting; ///< process is currently in a waiting state char param[PARAM_SIZE]; ///< process specific info }; typedef PROCESS *PPROCESS; @@ -134,7 +135,7 @@ public: PROCESS *getCurrentProcess(); int getCurrentPID() const; - int killMatchingProcess(int pidKill, int pidMask = -1); + int killMatchingProcess(uint32 pidKill, int pidMask = -1); void setResourceCallback(VFPTRPP pFunc); @@ -143,6 +144,7 @@ public: void closeEvent(uint32 pidEvent); void setEvent(uint32 pidEvent); void resetEvent(uint32 pidEvent); + void pulseEvent(uint32 pidEvent); }; extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a4a478d40d..d0bce68c3b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,7 +36,7 @@ namespace Tony { TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony") { + _gameDescription(gameDesc), _randomSource("tony"), _scheduler() { _vm = this; DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 073ebf2be4..ad13d49d54 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -67,7 +67,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); m_bAction = false; @@ -240,26 +240,26 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { if (hThread != INVALID_HANDLE_VALUE) { m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { hThread = mpalQueryDoAction(6, 1, 0); m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } else if (nAction == TA_PALESATI) { hThread = mpalQueryDoAction(7, 1, 0); m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread=hThread; } else { hThread = mpalQueryDoAction(5, 1, 0); m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } } @@ -1074,7 +1074,9 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } break; - } + } + + return true; } void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { -- cgit v1.2.3 From 26898dd7ad399a641f63eabf04aa2d839f8508fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 9 May 2012 00:42:27 +1000 Subject: TONY: Completed bulk of initial coro refactoring --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 622 ++++++++++++++++++++++++------------------ engines/tony/font.cpp | 167 +++++++----- engines/tony/font.h | 25 +- engines/tony/game.cpp | 8 +- engines/tony/gfxengine.cpp | 90 +++--- engines/tony/gfxengine.h | 8 +- engines/tony/loc.cpp | 45 +-- engines/tony/loc.h | 10 +- engines/tony/mpal/loadmpc.cpp | 59 ++-- engines/tony/mpal/mpal.cpp | 156 ++++++----- engines/tony/mpal/stubs.cpp | 70 ----- engines/tony/mpal/stubs.h | 36 +-- engines/tony/sched.cpp | 34 +++ engines/tony/sched.h | 4 +- engines/tony/sound.cpp | 3 +- engines/tony/sound.h | 2 +- engines/tony/tony.cpp | 35 ++- engines/tony/tony.h | 8 +- engines/tony/tonychar.cpp | 38 ++- engines/tony/tonychar.h | 8 +- 21 files changed, 772 insertions(+), 660 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 056934e932..22205cf05b 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -96,7 +96,7 @@ void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); void MainLinkGraphicTask(RMGfxTask *task); void MainFreeze(void); void MainUnfreeze(void); -void MainWaitFrame(void); +void MainWaitFrame(CORO_PARAM); void MainShowMouse(void); void MainHideMouse(void); void MainEnableInput(void); @@ -104,7 +104,7 @@ void MainDisableInput(void); void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); void MainInitWipe(int type); void MainCloseWipe(void); -void MainWaitWipeEnd(void); +void MainWaitWipeEnd(CORO_PARAM); void MainEnableGUI(void); void MainDisableGUI(void); void MainSetPalesati(bool bPalesati); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 18a92899df..9d46d7e6b7 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -56,6 +56,7 @@ #include "tony/font.h" #include "tony/game.h" #include "tony/gfxcore.h" +#include "tony/sched.h" #include "tony/tony.h" #include "tony/tonychar.h" #include "tony/utils.h" @@ -76,9 +77,9 @@ void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, HANDLE *result); void (*LinkGraphicTask)(RMGfxTask *task); void (*Freeze)(void); void (*Unfreeze)(void); -void (*WaitFrame)(void); +void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); -void (*WaitWipeEnd)(void); +void (*WaitWipeEnd)(CORO_PARAM); void (*CloseWipe)(void); void (*InitWipe)(int type); void (*EnableGUI)(void); @@ -96,7 +97,7 @@ OSystem::MutexRef vdb; HANDLE mut[10]; bool bSkipIdle = false; -HANDLE hSkipIdle; +uint32 hSkipIdle; int lastMusic = 0, lastTappeto = 0; @@ -319,8 +320,16 @@ DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uin } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { - if (bSkipIdle) return; - Sleep(dwTime); + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (!bSkipIdle) + CORO_INVOKE_1(g_scheduler->sleep, dwTime); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { @@ -376,6 +385,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX int curOffset; VoiceHeader *curVoc; FPSFX *voice; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -422,39 +432,38 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } if (curBackText) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); + bTonyIsSpeaking = true; for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { - RMTextDialog text; - - text.SetInput(Input); + _ctx->text.SetInput(Input); // Allineamento - text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - text.SetColor(0,255,0); + _ctx->text.SetColor(0,255,0); // Scrive il testo - text.WriteText((*_ctx->msg)[_ctx->i],0); + _ctx->text.WriteText((*_ctx->msg)[_ctx->i],0); // Setta la posizione if (nX == 0 && nY == 0) - text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); + _ctx->text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); else - text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); + _ctx->text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); // Setta l'always display - if (bAlwaysDisplay) { text.SetAlwaysDisplay(); text.ForceTime(); } + if (bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } // Registra il testo - LinkGraphicTask(&text); + LinkGraphicTask(&_ctx->text); if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->Play(); - text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(vdb); // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); @@ -465,14 +474,14 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); - text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); g_system->unlockMutex(vdb); } } // Aspetta la fine della visualizzazione - text.SetCustomSkipHandle(hSkipIdle); - text.WaitForEndDisplay(); + _ctx->text.SetCustomSkipHandle(hSkipIdle); + CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -497,7 +506,11 @@ DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, u DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { - HANDLE h; + CORO_BEGIN_CONTEXT; + uint32 h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); Freeze(); @@ -508,11 +521,13 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); Unfreeze(); - h = mpalQueryDoAction(0, nLoc, 0); + _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); // On Enter? - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h, INFINITE); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + + CORO_END_CODE; } @@ -524,6 +539,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 RMMessage *msg; RMGfxClearTask clear; int i; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -541,38 +557,36 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 Unfreeze(); for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { - RMTextDialog text; - - text.SetInput(Input); + _ctx->text.SetInput(Input); // Allineamento - text.SetAlignType(RMText::HCENTER,RMText::VCENTER); + _ctx->text.SetAlignType(RMText::HCENTER,RMText::VCENTER); // Forza il testo a scomparire a tempo - text.ForceTime(); + _ctx->text.ForceTime(); // Colore - text.SetColor(255,255,255); + _ctx->text.SetColor(255,255,255); // Scrive il testo if (nFont == 0) - text.WriteText((*_ctx->msg)[_ctx->i], 1); + _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 1); else if (nFont == 1) - text.WriteText((*_ctx->msg)[_ctx->i], 0); + _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 0); // Setta la posizione - text.SetPosition(RMPoint(320, 240)); + _ctx->text.SetPosition(RMPoint(320, 240)); - text.SetAlwaysDisplay(); - text.ForceTime(); + _ctx->text.SetAlwaysDisplay(); + _ctx->text.ForceTime(); // Registra il testo LinkGraphicTask(&_ctx->clear); - LinkGraphicTask(&text); + LinkGraphicTask(&_ctx->text); // Aspetta la fine della visualizzazione - text.SetCustomSkipHandle(hSkipIdle); - text.WaitForEndDisplay(); + _ctx->text.SetCustomSkipHandle(hSkipIdle); + CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } delete _ctx->msg; @@ -581,10 +595,18 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 } DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { - RMGfxClearTask clear; + CORO_BEGIN_CONTEXT; + char buf[256]; + RMGfxClearTask clear; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + LinkGraphicTask(&_ctx->clear); + + CORO_INVOKE_0(WaitFrame); - LinkGraphicTask(&clear); - WaitFrame(); + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { @@ -625,7 +647,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 if (!bNoOcchioDiBue) { InitWipe(1); - WaitWipeEnd(); + CORO_INVOKE_0(WaitWipeEnd); } _vm->StopMusic(4); @@ -640,14 +662,14 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { CORO_BEGIN_CONTEXT; - HANDLE h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (!bNoOcchioDiBue) { InitWipe(1); - WaitWipeEnd(); + CORO_INVOKE_0(WaitWipeEnd); } if (lastTappeto != tappeti[nLoc]) { @@ -676,18 +698,18 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint Unfreeze(); - _ctx->h = mpalQueryDoAction(0, nLoc, 0); + _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); if (!bNoOcchioDiBue) { - WaitWipeEnd(); + CORO_INVOKE_0(WaitWipeEnd); CloseWipe(); } bNoOcchioDiBue = false; // On Enter? - if (_ctx->h != INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h, INFINITE); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); CORO_END_CODE; } @@ -725,7 +747,7 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->StopNoAction(); + Tony->StopNoAction(coroParam); } @@ -1328,114 +1350,123 @@ DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { - int lx, ly; - RMPoint pt; + CORO_BEGIN_CONTEXT; + int lx, ly; + RMPoint pt; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Prende le coordinate di quanto scrollare - lx=*((int*)&nX); - ly=*((int*)&nY); + _ctx->lx = (int32)nX; + _ctx->ly = (int32)nY; - pt=Loc->ScrollPosition(); + _ctx->pt = Loc->ScrollPosition(); - while ((lx != 0 || ly != 0) && !bSkipIdle) { - if (lx > 0) { - lx -= (int32)sX; if (lx < 0) lx = 0; - pt.Offset((int32)sX, 0); - } else if (lx < 0) { - lx += (int32)sX; if (lx > 0) lx = 0; - pt.Offset(-(int32)sX, 0); + while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + if (_ctx->lx > 0) { + _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; + _ctx->pt.Offset((int32)sX, 0); + } else if (_ctx->lx < 0) { + _ctx->lx += (int32)sX; if (_ctx->lx > 0) _ctx->lx = 0; + _ctx->pt.Offset(-(int32)sX, 0); } - if (ly > 0) { - ly -= sY; if (ly < 0) ly = 0; - pt.Offset(0, sY); - } else if (ly < 0) { - ly += sY; if (ly > 0) ly = 0; - pt.Offset(0, -(int32)sY); + if (_ctx->ly > 0) { + _ctx->ly -= sY; if (_ctx->ly < 0) _ctx->ly = 0; + _ctx->pt.Offset(0, sY); + } else if (_ctx->ly < 0) { + _ctx->ly += sY; if (_ctx->ly > 0) _ctx->ly = 0; + _ctx->pt.Offset(0, -(int32)sY); } - WaitFrame(); + CORO_INVOKE_0(WaitFrame); Freeze(); - Loc->SetScrollPosition(pt); - Tony->SetScrollPosition(pt); + Loc->SetScrollPosition(_ctx->pt); + Tony->SetScrollPosition(_ctx->pt); Unfreeze(); - } + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { - int lx, ly; - RMPoint pt, startpt; - uint32 dwStartTime, dwCurTime, dwTotalTime; - uint32 stepX, stepY; - int dimx, dimy; + CORO_BEGIN_CONTEXT; + int lx, ly; + RMPoint pt, startpt; + uint32 dwStartTime, dwCurTime, dwTotalTime; + uint32 stepX, stepY; + int dimx, dimy; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Prende le coordinate di quanto scrollare - lx=*((int*)&nX); - ly=*((int*)&nY); - dimx = lx; - dimy = ly; - if (lx < 0) dimx = -lx; - if (ly < 0) dimy = -ly; + _ctx->lx=*((int*)&nX); + _ctx->ly=*((int*)&nY); + _ctx->dimx = _ctx->lx; + _ctx->dimy = _ctx->ly; + if (_ctx->lx < 0) _ctx->dimx = -_ctx->lx; + if (_ctx->ly < 0) _ctx->dimy = -_ctx->ly; - stepX = sX; - stepY = sY; + _ctx->stepX = sX; + _ctx->stepY = sY; - startpt = Loc->ScrollPosition(); + _ctx->startpt = Loc->ScrollPosition(); - dwStartTime = timeGetTime(); + _ctx->dwStartTime = _vm->GetTime(); if (sX) - dwTotalTime = dimx * (1000 / 35) / sX; + _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; else - dwTotalTime = dimy * (1000 / 35) / sY; + _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; - while ((lx != 0 || ly != 0) && !bSkipIdle) { - dwCurTime = _vm->GetTime() - dwStartTime; - if (dwCurTime>dwTotalTime) + while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + _ctx->dwCurTime = _vm->GetTime() - _ctx->dwStartTime; + if (_ctx->dwCurTime > _ctx->dwTotalTime) break; - pt = startpt; + _ctx->pt = _ctx->startpt; if (sX) { - if (lx > 0) - pt.x += (dimx * dwCurTime) / dwTotalTime; + if (_ctx->lx > 0) + _ctx->pt.x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; else - pt.x -= (dimx * dwCurTime) / dwTotalTime; + _ctx->pt.x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; } else { - if (ly > 0) - pt.y += (dimy*dwCurTime) / dwTotalTime; + if (_ctx->ly > 0) + _ctx->pt.y += (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; else - pt.y -= (dimy*dwCurTime) / dwTotalTime; + _ctx->pt.y -= (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; } /* - sX = stepX * (dwCurTime-dwLastTime) / (1000 / 35); - sY = stepY * (dwCurTime-dwLastTime) / (1000 / 35); - - if (lx > 0) { - lx-=sX; if (lx < 0) lx = 0; - pt.Offset(sX,0); - } else if (lx < 0) { - lx+=sX; if (lx > 0) lx = 0; - pt.Offset(-sX,0); + sX = _ctx->stepX * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); + sY = _ctx->stepY * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); + + if (_ctx->lx > 0) { + _ctx->lx-=sX; if (_ctx->lx < 0) _ctx->lx = 0; + _ctx->pt.Offset(sX,0); + } else if (_ctx->lx < 0) { + _ctx->lx+=sX; if (_ctx->lx > 0) _ctx->lx = 0; + _ctx->pt.Offset(-sX,0); } - if (ly > 0) { - ly-=sY; if (ly<0) ly = 0; - pt.Offset(0,sY); - } else if (ly<0) { - ly+=sY; if (ly > 0) ly = 0; - pt.Offset(0,-sY); + if (_ctx->ly > 0) { + _ctx->ly-=sY; if (_ctx->ly<0) _ctx->ly = 0; + _ctx->pt.Offset(0,sY); + } else if (_ctx->ly<0) { + _ctx->ly+=sY; if (_ctx->ly > 0) _ctx->ly = 0; + _ctx->pt.Offset(0,-sY); } */ - WaitFrame(); + CORO_INVOKE_0(WaitFrame); Freeze(); - Loc->SetScrollPosition(pt); - Tony->SetScrollPosition(pt); + Loc->SetScrollPosition(_ctx->pt); + Tony->SetScrollPosition(_ctx->pt); Unfreeze(); } @@ -1443,22 +1474,23 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui // Setta la posizione finale if (sX) { - if (lx > 0) - pt.x = startpt.x + dimx; + if (_ctx->lx > 0) + _ctx->pt.x = _ctx->startpt.x + _ctx->dimx; else - pt.x = startpt.x - dimx; + _ctx->pt.x = _ctx->startpt.x - _ctx->dimx; } else { - if (ly > 0) - pt.y = startpt.y + dimy; + if (_ctx->ly > 0) + _ctx->pt.y = _ctx->startpt.y + _ctx->dimy; else - pt.y = startpt.y - dimy; - + _ctx->pt.y = _ctx->startpt.y - _ctx->dimy; } Freeze(); - Loc->SetScrollPosition(pt); - Tony->SetScrollPosition(pt); + Loc->SetScrollPosition(_ctx->pt); + Tony->SetScrollPosition(_ctx->pt); Unfreeze(); + + CORO_END_CODE; } @@ -1484,7 +1516,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->AutoSave(); + _vm->AutoSave(coroParam); } DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1492,33 +1524,41 @@ DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { } DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { - uint32 i; - uint32 curTime = _vm->GetTime(); - int dirx,diry; + CORO_BEGIN_CONTEXT; + uint32 i; + uint32 curTime; + int dirx,diry; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curTime = _vm->GetTime(); - dirx = 1; - diry = 1; + _ctx->dirx = 1; + _ctx->diry = 1; - while (_vm->GetTime() < curTime + nScosse) { - WaitFrame(); + while (_vm->GetTime() < _ctx->curTime + nScosse) { + CORO_INVOKE_0(WaitFrame); Freeze(); - Loc->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); - Tony->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); + Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); Unfreeze(); - i = _vm->_randomSource.getRandomNumber(2); + _ctx->i = _vm->_randomSource.getRandomNumber(2); - if (i == 0 || i == 2) - dirx = -dirx; - else if (i == 1 || i == 2) - diry = -diry; + if (_ctx->i == 0 || _ctx->i == 2) + _ctx->dirx = -_ctx->dirx; + else if (_ctx->i == 1 || _ctx->i == 2) + _ctx->diry = -_ctx->diry; } Freeze(); Loc->SetFixedScroll(RMPoint(0, 0)); Tony->SetFixedScroll(RMPoint(0, 0)); Unfreeze(); + + CORO_END_CODE; } @@ -1607,7 +1647,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess if (bIsBack) { curBackText = _ctx->text = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); } else _ctx->text = new RMTextDialog; @@ -1649,7 +1689,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(hSkipIdle); - _ctx->text->WaitForEndDisplay(); + CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -1769,13 +1809,22 @@ DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAl DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { - RMMessage msg(dwMessage); - int i; - int parm; - RMPoint pt; - HANDLE h; - RMTextDialog *text; - int curOffset = 0; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + int i; + int parm; + RMPoint pt; + uint32 h; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(dwMessage); + _ctx->curOffset = 0; assert(nChar < 10); @@ -1783,99 +1832,103 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Calcola la posizione del testo in base al frame corrente if (MCharacter[nChar].x==-1) - pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + _ctx->pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); else - pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); + _ctx->pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); // Parametro per le azioni speciali: random tra le parlate - parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( MCharacter[nChar].numtalks[MCharacter[nChar].curgroup] - 1) + 1; // Cerca di eseguire la funzione custom per inizializzare la parlata if (MCharacter[nChar].item) { - h = mpalQueryDoAction(30,MCharacter[nChar].item->MpalCode(), parm); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoActionU32(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_PID_VALUE) { + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + } } - VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); - FPSFX *voice = NULL; - if (curVoc) { + _ctx->curVoc = SearchVoiceHeader(0, dwMessage); + _ctx->voice = NULL; + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(curVoc->offset); - curOffset = curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->offset); + _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(vdb); } - for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { // Crea l'oggetto diverso se back o no if (bIsBack) { - curBackText=text = new RMTextDialogScrolling(Loc); + curBackText=_ctx->text = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); } else - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - text->SetInput(Input); + _ctx->text->SetInput(Input); // Skipping - text->SetSkipStatus(!bIsBack); + _ctx->text->SetSkipStatus(!bIsBack); // Allineamento - text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); + _ctx->text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); // Scrive il testo - text->WriteText(msg[i],nFont); + _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); // Setta la posizione - text->SetPosition(pt); + _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(text); + LinkGraphicTask(_ctx->text); - if (curVoc) { + if (_ctx->curVoc) { g_system->lockMutex(vdb); - _vm->_theSound.CreateSfx(&voice); - _vm->_vdbFP.seek(curOffset); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - voice->SetLoop(false); - if (bIsBack) voice->SetVolume(55); - voice->Play(); - text->SetCustomSkipHandle2(voice->hEndOfBuffer); - curOffset = _vm->_vdbFP.pos(); + _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->SetLoop(false); + if (bIsBack) _ctx->voice->SetVolume(55); + _ctx->voice->Play(); + _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->curOffset = _vm->_vdbFP.pos(); g_system->unlockMutex(vdb); } // Aspetta la fine della visualizzazione - text->SetCustomSkipHandle(hSkipIdle); - text->WaitForEndDisplay(); + _ctx->text->SetCustomSkipHandle(hSkipIdle); + CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice = NULL; } - curBackText=NULL; - delete text; + curBackText = NULL; + delete _ctx->text; + delete _ctx->msg; } // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { - h = mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); - if (h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoActionU32(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } + + CORO_END_CODE; } @@ -1894,7 +1947,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg LPSTR string; RMTextDialog *text; int parm; - HANDLE h; + uint32 h; bool bIsBack; VoiceHeader *curVoc; FPSFX *voice; @@ -1968,12 +2021,10 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } else { - RMPoint pt; - if (MCharacter[nPers].x == -1) - pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + _ctx->pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); else - pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); + _ctx->pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); // Parametro per le azioni speciali: random tra le parlate _ctx->parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( @@ -1983,9 +2034,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h,INFINITE); + _ctx->h = mpalQueryDoActionU32(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); MCharacter[nPers].curTalk = _ctx->parm; @@ -1998,7 +2049,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (MCharacter[nPers].bAlwaysBack) { _ctx->text = curBackText = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); + _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; @@ -2006,7 +2058,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); _ctx->text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); _ctx->text->WriteText(_ctx->string,0); - _ctx->text->SetPosition(pt); + _ctx->text->SetPosition(_ctx->pt); } if (!bSkipIdle) { @@ -2022,7 +2074,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(hSkipIdle); - _ctx->text->WaitForEndDisplay(); + CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } if (_ctx->curVoc) { @@ -2046,9 +2098,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); - if (_ctx->h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h,INFINITE); + _ctx->h = mpalQueryDoActionU32(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); MCharacter[nPers].bInTexts = false; MCharacter[nPers].numtexts = 0; @@ -2121,14 +2173,14 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Attiva l'oggetto LinkGraphicTask(&_ctx->dc); - _ctx->dc.Show(); + CORO_INVOKE_0(_ctx->dc.Show); // Disegna il puntatore Pointer->SetSpecialPointer(Pointer->PTR_NONE); MainShowMouse(); while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { - WaitFrame(); + CORO_INVOKE_0(WaitFrame); Freeze(); _ctx->dc.DoFrame(Input->MousePos()); Unfreeze(); @@ -2137,7 +2189,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Nascondi il puntatore MainHideMouse(); - _ctx->dc.Hide(); + CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta @@ -2162,7 +2214,8 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); - WaitForSingleObject(mut[num],INFINITE); +// WaitForSingleObject(mut[num],INFINITE); + warning("TODO"); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2197,33 +2250,50 @@ int curSonoriz = 0; bool bFadeOutStop; -void ThreadFadeInMusic(void *nMusic) { - int i; - int nChannel = (int)nMusic; +void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + int nChannel = *(const int *)nMusic; + + CORO_BEGIN_CODE(_ctx); debug("Start FadeIn Music\n"); - for (i = 0; i < 16; i++) { - _vm->SetMusicVolume(nChannel, i * 4); - Sleep(100); + for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { + _vm->SetMusicVolume(nChannel, _ctx->i * 4); + + CORO_INVOKE_1(g_scheduler->sleep, 100); } _vm->SetMusicVolume(nChannel, 64); debug("End FadeIn Music\n"); - _endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } -void ThreadFadeOutMusic(void *nMusic) { - int i; - int nChannel = (int)nMusic; - int startVolume = _vm->GetMusicVolume(nChannel); +void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { + CORO_BEGIN_CONTEXT; + int i; + int startVolume; + CORO_END_CONTEXT(_ctx); + + int nChannel = *(const int *)nMusic; + + CORO_BEGIN_CODE(_ctx); + + _ctx->startVolume = _vm->GetMusicVolume(nChannel); debug("Start FadeOut Music\n"); - for (i = 16; i > 0 && !bFadeOutStop; i--) { - if (i * 4 < startVolume) - _vm->SetMusicVolume(nChannel, i * 4); - Sleep(100); + for (_ctx->i = 16; _ctx->i > 0 && !bFadeOutStop; _ctx->i--) { + if (_ctx->i * 4 < _ctx->startVolume) + _vm->SetMusicVolume(nChannel, _ctx->i * 4); + + CORO_INVOKE_1(g_scheduler->sleep, 100); } if (!bFadeOutStop) @@ -2235,25 +2305,29 @@ void ThreadFadeOutMusic(void *nMusic) { debug("End FadeOut Music\n"); - _endthread(); + CORO_KILL_SELF(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _beginthread(ThreadFadeInMusic, 10240, (void*)curSonoriz); + g_scheduler->createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; - _beginthread(ThreadFadeOutMusic, 10240, (void *)curSonoriz); + g_scheduler->createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; - _beginthread(ThreadFadeOutMusic, 10240, (void*)2); + int channel = 2; + g_scheduler->createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _beginthread(ThreadFadeInMusic, 10240, (void*)2); + int channel = 2; + g_scheduler->createProcess(ThreadFadeInMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2475,12 +2549,12 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = true; - SetEvent(hSkipIdle); + g_scheduler->setEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = false; - ResetEvent(hSkipIdle); + g_scheduler->resetEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { @@ -2488,70 +2562,94 @@ DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32 } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - _vm->OpenInitLoadMenu(); + CORO_INVOKE_0(_vm->OpenInitLoadMenu); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - _vm->OpenInitOptions(); + CORO_INVOKE_0(_vm->OpenInitOptions); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint32, uint32) { - RMMessage msg(nMsg); - RMTextDialog *text; - HANDLE hDisable = CreateEvent(NULL, true, false, NULL); - int i; - uint32 startTime; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + RMTextDialog *text; + uint32 hDisable; + int i; + uint32 startTime; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(nMsg); + _ctx->hDisable = g_scheduler->createEvent(true, false); - text = new RMTextDialog[msg.NumPeriods()]; + _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; - for (i = 0; i < msg.NumPeriods(); i++) { - text[i].SetInput(Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { + _ctx->text[_ctx->i].SetInput(Input); // Allineamento - if (msg[i][0] == '@') { - text[i].SetAlignType(RMText::HCENTER, RMText::VTOP); - text[i].WriteText(&msg[i][1], 3); - text[i].SetPosition(RMPoint(414, 70 + i * 26)); // 70 + if ((*_ctx->msg)[_ctx->i][0] == '@') { + _ctx->text[_ctx->i].SetAlignType(RMText::HCENTER, RMText::VTOP); + _ctx->text[_ctx->i].WriteText(_ctx->msg[_ctx->i][1], 3); + _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { - text[i].SetAlignType(RMText::HLEFT,RMText::VTOP); - text[i].WriteText(msg[i], 3); - text[i].SetPosition(RMPoint(260, 70 + i * 26)); + _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT,RMText::VTOP); + _ctx->text[_ctx->i].WriteText((*_ctx->msg)[_ctx->i], 3); + _ctx->text[_ctx->i].SetPosition(RMPoint(260, 70 + _ctx->i * 26)); } // Setta la posizione - text[i].SetAlwaysDisplay(); - text[i].SetForcedTime(dwTime * 1000); - text[i].SetNoTab(); + _ctx->text[_ctx->i].SetAlwaysDisplay(); + _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); + _ctx->text[_ctx->i].SetNoTab(); // Aspetta la fine della visualizzazione - text[i].SetCustomSkipHandle(hDisable); + _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); // Registra il testo - LinkGraphicTask(&text[i]); + LinkGraphicTask(&_ctx->text[_ctx->i]); } - startTime = _vm->GetTime(); + _ctx->startTime = _vm->GetTime(); - while (startTime + dwTime * 1000 > _vm->GetTime()) { - WaitFrame(); + while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { + CORO_INVOKE_0(WaitFrame); if (Input->MouseLeftClicked() || Input->MouseRightClicked()) break; if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) break; } - SetEvent(hDisable); + g_scheduler->setEvent(_ctx->hDisable); + + CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(WaitFrame); - WaitFrame(); - WaitFrame(); + delete[] _ctx->text; + delete _ctx->msg; - delete[] text; + CORO_END_CODE; } @@ -2776,7 +2874,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation // Crea l'evento per skippare le idle - hSkipIdle = CreateEvent(NULL, true, false, NULL); + hSkipIdle = g_scheduler->createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 28e8f14d38..d04e1f0a13 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2048,23 +2048,23 @@ RMTextDialog::RMTextDialog() : RMText() { m_bForceNoTime = false; m_bAlwaysDisplay = false; m_bNoTab = false; - hCustomSkip = INVALID_HANDLE_VALUE; - hCustomSkip2 = INVALID_HANDLE_VALUE; + hCustomSkip = INVALID_PID_VALUE; + hCustomSkip2 = INVALID_PID_VALUE; m_input = NULL; // Crea l'evento di fine displaying - hEndDisplay = CreateEvent(NULL, false, false, NULL); + hEndDisplay = g_scheduler->createEvent(false, false); } RMTextDialog::~RMTextDialog() { - CloseHandle(hEndDisplay); + g_scheduler->closeEvent(hEndDisplay); } void RMTextDialog::Show(void) { m_bShowed = true; } -void RMTextDialog::Hide(void) { +void RMTextDialog::Hide(CORO_PARAM) { m_bShowed = false; } @@ -2084,7 +2084,7 @@ void RMTextDialog::WriteText(RMString text, RMFontColor *font, int *time) { void RMTextDialog::SetSkipStatus(bool bEnabled) { - m_bSkipStatus=bEnabled; + m_bSkipStatus = bEnabled; } void RMTextDialog::ForceTime(void) { @@ -2107,53 +2107,70 @@ void RMTextDialog::SetAlwaysDisplay(void) { m_bAlwaysDisplay = true; } -bool RMTextDialog::RemoveThis(void) { +void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { + CORO_BEGIN_CONTEXT; + bool expired; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + // Presume successful result + result = true; + // Frase NON di background if (m_bSkipStatus) { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) if (bCfgTimerizedText) { if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) - return true; + return; } if (!m_bNoTab) if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) - return true; + return; if (!m_bNoTab) if (m_input) if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) - return true; + return; } // Frase di background else { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) - return true; + return; } // Se il tempo forzato if (m_bForceTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) - return true; + return; - if (hCustomSkip != INVALID_HANDLE_VALUE) - if (WaitForSingleObject(hCustomSkip, 0) == WAIT_OBJECT_0) - return true; + if (hCustomSkip != INVALID_PID_VALUE) { + CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip, 0, &_ctx->expired); + // == WAIT_OBJECT_0 + if (!_ctx->expired) + return; + } + + if (bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE) { + CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); + // == WAIT_OBJECT_0 + if (!_ctx->expired) + return; + } - if (bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE) - if (WaitForSingleObject(hCustomSkip2,0) == WAIT_OBJECT_0) - return true; + result = false; - return false; + CORO_END_CODE; } void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - SetEvent(hEndDisplay); + g_scheduler->setEvent(hEndDisplay); } void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2168,16 +2185,16 @@ void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } -void RMTextDialog::SetCustomSkipHandle(HANDLE hCustom) { +void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { hCustomSkip = hCustom; } -void RMTextDialog::SetCustomSkipHandle2(HANDLE hCustom) { +void RMTextDialog::SetCustomSkipHandle2(uint32 hCustom) { hCustomSkip2 = hCustom; } -void RMTextDialog::WaitForEndDisplay(void) { - WaitForSingleObject(hEndDisplay, INFINITE); +void RMTextDialog::WaitForEndDisplay(CORO_PARAM) { + g_scheduler->waitForSingleObject(coroParam, hEndDisplay, INFINITE); } void RMTextDialog::SetInput(RMInput *input) { @@ -2231,9 +2248,16 @@ RMTextItemName::~RMTextItemName() { } -void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { - RMString itemName; - RMItem *lastItem = m_item; +void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { + CORO_BEGIN_CONTEXT; + RMString itemName; + RMItem *lastItem; + uint32 hThread; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->lastItem = m_item; // Si aggiunge alla lista se c'e' bisogno if (!m_nInList) @@ -2248,27 +2272,29 @@ void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPoint else m_item = loc.WhichItemIsIn(m_mpos); - itemName = ""; + _ctx->itemName = ""; // Si fa dare il nuovo nome if (m_item != NULL) - m_item->GetName(itemName); + m_item->GetName(_ctx->itemName); // Se lo scrive - WriteText(itemName, 1); + WriteText(_ctx->itemName, 1); // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer - if (lastItem != m_item) { + if (_ctx->lastItem != m_item) { if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { - HANDLE hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); - if (hThread == INVALID_HANDLE_VALUE) + _ctx->hThread = mpalQueryDoActionU32(20, m_item->MpalCode(), 0); + if (_ctx->hThread == INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else - WaitForSingleObject(hThread,INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); } } + + CORO_END_CODE; } @@ -2318,18 +2344,18 @@ RMDialogChoice::RMDialogChoice() { DlgText.LoadPaletteWA(dlgpal); DlgTextLine.LoadPaletteWA(dlgpal); - hUnreg=CreateEvent(NULL, false, false, NULL); + hUnreg = g_scheduler->createEvent(false, false); bRemoveFromOT = false; } RMDialogChoice::~RMDialogChoice() { - CloseHandle(hUnreg); + g_scheduler->closeEvent(hUnreg); } void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); assert(!m_nInList); - PulseEvent(hUnreg); + g_scheduler->pulseEvent(hUnreg); bRemoveFromOT = false; } @@ -2444,7 +2470,16 @@ void RMDialogChoice::SetSelected(int pos) { m_curSelection = pos; } -void RMDialogChoice::Show(RMGfxTargetBuffer *bigBuf) { +void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { + CORO_BEGIN_CONTEXT; + RMPoint destpt; + int deltay; + int starttime; + int elaps; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Prepare(); m_bShow = false; @@ -2454,30 +2489,28 @@ void RMDialogChoice::Show(RMGfxTargetBuffer *bigBuf) { if (0) { m_bShow = true; } else { - RMPoint destpt; - int deltay; - int starttime = _vm->GetTime(); - int elaps; - - deltay=480 - m_ptDrawPos.y; - destpt = m_ptDrawPos; + _ctx->starttime = _vm->GetTime(); + _ctx->deltay = 480 - m_ptDrawPos.y; + _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); if (!m_nInList && bigBuf != NULL) bigBuf->AddPrim(new RMGfxPrimitive(this)); m_bShow = true; - elaps = 0; - while (elaps < 700) { - MainWaitFrame(); + _ctx->elaps = 0; + while (_ctx->elaps < 700) { + CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - elaps = _vm->GetTime() - starttime; - m_ptDrawPos.y = 480 - ((deltay * 100) / 700 * elaps) / 100; + _ctx->elaps = _vm->GetTime() - _ctx->starttime; + m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; MainUnfreeze(); } - m_ptDrawPos.y = destpt.y; + m_ptDrawPos.y = _ctx->destpt.y; } + + CORO_END_CODE; } void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2489,26 +2522,34 @@ void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -void RMDialogChoice::Hide(void) { - if (1) { +void RMDialogChoice::Hide(CORO_PARAM) { + CORO_BEGIN_CONTEXT; int deltay; - int starttime = _vm->GetTime(); + int starttime; int elaps; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - deltay=480 - m_ptDrawPos.y; - elaps = 0; - while (elaps < 700) { - MainWaitFrame(); + if (1) { + _ctx->starttime = _vm->GetTime(); + + _ctx->deltay = 480 - m_ptDrawPos.y; + _ctx->elaps = 0; + while (_ctx->elaps < 700) { + CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - elaps=_vm->GetTime()-starttime; - m_ptDrawPos.y=480-((deltay*100)/700*(700-elaps))/100; + _ctx->elaps = _vm->GetTime()-_ctx->starttime; + m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; MainUnfreeze(); } } m_bShow = false; bRemoveFromOT = true; - WaitForSingleObject(hUnreg, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hUnreg, INFINITE); + + CORO_END_CODE; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 3012502d4c..0306c6c673 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -51,6 +51,7 @@ #include "common/system.h" #include "tony/gfxcore.h" #include "tony/resid.h" +#include "tony/sched.h" namespace Tony { @@ -247,12 +248,12 @@ class RMTextDialog : public RMText { int m_time; bool m_bSkipStatus; RMPoint dst; - HANDLE hEndDisplay; + uint32 hEndDisplay; bool m_bShowed; bool m_bForceTime; bool m_bForceNoTime; - HANDLE hCustomSkip; - HANDLE hCustomSkip2; + uint32 hCustomSkip; + uint32 hCustomSkip2; RMInput *m_input; bool m_bAlwaysDisplay; bool m_bNoTab; @@ -267,7 +268,7 @@ class RMTextDialog : public RMText { // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading della funzione di deregistrazione, utilizzata per capire // quando ci leviamo di torno @@ -280,9 +281,9 @@ class RMTextDialog : public RMText { void SetPosition(RMPoint pt) { dst=pt; } // Aspetta che venga finita la visualizzazione - void WaitForEndDisplay(void); - void SetCustomSkipHandle(HANDLE hCustomSkip); - void SetCustomSkipHandle2(HANDLE hCustomSkip); + void WaitForEndDisplay(CORO_PARAM); + void SetCustomSkipHandle(uint32 hCustomSkip); + void SetCustomSkipHandle2(uint32 hCustomSkip); void SetSkipStatus(bool bEnabled); void SetForcedTime(uint32 dwTime); void SetNoTab(void); @@ -294,7 +295,7 @@ class RMTextDialog : public RMText { void SetInput(RMInput* input); void Show(void); - void Hide(void); + void Hide(CORO_PARAM); }; class RMTextDialogScrolling : public RMTextDialog { @@ -332,7 +333,7 @@ public: void SetMouseCoord(RMPoint m) { m_mpos=m; } - void DoFrame(RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); RMPoint GetHotspot(); @@ -358,7 +359,7 @@ private: RMGfxSourceBuffer8 DlgText; RMGfxSourceBuffer8 DlgTextLine; RMPoint m_ptDrawPos; - HANDLE hUnreg; + uint32 hUnreg; bool bRemoveFromOT; protected: @@ -389,8 +390,8 @@ public: // Mostra e nasconde la scelta, con eventuali animazioni // NOTA: Se non viene passato parametro alla Show(), obbligo del // chiamante assicurarsi che la classe venga inserita alla OTlist - void Show(RMGfxTargetBuffer* bigBuf = NULL); - void Hide(void); + void Show(CORO_PARAM, RMGfxTargetBuffer* bigBuf = NULL); + void Hide(CORO_PARAM); // Polling di aggiornamento void DoFrame(RMPoint ptMousePos); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4eef8b0c96..59196ec18a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -112,8 +112,8 @@ void MainUnfreeze(void) { _vm->GetEngine()->Unfreeze(); } -void MainWaitFrame(void) { - WaitForSingleObject(_vm->m_hEndOfFrame, INFINITE); +void MainWaitFrame(CORO_PARAM) { + g_scheduler->waitForSingleObject(coroParam, _vm->m_hEndOfFrame, INFINITE); } void MainShowMouse(void) { @@ -144,8 +144,8 @@ void MainCloseWipe(void) { _vm->GetEngine()->CloseWipe(); } -void MainWaitWipeEnd(void) { - _vm->GetEngine()->WaitWipeEnd(); +void MainWaitWipeEnd(CORO_PARAM) { + _vm->GetEngine()->WaitWipeEnd(coroParam); } void MainEnableGUI(void) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index acf6339e73..12de3573eb 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -65,10 +65,12 @@ extern bool bSkipSfxNoLoop; bool bIdleExited; -void ExitAllIdles(CORO_PARAM, int nCurLoc) { +void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); + int nCurLoc = *(const int *)param; + CORO_BEGIN_CODE(_ctx); // Chiude le idle @@ -96,28 +98,27 @@ RMGfxEngine::~RMGfxEngine() { g_system->deleteMutex(csMainLoop); } -void RMGfxEngine::OpenOptionScreen(int type) { - bool bRes = false; - - switch (type) { - case 0: - bRes = m_opt.Init(m_bigBuf); - break; - case 1: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf,true); - break; - case 2: - bRes = m_opt.InitNoLoadSave(m_bigBuf); - break; - case 3: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf,false); - break; - case 4: - bRes = m_opt.InitSaveMenuOnly(m_bigBuf,false); - break; - } +void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { + CORO_BEGIN_CONTEXT; + bool bRes; + CORO_END_CONTEXT(_ctx); - if (bRes) { + CORO_BEGIN_CODE(_ctx); + + _ctx->bRes = false; + + if (type == 0) + _ctx->bRes = m_opt.Init(m_bigBuf); + else if (type == 1) + _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); + else if (type == 2) + _ctx->bRes = m_opt.InitNoLoadSave(m_bigBuf); + else if (type == 3) + _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); + else if (type == 4) + _ctx->bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); + + if (_ctx->bRes) { _vm->PauseSound(true); DisableInput(); @@ -135,16 +136,23 @@ void RMGfxEngine::OpenOptionScreen(int type) { if (type == 1 || type == 2) { bIdleExited = true; } else { - m_tony.StopNoAction(); + CORO_INVOKE_0(m_tony.StopNoAction); - uint32 id; bIdleExited = false; - CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); + + g_scheduler->createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); } } + + CORO_END_CODE; } -void RMGfxEngine::DoFrame(bool bDrawLocation) { +void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + g_system->lockMutex(csMainLoop); // Poll dei dispositivi di input @@ -212,15 +220,15 @@ void RMGfxEngine::DoFrame(bool bDrawLocation) { if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { - OpenOptionScreen(0); + OpenOptionScreen(nullContext, 0); goto SKIPCLICKSINISTRO; } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) - OpenOptionScreen(0); + OpenOptionScreen(nullContext, 0); else if (_vm->getIsDemo()) { if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) - OpenOptionScreen(3); + OpenOptionScreen(nullContext, 3); else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) - OpenOptionScreen(4); + OpenOptionScreen(nullContext, 4); } } } @@ -287,7 +295,7 @@ SKIPCLICKSINISTRO: // Aggiorna il nome sotto il puntatore del mouse m_itemName.SetMouseCoord(m_input.MousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) - m_itemName.DoFrame(m_bigBuf,m_loc,m_point,m_inv); + CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } // Inventario & interfaccia @@ -325,7 +333,7 @@ SKIPCLICKSINISTRO: switch (m_nWipeType) { case 1: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - SetEvent(m_hWipeEvent); + g_scheduler->setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -338,7 +346,7 @@ SKIPCLICKSINISTRO: case 2: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - SetEvent(m_hWipeEvent); + g_scheduler->setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -352,6 +360,8 @@ SKIPCLICKSINISTRO: } g_system->unlockMutex(csMainLoop); + + CORO_END_CODE; } @@ -524,7 +534,7 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { CORO_BEGIN_CONTEXT; - HANDLE h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -534,9 +544,9 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { // On Exit? if (bDoOnExit) { - _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (_ctx->h != INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h, INFINITE); + _ctx->h = mpalQueryDoActionU32(1, m_nCurLoc, 0); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } MainFreeze(); @@ -588,7 +598,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { bIdleExited = false; m_bOption = false; m_bWiping = false; - m_hWipeEvent = CreateEvent(NULL, false, false, NULL); + m_hWipeEvent = g_scheduler->createEvent(false, false); // Crea l'evento di freeze csMainLoop = g_system->createMutex(); @@ -986,8 +996,8 @@ void RMGfxEngine::CloseWipe(void) { m_bWiping = false; } -void RMGfxEngine::WaitWipeEnd(void) { - WaitForSingleObject(m_hWipeEvent,INFINITE); +void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { + g_scheduler->waitForSingleObject(coroParam, m_hWipeEvent, INFINITE); } } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 42b2050046..11d591b408 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -85,7 +85,7 @@ private: OSystem::MutexRef csMainLoop; int m_nWipeType; - HANDLE m_hWipeEvent; + uint32 m_hWipeEvent; int m_nWipeStep; bool m_bMustEnterMenu; @@ -103,7 +103,7 @@ public: virtual ~RMGfxEngine(); // Draw the next frame - void DoFrame(bool bDrawLocation); + void DoFrame(CORO_PARAM, bool bDrawLocation); // Initialises the graphics engine void Init(); @@ -118,7 +118,7 @@ public: void GDIControl(bool bCon); // Warns when entering or exits the options menu - void OpenOptionScreen(int type); + void OpenOptionScreen(CORO_PARAM, int type); // Enables or disables mouse input void EnableInput(void); @@ -157,7 +157,7 @@ public: // Wipe void InitWipe(int type); void CloseWipe(void); - void WaitWipeEnd(void); + void WaitWipeEnd(CORO_PARAM); void SetPalesati(bool bpal) { m_inter.SetPalesati(bpal); } }; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 4eced3fbd5..a412f9cfd2 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -248,12 +248,12 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { return m_nCurSprite; } -int RMPattern::Update(HANDLE hEndPattern, byte &bFlag, RMSfx *sfx) { +int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { int CurTime = _vm->GetTime(); // Se la speed e' 0, il pattern non avanza mai if (m_speed == 0) { - PulseEvent(hEndPattern); + g_scheduler->pulseEvent(hEndPattern); bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -266,7 +266,8 @@ int RMPattern::Update(HANDLE hEndPattern, byte &bFlag, RMSfx *sfx) { if (m_nCurSlot == m_nSlots) { m_nCurSlot = 0; bFlag = m_slots[m_nCurSlot].m_flag; - PulseEvent(hEndPattern); + + g_scheduler->pulseEvent(hEndPattern); // @@@ Se non c'e' loop avverte che il pattern e' finito // Se non c'e' loop rimane sull'ultimo frame @@ -705,9 +706,8 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return false; // Facciamo un update del pattern, che ci ritorna anche il frame corrente - // FIXME: Get rid of HANDLE cast if (m_nCurPattern != 0) - m_nCurSprite = m_patterns[m_nCurPattern].Update((HANDLE)m_hEndPattern, m_bCurFlag, m_sfx); + m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito if (m_nCurSprite == -1) { @@ -844,7 +844,7 @@ RMItem::~RMItem() { } //FIXME: Pass uint32 directly for hCustomSkip -void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { +void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; uint32 h[2]; CORO_END_CONTEXT(_ctx); @@ -852,10 +852,10 @@ void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { CORO_BEGIN_CODE(_ctx); if (m_nCurPattern != 0) { - if (hCustomSkip == INVALID_HANDLE_VALUE) + if (hCustomSkip == INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndPattern, INFINITE); else { - _ctx->h[0] = (uint32)hCustomSkip; + _ctx->h[0] = hCustomSkip; _ctx->h[1] = m_hEndPattern; CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); } @@ -888,13 +888,13 @@ void RMItem::PauseSound(bool bPause) { RMWipe::RMWipe() { - m_hUnregistered=CreateEvent(NULL,false,false,NULL); - m_hEndOfFade=CreateEvent(NULL,false,false,NULL); + m_hUnregistered = g_scheduler->createEvent(false, false); + m_hEndOfFade = g_scheduler->createEvent(false, false); } RMWipe::~RMWipe() { - CloseHandle(m_hUnregistered); - CloseHandle(m_hEndOfFade); + g_scheduler->closeEvent(m_hUnregistered); + g_scheduler->closeEvent(m_hEndOfFade); } int RMWipe::Priority(void) { @@ -904,19 +904,28 @@ int RMWipe::Priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - SetEvent(m_hUnregistered); + g_scheduler->setEvent(m_hUnregistered); } bool RMWipe::RemoveThis(void) { return m_bUnregister; } -void RMWipe::WaitForFadeEnd(void) { - WaitForSingleObject(m_hEndOfFade, INFINITE); +void RMWipe::WaitForFadeEnd(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndOfFade, INFINITE); + m_bEndFade = true; m_bFading = false; - MainWaitFrame(); - MainWaitFrame(); + + CORO_INVOKE_0(MainWaitFrame); + CORO_INVOKE_0(MainWaitFrame); + + CORO_END_CODE; } void RMWipe::CloseFade(void) { @@ -958,7 +967,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { m_nFadeStep++; if (m_nFadeStep == 10) { - SetEvent(m_hEndOfFade); + g_scheduler->setEvent(m_hEndOfFade); } } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 153ef7f18c..744dab3c25 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -171,7 +171,7 @@ public: // Update the pattern, checking to see if it's time to change slot and executing // any associated commands - int Update(HANDLE hEndPattern, byte& bFlag, RMSfx* sfx); + int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); // Stop a sound effect void StopSfx(RMSfx *sfx); @@ -292,7 +292,7 @@ public: void Unload(void); // Aspetta la fine del pattern in play - void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE); + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE); // Setta un nuovo hotspot per l'oggetto void ChangeHotspot(RMPoint pt); @@ -494,9 +494,9 @@ private: bool m_bFading; bool m_bEndFade; bool m_bUnregister; - HANDLE m_hUnregistered; + uint32 m_hUnregistered; int m_nFadeStep; - HANDLE m_hEndOfFade; + uint32 m_hEndOfFade; bool m_bMustRegister; RMItem m_wip0r; @@ -510,7 +510,7 @@ public: void InitFade(int type); void CloseFade(void); - void WaitForFadeEnd(void); + void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); virtual bool RemoveThis(void); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 27ef3f99c5..9d6ef19e55 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -174,10 +174,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (num >= MAX_PERIODS_PER_DIALOG - 1) { - Common::String msg = Common::String::format("Too much periods in dialog #%d", lpmdDialog->nObj); - MessageBox(msg); - } + if (num >= MAX_PERIODS_PER_DIALOG - 1) + error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -195,19 +193,15 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { num = READ_LE_UINT16(lpBuf); lpBuf += 2; curCmd = 0; - if (num >= MAX_GROUPS_PER_DIALOG) { - Common::String msg = Common::String::format("Too much groups in dialog #%d", lpmdDialog->nObj); - MessageBox(msg); - } + if (num >= MAX_GROUPS_PER_DIALOG) + error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) { - Common::String msg = Common::String::format("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); - MessageBox(msg); - } + if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); for (j = 0; j < lpmdDialog->Group[i].nCmds; j++) { lpmdDialog->Command[curCmd].type = *lpBuf; @@ -262,28 +256,22 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } } - if (curCmd >= MAX_COMMANDS_PER_DIALOG) { - Common::String msg = Common::String::format("Too much commands in dialog #%d",lpmdDialog->nObj); - MessageBox(msg); - } + if (curCmd >= MAX_COMMANDS_PER_DIALOG) + error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ num=*(uint16 *)lpBuf; lpBuf += 2; - if (num >= MAX_CHOICES_PER_DIALOG) { - Common::String msg = Common::String::format("Too much choices in dialog #%d",lpmdDialog->nObj); - MessageBox(msg); - } + if (num >= MAX_CHOICES_PER_DIALOG) + error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; - if (num2 >= MAX_SELECTS_PER_CHOICE) { - Common::String msg = Common::String::format("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); - MessageBox(msg); - } + if (num2 >= MAX_SELECTS_PER_CHOICE) + error("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); for (j = 0; j < num2; j++) { // When @@ -311,10 +299,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { // PlayGroup num3 = *lpBuf; *lpBuf++; - if (num3 >= MAX_PLAYGROUPS_PER_SELECT) { - Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); - MessageBox(msg); - } + if (num3 >= MAX_PLAYGROUPS_PER_SELECT) + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -365,10 +351,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { CopyMemory(lpmiItem->lpszDescribe,lpBuf, MIN((byte)127, len)); lpBuf+=len; - if (len >= MAX_DESCRIBE_SIZE) { - Common::String msg = Common::String::format("Describe too long in item #%d",lpmiItem->nObj); - MessageBox(msg); - } + if (len >= MAX_DESCRIBE_SIZE) + error("Describe too long in item #%d",lpmiItem->nObj); lpmiItem->nActions=*lpBuf; lpBuf++; @@ -408,10 +392,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].nCmds=*lpBuf; lpBuf++; - if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) { - Common::String msg = Common::String::format("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); - MessageBox(msg); - } + if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) + error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); for (j=0;jAction[i].nCmds;j++) { lpmiItem->Command[curCmd].type=*lpBuf; @@ -455,9 +437,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { - Common::String msg = Common::String::format("Too much commands in item #%d",lpmiItem->nObj); - MessageBox(msg); - curCmd=0; + error("Too much commands in item #%d",lpmiItem->nObj); + //curCmd=0; } } } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 0cea50a3d3..d6230d7768 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -137,9 +137,9 @@ uint32 * lpResources; bool bExecutingAction; bool bExecutingDialog; -uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; -HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; -uint32 PollingThreads[MAXPOLLINGLOCATIONS]; +uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; +uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; +uint32 PollingThreads[MAXPOLLINGLOCATIONS]; uint32 hAskChoice; uint32 hDoneChoice; @@ -830,14 +830,20 @@ static LPITEM GetItemData(uint32 nOrdItem) { * \****************************************************************************/ -void PASCAL CustomThread(LPCFCALL p) { - // FIXME: Convert to proper corotuine call - warning("FIXME: CustomThread call"); +void CustomThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + LPCFCALL p; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->p = *(LPCFCALL *)param; - lplpFunctions[p->nCf](nullContext, p->arg1, p->arg2, p->arg3, p->arg4); - GlobalFree(p); - ExitThread(1); -// _endthread(); + CORO_INVOKE_4(lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); + + GlobalFree(_ctx->p); + + CORO_END_CODE; } @@ -855,78 +861,87 @@ void PASCAL CustomThread(LPCFCALL p) { * \****************************************************************************/ -void PASCAL ScriptThread(LPMPALSCRIPT s) { - uint i,j,k; - uint32 dwStartTime = timeGetTime(); - uint32 dwCurTime; - uint32 dwId; - static HANDLE cfHandles[MAX_COMMANDS_PER_MOMENT]; - int numHandles = 0; - LPCFCALL p; +void ScriptThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + uint i, j, k; + uint32 dwStartTime; + uint32 dwCurTime; + uint32 dwId; + int numHandles; + LPCFCALL p; + CORO_END_CONTEXT(_ctx); + + static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; + LPMPALSCRIPT s = *(const LPMPALSCRIPT *)param; + + CORO_BEGIN_CODE(_ctx); + + _ctx->dwStartTime = _vm->GetTime(); + _ctx->numHandles = 0; // warning("PlayScript(): Moments: %u\n",s->nMoments); - for (i = 0; i < s->nMoments; i++) { + for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { // Dorme il tempo necessario per arrivare al momento successivo - if (s->Moment[i].dwTime == -1) { - WaitForMultipleObjects(numHandles, cfHandles, true, INFINITE); - dwStartTime = timeGetTime(); + if (s->Moment[_ctx->i].dwTime == -1) { + CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, _ctx->numHandles, cfHandles, true, INFINITE); + _ctx->dwStartTime = _vm->GetTime(); } else { - dwCurTime = timeGetTime(); - if (dwCurTime < dwStartTime + (s->Moment[i].dwTime * 100)) { - // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); - Sleep(dwStartTime+(s->Moment[i].dwTime * 100) - dwCurTime); + _ctx->dwCurTime = _vm->GetTime(); + if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { + // warning("PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); + CORO_INVOKE_1(g_scheduler->sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); } } - numHandles = 0; - for (j = 0;jMoment[i].nCmds; j++) { - k=s->Moment[i].CmdNum[j]; + _ctx->numHandles = 0; + for (_ctx->j = 0; _ctx->jMoment[_ctx->i].nCmds; _ctx->j++) { + _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; - switch (s->Command[k].type) { - case 1: - p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); - if (p == NULL) { + if (s->Command[_ctx->k].type == 1) { + _ctx->p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + if (_ctx->p == NULL) { mpalError = 1; - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; } - p->nCf=s->Command[k].nCf; - p->arg1=s->Command[k].arg1; - p->arg2=s->Command[k].arg2; - p->arg3=s->Command[k].arg3; - p->arg4=s->Command[k].arg4; + _ctx->p->nCf=s->Command[_ctx->k].nCf; + _ctx->p->arg1=s->Command[_ctx->k].arg1; + _ctx->p->arg2=s->Command[_ctx->k].arg2; + _ctx->p->arg3=s->Command[_ctx->k].arg3; + _ctx->p->arg4=s->Command[_ctx->k].arg4; // !!! Nuova gestione dei thread - if ((cfHandles[numHandles++] = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)CustomThread,(void *)p, 0, &dwId)) == NULL) { - //if ((cfHandles[numHandles++]=(void*)_beginthread(CustomThread, 10240, (void *)p))==(void*)-1) + if ((cfHandles[_ctx->numHandles++] = g_scheduler->createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { mpalError = 1; - ExitThread(0); -// _endthread(); - } - break; - case 2: + CORO_KILL_SELF(); + return; + } + } else if (s->Command[_ctx->k].type == 2) { LockVar(); varSetValue( - s->Command[k].lpszVarName, - EvaluateExpression(s->Command[k].expr) + s->Command[_ctx->k].lpszVarName, + EvaluateExpression(s->Command[_ctx->k].expr) ); UnlockVar(); - break; - default: + } else { mpalError = 1; GlobalFree(s); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; } } } GlobalFree(s); - ExitThread(1); - //_endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } @@ -1063,6 +1078,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { uint32 dwId; int ord; bool delayExpired; + bool expired; MYACTION *MyActions; MYTHREAD *MyThreads; @@ -1122,7 +1138,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } /* Inizializziamo le routine random */ - //curTime = timeGetTime(); + //curTime = _vm->GetTime(); //srand(curTime); @@ -1157,7 +1173,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = timeGetTime(); + _ctx->MyActions[_ctx->k].dwLastTime = _vm->GetTime(); _ctx->k++; } } @@ -1172,7 +1188,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - _ctx->curTime = timeGetTime(); + _ctx->curTime = _vm->GetTime(); _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) @@ -1184,8 +1200,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - _ctx->k = WaitForSingleObject(hEndPollingLocations[id], _ctx->dwSleepTime); - if (_ctx->k == WAIT_OBJECT_0) + + CORO_INVOKE_3(g_scheduler->waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + + //if (_ctx->k == WAIT_OBJECT_0) + if (!_ctx->expired) break; for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) @@ -1197,7 +1216,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = 0; } - _ctx->curTime = timeGetTime(); + _ctx->curTime = _vm->GetTime(); /* Cerchiamo all'interno delle idle actions quale e' necessario eseguire */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) @@ -2163,10 +2182,9 @@ bool EXPORT mpalExecuteScript(int nScript) { CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); UnlockScripts(); -// !!! Nuova gestione dei thread - if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s, 0, &dwId) == NULL) - //if ((void*)_beginthread(ScriptThread, 10240,(void *)s)==(void*)-1) - return false; + // !!! Nuova gestione dei thread + if (g_scheduler->createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == INVALID_PID_VALUE) + return false; return true; } @@ -2213,9 +2231,9 @@ bool mpalStartIdlePoll(int nLoc) { for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (nPollingLocations[i] == 0) { - nPollingLocations[i]=nLoc; + nPollingLocations[i] = nLoc; - hEndPollingLocations[i] = CreateEvent(NULL, true, false, NULL); + hEndPollingLocations[i] = g_scheduler->createEvent(true, false); // !!! Nuova gestione dei thread if ((PollingThreads[i] = g_scheduler->createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) @@ -2252,11 +2270,11 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { if (nPollingLocations[_ctx->i] == (uint32)nLoc) { - SetEvent(hEndPollingLocations[_ctx->i]); + g_scheduler->setEvent(hEndPollingLocations[_ctx->i]); CORO_INVOKE_2(g_scheduler->waitForSingleObject, PollingThreads[_ctx->i], INFINITE); - CloseHandle(hEndPollingLocations[_ctx->i]); + g_scheduler->closeEvent(hEndPollingLocations[_ctx->i]); nPollingLocations[_ctx->i] = 0; if (result) diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 58ecc6d6d9..23bc18b0ea 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -36,76 +36,6 @@ namespace Tony { namespace MPAL { -/** - * Display a message - * @param msg Message to display - */ -void MessageBox(const Common::String &msg) { - - _vm->GUIError(msg); -} - -/** - * Gets the current time in milliseconds - */ -uint32 timeGetTime() { - return g_system->getMillis(); -} - -HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, - uint32 dwCreationFlags, uint32 *lpThreadId) { - *lpThreadId = 0; - return 0; -} - -void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter) { -} - -void ExitThread(int ThreadId) { -} - -void _endthread() { -} - -void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { - -} - -void CloseHandle(HANDLE ThreadId) { - -} - -void Sleep(uint32 time) { -} - -int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime) { - warning("TODO: Old style WaitForSingleObject"); - return 0; -} - -uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds) { - warning("TODO: Old style WaitForMultipleObjects"); - return 0; -} - -HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName) { - warning("TODO: Refactor call to old style CreateEvent method"); - return 0; -} - -void SetEvent(HANDLE hEvent) { - warning("TODO: Refactor call to old style SetEvent method"); -} - -void ResetEvent(HANDLE hEvent) { - warning("TODO: Refactor call to old style ResetEvent method"); -} - -void PulseEvent(HANDLE hEvent) { - warning("TODO: Refactor call to old style PulseEvent method"); -} - uint16 GetAsyncKeyState(Common::KeyCode kc) { return 0; } diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index 5c50b76db1..082974898c 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -71,42 +71,8 @@ Out CopyMemory(Out dst, In first, int size) { * Methods \****************************************************************************/ -extern void MessageBox(const Common::String &msg); - -extern uint32 timeGetTime(); - -#define INFINITE 0xffffffff -#define WAIT_OBJECT_0 -2 // Horrendously bad cast -#define INVALID_HANDLE_VALUE (void *)-3 - -extern HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, - uint32 dwCreationFlags, uint32 *lpThreadId); - -extern void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter); - -extern void ExitThread(int ThreadId); - -extern void _endthread(); - -extern void TerminateThread(HANDLE ThreadId, uint32 dwExitCode); - -extern void CloseHandle(HANDLE ThreadId); - -extern void Sleep(uint32 time); - -extern int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime); - -extern uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds); - -extern HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName); - -extern void SetEvent(HANDLE hEvent); - -extern void ResetEvent(HANDLE hEvent); - -extern void PulseEvent(HANDLE hEvent); +#define INVALID_HANDLE_VALUE (void *)-1 extern uint16 GetAsyncKeyState(Common::KeyCode kc); diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 2671b01b7f..c447afa094 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -437,6 +437,40 @@ void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, CORO_END_CODE; } +/** + * Make the active process sleep for the given duration in milliseconds + * @param duration Duration in milliseconds + * @remarks This duration won't be precise, since it relies on the frequency the + * scheduler is called. + */ +void Scheduler::sleep(CORO_PARAM, uint32 duration) { + if (!pCurrent) + error("Called Scheduler::waitForSingleObject from the main process"); + + CORO_BEGIN_CONTEXT; + uint32 endTime; + PROCESS *pProcess; + EVENT *pEvent; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + // Signal as waiting + pCurrent->waiting = true; + + _ctx->endTime = g_system->getMillis() + duration; + + // Outer loop for doing checks until expiry + while (g_system->getMillis() < _ctx->endTime) { + // Sleep until the next cycle + CORO_SLEEP(1); + } + + // Signal waiting is done + pCurrent->waiting = false; + + CORO_END_CODE; +} /** * Creates a new process. diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 3997cb2c47..a9868edad0 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -37,6 +37,7 @@ namespace Tony { #define MAX_PROCESSES 100 #define INFINITE 0xffffffff +#define INVALID_PID_VALUE 0 typedef void (*CORO_ADDR)(CoroContext &, const void *); @@ -125,7 +126,8 @@ public: void giveWay(PPROCESS pReSchedProc = NULL); void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired = NULL); + uint32 duration, bool *expired = NULL); + void Scheduler::sleep(CORO_PARAM, uint32 duration); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 7c340be86e..b376d14149 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -2179,8 +2179,9 @@ void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); -#endif + ExitThread(0); +#endif } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 8853e1a344..e263c7ee51 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -240,7 +240,7 @@ private: // DSBPOSITIONNOTIFY dspnHot[2]; public: - HANDLE hEndOfBuffer; + uint32 hEndOfBuffer; private: diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d0bce68c3b..ef27f509b9 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -68,7 +68,7 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { - m_hEndOfFrame = CreateEvent(NULL, false, false, NULL); + m_hEndOfFrame = g_scheduler->createEvent(false, false); m_bPaused = false; m_bDrawLocation = true; @@ -295,16 +295,22 @@ void TonyEngine::GetSaveStateFileName(int n, char *buf) { name += ".sav"; } -void TonyEngine::AutoSave(void) { - char buf[256]; +void TonyEngine::AutoSave(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + char buf[256]; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); GrabThumbnail(); - MainWaitFrame(); - MainWaitFrame(); + CORO_INVOKE_0(MainWaitFrame); + CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - GetSaveStateFileName(0,buf); - _theEngine.SaveState(buf, (byte *)m_curThumbnail, "Autosave", true); + GetSaveStateFileName(0, _ctx->buf); + _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave", true); MainUnfreeze(); + + CORO_END_CODE; } @@ -375,12 +381,12 @@ void TonyEngine::GrabThumbnail(void) { void TonyEngine::OptionScreen(void) { } -void TonyEngine::OpenInitLoadMenu(void) { - _theEngine.OpenOptionScreen(1); +void TonyEngine::OpenInitLoadMenu(CORO_PARAM) { + _theEngine.OpenOptionScreen(coroParam, 1); } -void TonyEngine::OpenInitOptions(void) { - _theEngine.OpenOptionScreen(2); +void TonyEngine::OpenInitOptions(CORO_PARAM) { + _theEngine.OpenOptionScreen(coroParam, 2); } void TonyEngine::Abort(void) { @@ -400,10 +406,11 @@ void TonyEngine::Play(void) { _scheduler.schedule(); // Call the engine to handle the next frame - _theEngine.DoFrame(m_bDrawLocation); + // FIXME: This needs to be moved into it's own process + _theEngine.DoFrame(nullContext, m_bDrawLocation); // Warns that a frame is finished - PulseEvent(m_hEndOfFrame); + g_scheduler->pulseEvent(m_hEndOfFrame); // Handle drawing the frame if (!m_bPaused) { @@ -422,7 +429,7 @@ void TonyEngine::Play(void) { void TonyEngine::Close(void) { CloseMusic(); - CloseHandle(m_hEndOfFrame); + g_scheduler->closeEvent(m_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); _window.Close(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 3c7e8fe6b2..fdb92e3795 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -92,7 +92,7 @@ public: Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; - HANDLE m_hEndOfFrame; + uint32 m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; @@ -191,7 +191,7 @@ public: int GetMusicVolume(int nChannel); // Salvataggio - void AutoSave(void); + void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(int n); void GetSaveStateFileName(int n, char *buf); @@ -202,8 +202,8 @@ public: void Quit(void) { m_bQuitNow = true; } - void OpenInitLoadMenu(void); - void OpenInitOptions(void); + void OpenInitLoadMenu(CORO_PARAM); + void OpenInitOptions(CORO_PARAM); }; // Global reference to the TonyEngine object diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index ad13d49d54..ea233233d2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -212,6 +212,7 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { + // fixme: See if hThread can be converted to uint32 HANDLE hThread; uint32 pid; @@ -241,53 +242,64 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = hThread; + hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { hThread = mpalQueryDoAction(6, 1, 0); m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = hThread; + hActionThread = pid; } else if (nAction == TA_PALESATI) { hThread = mpalQueryDoAction(7, 1, 0); m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread=hThread; + hActionThread = pid; } else { hThread = mpalQueryDoAction(5, 1, 0); m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = hThread; + hActionThread = pid; } } } -void RMTony::StopNoAction(void) { +void RMTony::StopNoAction(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bAction) - WaitForSingleObject(hActionThread, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hActionThread, INFINITE); m_bActionPending = false; m_ActionItem = NULL; - Stop(); + CORO_INVOKE_0(Stop); + + CORO_END_CODE; } -void RMTony::Stop(void) { - HANDLE hThread; +void RMTony::Stop(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + uint32 hThread; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (m_ActionItem != NULL) { // Richiama l'MPAL per scegliere la direzione - hThread = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); + _ctx->hThread = mpalQueryDoActionU32(21, m_ActionItem->MpalCode(), 0); - if (hThread==INVALID_HANDLE_VALUE) + if (_ctx->hThread == INVALID_PID_VALUE) RMCharacter::Stop(); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; - WaitForSingleObject(hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { RMCharacter::Stop(); @@ -301,6 +313,8 @@ void RMTony::Stop(void) { ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); m_ActionItem=NULL; + + CORO_END_CODE; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 2cbcf60a00..98f247f688 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -123,7 +123,7 @@ private: int m_nTimeLastStep; RMItem m_body; - HANDLE hActionThread; + uint32 hActionThread; protected: // Overload dell'allocazione degli sprites per cambiare il tipo @@ -398,8 +398,8 @@ public: void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) - virtual void Stop(void); - void StopNoAction(void); + virtual void Stop(CORO_PARAM); + void StopNoAction(CORO_PARAM); // Setta un pattern void SetPattern(int npatt, bool bPlayP0 = false); @@ -408,7 +408,7 @@ public: int GetCurPattern(); // Attende la fine di un pattern - void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } -- cgit v1.2.3 From 5a069cdc861538fe763de48de8628d7d754f7959 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 9 May 2012 23:15:41 +1000 Subject: TONY: Refactored out usage of nullContext in favour of proper coroutines --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 34 +++-- engines/tony/font.cpp | 16 +- engines/tony/game.cpp | 170 ++++++++++----------- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 206 +++++++++++++------------ engines/tony/gfxengine.h | 6 +- engines/tony/loc.cpp | 4 +- engines/tony/mpal/mpal.cpp | 368 ++++++++++++++++++++++++++++++++------------- engines/tony/mpal/mpal.h | 59 ++++---- engines/tony/mpal/stubs.h | 3 - engines/tony/sound.cpp | 6 +- engines/tony/tony.cpp | 77 +++++++--- engines/tony/tony.h | 3 +- engines/tony/tonychar.cpp | 37 ++--- engines/tony/window.cpp | 8 +- 16 files changed, 601 insertions(+), 402 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 22205cf05b..a1b21c1e08 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -91,8 +91,8 @@ enum RMTonyAction { }; // Funzioni globali -HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); +uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void MainLinkGraphicTask(RMGfxTask *task); void MainFreeze(void); void MainUnfreeze(void); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 9d46d7e6b7..150e199fc8 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -72,8 +72,8 @@ RMLocation *Loc; RMInventory *Inventory; RMInput *Input; -HANDLE (*LoadLocation)(int, RMPoint, RMPoint start); -void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, HANDLE *result); +uint32 (*LoadLocation)(int, RMPoint, RMPoint start); +void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); void (*Freeze)(void); void (*Unfreeze)(void); @@ -521,7 +521,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); Unfreeze(); - _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); + _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? if (_ctx->h != INVALID_PID_VALUE) @@ -698,7 +698,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint Unfreeze(); - _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); + _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!bNoOcchioDiBue) { CORO_INVOKE_0(WaitWipeEnd); @@ -1842,7 +1842,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per inizializzare la parlata if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoActionU32(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != INVALID_PID_VALUE) { CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } @@ -1923,7 +1923,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoActionU32(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } @@ -2034,7 +2034,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - _ctx->h = mpalQueryDoActionU32(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); @@ -2098,7 +2098,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoActionU32(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); @@ -2142,7 +2142,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr curDialog = nDialog; // Call MPAL to start the dialog - mpalQueryDoDialogU32(nDialog, nStartGroup); + mpalQueryDoDialog(nDialog, nStartGroup); // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); @@ -2154,7 +2154,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta if (_ctx->num == 1) { - mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[0]); + mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); continue; } @@ -2190,7 +2190,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr MainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); - mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[_ctx->sel]); + mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta _ctx->dc.Close(); @@ -2501,10 +2501,18 @@ DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint } -void RestoreMusic(void) { - PlaySonoriz(nullContext, lastMusic, 0, 0, 0); +void RestoreMusic(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(PlaySonoriz, lastMusic, 0, 0, 0); + if (lastTappeto != 0) CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); + + CORO_END_CODE; } void SaveMusic(Common::OutSaveFile *f) { diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index d04e1f0a13..5dbbd3f71f 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2236,7 +2236,7 @@ void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { /****************************************************************************\ -* Metodi di RMTextItemName +* RMTextItemName Methods \****************************************************************************/ RMTextItemName::RMTextItemName() : RMText() { @@ -2259,14 +2259,14 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _ctx->lastItem = m_item; - // Si aggiunge alla lista se c'e' bisogno + // Adds to the list if there is need if (!m_nInList) bigBuf.AddPrim(new RMGfxPrimitive(this)); - // Aggiorna le coordinate di scrolling + // Update the scrolling co-ordinates m_curscroll = loc.ScrollPosition(); - // Controlla se siamo sopra l'inventario + // Check if we are on the inventory if (inv.ItemInFocus(m_mpos)) m_item = inv.WhichItemIsIn(m_mpos); else @@ -2274,19 +2274,19 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _ctx->itemName = ""; - // Si fa dare il nuovo nome + // If there an item, get it's name if (m_item != NULL) m_item->GetName(_ctx->itemName); - // Se lo scrive + // Write it WriteText(_ctx->itemName, 1); - // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer + // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != m_item) { if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoActionU32(20, m_item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); if (_ctx->hThread == INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 59196ec18a..377ec73673 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -92,11 +92,11 @@ bool bPatIrqFreeze; /* Funzioni globali per la DLL Custom */ /****************************************/ -HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { +uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _vm->GetEngine()->UnloadLocation(coroParam, bDoOnExit, result); } @@ -934,110 +934,110 @@ void RMOptionScreen::ChangeState(STATE newState) { InitState(); } -void RMOptionScreen::DoFrame(RMInput *input) { - bool bLeftClick, bRightClick; - RMPoint mousePos; - bool bRefresh; - int i; +void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { + CORO_BEGIN_CONTEXT; + bool bLeftClick, bRightClick; + RMPoint mousePos; + bool bRefresh; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se non completamente aperto, non fare nulla if (m_FadeStep != 6) return; // Legge l'input - mousePos = input->MousePos(); - bLeftClick = input->MouseLeftClicked(); - bRightClick = input->MouseRightClicked(); + _ctx->mousePos = input->MousePos(); + _ctx->bLeftClick = input->MouseLeftClicked(); + _ctx->bRightClick = input->MouseRightClicked(); - bRefresh = false; + _ctx->bRefresh = false; if (m_bQuitConfirm) { - bRefresh |= m_ButtonQuitYes->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonQuitNo->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonQuitYes->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonQuitNo->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else { - bRefresh |= m_ButtonExit->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonExit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Controlla se ha clickato sull'uscita if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { // bottoni senza grafica... - m_ButtonGameMenu->DoFrame(mousePos, bLeftClick, bRightClick); - m_ButtonGfxMenu->DoFrame(mousePos, bLeftClick, bRightClick); - m_ButtonSoundMenu->DoFrame(mousePos, bLeftClick, bRightClick); + m_ButtonGameMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + m_ButtonGfxMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + m_ButtonSoundMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // bottoni con grafica if (!m_bNoLoadSave) { if (!_vm->getIsDemo()) { - bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonLoad->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSave->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } - bRefresh |= m_ButtonQuit->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonQuit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } - switch (m_nState) { - case MENUGAME: - bRefresh |= m_ButtonGame_Lock->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGame_TimerizedText->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGame_Scrolling->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGame_InterUp->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SlideTextSpeed->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SlideTonySpeed->DoFrame(mousePos, bLeftClick, bRightClick); - break; - - case MENUGFX: - bRefresh |= m_ButtonGfx_Anni30->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_Tips->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_Trans->DoFrame(mousePos, bLeftClick, bRightClick); - break; - - case MENUSOUND: - bRefresh |= m_SliderSound_Dubbing->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SliderSound_Music->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SliderSound_SFX->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSound_DubbingOn->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSound_MusicOn->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSound_SFXOn->DoFrame(mousePos, bLeftClick, bRightClick); - break; - - case MENULOAD: - case MENUSAVE: - for (i=0;i<6;i++) - m_ButtonSave_States[i]->DoFrame(mousePos, bLeftClick, bRightClick); + if (m_nState == MENUGAME) { + _ctx->bRefresh |= m_ButtonGame_Lock->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGame_TimerizedText->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGame_Scrolling->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGame_InterUp->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SlideTextSpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SlideTonySpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (m_nState == MENUGFX) { + _ctx->bRefresh |= m_ButtonGfx_Anni30->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_Tips->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_Trans->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (m_nState == MENUSOUND) { + _ctx->bRefresh |= m_SliderSound_Dubbing->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SliderSound_Music->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SliderSound_SFX->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSound_DubbingOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSound_MusicOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSound_SFXOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (m_nState == MENULOAD || m_nState == MENUSAVE) { + for (_ctx->i=0;_ctx->i<6;_ctx->i++) + m_ButtonSave_States[_ctx->i]->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (m_statePos > 0) - bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (m_statePos < 90) - bRefresh |= m_ButtonSave_ArrowRight->DoFrame(mousePos, bLeftClick, bRightClick); - break; + _ctx->bRefresh |= m_ButtonSave_ArrowRight->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + } } #define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; bRefresh = true; } + m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } /**************** STATO BOTTONI **************/ if (m_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { if (m_EditName[0] != '\0') { m_EditName[strlen(m_EditName) - 1] = '\0'; - bRefresh = true; + _ctx->bRefresh = true; } } - for (i=0;i<26 && strlen(m_EditName)<12;i++) + for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { - PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'A'); + PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { - PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'a'); + PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } - for (i = 0; i < 10 && strlen(m_EditName) < 12; i++) - PROCESS_CHAR((Common::KeyCode)((int)'0' + i), i + '0'); + for (_ctx->i = 0; _ctx->i < 10 && strlen(m_EditName) < 12; _ctx->i++) + PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); if (strlen(m_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_SPACE,' '); @@ -1056,7 +1056,7 @@ void RMOptionScreen::DoFrame(RMInput *input) { // ANNULLA if (KEYPRESS(Common::KEYCODE_ESCAPE)) { m_bEditSaveName = false; - bRefresh = true; + _ctx->bRefresh = true; } // OK @@ -1066,7 +1066,7 @@ void RMOptionScreen::DoFrame(RMInput *input) { Close(); } - } else if (bLeftClick) { + } else if (_ctx->bLeftClick) { if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_ButtonExit->IsActive()) { if (m_bLoadMenuOnly) { @@ -1074,14 +1074,14 @@ void RMOptionScreen::DoFrame(RMInput *input) { Close(); } else { ChangeState(m_nLastState); - bRefresh = true; + _ctx->bRefresh = true; } } else if (m_ButtonSave_ArrowLeft->IsActive()) { if (m_statePos > 0) { m_statePos -= 6; if (m_statePos < 0) m_statePos = 0; m_ButtonSave_ArrowLeft->SetActiveState(false); - bRefresh = true; + _ctx->bRefresh = true; RefreshThumbnails(); } } else if (m_ButtonSave_ArrowRight->IsActive()) { @@ -1089,25 +1089,25 @@ void RMOptionScreen::DoFrame(RMInput *input) { m_statePos += 6; if (m_statePos > 90) m_statePos = 90; m_ButtonSave_ArrowRight->SetActiveState(false); - bRefresh = true; + _ctx->bRefresh = true; RefreshThumbnails(); } } else { - for (i = 0; i < 6; i++) - if (m_ButtonSave_States[i]->IsActive()) { + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) + if (m_ButtonSave_States[_ctx->i]->IsActive()) { // C' da effettuare il salvataggio o il caricamento!!!! - if (m_nState == MENULOAD && m_curThumb[i] != NULL) { + if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento - _vm->LoadState(m_statePos+i); + CORO_INVOKE_1(_vm->LoadState, m_statePos+_ctx->i); Close(); - } else if (m_nState == MENUSAVE && (m_statePos != 0 || i != 0)) { + } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { // Attiva la modalit di editing m_bEditSaveName = true; - m_nEditPos = i; - strcpy(m_EditName, m_curThumbName[i]); - bRefresh = true; + m_nEditPos = _ctx->i; + strcpy(m_EditName, m_curThumbName[_ctx->i]); + _ctx->bRefresh = true; - //_vm->SaveState(m_statePos+i,"No name"); + //_vm->SaveState(m_statePos+_ctx->i,"No name"); //Close(); } @@ -1120,10 +1120,10 @@ void RMOptionScreen::DoFrame(RMInput *input) { if (m_bQuitConfirm) { if (m_ButtonQuitNo->IsActive()) { m_bQuitConfirm = false; - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonQuitYes->IsActive()) { m_bQuitConfirm = false; - bRefresh = true; + _ctx->bRefresh = true; _vm->Quit(); } @@ -1132,24 +1132,24 @@ void RMOptionScreen::DoFrame(RMInput *input) { m_bQuitConfirm = true; m_ButtonQuitNo->SetActiveState(false); m_ButtonQuitYes->SetActiveState(false); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonExit->IsActive()) Close(); else if (m_ButtonLoad->IsActive()) { ChangeState(MENULOAD); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonSave->IsActive()) { ChangeState(MENUSAVE); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { ChangeState(MENUGAME); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { ChangeState(MENUGFX); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { ChangeState(MENUSOUND); - bRefresh = true; + _ctx->bRefresh = true; } if (m_nState == MENUGFX) { @@ -1177,8 +1177,10 @@ void RMOptionScreen::DoFrame(RMInput *input) { if (!m_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) Close(); - if (bRefresh) + if (_ctx->bRefresh) RefreshAll(); + + CORO_END_CODE; } diff --git a/engines/tony/game.h b/engines/tony/game.h index 593203e443..55fed71380 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -300,7 +300,7 @@ public: bool RemoveThis(); // Polling per l'option screen - void DoFrame(RMInput *m_input); + void DoFrame(CORO_PARAM, RMInput *m_input); protected: diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 12de3573eb..3952d0c227 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -165,7 +165,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } if (m_bOption) { - m_opt.DoFrame(&m_input); + CORO_INVOKE_1(m_opt.DoFrame, &m_input); m_bOption = !m_opt.IsClosing(); if (!m_bOption) { DisableMouse(); @@ -220,15 +220,15 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { - OpenOptionScreen(nullContext, 0); + CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) - OpenOptionScreen(nullContext, 0); + CORO_INVOKE_1(OpenOptionScreen, 0); else if (_vm->getIsDemo()) { if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) - OpenOptionScreen(nullContext, 3); + CORO_INVOKE_1(OpenOptionScreen, 3); else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) - OpenOptionScreen(nullContext, 4); + CORO_INVOKE_1(OpenOptionScreen, 4); } } } @@ -494,7 +494,7 @@ void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star mpalStartIdlePoll(m_nCurLoc); } -HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { +uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bool bLoaded; int i; @@ -529,10 +529,10 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { m_bLocationLoaded = true; // On Enter per la locazion - return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); + return INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { +void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CONTEXT; uint32 h; CORO_END_CONTEXT(_ctx); @@ -544,7 +544,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { // On Exit? if (bDoOnExit) { - _ctx->h = mpalQueryDoActionU32(1, m_nCurLoc, 0); + _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } @@ -557,7 +557,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { m_loc.Unload(); if (result != NULL) - *result = INVALID_HANDLE_VALUE; + *result = INVALID_PID_VALUE; CORO_END_CODE; } @@ -707,7 +707,7 @@ void SaveChangedHotspot(Common::OutSaveFile *f); void LoadChangedHotspot(Common::InSaveFile *f); void ReapplyChangedHotspot(void); -void RestoreMusic(void); +void RestoreMusic(CORO_PARAM); void SaveMusic(Common::OutSaveFile *f); void LoadMusic(Common::InSaveFile *f); @@ -827,153 +827,159 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo delete f; } -void RMGfxEngine::LoadState(const char *fn) { +void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... - Common::InSaveFile *f; - byte *state, *statecmp; - uint size, sizecmp; - char buf[4]; - RMPoint tp; - int loc; - int ver; - int i; + CORO_BEGIN_CONTEXT; + Common::InSaveFile *f; + byte *state, *statecmp; + uint size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - f = g_system->getSavefileManager()->openForLoading(fn); - if (f == NULL) return; - f->read(buf, 4); - if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { - delete f; + _ctx->f = g_system->getSavefileManager()->openForLoading(fn); + if (_ctx->f == NULL) return; + _ctx->f->read(_ctx->buf, 4); + if (_ctx->buf[0] != 'R' || _ctx->buf[1] != 'M' || _ctx->buf[2] != 'S') { + delete _ctx->f; return; } - ver = buf[3]; + _ctx->ver = _ctx->buf[3]; - if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { - delete f; + if (_ctx->ver != 0x1 && _ctx->ver != 0x2 && _ctx->ver != 0x3 && _ctx->ver != 0x4 && _ctx->ver != 0x5 && _ctx->ver != 0x6 && _ctx->ver != 0x7) { + delete _ctx->f; return; } - if (ver >= 0x3) { - // C' il thumbnail. Se ver >= 5, compresso - if (ver >= 0x5) { - i = 0; - i = f->readUint32LE(); - f->seek(i); + if (_ctx->ver >= 0x3) { + // C' il thumbnail. Se _ctx->ver >= 5, compresso + if (_ctx->ver >= 0x5) { + _ctx->i = 0; + _ctx->i = _ctx->f->readUint32LE(); + _ctx->f->seek(_ctx->i); } else - f->seek(160 * 120 * 2, SEEK_CUR); + _ctx->f->seek(160 * 120 * 2, SEEK_CUR); } - if (ver >= 0x5) { + if (_ctx->ver >= 0x5) { // Skip del livello di difficolt - f->seek(1, SEEK_CUR); + _ctx->f->seek(1, SEEK_CUR); } - if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno - i = f->readByte(); - f->seek(i, SEEK_CUR); + if (_ctx->ver >= 0x4) { // Skippa il nome, che non serve a nessuno + _ctx->i = _ctx->f->readByte(); + _ctx->f->seek(_ctx->i, SEEK_CUR); } - loc = f->readUint32LE(); - loc = f->readUint32LE(); - tp.x = f->readUint32LE(); - tp.y = f->readUint32LE(); - size = f->readUint32LE(); + _ctx->loc = _ctx->f->readUint32LE(); + _ctx->loc = _ctx->f->readUint32LE(); + _ctx->tp.x = _ctx->f->readUint32LE(); + _ctx->tp.y = _ctx->f->readUint32LE(); + _ctx->size = _ctx->f->readUint32LE(); - if (ver >= 0x5) { + if (_ctx->ver >= 0x5) { // Stato MPAL compresso! - sizecmp = f->readUint32LE(); - state = new byte[size]; - statecmp = new byte[sizecmp]; - f->read(statecmp, sizecmp); - lzo1x_decompress(statecmp,sizecmp,state,&size); - delete[] statecmp; + _ctx->sizecmp = _ctx->f->readUint32LE(); + _ctx->state = new byte[_ctx->size]; + _ctx->statecmp = new byte[_ctx->sizecmp]; + _ctx->f->read(_ctx->statecmp, _ctx->sizecmp); + lzo1x_decompress(_ctx->statecmp,_ctx->sizecmp,_ctx->state,&_ctx->size); + delete[] _ctx->statecmp; } else { - state = new byte[size]; - f->read(state, size); + _ctx->state = new byte[_ctx->size]; + _ctx->f->read(_ctx->state, _ctx->size); } - mpalLoadState(state); - delete[] state; + mpalLoadState(_ctx->state); + delete[] _ctx->state; // inventario - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - m_inv.LoadState(state); - delete[] state; - - if (ver >= 0x2) { // Versione 2: box please - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - _vm->_theBoxes.LoadState(state); - delete[] state; + _ctx->size = _ctx->f->readUint32LE(); + _ctx->state = new byte[_ctx->size]; + _ctx->f->read(_ctx->state, _ctx->size); + m_inv.LoadState(_ctx->state); + delete[] _ctx->state; + + if (_ctx->ver >= 0x2) { // Versione 2: box please + _ctx->size = _ctx->f->readUint32LE(); + _ctx->state = new byte[_ctx->size]; + _ctx->f->read(_ctx->state, _ctx->size); + _vm->_theBoxes.LoadState(_ctx->state); + delete[] _ctx->state; } - if (ver >= 5) { + if (_ctx->ver >= 5) { // Versione 5: bool bStat = false; - bStat = f->readByte(); + bStat = _ctx->f->readByte(); m_tony.SetPastorella(bStat); - bStat = f->readByte(); + bStat = _ctx->f->readByte(); m_inter.SetPalesati(bStat); - CharsLoadAll(f); + CharsLoadAll(_ctx->f); } - if (ver >= 6) { + if (_ctx->ver >= 6) { // Carica le opzioni - bCfgInvLocked = f->readByte(); - bCfgInvNoScroll = f->readByte(); - bCfgTimerizedText = f->readByte(); - bCfgInvUp = f->readByte(); - bCfgAnni30 = f->readByte(); - bCfgAntiAlias = f->readByte(); - bCfgSottotitoli = f->readByte(); - bCfgTransparence = f->readByte(); - bCfgInterTips = f->readByte(); - bCfgDubbing = f->readByte(); - bCfgMusic = f->readByte(); - bCfgSFX = f->readByte(); - nCfgTonySpeed = f->readByte(); - nCfgTextSpeed = f->readByte(); - nCfgDubbingVolume = f->readByte(); - nCfgMusicVolume = f->readByte(); - nCfgSFXVolume = f->readByte(); + bCfgInvLocked = _ctx->f->readByte(); + bCfgInvNoScroll = _ctx->f->readByte(); + bCfgTimerizedText = _ctx->f->readByte(); + bCfgInvUp = _ctx->f->readByte(); + bCfgAnni30 = _ctx->f->readByte(); + bCfgAntiAlias = _ctx->f->readByte(); + bCfgSottotitoli = _ctx->f->readByte(); + bCfgTransparence = _ctx->f->readByte(); + bCfgInterTips = _ctx->f->readByte(); + bCfgDubbing = _ctx->f->readByte(); + bCfgMusic = _ctx->f->readByte(); + bCfgSFX = _ctx->f->readByte(); + nCfgTonySpeed = _ctx->f->readByte(); + nCfgTextSpeed = _ctx->f->readByte(); + nCfgDubbingVolume = _ctx->f->readByte(); + nCfgMusicVolume = _ctx->f->readByte(); + nCfgSFXVolume = _ctx->f->readByte(); // Carica gli hotspot - LoadChangedHotspot(f); + LoadChangedHotspot(_ctx->f); } - if (ver >= 7) { - LoadMusic(f); + if (_ctx->ver >= 7) { + LoadMusic(_ctx->f); } - delete f; + delete _ctx->f; - UnloadLocation(nullContext, false, NULL); - LoadLocation(loc,tp,RMPoint(-1, -1)); + CORO_INVOKE_2(UnloadLocation, false, NULL); + LoadLocation(_ctx->loc,_ctx->tp,RMPoint(-1, -1)); m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); // Le versioni vecchie necessitano di On enter - if (ver < 5) - mpalQueryDoActionU32(0, loc, 0); + if (_ctx->ver < 5) + mpalQueryDoAction(0, _ctx->loc, 0); else { // In quelle nuove, ci basta resettare gli mcode MCharResetCodes(); } - if (ver >= 6) + if (_ctx->ver >= 6) ReapplyChangedHotspot(); - RestoreMusic(); + CORO_INVOKE_0(RestoreMusic); m_bGUIInterface = true; m_bGUIInventory = true; m_bGUIOption = true; + + CORO_END_CODE; } void RMGfxEngine::PauseSound(bool bPause) { diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 11d591b408..d119bb07a6 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -137,8 +137,8 @@ public: void LinkGraphicTask(RMGfxTask *task) { m_bigBuf.AddPrim(new RMGfxPrimitive(task)); }; // Manage a location - HANDLE LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); - void UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); + uint32 LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); + void UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); // Freeze and unfreeze void Freeze(void); @@ -146,7 +146,7 @@ public: // State management void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false); - void LoadState(const char *fn); + void LoadState(CORO_PARAM, const char *fn); // Selects a location void SelectLocation(RMPoint ptTonyStart=RMPoint(-1,-1), RMPoint start=RMPoint(-1,-1)); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a412f9cfd2..bba1ad2f23 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1376,7 +1376,7 @@ void RMCharacter::NewBoxEntered(int nBox) { bool bOldReverse; // Richiama la On ExitBox - mpalQueryDoActionU32(3, curLocation, curbox); + mpalQueryDoAction(3, curLocation, curbox); cur = theBoxes->GetBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; @@ -1410,7 +1410,7 @@ void RMCharacter::NewBoxEntered(int nBox) { } // Richiama la On EnterBox - mpalQueryDoActionU32(2, curLocation, curbox); + mpalQueryDoAction(2, curLocation, curbox); } void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d6230d7768..c21d84cd9b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1570,7 +1570,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * uint32 dwParam Eventuale parametro per l'azione * * Return: Handle del thread che sta eseguendo l'azione, oppure -* INVALID_HANDLE_VALUE se l'azione non e' definita, o l'item +* INVALID_PID_VALUE se l'azione non e' definita, o l'item * e' disattivato. * * Note: Si puo' ottenere l'indice dell'item a partire dal suo numero @@ -1580,7 +1580,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * \****************************************************************************/ -static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { +static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; @@ -1589,7 +1589,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); if (varGetValue(buf.c_str()) <= 0) - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; for (i = 0; i < item->nActions; i++) { if (item->Action[i].num != nAction) @@ -1607,7 +1607,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // Duplichiamo l'item corrente e copiamo la azione #i nella #0 newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); @@ -1621,26 +1621,18 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // !!! New thread management if ((h = g_scheduler->createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; - if ((h = g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32))) == NULL) - return INVALID_HANDLE_VALUE; + if (g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) + return INVALID_PID_VALUE; -/* - if ((h=(void*)_beginthread(ActionThread, 10240,(void *)newitem))==(void*)-1) - return INVALID_HANDLE_VALUE; - - if ((h=(void*)_beginthread(ShutUpActionThread, 10240,(void *)h))==(void*)-1) - return INVALID_HANDLE_VALUE; - -*/ nExecutingAction = item->nObj; bExecutingAction = true; - return (HANDLE)h; + return h; } - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; } /** @@ -1649,7 +1641,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * @param nDlgOrd The index of the dialog in the dialog list * @param nGroup Number of the group to perform * @returns The process Id of the process running the dialog - * or INVALID_HANDLE_VALUE on error + * or INVALID_PID_VALUE on error * @remarks The dialogue runs in a thread created on purpose, * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. @@ -1669,14 +1661,14 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Create a thread that performs the dialogue group // Create the process - if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) - return 0; + if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == INVALID_PID_VALUE) + return INVALID_PID_VALUE; // Create a thread that waits until the end of the dialog process, and will restore the global variables - if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { + if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == INVALID_PID_VALUE) { // Something went wrong, so kill the previously started dialog process g_scheduler->killMatchingProcess(h); - return 0; + return INVALID_PID_VALUE; } return h; @@ -1912,16 +1904,23 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, * \****************************************************************************/ -#define GETARG(type) va_arg(v,type) +#define GETARG(type) va_arg(v, type) -void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { - CORO_BEGIN_CONTEXT; - int x, y, z; - char *n; - Common::String buf; - CORO_END_CONTEXT(_ctx); +/** + * MPAL Query variation #1 - dword return + * This variation handles mpal query types that need to return a dword result. + * + * @param wQueryType Query type + * @param v Variable length argument list + */ +uint32 mpalQueryDWORD(uint16 wQueryType, ...) { + int x, y, z; + Common::String buf; + uint32 dwRet = 0; + char *n; - CORO_BEGIN_CODE(_ctx); + va_list v; + va_start(v, wQueryType); mpalError = OK; @@ -1929,31 +1928,30 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { /* * uint32 mpalQuery(MPQ_VERSION); */ - *dwRet = HEX_VERSION; + dwRet = HEX_VERSION; } else if (wQueryType == MPQ_GLOBAL_VAR) { /* * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); */ LockVar(); - *dwRet = (uint32)varGetValue(GETARG(char *)); + dwRet = (uint32)varGetValue(GETARG(char *)); UnlockVar(); } else if (wQueryType == MPQ_MESSAGE) { /* * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); */ - LockMsg(); - *dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); - UnlockMsg(); + error("mpalQuery(MPQ_MESSAGE, uint32 nMsg) used incorrect method variant"); + } else if (wQueryType == MPQ_ITEM_PATTERN) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); */ LockVar(); - _ctx->buf = Common::String::format("Pattern.%u", GETARG(uint32)); - *dwRet = (uint32)varGetValue(_ctx->buf.c_str()); + buf = Common::String::format("Pattern.%u", GETARG(uint32)); + dwRet = (uint32)varGetValue(buf.c_str()); UnlockVar(); } else if (wQueryType == MPQ_LOCATION_SIZE) { @@ -1961,61 +1959,56 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ LockLocations(); - _ctx->x = locGetOrderFromNum(GETARG(uint32)); - _ctx->y = GETARG(uint32); - if (_ctx->x != -1) { - if (_ctx->y == MPQ_X) - *dwRet = lpmlLocations[_ctx->x].dwXlen; - else if (_ctx->y == MPQ_Y) - *dwRet = lpmlLocations[_ctx->x].dwYlen; + x = locGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + if (x != -1) { + if (y == MPQ_X) + dwRet = lpmlLocations[x].dwXlen; + else if (y == MPQ_Y) + dwRet = lpmlLocations[x].dwYlen; else mpalError = 1; } else mpalError = 1; + UnlockLocations(); } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); */ - LockLocations(); - _ctx->x = locGetOrderFromNum(GETARG(uint32)); - *dwRet = (uint32)resLoad(lpmlLocations[_ctx->x].dwPicRes); - UnlockLocations(); + error("mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc) used incorrect variant"); } else if (wQueryType == MPQ_RESOURCE) { /* * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); */ - *dwRet = (uint32)resLoad(GETARG(uint32)); + error("mpalQuery(MPQ_RESOURCE, uint32 dwRes) used incorrect variant"); } else if (wQueryType == MPQ_ITEM_LIST) { /* * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); */ - LockVar(); - *dwRet = (uint32)GetItemList(GETARG(uint32)); - LockVar(); + error("mpalQuery(MPQ_ITEM_LIST, uint32 nLoc) used incorrect variant"); } else if (wQueryType == MPQ_ITEM_DATA) { /* * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ - LockItems(); - *dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); - UnlockItems(); + error("mpalQuery(MPQ_ITEM_DATA, uint32 nItem) used incorrect variant"); } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { /* * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); */ LockVar(); - _ctx->x = GETARG(uint32); - _ctx->buf = Common::String::format("Status.%u", _ctx->x); - if (varGetValue(_ctx->buf.c_str()) <= 0) - *dwRet = (uint32)false; + x = GETARG(uint32); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + dwRet = (uint32)false; else - *dwRet = (uint32)true; + dwRet = (uint32)true; + UnlockVar(); } else if (wQueryType == MPQ_ITEM_NAME) { @@ -2023,15 +2016,15 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); */ LockVar(); - _ctx->x = GETARG(uint32); - _ctx->n = GETARG(char *); - _ctx->buf = Common::String::format("Status.%u", _ctx->x); - if (varGetValue(_ctx->buf.c_str()) <= 0) - _ctx->n[0]='\0'; + x = GETARG(uint32); + n = GETARG(char *); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + n[0]='\0'; else { LockItems(); - _ctx->y = itemGetOrderFromNum(_ctx->x); - CopyMemory(_ctx->n, (char *)(lpmiItems+_ctx->y)->lpszDescribe, MAX_DESCRIBE_SIZE); + y = itemGetOrderFromNum(x); + CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -2039,43 +2032,31 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { } else if (wQueryType == MPQ_DIALOG_PERIOD) { /* - * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + * char *mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); */ - LockDialogs(); - _ctx->y = GETARG(uint32); - *dwRet = (uint32)DuplicateDialogPeriod(_ctx->y); - UnlockDialogs(); + error("mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod) used incorrect variant"); } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); - - g_scheduler->resetEvent(hAskChoice); - - if (bExecutingDialog) - *dwRet = (uint32)nExecutingChoice; - else - *dwRet = (uint32)((int)-1); + error("mpalQuery(MPQ_DIALOG_WAITFORCHOICE) used incorrect variant"); } else if (wQueryType == MPQ_DIALOG_SELECTLIST) { /* * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); */ - LockDialogs(); - *dwRet = (uint32)GetSelectList(GETARG(uint32)); - UnlockDialogs(); - break; + error("mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice) used incorrect variant"); } else if (wQueryType == MPQ_DIALOG_SELECTION) { /* * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); */ LockDialogs(); - _ctx->x = GETARG(uint32); - _ctx->y = GETARG(uint32); - *dwRet = (uint32)DoSelection(_ctx->x,_ctx->y); + x = GETARG(uint32); + y = GETARG(uint32); + dwRet = (uint32)DoSelection(x, y); + UnlockDialogs(); } else if (wQueryType == MPQ_DO_ACTION) { @@ -2084,15 +2065,16 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { */ LockItems(); LockVar(); - _ctx->x = GETARG(uint32); - _ctx->z = GETARG(uint32); - _ctx->y = itemGetOrderFromNum(_ctx->z); - if (_ctx->y!=-1) { - *dwRet = (uint32)DoAction(_ctx->x, _ctx->y, GETARG(uint32)); + x = GETARG(uint32); + z = GETARG(uint32); + y = itemGetOrderFromNum(z); + if (y != -1) { + dwRet = DoAction(x, y, GETARG(uint32)); } else { - *dwRet = (uint32)INVALID_HANDLE_VALUE; + dwRet = INVALID_PID_VALUE; mpalError = 1; } + UnlockVar(); UnlockItems(); @@ -2103,9 +2085,9 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { if (!bExecutingDialog) { LockDialogs(); - _ctx->x = dialogGetOrderFromNum(GETARG(uint32)); - _ctx->y = GETARG(uint32); - *dwRet = DoDialog(_ctx->x, _ctx->y); + x = dialogGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + dwRet = DoDialog(x, y); UnlockDialogs(); } } else { @@ -2115,26 +2097,201 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { mpalError = 1; } - CORO_END_CODE; + va_end(v); + return dwRet; } -uint32 mpalQuery(uint16 wQueryType, ...) { - uint32 dwRet; +/** + * MPAL Query variation #1 - dword return + * This variation handles mpal query types that need to return a pointer/handle result + * + * @param wQueryType Query type + * @param v Variable length argument list + */ +HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { + int x, y; + char *n; + Common::String buf; va_list v; va_start(v, wQueryType); + void *hRet = NULL; + + mpalError = OK; - mpalQueryInner(nullContext, wQueryType, &dwRet, v); + if (wQueryType == MPQ_VERSION) { + /* + * uint32 mpalQuery(MPQ_VERSION); + */ + error("mpalQuery(MPQ_VERSION) used incorrect variant"); - va_end(v); + } else if (wQueryType == MPQ_GLOBAL_VAR) { + /* + * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); + */ + error("mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName) used incorrect variant"); - return dwRet; + } else if (wQueryType == MPQ_MESSAGE) { + /* + * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); + */ + LockMsg(); + hRet = DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + UnlockMsg(); + + } else if (wQueryType == MPQ_ITEM_PATTERN) { + /* + * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); + */ + error("mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem) used incorrect variant"); + + } else if (wQueryType == MPQ_LOCATION_SIZE) { + /* + * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); + */ + error("mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord) used incorrect variant"); + + } else if (wQueryType == MPQ_LOCATION_IMAGE) { + /* + * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); + */ + LockLocations(); + x = locGetOrderFromNum(GETARG(uint32)); + hRet = resLoad(lpmlLocations[x].dwPicRes); + UnlockLocations(); + + } else if (wQueryType == MPQ_RESOURCE) { + /* + * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); + */ + hRet = resLoad(GETARG(uint32)); + + } else if (wQueryType == MPQ_ITEM_LIST) { + /* + * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); + */ + LockVar(); + hRet = GetItemList(GETARG(uint32)); + LockVar(); + + } else if (wQueryType == MPQ_ITEM_DATA) { + /* + * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + */ + LockItems(); + hRet = GetItemData(itemGetOrderFromNum(GETARG(uint32))); + UnlockItems(); + + } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { + /* + * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); + */ + error("mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem) used incorrect variant"); + + } else if (wQueryType == MPQ_ITEM_NAME) { + /* + * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName); + */ + LockVar(); + x = GETARG(uint32); + n = GETARG(char *); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + n[0]='\0'; + else { + LockItems(); + y = itemGetOrderFromNum(x); + CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + UnlockItems(); + } + + UnlockVar(); + + } else if (wQueryType == MPQ_DIALOG_PERIOD) { + /* + * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + */ + LockDialogs(); + y = GETARG(uint32); + hRet = DuplicateDialogPeriod(y); + UnlockDialogs(); + + } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ + error("mpalQuery(MPQ_DIALOG_WAITFORCHOICE) used incorrect variant"); + + } else if (wQueryType == MPQ_DIALOG_SELECTLIST) { + /* + * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); + */ + LockDialogs(); + hRet = GetSelectList(GETARG(uint32)); + UnlockDialogs(); + + } else if (wQueryType == MPQ_DIALOG_SELECTION) { + /* + * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); + */ + error("mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData) used incorrect variant"); + + } else if (wQueryType == MPQ_DO_ACTION) { + /* + * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); + */ + error("mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam) used incorrect variant"); + + } else if (wQueryType == MPQ_DO_DIALOG) { + /* + * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); + */ + error("mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup) used incorrect variant"); + } else { + /* + * DEFAULT -> ERROR + */ + mpalError = 1; + } + + va_end(v); + return hRet; } -void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...) { +/** + * MPAL Query variation #1 - dword return + * This variation handles mpal query types that need to return a pointer/handle result + * + * @param wQueryType Query type + * @param dwRet DWORD return value (when coroutine method completes) + * @param v Variable length argument list + */ +void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { + CORO_BEGIN_CONTEXT; + uint32 dwRet; + CORO_END_CONTEXT(_ctx); + va_list v; - va_start(v, wQueryType); + va_start(v, dwRet); + + CORO_BEGIN_CODE(_ctx); + + if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); + + g_scheduler->resetEvent(hAskChoice); - mpalQueryInner(coroParam, wQueryType, dwRet, v); + if (bExecutingDialog) + *dwRet = (uint32)nExecutingChoice; + else + *dwRet = (uint32)((int)-1); + } else { + error("mpalQueryCORO called with unsupported query type"); + } + + CORO_END_CODE; va_end(v); } @@ -2171,7 +2328,6 @@ uint32 mpalGetError(void) { bool EXPORT mpalExecuteScript(int nScript) { int n; LPMPALSCRIPT s; - uint32 dwId; LockScripts(); n = scriptGetOrderFromNum(nScript); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 5517a6518c..9a85f2df17 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -156,7 +156,7 @@ enum QueryCoordinates { /****************************************************************************\ * enum QueryTypes * --------------- -* Description: Query can be used with mpalQuery (). In practice corresponds +* Description: Query can be used with mpalQuery methods. In practice corresponds * all claims that can do at the library \****************************************************************************/ @@ -252,7 +252,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryVersion() \ - (uint16)mpalQuery(MPQ_VERSION) + (uint16)mpalQueryDWORD(MPQ_VERSION) @@ -273,7 +273,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryGlobalVar(lpszVarName) \ - (uint32)mpalQuery(MPQ_GLOBAL_VAR,(const char *)(lpszVarName)) + mpalQueryDWORD(MPQ_GLOBAL_VAR, (const char *)(lpszVarName)) @@ -291,7 +291,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryResource(dwResId) \ - (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) + mpalQueryHANDLE(MPQ_RESOURCE, (uint32)(dwResId)) @@ -311,7 +311,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryMessage(nMsg) \ - (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) + (LPSTR)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) @@ -328,7 +328,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryLocationImage(nLoc) \ - (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) + mpalQueryHANDLE(MPQ_LOCATION_IMAGE, (uint32)(nLoc)) @@ -346,7 +346,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryLocationSize(nLoc,dwCoord) \ - (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + mpalQueryDWORD(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) @@ -361,9 +361,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * Return: List of objects (accessible by Item [0], Item [1], etc.) * \****************************************************************************/ - +// TODO: Check if the results of this are endian safe #define mpalQueryItemList(nLoc) \ - (uint32 *)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) + (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST,(uint32)(nLoc)) @@ -380,7 +380,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryItemData(nItem) \ - (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) + (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA,(uint32)(nItem)) @@ -400,7 +400,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryItemPattern(nItem) \ - (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) + mpalQueryDWORD(MPQ_ITEM_PATTERN,(uint32)(nItem)) @@ -417,7 +417,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryItemIsActive(nItem) \ - (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) /****************************************************************************\ @@ -435,8 +435,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * \****************************************************************************/ -#define mpalQueryItemName(nItem,lpszName) \ - (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) +#define mpalQueryItemName(nItem, lpszName) \ + mpalQueryHANDLE(MPQ_ITEM_NAME,(uint32)(nItem), (LPSTR)(lpszName)) @@ -459,7 +459,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogPeriod(nPeriod) \ - (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) + (LPSTR)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) @@ -475,7 +475,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogWaitForChoice(dwRet) \ - CORO_INVOKE_2(mpalQueryCoro, dwRet, MPQ_DIALOG_WAITFORCHOICE) + CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) /****************************************************************************\ * @@ -496,7 +496,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogSelectList(nChoice) \ - (uint32 *)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) @@ -521,10 +521,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogSelection(nChoice,dwData) \ - (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) -#define mpalQueryDialogSelectionU32(nChoice, dwData) \ - mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) /****************************************************************************\ * @@ -539,7 +537,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 dwParam Action parameter * * Return: Handle to the thread that is performing the action, or -* INVALID_HANDLE_VALUE if the action is not 'defined for +* INVALID_PID_VALUE if the action is not 'defined for * the item, or the item and 'off. * * Note: The parameter is used primarily to implement actions @@ -549,10 +547,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDoAction(nAction, nItem, dwParam) \ - (HANDLE)mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) + mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) -#define mpalQueryDoActionU32(nAction, nItem, dwParam) \ - mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) /****************************************************************************\ @@ -565,15 +561,12 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 nGroup Group number to use * * Return: Handle to the thread that is running the box, or -* INVALID_HANDLE_VALUE if the dialogue does not exist. +* INVALID_PID_VALUE if the dialogue does not exist. * \****************************************************************************/ #define mpalQueryDoDialog(nDialog,nGroup) \ - (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) - -#define mpalQueryDoDialogU32(nDialog, nGroup) \ - mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) + mpalQueryHANDLE(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) /****************************************************************************\ @@ -623,9 +616,13 @@ bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, * \****************************************************************************/ -uint32 EXPORT mpalQuery(uint16 wQueryType, ...); +typedef void *HANDLE; + +uint32 mpalQueryDWORD(uint16 wQueryType, ...); + +HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); -void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...); +void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); /****************************************************************************\ * diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index 082974898c..ae25f7127e 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -71,9 +71,6 @@ Out CopyMemory(Out dst, In first, int size) { * Methods \****************************************************************************/ -// Horrendously bad cast -#define INVALID_HANDLE_VALUE (void *)-1 - extern uint16 GetAsyncKeyState(Common::KeyCode kc); } // end of namespace MPAL diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index b376d14149..a2b3d7c8ce 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1021,7 +1021,7 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { lpDSNotify = NULL; lpDS = lpds; lastVolume = 63; - hEndOfBuffer = INVALID_HANDLE_VALUE; + hEndOfBuffer = INVALID_PID_VALUE; bIsVoice = false; if (bSoundSupported == false) @@ -1053,7 +1053,7 @@ FPSFX::~FPSFX() { RELEASE(lpDSNotify); - if (hEndOfBuffer != INVALID_HANDLE_VALUE) + if (hEndOfBuffer != INVALID_PID_VALUE) CloseHandle(hEndOfBuffer); RELEASE(lpDSBuffer); @@ -1415,7 +1415,7 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { bool FPSFX::Play() { #ifdef REFACTOR_ME if (bFileLoaded) { - if (hEndOfBuffer != INVALID_HANDLE_VALUE) + if (hEndOfBuffer != INVALID_PID_VALUE) ResetEvent(hEndOfBuffer); lpDSBuffer->SetCurrentPosition(0); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ef27f509b9..d8ea05d06a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -322,11 +322,17 @@ void TonyEngine::SaveState(int n, const char *name) { } -void TonyEngine::LoadState(int n) { - char buf[256]; +void TonyEngine::LoadState(CORO_PARAM, int n) { + CORO_BEGIN_CONTEXT; + char buf[256]; + CORO_END_CONTEXT(_ctx); - GetSaveStateFileName(n, buf); - _theEngine.LoadState(buf); + CORO_BEGIN_CODE(_ctx); + + GetSaveStateFileName(n, _ctx->buf); + CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf); + + CORO_END_CODE; } bool TonyEngine::OpenVoiceDatabase() { @@ -393,35 +399,66 @@ void TonyEngine::Abort(void) { m_bQuitNow = true; } -void TonyEngine::Play(void) { - // Main game loop - while (!shouldQuit() && !m_bQuitNow) { - // Se siamo in pausa, entra nel loop appropriato - if (m_bPaused) - PauseLoop(); +/** + * Main process for playing the game. + * + * @remarks This needs to be in a separate process, since there are some things that can briefly + * block the execution of process. For now, all ScummVm event handling is dispatched to within the context of this + * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain + * in the outer 'main' process. + */ +void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); - g_system->delayMillis(50); + CORO_BEGIN_CODE(_ctx); - // Call any scheduled processes - _scheduler.schedule(); + // Infinite loop. We rely on the outer main process to detect if a shutdown is required, + // and kill the scheudler and all the processes, including this one + for (;;) { + // Se siamo in pausa, entra nel loop appropriato + if (_vm->m_bPaused) + _vm->PauseLoop(); + + // Wait for the next frame + CORO_INVOKE_1(g_scheduler->sleep, 50); // Call the engine to handle the next frame // FIXME: This needs to be moved into it's own process - _theEngine.DoFrame(nullContext, m_bDrawLocation); + CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished - g_scheduler->pulseEvent(m_hEndOfFrame); + g_scheduler->pulseEvent(_vm->m_hEndOfFrame); // Handle drawing the frame - if (!m_bPaused) { - if (!_theEngine.m_bWiping) - _window.GetNewFrame(_theEngine, NULL); + if (!_vm->m_bPaused) { + if (!_vm->_theEngine.m_bWiping) + _vm->_window.GetNewFrame(_vm->_theEngine, NULL); else - _window.GetNewFrame(_theEngine, &_theEngine.m_rcWipeEllipse); + _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine.m_rcWipeEllipse); } // Paint the frame onto the screen - _window.Repaint(); + _vm->_window.Repaint(); + } + + CORO_END_CODE; +} + +/** + * Play the game + */ +void TonyEngine::Play(void) { + // Create the game player process + g_scheduler->createProcess(PlayProcess, NULL); + + // Loop through calling the scheduler until it's time for the game to quit + while (!shouldQuit() && !m_bQuitNow) { + // Delay for a brief amount + g_system->delayMillis(10); + + // Call any scheduled processes + _scheduler.schedule(); } } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index fdb92e3795..935f805912 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -82,6 +82,7 @@ private: bool OpenVoiceDatabase(); void CloseVoiceDatabase(); void InitCustomFunctionMap(); + static void PlayProcess(CORO_PARAM, const void *param); protected: // Engine APIs virtual Common::Error run(); @@ -193,7 +194,7 @@ public: // Salvataggio void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); - void LoadState(int n); + void LoadState(CORO_PARAM, int n); void GetSaveStateFileName(int n, char *buf); // Prende il thumbnail diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index ea233233d2..06adcd15b8 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -213,53 +213,48 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { // fixme: See if hThread can be converted to uint32 - HANDLE hThread; uint32 pid; if (nAction == TA_COMBINE) { - hThread = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); + pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); // Se fallito il combine, proviamo con il ReceiveCombine - if (hThread == INVALID_HANDLE_VALUE) { - hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + if (pid == INVALID_PID_VALUE) { + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); // Se fallito il receive, andiamo con quelli generici // @@@ CombineGive! - if (hThread == INVALID_HANDLE_VALUE) { - hThread = mpalQueryDoAction(TA_COMBINE, nParm, 0); + if (pid == INVALID_PID_VALUE) { + pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - if (hThread == INVALID_HANDLE_VALUE){ - hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); + if (pid == INVALID_PID_VALUE){ + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } } } else { // Perform the action - hThread = mpalQueryDoAction(nAction, nActionItem, 0); + pid = mpalQueryDoAction(nAction, nActionItem, 0); } - if (hThread != INVALID_HANDLE_VALUE) { + if (pid != INVALID_PID_VALUE) { m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { - hThread = mpalQueryDoAction(6, 1, 0); + pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction == TA_PALESATI) { - hThread = mpalQueryDoAction(7, 1, 0); + pid = mpalQueryDoAction(7, 1, 0); m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else { - hThread = mpalQueryDoAction(5, 1, 0); + pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } @@ -285,21 +280,21 @@ void RMTony::StopNoAction(CORO_PARAM) { void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; - uint32 hThread; + uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (m_ActionItem != NULL) { // Richiama l'MPAL per scegliere la direzione - _ctx->hThread = mpalQueryDoActionU32(21, m_ActionItem->MpalCode(), 0); + _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); - if (_ctx->hThread == INVALID_PID_VALUE) + if (_ctx->pid == INVALID_PID_VALUE) RMCharacter::Stop(); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { RMCharacter::Stop(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 8ac36a5693..f68c612911 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -149,7 +149,7 @@ byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; bool RMSnapshot::GetFreeSnapName(char *fn) { #ifdef REFACTOR_ME int i, j, k; - HANDLE h; + uint32 h; theGame.GetDataDirectory(RMGame::DD_SHOTS, fn); _splitpath(fn, bufDrive, bufDir, NULL, NULL); @@ -158,7 +158,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d00",i); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) + if (h == INVALID_PID_VALUE) break; CloseHandle(h); } @@ -169,7 +169,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d0",i,j); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_HANDLE_VALUE) + if (h==INVALID_PID_VALUE) break; CloseHandle(h); } @@ -180,7 +180,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d%d",i,j,k); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_HANDLE_VALUE) + if (h==INVALID_PID_VALUE) break; CloseHandle(h); } -- cgit v1.2.3 From 9a7393e0c397c2f5e3a6a9be06197d847ab0d28b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 May 2012 22:18:33 +1000 Subject: TONY: Fix operation of MPAL ActionThread method --- engines/tony/mpal/mpal.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index c21d84cd9b..da736a138f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -996,7 +996,6 @@ void ActionThread(CORO_PARAM, const void *param) { LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); UnlockVar(); - break; } else { mpalError = 1; -- cgit v1.2.3 From 82361a3ea3efb9b6454eb4805e777cd4bfc3a0e3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 00:09:34 +1000 Subject: TONY: Fixed some missed methods to coroutines --- engines/tony/custom.cpp | 4 +- engines/tony/gfxengine.cpp | 10 ++--- engines/tony/loc.cpp | 107 ++++++++++++++++++++++++++++++--------------- engines/tony/loc.h | 8 ++-- engines/tony/tonychar.cpp | 33 ++++++++++---- engines/tony/tonychar.h | 4 +- 6 files changed, 109 insertions(+), 57 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 150e199fc8..c82d0fcd2b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1337,7 +1337,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - Tony->Move(RMPoint(nX, nY)); + CORO_INVOKE_1(Tony->Move, RMPoint(nX, nY)); if (!bSkipIdle) CORO_INVOKE_0(Tony->WaitForEndMovement); @@ -1346,7 +1346,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(RMPoint(nX, nY)); + Tony->Move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 3952d0c227..5a9c0555e0 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -208,7 +208,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // *************** if (m_input.MouseRightReleased()) { if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { - m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(),m_curAction); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); m_curAction = TA_GOTO; m_point.SetAction(m_curAction); @@ -240,9 +240,9 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { //if (m_itemName.IsItemSelected()) { if (m_curAction != TA_COMBINE) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); else if (m_itemName.GetSelectedItem() != NULL) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); } if (m_curAction == TA_COMBINE) { @@ -283,7 +283,7 @@ SKIPCLICKSINISTRO: if (m_bGUIInterface) { if (m_inter.Released(m_input.MousePos(),m_curAction)) { m_point.SetAction(m_curAction); - m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(), m_curAction); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); m_curAction = TA_GOTO; m_point.SetAction(m_curAction); @@ -304,7 +304,7 @@ SKIPCLICKSINISTRO: } // Anima Tony - m_tony.DoFrame(&m_bigBuf, m_nCurLoc); + CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); // Aggiorna lo scrolling per tenere Tony dentro lo schermo if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index bba1ad2f23..080e06da87 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1087,10 +1087,15 @@ short RMCharacter::FindPath(short source, short destination) { } -void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { +void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_pos == destcoord) { if (minpath == 0) { - Stop(); + CORO_INVOKE_0(Stop); g_scheduler->pulseEvent(hEndOfPath); return; } @@ -1149,6 +1154,7 @@ void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { olddy = dy; // ResetEvent(hTonyEndMovement); @@@ + CORO_END_CODE; } @@ -1413,10 +1419,15 @@ void RMCharacter::NewBoxEntered(int nBox) { mpalQueryDoAction(2, curLocation, curbox); } -void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { - bool bEndNow; +void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { + CORO_BEGIN_CONTEXT; + bool bEndNow; + RMBoxLoc *cur; + CORO_END_CONTEXT(_ctx); - bEndNow = false; + CORO_BEGIN_CODE(_ctx); + + _ctx->bEndNow = false; bEndOfPath = false; bDrawNow = (curLocation == loc); @@ -1435,7 +1446,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { m_pos = lineend; status = STAND; - bEndNow = true; + _ctx->bEndNow = true; } } @@ -1450,7 +1461,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { m_pos = lineend; status = STAND; - bEndNow = true; + _ctx->bEndNow = true; } } @@ -1463,9 +1474,9 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // Se siamo appena arrivati alla destinazione temporanea ed finito il percorso minimo, // ci fermiamo definitivamente - if (bEndNow && minpath == 0) { + if (_ctx->bEndNow && minpath == 0) { if (!bEndOfPath) - Stop(); + CORO_INVOKE_0(Stop); bEndOfPath = true; g_scheduler->pulseEvent(hEndOfPath); } @@ -1487,15 +1498,15 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (status == STAND) { // Controlliamo se c' ancora percorso minimo da calcolare if (minpath == 1) { - RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->GetBoxes(curLocation); // Se dobbiamo ancora attraversare un box if (pathcount < pathlenght) { // Controlliamo che il box su cui stiamo entrando sia attivo - if (cur->boxes[path[pathcount-1]].attivo) { + if (_ctx->cur->boxes[path[pathcount-1]].attivo) { // Muoviti in linea retta verso l'hotspot pi vicino, tenendo conto del reversing please // NEWBOX = path[pathcount-1] - GoTo(NearestHotSpot(path[pathcount-1], path[pathcount]), cur->boxes[path[pathcount-1]].bReversed); + CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); pathcount++; } else { // Se il box disattivato, possiamo solo bloccare tutto @@ -1503,7 +1514,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // la ricerca del percorso minimo minpath = 0; if (!bEndOfPath) - Stop(); + CORO_INVOKE_0(Stop); bEndOfPath = true; g_scheduler->pulseEvent(hEndOfPath); } @@ -1512,7 +1523,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // punto di arrivo // NEWBOX = InWhichBox(pathend) minpath = 0; - GoTo(pathend, cur->boxes[InWhichBox(pathend)].bReversed); + CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed); } } } @@ -1521,9 +1532,16 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // Richiama il DoFrame dell'item RMItem::DoFrame(bigBuf); + + CORO_END_CODE; } -void RMCharacter::Stop(void) { +void RMCharacter::Stop(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + bMoving = false; // Non si sa mai... @@ -1558,6 +1576,8 @@ void RMCharacter::Stop(void) { SetPattern(PAT_STANDDOWN); break; } + + CORO_END_CODE; } inline int RMCharacter::InWhichBox(RMPoint pt) { @@ -1565,9 +1585,14 @@ inline int RMCharacter::InWhichBox(RMPoint pt) { } -bool RMCharacter::Move(RMPoint pt) { - RMPoint dest; - int numbox; +void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { + CORO_BEGIN_CONTEXT; + RMPoint dest; + int numbox; + RMBoxLoc *cur; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); bMoving = true; @@ -1575,31 +1600,33 @@ bool RMCharacter::Move(RMPoint pt) { if (pt.x == 0 && pt.y == 0) { minpath = 0; status = STAND; - Stop(); - return true; + CORO_INVOKE_0(Stop); + if (result) + *result = true; + return; } // Se clicko fuori dai box - numbox = InWhichBox(pt); - if (numbox == -1) { + _ctx->numbox = InWhichBox(pt); + if (_ctx->numbox == -1) { // Trova il punto pi vicino dentro i box - dest = NearestPoint(pt); + _ctx->dest = NearestPoint(pt); // ???!?? - if (dest == pt) - dest = InvScanLine(pt); + if (_ctx->dest == pt) + _ctx->dest = InvScanLine(pt); - pt = dest; - numbox = InWhichBox(pt); + pt = _ctx->dest; + _ctx->numbox = InWhichBox(pt); } - RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->GetBoxes(curLocation); minpath = 0; status = STAND; bMovingWithoutMinpath = true; if (ScanLine(pt)) - GoTo(pt, cur->boxes[numbox].bReversed); + CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; @@ -1609,22 +1636,30 @@ bool RMCharacter::Move(RMPoint pt) { // @@@ Questo caso se un hotspot dentro un box // ma non c' un path per arrivarci. Usiamo quindi // la invscanline per cercare un punto intorno - dest = InvScanLine(pt); - pt = dest; + _ctx->dest = InvScanLine(pt); + pt = _ctx->dest; if (ScanLine(pt)) - GoTo(pt,cur->boxes[numbox].bReversed); + CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; pathcount = 1; pathend = pt; - return true; - } else - return false; + if (result) + *result = true; + } else { + if (result) + *result = false; + } + + return; } - return true; + if (result) + *result = true; + + CORO_END_CODE; } void RMCharacter::SetPosition(RMPoint pt, int newloc) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 744dab3c25..f5826022e0 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -439,7 +439,7 @@ private: RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); RMPoint NearestPoint(RMPoint punto); - void GoTo(RMPoint destcoord, bool bReversed=false); + void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); short ScanLine(RMPoint punto); RMPoint InvScanLine(RMPoint punto); RMPoint NearestHotSpot(int sourcebox, int destbox); @@ -461,7 +461,7 @@ public: virtual bool RemoveThis(void); // Aggiorna la posizione del personaggio - void DoFrame(RMGfxTargetBuffer* bigBuf, int loc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloading del Draw void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); @@ -470,13 +470,13 @@ public: bool EndOfPath() { return bEndOfPath; } // Cambia il pattern del personaggio per fermarlo - virtual void Stop(void); + virtual void Stop(CORO_PARAM); // Controlla se il personaggio si sta muovendo bool IsMoving() { return bMoving; } // Muove il personaggio a una certa posizione - bool Move(RMPoint pt); + void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); // Posiziona il personaggio a una certa posizione SENZA farlo muovere void SetPosition(RMPoint pt, int newloc=-1); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 06adcd15b8..c3deae497b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -125,20 +125,26 @@ void RMTony::Close(void) { m_ombra.Destroy(); } -void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { +void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { + CORO_BEGIN_CONTEXT; + int time; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); SetSpeed(nCfgTonySpeed); // Esegue il movimento normale del personaggio - int time = _vm->GetTime(); + _ctx->time = _vm->GetTime(); do { m_nTimeLastStep += (1000 / 40); - RMCharacter::DoFrame(bigBuf, curLoc); + CORO_INVOKE_2(RMCharacter::DoFrame, bigBuf, curLoc); - } while (time > m_nTimeLastStep + (1000 / 40)); + } while (_ctx->time > m_nTimeLastStep + (1000 / 40)); // Controlla se siamo alla fine del percorso if (EndOfPath() && m_bActionPending) { @@ -148,6 +154,8 @@ void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { if (m_bIsTalking || m_bIsStaticTalk) m_body.DoFrame(bigBuf, false); + + CORO_END_CODE; } void RMTony::Show(void) { @@ -192,7 +200,13 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } -void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm) { +void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { + CORO_BEGIN_CONTEXT; + bool result; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Fa il movimento normale, ma si ricorda se deve poi eseguire un azione if (item == NULL) { m_bActionPending = false; @@ -204,10 +218,13 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction m_bActionPending = true; } - if (!RMCharacter::Move(dst)) { + CORO_INVOKE_2(RMCharacter::Move, dst, &_ctx->result); + if (!_ctx->result) { m_bActionPending = false; m_ActionItem = NULL; } + + CORO_END_CODE; } @@ -290,14 +307,14 @@ void RMTony::Stop(CORO_PARAM) { _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); if (_ctx->pid == INVALID_PID_VALUE) - RMCharacter::Stop(); + CORO_INVOKE_0(RMCharacter::Stop); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { - RMCharacter::Stop(); + CORO_INVOKE_0(RMCharacter::Stop); } if (!m_bActionPending) diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 98f247f688..050b39c0ca 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -385,7 +385,7 @@ public: void Close(void); // Fa un frame di Tony, aggiornando il movimento, etc - void DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Metodi di Draw, che controlla la variabile di show void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -395,7 +395,7 @@ public: void Hide(bool bShowOmbra = false); // Si muove e fa un azione, se necessario - void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); + void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) virtual void Stop(CORO_PARAM); -- cgit v1.2.3 From 724deb6b84b8a5f5a3aa96adc2a512c962f7081a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 08:44:50 +1000 Subject: TONY: Bugfixes for showing the credits screen. --- engines/tony/custom.cpp | 4 ++-- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/mpal/mpal.h | 2 +- engines/tony/window.cpp | 28 ++++++++++++++++++++++++---- engines/tony/window.h | 1 + 5 files changed, 30 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index c82d0fcd2b..5089914d88 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2615,10 +2615,10 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { _ctx->text[_ctx->i].SetInput(Input); - // Allineamento + // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { _ctx->text[_ctx->i].SetAlignType(RMText::HCENTER, RMText::VTOP); - _ctx->text[_ctx->i].WriteText(_ctx->msg[_ctx->i][1], 3); + _ctx->text[_ctx->i].WriteText(&(*_ctx->msg)[_ctx->i][1], 3); _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT,RMText::VTOP); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index da736a138f..e82df11328 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -422,7 +422,7 @@ static int locGetOrderFromNum(uint32 nLoc) { static int msgGetOrderFromNum(uint32 nMsg) { int i; - LPMPALMSG msg=lpmmMsgs; + LPMPALMSG msg = lpmmMsgs; for (i = 0; i < nMsgs; i++, msg++) if (msg->wNum == nMsg) @@ -542,7 +542,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); j = 0; - while (origmsg[j] != '\0' || origmsg[j+1] != '\0') + while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') j++; j += 2; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 9a85f2df17..cd46219b57 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -566,7 +566,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDoDialog(nDialog,nGroup) \ - mpalQueryHANDLE(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) + mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) /****************************************************************************\ diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index f68c612911..18dcfb7cb6 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -128,12 +128,32 @@ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { - Common::Rect bounds = (rcBoundEllipse) ? *rcBoundEllipse : Common::Rect(0, 0, RM_SX, RM_SY); - - // Update a screen section - g_system->copyRectToScreen(lpBuf, RM_SX * 2, bounds.left, bounds.top, bounds.width(), bounds.height()); + if (rcBoundEllipse != NULL) { + // Circular wipe effect + GetNewFrameWipe(lpBuf, *rcBoundEllipse); + } else { + // Standard screen copy + g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + } } +/** + * Copies a section of the game frame in a circle bounded by the specified rectangle + */ +void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { + // Clear the screen + g_system->fillScreen(0); + + if (!rcBoundEllipse.isValidRect()) + return; + + // TODO: Do a proper circular wipe + for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { + const byte *pSrc = lpBuf + (yp * RM_SX * 2) + rcBoundEllipse.left * 2; + + g_system->copyRectToScreen(pSrc, RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + } +} /****************************************************************************\ * RMSnapshot Methods diff --git a/engines/tony/window.h b/engines/tony/window.h index 5190fc4d16..06f684a15b 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -97,6 +97,7 @@ protected: void CreateBWPrecalcTable(void); void WipeEffect(Common::Rect &rcBoundEllipse); + void GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); public: RMWindow(); -- cgit v1.2.3 From 50153aba8832d8707031df2219512515797d93ce Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:08:27 +1000 Subject: COMMON: Merged the Tinsel & Tony Coroutine schedulers into Common --- engines/tinsel/coroutine.h | 282 --------------------------------------------- 1 file changed, 282 deletions(-) delete mode 100644 engines/tinsel/coroutine.h (limited to 'engines') diff --git a/engines/tinsel/coroutine.h b/engines/tinsel/coroutine.h deleted file mode 100644 index 5bcf1149d9..0000000000 --- a/engines/tinsel/coroutine.h +++ /dev/null @@ -1,282 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public 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 TINSEL_COROUTINE_H -#define TINSEL_COROUTINE_H - -#include "common/scummsys.h" -#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION - -namespace Tinsel { - -/** - * @defgroup TinselCoroutines Coroutine support for Tinsel - * - * The following is loosely based on an article by Simon Tatham: - * . - * However, many improvements and tweaks have been made, in particular - * by taking advantage of C++ features not available in C. - * - * Why is this code here? Well, the Tinsel engine apparently used - * setjmp/longjmp based coroutines as a core tool from the start, and - * so they are deeply ingrained into the whole code base. When we - * started to get Tinsel ready for ScummVM, we had to deal with that. - * It soon got clear that we could not simply rewrite the code to work - * without some form of coroutines. While possible in principle, it - * would have meant a major restructuring of the entire code base, a - * rather daunting task. Also, it would have very likely introduced - * tons of regressons. - * - * So instead of getting rid of the coroutines, we chose to implement - * them in an alternate way, using Simon Tatham's trick as described - * above. While the trick is dirty, the result seems to be clear enough, - * we hope; plus, it allowed us to stay relatively close to the - * original structure of the code, which made it easier to avoid - * regressions, and will be helpful in the future when comparing things - * against the original code base. - */ -//@{ - - -// Enable this macro to enable some debugging support in the coroutine code. -//#define COROUTINE_DEBUG 1 - -/** - * The core of any coroutine context which captures the 'state' of a coroutine. - * Private use only. - */ -struct CoroBaseContext { - int _line; - int _sleep; - CoroBaseContext *_subctx; -#if COROUTINE_DEBUG - const char *_funcName; -#endif - CoroBaseContext(const char *func); - ~CoroBaseContext(); -}; - -typedef CoroBaseContext *CoroContext; - - -// FIXME: Document this! -extern CoroContext nullContext; - -/** - * Wrapper class which holds a pointer to a pointer to a CoroBaseContext. - * The interesting part is the destructor, which kills the context being held, - * but ONLY if the _sleep val of that context is zero. This way, a coroutine - * can just 'return' w/o having to worry about freeing the allocated context - * (in Simon Tatham's original code, one had to use a special macro to - * return from a coroutine). - */ -class CoroContextHolder { - CoroContext &_ctx; -public: - CoroContextHolder(CoroContext &ctx) : _ctx(ctx) { - assert(ctx); - assert(ctx->_sleep >= 0); - ctx->_sleep = 0; - } - ~CoroContextHolder() { - if (_ctx && _ctx->_sleep == 0) { - delete _ctx; - _ctx = 0; - } - } -}; - - -#define CORO_PARAM CoroContext &coroParam - - -/** - * Begin the declaration of a coroutine context. - * This allows declaring variables which are 'persistent' during the - * lifetime of the coroutine. An example use would be: - * - * CORO_BEGIN_CONTEXT; - * int var; - * char *foo; - * CORO_END_CONTEXT(_ctx); - * - * It is not possible to initialize variables here, due to the way this - * macro is implemented. Furthermore, to use the variables declared in - * the coroutine context, you have to access them via the context variable - * name that was specified as parameter to CORO_END_CONTEXT, e.g. - * _ctx->var = 0; - * - * @see CORO_END_CONTEXT - * - * @note We declare a variable 'DUMMY' to allow the user to specify an 'empty' - * context, and so compilers won't complain about ";" following the macro. - */ -#define CORO_BEGIN_CONTEXT \ - struct CoroContextTag : CoroBaseContext { \ - CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ - int DUMMY - -/** - * End the declaration of a coroutine context. - * @param x name of the coroutine context - * @see CORO_BEGIN_CONTEXT - */ -#define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam - -/** - * Begin the code section of a coroutine. - * @param x name of the coroutine context - * @see CORO_BEGIN_CODE - */ -#define CORO_BEGIN_CODE(x) \ - if (&coroParam == &nullContext) assert(!nullContext);\ - if (!x) {coroParam = x = new CoroContextTag();}\ - CoroContextHolder tmpHolder(coroParam);\ - switch (coroParam->_line) { case 0:; - -/** - * End the code section of a coroutine. - * @see CORO_END_CODE - */ -#define CORO_END_CODE \ - if (&coroParam == &nullContext) { \ - delete nullContext; \ - nullContext = NULL; \ - } \ - } - -/** - * Sleep for the specified number of scheduler cycles. - */ -#define CORO_SLEEP(delay) do {\ - coroParam->_line = __LINE__;\ - coroParam->_sleep = delay;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (0) - -#define CORO_GIVE_WAY do { g_scheduler->giveWay(); CORO_SLEEP(1); } while (0) -#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0) - -/** - * Stop the currently running coroutine and all calling coroutines. - * - * This sets _sleep to -1 rather than 0 so that the context doesn't get - * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to - * propogate the _sleep value and return immediately (the scheduler will - * then delete the entire coroutine's state, including all subcontexts). - */ -#define CORO_KILL_SELF() \ - do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0) - - -/** - * This macro is to be used in conjunction with CORO_INVOKE_ARGS and - * similar macros for calling coroutines-enabled subroutines. - */ -#define CORO_SUBCTX coroParam->_subctx - -/** - * Invoke another coroutine. - * - * If the subcontext still exists after the coroutine is invoked, it has - * either yielded/slept or killed itself, and so we copy the _sleep value - * to our own context and return (execution will continue at the case - * statement below, where we loop and call the coroutine again). - * If the subcontext is null, the coroutine ended normally, and we can - * simply break out of the loop and continue execution. - * - * @param subCoro name of the coroutine-enabled function to invoke - * @param ARGS list of arguments to pass to subCoro - * - * @note ARGS must be surrounded by parentheses, and the first argument - * in this list must always be CORO_SUBCTX. For example, the - * regular function call - * myFunc(a, b); - * becomes the following: - * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); - */ -#define CORO_INVOKE_ARGS(subCoro, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, - * but allows specifying a return value which is returned - * if invoked coroutine yields (thus causing the current - * coroutine to yield, too). - */ -#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return RESULT; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with no parameters. - */ -#define CORO_INVOKE_0(subCoroutine) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with one parameter. - */ -#define CORO_INVOKE_1(subCoroutine, a0) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with two parameters. - */ -#define CORO_INVOKE_2(subCoroutine, a0,a1) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with three parameters. - */ -#define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) - -//@} - -} // End of namespace Tinsel - -#endif // TINSEL_COROUTINE_H -- cgit v1.2.3 From 64669234b2fdb2375d23157232d6104e6d8967d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:10:12 +1000 Subject: TINSEL: Refactored Tinsel engine to use the Common coroutine scheduler --- engines/tinsel/actors.cpp | 12 +- engines/tinsel/background.h | 2 +- engines/tinsel/bg.cpp | 6 +- engines/tinsel/bmv.cpp | 4 +- engines/tinsel/bmv.h | 2 +- engines/tinsel/coroutine.cpp | 82 -------- engines/tinsel/dialogs.cpp | 20 +- engines/tinsel/drives.cpp | 6 +- engines/tinsel/drives.h | 2 +- engines/tinsel/effect.cpp | 2 +- engines/tinsel/events.cpp | 18 +- engines/tinsel/events.h | 4 +- engines/tinsel/faders.cpp | 4 +- engines/tinsel/handle.cpp | 2 +- engines/tinsel/module.mk | 1 - engines/tinsel/move.cpp | 4 +- engines/tinsel/pcode.cpp | 20 +- engines/tinsel/pcode.h | 12 +- engines/tinsel/pdisplay.cpp | 6 +- engines/tinsel/play.cpp | 16 +- engines/tinsel/play.h | 2 +- engines/tinsel/polygons.cpp | 4 +- engines/tinsel/rince.cpp | 8 +- engines/tinsel/rince.h | 4 +- engines/tinsel/savescn.cpp | 10 +- engines/tinsel/scene.cpp | 20 +- engines/tinsel/sched.cpp | 487 +------------------------------------------ engines/tinsel/sched.h | 93 +-------- engines/tinsel/text.h | 2 +- engines/tinsel/tinlib.cpp | 12 +- engines/tinsel/tinsel.cpp | 33 ++- engines/tinsel/token.cpp | 14 +- 32 files changed, 137 insertions(+), 777 deletions(-) delete mode 100644 engines/tinsel/coroutine.cpp (limited to 'engines') diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp index acacd89667..a784ff5788 100644 --- a/engines/tinsel/actors.cpp +++ b/engines/tinsel/actors.cpp @@ -340,7 +340,7 @@ void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag) { if (savegameFlag) pic->resumeState = RES_SAVEGAME; - g_scheduler->createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r)); + CoroScheduler.createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r)); } /** @@ -358,7 +358,7 @@ void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be) { atp.event = event; atp.bev = be; atp.pic = NULL; - g_scheduler->createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); + CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); } } @@ -369,7 +369,7 @@ void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEsca ATP_INIT atp; int index; CORO_BEGIN_CONTEXT; - PPROCESS pProc; + Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -389,7 +389,7 @@ void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEsca myEscape); if (atp.pic != NULL) { - _ctx->pProc = g_scheduler->createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); + _ctx->pProc = CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); AttachInterpret(atp.pic, _ctx->pProc); if (bWait) @@ -474,8 +474,8 @@ void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) { // Run actor's script for this scene if (bRunScript) { // Send in reverse order - they get swapped round in the scheduler - ActorEvent(nullContext, taggedActors[i].id, SHOWEVENT, false, 0); - ActorEvent(nullContext, taggedActors[i].id, STARTUP, false, 0); + ActorEvent(Common::nullContext, taggedActors[i].id, SHOWEVENT, false, 0); + ActorEvent(Common::nullContext, taggedActors[i].id, STARTUP, false, 0); } } } diff --git a/engines/tinsel/background.h b/engines/tinsel/background.h index 34f1bd6dd2..cfa3998eda 100644 --- a/engines/tinsel/background.h +++ b/engines/tinsel/background.h @@ -24,9 +24,9 @@ #ifndef TINSEL_BACKGND_H // prevent multiple includes #define TINSEL_BACKGND_H +#include "common/coroutines.h" #include "common/frac.h" #include "common/rect.h" -#include "tinsel/coroutine.h" #include "tinsel/dw.h" // for SCNHANDLE #include "tinsel/palette.h" // palette definitions diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp index 72ba05f0b9..a3e21a8227 100644 --- a/engines/tinsel/bg.cpp +++ b/engines/tinsel/bg.cpp @@ -255,17 +255,17 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) { g_BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate); // Start display process for each reel in the film - g_scheduler->createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL)); + CoroScheduler.createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL)); if (TinselV0) { for (uint i = 1; i < FROM_LE_32(pfilm->numreels); ++i) - g_scheduler->createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL)); + CoroScheduler.createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL)); } if (g_pBG[0] == NULL) ControlStartOff(); - if (TinselV2 && (coroParam != nullContext)) + if (TinselV2 && (coroParam != Common::nullContext)) CORO_GIVE_WAY; CORO_END_CODE; diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp index 24d47b920f..438fd52a81 100644 --- a/engines/tinsel/bmv.cpp +++ b/engines/tinsel/bmv.cpp @@ -529,7 +529,7 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { if (cmd & CD_PRINT) { PRINT_CMD *pCmd = (PRINT_CMD *)(bigBuffer + commandOffset); - MovieText(nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), + MovieText(Common::nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), (int16)READ_LE_UINT16(&pCmd->x), (int16)READ_LE_UINT16(&pCmd->y), pCmd->fontId, @@ -542,7 +542,7 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { TALK_CMD *pCmd = (TALK_CMD *)(bigBuffer + commandOffset); talkColor = TINSEL_RGB(pCmd->r, pCmd->g, pCmd->b); - MovieText(nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), + MovieText(Common::nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), (int16)READ_LE_UINT16(&pCmd->x), (int16)READ_LE_UINT16(&pCmd->y), 0, diff --git a/engines/tinsel/bmv.h b/engines/tinsel/bmv.h index eadf65c3aa..fa254ed26d 100644 --- a/engines/tinsel/bmv.h +++ b/engines/tinsel/bmv.h @@ -24,12 +24,12 @@ #ifndef TINSEL_BMV_H #define TINSEL_BMV_H +#include "common/coroutines.h" #include "common/file.h" #include "audio/audiostream.h" #include "audio/mixer.h" -#include "tinsel/coroutine.h" #include "tinsel/object.h" #include "tinsel/palette.h" diff --git a/engines/tinsel/coroutine.cpp b/engines/tinsel/coroutine.cpp deleted file mode 100644 index ef0097f043..0000000000 --- a/engines/tinsel/coroutine.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public 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 "tinsel/coroutine.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Tinsel { - - -CoroContext nullContext = NULL; // FIXME: Avoid non-const global vars - - -#if COROUTINE_DEBUG -namespace { -static int s_coroCount = 0; - -typedef Common::HashMap CoroHashMap; -static CoroHashMap *s_coroFuncs = 0; - -static void changeCoroStats(const char *func, int change) { - if (!s_coroFuncs) - s_coroFuncs = new CoroHashMap(); - - (*s_coroFuncs)[func] += change; -} - -static void displayCoroStats() { - debug("%d active coros", s_coroCount); - - // Loop over s_coroFuncs and print info about active coros - if (!s_coroFuncs) - return; - for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); - it != s_coroFuncs->end(); ++it) { - if (it->_value != 0) - debug(" %3d x %s", it->_value, it->_key.c_str()); - } -} - -} -#endif - -CoroBaseContext::CoroBaseContext(const char *func) - : _line(0), _sleep(0), _subctx(0) { -#if COROUTINE_DEBUG - _funcName = func; - changeCoroStats(_funcName, +1); - s_coroCount++; -#endif -} - -CoroBaseContext::~CoroBaseContext() { -#if COROUTINE_DEBUG - s_coroCount--; - changeCoroStats(_funcName, -1); - debug("Deleting coro in %s at %p (subctx %p)", - _funcName, (void *)this, (void *)_subctx); - displayCoroStats(); -#endif - delete _subctx; -} - -} // End of namespace Tinsel diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index 5396e47566..fbe9e8d1f6 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -1075,7 +1075,7 @@ static void PrimeSceneHopper() { uint32 vSize; // Open the file (it's on the CD) - CdCD(nullContext); + CdCD(Common::nullContext); if (!f.open(HOPPER_FILENAME)) error(CANNOT_FIND_FILE, HOPPER_FILENAME); @@ -1191,13 +1191,13 @@ static void HopAction() { debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber); if (FROM_LE_32(pEntry->flags) & fCall) { - SaveScene(nullContext); - NewScene(nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE); + SaveScene(Common::nullContext); + NewScene(Common::nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE); } else if (FROM_LE_32(pEntry->flags) & fHook) HookScene(hScene, eNumber, TRANS_FADE); else - NewScene(nullContext, hScene, eNumber, TRANS_CUT); + NewScene(Common::nullContext, hScene, eNumber, TRANS_CUT); } /**************************************************************************/ @@ -1406,13 +1406,13 @@ static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, return; g_GlitterIndex = index; - g_scheduler->createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to)); } extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result) { // COROUTINE CORO_BEGIN_CONTEXT; - PROCESS *pProc; + Common::PROCESS *pProc; INV_OBJECT *pInvo; OP_INIT op; CORO_END_CONTEXT(_ctx); @@ -1428,7 +1428,7 @@ extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, i _ctx->op.event = event; _ctx->op.myEscape = myEscape; - g_scheduler->createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op)); + CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op)); if (bWait) CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result); @@ -3540,9 +3540,9 @@ extern void ConvAction(int index) { } if (g_thisConvPoly != NOPOLY) - PolygonEvent(nullContext, g_thisConvPoly, CONVERSE, 0, false, 0); + PolygonEvent(Common::nullContext, g_thisConvPoly, CONVERSE, 0, false, 0); else - ActorEvent(nullContext, g_thisConvActor, CONVERSE, false, 0); + ActorEvent(Common::nullContext, g_thisConvActor, CONVERSE, false, 0); } } @@ -5128,7 +5128,7 @@ static void InvPickup(int index) { if (TinselV2) InvPutDown(index); else - g_scheduler->createProcess(PID_TCODE, InvPdProcess, &index, sizeof(index)); + CoroScheduler.createProcess(PID_TCODE, InvPdProcess, &index, sizeof(index)); } } } diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp index d815fd165d..5c4b939e4e 100644 --- a/engines/tinsel/drives.cpp +++ b/engines/tinsel/drives.cpp @@ -48,13 +48,13 @@ void CdCD(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); while (g_bChangingCD) { - if (g_scheduler->getCurrentProcess()) { - // FIXME: CdCD gets passed a nullContext in RegisterGlobals() and + if (CoroScheduler.getCurrentProcess()) { + // FIXME: CdCD gets passed a Common::nullContext in RegisterGlobals() and // PrimeSceneHopper(), because I didn't know how to get a proper // context without converting the whole calling stack to CORO'd // functions. If these functions really get called while a CD // change is requested, this needs to be resolved. - if (coroParam == nullContext) + if (coroParam == Common::nullContext) error("CdCD needs context"); CORO_SLEEP(1); } else diff --git a/engines/tinsel/drives.h b/engines/tinsel/drives.h index 907071d2f8..9e97b92fa5 100644 --- a/engines/tinsel/drives.h +++ b/engines/tinsel/drives.h @@ -24,9 +24,9 @@ #ifndef TINSEL_DRIVES_H #define TINSEL_DRIVES_H +#include "common/coroutines.h" #include "common/stream.h" #include "tinsel/dw.h" -#include "tinsel/coroutine.h" namespace Tinsel { diff --git a/engines/tinsel/effect.cpp b/engines/tinsel/effect.cpp index 22027b0f02..f5adb63c2b 100644 --- a/engines/tinsel/effect.cpp +++ b/engines/tinsel/effect.cpp @@ -108,7 +108,7 @@ static void FettleEffectPolys(int x, int y, int index, PMOVER pActor) { epi.hEpoly = hPoly; epi.pMover = pActor; epi.index = index; - g_scheduler->createProcess(PID_TCODE, EffectProcess, &epi, sizeof(epi)); + CoroScheduler.createProcess(PID_TCODE, EffectProcess, &epi, sizeof(epi)); } } } diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp index 74454c5f2a..1aa4d34227 100644 --- a/engines/tinsel/events.cpp +++ b/engines/tinsel/events.cpp @@ -22,10 +22,10 @@ * Also provides a couple of utility functions. */ +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" #include "tinsel/config.h" -#include "tinsel/coroutine.h" #include "tinsel/cursor.h" #include "tinsel/dw.h" #include "tinsel/events.h" @@ -276,7 +276,7 @@ static void WalkProcess(CORO_PARAM, const void *param) { void WalkTo(int x, int y) { WP_INIT to = { x, y }; - g_scheduler->createProcess(PID_TCODE, WalkProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, WalkProcess, &to, sizeof(to)); } /** @@ -295,7 +295,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P if ((actor = GetTaggedActor()) != 0) { // Event for a tagged actor if (TinselV2) - ActorEvent(nullContext, actor, uEvent, false, 0); + ActorEvent(Common::nullContext, actor, uEvent, false, 0); else ActorEvent(actor, uEvent, be); } else if ((hPoly = GetTaggedPoly()) != NOPOLY) { @@ -303,7 +303,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P if (!TinselV2) RunPolyTinselCode(hPoly, uEvent, be, false); else if (uEvent != PROV_WALKTO) - PolygonEvent(nullContext, hPoly, uEvent, 0, false, 0); + PolygonEvent(Common::nullContext, hPoly, uEvent, 0, false, 0); } else { GetCursorXY(&aniX, &aniY, true); @@ -312,7 +312,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P if ((hPoly = InPolygon(aniX, aniY, TAG)) != NOPOLY || (!TinselV2 && ((hPoly = InPolygon(aniX, aniY, EXIT)) != NOPOLY))) { if (TinselV2 && (uEvent != PROV_WALKTO)) - PolygonEvent(nullContext, hPoly, uEvent, 0, false, 0); + PolygonEvent(Common::nullContext, hPoly, uEvent, 0, false, 0); else if (!TinselV2) RunPolyTinselCode(hPoly, uEvent, be, false); } else if ((uEvent == PROV_WALKTO) || (uEvent == WALKTO)) { @@ -604,7 +604,7 @@ void PolyTinselProcess(CORO_PARAM, const void *param) { void PolygonEvent(CORO_PARAM, HPOLYGON hPoly, TINSEL_EVENT tEvent, int actor, bool bWait, int myEscape, bool *result) { CORO_BEGIN_CONTEXT; - PPROCESS pProc; + Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -623,7 +623,7 @@ void PolygonEvent(CORO_PARAM, HPOLYGON hPoly, TINSEL_EVENT tEvent, int actor, bo NULL, // No Object myEscape); if (to.pic != NULL) { - _ctx->pProc = g_scheduler->createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); + _ctx->pProc = CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); AttachInterpret(to.pic, _ctx->pProc); if (bWait) @@ -640,14 +640,14 @@ void RunPolyTinselCode(HPOLYGON hPoly, TINSEL_EVENT event, PLR_EVENT be, bool tc PTP_INIT to = { hPoly, event, be, tc, 0, NULL }; assert(!TinselV2); - g_scheduler->createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); } void effRunPolyTinselCode(HPOLYGON hPoly, TINSEL_EVENT event, int actor) { PTP_INIT to = { hPoly, event, PLR_NOEVENT, false, actor, NULL }; assert(!TinselV2); - g_scheduler->createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); } /** diff --git a/engines/tinsel/events.h b/engines/tinsel/events.h index f2b4d7f663..cdf5ae2ae4 100644 --- a/engines/tinsel/events.h +++ b/engines/tinsel/events.h @@ -24,9 +24,9 @@ #ifndef TINSEL_EVENTS_H #define TINSEL_EVENTS_H -#include "tinsel/dw.h" -#include "tinsel/coroutine.h" +#include "common/coroutines.h" #include "common/rect.h" +#include "tinsel/dw.h" namespace Tinsel { diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp index 86d117af81..c1574ff963 100644 --- a/engines/tinsel/faders.cpp +++ b/engines/tinsel/faders.cpp @@ -145,7 +145,7 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) { if (TinselV2) { // The is only ever one cuncurrent fade // But this could be a fade out and the fade in is still going! - g_scheduler->killMatchingProcess(PID_FADER); + CoroScheduler.killMatchingProcess(PID_FADER); NoFadingPalettes(); } @@ -176,7 +176,7 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) { fade.pPalQ = pPal; // create a fader process for this palette - g_scheduler->createProcess(PID_FADER, FadeProcess, (void *)&fade, sizeof(FADE)); + CoroScheduler.createProcess(PID_FADER, FadeProcess, (void *)&fade, sizeof(FADE)); } } } diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index e31b2141f5..c3089db990 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -361,7 +361,7 @@ byte *LockMem(SCNHANDLE offset) { if (TinselV2) { SetCD(pH->flags2 & fAllCds); - CdCD(nullContext); + CdCD(Common::nullContext); } LoadFile(pH); } diff --git a/engines/tinsel/module.mk b/engines/tinsel/module.mk index 2ab94b830a..3485bac74b 100644 --- a/engines/tinsel/module.mk +++ b/engines/tinsel/module.mk @@ -9,7 +9,6 @@ MODULE_OBJS := \ bmv.o \ cliprect.o \ config.o \ - coroutine.o \ cursor.o \ debugger.o \ detection.o \ diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp index bb49e59fe7..275b6006f5 100644 --- a/engines/tinsel/move.cpp +++ b/engines/tinsel/move.cpp @@ -1299,14 +1299,14 @@ static void SetOffWithinNodePath(PMOVER pMover, HPOLYGON StartPath, HPOLYGON Des */ void SSetActorDest(PMOVER pActor) { if (pActor->UtargetX != -1 && pActor->UtargetY != -1) { - Stand(nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); + Stand(Common::nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); if (pActor->UtargetX != -1 && pActor->UtargetY != -1) { SetActorDest(pActor, pActor->UtargetX, pActor->UtargetY, pActor->bIgPath, 0); } } else { - Stand(nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); + Stand(Common::nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); } } diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp index 145a6a8e5d..60f04b47fd 100644 --- a/engines/tinsel/pcode.cpp +++ b/engines/tinsel/pcode.cpp @@ -243,13 +243,13 @@ static INT_CONTEXT *AllocateInterpretContext(GSORT gsort) { for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) { if (pic->GSort == GS_NONE) { - pic->pProc = g_scheduler->getCurrentProcess(); + pic->pProc = CoroScheduler.getCurrentProcess(); pic->GSort = gsort; return pic; } #ifdef DEBUG else { - if (pic->pProc == g_scheduler->getCurrentProcess()) + if (pic->pProc == CoroScheduler.getCurrentProcess()) error("Found unreleased interpret context"); } #endif @@ -277,7 +277,7 @@ static void FreeWaitCheck(PINT_CONTEXT pic, bool bVoluntary) { if ((g_icList + i)->waitNumber1 == pic->waitNumber2) { (g_icList + i)->waitNumber1 = 0; (g_icList + i)->resumeCode = bVoluntary ? RES_FINISHED : RES_CUTSHORT; - g_scheduler->reschedule((g_icList + i)->pProc); + CoroScheduler.reschedule((g_icList + i)->pProc); break; } } @@ -301,7 +301,7 @@ static void FreeInterpretContextPi(INT_CONTEXT *pic) { * Ensures that interpret contexts don't get lost when an Interpret() * call doesn't complete. */ -void FreeInterpretContextPr(PROCESS *pProc) { +void FreeInterpretContextPr(Common::PROCESS *pProc) { INT_CONTEXT *pic; int i; @@ -393,7 +393,7 @@ INT_CONTEXT *RestoreInterpretContext(INT_CONTEXT *ric) { ic = AllocateInterpretContext(GS_NONE); // Sort will soon be overridden memcpy(ic, ric, sizeof(INT_CONTEXT)); - ic->pProc = g_scheduler->getCurrentProcess(); + ic->pProc = CoroScheduler.getCurrentProcess(); ic->resumeState = RES_1; LockCode(ic); @@ -422,7 +422,7 @@ void RegisterGlobals(int num) { if (g_icList == NULL) { error("Cannot allocate memory for interpret contexts"); } - g_scheduler->setResourceCallback(FreeInterpretContextPr); + CoroScheduler.setResourceCallback(FreeInterpretContextPr); } else { // Check size is still the same assert(g_numGlobals == num); @@ -433,7 +433,7 @@ void RegisterGlobals(int num) { if (TinselV2) { // read initial values - CdCD(nullContext); + CdCD(Common::nullContext); Common::File f; if (!f.open(GLOBALS_FILENAME)) @@ -839,7 +839,7 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) { * Associates an interpret context with the * process that will run it. */ -void AttachInterpret(INT_CONTEXT *pic, PROCESS *pProc) { +void AttachInterpret(INT_CONTEXT *pic, Common::PROCESS *pProc) { // Attach the process which is using this context pic->pProc = pProc; } @@ -869,9 +869,9 @@ static uint32 UniqueWaitNumber() { /** * WaitInterpret */ -void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result) { +void WaitInterpret(CORO_PARAM, Common::PPROCESS pWaitProc, bool *result) { int i; - PPROCESS currentProcess = g_scheduler->getCurrentProcess(); + Common::PPROCESS currentProcess = CoroScheduler.getCurrentProcess(); assert(currentProcess); assert(currentProcess != pWaitProc); if (result) *result = false; diff --git a/engines/tinsel/pcode.h b/engines/tinsel/pcode.h index 5d16dae432..4980fc6ed9 100644 --- a/engines/tinsel/pcode.h +++ b/engines/tinsel/pcode.h @@ -25,7 +25,7 @@ #define TINSEL_PCODE_H #include "tinsel/events.h" // for TINSEL_EVENT -#include "tinsel/sched.h" // for PROCESS +#include "tinsel/sched.h" // for Common::PROCESS namespace Common { class Serializer; @@ -56,7 +56,7 @@ struct WorkaroundEntry; struct INT_CONTEXT { // Elements for interpret context management - PROCESS *pProc; ///< processes owning this context + Common::PROCESS *pProc; ///< processes owning this context GSORT GSort; ///< sort of this context // Previously parameters to Interpret() @@ -114,12 +114,12 @@ void SaveInterpretContexts(INT_CONTEXT *sICInfo); void RegisterGlobals(int num); void FreeGlobals(); -void AttachInterpret(INT_CONTEXT *pic, PROCESS *pProc); +void AttachInterpret(INT_CONTEXT *pic, Common::PROCESS *pProc); -void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result); +void WaitInterpret(CORO_PARAM, Common::PPROCESS pWaitProc, bool *result); -#define NUM_INTERPRET (NUM_PROCESS - 20) -#define MAX_INTERPRET (MAX_PROCESSES - 20) +#define NUM_INTERPRET (CORO_NUM_PROCESS - 20) +#define MAX_INTERPRET (CORO_MAX_PROCESSES - 20) /*----------------------------------------------------------------------*\ |* Library Procedure and Function codes parameter enums *| diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp index 9a9e6ab00f..b821c5dee2 100644 --- a/engines/tinsel/pdisplay.cpp +++ b/engines/tinsel/pdisplay.cpp @@ -23,9 +23,9 @@ * PointProcess() */ +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" -#include "tinsel/coroutine.h" #include "tinsel/cursor.h" #include "tinsel/dw.h" #include "tinsel/events.h" @@ -265,7 +265,7 @@ void DisablePointing() { if (hPoly != NOPOLY && PolyType(hPoly) == TAG && PolyIsPointedTo(hPoly)) { SetPolyPointedTo(hPoly, false); SetPolyTagWanted(hPoly, false, false, 0); - PolygonEvent(nullContext, hPoly, UNPOINT, 0, false, 0); + PolygonEvent(Common::nullContext, hPoly, UNPOINT, 0, false, 0); } } @@ -275,7 +275,7 @@ void DisablePointing() { SetActorPointedTo(i, false); SetActorTagWanted(i, false, false, 0); - ActorEvent(nullContext, i, UNPOINT, false, 0); + ActorEvent(Common::nullContext, i, UNPOINT, false, 0); } } } diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp index 40729d9f3a..9e0baa749e 100644 --- a/engines/tinsel/play.cpp +++ b/engines/tinsel/play.cpp @@ -21,9 +21,9 @@ * Plays films within a scene, takes into account the actor in each 'column'. | */ +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" -#include "tinsel/coroutine.h" #include "tinsel/dw.h" #include "tinsel/film.h" #include "tinsel/handle.h" @@ -395,7 +395,7 @@ static void SoundReelWaitCheck() { if (--g_soundReelWait == 0) { for (int i = 0; i < MAX_SOUNDREELS; i++) { if (g_soundReels[i].hFilm) { - g_scheduler->createProcess(PID_REEL, ResSoundReel, &i, sizeof(i)); + CoroScheduler.createProcess(PID_REEL, ResSoundReel, &i, sizeof(i)); } } } @@ -1001,7 +1001,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay NewestFilm(hFilm, &pFilm->reels[i]); ppi.column = i; - g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(PPINIT)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &ppi, sizeof(PPINIT)); } if (TinselV2) { @@ -1011,7 +1011,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay CORO_GIVE_WAY; if (myescEvent && myescEvent != GetEscEvents()) - g_scheduler->rescheduleAll(); + CoroScheduler.rescheduleAll(); } CORO_END_CODE; @@ -1063,7 +1063,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla NewestFilm(hFilm, &pFilm->reels[i]); _ctx->ppi.column = i; - g_scheduler->createProcess(PID_REEL, PlayProcess, &_ctx->ppi, sizeof(PPINIT)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &_ctx->ppi, sizeof(PPINIT)); } if (TinselV2) { @@ -1078,7 +1078,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla // Wait until film changes or loop count increases while (GetActorPresFilm(_ctx->i) == hFilm && GetLoopCount(_ctx->i) == _ctx->loopCount) { if (myescEvent && myescEvent != GetEscEvents()) { - g_scheduler->rescheduleAll(); + CoroScheduler.rescheduleAll(); break; } @@ -1126,7 +1126,7 @@ void RestoreActorReels(SCNHANDLE hFilm, short reelnum, short z, int x, int y) { NewestFilm(hFilm, &pfilm->reels[reelnum]); // Start display process for the reel - g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); } /** @@ -1160,7 +1160,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) { NewestFilm(hFilm, &pFilm->reels[i]); // Start display process for the reel - g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); g_soundReelWait++; } diff --git a/engines/tinsel/play.h b/engines/tinsel/play.h index 041b7096a8..fffa8a9329 100644 --- a/engines/tinsel/play.h +++ b/engines/tinsel/play.h @@ -24,7 +24,7 @@ #ifndef TINSEL_PLAY_H // prevent multiple includes #define TINSEL_PLAY_H -#include "tinsel/coroutine.h" +#include "common/coroutines.h" #include "tinsel/dw.h" #include "tinsel/multiobj.h" diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp index 6fc1c65ec5..d8c1cef0b6 100644 --- a/engines/tinsel/polygons.cpp +++ b/engines/tinsel/polygons.cpp @@ -1469,7 +1469,7 @@ static void SetExTags(SCNHANDLE ph) { pts = &TagStates[SceneTags[i].offset]; for (j = 0; j < SceneTags[i].nooftags; j++, pts++) { if (!pts->enabled) - DisableTag(nullContext, pts->tid); + DisableTag(Common::nullContext, pts->tid); } return; } @@ -1873,7 +1873,7 @@ void InitPolygons(SCNHANDLE ph, int numPoly, bool bRestart) { } else { for (int i = numPoly - 1; i >= 0; i--) { if (Polys[i]->polyType == TAG) { - PolygonEvent(nullContext, i, STARTUP, 0, false, 0); + PolygonEvent(Common::nullContext, i, STARTUP, 0, false, 0); } } } diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp index bb0aeabd2f..ba8f47f9cf 100644 --- a/engines/tinsel/rince.cpp +++ b/engines/tinsel/rince.cpp @@ -202,8 +202,8 @@ void KillMover(PMOVER pMover) { pMover->bActive = false; MultiDeleteObject(GetPlayfieldList(FIELD_WORLD), pMover->actorObj); pMover->actorObj = NULL; - assert(g_scheduler->getCurrentProcess() != pMover->pProc); - g_scheduler->killProcess(pMover->pProc); + assert(CoroScheduler.getCurrentProcess() != pMover->pProc); + CoroScheduler.killProcess(pMover->pProc); } } @@ -856,10 +856,10 @@ void MoverProcessCreate(int X, int Y, int id, PMOVER pMover) { iStruct.Y = Y; iStruct.pMover = pMover; - g_scheduler->createProcess(PID_MOVER, T2MoverProcess, &iStruct, sizeof(MAINIT)); + CoroScheduler.createProcess(PID_MOVER, T2MoverProcess, &iStruct, sizeof(MAINIT)); } else { MoverProcessHelper(X, Y, id, pMover); - pMover->pProc = g_scheduler->createProcess(PID_MOVER, T1MoverProcess, &pMover, sizeof(PMOVER)); + pMover->pProc = CoroScheduler.createProcess(PID_MOVER, T1MoverProcess, &pMover, sizeof(PMOVER)); } } diff --git a/engines/tinsel/rince.h b/engines/tinsel/rince.h index 93fd191172..b34c3f20de 100644 --- a/engines/tinsel/rince.h +++ b/engines/tinsel/rince.h @@ -31,7 +31,7 @@ namespace Tinsel { struct OBJECT; -struct PROCESS; +struct Common::PROCESS; enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING}; @@ -110,7 +110,7 @@ struct MOVER { /* NOTE: If effect polys can overlap, this needs improving */ bool bInEffect; - PROCESS *pProc; + Common::PROCESS *pProc; // Discworld 2 specific fields int32 zOverride; diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp index 1b06e3929c..0c0cc5c81e 100644 --- a/engines/tinsel/savescn.cpp +++ b/engines/tinsel/savescn.cpp @@ -190,7 +190,7 @@ void sortActors(SAVED_DATA *sd) { RestoreAuxScales(sd->SavedMoverInfo); for (int i = 0; i < MAX_MOVERS; i++) { if (sd->SavedMoverInfo[i].bActive) - Stand(nullContext, sd->SavedMoverInfo[i].actorID, sd->SavedMoverInfo[i].objX, + Stand(Common::nullContext, sd->SavedMoverInfo[i].actorID, sd->SavedMoverInfo[i].objX, sd->SavedMoverInfo[i].objY, sd->SavedMoverInfo[i].hLastfilm); } } @@ -245,7 +245,7 @@ static void SortMAProcess(CORO_PARAM, const void *) { void ResumeInterprets() { // Master script only affected on restore game, not restore scene if (!TinselV2 && (g_rsd == &g_sgData)) { - g_scheduler->killMatchingProcess(PID_MASTER_SCR, -1); + CoroScheduler.killMatchingProcess(PID_MASTER_SCR, -1); FreeMasterInterpretContext(); } @@ -314,7 +314,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { // Master script only affected on restore game, not restore scene if (sd == &g_sgData) { - g_scheduler->killMatchingProcess(PID_MASTER_SCR); + CoroScheduler.killMatchingProcess(PID_MASTER_SCR); KillGlobalProcesses(); FreeMasterInterpretContext(); } @@ -340,7 +340,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { SetDoFadeIn(!g_bNoFade); g_bNoFade = false; - StartupBackground(nullContext, sd->SavedBgroundHandle); + StartupBackground(Common::nullContext, sd->SavedBgroundHandle); if (TinselV2) { Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset); @@ -354,7 +354,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { if (TinselV2) { // create process to sort out the moving actors - g_scheduler->createProcess(PID_MOVER, SortMAProcess, NULL, 0); + CoroScheduler.createProcess(PID_MOVER, SortMAProcess, NULL, 0); g_bNotDoneYet = true; RestoreActorZ(sd->savedActorZ); diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp index f635ce13a3..79bb30f7a3 100644 --- a/engines/tinsel/scene.cpp +++ b/engines/tinsel/scene.cpp @@ -193,7 +193,7 @@ void SendSceneTinselProcess(TINSEL_EVENT event) { init.event = event; init.hTinselCode = ss->hSceneScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } } } @@ -271,7 +271,7 @@ static void LoadScene(SCNHANDLE scene, int entry) { init.event = STARTUP; init.hTinselCode = es->hScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } break; } @@ -291,7 +291,7 @@ static void LoadScene(SCNHANDLE scene, int entry) { init.event = STARTUP; init.hTinselCode = ss->hSceneScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } } @@ -344,7 +344,7 @@ void EndScene() { KillAllObjects(); // kill all destructable process - g_scheduler->killMatchingProcess(PID_DESTROY, PID_DESTROY); + CoroScheduler.killMatchingProcess(PID_DESTROY, PID_DESTROY); } /** @@ -405,16 +405,16 @@ void PrimeScene() { if (!TinselV2) EnableTags(); // Next scene with tags enabled - g_scheduler->createProcess(PID_SCROLL, ScrollProcess, NULL, 0); - g_scheduler->createProcess(PID_SCROLL, EffectPolyProcess, NULL, 0); + CoroScheduler.createProcess(PID_SCROLL, ScrollProcess, NULL, 0); + CoroScheduler.createProcess(PID_SCROLL, EffectPolyProcess, NULL, 0); #ifdef DEBUG if (g_ShowPosition) - g_scheduler->createProcess(PID_POSITION, CursorPositionProcess, NULL, 0); + CoroScheduler.createProcess(PID_POSITION, CursorPositionProcess, NULL, 0); #endif - g_scheduler->createProcess(PID_TAG, TagProcess, NULL, 0); - g_scheduler->createProcess(PID_TAG, PointProcess, NULL, 0); + CoroScheduler.createProcess(PID_TAG, TagProcess, NULL, 0); + CoroScheduler.createProcess(PID_TAG, PointProcess, NULL, 0); // init the current background PrimeBackground(); @@ -471,7 +471,7 @@ void DoHailScene(SCNHANDLE scene) { init.event = NOEVENT; init.hTinselCode = ss->hSceneScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } } diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp index 343758d924..4bf356ba36 100644 --- a/engines/tinsel/sched.cpp +++ b/engines/tinsel/sched.cpp @@ -32,8 +32,6 @@ namespace Tinsel { -Scheduler *g_scheduler = 0; - #include "common/pack-start.h" // START STRUCT PACKING struct PROCESS_STRUC { @@ -53,471 +51,6 @@ static SCNHANDLE g_hSceneProcess; static uint32 g_numGlobalProcess; static PROCESS_STRUC *g_pGlobalProcess; -//--------------------- FUNCTIONS ------------------------ - -Scheduler::Scheduler() { - processList = 0; - pFreeProcesses = 0; - pCurrent = 0; - -#ifdef DEBUG - // diagnostic process counters - numProcs = 0; - maxProcs = 0; -#endif - - pRCfunction = 0; - - active = new PROCESS; - active->pPrevious = NULL; - active->pNext = NULL; - - g_scheduler = this; // FIXME HACK -} - -Scheduler::~Scheduler() { - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc = pProc->pNext; - } - - free(processList); - processList = NULL; - - delete active; - active = 0; -} - -/** - * Kills all processes and places them on the free list. - */ -void Scheduler::reset() { - -#ifdef DEBUG - // clear number of process in use - numProcs = 0; -#endif - - if (processList == NULL) { - // first time - allocate memory for process list - processList = (PROCESS *)calloc(MAX_PROCESSES, sizeof(PROCESS)); - - // make sure memory allocated - if (processList == NULL) { - error("Cannot allocate memory for process data"); - } - - // fill with garbage - memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); - } - - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc = pProc->pNext; - } - - // no active processes - pCurrent = active->pNext = NULL; - - // place first process on free list - pFreeProcesses = processList; - - // link all other processes after first - for (int i = 1; i <= NUM_PROCESS; i++) { - processList[i - 1].pNext = (i == NUM_PROCESS) ? NULL : processList + i; - processList[i - 1].pPrevious = (i == 1) ? active : processList + (i - 2); - } -} - - -#ifdef DEBUG -/** - * Shows the maximum number of process used at once. - */ -void Scheduler::printStats() { - debug("%i process of %i used", maxProcs, NUM_PROCESS); -} -#endif - -#ifdef DEBUG -/** - * Checks both the active and free process list to insure all the links are valid, - * and that no processes have been lost - */ -void Scheduler::CheckStack() { - Common::List pList; - - // Check both the active and free process lists - for (int i = 0; i < 2; ++i) { - PROCESS *p = (i == 0) ? active : pFreeProcesses; - - if (p != NULL) { - // Make sure the linkages are correct - while (p->pNext != NULL) { - assert(p->pNext->pPrevious == p); - pList.push_back(p); - p = p->pNext; - } - pList.push_back(p); - } - } - - // Make sure all processes are accounted for - for (int idx = 0; idx < NUM_PROCESS; idx++) { - bool found = false; - for (Common::List::iterator i = pList.begin(); i != pList.end(); ++i) { - PROCESS *pTemp = *i; - if (*i == &processList[idx]) { - found = true; - break; - } - } - - assert(found); - } -} -#endif - -/** - * Give all active processes a chance to run - */ -void Scheduler::schedule() { - // start dispatching active process list - PROCESS *pNext; - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - pNext = pProc->pNext; - - if (--pProc->sleepTime <= 0) { - // process is ready for dispatch, activate it - pCurrent = pProc; - pProc->coroAddr(pProc->state, pProc->param); - - if (!pProc->state || pProc->state->_sleep <= 0) { - // Coroutine finished - pCurrent = pCurrent->pPrevious; - killProcess(pProc); - } else { - pProc->sleepTime = pProc->state->_sleep; - } - - // pCurrent may have been changed - pNext = pCurrent->pNext; - pCurrent = NULL; - } - - pProc = pNext; - } -} - -/** - * Reschedules all the processes to run again this query - */ -void Scheduler::rescheduleAll() { - assert(pCurrent); - - // Unlink current process - pCurrent->pPrevious->pNext = pCurrent->pNext; - if (pCurrent->pNext) - pCurrent->pNext->pPrevious = pCurrent->pPrevious; - - // Add process to the start of the active list - pCurrent->pNext = active->pNext; - active->pNext->pPrevious = pCurrent; - active->pNext = pCurrent; - pCurrent->pPrevious = active; -} - -/** - * If the specified process has already run on this tick, make it run - * again on the current tick. - */ -void Scheduler::reschedule(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - PPROCESS pEnd; - - // Find the last process in the list. - // But if the target process is down the list from here, do nothing - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) { - if (pEnd->pNext == pReSchedProc) - return; - } - - assert(pEnd->pNext == NULL); - - // Could be in the middle of a KillProc()! - // Dying process was last and this process was penultimate - if (pReSchedProc->pNext == NULL) - return; - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Moves the specified process to the end of the dispatch queue - * allowing it to run again within the current game cycle. - * @param pGiveProc Which process - */ -void Scheduler::giveWay(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - // If the process is already at the end of the queue, nothing has to be done - if (!pReSchedProc->pNext) - return; - - PPROCESS pEnd; - - // Find the last process in the list. - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) - ; - assert(pEnd->pNext == NULL); - - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Creates a new process. - * - * @param pid process identifier - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info - */ -PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { - PROCESS *pProc; - - // get a free process - pProc = pFreeProcesses; - - // trap no free process - assert(pProc != NULL); // Out of processes - -#ifdef DEBUG - // one more process in use - if (++numProcs > maxProcs) - maxProcs = numProcs; -#endif - - // get link to next free process - pFreeProcesses = pProc->pNext; - if (pFreeProcesses) - pFreeProcesses->pPrevious = NULL; - - if (pCurrent != NULL) { - // place new process before the next active process - pProc->pNext = pCurrent->pNext; - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - - // make this new process the next active process - pCurrent->pNext = pProc; - pProc->pPrevious = pCurrent; - - } else { // no active processes, place process at head of list - pProc->pNext = active->pNext; - pProc->pPrevious = active; - - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - active->pNext = pProc; - - } - - // set coroutine entry point - pProc->coroAddr = coroAddr; - - // clear coroutine state - pProc->state = 0; - - // wake process up as soon as possible - pProc->sleepTime = 1; - - // set new process id - pProc->pid = pid; - - // set new process specific info - if (sizeParam) { - assert(sizeParam > 0 && sizeParam <= PARAM_SIZE); - - // set new process specific info - memcpy(pProc->param, pParam, sizeParam); - } - - // return created process - return pProc; -} - -/** - * Kills the specified process. - * - * @param pKillProc which process to kill - */ -void Scheduler::killProcess(PROCESS *pKillProc) { - // make sure a valid process pointer - assert(pKillProc >= processList && pKillProc <= processList + NUM_PROCESS - 1); - - // can not kill the current process using killProcess ! - assert(pCurrent != pKillProc); - -#ifdef DEBUG - // one less process in use - --numProcs; - assert(numProcs >= 0); -#endif - - // Free process' resources - if (pRCfunction != NULL) - (pRCfunction)(pKillProc); - - delete pKillProc->state; - pKillProc->state = 0; - - // Take the process out of the active chain list - pKillProc->pPrevious->pNext = pKillProc->pNext; - if (pKillProc->pNext) - pKillProc->pNext->pPrevious = pKillProc->pPrevious; - - // link first free process after pProc - pKillProc->pNext = pFreeProcesses; - if (pFreeProcesses) - pKillProc->pNext->pPrevious = pKillProc; - pKillProc->pPrevious = NULL; - - // make pKillProc the first free process - pFreeProcesses = pKillProc; -} - - - -/** - * Returns a pointer to the currently running process. - */ -PROCESS *Scheduler::getCurrentProcess() { - return pCurrent; -} - -/** - * Returns the process identifier of the specified process. - * - * @param pProc which process - */ -int Scheduler::getCurrentPID() const { - PROCESS *pProc = pCurrent; - - // make sure a valid process pointer - assert(pProc >= processList && pProc <= processList + NUM_PROCESS - 1); - - // return processes PID - return pProc->pid; -} - -/** - * Kills any process matching the specified PID. The current - * process cannot be killed. - * - * @param pidKill process identifier of process to kill - * @param pidMask mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. - */ -int Scheduler::killMatchingProcess(int pidKill, int pidMask) { - int numKilled = 0; - PROCESS *pProc, *pPrev; // process list pointers - - for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { - if ((pProc->pid & pidMask) == pidKill) { - // found a matching process - - // dont kill the current process - if (pProc != pCurrent) { - // kill this process - numKilled++; - - // Free the process' resources - if (pRCfunction != NULL) - (pRCfunction)(pProc); - - delete pProc->state; - pProc->state = 0; - - // make prev point to next to unlink pProc - pPrev->pNext = pProc->pNext; - if (pProc->pNext) - pPrev->pNext->pPrevious = pPrev; - - // link first free process after pProc - pProc->pNext = pFreeProcesses; - pProc->pPrevious = NULL; - pFreeProcesses->pPrevious = pProc; - - // make pProc the first free process - pFreeProcesses = pProc; - - // set to a process on the active list - pProc = pPrev; - } - } - } - -#ifdef DEBUG - // adjust process in use - numProcs -= numKilled; - assert(numProcs >= 0); -#endif - - // return number of processes killed - return numKilled; -} - -/** - * Set pointer to a function to be called by killProcess(). - * - * May be called by a resource allocator, the function supplied is - * called by killProcess() to allow the resource allocator to free - * resources allocated to the dying process. - * - * @param pFunc Function to be called by killProcess() - */ -void Scheduler::setResourceCallback(VFPTRPP pFunc) { - pRCfunction = pFunc; -} /**************************************************************************\ |*********** Stuff to do with scene and global processes ************| @@ -537,7 +70,7 @@ static void RestoredProcessProcess(CORO_PARAM, const void *param) { _ctx->pic = *(const PINT_CONTEXT *)param; _ctx->pic = RestoreInterpretContext(_ctx->pic); - AttachInterpret(_ctx->pic, g_scheduler->getCurrentProcess()); + AttachInterpret(_ctx->pic, CoroScheduler.getCurrentProcess()); CORO_INVOKE_1(Interpret, _ctx->pic); @@ -577,7 +110,7 @@ void RestoreSceneProcess(INT_CONTEXT *pic) { pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { if (FROM_LE_32(pStruc[i].hProcessCode) == pic->hCode) { - g_scheduler->createProcess(PID_PROCESS + i, RestoredProcessProcess, + CoroScheduler.createProcess(PID_PROCESS + i, RestoredProcessProcess, &pic, sizeof(pic)); break; } @@ -596,7 +129,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait CORO_BEGIN_CONTEXT; PROCESS_STRUC *pStruc; - PPROCESS pProc; + Common::PPROCESS pProc; PINT_CONTEXT pic; CORO_END_CONTEXT(_ctx); @@ -617,7 +150,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait if (_ctx->pic == NULL) return; - _ctx->pProc = g_scheduler->createProcess(PID_PROCESS + i, ProcessTinselProcess, + _ctx->pProc = CoroScheduler.createProcess(PID_PROCESS + i, ProcessTinselProcess, &_ctx->pic, sizeof(_ctx->pic)); AttachInterpret(_ctx->pic, _ctx->pProc); break; @@ -644,7 +177,7 @@ void KillSceneProcess(uint32 procID) { pStruc = (PROCESS_STRUC *) LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { if (FROM_LE_32(pStruc[i].processId) == procID) { - g_scheduler->killMatchingProcess(PID_PROCESS + i, -1); + CoroScheduler.killMatchingProcess(PID_PROCESS + i, -1); break; } } @@ -671,7 +204,7 @@ void RestoreGlobalProcess(INT_CONTEXT *pic) { for (i = 0; i < g_numGlobalProcess; i++) { if (g_pGlobalProcess[i].hProcessCode == pic->hCode) { - g_scheduler->createProcess(PID_GPROCESS + i, RestoredProcessProcess, + CoroScheduler.createProcess(PID_GPROCESS + i, RestoredProcessProcess, &pic, sizeof(pic)); break; } @@ -686,7 +219,7 @@ void RestoreGlobalProcess(INT_CONTEXT *pic) { void KillGlobalProcesses() { for (uint32 i = 0; i < g_numGlobalProcess; ++i) { - g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1); + CoroScheduler.killMatchingProcess(PID_GPROCESS + i, -1); } } @@ -696,7 +229,7 @@ void KillGlobalProcesses() { bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait, int myEscape) { CORO_BEGIN_CONTEXT; PINT_CONTEXT pic; - PPROCESS pProc; + Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); bool result = false; @@ -720,7 +253,7 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai if (_ctx->pic != NULL) { - _ctx->pProc = g_scheduler->createProcess(PID_GPROCESS + i, ProcessTinselProcess, + _ctx->pProc = CoroScheduler.createProcess(PID_GPROCESS + i, ProcessTinselProcess, &_ctx->pic, sizeof(_ctx->pic)); AttachInterpret(_ctx->pic, _ctx->pProc); } @@ -745,7 +278,7 @@ void xKillGlobalProcess(uint32 procID) { for (i = 0; i < g_numGlobalProcess; ++i) { if (g_pGlobalProcess[i].processId == procID) { - g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1); + CoroScheduler.killMatchingProcess(PID_GPROCESS + i, -1); break; } } diff --git a/engines/tinsel/sched.h b/engines/tinsel/sched.h index a1eafcdc47..3e791cecd8 100644 --- a/engines/tinsel/sched.h +++ b/engines/tinsel/sched.h @@ -24,105 +24,16 @@ #ifndef TINSEL_SCHED_H // prevent multiple includes #define TINSEL_SCHED_H +#include "common/coroutines.h" #include "tinsel/dw.h" // new data types -#include "tinsel/coroutine.h" #include "tinsel/events.h" +#include "tinsel/pcode.h" #include "tinsel/tinsel.h" namespace Tinsel { -// the size of process specific info -#define PARAM_SIZE 32 - -// the maximum number of processes -#define NUM_PROCESS (TinselV2 ? 70 : 64) -#define MAX_PROCESSES 70 - -typedef void (*CORO_ADDR)(CoroContext &, const void *); - -/** process structure */ -struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list - PROCESS *pPrevious; ///< pointer to previous process in active or free list - - CoroContext state; ///< the state of the coroutine - CORO_ADDR coroAddr; ///< the entry point of the coroutine - - int sleepTime; ///< number of scheduler cycles to sleep - int pid; ///< process ID - char param[PARAM_SIZE]; ///< process specific info -}; -typedef PROCESS *PPROCESS; - struct INT_CONTEXT; -/** - * Create and manage "processes" (really coroutines). - */ -class Scheduler { -public: - /** Pointer to a function of the form "void function(PPROCESS)" */ - typedef void (*VFPTRPP)(PROCESS *); - -private: - - /** list of all processes */ - PROCESS *processList; - - /** active process list - also saves scheduler state */ - PROCESS *active; - - /** pointer to free process list */ - PROCESS *pFreeProcesses; - - /** the currently active process */ - PROCESS *pCurrent; - -#ifdef DEBUG - // diagnostic process counters - int numProcs; - int maxProcs; - - void CheckStack(); -#endif - - /** - * Called from killProcess() to enable other resources - * a process may be allocated to be released. - */ - VFPTRPP pRCfunction; - - -public: - - Scheduler(); - ~Scheduler(); - - void reset(); - - #ifdef DEBUG - void printStats(); - #endif - - void schedule(); - void rescheduleAll(); - void reschedule(PPROCESS pReSchedProc = NULL); - void giveWay(PPROCESS pReSchedProc = NULL); - - PROCESS *createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); - void killProcess(PROCESS *pKillProc); - - PROCESS *getCurrentProcess(); - int getCurrentPID() const; - int killMatchingProcess(int pidKill, int pidMask = -1); - - - void setResourceCallback(VFPTRPP pFunc); - -}; - -extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied - //----------------- FUNCTION PROTOTYPES -------------------- void SceneProcesses(uint32 numProcess, SCNHANDLE hProcess); diff --git a/engines/tinsel/text.h b/engines/tinsel/text.h index 4c80300c46..97e82c7a93 100644 --- a/engines/tinsel/text.h +++ b/engines/tinsel/text.h @@ -24,7 +24,7 @@ #ifndef TINSEL_TEXT_H // prevent multiple includes #define TINSEL_TEXT_H -#include "tinsel/coroutine.h" +#include "common/coroutines.h" #include "tinsel/object.h" // object manager defines namespace Tinsel { diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp index c652abca25..dfa44c505a 100644 --- a/engines/tinsel/tinlib.cpp +++ b/engines/tinsel/tinlib.cpp @@ -28,11 +28,11 @@ #define BODGE +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" #include "tinsel/bmv.h" #include "tinsel/config.h" -#include "tinsel/coroutine.h" #include "tinsel/cursor.h" #include "tinsel/drives.h" #include "tinsel/dw.h" @@ -1468,7 +1468,7 @@ void NewScene(CORO_PARAM, SCNHANDLE scene, int entrance, int transition) { ++g_sceneCtr; // Prevent code subsequent to this call running before scene changes - if (g_scheduler->getCurrentPID() != PID_MASTER_SCR) + if (CoroScheduler.getCurrentPID() != PID_MASTER_SCR) CORO_KILL_SELF(); CORO_END_CODE; } @@ -2594,7 +2594,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y sm.y = _ctx->y; sm.thisScroll = g_scrollNumber; sm.myEscape = myEscape; - g_scheduler->createProcess(PID_TCODE, ScrollMonitorProcess, &sm, sizeof(sm)); + CoroScheduler.createProcess(PID_TCODE, ScrollMonitorProcess, &sm, sizeof(sm)); } } CORO_END_CODE; @@ -2975,12 +2975,12 @@ static void StandTag(int actor, HPOLYGON hp) { && hFilm != TF_LEFT && hFilm != TF_RIGHT) hFilm = 0; - Stand(nullContext, actor, pnodex, pnodey, hFilm); + Stand(Common::nullContext, actor, pnodex, pnodey, hFilm); } else if (hFilm && (actor == LEAD_ACTOR || actor == GetLeadId())) - Stand(nullContext, actor, pnodex, pnodey, hFilm); + Stand(Common::nullContext, actor, pnodex, pnodey, hFilm); else - Stand(nullContext, actor, pnodex, pnodey, 0); + Stand(Common::nullContext, actor, pnodex, pnodey, 0); } diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 65900cc7f3..e09e2c1dcf 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -109,8 +109,8 @@ static Scene g_NextScene = { 0, 0, 0 }; static Scene g_HookScene = { 0, 0, 0 }; static Scene g_DelayedScene = { 0, 0, 0 }; -static PROCESS *g_pMouseProcess = 0; -static PROCESS *g_pKeyboardProcess = 0; +static Common::PROCESS *g_pMouseProcess = 0; +static Common::PROCESS *g_pKeyboardProcess = 0; static SCNHANDLE g_hCdChangeScene; @@ -324,7 +324,7 @@ static void MouseProcess(CORO_PARAM, const void *) { if (TinselV2) { // Kill off the button process and fire off the action command - g_scheduler->killMatchingProcess(PID_BTN_CLICK, -1); + CoroScheduler.killMatchingProcess(PID_BTN_CLICK, -1); PlayerEvent(PLR_ACTION, _ctx->clickPos); } else { // signal left drag start @@ -368,7 +368,7 @@ static void MouseProcess(CORO_PARAM, const void *) { // will activate a single button click if (TinselV2 && ControlIsOn()) { _ctx->clickPos = mousePos; - g_scheduler->createProcess(PID_BTN_CLICK, SingleLeftProcess, &_ctx->clickPos, sizeof(Common::Point)); + CoroScheduler.createProcess(PID_BTN_CLICK, SingleLeftProcess, &_ctx->clickPos, sizeof(Common::Point)); } } else _ctx->lastLeftClick -= _vm->_config->_dclickSpeed; @@ -616,11 +616,11 @@ static void RestoredProcess(CORO_PARAM, const void *param) { } void RestoreProcess(INT_CONTEXT *pic) { - g_scheduler->createProcess(PID_TCODE, RestoredProcess, &pic, sizeof(pic)); + CoroScheduler.createProcess(PID_TCODE, RestoredProcess, &pic, sizeof(pic)); } void RestoreMasterProcess(INT_CONTEXT *pic) { - g_scheduler->createProcess(PID_MASTER_SCR, RestoredProcess, &pic, sizeof(pic)); + CoroScheduler.createProcess(PID_MASTER_SCR, RestoredProcess, &pic, sizeof(pic)); } // FIXME: CountOut is used by ChangeScene @@ -878,7 +878,6 @@ TinselEngine::~TinselEngine() { FreeObjectList(); FreeGlobalProcesses(); FreeGlobals(); - delete _scheduler; delete _config; @@ -905,7 +904,7 @@ Common::Error TinselEngine::run() { _console = new Console(); - _scheduler = new Scheduler(); + CoroScheduler.reset(); InitSysVars(); @@ -1022,7 +1021,7 @@ void TinselEngine::NextGameCycle() { ResetEcount(); // schedule process - _scheduler->schedule(); + CoroScheduler.schedule(); if (_bmv->MoviePlaying()) _bmv->CopyMovieToScreen(); @@ -1078,11 +1077,11 @@ bool TinselEngine::pollEvent() { */ void TinselEngine::CreateConstProcesses() { // Process to run the master script - _scheduler->createProcess(PID_MASTER_SCR, MasterScriptProcess, NULL, 0); + CoroScheduler.createProcess(PID_MASTER_SCR, MasterScriptProcess, NULL, 0); // Processes to run the cursor and inventory, - _scheduler->createProcess(PID_CURSOR, CursorProcess, NULL, 0); - _scheduler->createProcess(PID_INVENTORY, InventoryProcess, NULL, 0); + CoroScheduler.createProcess(PID_CURSOR, CursorProcess, NULL, 0); + CoroScheduler.createProcess(PID_INVENTORY, InventoryProcess, NULL, 0); } /** @@ -1132,11 +1131,11 @@ void TinselEngine::RestartDrivers() { KillAllObjects(); // init the process scheduler - _scheduler->reset(); + CoroScheduler.reset(); // init the event handlers - g_pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0); - g_pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0); + g_pMouseProcess = CoroScheduler.createProcess(PID_MOUSE, MouseProcess, NULL, 0); + g_pKeyboardProcess = CoroScheduler.createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0); // open MIDI files OpenMidiFiles(); @@ -1164,8 +1163,8 @@ void TinselEngine::ChopDrivers() { DeleteMidiBuffer(); // remove event drivers - _scheduler->killProcess(g_pMouseProcess); - _scheduler->killProcess(g_pKeyboardProcess); + CoroScheduler.killProcess(g_pMouseProcess); + CoroScheduler.killProcess(g_pKeyboardProcess); } /** diff --git a/engines/tinsel/token.cpp b/engines/tinsel/token.cpp index c26fa40466..080c005c3c 100644 --- a/engines/tinsel/token.cpp +++ b/engines/tinsel/token.cpp @@ -31,7 +31,7 @@ namespace Tinsel { //----------------- LOCAL GLOBAL DATA -------------------- struct Token { - PROCESS *proc; + Common::PROCESS *proc; }; static Token g_tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars @@ -40,7 +40,7 @@ static Token g_tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars /** * Release all tokens held by this process, and kill the process. */ -static void TerminateProcess(PROCESS *tProc) { +static void TerminateProcess(Common::PROCESS *tProc) { // Release tokens held by the process for (int i = 0; i < NUMTOKENS; i++) { @@ -50,7 +50,7 @@ static void TerminateProcess(PROCESS *tProc) { } // Kill the process - g_scheduler->killProcess(tProc); + CoroScheduler.killProcess(tProc); } /** @@ -60,7 +60,7 @@ void GetControlToken() { const int which = TOKEN_CONTROL; if (g_tokens[which].proc == NULL) { - g_tokens[which].proc = g_scheduler->getCurrentProcess(); + g_tokens[which].proc = CoroScheduler.getCurrentProcess(); } } @@ -85,11 +85,11 @@ void GetToken(int which) { assert(TOKEN_LEAD <= which && which < NUMTOKENS); if (g_tokens[which].proc != NULL) { - assert(g_tokens[which].proc != g_scheduler->getCurrentProcess()); + assert(g_tokens[which].proc != CoroScheduler.getCurrentProcess()); TerminateProcess(g_tokens[which].proc); } - g_tokens[which].proc = g_scheduler->getCurrentProcess(); + g_tokens[which].proc = CoroScheduler.getCurrentProcess(); } /** @@ -99,7 +99,7 @@ void GetToken(int which) { void FreeToken(int which) { assert(TOKEN_LEAD <= which && which < NUMTOKENS); - assert(g_tokens[which].proc == g_scheduler->getCurrentProcess()); // we'd have been killed if some other proc had taken this token + assert(g_tokens[which].proc == CoroScheduler.getCurrentProcess()); // we'd have been killed if some other proc had taken this token g_tokens[which].proc = NULL; } -- cgit v1.2.3 From 68c1b0b0e46b0575a4670d1ffda2fa3c8ae94ed8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:15:59 +1000 Subject: TONY: Refactored Tony to use the Common coroutine scheduler --- engines/tony/adv.h | 2 +- engines/tony/coroutine.h | 6 +-- engines/tony/custom.cpp | 50 +++++++++--------- engines/tony/font.cpp | 36 ++++++------- engines/tony/font.h | 1 + engines/tony/game.cpp | 2 +- engines/tony/gfxengine.cpp | 20 +++---- engines/tony/loc.cpp | 42 +++++++-------- engines/tony/loc.h | 2 +- engines/tony/module.mk | 2 - engines/tony/mpal/mpal.cpp | 92 ++++++++++++++++---------------- engines/tony/mpal/mpal.h | 6 +-- engines/tony/sched.h | 129 --------------------------------------------- engines/tony/sound.cpp | 12 ++--- engines/tony/tony.cpp | 21 ++++---- engines/tony/tony.h | 2 +- engines/tony/tonychar.cpp | 24 ++++----- engines/tony/tonychar.h | 4 +- engines/tony/window.cpp | 6 +-- 19 files changed, 166 insertions(+), 293 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index a1b21c1e08..6a1b6ce246 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -48,8 +48,8 @@ #ifndef TONY_ADV_H #define TONY_ADV_H +#include "common/coroutines.h" #include "tony/mpal/memory.h" -#include "tony/coroutine.h" #include "tony/gfxcore.h" diff --git a/engines/tony/coroutine.h b/engines/tony/coroutine.h index 24742a22f9..b4eb105f58 100644 --- a/engines/tony/coroutine.h +++ b/engines/tony/coroutine.h @@ -113,7 +113,7 @@ public: * context, and so compilers won't complain about ";" following the macro. */ #define CORO_BEGIN_CONTEXT \ - struct CoroContextTag : CoroBaseContext { \ + struct CoroContextTag : Common::CoroBaseContext { \ CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ int DUMMY @@ -156,8 +156,8 @@ public: return; case __LINE__:;\ } while (0) -#define CORO_GIVE_WAY do { g_scheduler->giveWay(); CORO_SLEEP(1); } while (0) -#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0) +#define CORO_GIVE_WAY do { CoroScheduler.giveWay(); CORO_SLEEP(1); } while (0) +#define CORO_RESCHEDULE do { CoroScheduler.reschedule(); CORO_SLEEP(1); } while (0) /** * Stop the currently running coroutine and all calling coroutines. diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 5089914d88..234dd0a4f9 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -327,7 +327,7 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); if (!bSkipIdle) - CORO_INVOKE_1(g_scheduler->sleep, dwTime); + CORO_INVOKE_1(CoroScheduler.sleep, dwTime); CORO_END_CODE; } @@ -524,8 +524,8 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); CORO_END_CODE; } @@ -708,8 +708,8 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint bNoOcchioDiBue = false; // On Enter? - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); CORO_END_CODE; } @@ -1843,8 +1843,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per inizializzare la parlata if (MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_PID_VALUE) { - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } } @@ -1924,8 +1924,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } CORO_END_CODE; @@ -2035,8 +2035,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } else { // Cerca di eseguire la funzione custom per inizializzare la parlata _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); MCharacter[nPers].curTalk = _ctx->parm; @@ -2099,8 +2099,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); MCharacter[nPers].bInTexts = false; MCharacter[nPers].numtexts = 0; @@ -2214,7 +2214,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); -// WaitForSingleObject(mut[num],INFINITE); +// WaitForSingleObject(mut[num],CORO_INFINITE); warning("TODO"); } @@ -2264,7 +2264,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { _vm->SetMusicVolume(nChannel, _ctx->i * 4); - CORO_INVOKE_1(g_scheduler->sleep, 100); + CORO_INVOKE_1(CoroScheduler.sleep, 100); } _vm->SetMusicVolume(nChannel, 64); @@ -2293,7 +2293,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (_ctx->i * 4 < _ctx->startVolume) _vm->SetMusicVolume(nChannel, _ctx->i * 4); - CORO_INVOKE_1(g_scheduler->sleep, 100); + CORO_INVOKE_1(CoroScheduler.sleep, 100); } if (!bFadeOutStop) @@ -2311,23 +2311,23 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - g_scheduler->createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; - g_scheduler->createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; int channel = 2; - g_scheduler->createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { int channel = 2; - g_scheduler->createProcess(ThreadFadeInMusic, &channel, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2557,12 +2557,12 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = true; - g_scheduler->setEvent(hSkipIdle); + CoroScheduler.setEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = false; - g_scheduler->resetEvent(hSkipIdle); + CoroScheduler.resetEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { @@ -2608,7 +2608,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_BEGIN_CODE(_ctx); _ctx->msg = new RMMessage(nMsg); - _ctx->hDisable = g_scheduler->createEvent(true, false); + _ctx->hDisable = CoroScheduler.createEvent(true, false); _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; @@ -2649,7 +2649,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 break; } - g_scheduler->setEvent(_ctx->hDisable); + CoroScheduler.setEvent(_ctx->hDisable); CORO_INVOKE_0(WaitFrame); CORO_INVOKE_0(WaitFrame); @@ -2882,7 +2882,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation // Crea l'evento per skippare le idle - hSkipIdle = g_scheduler->createEvent(true, false); + hSkipIdle = CoroScheduler.createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 5dbbd3f71f..8cc60a917b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2048,16 +2048,16 @@ RMTextDialog::RMTextDialog() : RMText() { m_bForceNoTime = false; m_bAlwaysDisplay = false; m_bNoTab = false; - hCustomSkip = INVALID_PID_VALUE; - hCustomSkip2 = INVALID_PID_VALUE; + hCustomSkip = CORO_INVALID_PID_VALUE; + hCustomSkip2 = CORO_INVALID_PID_VALUE; m_input = NULL; // Crea l'evento di fine displaying - hEndDisplay = g_scheduler->createEvent(false, false); + hEndDisplay = CoroScheduler.createEvent(false, false); } RMTextDialog::~RMTextDialog() { - g_scheduler->closeEvent(hEndDisplay); + CoroScheduler.closeEvent(hEndDisplay); } void RMTextDialog::Show(void) { @@ -2119,7 +2119,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Frase NON di background if (m_bSkipStatus) { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (bCfgTimerizedText) { if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) @@ -2137,7 +2137,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } // Frase di background else { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2148,15 +2148,15 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; - if (hCustomSkip != INVALID_PID_VALUE) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip, 0, &_ctx->expired); + if (hCustomSkip != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; } - if (bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); + if (bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; @@ -2170,7 +2170,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - g_scheduler->setEvent(hEndDisplay); + CoroScheduler.setEvent(hEndDisplay); } void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2194,7 +2194,7 @@ void RMTextDialog::SetCustomSkipHandle2(uint32 hCustom) { } void RMTextDialog::WaitForEndDisplay(CORO_PARAM) { - g_scheduler->waitForSingleObject(coroParam, hEndDisplay, INFINITE); + CoroScheduler.waitForSingleObject(coroParam, hEndDisplay, CORO_INFINITE); } void RMTextDialog::SetInput(RMInput *input) { @@ -2287,10 +2287,10 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); - if (_ctx->hThread == INVALID_PID_VALUE) + if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->hThread, CORO_INFINITE); } } @@ -2344,18 +2344,18 @@ RMDialogChoice::RMDialogChoice() { DlgText.LoadPaletteWA(dlgpal); DlgTextLine.LoadPaletteWA(dlgpal); - hUnreg = g_scheduler->createEvent(false, false); + hUnreg = CoroScheduler.createEvent(false, false); bRemoveFromOT = false; } RMDialogChoice::~RMDialogChoice() { - g_scheduler->closeEvent(hUnreg); + CoroScheduler.closeEvent(hUnreg); } void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); assert(!m_nInList); - g_scheduler->pulseEvent(hUnreg); + CoroScheduler.pulseEvent(hUnreg); bRemoveFromOT = false; } @@ -2547,7 +2547,7 @@ void RMDialogChoice::Hide(CORO_PARAM) { m_bShow = false; bRemoveFromOT = true; - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hUnreg, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hUnreg, CORO_INFINITE); CORO_END_CODE; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 0306c6c673..7447f31515 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -49,6 +49,7 @@ #define TONY_FONT_H #include "common/system.h" +#include "common/coroutines.h" #include "tony/gfxcore.h" #include "tony/resid.h" #include "tony/sched.h" diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 377ec73673..820641e48f 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -113,7 +113,7 @@ void MainUnfreeze(void) { } void MainWaitFrame(CORO_PARAM) { - g_scheduler->waitForSingleObject(coroParam, _vm->m_hEndOfFrame, INFINITE); + CoroScheduler.waitForSingleObject(coroParam, _vm->m_hEndOfFrame, CORO_INFINITE); } void MainShowMouse(void) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 5a9c0555e0..88aac99ebe 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -140,7 +140,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { bIdleExited = false; - g_scheduler->createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); + CoroScheduler.createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); } } @@ -242,7 +242,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if (m_curAction != TA_COMBINE) CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); else if (m_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); } if (m_curAction == TA_COMBINE) { @@ -333,7 +333,7 @@ SKIPCLICKSINISTRO: switch (m_nWipeType) { case 1: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - g_scheduler->setEvent(m_hWipeEvent); + CoroScheduler.setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -346,7 +346,7 @@ SKIPCLICKSINISTRO: case 2: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - g_scheduler->setEvent(m_hWipeEvent); + CoroScheduler.setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -529,7 +529,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { m_bLocationLoaded = true; // On Enter per la locazion - return INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); + return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { @@ -545,8 +545,8 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { // On Exit? if (bDoOnExit) { _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } MainFreeze(); @@ -557,7 +557,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { m_loc.Unload(); if (result != NULL) - *result = INVALID_PID_VALUE; + *result = CORO_INVALID_PID_VALUE; CORO_END_CODE; } @@ -598,7 +598,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { bIdleExited = false; m_bOption = false; m_bWiping = false; - m_hWipeEvent = g_scheduler->createEvent(false, false); + m_hWipeEvent = CoroScheduler.createEvent(false, false); // Crea l'evento di freeze csMainLoop = g_system->createMutex(); @@ -1003,7 +1003,7 @@ void RMGfxEngine::CloseWipe(void) { } void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { - g_scheduler->waitForSingleObject(coroParam, m_hWipeEvent, INFINITE); + CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE); } } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 080e06da87..e4a60cb52a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -253,7 +253,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { // Se la speed e' 0, il pattern non avanza mai if (m_speed == 0) { - g_scheduler->pulseEvent(hEndPattern); + CoroScheduler.pulseEvent(hEndPattern); bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -267,7 +267,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { m_nCurSlot = 0; bFlag = m_slots[m_nCurSlot].m_flag; - g_scheduler->pulseEvent(hEndPattern); + CoroScheduler.pulseEvent(hEndPattern); // @@@ Se non c'e' loop avverte che il pattern e' finito // Se non c'e' loop rimane sull'ultimo frame @@ -835,12 +835,12 @@ RMItem::RMItem() { m_bPal = 0; m_nCurSprite = 0; - m_hEndPattern = g_scheduler->createEvent(false, false); + m_hEndPattern = CoroScheduler.createEvent(false, false); } RMItem::~RMItem() { Unload(); - g_scheduler->closeEvent(m_hEndPattern); + CoroScheduler.closeEvent(m_hEndPattern); } //FIXME: Pass uint32 directly for hCustomSkip @@ -852,12 +852,12 @@ void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CODE(_ctx); if (m_nCurPattern != 0) { - if (hCustomSkip == INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndPattern, INFINITE); + if (hCustomSkip == CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndPattern, CORO_INFINITE); else { _ctx->h[0] = hCustomSkip; _ctx->h[1] = m_hEndPattern; - CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); + CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, CORO_INFINITE); } } @@ -888,13 +888,13 @@ void RMItem::PauseSound(bool bPause) { RMWipe::RMWipe() { - m_hUnregistered = g_scheduler->createEvent(false, false); - m_hEndOfFade = g_scheduler->createEvent(false, false); + m_hUnregistered = CoroScheduler.createEvent(false, false); + m_hEndOfFade = CoroScheduler.createEvent(false, false); } RMWipe::~RMWipe() { - g_scheduler->closeEvent(m_hUnregistered); - g_scheduler->closeEvent(m_hEndOfFade); + CoroScheduler.closeEvent(m_hUnregistered); + CoroScheduler.closeEvent(m_hEndOfFade); } int RMWipe::Priority(void) { @@ -904,7 +904,7 @@ int RMWipe::Priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - g_scheduler->setEvent(m_hUnregistered); + CoroScheduler.setEvent(m_hUnregistered); } bool RMWipe::RemoveThis(void) { @@ -917,7 +917,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndOfFade, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); m_bEndFade = true; m_bFading = false; @@ -930,7 +930,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { void RMWipe::CloseFade(void) { // m_bUnregister=true; -// WaitForSingleObject(m_hUnregistered,INFINITE); +// WaitForSingleObject(m_hUnregistered,CORO_INFINITE); m_wip0r.Unload(); } @@ -967,7 +967,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { m_nFadeStep++; if (m_nFadeStep == 10) { - g_scheduler->setEvent(m_hEndOfFade); + CoroScheduler.setEvent(m_hEndOfFade); } } } @@ -1096,7 +1096,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { if (m_pos == destcoord) { if (minpath == 0) { CORO_INVOKE_0(Stop); - g_scheduler->pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(hEndOfPath); return; } } @@ -1478,7 +1478,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) CORO_INVOKE_0(Stop); bEndOfPath = true; - g_scheduler->pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(hEndOfPath); } walkcount++; @@ -1516,7 +1516,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) CORO_INVOKE_0(Stop); bEndOfPath = true; - g_scheduler->pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(hEndOfPath); } } else { // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il @@ -1687,7 +1687,7 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (bMoving) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hEndOfPath, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1701,7 +1701,7 @@ bool RMCharacter::RemoveThis(void) { RMCharacter::RMCharacter() { csMove = g_system->createMutex(); - hEndOfPath = g_scheduler->createEvent(false, false); + hEndOfPath = CoroScheduler.createEvent(false, false); minpath = 0; curSpeed = 3; bRemoveFromOT = false; @@ -1722,7 +1722,7 @@ RMCharacter::RMCharacter() { RMCharacter::~RMCharacter() { g_system->deleteMutex(csMove); - g_scheduler->closeEvent(hEndOfPath); + CoroScheduler.closeEvent(hEndOfPath); } void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index f5826022e0..4b8946da54 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -292,7 +292,7 @@ public: void Unload(void); // Aspetta la fine del pattern in play - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE); + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); // Setta un nuovo hotspot per l'oggetto void ChangeHotspot(RMPoint pt); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 24e7f70557..af0b3acd2c 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -1,7 +1,6 @@ MODULE := engines/tony MODULE_OBJS := \ - coroutine.o \ custom.o \ detection.o \ font.o \ @@ -11,7 +10,6 @@ MODULE_OBJS := \ input.o \ inventory.o \ loc.o \ - sched.o \ sound.o \ tony.o \ tonychar.o \ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index e82df11328..42c790a1c7 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -883,13 +883,13 @@ void ScriptThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { // Dorme il tempo necessario per arrivare al momento successivo if (s->Moment[_ctx->i].dwTime == -1) { - CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, _ctx->numHandles, cfHandles, true, INFINITE); + CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = _vm->GetTime(); } else { _ctx->dwCurTime = _vm->GetTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { // warning("PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(g_scheduler->sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); } } @@ -913,7 +913,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->arg4=s->Command[_ctx->k].arg4; // !!! Nuova gestione dei thread - if ((cfHandles[_ctx->numHandles++] = g_scheduler->createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { + if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { mpalError = 1; CORO_KILL_SELF(); @@ -976,7 +976,7 @@ void ActionThread(CORO_PARAM, const void *param) { if (item->Command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - g_scheduler->getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + CoroScheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 ); @@ -991,7 +991,7 @@ void ActionThread(CORO_PARAM, const void *param) { } else if (item->Command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - g_scheduler->getCurrentPID(), item->Command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); @@ -1005,7 +1005,7 @@ void ActionThread(CORO_PARAM, const void *param) { GlobalFree(item); - debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", g_scheduler->getCurrentPID()); + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); CORO_KILL_SELF(); @@ -1026,7 +1026,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); bExecutingAction = false; @@ -1200,7 +1200,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - CORO_INVOKE_3(g_scheduler->waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) if (!_ctx->expired) @@ -1208,7 +1208,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); // if result ) == WAIT_OBJECT_0) if (!_ctx->delayExpired) @@ -1279,7 +1279,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; // !!! Nuova gestione dei thread - if ((_ctx->MyThreads[_ctx->i].hThread = g_scheduler->createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); @@ -1309,18 +1309,18 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip on // FIXME: Convert to co-routine - lplpFunctions[200](nullContext, 0, 0, 0, 0); + CORO_INVOKE_4(lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); /* //if (result != WAIT_OBJECT_0) if (_ctx->delayExpired) TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); */ - g_scheduler->killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } // Set idle skip off @@ -1361,13 +1361,13 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); bExecutingDialog = false; nExecutingDialog = 0; nExecutingChoice = 0; - g_scheduler->setEvent(hAskChoice); + CoroScheduler.setEvent(hAskChoice); CORO_KILL_SELF(); @@ -1519,9 +1519,9 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - g_scheduler->resetEvent(hDoneChoice); - g_scheduler->setEvent(hAskChoice); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hDoneChoice, INFINITE); + CoroScheduler.resetEvent(hDoneChoice); + CoroScheduler.setEvent(hAskChoice); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hDoneChoice, CORO_INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ @@ -1569,7 +1569,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * uint32 dwParam Eventuale parametro per l'azione * * Return: Handle del thread che sta eseguendo l'azione, oppure -* INVALID_PID_VALUE se l'azione non e' definita, o l'item +* CORO_INVALID_PID_VALUE se l'azione non e' definita, o l'item * e' disattivato. * * Note: Si puo' ottenere l'indice dell'item a partire dal suo numero @@ -1588,7 +1588,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); if (varGetValue(buf.c_str()) <= 0) - return INVALID_PID_VALUE; + return CORO_INVALID_PID_VALUE; for (i = 0; i < item->nActions; i++) { if (item->Action[i].num != nAction) @@ -1606,7 +1606,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // Duplichiamo l'item corrente e copiamo la azione #i nella #0 newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) - return INVALID_PID_VALUE; + return CORO_INVALID_PID_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); @@ -1619,11 +1619,11 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // 0 dell'item, e poi liberera' la memoria con la GlobalFree() // !!! New thread management - if ((h = g_scheduler->createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) - return INVALID_PID_VALUE; + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) + return CORO_INVALID_PID_VALUE; - if (g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) - return INVALID_PID_VALUE; + if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) + return CORO_INVALID_PID_VALUE; nExecutingAction = item->nObj; bExecutingAction = true; @@ -1631,7 +1631,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { return h; } - return INVALID_PID_VALUE; + return CORO_INVALID_PID_VALUE; } /** @@ -1640,7 +1640,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * @param nDlgOrd The index of the dialog in the dialog list * @param nGroup Number of the group to perform * @returns The process Id of the process running the dialog - * or INVALID_PID_VALUE on error + * or CORO_INVALID_PID_VALUE on error * @remarks The dialogue runs in a thread created on purpose, * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. @@ -1654,20 +1654,20 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; - g_scheduler->resetEvent(hAskChoice); - g_scheduler->resetEvent(hDoneChoice); + CoroScheduler.resetEvent(hAskChoice); + CoroScheduler.resetEvent(hDoneChoice); // Create a thread that performs the dialogue group // Create the process - if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == INVALID_PID_VALUE) - return INVALID_PID_VALUE; + if ((h = CoroScheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == CORO_INVALID_PID_VALUE) + return CORO_INVALID_PID_VALUE; // Create a thread that waits until the end of the dialog process, and will restore the global variables - if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == INVALID_PID_VALUE) { + if (CoroScheduler.createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) { // Something went wrong, so kill the previously started dialog process - g_scheduler->killMatchingProcess(h); - return INVALID_PID_VALUE; + CoroScheduler.killMatchingProcess(h); + return CORO_INVALID_PID_VALUE; } return h; @@ -1700,7 +1700,7 @@ bool DoSelection(uint32 i, uint32 dwData) { return false; nSelectedChoice = j; - g_scheduler->setEvent(hDoneChoice); + CoroScheduler.setEvent(hDoneChoice); return true; } @@ -1877,8 +1877,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = g_scheduler->createEvent(true, false); - hDoneChoice = g_scheduler->createEvent(true, false); + hAskChoice = CoroScheduler.createEvent(true, false); + hDoneChoice = CoroScheduler.createEvent(true, false); return true; } @@ -2070,7 +2070,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { if (y != -1) { dwRet = DoAction(x, y, GETARG(uint32)); } else { - dwRet = INVALID_PID_VALUE; + dwRet = CORO_INVALID_PID_VALUE; mpalError = 1; } @@ -2278,9 +2278,9 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hAskChoice, CORO_INFINITE); - g_scheduler->resetEvent(hAskChoice); + CoroScheduler.resetEvent(hAskChoice); if (bExecutingDialog) *dwRet = (uint32)nExecutingChoice; @@ -2338,7 +2338,7 @@ bool EXPORT mpalExecuteScript(int nScript) { UnlockScripts(); // !!! Nuova gestione dei thread - if (g_scheduler->createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == INVALID_PID_VALUE) + if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) return false; return true; @@ -2388,9 +2388,9 @@ bool mpalStartIdlePoll(int nLoc) { if (nPollingLocations[i] == 0) { nPollingLocations[i] = nLoc; - hEndPollingLocations[i] = g_scheduler->createEvent(true, false); + hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = g_scheduler->createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) + if ((PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2425,11 +2425,11 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { if (nPollingLocations[_ctx->i] == (uint32)nLoc) { - g_scheduler->setEvent(hEndPollingLocations[_ctx->i]); + CoroScheduler.setEvent(hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, PollingThreads[_ctx->i], INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, PollingThreads[_ctx->i], CORO_INFINITE); - g_scheduler->closeEvent(hEndPollingLocations[_ctx->i]); + CoroScheduler.closeEvent(hEndPollingLocations[_ctx->i]); nPollingLocations[_ctx->i] = 0; if (result) diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index cd46219b57..49601bc1e9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -118,9 +118,9 @@ #define TONY_MPAL_H #include "common/scummsys.h" +#include "common/coroutines.h" #include "common/rect.h" #include "common/str.h" -#include "tony/coroutine.h" namespace Tony { @@ -537,7 +537,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 dwParam Action parameter * * Return: Handle to the thread that is performing the action, or -* INVALID_PID_VALUE if the action is not 'defined for +* CORO_INVALID_PID_VALUE if the action is not 'defined for * the item, or the item and 'off. * * Note: The parameter is used primarily to implement actions @@ -561,7 +561,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 nGroup Group number to use * * Return: Handle to the thread that is running the box, or -* INVALID_PID_VALUE if the dialogue does not exist. +* CORO_INVALID_PID_VALUE if the dialogue does not exist. * \****************************************************************************/ diff --git a/engines/tony/sched.h b/engines/tony/sched.h index a9868edad0..f7dabd47ae 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -24,133 +24,4 @@ #ifndef TONY_SCHED_H #define TONY_SCHED_H -#include "common/list.h" -#include "tony/coroutine.h" - -namespace Tony { - -// the size of process specific info -#define PARAM_SIZE 32 - -// the maximum number of processes -#define NUM_PROCESS 100 -#define MAX_PROCESSES 100 - -#define INFINITE 0xffffffff -#define INVALID_PID_VALUE 0 - -typedef void (*CORO_ADDR)(CoroContext &, const void *); - -/** process structure */ -struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list - PROCESS *pPrevious; ///< pointer to previous process in active or free list - - CoroContext state; ///< the state of the coroutine - CORO_ADDR coroAddr; ///< the entry point of the coroutine - - int sleepTime; ///< number of scheduler cycles to sleep - uint32 pid; ///< process ID - bool waiting; ///< process is currently in a waiting state - char param[PARAM_SIZE]; ///< process specific info -}; -typedef PROCESS *PPROCESS; - -struct INT_CONTEXT; - -/** Event structure */ -struct EVENT { - uint32 pid; - bool manualReset; - bool signalled; -}; - -/** - * Create and manage "processes" (really coroutines). - */ -class Scheduler { -public: - /** Pointer to a function of the form "void function(PPROCESS)" */ - typedef void (*VFPTRPP)(PROCESS *); - -private: - - /** list of all processes */ - PROCESS *processList; - - /** active process list - also saves scheduler state */ - PROCESS *active; - - /** pointer to free process list */ - PROCESS *pFreeProcesses; - - /** the currently active process */ - PROCESS *pCurrent; - - /** Auto-incrementing process Id */ - int pidCounter; - - /** Event list */ - Common::List _events; - -#ifdef DEBUG - // diagnostic process counters - int numProcs; - int maxProcs; - - void CheckStack(); -#endif - - /** - * Called from killProcess() to enable other resources - * a process may be allocated to be released. - */ - VFPTRPP pRCfunction; - - PROCESS *getProcess(uint32 pid); - EVENT *getEvent(uint32 pid); -public: - - Scheduler(); - ~Scheduler(); - - void reset(); - - #ifdef DEBUG - void printStats(); - #endif - - void schedule(); - void rescheduleAll(); - void reschedule(PPROCESS pReSchedProc = NULL); - void giveWay(PPROCESS pReSchedProc = NULL); - void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); - void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired = NULL); - void Scheduler::sleep(CORO_PARAM, uint32 duration); - - uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); - uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { - return createProcess(coroAddr, &pParam, sizeof(void *)); - } - void killProcess(PROCESS *pKillProc); - - PROCESS *getCurrentProcess(); - int getCurrentPID() const; - int killMatchingProcess(uint32 pidKill, int pidMask = -1); - - void setResourceCallback(VFPTRPP pFunc); - - /* Event methods */ - uint32 createEvent(bool bManualReset, bool bInitialState); - void closeEvent(uint32 pidEvent); - void setEvent(uint32 pidEvent); - void resetEvent(uint32 pidEvent); - void pulseEvent(uint32 pidEvent); -}; - -extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied - -} // End of namespace Tony - #endif // TONY_SCHED_H diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index a2b3d7c8ce..c8caf5043d 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1021,7 +1021,7 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { lpDSNotify = NULL; lpDS = lpds; lastVolume = 63; - hEndOfBuffer = INVALID_PID_VALUE; + hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; if (bSoundSupported == false) @@ -1053,7 +1053,7 @@ FPSFX::~FPSFX() { RELEASE(lpDSNotify); - if (hEndOfBuffer != INVALID_PID_VALUE) + if (hEndOfBuffer != CORO_INVALID_PID_VALUE) CloseHandle(hEndOfBuffer); RELEASE(lpDSBuffer); @@ -1415,7 +1415,7 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { bool FPSFX::Play() { #ifdef REFACTOR_ME if (bFileLoaded) { - if (hEndOfBuffer != INVALID_PID_VALUE) + if (hEndOfBuffer != CORO_INVALID_PID_VALUE) ResetEvent(hEndOfBuffer); lpDSBuffer->SetCurrentPosition(0); @@ -2012,7 +2012,7 @@ bool FPSTREAM::Stop(bool bSync) { /* Avverte il thread che deve uscire e aspetta che si chiuda */ SetEvent(hThreadEnd); - WaitForSingleObject(hPlayThread, INFINITE); + WaitForSingleObject(hPlayThread, CORO_INFINITE); /* Chiude l'handle del thread e disalloca la memoria temporanea */ CloseHandle(hPlayThread); @@ -2048,7 +2048,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); warning(buf); - WaitForSingleObject(hPlayThread, INFINITE); + WaitForSingleObject(hPlayThread, CORO_INFINITE); /* Chiude l'handle del thread e disalloca la memoria temporanea */ CloseHandle(hPlayThread); @@ -2109,7 +2109,7 @@ void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { // sprintf(buf, "WFMO: %x (buf status: %x) MyThread: 0x%x\n", This->lpDSBuffer, dwBufStatus, GetCurrentThreadId()); // warning(buf); - dwResult = WaitForMultipleObjects(5, hList, false, INFINITE); + dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); /* uint32 dwPlay, dwWrite; This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d8ea05d06a..ece1904810 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,7 +36,7 @@ namespace Tony { TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony"), _scheduler() { + _gameDescription(gameDesc), _randomSource("tony") { _vm = this; DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); @@ -48,6 +48,9 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng TonyEngine::~TonyEngine() { // Close the voice database CloseVoiceDatabase(); + + // Reset the coroutine scheduler + CoroScheduler.reset(); } /** @@ -68,14 +71,14 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { - m_hEndOfFrame = g_scheduler->createEvent(false, false); + m_hEndOfFrame = CoroScheduler.createEvent(false, false); m_bPaused = false; m_bDrawLocation = true; m_startTime = g_system->getMillis(); // Reset the scheduler - _scheduler.reset(); + CoroScheduler.reset(); // Initialise the graphics window _window.Init(); @@ -413,7 +416,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - // Infinite loop. We rely on the outer main process to detect if a shutdown is required, + // CORO_INFINITE loop. We rely on the outer main process to detect if a shutdown is required, // and kill the scheudler and all the processes, including this one for (;;) { // Se siamo in pausa, entra nel loop appropriato @@ -421,14 +424,14 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { _vm->PauseLoop(); // Wait for the next frame - CORO_INVOKE_1(g_scheduler->sleep, 50); + CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame // FIXME: This needs to be moved into it's own process CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished - g_scheduler->pulseEvent(_vm->m_hEndOfFrame); + CoroScheduler.pulseEvent(_vm->m_hEndOfFrame); // Handle drawing the frame if (!_vm->m_bPaused) { @@ -450,7 +453,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { */ void TonyEngine::Play(void) { // Create the game player process - g_scheduler->createProcess(PlayProcess, NULL); + CoroScheduler.createProcess(PlayProcess, NULL); // Loop through calling the scheduler until it's time for the game to quit while (!shouldQuit() && !m_bQuitNow) { @@ -458,7 +461,7 @@ void TonyEngine::Play(void) { g_system->delayMillis(10); // Call any scheduled processes - _scheduler.schedule(); + CoroScheduler.schedule(); } } @@ -466,7 +469,7 @@ void TonyEngine::Play(void) { void TonyEngine::Close(void) { CloseMusic(); - g_scheduler->closeEvent(m_hEndOfFrame); + CoroScheduler.closeEvent(m_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); _window.Close(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 935f805912..d8104e641b 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/array.h" +#include "common/coroutines.h" #include "common/error.h" #include "common/random.h" #include "common/util.h" @@ -97,7 +98,6 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; - Scheduler _scheduler; enum DATADIR { DD_BASE = 1, diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index c3deae497b..6a5d80f51e 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -67,7 +67,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); m_bAction = false; @@ -236,15 +236,15 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); // Se fallito il combine, proviamo con il ReceiveCombine - if (pid == INVALID_PID_VALUE) { + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); // Se fallito il receive, andiamo con quelli generici // @@@ CombineGive! - if (pid == INVALID_PID_VALUE) { + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - if (pid == INVALID_PID_VALUE){ + if (pid == CORO_INVALID_PID_VALUE){ pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } @@ -254,25 +254,25 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { pid = mpalQueryDoAction(nAction, nActionItem, 0); } - if (pid != INVALID_PID_VALUE) { + if (pid != CORO_INVALID_PID_VALUE) { m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else { pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } } @@ -286,7 +286,7 @@ void RMTony::StopNoAction(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (m_bAction) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hActionThread, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE); m_bActionPending = false; m_ActionItem = NULL; @@ -306,12 +306,12 @@ void RMTony::Stop(CORO_PARAM) { // Richiama l'MPAL per scegliere la direzione _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); - if (_ctx->pid == INVALID_PID_VALUE) + if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { CORO_INVOKE_0(RMCharacter::Stop); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 050b39c0ca..cf67db4df5 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -48,8 +48,8 @@ #ifndef TONY_TONYCHAR_H #define TONY_TONYCHAR_H +#include "common/coroutines.h" #include "tony/mpal/stubs.h" -#include "tony/coroutine.h" #include "tony/loc.h" namespace Tony { @@ -408,7 +408,7 @@ public: int GetCurPattern(); // Attende la fine di un pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 18dcfb7cb6..3185e5aa4d 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -178,7 +178,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d00",i); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_PID_VALUE) + if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -189,7 +189,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d0",i,j); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_PID_VALUE) + if (h==CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -200,7 +200,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d%d",i,j,k); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_PID_VALUE) + if (h==CORO_INVALID_PID_VALUE) break; CloseHandle(h); } -- cgit v1.2.3 From beef5fdb264850079208b5513cf72626ff7edd86 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:23:05 +1000 Subject: TONY: Removal of now redundant includes, and deprecated scheduler/coroutine files --- engines/tony/coroutine.cpp | 82 ----- engines/tony/coroutine.h | 271 --------------- engines/tony/custom.cpp | 1 - engines/tony/font.h | 1 - engines/tony/loc.h | 1 - engines/tony/mpal/mpal.cpp | 1 - engines/tony/sched.cpp | 801 --------------------------------------------- engines/tony/sched.h | 27 -- engines/tony/tony.cpp | 109 +++++- engines/tony/tony.h | 1 - 10 files changed, 104 insertions(+), 1191 deletions(-) delete mode 100644 engines/tony/coroutine.cpp delete mode 100644 engines/tony/coroutine.h delete mode 100644 engines/tony/sched.cpp delete mode 100644 engines/tony/sched.h (limited to 'engines') diff --git a/engines/tony/coroutine.cpp b/engines/tony/coroutine.cpp deleted file mode 100644 index 504dc2a3fd..0000000000 --- a/engines/tony/coroutine.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public 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 "tony/coroutine.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Tony { - - -CoroContext nullContext = NULL; // FIXME: Avoid non-const global vars - - -#if COROUTINE_DEBUG -namespace { -static int s_coroCount = 0; - -typedef Common::HashMap CoroHashMap; -static CoroHashMap *s_coroFuncs = 0; - -static void changeCoroStats(const char *func, int change) { - if (!s_coroFuncs) - s_coroFuncs = new CoroHashMap(); - - (*s_coroFuncs)[func] += change; -} - -static void displayCoroStats() { - debug("%d active coros", s_coroCount); - - // Loop over s_coroFuncs and print info about active coros - if (!s_coroFuncs) - return; - for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); - it != s_coroFuncs->end(); ++it) { - if (it->_value != 0) - debug(" %3d x %s", it->_value, it->_key.c_str()); - } -} - -} -#endif - -CoroBaseContext::CoroBaseContext(const char *func) - : _line(0), _sleep(0), _subctx(0) { -#if COROUTINE_DEBUG - _funcName = func; - changeCoroStats(_funcName, +1); - s_coroCount++; -#endif -} - -CoroBaseContext::~CoroBaseContext() { -#if COROUTINE_DEBUG - s_coroCount--; - changeCoroStats(_funcName, -1); - debug("Deleting coro in %s at %p (subctx %p)", - _funcName, (void *)this, (void *)_subctx); - displayCoroStats(); -#endif - delete _subctx; -} - -} // End of namespace Tony diff --git a/engines/tony/coroutine.h b/engines/tony/coroutine.h deleted file mode 100644 index b4eb105f58..0000000000 --- a/engines/tony/coroutine.h +++ /dev/null @@ -1,271 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public 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 TONY_COROUTINE_H -#define TONY_COROUTINE_H - -#include "common/scummsys.h" -#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION - -namespace Tony { - -/** - * @defgroup TonyCoroutines Coroutine support for Tony engine - * - * The following is loosely based on an article by Simon Tatham: - * . - * However, many improvements and tweaks have been made, in particular - * by taking advantage of C++ features not available in C. - */ -//@{ - - -// Enable this macro to enable some debugging support in the coroutine code. -//#define COROUTINE_DEBUG 1 - -/** - * The core of any coroutine context which captures the 'state' of a coroutine. - * Private use only. - */ -struct CoroBaseContext { - int _line; - int _sleep; - CoroBaseContext *_subctx; -#if COROUTINE_DEBUG - const char *_funcName; -#endif - CoroBaseContext(const char *func); - ~CoroBaseContext(); -}; - -typedef CoroBaseContext *CoroContext; - - -// FIXME: Document this! -extern CoroContext nullContext; - -/** - * Wrapper class which holds a pointer to a pointer to a CoroBaseContext. - * The interesting part is the destructor, which kills the context being held, - * but ONLY if the _sleep val of that context is zero. This way, a coroutine - * can just 'return' w/o having to worry about freeing the allocated context - * (in Simon Tatham's original code, one had to use a special macro to - * return from a coroutine). - */ -class CoroContextHolder { - CoroContext &_ctx; -public: - CoroContextHolder(CoroContext &ctx) : _ctx(ctx) { - assert(ctx); - assert(ctx->_sleep >= 0); - ctx->_sleep = 0; - } - ~CoroContextHolder() { - if (_ctx && _ctx->_sleep == 0) { - delete _ctx; - _ctx = 0; - } - } -}; - - -#define CORO_PARAM CoroContext &coroParam - - -/** - * Begin the declaration of a coroutine context. - * This allows declaring variables which are 'persistent' during the - * lifetime of the coroutine. An example use would be: - * - * CORO_BEGIN_CONTEXT; - * int var; - * char *foo; - * CORO_END_CONTEXT(_ctx); - * - * It is not possible to initialize variables here, due to the way this - * macro is implemented. Furthermore, to use the variables declared in - * the coroutine context, you have to access them via the context variable - * name that was specified as parameter to CORO_END_CONTEXT, e.g. - * _ctx->var = 0; - * - * @see CORO_END_CONTEXT - * - * @note We declare a variable 'DUMMY' to allow the user to specify an 'empty' - * context, and so compilers won't complain about ";" following the macro. - */ -#define CORO_BEGIN_CONTEXT \ - struct CoroContextTag : Common::CoroBaseContext { \ - CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ - int DUMMY - -/** - * End the declaration of a coroutine context. - * @param x name of the coroutine context - * @see CORO_BEGIN_CONTEXT - */ -#define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam - -/** - * Begin the code section of a coroutine. - * @param x name of the coroutine context - * @see CORO_BEGIN_CODE - */ -#define CORO_BEGIN_CODE(x) \ - if (&coroParam == &nullContext) assert(!nullContext);\ - if (!x) {coroParam = x = new CoroContextTag();}\ - CoroContextHolder tmpHolder(coroParam);\ - switch (coroParam->_line) { case 0:; - -/** - * End the code section of a coroutine. - * @see CORO_END_CODE - */ -#define CORO_END_CODE \ - if (&coroParam == &nullContext) { \ - delete nullContext; \ - nullContext = NULL; \ - } \ - } - -/** - * Sleep for the specified number of scheduler cycles. - */ -#define CORO_SLEEP(delay) do {\ - coroParam->_line = __LINE__;\ - coroParam->_sleep = delay;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (0) - -#define CORO_GIVE_WAY do { CoroScheduler.giveWay(); CORO_SLEEP(1); } while (0) -#define CORO_RESCHEDULE do { CoroScheduler.reschedule(); CORO_SLEEP(1); } while (0) - -/** - * Stop the currently running coroutine and all calling coroutines. - * - * This sets _sleep to -1 rather than 0 so that the context doesn't get - * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to - * propogate the _sleep value and return immediately (the scheduler will - * then delete the entire coroutine's state, including all subcontexts). - */ -#define CORO_KILL_SELF() \ - do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0) - - -/** - * This macro is to be used in conjunction with CORO_INVOKE_ARGS and - * similar macros for calling coroutines-enabled subroutines. - */ -#define CORO_SUBCTX coroParam->_subctx - -/** - * Invoke another coroutine. - * - * If the subcontext still exists after the coroutine is invoked, it has - * either yielded/slept or killed itself, and so we copy the _sleep value - * to our own context and return (execution will continue at the case - * statement below, where we loop and call the coroutine again). - * If the subcontext is null, the coroutine ended normally, and we can - * simply break out of the loop and continue execution. - * - * @param subCoro name of the coroutine-enabled function to invoke - * @param ARGS list of arguments to pass to subCoro - * - * @note ARGS must be surrounded by parentheses, and the first argument - * in this list must always be CORO_SUBCTX. For example, the - * regular function call - * myFunc(a, b); - * becomes the following: - * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); - */ -#define CORO_INVOKE_ARGS(subCoro, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, - * but allows specifying a return value which is returned - * if invoked coroutine yields (thus causing the current - * coroutine to yield, too). - */ -#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return RESULT; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with no parameters. - */ -#define CORO_INVOKE_0(subCoroutine) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with one parameter. - */ -#define CORO_INVOKE_1(subCoroutine, a0) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with two parameters. - */ -#define CORO_INVOKE_2(subCoroutine, a0,a1) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with three parameters. - */ -#define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with four parameters. - */ -#define CORO_INVOKE_4(subCoroutine, a0,a1,a2,a3) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2,a3)) - -//@} - -} // End of namespace Tony - -#endif // TONY_COROUTINE_H diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 234dd0a4f9..89d3123b60 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -56,7 +56,6 @@ #include "tony/font.h" #include "tony/game.h" #include "tony/gfxcore.h" -#include "tony/sched.h" #include "tony/tony.h" #include "tony/tonychar.h" #include "tony/utils.h" diff --git a/engines/tony/font.h b/engines/tony/font.h index 7447f31515..d883733db6 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -52,7 +52,6 @@ #include "common/coroutines.h" #include "tony/gfxcore.h" #include "tony/resid.h" -#include "tony/sched.h" namespace Tony { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4b8946da54..218aca02e7 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -52,7 +52,6 @@ #include "common/system.h" #include "common/file.h" #include "tony/mpal/stubs.h" -#include "tony/sched.h" #include "tony/sound.h" #include "tony/utils.h" diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 42c790a1c7..a665fbacc5 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -51,7 +51,6 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" -#include "tony/sched.h" #include "tony/tony.h" #include "tony/mpal/lzo.h" #include "tony/mpal/mpal.h" diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp deleted file mode 100644 index c447afa094..0000000000 --- a/engines/tony/sched.cpp +++ /dev/null @@ -1,801 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Process scheduler. - */ - -#include "common/system.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "tony/sched.h" - -namespace Tony { - -Scheduler *g_scheduler = 0; - -//--------------------- FUNCTIONS ------------------------ - -Scheduler::Scheduler() { - processList = NULL; - pFreeProcesses = NULL; - pCurrent = NULL; - -#ifdef DEBUG - // diagnostic process counters - numProcs = 0; - maxProcs = 0; -#endif - - pRCfunction = NULL; - pidCounter = 0; - - active = new PROCESS; - active->pPrevious = NULL; - active->pNext = NULL; - - g_scheduler = this; // FIXME HACK - - reset(); -} - -Scheduler::~Scheduler() { - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc = pProc->pNext; - } - - free(processList); - processList = NULL; - - delete active; - active = 0; - - // Clear the event list - Common::List::iterator i; - for (i = _events.begin(); i != _events.end(); ++i) - delete (*i); -} - -/** - * Kills all processes and places them on the free list. - */ -void Scheduler::reset() { - -#ifdef DEBUG - // clear number of process in use - numProcs = 0; -#endif - - if (processList == NULL) { - // first time - allocate memory for process list - processList = (PROCESS *)calloc(MAX_PROCESSES, sizeof(PROCESS)); - - // make sure memory allocated - if (processList == NULL) { - error("Cannot allocate memory for process data"); - } - - // fill with garbage - memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); - } - - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc->waiting = false; - pProc = pProc->pNext; - } - - // no active processes - pCurrent = active->pNext = NULL; - - // place first process on free list - pFreeProcesses = processList; - - // link all other processes after first - for (int i = 1; i <= NUM_PROCESS; i++) { - processList[i - 1].pNext = (i == NUM_PROCESS) ? NULL : processList + i; - processList[i - 1].pPrevious = (i == 1) ? active : processList + (i - 2); - } -} - - -#ifdef DEBUG -/** - * Shows the maximum number of process used at once. - */ -void Scheduler::printStats() { - debug("%i process of %i used", maxProcs, NUM_PROCESS); -} -#endif - -#ifdef DEBUG -/** - * Checks both the active and free process list to insure all the links are valid, - * and that no processes have been lost - */ -void Scheduler::CheckStack() { - Common::List pList; - - // Check both the active and free process lists - for (int i = 0; i < 2; ++i) { - PROCESS *p = (i == 0) ? active : pFreeProcesses; - - if (p != NULL) { - // Make sure the linkages are correct - while (p->pNext != NULL) { - assert(p->pNext->pPrevious == p); - pList.push_back(p); - p = p->pNext; - } - pList.push_back(p); - } - } - - // Make sure all processes are accounted for - for (int idx = 0; idx < NUM_PROCESS; idx++) { - bool found = false; - for (Common::List::iterator i = pList.begin(); i != pList.end(); ++i) { - PROCESS *pTemp = *i; - if (*i == &processList[idx]) { - found = true; - break; - } - } - - assert(found); - } -} -#endif - -/** - * Give all active processes a chance to run - */ -void Scheduler::schedule() { - // start dispatching active process list - PROCESS *pNext; - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - pNext = pProc->pNext; - - if (--pProc->sleepTime <= 0) { - // process is ready for dispatch, activate it - pCurrent = pProc; - pProc->coroAddr(pProc->state, pProc->param); - - if (!pProc->state || pProc->state->_sleep <= 0) { - // Coroutine finished - pCurrent = pCurrent->pPrevious; - killProcess(pProc); - } else { - pProc->sleepTime = pProc->state->_sleep; - } - - // pCurrent may have been changed - pNext = pCurrent->pNext; - pCurrent = NULL; - } - - pProc = pNext; - } -} - -/** - * Reschedules all the processes to run again this query - */ -void Scheduler::rescheduleAll() { - assert(pCurrent); - - // Unlink current process - pCurrent->pPrevious->pNext = pCurrent->pNext; - if (pCurrent->pNext) - pCurrent->pNext->pPrevious = pCurrent->pPrevious; - - // Add process to the start of the active list - pCurrent->pNext = active->pNext; - active->pNext->pPrevious = pCurrent; - active->pNext = pCurrent; - pCurrent->pPrevious = active; -} - -/** - * If the specified process has already run on this tick, make it run - * again on the current tick. - */ -void Scheduler::reschedule(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - PPROCESS pEnd; - - // Find the last process in the list. - // But if the target process is down the list from here, do nothing - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) { - if (pEnd->pNext == pReSchedProc) - return; - } - - assert(pEnd->pNext == NULL); - - // Could be in the middle of a KillProc()! - // Dying process was last and this process was penultimate - if (pReSchedProc->pNext == NULL) - return; - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Moves the specified process to the end of the dispatch queue - * allowing it to run again within the current game cycle. - * @param pGiveProc Which process - */ -void Scheduler::giveWay(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - // If the process is already at the end of the queue, nothing has to be done - if (!pReSchedProc->pNext) - return; - - PPROCESS pEnd; - - // Find the last process in the list. - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) - ; - assert(pEnd->pNext == NULL); - - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Continously makes a given process wait for another process to finish or event to signal. - * - * @param pid Process/Event identifier - * @param duration Duration in milliseconds - * @param expired If specified, set to true if delay period expired - */ -void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired) { - if (!pCurrent) - error("Called Scheduler::waitForSingleObject from the main process"); - - CORO_BEGIN_CONTEXT; - uint32 endTime; - PROCESS *pProcess; - EVENT *pEvent; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - - // Signal as waiting - pCurrent->waiting = true; - - _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; - if (expired) - // Presume it will expire - *expired = true; - - // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { - // Check to see if a process or event with the given Id exists - _ctx->pProcess = getProcess(pid); - _ctx->pEvent = !_ctx->pProcess ? getEvent(pid) : NULL; - - // If there's no active process or event, presume it's a process that's finished, - // so the waiting can immediately exit - if ((_ctx->pProcess == NULL) && (_ctx->pEvent == NULL)) { - if (expired) - *expired = false; - break; - } - - // If a process was found, don't go into the if statement, and keep waiting. - // Likewise if it's an event that's not yet signalled - if ((_ctx->pEvent != NULL) && _ctx->pEvent->signalled) { - // Unless the event is flagged for manual reset, reset it now - if (!_ctx->pEvent->manualReset) - _ctx->pEvent->signalled = false; - - if (expired) - *expired = false; - break; - } - - // Sleep until the next cycle - CORO_SLEEP(1); - } - - // Signal waiting is done - pCurrent->waiting = false; - - CORO_END_CODE; -} - -/** - * Continously makes a given process wait for given prcesses to finished or events to be set - * - * @param nCount Number of Id's being passed - * @param evtList List of pids to wait for - * @param bWaitAll Specifies whether all or any of the processes/events - * @param duration Duration in milliseconds - * @param expired Set to true if delay period expired - */ -void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired) { - if (!pCurrent) - error("Called Scheduler::waitForMultipleEvents from the main process"); - - CORO_BEGIN_CONTEXT; - uint32 endTime; - bool signalled; - bool pidSignalled; - int i; - PROCESS *pProcess; - EVENT *pEvent; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - - // Signal as waiting - pCurrent->waiting = true; - - _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; - if (expired) - // Presume that delay will expire - *expired = true; - - // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { - _ctx->signalled = bWaitAll; - - for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { - _ctx->pProcess = getProcess(pidList[_ctx->i]); - _ctx->pEvent = !_ctx->pProcess ? getEvent(pidList[_ctx->i]) : NULL; - - // Determine the signalled state - _ctx->pidSignalled = (_ctx->pProcess) || !_ctx->pEvent ? false : _ctx->pEvent->signalled; - - if (bWaitAll && _ctx->pidSignalled) - _ctx->signalled = false; - else if (!bWaitAll & _ctx->pidSignalled) - _ctx->signalled = true; - } - - // At this point, if the signalled variable is set, waiting is finished - if (_ctx->signalled) { - // Automatically reset any events not flagged for manual reset - for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { - _ctx->pEvent = getEvent(pidList[_ctx->i]); - - if (_ctx->pEvent->manualReset) - _ctx->pEvent->signalled = false; - } - - if (expired) - *expired = false; - break; - } - - // Sleep until the next cycle - CORO_SLEEP(1); - } - - // Signal waiting is done - pCurrent->waiting = false; - - CORO_END_CODE; -} - -/** - * Make the active process sleep for the given duration in milliseconds - * @param duration Duration in milliseconds - * @remarks This duration won't be precise, since it relies on the frequency the - * scheduler is called. - */ -void Scheduler::sleep(CORO_PARAM, uint32 duration) { - if (!pCurrent) - error("Called Scheduler::waitForSingleObject from the main process"); - - CORO_BEGIN_CONTEXT; - uint32 endTime; - PROCESS *pProcess; - EVENT *pEvent; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - - // Signal as waiting - pCurrent->waiting = true; - - _ctx->endTime = g_system->getMillis() + duration; - - // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { - // Sleep until the next cycle - CORO_SLEEP(1); - } - - // Signal waiting is done - pCurrent->waiting = false; - - CORO_END_CODE; -} - -/** - * Creates a new process. - * - * @param pid process identifier - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info - */ -uint32 Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { - PROCESS *pProc; - - // get a free process - pProc = pFreeProcesses; - - // trap no free process - assert(pProc != NULL); // Out of processes - -#ifdef DEBUG - // one more process in use - if (++numProcs > maxProcs) - maxProcs = numProcs; -#endif - - // get link to next free process - pFreeProcesses = pProc->pNext; - if (pFreeProcesses) - pFreeProcesses->pPrevious = NULL; - - if (pCurrent != NULL) { - // place new process before the next active process - pProc->pNext = pCurrent->pNext; - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - - // make this new process the next active process - pCurrent->pNext = pProc; - pProc->pPrevious = pCurrent; - - } else { // no active processes, place process at head of list - pProc->pNext = active->pNext; - pProc->pPrevious = active; - - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - active->pNext = pProc; - - } - - // set coroutine entry point - pProc->coroAddr = coroAddr; - - // clear coroutine state - pProc->state = 0; - - // wake process up as soon as possible - pProc->sleepTime = 1; - - // set new process id - pProc->pid = ++pidCounter; - - // set new process specific info - if (sizeParam) { - assert(sizeParam > 0 && sizeParam <= PARAM_SIZE); - - // set new process specific info - memcpy(pProc->param, pParam, sizeParam); - } - - // return created process - return pProc->pid; -} - -/** - * Kills the specified process. - * - * @param pKillProc which process to kill - */ -void Scheduler::killProcess(PROCESS *pKillProc) { - // make sure a valid process pointer - assert(pKillProc >= processList && pKillProc <= processList + NUM_PROCESS - 1); - - // can not kill the current process using killProcess ! - assert(pCurrent != pKillProc); - -#ifdef DEBUG - // one less process in use - --numProcs; - assert(numProcs >= 0); -#endif - - // Free process' resources - if (pRCfunction != NULL) - (pRCfunction)(pKillProc); - - delete pKillProc->state; - pKillProc->state = 0; - - // Take the process out of the active chain list - pKillProc->pPrevious->pNext = pKillProc->pNext; - if (pKillProc->pNext) - pKillProc->pNext->pPrevious = pKillProc->pPrevious; - - // link first free process after pProc - pKillProc->pNext = pFreeProcesses; - if (pFreeProcesses) - pKillProc->pNext->pPrevious = pKillProc; - pKillProc->pPrevious = NULL; - - // make pKillProc the first free process - pFreeProcesses = pKillProc; -} - - - -/** - * Returns a pointer to the currently running process. - */ -PROCESS *Scheduler::getCurrentProcess() { - return pCurrent; -} - -/** - * Returns the process identifier of the specified process. - * - * @param pProc which process - */ -int Scheduler::getCurrentPID() const { - PROCESS *pProc = pCurrent; - - // make sure a valid process pointer - assert(pProc >= processList && pProc <= processList + NUM_PROCESS - 1); - - // return processes PID - return pProc->pid; -} - -/** - * Kills any process matching the specified PID. The current - * process cannot be killed. - * - * @param pidKill process identifier of process to kill - * @param pidMask mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. - */ -int Scheduler::killMatchingProcess(uint32 pidKill, int pidMask) { - int numKilled = 0; - PROCESS *pProc, *pPrev; // process list pointers - - for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { - if ((pProc->pid & (uint32)pidMask) == pidKill) { - // found a matching process - - // dont kill the current process - if (pProc != pCurrent) { - // kill this process - numKilled++; - - // Free the process' resources - if (pRCfunction != NULL) - (pRCfunction)(pProc); - - delete pProc->state; - pProc->state = 0; - - // make prev point to next to unlink pProc - pPrev->pNext = pProc->pNext; - if (pProc->pNext) - pPrev->pNext->pPrevious = pPrev; - - // link first free process after pProc - pProc->pNext = pFreeProcesses; - pProc->pPrevious = NULL; - pFreeProcesses->pPrevious = pProc; - - // make pProc the first free process - pFreeProcesses = pProc; - - // set to a process on the active list - pProc = pPrev; - } - } - } - -#ifdef DEBUG - // adjust process in use - numProcs -= numKilled; - assert(numProcs >= 0); -#endif - - // return number of processes killed - return numKilled; -} - -/** - * Set pointer to a function to be called by killProcess(). - * - * May be called by a resource allocator, the function supplied is - * called by killProcess() to allow the resource allocator to free - * resources allocated to the dying process. - * - * @param pFunc Function to be called by killProcess() - */ -void Scheduler::setResourceCallback(VFPTRPP pFunc) { - pRCfunction = pFunc; -} - -PROCESS *Scheduler::getProcess(uint32 pid) { - PROCESS *pProc = active->pNext; - while ((pProc != NULL) && (pProc->pid != pid)) - pProc = pProc->pNext; - - return pProc; -} - -EVENT *Scheduler::getEvent(uint32 pid) { - Common::List::iterator i; - for (i = _events.begin(); i != _events.end(); ++i) { - EVENT *evt = *i; - if (evt->pid == pid) - return evt; - } - - return NULL; -} - - -/** - * Creates a new event object - * @param bManualReset Events needs to be manually reset. Otherwise, events - * will be automatically reset after a process waits on the event finishes - * @param bInitialState Specifies whether the event is signalled or not initially - */ -uint32 Scheduler::createEvent(bool bManualReset, bool bInitialState) { - EVENT *evt = new EVENT(); - evt->pid = ++pidCounter; - evt->manualReset = bManualReset; - evt->signalled = bInitialState; - - _events.push_back(evt); - return evt->pid; -} - -/** - * Destroys the given event - * @param pidEvent Event PID - */ -void Scheduler::closeEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (evt) { - _events.remove(evt); - delete evt; - } -} - -/** - * Sets the event - * @param pidEvent Event PID - */ -void Scheduler::setEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (evt) - evt->signalled = true; -} - -/** - * Resets the event - * @param pidEvent Event PID - */ -void Scheduler::resetEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (evt) - evt->signalled = false; -} - -/** - * Temporarily sets a given event to true, and then runs all waiting processes, allowing any - * processes waiting on the event to be fired. It then immediately resets the event again. - * @param pidEvent Event PID - * - * @remarks Should not be run inside of another process - */ -void Scheduler::pulseEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (!evt) - return; - - // Set the event as true - evt->signalled = true; - - // start dispatching active process list for any processes that are currently waiting - PROCESS *pOriginal = pCurrent; - PROCESS *pNext; - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - pNext = pProc->pNext; - - // Only call processes that are currently waiting (either in waitForSingleObject or - // waitForMultipleObjects). If one is found, execute it immediately - if (pProc->waiting) { - // Dispatch the process - pCurrent = pProc; - pProc->coroAddr(pProc->state, pProc->param); - - if (!pProc->state || pProc->state->_sleep <= 0) { - // Coroutine finished - pCurrent = pCurrent->pPrevious; - killProcess(pProc); - } else { - pProc->sleepTime = pProc->state->_sleep; - } - - // pCurrent may have been changed - pNext = pCurrent->pNext; - pCurrent = NULL; - } - - pProc = pNext; - } - - // Restore the original current process (if one was active) - pCurrent = pOriginal; - - // Reset the event back to non-signalled - evt->signalled = false; -} - -} // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h deleted file mode 100644 index f7dabd47ae..0000000000 --- a/engines/tony/sched.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Data structures used by the process scheduler - */ - -#ifndef TONY_SCHED_H -#define TONY_SCHED_H - -#endif // TONY_SCHED_H diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ece1904810..76f6cfcecb 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -162,7 +162,85 @@ OSystem::MutexRef csMusic; void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { - warning("TonyEngine::PlayMusic"); + warning("TODO: TonyEngine::PlayMusic"); + g_system->lockMutex(csMusic); + + if (nChannel < 4) + if (flipflop) + nChannel = nChannel + 1; + + switch (nFX) { + case 0: + case 1: + case 2: + m_stream[nChannel]->Stop(); + m_stream[nChannel]->UnloadFile(); + break; + + case 22: + break; + } + +#ifdef REFACTOR_ME + // Mette il path giusto + if (nChannel < 4) + GetDataDirectory(DD_MUSIC, path_buffer); + else + GetDataDirectory(DD_LAYER, path_buffer); + _splitpath(path_buffer,drive,dir,NULL,NULL); + _splitpath(fn,NULL,NULL,fname,ext); + _makepath(path_buffer,drive,dir,fname,ext); + + _makepath(path_buffer,drive,dir,fname,ext); + + if (nFX==22) // Sync a tempo + { + curChannel=nChannel; + strcpy(nextMusic, path_buffer); + nextLoop=bLoop; + nextSync=nSync; + if (flipflop) + nextChannel=nChannel-1; + else + nextChannel=nChannel+1; + DWORD id; + HANDLE hThread=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)DoNextMusic,m_stream,0,&id); + SetThreadPriority(hThread,THREAD_PRIORITY_HIGHEST); + } + else if (nFX==44) // Cambia canale e lascia finire il primo + { + if (flipflop) + nextChannel=nChannel-1; + else + nextChannel=nChannel+1; + + m_stream[nextChannel]->Stop(); + m_stream[nextChannel]->UnloadFile(); +#ifndef DEMO + if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); +#else + m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); +#endif + m_stream[nextChannel]->SetLoop(bLoop); + m_stream[nextChannel]->Play(); + + flipflop = 1-flipflop; + } + else + { +#ifndef DEMO + if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); +#else + m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); +#endif + m_stream[nChannel]->SetLoop(bLoop); + m_stream[nChannel]->Play(); + } +#endif + + g_system->unlockMutex(csMusic); } void TonyEngine::PlaySFX(int nChannel, int nFX) { @@ -183,19 +261,40 @@ void TonyEngine::PlaySFX(int nChannel, int nFX) { } void TonyEngine::StopMusic(int nChannel) { - warning("TODO TonyEngine::StopMusic"); + g_system->lockMutex(csMusic); + + if (nChannel < 4) + m_stream[nChannel+flipflop]->Stop(); + else + m_stream[nChannel]->Stop(); + + g_system->unlockMutex(csMusic); } void TonyEngine::StopSFX(int nChannel) { - warning("TODO TonyEngine::StopSFX"); + m_sfx[nChannel]->Stop(); } void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - warning("TODO TonyEngine::PlayUtilSFX"); + if (m_utilSfx[nChannel]==NULL) + return; + + switch (nFX) { + case 0: + m_utilSfx[nChannel]->SetLoop(false); + break; + + case 1: + m_utilSfx[nChannel]->SetLoop(true); + break; + } + + m_utilSfx[nChannel]->SetVolume(52); + m_utilSfx[nChannel]->Play(); } void TonyEngine::StopUtilSFX(int nChannel) { - warning("TODO TonyEngine::StopUtilSFX"); + m_utilSfx[nChannel]->Stop(); } void TonyEngine::PreloadSFX(int nChannel, const char *fn) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index d8104e641b..69b54e8edb 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -36,7 +36,6 @@ #include "tony/mpal/memory.h" #include "tony/gfxengine.h" #include "tony/loc.h" -#include "tony/sched.h" #include "tony/utils.h" #include "tony/window.h" -- cgit v1.2.3 From 67c47e9045cab111ff9daadf9968553106f14bfe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:36:13 +1000 Subject: TONY: First attempt at simulating the circular fade in/out effect engine uses The engine uses DirectX drawing functionality to do drawing of partial frames within an ellipsis, so we need to replicate that manually in code. --- engines/tony/window.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++----- engines/tony/window.h | 2 ++ 2 files changed, 54 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 3185e5aa4d..da49b91109 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -147,11 +147,58 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { if (!rcBoundEllipse.isValidRect()) return; - // TODO: Do a proper circular wipe - for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { - const byte *pSrc = lpBuf + (yp * RM_SX * 2) + rcBoundEllipse.left * 2; - - g_system->copyRectToScreen(pSrc, RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, + rcBoundEllipse.top + rcBoundEllipse.height() / 2); + int radius = rcBoundEllipse.width() / 2; + + int error = -radius; + int x = radius; + int y = 0; + + while (x >= y) { + plotSplices(lpBuf, center, x, y); + + error += y; + ++y; + error += y; + + if (error >= 0) { + error -= x; + --x; + error -= x; + } + } +} + +/** + * Handles drawing the line splices for the circle of viewable area + */ +void RMWindow::plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y) { + plotLines(lpBuf, center, x, y); + if (x != y) + plotLines(lpBuf, center, y, x); +} + +/** + * Handles drawing the line splices for the circle of viewable area + */ +void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y) { + // Skips lines that have no width (i.e. at the top of the circle) + if ((x == 0) || (y > center.y)) + return; + + const byte *pSrc; + + if ((center.y - y) >= 0) { + // Draw line in top half of circle + pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + (center.x - x) * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y - y, x * 2, 1); + } + + if ((center.y + y) < RM_SY) { + // Draw line in bottom half of circle + pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + (center.x - x) * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y + y, x * 2, 1); } } diff --git a/engines/tony/window.h b/engines/tony/window.h index 06f684a15b..56f48d7698 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -80,6 +80,8 @@ class RMWindow { private: bool Lock(); void Unlock(); + void plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y); + void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; -- cgit v1.2.3 From 3a61568b6f0c5d74ced621a5f4161efbcb33f6a9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:39:32 +1000 Subject: TONY: Removed carriage returns from debug line strings --- engines/tony/custom.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 89d3123b60..a9e8e5bc62 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2258,7 +2258,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CODE(_ctx); - debug("Start FadeIn Music\n"); + debug("Start FadeIn Music"); for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { _vm->SetMusicVolume(nChannel, _ctx->i * 4); @@ -2267,7 +2267,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { } _vm->SetMusicVolume(nChannel, 64); - debug("End FadeIn Music\n"); + debug("End FadeIn Music"); CORO_KILL_SELF(); @@ -2286,7 +2286,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { _ctx->startVolume = _vm->GetMusicVolume(nChannel); - debug("Start FadeOut Music\n"); + debug("Start FadeOut Music"); for (_ctx->i = 16; _ctx->i > 0 && !bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) @@ -2302,7 +2302,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (nChannel == 2) _vm->StopMusic(2); - debug("End FadeOut Music\n"); + debug("End FadeOut Music"); CORO_KILL_SELF(); @@ -2470,14 +2470,14 @@ const char *staccFileNames[] = { void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; - debug("Start CustPlayMusic\n"); + debug("Start CustPlayMusic"); PlayMusic(nChannel, mFN, nFX, bLoop, nSync); - debug("End CustPlayMusic\n"); + debug("End CustPlayMusic"); } DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX==2) { - debug("PlaySonoriz stop fadeout\n"); + debug("PlaySonoriz stop fadeout"); bFadeOutStop = true; } -- cgit v1.2.3 From 166980fa4f7aa29ef604307662ed04d21b26a211 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 00:08:09 +1000 Subject: TONY: Fix for properly signaling right button release. --- engines/tony/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index b6793695f3..3574980176 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -86,7 +86,7 @@ void RMInput::Poll(void) { } else if (_event.type == Common::EVENT_RBUTTONDOWN) { _rightButton = true; _rightClickMouse = true; - } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + } else if (_event.type == Common::EVENT_RBUTTONUP) { _rightButton = false; _rightReleaseMouse = true; } else -- cgit v1.2.3 From a153f9a2e633c788edd00b1c71c75377a3319e66 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 10:34:52 +1000 Subject: TONY: Explicitly initialise fields of various objects in their constructors This fixes a crash when the pop-up inventory was displayed. --- engines/tony/gfxcore.cpp | 1 + engines/tony/inventory.cpp | 13 +++++++++++++ engines/tony/tonychar.cpp | 18 ++++++++++++++++++ engines/tony/tonychar.h | 4 +++- 4 files changed, 35 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index de78b51a4e..344542b801 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -287,6 +287,7 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; + m_otSize = 0; csModifyingOT = g_system->createMutex(); } diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 50e4dd9411..9d673459c5 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -64,6 +64,18 @@ RMInventory::RMInventory() { m_bCombining = false; m_csModifyInterface = g_system->createMutex(); m_nItems = 0; + + Common::fill(m_inv, m_inv + 256, 0); + m_nInv = 0; + m_curPutY = 0; + m_curPutTime = 0; + m_curPos = 0; + m_bHasFocus = false; + m_nSelectObj = 0; + m_nCombine = 0; + m_bBlinkingRight = false; + m_bBlinkingLeft = false; + miniAction = 0; } RMInventory::~RMInventory() { @@ -932,6 +944,7 @@ void RMInterface::Init(void) { */ m_bActive = false; m_bPalesati = false; + m_lastHotZone = 0; } void RMInterface::Close(void) { diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 6a5d80f51e..982949870c 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -59,6 +59,24 @@ namespace Tony { bool RMTony::m_bAction = false; +RMTony::RMTony() { + m_bShow = false; + m_bShowOmbra = false; + m_bCorpoDavanti = false; + m_bActionPending = false; + m_ActionItem = NULL; + m_Action = 0; + m_ActionParm = 0; + m_bPastorella = false; + m_bIsStaticTalk = false; + m_bIsTalking = false; + m_nPatB4Talking = 0; + m_nTalkType = TALK_NORMAL; + m_TalkDirection = UP; + m_nTimeLastStep = 0; + hActionThread = CORO_INVALID_PID_VALUE; +} + void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index cf67db4df5..bbb1667c9b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -127,7 +127,7 @@ private: protected: // Overload dell'allocazione degli sprites per cambiare il tipo - virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); // Thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); @@ -378,6 +378,8 @@ public: // per farlo rialzare, altrimenti private }; public: + RMTony(); + // Inizializza Tony void Init(void); -- cgit v1.2.3 From 435971f256f33f9944bc37f7c23c90eb70c77948 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 10:55:18 +1000 Subject: TONY: Fixed the CopyMemory stub to copy the correct number of bytes. Tony can now leave his office without the game crashing. --- engines/tony/mpal/stubs.cpp | 4 ++++ engines/tony/mpal/stubs.h | 16 ++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 23bc18b0ea..89740fdd52 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -40,6 +40,10 @@ uint16 GetAsyncKeyState(Common::KeyCode kc) { return 0; } +void CopyMemory(void *dst, const void *first, int size) { + Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index ae25f7127e..ea88c1c76c 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -53,24 +53,12 @@ typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); #define PASCAL -/****************************************************************************\ -* Templates -\****************************************************************************/ - -/** - * Copies data from the range [first, last) to [dst, dst + (last - first)). - * It requires the range [dst, dst + (last - first)) to be valid. - * It also requires dst not to be in the range [first, last). - */ -template -Out CopyMemory(Out dst, In first, int size) { - return Common::copy(first, first + size, dst); -} - /****************************************************************************\ * Methods \****************************************************************************/ +extern void CopyMemory(void *dst, const void *first, int size); + extern uint16 GetAsyncKeyState(Common::KeyCode kc); } // end of namespace MPAL -- cgit v1.2.3 From 65ec900cebbfdbf453cdcdb8ec24f86bd797fdcd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 11:01:20 +1000 Subject: TONY: Removed old extern, PASCAL, and EXPORT function modifiers --- engines/tony/mpal/mpal.cpp | 12 ++++++------ engines/tony/mpal/mpal.h | 25 +++++++++---------------- engines/tony/mpal/stubs.h | 2 -- engines/tony/sound.cpp | 2 +- 4 files changed, 16 insertions(+), 25 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a665fbacc5..d28fd8e8e2 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -816,7 +816,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { /****************************************************************************\ * -* Function: void PASCAL CustomThread(LPCFCALL p); +* Function: void CustomThread(LPCFCALL p); * * Description: Thread che richiama una funzione custom. Viene usato negli * script, in modo che ciascuna funzione venga eseguita senza @@ -848,7 +848,7 @@ void CustomThread(CORO_PARAM, const void *param) { /****************************************************************************\ * -* Function: void PASCAL ScriptThread(LPMPALSCRIPT s); +* Function: void ScriptThread(LPMPALSCRIPT s); * * Description: Esegue uno script. Questa funzione e' pensata come starting * point per un thread @@ -946,7 +946,7 @@ void ScriptThread(CORO_PARAM, const void *param) { /****************************************************************************\ * -* Function: void PASCAL ActionThread(LPMPALITEM item); +* Function: void ActionThread(LPMPALITEM item); * * Description: Thread che esegue una azione su un item. Il thread * esegue sempre l'azione 0, per cui e' necessario creare @@ -1036,7 +1036,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { /****************************************************************************\ * -* Function: void PASCAL LocationPollThread(uint32 id); +* Function: void LocationPollThread(uint32 id); * * Description: Esegue il polling di una locazione (starting point di un * thread). @@ -2323,7 +2323,7 @@ uint32 mpalGetError(void) { * \****************************************************************************/ -bool EXPORT mpalExecuteScript(int nScript) { +bool mpalExecuteScript(int nScript) { int n; LPMPALSCRIPT s; @@ -2355,7 +2355,7 @@ bool EXPORT mpalExecuteScript(int nScript) { * \****************************************************************************/ -void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { +void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { lpiifCustom = lpiifCus; } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 49601bc1e9..1d298b4f26 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -138,7 +138,6 @@ namespace MPAL { #define MAXPOLLINGLOCATIONS 64 -#define EXPORT #define LPSTR char * /****************************************************************************\ @@ -570,12 +569,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; /****************************************************************************\ -* Functions exported DLL +* Functions exported to the main game \****************************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif /****************************************************************************\ * @@ -593,7 +589,7 @@ extern "C" { * \****************************************************************************/ -bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, +bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); @@ -636,7 +632,7 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); * \****************************************************************************/ -bool EXPORT mpalExecuteScript(int nScript); +bool mpalExecuteScript(int nScript); @@ -650,7 +646,7 @@ bool EXPORT mpalExecuteScript(int nScript); * \****************************************************************************/ -uint32 EXPORT mpalGetError(void); +uint32 mpalGetError(void); @@ -665,7 +661,7 @@ uint32 EXPORT mpalGetError(void); * \****************************************************************************/ -void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); /****************************************************************************\ @@ -684,7 +680,7 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); * \****************************************************************************/ -bool EXPORT mpalStartIdlePoll(int nLoc); +bool mpalStartIdlePoll(int nLoc); /****************************************************************************\ @@ -715,7 +711,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); * \****************************************************************************/ -int EXPORT mpalLoadState(byte *buf); +int mpalLoadState(byte *buf); @@ -730,7 +726,7 @@ int EXPORT mpalLoadState(byte *buf); * \****************************************************************************/ -void EXPORT mpalSaveState(byte *buf); +void mpalSaveState(byte *buf); @@ -744,11 +740,8 @@ void EXPORT mpalSaveState(byte *buf); * \****************************************************************************/ -int EXPORT mpalGetSaveStateSize(void); +int mpalGetSaveStateSize(void); -#ifdef __cplusplus -} -#endif /****************************************************************************\ * diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index ea88c1c76c..66f83997ae 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -51,8 +51,6 @@ typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); #define MB_OK 1 -#define PASCAL - /****************************************************************************\ * Methods \****************************************************************************/ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index c8caf5043d..0658c99f48 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -2069,7 +2069,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { * \****************************************************************************/ -void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { +void FPSTREAM::PlayThread(FPSTREAM *This) { #ifdef REFACTOR_ME byte *lpLockBuf; uint32 dwResult; -- cgit v1.2.3 From 109e5f8226c1db18926e307d4ecb9c3c83fdd7bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 20:49:36 +1000 Subject: TONY: Conversion of more methods to coroutines --- engines/tony/custom.cpp | 9 +- engines/tony/detection_tables.h | 4 + engines/tony/font.cpp | 185 +++++++++++------ engines/tony/font.h | 24 +-- engines/tony/game.cpp | 431 +++++++++++++++++++++++++--------------- engines/tony/game.h | 28 +-- engines/tony/gfxcore.cpp | 124 ++++++++---- engines/tony/gfxcore.h | 33 +-- engines/tony/gfxengine.cpp | 24 ++- engines/tony/gfxengine.h | 1 + engines/tony/input.cpp | 12 ++ engines/tony/input.h | 11 +- engines/tony/inventory.cpp | 91 +++++---- engines/tony/inventory.h | 6 +- engines/tony/loc.cpp | 69 +++++-- engines/tony/loc.h | 16 +- engines/tony/tony.cpp | 27 +-- engines/tony/tonychar.cpp | 15 +- engines/tony/tonychar.h | 2 +- 19 files changed, 698 insertions(+), 414 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a9e8e5bc62..a3a57dfce9 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2155,6 +2155,9 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr if (_ctx->num == 1) { mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); + + // Wait for the next choice to be made + mpalQueryDialogWaitForChoice(&_ctx->nChoice); continue; } @@ -2181,7 +2184,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(WaitFrame); Freeze(); - _ctx->dc.DoFrame(Input->MousePos()); + CORO_INVOKE_1(_ctx->dc.DoFrame, Input->MousePos()); Unfreeze(); } @@ -2214,7 +2217,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); // WaitForSingleObject(mut[num],CORO_INFINITE); - warning("TODO"); + warning("TODO: TakeOwnership"); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2644,7 +2647,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_INVOKE_0(WaitFrame); if (Input->MouseLeftClicked() || Input->MouseRightClicked()) break; - if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index bb660dd862..afcf787ca1 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -32,7 +32,11 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, +#ifdef TEMPORARY_DISABLED ADGF_DEMO, +#else + ADGF_NO_FLAGS, +#endif GUIO1(GUIO_NONE) }, }, diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8cc60a917b..5712014bf2 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -152,12 +152,19 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { return prim; } -void RMFont::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { - RMFontPrimitive *prim = (RMFontPrimitive *)prim2; +void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + RMFontPrimitive *prim = (RMFontPrimitive *)prim2; + + CORO_BEGIN_CODE(_ctx); + + // Richiama la Draw della lettera assegnata alla primitiva + if (prim->m_nChar != -1) + CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); - // Richiama la Draw della lettera assegnata alla primitiva - if (prim->m_nChar != -1) - m_letter[prim->m_nChar].Draw(bigBuf,prim); + CORO_END_CODE; } void RMFont::Close(void) { @@ -1845,10 +1852,10 @@ void RMText::SetMaxLineLength(int max) { maxLineLength = max; } -bool RMText::RemoveThis() { +void RMText::RemoveThis(CORO_PARAM, bool &result) { // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso // etc. - return true; + result = true; } @@ -2007,7 +2014,11 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; } -void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Allinea orizzontalmente if (aHorType == HCENTER) prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); @@ -2016,22 +2027,20 @@ void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Alinea verticalemente - switch (aVerType) { - case VTOP: - break; + if (aVerType == VTOP) { - case VCENTER: - prim->Dst().y1-=m_dimy/2; - break; + } else if (aVerType == VCENTER) { + prim->Dst().y1 -= m_dimy / 2; - case VBOTTOM: - prim->Dst().y1-=m_dimy; - break; + } else if (aVerType == VBOTTOM) { + prim->Dst().y1 -= m_dimy; } ClipOnScreen(prim); - RMGfxWoodyBuffer::Draw(bigBuf,prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + + CORO_END_CODE; } /****************************************************************************\ @@ -2127,7 +2136,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) - if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; if (!m_bNoTab) @@ -2173,16 +2182,23 @@ void RMTextDialog::Unregister(void) { CoroScheduler.setEvent(hEndDisplay); } -void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_startTime == 0) m_startTime = _vm->GetTime(); if (m_bShowed) { if (bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; - RMText::Draw(bigBuf, prim); + CORO_INVOKE_2(RMText::Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { @@ -2217,17 +2233,23 @@ RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { RMTextDialogScrolling::~RMTextDialogScrolling() { } -void RMTextDialogScrolling::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMPoint curDst; +void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + RMPoint curDst; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - curDst = dst; + _ctx->curDst = dst; if (curLoc != NULL) dst -= curLoc->ScrollPosition() - startScroll; - RMTextDialog::Draw(bigBuf, prim); + CORO_INVOKE_2(RMTextDialog::Draw, bigBuf, prim); + + dst = _ctx->curDst; - dst = curDst; + CORO_END_CODE; } void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { @@ -2298,7 +2320,12 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & } -void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se non c'e' testo, e' inutile continuare if (m_buf == NULL) return; @@ -2306,7 +2333,9 @@ void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Setta come coordinate destinazione quelle del mouse prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); - RMText::Draw(bigBuf,prim); + CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + + CORO_END_CODE; } RMPoint RMTextItemName::GetHotspot() { @@ -2411,9 +2440,13 @@ void RMDialogChoice::AddChoice(RMString string) { m_drawedStrings[m_curAdded++].WriteText(string,0); } -void RMDialogChoice::Prepare(void) { - int i; - RMPoint ptPos; +void RMDialogChoice::Prepare(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + int i; + RMPoint ptPos; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); @@ -2421,53 +2454,60 @@ void RMDialogChoice::Prepare(void) { AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); - ptPos.Set(20,90); + _ctx->ptPos.Set(20,90); - for (i = 0; i < m_numChoices; i++) { - AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); - m_ptDrawStrings[i] = ptPos; - ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); + for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { + AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); + m_ptDrawStrings[_ctx->i] = _ctx->ptPos; + _ctx->ptPos.Offset(0,m_drawedStrings[_ctx->i].Dimy() + 15); } - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); - m_ptDrawPos.Set(0,480-ptPos.y); + m_ptDrawPos.Set(0,480-_ctx->ptPos.y); + + CORO_END_CODE; } -void RMDialogChoice::SetSelected(int pos) { - //uint16 * buf = (uint16 *)m_buf; - RMGfxBox box; - RMRect rc; +void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { + CORO_BEGIN_CONTEXT; + RMGfxBox box; + RMRect rc; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (pos == m_curSelection) return; - box.SetPriority(5); + _ctx->box.SetPriority(5); if (m_curSelection != -1) { - box.SetColor(0xCC, 0xCC, 0xFF); - rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); - rc.BottomRight() = rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); - AddPrim(new RMGfxPrimitive(&box, rc)); + _ctx->box.SetColor(0xCC, 0xCC, 0xFF); + _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); + AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); } if (pos != -1) { - box.SetColor(100, 100, 100); - rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); - rc.BottomRight() = rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); - AddPrim(new RMGfxPrimitive(&box, rc)); + _ctx->box.SetColor(100, 100, 100); + _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); m_curSelection = pos; + + CORO_END_CODE; } void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { @@ -2480,7 +2520,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CODE(_ctx); - Prepare(); + CORO_INVOKE_0(Prepare); m_bShow = false; if (!m_nInList && bigBuf != NULL) @@ -2513,12 +2553,19 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_END_CODE; } -void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bShow == false) return; prim->SetDst(m_ptDrawPos); - RMGfxSourceBuffer16::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + + CORO_END_CODE; } @@ -2553,24 +2600,30 @@ void RMDialogChoice::Hide(CORO_PARAM) { } -bool RMDialogChoice::RemoveThis(void) { - return bRemoveFromOT; +void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { + result = bRemoveFromOT; } -void RMDialogChoice::DoFrame(RMPoint ptMousePos) { - int i; - +void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (ptMousePos.y > m_ptDrawPos.y) { - for (i = 0; i < m_numChoices; i++) { - if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[i].y+m_drawedStrings[i].Dimy())) { - SetSelected(i); + for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { + if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y+m_drawedStrings[_ctx->i].Dimy())) { + CORO_INVOKE_1(SetSelected, _ctx->i); break; } } - if (i == m_numChoices) - SetSelected(-1); + if (_ctx->i == m_numChoices) + CORO_INVOKE_1(SetSelected, -1); } + + CORO_END_CODE; } int RMDialogChoice::GetSelection(void) { diff --git a/engines/tony/font.h b/engines/tony/font.h index d883733db6..7c766e5d01 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -112,7 +112,7 @@ public: virtual void Close(void); // Funzione del task da overloadare - void Draw(RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Crea una primitiva per una lettera RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); @@ -230,10 +230,10 @@ public: // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta il colore di base void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } @@ -275,7 +275,7 @@ class RMTextDialog : public RMText { virtual void Unregister(void); // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta la posizione void SetPosition(RMPoint pt) { dst=pt; } @@ -310,7 +310,7 @@ public: RMTextDialogScrolling(RMLocation* loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -334,14 +334,14 @@ public: void SetMouseCoord(RMPoint m) { m_mpos=m; } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); RMPoint GetHotspot(); RMItem *GetSelectedItem(); bool IsItemSelected(); bool IsNormalItemSelected(); - virtual bool RemoveThis() { return true; } + virtual void RemoveThis(CORO_PARAM, bool &result) { result = true; } }; @@ -363,12 +363,12 @@ private: bool bRemoveFromOT; protected: - void Prepare(void); - void SetSelected(int pos); + void Prepare(CORO_PARAM); + void SetSelected(CORO_PARAM, int pos); public: - bool RemoveThis(void); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); void Unregister(void); public: @@ -394,7 +394,7 @@ public: void Hide(CORO_PARAM); // Polling di aggiornamento - void DoFrame(RMPoint ptMousePos); + void DoFrame(CORO_PARAM, RMPoint ptMousePos); // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata int GetSelection(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 820641e48f..e5e08f57e7 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -217,12 +217,19 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick -void RMOptionButton::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!m_bActive) return; if (m_bHasGfx) - m_buf->Draw(bigBuf,prim); + CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + + CORO_END_CODE; } void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { @@ -310,37 +317,43 @@ bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) return bRefresh; } -void RMOptionSlide::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int i; - int val; +void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int i; + int val; + RMPoint pos; + CORO_END_CONTEXT(_ctx); - RMPoint pos; - pos = m_pos; - pos.x += 4; - pos.y += 4; + CORO_BEGIN_CODE(_ctx); + + _ctx->pos = m_pos; + _ctx->pos.x += 4; + _ctx->pos.y += 4; - val = m_nValue * m_nStep; - if (val < 1) val = 1; - else if (val > 100) val = 100; + _ctx->val = m_nValue * m_nStep; + if (_ctx->val < 1) _ctx->val = 1; + else if (_ctx->val > 100) _ctx->val = 100; - if (val == 1) { - prim->SetDst(pos); - m_SliderSingle->Draw(bigBuf, prim); + if (_ctx->val == 1) { + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderSingle->Draw, bigBuf, prim); } else { - prim->SetDst(pos); - m_SliderLeft->Draw(bigBuf, prim); - pos.x += 3; - - for (i = 1; i < val - 1; i++) { - prim->SetDst(pos); - m_SliderCenter->Draw(bigBuf, prim); - pos.x += 3; + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderLeft->Draw, bigBuf, prim); + _ctx->pos.x += 3; + + for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderCenter->Draw, bigBuf, prim); + _ctx->pos.x += 3; } - prim->SetDst(pos); - m_SliderRight->Draw(bigBuf, prim); - pos.x += 3; + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderRight->Draw, bigBuf, prim); + _ctx->pos.x += 3; } + + CORO_END_CODE; } void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { @@ -379,12 +392,49 @@ RMOptionScreen::RMOptionScreen(void) { } m_statePos = 0; + m_ButtonQuitYes = NULL; + m_ButtonQuitNo = NULL; + m_ButtonQuit = NULL; + m_SaveEasy = NULL; + m_SaveHard = NULL; + m_ButtonGfx_Tips = NULL; + m_ButtonSound_DubbingOn = NULL; + m_ButtonSound_MusicOn = NULL; + m_ButtonSound_SFXOn = NULL; + m_SlideTonySpeed = NULL; + m_SlideTextSpeed = NULL; + m_ButtonGame_Lock = NULL; + m_ButtonGfx_Anni30 = NULL; + m_SliderSound_Music = NULL; + m_ButtonGame_TimerizedText = NULL; + m_ButtonGfx_AntiAlias = NULL; + m_SliderSound_SFX = NULL; + m_ButtonGame_Scrolling = NULL; + m_ButtonGfx_Sottotitoli = NULL; + m_SliderSound_Dubbing = NULL; + m_ButtonGame_InterUp = NULL; + m_ButtonGfx_Trans = NULL; + + m_FadeStep = 0; + m_FadeY = 0; + m_FadeTime = 0; + m_nEditPos = 0; + m_nLastState = MENUGAME; } + RMOptionScreen::~RMOptionScreen(void) { } -void RMOptionScreen::RefreshAll(void) { +void RMOptionScreen::RefreshAll(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + RMGfxSourceBuffer16 *thumb; + RMText* title; + RMText *num[6]; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); ClearOT(); AddPrim(new RMGfxPrimitive(m_menu)); @@ -428,22 +478,21 @@ void RMOptionScreen::RefreshAll(void) { m_ButtonSound_SFXOn->AddToList(*this); } - RMGfxSourceBuffer16 *thumb = NULL; - RMText* title = NULL; - RMText* num[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; - int i; + _ctx->thumb = NULL; + _ctx->title = NULL; + Common::fill(&_ctx->num[0], &_ctx->num[6], (RMText *)NULL); if (m_nState == MENULOAD || m_nState == MENUSAVE) { - title = new RMText; + _ctx->title = new RMText; if (m_nState == MENULOAD) { RMMessage msg(10); - title->WriteText(msg[0], 1); + _ctx->title->WriteText(msg[0], 1); } else { RMMessage msg(11); - title->WriteText(msg[0], 1); + _ctx->title->WriteText(msg[0], 1); } - AddPrim(new RMGfxPrimitive(title, RMPoint(320, 10))); + AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); @@ -466,56 +515,62 @@ void RMOptionScreen::RefreshAll(void) { if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { - thumb = new RMGfxSourceBuffer16; - thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); - - switch (m_nEditPos) { - case 0: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 57))); break; - case 1: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 57))); break; - case 2: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 57))); break; - case 3: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 239))); break; - case 4: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 239))); break; - case 5: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 239))); break; - } + _ctx->thumb = new RMGfxSourceBuffer16; + _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + + if (m_nEditPos == 0) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 57))); + else if (m_nEditPos == 1) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 57))); + else if (m_nEditPos == 2) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 57))); + else if (m_nEditPos == 3) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 239))); + else if (m_nEditPos == 4) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 239))); + else if (m_nEditPos == 5) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 239))); } - for (i = 0; i < 6; i++) { + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - if (m_bEditSaveName && m_nEditPos == i) - s.Format("%02d)%s*", m_statePos + i, m_EditName); + if (m_bEditSaveName && m_nEditPos == _ctx->i) + s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); else { - if (m_statePos == 0 && i == 0) + if (m_statePos == 0 && _ctx->i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + i, (const char *)m_curThumbName[i]); + s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); } - num[i] = new RMText; - num[i]->SetAlignType(RMText::HLEFT, RMText::VTOP); - num[i]->WriteText(s, 2); + _ctx->num[_ctx->i] = new RMText; + _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->num[_ctx->i]->WriteText(s, 2); } - AddPrim(new RMGfxPrimitive(num[0], RMPoint(55 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[2],RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[3],RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(num[4],RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(num[5],RMPoint(439 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[2],RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[3],RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[4],RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[5],RMPoint(439 - 3, 362 + 14))); m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - DrawOT(); + CORO_INVOKE_0(DrawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (thumb) delete thumb; - if (title) delete title; + if (_ctx->thumb) delete _ctx->thumb; + if (_ctx->title) delete _ctx->title; - for (i = 0; i < 6; i++) - if (num[i]) delete num[i]; + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) + if (_ctx->num[_ctx->i]) delete _ctx->num[_ctx->i]; } + + CORO_END_CODE; } void RMOptionScreen::RefreshThumbnails(void) { @@ -537,25 +592,29 @@ void RMOptionScreen::RefreshThumbnails(void) { } -void RMOptionScreen::InitState(void) { - RMResRaw *raw; +void RMOptionScreen::InitState(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + RMResRaw *raw; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - raw = new RMResRaw(20000 + m_nState); + _ctx->raw = new RMResRaw(20000 + m_nState); else if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_bAlterGfx) - raw = new RMResRaw(20024); + _ctx->raw = new RMResRaw(20024); else - raw = new RMResRaw(20003); + _ctx->raw = new RMResRaw(20003); } else { error("Invalid state"); } - assert(raw->IsValid()); + assert(_ctx->raw->IsValid()); assert(m_menu == NULL); m_menu = new RMGfxSourceBuffer16(false); - m_menu->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_menu->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_bAlterGfx) { @@ -566,8 +625,8 @@ void RMOptionScreen::InitState(void) { m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(20036, m_SaveEasy); - INIT_GFX8_FROMRAW(20037, m_SaveHard); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, m_SaveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, m_SaveHard); RefreshThumbnails(); @@ -612,12 +671,12 @@ void RMOptionScreen::InitState(void) { assert(m_ButtonSoundMenu == NULL); m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); - raw = new RMResRaw(20021); - assert(raw->IsValid()); + _ctx->raw = new RMResRaw(20021); + assert(_ctx->raw->IsValid()); assert(m_QuitConfirm == NULL); m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_QuitConfirm->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; assert(m_ButtonQuitYes == NULL); m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); @@ -627,12 +686,12 @@ void RMOptionScreen::InitState(void) { m_ButtonQuitNo->SetPriority(30); if (m_bNoLoadSave) { - raw = new RMResRaw(20028); - assert(raw->IsValid()); + _ctx->raw = new RMResRaw(20028); + assert(_ctx->raw->IsValid()); assert(m_HideLoadSave == NULL); m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_HideLoadSave->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; } // Menu GAME @@ -693,7 +752,9 @@ void RMOptionScreen::InitState(void) { } } - RefreshAll(); + CORO_INVOKE_0(RefreshAll); + + CORO_END_CODE; } void RMOptionScreen::CloseState(void) { @@ -828,9 +889,16 @@ void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); } -bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -844,14 +912,24 @@ bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { if (m_nState == MENULOAD || m_nState == MENUSAVE) m_nState = MENUGAME; - InitState(); + + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -864,14 +942,23 @@ bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternate bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENULOAD; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -884,14 +971,23 @@ bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternate bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENUSAVE; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -903,9 +999,11 @@ bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENUGAME; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } bool RMOptionScreen::Close(void) { @@ -927,11 +1025,18 @@ int RMOptionScreen::Priority() { return 190; } -void RMOptionScreen::ChangeState(STATE newState) { +void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + CloseState(); m_nLastState = m_nState; m_nState = newState; - InitState(); + CORO_INVOKE_0(InitState); + + CORO_END_CODE; } void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { @@ -1015,7 +1120,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) +#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } @@ -1029,8 +1134,8 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) - if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || - (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { + if (KEYPRESS(Common::KEYCODE_LSHIFT) || + KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); @@ -1073,7 +1178,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // Se solo il menu di loading, chiudiamo Close(); } else { - ChangeState(m_nLastState); + CORO_INVOKE_1(ChangeState, m_nLastState); _ctx->bRefresh = true; } } else if (m_ButtonSave_ArrowLeft->IsActive()) { @@ -1136,19 +1241,19 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else if (m_ButtonExit->IsActive()) Close(); else if (m_ButtonLoad->IsActive()) { - ChangeState(MENULOAD); + CORO_INVOKE_1(ChangeState, MENULOAD); _ctx->bRefresh = true; } else if (m_ButtonSave->IsActive()) { - ChangeState(MENUSAVE); + CORO_INVOKE_1(ChangeState, MENUSAVE); _ctx->bRefresh = true; } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { - ChangeState(MENUGAME); + CORO_INVOKE_1(ChangeState, MENUGAME); _ctx->bRefresh = true; } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { - ChangeState(MENUGFX); + CORO_INVOKE_1(ChangeState, MENUGFX); _ctx->bRefresh = true; } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { - ChangeState(MENUSOUND); + CORO_INVOKE_1(ChangeState, MENUSOUND); _ctx->bRefresh = true; } @@ -1178,24 +1283,29 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { Close(); if (_ctx->bRefresh) - RefreshAll(); + CORO_INVOKE_0(RefreshAll); CORO_END_CODE; } -void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int curTime = _vm->GetTime(); +void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int curTime; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curTime = _vm->GetTime(); #define FADE_SPEED 20 -#define SYNC (curTime-m_FadeTime) / 25 +#define SYNC (_ctx->curTime-m_FadeTime) / 25 if (m_bExit) return; - switch (m_FadeStep) { + if (m_FadeStep == 1) { // Discesa veloce - case 1: if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else @@ -1207,10 +1317,9 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Setta la parte da disegnare per lo scrolling prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - - // Rimbalzo 1 - case 2: + + } else if (m_FadeStep == 2) { + // Rimbalzo 1 m_FadeY -= FADE_SPEED / 2 * SYNC; if (m_FadeY < 400) { m_FadeY = 400; @@ -1218,9 +1327,8 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - case 3: + } else if (m_FadeStep == 3) { m_FadeY -= FADE_SPEED / 4 * SYNC; if (m_FadeY < 380) { m_FadeY = 380; @@ -1228,10 +1336,9 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Rimbalzo 1 - 2 - case 4: + } else if (m_FadeStep == 4) { + // Rimbalzo 1 - 2 m_FadeY += FADE_SPEED / 3 * SYNC; if (m_FadeY > 420) { m_FadeY = 420; @@ -1239,9 +1346,8 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - case 5: + } else if (m_FadeStep == 5) { m_FadeY += FADE_SPEED / 2 * SYNC; if (m_FadeY > 480) { m_FadeY = 480; @@ -1250,29 +1356,25 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Menu ON - case 6: - break; + } else if (m_FadeStep == 6) { + // Menu ON - // Menu OFF - case 7: + } else if (m_FadeStep == 7) { + // Menu OFF _vm->ShowLocation(); m_FadeStep++; - break; - case 8: + } else if (m_FadeStep == 8) { m_FadeY -= FADE_SPEED * SYNC; if (m_FadeY < 0) { m_FadeY = 0; m_FadeStep++; } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Ciao ciao! - case 9: + } else if (m_FadeStep == 9) { + // Ciao ciao! m_bExit = true; m_FadeStep = 0; @@ -1280,21 +1382,22 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CloseState(); return; - default: + } else { m_FadeStep = 0; - break; } - m_FadeTime = curTime; + m_FadeTime = _ctx->curTime; + + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); - RMGfxWoodyBuffer::Draw(bigBuf,prim); + CORO_END_CODE; } -bool RMOptionScreen::RemoveThis() { +void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { if (m_bExit) - return true; - - return false; + result = true; + else + result = false; } @@ -1434,30 +1537,36 @@ int RMPointer::Priority() { return 200; } -void RMPointer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int n; +void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int n; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Controlla il pointer - n = m_nCurPointer; - if (n == TA_COMBINE) n = TA_USE; + _ctx->n = m_nCurPointer; + if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copia le coordinate di destinazione nella primitiva prim->SetDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Richiama il draw del puntatore - prim->Dst()-=m_hotspot[n]; + prim->Dst()-=m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { - m_pointer[n]->Draw(bigBuf,prim); + CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); } else { if (m_nCurSpecialPointer == PTR_CUSTOM) - m_nCurCustomPointer->Draw(bigBuf, prim); + CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else // Richiama il draw sul puntatore speciale - m_specialPointer[m_nCurSpecialPointer-1]->Draw(bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer-1]->Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { @@ -1469,9 +1578,9 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); } -bool RMPointer::RemoveThis() { +void RMPointer::RemoveThis(CORO_PARAM, bool &result) { // Si leva sempre dalla lista di OT, per supportare la DisableInput - return true; + result = true; } int RMPointer::CurAction(void) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 55fed71380..554279c13f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -64,7 +64,7 @@ namespace Tony { (buf16)->Init(*raw,raw->Width(),raw->Height()); \ delete raw; -#define INIT_GFX8_FROMRAW(dwRes, buf8) \ +#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ raw = new RMResRaw(dwRes); \ assert(raw->IsValid()); \ assert((buf8) == NULL); \ @@ -135,13 +135,13 @@ public: int Priority(); // Overloading draw method - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates void SetCoord(RMPoint pt) { m_pos = pt; } // Overloading of the method to see if rising from the list - bool RemoveThis(); + virtual void RemoveThis(CORO_PARAM, bool &result); // Sets a new action as current void SetAction(RMTonyAction action) { m_nCurPointer = action; } @@ -174,7 +174,7 @@ public: virtual ~RMOptionButton(); bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; } void SetActiveState(bool bState) { m_bActive=bState; } @@ -199,7 +199,7 @@ public: virtual ~RMOptionSlide(); bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer& bigBuf); int GetValue() { return m_nValue; } @@ -286,18 +286,18 @@ public: RMOptionScreen(); virtual ~RMOptionScreen(); - bool Init(RMGfxTargetBuffer& bigBuf); - bool InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); - bool InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); - bool InitNoLoadSave(RMGfxTargetBuffer &bigBuf); + void Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); void ReInit(RMGfxTargetBuffer &bigBuf); bool Close(); bool IsClosing(); // Metodi in overloading da RMGfxTask int Priority(); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); // Polling per l'option screen void DoFrame(CORO_PARAM, RMInput *m_input); @@ -305,12 +305,12 @@ public: protected: // Inizializza tutto per il nuovo stato - void InitState(void); + void InitState(CORO_PARAM); void CloseState(void); - void ChangeState(STATE newState); + void ChangeState(CORO_PARAM, STATE newState); // Ridisegna tutto il menu delle opzioni - void RefreshAll(void); + void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); // Carica lo screenshot per il salvataggio diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 344542b801..6f24941545 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -63,8 +63,8 @@ int RMGfxTask::Priority() { return m_nPrior; } -bool RMGfxTask::RemoveThis() { - return true; +void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { + result = true; } @@ -261,12 +261,19 @@ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { } -void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Prima si fa disegnare tramite la propria OT list - DrawOT(); + CORO_INVOKE_0(DrawOT); // Poi disegna se stesso nel target buffer - RMGfxSourceBuffer16::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + + CORO_END_CODE; } RMGfxWoodyBuffer::RMGfxWoodyBuffer() { @@ -316,47 +323,53 @@ void RMGfxTargetBuffer::ClearOT(void) { g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::DrawOT(void) { - OTList *cur; - OTList *prev; - OTList *next; - RMGfxPrimitive *myprim; +void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + bool result; + CORO_END_CONTEXT(_ctx); - prev = NULL; - cur = otlist; + CORO_BEGIN_CODE(_ctx); + + _ctx->prev = NULL; + _ctx->cur = otlist; // Lock del buffer per accederci Lock(); g_system->lockMutex(csModifyingOT); - while (cur != NULL) { + while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva - myprim=cur->prim->Duplicate(); - cur->prim->m_task->Draw(*this, myprim); - delete myprim; + _ctx->myprim=_ctx->cur->prim->Duplicate(); + CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); + delete _ctx->myprim; // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist - if (cur->prim->m_task->RemoveThis()) { + CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); + if (_ctx->result) { // Deregistra il task - cur->prim->m_task->Unregister(); + _ctx->cur->prim->m_task->Unregister(); // Cancella il task liberando la memoria - delete cur->prim; - next=cur->next; - delete cur; + delete _ctx->cur->prim; + _ctx->next = _ctx->cur->next; + delete _ctx->cur; // Se era il primo elemento, aggiorna la testa della lista - if (prev == NULL) - otlist = next; + if (_ctx->prev == NULL) + otlist = _ctx->next; // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente else - prev->next = next; + _ctx->prev->next = _ctx->next; - cur = next; + _ctx->cur = _ctx->next; } else { // Aggiorna il puntatore al precedente e scorre la lista - prev = cur; - cur = cur->next; + _ctx->prev = _ctx->cur; + _ctx->cur = _ctx->cur->next; } } @@ -364,6 +377,8 @@ void RMGfxTargetBuffer::DrawOT(void) { // Unlock dopo la scrittura Unlock(); + + CORO_END_CODE; } void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { @@ -490,7 +505,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { * Metodi di RMGfxSourceBuffer4 \****************************************************************************/ -void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) @@ -524,7 +539,7 @@ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { } -void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; int bufx = bigBuf.Dimx(); uint16 *buf = bigBuf; @@ -637,7 +652,7 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) } -void RMGfxSourceBuffer8AB::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; int bufx=bigBuf.Dimx(); uint16 *buf = bigBuf; @@ -838,7 +853,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); } -void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int y; byte *src; uint16 *buf = bigBuf; @@ -1750,9 +1765,16 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri -void RMGfxSourceBuffer8AA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8::Draw(bigBuf, prim); +void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8::Draw, bigBuf, prim); DrawAA(bigBuf, prim); + + CORO_END_CODE; } @@ -1770,10 +1792,17 @@ void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { CompressRLE(); } -void RMGfxSourceBuffer8RLEByteAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); +void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (bCfgAntiAlias) DrawAA(bigBuf,prim); + + CORO_END_CODE; } int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { @@ -1801,10 +1830,17 @@ void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { CompressRLE(); } -void RMGfxSourceBuffer8RLEWordAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); +void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (bCfgAntiAlias) DrawAA(bigBuf,prim); + + CORO_END_CODE; } int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { @@ -1833,7 +1869,7 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } -void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16*)m_buf; @@ -1927,8 +1963,8 @@ void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { * Metodi di RMGfxBox \****************************************************************************/ -bool RMGfxBox::RemoveThis(void) { - return true; +void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { + result = true; } void RMGfxBox::SetColor(byte r, byte g, byte b) { @@ -1938,7 +1974,7 @@ void RMGfxBox::SetColor(byte r, byte g, byte b) { wFillColor = (r << 10) | (g << 5) | b; } -void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int i, j; uint16 *buf = bigBuf; RMRect rcDst; @@ -1966,14 +2002,14 @@ int RMGfxClearTask::Priority() { return 1; } -void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Pulisce tutto il target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } -bool RMGfxClearTask::RemoveThis() { +void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { // Il task di clear si disattiva sempre - return true; + result = true; } } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 88f2d6ed22..289c3e9564 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -49,6 +49,7 @@ #define TONY_GFXCORE_H #include "common/system.h" +#include "common/coroutines.h" #include "tony/utils.h" namespace Tony { @@ -190,8 +191,8 @@ public: virtual ~RMGfxTask() { } virtual int Priority(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void RemoveThis(CORO_PARAM, bool &result); // Registration virtual void Register(void) { m_nInList++; } @@ -217,8 +218,8 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -233,8 +234,8 @@ public: virtual ~RMGfxBox() { } void SetColor(byte r, byte g, byte b); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -277,7 +278,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -322,7 +323,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); }; @@ -335,7 +336,7 @@ protected: public: virtual ~RMGfxSourceBuffer8AB(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -376,7 +377,7 @@ public: virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the color that will be alpha blended void SetAlphaBlendColor(int color); @@ -443,7 +444,7 @@ public: virtual ~RMGfxSourceBuffer8AA(); // Draw con antialiasing - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -452,7 +453,7 @@ protected: void PrepareImage(void); public: - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); @@ -466,7 +467,7 @@ protected: void PrepareImage(void); public: - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation method virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); @@ -488,7 +489,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -520,7 +521,7 @@ public: // management of the OT list void ClearOT(void); - void DrawOT(void); + void DrawOT(CORO_PARAM); void AddPrim(RMGfxPrimitive *prim); // The pointer must be delted // Adds a task to clear the screen @@ -547,7 +548,7 @@ public: RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 88aac99ebe..b5278b3b05 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -108,15 +108,15 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - _ctx->bRes = m_opt.Init(m_bigBuf); + CORO_INVOKE_2(m_opt.Init, m_bigBuf, _ctx->bRes); else if (type == 1) - _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); + CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, true, _ctx->bRes); else if (type == 2) - _ctx->bRes = m_opt.InitNoLoadSave(m_bigBuf); + CORO_INVOKE_2(m_opt.InitNoLoadSave, m_bigBuf, _ctx->bRes); else if (type == 3) - _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); + CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, false, _ctx->bRes); else if (type == 4) - _ctx->bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); + CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->PauseSound(true); @@ -222,12 +222,14 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) + } else if (m_input.GetAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(OpenOptionScreen, 0); - else if (_vm->getIsDemo()) { - if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) + else if (!_vm->getIsDemo()) { + if (m_input.GetAsyncKeyState(Common::KEYCODE_F3) || m_input.GetAsyncKeyState(Common::KEYCODE_F5)) + // Save game screen CORO_INVOKE_1(OpenOptionScreen, 3); - else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) + else if (m_input.GetAsyncKeyState(Common::KEYCODE_F2) || m_input.GetAsyncKeyState(Common::KEYCODE_F7)) + // Load game screen CORO_INVOKE_1(OpenOptionScreen, 4); } } @@ -324,7 +326,7 @@ SKIPCLICKSINISTRO: // ********************** // Disegna la lista di OT // ********************** - m_bigBuf.DrawOT(); + m_bigBuf.DrawOT(Common::nullContext); #define FSTEP (480/32) @@ -579,7 +581,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(); + m_bigBuf.DrawOT(Common::nullContext); m_bigBuf.ClearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index d119bb07a6..41255229b8 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -129,6 +129,7 @@ public: void DisableMouse(void); operator byte *() { return (byte *)m_bigBuf; } + RMInput &GetInput() { return m_input; } // Link to the custom function list void InitCustomDll(void); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 3574980176..bd90ec641d 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,12 +52,16 @@ namespace Tony { #define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } RMInput::RMInput() { + // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + + // Setup keyboard fields + Common::fill(&_keyDown[0], &_keyDown[350], 0); } RMInput::~RMInput() { @@ -95,6 +99,14 @@ void RMInput::Poll(void) { // Since a mouse button has changed, don't do any further event processing this frame return; + case Common::EVENT_KEYDOWN: + _keyDown[(int)_event.kbd.keycode] = true; + return; + + case Common::EVENT_KEYUP: + _keyDown[(int)_event.kbd.keycode] = false; + return; + default: break; } diff --git a/engines/tony/input.h b/engines/tony/input.h index dce35141c5..acb7fbd677 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -56,14 +56,15 @@ namespace Tony { class RMInput { private: Common::Event _event; - RMPoint _mousePos; -// DIMOUSESTATE m_mState; + // Mouse related fields + RMPoint _mousePos; bool _clampMouse; bool _leftButton, _rightButton; - bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse; + // Keyboard related fields + bool _keyDown[350]; private: // Deinizializza DirectInput void DIClose(void); @@ -96,8 +97,8 @@ public: bool MouseRightReleased() { return _rightReleaseMouse; } bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } - // Warns when we are in the GDI loop - void GDIControl(bool bCon); + // Returns true if the given key is pressed + bool GetAsyncKeyState(Common::KeyCode kc) { return _keyDown[(int)kc]; } }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 9d673459c5..b5c28506a9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -181,7 +181,7 @@ void RMInventory::Init(void) { // Prepara il primo inventario Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); } @@ -205,50 +205,62 @@ void RMInventory::Reset(void) { EndCombine(); } -void RMInventory::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + RMPoint pos; + RMPoint pos2; + RMGfxPrimitive *p; + RMGfxPrimitive *p2; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_state == OPENING || m_state == CLOSING) prim->SetDst(RMPoint(0, m_curPutY)); else prim->SetDst(RMPoint(0, m_curPutY)); g_system->lockMutex(m_csModifyInterface); - RMGfxWoodyBuffer::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); g_system->unlockMutex(m_csModifyInterface); if (m_state == SELECTING) { - RMPoint pos; - RMPoint pos2; if (!bCfgInvUp) { - pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); - pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); + _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); } else { - pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( - pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + _ctx->pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); } - RMGfxPrimitive p(prim->m_task, pos); - RMGfxPrimitive p2(prim->m_task, pos2); + _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); + _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); // Disegna l'interfaccina stupida - miniInterface.Draw(bigBuf,&p); + CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); if (bCfgInterTips) { if (miniAction == 1) // Esamina - m_hints[0].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Parla - m_hints[1].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Usa - m_hints[2].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); } + + delete _ctx->p; + delete _ctx->p2; } + + CORO_END_CODE; } -bool RMInventory::RemoveThis(void) { +void RMInventory::RemoveThis(CORO_PARAM, bool &result) { if (m_state == CLOSED) - return true; - - return false; + result = true; + else + result = false; } void RMInventory::RemoveItem(int code) { @@ -263,7 +275,7 @@ void RMInventory::RemoveItem(int code) { m_nInv--; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); return; @@ -287,7 +299,7 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++]=code-10000; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -302,7 +314,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].status = dwStatus; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -384,7 +396,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -405,7 +417,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -450,7 +462,7 @@ void RMInventory::RightClick(RMPoint mpos) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } else if ((m_state == OPENED) && m_bBlinkingLeft) { @@ -470,7 +482,7 @@ void RMInventory::RightClick(RMPoint mpos) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -550,7 +562,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if ((GetAsyncKeyState(Common::KEYCODE_i) & 0x8001) == 0x8001) { + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { bCfgInvLocked = !bCfgInvLocked; } @@ -759,7 +771,7 @@ int RMInventory::LoadState(byte *state) { m_items[28].icon.SetPattern(1); Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); return GetSaveStateSize(); @@ -795,30 +807,35 @@ int RMInterface::OnWhichBox(RMPoint pt) { return -1; } -void RMInterface::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int h; +void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); prim->Dst().TopLeft() = m_openStart; - RMGfxSourceBuffer8RLEByte::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); // Controlla se c'e' da disegnare una zona calda - h = OnWhichBox(m_mpos); - if (h != -1) { + _ctx->h = OnWhichBox(m_mpos); + if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; - m_hotzone[h].Draw(bigBuf, prim); + CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); - if (m_lastHotZone != h) { - m_lastHotZone = h; + if (m_lastHotZone != _ctx->h) { + m_lastHotZone = _ctx->h; _vm->PlayUtilSFX(1); } if (bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - m_hints[h].Draw(bigBuf,prim); + CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); } } else m_lastHotZone = -1; + CORO_END_CODE; } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 3d8650773f..e2143bb24b 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -119,10 +119,10 @@ public: void Reset(void); // Overload per la rimozione da otlist - bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overload per il disegno (per la posizione x&y e l'interfaccina) - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Metodo per determinare se l'inventario sta comandando gli input bool HaveFocus(RMPoint mpos); @@ -205,7 +205,7 @@ public: bool GetPalesati(void); // Overloading del Draw per il posizionamente - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e4a60cb52a..37fe29f359 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -398,8 +398,8 @@ void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { m_buf->Init(ds, dimx,dimy); } -void RMSprite::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->Draw(bigBuf, prim); +void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->Draw(coroParam, bigBuf, prim); } void RMSprite::SetPalette(byte *buf) { @@ -727,7 +727,12 @@ RMPoint RMItem::CalculatePos(void) { return m_pos + m_patterns[m_nCurPattern].Pos(); } -void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se CurSprite == -1, allora e' finito il pattern if (m_nCurSprite == -1) return; @@ -746,13 +751,15 @@ void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->SetStrecth(false); // Ora la passiamo alla routine di drawing generica per surface - m_sprites[m_nCurSprite].Draw(bigBuf, prim); + CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); + + CORO_END_CODE; } -bool RMItem::RemoveThis() { +void RMItem::RemoveThis(CORO_PARAM, bool &result) { // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) - return (m_nCurSprite == -1); + result = (m_nCurSprite == -1); } @@ -907,8 +914,8 @@ void RMWipe::Unregister(void) { CoroScheduler.setEvent(m_hUnregistered); } -bool RMWipe::RemoveThis(void) { - return m_bUnregister; +void RMWipe::RemoveThis(CORO_PARAM, bool &result) { + result = m_bUnregister; } void RMWipe::WaitForFadeEnd(CORO_PARAM) { @@ -972,13 +979,20 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } } -void RMWipe::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bFading) { - m_wip0r.Draw(bigBuf, prim); + CORO_INVOKE_2(m_wip0r.Draw, bigBuf, prim); } if (m_bEndFade) Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); + + CORO_END_CODE; } @@ -1369,12 +1383,19 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { return puntocaldo; } -void RMCharacter::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (bDrawNow) { prim->Dst() += m_fixedScroll; - RMItem::Draw(bigBuf, prim); + CORO_INVOKE_2(RMItem::Draw, bigBuf, prim); } + + CORO_END_CODE; } void RMCharacter::NewBoxEntered(int nBox) { @@ -1692,11 +1713,18 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_END_CODE; } -bool RMCharacter::RemoveThis(void) { +void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (bRemoveFromOT) - return true; + result = true; + else + CORO_INVOKE_1(RMItem::RemoveThis, result); - return RMItem::RemoveThis(); + CORO_END_CODE; } RMCharacter::RMCharacter() { @@ -2214,7 +2242,12 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { * \****************************************************************************/ -void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Setta la posizione sorgente dello scrolling if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); @@ -2224,7 +2257,9 @@ void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Richiama il metodo di drawing della classe dell'immagine, che disegner il background // della locazione - m_buf->Draw(bigBuf, prim); + CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + + CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 218aca02e7..bbe37778c0 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -202,7 +202,7 @@ public: void Init(RMGfxSourceBuffer* buf); friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); @@ -265,10 +265,10 @@ public: void SetScrollPosition(RMPoint scroll); // Overloading della funzione per la rimozione da ot list - virtual bool RemoveThis(); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading del draw - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloading della priorit: la Z virtual int Priority() { return m_z; } @@ -457,13 +457,13 @@ public: void LinkToBoxes(RMGameBoxes* theBoxes); - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Aggiorna la posizione del personaggio void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloading del Draw - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE se si appena fermato bool EndOfPath() { return bEndOfPath; } @@ -505,14 +505,14 @@ public: virtual ~RMWipe(); void DoFrame(RMGfxTargetBuffer& bigBuf); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void InitFade(int type); void CloseFade(void); void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); virtual int Priority(void); }; @@ -557,7 +557,7 @@ public: void Unload(void); // Overloading del Draw - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepara un frame disegnando la locazione e tutti i suoi item void DoFrame(RMGfxTargetBuffer *bigBuf); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 76f6cfcecb..f86576d5c2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -216,12 +216,14 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in m_stream[nextChannel]->Stop(); m_stream[nextChannel]->UnloadFile(); -#ifndef DEMO - if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) - theGame.Abort(); -#else - m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); -#endif + + if (!getIsDemo()) { + if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); + } else { + m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + } + m_stream[nextChannel]->SetLoop(bLoop); m_stream[nextChannel]->Play(); @@ -229,12 +231,13 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in } else { -#ifndef DEMO - if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) - theGame.Abort(); -#else - m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); -#endif + if (!getIsDemo()) { + if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); + } else { + m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + } + m_stream[nChannel]->SetLoop(bLoop); m_stream[nChannel]->Play(); } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 982949870c..0e59779229 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -187,7 +187,12 @@ void RMTony::Hide(bool bShowOmbra) { } -void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Richiama il Draw() della classe madre se tony visibile if (m_bShow && bDrawNow) { if (m_bCorpoDavanti) { @@ -195,7 +200,7 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(1, 4); - RMCharacter::Draw(bigBuf, prim); + CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); } if (m_bIsTalking || m_bIsStaticTalk) { @@ -205,7 +210,7 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); prim->Dst() += m_nBodyOffset; - m_body.Draw(bigBuf, prim); + CORO_INVOKE_2(m_body.Draw, bigBuf, prim); } if (!m_bCorpoDavanti) { @@ -213,9 +218,11 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(0, 3); - RMCharacter::Draw(bigBuf, prim); + CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index bbb1667c9b..17b5be23dc 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -390,7 +390,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Metodi di Draw, che controlla la variabile di show - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Mostra o nascondi void Show(void); -- cgit v1.2.3 From 073e46503cd09130c3d7e2372ae50e47402569d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 21:54:37 +1000 Subject: TONY: Properly implement game saving and loading. Saving isn't enabled in the demo, so for testing purposes I'm currently dissbling the ADGF_DEMO flag in the detection tables so saving is enabled. --- engines/tony/game.cpp | 62 +++++++++++++++++------------- engines/tony/gfxengine.cpp | 95 ++++++++++++++++++++++------------------------ engines/tony/input.cpp | 10 +++++ engines/tony/input.h | 2 +- engines/tony/tony.cpp | 32 ++++++---------- engines/tony/tony.h | 2 +- engines/tony/window.cpp | 65 ++++++++----------------------- 7 files changed, 120 insertions(+), 148 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index e5e08f57e7..7378826a71 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -371,6 +371,7 @@ RMOptionScreen::RMOptionScreen(void) { m_menu = NULL; m_HideLoadSave = NULL; m_QuitConfirm = NULL; + m_bQuitConfirm = false; Create(RM_SX, RM_SY); @@ -1401,10 +1402,11 @@ void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { } -bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString& name, byte &diff) { - char buf[256]; - char namebuf[256]; int i; - Common::File f; +bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { + Common::String buf; + char namebuf[256]; + int i; + Common::InSaveFile *f; char id[4]; // Pulisce la destinazione @@ -1412,60 +1414,68 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS name = "No name"; diff = 10; - // Si fa dare il nome del salvataggio - _vm->GetSaveStateFileName(nState, buf); + // Get the savegame filename for the given slot + buf = _vm->GetSaveStateFileName(nState); - // Guarda se esiste - if (f.open(buf)) + // Try and open the savegame + f = g_system->getSavefileManager()->openForLoading(buf); + if (f == NULL) return false; - // Controlla se giusto l'header - f.read(id, 4); + // Check to see if the file has a valid header + f->read(id, 4); if (id[0] != 'R' || id[1] != 'M' || id[2] != 'S') { - f.close(); + delete f; return false; } if (id[3] < 0x3) { - // Versione vecchia, niente screenshot - f.close(); + // Very old version that doesn't have screenshots + delete f; return true; } - // legge lo screenshot - if (id[3] >= 0x5) { + // Load the screenshot + if ((id[3] >= 0x5) && (id[3] < 0x8)) { + // Read it as an LZO compressed data block byte *cmpbuf; uint32 cmpsize, size; cmpbuf = new byte[160 * 120 * 4]; // Se la versione >= 5, compresso! - cmpsize = f.readUint32LE(); - f.read(cmpbuf, cmpsize); + cmpsize = f->readUint32LE(); + f->read(cmpbuf, cmpsize); lzo1x_decompress(cmpbuf,cmpsize,lpDestBuf,&size); delete[] cmpbuf; - } else - f.read(lpDestBuf, 160 * 120 * 2); + } else { + // Read in the screenshot as an uncompressed data block + if (id[3] >= 8) + // Recent versions use hardcoded 160x120 uncomrpessed data, so size can be skipped + f->skip(4); + + f->read(lpDestBuf, 160 * 120 * 2); + } if (id[3] >= 0x5) { - // Legge il livello di difficolt - diff = f.readByte(); + // Read in the difficulty level + diff = f->readByte(); } if (id[3] < 0x4) { - // Versione vecchia, niente nome - f.close(); + // Savegame version doesn't have a stored name + delete f; return true; } - i = f.readByte(); - f.read(namebuf, i); + i = f->readByte(); + f->read(namebuf, i); namebuf[i] = '\0'; name = namebuf; - f.close(); + delete f; return true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b5278b3b05..579983ad75 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -713,66 +713,55 @@ void RestoreMusic(CORO_PARAM); void SaveMusic(Common::OutSaveFile *f); void LoadMusic(Common::InSaveFile *f); -unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; +#define TONY_SAVEGAME_VERSION 8 void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { Common::OutSaveFile *f; - byte *state, *statecmp; - byte *thumbcmp; - uint thumbsizecmp, thumbsize; - uint size, sizecmp; + byte *state; + uint thumbsize; + uint size; int i; char buf[4]; RMPoint tp = m_tony.Position(); - // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario + // Saving: mpal variables, current location, + tony inventory position - // Per ora salviamo solo lo stato MPAL - size=mpalGetSaveStateSize(); + // For now, we only save the MPAL state + size = mpalGetSaveStateSize(); state = new byte[size]; - statecmp = new byte[size*2]; mpalSaveState(state); - thumbcmp = new byte[160 * 120 * 4]; thumbsize = 160 * 120 * 2; - if (bFastCompress) { - lzo1x_1_compress(state,size,statecmp,&sizecmp,wrkmem); - lzo1x_1_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); - } else { - lzo1x_999_compress(state,size,statecmp,&sizecmp,wrkmem); - lzo1x_999_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); - } - buf[0] = 'R'; buf[1] = 'M'; buf[2] = 'S'; - buf[3] = 0x7; + buf[3] = TONY_SAVEGAME_VERSION; f = g_system->getSavefileManager()->openForSaving(fn); - if (f==NULL) return; + if (f == NULL) + return; + f->write(buf, 4); - f->writeUint32LE(thumbsizecmp); - f->write(thumbcmp, thumbsizecmp); + f->writeUint32LE(thumbsize); + f->write(curThumb, thumbsize); - // Livello di difficolt + // Difficulty level i = mpalQueryGlobalVar("VERSIONEFACILE"); f->writeByte(i); - i=strlen(name); + i = strlen(name); f->writeByte(i); f->write(name, i); f->writeUint32LE(m_nCurLoc); f->writeUint32LE(tp.x); f->writeUint32LE(tp.y); + f->writeUint32LE(size); - f->writeUint32LE(sizecmp); - f->write(statecmp, sizecmp); + f->write(state, size); delete[] state; - delete[] statecmp; - delete[] thumbcmp; - // inventario + // Inventory size = m_inv.GetSaveStateSize(); state = new byte[size]; m_inv.SaveState(state); @@ -791,16 +780,16 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo // New Ver5 bool bStat; - // Salva lo stato della pastorella e del palesati + // Saves the state of the shepherdess and show yourself bStat = m_tony.GetPastorella(); f->writeByte(bStat); bStat = m_inter.GetPalesati(); f->writeByte(bStat); - // Salva gli mchar + // Save the chars CharsSaveAll(f); - // Salva le opzioni + // Save the options f->writeByte(bCfgInvLocked); f->writeByte(bCfgInvNoScroll); f->writeByte(bCfgTimerizedText); @@ -819,10 +808,10 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo f->writeByte(nCfgMusicVolume); f->writeByte(nCfgSFXVolume); - // Salva gli hotspot + // Save the hotspots SaveChangedHotspot(f); - // Salva la musica + // Save the music SaveMusic(f); f->finalize(); @@ -845,8 +834,10 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { CORO_BEGIN_CODE(_ctx); _ctx->f = g_system->getSavefileManager()->openForLoading(fn); - if (_ctx->f == NULL) return; + if (_ctx->f == NULL) + return; _ctx->f->read(_ctx->buf, 4); + if (_ctx->buf[0] != 'R' || _ctx->buf[1] != 'M' || _ctx->buf[2] != 'S') { delete _ctx->f; return; @@ -854,39 +845,43 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { _ctx->ver = _ctx->buf[3]; - if (_ctx->ver != 0x1 && _ctx->ver != 0x2 && _ctx->ver != 0x3 && _ctx->ver != 0x4 && _ctx->ver != 0x5 && _ctx->ver != 0x6 && _ctx->ver != 0x7) { + if (_ctx->ver == 0 || _ctx->ver > TONY_SAVEGAME_VERSION) { delete _ctx->f; return; } if (_ctx->ver >= 0x3) { - // C' il thumbnail. Se _ctx->ver >= 5, compresso - if (_ctx->ver >= 0x5) { + // There is a thumbnail. If the version is between 5 and 7, it's compressed + if ((_ctx->ver >= 0x5) && (_ctx->ver <= 0x7)) { _ctx->i = 0; _ctx->i = _ctx->f->readUint32LE(); _ctx->f->seek(_ctx->i); - } else + } else { + if (_ctx->ver >= 8) + // Skip thumbnail size + _ctx->f->skip(4); + _ctx->f->seek(160 * 120 * 2, SEEK_CUR); + } } if (_ctx->ver >= 0x5) { - // Skip del livello di difficolt + // Skip the difficulty level _ctx->f->seek(1, SEEK_CUR); } - if (_ctx->ver >= 0x4) { // Skippa il nome, che non serve a nessuno + if (_ctx->ver >= 0x4) { // Skip the savegame name, which serves no purpose _ctx->i = _ctx->f->readByte(); _ctx->f->seek(_ctx->i, SEEK_CUR); } - _ctx->loc = _ctx->f->readUint32LE(); _ctx->loc = _ctx->f->readUint32LE(); _ctx->tp.x = _ctx->f->readUint32LE(); _ctx->tp.y = _ctx->f->readUint32LE(); _ctx->size = _ctx->f->readUint32LE(); - if (_ctx->ver >= 0x5) { - // Stato MPAL compresso! + if ((_ctx->ver >= 0x5) && (_ctx->ver <= 7)) { + // MPAL was packed! _ctx->sizecmp = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->statecmp = new byte[_ctx->sizecmp]; @@ -894,6 +889,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { lzo1x_decompress(_ctx->statecmp,_ctx->sizecmp,_ctx->state,&_ctx->size); delete[] _ctx->statecmp; } else { + // Read uncompressed MPAL data _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); } @@ -901,8 +897,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { mpalLoadState(_ctx->state); delete[] _ctx->state; - - // inventario + // Inventory _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); @@ -930,7 +925,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { } if (_ctx->ver >= 6) { - // Carica le opzioni + // Load options bCfgInvLocked = _ctx->f->readByte(); bCfgInvNoScroll = _ctx->f->readByte(); bCfgTimerizedText = _ctx->f->readByte(); @@ -949,7 +944,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { nCfgMusicVolume = _ctx->f->readByte(); nCfgSFXVolume = _ctx->f->readByte(); - // Carica gli hotspot + // Load hotspots LoadChangedHotspot(_ctx->f); } @@ -964,11 +959,11 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); - // Le versioni vecchie necessitano di On enter + // On older versions, need to an enter action if (_ctx->ver < 5) mpalQueryDoAction(0, _ctx->loc, 0); else { - // In quelle nuove, ci basta resettare gli mcode + // In the new ones, we just reset the mcode MCharResetCodes(); } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index bd90ec641d..fcd56b5989 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -127,4 +127,14 @@ bool RMInput::MouseRight() { return _rightButton; } +/** + * Return true if a key has been pressed */ +bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { + // The act of testing for a particular key automatically clears the state, to prevent + // the same key being registered in multiple different frames + bool result = _keyDown[(int)kc]; + _keyDown[(int)kc] = false; + return result; +} + } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index acb7fbd677..79a11db678 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -98,7 +98,7 @@ public: bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } // Returns true if the given key is pressed - bool GetAsyncKeyState(Common::KeyCode kc) { return _keyDown[(int)kc]; } + bool GetAsyncKeyState(Common::KeyCode kc); }; } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index f86576d5c2..56b68419fd 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -389,20 +389,13 @@ int TonyEngine::GetMusicVolume(int nChannel) { } -void TonyEngine::GetSaveStateFileName(int n, char *buf) { - RMString name; - - if (n > 0) - name.Format("%02d", n); - else - name.Format("autosave"); - - name += ".sav"; +Common::String TonyEngine::GetSaveStateFileName(int n) { + return Common::String::format("tony.%03d", n); } void TonyEngine::AutoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; - char buf[256]; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -411,8 +404,8 @@ void TonyEngine::AutoSave(CORO_PARAM) { CORO_INVOKE_0(MainWaitFrame); CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - GetSaveStateFileName(0, _ctx->buf); - _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave", true); + _ctx->buf = GetSaveStateFileName(0); + _theEngine.SaveState(_ctx->buf.c_str(), (byte *)m_curThumbnail, "Autosave", true); MainUnfreeze(); CORO_END_CODE; @@ -420,22 +413,20 @@ void TonyEngine::AutoSave(CORO_PARAM) { void TonyEngine::SaveState(int n, const char *name) { - char buf[256]; - - GetSaveStateFileName(n, buf); - _theEngine.SaveState(buf,(byte *)m_curThumbnail, name); + Common::String buf = GetSaveStateFileName(n); + _theEngine.SaveState(buf.c_str(), (byte *)m_curThumbnail, name); } void TonyEngine::LoadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; - char buf[256]; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GetSaveStateFileName(n, _ctx->buf); - CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf); + _ctx->buf = GetSaveStateFileName(n); + CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf.c_str()); CORO_END_CODE; } @@ -485,8 +476,7 @@ void TonyEngine::CloseVoiceDatabase() { } void TonyEngine::GrabThumbnail(void) { - //_window.GrabThumbnail(m_curThumbnail); - warning("TODO: TonyEngine::GrabThumbnail"); + _window.GrabThumbnail(m_curThumbnail); } void TonyEngine::OptionScreen(void) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 69b54e8edb..4a80970bb9 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -194,7 +194,7 @@ public: void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); - void GetSaveStateFileName(int n, char *buf); + Common::String GetSaveStateFileName(int n); // Prende il thumbnail void GrabThumbnail(void); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index da49b91109..2518250bc7 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -90,7 +90,8 @@ void RMWindow::Close(void) { } void RMWindow::GrabThumbnail(uint16 *thumbmem) { - warning("TODO: RMWindow::GrabThumbnail"); + m_bGrabThumbnail = true; + m_wThumbBuf = thumbmem; } /** @@ -135,6 +136,14 @@ void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { // Standard screen copy g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); } + + if (m_bGrabThumbnail) { + // Need to generate a thumbnail + RMSnapshot s; + + s.GrabScreenshot(lpBuf, 4, m_wThumbBuf); + m_bGrabThumbnail = false; + } } /** @@ -270,7 +279,6 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { } void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { -#ifdef REFACTOR_ME uint16 *src = (uint16 *)lpBuf; int dimx = RM_SX / dezoom; @@ -278,15 +286,15 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int u, v, curv; - uint16 appo; - uint32 k = 0; + uint16 appo; + uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; if (lpDestBuf == NULL) src += (RM_SY - 1) * RM_BBX; - if (dezoom == 1 && 0) { // @@@ NON E' TESTATA MOLTO BENE!!! + if (dezoom == 1 && 0) { byte *curOut = rgb; for (int y = 0; y < dimy; y++) { @@ -329,9 +337,10 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); if (lpDestBuf!=NULL) - lpDestBuf[k/3] = ((int)rgb[k+0]>>3) | (((int)rgb[k+1]>>3)<<5) | (((int)rgb[k+2]>>3)<<10); + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); - k+=3; + k += 3; } if (lpDestBuf == NULL) @@ -340,48 +349,6 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src += RM_BBX * dezoom; } } - - - if (lpDestBuf == NULL) { - if (!GetFreeSnapName(filename)) - return; - - HANDLE hFile = CreateFile(filename, - GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL); - - BITMAPFILEHEADER bmfHeader; - bmfHeader.bfType = ((uint16) ('M' << 8) | 'B'); - bmfHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dimx * dimy * 3; - bmfHeader.bfReserved1 = 0; - bmfHeader.bfReserved2 = 0; - bmfHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); - - BITMAPINFOHEADER bmiHeader; - bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmiHeader.biWidth = dimx; - bmiHeader.biHeight = dimy; - bmiHeader.biPlanes = 1; - bmiHeader.biBitCount = 24; - bmiHeader.biCompression = BI_RGB; - bmiHeader.biSizeImage = dimx * dimy * 3; - bmiHeader.biXPelsPerMeter = 0xB12; - bmiHeader.biYPelsPerMeter = 0xB12; - bmiHeader.biClrUsed = 0; - bmiHeader.biClrImportant = 0; - - uint32 dwWritten; - WriteFile(hFile, &bmfHeader, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); - WriteFile(hFile, &bmiHeader, sizeof(BITMAPINFOHEADER), &dwWritten, NULL); - - WriteFile(hFile, rgb, dimx * dimy * 3, &dwWritten, NULL); - CloseHandle(hFile); - } -#endif } } // End of namespace Tony -- cgit v1.2.3 From d615f0054058a8888a8dfa366adaae75c72c5ac9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:24:53 +1000 Subject: TONY: Workaround for correctly hiding items when they are disabled. I've traced through the code, and the order seems to specifically put the object into the 'destroy me' state by calling another process/thread, but then immediately replaces the values when it returns to the calling method. This workaround at least detects when an item is supposed to be destroyed, and ensures it remains in the 'destroy me' state. --- engines/tony/loc.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 37fe29f359..7a51386a1c 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -321,6 +321,13 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { RMPattern::RMPattern() { m_slots = NULL; + m_speed = 0; + m_bLoop = 0; + m_nSlots = 0; + m_nCurSlot = 0; + m_nCurSprite = 0; + m_nStartTime = 0; + m_slots = NULL; } RMPattern::~RMPattern() { @@ -706,9 +713,18 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return false; // Facciamo un update del pattern, che ci ritorna anche il frame corrente - if (m_nCurPattern != 0) + if (m_nCurPattern != 0) { m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); + // WORKAROUND: Currently, m_nCurSprite = -1 is used to flag that an item should be removed. + // However, this seems to be done inside a process waiting on an event pulsed inside the pattern + // Update method. So the value of m_nCurSprite = -1 is being destroyed with the return value + // replacing it. It may be that the current coroutine PulseEvent implementation is wrong somehow. + // In any case, a special check here is done for items that have ended + if (m_nCurPattern == 0) + m_nCurSprite = -1; + } + // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito if (m_nCurSprite == -1) { // Mettiamo il pattern 0, e usciamo. La classe si auto-deregistrera' della OT list @@ -764,7 +780,7 @@ void RMItem::RemoveThis(CORO_PARAM, bool &result) { void RMItem::SetStatus(int nStatus) { - m_bIsActive = (nStatus>0); + m_bIsActive = (nStatus > 0); } void RMItem::SetPattern(int nPattern, bool bPlayP0) { -- cgit v1.2.3 From 09afc8a1fa354bc25a118a181d261e54c81f97c9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:25:32 +1000 Subject: TONY: Added FIXME for unsafe pointer conversion --- engines/tony/gfxengine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 579983ad75..bbb6eb8f3e 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -371,6 +371,7 @@ void RMGfxEngine::InitCustomDll(void) { SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); } +// FIXME: Casting nPattern from int to RMGfxEngine * void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { static RMGfxEngine *This = NULL; RMItem *item; -- cgit v1.2.3 From 8a88ad861d68bd4c5a1a932d9da2518569ecc4ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:43:02 +1000 Subject: TONY: Converted object passing to use const reference where appropriate. This should cut down on the number of redunndant creations of temporary objects. --- engines/tony/font.cpp | 14 +++++++------- engines/tony/font.h | 18 +++++++++--------- engines/tony/game.cpp | 10 +++++----- engines/tony/game.h | 10 +++++----- engines/tony/gfxengine.cpp | 2 +- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 18 +++++++++--------- engines/tony/inventory.h | 18 +++++++++--------- engines/tony/loc.cpp | 28 ++++++++++++++-------------- engines/tony/loc.h | 30 +++++++++++++++--------------- engines/tony/tonychar.h | 2 +- engines/tony/utils.cpp | 10 +++++----- engines/tony/utils.h | 12 ++++++------ engines/tony/window.cpp | 1 - 14 files changed, 87 insertions(+), 88 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 5712014bf2..2f8c0c5065 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -171,7 +171,7 @@ void RMFont::Close(void) { Unload(); } -int RMFont::StringLen(RMString text) { +int RMFont::StringLen(const RMString &text) { int len, i; len = 0; @@ -1859,7 +1859,7 @@ void RMText::RemoveThis(CORO_PARAM, bool &result) { } -void RMText::WriteText(RMString text, int nFont, int *time) { +void RMText::WriteText(const RMString &text, int nFont, int *time) { // Inizializza i font (una volta sola) if (m_fonts[0] == NULL) { m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); @@ -1876,7 +1876,7 @@ void RMText::WriteText(RMString text, int nFont, int *time) { } -void RMText::WriteText(RMString text, RMFontColor *font, int *time) { +void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; char *p, *old_p; int i, j, x, y; @@ -2077,14 +2077,14 @@ void RMTextDialog::Hide(CORO_PARAM) { m_bShowed = false; } -void RMTextDialog::WriteText(RMString text, int font, int *time) { +void RMTextDialog::WriteText(const RMString &text, int font, int *time) { RMText::WriteText(text,font,&m_time); if (time != NULL) *time = m_time; } -void RMTextDialog::WriteText(RMString text, RMFontColor *font, int *time) { +void RMTextDialog::WriteText(const RMString &text, RMFontColor *font, int *time) { RMText::WriteText(text,font,&m_time); if (time != NULL) @@ -2434,10 +2434,10 @@ void RMDialogChoice::SetNumChoices(int num) { } } -void RMDialogChoice::AddChoice(RMString string) { +void RMDialogChoice::AddChoice(const RMString &string) { // Si disegna la stringa assert(m_curAdded < m_numChoices); - m_drawedStrings[m_curAdded++].WriteText(string,0); + m_drawedStrings[m_curAdded++].WriteText(string, 0); } void RMDialogChoice::Prepare(CORO_PARAM) { diff --git a/engines/tony/font.h b/engines/tony/font.h index 7c766e5d01..a63c90638d 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -118,8 +118,8 @@ public: RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); // Lunghezza in pixel di una stringa con il font corrente - int StringLen(RMString text); - int StringLen(char bChar, char bNext=0); + int StringLen(const RMString &text); + int StringLen(char bChar, char bNext = 0); }; @@ -225,8 +225,8 @@ public: void SetMaxLineLength(int max); // Scrive un testo - void WriteText(RMString text, int font, int *time = NULL); - void WriteText(RMString text, RMFontColor* font, int *time = NULL); + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST @@ -263,8 +263,8 @@ class RMTextDialog : public RMText { virtual ~RMTextDialog(); // Scrive un testo - void WriteText(RMString text, int font, int *time=NULL); - void WriteText(RMString text, RMFontColor* font, int *time=NULL); + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST @@ -278,7 +278,7 @@ class RMTextDialog : public RMText { virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta la posizione - void SetPosition(RMPoint pt) { dst=pt; } + void SetPosition(const RMPoint &pt) { dst = pt; } // Aspetta che venga finita la visualizzazione void WaitForEndDisplay(CORO_PARAM); @@ -331,7 +331,7 @@ public: RMTextItemName(); virtual ~RMTextItemName(); - void SetMouseCoord(RMPoint m) { m_mpos=m; } + void SetMouseCoord(const RMPoint &m) { m_mpos = m; } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -385,7 +385,7 @@ public: void SetNumChoices(int num); // Aggiunge una stringa con la scelta - void AddChoice(RMString string); + void AddChoice(const RMString &string); // Mostra e nasconde la scelta, con eventuali animazioni // NOTA: Se non viene passato parametro alla Show(), obbligo del diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 7378826a71..d579ac34a3 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -180,7 +180,7 @@ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { m_bDoubleState = bDoubleState; } -RMOptionButton::RMOptionButton(RMRect pt) { +RMOptionButton::RMOptionButton(const RMRect &pt) { m_rect = pt; m_bActive = false; m_bHasGfx = false; @@ -192,7 +192,7 @@ RMOptionButton::~RMOptionButton() { delete m_buf; } -bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { +bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { if (!m_bDoubleState) { if (m_rect.PtInRect(mousePos)) { if (!m_bActive) { @@ -201,7 +201,7 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick } } else { if (m_bActive) { - m_bActive=false; + m_bActive = false; return true; } } @@ -241,7 +241,7 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { * Metodi di RMOptionSlide \****************************************************************************/ -RMOptionSlide::RMOptionSlide(RMPoint pt, int nRange, int nStartValue, int slideSize) { +RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int slideSize) { RMResRaw *raw; m_pos = pt; @@ -283,7 +283,7 @@ RMOptionSlide::~RMOptionSlide() { m_PushRight = NULL; } -bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { +bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; // Doframe dei bottoni diff --git a/engines/tony/game.h b/engines/tony/game.h index 554279c13f..8cd64ec7d2 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -138,7 +138,7 @@ public: virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates - void SetCoord(RMPoint pt) { m_pos = pt; } + void SetCoord(const RMPoint &pt) { m_pos = pt; } // Overloading of the method to see if rising from the list virtual void RemoveThis(CORO_PARAM, bool &result); @@ -170,10 +170,10 @@ public: public: RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false); - RMOptionButton(RMRect pt); + RMOptionButton(const RMRect &pt); virtual ~RMOptionButton(); - bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; } @@ -195,10 +195,10 @@ private: int m_nStep; public: - RMOptionSlide(RMPoint pt, int m_nRange=100, int m_nStartValue=0, int slideSize=300); + RMOptionSlide(const RMPoint &pt, int m_nRange = 100, int m_nStartValue = 0, int slideSize = 300); virtual ~RMOptionSlide(); - bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer& bigBuf); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index bbb6eb8f3e..1b09e00956 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -437,7 +437,7 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { */ -void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { +void RMGfxEngine::SelectLocation(const RMPoint &ptTonyStart, const RMPoint &start) { #if 0 OPENFILENAME ofn; char lpszFileName[512]; diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 41255229b8..3f90d41ad7 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -150,7 +150,7 @@ public: void LoadState(CORO_PARAM, const char *fn); // Selects a location - void SelectLocation(RMPoint ptTonyStart=RMPoint(-1,-1), RMPoint start=RMPoint(-1,-1)); + void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1,-1)); // Pauses sound void PauseSound(bool bPause); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index b5c28506a9..b4eef0ac0d 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -83,7 +83,7 @@ RMInventory::~RMInventory() { g_system->deleteMutex(m_csModifyInterface); } -bool RMInventory::CheckPointInside(RMPoint &pt) { +bool RMInventory::CheckPointInside(const RMPoint &pt) { if (!bCfgInvUp) return pt.y > RM_SY - 70; else @@ -343,7 +343,7 @@ bool RMInventory::MiniActive(void) { return m_state == SELECTING; } -bool RMInventory::HaveFocus(RMPoint mpos) { +bool RMInventory::HaveFocus(const RMPoint &mpos) { // In fase di combine abbiamo il focus solo se siamo su una freccia (per poter scrollare) if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) return true; @@ -363,7 +363,7 @@ void RMInventory::EndCombine(void) { m_bCombining = false; } -bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { +bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { int n; // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo @@ -427,7 +427,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } -void RMInventory::RightClick(RMPoint mpos) { +void RMInventory::RightClick(const RMPoint &mpos) { int n; assert(CheckPointInside(mpos)); @@ -488,7 +488,7 @@ void RMInventory::RightClick(RMPoint mpos) { } } -bool RMInventory::RightRelease(RMPoint mpos, RMTonyAction& curAction) { +bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction& curAction) { if (m_state == SELECTING) { m_state = OPENED; @@ -701,14 +701,14 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } -bool RMInventory::ItemInFocus(RMPoint mpt) { +bool RMInventory::ItemInFocus(const RMPoint &mpt) { if ((m_state == OPENED || m_state == OPENING) && CheckPointInside(mpt)) return true; else return false; } -RMItem *RMInventory::WhichItemIsIn(RMPoint mpt) { +RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { int n; if (m_state == OPENED) { @@ -847,7 +847,7 @@ void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { m_mpos = mousepos; } -void RMInterface::Clicked(RMPoint mousepos) { +void RMInterface::Clicked(const RMPoint &mousepos) { m_bActive = true; m_openPos = mousepos; @@ -865,7 +865,7 @@ void RMInterface::Clicked(RMPoint mousepos) { _vm->PlayUtilSFX(0); } -bool RMInterface::Released(RMPoint mousepos, RMTonyAction &action) { +bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { if (!m_bActive) return false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index e2143bb24b..86eaa6801e 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -104,7 +104,7 @@ protected: // Controlla se la posizione Y del mouse corretta, anche in base // alla posizione dell'inventario su schermo - bool CheckPointInside(RMPoint &pt); + bool CheckPointInside(const RMPoint &pt); public: RMInventory(); @@ -125,17 +125,17 @@ public: virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Metodo per determinare se l'inventario sta comandando gli input - bool HaveFocus(RMPoint mpos); + bool HaveFocus(const RMPoint &mpos); // Metodo per determinare se la mini interfaccia attiva bool MiniActive(void); // Gestisce il click sinistro del mouse (solo quando c'ha focus) - bool LeftClick(RMPoint mpos, int &nCombineObj); + bool LeftClick(const RMPoint &mpos, int &nCombineObj); // Gestisce il tasto destro del mouse (solo quando c'ha focus) - void RightClick(RMPoint mpos); - bool RightRelease(RMPoint mpos, RMTonyAction &curAction); + void RightClick(const RMPoint &mpos); + bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Avverte che finito il combine void EndCombine(void); @@ -151,8 +151,8 @@ public: void RemoveItem(int code); // Siamo sopra un oggetto? - RMItem* WhichItemIsIn(RMPoint mpt); - bool ItemInFocus(RMPoint mpt); + RMItem *WhichItemIsIn(const RMPoint &mpt); + bool ItemInFocus(const RMPoint &mpt); // Cambia l'icona di un oggetto void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); @@ -197,8 +197,8 @@ public: void Reset(void); // Avverte dei click e rilasci del mouse - void Clicked(RMPoint mousepos); - bool Released(RMPoint mousepos, RMTonyAction &action); + void Clicked(const RMPoint &mousepos); + bool Released(const RMPoint &mousepos, RMTonyAction &action); // Attiva o disattiva il quinto verbo void SetPalesati(bool bOn); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 7a51386a1c..d805e9ee82 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -576,7 +576,7 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(RMPoint pt, int *size) { +bool RMItem::IsIn(const RMPoint &pt, int *size) { RMRect rc; if (!m_bIsActive) @@ -701,7 +701,7 @@ RMGfxPrimitive *RMItem::NewItemPrimitive() { return new RMGfxPrimitive(this); } -void RMItem::SetScrollPosition(RMPoint scroll) { +void RMItem::SetScrollPosition(const RMPoint &scroll) { m_curScroll = scroll; } @@ -810,7 +810,7 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { } -bool RMItem::GetName(RMString& name) +bool RMItem::GetName(RMString &name) { char buf[256]; @@ -887,7 +887,7 @@ void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_END_CODE; } -void RMItem::ChangeHotspot(RMPoint pt) { +void RMItem::ChangeHotspot(const RMPoint &pt) { m_hot = pt; } @@ -1246,7 +1246,7 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin } -RMPoint RMCharacter::NearestPoint(RMPoint punto) { +RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { /* RMPoint tofind; signed short difx,dify; @@ -1273,7 +1273,7 @@ RMPoint RMCharacter::NearestPoint(RMPoint punto) { } -short RMCharacter::ScanLine(RMPoint punto) { +short RMCharacter::ScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; @@ -1321,7 +1321,7 @@ short RMCharacter::ScanLine(RMPoint punto) { } // Calcola intersezioni tra la traiettoria rettilinea ed il pi vicino BBOX -RMPoint RMCharacter::InvScanLine(RMPoint punto) { +RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; @@ -1617,8 +1617,8 @@ void RMCharacter::Stop(CORO_PARAM) { CORO_END_CODE; } -inline int RMCharacter::InWhichBox(RMPoint pt) { - return theBoxes->WhichBox(curLocation,pt); +inline int RMCharacter::InWhichBox(const RMPoint &pt) { + return theBoxes->WhichBox(curLocation, pt); } @@ -1699,7 +1699,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_END_CODE; } -void RMCharacter::SetPosition(RMPoint pt, int newloc) { +void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; minpath = 0; @@ -1912,7 +1912,7 @@ RMBoxLoc *RMGameBoxes::GetBoxes(int nLoc) { return m_allBoxes[nLoc]; } -bool RMGameBoxes::IsInBox(int nLoc, int nBox, RMPoint pt) { +bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = GetBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && @@ -1922,7 +1922,7 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, RMPoint pt) { return false; } -int RMGameBoxes::WhichBox(int nLoc, RMPoint punto) { +int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { int i; RMBoxLoc *cur = GetBoxes(nLoc); @@ -2311,7 +2311,7 @@ RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { return NULL; } -RMItem *RMLocation::WhichItemIsIn(RMPoint pt) { +RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; @@ -2351,7 +2351,7 @@ void RMLocation::Unload(void) { } } -void RMLocation::UpdateScrolling(RMPoint ptShowThis) { +void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { RMPoint oldScroll = m_curScroll; if (m_curScroll.x + 250 > ptShowThis.x) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index bbe37778c0..d81ecb45d5 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -262,7 +262,7 @@ public: bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); // Setta la posizione corrente di scrolling - void SetScrollPosition(RMPoint scroll); + void SetScrollPosition(const RMPoint &scroll); // Overloading della funzione per la rimozione da ot list virtual void RemoveThis(CORO_PARAM, bool &result); @@ -282,9 +282,9 @@ public: // Setta un nuovo status. void SetStatus(int nStatus); - bool IsIn(RMPoint pt, int* size=NULL); + bool IsIn(const RMPoint &pt, int *size = NULL); RMPoint Hotspot() { return m_hot; } - bool GetName(RMString& name); + bool GetName(RMString &name); int MpalCode() { return m_mpalCode; } // Scarica l'item @@ -294,7 +294,7 @@ public: void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); // Setta un nuovo hotspot per l'oggetto - void ChangeHotspot(RMPoint pt); + void ChangeHotspot(const RMPoint &pt); void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } @@ -375,10 +375,10 @@ public: RMBoxLoc *GetBoxes(int nLoc); // Calcola in quale box si trova il punto - int WhichBox(int nLoc, RMPoint pt); + int WhichBox(int nLoc, const RMPoint &pt); // Controlla che il punto sia dentro un certo box - bool IsInBox(int nLoc, int nBox, RMPoint pt); + bool IsInBox(int nLoc, int nBox, const RMPoint &pt); // Cambia lo stato di un box void ChangeBoxStatus(int nLoc, int nBox, int status); @@ -432,15 +432,15 @@ private: RMPoint m_fixedScroll; private: - int InWhichBox(RMPoint pt); + int InWhichBox(const RMPoint &pt); short FindPath(short source, short destination); RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); - RMPoint NearestPoint(RMPoint punto); + RMPoint NearestPoint(const RMPoint &punto); void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); - short ScanLine(RMPoint punto); - RMPoint InvScanLine(RMPoint punto); + short ScanLine(const RMPoint &punto); + RMPoint InvScanLine(const RMPoint &punto); RMPoint NearestHotSpot(int sourcebox, int destbox); void NewBoxEntered(int nBox); @@ -478,13 +478,13 @@ public: void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); // Posiziona il personaggio a una certa posizione SENZA farlo muovere - void SetPosition(RMPoint pt, int newloc=-1); + void SetPosition(const RMPoint &pt, int newloc = -1); // Aspetta la fine del movimento void WaitForEndMovement(CORO_PARAM); - void SetFixedScroll(RMPoint fix) { m_fixedScroll = fix; } - void SetSpeed(int speed) { curSpeed=speed; } + void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } + void SetSpeed(int speed) { curSpeed = speed; } }; @@ -563,7 +563,7 @@ public: void DoFrame(RMGfxTargetBuffer *bigBuf); // Si fa dare il numero dell'item - RMItem* WhichItemIsIn(RMPoint pt); + RMItem *WhichItemIsIn(const RMPoint &pt); // Si fa dare un elemento dal suo codice MPAL RMItem* GetItemFromCode(uint32 dwCode); @@ -575,7 +575,7 @@ public: void SetFixedScroll(const RMPoint &scroll); // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito - void UpdateScrolling(RMPoint ptShowThis); + void UpdateScrolling(const RMPoint &ptShowThis); // Legge la posizione di scrolling corrente RMPoint ScrollPosition() { return m_curScroll; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 17b5be23dc..ee6d518f4b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -424,7 +424,7 @@ public: RMPoint Position() { return m_pos; } // Setta la posizione di scrolling - void SetScrollPosition(RMPoint pt) { RMCharacter::SetScrollPosition(pt); } + void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } // Setta l'animazione di Take void Take(int nWhere, int nPart); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 7a750c2975..a3998a01ab 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -109,7 +109,7 @@ RMString::RMString(const int ch) { * Returns the length of the string * @returns Length */ -int RMString::Length() { +int RMString::Length() const { return m_length; } @@ -785,7 +785,7 @@ RMPoint &RMPoint::operator=(RMPoint p) { /** * Offsets the point by another point */ -void RMPoint::Offset(RMPoint p) { +void RMPoint::Offset(const RMPoint &p) { x += p.x; y += p.y; } @@ -878,7 +878,7 @@ void RMRect::SetEmpty(void) { x1 = y1 = x2 = y2 = 0; } -RMRect::RMRect(RMPoint p1, RMPoint p2) { +RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { SetRect(p1, p2); } @@ -890,7 +890,7 @@ RMRect::RMRect(const RMRect &rc) { CopyRect(rc); } -void RMRect::SetRect(RMPoint p1, RMPoint p2) { +void RMRect::SetRect(const RMPoint &p1, const RMPoint &p2) { x1 = p1.x; y1 = p1.y; x2 = p2.x; @@ -957,7 +957,7 @@ void RMRect::Offset(int xOff, int yOff) { y2 += yOff; } -void RMRect::Offset(RMPoint p) { +void RMRect::Offset(const RMPoint &p) { x1 += p.x; y1 += p.y; x2 += p.x; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c8ffe062ea..4137823587 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -185,7 +185,7 @@ public: RMString(const int ch); // Metodi generici - int Length(); + int Length() const; void Compact(); // Access characters within string @@ -247,7 +247,7 @@ public: // Offset void Offset(int xOff, int yOff); - void Offset(RMPoint p); + void Offset(const RMPoint &p); friend RMPoint operator+(RMPoint p1, RMPoint p2); friend RMPoint operator-(RMPoint p1, RMPoint p2); RMPoint &operator+=(RMPoint p); @@ -273,7 +273,7 @@ public: public: RMRect(); RMRect(int x1, int y1, int x2, int y2); - RMRect(RMPoint p1, RMPoint p2); + RMRect(const RMPoint &p1, const RMPoint &p2); RMRect(const RMRect &rc); // Attributes @@ -287,7 +287,7 @@ public: // Set void SetRect(int x1, int y1, int x2, int y2); - void SetRect(RMPoint p1, RMPoint p2); + void SetRect(const RMPoint &p1, const RMPoint &p2); void SetEmpty(void); // Copiers @@ -297,7 +297,7 @@ public: // Offset void Offset(int xOff, int yOff); - void Offset(RMPoint p); + void Offset(const RMPoint &p); friend RMRect operator+(const RMRect &rc, RMPoint p); friend RMRect operator-(const RMRect &rc, RMPoint p); friend RMRect operator+(RMPoint p, const RMRect &rc); @@ -313,7 +313,7 @@ public: void NormalizeRect(); // Point in rect - bool PtInRect(RMPoint pt) { return (pt.x>=x1 && pt.x<=x2 && pt.y>=y1 && pt.y<=y2); } + bool PtInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } // Extract from data stream friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 2518250bc7..f997b8c53d 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -286,7 +286,6 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int u, v, curv; - uint16 appo; uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; -- cgit v1.2.3 From ef4846c1218b0709a71ffb5feafebebd26988a4d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:47:28 +1000 Subject: TINSEL: Fix compiler warning --- engines/tinsel/rince.h | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/tinsel/rince.h b/engines/tinsel/rince.h index b34c3f20de..623f3ee137 100644 --- a/engines/tinsel/rince.h +++ b/engines/tinsel/rince.h @@ -31,7 +31,6 @@ namespace Tinsel { struct OBJECT; -struct Common::PROCESS; enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING}; -- cgit v1.2.3 From 63e3b47857fe5a507858b4256b1f3f4d7fe50c22 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:53:09 +1000 Subject: TONY: Fix compiler warnings --- engines/tony/custom.cpp | 6 +++--- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/mpal/mpal.h | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a3a57dfce9..3e8f0b95e6 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2130,7 +2130,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_BEGIN_CONTEXT; uint32 nChoice; uint32 *sl; - int i, num; + uint32 i, num; char *string; RMDialogChoice dc; int sel; @@ -2153,7 +2153,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta if (_ctx->num == 1) { - mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); + mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); // Wait for the next choice to be made @@ -2192,7 +2192,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr MainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); - mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[_ctx->sel]); + mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta _ctx->dc.Close(); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d28fd8e8e2..bfde7fe2a6 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1618,10 +1618,10 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // 0 dell'item, e poi liberera' la memoria con la GlobalFree() // !!! New thread management - if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) + if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; nExecutingAction = item->nObj; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1d298b4f26..319f71c6a8 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -522,6 +522,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelection(nChoice,dwData) \ (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) +#define mpalQueryDialogSelectionDWORD(nChoice,dwData) \ + mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + /****************************************************************************\ * -- cgit v1.2.3 From 28c58a7f56ada6e4c72fcddc92fc4d5a1b181224 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:58:59 +1000 Subject: TONY: Fix unsigned comparison warning --- engines/tony/custom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3e8f0b95e6..b1b660c423 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2145,7 +2145,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); - while (_ctx->nChoice != -1) { + while (_ctx->nChoice != (uint32)-1) { // Si fa dare la lista di opzioni e le conta _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) -- cgit v1.2.3 From 0a835de46805a3f8db4c68b3081fdf376e03a567 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sat, 12 May 2012 19:40:33 +0200 Subject: TONY: Fix compiler warning --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d579ac34a3..758170c848 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -763,7 +763,7 @@ void RMOptionScreen::CloseState(void) { m_menu = NULL; delete m_ButtonExit; - m_ButtonExit = false; + m_ButtonExit = NULL; if (m_nState == MENULOAD || m_nState == MENUSAVE) { int i; -- cgit v1.2.3 From c35b5397168299176eab69622044a98c8995a369 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 09:42:09 +1000 Subject: TONY: Some further initialisation of object fields --- engines/tony/gfxengine.cpp | 11 +++++++++++ engines/tony/sound.cpp | 15 +++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 1b09e00956..f6d047d267 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -90,6 +90,17 @@ RMGfxEngine::RMGfxEngine() { m_bigBuf.OffsetY(RM_SKIPY); csMainLoop = NULL; + m_nCurLoc = 0; + m_curAction = TA_GOTO; + m_curActionObj = 0; + m_nWipeType = 0; + m_hWipeEvent = 0; + m_nWipeStep = 0; + m_bMustEnterMenu = false; + m_bWiping = false; + m_bGUIOption = false; + m_bGUIInterface = false; + m_bGUIInventory = false; } RMGfxEngine::~RMGfxEngine() { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 0658c99f48..01968ea579 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -775,6 +775,8 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) FPSOUND::FPSOUND() { lpDS = NULL; lpDSBPrimary = NULL; + hwnd = 0; + bSoundSupported = false; } @@ -1028,6 +1030,19 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { return; /* Poich non abbiamo ancora nessun dato sull'effetto sonoro, non possiamo fare nulla */ +#else + bIsVoice = false; + lastVolume = 0; + dwFreq = 0; + hEndOfBuffer = CORO_INVALID_PID_VALUE; + bFileLoaded = false; + bSoundSupported = false; + bLoop = false; + bPaused = false; + bStereo = false; + b16bit = false; + bIsPlaying = false; + bIsVoice = false; #endif } -- cgit v1.2.3 From 60deca7f54f395974c58683c9e8ce0a079a90ebf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 09:58:07 +1000 Subject: TONY: Fix some more uninitialised field values --- engines/tony/gfxengine.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index f6d047d267..2c8543326f 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -101,6 +101,10 @@ RMGfxEngine::RMGfxEngine() { m_bGUIOption = false; m_bGUIInterface = false; m_bGUIInventory = false; + m_bAlwaysDrawMouse = false; + m_bOption = false; + m_bLocationLoaded = false; + m_bInput = false; } RMGfxEngine::~RMGfxEngine() { -- cgit v1.2.3 From 7978eb007c5b03b8eb3148883245cba395e3efd3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 10:11:01 +1000 Subject: TONY: Fixed initialisation of missed RMCharacter fields --- engines/tony/loc.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d805e9ee82..4f61582578 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1760,6 +1760,11 @@ RMCharacter::RMCharacter() { pathlenght = pathcount = 0; status = STAND; theBoxes = NULL; + walkcount = 0; + bEndOfPath = false; + bMovingWithoutMinpath = false; + bDrawNow = false; + bNeedToStop = false; m_pos.Set(0, 0); } -- cgit v1.2.3 From 81e5a19d58274c2845587500db25c94502eb99a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 10:42:03 +1000 Subject: TONY: Fix memory leak in displaying hotspot texts --- engines/tony/font.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 2f8c0c5065..f7f3fb3f8c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2272,11 +2272,12 @@ RMTextItemName::~RMTextItemName() { void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { CORO_BEGIN_CONTEXT; - RMString itemName; RMItem *lastItem; uint32 hThread; CORO_END_CONTEXT(_ctx); + RMString itemName; + CORO_BEGIN_CODE(_ctx); _ctx->lastItem = m_item; @@ -2294,14 +2295,14 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & else m_item = loc.WhichItemIsIn(m_mpos); - _ctx->itemName = ""; + itemName = ""; // If there an item, get it's name if (m_item != NULL) - m_item->GetName(_ctx->itemName); + m_item->GetName(itemName); // Write it - WriteText(_ctx->itemName, 1); + WriteText(itemName, 1); // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != m_item) { -- cgit v1.2.3 From 089d7048b60b8ac880b47a0835b5c2890d8d4423 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 15:50:15 +1000 Subject: TONY: Bugfix for crash when removing item from inventory --- engines/tony/gfxengine.cpp | 2 +- engines/tony/inventory.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 2c8543326f..8f7d27dafc 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -341,7 +341,7 @@ SKIPCLICKSINISTRO: // ********************** // Disegna la lista di OT // ********************** - m_bigBuf.DrawOT(Common::nullContext); + CORO_INVOKE_0(m_bigBuf.DrawOT); #define FSTEP (480/32) diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index b4eef0ac0d..468ec225a5 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -266,11 +266,11 @@ void RMInventory::RemoveThis(CORO_PARAM, bool &result) { void RMInventory::RemoveItem(int code) { int i; - for (i=0;ilockMutex(m_csModifyInterface); - Common::copy_backward(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); + Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); // m_inv[m_nInv-1]=0; m_nInv--; -- cgit v1.2.3 From 8466314735761e3b71adfcc34471db539c14bad2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 19:02:47 +1000 Subject: TONY: Disabled target buffer mutex which isn't needed anymore --- engines/tony/gfxcore.cpp | 16 ++++++++-------- engines/tony/gfxcore.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6f24941545..49dd36cfe7 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -295,18 +295,18 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; m_otSize = 0; - csModifyingOT = g_system->createMutex(); +// csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { ClearOT(); - g_system->deleteMutex(csModifyingOT); +// g_system->deleteMutex(csModifyingOT); } void RMGfxTargetBuffer::ClearOT(void) { OTList *cur, *n; - g_system->lockMutex(csModifyingOT); +// g_system->lockMutex(csModifyingOT); cur = otlist; @@ -320,7 +320,7 @@ void RMGfxTargetBuffer::ClearOT(void) { otlist = NULL; - g_system->unlockMutex(csModifyingOT); +// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { @@ -339,7 +339,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // Lock del buffer per accederci Lock(); - g_system->lockMutex(csModifyingOT); +// g_system->lockMutex(csModifyingOT); while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva @@ -373,7 +373,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { } } - g_system->unlockMutex(csModifyingOT); +// g_system->unlockMutex(csModifyingOT); // Unlock dopo la scrittura Unlock(); @@ -385,7 +385,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { int nPrior; OTList *cur, *n; - g_system->lockMutex(csModifyingOT); +// g_system->lockMutex(csModifyingOT); // Avverte che e' in lista di OT prim->m_task->Register(); @@ -412,7 +412,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { cur->next = n; } - g_system->unlockMutex(csModifyingOT); +// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::AddClearTask(void) { diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 289c3e9564..23f1a9809a 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -509,7 +509,7 @@ static RMGfxClearTask taskClear; }; private: - OSystem::MutexRef csModifyingOT; +// OSystem::MutexRef csModifyingOT; protected: OTList *otlist; -- cgit v1.2.3 From 35143eae094b713524ef677412befdc4c766df04 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 19:06:08 +1000 Subject: TONY: Converted SendTonyMessage msg field from a pointer back to an object instance --- engines/tony/custom.cpp | 19 +++++++------------ engines/tony/loc.cpp | 18 +++++++++++++----- engines/tony/loc.h | 2 ++ 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index b1b660c423..bda65fcf67 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -379,7 +379,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; + RMMessage msg; int i; int curOffset; VoiceHeader *curVoc; @@ -393,9 +393,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (bSkipIdle) return; - _ctx->msg = new RMMessage(dwMessage); - if (!_ctx->msg->IsValid()) { - delete _ctx->msg; + _ctx->msg.Load(dwMessage); + if (!_ctx->msg.IsValid()) { return; } @@ -424,7 +423,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } else { - if (_ctx->msg->NumPeriods() > 1) + if (_ctx->msg.NumPeriods() > 1) CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_FIANCHI); else CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); @@ -435,17 +434,17 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !bSkipIdle; _ctx->i++) { _ctx->text.SetInput(Input); // Allineamento - _ctx->text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colore _ctx->text.SetColor(0,255,0); // Scrive il testo - _ctx->text.WriteText((*_ctx->msg)[_ctx->i],0); + _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); // Setta la posizione if (nX == 0 && nY == 0) @@ -494,7 +493,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX curBackText->Show(); CORO_INVOKE_0(Tony->EndTalk); - delete _ctx->msg; CORO_END_CODE; } @@ -2207,9 +2205,6 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } - - - /* * Sync tra idle e mpal */ diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 4f61582578..32754bbb51 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -2425,11 +2425,11 @@ void RMLocation::PauseSound(bool bPause) { \****************************************************************************/ RMMessage::RMMessage(uint32 dwId) { - lpMessage=mpalQueryMessage(dwId); - assert(lpMessage != NULL); - - if (lpMessage) - ParseMessage(); + Load(dwId); +} + +RMMessage::RMMessage() { + lpMessage = NULL; } RMMessage::~RMMessage() { @@ -2437,6 +2437,14 @@ RMMessage::~RMMessage() { GlobalFree(lpMessage); } +void RMMessage::Load(uint32 dwId) { + lpMessage = mpalQueryMessage(dwId); + assert(lpMessage != NULL); + + if (lpMessage) + ParseMessage(); +} + void RMMessage::ParseMessage(void) { char *p; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index d81ecb45d5..bbb98bd9db 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -598,9 +598,11 @@ private: void ParseMessage(void); public: + RMMessage(); RMMessage(uint32 dwId); virtual ~RMMessage(); + void Load(uint32 dwId); bool IsValid() { return lpMessage != NULL; } int NumPeriods() { return nPeriods; } char *Period(int num) { return lpPeriods[num]; } -- cgit v1.2.3 From 546f47ddcee07b5bd7ecad5f25f4bb022944e234 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 22:34:40 +1000 Subject: TONY: Beginnings of refactoring Globals into their own class --- engines/tony/custom.cpp | 1476 ++++++++++++++++++++------------------------ engines/tony/font.cpp | 12 +- engines/tony/game.cpp | 106 ++-- engines/tony/game.h | 20 - engines/tony/gfxcore.cpp | 7 +- engines/tony/gfxengine.cpp | 98 ++- engines/tony/globals.cpp | 93 +++ engines/tony/globals.h | 232 +++++++ engines/tony/inventory.cpp | 30 +- engines/tony/loc.cpp | 4 +- engines/tony/module.mk | 1 + engines/tony/sound.cpp | 19 +- engines/tony/tony.cpp | 61 +- engines/tony/tony.h | 6 + engines/tony/tonychar.cpp | 2 +- 15 files changed, 1130 insertions(+), 1037 deletions(-) create mode 100644 engines/tony/globals.cpp create mode 100644 engines/tony/globals.h (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index bda65fcf67..168c2d38cd 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -62,54 +62,6 @@ namespace Tony { -extern bool bPatIrqFreeze; - -RMTony *Tony; -RMPointer *Pointer; -RMGameBoxes *Boxes; -RMLocation *Loc; -RMInventory *Inventory; -RMInput *Input; - -uint32 (*LoadLocation)(int, RMPoint, RMPoint start); -void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); -void (*LinkGraphicTask)(RMGfxTask *task); -void (*Freeze)(void); -void (*Unfreeze)(void); -void (*WaitFrame)(CORO_PARAM); -void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); -void (*WaitWipeEnd)(CORO_PARAM); -void (*CloseWipe)(void); -void (*InitWipe)(int type); -void (*EnableGUI)(void); -void (*DisableGUI)(void); -void (*SetPalesati)(bool bpal); - -uint32 dwTonyNumTexts = 0; -bool bTonyInTexts = false; -bool bStaticTalk = false; -RMTony::TALKTYPE nTonyNextTalkType; - -RMPoint StartLocPos[256]; -OSystem::MutexRef cs[10]; -OSystem::MutexRef vdb; -HANDLE mut[10]; - -bool bSkipIdle = false; -uint32 hSkipIdle; - -int lastMusic = 0, lastTappeto = 0; - -int tappeti[200]; - -#define T_GRILLI 1 -#define T_GRILLIOV 2 -#define T_GRILLIVENTO 3 -#define T_GRILLIVENTO1 4 -#define T_VENTO 5 -#define T_MARE 6 -#define T_MAREMETA 7 - const char *tappetiFile[] = { "None", "1.ADP", // Grilli.WAV @@ -121,140 +73,139 @@ const char *tappetiFile[] = { "6.ADP" // Mare1.WAV met volume }; -struct CharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int talkpattern; - int standpattern; - int starttalkpattern, endtalkpattern; - int numtexts; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); - f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(talkpattern); - f->writeUint32LE(standpattern); - f->writeUint32LE(starttalkpattern); - f->writeUint32LE(endtalkpattern); - f->writeUint32LE(numtexts); - } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); - f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - talkpattern = f->readUint32LE(); - standpattern = f->readUint32LE(); - starttalkpattern = f->readUint32LE(); - endtalkpattern = f->readUint32LE(); - numtexts = f->readUint32LE(); - } -}; -CharacterStruct Character[16]; - -struct MCharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int x, y; - int numtalks[10]; - int curgroup; - int numtexts; - bool bInTexts; - int curTalk; - bool bAlwaysBack; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); - f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(x); - f->writeUint32LE(y); - for (int i = 0; i < 10; ++i) - f->writeUint32LE(numtalks[i]); - f->writeUint32LE(curgroup); - f->writeUint32LE(numtexts); - f->writeByte(bInTexts); - f->writeUint32LE(curTalk); - f->writeByte(bAlwaysBack); - } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); - f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - x = f->readUint32LE(); - y = f->readUint32LE(); - for (int i = 0; i < 10; ++i) - numtalks[i] = f->readUint32LE(); - curgroup = f->readUint32LE(); - numtexts = f->readUint32LE(); - bInTexts = f->readByte(); - curTalk = f->readUint32LE(); - bAlwaysBack = f->readByte(); - } +struct MusicFileEntry { + const char *name; + int sync; }; -MCharacterStruct MCharacter[10]; +const MusicFileEntry musicFiles[] = { +/* + { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, + { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, + { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, + { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, + { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, +*/ + { "00.ADP", 0 }, { "01.ADP", 0 }, + { "02.ADP", 0 }, { "03.ADP", 0 }, + { "04.ADP",0 }, { "05.ADP", 0 }, + { "06.ADP", 0 }, { "07.ADP", 0 }, + { "08.ADP", 2450 }, { "09.ADP", 0 }, -bool IsMChar[16]; +/* + { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, + { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, + { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, + { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, + { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, +*/ + { "10.ADP", 0 }, { "11.ADP", 0 }, + { "12.ADP", 0 }, { "13.ADP", 0 }, + { "14.ADP", 0 }, { "15.ADP", 0 }, + { "16.ADP", 0 }, { "17.ADP", 0 }, + { "18.ADP", 0 }, { "19.ADP", 0 }, +/* + { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, + { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, + { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, + { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, + { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, +*/ + { "20.ADP", 0 }, { "21.ADP", 0 }, + { "22.ADP", 0 }, { "23.ADP", 0 }, + { "24.ADP", 0 }, { "25.ADP", 0 }, + { "26.ADP", 0 }, { "27.ADP", 0 }, + { "28.ADP", 1670 }, { "29.ADP", 0 }, +/* + { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, + { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, + { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, + { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, + { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, +*/ + { "30.ADP", 0 }, { "31.ADP", 0 }, + { "32.ADP", 2900 }, { "33.ADP", 0 }, + { "34.ADP", 0 }, { "35.ADP", 0 }, + { "36.ADP", 0 }, { "37.ADP", 0 }, + { "38.ADP", 0 }, { "39.ADP", 0 }, +/* + { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, + { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, + { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, + { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, + { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, +*/ + { "40.ADP", 0 }, { "41.ADP", 1920 }, + { "42.ADP", 1560 }, { "43.ADP", 1920 }, + { "44.ADP", 1920 }, { "45.ADP", 1920 }, + { "46.ADP", 1920 }, { "47.ADP", 1920 }, + { "48.ADP", 1920 }, { "49.ADP", 1920 }, -bool bAlwaysDisplay; +/* + { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, + { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, + { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, + { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, + { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } +*/ -RMPoint saveTonyPos; -int saveTonyLoc; + { "50.ADP", 1920 }, { "51.ADP", 1920 }, + { "52.ADP", 1920 }, { "53.ADP", 0 }, + { "54.ADP", 0 }, { "55.ADP", 0 }, + { "56.ADP", 0 }, { "57.ADP", 0 }, + { "58.ADP", 0 }, { "59.ADP", 0 } -RMTextDialog *curBackText = NULL; -bool bTonyIsSpeaking = false; +}; -int curChangedHotspot = 0; -struct ChangedHotspotStruct { - uint32 dwCode; - uint32 nX, nY; +const char *staccFileNames[] = { +/* + "05-MUCCA.ADP", "06-HALOW.ADP", + "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", + "LETTERAFINE.ADP", "PREGAME2.ADP", + "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", + "15-SHOTTONY.ADP", "27-ZUCC2.ADP", +*/ + "S00.ADP", "S01.ADP", + "S02.ADP", "S03.ADP", + "S04.ADP", "S05.ADP", + "S06.ADP", "S07.ADP", + "S08.ADP", "S09.ADP", - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(dwCode); - f->writeUint32LE(nX); - f->writeUint32LE(nY); - } - void Load(Common::InSaveFile *f) { - dwCode = f->readUint32LE(); - nX = f->readUint32LE(); - nY = f->readUint32LE(); - } +/* + "53-DLOGO.ADP", "16-DIALOG1.ADP", + "TORRE1.ADP", "GARG1.ADP", + "LORENZ1.ADP", "24-FIGHT.ADP", + "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", + "GATTO1.ADP" +*/ + "S10.ADP", "S11.ADP", + "S12.ADP", "S13.ADP", + "S14.ADP", "S15.ADP", + "S16.ADP", "S17.ADP", + "S18.ADP" }; -ChangedHotspotStruct ChangedHotspot[256]; + void ReapplyChangedHotspot(void) { int i; - for (i = 0; iGetItemFromCode(ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(ChangedHotspot[i].nX, ChangedHotspot[i].nY)); + for (i = 0; i < GLOBALS.curChangedHotspot; i++) + GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { - f->writeByte(curChangedHotspot); - if (curChangedHotspot > 0) { - for (int i = 0; i < curChangedHotspot; ++i) - ChangedHotspot[i].Save(f); + f->writeByte(GLOBALS.curChangedHotspot); + if (GLOBALS.curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) + GLOBALS.ChangedHotspot[i].Save(f); } } void LoadChangedHotspot(Common::InSaveFile *f) { - curChangedHotspot = f->readByte(); + GLOBALS.curChangedHotspot = f->readByte(); - if (curChangedHotspot > 0) { - for (int i = 0; i < curChangedHotspot; ++i) - ChangedHotspot[i].Load(f); + if (GLOBALS.curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) + GLOBALS.ChangedHotspot[i].Load(f); } } @@ -271,51 +222,51 @@ void LoadChangedHotspot(Common::InSaveFile *f) { void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - MCharacter[i].item = Loc->GetItemFromCode(MCharacter[i].code); + GLOBALS.MCharacter[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[i].code); for (int i = 0; i < 10; i++) - Character[i].item = Loc->GetItemFromCode(Character[i].code); + GLOBALS.Character[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.Character[i].code); } void CharsSaveAll(Common::OutSaveFile *f) { for (int i = 0; i < 10; i++) { - f->writeByte(IsMChar[i]); - if (IsMChar[i]) { - MCharacter[i].Save(f); + f->writeByte(GLOBALS.IsMChar[i]); + if (GLOBALS.IsMChar[i]) { + GLOBALS.MCharacter[i].Save(f); } else { - Character[i].Save(f); + GLOBALS.Character[i].Save(f); } } } void CharsLoadAll(Common::InSaveFile *f) { for (int i = 0; i < 10; i++) { - IsMChar[i] = f->readByte(); - if (IsMChar[i]) - MCharacter[i].Load(f); + GLOBALS.IsMChar[i] = f->readByte(); + if (GLOBALS.IsMChar[i]) + GLOBALS.MCharacter[i].Load(f); else - Character[i].Load(f); + GLOBALS.Character[i].Load(f); } } DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDDOWN); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDDOWN); } DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDUP); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDUP); } DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDLEFT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDLEFT); } DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDRIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); } DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - SetPalesati(bStatus); + GLOBALS.SetPalesati(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { @@ -325,37 +276,37 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - if (!bSkipIdle) + if (!GLOBALS.bSkipIdle) CORO_INVOKE_1(CoroScheduler.sleep, dwTime); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { - bAlwaysDisplay = (val != 0); + GLOBALS.bAlwaysDisplay = (val != 0); } DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASU); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); break; case 2: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAGIU); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); break; case 3: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASINISTRA); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); break; case 4: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIADESTRA); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); break; case 5: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAMAPPA); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); break; default: - Pointer->SetSpecialPointer(Pointer->PTR_NONE); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); break; } } @@ -391,7 +342,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = 0; - if (bSkipIdle) return; + if (GLOBALS.bSkipIdle) return; _ctx->msg.Load(dwMessage); if (!_ctx->msg.IsValid()) { @@ -405,7 +356,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _ctx->curVoc->offset; // PRIMA VOLTA PREALLOCA - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); //fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -414,28 +365,28 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } - if (nTonyNextTalkType != Tony->TALK_NORMAL) { - CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); + if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); - if (!bStaticTalk) - nTonyNextTalkType = Tony->TALK_NORMAL; + if (!GLOBALS.bStaticTalk) + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else { if (_ctx->msg.NumPeriods() > 1) - CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_FIANCHI); + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_FIANCHI); else - CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); } - if (curBackText) - CORO_INVOKE_0(curBackText->Hide); + if (GLOBALS.curBackText) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); - bTonyIsSpeaking = true; + GLOBALS.bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + _ctx->text.SetInput(GLOBALS.Input); // Allineamento _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); @@ -448,22 +399,22 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Setta la posizione if (nX == 0 && nY == 0) - _ctx->text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); + _ctx->text.SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); else - _ctx->text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); + _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); // Setta l'always display - if (bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } // Registra il testo - LinkGraphicTask(&_ctx->text); + GLOBALS.LinkGraphicTask(&_ctx->text); if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -473,12 +424,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->SetLoop(false); _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } } // Aspetta la fine della visualizzazione - _ctx->text.SetCustomSkipHandle(hSkipIdle); + _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); if (_ctx->curVoc) { @@ -488,17 +439,17 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - bTonyIsSpeaking = false; - if (curBackText) - curBackText->Show(); + GLOBALS.bTonyIsSpeaking = false; + if (GLOBALS.curBackText) + GLOBALS.curBackText->Show(); - CORO_INVOKE_0(Tony->EndTalk); + CORO_INVOKE_0(GLOBALS.Tony->EndTalk); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { - Boxes->ChangeBoxStatus(nLoc,nBox,nStatus); + GLOBALS.Boxes->ChangeBoxStatus(nLoc, nBox, nStatus); } @@ -509,15 +460,15 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui CORO_BEGIN_CODE(_ctx); - Freeze(); + GLOBALS.Freeze(); - curChangedHotspot = 0; + GLOBALS.curChangedHotspot = 0; if (bUseStartPos != 0) - LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else - LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - Unfreeze(); + GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? @@ -528,9 +479,6 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui } -RMPoint SFM_pt; -int SFM_nLoc; - DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { CORO_BEGIN_CONTEXT; RMMessage *msg; @@ -543,18 +491,18 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); - SFM_nLoc = Loc->TEMPGetNumLoc(); - SFM_pt = Tony->Position(); + GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); + GLOBALS.SFM_pt = GLOBALS.Tony->Position(); - if (bSkipIdle) + if (GLOBALS.bSkipIdle) return; - CORO_INVOKE_2(UnloadLocation, false, NULL); - Tony->Hide(); - Unfreeze(); + CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); + GLOBALS.Tony->Hide(); + GLOBALS.Unfreeze(); - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + _ctx->text.SetInput(GLOBALS.Input); // Allineamento _ctx->text.SetAlignType(RMText::HCENTER,RMText::VCENTER); @@ -578,11 +526,11 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->text.ForceTime(); // Registra il testo - LinkGraphicTask(&_ctx->clear); - LinkGraphicTask(&_ctx->text); + GLOBALS.LinkGraphicTask(&_ctx->clear); + GLOBALS.LinkGraphicTask(&_ctx->text); // Aspetta la fine della visualizzazione - _ctx->text.SetCustomSkipHandle(hSkipIdle); + _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } @@ -599,19 +547,19 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) CORO_BEGIN_CODE(_ctx); - LinkGraphicTask(&_ctx->clear); + GLOBALS.LinkGraphicTask(&_ctx->clear); - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { - Freeze(); - LoadLocation(SFM_nLoc,RMPoint(SFM_pt.x,SFM_pt.y),RMPoint(-1,-1)); + GLOBALS.Freeze(); + GLOBALS.LoadLocation(GLOBALS.SFM_nLoc,RMPoint(GLOBALS.SFM_pt.x,GLOBALS.SFM_pt.y),RMPoint(-1,-1)); if (!bNotEnableTony) - Tony->Show(); - Unfreeze(); + GLOBALS.Tony->Show(); + GLOBALS.Unfreeze(); MCharResetCodes(); ReapplyChangedHotspot(); @@ -630,10 +578,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 n CORO_END_CODE; } -bool bNoOcchioDiBue = false; - DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bNoOcchioDiBue = true; + GLOBALS.bNoOcchioDiBue = true; } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -642,16 +588,16 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - if (!bNoOcchioDiBue) { - InitWipe(1); - CORO_INVOKE_0(WaitWipeEnd); + if (!GLOBALS.bNoOcchioDiBue) { + GLOBALS.InitWipe(1); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } _vm->StopMusic(4); // On Exit e lascia freezzato - CORO_INVOKE_2(UnloadLocation, true, NULL); - Unfreeze(); + CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -664,45 +610,45 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); - if (!bNoOcchioDiBue) { - InitWipe(1); - CORO_INVOKE_0(WaitWipeEnd); + if (!GLOBALS.bNoOcchioDiBue) { + GLOBALS.InitWipe(1); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - if (lastTappeto != tappeti[nLoc]) { + if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { _vm->StopMusic(4); } // On Exit e lascia freezzato - CORO_INVOKE_2(UnloadLocation, true, NULL); + CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); - curChangedHotspot = 0; + GLOBALS.curChangedHotspot = 0; if (bUseStartPos != 0) - LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else - LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - if (lastTappeto != tappeti[nLoc]) { - lastTappeto = tappeti[nLoc]; - if (lastTappeto != 0) - _vm->PlayMusic(4, tappetiFile[lastTappeto], 0, true, 2000); + if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { + GLOBALS.lastTappeto = GLOBALS.tappeti[nLoc]; + if (GLOBALS.lastTappeto != 0) + _vm->PlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); } - if (!bNoOcchioDiBue) { - InitWipe(2); + if (!GLOBALS.bNoOcchioDiBue) { + GLOBALS.InitWipe(2); } - Unfreeze(); + GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); - if (!bNoOcchioDiBue) { - CORO_INVOKE_0(WaitWipeEnd); - CloseWipe(); + if (!GLOBALS.bNoOcchioDiBue) { + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + GLOBALS.CloseWipe(); } - bNoOcchioDiBue = false; + GLOBALS.bNoOcchioDiBue = false; // On Enter? if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -712,12 +658,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - StartLocPos[nLoc].Set(lX,lY); + GLOBALS.StartLocPos[nLoc].Set(lX,lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - saveTonyPos = Tony->Position(); - saveTonyLoc = Loc->TEMPGetNumLoc(); + GLOBALS.saveTonyPos = GLOBALS.Tony->Position(); + GLOBALS.saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); } DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -726,7 +672,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(ChangeLocation, saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); + CORO_INVOKE_4(ChangeLocation, GLOBALS.saveTonyLoc, GLOBALS.saveTonyPos.x, GLOBALS.saveTonyPos.y, 0); MCharResetCodes(); @@ -744,16 +690,16 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->StopNoAction(coroParam); + GLOBALS.Tony->StopNoAction(coroParam); } DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { - EnableGUI(); + GLOBALS.EnableGUI(); } DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { - DisableGUI(); + GLOBALS.DisableGUI(); } @@ -764,12 +710,12 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Take(nDirection, 0); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Take(nDirection, 0); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_END_CODE; } @@ -780,16 +726,16 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Take(nDirection, 1); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Take(nDirection, 1); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); - Freeze(); - Tony->Take(nDirection,2); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Take(nDirection,2); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -800,12 +746,12 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Put(nDirection, 0); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Put(nDirection, 0); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_END_CODE; } @@ -816,16 +762,16 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Put(nDirection,1); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Put(nDirection,1); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); - Freeze(); - Tony->Put(nDirection,2); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Put(nDirection,2); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -890,9 +836,9 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - Tony->SetPattern(Tony->PAT_PERTERRALEFT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRALEFT); else - Tony->SetPattern(Tony->PAT_PERTERRARIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { @@ -902,18 +848,18 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - Tony->SetPattern(Tony->PAT_SIRIALZALEFT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); else - Tony->SetPattern(Tony->PAT_SIRIALZARIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - Tony->SetPastorella(bIsPast); + GLOBALS.Tony->SetPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -922,104 +868,104 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); - Tony->SetPattern(Tony->PAT_STANDRIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); CORO_END_CODE; } void TonySetNumTexts(uint32 dwText) { - dwTonyNumTexts=dwText; - bTonyInTexts = false; + GLOBALS.dwTonyNumTexts = dwText; + GLOBALS.bTonyInTexts = false; } DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_RIDE; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE; } DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_RIDE2; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE2; } DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_FIANCHI; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_FIANCHI; } DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CANTA; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CANTA; } DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SIINDICA; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SIINDICA; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SPAVENTATO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SPAVENTATO2; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO2; } DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONMARTELLO; - Tony->SetPattern(Tony->PAT_CONMARTELLO); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMARTELLO; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONMARTELLO); } DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONBICCHIERE; - Tony->SetPattern(Tony->PAT_CONBICCHIERE); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBICCHIERE; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONBICCHIERE); } DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONVERME; - Tony->SetPattern(Tony->PAT_CONVERME); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONVERME; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONVERME); } DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONCORDA; - Tony->SetPattern(Tony->PAT_CONCORDA); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCORDA; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONCORDA); } DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONSEGRETARIA; - Tony->SetPattern(Tony->PAT_CONSEGRETARIA); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONSEGRETARIA; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); } DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONCONIGLIO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIO; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONRICETTA; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTA; } DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONCARTE; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTE; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONPUPAZZO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZO; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1028,9 +974,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONPUPAZZOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); CORO_END_CODE; } @@ -1041,9 +987,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONPUPAZZOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1054,9 +1000,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCONIGLIOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); CORO_END_CODE; } @@ -1067,9 +1013,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCONIGLIOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1080,9 +1026,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONRICETTASTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTASTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); CORO_END_CODE; } @@ -1093,9 +1039,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONRICETTASTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1106,9 +1052,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCARTESTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTESTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); CORO_END_CODE; } @@ -1119,9 +1065,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCARTESTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1132,9 +1078,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONTACCUINOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONTACCUINOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); CORO_END_CODE; } @@ -1145,9 +1091,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONTACCUINOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1158,9 +1104,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONMEGAFONOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMEGAFONOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); CORO_END_CODE; } @@ -1171,9 +1117,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONMEGAFONOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1184,9 +1130,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONBARBASTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBARBASTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); CORO_END_CODE; } @@ -1197,9 +1143,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONBARBASTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1210,9 +1156,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_SPAVENTATOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); CORO_END_CODE; } @@ -1223,9 +1169,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_SPAVENTATOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1233,7 +1179,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SCHIFATO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SCHIFATO; } DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1242,8 +1188,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); - CORO_INVOKE_0(Tony->WaitForEndPattern); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1255,8 +1201,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); - CORO_INVOKE_0(Tony->WaitForEndPattern); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1264,48 +1210,48 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_NAAH; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NAAH; } DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { switch (nPos) { case 1: - nTonyNextTalkType = Tony->TALK_MACBETH1; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH1; break; case 2: - nTonyNextTalkType = Tony->TALK_MACBETH2; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH2; break; case 3: - nTonyNextTalkType = Tony->TALK_MACBETH3; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH3; break; case 4: - nTonyNextTalkType = Tony->TALK_MACBETH4; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH4; break; case 5: - nTonyNextTalkType = Tony->TALK_MACBETH5; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH5; break; case 6: - nTonyNextTalkType = Tony->TALK_MACBETH6; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH6; break; case 7: - nTonyNextTalkType = Tony->TALK_MACBETH7; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH7; break; case 8: - nTonyNextTalkType = Tony->TALK_MACBETH8; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH8; break; case 9: - nTonyNextTalkType = Tony->TALK_MACBETH9; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH9; break; } } DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->Show(); + GLOBALS.Tony->Show(); } DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - Tony->Hide(bShowOmbra); + GLOBALS.Tony->Hide(bShowOmbra); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -1315,17 +1261,17 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uin CORO_BEGIN_CODE(_ctx); - _ctx->item = Loc->GetItemFromCode(nItem); + _ctx->item = GLOBALS.Loc->GetItemFromCode(nItem); - if (!bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->WaitForEndPattern, hSkipIdle); + if (!GLOBALS.bSkipIdle && _ctx->item != NULL) + CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { - Tony->SetPosition(RMPoint(nX, nY), nLoc); + GLOBALS.Tony->SetPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { @@ -1334,16 +1280,16 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->Move, RMPoint(nX, nY)); + CORO_INVOKE_1(GLOBALS.Tony->Move, RMPoint(nX, nY)); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndMovement); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndMovement); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(coroParam, RMPoint(nX, nY)); + GLOBALS.Tony->Move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1358,9 +1304,9 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; - _ctx->pt = Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Loc->ScrollPosition(); - while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; _ctx->pt.Offset((int32)sX, 0); @@ -1377,12 +1323,12 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->pt.Offset(0, -(int32)sY); } - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); - Freeze(); - Loc->SetScrollPosition(_ctx->pt); - Tony->SetScrollPosition(_ctx->pt); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetScrollPosition(_ctx->pt); + GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Unfreeze(); } CORO_END_CODE; @@ -1410,7 +1356,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->stepX = sX; _ctx->stepY = sY; - _ctx->startpt = Loc->ScrollPosition(); + _ctx->startpt = GLOBALS.Loc->ScrollPosition(); _ctx->dwStartTime = _vm->GetTime(); @@ -1419,7 +1365,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui else _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; - while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { _ctx->dwCurTime = _vm->GetTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1459,12 +1405,12 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt.Offset(0,-sY); } */ - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); - Freeze(); - Loc->SetScrollPosition(_ctx->pt); - Tony->SetScrollPosition(_ctx->pt); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetScrollPosition(_ctx->pt); + GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Unfreeze(); } @@ -1482,10 +1428,10 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt.y = _ctx->startpt.y - _ctx->dimy; } - Freeze(); - Loc->SetScrollPosition(_ctx->pt); - Tony->SetScrollPosition(_ctx->pt); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetScrollPosition(_ctx->pt); + GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1494,21 +1440,21 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; - for (i = 0; i < curChangedHotspot; i++) - if (ChangedHotspot[i].dwCode == dwCode) { - ChangedHotspot[i].nX=nX; - ChangedHotspot[i].nY=nY; + for (i = 0; i < GLOBALS.curChangedHotspot; i++) + if (GLOBALS.ChangedHotspot[i].dwCode == dwCode) { + GLOBALS.ChangedHotspot[i].nX=nX; + GLOBALS.ChangedHotspot[i].nY=nY; break; } - if (i == curChangedHotspot) { - ChangedHotspot[i].dwCode=dwCode; - ChangedHotspot[i].nX=nX; - ChangedHotspot[i].nY=nY; - curChangedHotspot++; + if (i == GLOBALS.curChangedHotspot) { + GLOBALS.ChangedHotspot[i].dwCode=dwCode; + GLOBALS.ChangedHotspot[i].nX=nX; + GLOBALS.ChangedHotspot[i].nY=nY; + GLOBALS.curChangedHotspot++; } - Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); + GLOBALS.Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); } @@ -1535,12 +1481,12 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 _ctx->diry = 1; while (_vm->GetTime() < _ctx->curTime + nScosse) { - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); - Freeze(); - Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Unfreeze(); _ctx->i = _vm->_randomSource.getRandomNumber(2); @@ -1550,10 +1496,10 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 _ctx->diry = -_ctx->diry; } - Freeze(); - Loc->SetFixedScroll(RMPoint(0, 0)); - Tony->SetFixedScroll(RMPoint(0, 0)); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetFixedScroll(RMPoint(0, 0)); + GLOBALS.Tony->SetFixedScroll(RMPoint(0, 0)); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1566,36 +1512,36 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); - Character[nChar].code = nCode; - Character[nChar].item = Loc->GetItemFromCode(nCode); - Character[nChar].r = 255; - Character[nChar].g = 255; - Character[nChar].b = 255; - Character[nChar].talkpattern = 0; - Character[nChar].starttalkpattern = 0; - Character[nChar].endtalkpattern = 0; - Character[nChar].standpattern = 0; + GLOBALS.Character[nChar].code = nCode; + GLOBALS.Character[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.Character[nChar].r = 255; + GLOBALS.Character[nChar].g = 255; + GLOBALS.Character[nChar].b = 255; + GLOBALS.Character[nChar].talkpattern = 0; + GLOBALS.Character[nChar].starttalkpattern = 0; + GLOBALS.Character[nChar].endtalkpattern = 0; + GLOBALS.Character[nChar].standpattern = 0; - IsMChar[nChar] = false; + GLOBALS.IsMChar[nChar] = false; } DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar<16); - Character[nChar].r = r; - Character[nChar].g = g; - Character[nChar].b = b; + GLOBALS.Character[nChar].r = r; + GLOBALS.Character[nChar].g = g; + GLOBALS.Character[nChar].b = b; } DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { assert(nChar<16); - Character[nChar].talkpattern = tp; - Character[nChar].standpattern = sp; + GLOBALS.Character[nChar].talkpattern = tp; + GLOBALS.Character[nChar].standpattern = sp; } DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { assert(nChar<16); - Character[nChar].starttalkpattern=sp; - Character[nChar].endtalkpattern=ep; + GLOBALS.Character[nChar].starttalkpattern=sp; + GLOBALS.Character[nChar].endtalkpattern=ep; } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { @@ -1615,40 +1561,40 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); - if (Character[nChar].starttalkpattern != 0) { - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].starttalkpattern); - Unfreeze(); + if (GLOBALS.Character[nChar].starttalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].starttalkpattern); + GLOBALS.Unfreeze(); - CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); } - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].talkpattern); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].talkpattern); + GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } - for (_ctx->i = 0; _ctx->i<_ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i<_ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { - curBackText = _ctx->text = new RMTextDialogScrolling(Loc); - if (bTonyIsSpeaking) - CORO_INVOKE_0(curBackText->Hide); + GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS.bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(Input); + _ctx->text->SetInput(GLOBALS.Input); // Skipping _ctx->text->SetSkipStatus(!bIsBack); @@ -1657,7 +1603,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - _ctx->text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); + _ctx->text->SetColor(GLOBALS.Character[nChar].r,GLOBALS.Character[nChar].g,GLOBALS.Character[nChar].b); // Scrive il testo _ctx->text->WriteText((*_ctx->msg)[_ctx->i],0); @@ -1666,13 +1612,13 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(_ctx->text); + GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1681,11 +1627,11 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } // Aspetta la fine della visualizzazione - _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { @@ -1695,83 +1641,81 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } - curBackText=NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; } - if (Character[nChar].endtalkpattern != 0) { - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].endtalkpattern); - Unfreeze(); - CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); + if (GLOBALS.Character[nChar].endtalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].endtalkpattern); + GLOBALS.Unfreeze(); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); } - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].standpattern); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].standpattern); + GLOBALS.Unfreeze(); delete _ctx->msg; CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - Inventory->AddItem(dwCode); + GLOBALS.Inventory->AddItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - Inventory->RemoveItem(dwCode); + GLOBALS.Inventory->RemoveItem(dwCode); } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - Inventory->ChangeItemStatus(dwCode,dwStatus); + GLOBALS.Inventory->ChangeItemStatus(dwCode,dwStatus); } - - /* * Mastri Personaggi */ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); - MCharacter[nChar].code=nCode; + GLOBALS.MCharacter[nChar].code=nCode; if (nCode== 0) - MCharacter[nChar].item=NULL; + GLOBALS.MCharacter[nChar].item=NULL; else - MCharacter[nChar].item=Loc->GetItemFromCode(nCode); - MCharacter[nChar].r=255; - MCharacter[nChar].g=255; - MCharacter[nChar].b=255; - MCharacter[nChar].x=-1; - MCharacter[nChar].y=-1; - MCharacter[nChar].bAlwaysBack = 0; + GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.MCharacter[nChar].r=255; + GLOBALS.MCharacter[nChar].g=255; + GLOBALS.MCharacter[nChar].b=255; + GLOBALS.MCharacter[nChar].x=-1; + GLOBALS.MCharacter[nChar].y=-1; + GLOBALS.MCharacter[nChar].bAlwaysBack = 0; for (int i = 0; i < 10; i++) - MCharacter[nChar].numtalks[i] = 1; + GLOBALS.MCharacter[nChar].numtalks[i] = 1; - MCharacter[nChar].curgroup = 0; + GLOBALS.MCharacter[nChar].curgroup = 0; - IsMChar[nChar] = true; + GLOBALS.IsMChar[nChar] = true; } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - MCharacter[nChar].item=Loc->GetItemFromCode(MCharacter[nChar].code); + GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); } DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); - MCharacter[nChar].x=nX; - MCharacter[nChar].y=nY; + GLOBALS.MCharacter[nChar].x=nX; + GLOBALS.MCharacter[nChar].y=nY; } DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); - MCharacter[nChar].r=r; - MCharacter[nChar].g=g; - MCharacter[nChar].b=b; + GLOBALS.MCharacter[nChar].r=r; + GLOBALS.MCharacter[nChar].g=g; + GLOBALS.MCharacter[nChar].b=b; } @@ -1779,7 +1723,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint3 assert(nChar < 10); assert(nGroup < 10); - MCharacter[nChar].numtalks[nGroup]=nTalks; + GLOBALS.MCharacter[nChar].numtalks[nGroup]=nTalks; } @@ -1788,20 +1732,20 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 n assert(nChar < 10); assert(nGroup < 10); - MCharacter[nChar].curgroup = nGroup; + GLOBALS.MCharacter[nChar].curgroup = nGroup; } DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); - MCharacter[nChar].numtexts=nTexts-1; - MCharacter[nChar].bInTexts = false; + GLOBALS.MCharacter[nChar].numtexts=nTexts-1; + GLOBALS.MCharacter[nChar].bInTexts = false; } DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); - MCharacter[nChar].bAlwaysBack=bAlwaysBack; + GLOBALS.MCharacter[nChar].bAlwaysBack=bAlwaysBack; } @@ -1825,21 +1769,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes assert(nChar < 10); - bIsBack |= MCharacter[nChar].bAlwaysBack ? 1 : 0; + bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; // Calcola la posizione del testo in base al frame corrente - if (MCharacter[nChar].x==-1) - _ctx->pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + if (GLOBALS.MCharacter[nChar].x==-1) + _ctx->pt=GLOBALS.MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-GLOBALS.Loc->ScrollPosition(); else - _ctx->pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); + _ctx->pt=RMPoint(GLOBALS.MCharacter[nChar].x,GLOBALS.MCharacter[nChar].y); // Parametro per le azioni speciali: random tra le parlate - _ctx->parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( - MCharacter[nChar].numtalks[MCharacter[nChar].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; // Cerca di eseguire la funzione custom per inizializzare la parlata - if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (GLOBALS.MCharacter[nChar].item) { + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1849,24 +1793,24 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { // Crea l'oggetto diverso se back o no if (bIsBack) { - curBackText=_ctx->text = new RMTextDialogScrolling(Loc); - if (bTonyIsSpeaking) - CORO_INVOKE_0(curBackText->Hide); + GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS.bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(Input); + _ctx->text->SetInput(GLOBALS.Input); // Skipping _ctx->text->SetSkipStatus(!bIsBack); @@ -1875,7 +1819,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - _ctx->text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); + _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r,GLOBALS.MCharacter[nChar].g,GLOBALS.MCharacter[nChar].b); // Scrive il testo _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); @@ -1884,13 +1828,13 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(_ctx->text); + GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1899,11 +1843,11 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } // Aspetta la fine della visualizzazione - _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { @@ -1912,15 +1856,15 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; } - curBackText = NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; delete _ctx->msg; } // Cerca di eseguire la funzione custom per chiudere la parlata - if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (GLOBALS.MCharacter[nChar].item) { + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1957,7 +1901,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato // con la SetAlwaysBack - if (nPers != 0 && IsMChar[nPers] && MCharacter[nPers].bAlwaysBack) + if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) _ctx->bIsBack = true; _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); @@ -1965,14 +1909,14 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); _ctx->voice->SetLoop(false); if (_ctx->bIsBack) _ctx->voice->SetVolume(55); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } _ctx->string = mpalQueryDialogPeriod(nMsg); @@ -1980,89 +1924,89 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; _ctx->text->SetColor(0,255,0); - _ctx->text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); + _ctx->text->SetPosition(GLOBALS.Tony->Position()-RMPoint(0,130)-GLOBALS.Loc->ScrollPosition()); _ctx->text->WriteText(_ctx->string,0); - if (dwTonyNumTexts > 0) { - if (!bTonyInTexts) { - if (nTonyNextTalkType != Tony->TALK_NORMAL) { - CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); - if (!bStaticTalk) - nTonyNextTalkType = Tony->TALK_NORMAL; + if (GLOBALS.dwTonyNumTexts > 0) { + if (!GLOBALS.bTonyInTexts) { + if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + if (!GLOBALS.bStaticTalk) + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else - CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); - bTonyInTexts = true; + GLOBALS.bTonyInTexts = true; } - dwTonyNumTexts--; + GLOBALS.dwTonyNumTexts--; } else { - CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); - if (!bStaticTalk) - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + if (!GLOBALS.bStaticTalk) + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } - } else if (!IsMChar[nPers]) { + } else if (!GLOBALS.IsMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); - if (Character[nPers].starttalkpattern != 0) { - Freeze(); - Character[nPers].item->SetPattern(Character[nPers].starttalkpattern); - Unfreeze(); - CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); + if (GLOBALS.Character[nPers].starttalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS.Unfreeze(); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); } - Character[nPers].item->SetPattern(Character[nPers].talkpattern); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); - _ctx->text->SetColor(Character[nPers].r, Character[nPers].g,Character[nPers].b); + _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g,GLOBALS.Character[nPers].b); _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } else { - if (MCharacter[nPers].x == -1) - _ctx->pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + if (GLOBALS.MCharacter[nPers].x == -1) + _ctx->pt = GLOBALS.MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); else - _ctx->pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); + _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); // Parametro per le azioni speciali: random tra le parlate - _ctx->parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( - MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; - if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { - MCharacter[nPers].numtexts--; + if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { + GLOBALS.MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - MCharacter[nPers].curTalk = _ctx->parm; + GLOBALS.MCharacter[nPers].curTalk = _ctx->parm; - if (MCharacter[nPers].numtexts != 0) { - MCharacter[nPers].bInTexts = true; - MCharacter[nPers].numtexts--; + if (GLOBALS.MCharacter[nPers].numtexts != 0) { + GLOBALS.MCharacter[nPers].bInTexts = true; + GLOBALS.MCharacter[nPers].numtexts--; } } - if (MCharacter[nPers].bAlwaysBack) { - _ctx->text = curBackText = new RMTextDialogScrolling(Loc); - if (bTonyIsSpeaking) - CORO_INVOKE_0(curBackText->Hide); + if (GLOBALS.MCharacter[nPers].bAlwaysBack) { + _ctx->text = GLOBALS.curBackText = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS.bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; - _ctx->text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); - _ctx->text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); + _ctx->text->SetSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); + _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r,GLOBALS.MCharacter[nPers].g,GLOBALS.MCharacter[nPers].b); _ctx->text->WriteText(_ctx->string,0); _ctx->text->SetPosition(_ctx->pt); } - if (!bSkipIdle) { - _ctx->text->SetInput(Input); - if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (!GLOBALS.bSkipIdle) { + _ctx->text->SetInput(GLOBALS.Input); + if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - LinkGraphicTask(_ctx->text); + GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { _ctx->voice->Play(); @@ -2070,7 +2014,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } // Aspetta la fine della visualizzazione - _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } @@ -2081,36 +2025,36 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (nPers != 0) { - if (!IsMChar[nPers]) { - if (Character[nPers].endtalkpattern != 0) { - Freeze(); - Character[nPers].item->SetPattern(Character[nPers].endtalkpattern); - Unfreeze(); - CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); + if (!GLOBALS.IsMChar[nPers]) { + if (GLOBALS.Character[nPers].endtalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].endtalkpattern); + GLOBALS.Unfreeze(); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); } - Character[nPers].item->SetPattern(Character[nPers].standpattern); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].standpattern); delete _ctx->text; } else { - if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { + if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts== 0) || !GLOBALS.MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata - MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk%10) + GLOBALS.MCharacter[nPers].curgroup*10; + _ctx->h = mpalQueryDoAction(31,GLOBALS.MCharacter[nPers].item->MpalCode(),GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - MCharacter[nPers].bInTexts = false; - MCharacter[nPers].numtexts = 0; + GLOBALS.MCharacter[nPers].bInTexts = false; + GLOBALS.MCharacter[nPers].numtexts = 0; } - curBackText = NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; } } else { - if ((dwTonyNumTexts== 0 && bTonyInTexts) || !bTonyInTexts) { - CORO_INVOKE_0(Tony->EndTalk); - dwTonyNumTexts = 0; - bTonyInTexts = false; + if ((GLOBALS.dwTonyNumTexts== 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { + CORO_INVOKE_0(GLOBALS.Tony->EndTalk); + GLOBALS.dwTonyNumTexts = 0; + GLOBALS.bTonyInTexts = false; } delete _ctx->text; @@ -2172,18 +2116,18 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Attiva l'oggetto - LinkGraphicTask(&_ctx->dc); + GLOBALS.LinkGraphicTask(&_ctx->dc); CORO_INVOKE_0(_ctx->dc.Show); // Disegna il puntatore - Pointer->SetSpecialPointer(Pointer->PTR_NONE); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); - while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { - CORO_INVOKE_0(WaitFrame); - Freeze(); - CORO_INVOKE_1(_ctx->dc.DoFrame, Input->MousePos()); - Unfreeze(); + while (!(GLOBALS.Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { + CORO_INVOKE_0(GLOBALS.WaitFrame); + GLOBALS.Freeze(); + CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->MousePos()); + GLOBALS.Unfreeze(); } // Nascondi il puntatore @@ -2243,10 +2187,6 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 * */ -int curSonoriz = 0; - -bool bFadeOutStop; - void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CONTEXT; int i; @@ -2286,14 +2226,14 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeOut Music"); - for (_ctx->i = 16; _ctx->i > 0 && !bFadeOutStop; _ctx->i--) { + for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS.bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) _vm->SetMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - if (!bFadeOutStop) + if (!GLOBALS.bFadeOutStop) _vm->SetMusicVolume(nChannel, 0); // Se uno stacchetto ferma tutto @@ -2308,16 +2248,16 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - CoroScheduler.createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS.curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bFadeOutStop = false; - CoroScheduler.createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); + GLOBALS.bFadeOutStop = false; + CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS.curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bFadeOutStop = false; + GLOBALS.bFadeOutStop = false; int channel = 2; CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } @@ -2328,7 +2268,7 @@ DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->StopMusic(curSonoriz); + _vm->StopMusic(GLOBALS.curSonoriz); } DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2336,12 +2276,12 @@ DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint } DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(curSonoriz, 0); + _vm->SetMusicVolume(GLOBALS.curSonoriz, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bFadeOutStop = true; - _vm->SetMusicVolume(curSonoriz, 64); + GLOBALS.bFadeOutStop = true; + _vm->SetMusicVolume(GLOBALS.curSonoriz, 64); } DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2352,135 +2292,26 @@ DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui _vm->SetMusicVolume(2, 64); } -struct MusicFileEntry { - const char *name; - int sync; -}; -const MusicFileEntry musicFiles[] = { -/* - { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, - { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, - { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, - { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, - { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, -*/ - { "00.ADP", 0 }, { "01.ADP", 0 }, - { "02.ADP", 0 }, { "03.ADP", 0 }, - { "04.ADP",0 }, { "05.ADP", 0 }, - { "06.ADP", 0 }, { "07.ADP", 0 }, - { "08.ADP", 2450 }, { "09.ADP", 0 }, - -/* - { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, - { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, - { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, - { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, - { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, -*/ - { "10.ADP", 0 }, { "11.ADP", 0 }, - { "12.ADP", 0 }, { "13.ADP", 0 }, - { "14.ADP", 0 }, { "15.ADP", 0 }, - { "16.ADP", 0 }, { "17.ADP", 0 }, - { "18.ADP", 0 }, { "19.ADP", 0 }, -/* - { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, - { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, - { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, - { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, - { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, -*/ - { "20.ADP", 0 }, { "21.ADP", 0 }, - { "22.ADP", 0 }, { "23.ADP", 0 }, - { "24.ADP", 0 }, { "25.ADP", 0 }, - { "26.ADP", 0 }, { "27.ADP", 0 }, - { "28.ADP", 1670 }, { "29.ADP", 0 }, -/* - { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, - { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, - { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, - { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, - { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, -*/ - { "30.ADP", 0 }, { "31.ADP", 0 }, - { "32.ADP", 2900 }, { "33.ADP", 0 }, - { "34.ADP", 0 }, { "35.ADP", 0 }, - { "36.ADP", 0 }, { "37.ADP", 0 }, - { "38.ADP", 0 }, { "39.ADP", 0 }, -/* - { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, - { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, - { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, - { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, - { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, -*/ - { "40.ADP", 0 }, { "41.ADP", 1920 }, - { "42.ADP", 1560 }, { "43.ADP", 1920 }, - { "44.ADP", 1920 }, { "45.ADP", 1920 }, - { "46.ADP", 1920 }, { "47.ADP", 1920 }, - { "48.ADP", 1920 }, { "49.ADP", 1920 }, - -/* - { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, - { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, - { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, - { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, - { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } -*/ - { "50.ADP", 1920 }, { "51.ADP", 1920 }, - { "52.ADP", 1920 }, { "53.ADP", 0 }, - { "54.ADP", 0 }, { "55.ADP", 0 }, - { "56.ADP", 0 }, { "57.ADP", 0 }, - { "58.ADP", 0 }, { "59.ADP", 0 } -}; - - -const char *staccFileNames[] = { -/* - "05-MUCCA.ADP", "06-HALOW.ADP", - "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", - "LETTERAFINE.ADP", "PREGAME2.ADP", - "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", - "15-SHOTTONY.ADP", "27-ZUCC2.ADP", -*/ - "S00.ADP", "S01.ADP", - "S02.ADP", "S03.ADP", - "S04.ADP", "S05.ADP", - "S06.ADP", "S07.ADP", - "S08.ADP", "S09.ADP", - -/* - "53-DLOGO.ADP", "16-DIALOG1.ADP", - "TORRE1.ADP", "GARG1.ADP", - "LORENZ1.ADP", "24-FIGHT.ADP", - "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", - "GATTO1.ADP" -*/ - "S10.ADP", "S11.ADP", - "S12.ADP", "S13.ADP", - "S14.ADP", "S15.ADP", - "S16.ADP", "S17.ADP", - "S18.ADP" -}; void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; debug("Start CustPlayMusic"); - PlayMusic(nChannel, mFN, nFX, bLoop, nSync); + GLOBALS.PlayMusic(nChannel, mFN, nFX, bLoop, nSync); debug("End CustPlayMusic"); } DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX==2) { debug("PlaySonoriz stop fadeout"); - bFadeOutStop = true; + GLOBALS.bFadeOutStop = true; } - lastMusic = nMusic; - CustPlayMusic(curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); + GLOBALS.lastMusic = nMusic; + CustPlayMusic(GLOBALS.curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { @@ -2489,9 +2320,9 @@ DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, u DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem== 0) { - Tony->PlaySfx(nSFX); + GLOBALS.Tony->PlaySfx(nSFX); } else { - RMItem *item = Loc->GetItemFromCode(nItem); + RMItem *item = GLOBALS.Loc->GetItemFromCode(nItem); if (item) item->PlaySfx(nSFX); } @@ -2504,22 +2335,22 @@ void RestoreMusic(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(PlaySonoriz, lastMusic, 0, 0, 0); + CORO_INVOKE_4(PlaySonoriz, GLOBALS.lastMusic, 0, 0, 0); - if (lastTappeto != 0) - CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); + if (GLOBALS.lastTappeto != 0) + CustPlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true); CORO_END_CODE; } void SaveMusic(Common::OutSaveFile *f) { - f->writeByte(lastMusic); - f->writeByte(lastTappeto); + f->writeByte(GLOBALS.lastMusic); + f->writeByte(GLOBALS.lastTappeto); } void LoadMusic(Common::InSaveFile *f) { - lastMusic = f->readByte(); - lastTappeto = f->readByte(); + GLOBALS.lastMusic = f->readByte(); + GLOBALS.lastTappeto = f->readByte(); } @@ -2553,17 +2384,17 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bSkipIdle = true; - CoroScheduler.setEvent(hSkipIdle); + GLOBALS.bSkipIdle = true; + CoroScheduler.setEvent(GLOBALS.hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bSkipIdle = false; - CoroScheduler.resetEvent(hSkipIdle); + GLOBALS.bSkipIdle = false; + CoroScheduler.resetEvent(GLOBALS.hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - bPatIrqFreeze = bStatus; + GLOBALS.bPatIrqFreeze = bStatus; } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2572,9 +2403,9 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); - Freeze(); + GLOBALS.Freeze(); CORO_INVOKE_0(_vm->OpenInitLoadMenu); - Unfreeze(); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2585,9 +2416,9 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - Freeze(); + GLOBALS.Freeze(); CORO_INVOKE_0(_vm->OpenInitOptions); - Unfreeze(); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2610,7 +2441,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { - _ctx->text[_ctx->i].SetInput(Input); + _ctx->text[_ctx->i].SetInput(GLOBALS.Input); // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { @@ -2633,14 +2464,14 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); // Registra il testo - LinkGraphicTask(&_ctx->text[_ctx->i]); + GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } _ctx->startTime = _vm->GetTime(); while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { - CORO_INVOKE_0(WaitFrame); - if (Input->MouseLeftClicked() || Input->MouseRightClicked()) + CORO_INVOKE_0(GLOBALS.WaitFrame); + if (GLOBALS.Input->MouseLeftClicked() || GLOBALS.Input->MouseRightClicked()) break; if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; @@ -2648,8 +2479,8 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CoroScheduler.setEvent(_ctx->hDisable); - CORO_INVOKE_0(WaitFrame); - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); delete[] _ctx->text; delete _ctx->msg; @@ -2809,77 +2640,76 @@ BEGIN_CUSTOM_FUNCTION_MAP() END_CUSTOM_FUNCTION_MAP() void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { - Tony = tony; - Pointer = ptr; - Boxes = box; - Loc = loc; - Inventory = inv; - Input = input; - - LoadLocation = MainLoadLocation; - UnloadLocation = MainUnloadLocation; - LinkGraphicTask = MainLinkGraphicTask; - Freeze = MainFreeze; - Unfreeze = MainUnfreeze; - WaitFrame = MainWaitFrame; - PlayMusic = MainPlayMusic; - InitWipe = MainInitWipe; - CloseWipe = MainCloseWipe; - WaitWipeEnd = MainWaitWipeEnd; - DisableGUI = MainDisableGUI; - EnableGUI = MainEnableGUI; - SetPalesati = MainSetPalesati; - - vdb = g_system->createMutex(); - - bAlwaysDisplay = false; + GLOBALS.Tony = tony; + GLOBALS.Pointer = ptr; + GLOBALS.Boxes = box; + GLOBALS.Loc = loc; + GLOBALS.Inventory = inv; + GLOBALS.Input = input; + + GLOBALS.LoadLocation = MainLoadLocation; + GLOBALS.UnloadLocation = MainUnloadLocation; + GLOBALS.LinkGraphicTask = MainLinkGraphicTask; + GLOBALS.Freeze = MainFreeze; + GLOBALS.Unfreeze = MainUnfreeze; + GLOBALS.WaitFrame = MainWaitFrame; + GLOBALS.PlayMusic = MainPlayMusic; + GLOBALS.InitWipe = MainInitWipe; + GLOBALS.CloseWipe = MainCloseWipe; + GLOBALS.WaitWipeEnd = MainWaitWipeEnd; + GLOBALS.DisableGUI = MainDisableGUI; + GLOBALS.EnableGUI = MainEnableGUI; + GLOBALS.SetPalesati = MainSetPalesati; + + GLOBALS.vdb = g_system->createMutex(); + + GLOBALS.bAlwaysDisplay = false; int i; - for (i = 0;i < 10; i++) +/* for (i = 0;i < 10; i++) cs[i] = g_system->createMutex(); -/* for (i = 0;i < 10; i++) mut[i] = CreateMutex(NULL, false, NULL); */ for (i = 0; i < 200; i++) - tappeti[i] = 0; - - tappeti[6] = T_GRILLI; - tappeti[7] = T_GRILLI; - tappeti[8] = T_GRILLIOV; - tappeti[10] = T_GRILLI; - tappeti[12] = T_GRILLI; - tappeti[13] = T_GRILLIOV; - tappeti[15] = T_GRILLI; - tappeti[16] = T_GRILLIVENTO; - tappeti[18] = T_GRILLI; - tappeti[19] = T_GRILLIVENTO; - tappeti[20] = T_GRILLI; - tappeti[23] = T_GRILLI; - tappeti[26] = T_MAREMETA; - tappeti[27] = T_GRILLI; - tappeti[28] = T_GRILLIVENTO; - tappeti[31] = T_GRILLI; - tappeti[33] = T_MARE; - tappeti[35] = T_MARE; - tappeti[36] = T_GRILLI; - tappeti[37] = T_GRILLI; - tappeti[40] = T_GRILLI; - tappeti[41] = T_GRILLI; - tappeti[42] = T_GRILLI; - tappeti[45] = T_GRILLI; - tappeti[51] = T_GRILLI; - tappeti[52] = T_GRILLIVENTO1; - tappeti[53] = T_GRILLI; - tappeti[54] = T_GRILLI; - tappeti[57] = T_VENTO; - tappeti[58] = T_VENTO; - tappeti[60] = T_VENTO; + GLOBALS.tappeti[i] = 0; + + GLOBALS.tappeti[6] = T_GRILLI; + GLOBALS.tappeti[7] = T_GRILLI; + GLOBALS.tappeti[8] = T_GRILLIOV; + GLOBALS.tappeti[10] = T_GRILLI; + GLOBALS.tappeti[12] = T_GRILLI; + GLOBALS.tappeti[13] = T_GRILLIOV; + GLOBALS.tappeti[15] = T_GRILLI; + GLOBALS.tappeti[16] = T_GRILLIVENTO; + GLOBALS.tappeti[18] = T_GRILLI; + GLOBALS.tappeti[19] = T_GRILLIVENTO; + GLOBALS.tappeti[20] = T_GRILLI; + GLOBALS.tappeti[23] = T_GRILLI; + GLOBALS.tappeti[26] = T_MAREMETA; + GLOBALS.tappeti[27] = T_GRILLI; + GLOBALS.tappeti[28] = T_GRILLIVENTO; + GLOBALS.tappeti[31] = T_GRILLI; + GLOBALS.tappeti[33] = T_MARE; + GLOBALS.tappeti[35] = T_MARE; + GLOBALS.tappeti[36] = T_GRILLI; + GLOBALS.tappeti[37] = T_GRILLI; + GLOBALS.tappeti[40] = T_GRILLI; + GLOBALS.tappeti[41] = T_GRILLI; + GLOBALS.tappeti[42] = T_GRILLI; + GLOBALS.tappeti[45] = T_GRILLI; + GLOBALS.tappeti[51] = T_GRILLI; + GLOBALS.tappeti[52] = T_GRILLIVENTO1; + GLOBALS.tappeti[53] = T_GRILLI; + GLOBALS.tappeti[54] = T_GRILLI; + GLOBALS.tappeti[57] = T_VENTO; + GLOBALS.tappeti[58] = T_VENTO; + GLOBALS.tappeti[60] = T_VENTO; // Crea l'evento per skippare le idle - hSkipIdle = CoroScheduler.createEvent(true, false); + GLOBALS.hSkipIdle = CoroScheduler.createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index f7f3fb3f8c..dee3c3228a 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2003,7 +2003,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { } if (time != NULL) - *time = 1000 + numchar * (11 - nCfgTextSpeed) * 14; + *time = 1000 + numchar * (11 - GLOBALS.nCfgTextSpeed) * 14; } void RMText::ClipOnScreen(RMGfxPrimitive *prim) { @@ -2128,8 +2128,8 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Frase NON di background if (m_bSkipStatus) { - if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) - if (bCfgTimerizedText) { + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (GLOBALS.bCfgTimerizedText) { if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2146,7 +2146,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } // Frase di background else { - if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2164,7 +2164,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { return; } - if (bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { + if (GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) @@ -2192,7 +2192,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p m_startTime = _vm->GetTime(); if (m_bShowed) { - if (bCfgSottotitoli || m_bAlwaysDisplay) { + if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; CORO_INVOKE_2(RMText::Draw, bigBuf, prim); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 758170c848..b21498a5e8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -62,32 +62,6 @@ namespace Tony { using namespace MPAL; -/****************************************/ -/* Variabili globali di configurazione */ -/****************************************/ - -// FIXME: Move into a class instance -bool bCfgInvLocked; -bool bCfgInvNoScroll; -bool bCfgTimerizedText; -bool bCfgInvUp; -bool bCfgAnni30; -bool bCfgAntiAlias; -bool bCfgSottotitoli; -bool bCfgTransparence; -bool bCfgInterTips; -bool bCfgDubbing; -bool bCfgMusic; -bool bCfgSFX; -int nCfgTonySpeed; -int nCfgTextSpeed; -int nCfgDubbingVolume; -int nCfgMusicVolume; -int nCfgSFXVolume; -bool bSkipSfxNoLoop; - -bool bPatIrqFreeze; - /****************************************/ /* Funzioni globali per la DLL Custom */ /****************************************/ @@ -699,57 +673,57 @@ void RMOptionScreen::InitState(CORO_PARAM) { if (m_nState == MENUGAME) { assert(m_ButtonGame_Lock == NULL); m_ButtonGame_Lock = new RMOptionButton(20008,RMPoint(176, 262), true); - m_ButtonGame_Lock->SetActiveState(bCfgInvLocked); + m_ButtonGame_Lock->SetActiveState(GLOBALS.bCfgInvLocked); assert(m_ButtonGame_TimerizedText == NULL); m_ButtonGame_TimerizedText = new RMOptionButton(20009,RMPoint(463, 273), true); - m_ButtonGame_TimerizedText->SetActiveState(!bCfgTimerizedText); + m_ButtonGame_TimerizedText->SetActiveState(!GLOBALS.bCfgTimerizedText); assert(m_ButtonGame_Scrolling == NULL); m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - m_ButtonGame_Scrolling->SetActiveState(bCfgInvNoScroll); + m_ButtonGame_Scrolling->SetActiveState(GLOBALS.bCfgInvNoScroll); assert(m_ButtonGame_InterUp == NULL); m_ButtonGame_InterUp = new RMOptionButton(20011,RMPoint(36, 258), true); - m_ButtonGame_InterUp->SetActiveState(bCfgInvUp); + m_ButtonGame_InterUp->SetActiveState(GLOBALS.bCfgInvUp); assert(m_SlideTextSpeed == NULL); - m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, nCfgTextSpeed); + m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); assert(m_SlideTonySpeed == NULL); - m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, nCfgTonySpeed); + m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); } // Menu Graphics else if (m_nState == MENUGFX) { assert(m_ButtonGfx_Anni30 == NULL); m_ButtonGfx_Anni30 = new RMOptionButton(20015,RMPoint(247, 178), true); - m_ButtonGfx_Anni30->SetActiveState(bCfgAnni30); + m_ButtonGfx_Anni30->SetActiveState(GLOBALS.bCfgAnni30); assert(m_ButtonGfx_AntiAlias == NULL); m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - m_ButtonGfx_AntiAlias->SetActiveState(!bCfgAntiAlias); + m_ButtonGfx_AntiAlias->SetActiveState(!GLOBALS.bCfgAntiAlias); assert(m_ButtonGfx_Sottotitoli == NULL); m_ButtonGfx_Sottotitoli = new RMOptionButton(20017,RMPoint(98, 82), true); - m_ButtonGfx_Sottotitoli->SetActiveState(!bCfgSottotitoli); + m_ButtonGfx_Sottotitoli->SetActiveState(!GLOBALS.bCfgSottotitoli); assert(m_ButtonGfx_Tips == NULL); m_ButtonGfx_Tips = new RMOptionButton(20018,RMPoint(431, 246), true); - m_ButtonGfx_Tips->SetActiveState(bCfgInterTips); + m_ButtonGfx_Tips->SetActiveState(GLOBALS.bCfgInterTips); assert(m_ButtonGfx_Trans == NULL); m_ButtonGfx_Trans = new RMOptionButton(20019,RMPoint(126, 271), true); - m_ButtonGfx_Trans->SetActiveState(!bCfgTransparence); + m_ButtonGfx_Trans->SetActiveState(!GLOBALS.bCfgTransparence); } else if (m_nState == MENUSOUND) { assert(m_SliderSound_Dubbing == NULL); - m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, nCfgDubbingVolume); + m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); assert(m_SliderSound_Music == NULL); - m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, nCfgMusicVolume); + m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); assert(m_SliderSound_SFX == NULL); - m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, nCfgSFXVolume); + m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); assert(m_ButtonSound_DubbingOn == NULL); m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - m_ButtonSound_DubbingOn->SetActiveState(bCfgDubbing); + m_ButtonSound_DubbingOn->SetActiveState(GLOBALS.bCfgDubbing); assert(m_ButtonSound_MusicOn == NULL); m_ButtonSound_MusicOn = new RMOptionButton(20034,RMPoint(338, 179), true); - m_ButtonSound_MusicOn->SetActiveState(bCfgMusic); + m_ButtonSound_MusicOn->SetActiveState(GLOBALS.bCfgMusic); assert(m_ButtonSound_SFXOn == NULL); m_ButtonSound_SFXOn = new RMOptionButton(20035,RMPoint(338, 283), true); - m_ButtonSound_SFXOn->SetActiveState(bCfgSFX); + m_ButtonSound_SFXOn->SetActiveState(GLOBALS.bCfgSFX); } } @@ -815,71 +789,71 @@ void RMOptionScreen::CloseState(void) { } if (m_nState == MENUGAME) { - bCfgInvLocked = m_ButtonGame_Lock->IsActive(); + GLOBALS.bCfgInvLocked = m_ButtonGame_Lock->IsActive(); delete m_ButtonGame_Lock; m_ButtonGame_Lock = NULL; - bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); + GLOBALS.bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); delete m_ButtonGame_TimerizedText; m_ButtonGame_TimerizedText = NULL; - bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); + GLOBALS.bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); delete m_ButtonGame_Scrolling; m_ButtonGame_Scrolling = NULL; - bCfgInvUp = m_ButtonGame_InterUp->IsActive(); + GLOBALS.bCfgInvUp = m_ButtonGame_InterUp->IsActive(); delete m_ButtonGame_InterUp; m_ButtonGame_InterUp = NULL; - nCfgTextSpeed = m_SlideTextSpeed->GetValue(); + GLOBALS.nCfgTextSpeed = m_SlideTextSpeed->GetValue(); delete m_SlideTextSpeed; m_SlideTextSpeed = NULL; - nCfgTonySpeed = m_SlideTonySpeed->GetValue(); + GLOBALS.nCfgTonySpeed = m_SlideTonySpeed->GetValue(); delete m_SlideTonySpeed; m_SlideTonySpeed = NULL; } else if (m_nState == MENUGFX) { - bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); + GLOBALS.bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); delete m_ButtonGfx_Anni30; m_ButtonGfx_Anni30 = NULL; - bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); + GLOBALS.bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); delete m_ButtonGfx_AntiAlias; m_ButtonGfx_AntiAlias = NULL; - bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); + GLOBALS.bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); delete m_ButtonGfx_Sottotitoli; m_ButtonGfx_Sottotitoli = NULL; - bCfgInterTips = m_ButtonGfx_Tips->IsActive(); + GLOBALS.bCfgInterTips = m_ButtonGfx_Tips->IsActive(); delete m_ButtonGfx_Tips; m_ButtonGfx_Tips = NULL; - bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); + GLOBALS.bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); delete m_ButtonGfx_Trans; m_ButtonGfx_Trans = NULL; } else if (m_nState == MENUSOUND) { - nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); + GLOBALS.nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); delete m_SliderSound_Dubbing; m_SliderSound_Dubbing = NULL; - nCfgMusicVolume = m_SliderSound_Music->GetValue(); + GLOBALS.nCfgMusicVolume = m_SliderSound_Music->GetValue(); delete m_SliderSound_Music; m_SliderSound_Music = NULL; - nCfgSFXVolume = m_SliderSound_SFX->GetValue(); + GLOBALS.nCfgSFXVolume = m_SliderSound_SFX->GetValue(); delete m_SliderSound_SFX; m_SliderSound_SFX = NULL; - bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); + GLOBALS.bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); delete m_ButtonSound_DubbingOn; m_ButtonSound_DubbingOn = NULL; - bCfgMusic = m_ButtonSound_MusicOn->IsActive(); + GLOBALS.bCfgMusic = m_ButtonSound_MusicOn->IsActive(); delete m_ButtonSound_MusicOn; m_ButtonSound_MusicOn = NULL; - bCfgSFX = m_ButtonSound_SFXOn->IsActive(); + GLOBALS.bCfgSFX = m_ButtonSound_SFXOn->IsActive(); delete m_ButtonSound_SFXOn; m_ButtonSound_SFXOn = NULL; } @@ -1261,19 +1235,19 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { if (m_nState == MENUGFX) { // Queste opzioni hanno effetto immediato if (m_ButtonGfx_Anni30->IsActive()) - bCfgAnni30 = true; + GLOBALS.bCfgAnni30 = true; else - bCfgAnni30 = false; + GLOBALS.bCfgAnni30 = false; if (m_ButtonGfx_AntiAlias->IsActive()) - bCfgAntiAlias = false; + GLOBALS.bCfgAntiAlias = false; else - bCfgAntiAlias = true; + GLOBALS.bCfgAntiAlias = true; if (m_ButtonGfx_Trans->IsActive()) - bCfgTransparence = false; + GLOBALS.bCfgTransparence = false; else - bCfgTransparence = true; + GLOBALS.bCfgTransparence = true; } } } diff --git a/engines/tony/game.h b/engines/tony/game.h index 8cd64ec7d2..80482f39da 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -72,26 +72,6 @@ namespace Tony { (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ delete raw; -extern bool bCfgInvLocked; -extern bool bCfgInvNoScroll; -extern bool bCfgTimerizedText; -extern bool bCfgInvUp; -extern bool bCfgAnni30; -extern bool bCfgAntiAlias; -extern bool bCfgSottotitoli; -extern bool bCfgTransparence; -extern bool bCfgInterTips; -extern bool bCfgDubbing; -extern bool bCfgMusic; -extern bool bCfgSFX; -extern int nCfgTonySpeed; -extern int nCfgTextSpeed; -extern int nCfgDubbingVolume; -extern int nCfgMusicVolume; -extern int nCfgSFXVolume; -extern bool bSkipSfxNoLoop; - -extern bool bPatIrqFreeze; class RMPointer : public RMGfxTask { private: diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 49dd36cfe7..0c5ffa8096 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -47,6 +47,7 @@ #include "tony/gfxengine.h" #include "tony/mpal/mpalutils.h" +#include "tony/tony.h" namespace Tony { @@ -1437,7 +1438,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int int i, n; int r, g, b, r2, g2, b2; - if (!bCfgTransparence) { + if (!GLOBALS.bCfgTransparence) { RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); return; } @@ -1799,7 +1800,7 @@ void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); - if (bCfgAntiAlias) + if (GLOBALS.bCfgAntiAlias) DrawAA(bigBuf,prim); CORO_END_CODE; @@ -1837,7 +1838,7 @@ void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); - if (bCfgAntiAlias) + if (GLOBALS.bCfgAntiAlias) DrawAA(bigBuf,prim); CORO_END_CODE; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 8f7d27dafc..bf1a08f245 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -54,17 +54,11 @@ namespace Tony { -extern bool bIdleExited; -extern bool bPatIrqFreeze; -extern bool bSkipSfxNoLoop; - /****************************************************************************\ * Metodi di RMGfxEngine \****************************************************************************/ -bool bIdleExited; - void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -74,12 +68,12 @@ void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Chiude le idle - bSkipSfxNoLoop = true; + GLOBALS.bSkipSfxNoLoop = true; CORO_INVOKE_2(mpalEndIdlePoll, nCurLoc, NULL); - bIdleExited = true; - bSkipSfxNoLoop = false; + GLOBALS.bIdleExited = true; + GLOBALS.bSkipSfxNoLoop = false; CORO_END_CODE; } @@ -149,11 +143,11 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { // Esce la IDLE onde evitare la morte prematura in caricamento m_bMustEnterMenu = true; if (type == 1 || type == 2) { - bIdleExited = true; + GLOBALS.bIdleExited = true; } else { CORO_INVOKE_0(m_tony.StopNoAction); - bIdleExited = false; + GLOBALS.bIdleExited = false; CoroScheduler.createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); } @@ -173,10 +167,10 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Poll dei dispositivi di input m_input.Poll(); - if (m_bMustEnterMenu && bIdleExited) { + if (m_bMustEnterMenu && GLOBALS.bIdleExited) { m_bOption = true; m_bMustEnterMenu = false; - bIdleExited = false; + GLOBALS.bIdleExited = false; } if (m_bOption) { @@ -401,10 +395,10 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { item=This->m_loc.GetItemFromCode(dwItem); if (item != NULL) { if (nPattern!=-1) { - if (bPatIrqFreeze) + if (GLOBALS.bPatIrqFreeze) MainFreeze(); item->SetPattern(nPattern,true); - if (bPatIrqFreeze) + if (GLOBALS.bPatIrqFreeze) MainUnfreeze(); } if (nStatus!=-1) @@ -604,16 +598,16 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { - bPatIrqFreeze = true; + GLOBALS.bPatIrqFreeze = true; // GUI attivabile m_bGUIOption = true; m_bGUIInterface = true; m_bGUIInventory = true; - bSkipSfxNoLoop = false; + GLOBALS.bSkipSfxNoLoop = false; m_bMustEnterMenu = false; - bIdleExited = false; + GLOBALS.bIdleExited = false; m_bOption = false; m_bWiping = false; m_hWipeEvent = CoroScheduler.createEvent(false, false); @@ -806,23 +800,23 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo CharsSaveAll(f); // Save the options - f->writeByte(bCfgInvLocked); - f->writeByte(bCfgInvNoScroll); - f->writeByte(bCfgTimerizedText); - f->writeByte(bCfgInvUp); - f->writeByte(bCfgAnni30); - f->writeByte(bCfgAntiAlias); - f->writeByte(bCfgSottotitoli); - f->writeByte(bCfgTransparence); - f->writeByte(bCfgInterTips); - f->writeByte(bCfgDubbing); - f->writeByte(bCfgMusic); - f->writeByte(bCfgSFX); - f->writeByte(nCfgTonySpeed); - f->writeByte(nCfgTextSpeed); - f->writeByte(nCfgDubbingVolume); - f->writeByte(nCfgMusicVolume); - f->writeByte(nCfgSFXVolume); + f->writeByte(GLOBALS.bCfgInvLocked); + f->writeByte(GLOBALS.bCfgInvNoScroll); + f->writeByte(GLOBALS.bCfgTimerizedText); + f->writeByte(GLOBALS.bCfgInvUp); + f->writeByte(GLOBALS.bCfgAnni30); + f->writeByte(GLOBALS.bCfgAntiAlias); + f->writeByte(GLOBALS.bCfgSottotitoli); + f->writeByte(GLOBALS.bCfgTransparence); + f->writeByte(GLOBALS.bCfgInterTips); + f->writeByte(GLOBALS.bCfgDubbing); + f->writeByte(GLOBALS.bCfgMusic); + f->writeByte(GLOBALS.bCfgSFX); + f->writeByte(GLOBALS.nCfgTonySpeed); + f->writeByte(GLOBALS.nCfgTextSpeed); + f->writeByte(GLOBALS.nCfgDubbingVolume); + f->writeByte(GLOBALS.nCfgMusicVolume); + f->writeByte(GLOBALS.nCfgSFXVolume); // Save the hotspots SaveChangedHotspot(f); @@ -942,23 +936,23 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { if (_ctx->ver >= 6) { // Load options - bCfgInvLocked = _ctx->f->readByte(); - bCfgInvNoScroll = _ctx->f->readByte(); - bCfgTimerizedText = _ctx->f->readByte(); - bCfgInvUp = _ctx->f->readByte(); - bCfgAnni30 = _ctx->f->readByte(); - bCfgAntiAlias = _ctx->f->readByte(); - bCfgSottotitoli = _ctx->f->readByte(); - bCfgTransparence = _ctx->f->readByte(); - bCfgInterTips = _ctx->f->readByte(); - bCfgDubbing = _ctx->f->readByte(); - bCfgMusic = _ctx->f->readByte(); - bCfgSFX = _ctx->f->readByte(); - nCfgTonySpeed = _ctx->f->readByte(); - nCfgTextSpeed = _ctx->f->readByte(); - nCfgDubbingVolume = _ctx->f->readByte(); - nCfgMusicVolume = _ctx->f->readByte(); - nCfgSFXVolume = _ctx->f->readByte(); + GLOBALS.bCfgInvLocked = _ctx->f->readByte(); + GLOBALS.bCfgInvNoScroll = _ctx->f->readByte(); + GLOBALS.bCfgTimerizedText = _ctx->f->readByte(); + GLOBALS.bCfgInvUp = _ctx->f->readByte(); + GLOBALS.bCfgAnni30 = _ctx->f->readByte(); + GLOBALS.bCfgAntiAlias = _ctx->f->readByte(); + GLOBALS.bCfgSottotitoli = _ctx->f->readByte(); + GLOBALS.bCfgTransparence = _ctx->f->readByte(); + GLOBALS.bCfgInterTips = _ctx->f->readByte(); + GLOBALS.bCfgDubbing = _ctx->f->readByte(); + GLOBALS.bCfgMusic = _ctx->f->readByte(); + GLOBALS.bCfgSFX = _ctx->f->readByte(); + GLOBALS.nCfgTonySpeed = _ctx->f->readByte(); + GLOBALS.nCfgTextSpeed = _ctx->f->readByte(); + GLOBALS.nCfgDubbingVolume = _ctx->f->readByte(); + GLOBALS.nCfgMusicVolume = _ctx->f->readByte(); + GLOBALS.nCfgSFXVolume = _ctx->f->readByte(); // Load hotspots LoadChangedHotspot(_ctx->f); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp new file mode 100644 index 0000000000..c39ba215b4 --- /dev/null +++ b/engines/tony/globals.cpp @@ -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. + * + */ + +#include "tony/globals.h" + +namespace Tony { + +Globals::Globals() { + nextLoop = false; + nextChannel = 0; + nextSync = 0; + curChannel = 0; + flipflop = 0; + curBackText = NULL; + Tony = NULL; + Pointer = NULL; + Boxes = NULL; + Loc = NULL; + Inventory = NULL; + Input = NULL; + LoadLocation = NULL; + UnloadLocation = NULL; + LinkGraphicTask = NULL; + Freeze = NULL; + Unfreeze = NULL; + WaitFrame = NULL; + PlayMusic = NULL; + WaitWipeEnd = NULL; + CloseWipe = NULL; + InitWipe = NULL; + EnableGUI = NULL; + DisableGUI = NULL; + SetPalesati = NULL; + + dwTonyNumTexts = 0; + bTonyInTexts = false; + bStaticTalk = false; + bPatIrqFreeze = false; + bCfgInvLocked = false; + bCfgInvNoScroll = false; + bCfgTimerizedText = false; + bCfgInvUp = false; + bCfgAnni30 = false; + bCfgAntiAlias = false; + bCfgSottotitoli = false; + bCfgTransparence = false; + bCfgInterTips = false; + bCfgDubbing = false; + bCfgMusic = false; + bCfgSFX = false; + nCfgTonySpeed = 0; + nCfgTextSpeed = 0; + nCfgDubbingVolume = 0; + nCfgMusicVolume = 0; + nCfgSFXVolume = 0; + bIdleExited = false; + bSkipSfxNoLoop = false; + bNoOcchioDiBue = false; + curDialog = 0; + curSonoriz = 0; + bFadeOutStop = false; + +// OSystem::MutexRef cs[10]; +// OSystem::MutexRef vdb; + Common::fill(&mut[0], &mut[10], (HANDLE)NULL); + bSkipIdle = false; + hSkipIdle = 0; + lastMusic = 0; + lastTappeto = 0; + Common::fill(&tappeti[0], &tappeti[200], 0); + SFM_nLoc = 0; +} + +} // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h new file mode 100644 index 0000000000..7f6f8ed880 --- /dev/null +++ b/engines/tony/globals.h @@ -0,0 +1,232 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 TONY_GLOBALS +#define TONY_GLOBALS + +#include "common/savefile.h" +#include "tony/adv.h" +#include "tony/input.h" +#include "tony/inventory.h" +#include "tony/loc.h" +#include "tony/tonychar.h" + +namespace Tony { + +#define T_GRILLI 1 +#define T_GRILLIOV 2 +#define T_GRILLIVENTO 3 +#define T_GRILLIVENTO1 4 +#define T_VENTO 5 +#define T_MARE 6 +#define T_MAREMETA 7 + + +struct CharacterStruct { + uint32 code; + RMItem *item; + byte r, g, b; + int talkpattern; + int standpattern; + int starttalkpattern, endtalkpattern; + int numtexts; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(talkpattern); + f->writeUint32LE(standpattern); + f->writeUint32LE(starttalkpattern); + f->writeUint32LE(endtalkpattern); + f->writeUint32LE(numtexts); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + talkpattern = f->readUint32LE(); + standpattern = f->readUint32LE(); + starttalkpattern = f->readUint32LE(); + endtalkpattern = f->readUint32LE(); + numtexts = f->readUint32LE(); + } +}; + +struct MCharacterStruct { + uint32 code; + RMItem *item; + byte r, g, b; + int x, y; + int numtalks[10]; + int curgroup; + int numtexts; + bool bInTexts; + int curTalk; + bool bAlwaysBack; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(x); + f->writeUint32LE(y); + for (int i = 0; i < 10; ++i) + f->writeUint32LE(numtalks[i]); + f->writeUint32LE(curgroup); + f->writeUint32LE(numtexts); + f->writeByte(bInTexts); + f->writeUint32LE(curTalk); + f->writeByte(bAlwaysBack); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + x = f->readUint32LE(); + y = f->readUint32LE(); + for (int i = 0; i < 10; ++i) + numtalks[i] = f->readUint32LE(); + curgroup = f->readUint32LE(); + numtexts = f->readUint32LE(); + bInTexts = f->readByte(); + curTalk = f->readUint32LE(); + bAlwaysBack = f->readByte(); + } +}; + +struct ChangedHotspotStruct { + uint32 dwCode; + uint32 nX, nY; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(dwCode); + f->writeUint32LE(nX); + f->writeUint32LE(nY); + } + void Load(Common::InSaveFile *f) { + dwCode = f->readUint32LE(); + nX = f->readUint32LE(); + nY = f->readUint32LE(); + } +}; + +class Globals { +public: + Globals(); + + char nextMusic[MAX_PATH]; + bool nextLoop; + int nextChannel; + int nextSync; + int curChannel; + int flipflop; + // OSystem::MutexRef csMusic; + CharacterStruct Character[16]; + MCharacterStruct MCharacter[10]; + ChangedHotspotStruct ChangedHotspot[256]; + bool IsMChar[16]; + bool bAlwaysDisplay; + RMPoint saveTonyPos; + int saveTonyLoc; + RMTextDialog *curBackText; + bool bTonyIsSpeaking; + int curChangedHotspot; + bool bPatIrqFreeze; + bool bCfgInvLocked; + bool bCfgInvNoScroll; + bool bCfgTimerizedText; + bool bCfgInvUp; + bool bCfgAnni30; + bool bCfgAntiAlias; + bool bCfgSottotitoli; + bool bCfgTransparence; + bool bCfgInterTips; + bool bCfgDubbing; + bool bCfgMusic; + bool bCfgSFX; + int nCfgTonySpeed; + int nCfgTextSpeed; + int nCfgDubbingVolume; + int nCfgMusicVolume; + int nCfgSFXVolume; + bool bSkipSfxNoLoop; + bool bIdleExited; + bool bNoOcchioDiBue; + int curDialog; + int curSonoriz; + bool bFadeOutStop; + + RMTony *Tony; + RMPointer *Pointer; + RMGameBoxes *Boxes; + RMLocation *Loc; + RMInventory *Inventory; + RMInput *Input; + + uint32 (*LoadLocation)(int, RMPoint, RMPoint start); + void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); + void (*LinkGraphicTask)(RMGfxTask *task); + void (*Freeze)(void); + void (*Unfreeze)(void); + void (*WaitFrame)(CORO_PARAM); + void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); + void (*WaitWipeEnd)(CORO_PARAM); + void (*CloseWipe)(void); + void (*InitWipe)(int type); + void (*EnableGUI)(void); + void (*DisableGUI)(void); + void (*SetPalesati)(bool bpal); + + uint32 dwTonyNumTexts; + bool bTonyInTexts; + bool bStaticTalk; + RMTony::TALKTYPE nTonyNextTalkType; + + RMPoint StartLocPos[256]; + OSystem::MutexRef cs[10]; + OSystem::MutexRef vdb; + HANDLE mut[10]; + + bool bSkipIdle; + uint32 hSkipIdle; + + int lastMusic, lastTappeto; + + int tappeti[200]; + RMPoint SFM_pt; + int SFM_nLoc; +}; + +} // End of namespace Tony + +#endif // TONY_GLOBALS diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 468ec225a5..fbc0918e10 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -84,7 +84,7 @@ RMInventory::~RMInventory() { } bool RMInventory::CheckPointInside(const RMPoint &pt) { - if (!bCfgInvUp) + if (!GLOBALS.bCfgInvUp) return pt.y > RM_SY - 70; else return pt.y < 70; @@ -226,7 +226,7 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (m_state == SELECTING) { - if (!bCfgInvUp) { + if (!GLOBALS.bCfgInvUp) { _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); } else { @@ -240,7 +240,7 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr // Disegna l'interfaccina stupida CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); - if (bCfgInterTips) { + if (GLOBALS.bCfgInterTips) { if (miniAction == 1) // Esamina CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Parla @@ -563,7 +563,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { - bCfgInvLocked = !bCfgInvLocked; + GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } if (m_bCombining) {//m_state == COMBINING) @@ -571,9 +571,9 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); } - if (!bCfgInvUp) { - if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || bCfgInvLocked) && bCanOpen) { - if (!bCfgInvNoScroll) { + if (!GLOBALS.bCfgInvUp) { + if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = RM_SY - 1; m_curPutTime=_vm->GetTime(); @@ -582,8 +582,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_curPutY = RM_SY - 68; } } else if (m_state == OPENED) { - if ((mpos.y < RM_SY - 70 && !bCfgInvLocked) || !bCanOpen) { - if (!bCfgInvNoScroll) { + if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = RM_SY - 68; m_curPutTime = _vm->GetTime(); @@ -612,8 +612,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_state = CLOSED; } } else { - if ((m_state == CLOSED) && (mpos.y<10 || bCfgInvLocked) && bCanOpen) { - if (!bCfgInvNoScroll) { + if ((m_state == CLOSED) && (mpos.y<10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY =- 68; m_curPutTime = _vm->GetTime(); @@ -623,8 +623,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } else if (m_state == OPENED) { - if ((mpos.y>70 && !bCfgInvLocked) || !bCanOpen) { - if (!bCfgInvNoScroll) { + if ((mpos.y>70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = -2; m_curPutTime = _vm->GetTime(); @@ -657,7 +657,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo int startx = (m_nSelectObj + 1) * 64 - 20; int starty; - if (!bCfgInvUp) + if (!GLOBALS.bCfgInvUp) starty=RM_SY-109; else starty=70; @@ -828,7 +828,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _vm->PlayUtilSFX(1); } - if (bCfgInterTips) { + if (GLOBALS.bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 32754bbb51..306322f2ad 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -55,8 +55,6 @@ namespace Tony { using namespace ::Tony::MPAL; -extern bool bSkipSfxNoLoop; - /****************************************************************************\ * Metodi di RMPalette @@ -186,7 +184,7 @@ void RMPattern::StopSfx(RMSfx *sfx) { if (m_slots[i].m_type == SOUND) { if (sfx[m_slots[i].m_data].m_name[0] == '_') sfx[m_slots[i].m_data].Stop(); - else if (bSkipSfxNoLoop) + else if (GLOBALS.bSkipSfxNoLoop) sfx[m_slots[i].m_data].Stop(); } } diff --git a/engines/tony/module.mk b/engines/tony/module.mk index af0b3acd2c..6512391d04 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ game.o \ gfxcore.o \ gfxengine.o \ + globals.o \ input.o \ inventory.o \ loc.o \ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 01968ea579..53d3b962d2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -51,13 +51,6 @@ namespace Tony { -extern bool bCfgMusic; -extern bool bCfgSFX; -extern bool bCfgDubbing; -extern int nCfgSFXVolume; -extern int nCfgMusicVolume; -extern int nCfgDubbingVolume; - /****************************************************************************\ * Defines @@ -1527,15 +1520,15 @@ void FPSFX::SetVolume(int dwVolume) { lastVolume = dwVolume; if (bIsVoice) { - if (!bCfgDubbing) dwVolume = 0; + if (!GLOBALS.bCfgDubbing) dwVolume = 0; else { - dwVolume -= (10 - nCfgDubbingVolume) * 2; + dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; if (dwVolume<0) dwVolume = 0; } } else { - if (!bCfgSFX) dwVolume = 0; + if (!GLOBALS.bCfgSFX) dwVolume = 0; else { - dwVolume -= (10 - nCfgSFXVolume) * 2; + dwVolume -= (10 - GLOBALS.nCfgSFXVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } @@ -2273,9 +2266,9 @@ void FPSTREAM::SetVolume(int dwVolume) { lastVolume = dwVolume; - if (!bCfgMusic) dwVolume = 0; + if (!GLOBALS.bCfgMusic) dwVolume = 0; else { - dwVolume -= (10 - nCfgMusicVolume) * 2; + dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; if (dwVolume<0) dwVolume = 0; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 56b68419fd..1b4a11df0c 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -119,23 +119,23 @@ Common::ErrorCode TonyEngine::Init() { m_curThumbnail = new uint16[160 * 120]; // Configurazione di default - bCfgInvLocked = false; - bCfgInvNoScroll = false; - bCfgTimerizedText = true; - bCfgInvUp = false; - bCfgAnni30 = false; - bCfgAntiAlias = false; - bCfgTransparence = true; - bCfgInterTips = true; - bCfgSottotitoli = true; - nCfgTonySpeed = 3; - nCfgTextSpeed = 5; - bCfgDubbing = true; - bCfgMusic = true; - bCfgSFX = true; - nCfgDubbingVolume = 10; - nCfgMusicVolume = 7; - nCfgSFXVolume = 10; + GLOBALS.bCfgInvLocked = false; + GLOBALS.bCfgInvNoScroll = false; + GLOBALS.bCfgTimerizedText = true; + GLOBALS.bCfgInvUp = false; + GLOBALS.bCfgAnni30 = false; + GLOBALS.bCfgAntiAlias = false; + GLOBALS.bCfgTransparence = true; + GLOBALS.bCfgInterTips = true; + GLOBALS.bCfgSottotitoli = true; + GLOBALS.nCfgTonySpeed = 3; + GLOBALS.nCfgTextSpeed = 5; + GLOBALS.bCfgDubbing = true; + GLOBALS.bCfgMusic = true; + GLOBALS.bCfgSFX = true; + GLOBALS.nCfgDubbingVolume = 10; + GLOBALS.nCfgMusicVolume = 7; + GLOBALS.nCfgSFXVolume = 10; m_bQuitNow = false; return Common::kNoError; @@ -152,21 +152,12 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -char nextMusic[MAX_PATH]; -bool nextLoop; -int nextChannel; -int nextSync; -int curChannel; -int flipflop=0; -OSystem::MutexRef csMusic; - - void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { warning("TODO: TonyEngine::PlayMusic"); - g_system->lockMutex(csMusic); +// g_system->lockMutex(csMusic); if (nChannel < 4) - if (flipflop) + if (GLOBALS.flipflop) nChannel = nChannel + 1; switch (nFX) { @@ -243,7 +234,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in } #endif - g_system->unlockMutex(csMusic); +// g_system->unlockMutex(csMusic); } void TonyEngine::PlaySFX(int nChannel, int nFX) { @@ -264,14 +255,14 @@ void TonyEngine::PlaySFX(int nChannel, int nFX) { } void TonyEngine::StopMusic(int nChannel) { - g_system->lockMutex(csMusic); +// g_system->lockMutex(csMusic); if (nChannel < 4) - m_stream[nChannel+flipflop]->Stop(); + m_stream[nChannel + GLOBALS.flipflop]->Stop(); else m_stream[nChannel]->Stop(); - g_system->unlockMutex(csMusic); +// g_system->unlockMutex(csMusic); } void TonyEngine::StopSFX(int nChannel) { @@ -279,7 +270,7 @@ void TonyEngine::StopSFX(int nChannel) { } void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - if (m_utilSfx[nChannel]==NULL) + if (m_utilSfx[nChannel] == NULL) return; switch (nFX) { @@ -355,7 +346,7 @@ void TonyEngine::InitMusic() { } // Crea la critical section per la musica - csMusic = g_system->createMutex(); +// csMusic = g_system->createMutex(); // Carica effetti sonori // PreloadUtilSFX(0,"AccendiOpzione.ADP"); @@ -372,7 +363,7 @@ void TonyEngine::CloseMusic() { m_stream[i]->Release(); } - g_system->deleteMutex(csMusic); +// g_system->deleteMutex(csMusic); UnloadAllSFX(); UnloadAllUtilSFX(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 4a80970bb9..c1ad6756c2 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -38,6 +38,7 @@ #include "tony/loc.h" #include "tony/utils.h" #include "tony/window.h" +#include "tony/globals.h" /** * This is the namespace of the Tony engine. @@ -51,6 +52,8 @@ namespace Tony { using namespace MPAL; +class Globals; + enum { kTonyDebugAnimations = 1 << 0, kTonyDebugActions = 1 << 1, @@ -97,6 +100,7 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; + Globals _globals; enum DATADIR { DD_BASE = 1, @@ -209,6 +213,8 @@ public: // Global reference to the TonyEngine object extern TonyEngine *_vm; +#define GLOBALS _vm->_globals + } // End of namespace Tony #endif /* TONY_H */ diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 0e59779229..072e822c36 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -153,7 +153,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); - SetSpeed(nCfgTonySpeed); + SetSpeed(GLOBALS.nCfgTonySpeed); // Esegue il movimento normale del personaggio _ctx->time = _vm->GetTime(); -- cgit v1.2.3 From b01482bddb6d8f0b0be4dd46ee7c9e4141908673 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 23:05:41 +1000 Subject: TONY: Further globals added to Globals class --- engines/tony/font.cpp | 13 +++++-------- engines/tony/font.h | 2 +- engines/tony/globals.cpp | 1 + engines/tony/input.cpp | 5 ++--- engines/tony/loc.cpp | 2 +- engines/tony/sound.cpp | 8 ++++---- engines/tony/tony.cpp | 4 ++++ engines/tony/tonychar.cpp | 4 ++++ engines/tony/tonychar.h | 1 + engines/tony/window.cpp | 1 - 10 files changed, 23 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index dee3c3228a..8957c09a87 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1816,9 +1816,12 @@ void RMFontObj::Init(void) { \****************************************************************************/ RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; -OSystem::MutexRef RMText::m_cs; RMGfxClearTask RMText::m_clear; +void RMText::InitStatics() { + Common::fill(&m_fonts[0], &m_fonts[4], (RMFontColor *)NULL); +} + RMText::RMText() { // Colore di default: bianco m_r = m_g = m_b = 255; @@ -1843,8 +1846,6 @@ void RMText::Unload() { delete m_fonts[2]; delete m_fonts[3]; m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0; - - g_system->unlockMutex(m_cs); } } @@ -1866,13 +1867,9 @@ void RMText::WriteText(const RMString &text, int nFont, int *time) { m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); - - m_cs = g_system->createMutex(); } - g_system->lockMutex(m_cs); - WriteText(text,m_fonts[nFont],time); - g_system->unlockMutex(m_cs); + WriteText(text, m_fonts[nFont], time); } diff --git a/engines/tony/font.h b/engines/tony/font.h index a63c90638d..36fdc9baed 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -188,7 +188,6 @@ class RMText : public RMGfxWoodyBuffer { private: static RMFontColor *m_fonts[4]; static RMGfxClearTask m_clear; - static OSystem::MutexRef m_cs; int maxLineLength; public: @@ -216,6 +215,7 @@ protected: public: RMText(); virtual ~RMText(); + static void InitStatics(); static void Unload(); // Setta il tipo di allineamento diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index c39ba215b4..9bc9ea5d7c 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -88,6 +88,7 @@ Globals::Globals() { lastTappeto = 0; Common::fill(&tappeti[0], &tappeti[200], 0); SFM_nLoc = 0; + vdb = NULL; } } // End of namespace Tony diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index fcd56b5989..f29d4ddc8e 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,8 +49,6 @@ namespace Tony { -#define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } - RMInput::RMInput() { // Setup mouse fields _clampMouse = false; @@ -128,7 +126,8 @@ bool RMInput::MouseRight() { } /** - * Return true if a key has been pressed */ + * Return true if a key has been pressed + */ bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 306322f2ad..70e800a5d4 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -864,7 +864,7 @@ RMItem::~RMItem() { CoroScheduler.closeEvent(m_hEndPattern); } -//FIXME: Pass uint32 directly for hCustomSkip + void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; uint32 h[2]; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 53d3b962d2..61d225b88b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -113,8 +113,8 @@ public: class CODECADPCM : public CODECRAW { protected: byte *lpTemp; - static int indexTable[16]; - static int stepSizeTable[89]; + static const int indexTable[16]; + static const int stepSizeTable[89]; public: CODECADPCM(bool bLoop = true, byte *lpTempBuffer = NULL); @@ -298,12 +298,12 @@ uint32 CODECRAW::Decompress(Common::File &fp, void *buf, uint32 dwSize) { * Metodi per CODECADPCM \****************************************************************************/ -int CODECADPCM::indexTable[16] = { +const int CODECADPCM::indexTable[16] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8, }; -int CODECADPCM::stepSizeTable[89] = { +const int CODECADPCM::stepSizeTable[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 1b4a11df0c..aa110ce008 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -77,6 +77,10 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); + // Init static class fields + RMText::InitStatics(); + RMTony::InitStatics(); + // Reset the scheduler CoroScheduler.reset(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 072e822c36..7430ca89ae 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -59,6 +59,10 @@ namespace Tony { bool RMTony::m_bAction = false; +void RMTony::InitStatics() { + m_bAction = false; +} + RMTony::RMTony() { m_bShow = false; m_bShowOmbra = false; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index ee6d518f4b..27d62d9d57 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -378,6 +378,7 @@ public: // per farlo rialzare, altrimenti private }; public: + static void InitStatics(); RMTony(); // Inizializza Tony diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index f997b8c53d..18e6901547 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -53,7 +53,6 @@ namespace Tony { -#define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } /****************************************************************************\ * RMWindow Methods -- cgit v1.2.3 From 94f5a989873151d435f144de59bf06146a48a4b6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 23:44:08 +1000 Subject: TONY: Moved remaining globals to Globals class --- engines/tony/globals.cpp | 41 ++++ engines/tony/globals.h | 66 +++++++ engines/tony/mpal/expr.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 124 ++++++------ engines/tony/mpal/mpal.cpp | 438 +++++++++++++++++------------------------- engines/tony/mpal/mpaldll.h | 44 +---- 6 files changed, 354 insertions(+), 361 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 9bc9ea5d7c..0ce99f88e7 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -20,6 +20,7 @@ * */ +#include "common/algorithm.h" #include "tony/globals.h" namespace Tony { @@ -31,6 +32,8 @@ Globals::Globals() { curChannel = 0; flipflop = 0; curBackText = NULL; + bTonyIsSpeaking = false; + curChangedHotspot = 0; Tony = NULL; Pointer = NULL; Boxes = NULL; @@ -89,6 +92,44 @@ Globals::Globals() { Common::fill(&tappeti[0], &tappeti[200], 0); SFM_nLoc = 0; vdb = NULL; + + // MPAL global variables + mpalError = 0; + lpiifCustom = NULL; + lplpFunctions = NULL; + lplpFunctionStrings = NULL; + nObjs = 0; + nVars = 0; + hVars = NULL; + lpmvVars = NULL; + nMsgs = 0; + hMsgs = NULL; + lpmmMsgs = NULL; + nDialogs = 0; + hDialogs = NULL; + lpmdDialogs = NULL; + nItems = 0; + hItems = NULL; + lpmiItems = NULL; + nLocations = 0; + hLocations = NULL; + lpmlLocations = NULL; + nScripts = 0; + hScripts = NULL; + lpmsScripts = NULL; + nResources = 0; + lpResources = NULL; + bExecutingAction = false; + bExecutingDialog = false; + Common::fill(&nPollingLocations[0], &nPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&hEndPollingLocations[0], &hEndPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&PollingThreads[0], &PollingThreads[MAXPOLLINGLOCATIONS], 0); + hAskChoice = 0; + hDoneChoice = 0; + nExecutingAction = 0; + nExecutingDialog = 0; + nExecutingChoice = 0; + nSelectedChoice = 0; } } // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 7f6f8ed880..1a11a871d0 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -29,6 +29,8 @@ #include "tony/inventory.h" #include "tony/loc.h" #include "tony/tonychar.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/mpaldll.h" namespace Tony { @@ -140,6 +142,28 @@ struct ChangedHotspotStruct { } }; +/****************************************************************************\ +* typedef CFCALL +* -------------- +* Description: Descrizione di una chiamata a una custom function +\****************************************************************************/ + +typedef struct { + int nCf; + + int arg1, arg2, arg3, arg4; +} CFCALL; +typedef CFCALL* LPCFCALL; +typedef LPCFCALL* LPLPCFCALL; + + +/****************************************************************************\ +* Global variables +\****************************************************************************/ + +/** + * Globals class + */ class Globals { public: Globals(); @@ -225,6 +249,48 @@ public: int tappeti[200]; RMPoint SFM_pt; int SFM_nLoc; + + /** + * @defgroup MPAL variables + * + */ + uint32 mpalError; + LPITEMIRQFUNCTION lpiifCustom; + LPLPCUSTOMFUNCTION lplpFunctions; + Common::String * lplpFunctionStrings; + uint16 nObjs; + uint16 nVars; + HGLOBAL hVars; + LPMPALVAR lpmvVars; + uint16 nMsgs; + HGLOBAL hMsgs; + LPMPALMSG lpmmMsgs; + uint16 nDialogs; + HGLOBAL hDialogs; + LPMPALDIALOG lpmdDialogs; + uint16 nItems; + HGLOBAL hItems; + LPMPALITEM lpmiItems; + uint16 nLocations; + HGLOBAL hLocations; + LPMPALLOCATION lpmlLocations; + uint16 nScripts; + HGLOBAL hScripts; + LPMPALSCRIPT lpmsScripts; + Common::File hMpr; + uint16 nResources; + uint32 * lpResources; + bool bExecutingAction; + bool bExecutingDialog; + uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 PollingThreads[MAXPOLLINGLOCATIONS]; + uint32 hAskChoice; + uint32 hDoneChoice; + uint32 nExecutingAction; + uint32 nExecutingDialog; + uint32 nExecutingChoice; + uint32 nSelectedChoice; }; } // End of namespace Tony diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 0ca02d2931..19170ce60c 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -209,7 +209,7 @@ static int Compute(int a, int b, byte symbol) { case OP_OR: return a||b; default: - mpalError=1; + GLOBALS.mpalError = 1; break; } diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9d6ef19e55..937374517f 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -517,58 +517,58 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - nVars = READ_LE_UINT16(lpBuf); + GLOBALS.nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)nVars); - if (hVars == NULL) + GLOBALS.hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); + if (GLOBALS.hVars == NULL) return false; - lpmvVars = (LPMPALVAR)GlobalLock(hVars); + GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); - for (i = 0; i < nVars; i++) { + for (i = 0; i < GLOBALS.nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - CopyMemory(lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + CopyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS.lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Salta 'ext' - lpmvVars++; + GLOBALS.lpmvVars++; } - GlobalUnlock(hVars); + GlobalUnlock(GLOBALS.hVars); /* 2. Messaggi */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; lpBuf += 4; - nMsgs = READ_LE_UINT16(lpBuf); + GLOBALS.nMsgs = READ_LE_UINT16(lpBuf); lpBuf += 2; #ifdef NEED_LOCK_MSGS - hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)nMsgs); - if (hMsgs == NULL) + GLOBALS.hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); + if (GLOBALS.hMsgs == NULL) return false; - lpmmMsgs = (LPMPALMSG)GlobalLock(hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); #else - lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); - if (lpmmMsgs==NULL) + GLOBALS.lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)GLOBALS.nMsgs); + if (GLOBALS.lpmmMsgs==NULL) return false; #endif - for (i = 0; i < nMsgs; i++) { - lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); + for (i = 0; i < GLOBALS.nMsgs; i++) { + GLOBALS.lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); lpBuf += 2; for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)GlobalLock(lpmmMsgs->hText); + GLOBALS.lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)GlobalLock(GLOBALS.lpmmMsgs->hText); for (j = 0; lpBuf[j] != 0;) { CopyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); @@ -580,12 +580,12 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += j + 1; *lpTemp = '\0'; - GlobalUnlock(lpmmMsgs->hText); - lpmmMsgs++; + GlobalUnlock(GLOBALS.lpmmMsgs->hText); + GLOBALS.lpmmMsgs++; } #ifdef NEED_LOCK_MSGS - GlobalUnlock(hMsgs); + GlobalUnlock(GLOBALS.hMsgs); #endif /* 3. Oggetti */ @@ -593,96 +593,96 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - nObjs = READ_LE_UINT16(lpBuf); + GLOBALS.nObjs = READ_LE_UINT16(lpBuf); lpBuf += 2; // Controlla i dialoghi - nDialogs = 0; - hDialogs = lpmdDialogs = NULL; + GLOBALS.nDialogs = 0; + GLOBALS.hDialogs = GLOBALS.lpmdDialogs = NULL; if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { - nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nDialogs * sizeof(MPALDIALOG)); - if (hDialogs == NULL) + GLOBALS.hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); + if (GLOBALS.hDialogs == NULL) return false; - lpmdDialogs = (LPMPALDIALOG)GlobalLock(hDialogs); + GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); - for (i = 0;i < nDialogs; i++) - if ((lpBuf = ParseDialog(lpBuf + 7, &lpmdDialogs[i])) == NULL) + for (i = 0;i < GLOBALS.nDialogs; i++) + if ((lpBuf = ParseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) return false; - GlobalUnlock(hDialogs); + GlobalUnlock(GLOBALS.hDialogs); } // Controlla gli item - nItems = 0; - hItems = lpmiItems = NULL; + GLOBALS.nItems = 0; + GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; // Alloca la memoria e li legge - hItems=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nItems * sizeof(MPALITEM)); - if (hItems == NULL) + GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); + if (GLOBALS.hItems == NULL) return false; - lpmiItems=(LPMPALITEM)GlobalLock(hItems); + GLOBALS.lpmiItems=(LPMPALITEM)GlobalLock(GLOBALS.hItems); - for (i = 0; i < nItems; i++) - if ((lpBuf = ParseItem(lpBuf + 5, &lpmiItems[i])) == NULL) + for (i = 0; i < GLOBALS.nItems; i++) + if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) return false; - GlobalUnlock(hItems); + GlobalUnlock(GLOBALS.hItems); } // Controlla le locazioni - nLocations = 0; - hLocations = lpmlLocations = NULL; + GLOBALS.nLocations = 0; + GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { - nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; // Alloca la memoria e li legge - hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nLocations*sizeof(MPALLOCATION)); - if (hLocations == NULL) + GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); + if (GLOBALS.hLocations == NULL) return false; - lpmlLocations = (LPMPALLOCATION)GlobalLock(hLocations); + GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); - for (i = 0; i < nLocations; i++) - if ((lpBuf = ParseLocation(lpBuf + 9, &lpmlLocations[i])) == NULL) + for (i = 0; i < GLOBALS.nLocations; i++) + if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS.lpmlLocations[i])) == NULL) return false; - GlobalUnlock(hLocations); + GlobalUnlock(GLOBALS.hLocations); } // Controlla gli script - nScripts = 0; - hScripts = lpmsScripts = NULL; + GLOBALS.nScripts = 0; + GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; // Alloca la memoria - hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nScripts * sizeof(MPALSCRIPT)); - if (hScripts == NULL) + GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); + if (GLOBALS.hScripts == NULL) return false; - lpmsScripts = (LPMPALSCRIPT)GlobalLock(hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); - for (i = 0; i < nScripts; i++) { - if ((lpBuf = ParseScript(lpBuf + 7, &lpmsScripts[i])) == NULL) + for (i = 0; i < GLOBALS.nScripts; i++) { + if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) return false; // Ordina i vari moments dello script //qsort( - //lpmsScripts[i].Moment, - //lpmsScripts[i].nMoments, - //sizeof(lpmsScripts[i].Moment[0]), + //GLOBALS.lpmsScripts[i].Moment, + //GLOBALS.lpmsScripts[i].nMoments, + //sizeof(GLOBALS.lpmsScripts[i].Moment[0]), //(int (*)(const void *, const void *))CompareMoments //); } - GlobalUnlock(hScripts); + GlobalUnlock(GLOBALS.hScripts); } if (lpBuf[0] != 'E' || lpBuf[1] != 'N' || lpBuf[2] != 'D' || lpBuf[3] != '0') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index bfde7fe2a6..66d467f301 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -72,84 +72,6 @@ const char *mpalCopyright = "\n" "\n"; -/****************************************************************************\ -* Structures -\****************************************************************************/ - -/****************************************************************************\ -* typedef CFCALL -* -------------- -* Description: Descrizione di una chiamata a una custom function -\****************************************************************************/ - -typedef struct { - int nCf; - - int arg1, arg2, arg3, arg4; -} CFCALL; -typedef CFCALL* LPCFCALL; -typedef LPCFCALL* LPLPCFCALL; - - -/****************************************************************************\ -* Global variables -\****************************************************************************/ - -uint32 mpalError; - -static byte * lpMpcImage; - -LPITEMIRQFUNCTION lpiifCustom=NULL; - -LPLPCUSTOMFUNCTION lplpFunctions = NULL; -Common::String * lplpFunctionStrings = NULL; -uint16 nObjs; - -uint16 nVars; -HGLOBAL hVars; -LPMPALVAR lpmvVars; - -uint16 nMsgs; -HGLOBAL hMsgs; -LPMPALMSG lpmmMsgs; - -uint16 nDialogs; -HGLOBAL hDialogs; -LPMPALDIALOG lpmdDialogs; - -uint16 nItems; -HGLOBAL hItems; -LPMPALITEM lpmiItems; - -uint16 nLocations; -HGLOBAL hLocations; -LPMPALLOCATION lpmlLocations; - -uint16 nScripts; -HGLOBAL hScripts; -LPMPALSCRIPT lpmsScripts; - -Common::File hMpr; -uint16 nResources; -uint32 * lpResources; - -bool bExecutingAction; -bool bExecutingDialog; - -uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; -uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; -uint32 PollingThreads[MAXPOLLINGLOCATIONS]; - -uint32 hAskChoice; -uint32 hDoneChoice; - -uint32 nExecutingAction; - -uint32 nExecutingDialog; -uint32 nExecutingChoice; -uint32 nSelectedChoice; - - /****************************************************************************\ * Internal functions \****************************************************************************/ @@ -163,7 +85,7 @@ uint32 nSelectedChoice; \****************************************************************************/ void LockVar(void) { - lpmvVars=(LPMPALVAR)GlobalLock(hVars); + GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); } /****************************************************************************\ @@ -175,7 +97,7 @@ void LockVar(void) { \****************************************************************************/ void UnlockVar(void) { - GlobalUnlock(hVars); + GlobalUnlock(GLOBALS.hVars); } @@ -189,7 +111,7 @@ void UnlockVar(void) { static void LockMsg(void) { #ifdef NEED_LOCK_MSGS - lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); #endif } @@ -204,7 +126,7 @@ static void LockMsg(void) { static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS - GlobalUnlock(hMsgs); + GlobalUnlock(GLOBALS.hMsgs); #endif } @@ -218,7 +140,7 @@ static void UnlockMsg(void) { \****************************************************************************/ static void LockDialogs(void) { - lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); + GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); } @@ -231,7 +153,7 @@ static void LockDialogs(void) { \****************************************************************************/ static void UnlockDialogs(void) { - GlobalUnlock(hDialogs); + GlobalUnlock(GLOBALS.hDialogs); } @@ -244,7 +166,7 @@ static void UnlockDialogs(void) { \****************************************************************************/ static void LockLocations(void) { - lpmlLocations=(LPMPALLOCATION)GlobalLock(hLocations); + GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); } @@ -257,7 +179,7 @@ static void LockLocations(void) { \****************************************************************************/ static void UnlockLocations(void) { - GlobalUnlock(hLocations); + GlobalUnlock(GLOBALS.hLocations); } @@ -270,7 +192,7 @@ static void UnlockLocations(void) { \****************************************************************************/ static void LockItems(void) { - lpmiItems=(LPMPALITEM)GlobalLock(hItems); + GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); } @@ -283,7 +205,7 @@ static void LockItems(void) { \****************************************************************************/ static void UnlockItems(void) { - GlobalUnlock(hItems); + GlobalUnlock(GLOBALS.hItems); } /****************************************************************************\ @@ -295,7 +217,7 @@ static void UnlockItems(void) { \****************************************************************************/ static void LockScripts(void) { - lpmsScripts=(LPMPALSCRIPT)GlobalLock(hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); } @@ -308,7 +230,7 @@ static void LockScripts(void) { \****************************************************************************/ static void UnlockScripts(void) { - GlobalUnlock(hScripts); + GlobalUnlock(GLOBALS.hScripts); } @@ -330,13 +252,13 @@ static void UnlockScripts(void) { int32 varGetValue(const char *lpszVarName) { int i; - LPMPALVAR v=lpmvVars; + LPMPALVAR v=GLOBALS.lpmvVars; - for (i = 0; i < nVars; v++, i++) + for (i = 0; i < GLOBALS.nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; - mpalError = 1; + GLOBALS.mpalError = 1; return 0; } @@ -354,24 +276,24 @@ int32 varGetValue(const char *lpszVarName) { void varSetValue(const char *lpszVarName, int32 val) { uint i; - LPMPALVAR v = lpmvVars; + LPMPALVAR v = GLOBALS.lpmvVars; - for (i = 0; i < nVars; v++, i++) + for (i = 0; i < GLOBALS.nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) { v->dwVal = val; - if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { i = 0; sscanf(v->lpszVarName, "Pattern.%u", &i); - lpiifCustom(i, val, -1); - } else if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + GLOBALS.lpiifCustom(i, val, -1); + } else if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { i = 0; sscanf(v->lpszVarName,"Status.%u", &i); - lpiifCustom(i, -1, val); + GLOBALS.lpiifCustom(i, -1, val); } return; } - mpalError = 1; + GLOBALS.mpalError = 1; return; } @@ -394,9 +316,9 @@ void varSetValue(const char *lpszVarName, int32 val) { static int locGetOrderFromNum(uint32 nLoc) { int i; - LPMPALLOCATION loc = lpmlLocations; + LPMPALLOCATION loc = GLOBALS.lpmlLocations; - for (i = 0; i < nLocations; i++,loc++) + for (i = 0; i < GLOBALS.nLocations; i++, loc++) if (loc->nObj == nLoc) return i; @@ -421,9 +343,9 @@ static int locGetOrderFromNum(uint32 nLoc) { static int msgGetOrderFromNum(uint32 nMsg) { int i; - LPMPALMSG msg = lpmmMsgs; + LPMPALMSG msg = GLOBALS.lpmmMsgs; - for (i = 0; i < nMsgs; i++, msg++) + for (i = 0; i < GLOBALS.nMsgs; i++, msg++) if (msg->wNum == nMsg) return i; @@ -449,9 +371,9 @@ static int msgGetOrderFromNum(uint32 nMsg) { static int itemGetOrderFromNum(uint32 nItem) { int i; - LPMPALITEM item=lpmiItems; + LPMPALITEM item = GLOBALS.lpmiItems; - for (i = 0; i < nItems; i++, item++) + for (i = 0; i < GLOBALS.nItems; i++, item++) if (item->nObj == nItem) return i; @@ -477,9 +399,9 @@ static int itemGetOrderFromNum(uint32 nItem) { static int scriptGetOrderFromNum(uint32 nScript) { int i; - LPMPALSCRIPT script = lpmsScripts; + LPMPALSCRIPT script = GLOBALS.lpmsScripts; - for (i = 0; i < nScripts; i++,script++) + for (i = 0; i < GLOBALS.nScripts; i++, script++) if (script->nObj == nScript) return i; @@ -505,9 +427,9 @@ static int scriptGetOrderFromNum(uint32 nScript) { static int dialogGetOrderFromNum(uint32 nDialog) { int i; - LPMPALDIALOG dialog=lpmdDialogs; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs; - for (i = 0; i < nDialogs; i++, dialog++) + for (i = 0; i < GLOBALS.nDialogs; i++, dialog++) if (dialog->nObj == nDialog) return i; @@ -538,7 +460,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (nMsgOrd == (uint32)-1) return NULL; - origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); + origmsg = (const char *)GlobalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') @@ -550,7 +472,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { return NULL; CopyMemory(clonemsg, origmsg, j); - GlobalUnlock(lpmmMsgs[nMsgOrd].hText); + GlobalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); return clonemsg; } @@ -575,7 +497,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; int i,j; for (j = 0; dialog->Periods[j] != NULL; j++) @@ -623,28 +545,28 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i = 0; i < nResources; i++) - if (lpResources[i * 2] == dwId) { - hMpr.seek(lpResources[i * 2 + 1]); - nBytesRead = hMpr.read(head, 4); + for (i = 0; i < GLOBALS.nResources; i++) + if (GLOBALS.lpResources[i * 2] == dwId) { + GLOBALS.hMpr.seek(GLOBALS.lpResources[i * 2 + 1]); + nBytesRead = GLOBALS.hMpr.read(head, 4); if (nBytesRead != 4) return NULL; if (head[0] != 'R' || head[1] != 'E' || head[2] != 'S' || head[3] != 'D') return NULL; - nSizeDecomp = hMpr.readUint32LE(); - if (hMpr.err()) + nSizeDecomp = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return NULL; - nSizeComp = hMpr.readUint32LE(); - if (hMpr.err()) + nSizeComp = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return NULL; h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)GlobalLock(h); temp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); - nBytesRead = hMpr.read(temp, nSizeComp); + nBytesRead = GLOBALS.hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) return NULL; @@ -663,7 +585,7 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *GetSelectList(uint32 i) { uint32 *sl; int j,k,num; - LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; /* Conta quanti select attivi ci sono */ num = 0; @@ -692,10 +614,10 @@ static uint32 *GetSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; uint32 num,i,j; - LPMPALVAR v = lpmvVars; + LPMPALVAR v = GLOBALS.lpmvVars; num = 0; - for (i = 0; i < nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++,v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -704,9 +626,9 @@ static uint32 *GetItemList(uint32 nLoc) { if (il == NULL) return NULL; - v = lpmvVars; + v = GLOBALS.lpmvVars; j = 0; - for (i = 0; i < nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++,v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; @@ -718,7 +640,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM GetItemData(uint32 nOrdItem) { - LPMPALITEM curitem = lpmiItems+nOrdItem; + LPMPALITEM curitem = GLOBALS.lpmiItems+nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -838,7 +760,7 @@ void CustomThread(CORO_PARAM, const void *param) { _ctx->p = *(LPCFCALL *)param; - CORO_INVOKE_4(lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); + CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); GlobalFree(_ctx->p); @@ -899,7 +821,7 @@ void ScriptThread(CORO_PARAM, const void *param) { if (s->Command[_ctx->k].type == 1) { _ctx->p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { - mpalError = 1; + GLOBALS.mpalError = 1; CORO_KILL_SELF(); return; @@ -913,7 +835,7 @@ void ScriptThread(CORO_PARAM, const void *param) { // !!! Nuova gestione dei thread if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { - mpalError = 1; + GLOBALS.mpalError = 1; CORO_KILL_SELF(); return; @@ -927,7 +849,7 @@ void ScriptThread(CORO_PARAM, const void *param) { UnlockVar(); } else { - mpalError = 1; + GLOBALS.mpalError = 1; GlobalFree(s); CORO_KILL_SELF(); @@ -968,19 +890,19 @@ void ActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - mpalError = 0; + GLOBALS.mpalError = 0; for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; if (item->Command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 ); - CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf], + CORO_INVOKE_4(GLOBALS.lplpFunctions[item->Command[_ctx->k].nCf], item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, @@ -997,7 +919,7 @@ void ActionThread(CORO_PARAM, const void *param) { UnlockVar(); } else { - mpalError = 1; + GLOBALS.mpalError = 1; break; } } @@ -1027,7 +949,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - bExecutingAction = false; + GLOBALS.bExecutingAction = false; CORO_KILL_SELF(); @@ -1088,7 +1010,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Tanto per cominciare, e' necessario richiedere la lista degli item presenti nella locazione. */ - _ctx->il = mpalQueryItemList(nPollingLocations[id]); + _ctx->il = mpalQueryItemList(GLOBALS.nPollingLocations[id]); /* Contiamo gli items */ for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) @@ -1104,7 +1026,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->ord == -1) continue; - _ctx->curItem = lpmiItems + _ctx->ord; + _ctx->curItem = GLOBALS.lpmiItems + _ctx->ord; _ctx->k = 0; for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) @@ -1157,7 +1079,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->il[_ctx->i] == 0) continue; - _ctx->curItem = lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); + _ctx->curItem = GLOBALS.lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { @@ -1199,7 +1121,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) if (!_ctx->expired) @@ -1226,7 +1148,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Controlliamo se c'e' una action in esecuzione sull'item */ - if ((bExecutingAction) && (nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS.bExecutingAction) && (GLOBALS.nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; /* Controlliamo se c'e' gia' un'altra idle function in esecuzione @@ -1240,7 +1162,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ok, siamo gli unici :) */ LockItems(); - _ctx->curItem=lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Controlliamo se c'e' un esperessione WhenExecute */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; @@ -1308,7 +1230,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip on // FIXME: Convert to co-routine - CORO_INVOKE_4(lplpFunctions[200], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { @@ -1323,7 +1245,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } // Set idle skip off - CORO_INVOKE_4(lplpFunctions[201], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); /* Abbiamo finito */ GlobalFree(_ctx->MyThreads); @@ -1362,11 +1284,11 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - bExecutingDialog = false; - nExecutingDialog = 0; - nExecutingChoice = 0; + GLOBALS.bExecutingDialog = false; + GLOBALS.nExecutingDialog = 0; + GLOBALS.nExecutingChoice = 0; - CoroScheduler.setEvent(hAskChoice); + CoroScheduler.setEvent(GLOBALS.hAskChoice); CORO_KILL_SELF(); @@ -1394,7 +1316,7 @@ void GroupThread(CORO_PARAM, const void *param) { LockDialogs(); // Find the pointer to the current _ctx->dialog - _ctx->dialog = lpmdDialogs + nExecutingDialog; + _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; // Search inside the group requesting the _ctx->dialog for (_ctx->i = 0; _ctx->dialog->Group[_ctx->i].num != 0; _ctx->i++) { @@ -1406,7 +1328,7 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->type = _ctx->dialog->Command[_ctx->k].type; if (_ctx->type == 1) { // Call custom function - CORO_INVOKE_4(lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], + CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], _ctx->dialog->Command[_ctx->k].arg1, _ctx->dialog->Command[_ctx->k].arg2, _ctx->dialog->Command[_ctx->k].arg3, @@ -1424,7 +1346,7 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_INVOKE_1(DoChoice, (uint32)_ctx->dialog->Command[_ctx->k].nChoice); } else { - mpalError = 1; + GLOBALS.mpalError = 1; UnlockDialogs(); CORO_KILL_SELF(); @@ -1441,7 +1363,7 @@ void GroupThread(CORO_PARAM, const void *param) { } /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ - mpalError = 1; + GLOBALS.mpalError = 1; UnlockDialogs(); CORO_KILL_SELF(); @@ -1473,7 +1395,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { LockDialogs(); /* Trova il puntatore al dialogo corrente */ - _ctx->dialog=lpmdDialogs+nExecutingDialog; + _ctx->dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; /* Cerca la scelta richiesta tra quelle nel dialogo */ for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) @@ -1483,7 +1405,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Se non l'ha trovata, esce con errore */ if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { /* Se siamo qui, non abbiamo trovato la choice richiesta */ - mpalError = 1; + GLOBALS.mpalError = 1; UnlockDialogs(); CORO_KILL_SELF(); @@ -1492,10 +1414,10 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella variabile globale */ - nExecutingChoice = _ctx->i; + GLOBALS.nExecutingChoice = _ctx->i; while (1) { - nExecutingChoice = _ctx->i; + GLOBALS.nExecutingChoice = _ctx->i; _ctx->k = 0; /* Calcoliamo le when expression di ciascun select, per vedere se sono @@ -1518,13 +1440,13 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - CoroScheduler.resetEvent(hDoneChoice); - CoroScheduler.setEvent(hAskChoice); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hDoneChoice, CORO_INFINITE); + CoroScheduler.resetEvent(GLOBALS.hDoneChoice); + CoroScheduler.setEvent(GLOBALS.hAskChoice); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hDoneChoice, CORO_INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ - _ctx->j = nSelectedChoice; + _ctx->j = GLOBALS.nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); @@ -1579,7 +1501,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { \****************************************************************************/ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = lpmiItems; + LPMPALITEM item = GLOBALS.lpmiItems; int i; LPMPALITEM newitem; uint32 h; @@ -1624,8 +1546,8 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - nExecutingAction = item->nObj; - bExecutingAction = true; + GLOBALS.nExecutingAction = item->nObj; + GLOBALS.bExecutingAction = true; return h; } @@ -1648,13 +1570,13 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { uint32 h; // Store the running dialog in a global variable - nExecutingDialog = nDlgOrd; + GLOBALS.nExecutingDialog = nDlgOrd; // Enables the flag to indicate that there is' a running dialogue - bExecutingDialog = true; + GLOBALS.bExecutingDialog = true; - CoroScheduler.resetEvent(hAskChoice); - CoroScheduler.resetEvent(hDoneChoice); + CoroScheduler.resetEvent(GLOBALS.hAskChoice); + CoroScheduler.resetEvent(GLOBALS.hDoneChoice); // Create a thread that performs the dialogue group @@ -1688,7 +1610,7 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { \****************************************************************************/ bool DoSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) @@ -1698,8 +1620,8 @@ bool DoSelection(uint32 i, uint32 dwData) { if (dialog->Choice[i].Select[j].dwData == 0) return false; - nSelectedChoice = j; - CoroScheduler.setEvent(hDoneChoice); + GLOBALS.nSelectedChoice = j; + CoroScheduler.setEvent(GLOBALS.hDoneChoice); return true; } @@ -1742,8 +1664,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Si salva l'array delle funzioni custom */ - lplpFunctions = lplpcfArray; - lplpFunctionStrings = lpcfStrings; + GLOBALS.lplpFunctions = lplpcfArray; + GLOBALS.lplpFunctionStrings = lpcfStrings; /* Apre il file MPC in lettura */ if (!hMpc.open(lpszMpcFileName)) @@ -1764,7 +1686,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); + byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); if (lpMpcImage == NULL) return false; @@ -1811,73 +1733,73 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, { char errbuf[256]; wsprintf(errbuf,"Utilizzo in RAM: VAR %lu, MSG %lu, DLG %lu, ITM %lu, LOC %lu, SCR %lu", - nVars*sizeof(MPALVAR), - nMsgs*sizeof(MPALMSG), - nDialogs*sizeof(MPALDIALOG), - nItems*sizeof(MPALITEM), - nLocations*sizeof(MPALLOCATION), - nScripts*sizeof(MPALSCRIPT)); + GLOBALS.nVars*sizeof(MPALVAR), + GLOBALS.nMsgs*sizeof(MPALMSG), + GLOBALS.nDialogs*sizeof(MPALDIALOG), + GLOBALS.nItems*sizeof(MPALITEM), + GLOBALS.nLocations*sizeof(MPALLOCATION), + GLOBALS.nScripts*sizeof(MPALSCRIPT)); MessageBox(NULL,errbuf,"Dump",MB_OK); } */ /* Apre il file MPR in lettura */ - if (!hMpr.open(lpszMprFileName)) + if (!GLOBALS.hMpr.open(lpszMprFileName)) return false; /* Si posiziona a 8 byte dalla fine del file */ - hMpr.seek(-12, SEEK_END); + GLOBALS.hMpr.seek(-12, SEEK_END); - dwSizeComp = hMpr.readUint32LE(); - if (hMpr.err()) + dwSizeComp = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return false; - nResources = hMpr.readUint32LE(); - if (hMpr.err()) + GLOBALS.nResources = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return false; - nBytesRead = hMpr.read(buf, 4); - if (hMpr.err()) + nBytesRead = GLOBALS.hMpr.read(buf, 4); + if (GLOBALS.hMpr.err()) return false; if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; /* Si posiziona all'inizio dell'header delle risorse */ - hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); + GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); - lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nResources * 8); - if (lpResources == NULL) + GLOBALS.lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); + if (GLOBALS.lpResources == NULL) return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf == NULL) return false; - nBytesRead = hMpr.read(cmpbuf, dwSizeComp); + nBytesRead = GLOBALS.hMpr.read(cmpbuf, dwSizeComp); if (nBytesRead != dwSizeComp) return false; - lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)lpResources, (uint32 *)&nBytesRead); - if (nBytesRead != (uint32)nResources*8) + lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS.lpResources, (uint32 *)&nBytesRead); + if (nBytesRead != (uint32)GLOBALS.nResources*8) return false; GlobalFree(cmpbuf); /* Si riposiziona all'inizio lasciando il file di risorse aperto */ - hMpr.seek(0, SEEK_SET); + GLOBALS.hMpr.seek(0, SEEK_SET); /* Non c'e' nessuna azione ne' dialogo in esecuzione */ - bExecutingAction = false; - bExecutingDialog = false; + GLOBALS.bExecutingAction = false; + GLOBALS.bExecutingDialog = false; /* Non c'e' nessuna locazione in polling */ - Common::fill(nPollingLocations, nPollingLocations + MAXPOLLINGLOCATIONS, 0); + Common::fill(GLOBALS.nPollingLocations, GLOBALS.nPollingLocations + MAXPOLLINGLOCATIONS, 0); /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = CoroScheduler.createEvent(true, false); - hDoneChoice = CoroScheduler.createEvent(true, false); + GLOBALS.hAskChoice = CoroScheduler.createEvent(true, false); + GLOBALS.hDoneChoice = CoroScheduler.createEvent(true, false); return true; } @@ -1920,7 +1842,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { va_list v; va_start(v, wQueryType); - mpalError = OK; + GLOBALS.mpalError = OK; if (wQueryType == MPQ_VERSION) { /* @@ -1961,13 +1883,13 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = lpmlLocations[x].dwXlen; + dwRet = GLOBALS.lpmlLocations[x].dwXlen; else if (y == MPQ_Y) - dwRet = lpmlLocations[x].dwYlen; + dwRet = GLOBALS.lpmlLocations[x].dwYlen; else - mpalError = 1; + GLOBALS.mpalError = 1; } else - mpalError = 1; + GLOBALS.mpalError = 1; UnlockLocations(); @@ -2022,7 +1944,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { LockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -2070,7 +1992,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { dwRet = DoAction(x, y, GETARG(uint32)); } else { dwRet = CORO_INVALID_PID_VALUE; - mpalError = 1; + GLOBALS.mpalError = 1; } UnlockVar(); @@ -2080,7 +2002,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); */ - if (!bExecutingDialog) { + if (!GLOBALS.bExecutingDialog) { LockDialogs(); x = dialogGetOrderFromNum(GETARG(uint32)); @@ -2092,7 +2014,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - mpalError = 1; + GLOBALS.mpalError = 1; } va_end(v); @@ -2114,7 +2036,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { va_start(v, wQueryType); void *hRet = NULL; - mpalError = OK; + GLOBALS.mpalError = OK; if (wQueryType == MPQ_VERSION) { /* @@ -2154,7 +2076,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ LockLocations(); x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS.lpmlLocations[x].dwPicRes); UnlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -2198,7 +2120,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { LockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -2248,7 +2170,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - mpalError = 1; + GLOBALS.mpalError = 1; } va_end(v); @@ -2277,12 +2199,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hAskChoice, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hAskChoice, CORO_INFINITE); - CoroScheduler.resetEvent(hAskChoice); + CoroScheduler.resetEvent(GLOBALS.hAskChoice); - if (bExecutingDialog) - *dwRet = (uint32)nExecutingChoice; + if (GLOBALS.bExecutingDialog) + *dwRet = (uint32)GLOBALS.nExecutingChoice; else *dwRet = (uint32)((int)-1); } else { @@ -2306,7 +2228,7 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { \****************************************************************************/ uint32 mpalGetError(void) { - return mpalError; + return GLOBALS.mpalError; } @@ -2333,7 +2255,7 @@ bool mpalExecuteScript(int nScript) { if (s == NULL) return false; - CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); + CopyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); UnlockScripts(); // !!! Nuova gestione dei thread @@ -2346,17 +2268,17 @@ bool mpalExecuteScript(int nScript) { /****************************************************************************\ * -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION GLOBALS.lpiifCustom); * * Description: Install a custom routine that will be called by MPAL every * time the pattern of an item has been changed. * -* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* Input: LPITEMIRQFUNCTION GLOBALS.lpiifCustom Custom function to install * \****************************************************************************/ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { - lpiifCustom = lpiifCus; + GLOBALS.lpiifCustom = lpiifCus; } @@ -2380,17 +2302,17 @@ bool mpalStartIdlePoll(int nLoc) { uint32 i; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) - if (nPollingLocations[i] == (uint32)nLoc) + if (GLOBALS.nPollingLocations[i] == (uint32)nLoc) return false; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { - if (nPollingLocations[i] == 0) { - nPollingLocations[i] = nLoc; + if (GLOBALS.nPollingLocations[i] == 0) { + GLOBALS.nPollingLocations[i] = nLoc; - hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); + GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) -// if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) + if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) +// if ((GLOBALS.hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; return true; @@ -2423,13 +2345,13 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_BEGIN_CODE(_ctx); for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { - if (nPollingLocations[_ctx->i] == (uint32)nLoc) { - CoroScheduler.setEvent(hEndPollingLocations[_ctx->i]); + if (GLOBALS.nPollingLocations[_ctx->i] == (uint32)nLoc) { + CoroScheduler.setEvent(GLOBALS.hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, PollingThreads[_ctx->i], CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.PollingThreads[_ctx->i], CORO_INFINITE); - CoroScheduler.closeEvent(hEndPollingLocations[_ctx->i]); - nPollingLocations[_ctx->i] = 0; + CoroScheduler.closeEvent(GLOBALS.hEndPollingLocations[_ctx->i]); + GLOBALS.nPollingLocations[_ctx->i] = 0; if (result) *result = true; @@ -2456,7 +2378,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { \****************************************************************************/ int mpalGetSaveStateSize(void) { - return nVars * sizeof(MPALVAR) + 4; + return GLOBALS.nVars * sizeof(MPALVAR) + 4; } @@ -2473,8 +2395,8 @@ int mpalGetSaveStateSize(void) { void mpalSaveState(byte *buf) { LockVar(); - WRITE_LE_UINT32(buf, nVars); - CopyMemory(buf + 4, (byte *)lpmvVars, nVars * sizeof(MPALVAR)); + WRITE_LE_UINT32(buf, GLOBALS.nVars); + CopyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); UnlockVar(); } @@ -2492,16 +2414,16 @@ void mpalSaveState(byte *buf) { int mpalLoadState(byte *buf) { // Dobbiamo distruggere tutte le variabili e ricrearle - GlobalFree(hVars); + GlobalFree(GLOBALS.hVars); - nVars = READ_LE_UINT32(buf); + GLOBALS.nVars = READ_LE_UINT32(buf); - hVars = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, nVars * sizeof(MPALVAR)); + GLOBALS.hVars = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); LockVar(); - CopyMemory((byte *)lpmvVars, buf + 4, nVars * sizeof(MPALVAR)); + CopyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); UnlockVar(); - return nVars*sizeof(MPALVAR)+4; + return GLOBALS.nVars*sizeof(MPALVAR)+4; } bool bDontOutput; @@ -2652,18 +2574,18 @@ void mpalDumpMessages(void) { f = g_system->getSavefileManager()->openForSaving("Messages.htm"); f->writeString("\n\n
%s %s %s %s
\n"); - for (i = 0; i < nMsgs; i++) { - lpMessage = (char*)GlobalLock(lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS.nMsgs; i++) { + lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { // bernie: debug - /*if (lpmmMsgs[i].wNum == 1950) { + /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { int a = 1; }*/ nPeriods = 1; p=lpPeriods[0] = lpMessage; - OutputStartMsgComment(lpmmMsgs[i].wNum, f); + OutputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); while (1) { // Trova la fine del periodo corrente @@ -2682,9 +2604,9 @@ void mpalDumpMessages(void) { // Ora fa un ciclo su tutti i periodi for (j = 0;jwriteString("\n\n"); - for (i = 0; i < nMsgs; i++) { - lpMessage = (char*)GlobalLock(lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS.nMsgs; i++) { + lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { nPeriods = 1; p=lpPeriods[0] = lpMessage; - if (OutputStartOther(lpmmMsgs[i].wNum, f)) { + if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { while (1) { // Trova la fine del periodo corrente while (*p!='\0') @@ -2768,9 +2690,9 @@ void mpalDumpOthers(void) { // Ora fa un ciclo su tutti i periodi for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", lpmmMsgs[i].wNum); + sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); else - sprintf(fname, "000-%05d-%02d.WAV", lpmmMsgs[i].wNum,j); + sprintf(fname, "000-%05d-%02d.WAV", GLOBALS.lpmmMsgs[i].wNum,j); strcpy(frase,lpPeriods[j]); @@ -2792,9 +2714,9 @@ void mpalDumpOthers(void) { } } - OutputEndOther(lpmmMsgs[i].wNum, f); + OutputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); - GlobalUnlock(lpmmMsgs[i].hText); + GlobalUnlock(GLOBALS.lpmmMsgs[i].hText); } } @@ -3284,8 +3206,8 @@ void mpalDumpDialogs(void) { LockDialogs(); - for (i = 0; i < nDialogs; i++) - mpalDumpDialog(&lpmdDialogs[i]); + for (i = 0; i < GLOBALS.nDialogs; i++) + mpalDumpDialog(&GLOBALS.lpmdDialogs[i]); UnlockDialogs(); } diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index ee3820531a..a7b6dfc5aa 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -51,8 +51,10 @@ #define __MPALDLL_H #include "common/file.h" -#include "memory.h" -#include "stubs.h" +#include "tony/mpal/memory.h" +#include "tony/mpal/stubs.h" +#include "tony/mpal/loadmpc.h" +#include "tony/mpal/expr.h" namespace Tony { @@ -332,41 +334,6 @@ typedef LPMPALSCRIPT* LPLPMPALSCRIPT; #include "common/pack-end.h" -/****************************************************************************\ -* Variabili globali -\****************************************************************************/ - -extern uint32 mpalError; -extern LPLPCUSTOMFUNCTION lplpFunctions; -extern uint16 nObjs; - -extern uint16 nVars; -extern HGLOBAL hVars; -extern LPMPALVAR lpmvVars; - -extern uint16 nMsgs; -extern HGLOBAL hMsgs; -extern LPMPALMSG lpmmMsgs; - -extern uint16 nDialogs; -extern HGLOBAL hDialogs; -extern LPMPALDIALOG lpmdDialogs; - -extern uint16 nItems; -extern HGLOBAL hItems; -extern LPMPALITEM lpmiItems; - -extern uint16 nLocations; -extern HGLOBAL hLocations; -extern LPMPALLOCATION lpmlLocations; - -extern uint16 nScripts; -extern HGLOBAL hScripts; -extern LPMPALSCRIPT lpmsScripts; - -extern Common::File hMpr; -extern uint16 nResources; -extern uint32 * lpResources; /****************************************************************************\ * Prototipi di funzione @@ -412,8 +379,5 @@ void varSetValue(const char *lpszVarName, int32 val); } // end of namespace Tony -#include "loadmpc.h" -#include "expr.h" - #endif -- cgit v1.2.3 From cf3d2cd3562a6d30690f6e8acb8fb4f17739fa35 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 08:53:09 +1000 Subject: TONY: Removed some no longer needed FIXME's --- engines/tony/loc.cpp | 1 - engines/tony/mpal/mpal.cpp | 1 - engines/tony/tony.cpp | 1 - 3 files changed, 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 70e800a5d4..cee657791d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1021,7 +1021,6 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /***************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - // FIXME: Refactor static RMBox BOX[MAXBOXES]; // Matrice di Adjacenza static short COSTO[MAXBOXES]; // Costi per Nodo static short VALIDO[MAXBOXES]; // 0:non valido 1:valido 2:saturo diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 66d467f301..f049ecf3ea 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1229,7 +1229,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { */ // Set idle skip on - // FIXME: Convert to co-routine CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index aa110ce008..d476f60859 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -514,7 +514,6 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - // FIXME: This needs to be moved into it's own process CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished -- cgit v1.2.3 From 099fe1e9e62ada666a312e08d7dca5cd2083de0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 07:43:50 +0200 Subject: TONY: Remove original header --- engines/tony/adv.h | 35 ++++++++--------------------------- engines/tony/custom.cpp | 30 +++++------------------------- engines/tony/custom.h | 31 ++++++------------------------- engines/tony/font.cpp | 31 ++++++------------------------- engines/tony/font.h | 30 +++++------------------------- engines/tony/game.cpp | 31 ++++++------------------------- engines/tony/game.h | 31 ++++++------------------------- engines/tony/gfxcore.cpp | 31 ++++++------------------------- engines/tony/gfxcore.h | 31 ++++++------------------------- engines/tony/gfxengine.cpp | 31 ++++++------------------------- engines/tony/gfxengine.h | 31 ++++++------------------------- engines/tony/input.cpp | 31 ++++++------------------------- engines/tony/input.h | 31 ++++++------------------------- engines/tony/inventory.cpp | 31 ++++++------------------------- engines/tony/inventory.h | 31 ++++++------------------------- engines/tony/loc.cpp | 31 ++++++------------------------- engines/tony/loc.h | 31 ++++++------------------------- engines/tony/resid.h | 9 +++------ engines/tony/sound.cpp | 31 ++++++------------------------- engines/tony/sound.h | 31 ++++++------------------------- engines/tony/tonychar.cpp | 31 ++++++------------------------- engines/tony/tonychar.h | 31 ++++++------------------------- engines/tony/utils.cpp | 31 ++++++------------------------- engines/tony/utils.h | 31 ++++++------------------------- engines/tony/window.cpp | 31 ++++++------------------------- engines/tony/window.h | 39 ++++++++++----------------------------- 26 files changed, 157 insertions(+), 637 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 6a1b6ce246..314672fe39 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: ADV.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_ADV_H #define TONY_ADV_H @@ -59,7 +40,7 @@ namespace Tony { #define RM_SX 640 #define RM_SY 480 -// Dimensioni X&Y del bigbuf +// X&Y dimensions of bigbuf #define RM_BBX (RM_SX) #define RM_BBY (RM_SY) @@ -90,7 +71,7 @@ enum RMTonyAction { TA_RECEIVECOMBINEGIVE }; -// Funzioni globali +// Global Functions uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void MainLinkGraphicTask(RMGfxTask *task); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 168c2d38cd..c84aa63edb 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -20,31 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Custom functions..... * - * z$$beu .ue=" $ "=e.. .zed$$c ..................... * - * "#$e z$*" . `. ^*Nc e$"" ..................... * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - ************************************************************************** + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software */ #include "common/system.h" diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 4b9701cec4..875710f974 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -20,31 +20,12 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Custom functions..... * - * z$$beu .ue=" $ "=e.. .zed$$c ..................... * - * "#$e z$*" . `. ^*Nc e$"" ..................... * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_CUSTOM_H #define TONY_CUSTOM_H diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8957c09a87..c2af10c74a 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/textconsole.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/font.h b/engines/tony/font.h index 36fdc9baed..9715e95043 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -19,31 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_FONT_H #define TONY_FONT_H diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index b21498a5e8..8844374821 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/file.h" #include "common/savefile.h" diff --git a/engines/tony/game.h b/engines/tony/game.h index 80482f39da..83972e0f17 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Game.CPP............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_GAME_H #define TONY_GAME_H diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 0c5ffa8096..826159a8d7 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/gfxengine.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 23f1a9809a..dacb66d68c 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_GFXCORE_H #define TONY_GFXCORE_H diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index bf1a08f245..4a0fdc0795 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxEngine.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/savefile.h" #include "tony/mpal/lzo.h" diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 3f90d41ad7..2aae0b6ea6 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxEngine.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_GFXENGINE_H #define TONY_GFXENGINE_H diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index f29d4ddc8e..97425e49c9 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Input.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/gfxengine.h" diff --git a/engines/tony/input.h b/engines/tony/input.h index 79a11db678..544424581f 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Input.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_INPUT_H #define TONY_INPUT_H diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index fbc0918e10..7b53e75cdd 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Inventory.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/textconsole.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 86eaa6801e..309674ff0a 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Inventory.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_INVENTORY_H #define TONY_INVENTORY_H diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index cee657791d..b88fc68fc5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/loc.h b/engines/tony/loc.h index bbb98bd9db..aee4936490 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_LOC_H #define TONY_LOC_H diff --git a/engines/tony/resid.h b/engines/tony/resid.h index 01ed9b9bd2..aec4d4c38c 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -19,14 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + /* - * ResID.H - Include per le risorse MPAL - * - * Coded by Giovanni Bajo - Nayma/Prograph - * - * (C) 1997-98, Nayma Software - * (C) 1998, Prograph Research srl + * This code is based on original Tony Tough source code * + * Copyright (c) 1997-2003 Nayma Software */ /* diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 61d225b88b..4f7a28b2b3 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/textconsole.h" #include "tony/game.h" diff --git a/engines/tony/sound.h b/engines/tony/sound.h index e263c7ee51..bfa48f4d78 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_SOUND_H #define TONY_SOUND_H diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 7430ca89ae..df92cafebd 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/mpal/memory.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 27d62d9d57..9cea3a4b2d 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_TONYCHAR_H #define TONY_TONYCHAR_H diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index a3998a01ab..d57640fee8 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/utils.h" #include "tony/tony.h" diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 4137823587..1e3841c185 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_UTILS_H #define TONY_UTILS_H diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 18e6901547..92f6dea032 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi per la gestione * - * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct - * "#$e z$*" . `. ^*Nc e$"" Draw................. * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/scummsys.h" #include "util.h" diff --git a/engines/tony/window.h b/engines/tony/window.h index 56f48d7698..ea26df3920 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi per la gestione * - * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct - * "#$e z$*" . `. ^*Nc e$"" Draw................. * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_WINDOW_H #define TONY_WINDOW_H @@ -60,18 +41,18 @@ struct DDSURFACEDESC { class RMSnapshot { private: - // Buffer per la creazione dei path + // Buffer used to create a path static char bufDrive[MAX_DRIVE], bufDir[MAX_DIR], bufName[MAX_FNAME], bufExt[MAX_EXT]; static char filename[512]; - // Buffer per la conversione a RGB + // Buffer used to convert a RGB static byte rgb[RM_SX * RM_SY * 3]; private: bool GetFreeSnapName(char *fn); public: - // Prende uno screenshot + // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); }; @@ -105,7 +86,7 @@ public: RMWindow(); ~RMWindow(); - // Inizializzazione + // Initialization void Init(/*HINSTANCE hInst*/); void InitDirectDraw(void); void Close(void); -- cgit v1.2.3 From 4bf61b2f02bc933f66588332de37e1fdb996468b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 20:20:02 +1000 Subject: TONY: Fixed nasty cast in ItemIrq initialisation --- engines/tony/gfxengine.cpp | 19 ++++++------------- engines/tony/globals.cpp | 1 + engines/tony/globals.h | 2 ++ 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4a0fdc0795..a2b58f660e 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -361,28 +361,21 @@ void RMGfxEngine::InitCustomDll(void) { SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); } -// FIXME: Casting nPattern from int to RMGfxEngine * void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { - static RMGfxEngine *This = NULL; RMItem *item; + assert(GLOBALS.GfxEngine); - // Inizializzazione! - if ((int)dwItem == -1) { - This = (RMGfxEngine*)nPattern; - return; - } - - if (This->m_bLocationLoaded) { - item=This->m_loc.GetItemFromCode(dwItem); + if (GLOBALS.GfxEngine->m_bLocationLoaded) { + item = GLOBALS.GfxEngine->m_loc.GetItemFromCode(dwItem); if (item != NULL) { - if (nPattern!=-1) { + if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) MainFreeze(); item->SetPattern(nPattern,true); if (GLOBALS.bPatIrqFreeze) MainUnfreeze(); } - if (nStatus!=-1) + if (nStatus != -1) item->SetStatus(nStatus); } } @@ -597,7 +590,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { csMainLoop = g_system->createMutex(); // Inizializza la funzione di IRQ di Item per l'MPAL - ItemIrq((uint32)-1, (uint32)this, 0); + GLOBALS.GfxEngine = this; mpalInstallItemIrq(ItemIrq); // Inizializza DirectInput diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 0ce99f88e7..867d48e0fa 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -40,6 +40,7 @@ Globals::Globals() { Loc = NULL; Inventory = NULL; Input = NULL; + GfxEngine = NULL; LoadLocation = NULL; UnloadLocation = NULL; LinkGraphicTask = NULL; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 1a11a871d0..72faa6a6c5 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -25,6 +25,7 @@ #include "common/savefile.h" #include "tony/adv.h" +#include "tony/gfxengine.h" #include "tony/input.h" #include "tony/inventory.h" #include "tony/loc.h" @@ -216,6 +217,7 @@ public: RMLocation *Loc; RMInventory *Inventory; RMInput *Input; + RMGfxEngine *GfxEngine; uint32 (*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); -- cgit v1.2.3 From 8f4694a80c92b20d76a69c46dc43d1a990ec82c6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 20:20:58 +1000 Subject: TONY: Fixed suspicious casting --- engines/tony/custom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index c84aa63edb..0392fc409d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1326,8 +1326,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_BEGIN_CODE(_ctx); // Prende le coordinate di quanto scrollare - _ctx->lx=*((int*)&nX); - _ctx->ly=*((int*)&nY); + _ctx->lx = (int32)nX; + _ctx->ly = (int32)nY; _ctx->dimx = _ctx->lx; _ctx->dimy = _ctx->ly; if (_ctx->lx < 0) _ctx->dimx = -_ctx->lx; -- cgit v1.2.3 From 9eb66a2324120a6c4e22a980a9114bce437fcd8b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 20:21:54 +1000 Subject: TONY: Added endian fixes for reading data --- engines/tony/mpal/loadmpc.cpp | 62 +++++++++++++++++++++---------------------- engines/tony/sound.cpp | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 937374517f..6430325503 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -96,27 +96,27 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { int curCmd,j,len; uint i; - lpmsScript->nObj=*(int *)lpBuf; - lpBuf+=4; + lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; - lpmsScript->nMoments=*(uint16 *)lpBuf; - lpBuf+=2; + lpmsScript->nMoments = READ_LE_UINT16(lpBuf); + lpBuf += 2; curCmd=0; for (i=0;inMoments;i++) { - lpmsScript->Moment[i].dwTime=*(int *)lpBuf; lpBuf+=4; + lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; lpmsScript->Moment[i].nCmds=*lpBuf; lpBuf++; for (j=0;jMoment[i].nCmds;j++) { lpmsScript->Command[curCmd].type=*lpBuf; lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; - lpmsScript->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; - lpmsScript->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; - lpmsScript->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; - lpmsScript->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign @@ -260,7 +260,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ - num=*(uint16 *)lpBuf; lpBuf += 2; + num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) error("Too much choices in dialog #%d",lpmdDialog->nObj); @@ -343,8 +343,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { uint32 i,j,kk; uint32 curCmd; - lpmiItem->nObj=*(int *)lpBuf; - lpBuf+=4; + lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; len=*lpBuf; lpBuf++; @@ -367,12 +367,12 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].num=*lpBuf; lpBuf++; - lpmiItem->Action[i].wParm=*(uint16 *)lpBuf; - lpBuf+=2; + lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (lpmiItem->Action[i].num==0xFF) { - lpmiItem->Action[i].wTime=*(uint16 *)lpBuf; - lpBuf+=2; + lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmiItem->Action[i].perc=*lpBuf; lpBuf++; @@ -400,11 +400,11 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; - lpmiItem->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; - lpmiItem->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; - lpmiItem->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; - lpmiItem->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign @@ -444,7 +444,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - lpmiItem->dwRes=*(uint32 *)lpBuf; lpBuf+=4; + lpmiItem->dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; } @@ -468,14 +468,14 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { \****************************************************************************/ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { - lpmlLocation->nObj=*(int *)lpBuf; - lpBuf+=4; - lpmlLocation->dwXlen=*(uint16 *)lpBuf; - lpBuf+=2; - lpmlLocation->dwYlen=*(uint16 *)lpBuf; - lpBuf+=2; - lpmlLocation->dwPicRes=*(uint32 *)lpBuf; - lpBuf+=4; + lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmlLocation->dwXlen = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpBuf += 4; return lpBuf; } diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 4f7a28b2b3..33dd6e1497 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1122,7 +1122,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { return false; lpBuf += 4; - dwSize = *(uint32*)lpBuf; + dwSize = READ_LE_UINT32(lpBuf); lpBuf += 4; b16bit = (WAVHeader->nBitsPerSample == 16); -- cgit v1.2.3 From 47ddb2ff339ed21d5cc518b8851961b097169652 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 21:06:03 +1000 Subject: TONY: Replace stubs for TakeOwnership/ReleaseOwnership with actual implementation --- engines/tony/custom.cpp | 15 +++++---------- engines/tony/globals.cpp | 3 +-- engines/tony/globals.h | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0392fc409d..d6e7fdd2ee 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2134,15 +2134,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { -// EnterCriticalSection(&cs[num]); -// WaitForSingleObject(mut[num],CORO_INFINITE); - warning("TODO: TakeOwnership"); + CoroScheduler.waitForSingleObject(coroParam, GLOBALS.mut[num], CORO_INFINITE); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { -// LeaveCriticalSection(&cs[num]); -// g_system->unlockMutex(mut[num]); - warning("TODO: ReleaseOwnership"); + CoroScheduler.pulseEvent(GLOBALS.mut[num]); + warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } @@ -2646,11 +2643,9 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.bAlwaysDisplay = false; int i; -/* for (i = 0;i < 10; i++) - cs[i] = g_system->createMutex(); for (i = 0;i < 10; i++) - mut[i] = CreateMutex(NULL, false, NULL); -*/ + GLOBALS.mut[i] = CoroScheduler.createEvent(false, false); + for (i = 0; i < 200; i++) GLOBALS.tappeti[i] = 0; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 867d48e0fa..7c801a787d 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -83,9 +83,8 @@ Globals::Globals() { curSonoriz = 0; bFadeOutStop = false; -// OSystem::MutexRef cs[10]; // OSystem::MutexRef vdb; - Common::fill(&mut[0], &mut[10], (HANDLE)NULL); + Common::fill(&mut[0], &mut[10], 0); bSkipIdle = false; hSkipIdle = 0; lastMusic = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 72faa6a6c5..d82e0fcaf2 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -241,7 +241,7 @@ public: RMPoint StartLocPos[256]; OSystem::MutexRef cs[10]; OSystem::MutexRef vdb; - HANDLE mut[10]; + uint32 mut[10]; bool bSkipIdle; uint32 hSkipIdle; -- cgit v1.2.3 From d5b80688e773427e0a96fe9270b0177efd953b14 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 22:39:24 +1000 Subject: TONY: Implemented list-saves and delete save functionality --- engines/tony/detection.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++- engines/tony/game.h | 5 +++-- engines/tony/tony.h | 2 +- 3 files changed, 49 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 6be0ca302c..7a943223a4 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -27,6 +27,7 @@ #include "common/system.h" #include "tony/tony.h" +#include "tony/game.h" namespace Tony { @@ -71,10 +72,16 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; + virtual int getMaximumSaveSlot() const; + virtual void removeSaveState(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { - return false; + return + (f == kSupportsListSaves) || +// (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { @@ -90,6 +97,43 @@ bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame return gd != 0; } +SaveStateList TonyMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = "tony.0??"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if (slotNum >= 0 && slotNum <= 999) { + byte thumbnailData[160 * 120 * 2]; + Tony::RMString saveName; + byte difficulty; + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { + // Add the save name to the savegame list + saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); + } + } + } + + return saveList; +} + +int TonyMetaEngine::getMaximumSaveSlot() const { return 99; } + +void TonyMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); + + g_system->getSavefileManager()->removeSavefile(filename); +} + #if PLUGIN_ENABLED_DYNAMIC(TONY) REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else diff --git a/engines/tony/game.h b/engines/tony/game.h index 83972e0f17..22df40c6d8 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -263,6 +263,9 @@ public: // Polling per l'option screen void DoFrame(CORO_PARAM, RMInput *m_input); + // Retrieves a savegame's thumbnail, description, and difficulty level + static bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + protected: // Inizializza tutto per il nuovo stato @@ -274,8 +277,6 @@ protected: void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - // Carica lo screenshot per il salvataggio - bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); }; } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c1ad6756c2..c106a0856b 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -198,7 +198,7 @@ public: void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); - Common::String GetSaveStateFileName(int n); + static Common::String GetSaveStateFileName(int n); // Prende il thumbnail void GrabThumbnail(void); -- cgit v1.2.3 From 88762667b52e4b904c56ecc94bf304c1a91e9feb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 21:29:27 +0200 Subject: TONY: Fix some formatting --- engines/tony/adv.h | 24 +- engines/tony/custom.cpp | 1008 +++++++++++++++++++++----------------------- engines/tony/custom.h | 30 +- engines/tony/detection.cpp | 20 +- engines/tony/font.cpp | 472 ++++++++++----------- engines/tony/font.h | 407 +++++++++--------- engines/tony/game.cpp | 272 ++++++------ engines/tony/game.h | 89 ++-- engines/tony/gfxcore.cpp | 528 +++++++++++------------ engines/tony/gfxcore.h | 277 +++++++----- engines/tony/gfxengine.cpp | 357 ++++++++-------- engines/tony/gfxengine.h | 26 +- engines/tony/globals.h | 46 +- engines/tony/input.cpp | 10 +- engines/tony/input.h | 30 +- engines/tony/inventory.cpp | 199 ++++----- engines/tony/tonychar.cpp | 31 +- engines/tony/window.cpp | 44 +- 18 files changed, 2000 insertions(+), 1870 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 314672fe39..90a9c245b5 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -37,24 +37,24 @@ namespace Tony { // X & Y dimensions of the adventure -#define RM_SX 640 -#define RM_SY 480 +#define RM_SX 640 +#define RM_SY 480 // X&Y dimensions of bigbuf -#define RM_BBX (RM_SX) -#define RM_BBY (RM_SY) +#define RM_BBX (RM_SX) +#define RM_BBY (RM_SY) -// Skipping X&Y -#define RM_SKIPY ((RM_BBY - RM_SY) / 2) -#define RM_SKIPX 0 +// Skipping X&Y +#define RM_SKIPY ((RM_BBY - RM_SY) / 2) +#define RM_SKIPX 0 // Name lengths // FIXME: Some of these can likely be removed when refactoring is completed -#define MAX_DRIVE 10 -#define MAX_DIR 255 -#define MAX_PATH 255 -#define MAX_FNAME 100 -#define MAX_EXT 10 +#define MAX_DRIVE 10 +#define MAX_DIR 255 +#define MAX_PATH 255 +#define MAX_FNAME 100 +#define MAX_EXT 10 // Tony's actions enum RMTonyAction { diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d6e7fdd2ee..d38f840011 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -44,120 +44,60 @@ namespace Tony { const char *tappetiFile[] = { "None", - "1.ADP", // Grilli.WAV - "2.ADP", // Grilli-Ovattati.WAV - "3.ADP", // Grilli-Vento.WAV - "3.ADP", // Grilli-Vento1.WAV - "5.ADP", // Vento1.WAV - "4.ADP", // Mare1.WAV - "6.ADP" // Mare1.WAV met volume + "1.ADP", // Grilli.WAV + "2.ADP", // Grilli-Ovattati.WAV + "3.ADP", // Grilli-Vento.WAV + "3.ADP", // Grilli-Vento1.WAV + "5.ADP", // Vento1.WAV + "4.ADP", // Mare1.WAV + "6.ADP" // Mare1.WAV met volume }; struct MusicFileEntry { const char *name; int sync; }; -const MusicFileEntry musicFiles[] = { -/* - { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, - { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, - { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, - { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, - { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, -*/ - { "00.ADP", 0 }, { "01.ADP", 0 }, - { "02.ADP", 0 }, { "03.ADP", 0 }, - { "04.ADP",0 }, { "05.ADP", 0 }, - { "06.ADP", 0 }, { "07.ADP", 0 }, - { "08.ADP", 2450 }, { "09.ADP", 0 }, - -/* - { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, - { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, - { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, - { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, - { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, -*/ - { "10.ADP", 0 }, { "11.ADP", 0 }, - { "12.ADP", 0 }, { "13.ADP", 0 }, - { "14.ADP", 0 }, { "15.ADP", 0 }, - { "16.ADP", 0 }, { "17.ADP", 0 }, - { "18.ADP", 0 }, { "19.ADP", 0 }, -/* - { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, - { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, - { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, - { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, - { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, -*/ - { "20.ADP", 0 }, { "21.ADP", 0 }, - { "22.ADP", 0 }, { "23.ADP", 0 }, - { "24.ADP", 0 }, { "25.ADP", 0 }, - { "26.ADP", 0 }, { "27.ADP", 0 }, - { "28.ADP", 1670 }, { "29.ADP", 0 }, -/* - { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, - { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, - { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, - { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, - { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, -*/ - { "30.ADP", 0 }, { "31.ADP", 0 }, - { "32.ADP", 2900 }, { "33.ADP", 0 }, - { "34.ADP", 0 }, { "35.ADP", 0 }, - { "36.ADP", 0 }, { "37.ADP", 0 }, - { "38.ADP", 0 }, { "39.ADP", 0 }, -/* - { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, - { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, - { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, - { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, - { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, -*/ - { "40.ADP", 0 }, { "41.ADP", 1920 }, - { "42.ADP", 1560 }, { "43.ADP", 1920 }, - { "44.ADP", 1920 }, { "45.ADP", 1920 }, - { "46.ADP", 1920 }, { "47.ADP", 1920 }, - { "48.ADP", 1920 }, { "49.ADP", 1920 }, - -/* - { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, - { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, - { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, - { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, - { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } -*/ - - { "50.ADP", 1920 }, { "51.ADP", 1920 }, - { "52.ADP", 1920 }, { "53.ADP", 0 }, - { "54.ADP", 0 }, { "55.ADP", 0 }, - { "56.ADP", 0 }, { "57.ADP", 0 }, - { "58.ADP", 0 }, { "59.ADP", 0 } +const MusicFileEntry musicFiles[] = { + {"00.ADP", 0}, {"01.ADP", 0}, + {"02.ADP", 0}, {"03.ADP", 0}, + {"04.ADP", 0}, {"05.ADP", 0}, + {"06.ADP", 0}, {"07.ADP", 0}, + {"08.ADP", 2450}, {"09.ADP", 0}, + {"10.ADP", 0}, {"11.ADP", 0}, + {"12.ADP", 0}, {"13.ADP", 0}, + {"14.ADP", 0}, {"15.ADP", 0}, + {"16.ADP", 0}, {"17.ADP", 0}, + {"18.ADP", 0}, {"19.ADP", 0}, + {"20.ADP", 0}, {"21.ADP", 0}, + {"22.ADP", 0}, {"23.ADP", 0}, + {"24.ADP", 0}, {"25.ADP", 0}, + {"26.ADP", 0}, {"27.ADP", 0}, + {"28.ADP", 1670}, {"29.ADP", 0}, + {"30.ADP", 0}, {"31.ADP", 0}, + {"32.ADP", 2900}, {"33.ADP", 0}, + {"34.ADP", 0}, {"35.ADP", 0}, + {"36.ADP", 0}, {"37.ADP", 0}, + {"38.ADP", 0}, {"39.ADP", 0}, + {"40.ADP", 0}, {"41.ADP", 1920}, + {"42.ADP", 1560}, {"43.ADP", 1920}, + {"44.ADP", 1920}, {"45.ADP", 1920}, + {"46.ADP", 1920}, {"47.ADP", 1920}, + {"48.ADP", 1920}, {"49.ADP", 1920}, + {"50.ADP", 1920}, {"51.ADP", 1920}, + {"52.ADP", 1920}, {"53.ADP", 0}, + {"54.ADP", 0}, {"55.ADP", 0}, + {"56.ADP", 0}, {"57.ADP", 0}, + {"58.ADP", 0}, {"59.ADP", 0} }; -const char *staccFileNames[] = { -/* - "05-MUCCA.ADP", "06-HALOW.ADP", - "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", - "LETTERAFINE.ADP", "PREGAME2.ADP", - "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", - "15-SHOTTONY.ADP", "27-ZUCC2.ADP", -*/ - "S00.ADP", "S01.ADP", - "S02.ADP", "S03.ADP", +const char *staccFileNames[] = { + "S00.ADP", "S01.ADP", + "S02.ADP", "S03.ADP", "S04.ADP", "S05.ADP", "S06.ADP", "S07.ADP", "S08.ADP", "S09.ADP", - -/* - "53-DLOGO.ADP", "16-DIALOG1.ADP", - "TORRE1.ADP", "GARG1.ADP", - "LORENZ1.ADP", "24-FIGHT.ADP", - "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", - "GATTO1.ADP" -*/ "S10.ADP", "S11.ADP", "S12.ADP", "S13.ADP", "S14.ADP", "S15.ADP", @@ -169,7 +109,7 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; for (i = 0; i < GLOBALS.curChangedHotspot; i++) - GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); + GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { @@ -182,7 +122,7 @@ void SaveChangedHotspot(Common::OutSaveFile *f) { void LoadChangedHotspot(Common::InSaveFile *f) { GLOBALS.curChangedHotspot = f->readByte(); - + if (GLOBALS.curChangedHotspot > 0) { for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) GLOBALS.ChangedHotspot[i].Load(f); @@ -191,13 +131,13 @@ void LoadChangedHotspot(Common::InSaveFile *f) { /* - Classi richieste per le funzioni custom! + Classi richieste per le funzioni custom! - Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s + Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s - SendMessage -> Direi che basta theEngine.SendMessage() - ChangeLocation -> theEngine.ChangeLocation() - AddInventory -> theEngine.AddInventory() + SendMessage -> Direi che basta theEngine.SendMessage() + ChangeLocation -> theEngine.ChangeLocation() + AddInventory -> theEngine.AddInventory() */ void MCharResetCodes(void) { @@ -246,12 +186,12 @@ DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.SetPalesati(bStatus); + GLOBALS.SetPalesati(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - int i; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -269,25 +209,25 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { - case 1: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); - break; - case 2: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); - break; - case 3: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); - break; - case 4: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); - break; - case 5: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); - break; + case 1: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); + break; + case 2: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); + break; + case 3: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); + break; + case 4: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); + break; + case 5: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); + break; - default: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); - break; + default: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); + break; } } @@ -296,7 +236,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { int code; code = (codehi << 16) | codelo; - + if (_vm->_voices.size() == 0) return NULL; @@ -310,12 +250,12 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { CORO_BEGIN_CONTEXT; - RMMessage msg; - int i; - int curOffset; - VoiceHeader *curVoc; - FPSFX *voice; - RMTextDialog text; + RMMessage msg; + int i; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -337,11 +277,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // PRIMA VOLTA PREALLOCA g_system->lockMutex(GLOBALS.vdb); - //fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); -// _ctx->curOffset = ftell(_vm->m_vdbFP); + // _ctx->curOffset = ftell(_vm->m_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); @@ -367,12 +307,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.SetInput(GLOBALS.Input); - + // Allineamento _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - + // Colore - _ctx->text.SetColor(0,255,0); + _ctx->text.SetColor(0, 255, 0); // Scrive il testo _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); @@ -384,7 +324,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); // Setta l'always display - if (GLOBALS.bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { + _ctx->text.SetAlwaysDisplay(); + _ctx->text.ForceTime(); + } // Registra il testo GLOBALS.LinkGraphicTask(&_ctx->text); @@ -395,11 +338,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - // _ctx->curOffset = ftell(_vm->m_vdbFP); + // _ctx->curOffset = ftell(_vm->m_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); @@ -408,14 +351,14 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); _ctx->voice->Release(); - _ctx->voice=NULL; + _ctx->voice = NULL; } } @@ -435,7 +378,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, u DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { CORO_BEGIN_CONTEXT; - uint32 h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -461,20 +404,20 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - RMGfxClearTask clear; - int i; - RMTextDialog text; + RMMessage *msg; + RMGfxClearTask clear; + int i; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->msg = new RMMessage(nMsg); - + GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); GLOBALS.SFM_pt = GLOBALS.Tony->Position(); - - if (GLOBALS.bSkipIdle) + + if (GLOBALS.bSkipIdle) return; CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); @@ -485,13 +428,13 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->text.SetInput(GLOBALS.Input); // Allineamento - _ctx->text.SetAlignType(RMText::HCENTER,RMText::VCENTER); - - // Forza il testo a scomparire a tempo + _ctx->text.SetAlignType(RMText::HCENTER, RMText::VCENTER); + + // Forza il testo a scomparire a tempo _ctx->text.ForceTime(); // Colore - _ctx->text.SetColor(255,255,255); + _ctx->text.SetColor(255, 255, 255); // Scrive il testo if (nFont == 0) @@ -509,7 +452,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 GLOBALS.LinkGraphicTask(&_ctx->clear); GLOBALS.LinkGraphicTask(&_ctx->text); - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } @@ -521,14 +464,14 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - char buf[256]; - RMGfxClearTask clear; + char buf[256]; + RMGfxClearTask clear; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); GLOBALS.LinkGraphicTask(&_ctx->clear); - + CORO_INVOKE_0(GLOBALS.WaitFrame); CORO_END_CODE; @@ -536,7 +479,7 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { GLOBALS.Freeze(); - GLOBALS.LoadLocation(GLOBALS.SFM_nLoc,RMPoint(GLOBALS.SFM_pt.x,GLOBALS.SFM_pt.y),RMPoint(-1,-1)); + GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS.Tony->Show(); GLOBALS.Unfreeze(); @@ -569,8 +512,8 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); if (!GLOBALS.bNoOcchioDiBue) { - GLOBALS.InitWipe(1); - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + GLOBALS.InitWipe(1); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } _vm->StopMusic(4); @@ -585,7 +528,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { CORO_BEGIN_CONTEXT; - uint32 h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -598,7 +541,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { _vm->StopMusic(4); } - + // On Exit e lascia freezzato CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); @@ -615,16 +558,16 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (!GLOBALS.bNoOcchioDiBue) { - GLOBALS.InitWipe(2); + GLOBALS.InitWipe(2); } - + GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!GLOBALS.bNoOcchioDiBue) { - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); GLOBALS.CloseWipe(); } @@ -638,7 +581,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - GLOBALS.StartLocPos[nLoc].Set(lX,lY); + GLOBALS.StartLocPos[nLoc].Set(lX, lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -653,7 +596,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); CORO_INVOKE_4(ChangeLocation, GLOBALS.saveTonyLoc, GLOBALS.saveTonyPos.x, GLOBALS.saveTonyPos.y, 0); - + MCharResetCodes(); CORO_END_CODE; @@ -675,7 +618,7 @@ DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.EnableGUI(); + GLOBALS.EnableGUI(); } DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -693,7 +636,7 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { GLOBALS.Freeze(); GLOBALS.Tony->Take(nDirection, 0); GLOBALS.Unfreeze(); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); @@ -714,7 +657,7 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection,2); + GLOBALS.Tony->Take(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -729,7 +672,7 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { GLOBALS.Freeze(); GLOBALS.Tony->Put(nDirection, 0); GLOBALS.Unfreeze(); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); @@ -743,14 +686,14 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection,1); + GLOBALS.Tony->Put(nDirection, 1); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection,2); + GLOBALS.Tony->Put(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -831,7 +774,7 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); else GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); @@ -839,7 +782,7 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS.Tony->SetPastorella(bIsPast); + GLOBALS.Tony->SetPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1189,7 +1132,7 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin } DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { - TonySetNumTexts(dwText); + TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NAAH; } @@ -1236,15 +1179,15 @@ DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - RMItem *item; + RMItem *item; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->item = GLOBALS.Loc->GetItemFromCode(nItem); - + if (!GLOBALS.bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); + CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); CORO_END_CODE; } @@ -1261,7 +1204,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); CORO_INVOKE_1(GLOBALS.Tony->Move, RMPoint(nX, nY)); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndMovement); @@ -1274,8 +1217,8 @@ DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { CORO_BEGIN_CONTEXT; - int lx, ly; - RMPoint pt; + int lx, ly; + RMPoint pt; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1285,21 +1228,25 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->ly = (int32)nY; _ctx->pt = GLOBALS.Loc->ScrollPosition(); - + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { if (_ctx->lx > 0) { - _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; + _ctx->lx -= (int32)sX; + if (_ctx->lx < 0) _ctx->lx = 0; _ctx->pt.Offset((int32)sX, 0); } else if (_ctx->lx < 0) { - _ctx->lx += (int32)sX; if (_ctx->lx > 0) _ctx->lx = 0; + _ctx->lx += (int32)sX; + if (_ctx->lx > 0) _ctx->lx = 0; _ctx->pt.Offset(-(int32)sX, 0); } if (_ctx->ly > 0) { - _ctx->ly -= sY; if (_ctx->ly < 0) _ctx->ly = 0; + _ctx->ly -= sY; + if (_ctx->ly < 0) _ctx->ly = 0; _ctx->pt.Offset(0, sY); } else if (_ctx->ly < 0) { - _ctx->ly += sY; if (_ctx->ly > 0) _ctx->ly = 0; + _ctx->ly += sY; + if (_ctx->ly > 0) _ctx->ly = 0; _ctx->pt.Offset(0, -(int32)sY); } @@ -1316,11 +1263,11 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { CORO_BEGIN_CONTEXT; - int lx, ly; - RMPoint pt, startpt; - uint32 dwStartTime, dwCurTime, dwTotalTime; - uint32 stepX, stepY; - int dimx, dimy; + int lx, ly; + RMPoint pt, startpt; + uint32 dwStartTime, dwCurTime, dwTotalTime; + uint32 stepX, stepY; + int dimx, dimy; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1330,16 +1277,19 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->ly = (int32)nY; _ctx->dimx = _ctx->lx; _ctx->dimy = _ctx->ly; - if (_ctx->lx < 0) _ctx->dimx = -_ctx->lx; - if (_ctx->ly < 0) _ctx->dimy = -_ctx->ly; + if (_ctx->lx < 0) + _ctx->dimx = -_ctx->lx; + + if (_ctx->ly < 0) + _ctx->dimy = -_ctx->ly; _ctx->stepX = sX; _ctx->stepY = sY; _ctx->startpt = GLOBALS.Loc->ScrollPosition(); - + _ctx->dwStartTime = _vm->GetTime(); - + if (sX) _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; else @@ -1351,7 +1301,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui break; _ctx->pt = _ctx->startpt; - + if (sX) { if (_ctx->lx > 0) _ctx->pt.x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; @@ -1359,30 +1309,41 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt.x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; } else { if (_ctx->ly > 0) - _ctx->pt.y += (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt.y += (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; else - _ctx->pt.y -= (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt.y -= (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; } -/* +/* sX = _ctx->stepX * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); sY = _ctx->stepY * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); if (_ctx->lx > 0) { - _ctx->lx-=sX; if (_ctx->lx < 0) _ctx->lx = 0; - _ctx->pt.Offset(sX,0); + _ctx->lx -= sX; + if (_ctx->lx < 0) + _ctx->lx = 0; + _ctx->pt.Offset(sX, 0); } else if (_ctx->lx < 0) { - _ctx->lx+=sX; if (_ctx->lx > 0) _ctx->lx = 0; - _ctx->pt.Offset(-sX,0); + _ctx->lx += sX; + + if (_ctx->lx > 0) + _ctx->lx = 0; + + _ctx->pt.Offset(-sX, 0); } if (_ctx->ly > 0) { - _ctx->ly-=sY; if (_ctx->ly<0) _ctx->ly = 0; - _ctx->pt.Offset(0,sY); - } else if (_ctx->ly<0) { - _ctx->ly+=sY; if (_ctx->ly > 0) _ctx->ly = 0; - _ctx->pt.Offset(0,-sY); + _ctx->ly -= sY; + if (_ctx->ly < 0) + _ctx->ly = 0; + _ctx->pt.Offset(0, sY); + } else if (_ctx->ly < 0) { + _ctx->ly += sY; + if (_ctx->ly > 0) + _ctx->ly = 0; + + _ctx->pt.Offset(0, -sY); } */ CORO_INVOKE_0(GLOBALS.WaitFrame); @@ -1422,15 +1383,15 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin for (i = 0; i < GLOBALS.curChangedHotspot; i++) if (GLOBALS.ChangedHotspot[i].dwCode == dwCode) { - GLOBALS.ChangedHotspot[i].nX=nX; - GLOBALS.ChangedHotspot[i].nY=nY; + GLOBALS.ChangedHotspot[i].nX = nX; + GLOBALS.ChangedHotspot[i].nY = nY; break; } if (i == GLOBALS.curChangedHotspot) { - GLOBALS.ChangedHotspot[i].dwCode=dwCode; - GLOBALS.ChangedHotspot[i].nX=nX; - GLOBALS.ChangedHotspot[i].nY=nY; + GLOBALS.ChangedHotspot[i].dwCode = dwCode; + GLOBALS.ChangedHotspot[i].nX = nX; + GLOBALS.ChangedHotspot[i].nY = nY; GLOBALS.curChangedHotspot++; } @@ -1448,15 +1409,15 @@ DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - uint32 i; - uint32 curTime; - int dirx,diry; + uint32 i; + uint32 curTime; + int dirx, diry; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->curTime = _vm->GetTime(); - + _ctx->dirx = 1; _ctx->diry = 1; @@ -1480,14 +1441,14 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 GLOBALS.Loc->SetFixedScroll(RMPoint(0, 0)); GLOBALS.Tony->SetFixedScroll(RMPoint(0, 0)); GLOBALS.Unfreeze(); - + CORO_END_CODE; } /* - * Personaggi + * Personaggi */ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { @@ -1496,7 +1457,7 @@ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uin GLOBALS.Character[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); GLOBALS.Character[nChar].r = 255; GLOBALS.Character[nChar].g = 255; - GLOBALS.Character[nChar].b = 255; + GLOBALS.Character[nChar].b = 255; GLOBALS.Character[nChar].talkpattern = 0; GLOBALS.Character[nChar].starttalkpattern = 0; GLOBALS.Character[nChar].endtalkpattern = 0; @@ -1506,33 +1467,33 @@ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uin } DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { - assert(nChar<16); + assert(nChar < 16); GLOBALS.Character[nChar].r = r; GLOBALS.Character[nChar].g = g; GLOBALS.Character[nChar].b = b; } DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { - assert(nChar<16); + assert(nChar < 16); GLOBALS.Character[nChar].talkpattern = tp; GLOBALS.Character[nChar].standpattern = sp; } DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { - assert(nChar<16); - GLOBALS.Character[nChar].starttalkpattern=sp; - GLOBALS.Character[nChar].endtalkpattern=ep; + assert(nChar < 16); + GLOBALS.Character[nChar].starttalkpattern = sp; + GLOBALS.Character[nChar].endtalkpattern = ep; } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - int i; - RMPoint pt; - RMTextDialog *text; - int curOffset; - VoiceHeader *curVoc; - FPSFX *voice; + RMMessage *msg; + int i; + RMPoint pt; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1542,16 +1503,16 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess assert(nChar < 16); _ctx->pt = GLOBALS.Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); - + if (GLOBALS.Character[nChar].starttalkpattern != 0) { GLOBALS.Freeze(); GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].starttalkpattern); GLOBALS.Unfreeze(); - + CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); } - GLOBALS.Freeze(); + GLOBALS.Freeze(); GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].talkpattern); GLOBALS.Unfreeze(); @@ -1559,14 +1520,14 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima -// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(GLOBALS.vdb); } - for (_ctx->i = 0; _ctx->i<_ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) @@ -1578,21 +1539,24 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Skipping _ctx->text->SetSkipStatus(!bIsBack); - + // Allineamento - _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - + _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + // Colore - _ctx->text->SetColor(GLOBALS.Character[nChar].r,GLOBALS.Character[nChar].g,GLOBALS.Character[nChar].b); + _ctx->text->SetColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); // Scrive il testo - _ctx->text->WriteText((*_ctx->msg)[_ctx->i],0); + _ctx->text->WriteText((*_ctx->msg)[_ctx->i], 0); // Setta la posizione _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { + _ctx->text->SetAlwaysDisplay(); + _ctx->text->ForceTime(); + } // Registra il testo GLOBALS.LinkGraphicTask(_ctx->text); @@ -1610,14 +1574,14 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); _ctx->voice->Release(); - _ctx->voice=NULL; + _ctx->voice = NULL; } @@ -1630,7 +1594,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].endtalkpattern); GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); - } + } GLOBALS.Freeze(); GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].standpattern); @@ -1641,7 +1605,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->AddItem(dwCode); + GLOBALS.Inventory->AddItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { @@ -1649,67 +1613,66 @@ DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - GLOBALS.Inventory->ChangeItemStatus(dwCode,dwStatus); + GLOBALS.Inventory->ChangeItemStatus(dwCode, dwStatus); } /* - * Mastri Personaggi + * Mastri Personaggi */ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].code=nCode; - if (nCode== 0) - GLOBALS.MCharacter[nChar].item=NULL; + GLOBALS.MCharacter[nChar].code = nCode; + if (nCode == 0) + GLOBALS.MCharacter[nChar].item = NULL; else - GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(nCode); - GLOBALS.MCharacter[nChar].r=255; - GLOBALS.MCharacter[nChar].g=255; - GLOBALS.MCharacter[nChar].b=255; - GLOBALS.MCharacter[nChar].x=-1; - GLOBALS.MCharacter[nChar].y=-1; + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.MCharacter[nChar].r = 255; + GLOBALS.MCharacter[nChar].g = 255; + GLOBALS.MCharacter[nChar].b = 255; + GLOBALS.MCharacter[nChar].x = -1; + GLOBALS.MCharacter[nChar].y = -1; GLOBALS.MCharacter[nChar].bAlwaysBack = 0; for (int i = 0; i < 10; i++) GLOBALS.MCharacter[nChar].numtalks[i] = 1; GLOBALS.MCharacter[nChar].curgroup = 0; - + GLOBALS.IsMChar[nChar] = true; } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); } DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].x=nX; - GLOBALS.MCharacter[nChar].y=nY; + GLOBALS.MCharacter[nChar].x = nX; + GLOBALS.MCharacter[nChar].y = nY; } DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].r=r; - GLOBALS.MCharacter[nChar].g=g; - GLOBALS.MCharacter[nChar].b=b; + GLOBALS.MCharacter[nChar].r = r; + GLOBALS.MCharacter[nChar].g = g; + GLOBALS.MCharacter[nChar].b = b; } DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { - assert(nChar < 10); + assert(nChar < 10); assert(nGroup < 10); - GLOBALS.MCharacter[nChar].numtalks[nGroup]=nTalks; + GLOBALS.MCharacter[nChar].numtalks[nGroup] = nTalks; } -DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32, uint32) -{ - assert(nChar < 10); +DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32, uint32) { + assert(nChar < 10); assert(nGroup < 10); GLOBALS.MCharacter[nChar].curgroup = nGroup; @@ -1718,28 +1681,28 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 n DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].numtexts=nTexts-1; + GLOBALS.MCharacter[nChar].numtexts = nTexts - 1; GLOBALS.MCharacter[nChar].bInTexts = false; } DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].bAlwaysBack=bAlwaysBack; + GLOBALS.MCharacter[nChar].bAlwaysBack = bAlwaysBack; } DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - int i; - int parm; - RMPoint pt; - uint32 h; - RMTextDialog *text; - int curOffset; - VoiceHeader *curVoc; - FPSFX *voice; + RMMessage *msg; + int i; + int parm; + RMPoint pt; + uint32 h; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1752,14 +1715,14 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; // Calcola la posizione del testo in base al frame corrente - if (GLOBALS.MCharacter[nChar].x==-1) - _ctx->pt=GLOBALS.MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-GLOBALS.Loc->ScrollPosition(); + if (GLOBALS.MCharacter[nChar].x == -1) + _ctx->pt = GLOBALS.MCharacter[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); else - _ctx->pt=RMPoint(GLOBALS.MCharacter[nChar].x,GLOBALS.MCharacter[nChar].y); - + _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); + // Parametro per le azioni speciali: random tra le parlate _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; + GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; // Cerca di eseguire la funzione custom per inizializzare la parlata if (GLOBALS.MCharacter[nChar].item) { @@ -1774,7 +1737,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(GLOBALS.vdb); @@ -1786,20 +1749,19 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS.curBackText->Hide); - } - else + } else _ctx->text = new RMTextDialog; _ctx->text->SetInput(GLOBALS.Input); // Skipping _ctx->text->SetSkipStatus(!bIsBack); - + // Allineamento - _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - + _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + // Colore - _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r,GLOBALS.MCharacter[nChar].g,GLOBALS.MCharacter[nChar].b); + _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); // Scrive il testo _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); @@ -1808,7 +1770,10 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { + _ctx->text->SetAlwaysDisplay(); + _ctx->text->ForceTime(); + } // Registra il testo GLOBALS.LinkGraphicTask(_ctx->text); @@ -1826,7 +1791,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); @@ -1836,7 +1801,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; } - GLOBALS.curBackText = NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; delete _ctx->msg; } @@ -1858,21 +1823,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes /* - * Dialoghi + * Dialoghi */ int curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { CORO_BEGIN_CONTEXT; - LPSTR string; - RMTextDialog *text; - int parm; - uint32 h; - bool bIsBack; - VoiceHeader *curVoc; - FPSFX *voice; - RMPoint pt; + LPSTR string; + RMTextDialog *text; + int parm; + uint32 h; + bool bIsBack; + VoiceHeader *curVoc; + FPSFX *voice; + RMPoint pt; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1881,7 +1846,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato // con la SetAlwaysBack - if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) + if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) _ctx->bIsBack = true; _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); @@ -1890,7 +1855,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(GLOBALS.vdb); -// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1903,12 +1868,12 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; - _ctx->text->SetColor(0,255,0); - _ctx->text->SetPosition(GLOBALS.Tony->Position()-RMPoint(0,130)-GLOBALS.Loc->ScrollPosition()); - _ctx->text->WriteText(_ctx->string,0); + _ctx->text->SetColor(0, 255, 0); + _ctx->text->SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text->WriteText(_ctx->string, 0); if (GLOBALS.dwTonyNumTexts > 0) { - if (!GLOBALS.bTonyInTexts) { + if (!GLOBALS.bTonyInTexts) { if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) @@ -1930,15 +1895,15 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->pt = GLOBALS.Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); if (GLOBALS.Character[nPers].starttalkpattern != 0) { - GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); - GLOBALS.Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); - } + } GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); - _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g,GLOBALS.Character[nPers].b); + _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } else { @@ -1949,7 +1914,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // Parametro per le azioni speciali: random tra le parlate _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; + GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { GLOBALS.MCharacter[nPers].numtexts--; @@ -1960,7 +1925,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); GLOBALS.MCharacter[nPers].curTalk = _ctx->parm; - + if (GLOBALS.MCharacter[nPers].numtexts != 0) { GLOBALS.MCharacter[nPers].bInTexts = true; GLOBALS.MCharacter[nPers].numtexts--; @@ -1977,15 +1942,18 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text = new RMTextDialog; _ctx->text->SetSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); - _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r,GLOBALS.MCharacter[nPers].g,GLOBALS.MCharacter[nPers].b); - _ctx->text->WriteText(_ctx->string,0); + _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); + _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } if (!GLOBALS.bSkipIdle) { _ctx->text->SetInput(GLOBALS.Input); - if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } - _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + if (GLOBALS.bAlwaysDisplay) { + _ctx->text->SetAlwaysDisplay(); + _ctx->text->ForceTime(); + } + _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { @@ -1993,7 +1961,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } @@ -2001,25 +1969,25 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { _ctx->voice->Stop(); _ctx->voice->Release(); - _ctx->voice=NULL; + _ctx->voice = NULL; } if (nPers != 0) { if (!GLOBALS.IsMChar[nPers]) { - if (GLOBALS.Character[nPers].endtalkpattern != 0) { + if (GLOBALS.Character[nPers].endtalkpattern != 0) { GLOBALS.Freeze(); GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].endtalkpattern); GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); - } - + } + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].standpattern); delete _ctx->text; } else { - if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts== 0) || !GLOBALS.MCharacter[nPers].bInTexts) { + if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata - GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk%10) + GLOBALS.MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoAction(31,GLOBALS.MCharacter[nPers].item->MpalCode(),GLOBALS.MCharacter[nPers].curTalk); + GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->MpalCode(), GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -2031,7 +1999,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } } else { - if ((GLOBALS.dwTonyNumTexts== 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { + if ((GLOBALS.dwTonyNumTexts == 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { CORO_INVOKE_0(GLOBALS.Tony->EndTalk); GLOBALS.dwTonyNumTexts = 0; GLOBALS.bTonyInTexts = false; @@ -2050,24 +2018,24 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { CORO_BEGIN_CONTEXT; - uint32 nChoice; - uint32 *sl; - uint32 i, num; - char *string; - RMDialogChoice dc; - int sel; + uint32 nChoice; + uint32 *sl; + uint32 i, num; + char *string; + RMDialogChoice dc; + int sel; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); curDialog = nDialog; - + // Call MPAL to start the dialog mpalQueryDoDialog(nDialog, nStartGroup); // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); - while (_ctx->nChoice != (uint32)-1) { + while (_ctx->nChoice != (uint32) - 1) { // Si fa dare la lista di opzioni e le conta _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) @@ -2082,7 +2050,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr mpalQueryDialogWaitForChoice(&_ctx->nChoice); continue; } - + // Crea una scelta per il dialogo _ctx->dc.Init(); _ctx->dc.SetNumChoices(_ctx->num); @@ -2102,17 +2070,17 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Disegna il puntatore GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); - + while (!(GLOBALS.Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->MousePos()); GLOBALS.Unfreeze(); - } + } // Nascondi il puntatore MainHideMouse(); - + CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); @@ -2130,7 +2098,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr /* - * Sync tra idle e mpal + * Sync tra idle e mpal */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2138,7 +2106,7 @@ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, u } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.pulseEvent(GLOBALS.mut[num]); + CoroScheduler.pulseEvent(GLOBALS.mut[num]); warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } @@ -2153,20 +2121,20 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 /* - * Musica + * Musica * ------ * * Effetti di fade supportati: * * nFX = 0 - La nuova musica si sostituisce a quella vecchia * nFX=1 - La nuova musica si interfade con quella vecchia - * nFX=2 - La nuova musica subentra a tempo con quella vecchia + * nFX=2 - La nuova musica subentra a tempo con quella vecchia * */ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CONTEXT; - int i; + int i; CORO_END_CONTEXT(_ctx); int nChannel = *(const int *)nMusic; @@ -2183,7 +2151,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { _vm->SetMusicVolume(nChannel, 64); debug("End FadeIn Music"); - + CORO_KILL_SELF(); CORO_END_CODE; @@ -2191,8 +2159,8 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CONTEXT; - int i; - int startVolume; + int i; + int startVolume; CORO_END_CONTEXT(_ctx); int nChannel = *(const int *)nMusic; @@ -2209,7 +2177,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_INVOKE_1(CoroScheduler.sleep, 100); } - + if (!GLOBALS.bFadeOutStop) _vm->SetMusicVolume(nChannel, 0); @@ -2282,21 +2250,21 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int } DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { - if (nFX == 0 || nFX == 1 || nFX==2) { + if (nFX == 0 || nFX == 1 || nFX == 2) { debug("PlaySonoriz stop fadeout"); GLOBALS.bFadeOutStop = true; } - + GLOBALS.lastMusic = nMusic; CustPlayMusic(GLOBALS.curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { - CustPlayMusic(2,staccFileNames[nMusic],nFX,bLoop); + CustPlayMusic(2, staccFileNames[nMusic], nFX, bLoop); } DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { - if (nItem== 0) { + if (nItem == 0) { GLOBALS.Tony->PlaySfx(nSFX); } else { RMItem *item = GLOBALS.Loc->GetItemFromCode(nItem); @@ -2340,7 +2308,7 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(CORO_PARAM, uint32 nStacc, uint32 b CORO_INVOKE_4(FadeOutSonoriz, 0, 0, 0, 0); CORO_INVOKE_4(MuteStacchetto, 0, 0, 0, 0); CORO_INVOKE_4(PlayStacchetto, nStacc, 0, bLoop, 0); - CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); CORO_END_CODE; } @@ -2403,21 +2371,21 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint32, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - RMTextDialog *text; - uint32 hDisable; - int i; - uint32 startTime; + RMMessage *msg; + RMTextDialog *text; + uint32 hDisable; + int i; + uint32 startTime; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->msg = new RMMessage(nMsg); _ctx->hDisable = CoroScheduler.createEvent(true, false); - + _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { _ctx->text[_ctx->i].SetInput(GLOBALS.Input); // Alignment @@ -2426,24 +2394,24 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text[_ctx->i].WriteText(&(*_ctx->msg)[_ctx->i][1], 3); _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { - _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT,RMText::VTOP); + _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT, RMText::VTOP); _ctx->text[_ctx->i].WriteText((*_ctx->msg)[_ctx->i], 3); _ctx->text[_ctx->i].SetPosition(RMPoint(260, 70 + _ctx->i * 26)); } - - + + // Setta la posizione _ctx->text[_ctx->i].SetAlwaysDisplay(); _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); _ctx->text[_ctx->i].SetNoTab(); - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); // Registra il testo GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } - + _ctx->startTime = _vm->GetTime(); while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { @@ -2469,155 +2437,155 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 BEGIN_CUSTOM_FUNCTION_MAP() - ASSIGN( 1, CustLoadLocation) - ASSIGN( 2, MySleep) - ASSIGN( 3, SetPointer) - ASSIGN( 5, MoveTony) - ASSIGN( 6, FaceToMe) - ASSIGN( 7, BackToMe) - ASSIGN( 8, LeftToMe) - ASSIGN( 9, RightToMe) - ASSIGN( 10, SendTonyMessage) - ASSIGN( 11, ChangeBoxStatus) - ASSIGN( 12, ChangeLocation) - ASSIGN( 13, DisableTony) - ASSIGN( 14, EnableTony) - ASSIGN( 15, WaitForPatternEnd) - ASSIGN( 16, SetLocStartPosition) - ASSIGN( 17, ScrollLocation) - ASSIGN( 18, MoveTonyAndWait) - ASSIGN( 19, ChangeHotspot) - ASSIGN( 20, AddInventory) - ASSIGN( 21, RemoveInventory) - ASSIGN( 22, ChangeInventoryStatus) - ASSIGN( 23, SetTonyPosition) - ASSIGN( 24, SendFullscreenMessage) - ASSIGN( 25, SaveTonyPosition) - ASSIGN( 26, RestoreTonyPosition) - ASSIGN( 27, DisableInput) - ASSIGN( 28, EnableInput) - ASSIGN( 29, StopTony) - - ASSIGN( 30, TonyTakeUp1) - ASSIGN( 31, TonyTakeMid1) - ASSIGN( 32, TonyTakeDown1) - ASSIGN( 33, TonyTakeUp2) - ASSIGN( 34, TonyTakeMid2) - ASSIGN( 35, TonyTakeDown2) - - ASSIGN( 72, TonyPutUp1) - ASSIGN( 73, TonyPutMid1) - ASSIGN( 74, TonyPutDown1) - ASSIGN( 75, TonyPutUp2) - ASSIGN( 76, TonyPutMid2) - ASSIGN( 77, TonyPutDown2) - - ASSIGN( 36, TonyPerTerra) - ASSIGN( 37, TonySiRialza) - ASSIGN( 38, TonyPastorella) - ASSIGN( 39, TonyFischietto) - - ASSIGN( 40, TonyRide) - ASSIGN( 41, TonyFianchi) - ASSIGN( 42, TonyCanta) - ASSIGN( 43, TonySiIndica) - ASSIGN( 44, TonySpaventatoConMani) - ASSIGN( 49, TonySpaventatoSenzaMani) - ASSIGN( 45, TonyConBicchiere) - ASSIGN( 46, TonyConVerme) - ASSIGN( 47, TonyConMartello) - ASSIGN( 48, TonyConCorda) - ASSIGN( 90, TonyConConiglioANIM) - ASSIGN( 91, TonyConRicettaANIM) - ASSIGN( 92, TonyConCarteANIM) - ASSIGN( 93, TonyConPupazzoANIM) - ASSIGN( 94, TonyConPupazzoStart) - ASSIGN( 95, TonyConPupazzoEnd) - ASSIGN( 96, TonyConConiglioStart) - ASSIGN( 97, TonyConConiglioEnd) - ASSIGN( 98, TonyConRicettaStart) - ASSIGN( 99, TonyConRicettaEnd) - ASSIGN(100, TonyConCarteStart) - ASSIGN(101, TonyConCarteEnd) - ASSIGN(102, TonyConTaccuinoStart) - ASSIGN(103, TonyConTaccuinoEnd) - ASSIGN(104, TonyConMegafonoStart) - ASSIGN(105, TonyConMegafonoEnd) - ASSIGN(106, TonyConBarbaStart) - ASSIGN(107, TonyConBarbaEnd) - ASSIGN(108, TonyRidacchia) - ASSIGN(109, TonySchifato) - ASSIGN(110, TonyNaah) - ASSIGN(111, TonyMacbeth) - ASSIGN(112, TonySniffaLeft) - ASSIGN(113, TonySniffaRight) - ASSIGN(114, TonySpaventatoStart) - ASSIGN(115, TonySpaventatoEnd) - ASSIGN(116, TonyConSegretaria) - - ASSIGN( 50, CharSetCode) - ASSIGN( 51, CharSetColor) - ASSIGN( 52, CharSetTalkPattern) - ASSIGN( 53, CharSendMessage) - ASSIGN( 54, CharSetStartEndTalkPattern) - - ASSIGN( 60, MCharSetCode) - ASSIGN( 61, MCharSetColor) - ASSIGN( 62, MCharSetCurrentGroup) - ASSIGN( 63, MCharSetNumTalksInGroup) - ASSIGN( 64, MCharSetNumTexts) - ASSIGN( 65, MCharSendMessage) - ASSIGN( 66, MCharSetPosition) - ASSIGN( 67, MCharSetAlwaysBack) - ASSIGN( 68, MCharResetCode) - - ASSIGN( 70, StartDialog) - ASSIGN( 71, SendDialogMessage) - - ASSIGN( 80, TakeOwnership) - ASSIGN( 81, ReleaseOwnership) - - ASSIGN( 86, PlaySonoriz) - ASSIGN( 87, PlayStacchetto) - ASSIGN( 88, FadeInSonoriz) - ASSIGN( 89, FadeOutSonoriz) - ASSIGN(123, FadeInStacchetto) - ASSIGN(124, FadeOutStacchetto) - ASSIGN(125, MuteSonoriz) - ASSIGN(126, DemuteSonoriz) - ASSIGN(127, MuteStacchetto) - ASSIGN(128, DemuteStacchetto) - ASSIGN( 84, StopSonoriz) - ASSIGN( 85, StopStacchetto) - ASSIGN( 83, PlayItemSfx) - ASSIGN(129, StacchettoFadeStart) - ASSIGN(130, StacchettoFadeEnd) - - ASSIGN(120, TremaSchermo) - ASSIGN(121, AutoSave) - ASSIGN(122, Abort) - ASSIGN(131, NoOcchioDiBue) - ASSIGN(132, SendFullscreenMsgStart) - ASSIGN(133, SendFullscreenMsgEnd) - ASSIGN(134, CustEnableGUI) - ASSIGN(135, CustDisableGUI) - ASSIGN(136, ClearScreen) - ASSIGN(137, PatIrqFreeze) - ASSIGN(138, TonySetPalesati) - ASSIGN(139, OpenInitLoadMenu) - ASSIGN(140, OpenInitOptions) - ASSIGN(141, SyncScrollLocation) - ASSIGN(142, CloseLocation) - ASSIGN(143, SetAlwaysDisplay) - ASSIGN(144, DoCredits) - - ASSIGN( 200, MustSkipIdleStart); - ASSIGN( 201, MustSkipIdleEnd); +ASSIGN(1, CustLoadLocation) +ASSIGN(2, MySleep) +ASSIGN(3, SetPointer) +ASSIGN(5, MoveTony) +ASSIGN(6, FaceToMe) +ASSIGN(7, BackToMe) +ASSIGN(8, LeftToMe) +ASSIGN(9, RightToMe) +ASSIGN(10, SendTonyMessage) +ASSIGN(11, ChangeBoxStatus) +ASSIGN(12, ChangeLocation) +ASSIGN(13, DisableTony) +ASSIGN(14, EnableTony) +ASSIGN(15, WaitForPatternEnd) +ASSIGN(16, SetLocStartPosition) +ASSIGN(17, ScrollLocation) +ASSIGN(18, MoveTonyAndWait) +ASSIGN(19, ChangeHotspot) +ASSIGN(20, AddInventory) +ASSIGN(21, RemoveInventory) +ASSIGN(22, ChangeInventoryStatus) +ASSIGN(23, SetTonyPosition) +ASSIGN(24, SendFullscreenMessage) +ASSIGN(25, SaveTonyPosition) +ASSIGN(26, RestoreTonyPosition) +ASSIGN(27, DisableInput) +ASSIGN(28, EnableInput) +ASSIGN(29, StopTony) + +ASSIGN(30, TonyTakeUp1) +ASSIGN(31, TonyTakeMid1) +ASSIGN(32, TonyTakeDown1) +ASSIGN(33, TonyTakeUp2) +ASSIGN(34, TonyTakeMid2) +ASSIGN(35, TonyTakeDown2) + +ASSIGN(72, TonyPutUp1) +ASSIGN(73, TonyPutMid1) +ASSIGN(74, TonyPutDown1) +ASSIGN(75, TonyPutUp2) +ASSIGN(76, TonyPutMid2) +ASSIGN(77, TonyPutDown2) + +ASSIGN(36, TonyPerTerra) +ASSIGN(37, TonySiRialza) +ASSIGN(38, TonyPastorella) +ASSIGN(39, TonyFischietto) + +ASSIGN(40, TonyRide) +ASSIGN(41, TonyFianchi) +ASSIGN(42, TonyCanta) +ASSIGN(43, TonySiIndica) +ASSIGN(44, TonySpaventatoConMani) +ASSIGN(49, TonySpaventatoSenzaMani) +ASSIGN(45, TonyConBicchiere) +ASSIGN(46, TonyConVerme) +ASSIGN(47, TonyConMartello) +ASSIGN(48, TonyConCorda) +ASSIGN(90, TonyConConiglioANIM) +ASSIGN(91, TonyConRicettaANIM) +ASSIGN(92, TonyConCarteANIM) +ASSIGN(93, TonyConPupazzoANIM) +ASSIGN(94, TonyConPupazzoStart) +ASSIGN(95, TonyConPupazzoEnd) +ASSIGN(96, TonyConConiglioStart) +ASSIGN(97, TonyConConiglioEnd) +ASSIGN(98, TonyConRicettaStart) +ASSIGN(99, TonyConRicettaEnd) +ASSIGN(100, TonyConCarteStart) +ASSIGN(101, TonyConCarteEnd) +ASSIGN(102, TonyConTaccuinoStart) +ASSIGN(103, TonyConTaccuinoEnd) +ASSIGN(104, TonyConMegafonoStart) +ASSIGN(105, TonyConMegafonoEnd) +ASSIGN(106, TonyConBarbaStart) +ASSIGN(107, TonyConBarbaEnd) +ASSIGN(108, TonyRidacchia) +ASSIGN(109, TonySchifato) +ASSIGN(110, TonyNaah) +ASSIGN(111, TonyMacbeth) +ASSIGN(112, TonySniffaLeft) +ASSIGN(113, TonySniffaRight) +ASSIGN(114, TonySpaventatoStart) +ASSIGN(115, TonySpaventatoEnd) +ASSIGN(116, TonyConSegretaria) + +ASSIGN(50, CharSetCode) +ASSIGN(51, CharSetColor) +ASSIGN(52, CharSetTalkPattern) +ASSIGN(53, CharSendMessage) +ASSIGN(54, CharSetStartEndTalkPattern) + +ASSIGN(60, MCharSetCode) +ASSIGN(61, MCharSetColor) +ASSIGN(62, MCharSetCurrentGroup) +ASSIGN(63, MCharSetNumTalksInGroup) +ASSIGN(64, MCharSetNumTexts) +ASSIGN(65, MCharSendMessage) +ASSIGN(66, MCharSetPosition) +ASSIGN(67, MCharSetAlwaysBack) +ASSIGN(68, MCharResetCode) + +ASSIGN(70, StartDialog) +ASSIGN(71, SendDialogMessage) + +ASSIGN(80, TakeOwnership) +ASSIGN(81, ReleaseOwnership) + +ASSIGN(86, PlaySonoriz) +ASSIGN(87, PlayStacchetto) +ASSIGN(88, FadeInSonoriz) +ASSIGN(89, FadeOutSonoriz) +ASSIGN(123, FadeInStacchetto) +ASSIGN(124, FadeOutStacchetto) +ASSIGN(125, MuteSonoriz) +ASSIGN(126, DemuteSonoriz) +ASSIGN(127, MuteStacchetto) +ASSIGN(128, DemuteStacchetto) +ASSIGN(84, StopSonoriz) +ASSIGN(85, StopStacchetto) +ASSIGN(83, PlayItemSfx) +ASSIGN(129, StacchettoFadeStart) +ASSIGN(130, StacchettoFadeEnd) + +ASSIGN(120, TremaSchermo) +ASSIGN(121, AutoSave) +ASSIGN(122, Abort) +ASSIGN(131, NoOcchioDiBue) +ASSIGN(132, SendFullscreenMsgStart) +ASSIGN(133, SendFullscreenMsgEnd) +ASSIGN(134, CustEnableGUI) +ASSIGN(135, CustDisableGUI) +ASSIGN(136, ClearScreen) +ASSIGN(137, PatIrqFreeze) +ASSIGN(138, TonySetPalesati) +ASSIGN(139, OpenInitLoadMenu) +ASSIGN(140, OpenInitOptions) +ASSIGN(141, SyncScrollLocation) +ASSIGN(142, CloseLocation) +ASSIGN(143, SetAlwaysDisplay) +ASSIGN(144, DoCredits) + +ASSIGN(200, MustSkipIdleStart); +ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { - GLOBALS.Tony = tony; + GLOBALS.Tony = tony; GLOBALS.Pointer = ptr; GLOBALS.Boxes = box; GLOBALS.Loc = loc; @@ -2643,7 +2611,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.bAlwaysDisplay = false; int i; - for (i = 0;i < 10; i++) + for (i = 0; i < 10; i++) GLOBALS.mut[i] = CoroScheduler.createEvent(false, false); for (i = 0; i < 200; i++) diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 875710f974..9b53dc32d7 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -38,32 +38,30 @@ namespace Tony { using namespace MPAL; /* - * Defines + * Defines */ typedef uint32 HWND; -#define INIT_CUSTOM_FUNCTION MapCustomFunctions -#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" +#define INIT_CUSTOM_FUNCTION MapCustomFunctions +#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" -#define DECLARE_CUSTOM_FUNCTION(x) void x +#define DECLARE_CUSTOM_FUNCTION(x) void x -#define BEGIN_CUSTOM_FUNCTION_MAP() \ - static void AssignError(int num) { \ - error("Custom function %u has been already assigned!", num); \ - } \ +#define BEGIN_CUSTOM_FUNCTION_MAP() \ + static void AssignError(int num) { \ + error("Custom function %u has been already assigned!", num); \ + } \ void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap) \ - { + { - -#define END_CUSTOM_FUNCTION_MAP() \ +#define END_CUSTOM_FUNCTION_MAP() \ } - -#define ASSIGN(num, func) \ - if (lpMap[num] != NULL) \ - AssignError(num); \ - lpMap[num] = func; \ +#define ASSIGN(num, func) \ + if (lpMap[num] != NULL) \ + AssignError(num); \ + lpMap[num] = func; \ lpStrMap[num] = #func; class RMTony; diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 7a943223a4..944f717f26 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -44,8 +44,8 @@ Common::Language TonyEngine::getLanguage() const { return _gameDescription->desc.language; } -bool TonyEngine::getIsDemo() const { - return _gameDescription->desc.flags & ADGF_DEMO; +bool TonyEngine::getIsDemo() const { + return _gameDescription->desc.flags & ADGF_DEMO; } } @@ -79,14 +79,14 @@ public: bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { return - (f == kSupportsListSaves) || + (f == kSupportsListSaves) || // (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave); + (f == kSupportsDeleteSave); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { return - (f == kSupportsRTL); + (f == kSupportsRTL); } bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { @@ -104,7 +104,7 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { Common::String pattern = "tony.0??"; filenames = saveFileMan->listSavefiles(pattern); - sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) SaveStateList saveList; for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { @@ -126,7 +126,9 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { return saveList; } -int TonyMetaEngine::getMaximumSaveSlot() const { return 99; } +int TonyMetaEngine::getMaximumSaveSlot() const { + return 99; +} void TonyMetaEngine::removeSaveState(const char *target, int slot) const { Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); @@ -135,7 +137,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { } #if PLUGIN_ENABLED_DYNAMIC(TONY) - REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else - REGISTER_PLUGIN_STATIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +REGISTER_PLUGIN_STATIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #endif diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index c2af10c74a..5396b73796 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -73,8 +73,7 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes if (nChars == 112 && palResID == RES_F_PAL) { // Font parla DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } - else if (nChars == 102 && palResID == RES_F_PAL) { + } else if (nChars == 102 && palResID == RES_F_PAL) { // Font macc DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } else if (nChars == 85 && palResID == RES_F_PAL) { @@ -82,7 +81,7 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } else if (nChars == 112 && palResID == RES_F_CPAL) { // Font credits - DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } #endif @@ -96,7 +95,7 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes m_fontDimx = dimx; m_fontDimy = dimy; - nLetters=nChars; + nLetters = nChars; } void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { @@ -172,7 +171,7 @@ int RMFont::StringLen(char bChar, char bNext) { \****************************************************************************/ RMFontColor::RMFontColor() : RMFont() { - m_r = m_g = m_b = 255; + m_r = m_g = m_b = 255; } RMFontColor::~RMFontColor() { @@ -189,7 +188,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { int bstep = b / 14; int i; - byte pal[768*3]; + byte pal[768 * 3]; // Controlla se siamo gia' sul colore giusto if (m_r == r1 && m_g == g1 && m_b == b1) @@ -201,18 +200,18 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { // Costruisce la nuova palette per il font for (i = 1; i < 16; i++) { - pal[i * 3 + 0] = r >> 16; - pal[i * 3 + 1] = g >> 16; - pal[i * 3 + 2] = b >> 16; + pal[i * 3 + 0] = r >> 16; + pal[i * 3 + 1] = g >> 16; + pal[i * 3 + 2] = b >> 16; r -= rstep; g -= gstep; b -= bstep; } - pal[15*3 + 0] += 8; - pal[15*3 + 1] += 8; - pal[15*3 + 2] += 8; + pal[15 * 3 + 0] += 8; + pal[15 * 3 + 1] += 8; + pal[15 * 3 + 2] += 8; // La mette in tutte le lettere for (i = 0; i < nLetters; i++) @@ -229,12 +228,12 @@ void RMFontParla::Init(void) { // bernie: numero di caratteri nel font int nchars = - 112 // base - + 18 // polish - + 66 // russian - + 30 // czech - + 8 // french - + 5; // deutsch + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 5; // deutsch Load(RES_F_PARL, nchars, 20, 20); @@ -306,8 +305,8 @@ void RMFontParla::Init(void) { cTable[(byte)''] = 107; cTable[(byte)''] = 108; cTable[(byte)''] = 109; - //cTable[''] = 110; integrale - cTable['\''] = 111; + //cTable[''] = 110; integrale + cTable['\''] = 111; // Un po' di lunghezze lTable[' '] = 9; @@ -346,7 +345,7 @@ void RMFontParla::Init(void) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - + cTable[(byte)''] = 112; cTable[(byte)''] = 113; cTable[(byte)''] = 114; @@ -487,7 +486,7 @@ void RMFontParla::Init(void) { lTable[(byte)''] = 17; lTable[(byte)''] = 18; lTable[(byte)''] = 16; - lTable[(byte)''] = 18; + lTable[(byte)''] = 18; lTable[(byte)''] = 19; lTable[(byte)''] = 11; lTable[(byte)''] = 16; @@ -640,12 +639,12 @@ void RMFontMacc::Init(void) { // bernie: numero di caratteri nel font int nchars = - 102 // base - + 18 // polish - + 66 // russian - + 30 // czech - + 8 // francais - + 5; // deutsch + 102 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // francais + + 5; // deutsch Load(RES_F_MACC, nchars, 11, 16); @@ -654,41 +653,41 @@ void RMFontMacc::Init(void) { lDefault = 10; hDefault = 17; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } for (i = 0; i < 26; i++) - cTable['A'+i] = i + 0; + cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a'+i] = i + 26; + cTable['a' + i] = i + 26; for (i = 0; i < 10; i++) - cTable['0'+i] = i + 52; + cTable['0' + i] = i + 52; cTable['!'] = 62; - //cTable['!'] = 63; // ! rovescia - cTable['\"'] = 64; - cTable['$'] = 65; - cTable['%'] = 66; - cTable['&'] = 67; - cTable['/'] = 68; - cTable['('] = 69; - cTable[')'] = 70; - cTable['='] = 71; - cTable['?'] = 72; - //cTable['?'] = 73; // ? rovescia - cTable['*'] = 74; - cTable['+'] = 75; - cTable[(byte)''] = 76; - cTable[';'] = 77; - cTable[','] = 78; + //cTable['!'] = 63; // ! rovescia + cTable['\"'] = 64; + cTable['$'] = 65; + cTable['%'] = 66; + cTable['&'] = 67; + cTable['/'] = 68; + cTable['('] = 69; + cTable[')'] = 70; + cTable['='] = 71; + cTable['?'] = 72; + //cTable['?'] = 73; // ? rovescia + cTable['*'] = 74; + cTable['+'] = 75; + cTable[(byte)''] = 76; + cTable[';'] = 77; + cTable[','] = 78; cTable['.'] = 79; - cTable[':'] = 80; - cTable['-'] = 81; + cTable[':'] = 80; + cTable['-'] = 81; cTable['<'] = 82; cTable['>'] = 83; cTable['/'] = 84; @@ -698,22 +697,22 @@ void RMFontMacc::Init(void) { cTable[(byte)''] = 88; cTable[(byte)''] = 89; cTable[(byte)''] = 90; - //cTable[(byte)''] = 91; // e col pallino - cTable[(byte)''] = 92; - cTable[(byte)''] = 93; - //cTable[(byte)''] = 94; // i col pallino - cTable[(byte)''] = 95; - cTable[(byte)''] = 96; - //cTable[(byte)''] = 97; // o col pallino - cTable[(byte)''] = 98; - cTable[(byte)''] = 99; - //cTable[(byte)''] = 100; // u col pallino - cTable[(byte)''] = 101; + //cTable[(byte)''] = 91; // e col pallino + cTable[(byte)''] = 92; + cTable[(byte)''] = 93; + //cTable[(byte)''] = 94; // i col pallino + cTable[(byte)''] = 95; + cTable[(byte)''] = 96; + //cTable[(byte)''] = 97; // o col pallino + cTable[(byte)''] = 98; + cTable[(byte)''] = 99; + //cTable[(byte)''] = 100; // u col pallino + cTable[(byte)''] = 101; // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - + cTable[(byte)''] = 102; cTable[(byte)''] = 103; cTable[(byte)''] = 104; @@ -732,7 +731,7 @@ void RMFontMacc::Init(void) { cTable[(byte)''] = 117; cTable[(byte)''] = 118; cTable[(byte)''] = 119; - + lTable[(byte)''] = 14; lTable[(byte)''] = 16; lTable[(byte)''] = 12; @@ -898,7 +897,7 @@ void RMFontMacc::Init(void) { #endif // FONT_RUSSIAN #ifdef FONT_CZECH - + cTable[(byte)''] = 186; cTable[(byte)''] = 187; cTable[(byte)''] = 188; @@ -1007,21 +1006,21 @@ void RMFontCredits::Init(void) { // bernie: numero di caratteri nel font int nchars = - 112 // base - + 18 // polish - + 66 // russian - + 30 // czech - + 8 // french - + 2; // deutsch + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 2; // deutsch Load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); // Default - lDefault=10; - hDefault=28; + lDefault = 10; + hDefault = 28; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; @@ -1040,7 +1039,7 @@ void RMFontCredits::Init(void) { // cTable[''] = 54; // a ^ // cTable[''] = 55; // a pallini cTable[(byte)''] = 56; - cTable[(byte)''] = 57; + cTable[(byte)''] = 57; // cTable[''] = 58; // e ^ // cTable[''] = 59; // e pallini cTable[(byte)''] = 60; @@ -1057,14 +1056,14 @@ void RMFontCredits::Init(void) { // cTable[''] = 71; // u pallini // cTable[''] = 72; // y pallini cTable[(byte)''] = 73; - cTable[(byte)''] = 74; + cTable[(byte)''] = 74; // cTable[''] = 75; // o barrato // cTable[''] = 76; // ac cTable[(byte)''] = 77; // cTable[''] = 78; // ? rovesciato - cTable['?'] = 79; + cTable['?'] = 79; // cTable[''] = 80; // ! rovesciato - cTable['!'] = 81; + cTable['!'] = 81; // cTable[''] = 82; // 1/2 // cTable[''] = 83; // 1/4 cTable['('] = 84; @@ -1081,13 +1080,13 @@ void RMFontCredits::Init(void) { cTable[','] = 95; cTable['^'] = 96; cTable['='] = 97; - cTable['_'] = 98; - cTable['*'] = 99; - cTable['.'] = 100; + cTable['_'] = 98; + cTable['*'] = 99; + cTable['.'] = 100; for (i = 0; i < 10; i++) - cTable['0'+i] = i+101; - cTable['\''] = 111; + cTable['0' + i] = i + 101; + cTable['\''] = 111; lTable[' '] = 11; lTable[(byte)''] = lTable['A'] = 19; @@ -1168,7 +1167,7 @@ void RMFontCredits::Init(void) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - + cTable[(byte)''] = 112; cTable[(byte)''] = 113; cTable[(byte)''] = 114; @@ -1187,7 +1186,7 @@ void RMFontCredits::Init(void) { cTable[(byte)''] = 127; cTable[(byte)''] = 128; cTable[(byte)''] = 129; - + lTable[(byte)''] = 20; lTable[(byte)''] = 12; lTable[(byte)''] = 15; @@ -1310,7 +1309,7 @@ void RMFontCredits::Init(void) { lTable[(byte)''] = 23; lTable[(byte)''] = 23; lTable[(byte)''] = 10; - lTable[(byte)''] = 12; + lTable[(byte)''] = 12; lTable[(byte)''] = 16; lTable[(byte)''] = 12; lTable[(byte)''] = 20; @@ -1462,8 +1461,8 @@ void RMFontCredits::Init(void) { * Metodi di RMFontObj \****************************************************************************/ -#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) -#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) +#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) +#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1478,12 +1477,12 @@ void RMFontObj::Init(void) { //bernie: numero di caratteri nel font (solo maiuscolo) int nchars = - 85 // base - + 9 // polish - + 33 // russian - + 15 // czech - + 0 // francais (no uppercase chars) - + 1; // deutsch + 85 // base + + 9 // polish + + 33 // russian + + 15 // czech + + 0 // francais (no uppercase chars) + + 1; // deutsch Load(RES_F_OBJ, nchars, 25, 30); @@ -1499,8 +1498,8 @@ void RMFontObj::Init(void) { } for (i = 0; i < 26; i++) { - cTable['A' + i] = i+0; - cTable['a' + i] = i+0; + cTable['A' + i] = i + 0; + cTable['a' + i] = i + 0; } for (i = 0; i < 10; i++) @@ -1547,13 +1546,13 @@ void RMFontObj::Init(void) { //cTable[(byte)' '] = 74; e cerchietto cTable[(byte)''] = 75; cTable[(byte)''] = 76; - //cTable[(byte)' '] = 77; i cerchietto + //cTable[(byte)' '] = 77; i cerchietto cTable[(byte)''] = 78; cTable[(byte)''] = cTable[(byte)''] = 79; - //cTable[(byte)' '] = 80; o cerchietto + //cTable[(byte)' '] = 80; o cerchietto cTable[(byte)''] = 81; cTable[(byte)''] = cTable[(byte)''] = 82; - //cTable[' '] = 83; u cerchietto + //cTable[' '] = 83; u cerchietto //cTable[' '] = 84; y dieresi /* Un po' di lunghezze */ @@ -1572,7 +1571,7 @@ void RMFontObj::Init(void) { lTable['8'] = 20; lTable['9'] = 20; - + lTable['a'] = lTable['A'] = lTable[''] = lTable[''] = 17; lTable['b'] = lTable['B'] = 17; lTable['c'] = lTable['C'] = 19; @@ -1601,17 +1600,17 @@ void RMFontObj::Init(void) { lTable[(byte)''] = 17; /* Casi particolari */ - SetBothCase('C','C',2); - SetBothCase('A','T',-2); - SetBothCase('R','S',2); - SetBothCase('H','I',-2); - SetBothCase('T','S',2); - SetBothCase('O','R',2); - SetBothCase('O','L',2); - SetBothCase('O','G',2); - SetBothCase('Z','A',-1); - SetBothCase('R','R',1); - SetBothCase('R','U',3); + SetBothCase('C', 'C', 2); + SetBothCase('A', 'T', -2); + SetBothCase('R', 'S', 2); + SetBothCase('H', 'I', -2); + SetBothCase('T', 'S', 2); + SetBothCase('O', 'R', 2); + SetBothCase('O', 'L', 2); + SetBothCase('O', 'G', 2); + SetBothCase('Z', 'A', -1); + SetBothCase('R', 'R', 1); + SetBothCase('R', 'U', 3); // Polish characters @@ -1622,10 +1621,10 @@ void RMFontObj::Init(void) { cTable[(byte)''] = cTable[(byte)''] = 86; lTable[(byte)''] = lTable[(byte)''] = 22; - + cTable[(byte)''] = cTable[(byte)''] = 87; lTable[(byte)''] = lTable[(byte)''] = 17; - + cTable[(byte)''] = cTable[(byte)''] = 88; lTable[(byte)''] = lTable[(byte)''] = 19; @@ -1654,39 +1653,39 @@ void RMFontObj::Init(void) { cTable[(byte)''] = cTable[(byte)''] = 85; lTable[(byte)''] = lTable[(byte)''] = 20; - cTable[(byte)''] = cTable[(byte)''] =94; - cTable[(byte)''] = cTable[(byte)''] =95; - cTable[(byte)''] = cTable[(byte)''] =96; - cTable[(byte)''] = cTable[(byte)''] =97; - cTable[(byte)''] = cTable[(byte)''] =98; - cTable[(byte)''] = cTable[(byte)''] =99; - cTable[(byte)''] = cTable[(byte)''] =100; - cTable[(byte)''] = cTable[(byte)''] =101; - cTable[(byte)''] = cTable[(byte)''] =102; - cTable[(byte)''] = cTable[(byte)''] =103; - cTable[(byte)''] = cTable[(byte)''] =104; - cTable[(byte)''] = cTable[(byte)''] =105; - cTable[(byte)''] = cTable[(byte)''] =106; - cTable[(byte)''] = cTable[(byte)''] =107; - cTable[(byte)''] = cTable[(byte)''] =108; - cTable[(byte)''] = cTable[(byte)''] =109; - cTable[(byte)''] = cTable[(byte)''] =110; - cTable[(byte)''] = cTable[(byte)''] =111; - cTable[(byte)''] = cTable[(byte)''] =112; - cTable[(byte)''] = cTable[(byte)''] =113; - cTable[(byte)''] = cTable[(byte)''] =114; - cTable[(byte)''] = cTable[(byte)''] =115; - cTable[(byte)''] = cTable[(byte)''] =116; - cTable[(byte)''] = cTable[(byte)''] =117; - cTable[(byte)''] = cTable[(byte)''] =118; - cTable[(byte)''] = cTable[(byte)''] =119; - cTable[(byte)''] = cTable[(byte)''] =120; - cTable[(byte)''] = cTable[(byte)''] =121; - cTable[(byte)''] = cTable[(byte)''] =122; - cTable[(byte)''] = cTable[(byte)''] =123; - cTable[(byte)''] = cTable[(byte)''] =124; - cTable[(byte)''] = cTable[(byte)''] =125; - cTable[(byte)''] = cTable[(byte)''] =126; + cTable[(byte)''] = cTable[(byte)''] = 94; + cTable[(byte)''] = cTable[(byte)''] = 95; + cTable[(byte)''] = cTable[(byte)''] = 96; + cTable[(byte)''] = cTable[(byte)''] = 97; + cTable[(byte)''] = cTable[(byte)''] = 98; + cTable[(byte)''] = cTable[(byte)''] = 99; + cTable[(byte)''] = cTable[(byte)''] = 100; + cTable[(byte)''] = cTable[(byte)''] = 101; + cTable[(byte)''] = cTable[(byte)''] = 102; + cTable[(byte)''] = cTable[(byte)''] = 103; + cTable[(byte)''] = cTable[(byte)''] = 104; + cTable[(byte)''] = cTable[(byte)''] = 105; + cTable[(byte)''] = cTable[(byte)''] = 106; + cTable[(byte)''] = cTable[(byte)''] = 107; + cTable[(byte)''] = cTable[(byte)''] = 108; + cTable[(byte)''] = cTable[(byte)''] = 109; + cTable[(byte)''] = cTable[(byte)''] = 110; + cTable[(byte)''] = cTable[(byte)''] = 111; + cTable[(byte)''] = cTable[(byte)''] = 112; + cTable[(byte)''] = cTable[(byte)''] = 113; + cTable[(byte)''] = cTable[(byte)''] = 114; + cTable[(byte)''] = cTable[(byte)''] = 115; + cTable[(byte)''] = cTable[(byte)''] = 116; + cTable[(byte)''] = cTable[(byte)''] = 117; + cTable[(byte)''] = cTable[(byte)''] = 118; + cTable[(byte)''] = cTable[(byte)''] = 119; + cTable[(byte)''] = cTable[(byte)''] = 120; + cTable[(byte)''] = cTable[(byte)''] = 121; + cTable[(byte)''] = cTable[(byte)''] = 122; + cTable[(byte)''] = cTable[(byte)''] = 123; + cTable[(byte)''] = cTable[(byte)''] = 124; + cTable[(byte)''] = cTable[(byte)''] = 125; + cTable[(byte)''] = cTable[(byte)''] = 126; lTable[(byte)''] = lTable[(byte)''] = 18; @@ -1717,7 +1716,7 @@ void RMFontObj::Init(void) { lTable[(byte)''] = lTable[(byte)''] = 19; lTable[(byte)''] = lTable[(byte)''] = 22; lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 19; lTable[(byte)''] = lTable[(byte)''] = 19; lTable[(byte)''] = lTable[(byte)''] = 15; lTable[(byte)''] = lTable[(byte)''] = 18; @@ -1726,7 +1725,7 @@ void RMFontObj::Init(void) { #endif // FONT_RUSSIAN #ifdef FONT_CZECH - // rep. ceca characters + // rep. ceca characters cTable[(byte)''] = cTable[(byte)''] = 127; cTable[(byte)''] = cTable[(byte)''] = 128; @@ -1744,21 +1743,21 @@ void RMFontObj::Init(void) { cTable[(byte)''] = cTable[(byte)''] = 140; cTable[(byte)''] = cTable[(byte)''] = 141; - lTable[(byte)''] = lTable[(byte)''] =17; - lTable[(byte)''] = lTable[(byte)''] =15; - lTable[(byte)''] = lTable[(byte)''] =22; - lTable[(byte)''] = lTable[(byte)''] =18; - lTable[(byte)''] = lTable[(byte)''] =21; - lTable[(byte)''] = lTable[(byte)''] =16; - lTable[(byte)''] = lTable[(byte)''] =18; - lTable[(byte)''] = lTable[(byte)''] =19; - lTable[(byte)''] = lTable[(byte)''] =17; - lTable[(byte)''] = lTable[(byte)''] =23; - lTable[(byte)''] = lTable[(byte)''] =24; - lTable[(byte)''] = lTable[(byte)''] =17; - lTable[(byte)''] = lTable[(byte)''] =22; - lTable[(byte)''] = lTable[(byte)''] =16; - lTable[(byte)''] = lTable[(byte)''] =16; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 23; + lTable[(byte)''] = lTable[(byte)''] = 24; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; #endif // FONT_CZECH @@ -1817,7 +1816,7 @@ RMText::RMText() { } RMText::~RMText() { - + } void RMText::Unload() { @@ -1835,19 +1834,23 @@ void RMText::SetMaxLineLength(int max) { } void RMText::RemoveThis(CORO_PARAM, bool &result) { - // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso - // etc. +// Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso +// etc. result = true; } void RMText::WriteText(const RMString &text, int nFont, int *time) { - // Inizializza i font (una volta sola) + // Inizializza i font (una volta sola) if (m_fonts[0] == NULL) { - m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); - m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); - m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); - m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); + m_fonts[0] = new RMFontParla; + m_fonts[0]->Init(); + m_fonts[1] = new RMFontObj; + m_fonts[1]->Init(); + m_fonts[2] = new RMFontMacc; + m_fonts[2]->Init(); + m_fonts[3] = new RMFontCredits; + m_fonts[3]->Init(); } WriteText(text, m_fonts[nFont], time); @@ -1870,13 +1873,13 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Si autodistrugge il buffer prima di iniziare Destroy(); - // Se la stringa vuota, non fare nulla + // Se la stringa vuota, non fare nulla if (text == NULL || text[0] == '\0') return; - + // Divide la frase in linee. In questo ciclo, X contiene la lunghezza massima raggiunta da una linea // e I il numero delle linee - string=p = text; + string = p = text; i = j = x = 0; while (*p != '\0') { j += font->StringLen(*p); @@ -1912,7 +1915,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { } if (j > x) x = j; - + i++; numlines = i; @@ -1945,7 +1948,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { case HLEFTPAR: if (i == numlines) - x=0; + x = 0; else x = 25; break; @@ -1988,8 +1991,8 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { // Cerca di non farlo uscire dallo schermo if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1+m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1 + m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; } void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2027,7 +2030,7 @@ void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMTextDialog::RMTextDialog() : RMText() { m_startTime = 0; - dst = RMPoint(0,0); + dst = RMPoint(0, 0); m_bSkipStatus = true; m_bShowed = true; @@ -2056,14 +2059,14 @@ void RMTextDialog::Hide(CORO_PARAM) { } void RMTextDialog::WriteText(const RMString &text, int font, int *time) { - RMText::WriteText(text,font,&m_time); + RMText::WriteText(text, font, &m_time); if (time != NULL) *time = m_time; } void RMTextDialog::WriteText(const RMString &text, RMFontColor *font, int *time) { - RMText::WriteText(text,font,&m_time); + RMText::WriteText(text, font, &m_time); if (time != NULL) *time = m_time; @@ -2087,7 +2090,7 @@ void RMTextDialog::SetNoTab(void) { } void RMTextDialog::SetForcedTime(uint32 dwTime) { - m_time = dwTime; + m_time = dwTime; } void RMTextDialog::SetAlwaysDisplay(void) { @@ -2096,7 +2099,7 @@ void RMTextDialog::SetAlwaysDisplay(void) { void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; - bool expired; + bool expired; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2168,7 +2171,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (m_startTime == 0) m_startTime = _vm->GetTime(); - + if (m_bShowed) { if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; @@ -2213,7 +2216,7 @@ RMTextDialogScrolling::~RMTextDialogScrolling() { void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - RMPoint curDst; + RMPoint curDst; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2250,8 +2253,8 @@ RMTextItemName::~RMTextItemName() { void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { CORO_BEGIN_CONTEXT; - RMItem *lastItem; - uint32 hThread; + RMItem *lastItem; + uint32 hThread; CORO_END_CONTEXT(_ctx); RMString itemName; @@ -2263,7 +2266,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & // Adds to the list if there is need if (!m_nInList) bigBuf.AddPrim(new RMGfxPrimitive(this)); - + // Update the scrolling co-ordinates m_curscroll = loc.ScrollPosition(); @@ -2272,7 +2275,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & m_item = inv.WhichItemIsIn(m_mpos); else m_item = loc.WhichItemIsIn(m_mpos); - + itemName = ""; // If there an item, get it's name @@ -2287,7 +2290,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else @@ -2310,30 +2313,30 @@ void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Setta come coordinate destinazione quelle del mouse - prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); + prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::Draw, bigBuf, prim); CORO_END_CODE; } -RMPoint RMTextItemName::GetHotspot() { - if (m_item == NULL) - return m_mpos + m_curscroll; - else - return m_item->Hotspot(); +RMPoint RMTextItemName::GetHotspot() { + if (m_item == NULL) + return m_mpos + m_curscroll; + else + return m_item->Hotspot(); } -RMItem *RMTextItemName::GetSelectedItem() { - return m_item; +RMItem *RMTextItemName::GetSelectedItem() { + return m_item; } -bool RMTextItemName::IsItemSelected() { - return m_item != NULL; +bool RMTextItemName::IsItemSelected() { + return m_item != NULL; } -bool RMTextItemName::IsNormalItemSelected() { - return m_item != NULL && m_itemName.Length() > 0; +bool RMTextItemName::IsNormalItemSelected() { + return m_item != NULL && m_itemName.Length() > 0; } @@ -2345,13 +2348,13 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg1(RES_I_DLGTEXT); RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - + DlgText.Init(dlg1, dlg1.Width(), dlg1.Height()); DlgTextLine.Init(dlg2, dlg2.Width(), dlg2.Height()); DlgText.LoadPaletteWA(dlgpal); DlgTextLine.LoadPaletteWA(dlgpal); - + hUnreg = CoroScheduler.createEvent(false, false); bRemoveFromOT = false; } @@ -2368,8 +2371,7 @@ void RMDialogChoice::Unregister(void) { bRemoveFromOT = false; } -void RMDialogChoice::Init(void) -{ +void RMDialogChoice::Init(void) { m_numChoices = 0; m_drawedStrings = NULL; m_ptDrawStrings = NULL; @@ -2399,7 +2401,7 @@ void RMDialogChoice::SetNumChoices(int num) { m_numChoices = num; m_curAdded = 0; - + // Alloca lo spazio per le stringhe disegnate m_drawedStrings = new RMText[num]; m_ptDrawStrings = new RMPoint[num]; @@ -2416,43 +2418,43 @@ void RMDialogChoice::SetNumChoices(int num) { void RMDialogChoice::AddChoice(const RMString &string) { // Si disegna la stringa assert(m_curAdded < m_numChoices); - m_drawedStrings[m_curAdded++].WriteText(string, 0); + m_drawedStrings[m_curAdded++].WriteText(string, 0); } void RMDialogChoice::Prepare(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int i; - RMPoint ptPos; + int i; + RMPoint ptPos; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); + AddPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); - _ctx->ptPos.Set(20,90); + _ctx->ptPos.Set(20, 90); for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); m_ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0,m_drawedStrings[_ctx->i].Dimy() + 15); + _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].Dimy() + 15); } CORO_INVOKE_0(DrawOT); ClearOT(); - m_ptDrawPos.Set(0,480-_ctx->ptPos.y); + m_ptDrawPos.Set(0, 480 - _ctx->ptPos.y); CORO_END_CODE; } void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { CORO_BEGIN_CONTEXT; - RMGfxBox box; - RMRect rc; + RMGfxBox box; + RMRect rc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2464,7 +2466,7 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { if (m_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); - _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[m_curSelection].y); _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); @@ -2475,8 +2477,8 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { if (pos != -1) { _ctx->box.SetColor(100, 100, 100); - _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].Dimy()); AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } @@ -2491,10 +2493,10 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CONTEXT; - RMPoint destpt; - int deltay; - int starttime; - int elaps; + RMPoint destpt; + int deltay; + int starttime; + int elaps; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2513,8 +2515,8 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); - if (!m_nInList && bigBuf != NULL) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!m_nInList && bigBuf != NULL) + bigBuf->AddPrim(new RMGfxPrimitive(this)); m_bShow = true; _ctx->elaps = 0; @@ -2550,9 +2552,9 @@ void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive void RMDialogChoice::Hide(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int deltay; - int starttime; - int elaps; + int deltay; + int starttime; + int elaps; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2565,7 +2567,7 @@ void RMDialogChoice::Hide(CORO_PARAM) { while (_ctx->elaps < 700) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->elaps = _vm->GetTime()-_ctx->starttime; + _ctx->elaps = _vm->GetTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; MainUnfreeze(); } @@ -2585,14 +2587,14 @@ void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_BEGIN_CONTEXT; - int i; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (ptMousePos.y > m_ptDrawPos.y) { + if (ptMousePos.y > m_ptDrawPos.y) { for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y+m_drawedStrings[_ctx->i].Dimy())) { + if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].Dimy())) { CORO_INVOKE_1(SetSelected, _ctx->i); break; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 9715e95043..3ada4d76c0 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -47,118 +47,126 @@ class RMPointer; */ class RMFont : public RMGfxTaskSetPrior { protected: - int nLetters; - RMGfxSourceBuffer8RLEByte *m_letter; + int nLetters; + RMGfxSourceBuffer8RLEByte *m_letter; public: - int m_fontDimx,m_fontDimy; + int m_fontDimx, m_fontDimy; private: - int m_dimx,m_dimy; + int m_dimx, m_dimy; - class RMFontPrimitive : public RMGfxPrimitive { - public: - RMFontPrimitive() : RMGfxPrimitive() {} - RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} + class RMFontPrimitive : public RMGfxPrimitive { + public: + RMFontPrimitive() : RMGfxPrimitive() {} + RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} virtual ~RMFontPrimitive() { } - virtual RMGfxPrimitive *Duplicate() { return new RMFontPrimitive(*this); } + virtual RMGfxPrimitive *Duplicate() { + return new RMFontPrimitive(*this); + } - int m_nChar; - }; + int m_nChar; + }; protected: - // Caricamento del font - void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + // Caricamento del font + void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - // Scaricamente del font (anche da distruttore) - void Unload(void); + // Scaricamente del font (anche da distruttore) + void Unload(void); protected: - // Conversione (da overloadare) - virtual int ConvertToLetter(int nChar) = 0; + // Conversione (da overloadare) + virtual int ConvertToLetter(int nChar) = 0; - // Lunghezza dei caratteri (da overloadare) - virtual int LetterLength(int nChar, int nNext=0) = 0; + // Lunghezza dei caratteri (da overloadare) + virtual int LetterLength(int nChar, int nNext = 0) = 0; public: - virtual int LetterHeight(void) = 0; + virtual int LetterHeight(void) = 0; public: - RMFont(); - virtual ~RMFont(); + RMFont(); + virtual ~RMFont(); - // Inizializzazione e chiusura - virtual void Init(void) = 0; - virtual void Close(void); + // Inizializzazione e chiusura + virtual void Init(void) = 0; + virtual void Close(void); - // Funzione del task da overloadare - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + // Funzione del task da overloadare + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); - // Crea una primitiva per una lettera - RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); + // Crea una primitiva per una lettera + RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); - // Lunghezza in pixel di una stringa con il font corrente - int StringLen(const RMString &text); - int StringLen(char bChar, char bNext = 0); + // Lunghezza in pixel di una stringa con il font corrente + int StringLen(const RMString &text); + int StringLen(char bChar, char bNext = 0); }; class RMFontColor : public virtual RMFont { private: - byte m_r,m_g,m_b; + byte m_r, m_g, m_b; public: - RMFontColor(); + RMFontColor(); virtual ~RMFontColor(); - virtual void SetBaseColor(byte r, byte g, byte b); + virtual void SetBaseColor(byte r, byte g, byte b); }; class RMFontWithTables : public virtual RMFont { protected: - int cTable[256]; - int lTable[256]; - int lDefault; - int hDefault; - signed char l2Table[256][256]; + int cTable[256]; + int lTable[256]; + int lDefault; + int hDefault; + signed char l2Table[256][256]; protected: - // Overload dei metodi - int ConvertToLetter(int nChar) { return cTable[nChar]; } - int LetterLength(int nChar, int nNext=0) { return (nChar!=-1 ? lTable[nChar]+l2Table[nChar][nNext] : lDefault); } - + // Overload dei metodi + int ConvertToLetter(int nChar) { + return cTable[nChar]; + } + int LetterLength(int nChar, int nNext = 0) { + return (nChar != -1 ? lTable[nChar] + l2Table[nChar][nNext] : lDefault); + } + public: - int LetterHeight() { return hDefault; } + int LetterHeight() { + return hDefault; + } virtual ~RMFontWithTables() {} }; class RMFontParla : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void Init(void); virtual ~RMFontParla() {} }; class RMFontObj : public RMFontColor, public RMFontWithTables { private: - void SetBothCase(int nChar, int nNext, signed char spiazz); + void SetBothCase(int nChar, int nNext, signed char spiazz); public: - void Init(void); + void Init(void); virtual ~RMFontObj() {} }; class RMFontMacc : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void Init(void); virtual ~RMFontMacc() {} }; class RMFontCredits : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void Init(void); virtual ~RMFontCredits() {} - virtual void SetBaseColor(byte r, byte g, byte b) {} + virtual void SetBaseColor(byte r, byte g, byte b) {} }; /** @@ -166,131 +174,140 @@ public: */ class RMText : public RMGfxWoodyBuffer { private: - static RMFontColor *m_fonts[4]; - static RMGfxClearTask m_clear; - int maxLineLength; + static RMFontColor *m_fonts[4]; + static RMGfxClearTask m_clear; + int maxLineLength; public: - enum HORALIGN { - HLEFT, - HLEFTPAR, - HCENTER, - HRIGHT - }; - - enum VERALIGN { - VTOP, - VCENTER, - VBOTTOM - }; + enum HORALIGN { + HLEFT, + HLEFTPAR, + HCENTER, + HRIGHT + }; + + enum VERALIGN { + VTOP, + VCENTER, + VBOTTOM + }; private: HORALIGN aHorType; - VERALIGN aVerType; - byte m_r,m_g,m_b; + VERALIGN aVerType; + byte m_r, m_g, m_b; protected: - virtual void ClipOnScreen(RMGfxPrimitive* prim); + virtual void ClipOnScreen(RMGfxPrimitive *prim); public: - RMText(); - virtual ~RMText(); + RMText(); + virtual ~RMText(); static void InitStatics(); static void Unload(); - // Setta il tipo di allineamento - void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; } - - // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) - void SetMaxLineLength(int max); + // Setta il tipo di allineamento + void SetAlignType(HORALIGN aHor, VERALIGN aVer) { + aHorType = aHor; + aVerType = aVer; + } + + // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) + void SetMaxLineLength(int max); - // Scrive un testo - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + // Scrive un testo + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST - virtual void RemoveThis(CORO_PARAM, bool &result); + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Setta il colore di base - void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } + // Setta il colore di base + void SetColor(byte r, byte g, byte b) { + m_r = r; + m_g = g; + m_b = b; + } }; /** - * Gestisce il testo di un dialogo + * Gestisce il testo di un dialogo */ class RMTextDialog : public RMText { - protected: - int m_startTime; - int m_time; - bool m_bSkipStatus; - RMPoint dst; - uint32 hEndDisplay; - bool m_bShowed; +protected: + int m_startTime; + int m_time; + bool m_bSkipStatus; + RMPoint dst; + uint32 hEndDisplay; + bool m_bShowed; bool m_bForceTime; - bool m_bForceNoTime; + bool m_bForceNoTime; uint32 hCustomSkip; - uint32 hCustomSkip2; - RMInput *m_input; + uint32 hCustomSkip2; + RMInput *m_input; bool m_bAlwaysDisplay; bool m_bNoTab; - public: - RMTextDialog(); - virtual ~RMTextDialog(); - - // Scrive un testo - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST - virtual void RemoveThis(CORO_PARAM, bool &result); - - // Overloading della funzione di deregistrazione, utilizzata per capire - // quando ci leviamo di torno - virtual void Unregister(void); - - // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - - // Setta la posizione - void SetPosition(const RMPoint &pt) { dst = pt; } - - // Aspetta che venga finita la visualizzazione - void WaitForEndDisplay(CORO_PARAM); - void SetCustomSkipHandle(uint32 hCustomSkip); - void SetCustomSkipHandle2(uint32 hCustomSkip); - void SetSkipStatus(bool bEnabled); +public: + RMTextDialog(); + virtual ~RMTextDialog(); + + // Scrive un testo + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual void RemoveThis(CORO_PARAM, bool &result); + + // Overloading della funzione di deregistrazione, utilizzata per capire + // quando ci leviamo di torno + virtual void Unregister(void); + + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Setta la posizione + void SetPosition(const RMPoint &pt) { + dst = pt; + } + + // Aspetta che venga finita la visualizzazione + void WaitForEndDisplay(CORO_PARAM); + void SetCustomSkipHandle(uint32 hCustomSkip); + void SetCustomSkipHandle2(uint32 hCustomSkip); + void SetSkipStatus(bool bEnabled); void SetForcedTime(uint32 dwTime); void SetNoTab(void); void ForceTime(void); void ForceNoTime(void); void SetAlwaysDisplay(void); - - // Setta il dispositivo di input, per permettere skip da mouse - void SetInput(RMInput* input); - void Show(void); - void Hide(CORO_PARAM); + // Setta il dispositivo di input, per permettere skip da mouse + void SetInput(RMInput *input); + + void Show(void); + void Hide(CORO_PARAM); }; class RMTextDialogScrolling : public RMTextDialog { protected: - RMLocation *curLoc; - RMPoint startScroll; + RMLocation *curLoc; + RMPoint startScroll; - virtual void ClipOnScreen(RMGfxPrimitive* prim); + virtual void ClipOnScreen(RMGfxPrimitive *prim); public: - RMTextDialogScrolling(); - RMTextDialogScrolling(RMLocation* loc); + RMTextDialogScrolling(); + RMTextDialogScrolling(RMLocation *loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -302,26 +319,30 @@ public: class RMTextItemName : protected RMText { protected: - RMPoint m_mpos; - RMPoint m_curscroll; - RMItem *m_item; - RMString m_itemName; + RMPoint m_mpos; + RMPoint m_curscroll; + RMItem *m_item; + RMString m_itemName; public: - RMTextItemName(); + RMTextItemName(); virtual ~RMTextItemName(); - - void SetMouseCoord(const RMPoint &m) { m_mpos = m; } - void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void SetMouseCoord(const RMPoint &m) { + m_mpos = m; + } + + void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - RMPoint GetHotspot(); - RMItem *GetSelectedItem(); - bool IsItemSelected(); - bool IsNormalItemSelected(); + RMPoint GetHotspot(); + RMItem *GetSelectedItem(); + bool IsItemSelected(); + bool IsNormalItemSelected(); - virtual void RemoveThis(CORO_PARAM, bool &result) { result = true; } + virtual void RemoveThis(CORO_PARAM, bool &result) { + result = true; + } }; @@ -330,54 +351,54 @@ public: */ class RMDialogChoice : public RMGfxWoodyBuffer { private: - int m_curSelection; - int m_numChoices; - RMText* m_drawedStrings; - RMPoint *m_ptDrawStrings; - int m_curAdded; - bool m_bShow; - RMGfxSourceBuffer8 DlgText; - RMGfxSourceBuffer8 DlgTextLine; - RMPoint m_ptDrawPos; - uint32 hUnreg; - bool bRemoveFromOT; + int m_curSelection; + int m_numChoices; + RMText *m_drawedStrings; + RMPoint *m_ptDrawStrings; + int m_curAdded; + bool m_bShow; + RMGfxSourceBuffer8 DlgText; + RMGfxSourceBuffer8 DlgTextLine; + RMPoint m_ptDrawPos; + uint32 hUnreg; + bool bRemoveFromOT; protected: - void Prepare(CORO_PARAM); - void SetSelected(CORO_PARAM, int pos); - + void Prepare(CORO_PARAM); + void SetSelected(CORO_PARAM, int pos); + public: - virtual void RemoveThis(CORO_PARAM, bool &result); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - void Unregister(void); + virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void Unregister(void); public: - // Inizializzazione - RMDialogChoice(); - virtual ~RMDialogChoice(); - - // Inizializzazione e chiusura - void Init(void); - void Close(void); - - // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte - // con AddChoice() - void SetNumChoices(int num); - - // Aggiunge una stringa con la scelta - void AddChoice(const RMString &string); - - // Mostra e nasconde la scelta, con eventuali animazioni - // NOTA: Se non viene passato parametro alla Show(), obbligo del - // chiamante assicurarsi che la classe venga inserita alla OTlist - void Show(CORO_PARAM, RMGfxTargetBuffer* bigBuf = NULL); - void Hide(CORO_PARAM); - - // Polling di aggiornamento - void DoFrame(CORO_PARAM, RMPoint ptMousePos); - - // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata - int GetSelection(void); + // Inizializzazione + RMDialogChoice(); + virtual ~RMDialogChoice(); + + // Inizializzazione e chiusura + void Init(void); + void Close(void); + + // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte + // con AddChoice() + void SetNumChoices(int num); + + // Aggiunge una stringa con la scelta + void AddChoice(const RMString &string); + + // Mostra e nasconde la scelta, con eventuali animazioni + // NOTA: Se non viene passato parametro alla Show(), obbligo del + // chiamante assicurarsi che la classe venga inserita alla OTlist + void Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); + void Hide(CORO_PARAM); + + // Polling di aggiornamento + void DoFrame(CORO_PARAM, RMPoint ptMousePos); + + // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata + int GetSelection(void); }; } // End of namespace Tony diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 8844374821..64c91008a5 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -44,11 +44,11 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Funzioni globali per la DLL Custom */ +/* Funzioni globali per la DLL Custom */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->GetEngine()->LoadLocation(nLoc, pt,start); + return _vm->GetEngine()->LoadLocation(nLoc, pt, start); } void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { @@ -72,11 +72,11 @@ void MainWaitFrame(CORO_PARAM) { } void MainShowMouse(void) { - _vm->GetEngine()->EnableMouse(); + _vm->GetEngine()->EnableMouse(); } void MainHideMouse(void) { - _vm->GetEngine()->DisableMouse(); + _vm->GetEngine()->DisableMouse(); } void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { @@ -161,7 +161,7 @@ bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRig } } } else { - if (bLeftClick && m_rect.PtInRect(mousePos)) { + if (bLeftClick && m_rect.PtInRect(mousePos)) { m_bActive = !m_bActive; return true; } @@ -176,7 +176,7 @@ void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); - CORO_BEGIN_CODE(_ctx); + CORO_BEGIN_CODE(_ctx); if (!m_bActive) return; @@ -274,9 +274,9 @@ bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRigh void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int i; - int val; - RMPoint pos; + int i; + int val; + RMPoint pos; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -384,22 +384,22 @@ RMOptionScreen::~RMOptionScreen(void) { void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_BEGIN_CONTEXT; - RMGfxSourceBuffer16 *thumb; - RMText* title; - RMText *num[6]; - int i; + RMGfxSourceBuffer16 *thumb; + RMText *title; + RMText *num[6]; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); ClearOT(); AddPrim(new RMGfxPrimitive(m_menu)); - + if (m_bNoLoadSave) - AddPrim(new RMGfxPrimitive(m_HideLoadSave,RMPoint(0, 401))); + AddPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); if (m_bQuitConfirm) { - AddPrim(new RMGfxPrimitive(m_QuitConfirm,RMPoint(270, 200))); + AddPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); m_ButtonQuitYes->AddToList(*this); m_ButtonQuitNo->AddToList(*this); } @@ -450,47 +450,65 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); - if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); - else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); - if (m_curThumbDiff[1] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); - else if (m_curThumbDiff[1] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 57))); - if (m_curThumbDiff[2] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 57))); - else if (m_curThumbDiff[2] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 57))); - if (m_curThumbDiff[3] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(48, 239))); - else if (m_curThumbDiff[3] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(48, 239))); - if (m_curThumbDiff[4] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(240, 239))); - else if (m_curThumbDiff[4] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 239))); - if (m_curThumbDiff[5] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 239))); - else if (m_curThumbDiff[5] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 239))); - - if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); - if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); - if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); - if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); - if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); - if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); + if (m_curThumbDiff[0] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); + else if (m_curThumbDiff[0] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); + if (m_curThumbDiff[1] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); + else if (m_curThumbDiff[1] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); + if (m_curThumbDiff[2] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); + else if (m_curThumbDiff[2] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); + if (m_curThumbDiff[3] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); + else if (m_curThumbDiff[3] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); + if (m_curThumbDiff[4] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); + else if (m_curThumbDiff[4] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); + if (m_curThumbDiff[5] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); + else if (m_curThumbDiff[5] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); + + if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) + AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); + if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) + AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); + if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) + AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); + if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) + AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); + if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) + AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); + if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) + AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); if (m_nEditPos == 0) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 57))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); else if (m_nEditPos == 1) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 57))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); else if (m_nEditPos == 2) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 57))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); else if (m_nEditPos == 3) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 239))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); else if (m_nEditPos == 4) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 239))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); else if (m_nEditPos == 5) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 239))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - + if (m_bEditSaveName && m_nEditPos == _ctx->i) s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); else { @@ -499,23 +517,23 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { else s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); } - + _ctx->num[_ctx->i] = new RMText; _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); _ctx->num[_ctx->i]->WriteText(s, 2); } - + AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[2],RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[3],RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[4],RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[5],RMPoint(439 - 3, 362 + 14))); - + AddPrim(new RMGfxPrimitive(_ctx->num[2], RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[3], RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); + m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - + CORO_INVOKE_0(DrawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { @@ -535,7 +553,7 @@ void RMOptionScreen::RefreshThumbnails(void) { for (i = 0; i < 6; i++) { if (m_curThumb[i]) delete m_curThumb[i]; - + m_curThumb[i] = new RMGfxSourceBuffer16; m_curThumb[i]->Create(640 / 4, 480 / 4); if (!LoadThumbnailFromSaveState(m_statePos + i, *m_curThumb[i], m_curThumbName[i], m_curThumbDiff[i])) { @@ -550,11 +568,11 @@ void RMOptionScreen::RefreshThumbnails(void) { void RMOptionScreen::InitState(CORO_PARAM) { CORO_BEGIN_CONTEXT; - RMResRaw *raw; + RMResRaw *raw; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) _ctx->raw = new RMResRaw(20000 + m_nState); else if (m_nState == MENULOAD || m_nState == MENUSAVE) { @@ -601,14 +619,14 @@ void RMOptionScreen::InitState(CORO_PARAM) { if (m_bAlterGfx) { assert(m_ButtonSave_ArrowLeft == NULL); - m_ButtonSave_ArrowLeft = new RMOptionButton(20026,RMPoint(3,196)); + m_ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); assert(m_ButtonSave_ArrowRight == NULL); m_ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); } else { assert(m_ButtonSave_ArrowLeft == NULL); m_ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); assert(m_ButtonSave_ArrowRight == NULL); - m_ButtonSave_ArrowRight = new RMOptionButton(20014,RMPoint(601, 197)); + m_ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); } } else if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { assert(m_ButtonExit == NULL); @@ -638,7 +656,7 @@ void RMOptionScreen::InitState(CORO_PARAM) { m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); m_ButtonQuitYes->SetPriority(30); assert(m_ButtonQuitNo == NULL); - m_ButtonQuitNo = new RMOptionButton(20023,RMPoint(337, 264)); + m_ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); m_ButtonQuitNo->SetPriority(30); if (m_bNoLoadSave) { @@ -653,16 +671,16 @@ void RMOptionScreen::InitState(CORO_PARAM) { // Menu GAME if (m_nState == MENUGAME) { assert(m_ButtonGame_Lock == NULL); - m_ButtonGame_Lock = new RMOptionButton(20008,RMPoint(176, 262), true); + m_ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); m_ButtonGame_Lock->SetActiveState(GLOBALS.bCfgInvLocked); assert(m_ButtonGame_TimerizedText == NULL); - m_ButtonGame_TimerizedText = new RMOptionButton(20009,RMPoint(463, 273), true); + m_ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); m_ButtonGame_TimerizedText->SetActiveState(!GLOBALS.bCfgTimerizedText); assert(m_ButtonGame_Scrolling == NULL); m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); m_ButtonGame_Scrolling->SetActiveState(GLOBALS.bCfgInvNoScroll); assert(m_ButtonGame_InterUp == NULL); - m_ButtonGame_InterUp = new RMOptionButton(20011,RMPoint(36, 258), true); + m_ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); m_ButtonGame_InterUp->SetActiveState(GLOBALS.bCfgInvUp); assert(m_SlideTextSpeed == NULL); @@ -673,19 +691,19 @@ void RMOptionScreen::InitState(CORO_PARAM) { // Menu Graphics else if (m_nState == MENUGFX) { assert(m_ButtonGfx_Anni30 == NULL); - m_ButtonGfx_Anni30 = new RMOptionButton(20015,RMPoint(247, 178), true); + m_ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); m_ButtonGfx_Anni30->SetActiveState(GLOBALS.bCfgAnni30); assert(m_ButtonGfx_AntiAlias == NULL); m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); m_ButtonGfx_AntiAlias->SetActiveState(!GLOBALS.bCfgAntiAlias); assert(m_ButtonGfx_Sottotitoli == NULL); - m_ButtonGfx_Sottotitoli = new RMOptionButton(20017,RMPoint(98, 82), true); + m_ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); m_ButtonGfx_Sottotitoli->SetActiveState(!GLOBALS.bCfgSottotitoli); assert(m_ButtonGfx_Tips == NULL); - m_ButtonGfx_Tips = new RMOptionButton(20018,RMPoint(431, 246), true); + m_ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); m_ButtonGfx_Tips->SetActiveState(GLOBALS.bCfgInterTips); assert(m_ButtonGfx_Trans == NULL); - m_ButtonGfx_Trans = new RMOptionButton(20019,RMPoint(126, 271), true); + m_ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); m_ButtonGfx_Trans->SetActiveState(!GLOBALS.bCfgTransparence); } else if (m_nState == MENUSOUND) { @@ -700,10 +718,10 @@ void RMOptionScreen::InitState(CORO_PARAM) { m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); m_ButtonSound_DubbingOn->SetActiveState(GLOBALS.bCfgDubbing); assert(m_ButtonSound_MusicOn == NULL); - m_ButtonSound_MusicOn = new RMOptionButton(20034,RMPoint(338, 179), true); + m_ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); m_ButtonSound_MusicOn->SetActiveState(GLOBALS.bCfgMusic); assert(m_ButtonSound_SFXOn == NULL); - m_ButtonSound_SFXOn = new RMOptionButton(20035,RMPoint(338, 283), true); + m_ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); m_ButtonSound_SFXOn->SetActiveState(GLOBALS.bCfgSFX); } } @@ -728,7 +746,7 @@ void RMOptionScreen::CloseState(void) { delete m_curThumb[i]; m_curThumb[i] = NULL; } - + delete m_ButtonSave_States[i]; m_ButtonSave_States[i] = NULL; } @@ -817,11 +835,11 @@ void RMOptionScreen::CloseState(void) { GLOBALS.nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); delete m_SliderSound_Dubbing; m_SliderSound_Dubbing = NULL; - + GLOBALS.nCfgMusicVolume = m_SliderSound_Music->GetValue(); delete m_SliderSound_Music; m_SliderSound_Music = NULL; - + GLOBALS.nCfgSFXVolume = m_SliderSound_SFX->GetValue(); delete m_SliderSound_SFX; m_SliderSound_SFX = NULL; @@ -870,7 +888,7 @@ void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { m_nState = MENUGAME; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -899,7 +917,7 @@ void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_nState = MENULOAD; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -910,7 +928,7 @@ void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - + if (m_FadeStep != 0) { result = false; return; @@ -928,7 +946,7 @@ void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_nState = MENUSAVE; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -956,7 +974,7 @@ void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool m_nState = MENUGAME; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -995,12 +1013,12 @@ void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { CORO_END_CODE; } -void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { +void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { CORO_BEGIN_CONTEXT; - bool bLeftClick, bRightClick; - RMPoint mousePos; - bool bRefresh; - int i; + bool bLeftClick, bRightClick; + RMPoint mousePos; + bool bRefresh; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1063,11 +1081,11 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh |= m_ButtonSound_DubbingOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); _ctx->bRefresh |= m_ButtonSound_MusicOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); _ctx->bRefresh |= m_ButtonSound_SFXOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - + } else if (m_nState == MENULOAD || m_nState == MENUSAVE) { - for (_ctx->i=0;_ctx->i<6;_ctx->i++) + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) m_ButtonSave_States[_ctx->i]->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - + if (m_statePos > 0) _ctx->bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (m_statePos < 90) @@ -1075,10 +1093,10 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - -#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) + +#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } + m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } /**************** STATO BOTTONI **************/ if (m_bEditSaveName) { @@ -1089,9 +1107,9 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(m_EditName) < 12; _ctx->i++) if (KEYPRESS(Common::KEYCODE_LSHIFT) || - KEYPRESS(Common::KEYCODE_RSHIFT)) { + KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); @@ -1099,23 +1117,33 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { for (_ctx->i = 0; _ctx->i < 10 && strlen(m_EditName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); - + + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_SPACE, ' '); + + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP0, '0'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP1, '1'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP2, '2'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP3, '3'); if (strlen(m_EditName) < 12) - PROCESS_CHAR(Common::KEYCODE_SPACE,' '); - - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); + PROCESS_CHAR(Common::KEYCODE_KP4, '4'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP5, '5'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP6, '6'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP7, '7'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP8, '8'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP9, '9'); // ANNULLA - if (KEYPRESS(Common::KEYCODE_ESCAPE)) { + if (KEYPRESS(Common::KEYCODE_ESCAPE)) { m_bEditSaveName = false; _ctx->bRefresh = true; } @@ -1155,11 +1183,11 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (m_ButtonSave_States[_ctx->i]->IsActive()) { + if (m_ButtonSave_States[_ctx->i]->IsActive()) { // C' da effettuare il salvataggio o il caricamento!!!! if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento - CORO_INVOKE_1(_vm->LoadState, m_statePos+_ctx->i); + CORO_INVOKE_1(_vm->LoadState, m_statePos + _ctx->i); Close(); } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { // Attiva la modalit di editing @@ -1247,7 +1275,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int curTime; + int curTime; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1255,17 +1283,17 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _ctx->curTime = _vm->GetTime(); #define FADE_SPEED 20 -#define SYNC (_ctx->curTime-m_FadeTime) / 25 - +#define SYNC (_ctx->curTime-m_FadeTime) / 25 + if (m_bExit) return; if (m_FadeStep == 1) { - // Discesa veloce + // Discesa veloce if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else - m_FadeY += FADE_SPEED*SYNC; + m_FadeY += FADE_SPEED * SYNC; if (m_FadeY > 480) { m_FadeY = 480; m_FadeStep++; @@ -1334,7 +1362,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_bExit = true; m_FadeStep = 0; - // Libera la memoria + // Libera la memoria CloseState(); return; @@ -1357,13 +1385,13 @@ void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { } -bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { +bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { Common::String buf; - char namebuf[256]; + char namebuf[256]; int i; Common::InSaveFile *f; char id[4]; - + // Pulisce la destinazione Common::fill(lpDestBuf, lpDestBuf + 160 * 120 * 2, 0); name = "No name"; @@ -1371,7 +1399,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS // Get the savegame filename for the given slot buf = _vm->GetSaveStateFileName(nState); - + // Try and open the savegame f = g_system->getSavefileManager()->openForLoading(buf); if (f == NULL) @@ -1397,19 +1425,19 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS uint32 cmpsize, size; cmpbuf = new byte[160 * 120 * 4]; - + // Se la versione >= 5, compresso! cmpsize = f->readUint32LE(); f->read(cmpbuf, cmpsize); - lzo1x_decompress(cmpbuf,cmpsize,lpDestBuf,&size); + lzo1x_decompress(cmpbuf, cmpsize, lpDestBuf, &size); delete[] cmpbuf; } else { // Read in the screenshot as an uncompressed data block if (id[3] >= 8) // Recent versions use hardcoded 160x120 uncomrpessed data, so size can be skipped - f->skip(4); + f->skip(4); f->read(lpDestBuf, 160 * 120 * 2); } @@ -1467,7 +1495,7 @@ void RMPointer::Init(void) { m_specialPointer[i] = new RMItem; ds >> *m_specialPointer[i]; } - + //m_hotspot[0].Set(19,5); m_hotspot[0].Set(5, 1); m_hotspot[1].Set(32, 28); @@ -1504,10 +1532,10 @@ int RMPointer::Priority() { void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int n; + int n; CORO_END_CONTEXT(_ctx); - CORO_BEGIN_CODE(_ctx); + CORO_BEGIN_CODE(_ctx); // Controlla il pointer _ctx->n = m_nCurPointer; @@ -1518,7 +1546,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Richiama il draw del puntatore - prim->Dst()-=m_hotspot[_ctx->n]; + prim->Dst() -= m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); @@ -1527,7 +1555,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else // Richiama il draw sul puntatore speciale - CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer-1]->Draw, bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->Draw, bigBuf, prim); } } @@ -1539,8 +1567,8 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->AddPrim(new RMGfxPrimitive(this)); // Se c'e' un puntatore speciale, fa la DoFrame - if (m_nCurSpecialPointer!=0 && m_nCurSpecialPointer!=PTR_CUSTOM) - m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); + if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) + m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); } void RMPointer::RemoveThis(CORO_PARAM, bool &result) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 22df40c6d8..160637d9c2 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -37,19 +37,19 @@ namespace Tony { -#define INIT_GFX16_FROMRAW(dwRes, buf16) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf16) == NULL); \ - (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->Init(*raw,raw->Width(),raw->Height()); \ +#define INIT_GFX16_FROMRAW(dwRes, buf16) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf16) == NULL); \ + (buf16) = new RMGfxSourceBuffer16(false); \ + (buf16)->Init(*raw,raw->Width(),raw->Height()); \ delete raw; -#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf8) == NULL); \ - (buf8) = new RMGfxSourceBuffer8RLEByte(); \ +#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf8) == NULL); \ + (buf8) = new RMGfxSourceBuffer8RLEByte(); \ (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ delete raw; @@ -80,7 +80,7 @@ public: public: // Constructor & destructor - RMPointer(); + RMPointer(); virtual ~RMPointer(); // Initialisation @@ -97,25 +97,34 @@ public: // Overloading draw method virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - + // Sets the current co-ordinates - void SetCoord(const RMPoint &pt) { m_pos = pt; } + void SetCoord(const RMPoint &pt) { + m_pos = pt; + } // Overloading of the method to see if rising from the list virtual void RemoveThis(CORO_PARAM, bool &result); // Sets a new action as current - void SetAction(RMTonyAction action) { m_nCurPointer = action; } + void SetAction(RMTonyAction action) { + m_nCurPointer = action; + } // Sets a new pointer - void SetSpecialPointer(POINTER ptr) { - m_nCurSpecialPointer=ptr; - if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[ptr-1]->SetPattern(1); + void SetSpecialPointer(POINTER ptr) { + m_nCurSpecialPointer = ptr; + if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) + m_specialPointer[ptr - 1]->SetPattern(1); + } + POINTER GetSpecialPointer(void) { + return (POINTER)m_nCurSpecialPointer; } - POINTER GetSpecialPointer(void) { return (POINTER)m_nCurSpecialPointer; } // Set the new custom pointer - void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { m_nCurCustomPointer = ptr; } + void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { + m_nCurCustomPointer = ptr; + } // Return the current action to be applied according to the pointer int CurAction(void); @@ -137,18 +146,22 @@ public: bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); - bool IsActive() { return m_bActive; } - void SetActiveState(bool bState) { m_bActive=bState; } + bool IsActive() { + return m_bActive; + } + void SetActiveState(bool bState) { + m_bActive = bState; + } }; class RMOptionSlide : public RMGfxTaskSetPrior { private: - RMOptionButton* m_PushLeft; - RMOptionButton* m_PushRight; - RMGfxSourceBuffer16* m_SliderCenter; - RMGfxSourceBuffer16* m_SliderLeft; - RMGfxSourceBuffer16* m_SliderRight; - RMGfxSourceBuffer16* m_SliderSingle; + RMOptionButton *m_PushLeft; + RMOptionButton *m_PushRight; + RMGfxSourceBuffer16 *m_SliderCenter; + RMGfxSourceBuffer16 *m_SliderLeft; + RMGfxSourceBuffer16 *m_SliderRight; + RMGfxSourceBuffer16 *m_SliderSingle; int m_nSlideSize; RMPoint m_pos; int m_nValue; @@ -161,9 +174,11 @@ public: bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void AddToList(RMGfxTargetBuffer& bigBuf); + void AddToList(RMGfxTargetBuffer &bigBuf); - int GetValue() { return m_nValue; } + int GetValue() { + return m_nValue; + } }; class RMOptionScreen : public RMGfxWoodyBuffer { @@ -202,7 +217,7 @@ private: bool m_bEditSaveName; int m_nEditPos; char m_EditName[256]; - + union { RMOptionButton *m_ButtonGame_Lock; RMOptionButton *m_ButtonGfx_Anni30; @@ -233,11 +248,11 @@ private: bool m_bAlterGfx; enum STATE { - MENUGAME, - MENUGFX, - MENUSOUND, - MENULOAD, - MENUSAVE + MENUGAME, + MENUGFX, + MENUSOUND, + MENULOAD, + MENUSAVE }; STATE m_nState; @@ -276,7 +291,7 @@ protected: // Ridisegna tutto il menu delle opzioni void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - + }; } // End of namespace Tony diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 826159a8d7..ae68860e79 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -64,9 +64,9 @@ void RMGfxTaskSetPrior::SetPriority(int nPrior) { \****************************************************************************/ RMGfxBuffer::RMGfxBuffer() { - m_dimx = m_dimy = 0; - m_bUseDDraw = false; - m_origBuf = m_buf = NULL; + m_dimx = m_dimy = 0; + m_bUseDDraw = false; + m_origBuf = m_buf = NULL; } RMGfxBuffer::~RMGfxBuffer() { @@ -102,7 +102,7 @@ void RMGfxBuffer::Destroy(void) { void RMGfxBuffer::Lock(void) { if (m_bUseDDraw) { - // Gestisce l'accelerazione + // Gestisce l'accelerazione } } @@ -113,7 +113,7 @@ void RMGfxBuffer::Unlock(void) { } void RMGfxBuffer::OffsetY(int nLines, int nBpp) { - m_buf += nLines* Dimx() * nBpp / 8; + m_buf += nLines * Dimx() * nBpp / 8; } @@ -148,7 +148,7 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { Create(dimx, dimy, Bpp()); CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); - + // Richiama la funzione di preparazione della surface (ereditata) PrepareImage(); @@ -156,10 +156,10 @@ int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalet } -void RMGfxSourceBuffer::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { - Create(dimx, dimy,Bpp()); - ds.Read(m_buf, dimx * dimy*Bpp() / 8); - +void RMGfxSourceBuffer::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + Create(dimx, dimy, Bpp()); + ds.Read(m_buf, dimx * dimy * Bpp() / 8); + // Richiama la funzione di preparazione della surface (ereditata) PrepareImage(); } @@ -171,11 +171,11 @@ void RMGfxSourceBuffer::PrepareImage(void) { // Non fa nulla: puo' essere overloadata se necessaria } -bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer* buf) { +bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { int destw, desth; /* - OBSOLETE CODE: + OBSOLETE CODE: if (buf == NULL) { destw=RM_SX; @@ -185,6 +185,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int desth = buf->Dimy(); } */ + destw = buf->Dimx(); desth = buf->Dimy(); @@ -193,20 +194,25 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int width = m_dimx; height = m_dimy; } - - if (x1 > destw - 1) return false; - if (y1 > desth - 1) return false; - if (x1 < 0) { + if (x1 > destw - 1) + return false; + + if (y1 > desth - 1) + return false; + + if (x1 < 0) { width += x1; - if (width < 0) return false; + if (width < 0) + return false; u -= x1; - x1 = 0; + x1 = 0; } - if (y1 < 0) { + if (y1 < 0) { height += y1; - if (height < 0) return false; + if (height < 0) + return false; v -= y1; y1 = 0; } @@ -227,7 +233,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int * Description: Carica una surface partendo dall'ID della risorsa * * Input: uint32 resID ID della risorsa -* int dimx, dimy Dimensione del buffer +* int dimx, dimy Dimensione del buffer * \****************************************************************************/ @@ -263,7 +269,7 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer() { } RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { + : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { } @@ -307,11 +313,11 @@ void RMGfxTargetBuffer::ClearOT(void) { void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { CORO_BEGIN_CONTEXT; - OTList *cur; - OTList *prev; - OTList *next; - RMGfxPrimitive *myprim; - bool result; + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + bool result; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -323,9 +329,9 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { Lock(); // g_system->lockMutex(csModifyingOT); - while (_ctx->cur != NULL) { + while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva - _ctx->myprim=_ctx->cur->prim->Duplicate(); + _ctx->myprim = _ctx->cur->prim->Duplicate(); CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); delete _ctx->myprim; @@ -335,7 +341,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // Deregistra il task _ctx->cur->prim->m_task->Unregister(); - // Cancella il task liberando la memoria + // Cancella il task liberando la memoria delete _ctx->cur->prim; _ctx->next = _ctx->cur->next; delete _ctx->cur; @@ -388,7 +394,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { } else { cur = otlist; while (cur->next != NULL && nPrior > cur->next->prim->m_task->Priority()) - cur=cur->next; + cur = cur->next; n->next = cur->next; cur->next = n; @@ -403,7 +409,7 @@ void RMGfxTargetBuffer::AddClearTask(void) { /****************************************************************************\ -* Metodi di RMGfxSourceBufferPal +* Metodi di RMGfxSourceBufferPal \****************************************************************************/ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { @@ -420,11 +426,11 @@ int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { m_pal[i * 3 + 2] = buf[i * 3 + 0]; } else - CopyMemory(m_pal,buf,(1<> 3) << 10) | - (((int)m_pal[i * 3 + 1] >> 3) << 5) | - (((int)m_pal[i * 3 + 2] >> 3) << 0); + (((int)m_pal[i * 3 + 1] >> 3) << 5) | + (((int)m_pal[i * 3 + 2] >> 3) << 0); } } int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { int read; - + // Carica l'immagine RAW read = RMGfxSourceBuffer::Init(buf, dimx, dimy); - + // Carica la palette se necessario if (bLoadPalette) read += LoadPaletteWA(&buf[read]); @@ -465,7 +471,7 @@ int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPa void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { // Carica l'immagine RAW RMGfxSourceBuffer::Init(ds, dimx, dimy); - + // Carica la palette se necessario if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; @@ -484,14 +490,14 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer4 +* Metodi di RMGfxSourceBuffer4 \****************************************************************************/ void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx,dimy,4,bUseDDraw) { + : RMGfxBuffer(dimx, dimy, 4, bUseDDraw) { SetPriority(0); } @@ -510,11 +516,11 @@ int RMGfxSourceBuffer4::Bpp() { } void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx,dimy,4,bUseDDraw); + RMGfxBuffer::Create(dimx, dimy, 4, bUseDDraw); } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8 +* Metodi di RMGfxSourceBuffer8 \****************************************************************************/ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { @@ -530,13 +536,13 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit // Destination nel buffer RMRect dst; if (prim->HaveDst()) - dst=prim->Dst(); - + dst = prim->Dst(); + // Esegue il clip if (prim->HaveSrc()) { u = prim->Src().x1; v = prim->Src().y1; - + width = prim->Src().Width(); height = prim->Src().Height(); } @@ -567,7 +573,7 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit for (x = 0; x < width; x += 2) { buf[0] = m_palFinal[raw[0]]; buf[1] = m_palFinal[raw[1]]; - + buf += 2; raw += 2; } @@ -578,7 +584,7 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit } RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx,dimy,8,bUseDDraw) { + : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { SetPriority(0); } @@ -601,26 +607,25 @@ int RMGfxSourceBuffer8::Bpp() { return 8; } -void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw); } -#define GETRED(x) (((x) >> 10) & 0x1F) +#define GETRED(x) (((x) >> 10) & 0x1F) #define GETGREEN(x) (((x) >> 5) & 0x1F) #define GETBLUE(x) ((x) & 0x1F) /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AB +* Metodi di RMGfxSourceBuffer8AB \****************************************************************************/ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { } -int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) -{ - int r,g,b; +int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { + int r, g, b; r = (GETRED(fore) >> 2) + (GETRED(back) >> 1); g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1); @@ -630,13 +635,13 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) if (g > 0x1F) g = 0x1F; if (b > 0x1F) b = 0x1F; - return (r<<10)|(g<<5)|b; + return (r << 10) | (g << 5) | b; } void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; - int bufx=bigBuf.Dimx(); + int bufx = bigBuf.Dimx(); uint16 *buf = bigBuf; byte *raw = m_buf; @@ -644,12 +649,12 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim RMRect dst; if (prim->HaveDst()) dst = prim->Dst(); - + // Esegue il clip if (prim->HaveSrc()) { - u=prim->Src().x1; - v=prim->Src().y1; - + u = prim->Src().x1; + v = prim->Src().y1; + width = prim->Src().Width(); height = prim->Src().Height(); } @@ -675,12 +680,12 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim } } else { for (y = 0; y < height; y++) { - raw = m_buf + (y+v) * m_dimx + u; + raw = m_buf + (y + v) * m_dimx + u; for (x = 0; x < width; x += 2) { buf[0] = CalcTrasp(m_palFinal[raw[0]], buf[0]); buf[1] = CalcTrasp(m_palFinal[raw[1]], buf[1]); - + buf += 2; raw += 2; } @@ -695,7 +700,7 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLE +* Metodi di RMGfxSourceBuffer8RLE \****************************************************************************/ byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; @@ -724,7 +729,7 @@ int RMGfxSourceBuffer8RLE::Init(const byte *buf, int dimx, int dimy, bool bLoadP void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { if (bNeedRLECompress) { - RMGfxSourceBufferPal::Init(ds, dimx, dimy,bLoadPalette); + RMGfxSourceBufferPal::Init(ds, dimx, dimy, bLoadPalette); } else { int size; @@ -745,7 +750,7 @@ void RMGfxSourceBuffer8RLE::PreparePalette(void) { if (alphaBlendColor != -1) { alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; - alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; + alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; } } @@ -770,14 +775,14 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { byte *src; byte *startsrc; int rep; - + // Esegue la compressione RLE, per linee cur = MegaRLEBuf; src = m_buf; - for (y = 0;y < m_dimy; y++) { + for (y = 0; y < m_dimy; y++) { // Si salva l'inizio della linea startline = cur; - + // Lascia lo spazio per la lunghezza della linea cur += 2; @@ -787,7 +792,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { startsrc = src; for (x = 0; x < m_dimx;) { if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) - || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { + || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { src++; rep++; x++; @@ -795,8 +800,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { if (curdata == 0) { RLEWriteTrasp(cur, rep); curdata++; - } - else if (curdata == 1) { + } else if (curdata == 1) { RLEWriteAlphaBlend(cur, rep); curdata++; } else { @@ -807,14 +811,14 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { rep = 0; startsrc = src; } - } - + } + // Dati in sospeso? if (curdata == 1) { RLEWriteAlphaBlend(cur, rep); RLEWriteData(cur, 0, NULL); } - + if (curdata == 2) { RLEWriteData(cur, rep, startsrc); } @@ -825,9 +829,9 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { // Scrive la lunghezza della linea WRITE_LE_UINT16(startline, (uint16)(cur - startline)); } - + // Cancella l'immagine originale - delete[] m_buf; + delete[] m_buf; // Ci copia l'immagine compressa x = cur - MegaRLEBuf; @@ -840,20 +844,20 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri byte *src; uint16 *buf = bigBuf; int x1, y1, u, v, width, height; - + // Clippiamo lo sprite - x1=prim->Dst().x1; - y1=prim->Dst().y1; - if (!Clip2D(x1,y1,u,v,width,height,false,&bigBuf)) + x1 = prim->Dst().x1; + y1 = prim->Dst().y1; + if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; // Andiamo avanti di V linee nell'immagine RLE src = m_buf; - for (y = 0;yIsFlipped()) { @@ -861,8 +865,8 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // width = m_dimx; // x1=prim->Dst().x1; - // Flippiamo il clipping - u = m_dimx - (width+u); + // Flippiamo il clipping + u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; for (y = 0; y < height; y++) { @@ -873,7 +877,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } } else { for (y = 0; y < height; y++) { @@ -884,14 +888,14 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } } } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEByte +* Metodi di RMGfxSourceBuffer8RLEByte \****************************************************************************/ RMGfxSourceBuffer8RLEByte::~RMGfxSourceBuffer8RLEByte() { @@ -900,18 +904,18 @@ RMGfxSourceBuffer8RLEByte::~RMGfxSourceBuffer8RLEByte() { void RMGfxSourceBuffer8RLEByte::RLEWriteTrasp(byte *&cur, int rep) { assert(rep < 255); - *cur ++= rep; + *cur ++ = rep; } void RMGfxSourceBuffer8RLEByte::RLEWriteAlphaBlend(byte *&cur, int rep) { assert(rep < 255); - *cur ++= rep; + *cur ++ = rep; } void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { assert(rep < 256); - - *cur ++= rep; + + *cur ++ = rep; if (rep > 0) { CopyMemory(cur, src, rep); cur += rep; @@ -922,15 +926,15 @@ void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { } void RMGfxSourceBuffer8RLEByte::RLEWriteEOL(byte *&cur) { - *cur ++= 0xFF; + *cur ++ = 0xFF; } void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { int i, n; int r, g, b; - if (nStartSkip == 0) - goto RLEByteDoTrasp; + if (nStartSkip == 0) + goto RLEByteDoTrasp; while (1) { assert(nStartSkip > 0); @@ -939,7 +943,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS n = *src++; if (n == 0xFF) return; - + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; @@ -952,7 +956,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS assert(nStartSkip > 0); - + // ALPHA n = *src++; if (n >= nStartSkip) { @@ -979,11 +983,11 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS RLEByteDoTrasp: // Via il trasp di merda n = *src++; - + // EOL? if (n == 0xFF) - return; - + return; + dst += n; nLength -= n; if (nLength <= 0) @@ -997,15 +1001,15 @@ RLEByteDoAlpha2: if (n > nLength) n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst ++= (r << 10) | (g << 5) | b; + *dst ++ = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1020,9 +1024,9 @@ RLEByteDoAlpha2: RLEByteDoCopy2: if (n > nLength) n = nLength; - - for (i = 0; i < n; i++) - *dst ++= m_palFinal[*src++]; + + for (i = 0; i < n; i++) + *dst ++ = m_palFinal[*src++]; nLength -= n; if (!nLength) @@ -1035,8 +1039,8 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, int i, n; int r, g, b; - if (nStartSkip == 0) - goto RLEByteFlippedDoTrasp; + if (nStartSkip == 0) + goto RLEByteFlippedDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1045,7 +1049,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, n = *src++; if (n == 0xFF) return; - + if (n >= nStartSkip) { dst -= n - nStartSkip; nLength -= n - nStartSkip; @@ -1058,7 +1062,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, assert(nStartSkip > 0); - + // ALPHA n = *src++; if (n >= nStartSkip) { @@ -1071,7 +1075,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, // DATA n = *src++; - if (n >= nStartSkip){ + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; goto RLEByteFlippedDoCopy2; @@ -1085,11 +1089,11 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, RLEByteFlippedDoTrasp: // Via il trasp di merda n = *src++; - + // EOL? if (n == 0xFF) - return; - + return; + dst -= n; nLength -= n; if (nLength <= 0) @@ -1103,15 +1107,15 @@ RLEByteFlippedDoAlpha2: if (n > nLength) n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst--=(r << 10) | (g << 5) | b; + *dst-- = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1126,9 +1130,9 @@ RLEByteFlippedDoAlpha2: RLEByteFlippedDoCopy2: if (n > nLength) n = nLength; - - for (i = 0; i < n; i++) - *dst --= m_palFinal[*src++]; + + for (i = 0; i < n; i++) + *dst -- = m_palFinal[*src++]; nLength -= n; if (!nLength) @@ -1139,10 +1143,10 @@ RLEByteFlippedDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* Metodi di RMGfxSourceBuffer8RLEWord \****************************************************************************/ -RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord(){ +RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord() { } @@ -1161,23 +1165,23 @@ void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { cur += 2; if (rep > 0) { - CopyMemory(cur, src,rep); + CopyMemory(cur, src, rep); cur += rep; - src +=rep; + src += rep; } } void RMGfxSourceBuffer8RLEWord::RLEWriteEOL(byte *&cur) { - *cur ++= 0xFF; - *cur ++= 0xFF; + *cur ++ = 0xFF; + *cur ++ = 0xFF; } void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { int i, n; int r, g, b; - if (nStartSkip == 0) - goto RLEWordDoTrasp; + if (nStartSkip == 0) + goto RLEWordDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1188,11 +1192,11 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS if (n == 0xFFFF) return; - + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; - + if (nLength > 0) goto RLEWordDoAlpha; else @@ -1215,7 +1219,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS // DATA n = READ_LE_UINT16(src); src += 2; - + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; @@ -1231,11 +1235,11 @@ RLEWordDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); src += 2; - + // EOL? if (n == 0xFFFF) - return; - + return; + dst += n; nLength -= n; @@ -1252,15 +1256,15 @@ RLEWordDoAlpha2: n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst++=(r<<10)|(g<<5)|b; + *dst++ = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1273,29 +1277,29 @@ RLEWordDoAlpha2: // Copia la roba n = READ_LE_UINT16(src); src += 2; - + RLEWordDoCopy2: if (n > nLength) n = nLength; - for (i = 0; i < n; i++) - *dst ++= m_palFinal[*src++]; + for (i = 0; i < n; i++) + *dst ++ = m_palFinal[*src++]; nLength -= n; if (!nLength) return; - + assert(nLength > 0); } } void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) { - int i,n; - int r,g,b; + int i, n; + int r, g, b; - if (nStartSkip == 0) - goto RLEWordFlippedDoTrasp; + if (nStartSkip == 0) + goto RLEWordFlippedDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1306,11 +1310,11 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, if (n == 0xFFFF) return; - + if (n >= nStartSkip) { dst -= n - nStartSkip; nLength -= n - nStartSkip; - + if (nLength > 0) goto RLEWordFlippedDoAlpha; else @@ -1333,7 +1337,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, // DATA n = READ_LE_UINT16(src); src += 2; - + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; @@ -1349,11 +1353,11 @@ RLEWordFlippedDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); src += 2; - + // EOL? if (n == 0xFFFF) - return; - + return; + dst -= n; nLength -= n; @@ -1370,15 +1374,15 @@ RLEWordFlippedDoAlpha2: n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst--=(r << 10) | (g << 5) | b; + *dst-- = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1391,24 +1395,24 @@ RLEWordFlippedDoAlpha2: // Copia la roba n = READ_LE_UINT16(src); src += 2; - + RLEWordFlippedDoCopy2: if (n > nLength) n = nLength; - for (i = 0;i 0); } } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* Metodi di RMGfxSourceBuffer8RLEWord \****************************************************************************/ RMGfxSourceBuffer8RLEWordAB::~RMGfxSourceBuffer8RLEWordAB() { @@ -1424,8 +1428,8 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int return; } - if (nStartSkip == 0) - goto RLEWordDoTrasp; + if (nStartSkip == 0) + goto RLEWordDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1436,11 +1440,11 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int if (n == 0xFFFF) return; - + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; - + if (nLength > 0) goto RLEWordDoAlpha; else @@ -1463,7 +1467,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int // DATA n = READ_LE_UINT16(src); src += 2; - + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; @@ -1479,11 +1483,11 @@ RLEWordDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); src += 2; - + // EOL? if (n == 0xFFFF) - return; - + return; + dst += n; nLength -= n; @@ -1499,17 +1503,17 @@ RLEWordDoAlpha2: if (n > nLength) n = nLength; - // @@@ NON DOVREBBE ESSERCI!!!!! + // @@@ NON DOVREBBE ESSERCI!!!!! for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst++=(r<<10)|(g<<5)|b; + *dst++ = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1522,7 +1526,7 @@ RLEWordDoAlpha2: // Copia la roba n = READ_LE_UINT16(src); src += 2; - + RLEWordDoCopy2: if (n > nLength) n = nLength; @@ -1540,14 +1544,14 @@ RLEWordDoCopy2: g = (g >> 1) + (g2 >> 1); b = (b >> 1) + (b2 >> 1); - *dst ++= (r << 10) | (g << 5) | b; + *dst ++ = (r << 10) | (g << 5) | b; src++; } nLength -= n; if (!nLength) return; - + assert(nLength > 0); } @@ -1555,16 +1559,16 @@ RLEWordDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AA +* Metodi di RMGfxSourceBuffer8AA \****************************************************************************/ -byte RMGfxSourceBuffer8AA::MegaAABuf[256*1024]; -byte RMGfxSourceBuffer8AA::MegaAABuf2[64*1024]; +byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; +byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; void RMGfxSourceBuffer8AA::PrepareImage(void) { // Richiama il metodo padre RMGfxSourceBuffer::PrepareImage(); - + // Prepara il buffer di antialiasing CalculateAA(); } @@ -1574,44 +1578,44 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { // Io suxo tu suxi egli suxa noi suxiamo voi suxate essi suxano ---> ANTI ALIASING SUX! // ************************************************************ - int x,y; + int x, y; byte *src, *srcaa; /* Prima passata: cerchiamo i bordi */ Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); - + src = m_buf; - srcaa=MegaAABuf; - for (y = 0;y < m_dimy; y++) { + srcaa = MegaAABuf; + for (y = 0; y < m_dimy; y++) { for (x = 0; x < m_dimx; x++) { if (*src == 0) { if ((y > 0 && src[-m_dimx] != 0) || - (y 0 && src[-1] != 0) || - (x 0 && src[-1] != 0) || + (x < m_dimx - 1 && src[1] != 0)) *srcaa = 1; } src++; srcaa++; - } + } } src = m_buf; - srcaa=MegaAABuf; + srcaa = MegaAABuf; for (y = 0; y < m_dimy; y++) { for (x = 0; x < m_dimx; x++) { if (*src != 0) { - if ((y > 0 && srcaa[-m_dimx]==1) || - (y 0 && srcaa[-1]==1) || - (x 0 && srcaa[-m_dimx] == 1) || + (y < m_dimy - 1 && srcaa[m_dimx] == 1) || + (x > 0 && srcaa[-1] == 1) || + (x < m_dimx - 1 && srcaa[1] == 1)) *srcaa = 2; } src++; srcaa++; - } + } } if (m_aabuf != NULL) @@ -1631,14 +1635,14 @@ RMGfxSourceBuffer8AA::~RMGfxSourceBuffer8AA() { } void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int x,y; + int x, y; byte *src; uint16 *mybuf; uint16 *buf; int x1, y1, u, v, width, height; int r, g, b; int step; - + // Clippiamo lo sprite x1 = prim->Dst().x1; y1 = prim->Dst().y1; @@ -1652,7 +1656,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Annulliamo il clipping orizzontale - // Flippiamo il clipping + // Flippiamo il clipping if (prim->IsFlipped()) { u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; @@ -1660,7 +1664,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // width = m_dimx; // x1=prim->Dst().x1; - + // Posizionamoci nel buffer di destinazione buf = bigBuf; buf += y1 * bigBuf.Dimx(); @@ -1673,12 +1677,12 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Looppone buf += bigBuf.Dimx(); // skippa la prima linea for (y = 1; y < height - 1; y++) { -/* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else -*/ - mybuf=&buf[x1]; + /* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else + */ + mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) if (m_aabuf[(y + v) * m_dimx + x + u] == 2 && x != 0 && x != width - 1) { @@ -1689,7 +1693,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri r += GETRED(mybuf[0]); g += GETGREEN(mybuf[0]); b += GETBLUE(mybuf[0]); - + r /= 5; g /= 5; b /= 5; @@ -1698,28 +1702,28 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (g > 31) g = 31; if (b > 31) b = 31; - mybuf[0]=(r<<10)|(g<<5)|b; + mybuf[0] = (r << 10) | (g << 5) | b; } - + // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } // Posizionamoci nel buffer di destinazione buf = bigBuf; - buf += y1*bigBuf.Dimx(); + buf += y1 * bigBuf.Dimx(); // Looppone - buf+=bigBuf.Dimx(); + buf += bigBuf.Dimx(); for (y = 1; y < height - 1; y++) { -/* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else -*/ - mybuf=&buf[x1]; + /* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else + */ + mybuf = &buf[x1]; - for (x = 0;x < width; x++, mybuf += step) + for (x = 0; x < width; x++, mybuf += step) if (m_aabuf[(y + v) * m_dimx + x + u] == 1 && x != 0 && x != width - 1) { r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); @@ -1728,7 +1732,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri r += GETRED(mybuf[0]) * 2; g += GETGREEN(mybuf[0]) * 2; b += GETBLUE(mybuf[0]) * 2; - + r /= 6; g /= 6; b /= 6; @@ -1737,11 +1741,11 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (g > 31) g = 31; if (b > 31) b = 31; - mybuf[0]=(r<<10)|(g<<5)|b; + mybuf[0] = (r << 10) | (g << 5) | b; } - + // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } } @@ -1761,7 +1765,7 @@ void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEAA +* Metodi di RMGfxSourceBuffer8RLEAA \****************************************************************************/ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { @@ -1782,7 +1786,7 @@ void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf,prim); + DrawAA(bigBuf, prim); CORO_END_CODE; } @@ -1791,8 +1795,8 @@ int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); +void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Carica la maschera di antialiasing @@ -1820,17 +1824,17 @@ void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf,prim); + DrawAA(bigBuf, prim); CORO_END_CODE; } int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy,bLoadPalette); + return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); +void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Carica la maschera di antialiasing @@ -1841,11 +1845,11 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream& ds, int dimx, int dimy, boo /****************************************************************************\ -* Metodi di RMGfxSourceBuffer16 +* Metodi di RMGfxSourceBuffer16 \****************************************************************************/ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { - m_bTrasp0=bTrasp0; + m_bTrasp0 = bTrasp0; } RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { @@ -1854,10 +1858,10 @@ RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; - uint16 *raw = (uint16*)m_buf; + uint16 *raw = (uint16 *)m_buf; int dimx, dimy; - int u,v; - int x1,y1; + int u, v; + int x1, y1; dimx = m_dimx; dimy = m_dimy; @@ -1881,16 +1885,16 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi if (!Clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) return; - raw += v * m_dimx+u; + raw += v * m_dimx + u; buf += y1 * bigBuf.Dimx() + x1; if (m_bTrasp0) { for (y = 0; y < dimy; y++) { for (x = 0; x < dimx;) { - while (xDst(); - buf += rcDst.y1*bigBuf.Dimx() + rcDst.x1; + buf += rcDst.y1 * bigBuf.Dimx() + rcDst.x1; // Fa il suo bravo loop di put for (j = 0; j < rcDst.Height(); j++) { for (i = 0; i < rcDst.Width(); i++) - *buf ++= wFillColor; + *buf ++ = wFillColor; buf += bigBuf.Dimx() - rcDst.Width(); } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index dacb66d68c..3fa29e20f6 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -58,103 +58,157 @@ class RMGfxClearTask; // Task */ class RMGfxBuffer { protected: - int m_dimx, m_dimy; - byte *m_buf; + int m_dimx, m_dimy; + byte *m_buf; byte *m_origBuf; - bool m_bUseDDraw; + bool m_bUseDDraw; public: - RMGfxBuffer(); - RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual ~RMGfxBuffer(); + RMGfxBuffer(); + RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual ~RMGfxBuffer(); - // Attributes - int Dimx() { return m_dimx; } - int Dimy() { return m_dimy; } + // Attributes + int Dimx() { + return m_dimx; + } + int Dimy() { + return m_dimy; + } - // Creation - virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual void Destroy(void); + // Creation + virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void Destroy(void); - // Buffer access - void Lock(void); - void Unlock(void); + // Buffer access + void Lock(void); + void Unlock(void); - // These are valid only if the buffer is locked - operator byte *(); - operator void *(); + // These are valid only if the buffer is locked + operator byte *(); + operator void *(); // Getting the offset for a given Y position void OffsetY(int nLines, int nBpp); }; /** - * Graphics primitive + * Graphics primitive */ class RMGfxPrimitive { public: - RMGfxTask *m_task; + RMGfxTask *m_task; protected: - RMRect m_src; - RMRect m_dst; + RMRect m_src; + RMRect m_dst; -bool m_bStretch; + bool m_bStretch; byte m_bFlag; public: - RMGfxPrimitive() { m_bFlag = 0; m_task = NULL; m_src.SetEmpty(); m_dst.SetEmpty(); } + RMGfxPrimitive() { + m_bFlag = 0; + m_task = NULL; + m_src.SetEmpty(); + m_dst.SetEmpty(); + } - RMGfxPrimitive(RMGfxTask *task) { - m_task = task; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task) { + m_task = task; + m_bFlag = 0; + } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { - m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; + m_task = task; + m_src = src; + m_dst = dst; + m_bFlag = 0; m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); - } + } - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { - m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { + m_task = task; + m_src.TopLeft() = src; + m_dst = dst; + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { - m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { + m_task = task; + m_src.TopLeft() = src; + m_dst.TopLeft() = dst; + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { - m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { + m_task = task; + m_src = src; + m_dst.TopLeft() = dst; + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { - m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { + m_task = task; + m_dst = dst; + m_src.SetEmpty(); + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { - m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { + m_task = task; + m_dst.TopLeft() = dst; + m_src.SetEmpty(); + m_bFlag = 0; + } virtual ~RMGfxPrimitive() { } - void SetFlag(byte bFlag) { m_bFlag=bFlag; } - void SetTask(RMGfxTask *task) { m_task = task; } - void SetSrc(const RMRect &src) { m_src = src; } - void SetSrc(const RMPoint &src) { m_src.TopLeft() = src; } - void SetDst(const RMRect &dst) { m_dst = dst; } - void SetDst(const RMPoint &dst) { m_dst.TopLeft() = dst; } - void SetStrecth(bool bStretch) { m_bStretch = bStretch; } + void SetFlag(byte bFlag) { + m_bFlag = bFlag; + } + void SetTask(RMGfxTask *task) { + m_task = task; + } + void SetSrc(const RMRect &src) { + m_src = src; + } + void SetSrc(const RMPoint &src) { + m_src.TopLeft() = src; + } + void SetDst(const RMRect &dst) { + m_dst = dst; + } + void SetDst(const RMPoint &dst) { + m_dst.TopLeft() = dst; + } + void SetStrecth(bool bStretch) { + m_bStretch = bStretch; + } - bool HaveDst() { return !m_dst.IsEmpty(); } - RMRect &Dst() { return m_dst; } + bool HaveDst() { + return !m_dst.IsEmpty(); + } + RMRect &Dst() { + return m_dst; + } - bool HaveSrc() { return !m_src.IsEmpty(); } - RMRect &Src() { return m_src; } + bool HaveSrc() { + return !m_src.IsEmpty(); + } + RMRect &Src() { + return m_src; + } // Flags - bool IsFlipped() { return m_bFlag&1; } + bool IsFlipped() { + return m_bFlag & 1; + } // Duplicate - virtual RMGfxPrimitive* Duplicate() { return new RMGfxPrimitive(*this); } + virtual RMGfxPrimitive *Duplicate() { + return new RMGfxPrimitive(*this); + } }; @@ -168,16 +222,21 @@ protected: public: // Costruttore standard - RMGfxTask(); + RMGfxTask(); virtual ~RMGfxTask() { } virtual int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual void RemoveThis(CORO_PARAM, bool &result); - + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void RemoveThis(CORO_PARAM, bool &result); + // Registration - virtual void Register(void) { m_nInList++; } - virtual void Unregister(void) { m_nInList--; assert(m_nInList >= 0); } + virtual void Register(void) { + m_nInList++; + } + virtual void Unregister(void) { + m_nInList--; + assert(m_nInList >= 0); + } }; @@ -187,7 +246,7 @@ public: class RMGfxTaskSetPrior : public RMGfxTask { public: virtual ~RMGfxTaskSetPrior() { } - void SetPriority(int nPrior); + void SetPriority(int nPrior); }; @@ -199,7 +258,7 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -207,7 +266,7 @@ public: /** * Task that draws a coloured box */ -class RMGfxBox : public RMGfxTaskSetPrior { +class RMGfxBox : public RMGfxTaskSetPrior { protected: uint16 wFillColor; @@ -225,20 +284,22 @@ public: */ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: - // Carica i dati della surface a basso livello - virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + // Carica i dati della surface a basso livello + virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - + virtual ~RMGfxSourceBuffer(); protected: virtual void PrepareImage(void); bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); - void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines,Bpp()); } + void OffsetY(int nLines) { + RMGfxBuffer::OffsetY(nLines, Bpp()); + } public: - virtual int Bpp() = 0; + virtual int Bpp() = 0; }; @@ -249,17 +310,17 @@ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: virtual void PrepareImage(void); bool m_bTrasp0; - + public: - RMGfxSourceBuffer16(bool bUseTrasp = false); - RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer16(bool bUseTrasp = false); + RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); // Inizializzazione void Create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + int Bpp(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -279,8 +340,8 @@ public: virtual ~RMGfxSourceBufferPal(); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + int LoadPaletteWA(uint32 resID, bool bSwapped = false); int LoadPaletteWA(const byte *buf, bool bSwapped = false); int LoadPalette(uint32 resID); @@ -294,7 +355,7 @@ public: class RMGfxSourceBuffer8 : public RMGfxSourceBufferPal { protected: bool m_bTrasp0; - + public: RMGfxSourceBuffer8(bool bTrasp0 = true); RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw = false); @@ -304,7 +365,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -333,7 +394,7 @@ protected: protected: static byte MegaRLEBuf[]; - + virtual void RLEWriteTrasp(byte *&cur, int rep) = 0; virtual void RLEWriteData(byte *&cur, int rep, byte *src) = 0; virtual void RLEWriteEOL(byte *&cur) = 0; @@ -343,18 +404,18 @@ protected: // Perform image compression in RLE void CompressRLE(void); - + protected: // Overriding initialization methods virtual void PrepareImage(void); - virtual void PreparePalette(void); + virtual void PreparePalette(void); public: RMGfxSourceBuffer8RLE(); virtual ~RMGfxSourceBuffer8RLE(); // Overload of the initialization method - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression @@ -438,7 +499,7 @@ public: // Overloaded initialisation methods virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); }; @@ -451,8 +512,8 @@ public: virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation method - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEWordAA(); }; @@ -463,14 +524,14 @@ public: */ class RMGfxSourceBuffer4 : public RMGfxSourceBufferPal { public: - RMGfxSourceBuffer4(); - RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer4(); + RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); // Initialisation void Create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + int Bpp(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -479,14 +540,16 @@ public: */ class RMGfxTargetBuffer : public virtual RMGfxBuffer { private: -static RMGfxClearTask taskClear; + static RMGfxClearTask taskClear; struct OTList { - RMGfxPrimitive* prim; - OTList* next; + RMGfxPrimitive *prim; + OTList *next; OTList(); - OTList(RMGfxPrimitive* pr) { prim=pr; } + OTList(RMGfxPrimitive *pr) { + prim = pr; + } }; private: @@ -508,15 +571,21 @@ public: // Adds a task to clear the screen void AddClearTask(void); - operator byte *() { return m_buf; } - operator void *() { return (void *)m_buf; } - operator uint16 *() { + operator byte *() { + return m_buf; + } + operator void *() { + return (void *)m_buf; + } + operator uint16 *() { // FIXME: This may not be endian safe - return (uint16 *)m_buf; + return (uint16 *)m_buf; } // Offseting buffer - void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines, 16); } + void OffsetY(int nLines) { + RMGfxBuffer::OffsetY(nLines, 16); + } }; @@ -525,11 +594,11 @@ public: */ class RMGfxWoodyBuffer: public RMGfxSourceBuffer16, public RMGfxTargetBuffer { public: - RMGfxWoodyBuffer(); - RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); + RMGfxWoodyBuffer(); + RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index a2b58f660e..384e80f209 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -68,9 +68,9 @@ RMGfxEngine::RMGfxEngine() { m_nCurLoc = 0; m_curAction = TA_GOTO; m_curActionObj = 0; - m_nWipeType = 0; + m_nWipeType = 0; m_hWipeEvent = 0; - m_nWipeStep = 0; + m_nWipeStep = 0; m_bMustEnterMenu = false; m_bWiping = false; m_bGUIOption = false; @@ -90,7 +90,7 @@ RMGfxEngine::~RMGfxEngine() { void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { CORO_BEGIN_CONTEXT; - bool bRes; + bool bRes; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -120,9 +120,9 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { m_point.SetCustomPointer(NULL); EnableMouse(); _vm->GrabThumbnail(); - + // Esce la IDLE onde evitare la morte prematura in caricamento - m_bMustEnterMenu = true; + m_bMustEnterMenu = true; if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; } else { @@ -144,7 +144,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { CORO_BEGIN_CODE(_ctx); g_system->lockMutex(csMainLoop); - + // Poll dei dispositivi di input m_input.Poll(); @@ -153,8 +153,8 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { m_bMustEnterMenu = false; GLOBALS.bIdleExited = false; } - - if (m_bOption) { + + if (m_bOption) { CORO_INVOKE_1(m_opt.DoFrame, &m_input); m_bOption = !m_opt.IsClosing(); if (!m_bOption) { @@ -177,33 +177,32 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // ************** if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click attiva il combine, se siamo su un oggetto - if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { + if (m_inv.LeftClick(m_input.MousePos(), m_curActionObj)) { m_curAction = TA_COMBINE; m_point.SetAction(m_curAction); } - } - else + } else - // CLICK DESTRO - // ************ - if (m_input.MouseRightClicked()) { - if(m_itemName.IsItemSelected()) { - m_curActionObj=0; - m_inv.RightClick(m_input.MousePos()); + // CLICK DESTRO + // ************ + if (m_input.MouseRightClicked()) { + if (m_itemName.IsItemSelected()) { + m_curActionObj = 0; + m_inv.RightClick(m_input.MousePos()); + } else + m_inv.RightClick(m_input.MousePos()); } else - m_inv.RightClick(m_input.MousePos()); - } else - // RILASCIO DESTRO - // *************** - if (m_input.MouseRightReleased()) { - if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - } - } + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + } } else { // Menu Opzioni // ************ @@ -236,7 +235,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { else if (m_itemName.GetSelectedItem() != NULL) CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); } - + if (m_curAction == TA_COMBINE) { m_inv.EndCombine(); m_point.SetSpecialPointer(RMPointer::PTR_NONE); @@ -267,13 +266,13 @@ SKIPCLICKSINISTRO: m_inter.Clicked(m_input.MousePos()); } } - + // RILASCIO DESTRO // *************** if (m_input.MouseRightReleased()) { if (m_bGUIInterface) { - if (m_inter.Released(m_input.MousePos(),m_curAction)) { + if (m_inter.Released(m_input.MousePos(), m_curAction)) { m_point.SetAction(m_curAction); CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); @@ -287,7 +286,7 @@ SKIPCLICKSINISTRO: // Aggiorna il nome sotto il puntatore del mouse m_itemName.SetMouseCoord(m_input.MousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) - CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); + CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } // Inventario & interfaccia @@ -297,7 +296,7 @@ SKIPCLICKSINISTRO: // Anima Tony CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); - + // Aggiorna lo scrolling per tenere Tony dentro lo schermo if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { RMPoint showThis = m_tony.Position(); @@ -323,31 +322,31 @@ SKIPCLICKSINISTRO: // Wipe if (m_bWiping) { switch (m_nWipeType) { - case 1: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; - break; - } - - m_rcWipeEllipse.top += FSTEP; - m_rcWipeEllipse.left += FSTEP; - m_rcWipeEllipse.right -= FSTEP; - m_rcWipeEllipse.bottom -= FSTEP; + case 1: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { + CoroScheduler.setEvent(m_hWipeEvent); + m_nWipeType = 3; break; + } - case 2: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; - break; - } + m_rcWipeEllipse.top += FSTEP; + m_rcWipeEllipse.left += FSTEP; + m_rcWipeEllipse.right -= FSTEP; + m_rcWipeEllipse.bottom -= FSTEP; + break; - m_rcWipeEllipse.top -= FSTEP; - m_rcWipeEllipse.left -= FSTEP; - m_rcWipeEllipse.right += FSTEP; - m_rcWipeEllipse.bottom += FSTEP; + case 2: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { + CoroScheduler.setEvent(m_hWipeEvent); + m_nWipeType = 3; break; + } + + m_rcWipeEllipse.top -= FSTEP; + m_rcWipeEllipse.left -= FSTEP; + m_rcWipeEllipse.right += FSTEP; + m_rcWipeEllipse.bottom += FSTEP; + break; } } @@ -371,7 +370,7 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) MainFreeze(); - item->SetPattern(nPattern,true); + item->SetPattern(nPattern, true); if (GLOBALS.bPatIrqFreeze) MainUnfreeze(); } @@ -382,41 +381,41 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { } /* - // WINBUG: This is a special case for the file open/save dialog, - // which sometimes pumps while it is coming up but before it has - // disabled the main window. - HWND hWndFocus = ::GetFocus(); - bool bEnableParent = false; - m_ofn.hwndOwner = PreModal(); - AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { - bEnableParent = true; - ::EnableWindow(m_ofn.hwndOwner, false); - } - - _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - - if (m_ofn.Flags & OFN_EXPLORER) - pThreadState->m_pAlternateWndInit = this; - else - AfxHookWindowCreate(this); - - int nResult; - if (m_bOpenFileDialog) - nResult = ::GetOpenFileName(&m_ofn); - else - nResult = ::GetSaveFileName(&m_ofn); - - if (nResult) - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - pThreadState->m_pAlternateWndInit = NULL; - - // WINBUG: Second part of special case for file open/save dialog. - if (bEnableParent) - ::EnableWindow(m_ofn.hwndOwner, true); - if (::IsWindow(hWndFocus)) - ::SetFocus(hWndFocus); + // WINBUG: This is a special case for the file open/save dialog, + // which sometimes pumps while it is coming up but before it has + // disabled the main window. + HWND hWndFocus = ::GetFocus(); + bool bEnableParent = false; + m_ofn.hwndOwner = PreModal(); + AfxUnhookWindowCreate(); + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { + bEnableParent = true; + ::EnableWindow(m_ofn.hwndOwner, false); + } + + _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + + if (m_ofn.Flags & OFN_EXPLORER) + pThreadState->m_pAlternateWndInit = this; + else + AfxHookWindowCreate(this); + + int nResult; + if (m_bOpenFileDialog) + nResult = ::GetOpenFileName(&m_ofn); + else + nResult = ::GetSaveFileName(&m_ofn); + + if (nResult) + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + pThreadState->m_pAlternateWndInit = NULL; + + // WINBUG: Second part of special case for file open/save dialog. + if (bEnableParent) + ::EnableWindow(m_ofn.hwndOwner, true); + if (::IsWindow(hWndFocus)) + ::SetFocus(hWndFocus); */ @@ -427,46 +426,46 @@ void RMGfxEngine::SelectLocation(const RMPoint &ptTonyStart, const RMPoint &star // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione - // Sceglie la locazione - ZeroMemory(lpszFileName,512); - ZeroMemory(&ofn,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner=NULL; - ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; - ofn.lpstrCustomFilter=NULL; - ofn.nFilterIndex=1; - ofn.lpstrFile=lpszFileName; - ofn.nMaxFile=512; - ofn.lpstrInitialDir=NULL; - ofn.lpstrTitle="Load Location"; - ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; - - if (!GetOpenFileName(&ofn)) + // Sceglie la locazione + ZeroMemory(lpszFileName, 512); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = NULL; + ofn.lpstrFilter = "Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; + ofn.lpstrCustomFilter = NULL; + ofn.nFilterIndex = 1; + ofn.lpstrFile = lpszFileName; + ofn.nMaxFile = 512; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = "Load Location"; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + + if (!GetOpenFileName(&ofn)) ASSERT(0); // Carica la locazione m_loc.Load(lpszFileName); m_bLocationLoaded = true; - m_nCurLoc=m_loc.TEMPGetNumLoc(); - - if (ptTonyStart.x==-1 && ptTonyStart.y==-1) - InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); + m_nCurLoc = m_loc.TEMPGetNumLoc(); + + if (ptTonyStart.x == -1 && ptTonyStart.y == -1) + InitForNewLocation(m_loc.TEMPGetNumLoc(), m_loc.TEMPGetTonyStart(), RMPoint(-1, -1)); else - InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); + InitForNewLocation(m_loc.TEMPGetNumLoc(), ptTonyStart, start); #endif } void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start.x == -1 || start.y == -1) { - start.x = ptTonyStart.x-RM_SX / 2; - start.y = ptTonyStart.y-RM_SY / 2; + start.x = ptTonyStart.x - RM_SX / 2; + start.y = ptTonyStart.y - RM_SY / 2; } m_loc.SetScrollPosition(start); - - if (ptTonyStart.x==0 && ptTonyStart.y == 0) { + + if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { } else { - m_tony.SetPosition(ptTonyStart,nLoc); + m_tony.SetPosition(ptTonyStart, nLoc); m_tony.SetScrollPosition(start); } @@ -484,10 +483,10 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bool bLoaded; int i; - m_nCurLoc=nLoc; + m_nCurLoc = nLoc; bLoaded = false; - for (i=0; i < 5; i++) { + for (i = 0; i < 5; i++) { // Retry sul loading della locazione RMRes res(m_nCurLoc); if (!res.IsValid()) @@ -501,13 +500,13 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { } #endif m_loc.Load(res); - InitForNewLocation(nLoc,ptTonyStart,start); + InitForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; } - + if (!bLoaded) - SelectLocation(ptTonyStart,start); + SelectLocation(ptTonyStart, start); if (m_bOption) m_opt.ReInit(m_bigBuf); @@ -520,11 +519,11 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CONTEXT; - uint32 h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - + // Scarica tutta la memoria della locazione CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); @@ -538,7 +537,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { MainFreeze(); m_bLocationLoaded = false; - + m_bigBuf.ClearOT(); m_loc.Unload(); @@ -549,19 +548,19 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { } void RMGfxEngine::Init(/*HINSTANCE hInst*/) { -/* - //RECUPERARE UNA LOCAZIONE: - - RMRes res(5); - ASSERT(res.IsValid()); - FILE *f; - f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); - fwrite(res,1,5356900,f); - fclose(f); -*/ + /* + //RECUPERARE UNA LOCAZIONE: + + RMRes res(5); + ASSERT(res.IsValid()); + FILE *f; + f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); + fwrite(res,1,5356900,f); + fclose(f); + */ // Schermata di loading - RMResRaw *raw; + RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); m_bigBuf.AddPrim(new RMGfxPrimitive(load)); @@ -592,8 +591,8 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { // Inizializza la funzione di IRQ di Item per l'MPAL GLOBALS.GfxEngine = this; mpalInstallItemIrq(ItemIrq); - - // Inizializza DirectInput + + // Inizializza DirectInput m_input.Init(/*hInst*/); // Inizializza il puntatore del mouse @@ -607,25 +606,25 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_inv.Init(); m_inter.Init(); - // Carica la locazione e setta le priorit @@@@@ + // Carica la locazione e setta le priorit @@@@@ m_bLocationLoaded = false; -/* - m_nCurLoc=1; - RMRes res(m_nCurLoc); - m_loc.Load(res); - m_loc.SetPriority(1); - m_tony.SetPosition(RMPoint(201,316),1); - //m_tony.SetPosition(RMPoint(522,305),2); - //m_tony.SetPosition(RMPoint(158,398),4); - m_tony.SetPattern(m_tony.PAT_STANDDOWN); - m_curAction=TA_GOTO; -*/ + /* + m_nCurLoc=1; + RMRes res(m_nCurLoc); + m_loc.Load(res); + m_loc.SetPriority(1); + m_tony.SetPosition(RMPoint(201,316),1); + //m_tony.SetPosition(RMPoint(522,305),2); + //m_tony.SetPosition(RMPoint(158,398),4); + m_tony.SetPattern(m_tony.PAT_STANDDOWN); + m_curAction=TA_GOTO; + */ EnableInput(); // Inizio del gioco //m_tony.ExecuteAction(4,1,0); //PREGAME - - m_tony.ExecuteAction(20,1,0); + + m_tony.ExecuteAction(20, 1, 0); // theLog << "Seleziona la locazione\n"; //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); @@ -639,9 +638,9 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); - + // CASTELLO - + //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); } @@ -716,14 +715,14 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo mpalSaveState(state); thumbsize = 160 * 120 * 2; - + buf[0] = 'R'; buf[1] = 'M'; buf[2] = 'S'; buf[3] = TONY_SAVEGAME_VERSION; f = g_system->getSavefileManager()->openForSaving(fn); - if (f == NULL) + if (f == NULL) return; f->write(buf, 4); @@ -763,13 +762,13 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo // New Ver5 bool bStat; - + // Saves the state of the shepherdess and show yourself bStat = m_tony.GetPastorella(); f->writeByte(bStat); bStat = m_inter.GetPalesati(); f->writeByte(bStat); - + // Save the chars CharsSaveAll(f); @@ -805,20 +804,20 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... CORO_BEGIN_CONTEXT; - Common::InSaveFile *f; - byte *state, *statecmp; - uint size, sizecmp; - char buf[4]; - RMPoint tp; - int loc; - int ver; - int i; + Common::InSaveFile *f; + byte *state, *statecmp; + uint size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->f = g_system->getSavefileManager()->openForLoading(fn); - if (_ctx->f == NULL) + if (_ctx->f == NULL) return; _ctx->f->read(_ctx->buf, 4); @@ -826,14 +825,14 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { delete _ctx->f; return; } - + _ctx->ver = _ctx->buf[3]; - + if (_ctx->ver == 0 || _ctx->ver > TONY_SAVEGAME_VERSION) { delete _ctx->f; return; } - + if (_ctx->ver >= 0x3) { // There is a thumbnail. If the version is between 5 and 7, it's compressed if ((_ctx->ver >= 0x5) && (_ctx->ver <= 0x7)) { @@ -854,7 +853,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { _ctx->f->seek(1, SEEK_CUR); } - if (_ctx->ver >= 0x4) { // Skip the savegame name, which serves no purpose + if (_ctx->ver >= 0x4) { // Skip the savegame name, which serves no purpose _ctx->i = _ctx->f->readByte(); _ctx->f->seek(_ctx->i, SEEK_CUR); } @@ -870,7 +869,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { _ctx->state = new byte[_ctx->size]; _ctx->statecmp = new byte[_ctx->sizecmp]; _ctx->f->read(_ctx->statecmp, _ctx->sizecmp); - lzo1x_decompress(_ctx->statecmp,_ctx->sizecmp,_ctx->state,&_ctx->size); + lzo1x_decompress(_ctx->statecmp, _ctx->sizecmp, _ctx->state, &_ctx->size); delete[] _ctx->statecmp; } else { // Read uncompressed MPAL data @@ -888,7 +887,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { m_inv.LoadState(_ctx->state); delete[] _ctx->state; - if (_ctx->ver >= 0x2) { // Versione 2: box please + if (_ctx->ver >= 0x2) { // Versione 2: box please _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); @@ -897,13 +896,13 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { } if (_ctx->ver >= 5) { - // Versione 5: + // Versione 5: bool bStat = false; - + bStat = _ctx->f->readByte(); - m_tony.SetPastorella(bStat); + m_tony.SetPastorella(bStat); bStat = _ctx->f->readByte(); - m_inter.SetPalesati(bStat); + m_inter.SetPalesati(bStat); CharsLoadAll(_ctx->f); } @@ -939,10 +938,10 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { delete _ctx->f; CORO_INVOKE_2(UnloadLocation, false, NULL); - LoadLocation(_ctx->loc,_ctx->tp,RMPoint(-1, -1)); + LoadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); - + // On older versions, need to an enter action if (_ctx->ver < 5) mpalQueryDoAction(0, _ctx->loc, 0); @@ -970,8 +969,8 @@ void RMGfxEngine::PauseSound(bool bPause) { void RMGfxEngine::InitWipe(int type) { m_bWiping = true; - m_nWipeType=type; - m_nWipeStep=0; + m_nWipeType = type; + m_nWipeStep = 0; if (m_nWipeType == 1) m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2aae0b6ea6..24deb47ec4 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -44,7 +44,7 @@ namespace Tony { class RMGfxEngine { private: - RMGfxTargetBuffer m_bigBuf; + RMGfxTargetBuffer m_bigBuf; RMInput m_input; RMPointer m_point; RMLocation m_loc; @@ -62,7 +62,7 @@ private: int m_nCurLoc; RMTonyAction m_curAction; - int m_curActionObj; + int m_curActionObj; OSystem::MutexRef csMainLoop; int m_nWipeType; @@ -80,8 +80,8 @@ public: bool m_bGUIInterface; bool m_bGUIInventory; public: - RMGfxEngine(); - virtual ~RMGfxEngine(); + RMGfxEngine(); + virtual ~RMGfxEngine(); // Draw the next frame void DoFrame(CORO_PARAM, bool bDrawLocation); @@ -109,14 +109,20 @@ public: void EnableMouse(void); void DisableMouse(void); - operator byte *() { return (byte *)m_bigBuf; } - RMInput &GetInput() { return m_input; } + operator byte *() { + return (byte *)m_bigBuf; + } + RMInput &GetInput() { + return m_input; + } // Link to the custom function list void InitCustomDll(void); // Link to graphic task - void LinkGraphicTask(RMGfxTask *task) { m_bigBuf.AddPrim(new RMGfxPrimitive(task)); }; + void LinkGraphicTask(RMGfxTask *task) { + m_bigBuf.AddPrim(new RMGfxPrimitive(task)); + }; // Manage a location uint32 LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); @@ -131,7 +137,7 @@ public: void LoadState(CORO_PARAM, const char *fn); // Selects a location - void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1,-1)); + void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1)); // Pauses sound void PauseSound(bool bPause); @@ -141,7 +147,9 @@ public: void CloseWipe(void); void WaitWipeEnd(CORO_PARAM); - void SetPalesati(bool bpal) { m_inter.SetPalesati(bpal); } + void SetPalesati(bool bpal) { + m_inter.SetPalesati(bpal); + } }; } // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h index d82e0fcaf2..1c2835cf40 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -150,12 +150,12 @@ struct ChangedHotspotStruct { \****************************************************************************/ typedef struct { - int nCf; + int nCf; - int arg1, arg2, arg3, arg4; + int arg1, arg2, arg3, arg4; } CFCALL; -typedef CFCALL* LPCFCALL; -typedef LPCFCALL* LPLPCFCALL; +typedef CFCALL *LPCFCALL; +typedef LPCFCALL *LPLPCFCALL; /****************************************************************************\ @@ -201,9 +201,9 @@ public: bool bCfgSFX; int nCfgTonySpeed; int nCfgTextSpeed; - int nCfgDubbingVolume; - int nCfgMusicVolume; - int nCfgSFXVolume; + int nCfgDubbingVolume; + int nCfgMusicVolume; + int nCfgSFXVolume; bool bSkipSfxNoLoop; bool bIdleExited; bool bNoOcchioDiBue; @@ -219,18 +219,18 @@ public: RMInput *Input; RMGfxEngine *GfxEngine; - uint32 (*LoadLocation)(int, RMPoint, RMPoint start); + uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); - void (*Freeze)(void); - void (*Unfreeze)(void); - void (*WaitFrame)(CORO_PARAM); + void (*Freeze)(void); + void (*Unfreeze)(void); + void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); - void (*WaitWipeEnd)(CORO_PARAM); - void (*CloseWipe)(void); - void (*InitWipe)(int type); - void (*EnableGUI)(void); - void (*DisableGUI)(void); + void (*WaitWipeEnd)(CORO_PARAM); + void (*CloseWipe)(void); + void (*InitWipe)(int type); + void (*EnableGUI)(void); + void (*DisableGUI)(void); void (*SetPalesati)(bool bpal); uint32 dwTonyNumTexts; @@ -259,7 +259,7 @@ public: uint32 mpalError; LPITEMIRQFUNCTION lpiifCustom; LPLPCUSTOMFUNCTION lplpFunctions; - Common::String * lplpFunctionStrings; + Common::String *lplpFunctionStrings; uint16 nObjs; uint16 nVars; HGLOBAL hVars; @@ -281,14 +281,14 @@ public: LPMPALSCRIPT lpmsScripts; Common::File hMpr; uint16 nResources; - uint32 * lpResources; + uint32 *lpResources; bool bExecutingAction; bool bExecutingDialog; - uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 PollingThreads[MAXPOLLINGLOCATIONS]; - uint32 hAskChoice; - uint32 hDoneChoice; + uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 PollingThreads[MAXPOLLINGLOCATIONS]; + uint32 hAskChoice; + uint32 hDoneChoice; uint32 nExecutingAction; uint32 nExecutingDialog; uint32 nExecutingChoice; diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 97425e49c9..7663774ee4 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -32,7 +32,7 @@ namespace Tony { RMInput::RMInput() { // Setup mouse fields - _clampMouse = false; + _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; @@ -89,7 +89,7 @@ void RMInput::Poll(void) { default: break; } - } + } } void RMInput::Init() { @@ -107,12 +107,12 @@ bool RMInput::MouseRight() { } /** - * Return true if a key has been pressed + * Return true if a key has been pressed */ -bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { +bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames - bool result = _keyDown[(int)kc]; + bool result = _keyDown[(int)kc]; _keyDown[(int)kc] = false; return result; } diff --git a/engines/tony/input.h b/engines/tony/input.h index 544424581f..524f604ec2 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -49,7 +49,7 @@ private: private: // Deinizializza DirectInput void DIClose(void); - + public: RMInput(); ~RMInput(); @@ -64,19 +64,33 @@ public: void Poll(void); // Reading of the mouse - RMPoint MousePos() { return _mousePos; } + RMPoint MousePos() { + return _mousePos; + } // Current status of the mouse buttons bool MouseLeft(); bool MouseRight(); // Events of mouse clicks - bool MouseLeftClicked() { return _leftClickMouse; } - bool MouseRightClicked() { return _rightClickMouse; } - bool MouseBothClicked() { return _leftClickMouse && _rightClickMouse; } - bool MouseLeftReleased() { return _leftReleaseMouse; } - bool MouseRightReleased() { return _rightReleaseMouse; } - bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } + bool MouseLeftClicked() { + return _leftClickMouse; + } + bool MouseRightClicked() { + return _rightClickMouse; + } + bool MouseBothClicked() { + return _leftClickMouse && _rightClickMouse; + } + bool MouseLeftReleased() { + return _leftReleaseMouse; + } + bool MouseRightReleased() { + return _rightReleaseMouse; + } + bool MouseBothReleased() { + return _leftReleaseMouse && _rightReleaseMouse; + } // Returns true if the given key is pressed bool GetAsyncKeyState(Common::KeyCode kc); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 7b53e75cdd..e10fe228d3 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -36,7 +36,7 @@ namespace Tony { /****************************************************************************\ -* RMInventory Methods +* RMInventory Methods \****************************************************************************/ RMInventory::RMInventory() { @@ -74,7 +74,7 @@ bool RMInventory::CheckPointInside(const RMPoint &pt) { void RMInventory::Init(void) { - int i,j; + int i, j; int curres; // Crea il buffer principale @@ -87,7 +87,7 @@ void RMInventory::Init(void) { m_bCombining = false; // Nuovi oggetti - m_nItems = 78; // @@@ Numero di oggetti prendibili + m_nItems = 78; // @@@ Numero di oggetti prendibili m_items = new RMInventoryItem[m_nItems + 1]; curres = 10500; @@ -115,14 +115,14 @@ void RMInventory::Init(void) { curres++; if (i == 0 || i == 28 || i == 29) continue; - + m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; for (j = 0; j < m_items[i].icon.NumPattern(); j++) { RMResRaw raw(curres); assert(raw.IsValid()); - + m_items[i].pointer[j].Init((const byte *)raw, raw.Width(), raw.Height(), true); curres++; } @@ -141,24 +141,24 @@ void RMInventory::Init(void) { ds.Close(); // Crea il testo per gli hints sulla mini interfaccia - m_hints[0].SetAlignType(RMText::HCENTER,RMText::VTOP); - m_hints[1].SetAlignType(RMText::HCENTER,RMText::VTOP); - m_hints[2].SetAlignType(RMText::HCENTER,RMText::VTOP); + m_hints[0].SetAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[1].SetAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[2].SetAlignType(RMText::HCENTER, RMText::VTOP); // Il testo viene preso da MPAL per la traduzione RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0],1); - m_hints[1].WriteText(msg2[0],1); - m_hints[2].WriteText(msg3[0],1); + m_hints[0].WriteText(msg1[0], 1); + m_hints[1].WriteText(msg2[0], 1); + m_hints[2].WriteText(msg3[0], 1); -/* - m_hints[0].WriteText("Examine",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); -*/ + /* + m_hints[0].WriteText("Examine",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); + */ // Prepara il primo inventario Prepare(); @@ -167,7 +167,7 @@ void RMInventory::Init(void) { } void RMInventory::Close(void) { - // Ciao memoria + // Ciao memoria if (m_items != NULL) { // Delete the item pointers for (int i = 0; i <= m_nItems; i++) @@ -188,10 +188,10 @@ void RMInventory::Reset(void) { void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - RMPoint pos; - RMPoint pos2; - RMGfxPrimitive *p; - RMGfxPrimitive *p2; + RMPoint pos; + RMPoint pos2; + RMGfxPrimitive *p; + RMGfxPrimitive *p2; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -208,13 +208,13 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (m_state == SELECTING) { if (!GLOBALS.bCfgInvUp) { - _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); - _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, RM_SY - 113); + _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( - _ctx->pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); } - + _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); @@ -254,7 +254,7 @@ void RMInventory::RemoveItem(int code) { Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); // m_inv[m_nInv-1]=0; m_nInv--; - + Prepare(); DrawOT(Common::nullContext); ClearOT(); @@ -272,12 +272,12 @@ void RMInventory::AddItem(int code) { warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { g_system->lockMutex(m_csModifyInterface); - if (m_curPos + 8 == m_nInv) { + if (m_curPos + 8 == m_nInv) { // Sfondiamo l'inventario! Attivo il pattern di lampeggio m_items[28].icon.SetPattern(2); } - m_inv[m_nInv++]=code-10000; + m_inv[m_nInv++] = code - 10000; Prepare(); DrawOT(Common::nullContext); @@ -302,8 +302,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { } -void RMInventory::Prepare(void) -{ +void RMInventory::Prepare(void) { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { @@ -332,7 +331,7 @@ bool RMInventory::HaveFocus(const RMPoint &mpos) { // Se l'inventario aperto, abbiamo il focus quando ci andiamo sopra if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) return true; - + // Se stiamo selezionando un verbo (quindi tasto destro premuto), abbiamo il focus alltime if (m_state == SELECTING) return true; @@ -344,11 +343,11 @@ void RMInventory::EndCombine(void) { m_bCombining = false; } -bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { +bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { int n; // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo - n=mpos.x / 64; + n = mpos.x / 64; if (m_state == OPENED) { if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { @@ -360,13 +359,13 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { return true; } } - + // Click sulla freccia destra if ((m_state == OPENED) && m_bBlinkingRight) { g_system->lockMutex(m_csModifyInterface); m_curPos++; - if (m_curPos+8 >= m_nInv) { + if (m_curPos + 8 >= m_nInv) { m_bBlinkingRight = false; m_items[28].icon.SetPattern(1); } @@ -383,7 +382,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { } // Click sulla freccia sinistra else if ((m_state == OPENED) && m_bBlinkingLeft) { - assert(m_curPos>0); + assert(m_curPos > 0); g_system->lockMutex(m_csModifyInterface); m_curPos--; @@ -417,7 +416,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { // Apre l'interfaccina contestuale n = mpos.x / 64; - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { m_state = SELECTING; miniAction = 0; m_nSelectObj = n - 1; @@ -437,7 +436,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { m_items[28].icon.SetPattern(1); } - if (m_curPos>0) { + if (m_curPos > 0) { m_bBlinkingLeft = true; m_items[29].icon.SetPattern(2); } @@ -469,7 +468,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { } } -bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction& curAction) { +bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction &curAction) { if (m_state == SELECTING) { m_state = OPENED; @@ -488,7 +487,7 @@ bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction& curAction) { return false; } -#define INVSPEED 20 +#define INVSPEED 20 void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { int i; @@ -523,7 +522,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_items[29].icon.SetPattern(3); m_bBlinkingLeft = true; bNeedRedraw = true; - } + } } else if (m_bBlinkingLeft) { m_items[29].icon.SetPattern(2); m_bBlinkingLeft = false; @@ -542,12 +541,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } - if (m_bCombining) {//m_state == COMBINING) + if (m_bCombining) {//m_state == COMBINING) ptr.SetCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); } @@ -557,12 +556,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = RM_SY - 1; - m_curPutTime=_vm->GetTime(); + m_curPutTime = _vm->GetTime(); } else { m_state = OPENED; m_curPutY = RM_SY - 68; } - } else if (m_state == OPENED) { + } else if (m_state == OPENED) { if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; @@ -593,18 +592,17 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_state = CLOSED; } } else { - if ((m_state == CLOSED) && (mpos.y<10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if ((m_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; - m_curPutY =- 68; + m_curPutY = - 68; m_curPutTime = _vm->GetTime(); } else { m_state = OPENED; m_curPutY = 0; } - } - else if (m_state == OPENED) { - if ((mpos.y>70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { + } else if (m_state == OPENED) { + if ((mpos.y > 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = -2; @@ -637,31 +635,31 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (m_state == SELECTING) { int startx = (m_nSelectObj + 1) * 64 - 20; int starty; - + if (!GLOBALS.bCfgInvUp) - starty=RM_SY-109; + starty = RM_SY - 109; else - starty=70; - + starty = 70; + // Controlla se si trova su uno dei verbi if (mpos.y > starty && mpos.y < starty + 45) { - if (mpos.x > startx && mpos.x < startx + 40) { - if (miniAction !=1 ) { + if (mpos.x > startx && mpos.x < startx + 40) { + if (miniAction != 1) { miniInterface.SetPattern(2); miniAction = 1; - _vm->PlayUtilSFX(1); + _vm->PlayUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { if (miniAction != 2) { miniInterface.SetPattern(3); miniAction = 2; _vm->PlayUtilSFX(1); - } + } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { if (miniAction != 3) { miniInterface.SetPattern(4); miniAction = 3; - _vm->PlayUtilSFX(1); + _vm->PlayUtilSFX(1); } } else { miniInterface.SetPattern(1); @@ -671,12 +669,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniInterface.SetPattern(1); miniAction = 0; } - + // Aggiorna la miniinterface miniInterface.DoFrame(&bigBuf, false); } - if ((m_state!= CLOSED) && !m_nInList) { + if ((m_state != CLOSED) && !m_nInList) { bigBuf.AddPrim(new RMGfxPrimitive(this)); } } @@ -694,10 +692,10 @@ RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { if (m_state == OPENED) { if (CheckPointInside(mpt)) { - n=mpt.x / 64; - if (n>0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) + n = mpt.x / 64; + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) return &m_items[m_inv[n - 1 + m_curPos]].icon; - } + } } return NULL; @@ -707,14 +705,16 @@ RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { int RMInventory::GetSaveStateSize(void) { // m_inv pattern m_nInv - return 256*4 + 256*4 + 4 ; + return 256 * 4 + 256 * 4 + 4 ; } void RMInventory::SaveState(byte *state) { int i, x; - WRITE_LE_UINT32(state, m_nInv); state += 4; - Common::copy(m_inv, m_inv + 256, (uint32 *)state); state += 256 * 4; + WRITE_LE_UINT32(state, m_nInv); + state += 4; + Common::copy(m_inv, m_inv + 256, (uint32 *)state); + state += 256 * 4; for (i = 0; i < 256; i++) { if (i < m_nItems) @@ -722,19 +722,23 @@ void RMInventory::SaveState(byte *state) { else x = 0; - WRITE_LE_UINT32(state, x); state += 4; + WRITE_LE_UINT32(state, x); + state += 4; } } int RMInventory::LoadState(byte *state) { int i, x; - m_nInv = READ_LE_UINT32(state); state += 4; - Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); state += 256 * 4; + m_nInv = READ_LE_UINT32(state); + state += 4; + Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); + state += 256 * 4; for (i = 0; i < 256; i++) { - x = READ_LE_UINT32(state); state += 4; - + x = READ_LE_UINT32(state); + state += 4; + if (i < m_nItems) { m_items[i].status = x; m_items[i].icon.SetPattern(x); @@ -745,7 +749,7 @@ int RMInventory::LoadState(byte *state) { m_bCombining = false; m_items[29].icon.SetPattern(1); - + if (m_nInv > 8) m_items[28].icon.SetPattern(2); else @@ -760,7 +764,7 @@ int RMInventory::LoadState(byte *state) { /****************************************************************************\ -* RMInterface methods +* RMInterface methods \****************************************************************************/ RMInterface::~RMInterface() { @@ -777,8 +781,9 @@ int RMInterface::OnWhichBox(RMPoint pt) { pt -= m_openStart; // Controlla quanti verbi bisogna considerare - max = 4; if (m_bPalesati) max = 5; - + max = 4; + if (m_bPalesati) max = 5; + // Cerca il verbo for (i = 0; i < max; i++) if (m_hotbbox[i].PtInRect(pt)) @@ -790,7 +795,7 @@ int RMInterface::OnWhichBox(RMPoint pt) { void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int h; + int h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -803,7 +808,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); - + if (m_lastHotZone != _ctx->h) { m_lastHotZone = _ctx->h; _vm->PlayUtilSFX(1); @@ -839,8 +844,8 @@ void RMInterface::Clicked(const RMPoint &mousepos) { // La tiene dentro lo schermo if (m_openStart.x < 0) m_openStart.x = 0; if (m_openStart.y < 0) m_openStart.y = 0; - if (m_openStart.x+m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; - if (m_openStart.y+m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; + if (m_openStart.x + m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; + if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; // Play dell'effetto sonoro _vm->PlayUtilSFX(0); @@ -868,16 +873,16 @@ bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { case 3: action = TA_EXAMINE; break; - + case 4: action = TA_PALESATI; break; - default: // Nessun verbo + default: // Nessun verbo return false; - } - - return true; + } + + return true; } void RMInterface::Reset(void) { @@ -885,7 +890,7 @@ void RMInterface::Reset(void) { } void RMInterface::SetPalesati(bool bOn) { - m_bPalesati=bOn; + m_bPalesati = bOn; } bool RMInterface::GetPalesati(void) { @@ -894,7 +899,7 @@ bool RMInterface::GetPalesati(void) { void RMInterface::Init(void) { int i; - RMResRaw inter(RES_I_INTERFACE); + RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); SetPriority(191); @@ -909,8 +914,8 @@ void RMInterface::Init(void) { m_hotzone[i].LoadPaletteWA(pal); } - m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi - m_hotbbox[1].SetRect(90, 130, 125, 186); // parla + m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi + m_hotbbox[1].SetRect(90, 130, 125, 186); // parla m_hotbbox[2].SetRect(110, 60, 152, 125); m_hotbbox[3].SetRect(56, 51, 93, 99); m_hotbbox[4].SetRect(51, 105, 82, 172); @@ -933,13 +938,13 @@ void RMInterface::Init(void) { m_hints[2].WriteText(msg2[0], 1); m_hints[3].WriteText(msg3[0], 1); m_hints[4].WriteText(msg4[0], 1); -/* - m_hints[0].WriteText("Take",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); - m_hints[3].WriteText("Examine",1); - m_hints[4].WriteText("Palesati",1); -*/ + /* + m_hints[0].WriteText("Take",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); + m_hints[3].WriteText("Examine",1); + m_hints[4].WriteText("Palesati",1); + */ m_bActive = false; m_bPalesati = false; m_lastHotZone = 0; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index df92cafebd..c612ebbf77 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -334,14 +334,14 @@ void RMTony::Stop(CORO_PARAM) { ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); - m_ActionItem=NULL; + m_ActionItem = NULL; CORO_END_CODE; } int RMTony::GetCurPattern(void) { - int nPatt=RMCharacter::GetCurPattern(); + int nPatt = RMCharacter::GetCurPattern(); if (!m_bPastorella) return nPatt; @@ -355,7 +355,6 @@ int RMTony::GetCurPattern(void) { return PAT_STANDLEFT; case PAT_PAST_STANDRIGHT: return PAT_STANDRIGHT; - case PAT_PAST_WALKUP: return PAT_WALKUP; case PAT_PAST_WALKDOWN: @@ -438,7 +437,6 @@ void RMTony::Take(int nWhere, int nPart) { } break; - case PAT_STANDLEFT: switch (nWhere) { case 0: @@ -454,7 +452,7 @@ void RMTony::Take(int nWhere, int nPart) { break; } } else if (nPart == 1) { - SetPattern(GetCurPattern()+1); + SetPattern(GetCurPattern() + 1); } else if (nPart == 2) { switch (GetCurPattern()) { case PAT_TAKEUP_UP2: @@ -514,7 +512,6 @@ void RMTony::Put(int nWhere, int nPart) { } break; - case PAT_STANDLEFT: switch (nWhere) { case 0: @@ -530,7 +527,7 @@ void RMTony::Put(int nWhere, int nPart) { break; } } else if (nPart == 1) { - SetPattern(GetCurPattern()+1); + SetPattern(GetCurPattern() + 1); } else if (nPart == 2) { switch (GetCurPattern()) { case PAT_PUTUP_UP2: @@ -567,7 +564,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (!m_bIsStaticTalk) { switch (m_nPatB4Talking) { case PAT_STANDDOWN: - m_TalkDirection=DOWN; + m_TalkDirection = DOWN; break; case PAT_TAKELEFT_UP2: @@ -575,7 +572,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection=LEFT; + m_TalkDirection = LEFT; break; case PAT_TAKERIGHT_UP2: @@ -583,14 +580,14 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection=RIGHT; + m_TalkDirection = RIGHT; break; case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection=UP; + m_TalkDirection = UP; break; } @@ -1220,9 +1217,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_RIDE: case TALK_RIDE2: - if (m_TalkDirection==LEFT) + if (m_TalkDirection == LEFT) headEndPat = PAT_RIDELEFT_END; - else if (m_TalkDirection==RIGHT) + else if (m_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; bodyEndPat = 0; @@ -1532,7 +1529,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nPat) { case PAT_STANDDOWN: - m_TalkDirection=DOWN; + m_TalkDirection = DOWN; headPat = PAT_TESTA_RIGHT; break; @@ -1541,7 +1538,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection=LEFT; + m_TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; @@ -1550,7 +1547,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection=RIGHT; + m_TalkDirection = RIGHT; headPat = PAT_TESTA_RIGHT; break; @@ -1558,7 +1555,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection=UP; + m_TalkDirection = UP; headPat = PAT_TESTA_LEFT; break; } diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 92f6dea032..58d0bba2ba 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -211,9 +211,9 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { _splitpath(fn, bufDrive, bufDir, NULL, NULL); for (i = 1; i < 10; i++) { - wsprintf(bufName,"rm%d00",i); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); - h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + wsprintf(bufName, "rm%d00", i); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); + h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); @@ -222,10 +222,10 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { i--; for (j = 1; j < 10; j++) { - wsprintf(bufName,"rm%d%d0",i,j); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); - h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==CORO_INVALID_PID_VALUE) + wsprintf(bufName, "rm%d%d0", i, j); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); + h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -233,10 +233,10 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { j--; for (k = 0; k < 10; k++) { - wsprintf(bufName,"rm%d%d%d",i,j,k); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); - h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==CORO_INVALID_PID_VALUE) + wsprintf(bufName, "rm%d%d%d", i, j, k); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); + h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -251,8 +251,8 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { return false; } - wsprintf(bufName,"rm%d%d%d",i,j,k); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + wsprintf(bufName, "rm%d%d%d", i, j, k); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); } #endif return true; @@ -299,7 +299,7 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { cursrc = &src[RM_SKIPX + x * dezoom]; sommar = sommab = sommag = 0; - for (v = 0; v < dezoom; v++) + for (v = 0; v < dezoom; v++) { for (u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; @@ -310,16 +310,16 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { sommag += (cursrc[curv*RM_BBX + u] >> 5) & 0x1F; sommar += (cursrc[curv*RM_BBX + u] >> 10) & 0x1F; } + } + rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); - rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); - - if (lpDestBuf!=NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + if (lpDestBuf!=NULL) + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); - k += 3; + k += 3; } if (lpDestBuf == NULL) -- cgit v1.2.3 From 59942d9a41cf7d43b95e9775aca66c241884b516 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 May 2012 00:05:48 +1000 Subject: TONY: Work on enabling GMM saving and loading --- engines/tony/detection.cpp | 36 +++++++++++++++++++++++++++++++++--- engines/tony/gfxengine.cpp | 12 ++++++++---- engines/tony/gfxengine.h | 5 +++-- engines/tony/tony.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- engines/tony/tony.h | 8 +++++++- 5 files changed, 93 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 944f717f26..5b1092d2c0 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -25,6 +25,7 @@ #include "engines/advancedDetector.h" #include "common/system.h" +#include "graphics/surface.h" #include "tony/tony.h" #include "tony/game.h" @@ -75,18 +76,23 @@ public: virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; virtual void removeSaveState(const char *target, int slot) const; + SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { return (f == kSupportsListSaves) || -// (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave); + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { return - (f == kSupportsRTL); + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); } bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { @@ -136,6 +142,30 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { g_system->getSavefileManager()->removeSavefile(filename); } +SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Tony::RMString saveName; + byte difficulty; + + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::Surface *thumbnail = new Graphics::Surface(); + thumbnail->create(160, 120, pixelFormat); + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, (byte *)thumbnail->pixels, saveName, difficulty)) { + // Create the return descriptor + SaveStateDescriptor desc(slot, (const char *)saveName); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + desc.setThumbnail(thumbnail); + + return desc; + } + + thumbnail->free(); + delete thumbnail; + return SaveStateDescriptor(); +} + + #if PLUGIN_ENABLED_DYNAMIC(TONY) REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 384e80f209..7cfeaecb6f 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -698,7 +698,7 @@ void LoadMusic(Common::InSaveFile *f); #define TONY_SAVEGAME_VERSION 8 -void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { +void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Common::String &name) { Common::OutSaveFile *f; byte *state; uint thumbsize; @@ -733,9 +733,9 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo i = mpalQueryGlobalVar("VERSIONEFACILE"); f->writeByte(i); - i = strlen(name); + i = strlen(name.c_str()); f->writeByte(i); - f->write(name, i); + f->write(name.c_str(), i); f->writeUint32LE(m_nCurLoc); f->writeUint32LE(tp.x); f->writeUint32LE(tp.y); @@ -801,7 +801,7 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo delete f; } -void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { +void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... CORO_BEGIN_CONTEXT; Common::InSaveFile *f; @@ -986,4 +986,8 @@ void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE); } +bool RMGfxEngine::CanLoadSave() { + return m_bInput && !m_tony.InAction(); +} + } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 24deb47ec4..06eb3cc4ba 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -133,8 +133,8 @@ public: void Unfreeze(void); // State management - void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false); - void LoadState(CORO_PARAM, const char *fn); + void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name); + void LoadState(CORO_PARAM, const Common::String &fn); // Selects a location void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1)); @@ -150,6 +150,7 @@ public: void SetPalesati(bool bpal) { m_inter.SetPalesati(bpal); } + bool CanLoadSave(); }; } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d476f60859..c7056cb88d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -43,6 +43,14 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); + + // Set up load slot number + _loadSlotNumber = -1; + if (ConfMan.hasKey("save_slot")) { + int slotNumber = ConfMan.getInt("save_slot"); + if (slotNumber >= 0 && slotNumber <= 99) + _loadSlotNumber = slotNumber; + } } TonyEngine::~TonyEngine() { @@ -400,7 +408,7 @@ void TonyEngine::AutoSave(CORO_PARAM) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); _ctx->buf = GetSaveStateFileName(0); - _theEngine.SaveState(_ctx->buf.c_str(), (byte *)m_curThumbnail, "Autosave", true); + _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave"); MainUnfreeze(); CORO_END_CODE; @@ -499,17 +507,26 @@ void TonyEngine::Abort(void) { */ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; + Common::String fn; CORO_END_CONTEXT(_ctx); + CORO_BEGIN_CODE(_ctx); - // CORO_INFINITE loop. We rely on the outer main process to detect if a shutdown is required, + // Game loop. We rely on the outer main process to detect if a shutdown is required, // and kill the scheudler and all the processes, including this one for (;;) { // Se siamo in pausa, entra nel loop appropriato if (_vm->m_bPaused) _vm->PauseLoop(); + // If a savegame needs to be loaded, then do so + if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { + _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber); + CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn); + _vm->_loadSlotNumber = -1; + } + // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); @@ -627,4 +644,27 @@ uint32 TonyEngine::GetTime() { return g_system->getMillis(); } +bool TonyEngine::canLoadGameStateCurrently() { + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); +} +bool TonyEngine::canSaveGameStateCurrently() { + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); +} + +Common::Error TonyEngine::loadGameState(int slot) { + _loadSlotNumber = slot; + return Common::kNoError; +} + +Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { + if (!GLOBALS.GfxEngine) + return Common::kUnknownError; + + RMSnapshot s; + s.GrabScreenshot(*GLOBALS.GfxEngine, 4, m_curThumbnail); + + GLOBALS.GfxEngine->SaveState(GetSaveStateFileName(slot), (byte *)m_curThumbnail, desc); + return Common::kNoError; +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c106a0856b..574861487a 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -78,8 +78,9 @@ struct VoiceHeader { class TonyEngine : public Engine { private: - Common::ErrorCode Init(); + int _loadSlotNumber; + Common::ErrorCode Init(); void InitMusic(); void CloseMusic(); bool OpenVoiceDatabase(); @@ -142,6 +143,11 @@ public: RMGfxEngine *GetEngine() { return &_theEngine; } void GUIError(const Common::String &msg); + virtual bool canLoadGameStateCurrently(); + virtual bool canSaveGameStateCurrently(); + Common::Error TonyEngine::loadGameState(int slot); + Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc); + // Avverte che siamo guidati dal GDI void GDIControl(bool bCon); -- cgit v1.2.3 From 40926933c35cbded1ff2aa8078eaa3c76b2149b3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 17 May 2012 19:30:30 +1000 Subject: TONY: Handle translating savegame thumbnail for display in ScummVM GMM --- engines/tony/detection.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 5b1092d2c0..578c5c796c 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -23,8 +23,10 @@ #include "base/plugins.h" +#include "common/memstream.h" #include "engines/advancedDetector.h" #include "common/system.h" +#include "graphics/colormasks.h" #include "graphics/surface.h" #include "tony/tony.h" @@ -145,23 +147,35 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Tony::RMString saveName; byte difficulty; + byte thumbData[160 * 120 * 2]; + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { + // Convert the 565 thumbnail data to the needed overlay format + Common::MemoryReadStream thumbStream(thumbData, 160 * 120 * 2); + Graphics::PixelFormat destFormat = g_system->getOverlayFormat(); + Graphics::Surface *to = new Graphics::Surface(); + to->create(160, 120, destFormat); + + OverlayColor *pixels = (OverlayColor *)to->pixels; + for (int y = 0; y < to->h; ++y) { + for (int x = 0; x < to->w; ++x) { + uint8 r, g, b; + Graphics::colorToRGB >(thumbStream.readUint16LE(), r, g, b); + + // converting to current OSystem Color + *pixels++ = destFormat.RGBToColor(r, g, b); + } + } - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - Graphics::Surface *thumbnail = new Graphics::Surface(); - thumbnail->create(160, 120, pixelFormat); - - if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, (byte *)thumbnail->pixels, saveName, difficulty)) { // Create the return descriptor SaveStateDescriptor desc(slot, (const char *)saveName); desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); - desc.setThumbnail(thumbnail); + desc.setThumbnail(to); return desc; } - thumbnail->free(); - delete thumbnail; return SaveStateDescriptor(); } -- cgit v1.2.3 From 7a40750671915d517e8938fdca889f870b554c8c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 17 May 2012 19:41:53 +1000 Subject: TONY: Add a check to prevent GMM saving in the demo --- engines/tony/gfxengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 7cfeaecb6f..5d81c47333 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -987,7 +987,7 @@ void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { } bool RMGfxEngine::CanLoadSave() { - return m_bInput && !m_tony.InAction(); + return m_bInput && !m_tony.InAction() && !_vm->getIsDemo(); } } // End of namespace Tony -- cgit v1.2.3 From a5a3977c905d55dd3c8e9ff6e1acbac07b1fb305 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Thu, 17 May 2012 14:20:04 +0200 Subject: TONY: Fix compiling with GCC --- engines/tony/detection.cpp | 2 +- engines/tony/tony.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 578c5c796c..63bb02a5f2 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -78,7 +78,7 @@ public: virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; virtual void removeSaveState(const char *target, int slot) const; - SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 574861487a..f40eb1325d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -145,8 +145,8 @@ public: virtual bool canLoadGameStateCurrently(); virtual bool canSaveGameStateCurrently(); - Common::Error TonyEngine::loadGameState(int slot); - Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc); + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const Common::String &desc); // Avverte che siamo guidati dal GDI void GDIControl(bool bCon); -- cgit v1.2.3 From d67a5162addcc143c870ed35000212bdd7d7ab2c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 18 May 2012 21:48:03 +1000 Subject: TONY: Converting method comments to DOXYGEN format --- engines/tony/mpal/mpal.cpp | 770 +++++++++++++++------------------------------ engines/tony/mpal/mpal.h | 705 +++++++++++++++-------------------------- 2 files changed, 503 insertions(+), 972 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index f049ecf3ea..a173b707f2 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -61,6 +61,8 @@ namespace Tony { namespace MPAL { +#define GETARG(type) va_arg(v, type) + /****************************************************************************\ * Copyright \****************************************************************************/ @@ -76,39 +78,25 @@ const char *mpalCopyright = * Internal functions \****************************************************************************/ -/****************************************************************************\ -* -* Function: void LockVar(void); -* -* Description: Locka le variabili per accederci -* -\****************************************************************************/ - +/** + * Locks the variables for access + */ void LockVar(void) { GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); } -/****************************************************************************\ -* -* Function: void UnlockVar(void); -* -* Description: Unlocka le variabili dopo l'uso -* -\****************************************************************************/ +/** + * Unlocks variables after use + */ void UnlockVar(void) { GlobalUnlock(GLOBALS.hVars); } -/****************************************************************************\ -* -* Function: void LockMsg(void); -* -* Description: Locka i messaggi per accederci -* -\****************************************************************************/ - +/** + * Locks the messages for access + */ static void LockMsg(void) { #ifdef NEED_LOCK_MSGS GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); @@ -116,14 +104,9 @@ static void LockMsg(void) { } -/****************************************************************************\ -* -* Function: void UnlockMsg(void); -* -* Description: Unlocka i messaggi dopo l'uso -* -\****************************************************************************/ - +/** + * Unlocks the messages after use + */ static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS GlobalUnlock(GLOBALS.hMsgs); @@ -131,125 +114,79 @@ static void UnlockMsg(void) { } -/****************************************************************************\ -* -* Function: void LockDialogs(void); -* -* Description: Locka i dialoghi per accederci -* -\****************************************************************************/ - +/** + * Locks the dialogs for access + */ static void LockDialogs(void) { GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); } -/****************************************************************************\ -* -* Function: void UnlockDialogs(void); -* -* Description: Unlocka i dialoghi dopo l'uso -* -\****************************************************************************/ - +/** + * Unlocks the dialogs after use + */ static void UnlockDialogs(void) { GlobalUnlock(GLOBALS.hDialogs); } -/****************************************************************************\ -* -* Function: void LockLocations(void); -* -* Description: Locka le strutture di dati sulle locazioni -* -\****************************************************************************/ - +/** + * Locks the location data structures for access + */ static void LockLocations(void) { GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); } -/****************************************************************************\ -* -* Function: void UnlockLocations(void); -* -* Description: Unlocka le strutture di dati sulle locazioni -* -\****************************************************************************/ - +/** + * Unlocks the location structures after use + */ static void UnlockLocations(void) { GlobalUnlock(GLOBALS.hLocations); } -/****************************************************************************\ -* -* Function: void LockItems(void); -* -* Description: Locka le strutture di dati sugli item -* -\****************************************************************************/ - +/** + * Locks the items structures for use + */ static void LockItems(void) { GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); } -/****************************************************************************\ -* -* Function: void UnlockItems(void); -* -* Description: Unlocka le strutture di dati sugli item -* -\****************************************************************************/ - +/** + * Unlocks the items structures after use + */ static void UnlockItems(void) { GlobalUnlock(GLOBALS.hItems); } -/****************************************************************************\ -* -* Function: void LockScripts(void); -* -* Description: Locka le strutture di dati sugli script -* -\****************************************************************************/ +/** + * Locks the script data structures for use + */ static void LockScripts(void) { GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); } -/****************************************************************************\ -* -* Function: void UnlockScripts(void); -* -* Description: Unlocka le strutture di dati sugli script -* -\****************************************************************************/ - +/** + * Unlocks the script data structures after use + */ static void UnlockScripts(void) { GlobalUnlock(GLOBALS.hScripts); } -/****************************************************************************\ -* -* Function: int varGetValue(char * lpszVarName); -* -* Description: Restituisce il valore corrente di una variabile globale -* -* Input: char * lpszVarName Nome della variabile -* -* Return: Valore corrente -* -* Note: Prima di questa funzione, bisogna richiamare LockVar() che -* locka le variabili globali per l'utilizzo. Dopo inoltre bi- -* sogna ricordarsi di chiamare UnlockVar() -* -\****************************************************************************/ - +/** + * Returns the current value of a global variable + * + * @param lpszVarName Name of the variable + * @returns Current value + * @remarks Before using this method, you must call LockVar() to + * lock the global variablves for use. Then afterwards, you will + * need to remember to call UnlockVar() + */ int32 varGetValue(const char *lpszVarName) { int i; LPMPALVAR v=GLOBALS.lpmvVars; @@ -263,17 +200,11 @@ int32 varGetValue(const char *lpszVarName) { } -/****************************************************************************\ -* -* Function: void varSetValue(char * lpszVarName, int val); -* -* Description: Setta un nuovo valore per una variabile globale di MPAL -* -* Input: char * lpszVarName Nome della variabile -* int val Valore da settare -* -\****************************************************************************/ - +/** + * Sets the value of a MPAL global variable + * @param lpszVarName Name of the variable + * @param val Value to set + */ void varSetValue(const char *lpszVarName, int32 val) { uint i; LPMPALVAR v = GLOBALS.lpmvVars; @@ -298,22 +229,14 @@ void varSetValue(const char *lpszVarName, int32 val) { } -/****************************************************************************\ -* -* Function: int locGetOrderFromNum(uint32 nLoc); -* -* Description: Trova l'indice della locazione #nLoc all'interno dell'array -* delle strutture delle locazioni -* -* Input: uint32 nLoc Numero della locazione da cercare -* -* Return: Indice, o -1 se la locazione non e' presente -* -* Note: Per funzionare, la funzione necessita che le locazioni siano -* state lockate con LockLoc() -* -\****************************************************************************/ - +/** + * Find the index of a location within the location array. Remember to call LockLoc() beforehand. + * + * @param nLoc Location number to search for + * @returns Index, or -1 if the location is not present + * @remarks This function requires the location list to have + * first been locked with a call to LockLoc(). + */ static int locGetOrderFromNum(uint32 nLoc) { int i; LPMPALLOCATION loc = GLOBALS.lpmlLocations; @@ -325,22 +248,14 @@ static int locGetOrderFromNum(uint32 nLoc) { return -1; } -/****************************************************************************\ -* -* Function: int msgGetOrderFromNum(uint32 nMsg); -* -* Description: Trova l'indice del messaggio #nMsg all'interno dell'array -* delle strutture dei messaggi -* -* Input: uint32 nMsg Numero del messaggio da cercare -* -* Return: Indice, o -1 se il messaggio non e' presente -* -* Note: Per funzionare, la funzione necessita che i messaggi siano -* stati lockati con LockMsg() -* -\****************************************************************************/ +/** + * Find the index of a message within the messages array + * @param nMsg Message number to search for + * @returns Index, or -1 if the message is not present + * @remarks This function requires the message list to have + * first been locked with a call to LockMsg() + */ static int msgGetOrderFromNum(uint32 nMsg) { int i; LPMPALMSG msg = GLOBALS.lpmmMsgs; @@ -352,23 +267,13 @@ static int msgGetOrderFromNum(uint32 nMsg) { return -1; } - -/****************************************************************************\ -* -* Function: int itemGetOrderFromNum(uint32 nItem); -* -* Description: Trova l'indice dell'item #nItem all'interno dell'array delle -* strutture degli item -* -* Input: uint32 nItem Numero dell'item da cercare -* -* Return: Indice, o -1 se l'item non e' presente -* -* Note: Per funzionare, questa funzione necessita che gli item siano -* stati lockati tramite LockItem() -* -\****************************************************************************/ - +/** + * Find the index of an item within the items array + * @param nItem Item number to search for + * @returns Index, or -1 if the item is not present + * @remarks This function requires the item list to have + * first been locked with a call to LockItems() + */ static int itemGetOrderFromNum(uint32 nItem) { int i; LPMPALITEM item = GLOBALS.lpmiItems; @@ -381,22 +286,13 @@ static int itemGetOrderFromNum(uint32 nItem) { } -/****************************************************************************\ -* -* Function: int scriptGetOrderFromNum(uint32 nScript); -* -* Description: Trova l'indice dello script #nScript all'interno dell'array -* delle strutture degli script -* -* Input: uint32 nScript Numero dello script da cercare -* -* Return: Indice, o -1 se lo script non e' presente -* -* Note: Per funzionare, questa funzione necessita che gli script siano -* stati lockati tramite LockScript() -* -\****************************************************************************/ - +/** + * Find the index of a script within the scripts array + * @param nScript Script number to search for + * @returns Index, or -1 if the script is not present + * @remarks This function requires the script list to have + * first been locked with a call to LockScripts() + */ static int scriptGetOrderFromNum(uint32 nScript) { int i; LPMPALSCRIPT script = GLOBALS.lpmsScripts; @@ -409,22 +305,13 @@ static int scriptGetOrderFromNum(uint32 nScript) { } -/****************************************************************************\ -* -* Function: int dialogGetOrderFromNum(uint32 nDialog); -* -* Description: Trova l'indice del dialog #nDialog all'interno dell'array -* delle strutture dei dialog -* -* Input: uint32 nDialog Numero del dialog da cercare -* -* Return: Indice, o -1 se il dialog non e' presente -* -* Note: Per funzionare, questa funzione necessita che i dialog siano -* stati lockati tramite LockDialogs() -* -\****************************************************************************/ - +/** + * Find the index of a dialog within the dialogs array + * @param nDialog Dialog number to search for + * @returns Index, or -1 if the dialog is not present + * @remarks This function requires the dialog list to have + * first been locked with a call to LockDialogs() + */ static int dialogGetOrderFromNum(uint32 nDialog) { int i; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs; @@ -437,21 +324,12 @@ static int dialogGetOrderFromNum(uint32 nDialog) { } - -/****************************************************************************\ -* -* Function: char * DuplicateMessage(uint32 nMsgOrd); -* -* Description: Duplica un messaggio -* -* Input: uint32 nMsgOrd Indice del messaggio dentro l'array -* di strutture dei messaggi -* -* Return: Pointer al messaggio duplicato (che puo' essere liberato -* con GlobalFree()). -* -\****************************************************************************/ - +/** + * Duplicates a message + * @param nMsgOrd Index of the message inside the messages array + * @returns Pointer to the duplicated message. + * @remarks Remember to free the duplicated message when done with it. + */ static char *DuplicateMessage(uint32 nMsgOrd) { const char *origmsg; char *clonemsg; @@ -478,22 +356,13 @@ static char *DuplicateMessage(uint32 nMsgOrd) { } -/****************************************************************************\ -* -* Function: char * DuplicateDialogPeriod(uint32 nDlgOrd, uint32 nPeriod); -* -* Description: Duplica una frase di un dialog -* -* Input: uint32 nDlgOrd Indice del dialogo dentro l'array di -* strutture dei dialoghi -* -* uint32 nPeriod Numero della frase da duplicare -* -* Return: Pointer alla frase duplicata (che puo' essere liberata con -* GlobalFree()). -* -\****************************************************************************/ - +/** + * Duplicate a sentence of a dialog + * @param nDlgOrd Index of the dialog in the dialogs array + * @param nPeriod Sentence number to be duplicated. + * @returns Pointer to the duplicated phrase. Remember to free it + * when done with it. + */ static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; @@ -524,19 +393,12 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { } - -/****************************************************************************\ -* -* Function: HGLOBAL resLoad(uint32 dwId); -* -* Description: Carica una risorsa dal file MPR -* -* Input: uint32 dwId ID della risorsa da caricare -* -* Return: Handle alla memoria in cui si trova la risorsa -* -\****************************************************************************/ - +/** + * Load a resource from the MPR file + * + * @param dwId ID of the resource to load + * @returns Handle to the loaded resource + */ HGLOBAL resLoad(uint32 dwId) { int i; HGLOBAL h; @@ -736,21 +598,13 @@ static LPITEM GetItemData(uint32 nOrdItem) { } -/****************************************************************************\ -* -* Function: void CustomThread(LPCFCALL p); -* -* Description: Thread che richiama una funzione custom. Viene usato negli -* script, in modo che ciascuna funzione venga eseguita senza -* ritardare le altre -* -* Input: LPCFCALL p Struttura che definisce la chiamata -* -* Note: La struttura passata come parametro viene freeata con -* GlobalFree() alla fine dell'esecuzione. -* -\****************************************************************************/ - +/** + * Thread that calls a custom function. It is used in scripts, so that each script + * function is executed without delaying the others. + * + * @param param pointer to a pointer to the structure that defines the call. + * @remarks The passed structure is freed when the process finishes. + */ void CustomThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; LPCFCALL p; @@ -768,20 +622,12 @@ void CustomThread(CORO_PARAM, const void *param) { } -/****************************************************************************\ -* -* Function: void ScriptThread(LPMPALSCRIPT s); -* -* Description: Esegue uno script. Questa funzione e' pensata come starting -* point per un thread -* -* Input: LPMPALSCRIPT s Script da eseguire -* -* Note: Lo script passato come parametro viene, alla fine dell'ese- -* cuzione, freeato con una GlobalFree() -* -\****************************************************************************/ - +/** + * Main process for running a script. + * + * @param param Pointer to a pointer to a structure containing the script data. + * @remarks The passed structure is freed when the process finishes. + */ void ScriptThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; uint i, j, k; @@ -866,20 +712,13 @@ void ScriptThread(CORO_PARAM, const void *param) { } -/****************************************************************************\ -* -* Function: void ActionThread(LPMPALITEM item); -* -* Description: Thread che esegue una azione su un item. Il thread -* esegue sempre l'azione 0, per cui e' necessario creare -* un item nuovo in cui l'azione 0 sia quella richiesta. -* Inoltre non viene controllata l'espressione when, ma viene -* sempre eseguita l'azione. -* -* Input: LPMPALITEM item Item che contiene l'azione -* -\****************************************************************************/ - +/** + * Thread that performs an action on an item. the thread always executes the action, + * so it should create a new item in which the action is the one required. + * Furthermore, the expression is not checked, but it is always performed the action. + * + * @param param Pointer to a pointer to a structure containing the action. + */ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; @@ -935,8 +774,8 @@ void ActionThread(CORO_PARAM, const void *param) { /** * This thread monitors a created action to detect when it ends. - * @remarks Since actions can spawn sub-actions, this needs to be a - * separate thread to determine when the outer action is done + * @remarks Since actions can spawn sub-actions, this needs to be a + * separate thread to determine when the outer action is done */ void ShutUpActionThread(CORO_PARAM, const void *param) { // COROUTINE @@ -956,18 +795,12 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_END_CODE; } -/****************************************************************************\ -* -* Function: void LocationPollThread(uint32 id); -* -* Description: Esegue il polling di una locazione (starting point di un -* thread). -* -* Input: uint32 id Indice per gli array relativi ai -* polling degli item delle locazioni -* -\****************************************************************************/ +/** + * Polls one location (starting point of a process) + * + * @param param Pointer to an index in the array of polling locations. + */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { uint32 nItem, nAction; @@ -1257,22 +1090,17 @@ void LocationPollThread(CORO_PARAM, const void *param) { -/****************************************************************************\ -* -* Function: void ShutUpDialogThread(HANDLE hThread); -* -* Description: Aspetta la fine dell'esecuzione del dialog thread e ripri- -* stina le variabili globali indicando che il dialogo e' finito. -* -* Input: HANDLE hThread Handle del dialog thread -* -* Note: Si ricorre a questo thread aggiuntivo, al posto di azzerare -* le variabili all'interno del dialog thread stesso, poiche', -* a causa della natura ricorsiva di un dialogo, non e' sempre -* possibile sapere quando esattamente finisce un dialogo. -* -\****************************************************************************/ + +/** + * Wait for the end of the dialog execution thread, and then restore global + * variables indicating that the dialogue has finished. + * + * @param param Pointer to a handle to the dialog + * @remarks This additional process is used, instead of clearing variables + * within the same dialog thread, because due to the recursive nature of a dialog, + * it would be difficult to know within it when the dialog is actually ending. + */ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1296,9 +1124,10 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { void DoChoice(CORO_PARAM, uint32 nChoice); + /** * Executes a group of the current dialog. Can 'be the Starting point of a process. - * @parm nGroup Number of the group to perform + * @parm nGroup Number of the group to perform */ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; @@ -1371,16 +1200,11 @@ void GroupThread(CORO_PARAM, const void *param) { } -/****************************************************************************\ -* -* Function: void DoChoice(uint32 nChoice); -* -* Description: Esegue una scelta nel dialogo corrente -* -* Input: uint32 nChoice Numero della scelta da eseguire -* -\****************************************************************************/ - +/** + * Make a choice in the current dialog. + * + * @param nChoice Number of choice to perform + */ void DoChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; LPMPALDIALOG dialog; @@ -1476,29 +1300,18 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { } - -/****************************************************************************\ -* -* Function: HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam); -* -* Description: Esegue una azione su un certo item -* -* Input: uint32 nAction Numero dell'azione -* uint32 ordItem Indice dell'item nelle strutture -* degli item -* uint32 dwParam Eventuale parametro per l'azione -* -* Return: Handle del thread che sta eseguendo l'azione, oppure -* CORO_INVALID_PID_VALUE se l'azione non e' definita, o l'item -* e' disattivato. -* -* Note: Si puo' ottenere l'indice dell'item a partire dal suo numero -* tramite la funzione itemGetOrderFromNum(). -* Gli item devono essere lockati, perche' questa funzione -* funzioni, tramite LockItem(); -* -\****************************************************************************/ - +/** + * Perform an action on a certain item. + * + * @param nAction Action number + * @param ordItem Index of the item in the items list + * @param dwParam Any parameter for the action. + * @returns Id of the process that was launched to perform the action, or + * CORO_INVALID_PID_VALUE if the action was not defined, or the item was inactive. + * @remarks You can get the index of an item from it's number by using + * the itemGetOrderFromNum() function. The items list must first be locked + * by calling LockItem(). + */ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = GLOBALS.lpmiItems; int i; @@ -1594,20 +1407,14 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { } -/****************************************************************************\ -* -* Function: bool DoSelection(uint32 nChoice, uint32 dwData); -* -* Description: Prende nota del select scelto dall'utente, e avverte il -* thread che stava eseguendo il dialogo che puo' continuare. -* -* Input: uint32 nChoice Numero della scelta che era in corso -* uint32 dwData Dato abbinato al select selezionato -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Takes note of the selection chosen by the user, and warns the process that was running + * the box that it can continue. + * + * @param nChoice Number of choice that was in progress + * @param dwData Since combined with select selection + * @returns True if everything is OK, false on failure + */ bool DoSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; @@ -1625,30 +1432,18 @@ bool DoSelection(uint32 i, uint32 dwData) { } +/** + * @defgroup Exported functions + */ -/****************************************************************************\ -* Exported functions -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, -* LPLPCUSTOMFUNCTION lplpcfArray); -* -* Description: Inizializza la libreria MPAL, e apre un file .MPC, che -* verra' utilizzato per tutte le query -* -* Input: char * lpszMpcFileName Nome del file .MPC, comprensivo di -* estensione -* char * lpszMprFileName Nome del file .MPR, comprensivo di -* estensione -* LPLPCUSTOMFUNCTION -* lplpcfArray Array di pointer a funzioni custom -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Initialises the MPAL library and opens the .MPC file, which will be used for all queries. + * + * @param lpszMpcFileName Name of the MPC file + * @param lpszMprFileName Name of the MPR file + * @param lplpcfArray Array of pointers to custom functions. + * @returns True if everything is OK, false on failure + */ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) { Common::File hMpc; @@ -1803,34 +1598,15 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return true; } -/****************************************************************************\ -* -* Function: uint32 mpalQuery(uint16 wQueryType, ...); -* -* Description: Questa e' la funzione generale per comunicare con la libreria, -* per richiedere informazioni riguardo a quanto si trova nel -* file .MPC -* -* Input: uint16 wQueryType Tipo di query. La lista e' in -* enum QueryTypes -* -* Return: 4 bytes che dipendono dal tipo di query -* -* Note: E' _FORTEMENTE_ consigliato utilizzare le macro -* definite sopra per utilizzare le query, dato che -* permettono di evitare spiacevoli bug dovuti a dimenticanze -* di parametri. -* -\****************************************************************************/ - -#define GETARG(type) va_arg(v, type) /** - * MPAL Query variation #1 - dword return - * This variation handles mpal query types that need to return a dword result. + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file * - * @param wQueryType Query type - * @param v Variable length argument list + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns numeric results. */ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { int x, y, z; @@ -1844,6 +1620,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { GLOBALS.mpalError = OK; if (wQueryType == MPQ_VERSION) { + /* * uint32 mpalQuery(MPQ_VERSION); */ @@ -2021,11 +1798,13 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { } /** - * MPAL Query variation #1 - dword return - * This variation handles mpal query types that need to return a pointer/handle result + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file * - * @param wQueryType Query type - * @param v Variable length argument list + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns a pointer or handle. */ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { int x, y; @@ -2176,13 +1955,15 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { return hRet; } + /** - * MPAL Query variation #1 - dword return - * This variation handles mpal query types that need to return a pointer/handle result + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file * - * @param wQueryType Query type - * @param dwRet DWORD return value (when coroutine method completes) - * @param v Variable length argument list + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that needs to run within a co-routine context. */ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { CORO_BEGIN_CONTEXT; @@ -2216,34 +1997,22 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { } -/****************************************************************************\ -* -* Function: uint32 mpalGetError(void); -* -* Description: Ritorna il codice di errore corrente di MPAL -* -* Return: Codice di errore -* -\****************************************************************************/ - +/** + * Returns the current MPAL error code + * + * @returns Error code + */ uint32 mpalGetError(void) { return GLOBALS.mpalError; } -/****************************************************************************\ -* -* Function: void mpalExecuteScript(int nScript); -* -* Description: Esegue uno script. Lo script viene eseguito in multitasking -* tramite un thread. -* -* Input: int nScript Numero dello script da eseguire -* -* Return: true se lo script e' stato avviato, false in caso di errore -* -\****************************************************************************/ - +/** + * Execute a script. The script runs on multitasking by a thread. + * + * @param nScript Script number to run + * @returns TRUE if the script 'was launched, FALSE on failure + */ bool mpalExecuteScript(int nScript) { int n; LPMPALSCRIPT s; @@ -2265,38 +2034,26 @@ bool mpalExecuteScript(int nScript) { } -/****************************************************************************\ -* -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION GLOBALS.lpiifCustom); -* -* Description: Install a custom routine that will be called by MPAL every -* time the pattern of an item has been changed. -* -* Input: LPITEMIRQFUNCTION GLOBALS.lpiifCustom Custom function to install -* -\****************************************************************************/ - +/** + * Install a custom routine That will be called by MPAL every time the pattern + * of an item has been changed. + * + * @param lpiifCustom Custom function to install + */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { GLOBALS.lpiifCustom = lpiifCus; } -/****************************************************************************\ -* -* Function: bool mpalStartIdlePoll(int nLoc); -* -* Description: Process the idle actions of the items on one location. -* -* Input: int nLoc Number of the location whose items -* must be processed for idle actions. -* -* Return: true se tutto OK, false se si e' superato il limite massimo. -* -* Note: Il numero massimo delle locazione che e' possibile pollare -* contemporaneamente e' contenuto nel define MAXPOLLINGFUNCIONS -* -\****************************************************************************/ - +/** + * Process the idle actions of the items on one location. + * + * @param nLoc Number of the location whose items must be processed + * for idle actions. + * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. + * @remarks The maximum number of locations that can be polled + * simultaneously is defined defined by MAXPOLLINGFUNCIONS + */ bool mpalStartIdlePoll(int nLoc) { uint32 i; @@ -2322,20 +2079,13 @@ bool mpalStartIdlePoll(int nLoc) { } - -/****************************************************************************\ -* -* Function: bool mpalEndIdlePoll(int nLoc); -* -* Description: Stop processing the idle actions of the items on one location. -* -* Input: int nLoc Number of the location -* -* Return: true se tutto OK, false se la locazione specificata non era -* in fase di polling -* -\****************************************************************************/ - +/** + * Stop processing the idle actions of the items on one location. + * + * @param nLo Number of the location + * @returns TRUE if all OK, FALSE if the specified location was not + * in the process of polling + */ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_BEGIN_CONTEXT; int i; @@ -2365,33 +2115,22 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { } - -/****************************************************************************\ -* -* Function: int mpalGetSaveStateSize(void); -* -* Description: Acquire the length of a save state -* -* Return: Length in bytes -* -\****************************************************************************/ - +/** + * Retrieve the length of a save state + * + * @returns Length in bytes + */ int mpalGetSaveStateSize(void) { return GLOBALS.nVars * sizeof(MPALVAR) + 4; } -/****************************************************************************\ -* -* Function: void mpalSaveState(byte *buf); -* -* Description: Store the save state into a buffer. The buffer must be -* length at least the size specified with mpalGetSaveStateSize -* -* Input: byte *buf Buffer where to store the state -* -\****************************************************************************/ - +/** + * Store the save state into a buffer. The buffer must be + * length at least the size specified with mpalGetSaveStateSize + * + * @param buf Buffer where to store the state + */ void mpalSaveState(byte *buf) { LockVar(); WRITE_LE_UINT32(buf, GLOBALS.nVars); @@ -2399,18 +2138,13 @@ void mpalSaveState(byte *buf) { UnlockVar(); } -/****************************************************************************\ -* -* Function: int mpalLoadState(byte *buf); -* -* Description: Load a save state from a buffer. -* -* Input: byte *buf Buffer where to store the state -* -* Return: Length of the state in bytes -* -\****************************************************************************/ +/** + * Load a save state from a buffer. + * + * @param buf Buffer where to store the state + * @returns Length of the state buffer in bytes + */ int mpalLoadState(byte *buf) { // Dobbiamo distruggere tutte le variabili e ricrearle GlobalFree(GLOBALS.hVars); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 319f71c6a8..a14bfd1895 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -126,6 +126,12 @@ namespace Tony { namespace MPAL { +/****************************************************************************\ +* Type definitions +\****************************************************************************/ + +typedef void *HANDLE; + /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ @@ -140,25 +146,19 @@ namespace MPAL { #define LPSTR char * -/****************************************************************************\ -* enum QueryCoordinates -* --------------------- -* Description: Macro for use with queries that may refer to X and Y co-ordinates -\****************************************************************************/ - +/** + * Macro for use with queries that may refer to X and Y co-ordinates + */ enum QueryCoordinates { MPQ_X, MPQ_Y }; -/****************************************************************************\ -* enum QueryTypes -* --------------- -* Description: Query can be used with mpalQuery methods. In practice corresponds -* all claims that can do at the library -\****************************************************************************/ - +/** + * Query can be used with mpalQuery methods. In practice corresponds all claims + * that can do at the library + */ enum QueryTypes { /* General Query */ MPQ_VERSION=10, @@ -189,13 +189,9 @@ enum QueryTypes { MPQ_DO_DIALOG }; - -/****************************************************************************\ -* typedef ITEM -* ------------ -* Description: Framework to manage the animation of an item -\****************************************************************************/ - +/** + * Framework to manage the animation of an item + */ typedef struct { char *frames[MAXFRAMES]; Common::Rect frameslocations[MAXFRAMES]; @@ -214,311 +210,188 @@ typedef struct { typedef ITEM *LPITEM; -/****************************************************************************\ -* typedef LPCUSTOMFUNCTION -* ------------------------ -* Description: Define a custom function, to use the language MPAL -* to perform various controls as a result of an action -\****************************************************************************/ - +/** + * Define a custom function, to use the language MPAL to perform various controls as a result of an action + */ typedef void (*LPCUSTOMFUNCTION)(CORO_PARAM, uint32, uint32, uint32, uint32); typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; - -/****************************************************************************\ -* typedef LPITEMIRQFUNCTION -* ------------------------- -* Description: Define an IRQ of an item that is called when the -* pattern changes or the status of an item -\****************************************************************************/ - +/** + * + * Define an IRQ of an item that is called when the pattern changes or the status of an item + */ typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; +/** + * @defgroup Macrofunctions query + * + * The following are defines used for simplifying calling the mpalQuery variants + */ -/****************************************************************************\ -* Macrofunctions query -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: uint32 mpalQueryVersion(void); -* -* Description: Gets the current version of MPAL -* -* Return: Version number (0x1232 = 1.2.3b) -* -\****************************************************************************/ - +/** + * Gets the current version of MPAL + * + * @returns Version number (0x1232 = 1.2.3b) + */ #define mpalQueryVersion() \ (uint16)mpalQueryDWORD(MPQ_VERSION) - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); -* -* Description: Gets the numerical value of a global variable -* -* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) -* -* Return: Valore della variabile -* -* Note: This query was implemented for debugging. The program, -* if well designed, should not need to access variables from -* within the library. -* -\****************************************************************************/ - +/** + * Gets the numerical value of a global variable + * + * @param lpszVarName Nome della variabile (ASCIIZ) + * @returns Global variable value + * @remarks This query was implemented for debugging. The program, + * if well designed, should not need to access variables from + * within the library. + */ #define mpalQueryGlobalVar(lpszVarName) \ mpalQueryDWORD(MPQ_GLOBAL_VAR, (const char *)(lpszVarName)) - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryResource(uint32 dwResId); -* -* Description: Provides access to a resource inside the .MPC file -* -* Input: uint32 dwResId ID della risorsa -* -* Return: Handle to a memory area containing the resource, -* ready for use. -* -\****************************************************************************/ - +/** + * Provides access to a resource inside the .MPC file + * + * @param dwResId Resource Id + * @returns Handle to a memory area containing the resource, ready for use. + */ #define mpalQueryResource(dwResId) \ mpalQueryHANDLE(MPQ_RESOURCE, (uint32)(dwResId)) - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryMessage(uint32 nMsg); -* -* Description: Returns a message. -* -* Input: uint32 nMsg Message number -* -* Return: ASCIIZ message -* -* Note: The returned pointer must be freed with GlobalFree() +/** + * Returns a message. + * + * @param nMsg Message number + * @returns ASCIIZ message + * @remarks The returned pointer must be freed via the memory manager * after use. The message will be in ASCIIZ format. -* -\****************************************************************************/ - +*/ #define mpalQueryMessage(nMsg) \ (LPSTR)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); -* -* Description: Provides a image image -* -* Input: uint32 nLoc Locazion number -* -* Return: Returns a picture handle -* -\****************************************************************************/ - +/** + * Provides a location image + * @return Returns a picture handle + */ #define mpalQueryLocationImage(nLoc) \ mpalQueryHANDLE(MPQ_LOCATION_IMAGE, (uint32)(nLoc)) - -/****************************************************************************\ -* -* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); -* -* Description: Request the x or y size of a location in pixels -* -* Input: uint32 nLoc Location number -* uint32 dwCoord MPQ_Xr o MPQ_Y -* -* Return: Size -* -\****************************************************************************/ - +/** + * Request the x or y size of a location in pixels + * + * @param nLoc Location number + * @param dwCoord MPQ_X or MPQ_Y coordinate to retrieve + * @returns Size + */ #define mpalQueryLocationSize(nLoc,dwCoord) \ mpalQueryDWORD(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) - -/****************************************************************************\ -* -* Function: uint32 * mpalQueryItemList(uint32 nLoc); -* -* Description: Provides the list of objects in the lease. -* -* Input: uint32 nLoc Location number -* -* Return: List of objects (accessible by Item [0], Item [1], etc.) -* -\****************************************************************************/ -// TODO: Check if the results of this are endian safe +/** + * Provides the list of objects in a location. + * + * @param nLoc Location number + * @returns List of objects (accessible by Item [0], Item [1], etc.) + */ +// TODO: Determine if this is endian safe #define mpalQueryItemList(nLoc) \ (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST,(uint32)(nLoc)) - -/****************************************************************************\ -* -* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); -* -* Description: Provides information on an item -*e -* Input: uint32 nItem Item number -* -* Return: structure filled with requested information -* -\****************************************************************************/ - +/** + * Provides information on an item + * + * @param nItem Item number + * @returns Structure filled with requested information + */ #define mpalQueryItemData(nItem) \ (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA,(uint32)(nItem)) - -/****************************************************************************\ -* -* Function: uint32 mpalQueryItemPattern(uint32 nItem); -* -* Description: Provides the current pattern of an item -* -* Input: uint32 nItem Item number -* -* Return: Number of animation patterns to be executed. -* -* Note: By default, the pattern of 0 indicates that we should -* do nothing. -* -\****************************************************************************/ - +/** + * Provides the current pattern of an item + * + * @param nItem Item number + * @returns Number of animation patterns to be executed. + * @remarks By default, the pattern of 0 indicates that we should do nothing. + */ #define mpalQueryItemPattern(nItem) \ mpalQueryDWORD(MPQ_ITEM_PATTERN,(uint32)(nItem)) - -/****************************************************************************\ -* -* Function: bool mpalQueryItemIsActive(uint32 nItem); -* -* Description: Returns true if an item is active -* -* Input: uint32 nItem Item number -* -* Return: TRUE if the item is active, FALSE otherwise -* -\****************************************************************************/ - +/** + * Returns true if an item is active + * + * @param nItem Item number + * @returns TRUE if the item is active, FALSE otherwise + */ #define mpalQueryItemIsActive(nItem) \ (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) -/****************************************************************************\ -* -* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); -* -* Description: Returns the name of an item -* -* Input: uint32 nItem Item number -* LPSTR lpszName Pointer to a buffer of at least 33 bytes -* that will be filled with the name -* -* Note: If the item is not active (ie. if its status or number -* is less than or equal to 0), the string will be empty. -* -\****************************************************************************/ - +/** + * Returns the name of an item + * + * @param nItem Item number + * @param lpszName Pointer to a buffer of at least 33 bytes + * that will be filled with the name + * @remarks If the item is not active (ie. if its status or number + * is less than or equal to 0), the string will be empty. + */ #define mpalQueryItemName(nItem, lpszName) \ mpalQueryHANDLE(MPQ_ITEM_NAME,(uint32)(nItem), (LPSTR)(lpszName)) - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); -* -* Description: Returns a sentence of dialog. -* -* Input: uint32 nDialog Dialog number -* uint32 nPeriod Number of words -* -* Return: A pointer to the string of words, or NULL on failure. -* -* Note: The string must be freed after use by GlobalFree (). -* -* Unlike normal messages, the sentences of dialogue -* are formed by a single string terminated with 0. -* -\****************************************************************************/ - +/** + * Returns a sentence of dialog. + * + * @param nDialog Dialog number + * @param nPeriod Number of words + * @returns A pointer to the string of words, or NULL on failure. + * @remarks The string must be freed after use using the memory manager. + * Unlike normal messages, the sentences of dialogue are formed by a single + * string terminated with 0. + */ #define mpalQueryDialogPeriod(nPeriod) \ (LPSTR)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) - -/****************************************************************************\ -* -* Function: int mpalQueryDialogWaitForChoice(void); -* -* Description: Wait until the moment in which the need is signaled -* to make a choice by the user. -* -* Return: Number of choice to be made, or -1 if the dialogue is finished. -* -\****************************************************************************/ - +/** + * Wait until the moment in which the need is signaled to make a choice by the user. + * @returns Number of choice to be made, or -1 if the dialogue is finished. + */ #define mpalQueryDialogWaitForChoice(dwRet) \ CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) -/****************************************************************************\ -* -* Function: uint32 * mpalQueryDialogSelectList(uint32 nChoice); -* -* Description: Requires a list of various options for some choice within -* the current dialog. - -* Input: uint32 nChoice Choice number -* -* Return: A pointer to an array containing the data matched to each option. -* -* Note: The figure 'a uint32 specified in the source to which MPAL -* You can 'assign meaning that the more' suits. -* -* The pointer msut be freed after use by GlobalFree(). -* -\****************************************************************************/ +/** + * Requires a list of various options for some choice within the current dialog. + * + * @param nChoice Choice number + * @returns A pointer to an array containing the data matched to each option. + * @remarks The figure 'a uint32 specified in the source to which MPAL + * You can assign meaning that the more' suits. + * The pointer msut be freed after use using the memory memory. + */ #define mpalQueryDialogSelectList(nChoice) \ (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) - -/****************************************************************************\ -* -* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); -* -* Description: Warns the library that the user has selected, in a certain -* choice of the current dialog, corresponding option -* at a certain given. -* -* Input: uint32 nChoice Choice number of the choice that -* was in progress -* uint32 dwData Option that was selected by the user. -* -* Return: TRUE if all OK, FALSE on failure. -* -* Note: After execution of this query, MPAL continue -* Groups according to the execution of the dialogue. And necessary so the game -* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). -* -\****************************************************************************/ - +/** + * Warns the library that the user has selected, in a certain choice of the current dialog, + * corresponding option at a certain given. + * + * @param nChoice Choice number of the choice that was in progress + * @param dwData Option that was selected by the user. + * @returns TRUE if all OK, FALSE on failure. + * @remarks After execution of this query, MPAL continue + * Groups according to the execution of the dialogue. And necessary so the game + * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). + */ #define mpalQueryDialogSelection(nChoice,dwData) \ (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) @@ -526,245 +399,169 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, -* uint32 dwParam); -* -* Description: Warns the library an action was performed on a Object. -* The library will call 'custom functions, if necessary. -* -* Input: uint32 nAction Action number -* uint32 nItem Item number -* uint32 dwParam Action parameter -* -* Return: Handle to the thread that is performing the action, or -* CORO_INVALID_PID_VALUE if the action is not 'defined for -* the item, or the item and 'off. -* -* Note: The parameter is used primarily to implement actions -* as "U.S." involving two objects together. The action will be executed only -* if the item is active, ie if its status is a positive number greater than 0. -* -\****************************************************************************/ - +/** + * Warns the library an action was performed on a Object. + * The library will call custom functions, if necessary. + * + * @param nAction Action number + * @param nItem Item number + * @param dwParam Action parameter + * @returns Handle to the thread that is performing the action, or CORO_INVALID_PID_VALUE + * if the action is not defined for the item, or the item is inactive. + * @remarks The parameter is used primarily to implement actions + * as "U.S." involving two objects together. The action will be executed only + * if the item is active, ie if its status is a positive number greater than 0. + */ #define mpalQueryDoAction(nAction, nItem, dwParam) \ mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) - -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); -* -* Description: Warns the library a dialogue was required. -* -* Input: uint32 nDialog Dialog number -* uint32 nGroup Group number to use -* -* Return: Handle to the thread that is running the box, or -* CORO_INVALID_PID_VALUE if the dialogue does not exist. -* -\****************************************************************************/ - +/** + * Warns the library a dialogue was required. + * + * @param nDialog Dialog number + * @param nGroup Group number to use + * @returns Handle to the thread that is running the box, or + * CORO_INVALID_PID_VALUE if the dialogue does not exist. + */ #define mpalQueryDoDialog(nDialog,nGroup) \ mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) -/****************************************************************************\ -* Functions exported to the main game -\****************************************************************************/ - +/** + * @defgroup Functions exported to the main game + */ -/****************************************************************************\ -* -* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, -* LPLPCUSTOMFUNCTION lplpcfArray); -* -* Description: Initializes the MPAL library, and opens an .MPC file, which -* will be 'used for all queries -* -* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension -* LPSTR lpszMprFileName Name of the .MPR file, including extension -* LPLPCUSTOMFUNCTION Array of pointers to custom functions -* -* Return: TRUE if all OK, FALSE on failure -* -\****************************************************************************/ +/** + * Initializes the MPAL library, and opens an .MPC file, which will be 'used for all queries + * @param lpszMpcFileName Name of the .MPC file, including extension + * @param lpszMprFileName Name of the .MPR file, including extension + * @param lplpcfArray Array of pointers to custom functions + * @returns TRUE if all OK, FALSE on failure + */ bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); - -/****************************************************************************\ -* -* Function: uint32 mpalQuery(uint16 wQueryType, ...); -* -* Description: This is the general function to communicate with the library, -* To request information about what is in the .MPC file -* -* Input: uint16 wQueryType Type of query. The list is in -* the QueryTypes enum. -* -* Return: 4 bytes depending on the type of query -* -* Note: I _strongly_ recommended to use macros defined above to use -* the query, since it helps avoid any unpleasant bugs due to -* forgeting parameters. -* -\****************************************************************************/ - -typedef void *HANDLE; - +/** + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file + * + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns numeric results. + */ uint32 mpalQueryDWORD(uint16 wQueryType, ...); +/** + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file + * + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns a pointer or handle. + */ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); +/** + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file + * + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that needs to run within a co-routine context. + */ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); -/****************************************************************************\ -* -* Function: bool mpalExecuteScript(int nScript); -* -* Description: Execute a script. The script runs on multitasking by a thread. -* -* Input: int nScript Script number to run -* -* Return: TRUE if the script 'was launched, FALSE on failure -* -\****************************************************************************/ +/** + * Execute a script. The script runs on multitasking by a thread. + * + * @param nScript Script number to run + * @returns TRUE if the script 'was launched, FALSE on failure + */ bool mpalExecuteScript(int nScript); - -/****************************************************************************\ -* -* Function: uint32 mpalGetError(void); -* -* Description: Returns the current MPAL error code -* -* Return: Error code -* -\****************************************************************************/ - +/** + * Returns the current MPAL error code + * + * @returns Error code + */ uint32 mpalGetError(void); - -/****************************************************************************\ -* -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); -* -* Description: Install a custom routine That will be called by MPAL -* every time the pattern of an item has-been changed. -* -* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install -* -\****************************************************************************/ - +/** + * Install a custom routine That will be called by MPAL every time the pattern + * of an item has been changed. + * + * @param lpiifCustom Custom function to install + */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); -/****************************************************************************\ -* -* Function: bool mpalStartIdlePoll(int nLoc); -* -* Description: Process the idle actions of the items on one location. -* -* Input: int nLoc Number of the location whose items -* must be processed for idle actions. -* -* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. -* -* Note: The maximum number of locations that can be polled -* simultaneously is defined defined by MAXPOLLINGFUNCIONS -* -\****************************************************************************/ - +/** + * Process the idle actions of the items on one location. + * + * @param nLoc Number of the location whose items must be processed + * for idle actions. + * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. + * @remarks The maximum number of locations that can be polled + * simultaneously is defined defined by MAXPOLLINGFUNCIONS + */ bool mpalStartIdlePoll(int nLoc); -/****************************************************************************\ -* -* Function: bool mpalEndIdlePoll(int nLoc); -* -* Description: Stop processing the idle actions of the items on one location. -* -* Input: int nLoc Number of the location -* -* Return: TRUE if all OK, FALSE if the specified location was not -* in the process of polling -* -\****************************************************************************/ - +/** + * Stop processing the idle actions of the items on one location. + * + * @param nLo Number of the location + * @returns TRUE if all OK, FALSE if the specified location was not + * in the process of polling + */ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); -/****************************************************************************\ -* -* Function: int mpalLoadState(LPBYTE buf); -* -* Description: Load a save state from a buffer. -* -* Input: LPBYTE buf Buffer where to store the state -* -* Return: Length of the state in bytes -* -\****************************************************************************/ - +/** + * Load a save state from a buffer. + * + * @param buf Buffer where to store the state + * @returns Length of the state buffer in bytes + */ int mpalLoadState(byte *buf); - -/****************************************************************************\ -* -* Function: void mpalSaveState(LPBYTE buf); -* -* Description: Store the save state into a buffer. The buffer must be -* length at least the size specified with mpalGetSaveStateSize -* -* Input: LPBYTE buf Buffer where to store the state -* -\****************************************************************************/ - +/** + * Store the save state into a buffer. The buffer must be + * length at least the size specified with mpalGetSaveStateSize + * + * @param buf Buffer where to store the state + */ void mpalSaveState(byte *buf); - -/****************************************************************************\ -* -* Function: int mpalGetSaveStateSize(void); -* -* Description: Acquire the length of a save state -* -* Return: Length in bytes -* -\****************************************************************************/ - +/** + * Retrieve the length of a save state + * + * @returns Length in bytes + */ int mpalGetSaveStateSize(void); -/****************************************************************************\ -* -* Function: void LockVar(void); -* -* Description: Locka le variabili per accederci -* -\****************************************************************************/ - -extern void LockVar(void); +/** + * Locks the variables for access + */ +void LockVar(void); -/****************************************************************************\ -* -* Function: void UnlockVar(void); -* -* Description: Unlocka le variabili dopo l'uso -* -\****************************************************************************/ -extern void UnlockVar(void); +/** + * Unlocks variables after use + */ +void UnlockVar(void); } // end of namespace MPAL -- cgit v1.2.3 From bcaeacf1246b652f1564fc7696719ca9429b5acf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 18 May 2012 22:57:25 +1000 Subject: TONY: Implemented support for loading savegames directly from the launcher. It's not perfect.. the startup screen briefly flashes, and Tony briefly disappears when you do a first action afterwards. --- engines/tony/mpal/mpal.cpp | 11 ++++++++--- engines/tony/tony.cpp | 5 +++-- engines/tony/tony.h | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a173b707f2..854372cdda 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -767,8 +767,6 @@ void ActionThread(CORO_PARAM, const void *param) { debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); - CORO_KILL_SELF(); - CORO_END_CODE; } @@ -780,6 +778,7 @@ void ActionThread(CORO_PARAM, const void *param) { void ShutUpActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; + int slotNumber; CORO_END_CONTEXT(_ctx); uint32 pid = *(const uint32 *)param; @@ -790,7 +789,13 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { GLOBALS.bExecutingAction = false; - CORO_KILL_SELF(); + if (_vm->_initialLoadSlotNumber != -1) { + _ctx->slotNumber = _vm->_initialLoadSlotNumber; + _vm->_initialLoadSlotNumber = -1; + + CORO_INVOKE_1(_vm->LoadState, _ctx->slotNumber); + } + CORO_END_CODE; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c7056cb88d..2dbe102424 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -38,6 +38,7 @@ TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { _vm = this; + _loadSlotNumber = -1; DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); @@ -45,11 +46,11 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); // Set up load slot number - _loadSlotNumber = -1; + _initialLoadSlotNumber = -1; if (ConfMan.hasKey("save_slot")) { int slotNumber = ConfMan.getInt("save_slot"); if (slotNumber >= 0 && slotNumber <= 99) - _loadSlotNumber = slotNumber; + _initialLoadSlotNumber = slotNumber; } } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f40eb1325d..18d4a37067 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -78,8 +78,6 @@ struct VoiceHeader { class TonyEngine : public Engine { private: - int _loadSlotNumber; - Common::ErrorCode Init(); void InitMusic(); void CloseMusic(); @@ -122,6 +120,8 @@ public: bool m_bDrawLocation; int m_startTime; uint16 *m_curThumbnail; + int _initialLoadSlotNumber; + int _loadSlotNumber; // Bounding box list manager RMGameBoxes _theBoxes; -- cgit v1.2.3 From 5d18a71045bd933fc2efc7ed6e60ef7763745cb7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 12:33:14 +1000 Subject: TONY: Converting comments to English and formatting --- engines/tony/mpal/expr.cpp | 293 ++++++++++++++++++------------------------ engines/tony/mpal/expr.h | 65 +++------- engines/tony/mpal/loadmpc.cpp | 235 ++++++++++++++------------------- engines/tony/mpal/loadmpc.h | 21 +-- 4 files changed, 247 insertions(+), 367 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 19170ce60c..5e09e5dec6 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -61,9 +61,9 @@ namespace Tony { namespace MPAL { -/****************************************************************************\ -* Operazioni matematiche gestite -\****************************************************************************/ +/** + * @defgroup Mathamatical operations + */ #define OP_MUL ((1<<4)|0) #define OP_DIV ((1<<4)|1) @@ -85,32 +85,24 @@ namespace MPAL { #define OP_OR ((10<<4)|0) -/****************************************************************************\ -* enum ExprListTypes -* ------------------ -* Description: Tipi di oggetto che possono essere contenuti in una struttura -* EXPRESSION. -\****************************************************************************/ - -enum ExprListTypes -{ - ELT_NUMBER=1, - ELT_VAR=2, - ELT_PARENTH=3, - ELT_PARENTH2=4 +/** + * Object types that can be contained in an EXPRESSION structure + */ +enum ExprListTypes { + ELT_NUMBER = 1, + ELT_VAR = 2, + ELT_PARENTH = 3, + ELT_PARENTH2 = 4 }; -/****************************************************************************\ -* Structures -\****************************************************************************/ - -/****************************************************************************\ -* typedef EXPRESSION -* ------------------ -* Description: Struttura per gestire le operazioni matematiche -\****************************************************************************/ +/** + * @defgroup Structures + */ +/** + * Mathamatical framework to manage operations + */ typedef struct { byte type; // Tipo di oggetto (vedi enum ExprListTypes) byte unary; // Unary operatore (NON SUPPORTATO) @@ -128,38 +120,31 @@ typedef struct { typedef EXPRESSION* LPEXPRESSION; -/****************************************************************************\ -* -* Function: LPEXPRESSION DuplicateExpression(HGLOBAL h); -* -* Description: Duplica un'espressione matematica. L'espressione duplicata -* sara' formata da memoria non swappabile. -* -* Input: HGLOBAL h Handle dell'espressione originale -* -* Return: Pointer all'espressione clone della prima -* -\****************************************************************************/ - +/** + * Duplicate a mathematical expression. + * + * @param h Handle to the original expression + * @retruns Pointer to the cloned expression + */ static byte *DuplicateExpression(HGLOBAL h) { int i, num; byte *orig, *clone; LPEXPRESSION one, two; - orig=(byte *)GlobalLock(h); + orig = (byte *)GlobalLock(h); - num=*(byte *)orig; - one=(LPEXPRESSION)(orig+1); + num = *(byte *)orig; + one = (LPEXPRESSION)(orig+1); - clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION)*num+1); - two=(LPEXPRESSION)(clone+1); + clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); + two = (LPEXPRESSION)(clone + 1); - CopyMemory(clone,orig,sizeof(EXPRESSION)*num+1); + CopyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); - for (i=0;itype==ELT_PARENTH) { - two->type=ELT_PARENTH2; - two->val.pson=DuplicateExpression(two->val.son); + for (i = 0; i < num; i++) { + if (one->type == ELT_PARENTH) { + two->type = ELT_PARENTH2; + two->val.pson = DuplicateExpression(two->val.son); } one++; @@ -173,41 +158,41 @@ static byte *DuplicateExpression(HGLOBAL h) { static int Compute(int a, int b, byte symbol) { switch (symbol) { case OP_MUL: - return a*b; + return a * b; case OP_DIV: - return a/b; + return a / b; case OP_MODULE: - return a%b; + return a % b; case OP_ADD: - return a+b; + return a + b; case OP_SUB: - return a-b; + return a - b; case OP_SHL: - return a<>b; + return a >> b; case OP_MINOR: - return ab; + return a > b; case OP_MINEQ: - return a<=b; + return a <= b; case OP_MAJEQ: - return a>=b; + return a >= b; case OP_EQUAL: - return a==b; + return a == b; case OP_NOEQUAL: - return a!=b; + return a != b; case OP_BITAND: - return a&b; + return a & b; case OP_BITXOR: - return a^b; + return a ^ b; case OP_BITOR: - return a|b; + return a | b; case OP_AND: - return a&&b; + return a && b; case OP_OR: - return a||b; + return a || b; default: GLOBALS.mpalError = 1; break; @@ -220,52 +205,45 @@ static void Solve(LPEXPRESSION one, int num) { LPEXPRESSION two, three; int j; - while (num>1) { - two=one+1; - if ((two->symbol==0) || (one->symbol&0xF0) <= (two->symbol&0xF0)) { - two->val.num=Compute(one->val.num,two->val.num,one->symbol); - CopyMemory(one,two,(num-1)*sizeof(EXPRESSION)); + while (num > 1) { + two=one + 1; + if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { + two->val.num=Compute(one->val.num, two->val.num,one->symbol); + CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { - j=1; - three=two+1; - while ((three->symbol!=0) && (two->symbol&0xF0)>(three->symbol&0xF0)) { + j = 1; + three = two + 1; + while ((three->symbol != 0) && (two->symbol & 0xF0)>(three->symbol & 0xF0)) { two++; three++; j++; } - three->val.num=Compute(two->val.num,three->val.num,two->symbol); - CopyMemory(two,three,(num-j-1)*sizeof(EXPRESSION)); + three->val.num = Compute(two->val.num, three->val.num, two->symbol); + CopyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); num--; } } } -/****************************************************************************\ -* -* Function: int EvaluateAndFreeExpression(byte *expr); -* -* Description: Calcola il risultato di una espressione matematica, sosti- -* tuendo ad eventuali variabili il valore corrente. -* -* Input: byte *expr Pointer all'espressione duplicata -* tramite DuplicateExpression -* -* Return: Valore dell'espressione -* -\****************************************************************************/ - +/** + * Calculates the result of a mathematical expression, replacing the current + * value of any variable. + * + * @param expr Pointer to an expression duplicated by DuplicateExpression + * @returns Value + */ static int EvaluateAndFreeExpression(byte *expr) { int i,num,val; LPEXPRESSION one,cur; - num=*expr; - one=(LPEXPRESSION)(expr+1); + num = *expr; + one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i=0,cur=one;itype==ELT_VAR) { cur->type=ELT_NUMBER; cur->val.num=varGetValue(cur->val.name); @@ -273,39 +251,30 @@ static int EvaluateAndFreeExpression(byte *expr) { } // 2) Sostituzioni delle parentesi (tramite ricorsione) - for (i=0,cur=one;itype==ELT_PARENTH2) { - cur->type=ELT_NUMBER; - cur->val.num=EvaluateAndFreeExpression(cur->val.pson); + for (i = 0, cur = one; i < num; i++, cur++) { + if (cur->type == ELT_PARENTH2) { + cur->type = ELT_NUMBER; + cur->val.num = EvaluateAndFreeExpression(cur->val.pson); } } // 3) Risoluzione algebrica - Solve(one,num); - val=one->val.num; + Solve(one, num); + val = one->val.num; GlobalFree(expr); return val; } -/****************************************************************************\ -* -* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); -* -* Description: Esegue il parsing da file .MPC di un'espressione matematica. -* -* Input: byte *buf Buffer contenente l'espressione -* compilata. -* HGLOBAL *h Pointer a un handle che, alla fine -* dell'esecuzione, puntera' alla -* zona di memoria contenete l'espres- -* sione parsata -* -* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso -* di errore. -* -\****************************************************************************/ +/** + * Parses a mathematical expression from the MPC file + * + * @param buf Buffer containing the expression to evaluate + * @param h Pointer to a handle that, at the end of execution, + * will point to the area of memory containing the parsed expression + * @returns Pointer to the buffer immediately after the expression, or NULL if error. + */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; @@ -317,36 +286,36 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h==NULL) return NULL; - start=(byte *)GlobalLock(*h); - *start=(byte)num; + start = (byte *)GlobalLock(*h); + *start = (byte)num; - cur=(LPEXPRESSION)(start+1); + cur = (LPEXPRESSION)(start + 1); - for (i=0;itype=*(lpBuf); - cur->unary=*(lpBuf+1); - lpBuf+=2; + for (i = 0;i < num; i++) { + cur->type = *(lpBuf); + cur->unary = *(lpBuf + 1); + lpBuf += 2; switch (cur->type) { case ELT_NUMBER: - cur->val.num=*(int *)lpBuf; - lpBuf+=4; + cur->val.num = *(int *)lpBuf; + lpBuf += 4; break; case ELT_VAR: - cur->val.name=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,(*lpBuf)+1); - if (cur->val.name==NULL) + cur->val.name = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); + if (cur->val.name == NULL) return NULL; - CopyMemory(cur->val.name,lpBuf+1,*lpBuf); - lpBuf+=*lpBuf+1; + CopyMemory(cur->val.name, lpBuf + 1, *lpBuf); + lpBuf += *lpBuf + 1; break; case ELT_PARENTH: - lpBuf=ParseExpression(lpBuf,&cur->val.son); - if (lpBuf==NULL) + lpBuf=ParseExpression(lpBuf, &cur->val.son); + if (lpBuf == NULL) return NULL; break; @@ -354,13 +323,13 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; } - cur->symbol=*lpBuf; + cur->symbol = *lpBuf; lpBuf++; cur++; } - if (*lpBuf!=0) + if (*lpBuf != 0) return NULL; lpBuf++; @@ -369,18 +338,12 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { } -/****************************************************************************\ -* -* Function: int EvaluateExpression(HGLOBAL h); -* -* Description: Calcola il valore di un'espressione matematica -* -* Input: HGLOBAL h Handle all'espressione -* -* Return: Valore numerico -* -\****************************************************************************/ - +/** + * Calculate the value of a mathamatical expression + * + * @param h Handle to the expression + * @returns Numeric value + */ int EvaluateExpression(HGLOBAL h) { int ret; @@ -392,28 +355,22 @@ int EvaluateExpression(HGLOBAL h) { } -/****************************************************************************\ -* -* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); -* -* Description: Confronta due espressioni matematiche tra loro -* -* Input: HGLOBAL h1,h2 Espressioni da confrontare -* -* Return: true se sono uguali, false se sono diverse -* -\****************************************************************************/ - +/** + * Compare two mathematical expressions together + * + * @param h1 Expression to be compared + * @param h2 Expression to be compared + */ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { - int i,num1,num2; + int i, num1, num2; byte *e1, *e2; LPEXPRESSION one, two; - e1=(byte *)GlobalLock(h1); - e2=(byte *)GlobalLock(h2); + e1 = (byte *)GlobalLock(h1); + e2 = (byte *)GlobalLock(h2); - num1=*(byte *)e1; - num2=*(byte *)e2; + num1 = *(byte *)e1; + num2 = *(byte *)e2; if (num1 != num2) { GlobalUnlock(h1); @@ -421,11 +378,11 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one=(LPEXPRESSION)(e1+1); - two=(LPEXPRESSION)(e2+1); + one = (LPEXPRESSION)(e1+1); + two = (LPEXPRESSION)(e2+1); - for (i=0;itype!=two->type || (i!=num1-1 && one->symbol!=two->symbol)) { + for (i = 0; i < num1; i++) { + if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { GlobalUnlock(h1); GlobalUnlock(h2); return false; @@ -449,7 +406,7 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_PARENTH: - if (!CompareExpressions(one->val.son,two->val.son)) { + if (!CompareExpressions(one->val.son, two->val.son)) { GlobalUnlock(h1); GlobalUnlock(h2); return false; diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 582f6d381d..3a9f0f3208 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -55,60 +55,37 @@ namespace Tony { namespace MPAL { /****************************************************************************\ -* Prototipi di funzione -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); -* -* Description: Esegue il parsing da file .MPC di un'espressione matematica. -* -* Input: byte *buf Buffer contenente l'espressione -* compilata. -* HGLOBAL *h Pointer a un handle che, alla fine -* dell'esecuzione, puntera' alla -* zona di memoria contenete l'espres- -* sione parsata -* -* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso -* di errore. -* +* Function Prototypes \****************************************************************************/ +/** + * Parses a mathematical expression from the MPC file + * + * @param buf Buffer containing the expression to evaluate + * @param h Pointer to a handle that, at the end of execution, + * will point to the area of memory containing the parsed expression + * @returns Pointer to the buffer immediately after the expression, or NULL if error. + */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); -/****************************************************************************\ -* -* Function: int EvaluateExpression(HGLOBAL h); -* -* Description: Calcola il valore di un'espressione matematica -* -* Input: HGLOBAL h Handle all'espressione -* -* Return: Valore numerico -* -\****************************************************************************/ - +/** + * Calculate the value of a mathamatical expression + * + * @param h Handle to the expression + * @returns Numeric value + */ int EvaluateExpression(HGLOBAL h); -/****************************************************************************\ -* -* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); -* -* Description: Confronta due espressioni matematiche tra loro -* -* Input: HGLOBAL h1,h2 Espressioni da confrontare -* -* Return: TRUE se sono uguali, FALSE se sono diverse -* -\****************************************************************************/ - +/** + * Compare two mathematical expressions together + * + * @param h1 Expression to be compared + * @param h2 Expression to be compared + */ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6430325503..6a1213bc19 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -76,22 +76,14 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { } -/****************************************************************************\ -* -* Function: LPBTYE ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript); -* -* Description: Esegue il parsing da file .MPC di uno script e inserisce il -* tutto dentro una struttura -* -* Input: byte *lpBuf Buffer contenente lo script compilato -* LPMPALSCRIPT lpmsScript Puntatore a una struttura che verra' -* riempita con i dati dello script -* lato -* -* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore -* -\****************************************************************************/ - +/** + * Parses a script from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled script. + * @param lpmsScript Pointer to a structure that will be filled with the + * data of the script. + * @returns Pointer to the buffer after the item, or NULL on failure. + */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { int curCmd,j,len; uint i; @@ -102,14 +94,14 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpmsScript->nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; - curCmd=0; + curCmd = 0; - for (i=0;inMoments;i++) { + for (i = 0; i < lpmsScript->nMoments; i++) { lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds=*lpBuf; lpBuf++; + lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; - for (j=0;jMoment[i].nCmds;j++) { - lpmsScript->Command[curCmd].type=*lpBuf; lpBuf++; + for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { + lpmsScript->Command[curCmd].type = *lpBuf; lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -121,14 +113,14 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { case 2: // Variable assign len=*lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); - if (lpmsScript->Command[curCmd].lpszVarName==NULL) + lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmsScript->Command[curCmd].lpszVarName == NULL) return NULL; CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); lpBuf+=len; lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); - if (lpBuf==NULL) + if (lpBuf == NULL) return NULL; break; @@ -136,7 +128,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return NULL; } - lpmsScript->Moment[i].CmdNum[j]=curCmd; + lpmsScript->Moment[i].CmdNum[j] = curCmd; curCmd++; } } @@ -145,26 +137,17 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { } -/****************************************************************************\ -* -* Function: byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog); -* -* Description: Esegue il parsing da file .MPC di un dialog, e inserisce il -* tutto dentro una struttura -* -* Input: byte *lpBuf Buffer contenente il dialogo compi- -* lato -* LPMPALDIALOG lpmdDialog Puntatore a una struttura che verra' -* riempita con i dati del dialogo -* compilato -* -* Return: Puntatore al buffer dopo il dialogo, o NULL in caso di errore -* -\****************************************************************************/ - +/** + * Parses a dialog from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled dialog. + * @param lpmdDialog Pointer to a structure that will be filled with the + * data of the dialog. + * @returns Pointer to the buffer after the item, or NULL on failure. + */ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { - uint32 i,j,z,kk; - uint32 num,num2,num3; + uint32 i, j, z, kk; + uint32 num, num2, num3; byte *lpLock; uint32 curCmd; uint32 len; @@ -309,7 +292,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; } - // Segna l'ultimo select + // Mark the last selection lpmdDialog->Choice[i].Select[num2].dwData = 0; } @@ -318,70 +301,61 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { return lpBuf; } -/****************************************************************************\ -* -* Function: byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem); -* -* Description: Esegue il parsing da file .MPC di un item, e inserisce il -* tutto dentro una struttura -* -* Input: byte *lpBuf Buffer contenete l'item compilato -* LPMPALITEM lpmiItem Puntatore a una struttura che verra' -* riempita con i dati dell'item -* compilato -* -* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore -* -* Note: E' necessario che la struttura passata come parametro sia -* stata completamente inizializzata a 0 (con una ZeroMemory, -* ad esempio). -* -\****************************************************************************/ +/** + * Parses an item from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled dialog. + * @param lpmiItem Pointer to a structure that will be filled with the + * data of the item. + * @returns Pointer to the buffer after the item, or NULL on failure. + * @remarks It's necessary that the structure that is passed has been + * completely initialised to 0 beforehand. + */ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; - uint32 i,j,kk; + uint32 i, j, kk; uint32 curCmd; lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - len=*lpBuf; + len = *lpBuf; lpBuf++; - CopyMemory(lpmiItem->lpszDescribe,lpBuf, MIN((byte)127, len)); - lpBuf+=len; + CopyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) - error("Describe too long in item #%d",lpmiItem->nObj); + error("Describe too long in item #%d", lpmiItem->nObj); lpmiItem->nActions=*lpBuf; lpBuf++; /* Alloca le azioni */ - if (lpmiItem->nActions>0) - lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(struct ItemAction)*(int)lpmiItem->nActions); + if (lpmiItem->nActions > 0) + lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); - curCmd=0; + curCmd = 0; - for (i=0;inActions;i++) { - lpmiItem->Action[i].num=*lpBuf; + for (i = 0; i < lpmiItem->nActions; i++) { + lpmiItem->Action[i].num = *lpBuf; lpBuf++; lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (lpmiItem->Action[i].num==0xFF) { + if (lpmiItem->Action[i].num == 0xFF) { lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Action[i].perc=*lpBuf; + lpmiItem->Action[i].perc = *lpBuf; lpBuf++; } - if (*lpBuf==0) { + if (*lpBuf == 0) { lpBuf++; - lpmiItem->Action[i].when=NULL; + lpmiItem->Action[i].when = NULL; } else { lpBuf++; lpBuf = ParseExpression(lpBuf,&lpmiItem->Action[i].when); @@ -395,8 +369,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); - for (j=0;jAction[i].nCmds;j++) { - lpmiItem->Command[curCmd].type=*lpBuf; + for (j = 0; j < lpmiItem->Action[i].nCmds; j++) { + lpmiItem->Command[curCmd].type = *lpBuf; lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function @@ -408,16 +382,16 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { break; case 2: // Variable assign - len=*lpBuf; + len = *lpBuf; lpBuf++; - lpmiItem->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); - if (lpmiItem->Command[curCmd].lpszVarName==NULL) + lpmiItem->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->Command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmiItem->Command[curCmd].lpszVarName,lpBuf,len); - lpBuf+=len; + CopyMemory(lpmiItem->Command[curCmd].lpszVarName, lpBuf, len); + lpBuf += len; - lpBuf=ParseExpression(lpBuf,&lpmiItem->Command[curCmd].expr); - if (lpBuf==NULL) + lpBuf=ParseExpression(lpBuf, &lpmiItem->Command[curCmd].expr); + if (lpBuf == NULL) return NULL; break; @@ -425,15 +399,15 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { return NULL; } - for (kk=0;kkCommand[kk],&lpmiItem->Command[curCmd])) { - lpmiItem->Action[i].CmdNum[j]=kk; + lpmiItem->Action[i].CmdNum[j] = kk; break; } } if (kk==curCmd) { - lpmiItem->Action[i].CmdNum[j]=curCmd; + lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { @@ -450,23 +424,14 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } -/****************************************************************************\ -* -* Function: byte *ParseLocation(byte *buf, LPMPALLOCATIONN lpmlLocation) -* -* Description: Esegue il parsing da file .MPC di una locazione, riempendo -* una struttura -* -* Input: byte *buf Buffer contenente la locazione -* compilata -* LPMPALLOCATION -* lpmlLocation Pointer alla struttura che verra' -* riempita con i dati sulla locazione -* -* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore -* -\****************************************************************************/ - +/** + * Parses a location from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled location. + * @param lpmiLocation Pointer to a structure that will be filled with the + * data of the location. + * @returns Pointer to the buffer after the location, or NULL on failure. + */ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; @@ -480,39 +445,27 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) return lpBuf; } -/*static int CompareMoments(int * a, int * b) { - if (*a<*b) - return -1; - else if (*a>*b) - return 1; - else - return 0; -}*/ - -/****************************************************************************\ -* Funzioni globali -\****************************************************************************/ /****************************************************************************\ -* -* Function: bool ParseMpc(byte *lpBuf); -* -* Description: Legge e interpreta un file MPC, e crea le strutture per le -* varie direttive nelle variabili globali -* -* Input: byte *lpBuf Immagine in memoria del file MPC, -* escluso l'header -* -* Return: true se tutto OK, false in caso di errore. -* +* Exported functions \****************************************************************************/ +/** + * @defgroup Exported functions + */ +/** + * Reads and interprets the MPC file, and create structures for various directives + * in the global variables + * + * @param lpBuf Buffer containing the MPC file data, excluding the header. + * @returns True if succeeded OK, false if failure. + */ bool ParseMpc(const byte *lpBuf) { uint16 i, j; uint16 wLen; byte *lpTemp, *lpTemp2; - /* 1. Variabili */ + /* 1. Variables */ if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') return false; @@ -540,7 +493,7 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hVars); - /* 2. Messaggi */ + /* 2. Messages */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; @@ -588,7 +541,7 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hMsgs); #endif - /* 3. Oggetti */ + /* 3. Objects */ if (lpBuf[0] != 'O' || lpBuf[1] != 'B' || lpBuf[2] != 'J' || lpBuf[3] != 'S') return false; @@ -596,7 +549,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nObjs = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Controlla i dialoghi + // Check out the dialogs GLOBALS.nDialogs = 0; GLOBALS.hDialogs = GLOBALS.lpmdDialogs = NULL; if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { @@ -615,13 +568,13 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hDialogs); } - // Controlla gli item + // Check the items GLOBALS.nItems = 0; GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Alloca la memoria e li legge + // Allocate memory and read them in GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; @@ -635,13 +588,13 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hItems); } - // Controlla le locazioni + // Check the locations GLOBALS.nLocations = 0; GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Alloca la memoria e li legge + // Allocate memory and read them in GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); if (GLOBALS.hLocations == NULL) return false; @@ -655,13 +608,13 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hLocations); } - // Controlla gli script + // Check the scripts GLOBALS.nScripts = 0; GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Alloca la memoria + // Allocate memory GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); if (GLOBALS.hScripts == NULL) return false; @@ -672,7 +625,7 @@ bool ParseMpc(const byte *lpBuf) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) return false; - // Ordina i vari moments dello script + // Sort the various moments of the script //qsort( //GLOBALS.lpmsScripts[i].Moment, //GLOBALS.lpmsScripts[i].nMoments, diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 8763fbf95b..6aea3de16b 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -58,20 +58,13 @@ namespace MPAL { * Prototipi di funzione \****************************************************************************/ -/****************************************************************************\ -* -* Function: BOOL ParseMpc(LPBYTE lpBuf); -* -* Description: Legge e interpreta un file MPC, e crea le strutture per le -* varie direttive nelle variabili globali -* -* Input: LPBYTE lpBuf Immagine in memoria del file MPC, -* escluso l'header -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ - +/** + * Reads and interprets the MPC file, and create structures for various directives + * in the global variables + * + * @param lpBuf Buffer containing the MPC file data, excluding the header. + * @returns True if succeeded OK, false if failure. + */ bool ParseMpc(const byte *lpBuf); -- cgit v1.2.3 From bd064fe044beb4c38b48a1c111d922fdfcf73516 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 13:18:47 +1000 Subject: TONY: Endian fix in expression parser --- engines/tony/mpal/expr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 5e09e5dec6..7643c8bde3 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -301,7 +301,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { lpBuf += 2; switch (cur->type) { case ELT_NUMBER: - cur->val.num = *(int *)lpBuf; + cur->val.num = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; -- cgit v1.2.3 From 8457c1c7682e3c0d0c382c01b042158ec506e300 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 16:57:17 +1000 Subject: TONY: Removed deprecated MPAL stubs file --- engines/tony/font.cpp | 1 - engines/tony/game.cpp | 1 - engines/tony/loc.h | 1 - engines/tony/module.mk | 3 +- engines/tony/mpal/expr.cpp | 7 ++--- engines/tony/mpal/memory.cpp | 9 ++++++ engines/tony/mpal/memory.h | 3 ++ engines/tony/mpal/mpal.cpp | 1 - engines/tony/mpal/mpaldll.h | 1 - engines/tony/mpal/mpalutils.h | 3 +- engines/tony/mpal/stubs.cpp | 49 -------------------------------- engines/tony/mpal/stubs.h | 66 ------------------------------------------- engines/tony/tonychar.h | 1 - 13 files changed, 17 insertions(+), 129 deletions(-) delete mode 100644 engines/tony/mpal/stubs.cpp delete mode 100644 engines/tony/mpal/stubs.h (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 5396b73796..8fc011bb35 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -28,7 +28,6 @@ #include "common/textconsole.h" #include "tony/mpal/mpalutils.h" -#include "tony/mpal/stubs.h" #include "tony/font.h" #include "tony/input.h" #include "tony/inventory.h" diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 64c91008a5..3551f55c83 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -33,7 +33,6 @@ #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" #include "tony/mpal/mpalutils.h" -#include "tony/mpal/stubs.h" #include "tony/custom.h" #include "tony/game.h" #include "tony/gfxengine.h" diff --git a/engines/tony/loc.h b/engines/tony/loc.h index aee4936490..e25bdb500c 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -32,7 +32,6 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/file.h" -#include "tony/mpal/stubs.h" #include "tony/sound.h" #include "tony/utils.h" diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 6512391d04..719a598ee4 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -21,8 +21,7 @@ MODULE_OBJS := \ mpal/memory.o \ mpal/mpal.o \ mpal/mpalutils.o \ - mpal/lzo.o \ - mpal/stubs.o + mpal/lzo.o # This module can be built as a plugin ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 7643c8bde3..cf688341be 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -47,10 +47,9 @@ * * **************************************************************************/ -#include "mpal.h" -#include "memory.h" -#include "mpaldll.h" -#include "stubs.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/memory.h" +#include "tony/mpal/mpaldll.h" #include "tony/tony.h" /* diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 166e3598f8..4410e8016c 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -146,6 +146,15 @@ void MemoryManager::erase(HGLOBAL handle) { erase(&item); } +/****************************************************************************\ +* Stand-alone methods +\****************************************************************************/ + +void CopyMemory(void *dst, const void *first, int size) { + Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); +} + + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 6fd55e7ce5..8d8411c6a1 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -79,6 +79,9 @@ public: #define GMEM_MOVEABLE 2 #define GMEM_ZEROINIT 4 +// Stand-alone methods +extern void CopyMemory(void *dst, const void *first, int size); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 854372cdda..6ec92e74c1 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -55,7 +55,6 @@ #include "tony/mpal/lzo.h" #include "tony/mpal/mpal.h" #include "tony/mpal/mpaldll.h" -#include "tony/mpal/stubs.h" namespace Tony { diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index a7b6dfc5aa..69e58720a4 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -52,7 +52,6 @@ #include "common/file.h" #include "tony/mpal/memory.h" -#include "tony/mpal/stubs.h" #include "tony/mpal/loadmpc.h" #include "tony/mpal/expr.h" diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index cb8d4ec97d..a9f8403fcd 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -25,8 +25,7 @@ #define TONY_MPAL_MPALUTILS #include "common/scummsys.h" -#include "memory.h" -#include "stubs.h" +#include "tony/mpal/memory.h" namespace Tony { diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp deleted file mode 100644 index 89740fdd52..0000000000 --- a/engines/tony/mpal/stubs.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 contains stubs and mappings for things used by the MPAL -* library that are handled differently under ScummVM -\****************************************************************************/ - -#include "common/algorithm.h" -#include "common/system.h" -#include "engines/engine.h" -#include "tony/tony.h" -#include "stubs.h" - -namespace Tony { - -namespace MPAL { - -uint16 GetAsyncKeyState(Common::KeyCode kc) { - return 0; -} - -void CopyMemory(void *dst, const void *first, int size) { - Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); -} - -} // end of namespace MPAL - -} // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h deleted file mode 100644 index 66f83997ae..0000000000 --- a/engines/tony/mpal/stubs.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 contains stubs and mappings for things used by the MPAL -* library that are handled differently under ScummVM -\****************************************************************************/ - -#ifndef MPAL_STUBS -#define MPAL_STUBS - -#include "common/scummsys.h" -#include "common/algorithm.h" -#include "common/keyboard.h" -#include "tony/mpal/memory.h" - -namespace Tony { - -namespace MPAL { - -/****************************************************************************\ -* Types -\****************************************************************************/ - -typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); -typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); - -/****************************************************************************\ -* Defines -\****************************************************************************/ - -#define MB_OK 1 - -/****************************************************************************\ -* Methods -\****************************************************************************/ - -extern void CopyMemory(void *dst, const void *first, int size); - -extern uint16 GetAsyncKeyState(Common::KeyCode kc); - -} // end of namespace MPAL - -} // end of namespace Tony - -#endif diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 9cea3a4b2d..201803dc5f 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -30,7 +30,6 @@ #define TONY_TONYCHAR_H #include "common/coroutines.h" -#include "tony/mpal/stubs.h" #include "tony/loc.h" namespace Tony { -- cgit v1.2.3 From 827454a87ee73b079a96fbd4bd0df3b43224eb06 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sat, 19 May 2012 11:05:57 +0200 Subject: TONY: Change "it's" to "its" in comments where appropriate. (I think.) --- engines/tony/font.cpp | 2 +- engines/tony/gfxcore.h | 2 +- engines/tony/mpal/loadmpc.cpp | 8 ++++---- engines/tony/mpal/memory.cpp | 4 ++-- engines/tony/mpal/mpal.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8fc011bb35..db51dc3b79 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2277,7 +2277,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & itemName = ""; - // If there an item, get it's name + // If there an item, get its name if (m_item != NULL) m_item->GetName(itemName); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 3fa29e20f6..1af13d9a66 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -536,7 +536,7 @@ public: /** - * Destination buffer which manages it's own internal list of tasks + * Destination buffer which manages its own internal list of tasks */ class RMGfxTargetBuffer : public virtual RMGfxBuffer { private: diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6a1213bc19..6329a2090a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -77,7 +77,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { /** - * Parses a script from the MPC file, and inserts it's data into a structure + * Parses a script from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled script. * @param lpmsScript Pointer to a structure that will be filled with the @@ -138,7 +138,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { /** - * Parses a dialog from the MPC file, and inserts it's data into a structure + * Parses a dialog from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled dialog. * @param lpmdDialog Pointer to a structure that will be filled with the @@ -303,7 +303,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /** - * Parses an item from the MPC file, and inserts it's data into a structure + * Parses an item from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled dialog. * @param lpmiItem Pointer to a structure that will be filled with the @@ -425,7 +425,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { /** - * Parses a location from the MPC file, and inserts it's data into a structure + * Parses a location from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled location. * @param lpmiLocation Pointer to a structure that will be filled with the diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 4410e8016c..04cb906431 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -91,7 +91,7 @@ MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { } /** - * Allocates a new memory block and returns it's data pointer + * Allocates a new memory block and returns its data pointer * @returns Data pointer to allocated block */ HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { @@ -123,7 +123,7 @@ MemoryItem &MemoryManager::operator[](HGLOBAL handle) { } /** - * Returns a size of a memory block given it's pointer + * Returns a size of a memory block given its pointer */ uint32 MemoryManager::getSize(HGLOBAL handle) { MemoryItem &item = getItem(handle); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 6ec92e74c1..aea441138b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1312,7 +1312,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * @param dwParam Any parameter for the action. * @returns Id of the process that was launched to perform the action, or * CORO_INVALID_PID_VALUE if the action was not defined, or the item was inactive. - * @remarks You can get the index of an item from it's number by using + * @remarks You can get the index of an item from its number by using * the itemGetOrderFromNum() function. The items list must first be locked * by calling LockItem(). */ -- cgit v1.2.3 From a4a02e15b594e768b73a781823c38234f9f9cf7d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 19:43:30 +1000 Subject: TONY: Converting Italian comments to English --- engines/tony/mpal/mpal.cpp | 212 +++++++++++++++++----------------------- engines/tony/mpal/mpaldll.h | 232 ++++++++++++++++++-------------------------- 2 files changed, 188 insertions(+), 256 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index aea441138b..358b4e3505 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -370,10 +370,10 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { for (j = 0; dialog->Periods[j] != NULL; j++) if (dialog->PeriodNums[j] == nPeriod) { - /* Trovata la frase, va duplicata */ + /* Found the phrase, it should be duplicated */ origmsg = (const char *)GlobalLock(dialog->Periods[j]); - /* Calcola la lunghezza e alloca la memoria */ + /* Calculate the length and allocate memory */ i = 0; while (origmsg[i] != '\0') i++; @@ -448,13 +448,13 @@ static uint32 *GetSelectList(uint32 i) { int j,k,num; LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; - /* Conta quanti select attivi ci sono */ + /* Count how many are active selects */ num = 0; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) num++; - /* Se sono 0, e' un errore */ + /* If there are 0, it's a mistake */ if (num == 0) return NULL; @@ -462,7 +462,7 @@ static uint32 *GetSelectList(uint32 i) { if (sl == NULL) return NULL; - /* Copia il dato di ogni select attivo dentro la lista */ + /* Copy all the data inside the active select list */ k = 0; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) @@ -509,7 +509,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { char *patlength; uint32 dim; - // Lo zeroinit e' obbligatorio!!!! + // Zeroing out the allocated memory is required!!! ret = (LPITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); if (ret == NULL) return NULL; @@ -519,16 +519,16 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat = (char *)GlobalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { - i = dat[3]; // Versione!! Per ora 1.0 + i = dat[3]; // For version 1.0!! dat += 4; - if (i >= 0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto + if (i >= 0x10) { // From 1.0, there's a destination point for each object ret->destX = (int16)READ_LE_UINT16(dat); ret->destY = (int16)READ_LE_UINT16(dat + 2); dat+=4; } - if (i >= 0x11) {// Dalla 1.1 c'e' la velocita' di animazione + if (i >= 0x11) { // From 1.1, there's animation speed ret->speed = READ_LE_UINT16(dat); dat += 2; } else @@ -539,21 +539,21 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->numpattern=*dat++; ret->Zvalue=*dat++; - // Carica le coordinate left&top di ogni frame + // Upload the left & top co-ordinates of each frame for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].left = (int16)READ_LE_UINT16(dat); ret->frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); dat += 4; } - // Carica le dimensioni di ogni frame e calcola right&bottom + // Upload the size of each frame and calculate the right & bottom for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; dat+=4; } - // Carica i bounding box di ogni frame + // Upload the bounding boxes of each frame for (i = 0; i < ret->numframe; i++) { ret->bbox[i].left = (int16)READ_LE_UINT16(dat); ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); @@ -562,7 +562,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat+=8; } - // Carica i pattern di animazione + // Load the animation pattern patlength = dat; dat+=ret->numpattern; @@ -573,7 +573,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat += patlength[i]; } - // Carica i singoli frame di animazione + // Upload the individual frames of animations for (i = 1; i < ret->numframe; i++) { dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); @@ -585,7 +585,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat += dim; } - // Controlla se siamo arrivati fino alla fine del file + // Check if we've got to the end of the file i = READ_LE_UINT16(dat); if (i != 0xABCD) return NULL; @@ -678,7 +678,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->arg3=s->Command[_ctx->k].arg3; _ctx->p->arg4=s->Command[_ctx->k].arg4; - // !!! Nuova gestione dei thread + // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { GLOBALS.mpalError = 1; @@ -845,16 +845,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - /* Tanto per cominciare, e' necessario richiedere la lista degli item - presenti nella locazione. */ + /* To begin with, we need to request the item list from the location */ _ctx->il = mpalQueryItemList(GLOBALS.nPollingLocations[id]); - /* Contiamo gli items */ + /* Count the items */ for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) ; - /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo - dalla lista */ + /* We look for items without idle actions, and eliminate them from the list */ LockItems(); _ctx->nIdleActions = 0; _ctx->nRealItems = 0; @@ -873,7 +871,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->nIdleActions += _ctx->k; if (_ctx->k == 0) - /* Possiamo eliminare questo item dalla lista */ + /* We can remove this item from the list */ _ctx->il[_ctx->i] = (uint32)NULL; else _ctx->nRealItems++; @@ -894,13 +892,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - /* Inizializziamo le routine random */ - //curTime = _vm->GetTime(); - //srand(curTime); - - /* Abbiamo appurato che esiste almeno un item che contiene idle actions. - Ora creaiamo le copie speculari delle idle actions */ + /* We have established that there is at least one item that contains idle actions. + Now we created the mirrored copies of the idle actions. */ _ctx->MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { GlobalFree(_ctx->MyThreads); @@ -937,11 +931,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { UnlockItems(); - /* La item list non ci serve piu' */ + /* We don't need the item list anymore */ GlobalFree(_ctx->il); - /* Eccoci al ciclo principale. */ + /* Here's the main loop */ while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ @@ -955,9 +949,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } else _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); - /* Ci addormentiamo, ma controllando sempre l'evento che viene settato - quando viene richiesta la nostra chiusura */ - + /* We fall alseep, but always checking that the event is set when prompted for closure */ CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) @@ -968,28 +960,26 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); - // if result ) == WAIT_OBJECT_0) + // if result == WAIT_OBJECT_0) if (!_ctx->delayExpired) _ctx->MyThreads[_ctx->i].nItem = 0; } _ctx->curTime = _vm->GetTime(); - /* Cerchiamo all'interno delle idle actions quale e' necessario eseguire */ + /* Loop through all the necessary idle actions */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; - /* E' _ctx->il momento di tirare _ctx->il nostro dado virtuale, e controllare - se la sorte e' dalla parte della idle action */ + /* It's time to check to see if fortune is on the side of the idle action */ byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { - /* Controlliamo se c'e' una action in esecuzione sull'item */ + /* Check if there is an action running on the item */ if ((GLOBALS.bExecutingAction) && (GLOBALS.nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; - /* Controlliamo se c'e' gia' un'altra idle function in esecuzione - sullo stesso item */ + /* Check to see if there already another idle funning running on the item */ for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; @@ -997,11 +987,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->i < _ctx->nRealItems) continue; - /* Ok, siamo gli unici :) */ + /* Ok, we are the only ones :) */ LockItems(); _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); - /* Controlliamo se c'e' un esperessione WhenExecute */ + /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; if (_ctx->curItem->Action[_ctx->j].when != NULL) if (!EvaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { @@ -1009,8 +999,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { continue; } - /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in - un nuovo thread */ + /* Ok, we can perform the action. For convenience, we do it in a new process */ _ctx->newItem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { GlobalFree(_ctx->MyThreads); @@ -1023,21 +1012,20 @@ void LocationPollThread(CORO_PARAM, const void *param) { CopyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); UnlockItems(); - /* Copiamo l'azione nella #0 */ + /* We copy the action in #0 */ // _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; // CopyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; - /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria - allocata per _ctx->il nuovo item */ + /* We will create an action, and will provide the necessary details */ for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem == 0) break; _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; - // !!! Nuova gestione dei thread - if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + // Create the process + if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); @@ -1047,23 +1035,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - /* Skippa tutte le idle action dello stesso item */ + /* Skip all idle actions of the same item */ } } } - /* Chiude tutti _ctx->i thread interni */ - - /* - - CODICE OBSOLETO: ANDIAMO DI SKIP CHE RULLA - - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); - CloseHandle(_ctx->MyThreads[_ctx->i].hThread); - } -*/ // Set idle skip on CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); @@ -1083,7 +1059,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip off CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); - /* Abbiamo finito */ + /* We're finished */ GlobalFree(_ctx->MyThreads); GlobalFree(_ctx->MyActions); @@ -1218,20 +1194,20 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CODE(_ctx); - /* Locka _ctx->i dialoghi */ + /* Lock the dialogs */ LockDialogs(); - /* Trova il puntatore al dialogo corrente */ - _ctx->dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + /* Get a pointer to the current dialog */ + _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; - /* Cerca la scelta richiesta tra quelle nel dialogo */ + /* Search the choice between those required in the dialog */ for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) if (_ctx->dialog->Choice[_ctx->i].nChoice == nChoice) break; - /* Se non l'ha trovata, esce con errore */ + /* If nothing has been found, exit with an error */ if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { - /* Se siamo qui, non abbiamo trovato la choice richiesta */ + /* If we're here, we did not find the required choice */ GLOBALS.mpalError = 1; UnlockDialogs(); @@ -1239,16 +1215,14 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { return; } - /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella - variabile globale */ + /* We've found the requested choice. Remember what in global variables */ GLOBALS.nExecutingChoice = _ctx->i; while (1) { GLOBALS.nExecutingChoice = _ctx->i; _ctx->k = 0; - /* Calcoliamo le when expression di ciascun select, per vedere se sono - attivi o disattivi */ + /* Calculate the expression of each selection, to see if they're active or inactive */ for (_ctx->j = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].dwData != 0; _ctx->j++) if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when == NULL) { _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; @@ -1259,42 +1233,41 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { } else _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 0; - /* Se non ci sono scelte attivate, la scelta e' finita */ + /* If there are no choices activated, then the dialog is finished. */ if (_ctx->k == 0) { UnlockDialogs(); break; } - /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, - e restiamo in attesa della risposta */ + /* There are choices available to the user, so wait for them to make one */ CoroScheduler.resetEvent(GLOBALS.hDoneChoice); CoroScheduler.setEvent(GLOBALS.hAskChoice); CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hDoneChoice, CORO_INFINITE); - /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi - associati con la scelta */ + /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq + */ _ctx->j = GLOBALS.nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } - /* Controllo sugli attributi */ + /* Control attribute */ if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 0)) { - /* Bit 0 settato: fine della scelta */ + /* Bit 0 set: the end of the choice */ UnlockDialogs(); break; } if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 1)) { - /* Bit 1 settato: fine del dialogo */ + /* Bit 1 set: the end of the dialog */ UnlockDialogs(); CORO_KILL_SELF(); return; } - /* Fine della scelta senza attributi: bisogna rifarla */ + /* End of choic ewithout attributes. We must do it again */ } // If we're here, we found an end choice. Return to the caller group @@ -1339,23 +1312,23 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { continue; } - // Ora abbiamo trova l'azione giusta che deve essere eseguita. - // Duplichiamo l'item corrente e copiamo la azione #i nella #0 + // Now we find the right action to be performed + // Duplicate the item and copy the current action in #i into #0 newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; - // Nella nuova versione scriviamo il numero dell'azione in dwRes + // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ newitem->dwRes = i; - // E finalmente possiamo richiamare il thread, che eseguira' l'azione - // 0 dell'item, e poi liberera' la memoria con la GlobalFree() + // And finally we can laucnh the process that will execute the action, + // and a second process to free up the memory when the action is finished. - // !!! New thread management + // !!! New process management if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; @@ -1420,7 +1393,7 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool DoSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) @@ -1461,15 +1434,15 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, //printf("Script: %lu\n", sizeof(MPALSCRIPT)); //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); - /* Si salva l'array delle funzioni custom */ + /* Save the array of custom functions */ GLOBALS.lplpFunctions = lplpcfArray; GLOBALS.lplpFunctionStrings = lpcfStrings; - /* Apre il file MPC in lettura */ + /* OPen the MPC file for reading */ if (!hMpc.open(lpszMpcFileName)) return false; - /* Legge e controlla l'header */ + /* Read and check the header */ nBytesRead = hMpc.read(buf, 5); if (nBytesRead != 5) return false; @@ -1479,7 +1452,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, bCompress = buf[4]; - /* Legge la dimensione del file decompresso, e alloca la memoria */ + /* Reads the size of the uncompressed file, and allocate memory */ dwSizeDecomp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1489,8 +1462,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return false; if (bCompress) { - /* Se il file e' compresso, guarda quanto e' grande e alloca la - memoria temporanea per la decompressione */ + /* Get the compressed size and read the data in */ dwSizeComp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1503,30 +1475,29 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeComp) return false; - /* Decomprime l'immagine */ + /* Decompress the data */ lzo1x_decompress(cmpbuf, dwSizeComp, lpMpcImage, &nBytesRead); if (nBytesRead != dwSizeDecomp) return false; GlobalFree(cmpbuf); } else { - /* Se il file non e' compresso, lo legge all'interno della memoria gia' - allocata */ + /* If the file is not compressed, we directly read in the data */ nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); if (nBytesRead != dwSizeDecomp) return false; } - /* Chiude il file */ + /* Close the file */ hMpc.close(); - /* Parsa l'immagine */ + /* Process the data */ if (ParseMpc(lpMpcImage) == false) return false; GlobalFree(lpMpcImage); - /* Calcola utilizzo di memoria */ + /* Calculate memory usage */ /* { char errbuf[256]; @@ -1541,11 +1512,11 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, } */ - /* Apre il file MPR in lettura */ + /* Open the MPR file */ if (!GLOBALS.hMpr.open(lpszMprFileName)) return false; - /* Si posiziona a 8 byte dalla fine del file */ + /* Seek to the end of the file to read overall information */ GLOBALS.hMpr.seek(-12, SEEK_END); dwSizeComp = GLOBALS.hMpr.readUint32LE(); @@ -1563,7 +1534,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; - /* Si posiziona all'inizio dell'header delle risorse */ + /* Move to the start of the resources header */ GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); GLOBALS.lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); @@ -1584,18 +1555,17 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, GlobalFree(cmpbuf); - /* Si riposiziona all'inizio lasciando il file di risorse aperto */ + /* Reset back to the start of the file, leaving it open */ GLOBALS.hMpr.seek(0, SEEK_SET); - /* Non c'e' nessuna azione ne' dialogo in esecuzione */ + /* There is no action or dialog running by default */ GLOBALS.bExecutingAction = false; GLOBALS.bExecutingDialog = false; - /* Non c'e' nessuna locazione in polling */ + /* There's no polling location */ Common::fill(GLOBALS.nPollingLocations, GLOBALS.nPollingLocations + MAXPOLLINGLOCATIONS, 0); - /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' - da effettuare una scelta */ + /* Create the event that will be used to co-ordinate making choices and choices finishing */ GLOBALS.hAskChoice = CoroScheduler.createEvent(true, false); GLOBALS.hDoneChoice = CoroScheduler.createEvent(true, false); @@ -2030,7 +2000,7 @@ bool mpalExecuteScript(int nScript) { CopyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); UnlockScripts(); - // !!! Nuova gestione dei thread + // !!! New process management if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) return false; @@ -2070,7 +2040,7 @@ bool mpalStartIdlePoll(int nLoc) { GLOBALS.nPollingLocations[i] = nLoc; GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); -// !!! Nuova gestione dei thread +// !!! New process management if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) // if ((GLOBALS.hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2150,7 +2120,7 @@ void mpalSaveState(byte *buf) { * @returns Length of the state buffer in bytes */ int mpalLoadState(byte *buf) { - // Dobbiamo distruggere tutte le variabili e ricrearle + // We must destroy and recreate all the variables GlobalFree(GLOBALS.hVars); GLOBALS.nVars = READ_LE_UINT32(buf); @@ -2325,20 +2295,20 @@ void mpalDumpMessages(void) { OutputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); while (1) { - // Trova la fine del periodo corrente + // Find the end of the current period while (*p != '\0') p++; - // Se c'e' un altro '\0' siamo alla fine del messaggio + // If there is another '\0' at the end of the message, then finish p++; if (*p == '\0') break; - // Altrimenti c'e' un altro periodo, e ci ricordiamo il suo inizio + // Otherwise there is another line, so remember the next one's start lpPeriods[nPeriods++] = p; } - // Ora fa un ciclo su tutti i periodi + // Now make a loop over all the periods for (j = 0;jGroup[g].nCmds; c++) { curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; - // Se una funzione custom, e richiama la SendDialogMessage(nPers, nMsg) + // If it's a custom function, call SendDialogMessage(nPers, nMsg) if (curCmd->type == 1 && curCmd->nCf == 71) { sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 69e58720a4..dc42b597bc 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -66,7 +66,7 @@ namespace MPAL { #define HEX_VERSION 0x0170 /* - SICURA + Safe #define MAX_ACTIONS_PER_ITEM 40 #define MAX_COMMANDS_PER_ITEM 256 @@ -90,7 +90,7 @@ namespace MPAL { /* - Versione sicura! + Secure version! #define MAX_GROUPS_PER_DIALOG 128 #define MAX_COMMANDS_PER_DIALOG 640 @@ -111,7 +111,7 @@ namespace MPAL { #define MAX_PERIODS_PER_DIALOG 400 /* - Prima di Rufus: + Before Rufus: #define MAX_GROUPS_PER_DIALOG 128 #define MAX_COMMANDS_PER_DIALOG 512 @@ -131,90 +131,75 @@ namespace MPAL { #include "common/pack-start.h" -/****************************************************************************\ -* typedef MPALVAR -* --------------- -* Description: Variabile globale di MPAL -\****************************************************************************/ - +/** + * MPAL global variables + */ struct MPALVAR { - uint32 dwVal; // Valore della variabile - char lpszVarName[33]; // Nome della variabile + uint32 dwVal; // Variable value + char lpszVarName[33]; // Variable name } PACKED_STRUCT; -typedef MPALVAR* LPMPALVAR; -typedef LPMPALVAR* LPLPMPALVAR; - +typedef MPALVAR *LPMPALVAR; +typedef LPMPALVAR *LPLPMPALVAR; -/****************************************************************************\ -* typedef MPALMSG -* --------------- -* Description: Messaggio di MPAL -\****************************************************************************/ +/** + * MPAL Messages + */ struct MPALMSG { - HGLOBAL hText; // Handle al testo del messaggio - uint16 wNum; // Numero del messaggio + HGLOBAL hText; // Handle to the message text + uint16 wNum; // Message number } PACKED_STRUCT; -typedef MPALMSG* LPMPALMSG; -typedef LPMPALMSG* LPLPMPALMSG; +typedef MPALMSG *LPMPALMSG; +typedef LPMPALMSG *LPLPMPALMSG; -/****************************************************************************\ -* typedef MPALLOCATION -* -------------------- -* Description: Locazione di MPAL -\****************************************************************************/ - +/** + * MPAL Locations + */ struct MPALLOCATION { - uint32 nObj; // Numero della locazione - uint32 dwXlen, dwYlen; // Dimensione - uint32 dwPicRes; // Risorsa che contiene l'immagine + uint32 nObj; // Location number + uint32 dwXlen, dwYlen; // Dimensions + uint32 dwPicRes; // Resource that contains the image } PACKED_STRUCT; -typedef MPALLOCATION* LPMPALLOCATION; -typedef LPMPALLOCATION* LPLPMPALLOCATION; - +typedef MPALLOCATION *LPMPALLOCATION; +typedef LPMPALLOCATION *LPLPMPALLOCATION; -/****************************************************************************\ -* struct command -* -------------- -* Description: Gestisce un comando, cioe' le tag utilizzate dalle OnAction -* negli item, dalle Time negli script e dai Group nei Dialog -\****************************************************************************/ +/** + * All the data for a command, ie. tags used by OnAction in the item, the time + * in the script, and in the group dialog. + */ struct command { /* - * Tipi di comandi riconosciuti: + * Types of commands that are recognised * - * #1 -> Chiamata a funzione custom (ITEM, SCRIPT, DIALOG) - * #2 -> Assegnazione di variabile (ITEM, SCRIPT, DIALOG) - * #3 -> Esecuzione di una scelta (DIALOG) + * #1 -> Custom function call (ITEM, SCRIPT, DIALOG) + * #2 -> Variable assignment (ITEM, SCRIPT, DIALOG) + * #3 -> Making a choice (DIALOG) * */ - byte type; // Tipo di comando + byte type; // Type of control union { - int32 nCf; // Numero funzione custom [#1] - char *lpszVarName; // Nome variabile [#2] - int32 nChoice; // Numero di scelta da fare [#3] + int32 nCf; // Custom function call [#1] + char *lpszVarName; // Variable name [#2] + int32 nChoice; // Number of choice you make [#3] }; union { - int32 arg1; // Argomento 1 funzione custom [#1] - HGLOBAL expr; // Espressione da assegnare alla - // variabile [#2] + int32 arg1; // Argument for custom function [#1] + HGLOBAL expr; // Expression to assign to a variable [#2] }; - int32 arg2,arg3,arg4; // Argomenti per funzione custom [#1] + int32 arg2, arg3, arg4; // Arguments for custom function [#1] } PACKED_STRUCT; -/****************************************************************************\ -* typedef MPALDIALOG -* ------------------ -* Description: Dialog di MPAL -\****************************************************************************/ +/** + * MPAL dialog + */ struct MPALDIALOG { - uint32 nObj; // Numero dialog + uint32 nObj; // Dialog number struct command Command[MAX_COMMANDS_PER_DIALOG]; @@ -227,11 +212,10 @@ struct MPALDIALOG { } Group[MAX_GROUPS_PER_DIALOG]; struct { - // L'ultima choice ha nChoice==0 + // The last choice has nChoice == 0 uint16 nChoice; - // Non c'e' il numero di Select (siamo abbastanza avari di RAM). L'ultimo - // select ha dwData==0 + // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { HGLOBAL when; uint32 dwData; @@ -240,8 +224,8 @@ struct MPALDIALOG { // Bit 0=endchoice Bit 1=enddialog byte attr; - // Modificata a run-time: 0 se il select e' correntemente disabilitato, - // 1 se e' correntemente attivato + // Modified at run-time: 0 if the select is currently disabled, + // and 1 if currently active byte curActive; } Select[MAX_SELECTS_PER_CHOICE]; @@ -251,50 +235,48 @@ struct MPALDIALOG { HGLOBAL Periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; -typedef MPALDIALOG* LPMPALDIALOG; -typedef LPMPALDIALOG* LPLPMPALDIALOG; +typedef MPALDIALOG *LPMPALDIALOG; +typedef LPMPALDIALOG *LPLPMPALDIALOG; -/****************************************************************************\ -* typedef MPALITEM -* ---------------- -* Description: Item di MPAL -\****************************************************************************/ +/** + * MPAL Item + */ struct ItemAction { - byte num; // Numero dell'azione - uint16 wTime; // In caso di idle, il tempo che deve passare - byte perc; // Percentuale di eseguire l'idle - HGLOBAL when; // Espressione da calcolare: se !=0, allora - // l'azione puo' essere eseguita - uint16 wParm; // Parametro per l'azione - - byte nCmds; // Numero comandi da eseguire - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire + byte num; // Action number + uint16 wTime; // If idle, the time which must pass + byte perc; // Percentage of the idle run + HGLOBAL when; // Expression to compute. If != 0, then + // action can be done + uint16 wParm; // Parameter for action + + byte nCmds; // Number of commands to be executed + uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; struct MPALITEM { - uint32 nObj; // Numero item + uint32 nObj; // Item number - byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Nome - byte nActions; // Numero delle azioni gestite - uint32 dwRes; // Risorsa che contiene frame e pattern + byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Name + byte nActions; // Number of managed actions + uint32 dwRes; // Resource that contains frames and patterns struct command Command[MAX_COMMANDS_PER_ITEM]; - // Array di strutture contenenti le varie azioni gestite. In pratica, di - // ogni azione sappiamo quali comandi eseguire, tra quelli definiti nella - // struttura qui sopra + // Array of structures containing various managed activities. In practice, of + // every action we know what commands to run, including those defined in + // structures above /* struct { - byte num; // Numero dell'azione - uint16 wTime; // In caso di idle, il tempo che deve passare - byte perc; // Percentuale di eseguire l'idle - HGLOBAL when; // Espressione da calcolare: se !=0, allora - // l'azione puo' essere eseguita - uint16 wParm; // Parametro per l'azione - - byte nCmds; // Numero comandi da eseguire + byte num; // Numero dell'azione + uint16 wTime; // In caso di idle, il tempo che deve passare + byte perc; // Percentuale di eseguire l'idle + HGLOBAL when; // Espressione da calcolare: se !=0, allora + // l'azione puo' essere eseguita + uint16 wParm; // Parametro per l'azione + + byte nCmds; // Numero comandi da eseguire uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire } Action[MAX_ACTIONS_PER_ITEM]; @@ -306,12 +288,9 @@ typedef MPALITEM* LPMPALITEM; typedef LPMPALITEM* LPLPMPALITEM; -/****************************************************************************\ -* typedef MPALSCRIPT -* ------------------ -* Description: Script di MPAL -\****************************************************************************/ - +/** + * MPAL Script + */ struct MPALSCRIPT { uint32 nObj; @@ -335,44 +314,27 @@ typedef LPMPALSCRIPT* LPLPMPALSCRIPT; /****************************************************************************\ -* Prototipi di funzione -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: int32 varGetValue(const char *lpszVarName); -* -* Description: Restituisce il valore corrente di una variabile globale -* -* Input: const char *lpszVarName Nome della variabile -* -* Return: Valore corrente -* -* Note: Prima di questa funzione, bisogna richiamare LockVar() che -* locka le variabili globali per l'utilizzo. Dopo inoltre bi- -* sogna ricordarsi di chiamare UnlockVar() -* +* Function prototypes \****************************************************************************/ -int32 varGetValue(const char *lpszVarName); - - -/****************************************************************************\ -* -* Function: void varSetValue(const char *lpszVarName, int32 val); -* -* Description: Setta un nuovo valore per una variabile globale di MPAL -* -* Input: const char *lpszVarName Nome della variabile -* int32 val Valore da settare -* -\****************************************************************************/ +/** + * Returns the current value of a global variable + * + * @param lpszVarName Name of the variable + * @returns Current value + * @remarks Before using this method, you must call LockVar() to + * lock the global variablves for use. Then afterwards, you will + * need to remember to call UnlockVar() + */ +extern int32 varGetValue(const char *lpszVarName); -void varSetValue(const char *lpszVarName, int32 val); -/****************************************************************************\ -* Includes the various modules -\****************************************************************************/ +/** + * Sets the value of a MPAL global variable + * @param lpszVarName Name of the variable + * @param val Value to set + */ +extern void varSetValue(const char *lpszVarName, int32 val); } // end of namespace MPAL -- cgit v1.2.3 From f3398ee0104622a7ab0598507894c9d74a7a30e2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 19:54:04 +1000 Subject: TONY: Formatting fixes --- engines/tony/mpal/mpal.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 358b4e3505..d74248911e 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -67,11 +67,11 @@ namespace MPAL { \****************************************************************************/ const char *mpalCopyright = - "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n" - "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n" - "ALL RIGHTS RESERVED\n" - "\n" - "\n"; + "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n" + "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n" + "ALL RIGHTS RESERVED\n" + "\n" + "\n"; /****************************************************************************\ * Internal functions @@ -344,7 +344,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { j++; j += 2; - clonemsg=(char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); + clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); if (clonemsg == NULL) return NULL; @@ -483,7 +483,7 @@ static uint32 *GetItemList(uint32 nLoc) { num++; } - il=(uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + il = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (il == NULL) return NULL; @@ -569,15 +569,15 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 1; i < ret->numpattern; i++) { for (j = 0; j < patlength[i]; j++) ret->pattern[i][j] = dat[j]; - ret->pattern[i][(int)patlength[i]] = 255; // Termina i pattern + ret->pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } // Upload the individual frames of animations for (i = 1; i < ret->numframe; i++) { - dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * + dim = (uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); - ret->frames[i]=(char *)GlobalAlloc(GMEM_FIXED,dim); + ret->frames[i] = (char *)GlobalAlloc(GMEM_FIXED,dim); if (ret->frames[i] == NULL) return NULL; @@ -664,7 +664,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; if (s->Command[_ctx->k].type == 1) { - _ctx->p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + _ctx->p = (LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS.mpalError = 1; @@ -1026,7 +1026,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) + //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); GlobalFree(_ctx->MyActions); @@ -1457,7 +1457,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); + byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeDecomp + 16); if (lpMpcImage == NULL) return false; @@ -1467,7 +1467,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); + cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeComp); if (cmpbuf == NULL) return false; @@ -1550,7 +1550,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return false; lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS.lpResources, (uint32 *)&nBytesRead); - if (nBytesRead != (uint32)GLOBALS.nResources*8) + if (nBytesRead != (uint32)GLOBALS.nResources * 8) return false; GlobalFree(cmpbuf); @@ -2042,7 +2042,7 @@ bool mpalStartIdlePoll(int nLoc) { GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! New process management if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) -// if ((GLOBALS.hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) +// if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240,(void *)i))= = (void*)-1) return false; return true; @@ -2130,7 +2130,7 @@ int mpalLoadState(byte *buf) { CopyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); UnlockVar(); - return GLOBALS.nVars*sizeof(MPALVAR)+4; + return GLOBALS.nVars * sizeof(MPALVAR) + 4; } bool bDontOutput; -- cgit v1.2.3 From c402426117e83fa833fdadcc6ad81f418d195c7e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 20:29:53 +1000 Subject: TONY: Converted some warning calls to debugC --- engines/tony/mpal/mpal.cpp | 12 ++++++------ engines/tony/tony.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d74248911e..5cb6546343 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -645,7 +645,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->dwStartTime = _vm->GetTime(); _ctx->numHandles = 0; -// warning("PlayScript(): Moments: %u\n",s->nMoments); +// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { // Dorme il tempo necessario per arrivare al momento successivo if (s->Moment[_ctx->i].dwTime == -1) { @@ -654,7 +654,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } else { _ctx->dwCurTime = _vm->GetTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { - // warning("PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); + // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); } } @@ -2199,7 +2199,7 @@ void OutputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { for (i = 0; MsgComments[i].wStart != 0; i++) if (MsgComments[i].wStart == wNum) { - warning("Start: %d\n", wNum); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "Start: %d\n", wNum); f->writeString("
\n

\n

\n"); @@ -2217,7 +2217,7 @@ void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { for (i = 0; MsgComments[i].wEnd != 0; i++) if (MsgComments[i].wEnd == wNum) { -warning("End: %d\n", wNum); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "End: %d\n", wNum); if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { f->writeString("\n

\n"); @@ -2276,7 +2276,7 @@ void mpalDumpMessages(void) { bDontOutput = false; - warning("Dumping MESSAGES.HTM...\n"); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping MESSAGES.HTM...\n"); f = g_system->getSavefileManager()->openForSaving("Messages.htm"); f->writeString("\n\n\n"); @@ -2369,7 +2369,7 @@ void mpalDumpOthers(void) { bDontOutput = false; - warning("Dumping OTHERS.HTM...\n"); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping OTHERS.HTM...\n"); f->writeString("\n\n"); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 18d4a37067..32332a871d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -58,7 +58,8 @@ enum { kTonyDebugAnimations = 1 << 0, kTonyDebugActions = 1 << 1, kTonyDebugSound = 1 << 2, - kTonyDebugMusic = 2 << 3 + kTonyDebugMusic = 1 << 3, + kTonyDebugMPAL = 1 << 4 }; #define DEBUG_BASIC 1 -- cgit v1.2.3 From e76a55588af1deb9a14bb8d89d4d818ea8120d96 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 09:23:12 +1000 Subject: TONY: Added assert for character indexes outside provided font --- engines/tony/font.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index db51dc3b79..b0e42407cf 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -120,6 +120,7 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { // Converte da carattere a lettera nLett = ConvertToLetter(bChar); + assert(nLett < nLetters); // Crea la primitiva per il font prim = new RMFontPrimitive(this); -- cgit v1.2.3 From 0136bf4a863073a9a47dc379e2eeb2fa74af2ec6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 09:57:24 +1000 Subject: TONY: Fix issues with font loading and display of accented characters --- engines/tony/font.cpp | 578 +++++++++++++++++++++++++------------------------- engines/tony/font.h | 8 +- 2 files changed, 291 insertions(+), 295 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index b0e42407cf..706aca8467 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1162,297 +1162,293 @@ void RMFontCredits::Init(void) { lTable[':'] = 5; lTable['\''] = 5; - - - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 22; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 22; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 23; - lTable[(byte)''] = 23; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 20; - lTable[(byte)''] = 15; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 20; - lTable[(byte)''] = 7; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 19; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[(byte)''] = 234; - // 'SS' = 235 - - // old chars overrides - cTable[(byte)''] = cTable[(byte)''] = 55; - cTable[(byte)''] = cTable[(byte)''] = 67; - cTable[(byte)''] = cTable[(byte)''] = 71; - - lTable[(byte)''] = 11; - -#endif // FONT_GERMAN + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 20; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 22; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 22; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 23; + lTable[(byte)''] = 23; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 20; + lTable[(byte)''] = 15; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // CZECH Language + + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 20; + lTable[(byte)''] = 7; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 19; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French + + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + // German + + cTable[(byte)''] = 234; + // 'SS' = 235 + + // old chars overrides + cTable[(byte)''] = cTable[(byte)''] = 55; + cTable[(byte)''] = cTable[(byte)''] = 67; + cTable[(byte)''] = cTable[(byte)''] = 71; + + lTable[(byte)''] = 11; + } } diff --git a/engines/tony/font.h b/engines/tony/font.h index 3ada4d76c0..dab07b79b3 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -77,10 +77,10 @@ protected: protected: // Conversione (da overloadare) - virtual int ConvertToLetter(int nChar) = 0; + virtual int ConvertToLetter(byte nChar) = 0; // Lunghezza dei caratteri (da overloadare) - virtual int LetterLength(int nChar, int nNext = 0) = 0; + virtual int LetterLength(byte nChar, byte nNext = 0) = 0; public: virtual int LetterHeight(void) = 0; @@ -126,10 +126,10 @@ protected: protected: // Overload dei metodi - int ConvertToLetter(int nChar) { + int ConvertToLetter(byte nChar) { return cTable[nChar]; } - int LetterLength(int nChar, int nNext = 0) { + int LetterLength(byte nChar, byte nNext = 0) { return (nChar != -1 ? lTable[nChar] + l2Table[nChar][nNext] : lDefault); } -- cgit v1.2.3 From 10b0451776249c4ffe27e319da4e8898a9ddb488 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 10:52:08 +1000 Subject: TONY: Converted #ifdefs for different language fonts setup It now uses the ScummVM language from the game's detection entry, so foreign language versions like French and German should now load correctly. --- engines/tony/font.cpp | 1482 ++++++++++++++++++++++++------------------------- 1 file changed, 736 insertions(+), 746 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 706aca8467..91d6708a20 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -341,292 +341,288 @@ void RMFontParla::Init(void) { lTable['E'] = 10; lTable['F'] = 11; + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 18; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 18; + lTable[(byte)''] = 19; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 9; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // Czech + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 19; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 7; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 18; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 18; - lTable[(byte)''] = 19; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 9; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 19; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 7; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 9; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[(byte)''] = 234; - // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; - - lTable[(byte)''] = 15; - -#endif // FONT_GERMAN + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 9; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + cTable[(byte)''] = 234; + // 'SS' = 235 + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; + + lTable[(byte)''] = 15; + } } @@ -709,292 +705,290 @@ void RMFontMacc::Init(void) { //cTable[(byte)''] = 100; // u col pallino cTable[(byte)''] = 101; - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - cTable[(byte)''] = 102; - cTable[(byte)''] = 103; - cTable[(byte)''] = 104; - cTable[(byte)''] = 105; - cTable[(byte)''] = 106; - cTable[(byte)''] = 107; - cTable[(byte)''] = 108; - cTable[(byte)''] = 109; - cTable[(byte)''] = 110; - cTable[(byte)''] = 111; - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 8; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[(byte)''] = 234; - // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; - - lTable[(byte)''] = 11; -#endif // FONT_GERMAN + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[(byte)''] = 102; + cTable[(byte)''] = 103; + cTable[(byte)''] = 104; + cTable[(byte)''] = 105; + cTable[(byte)''] = 106; + cTable[(byte)''] = 107; + cTable[(byte)''] = 108; + cTable[(byte)''] = 109; + cTable[(byte)''] = 110; + cTable[(byte)''] = 111; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 8; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // Czech + + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French + + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + // German + + cTable[(byte)''] = 234; + // 'SS' = 235 + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; + + lTable[(byte)''] = 11; + } } /***************************************************************************\ @@ -1608,182 +1602,178 @@ void RMFontObj::Init(void) { SetBothCase('R', 'R', 1); SetBothCase('R', 'U', 3); + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //ス謎戊3剔囀 + //AaCcEeLlNnOoSsZzZz + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; + + cTable[(byte)''] = cTable[(byte)''] = 86; + lTable[(byte)''] = lTable[(byte)''] = 22; + + cTable[(byte)''] = cTable[(byte)''] = 87; + lTable[(byte)''] = lTable[(byte)''] = 17; + + cTable[(byte)''] = cTable[(byte)''] = 88; + lTable[(byte)''] = lTable[(byte)''] = 19; + + cTable[(byte)''] = cTable[(byte)''] = 89; + lTable[(byte)''] = lTable[(byte)''] = 17; + + cTable[(byte)''] = cTable[(byte)''] = 90; + lTable[(byte)''] = lTable[(byte)''] = 22; - // Polish characters - //ス謎戊3剔囀 - //AaCcEeLlNnOoSsZzZz - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; - - cTable[(byte)''] = cTable[(byte)''] = 86; - lTable[(byte)''] = lTable[(byte)''] = 22; - - cTable[(byte)''] = cTable[(byte)''] = 87; - lTable[(byte)''] = lTable[(byte)''] = 17; - - cTable[(byte)''] = cTable[(byte)''] = 88; - lTable[(byte)''] = lTable[(byte)''] = 19; - - cTable[(byte)''] = cTable[(byte)''] = 89; - lTable[(byte)''] = lTable[(byte)''] = 17; - - cTable[(byte)''] = cTable[(byte)''] = 90; - lTable[(byte)''] = lTable[(byte)''] = 22; - - cTable[(byte)''] = cTable[(byte)''] = 91; - lTable[(byte)''] = lTable[(byte)''] = 15; - - cTable[(byte)''] = cTable[(byte)''] = 92; - lTable[(byte)''] = lTable[(byte)''] = 21; - - cTable[(byte)''] = cTable[(byte)''] = 93; - lTable[(byte)''] = lTable[(byte)''] = 21; - - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; - - cTable[(byte)''] = cTable[(byte)''] = 94; - cTable[(byte)''] = cTable[(byte)''] = 95; - cTable[(byte)''] = cTable[(byte)''] = 96; - cTable[(byte)''] = cTable[(byte)''] = 97; - cTable[(byte)''] = cTable[(byte)''] = 98; - cTable[(byte)''] = cTable[(byte)''] = 99; - cTable[(byte)''] = cTable[(byte)''] = 100; - cTable[(byte)''] = cTable[(byte)''] = 101; - cTable[(byte)''] = cTable[(byte)''] = 102; - cTable[(byte)''] = cTable[(byte)''] = 103; - cTable[(byte)''] = cTable[(byte)''] = 104; - cTable[(byte)''] = cTable[(byte)''] = 105; - cTable[(byte)''] = cTable[(byte)''] = 106; - cTable[(byte)''] = cTable[(byte)''] = 107; - cTable[(byte)''] = cTable[(byte)''] = 108; - cTable[(byte)''] = cTable[(byte)''] = 109; - cTable[(byte)''] = cTable[(byte)''] = 110; - cTable[(byte)''] = cTable[(byte)''] = 111; - cTable[(byte)''] = cTable[(byte)''] = 112; - cTable[(byte)''] = cTable[(byte)''] = 113; - cTable[(byte)''] = cTable[(byte)''] = 114; - cTable[(byte)''] = cTable[(byte)''] = 115; - cTable[(byte)''] = cTable[(byte)''] = 116; - cTable[(byte)''] = cTable[(byte)''] = 117; - cTable[(byte)''] = cTable[(byte)''] = 118; - cTable[(byte)''] = cTable[(byte)''] = 119; - cTable[(byte)''] = cTable[(byte)''] = 120; - cTable[(byte)''] = cTable[(byte)''] = 121; - cTable[(byte)''] = cTable[(byte)''] = 122; - cTable[(byte)''] = cTable[(byte)''] = 123; - cTable[(byte)''] = cTable[(byte)''] = 124; - cTable[(byte)''] = cTable[(byte)''] = 125; - cTable[(byte)''] = cTable[(byte)''] = 126; - - - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - // rep. ceca characters - - cTable[(byte)''] = cTable[(byte)''] = 127; - cTable[(byte)''] = cTable[(byte)''] = 128; - cTable[(byte)''] = cTable[(byte)''] = 129; - cTable[(byte)''] = cTable[(byte)''] = 130; - cTable[(byte)''] = cTable[(byte)''] = 131; - cTable[(byte)''] = cTable[(byte)''] = 132; - cTable[(byte)''] = cTable[(byte)''] = 133; - cTable[(byte)''] = cTable[(byte)''] = 134; - cTable[(byte)''] = cTable[(byte)''] = 135; - cTable[(byte)''] = cTable[(byte)''] = 136; - cTable[(byte)''] = cTable[(byte)''] = 137; - cTable[(byte)''] = cTable[(byte)''] = 138; - cTable[(byte)''] = cTable[(byte)''] = 139; - cTable[(byte)''] = cTable[(byte)''] = 140; - cTable[(byte)''] = cTable[(byte)''] = 141; - - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 23; - lTable[(byte)''] = lTable[(byte)''] = 24; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - - // traduci le lettere accentate in lettere normali - - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; - - cTable[(byte)''] = cTable[(byte)''] = 4; // e - lTable[(byte)''] = lTable[(byte)''] = 15; - - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; - - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; - - cTable[(byte)''] = cTable[(byte)''] = 20; // u - lTable[(byte)''] = lTable[(byte)''] = 15; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[''] = 142; - // SS = 143 - - lTable[''] = 24; -#endif // FONT_GERMAN + cTable[(byte)''] = cTable[(byte)''] = 91; + lTable[(byte)''] = lTable[(byte)''] = 15; + + cTable[(byte)''] = cTable[(byte)''] = 92; + lTable[(byte)''] = lTable[(byte)''] = 21; + + cTable[(byte)''] = cTable[(byte)''] = 93; + lTable[(byte)''] = lTable[(byte)''] = 21; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; + + cTable[(byte)''] = cTable[(byte)''] = 94; + cTable[(byte)''] = cTable[(byte)''] = 95; + cTable[(byte)''] = cTable[(byte)''] = 96; + cTable[(byte)''] = cTable[(byte)''] = 97; + cTable[(byte)''] = cTable[(byte)''] = 98; + cTable[(byte)''] = cTable[(byte)''] = 99; + cTable[(byte)''] = cTable[(byte)''] = 100; + cTable[(byte)''] = cTable[(byte)''] = 101; + cTable[(byte)''] = cTable[(byte)''] = 102; + cTable[(byte)''] = cTable[(byte)''] = 103; + cTable[(byte)''] = cTable[(byte)''] = 104; + cTable[(byte)''] = cTable[(byte)''] = 105; + cTable[(byte)''] = cTable[(byte)''] = 106; + cTable[(byte)''] = cTable[(byte)''] = 107; + cTable[(byte)''] = cTable[(byte)''] = 108; + cTable[(byte)''] = cTable[(byte)''] = 109; + cTable[(byte)''] = cTable[(byte)''] = 110; + cTable[(byte)''] = cTable[(byte)''] = 111; + cTable[(byte)''] = cTable[(byte)''] = 112; + cTable[(byte)''] = cTable[(byte)''] = 113; + cTable[(byte)''] = cTable[(byte)''] = 114; + cTable[(byte)''] = cTable[(byte)''] = 115; + cTable[(byte)''] = cTable[(byte)''] = 116; + cTable[(byte)''] = cTable[(byte)''] = 117; + cTable[(byte)''] = cTable[(byte)''] = 118; + cTable[(byte)''] = cTable[(byte)''] = 119; + cTable[(byte)''] = cTable[(byte)''] = 120; + cTable[(byte)''] = cTable[(byte)''] = 121; + cTable[(byte)''] = cTable[(byte)''] = 122; + cTable[(byte)''] = cTable[(byte)''] = 123; + cTable[(byte)''] = cTable[(byte)''] = 124; + cTable[(byte)''] = cTable[(byte)''] = 125; + cTable[(byte)''] = cTable[(byte)''] = 126; + + + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // Czech + + cTable[(byte)''] = cTable[(byte)''] = 127; + cTable[(byte)''] = cTable[(byte)''] = 128; + cTable[(byte)''] = cTable[(byte)''] = 129; + cTable[(byte)''] = cTable[(byte)''] = 130; + cTable[(byte)''] = cTable[(byte)''] = 131; + cTable[(byte)''] = cTable[(byte)''] = 132; + cTable[(byte)''] = cTable[(byte)''] = 133; + cTable[(byte)''] = cTable[(byte)''] = 134; + cTable[(byte)''] = cTable[(byte)''] = 135; + cTable[(byte)''] = cTable[(byte)''] = 136; + cTable[(byte)''] = cTable[(byte)''] = 137; + cTable[(byte)''] = cTable[(byte)''] = 138; + cTable[(byte)''] = cTable[(byte)''] = 139; + cTable[(byte)''] = cTable[(byte)''] = 140; + cTable[(byte)''] = cTable[(byte)''] = 141; + + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 23; + lTable[(byte)''] = lTable[(byte)''] = 24; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French + + // traduci le lettere accentate in lettere normali + + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; + + cTable[(byte)''] = cTable[(byte)''] = 4; // e + lTable[(byte)''] = lTable[(byte)''] = 15; + + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; + + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; + + cTable[(byte)''] = cTable[(byte)''] = 20; // u + lTable[(byte)''] = lTable[(byte)''] = 15; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + // German + + cTable[''] = 142; + // SS = 143 + + lTable[''] = 24; + } } -- cgit v1.2.3 From 333c30b8c7f6781605f517f2a7150f78a77556fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 11:37:33 +1000 Subject: TONY: Removed unused drive & folder defines and code --- engines/tony/adv.h | 8 ------- engines/tony/globals.h | 3 +++ engines/tony/window.cpp | 61 ------------------------------------------------- engines/tony/window.h | 10 +------- 4 files changed, 4 insertions(+), 78 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 90a9c245b5..93359688f6 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -48,14 +48,6 @@ namespace Tony { #define RM_SKIPY ((RM_BBY - RM_SY) / 2) #define RM_SKIPX 0 -// Name lengths -// FIXME: Some of these can likely be removed when refactoring is completed -#define MAX_DRIVE 10 -#define MAX_DIR 255 -#define MAX_PATH 255 -#define MAX_FNAME 100 -#define MAX_EXT 10 - // Tony's actions enum RMTonyAction { TA_GOTO = 0, diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 1c2835cf40..9115b22ccc 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -44,6 +44,9 @@ namespace Tony { #define T_MAREMETA 7 +#define MAX_PATH 255 + + struct CharacterStruct { uint32 code; RMItem *item; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 58d0bba2ba..26dbaf88fc 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -195,69 +195,8 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -char RMSnapshot::bufDrive[MAX_DRIVE]; -char RMSnapshot::bufDir[MAX_DIR]; -char RMSnapshot::bufName[MAX_FNAME]; -char RMSnapshot::bufExt[MAX_EXT]; -char RMSnapshot::filename[512]; byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; -bool RMSnapshot::GetFreeSnapName(char *fn) { -#ifdef REFACTOR_ME - int i, j, k; - uint32 h; - - theGame.GetDataDirectory(RMGame::DD_SHOTS, fn); - _splitpath(fn, bufDrive, bufDir, NULL, NULL); - - for (i = 1; i < 10; i++) { - wsprintf(bufName, "rm%d00", i); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == CORO_INVALID_PID_VALUE) - break; - CloseHandle(h); - } - - i--; - - for (j = 1; j < 10; j++) { - wsprintf(bufName, "rm%d%d0", i, j); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == CORO_INVALID_PID_VALUE) - break; - CloseHandle(h); - } - - j--; - - for (k = 0; k < 10; k++) { - wsprintf(bufName, "rm%d%d%d", i, j, k); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == CORO_INVALID_PID_VALUE) - break; - CloseHandle(h); - } - - if (k == 10) { - k = 0; - j++; - if (j == 10) { - j = 0; - i++; - if (i == 10) - return false; - } - - wsprintf(bufName, "rm%d%d%d", i, j, k); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - } -#endif - return true; -} - void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; diff --git a/engines/tony/window.h b/engines/tony/window.h index ea26df3920..9483f693ab 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -41,16 +41,8 @@ struct DDSURFACEDESC { class RMSnapshot { private: - // Buffer used to create a path - static char bufDrive[MAX_DRIVE], bufDir[MAX_DIR], bufName[MAX_FNAME], bufExt[MAX_EXT]; - static char filename[512]; - - // Buffer used to convert a RGB + // Buffer used to convert to RGB static byte rgb[RM_SX * RM_SY * 3]; - -private: - bool GetFreeSnapName(char *fn); - public: // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); -- cgit v1.2.3 From 0450275c44c8c001d56cf37c78db6951ecaa4314 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 13:54:59 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/loc.cpp | 612 ++++++++++++++++++++-------------------------- engines/tony/loc.h | 119 +++++---- engines/tony/tony.cpp | 12 +- engines/tony/tony.h | 12 +- engines/tony/tonychar.cpp | 56 ++--- engines/tony/tonychar.h | 69 +++--- engines/tony/utils.cpp | 36 +-- engines/tony/utils.h | 20 +- engines/tony/window.cpp | 6 +- engines/tony/window.h | 10 +- 10 files changed, 433 insertions(+), 519 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b88fc68fc5..722116c47c 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -38,47 +38,34 @@ using namespace ::Tony::MPAL; /****************************************************************************\ -* Metodi di RMPalette -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMPalette& pal); -* -* Description: Operatore di estrazione di palette da data stream -* -* Input: RMDataStream &ds Data stream -* RMPalette& pal Palette di destinazione -* -* Return: Reference allo stream -* +* RMPalette Methods \****************************************************************************/ +/** + * Operator for reading palette information from a data stream. + * + * @param ds Data stream + * @param pal Destination palette + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { ds.Read(pal.m_data,1024); return ds; } /****************************************************************************\ -* Metodi di RMSlot -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMSlot& slot) -* -* Description: Operatore per estrarre uno slot di un pattern da un data -* stream -* -* Input: RMDataStream &ds Data stream -* RMSlot& slot Slot di destinazione -* -* Return: Reference allo stream -* +* RMSlot Methods \****************************************************************************/ +/** + * Operator for reading slot information from a data stream. + * + * @param ds Data stream + * @param slot Destination slot + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { slot.ReadFromStream(ds); return ds; @@ -107,20 +94,14 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { * Metodi di RMPattern \****************************************************************************/ -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMPattern& pat) -* -* Description: Operatore per estrarre un pattern da un data stream -* -* Input: RMDataStream &ds Data stream -* RMPattern& pat Pattern di destinazione -* -* Return: Reference allo stream -* -\****************************************************************************/ - +/** + * Operator for reading pattern information from a data stream + * + * @param ds Data stream + * @param pat Destination pattern + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { pat.ReadFromStream(ds); return ds; @@ -129,23 +110,23 @@ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { void RMPattern::ReadFromStream(RMDataStream &ds, bool bLOX) { int i; - // Nome del pattern + // Pattern name if (!bLOX) ds >> m_name; - // Velocita' + // Velocity ds >> m_speed; - // Posizione + // Position ds >> m_pos; - // Flag di loop del pattern + // Flag for pattern looping ds >> m_bLoop; - // Numero di slot + // Number of slots ds >> m_nSlots; - // Creazione e lettura degli slot + // Create and read the slots m_slots = new RMSlot[m_nSlots]; for (i = 0; i < m_nSlots && !ds.IsError(); i++) { @@ -174,11 +155,11 @@ void RMPattern::StopSfx(RMSfx *sfx) { int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; - // Prendiamo il tempo corrente + // Read the current time m_nStartTime = _vm->GetTime(); m_nCurSlot = 0; - // Cerca il primo frame nel pattern + // Find the first frame of the pattern i = 0; while (m_slots[i].m_type != SPRITE) { assert(i + 1 < m_nSlots); @@ -190,13 +171,13 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { if (bFlag) *bFlag = m_slots[i].m_flag; - // Calcola le coordinate correnti + // Calculate the current coordinates UpdateCoord(); - // Controlla per il sonoro: - // Se sta alla slot 0, lo playa - // Se speed = 0, deve suonare solo se va in loop '_', oppure se specificato dal parametro - // Se speed! = 0, suona solo quelli in loop + // Check for sound: + // If the slot is 0, play + // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter + // If speed != 0, play only the loop for (i = 0;i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { if (i == 0) { @@ -230,14 +211,14 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { int CurTime = _vm->GetTime(); - // Se la speed e' 0, il pattern non avanza mai + // If the speed is 0, then the pattern never advances if (m_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } - // E' arrivato il momento di cambiare slot? + // Is it time to change the slots? while (m_nStartTime + m_speed <= (uint32)CurTime) { m_nStartTime += m_speed; if (m_slots[m_nCurSlot].m_type == SPRITE) @@ -248,8 +229,8 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { CoroScheduler.pulseEvent(hEndPattern); - // @@@ Se non c'e' loop avverte che il pattern e' finito - // Se non c'e' loop rimane sull'ultimo frame + // @@@ If there is no loop pattern, and there's a warning that it's the final + // frame, then remain on the last frame if (!m_bLoop) { m_nCurSlot = m_nSlots - 1; bFlag = m_slots[m_nCurSlot].m_flag; @@ -260,10 +241,10 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { for (;;) { switch (m_slots[m_nCurSlot].m_type) { case SPRITE: - // Legge il prossimo sprite + // Read the next sprite m_nCurSprite = m_slots[m_nCurSlot].m_data; - // Aggiorna le coordinate babbo+figlio + // Update the parent & child coordinates UpdateCoord(); break; @@ -293,7 +274,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { } } - // Ritorna lo sprite corrente + // Return the current sprite bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -320,23 +301,17 @@ RMPattern::~RMPattern() { /****************************************************************************\ -* Metodi di RMSprite -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMSprite& sprite) -* -* Description: Operatore per estrarre uno sprite da un data stream -* -* Input: RMDataStream &ds Data stream -* RMItem &item Sprite di destinazione -* -* Return: Reference allo stream -* +* RMSprite Methods \****************************************************************************/ +/** + * Operator for reading sprite information from a data stream. + * + * @param ds Data stream + * @param sprite Destination slot + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { sprite.ReadFromStream(ds); return ds; @@ -366,22 +341,22 @@ void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { int dimx,dimy; - // Nome dello sprite + // Sprite name if (!bLOX) ds >> m_name; - // Dimensioni + // Dimensions ds >> dimx >> dimy; - // Bouding box + // Bounding box ds >> m_rcBox; - // Spazio inutilizzato + // Unused space if (!bLOX) - ds+=32; + ds += 32; - // Crezione del buffer e lettura - m_buf->Init(ds, dimx,dimy); + // Create buffer and read + m_buf->Init(ds, dimx, dimy); } void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -405,23 +380,17 @@ RMSprite::~RMSprite() { /****************************************************************************\ -* Metodi di RMSfx -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMSfx &sfx) -* -* Description: Operatore per estrarre uno sfx da un data stream -* -* Input: RMDataStream &ds Data stream -* RMSfx &sfx Sfx di destinazione -* -* Return: Reference allo stream -* +* RMSfx Methods \****************************************************************************/ +/** + * Operator for reading SFX information from a data stream. + * + * @param ds Data stream + * @param sfx Destination SFX + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { sfx.ReadFromStream(ds); return ds; @@ -432,29 +401,29 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { int size; byte *raw; - // Nome dello sfx + // sfx name ds >> m_name; ds >> size; - // Carica l'effetto sonoro dal buffer - ds.Read(id,4); + // Upload the sound effect identifier from the buffer + ds.Read(id, 4); - // Controlla che sia un riff + // Ensure it's a RIFF assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); - // Legge la dimensione + // Read the size ds >> size; - // Carica il wav + // Read the raw WAV data raw = new byte[size]; ds.Read(raw, size); - // Crea l'effetto sonoro + // Create the sound effect m_fx = _vm->CreateSFX(raw); m_fx->SetLoop(false); - // Cancella il buffer che non serve pi a nessuno + // Close the read buffer which is no longer needed delete[] raw; } @@ -476,7 +445,7 @@ void RMSfx::Play(bool bLoop) { m_fx->Play(); if (bLoop) - m_bPlayingLoop=true; + m_bPlayingLoop = true; } } @@ -502,23 +471,17 @@ void RMSfx::Stop(void) { /****************************************************************************\ -* Metodi di RMItem -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMItem &item) -* -* Description: Operatore per estrarre un item da un data stream -* -* Input: RMDataStream &ds Data stream -* RMItem &item Item di destinazione -* -* Return: Reference allo stream -* +* RMItem Methods \****************************************************************************/ +/** + * Operator for reading item information from a data stream. + * + * @param ds Data stream + * @param tem Destination item + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { item.ReadFromStream(ds); return ds; @@ -561,13 +524,12 @@ bool RMItem::IsIn(const RMPoint &pt, int *size) { if (!m_bIsActive) return false; - // Cerca il rettangolo giusto da usare, che quello dello sprite se ce l'ha, altrimenti - // quello generico dell'oggeto + // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); else if (!m_rcBox.IsEmpty()) rc = m_rcBox; - // Se non ha box, esce subito + // If no box, return immediately else return false; @@ -582,16 +544,16 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { int i, dimx, dimy; byte cm; - // Codice mpal + // MPAL code ds >> m_mpalCode; - // Nome dell'oggetto + // Object name ds >> m_name; // Z (signed) ds >> m_z; - // Posizione nonno + // Parent position ds >> m_pos; // Hotspot @@ -600,22 +562,22 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // Bounding box ds >> m_rcBox; - // Numero sprite, effetti sonori e pattern + // Number of sprites, sound effects, and patterns ds >> m_nSprites >> m_nSfx >> m_nPatterns; // Color mode ds >> cm; m_cm=(RMColorMode)cm; - // Flag di presenza della palette differnziata + // Flag for the presence of custom palette differences ds >> m_bPal; if (m_cm == CM_256) { - // Se c'e' la palette, leggiamola + // If there is a palette, read it in if (m_bPal) ds >> m_pal; } - // Dati MPAL + // MPAL data if (!bLOX) ds += 20; @@ -625,17 +587,17 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { if (!bLOX) ds += 106; - // Creazione delle classi + // Create sub-classes if (m_nSprites > 0) m_sprites = new RMSprite[m_nSprites]; if (m_nSfx > 0) m_sfx = new RMSfx[m_nSfx]; m_patterns = new RMPattern[m_nPatterns+1]; - // Lettura delle classi + // Read in class data if (!ds.IsError()) for (i = 0; i < m_nSprites && !ds.IsError(); i++) { - // Carica lo sprite + // Download the sprites if (bLOX) { m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); @@ -658,7 +620,7 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { m_sfx[i].ReadFromStream(ds, false); } - // Leggiamo i pattern a partire dal pattern 1 + // Read the pattern from pattern 1 if (!ds.IsError()) for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { if (bLOX) @@ -667,12 +629,12 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { m_patterns[i].ReadFromStream(ds, false); } - // Inizializza il curpattern + // Initialise the current pattern if (m_bInitCurPattern) SetPattern(mpalQueryItemPattern(m_mpalCode)); - // Inizializza lo stato di attivazione - m_bIsActive=mpalQueryItemIsActive(m_mpalCode); + // Initailise the current activation state + m_bIsActive = mpalQueryItemIsActive(m_mpalCode); } @@ -687,11 +649,11 @@ void RMItem::SetScrollPosition(const RMPoint &scroll) { bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { int oldSprite = m_nCurSprite; - // Pattern 0 = Non disegnare nulla! + // Pattern 0 = Do not draw anything! if (m_nCurPattern == 0) return false; - // Facciamo un update del pattern, che ci ritorna anche il frame corrente + // We do an update of the pattern, which also returns the current frame if (m_nCurPattern != 0) { m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); @@ -704,14 +666,14 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { m_nCurSprite = -1; } - // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito + // If the function returned -1, it means that the pattern has finished if (m_nCurSprite == -1) { - // Mettiamo il pattern 0, e usciamo. La classe si auto-deregistrera' della OT list + // We have pattern 0, so leave. The class will self de-register from the OT list m_nCurPattern = 0; return false; } - // Se non siamo in OT list, mettiamoci + // If we are not in the OT list, add ourselves if (!m_nInList && bAddToList) bigBuf->AddPrim(NewItemPrimitive()); @@ -728,24 +690,24 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); - // Se CurSprite == -1, allora e' finito il pattern + // If CurSprite == -1, then the pattern is finished if (m_nCurSprite == -1) return; - // Settiamo la flag + // Set the flag prim->SetFlag(m_bCurFlag); - // Offset inverso per lo scrolling + // Offset direction for scrolling prim->Dst().Offset(-m_curScroll); - // Dobbiamo sparaflashare le coordinate dell'item dentro la primitiva. - // Si calcola nonno+(babbo+figlio) + // We must offset the cordinates of the item inside the primitive + // It is estimated as nonno + (babbo + figlio) prim->Dst().Offset(CalculatePos()); // No stretching, please prim->SetStrecth(false); - // Ora la passiamo alla routine di drawing generica per surface + // Now we turn to the generic surface drawing routines CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); CORO_END_CODE; @@ -753,7 +715,7 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMItem::RemoveThis(CORO_PARAM, bool &result) { - // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) + // Remove from the OT list if the current frame is -1 (pattern over) result = (m_nCurSprite == -1); } @@ -771,16 +733,16 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { if (m_nCurPattern>0) m_patterns[m_nCurPattern].StopSfx(m_sfx); - // Si ricorda il pattern corrente + // Remember the current pattern m_nCurPattern = nPattern; - // Inizia il pattern per cominciare l'animazione + // Start the pattern to start the animation if (m_nCurPattern != 0) m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); else { m_nCurSprite = -1; - // Cerca l'effetto sonoro per il pattern 0 + // Look for the sound effect for pattern 0 if (bPlayP0) for (i = 0;i < m_nSfx; i++) if (strcmp(m_sfx[i].m_name, "p0") == 0) @@ -789,8 +751,7 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { } -bool RMItem::GetName(RMString &name) -{ +bool RMItem::GetName(RMString &name) { char buf[256]; mpalQueryItemName(m_mpalCode, buf); @@ -885,7 +846,7 @@ void RMItem::PauseSound(bool bPause) { /****************************************************************************\ -* Metodi di RMWipe +* RMWipe Methods \****************************************************************************/ @@ -931,13 +892,13 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { } void RMWipe::CloseFade(void) { -// m_bUnregister=true; +// m_bUnregister = true; // WaitForSingleObject(m_hUnregistered,CORO_INFINITE); m_wip0r.Unload(); } void RMWipe::InitFade(int type) { - // Attiva il fade + // Activate the fade m_bUnregister = false; m_bEndFade = false; @@ -993,19 +954,19 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************\ -* Metodi di RMCharacter +* RMCharacter Methods \****************************************************************************/ -/***************************************************************************/ -/* Cerca il percorso minimo tra due nodi del grafo di connessione dei BOX */ -/* Restituisce il percorso lungo pathlenght nel vettore path[] */ -/***************************************************************************/ +/****************************************************************************/ +/* Find the shortest path between two nodes of the graph connecting the BOX */ +/* Returns path along the vector path path[] */ +/****************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrice di Adjacenza - static short COSTO[MAXBOXES]; // Costi per Nodo - static short VALIDO[MAXBOXES]; // 0:non valido 1:valido 2:saturo - static short NEXT[MAXBOXES]; // Prossimo Nodo + static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes + static short COSTO[MAXBOXES]; // Cost per node + static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated + static short NEXT[MAXBOXES]; // Prossimo Nodo short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; @@ -1016,37 +977,37 @@ short RMCharacter::FindPath(short source, short destination) { return 0; } - // Si fa dare i box + // Get the boxes cur = theBoxes->GetBoxes(curLocation); - // Effettua una copia di riserva per lavorarci + // Make a backup copy to work on for (i = 0; i < cur->numbbox; i++) memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); - // Invalida tutti i Nodi + // Invalidate all nodes for (i = 0; i < cur->numbbox; i++) VALIDO[i] = 0; - // Prepara sorgente e variabili globali alla procedura + // Prepare source and variables for the procedure COSTO[source] = 0; VALIDO[source] = 1; fine = 0; - // Ricerca del percorso minimo + // Find the shortest path while(!fine) { - costominimo = 32000; // risetta il costo minimo - errore = 1; // errore possibile + costominimo = 32000; // Reset the minimum cost + errore = 1; // Possible error - // 1 ciclo : ricerca di possibili nuovi nodi + // 1st cycle: explore possible new nodes for (i = 0; i < cur->numbbox; i++) if (VALIDO[i] == 1) { - errore = 0; // errore sfatato + errore = 0; // Failure de-bunked j = 0; while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) j++; if (j >= cur->numbbox) - VALIDO[i] = 2; // nodo saturo? + VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; if (COSTO[i] + 1 < costominimo) @@ -1055,9 +1016,9 @@ short RMCharacter::FindPath(short source, short destination) { } if (errore) - fine = 1; // tutti i nodi saturi + fine = 1; // All nodes saturated - // 2 ciclo : aggiunta nuovi nodi trovati , saturazione nodi vecchi + // 2nd cycle: adding new nodes that were found, saturate old nodes for (i = 0; i < cur->numbbox; i++) if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { BOX[i].adj[NEXT[i]] = 2; @@ -1072,7 +1033,7 @@ short RMCharacter::FindPath(short source, short destination) { } } - // Estrazione del percorso dalla matrice di adiacenza modificata + // Remove the path from the adjacent modified matrixes if (!errore) { pathlenght = COSTO[destination]; k = pathlenght; @@ -1133,7 +1094,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkspeed = -walkspeed; walkstatus = 1; - // Cambia il proprio pattern per la nuova direzione + // Change the pattern for the new direction bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKLEFT) @@ -1148,7 +1109,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkspeed = -walkspeed; walkstatus = 0; - bNeedToStop=true; + bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKUP) SetPattern(PAT_WALKUP); @@ -1237,7 +1198,7 @@ RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { if ((difx<0) && (dify>0)) tofind=Searching(0,1,0,1,punto); if ((difx<0) && (dify<0)) tofind=Searching(1,0,0,1,punto); - // potrebbero essere tolti? Pensaci @@@@ + // Could be removed? Think @@@@ if ((difx= = 0) && (dify>0)) tofind=Searching(0,1,1,1,punto); if ((difx= = 0) && (dify<0)) tofind=Searching(1,0,1,1,punto); if ((dify= = 0) && (difx>0)) tofind=Searching(1,1,1,0,punto); @@ -1259,8 +1220,8 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstart = m_pos; Lend = punto; - Ldx = Lstart.x-Lend.x; - Ldy = Lstart.y-Lend.y; + Ldx = Lstart.x - Lend.x; + Ldy = Lstart.y - Lend.y; Lfx = Ldx; Lfy = Ldy; Ldx = ABS(Ldx); @@ -1278,7 +1239,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstatus = 0; } - Lscan = Lstart; // Inizio scansione + Lscan = Lstart; // Start scanning while (InWhichBox(Lscan) != -1) { Lcount++; if (Lstatus) { @@ -1298,7 +1259,9 @@ short RMCharacter::ScanLine(const RMPoint &punto) { return 0; } -// Calcola intersezioni tra la traiettoria rettilinea ed il pi vicino BBOX +/** + * Calculates intersections between the straight line and the closest BBOX + */ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; @@ -1351,9 +1314,9 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { } -/***************************************************************************/ -/* Ritorna la coordinata dell'HotSpot di uscita pi vicino al giocatore */ -/***************************************************************************/ +/** + * Returns the HotSpot coordinate closest to the player + */ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { RMPoint puntocaldo; @@ -1396,21 +1359,21 @@ void RMCharacter::NewBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; - // Richiama la On ExitBox + // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); cur = theBoxes->GetBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; curbox = nBox; - // Se cambiata la Z, dobbiamo rimuoverlo dalla OT + // If Z is changed, we must remove it from the OT if (cur->boxes[curbox].Zvalue != m_z) { bRemoveFromOT = true; m_z = cur->boxes[curbox].Zvalue; } - // Gestisce l'inversione del movimento SOLO se non siamo nel percorso minimo: se siamo in percorso - // minimo direttamente la DoFrame a farlo + // Movement management is reversed, only if we are not in the shortest path. If we are in the shortest + // path, directly do the DoFrame if (bMovingWithoutMinpath) { if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { switch (GetCurPattern()) { @@ -1430,7 +1393,7 @@ void RMCharacter::NewBoxEntered(int nBox) { } } - // Richiama la On EnterBox + // Recall On EnterBox mpalQueryDoAction(2, curLocation, curbox); } @@ -1448,16 +1411,16 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { g_system->lockMutex(csMove); - // Se stiamo camminando... + // If we're walking.. if (status != STAND) { - // Se stiamo andando in orizzontale + // If we are going horizontally if (walkstatus == 1) { dx = walkspeed * walkcount; dy = slope * dx; m_pos.x = linestart.x + dx; m_pos.y = linestart.y + dy; - // Destra + // Right if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { m_pos = lineend; status = STAND; @@ -1465,14 +1428,14 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { } } - // Se stiamo andando in verticale + // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; dx = slope * dy; m_pos.x = linestart.x + dx; m_pos.y = linestart.y + dy; - // Basso + // Down if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { m_pos = lineend; status = STAND; @@ -1480,15 +1443,13 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { } } - // Controlla se il personaggio uscito dai BOX per errore, nel qual caso - // lo fa rientrare subito + // Check if the character came out of the BOX in error, in which case he returns immediately if (InWhichBox(m_pos) == -1) { m_pos.x = linestart.x + olddx; m_pos.y = linestart.y + olddy; } - // Se siamo appena arrivati alla destinazione temporanea ed finito il percorso minimo, - // ci fermiamo definitivamente + // If we have just moved to a temporary location, and is over the shortest path, we stop permanently if (_ctx->bEndNow && minpath == 0) { if (!bEndOfPath) CORO_INVOKE_0(Stop); @@ -1498,35 +1459,35 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { walkcount++; - // Aggiorna la Z del personaggio @@@ bisognerebbe rimuoverlo solo se cambiata la Z + // Update the character Z. @@@ Should remove only if the Z was changed - // Controlla se abbiamo cambiato box + // Check if the box was changed if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) NewBoxEntered(InWhichBox(m_pos)); - // Aggiorna le vecchie coordinate + // Update the old coordinates olddx = dx; olddy = dy; } - // Se siamo fermi + // If we stop if (status == STAND) { - // Controlliamo se c' ancora percorso minimo da calcolare + // Check if there is still the shortest path to calculate if (minpath == 1) { _ctx->cur = theBoxes->GetBoxes(curLocation); - // Se dobbiamo ancora attraversare un box + // If we still have to go through a box if (pathcount < pathlenght) { - // Controlliamo che il box su cui stiamo entrando sia attivo + // Check if the box we're going into is active if (_ctx->cur->boxes[path[pathcount-1]].attivo) { - // Muoviti in linea retta verso l'hotspot pi vicino, tenendo conto del reversing please + // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); pathcount++; } else { - // Se il box disattivato, possiamo solo bloccare tutto - // @@@ Questo non dovrebbe pi avvenire, dato che abbiamo migliorato - // la ricerca del percorso minimo + // If the box is off, we can only block all + // @@@ Whilst this should not happen, because have improved + // the search for the minimum path minpath = 0; if (!bEndOfPath) CORO_INVOKE_0(Stop); @@ -1534,8 +1495,8 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { CoroScheduler.pulseEvent(hEndOfPath); } } else { - // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il - // punto di arrivo + // If we have already entered the last box, we just have to move in a straight line towards the + // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed); @@ -1545,7 +1506,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { g_system->unlockMutex(csMove); - // Richiama il DoFrame dell'item + // Invoke the DoFrame of the item RMItem::DoFrame(bigBuf); CORO_END_CODE; @@ -1611,7 +1572,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { bMoving = true; - // Se 0,0, non fare nulla, anzi fermati + // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { minpath = 0; status = STAND; @@ -1621,10 +1582,10 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { return; } - // Se clicko fuori dai box + // If clicked outside the box _ctx->numbox = InWhichBox(pt); if (_ctx->numbox == -1) { - // Trova il punto pi vicino dentro i box + // Find neareste point inside the box _ctx->dest = NearestPoint(pt); // ???!?? @@ -1687,7 +1648,7 @@ void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { if (newloc != -1) curLocation = newloc; - // Aggiorna la Z del personaggio + // Update the character's Z value box = theBoxes->GetBoxes(curLocation); curbox = InWhichBox(m_pos); assert(curbox != -1); @@ -1771,7 +1732,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { ds >> right; ds >> bottom; - // Adiacenza + // Adjacency for (i = 0; i < MAXBOXES; i++) { ds >> adj[i]; } @@ -1784,8 +1745,8 @@ void RMBox::ReadFromStream(RMDataStream &ds) { ds >> b; bReversed = b; - // Spazio di espansione - ds+=30; + // Reversed expansion space + ds += 30; // Hotspots for (i = 0; i < numhotspot; i++) { @@ -1818,18 +1779,18 @@ void RMBoxLoc::ReadFromStream(RMDataStream &ds) { char buf[2]; byte ver; - // ID and versione + // ID and version ds >> buf[0] >> buf[1] >> ver; assert(buf[0] == 'B' && buf[1] == 'X'); assert(ver == 3); - // Numero dei box + // Number of boxes ds >> numbbox; - // Alloca la memoria per i box + // Allocate memory for the boxes boxes = new RMBox[numbbox]; - // Li legge da disco + // Read in boxes for (i = 0; i < numbbox; i++) ds >> boxes[i]; } @@ -1950,7 +1911,7 @@ void RMGameBoxes::SaveState(byte *state) { // For each location, write out the number of boxes and their status for (i=1; i <= m_nLocBoxes; i++) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); - state+=4; + state += 4; for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; @@ -1958,17 +1919,16 @@ void RMGameBoxes::SaveState(byte *state) { } void RMGameBoxes::LoadState(byte *state) { - int i,j; - int nloc,nbox; + int i, j; + int nloc, nbox; - // Load number of locations with box + // Load number of items nloc = *(int*)state; - state+=4; + state += 4; - // Controlla che siano meno di quelli correnti assert(nloc <= m_nLocBoxes); - // Per ogni locazione, salva il numero di box e il loro stato + // For each location, read the number of boxes and their status for (i = 1; i <= nloc; i++) { nbox = READ_LE_UINT32(state); state += 4; @@ -1985,17 +1945,12 @@ void RMGameBoxes::LoadState(byte *state) { } /****************************************************************************\ -* Metodi di RMLocation -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: RMLocation::RMLocation(); -* -* Description: Costruttore standard -* +* RMLocation Methods \****************************************************************************/ +/** + * Standard constructor + */ RMLocation::RMLocation() { m_nItems = 0; m_items = NULL; @@ -2003,49 +1958,36 @@ RMLocation::RMLocation() { } -/****************************************************************************\ -* -* Function: bool RMLocation::Load(char *lpszFileName); -* -* Description: Carica una locazione (.LOC) da un file di cui viene fornito -* il pathname. -* -* Input: char *lpszFileName Nome del file di dati -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Load a location (.LOC) from a file that is provided. + * + * @param lpszFileName Name of the file + */ bool RMLocation::Load(const char *lpszFileName) { Common::File f; bool bRet; - // Apre il file in lettura + // Open the file for reading if (!f.open(lpszFileName)) return false; - // Lo passa alla routine di loading da file aperto + // Passes to the method variation for loading from the opened file bRet = Load(f); - // Chiude il file + // Close the file f.close(); return bRet; } -/****************************************************************************\ -* -* Function: bool RMLocation::Load(HANDLE hFile); -* -* Description: Carica una locazione (.LOC) da un handle di file aperto -* -* Input: HANDLE hFile Handle del file -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Load a location (.LOC) from a given open file + * + * @param hFile File reference + * + * @returns True if succeeded OK, false in case of error. + */ bool RMLocation::Load(Common::File &file) { int size; // byte *buf; @@ -2091,20 +2033,12 @@ bool RMLocation::Load(const byte *buf) { } - -/****************************************************************************\ -* -* Function: bool RMLocation::Load(byte *buf); -* -* Description: Carica una locazione (.LOC) parsando il file gia' caricato -* in memoria. -* -* Input: byte *buf Buffer con il file caricato -* -* Return: true se ok, false in caso di errore -* -\****************************************************************************/ - +/** + * Load a location (.LOC) from a given data stream + * + * @param ds Data stream + * @returns True if succeeded OK, false in case of error. + */ bool RMLocation::Load(RMDataStream &ds) { char id[3]; int dimx, dimy; @@ -2112,40 +2046,40 @@ bool RMLocation::Load(RMDataStream &ds) { byte cm; int i; - // Controlla l'ID + // Check the ID ds >> id[0] >> id[1] >> id[2]; - // Controlla se siamo in un LOX + // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') return LoadLOX(ds); - // Altrimenti, controlla che sia un LOC normale + // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') return false; - // Versione + // Version ds >> ver; assert(ver == 6); - // Nome della locazione + // Location name ds >> m_name; - // Skippa i salvataggi MPAL (64 bytes) + // Skip the MPAL bailouts (64 bytes) ds >> TEMPNumLoc; ds >> TEMPTonyStart.x >> TEMPTonyStart.y; ds += 64 - 4 * 3; - // Skippa il flag di background associato (?!) + // Skip flag associated with the background (?) ds += 1; - // Dimensioni della locazione + // Location dimensions ds >> dimx >> dimy; m_curScroll.Set(0, 0); - // Legge il color mode + // Read the colour mode ds >> cm; m_cmode = (RMColorMode)cm; - // Inizializza il source buffer e leggi la locazione dentro + // Initialise the source buffer and read the location switch (m_cmode) { case CM_256: m_buf = new RMGfxSourceBuffer8; @@ -2160,16 +2094,16 @@ bool RMLocation::Load(RMDataStream &ds) { break; }; - // Inizializza la surface, caricando anche la palette se necessario + // Initialise the surface, loading the palette if necessary m_buf->Init(ds, dimx, dimy, true); - // Controlla le dimensioni della locazione + // Check the size of the location // assert(dimy!=512); - // Numero oggetti + // Number of objects ds >> m_nItems; - // Creazione e lettura degli oggetti + // Create and read in the objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; @@ -2179,7 +2113,7 @@ bool RMLocation::Load(RMDataStream &ds) { ds >> m_items[i]; _vm->UnfreezeTime(); - // Setta i pattern iniziali @@@ doppione!! + // Sets the initial pattern @@@ duplication! //for (i = 0;i> ver; assert(ver == 1); - // Nome locazione + // Location name ds >> m_name; - // Numero loc + // Location number ds >> TEMPNumLoc; ds >> TEMPTonyStart.x >> TEMPTonyStart.y; - // Dimensioni + // Dimensions ds >> dimx >> dimy; m_curScroll.Set(0, 0); - // Color mode sempre 65K + // It's always 65K (16-bit) mode m_cmode = CM_65K; m_buf = new RMGfxSourceBuffer16; - // Inizializza la surface, caricando anche la palette se necessario + // Initialise the surface, loading in the palette if necessary m_buf->Init(ds, dimx, dimy, true); - // Controlla le dimensioni della locazione + // Check the size of the location // assert(dimy!=512); - // Numero oggetti + // Number of items ds >> m_nItems; - // Creazione e lettura degli oggetti + // Create and read objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; @@ -2231,54 +2165,40 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { } - -/****************************************************************************\ -* -* Function: void RMLocation::Draw(RMGfxTargetBuffer* bigBuf, -* RMGfxPrimitive* prim); -* -* Description: Metodo di drawing in overloading da RMGfxSourceBuffer8 -* -\****************************************************************************/ - +/** + * Draw method overloaded from RMGfxSourceBUffer8 + */ void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - // Setta la posizione sorgente dello scrolling + // Set the position of the source scrolling if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); } prim->SetDst(m_fixedScroll); - // Richiama il metodo di drawing della classe dell'immagine, che disegner il background - // della locazione + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); CORO_END_CODE; } -/****************************************************************************\ -* -* Function: void RMLocation::DoFrame(void); -* -* Description: Prepara un frame, aggiungendo alla OTList la locazione stessa -* e tutti gli item che hanno cambiato frame di animazione -* -\****************************************************************************/ - +/** + * Prepare a frame, adding the location to the OT list, and all the items that have changed animation frame. + */ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { int i; - // Se la locazione non e' in OT list, la aggiunge + // If the location is not in the OT list, add it in if (!m_nInList) bigBuf->AddPrim(new RMGfxPrimitive(this)); - // Processa tutti gli item della locazione + // Process all the location items for (i = 0;i < m_nItems; i++) m_items[i].DoFrame(bigBuf); } @@ -2321,13 +2241,13 @@ RMLocation::~RMLocation() { } void RMLocation::Unload(void) { - // Cancella la memoria + // Clear memory if (m_items) { delete[] m_items; m_items = NULL; } - // Cancella il buffer + // Destroy the buffer if (m_buf) { delete m_buf; m_buf = NULL; @@ -2399,7 +2319,7 @@ void RMLocation::PauseSound(bool bPause) { /****************************************************************************\ -* Metodi di RMMessage +* RMMessage Methods \****************************************************************************/ RMMessage::RMMessage(uint32 dwId) { @@ -2432,16 +2352,16 @@ void RMMessage::ParseMessage(void) { p = lpPeriods[0] = lpMessage; for (;;) { - // Trova la fine del periodo corrente + // Find the end of the current period while (*p != '\0') p++; - // Se c'e' un altro '\0' siamo alla fine del messaggio + // If there is another '0' at the end of the string, the end has been found p++; if (*p == '\0') break; - // Altrimenti c'e' un altro periodo, e ci ricordiamo il suo inizio + // Otherwise there is another line, and remember it's start lpPeriods[nPeriods++] = p; } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index e25bdb500c..4b9a18f406 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -128,8 +128,8 @@ public: private: int m_speed; - RMPoint m_pos; // Coordinate babbo - RMPoint m_curPos; // Coordinate babbo+figlio + RMPoint m_pos; // Parent coordinates + RMPoint m_curPos; // Parent + child coordinates int m_bLoop; int m_nSlots; int m_nCurSlot; @@ -237,29 +237,29 @@ public: friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); - // Processa l'oggetto per fare andare avanti eventuale animazioni. Ritorna TRUE se dovr - // essere ridisegnato il prossimo frame + // Process to make the object move on any animations. + // Returns TRUE if it should be redrawn on the next frame bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); - // Setta la posizione corrente di scrolling + // Sets the current scrolling position void SetScrollPosition(const RMPoint &scroll); - // Overloading della funzione per la rimozione da ot list + // Overloading of check whether to remove from active list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading del draw + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Overloading della priorit: la Z + // Overloaded priority: it's based on Z ordering virtual int Priority() { return m_z; } - // Numero di pattern + // Pattern number int NumPattern() { return m_nPatterns; } - // Setta un nuovo pattern di animazione, cambiando bruscamente da quello corrente + // Set anew animation pattern, changing abruptly from the current virtual void SetPattern(int nPattern, bool bPlayP0 = false); - // Setta un nuovo status. + // Set a new status void SetStatus(int nStatus); bool IsIn(const RMPoint &pt, int *size = NULL); @@ -267,13 +267,13 @@ public: bool GetName(RMString &name); int MpalCode() { return m_mpalCode; } - // Scarica l'item + // Unload void Unload(void); - // Aspetta la fine del pattern in play + // Wait for the end of the current pattern void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); - // Setta un nuovo hotspot per l'oggetto + // Sets a new hotspot fro the object void ChangeHotspot(const RMPoint &pt); void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } @@ -285,30 +285,30 @@ void ReadFromStream(RMDataStream& ds, bool bLOX=false); void PauseSound(bool bPause); protected: - // Crea una primitiva che ha come task l'item stesso + // Create a primitive that has as it's task this item virtual RMGfxPrimitive *NewItemPrimitive(); - // Alloca la memoria per gli sprites - virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + // Allocate memory for the sprites + virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); }; -#define MAXBOXES 50 // Non si puo' cambiare, comanda cosi' il boxed -#define MAXHOTSPOT 20 // Idem +#define MAXBOXES 50 // Maximum number of allowed boxes +#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots class RMBox { public: struct T_HOTSPOT { - int hotx, hoty; // coordinate HotSpot - int destination; // destinazione HotSpot + int hotx, hoty; // Hotspot coordinates + int destination; // Hotspot destination }; public: - int left,top,right,bottom; // Vertici BoundingBox - int adj[MAXBOXES]; // Lista di adjacenza - int numhotspot; // Numero HotSpot - uint8 Zvalue; // Zvalue per quel BoundingBox - T_HOTSPOT hotspot[MAXHOTSPOT]; // Lista degli HotSpot + int left, top, right, bottom; // Vertici bounding boxes + int adj[MAXBOXES]; // List of adjacent bounding boxes + int numhotspot; // Hotspot number + uint8 Zvalue; // Z value for the bounding box + T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots bool attivo; bool bReversed; @@ -351,19 +351,19 @@ public: void Init(void); void Close(void); - // Prende i box di una locazione + // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); - // Calcola in quale box si trova il punto + // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); - // Controlla che il punto sia dentro un certo box + // Check whether a point is inside a given box bool IsInBox(int nLoc, int nBox, const RMPoint &pt); - // Cambia lo stato di un box + // Change the status of a box void ChangeBoxStatus(int nLoc, int nBox, int status); - // Salvataggi + // Save state handling int GetSaveStateSize(void); void SaveState(byte *buf); void LoadState(byte *buf); @@ -429,38 +429,38 @@ protected: bool bMoving; bool bDrawNow; bool bNeedToStop; -// virtual RMGfxPrimitive* NewItemPrimitive(); +// virtual RMGfxPrimitive *NewItemPrimitive(); public: RMCharacter(); virtual ~RMCharacter(); - void LinkToBoxes(RMGameBoxes* theBoxes); + void LinkToBoxes(RMGameBoxes *theBoxes); virtual void RemoveThis(CORO_PARAM, bool &result); - // Aggiorna la posizione del personaggio + // Update the position of a character void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); - // Overloading del Draw + // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // TRUE se si appena fermato + // TRUE if you just stopped bool EndOfPath() { return bEndOfPath; } - // Cambia il pattern del personaggio per fermarlo + // Change the pattern of a character to STOP virtual void Stop(CORO_PARAM); - // Controlla se il personaggio si sta muovendo + // Check if the character is moving bool IsMoving() { return bMoving; } - // Muove il personaggio a una certa posizione + // Move the character to a certain position void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); - // Posiziona il personaggio a una certa posizione SENZA farlo muovere + // Place the character in a certain position WITHOUT moving void SetPosition(const RMPoint &pt, int newloc = -1); - // Aspetta la fine del movimento + // Wait for the end of movement void WaitForEndMovement(CORO_PARAM); void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } @@ -502,16 +502,16 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Nome + RMString m_name; // Name private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer* m_buf; // Immagine della locazione + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer *m_buf; // Location picture - int m_nItems; // Numero oggetti -RMItem* m_items; // Oggetti + int m_nItems; // Number of objects + RMItem *m_items; // Objects - RMPoint m_curScroll; // Posizione corrente di scroll + RMPoint m_curScroll; // Current scroll position RMPoint m_fixedScroll; public: @@ -526,41 +526,41 @@ public: RMLocation(); virtual ~RMLocation(); - // Caricamento da disco + // Load variations bool Load(const char *lpszFileName); bool Load(Common::File &file); bool Load(const byte *buf); bool Load(RMDataStream &ds); bool LoadLOX(RMDataStream &ds); - // Scaricamento + // Unload void Unload(void); - // Overloading del Draw + // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Prepara un frame disegnando la locazione e tutti i suoi item + // Prepare a frame by drawing the location and all it's items void DoFrame(RMGfxTargetBuffer *bigBuf); - // Si fa dare il numero dell'item + // Return the item at a given point RMItem *WhichItemIsIn(const RMPoint &pt); - // Si fa dare un elemento dal suo codice MPAL - RMItem* GetItemFromCode(uint32 dwCode); + // Return the item based on it's MPAL code + RMItem *GetItemFromCode(uint32 dwCode); - // Setta la posizione corrente di scrolling + // Set the current scroll position void SetScrollPosition(const RMPoint &scroll); - // Setta un offset aggiuntivo di scrolling da aggiungere sempre + // Sets an additinal offset for scrolling void SetFixedScroll(const RMPoint &scroll); - // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito + // Update the scrolling coordinates to display the specified point void UpdateScrolling(const RMPoint &ptShowThis); - // Legge la posizione di scrolling corrente + // Read the current scroll position RMPoint ScrollPosition() { return m_curScroll; } - // Pausa sonoro + // Pause sound void PauseSound(bool bPause); }; @@ -589,7 +589,6 @@ public: char *operator[](int num) { return lpPeriods[num]; } }; - } // End of namespace Tony #endif /* TONY_H */ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2dbe102424..c9abea04e0 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -124,14 +124,12 @@ Common::ErrorCode TonyEngine::Init() { // Link to the custom graphics engine _theEngine.InitCustomDll(); - - // Inizializza il gfxEngine _theEngine.Init(); - // Memoria per il thumbnail + // Allocate space for thumbnails when saving the game m_curThumbnail = new uint16[160 * 120]; - // Configurazione di default + // Set up global defaults GLOBALS.bCfgInvLocked = false; GLOBALS.bCfgInvNoScroll = false; GLOBALS.bCfgTimerizedText = true; @@ -358,14 +356,14 @@ void TonyEngine::InitMusic() { m_sfx[i] = m_utilSfx[i] = NULL; } - // Crea la critical section per la musica + // Create the mutex for controlling music access // csMusic = g_system->createMutex(); - // Carica effetti sonori + // Preload sound effects // PreloadUtilSFX(0,"AccendiOpzione.ADP"); // PreloadUtilSFX(1,"ApriInterfaccia.ADP"); - PreloadUtilSFX(0, "U01.ADP"); // invertiti!! + PreloadUtilSFX(0, "U01.ADP"); // Reversed!! PreloadUtilSFX(1, "U02.ADP"); } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 32332a871d..8d4e357079 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -149,10 +149,10 @@ public: Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); - // Avverte che siamo guidati dal GDI + // Warn when are being controlled by the GDI void GDIControl(bool bCon); - // Loop che gestisce i messaggi quando siamo in pausa + // Loop that handles messages when the game is paused void PauseLoop(void); void Play(); @@ -167,7 +167,7 @@ public: void ShowLocation(void) { m_bDrawLocation = true; } void HideLocation(void) { m_bDrawLocation = false; } - // Mette o leva la pausa + // Handle pause mode void Pause(bool bPause); bool IsPaused() { return m_bPaused; } @@ -195,19 +195,19 @@ public: void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); - // Ferma tutta la parte audio + // Stop all the audio void PauseSound(bool bPause); void SetMusicVolume(int nChannel, int volume); int GetMusicVolume(int nChannel); - // Salvataggio + // Handle saving void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); static Common::String GetSaveStateFileName(int n); - // Prende il thumbnail + // Get a thumbnail void GrabThumbnail(void); uint16 *GetThumbnail(void) { return m_curThumbnail; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index c612ebbf77..04b6193cd2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -93,10 +93,10 @@ void RMTony::Init(void) { RMRes body(9999); RMDataStream ds; - // Mostra Tony di default - m_bShow=m_bShowOmbra = true; + // Tony is shown by default + m_bShow = m_bShowOmbra = true; - // Nessuna azione in attesa + // No action pending m_bActionPending = false; m_bAction = false; @@ -104,18 +104,18 @@ void RMTony::Init(void) { m_bIsTalking = false; m_bIsStaticTalk = false; - // Apre il buffer + // Opens the buffer ds.OpenBuffer(tony); - // Legge dallo stream l'oggetto corrente (cio Tony) - ReadFromStream(ds, true); // da OGX + // Reads his details from the stream + ReadFromStream(ds, true); - // Chiude il buffer + // Closes the buffer ds.Close(); - // Legge il corpo di Tony + // Reads Tony's body ds.OpenBuffer(body); - m_body.ReadFromStream(ds, true); // da OGX + m_body.ReadFromStream(ds, true); ds.Close(); m_body.SetPattern(0); @@ -124,7 +124,7 @@ void RMTony::Init(void) { void RMTony::Close(void) { - // Disalloca @@@ Manca la disallocazione di un item + // Disalloca @@@ Deallocation of missing item m_ombra.Destroy(); } @@ -140,7 +140,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { SetSpeed(GLOBALS.nCfgTonySpeed); - // Esegue il movimento normale del personaggio + // Runs the normal character movement _ctx->time = _vm->GetTime(); do { @@ -149,9 +149,9 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { } while (_ctx->time > m_nTimeLastStep + (1000 / 40)); - // Controlla se siamo alla fine del percorso + // Check if we are at the end of a path if (EndOfPath() && m_bActionPending) { - // Bisogna eseguire l'azione sulla quale abbiamo clickato + // Must perform the action on which we clicked m_bActionPending = false; } @@ -239,17 +239,16 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { - // fixme: See if hThread can be converted to uint32 uint32 pid; if (nAction == TA_COMBINE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); - // Se fallito il combine, proviamo con il ReceiveCombine + // If you failed the combine, we have RECEIVECOMBINE as a fallback if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); - // Se fallito il receive, andiamo con quelli generici + // If you failed with that, go with the generic // @@@ CombineGive! if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); @@ -313,15 +312,15 @@ void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (m_ActionItem != NULL) { - // Richiama l'MPAL per scegliere la direzione + // Call MPAL to choose the direction _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { - bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() + bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } } else { CORO_INVOKE_0(RMCharacter::Stop); @@ -406,7 +405,7 @@ void RMTony::Take(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - assert(0); // Non esiste il prende mentre sei in StandDown + assert(0); // Not while you're doing a StandDown break; case PAT_STANDUP: @@ -481,7 +480,7 @@ void RMTony::Put(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - //assert(0); // Non esiste il prende mentre sei in StandDown + //assert(0); break; case PAT_STANDUP: @@ -560,7 +559,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body m_nPatB4Talking = GetCurPattern(); m_nTalkType = nTalkType; - // Setta la direzione di parlata SOLO se non siamo in una static animation (perch l'ha gi fatto) + // Set the direction of speech ONLY if we are not in a static animation (since it would have already been done) if (!m_bIsStaticTalk) { switch (m_nPatB4Talking) { case PAT_STANDDOWN: @@ -591,12 +590,12 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } - // Mette davanti il corpo di default + // Puts the body in front by default m_bCorpoDavanti = true; } if (m_bPastorella) { - // Da pastorella, c' un solo parlato + // Talking whilst a shepherdess MainFreeze(); switch (m_TalkDirection) { case UP: @@ -967,8 +966,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - // La barba l'unico caso in cui la testa animata a parte - // mentre il corpo quello standard + // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: switch (m_TalkDirection) { case LEFT: @@ -1127,7 +1125,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headLoopPat, _ctx->bodyLoopPat)) return; - // Esegue il set dei pattern vero e proprio + // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { MainFreeze(); SetPattern(_ctx->headStartPat); @@ -1446,7 +1444,7 @@ void RMTony::EndTalk(CORO_PARAM) { if (!EndTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) return; - // Gestisce la fine di una animazione static lasciando tutto invariato + // Handles the end of an animated and static, leaving everything unchanged if (m_bIsStaticTalk) { if (m_nTalkType == TALK_CONBARBASTATIC) { MainFreeze(); @@ -1471,7 +1469,7 @@ void RMTony::EndTalk(CORO_PARAM) { return; } - // Set dei pattern + // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { MainFreeze(); SetPattern(_ctx->headEndPat); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 201803dc5f..a7109256f5 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -106,13 +106,13 @@ private: uint32 hActionThread; protected: - // Overload dell'allocazione degli sprites per cambiare il tipo + // Overload of the allocation allocation of sprites virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); - // Thread which waits for the end of an action + // Watch thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); -public: // per farlo rialzare, altrimenti private +public: enum PATTERNS { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, @@ -140,7 +140,7 @@ public: // per farlo rialzare, altrimenti private PAT_SIRIALZARIGHT, PAT_PERTERRARIGHT, - // Pastorella! + // Sheperdess! PAT_PAST_WALKUP, PAT_PAST_WALKDOWN, PAT_PAST_WALKLEFT, @@ -151,19 +151,19 @@ public: // per farlo rialzare, altrimenti private PAT_PAST_STANDLEFT, PAT_PAST_STANDRIGHT, - // Parlata + // Speech PAT_TALK_UP, PAT_TALK_DOWN, PAT_TALK_LEFT, PAT_TALK_RIGHT, - // Testa statica + // Static head PAT_TESTA_UP, PAT_TESTA_DOWN, PAT_TESTA_LEFT, PAT_TESTA_RIGHT, - // Risata + // Laugh PAT_RIDELEFT_START, PAT_RIDELEFT_LOOP, PAT_RIDELEFT_END, @@ -171,13 +171,13 @@ public: // per farlo rialzare, altrimenti private PAT_RIDERIGHT_LOOP, PAT_RIDERIGHT_END, - // Parlata da pastorella + // Speaking as a shepherdess PAT_PAST_TALKUP, PAT_PAST_TALKDOWN, PAT_PAST_TALKLEFT, PAT_PAST_TALKRIGHT, - // Spavento + // Fear PAT_SPAVENTOLEFT_START, PAT_SPAVENTOLEFT_LOOP, PAT_SPAVENTOLEFT_END, @@ -188,16 +188,16 @@ public: // per farlo rialzare, altrimenti private PAT_SPAVENTODOWN_LOOP, PAT_SPAVENTODOWN_END, - // Con oggetti: corpo completo + // With objects: full body PAT_CONBICCHIERE, PAT_CONCORDA, PAT_CONVERME, PAT_CONMARTELLO, - // Suona il fischietto + // Sound the whistle PAT_FISCHIETTORIGHT, - // Testa con barba + // Head with beard PAT_TALKBARBA_LEFT, PAT_TALKBARBA_RIGHT, @@ -205,7 +205,7 @@ public: // per farlo rialzare, altrimenti private PAT_SNIFFA_LEFT, PAT_SNIFFA_RIGHT, - // Schifato + // Disgusted PAT_SCHIFATOLEFT_START, PAT_SCHIFATOLEFT_LOOP, PAT_SCHIFATOLEFT_END, @@ -219,7 +219,7 @@ public: // per farlo rialzare, altrimenti private PAT_NAAHRIGHT_LOOP, PAT_NAAHRIGHT_END, - // Stand spaventato + // Stand scared PAT_SPAVENTOLEFT_STAND, PAT_SPAVENTORIGHT_STAND, PAT_SPAVENTODOWN_STAND, @@ -361,81 +361,80 @@ public: static void InitStatics(); RMTony(); - // Inizializza Tony + // Initialise Tony void Init(void); - // Libera tutta la memoria + // Free all memory void Close(void); - // Fa un frame di Tony, aggiornando il movimento, etc + // Tony makes a frame, updating the movement, etc. void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); - // Metodi di Draw, che controlla la variabile di show + // Draw method, which controls chararacter display virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Mostra o nascondi + // Show or hide void Show(void); void Hide(bool bShowOmbra = false); - // Si muove e fa un azione, se necessario + // Move and make an action, if necessary void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); - // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) + // Tony stops (on the right side with respect to any subject) virtual void Stop(CORO_PARAM); void StopNoAction(CORO_PARAM); - // Setta un pattern + // Set a pattern void SetPattern(int npatt, bool bPlayP0 = false); - // Legge il pattern corrente + // Reads the current pattern int GetCurPattern(); - // Attende la fine di un pattern + // Waits until the end of a pattern void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } - // Controlla se si trova in azione - bool InAction() { return (m_bActionPending&&m_Action != 0) | m_bAction; } + // Check if currently in an action + bool InAction() { return (m_bActionPending && m_Action != 0) | m_bAction; } - // Controlla se c' da aggiornare il movimento di scrolling + // Check if there needs to be an update for scrolling movement bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } - // Prende la posizione di Tony + // Returns Tony's position RMPoint Position() { return m_pos; } - // Setta la posizione di scrolling + // Set the scrolling position void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } - // Setta l'animazione di Take + // Set the take animation void Take(int nWhere, int nPart); void Put(int nWhere, int nPart); - // Start e End Talk + // Start or End Talk bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); void StartTalk(CORO_PARAM, TALKTYPE nTalkType); bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void EndTalk(CORO_PARAM); - // Start e End Static + // Start or End Static void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); void StartStatic(CORO_PARAM, TALKTYPE nTalkType); void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void EndStatic(CORO_PARAM, TALKTYPE nTalkType); - // Tony si traveste! + // Tony disguises himself! void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } int GetPastorella(void) { return m_bPastorella; } - // Esegue una azione + // Perform an action void ExecuteAction(int nAction, int nActionItem, int nParm); void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } }; - } // End of namespace Tony #endif diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index d57640fee8..9aaffefceb 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -40,9 +40,9 @@ namespace Tony { * Constructor */ RMString::RMString() { - m_string=NULL; - m_length=0; - m_realLength=0; + m_string = NULL; + m_length = 0; + m_realLength = 0; } /** @@ -188,8 +188,8 @@ const RMString& RMString::operator=(const int ch) { // Destroy the current string if (m_realLength > 0) { delete [] m_string; - m_string=NULL; - m_length=m_realLength=0; + m_string = NULL; + m_length = m_realLength = 0; } } else { // Resize if necessary @@ -213,7 +213,7 @@ void RMString::Connect(const char *str, int size) { if (size > 0) { // Calculate the new lenght - nlen=m_length+size; + nlen = m_length+size; // Resize Resize(nlen + 1, true); @@ -242,7 +242,7 @@ const RMString &RMString::operator+=(RMString &str) { * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { - Connect(str,strlen(str)); + Connect(str, strlen(str)); return *this; } @@ -385,7 +385,7 @@ void RMString::Format(const char *str, ...) { } /****************************************************************************\ -* Metodi di RMFileStreamSlow +* RMFileStreamSlow Methods \****************************************************************************/ RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { @@ -410,7 +410,7 @@ bool RMFileStreamSlow::OpenFile(Common::File &file) { bool RMFileStreamSlow::OpenFile(const char *lpFN) { - // Apre il file in lettura + // Open file for reading Common::File f; if (!f.open(lpFN)) return false; @@ -679,13 +679,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; case START: - m_pos=0; + m_pos = 0; break; case END: if (m_length == SIZENOTKNOWN) return m_pos; - m_pos=m_length; + m_pos = m_length; break; } @@ -741,8 +741,8 @@ RMPoint::RMPoint() { * Copy constructor */ RMPoint::RMPoint(const RMPoint &p) { - x=p.x; - y=p.y; + x = p.x; + y = p.y; } /** @@ -969,13 +969,13 @@ RMRect operator-(const RMRect& rc, RMPoint p) { RMRect operator+(RMPoint p, const RMRect& rc) { RMRect r(rc); - return (r+=p); + return (r += p); } RMRect operator-(RMPoint p, const RMRect& rc) { RMRect r(rc); - return (r+=p); + return (r += p); } bool RMRect::operator==(const RMRect& rc) { @@ -987,7 +987,7 @@ bool RMRect::operator!=(const RMRect& rc) { } void RMRect::NormalizeRect(void) { - SetRect(MIN(x1,x2), MIN(y1,y2), MAX(x1,x2), MAX(y1,y2)); + SetRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { @@ -1029,7 +1029,7 @@ void RMResUpdate::Init(const Common::String &fileName) { _infos = new ResUpdInfo[_numUpd]; // Load the index of the resources in the file - for (i=0; i<_numUpd; ++i) { + for (i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; info.dwRes = _hFile.readUint32LE(); @@ -1045,7 +1045,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { return NULL; uint32 i; - for (i=0; i < _numUpd; ++i) + for (i = 0; i < _numUpd; ++i) if (_infos[i].dwRes == dwRes) // Found the index break; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 1e3841c185..c823421c62 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -71,7 +71,7 @@ public: void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); void Close(void); - // Attributi + // Attributei int Length(); virtual int Pos(); @@ -86,14 +86,14 @@ public: friend RMDataStream &operator>>(RMDataStream &df, int &var); friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - // Lettura generica + // General read virtual bool Read(void *buf, int size); // Skipping & Seeking virtual RMDataStream &operator+=(int nBytes); virtual int Seek(int nBytes, RMDSPos origin = CUR); - // Gestione errori + // Error handling void SetError(int ecode); int GetError(); bool IsError(); @@ -111,7 +111,7 @@ public: RMFileStream(); virtual ~RMFileStream(); - // Apre lo stream da file + // Methods for opening file bool OpenFile(const char *lpFN); bool OpenFile(Common::File &file); @@ -165,7 +165,7 @@ public: RMString(const char *str); RMString(const int ch); - // Metodi generici + // General methods int Length() const; void Compact(); @@ -196,10 +196,10 @@ public: friend RMString operator+(RMString &str, const char *s); friend RMString operator+(const char *s, RMString &str); - // Estrazione da data stream + // Extraction from data streams friend RMDataStream& operator>>(RMDataStream& df, RMString &var); - // Formattazione di stringa + // String formatting void Format(const char *str, ...); private: @@ -220,11 +220,11 @@ public: RMPoint(const RMPoint &p); RMPoint(int x1, int y1); - // Copia + // Copy RMPoint& operator=(RMPoint p); // Set - void Set(int x1, int y1) { x=x1; y=y1; } + void Set(int x1, int y1) { x = x1; y = y1; } // Offset void Offset(int xOff, int yOff); @@ -235,7 +235,7 @@ public: RMPoint &operator-=(RMPoint p); RMPoint operator-(); - // Confronti + // Comparison bool operator==(RMPoint p); bool operator!=(RMPoint p); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 26dbaf88fc..481393c5ed 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -245,9 +245,9 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { else curv = v; - sommab += cursrc[curv*RM_BBX + u] & 0x1F; - sommag += (cursrc[curv*RM_BBX + u] >> 5) & 0x1F; - sommar += (cursrc[curv*RM_BBX + u] >> 10) & 0x1F; + sommab += cursrc[curv * RM_BBX + u] & 0x1F; + sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; + sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); diff --git a/engines/tony/window.h b/engines/tony/window.h index 9483f693ab..73cc6d2005 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -78,21 +78,21 @@ public: RMWindow(); ~RMWindow(); - // Initialization + // Initialisation void Init(/*HINSTANCE hInst*/); void InitDirectDraw(void); void Close(void); - // Repaint grafico tramite DirectDraw + // Drawing void Repaint(void); - // Switch tra windowed e fullscreen + // Switch between windowed and fullscreen void SwitchFullscreen(bool bFull) {} - // Legge il prossimo frame + // Reads the next frame void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); - // Avverte di grabbare un thumbnail per il salvataggio + // Request a thumbnail be grabbed during the next frame void GrabThumbnail(uint16 *buf); int getFps() const { return fps; } -- cgit v1.2.3 From 6f6486e5896d8af782aaba408b1fe5ae53021c7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 13:56:33 +1000 Subject: TONY: Endian fix --- engines/tony/loc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 722116c47c..ef59b3f916 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1923,7 +1923,7 @@ void RMGameBoxes::LoadState(byte *state) { int nloc, nbox; // Load number of items - nloc = *(int*)state; + nloc = READ_LE_UINT32(state); state += 4; assert(nloc <= m_nLocBoxes); -- cgit v1.2.3 From 8b9831a50250ccc6b605058a702bb5f617a83978 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 15:28:48 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/font.cpp | 191 ++++++++++++++---------------- engines/tony/font.h | 81 ++++++------- engines/tony/game.cpp | 68 +++++------ engines/tony/game.h | 9 +- engines/tony/gfxcore.cpp | 285 ++++++++++++++++++++------------------------- engines/tony/gfxcore.h | 32 ++--- engines/tony/gfxengine.cpp | 86 +++++++------- engines/tony/globals.h | 8 +- engines/tony/inventory.cpp | 92 +++++++-------- engines/tony/inventory.h | 50 ++++---- 10 files changed, 424 insertions(+), 478 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 91d6708a20..972bd081bf 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -37,7 +37,7 @@ namespace Tony { /****************************************************************************\ -* Metodi di RMFont +* RMFont Methods \****************************************************************************/ RMFont::RMFont() { @@ -48,15 +48,13 @@ RMFont::~RMFont() { Unload(); } -/****************************************************************************\ -* -* Function: void RMFont::Load(byte *buf, int nChars, int dimx, int dimy); -* -* Description: Carica un font da buffer -* -* Input: byte *buf Buffer contenente il font -* int nChars Numero di caratteri (max 256) -* int dimx,dimy Dimensione in pixel di un carattere + +/** + * Dumps a font to a buffer + * @param buf Buffer contenente il font + * @param nChars Numero di caratteri (max 256) + * @param dimx X dimension in pixels + * @param dimy Y dimension in pixels * \****************************************************************************/ @@ -84,9 +82,9 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes } #endif - // Carichiamoce 'sto font + // Initialisation the fonts for (int i = 0; i < nChars; i++) { - // Inizializza il buffer con le lettere + // Initialise the buffer with the letters m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); m_letter[i].LoadPaletteWA(palResID); } @@ -118,15 +116,15 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { RMFontPrimitive *prim; int nLett; - // Converte da carattere a lettera + // Convert from character to glyph index nLett = ConvertToLetter(bChar); assert(nLett < nLetters); - // Crea la primitiva per il font + // Create primitive font prim = new RMFontPrimitive(this); prim->m_nChar = nLett; - // Si fa' dare la lunghezza della lettera in pixel + // Get the length of the character in pixels nLength = LetterLength(bChar); return prim; @@ -140,7 +138,7 @@ void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) CORO_BEGIN_CODE(_ctx); - // Richiama la Draw della lettera assegnata alla primitiva + // Call the draw method of the letter assigned to the primitive if (prim->m_nChar != -1) CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); @@ -190,7 +188,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { int i; byte pal[768 * 3]; - // Controlla se siamo gia' sul colore giusto + // Check if we are already on the right colour if (m_r == r1 && m_g == g1 && m_b == b1) return; @@ -198,7 +196,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { m_g = g1; m_b = b1; - // Costruisce la nuova palette per il font + // Constructs a new paletter for the font for (i = 1; i < 16; i++) { pal[i * 3 + 0] = r >> 16; pal[i * 3 + 1] = g >> 16; @@ -213,20 +211,20 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { pal[15 * 3 + 1] += 8; pal[15 * 3 + 2] += 8; - // La mette in tutte le lettere + // Puts in all the letters for (i = 0; i < nLetters; i++) m_letter[i].LoadPaletteWA(pal); } /***************************************************************************\ -* Metodi di RMFontParla +* RMFontParla Methods \****************************************************************************/ void RMFontParla::Init(void) { int i; - // bernie: numero di caratteri nel font + // bernie: Number of characters in the font int nchars = 112 // base + 18 // polish @@ -237,7 +235,7 @@ void RMFontParla::Init(void) { Load(RES_F_PARL, nchars, 20, 20); - // Inizializziamo le tabelline del cazzo + // Initialise the f**king table lDefault = 13; hDefault = 18; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); @@ -265,9 +263,9 @@ void RMFontParla::Init(void) { cTable['<'] = 69; cTable['>'] = 70; cTable['!'] = 71; - //cTable['!'] = 72; Esclamativo alla rovescia + //cTable['!'] = 72; Exclamation countdown cTable['?'] = 73; - //cTable['?'] = 74; Interrogativo alla rovescia + //cTable['?'] = 74; Question down cTable['('] = 75; cTable[')'] = 76; cTable['\"'] = 77; @@ -295,20 +293,20 @@ void RMFontParla::Init(void) { cTable[(byte)''] = 97; cTable[(byte)''] = 98; cTable[(byte)''] = 99; - //cTable[' '] = 100; e cerchietto - //cTable[' '] = 101; i cerchietto - //cTable[' '] = 102; o cerchietto - //cTable[' '] = 103; u cerchietto + //cTable[' '] = 100; e circlet + //cTable[' '] = 101; i circlet + //cTable[' '] = 102; o circlet + //cTable[' '] = 103; u circlet cTable[(byte)''] = 104; cTable[(byte)''] = 105; cTable[(byte)''] = 106; cTable[(byte)''] = 107; cTable[(byte)''] = 108; cTable[(byte)''] = 109; - //cTable[''] = 110; integrale + //cTable[''] = 110; integral cTable['\''] = 111; - // Un po' di lunghezze + // Little lengths lTable[' '] = 9; lTable['\''] = 5; lTable['.'] = 5; @@ -387,9 +385,9 @@ void RMFontParla::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; @@ -627,13 +625,13 @@ void RMFontParla::Init(void) { /***************************************************************************\ -* Metodi di RMFontMacc +* RMFontMacc Methods \****************************************************************************/ void RMFontMacc::Init(void) { int i; - // bernie: numero di caratteri nel font + // bernie: Number of characters in the font int nchars = 102 // base + 18 // polish @@ -693,16 +691,16 @@ void RMFontMacc::Init(void) { cTable[(byte)''] = 88; cTable[(byte)''] = 89; cTable[(byte)''] = 90; - //cTable[(byte)''] = 91; // e col pallino + //cTable[(byte)''] = 91; // e with ball cTable[(byte)''] = 92; cTable[(byte)''] = 93; - //cTable[(byte)''] = 94; // i col pallino + //cTable[(byte)''] = 94; // i with ball cTable[(byte)''] = 95; cTable[(byte)''] = 96; - //cTable[(byte)''] = 97; // o col pallino + //cTable[(byte)''] = 97; // o with ball cTable[(byte)''] = 98; cTable[(byte)''] = 99; - //cTable[(byte)''] = 100; // u col pallino + //cTable[(byte)''] = 100; // u with ball cTable[(byte)''] = 101; if (_vm->getLanguage() == Common::PL_POL) { @@ -750,10 +748,9 @@ void RMFontMacc::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = 120; cTable[(byte)''] = 121; cTable[(byte)''] = 122; @@ -992,13 +989,13 @@ void RMFontMacc::Init(void) { } /***************************************************************************\ -* Metodi di RMFontCredits +* RMFontCredits Methods \****************************************************************************/ void RMFontCredits::Init(void) { int i; - // bernie: numero di caratteri nel font + // bernie: Number of characters in the font int nchars = 112 // base + 18 // polish @@ -1200,12 +1197,10 @@ void RMFontCredits::Init(void) { lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; cTable[(byte)''] = 132; @@ -1465,7 +1460,7 @@ void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { void RMFontObj::Init(void) { int i; - //bernie: numero di caratteri nel font (solo maiuscolo) + //bernie: Number of characters in the font (solo maiuscolo) int nchars = 85 // base + 9 // polish @@ -1477,7 +1472,7 @@ void RMFontObj::Init(void) { Load(RES_F_OBJ, nchars, 25, 30); - // Inizializziamo le tabelline del cazzo + // Initialise the f**king table lDefault = 26; hDefault = 30; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); @@ -1502,7 +1497,7 @@ void RMFontObj::Init(void) { cTable['-'] = 40; cTable['+'] = 41; cTable['!'] = 42; - // cTable['!'] = 43; Esclamativo alla rovescia + // cTable['!'] = 43; Exclamation countdown cTable['?'] = 44; //cTable['?'] = 45; Interrogativo alla rovescia cTable['/'] = 46; @@ -1523,7 +1518,7 @@ void RMFontObj::Init(void) { cTable[(byte)''] = 61; cTable[(byte)''] = 62; cTable[(byte)''] = 63; - //cTable[(byte)''] = 64; integrale + //cTable[(byte)''] = 64; integral cTable[(byte)''] = 65; cTable[(byte)''] = 66; cTable[(byte)''] = 67; @@ -1533,19 +1528,19 @@ void RMFontObj::Init(void) { cTable[(byte)''] = 71; cTable[(byte)''] = 72; cTable[(byte)''] = 73; - //cTable[(byte)' '] = 74; e cerchietto + //cTable[(byte)' '] = 74; e circlet cTable[(byte)''] = 75; cTable[(byte)''] = 76; - //cTable[(byte)' '] = 77; i cerchietto + //cTable[(byte)' '] = 77; i circlet cTable[(byte)''] = 78; cTable[(byte)''] = cTable[(byte)''] = 79; - //cTable[(byte)' '] = 80; o cerchietto + //cTable[(byte)' '] = 80; o circlet cTable[(byte)''] = 81; cTable[(byte)''] = cTable[(byte)''] = 82; - //cTable[' '] = 83; u cerchietto + //cTable[' '] = 83; u circlet //cTable[' '] = 84; y dieresi - /* Un po' di lunghezze */ + /* Little lengths */ lTable[' '] = 11; lTable['.'] = 8; lTable['-'] = 12; @@ -1635,9 +1630,9 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = cTable[(byte)''] = 85; lTable[(byte)''] = lTable[(byte)''] = 20; @@ -1749,7 +1744,7 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::FR_FRA) { // French - // traduci le lettere accentate in lettere normali + // Translate accented characters as normal letters cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; @@ -1778,7 +1773,7 @@ void RMFontObj::Init(void) { /****************************************************************************\ -* Metodi di RMText +* RMText Methods \****************************************************************************/ RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; @@ -1789,10 +1784,10 @@ void RMText::InitStatics() { } RMText::RMText() { - // Colore di default: bianco + // Default colour: white m_r = m_g = m_b = 255; - // Lunghezza di default + // Default length maxLineLength = 350; m_bTrasp0 = true; @@ -1820,14 +1815,13 @@ void RMText::SetMaxLineLength(int max) { } void RMText::RemoveThis(CORO_PARAM, bool &result) { -// Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso -// etc. + // Here we can do checks on the number of frames, time spent, etc. result = true; } void RMText::WriteText(const RMString &text, int nFont, int *time) { - // Inizializza i font (una volta sola) + // Initialises the font (only once) if (m_fonts[0] == NULL) { m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); @@ -1853,18 +1847,18 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { char *string; int numlines; - // Setta il colore di base + // Set the base colour font->SetBaseColor(m_r, m_g, m_b); - // Si autodistrugge il buffer prima di iniziare + // Destroy the buffer before starting Destroy(); - // Se la stringa vuota, non fare nulla + // If the string is empty, do nothing if (text == NULL || text[0] == '\0') return; - // Divide la frase in linee. In questo ciclo, X contiene la lunghezza massima raggiunta da una linea - // e I il numero delle linee + // Divide the words into lines. In this cycle, X contains the maximum length reached by a line, + // and the number of lines string = p = text; i = j = x = 0; while (*p != '\0') { @@ -1873,14 +1867,11 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { j -= font->StringLen(*p, p[1]); if (j > x) x = j; - // Torna indietro al primo spazio utile + // Back to the first usable space // - // BERNIE: nella versione originale le frasi contenenti - // parole che superano la larghezza di una riga causavano - // l'interruzione dell'intera frase. - // Questo workaround e' parziale: la parola troppo lunga - // viene spezzata bruscamente e si perde una lettera. - // Oltre allo spazio e' ammesso il wrap sul carattere '-'. + // BERNIE: In the original, sentences containing words that exceed the + // width of a line caused discontinuation of the whole sentence. + // This workaround has the partial word broken up so it will still display // old_p = p; while (*p != ' ' && *p != '-' && p > string) p--; @@ -1888,7 +1879,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { if (p == string) p = old_p; - // Controlla se sono tutti spazi fino alla fine + // Check if there are any blanks to end while (*p == ' ' && *p != '\0') p++; if (*p == '\0') break; @@ -1905,15 +1896,13 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { i++; numlines = i; - // X=Lunghezza della linea piu' lunga. Controlla se puo' essere puttata a X1 - //x+=font->StringLen(-1)+1; // Meglio esagerare per sicurezza x += 8; - // Posizione di partenza per la surface: X1,Y + // Starting position for the surface: X1, Y width = x; height = (numlines - 1) * font->LetterHeight() + font->m_fontDimy; - // Crea la surface + // Create the surface Create(width, height); //AddPrim(new RMGfxPrimitive(&m_clear)); Common::fill(m_buf, m_buf + width * height * 2, 0); @@ -1923,7 +1912,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { y = 0; numchar = 0; for (; i > 0; i--) { - // Misura la lunghezza della linea + // Measure the length of the line x = 0; j = font->StringLen(RMString(p)); @@ -1974,7 +1963,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { } void RMText::ClipOnScreen(RMGfxPrimitive *prim) { - // Cerca di non farlo uscire dallo schermo + // Don't let it go outside the screen if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; @@ -1986,14 +1975,14 @@ void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - // Allinea orizzontalmente + // Horizontally if (aHorType == HCENTER) prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); else if (aHorType == HRIGHT) prim->Dst().TopLeft() -= RMPoint(m_dimx, 0); - // Alinea verticalemente + // Vertically if (aVerType == VTOP) { } else if (aVerType == VCENTER) { @@ -2011,7 +2000,7 @@ void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } /****************************************************************************\ -* Metodi di RMTextDialog +* RMTextDialog Methods \****************************************************************************/ RMTextDialog::RMTextDialog() : RMText() { @@ -2028,7 +2017,7 @@ RMTextDialog::RMTextDialog() : RMText() { hCustomSkip2 = CORO_INVALID_PID_VALUE; m_input = NULL; - // Crea l'evento di fine displaying + // Create the event for displaying the end hEndDisplay = CoroScheduler.createEvent(false, false); } @@ -2093,7 +2082,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Presume successful result result = true; - // Frase NON di background + // Don't erase the background if (m_bSkipStatus) { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (GLOBALS.bCfgTimerizedText) { @@ -2111,7 +2100,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) return; } - // Frase di background + // Erase the background else { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (!m_bForceNoTime) @@ -2119,7 +2108,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { return; } - // Se il tempo forzato + // If time is forced if (m_bForceTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2185,7 +2174,7 @@ void RMTextDialog::SetInput(RMInput *input) { } /****************************************************************************\ -* Metodi di RMTextDialogScrolling +* RMTextDialogScrolling Methods \****************************************************************************/ RMTextDialogScrolling::RMTextDialogScrolling() { @@ -2298,7 +2287,7 @@ void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (m_buf == NULL) return; - // Setta come coordinate destinazione quelle del mouse + // Set the destination coordinates of the mouse prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::Draw, bigBuf, prim); @@ -2327,7 +2316,7 @@ bool RMTextItemName::IsNormalItemSelected() { /****************************************************************************\ -* Metodi di RMDialogChoice +* RMDialogChoice Methods \****************************************************************************/ RMDialogChoice::RMDialogChoice() { @@ -2388,11 +2377,11 @@ void RMDialogChoice::SetNumChoices(int num) { m_numChoices = num; m_curAdded = 0; - // Alloca lo spazio per le stringhe disegnate + // Allocate space for drawn strings m_drawedStrings = new RMText[num]; m_ptDrawStrings = new RMPoint[num]; - // Le inizializza + // Initialisation for (i = 0; i < m_numChoices; i++) { m_drawedStrings[i].SetColor(0, 255, 0); m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); @@ -2402,7 +2391,7 @@ void RMDialogChoice::SetNumChoices(int num) { } void RMDialogChoice::AddChoice(const RMString &string) { - // Si disegna la stringa + // Draw the string assert(m_curAdded < m_numChoices); m_drawedStrings[m_curAdded++].WriteText(string, 0); } diff --git a/engines/tony/font.h b/engines/tony/font.h index dab07b79b3..b7488399a4 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -43,7 +43,7 @@ class RMLocation; class RMPointer; /** - * Gestisce un font, in cui ha varie surface per ogni lettera + * Manages a font, in which there is a different surface for each letter */ class RMFont : public RMGfxTaskSetPrior { protected: @@ -68,18 +68,18 @@ private: }; protected: - // Caricamento del font + // Loads the font void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - // Scaricamente del font (anche da distruttore) + // Remove the font void Unload(void); protected: - // Conversione (da overloadare) + // Conversion form character to font index virtual int ConvertToLetter(byte nChar) = 0; - // Lunghezza dei caratteri (da overloadare) + // Character width virtual int LetterLength(byte nChar, byte nNext = 0) = 0; public: @@ -89,17 +89,17 @@ public: RMFont(); virtual ~RMFont(); - // Inizializzazione e chiusura + // Initialisation and closing virtual void Init(void) = 0; virtual void Close(void); - // Funzione del task da overloadare + // Drawing virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); - // Crea una primitiva per una lettera + // Create a primitive for a letter RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); - // Lunghezza in pixel di una stringa con il font corrente + // Length in pixels of a string with the current font int StringLen(const RMString &text); int StringLen(char bChar, char bNext = 0); }; @@ -125,7 +125,7 @@ protected: signed char l2Table[256][256]; protected: - // Overload dei metodi + // Overloaded methods int ConvertToLetter(byte nChar) { return cTable[nChar]; } @@ -170,7 +170,7 @@ public: }; /** - * Gestisce una scritta su schermo, con tutte le possibilita' di formattazione disponibile + * Manages writing text onto9 the screen */ class RMText : public RMGfxWoodyBuffer { private: @@ -206,27 +206,26 @@ public: static void InitStatics(); static void Unload(); - // Setta il tipo di allineamento + // Set the alignment type void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType = aHor; aVerType = aVer; } - // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) + // Sets the maximum length of a line in pixels (used to format the text) void SetMaxLineLength(int max); - // Scrive un testo + // Write the text void WriteText(const RMString &text, int font, int *time = NULL); void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST + // Overloaded function to decide when you delete the object from the OT list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading del Draw per centrare la scritta, se necessario + // Overloading of the Draw to center the text, if necessary virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Setta il colore di base + // Set the base colour void SetColor(byte r, byte g, byte b) { m_r = r; m_g = g; @@ -235,7 +234,7 @@ public: }; /** - * Gestisce il testo di un dialogo + * Manages text in a dialog */ class RMTextDialog : public RMText { protected: @@ -257,27 +256,25 @@ public: RMTextDialog(); virtual ~RMTextDialog(); - // Scrive un testo + // Write the text void WriteText(const RMString &text, int font, int *time = NULL); void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST + // Overloaded function to decide when you delete the object from the OT list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading della funzione di deregistrazione, utilizzata per capire - // quando ci leviamo di torno + // Overloaded de-registration virtual void Unregister(void); - // Overloading del Draw per centrare la scritta, se necessario + // Overloading of the Draw to center the text, if necessary virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Setta la posizione + // Set the position void SetPosition(const RMPoint &pt) { dst = pt; } - // Aspetta che venga finita la visualizzazione + // Waiting void WaitForEndDisplay(CORO_PARAM); void SetCustomSkipHandle(uint32 hCustomSkip); void SetCustomSkipHandle2(uint32 hCustomSkip); @@ -288,7 +285,7 @@ public: void ForceNoTime(void); void SetAlwaysDisplay(void); - // Setta il dispositivo di input, per permettere skip da mouse + // Set the input device, to allow skip from mouse void SetInput(RMInput *input); void Show(void); @@ -311,12 +308,9 @@ public: }; -/****************************************************************************\ -* class RMTextItemName -* -------------------- -* Description: Gestisce il nome dell'oggetto selezionato su schermo -\****************************************************************************/ - +/** + * Manages the name of a selected item on the screen + */ class RMTextItemName : protected RMText { protected: RMPoint m_mpos; @@ -373,31 +367,30 @@ public: void Unregister(void); public: - // Inizializzazione + // Initialisation RMDialogChoice(); virtual ~RMDialogChoice(); - // Inizializzazione e chiusura + // Initialisation and closure void Init(void); void Close(void); - // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte - // con AddChoice() + // Sets the number of possible sentences, which then be added with AddChoice() void SetNumChoices(int num); - // Aggiunge una stringa con la scelta + // Adds a string with the choice void AddChoice(const RMString &string); - // Mostra e nasconde la scelta, con eventuali animazioni - // NOTA: Se non viene passato parametro alla Show(), obbligo del - // chiamante assicurarsi che la classe venga inserita alla OTlist + // Show and hide the selection, with possible animations. + // NOTE: If no parameter is passed to Show(), it is the obligation of + // caller to ensure that the class is inserted into OT list void Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); void Hide(CORO_PARAM); - // Polling di aggiornamento + // Polling Update void DoFrame(CORO_PARAM, RMPoint ptMousePos); - // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata + // Returns the currently selected item, or -1 if none is selected int GetSelection(void); }; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 3551f55c83..4fe1ea374e 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,7 +43,7 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Funzioni globali per la DLL Custom */ +/* Global functions */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { @@ -119,7 +119,7 @@ void MainSetPalesati(bool bPalesati) { } /****************************************************************************\ -* Metodi di RMOptionButton +* RMOptionButton Methods \****************************************************************************/ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { @@ -192,7 +192,7 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { } /****************************************************************************\ -* Metodi di RMOptionSlide +* RMOptionSlide Methods \****************************************************************************/ RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int slideSize) { @@ -240,7 +240,7 @@ RMOptionSlide::~RMOptionSlide() { bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; - // Doframe dei bottoni + // Do the button DoFrame's m_PushLeft->DoFrame(mousePos, bLeftClick, bRightClick); m_PushRight->DoFrame(mousePos, bLeftClick, bRightClick); @@ -317,7 +317,7 @@ void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { /****************************************************************************\ -* Metodi di RMOptionScreen +* RMOptionScreen Methods \****************************************************************************/ RMOptionScreen::RMOptionScreen(void) { @@ -983,7 +983,7 @@ bool RMOptionScreen::Close(void) { if (m_FadeStep != 6) return false; - // Inizia il fade out + // Start fade out m_FadeStep++; m_FadeTime = _vm->GetTime(); return true; @@ -994,7 +994,7 @@ bool RMOptionScreen::IsClosing(void) { } int RMOptionScreen::Priority() { - // Appena sotto il mouse + // Just below the mouse return 190; } @@ -1023,11 +1023,11 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { CORO_BEGIN_CODE(_ctx); - // Se non completamente aperto, non fare nulla + // If it is fully open, do nothing if (m_FadeStep != 6) return; - // Legge l'input + // Reads input _ctx->mousePos = input->MousePos(); _ctx->bLeftClick = input->MouseLeftClicked(); _ctx->bRightClick = input->MouseRightClicked(); @@ -1040,14 +1040,14 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else { _ctx->bRefresh |= m_ButtonExit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - // Controlla se ha clickato sull'uscita + // Check if you have clicked on the output if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - // bottoni senza grafica... + // Buttons without graphics... m_ButtonGameMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); m_ButtonGfxMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); m_ButtonSoundMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - // bottoni con grafica + // Buttons with graphics if (!m_bNoLoadSave) { if (!_vm->getIsDemo()) { _ctx->bRefresh |= m_ButtonLoad->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); @@ -1097,7 +1097,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } - /**************** STATO BOTTONI **************/ + /**************** State Buttons **************/ if (m_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { if (m_EditName[0] != '\0') { @@ -1141,7 +1141,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { if (strlen(m_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); - // ANNULLA + // Cancel if (KEYPRESS(Common::KEYCODE_ESCAPE)) { m_bEditSaveName = false; _ctx->bRefresh = true; @@ -1158,7 +1158,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_ButtonExit->IsActive()) { if (m_bLoadMenuOnly) { - // Se solo il menu di loading, chiudiamo + // If only the loading menu, close Close(); } else { CORO_INVOKE_1(ChangeState, m_nLastState); @@ -1183,13 +1183,13 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) if (m_ButtonSave_States[_ctx->i]->IsActive()) { - // C' da effettuare il salvataggio o il caricamento!!!! + // There by saving or loading!!! if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento CORO_INVOKE_1(_vm->LoadState, m_statePos + _ctx->i); Close(); } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { - // Attiva la modalit di editing + // Turn on edit mode m_bEditSaveName = true; m_nEditPos = _ctx->i; strcpy(m_EditName, m_curThumbName[_ctx->i]); @@ -1241,7 +1241,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } if (m_nState == MENUGFX) { - // Queste opzioni hanno effetto immediato + // These options take effect immediately if (m_ButtonGfx_Anni30->IsActive()) GLOBALS.bCfgAnni30 = true; else @@ -1288,7 +1288,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; if (m_FadeStep == 1) { - // Discesa veloce + // Downhill fast if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else @@ -1298,11 +1298,11 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - // Setta la parte da disegnare per lo scrolling + // Set the part to draw the scrolling prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 2) { - // Rimbalzo 1 + // Bounce 1 m_FadeY -= FADE_SPEED / 2 * SYNC; if (m_FadeY < 400) { m_FadeY = 400; @@ -1321,7 +1321,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 4) { - // Rimbalzo 1 - 2 + // Bounce 1 - 2 m_FadeY += FADE_SPEED / 3 * SYNC; if (m_FadeY > 420) { m_FadeY = 420; @@ -1357,11 +1357,11 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 9) { - // Ciao ciao! + // Hello hello! m_bExit = true; m_FadeStep = 0; - // Libera la memoria + // Free memory CloseState(); return; @@ -1391,7 +1391,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS Common::InSaveFile *f; char id[4]; - // Pulisce la destinazione + // Cleans the destination Common::fill(lpDestBuf, lpDestBuf + 160 * 120 * 2, 0); name = "No name"; diff = 10; @@ -1463,7 +1463,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS /****************************************************************************\ -* Metodi di RMPointer +* RMPointer Methods \****************************************************************************/ RMPointer::RMPointer() { @@ -1525,7 +1525,7 @@ void RMPointer::Close(void) { int RMPointer::Priority() { - // Priorita' minima: davanti a tutto + // Pointer has minimum priority so it will be drawn last return 200; } @@ -1536,15 +1536,15 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_BEGIN_CODE(_ctx); - // Controlla il pointer + // Check the pointer _ctx->n = m_nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // Copia le coordinate di destinazione nella primitiva + // Copy the destination coordinates in the primitive prim->SetDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { - // Richiama il draw del puntatore + // Call the Draw method of the poitner prim->Dst() -= m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { @@ -1553,7 +1553,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (m_nCurSpecialPointer == PTR_CUSTOM) CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else - // Richiama il draw sul puntatore speciale + // Call the draw on the special pointer CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->Draw, bigBuf, prim); } } @@ -1562,16 +1562,16 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim } void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { - // Si aggiunge alla lista delle primitive + // Add it to the list of primitives bigBuf->AddPrim(new RMGfxPrimitive(this)); - // Se c'e' un puntatore speciale, fa la DoFrame + // If there is a special pointer, does DoFrame if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); } void RMPointer::RemoveThis(CORO_PARAM, bool &result) { - // Si leva sempre dalla lista di OT, per supportare la DisableInput + // Always remove from the OT list, to support disabling the pointer result = true; } diff --git a/engines/tony/game.h b/engines/tony/game.h index 160637d9c2..532a457b8f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -270,12 +270,12 @@ public: bool Close(); bool IsClosing(); - // Metodi in overloading da RMGfxTask - int Priority(); + // Overloaded methods + virtual int Priority(); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void RemoveThis(CORO_PARAM, bool &result); - // Polling per l'option screen + // Polling for the option screen void DoFrame(CORO_PARAM, RMInput *m_input); // Retrieves a savegame's thumbnail, description, and difficulty level @@ -288,10 +288,9 @@ protected: void CloseState(void); void ChangeState(CORO_PARAM, STATE newState); - // Ridisegna tutto il menu delle opzioni + // Repaaint the options menu void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - }; } // End of namespace Tony diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index ae68860e79..8c992eb150 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -33,7 +33,7 @@ namespace Tony { /****************************************************************************\ -* Metodi di RMGfxTask +* RMGfxTask Methods \****************************************************************************/ RMGfxTask::RMGfxTask() { @@ -51,7 +51,7 @@ void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { /****************************************************************************\ -* Metodi di RMGfxTaskSetPrior +* RMGfxTaskSetPrior Methods \****************************************************************************/ void RMGfxTaskSetPrior::SetPriority(int nPrior) { @@ -60,7 +60,7 @@ void RMGfxTaskSetPrior::SetPriority(int nPrior) { /****************************************************************************\ -* Metodi di RMGfxBuffer +* RMGfxBuffer Methods \****************************************************************************/ RMGfxBuffer::RMGfxBuffer() { @@ -74,17 +74,17 @@ RMGfxBuffer::~RMGfxBuffer() { } void RMGfxBuffer::Create(int dimx, int dimy, int nBpp, bool bUseDDraw) { - // Distruggi il buffer se esiste di gia' + // Destroy the buffer it is already exists if (m_buf != NULL) Destroy(); - // Copia i parametri nei membri privati + // Copy the parameters in the private members m_dimx = dimx; m_dimy = dimy; m_bUseDDraw = bUseDDraw; if (!m_bUseDDraw) { - // Alloca il buffer + // Allocate a buffer m_origBuf = m_buf = new byte[m_dimx * m_dimy * nBpp / 8]; assert(m_buf != NULL); Common::fill(m_origBuf, m_origBuf + m_dimx * m_dimy * nBpp / 8, 0); @@ -102,13 +102,13 @@ void RMGfxBuffer::Destroy(void) { void RMGfxBuffer::Lock(void) { if (m_bUseDDraw) { - // Gestisce l'accelerazione + // Manages acceleration } } void RMGfxBuffer::Unlock(void) { if (m_bUseDDraw) { - // Gestisce l'accelerazione + // Manages acceleration } } @@ -130,26 +130,14 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: -* -* Description: -* -* Input: -* -* Return: -* +* RMGfxSourceBuffer Methods \****************************************************************************/ int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { Create(dimx, dimy, Bpp()); CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); - // Richiama la funzione di preparazione della surface (ereditata) + // Invokes the method for preparing the surface (inherited) PrepareImage(); return dimx * dimy * Bpp() / 8; @@ -160,7 +148,7 @@ void RMGfxSourceBuffer::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPal Create(dimx, dimy, Bpp()); ds.Read(m_buf, dimx * dimy * Bpp() / 8); - // Richiama la funzione di preparazione della surface (ereditata) + // Invokes the method for preparing the surface (inherited) PrepareImage(); } @@ -168,7 +156,7 @@ RMGfxSourceBuffer::~RMGfxSourceBuffer() { } void RMGfxSourceBuffer::PrepareImage(void) { - // Non fa nulla: puo' essere overloadata se necessaria + // Do nothing. Can be overloaded if necessary } bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { @@ -226,23 +214,20 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int return true; } -/****************************************************************************\ -* -* Function: void RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy); -* -* Description: Carica una surface partendo dall'ID della risorsa -* -* Input: uint32 resID ID della risorsa -* int dimx, dimy Dimensione del buffer -* -\****************************************************************************/ -int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +/** + * Initialises a surface by resource Id + * + * @param resID Resource ID + * @param dimx Buffer X dimension + * @param dimy Buffer Y dimension + */ + int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } /****************************************************************************\ -* Metodi di RMGfxWoodyBuffer +* RMGfxWoodyBuffer Methods \****************************************************************************/ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { @@ -255,10 +240,10 @@ void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitiv CORO_BEGIN_CODE(_ctx); - // Prima si fa disegnare tramite la propria OT list + // Draw the OT list CORO_INVOKE_0(DrawOT); - // Poi disegna se stesso nel target buffer + // Draw itself into the target buffer CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); CORO_END_CODE; @@ -275,7 +260,7 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) /****************************************************************************\ -* Metodi di RMGfxTargetBuffer +* RMGfxTargetBuffer Methods \****************************************************************************/ RMGfxClearTask RMGfxTargetBuffer::taskClear; @@ -325,37 +310,37 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { _ctx->prev = NULL; _ctx->cur = otlist; - // Lock del buffer per accederci + // Lock the buffer to access it Lock(); // g_system->lockMutex(csModifyingOT); while (_ctx->cur != NULL) { - // Richiama la draw sul task, passandogli una copia della primitiva + // Call the task Draw method, passing it a copy of the original _ctx->myprim = _ctx->cur->prim->Duplicate(); CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); delete _ctx->myprim; - // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist + // Check if it's time to remove the task from the OT list CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); if (_ctx->result) { - // Deregistra il task + // De-register the task _ctx->cur->prim->m_task->Unregister(); - // Cancella il task liberando la memoria + // Delete task, freeing the memory delete _ctx->cur->prim; _ctx->next = _ctx->cur->next; delete _ctx->cur; - // Se era il primo elemento, aggiorna la testa della lista + // If it was the first item, update the list head if (_ctx->prev == NULL) otlist = _ctx->next; - // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente + // Otherwise update the next pinter of the previous item else _ctx->prev->next = _ctx->next; _ctx->cur = _ctx->next; } else { - // Aggiorna il puntatore al precedente e scorre la lista + // Update the pointer to the previous item, and the current to the next _ctx->prev = _ctx->cur; _ctx->cur = _ctx->cur->next; } @@ -363,7 +348,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // g_system->unlockMutex(csModifyingOT); - // Unlock dopo la scrittura + //Unlock after writing Unlock(); CORO_END_CODE; @@ -375,19 +360,19 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { // g_system->lockMutex(csModifyingOT); - // Avverte che e' in lista di OT + // Warn of the OT listing prim->m_task->Register(); - // Controlla la sua priorita' + // Check the priority nPrior = prim->m_task->Priority(); n = new OTList(prim); - // Lista vuota + // Empty list if (otlist == NULL) { otlist = n; otlist->next = NULL; } - // Inserimento in testa + // Inclusion in the head else if (nPrior < otlist->prim->m_task->Priority()) { n->next = otlist; otlist = n; @@ -409,7 +394,7 @@ void RMGfxTargetBuffer::AddClearTask(void) { /****************************************************************************\ -* Metodi di RMGfxSourceBufferPal +* RMGfxSourceBufferPal Methods \****************************************************************************/ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { @@ -458,10 +443,10 @@ void RMGfxSourceBufferPal::PreparePalette(void) { int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { int read; - // Carica l'immagine RAW + // Load the RAW image read = RMGfxSourceBuffer::Init(buf, dimx, dimy); - // Carica la palette se necessario + // Load the palette if necessary if (bLoadPalette) read += LoadPaletteWA(&buf[read]); @@ -469,10 +454,10 @@ int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPa } void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - // Carica l'immagine RAW + // Load the RAW image RMGfxSourceBuffer::Init(ds, dimx, dimy); - // Carica la palette se necessario + // Load the palette if necessary if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; ds.Read(suxpal, 256 * 3); @@ -490,7 +475,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer4 +* RMGfxSourceBuffer4 Methods \****************************************************************************/ void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -501,16 +486,12 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) SetPriority(0); } -/****************************************************************************\ -* -* Function: int RMGfxSourceBuffer4::Bpp(); -* -* Description: Ritorna il numero di bit per pixel della surface -* -* Return: Bit per pixel -* -\****************************************************************************/ +/** + * Returns the number of bits per pixel of the surface + * + * @returns Bit per pixel + */ int RMGfxSourceBuffer4::Bpp() { return 4; } @@ -520,7 +501,7 @@ void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8 +* RMGfxSourceBuffer8 Methods \****************************************************************************/ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { @@ -533,12 +514,12 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit uint16 *buf = bigBuf; byte *raw = m_buf; - // Destination nel buffer + // Destination buffer RMRect dst; if (prim->HaveDst()) dst = prim->Dst(); - // Esegue il clip + // Clipping if (prim->HaveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -550,10 +531,10 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) return; - // Offset iniziale nel buffer + // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; - // Passaggio normale + // Normal step if (m_bTrasp0) { for (y = 0; y < height; y++) { raw = m_buf + (y + v) * m_dimx + u; @@ -593,16 +574,11 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { } -/****************************************************************************\ -* -* Function: int RMGfxSourceBuffer8::Bpp(); -* -* Description: Ritorna il numero di bit per pixel della surface -* -* Return: Bit per pixel -* -\****************************************************************************/ - +/** + * Returns the number of bits per pixel of the surface + * + * @returns Bit per pixel + */ int RMGfxSourceBuffer8::Bpp() { return 8; } @@ -617,7 +593,7 @@ void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AB +* RMGfxSourceBuffer8AB Methods \****************************************************************************/ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { @@ -645,12 +621,12 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim uint16 *buf = bigBuf; byte *raw = m_buf; - // Destination nel buffer + // Destination buffer RMRect dst; if (prim->HaveDst()) dst = prim->Dst(); - // Esegue il clip + // Clipping if (prim->HaveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -662,7 +638,7 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) return; - // Offset iniziale nel buffer + // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; // Passaggio normale @@ -700,7 +676,7 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLE +* RMGfxSourceBuffer8RLE Methods \****************************************************************************/ byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; @@ -743,10 +719,10 @@ void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoa } void RMGfxSourceBuffer8RLE::PreparePalette(void) { - // Richiama il metodo padre + // Invoke the parent method RMGfxSourceBuffer8::PreparePalette(); - // Si salva gli RGB di alpha blending + // Handle RGB alpha blending if (alphaBlendColor != -1) { alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; @@ -755,10 +731,10 @@ void RMGfxSourceBuffer8RLE::PreparePalette(void) { } void RMGfxSourceBuffer8RLE::PrepareImage(void) { - // Richiama il metodo padre + // Invoke the parent method RMGfxSourceBuffer::PrepareImage(); - // Comprime + // Compress CompressRLE(); } @@ -776,17 +752,17 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { byte *startsrc; int rep; - // Esegue la compressione RLE, per linee + // Perform RLE compression for lines cur = MegaRLEBuf; src = m_buf; for (y = 0; y < m_dimy; y++) { - // Si salva l'inizio della linea + // Save the beginning of the line startline = cur; - // Lascia lo spazio per la lunghezza della linea + // Leave space for the length of the line cur += 2; - // Si parte dallo spazio vuoto + // It starts from the empty space curdata = 0; rep = 0; startsrc = src; @@ -813,7 +789,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { } } - // Dati in sospeso? + // Pending data? if (curdata == 1) { RLEWriteAlphaBlend(cur, rep); RLEWriteData(cur, 0, NULL); @@ -823,17 +799,17 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { RLEWriteData(cur, rep, startsrc); } - // Fine linea + // End of line RLEWriteEOL(cur); - // Scrive la lunghezza della linea + // Write the length of the line WRITE_LE_UINT16(startline, (uint16)(cur - startline)); } - // Cancella l'immagine originale + // Delete the original image delete[] m_buf; - // Ci copia l'immagine compressa + // Copy the compressed image x = cur - MegaRLEBuf; m_buf = new byte[x]; Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); @@ -845,27 +821,27 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri uint16 *buf = bigBuf; int x1, y1, u, v, width, height; - // Clippiamo lo sprite + // Clipping x1 = prim->Dst().x1; y1 = prim->Dst().y1; if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; - // Andiamo avanti di V linee nell'immagine RLE + // Go forward through the RLE lines src = m_buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); - // Posizionamoci nel buffer di destinazione + // Calculate the position in the destination buffer buf += y1 * bigBuf.Dimx(); - // Looppone + // Loop if (prim->IsFlipped()) { -// Annulliamo il clipping orizzontale +// Eliminate horizontal clipping // width = m_dimx; // x1=prim->Dst().x1; - // Flippiamo il clipping + // Clipping u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; @@ -873,21 +849,21 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Decompressione RLEDecompressLineFlipped(buf + x1, src + 2, u, width); - // Prossima linea + // Next line src += READ_LE_UINT16(src); - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.Dimx(); } } else { for (y = 0; y < height; y++) { - // Decompressione + // Decompression RLEDecompressLine(buf + x1, src + 2, u, width); - // Prossima linea + // Next line src += READ_LE_UINT16(src); - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.Dimx(); } } @@ -895,7 +871,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEByte +* RMGfxSourceBuffer8RLEByte Methods \****************************************************************************/ RMGfxSourceBuffer8RLEByte::~RMGfxSourceBuffer8RLEByte() { @@ -981,7 +957,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS while (1) { RLEByteDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = *src++; // EOL? @@ -1018,7 +994,7 @@ RLEByteDoAlpha2: assert(nLength > 0); //RLEByteDoCopy: - // Copia la roba + // Copy the stuff n = *src++; RLEByteDoCopy2: @@ -1087,7 +1063,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, while (1) { RLEByteFlippedDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = *src++; // EOL? @@ -1124,7 +1100,7 @@ RLEByteFlippedDoAlpha2: assert(nLength > 0); //RLEByteFlippedDoCopy: - // Copia la roba + // Copy the data n = *src++; RLEByteFlippedDoCopy2: @@ -1143,7 +1119,7 @@ RLEByteFlippedDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* RMGfxSourceBuffer8RLEWord Methods \****************************************************************************/ RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord() { @@ -1232,7 +1208,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS while (1) { RLEWordDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = READ_LE_UINT16(src); src += 2; @@ -1274,7 +1250,7 @@ RLEWordDoAlpha2: assert(nLength > 0); //RLEWordDoCopy: - // Copia la roba + // Copy the data n = READ_LE_UINT16(src); src += 2; @@ -1350,7 +1326,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, while (1) { RLEWordFlippedDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = READ_LE_UINT16(src); src += 2; @@ -1392,7 +1368,7 @@ RLEWordFlippedDoAlpha2: assert(nLength > 0); //RLEWordFlippedDoCopy: - // Copia la roba + // Copy the data n = READ_LE_UINT16(src); src += 2; @@ -1480,7 +1456,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int while (1) { RLEWordDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = READ_LE_UINT16(src); src += 2; @@ -1503,7 +1479,7 @@ RLEWordDoAlpha2: if (n > nLength) n = nLength; - // @@@ NON DOVREBBE ESSERCI!!!!! + // @@@ SHOULD NOT BE THERE !!!!! for (i = 0; i < n; i++) { r = (*dst >> 10) & 0x1F; g = (*dst >> 5) & 0x1F; @@ -1523,7 +1499,7 @@ RLEWordDoAlpha2: assert(nLength > 0); //RLEWordDoCopy: - // Copia la roba + // Copy the data n = READ_LE_UINT16(src); src += 2; @@ -1566,22 +1542,22 @@ byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; void RMGfxSourceBuffer8AA::PrepareImage(void) { - // Richiama il metodo padre + // Invoke the parent method RMGfxSourceBuffer::PrepareImage(); - // Prepara il buffer di antialiasing + // Prepare the buffer for anti-aliasing CalculateAA(); } void RMGfxSourceBuffer8AA::CalculateAA(void) { - // Io suxo tu suxi egli suxa noi suxiamo voi suxate essi suxano ---> ANTI ALIASING SUX! + // I suck, you suck, he sucks, we suck, they all suck ---> ANTI ALIASING SUX! // ************************************************************ int x, y; byte *src, *srcaa; - /* Prima passata: cerchiamo i bordi */ + /* First pass: fill the edges */ Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); src = m_buf; @@ -1643,20 +1619,19 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri int r, g, b; int step; - // Clippiamo lo sprite + // Clip the sprite x1 = prim->Dst().x1; y1 = prim->Dst().y1; if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; - // Andiamo avanti di V linee nell'immagine RLE + // Go forward through the RLE lines src = m_buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); - // Annulliamo il clipping orizzontale + // Eliminate horizontal clipping - // Flippiamo il clipping if (prim->IsFlipped()) { u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; @@ -1665,7 +1640,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // x1=prim->Dst().x1; - // Posizionamoci nel buffer di destinazione + // Poisition into the destination buffer buf = bigBuf; buf += y1 * bigBuf.Dimx(); @@ -1674,8 +1649,8 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri else step = 1; - // Looppone - buf += bigBuf.Dimx(); // skippa la prima linea + // Loop + buf += bigBuf.Dimx(); // Skip the first line for (y = 1; y < height - 1; y++) { /* if (prim->IsFlipped()) @@ -1705,11 +1680,11 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.Dimx(); } -// Posizionamoci nel buffer di destinazione +// Position into the destination buffer buf = bigBuf; buf += y1 * bigBuf.Dimx(); @@ -1765,7 +1740,7 @@ void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEAA +* RMGfxSourceBuffer8RLEAA Methods \****************************************************************************/ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { @@ -1799,7 +1774,7 @@ void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream &ds, int dimx, int dimy, boo RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { - // Carica la maschera di antialiasing + // Load the anti-aliasing mask m_aabuf = new byte[dimx * dimy]; ds.Read(m_aabuf, dimx * dimy); } @@ -1845,7 +1820,7 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, boo /****************************************************************************\ -* Metodi di RMGfxSourceBuffer16 +* RMGfxSourceBuffer16 Methods \****************************************************************************/ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { @@ -1913,7 +1888,7 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } void RMGfxSourceBuffer16::PrepareImage(void) { - // Color space conversion se necessario! + // Colour space conversion if necessary! int i; uint16 *buf = (uint16 *)m_buf; @@ -1927,16 +1902,12 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) SetPriority(0); } -/****************************************************************************\ -* -* Function: int RMGfxSourceBuffer16::Bpp(); -* -* Description: Ritorna il numero di bit per pixel della surface -* -* Return: Bit per pixel -* -\****************************************************************************/ +/** + * Returns the number of bits per pixel of the surface + * + * @returns Bit per pixel + */ int RMGfxSourceBuffer16::Bpp() { return 16; } @@ -1946,7 +1917,7 @@ void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { } /****************************************************************************\ -* Metodi di RMGfxBox +* RMGfxBox Methods \****************************************************************************/ void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { @@ -1965,11 +1936,11 @@ void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) uint16 *buf = bigBuf; RMRect rcDst; - // Prende il rettangolo di destinazione + // It takes the destination rectangle rcDst = prim->Dst(); buf += rcDst.y1 * bigBuf.Dimx() + rcDst.x1; - // Fa il suo bravo loop di put + // Loop through the pixels for (j = 0; j < rcDst.Height(); j++) { for (i = 0; i < rcDst.Width(); i++) *buf ++ = wFillColor; @@ -1980,21 +1951,21 @@ void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) /****************************************************************************\ -* Metodi di RMGfxClearTask +* RMGfxClearTask Methods \****************************************************************************/ int RMGfxClearTask::Priority() { - // Priorita' massima (deve essere fatto per primo) + // Maximum priority (must be done first) return 1; } void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { - // Pulisce tutto il target buffer + // Clean the target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { - // Il task di clear si disattiva sempre + // The task is fine to be removed result = true; } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 1af13d9a66..f7ea40fa9b 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -39,13 +39,13 @@ namespace Tony { * Prototipi di classi \****************************************************************************/ -// Nome della classe Albero genealogico Astratto? -class RMGfxTask; // Si -class RMGfxTaskSetPrior; // Task Si +// Class Name Family Treee Abstract? +class RMGfxTask; // Yes +class RMGfxTaskSetPrior; // Task Yes class RMGfxBuffer; // -class RMGfxSourceBuffer; // TaskP+[Buffer] Si +class RMGfxSourceBuffer; // TaskP+[Buffer] Yes class RMGfxTargetBuffer; // [Buffer] -class RMGfxSourceBufferPal; // Source Si +class RMGfxSourceBufferPal; // Source Yes class RMGfxSourceBuffer4; // SourcePal class RMGfxSourceBuffer8; // SourcePal class RMGfxSourceBuffer16; // Source @@ -221,7 +221,7 @@ protected: int m_nInList; public: - // Costruttore standard + // Standard constructor RMGfxTask(); virtual ~RMGfxTask() { } @@ -284,7 +284,7 @@ public: */ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: - // Carica i dati della surface a basso livello + // Load the data for the surface virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); @@ -316,7 +316,7 @@ public: RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); - // Inizializzazione + // Initialisation void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); @@ -329,7 +329,7 @@ public: */ class RMGfxSourceBufferPal : public RMGfxSourceBuffer { protected: - // The size of the palette is (1<deleteMutex(csMainLoop); } @@ -121,7 +121,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { EnableMouse(); _vm->GrabThumbnail(); - // Esce la IDLE onde evitare la morte prematura in caricamento + // Exists the IDLE to avoid premature death in loading m_bMustEnterMenu = true; if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; @@ -145,7 +145,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { g_system->lockMutex(csMainLoop); - // Poll dei dispositivi di input + // Poll of input devices m_input.Poll(); if (m_bMustEnterMenu && GLOBALS.bIdleExited) { @@ -166,25 +166,25 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } if (bDrawLocation && m_bLocationLoaded) { - // Locazione e oggetti + // Location and objects m_loc.DoFrame(&m_bigBuf); - // Controlla gli input del mouse + // Check the mouse input if (m_bInput && !m_tony.InAction()) { - // Se siamo sull'inventario, lui che controlla tutti gli input + // If we are on the inventory, it is it who controls all input if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { - // CLICK SINISTRO - // ************** + // Left Click + // ********** if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { - // Left click attiva il combine, se siamo su un oggetto + // Left click activates the combine, if we are on an object if (m_inv.LeftClick(m_input.MousePos(), m_curActionObj)) { m_curAction = TA_COMBINE; m_point.SetAction(m_curAction); } } else - // CLICK DESTRO - // ************ + // Right Click + // *********** if (m_input.MouseRightClicked()) { if (m_itemName.IsItemSelected()) { m_curActionObj = 0; @@ -193,8 +193,8 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { m_inv.RightClick(m_input.MousePos()); } else - // RILASCIO DESTRO - // *************** + // Right Release + // ************* if (m_input.MouseRightReleased()) { if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); @@ -204,7 +204,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } } } else { - // Menu Opzioni + // Options Menu // ************ if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { @@ -224,10 +224,10 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } } - // CLICK SINISTRO + // Left Click // ************** if (m_input.MouseLeftClicked() && !m_inter.Active()) { - // Se clicko dentro un oggetto, esegui l'azione + // If click inside an item, perform action //if (m_itemName.IsItemSelected()) { if (m_curAction != TA_COMBINE) @@ -246,10 +246,10 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } SKIPCLICKSINISTRO: - // CLICK DESTRO + // Right Click // ************ if (m_curAction == TA_COMBINE) { - // Durante il combine, lo annulla. + // During a combine, it cancels it if (m_input.MouseRightClicked()) { m_inv.EndCombine(); m_curActionObj = 0; @@ -259,7 +259,7 @@ SKIPCLICKSINISTRO: } } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { if (m_bGUIInterface) { - // Prima di aprire l'interfaccia, rimette GOTO + // Before opening the interface, replaces GOTO m_curAction = TA_GOTO; m_curActionObj = 0; m_point.SetAction(m_curAction); @@ -268,8 +268,8 @@ SKIPCLICKSINISTRO: } - // RILASCIO DESTRO - // *************** + // Right Release + // ************* if (m_input.MouseRightReleased()) { if (m_bGUIInterface) { if (m_inter.Released(m_input.MousePos(), m_curAction)) { @@ -283,21 +283,21 @@ SKIPCLICKSINISTRO: } } - // Aggiorna il nome sotto il puntatore del mouse + // Update the name under the mouse pointer m_itemName.SetMouseCoord(m_input.MousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } - // Inventario & interfaccia + // Interface & Inventory m_inter.DoFrame(m_bigBuf, m_input.MousePos()); m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); } - // Anima Tony + // Animate Tony CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); - // Aggiorna lo scrolling per tenere Tony dentro lo schermo + // Update screen scrolling to keep Tony in focus if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { RMPoint showThis = m_tony.Position(); showThis.y -= 60; @@ -313,7 +313,7 @@ SKIPCLICKSINISTRO: } // ********************** - // Disegna la lista di OT + // Draw the list in the OT // ********************** CORO_INVOKE_0(m_bigBuf.DrawOT); @@ -487,7 +487,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bLoaded = false; for (i = 0; i < 5; i++) { - // Retry sul loading della locazione + // Retry the loading of the location RMRes res(m_nCurLoc); if (!res.IsValid()) continue; @@ -513,7 +513,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { m_bLocationLoaded = true; - // On Enter per la locazion + // On entering the location return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } @@ -524,7 +524,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CODE(_ctx); - // Scarica tutta la memoria della locazione + // Release the location CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); // On Exit? @@ -585,28 +585,28 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_bWiping = false; m_hWipeEvent = CoroScheduler.createEvent(false, false); - // Crea l'evento di freeze + // Create the freeze event csMainLoop = g_system->createMutex(); - // Inizializza la funzione di IRQ di Item per l'MPAL + // Initialise the IRQ function for items for MPAL GLOBALS.GfxEngine = this; mpalInstallItemIrq(ItemIrq); - // Inizializza DirectInput + // Initialise the input m_input.Init(/*hInst*/); - // Inizializza il puntatore del mouse + // Initialise the mouse pointer m_point.Init(); - // Inizializza Tony + // Initialise Tony m_tony.Init(); m_tony.LinkToBoxes(&_vm->_theBoxes); - // Inizializza l'inventario e l'interfaccia + // Initialise the inventory and the interface m_inv.Init(); m_inter.Init(); - // Carica la locazione e setta le priorit @@@@@ + // Download the location and set priorities @@@@@ m_bLocationLoaded = false; /* m_nCurLoc=1; @@ -621,7 +621,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { */ EnableInput(); - // Inizio del gioco + // Starting the game //m_tony.ExecuteAction(4,1,0); //PREGAME m_tony.ExecuteAction(20, 1, 0); @@ -707,7 +707,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm char buf[4]; RMPoint tp = m_tony.Position(); - // Saving: mpal variables, current location, + tony inventory position + // Saving: MPAL variables, current location, and Tony inventory position // For now, we only save the MPAL state size = mpalGetSaveStateSize(); @@ -802,7 +802,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm } void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { - // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... + // PROBLEM: You should change the location in a separate process to do the OnEnter CORO_BEGIN_CONTEXT; Common::InSaveFile *f; byte *state, *statecmp; @@ -896,7 +896,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { } if (_ctx->ver >= 5) { - // Versione 5: + // Versione 5 bool bStat = false; bStat = _ctx->f->readByte(); diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 9115b22ccc..d2d47d392a 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -146,12 +146,10 @@ struct ChangedHotspotStruct { } }; -/****************************************************************************\ -* typedef CFCALL -* -------------- -* Description: Descrizione di una chiamata a una custom function -\****************************************************************************/ +/** + * Description of a call to a custom function. + */ typedef struct { int nCf; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index e10fe228d3..a2a4923093 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -77,37 +77,36 @@ void RMInventory::Init(void) { int i, j; int curres; - // Crea il buffer principale + // Create the main buffer Create(RM_SX, 68); SetPriority(185); - // Pulisce l'inventario + // Setup the inventory m_nInv = 0; m_curPos = 0; m_bCombining = false; - // Nuovi oggetti - m_nItems = 78; // @@@ Numero di oggetti prendibili + // New items + m_nItems = 78; // @@@ Number of takeable items m_items = new RMInventoryItem[m_nItems + 1]; curres = 10500; - // Loop sugli oggetti + // Loop through the items for (i = 0; i <= m_nItems; i++) { - // Carica l'oggetto da risorsa + // Load the items from the resource RMRes res(curres); RMDataStream ds; assert(res.IsValid()); - // Non deve inizializzare il cur pattern dell'oggetto dell'inventario leggendolo da MPAL! - // Glelo mettiamo noi a MANO, e non c'entra nulla con l'oggetto in MPAL + // Initialise the MPAL inventory item by reading it in. m_items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); ds >> m_items[i].icon; ds.Close(); - // Mette di default a pattern 1 + // Puts in the default pattern 1 m_items[i].pointer = NULL; m_items[i].status = 1; m_items[i].icon.SetPattern(1); @@ -131,7 +130,7 @@ void RMInventory::Init(void) { m_items[28].icon.SetPattern(1); m_items[29].icon.SetPattern(1); - // Carica l'interfaccina + // Download interface RMDataStream ds; RMRes res(RES_I_MINIINTER); assert(res.IsValid()); @@ -140,12 +139,12 @@ void RMInventory::Init(void) { miniInterface.SetPattern(1); ds.Close(); - // Crea il testo per gli hints sulla mini interfaccia + // Create the text for hints on the mini interface m_hints[0].SetAlignType(RMText::HCENTER, RMText::VTOP); m_hints[1].SetAlignType(RMText::HCENTER, RMText::VTOP); m_hints[2].SetAlignType(RMText::HCENTER, RMText::VTOP); - // Il testo viene preso da MPAL per la traduzione + // The text is taken from MPAL for translation RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); @@ -160,14 +159,14 @@ void RMInventory::Init(void) { m_hints[2].WriteText("Use",1); */ - // Prepara il primo inventario + // Prepare initial inventory Prepare(); DrawOT(Common::nullContext); ClearOT(); } void RMInventory::Close(void) { - // Ciao memoria + // Has memory if (m_items != NULL) { // Delete the item pointers for (int i = 0; i <= m_nItems; i++) @@ -211,22 +210,22 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, RM_SY - 113); _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); } _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); - // Disegna l'interfaccina stupida + // Draw the mini interface CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); if (GLOBALS.bCfgInterTips) { - if (miniAction == 1) // Esamina + if (miniAction == 1) // Examine CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); - else if (miniAction == 2) // Parla + else if (miniAction == 2) // Talk CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); - else if (miniAction == 3) // Usa + else if (miniAction == 3) // Use CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); } @@ -267,13 +266,12 @@ void RMInventory::RemoveItem(int code) { void RMInventory::AddItem(int code) { if (code <= 10000 && code >= 10101) { - // Se siamo qui, vuol dire che stiamo aggiungendo un oggetto che non dovrebbe essere - // nell'inventario + // If we are here, it means that we are adding an item that should not be in the inventory warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { g_system->lockMutex(m_csModifyInterface); if (m_curPos + 8 == m_nInv) { - // Sfondiamo l'inventario! Attivo il pattern di lampeggio + // Break through the inventory! On the flashing pattern m_items[28].icon.SetPattern(2); } @@ -324,15 +322,15 @@ bool RMInventory::MiniActive(void) { } bool RMInventory::HaveFocus(const RMPoint &mpos) { - // In fase di combine abbiamo il focus solo se siamo su una freccia (per poter scrollare) + // When we combine, have the focus only if we are on an arrow (to scroll) if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) return true; - // Se l'inventario aperto, abbiamo il focus quando ci andiamo sopra + // If the inventory is open, focus we we go over it if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) return true; - // Se stiamo selezionando un verbo (quindi tasto destro premuto), abbiamo il focus alltime + // If we are selecting a verb (and then right down), we always focus if (m_state == SELECTING) return true; @@ -346,12 +344,12 @@ void RMInventory::EndCombine(void) { bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { int n; - // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo + // The left click picks an item from your inventory to use it with the background n = mpos.x / 64; if (m_state == OPENED) { if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { - m_bCombining = true; //m_state=COMBINING; + m_bCombining = true; //m_state = COMBINING; m_nCombine = m_inv[n - 1 + m_curPos]; nCombineObj = m_nCombine + 10000; @@ -360,7 +358,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } } - // Click sulla freccia destra + // Click the right arrow if ((m_state == OPENED) && m_bBlinkingRight) { g_system->lockMutex(m_csModifyInterface); m_curPos++; @@ -380,7 +378,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { ClearOT(); g_system->unlockMutex(m_csModifyInterface); } - // Click sulla freccia sinistra + // Click the left arrow else if ((m_state == OPENED) && m_bBlinkingLeft) { assert(m_curPos > 0); g_system->lockMutex(m_csModifyInterface); @@ -413,7 +411,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { assert(CheckPointInside(mpos)); if (m_state == OPENED && !m_bCombining) { - // Apre l'interfaccina contestuale + // Open the context interface n = mpos.x / 64; if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { @@ -494,12 +492,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bool bNeedRedraw = false; if (m_state != CLOSED) { - // Pulisce l'OTList + // Clean up the OT list g_system->lockMutex(m_csModifyInterface); ClearOT(); - // Fa il DoFrame di tutti gli oggetti contenuti attualmente nell'inventario - // @@@ forse bisognerebbe farlo di tutti gli oggetti takeable? Probabilmente non serve a nulla + // DoFrame makes all the objects currently in the inventory be displayed + // @@@ Maybe we should do all takeable objects? Please does not help for (i = 0; i < m_nInv; i++) if (m_items[m_inv[i]].icon.DoFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) bNeedRedraw = true; @@ -641,7 +639,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo else starty = 70; - // Controlla se si trova su uno dei verbi + // Make sure it is on one of the verbs if (mpos.y > starty && mpos.y < starty + 45) { if (mpos.x > startx && mpos.x < startx + 40) { if (miniAction != 1) { @@ -670,7 +668,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniAction = 0; } - // Aggiorna la miniinterface + // Update the mini-interface miniInterface.DoFrame(&bigBuf, false); } @@ -780,16 +778,16 @@ int RMInterface::OnWhichBox(RMPoint pt) { pt -= m_openStart; - // Controlla quanti verbi bisogna considerare + // Check how many verbs you have to consider max = 4; if (m_bPalesati) max = 5; - // Cerca il verbo + // Find the verb for (i = 0; i < max; i++) if (m_hotbbox[i].PtInRect(pt)) return i; - // Nessun verbo trovato + // Found no verb return -1; } @@ -803,7 +801,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr prim->Dst().TopLeft() = m_openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); - // Controlla se c'e' da disegnare una zona calda + // Check if there is a draw hot zone _ctx->h = OnWhichBox(m_mpos); if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; @@ -826,7 +824,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { - // Se c' bisogna, schedula nella OT list + // If needed, add to the OT schedule list if (!m_nInList && m_bActive) bigBuf.AddPrim(new RMGfxPrimitive(this)); @@ -837,17 +835,17 @@ void RMInterface::Clicked(const RMPoint &mousepos) { m_bActive = true; m_openPos = mousepos; - // Calcola l'angolo in alto a sinistra dell'interfaccia + // Calculate the top left corner of the interface m_openStart = m_openPos - RMPoint(m_dimx / 2, m_dimy / 2); m_lastHotZone = -1; - // La tiene dentro lo schermo + // Keep it inside the screen if (m_openStart.x < 0) m_openStart.x = 0; if (m_openStart.y < 0) m_openStart.y = 0; if (m_openStart.x + m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; - // Play dell'effetto sonoro + // Play the sound effect _vm->PlayUtilSFX(0); } @@ -878,7 +876,7 @@ bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { action = TA_PALESATI; break; - default: // Nessun verbo + default: // No verb return false; } @@ -914,8 +912,8 @@ void RMInterface::Init(void) { m_hotzone[i].LoadPaletteWA(pal); } - m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi - m_hotbbox[1].SetRect(90, 130, 125, 186); // parla + m_hotbbox[0].SetRect(126, 123, 159, 208); // Take + m_hotbbox[1].SetRect(90, 130, 125, 186); // About m_hotbbox[2].SetRect(110, 60, 152, 125); m_hotbbox[3].SetRect(56, 51, 93, 99); m_hotbbox[4].SetRect(51, 105, 82, 172); @@ -926,7 +924,7 @@ void RMInterface::Init(void) { m_hints[3].SetAlignType(RMText::HRIGHT, RMText::VTOP); m_hints[4].SetAlignType(RMText::HRIGHT, RMText::VTOP); - // Il testo viene preso da MPAL per la traduzione + // The text is taken from MPAL for translation RMMessage msg0(12); RMMessage msg1(13); RMMessage msg2(14); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 309674ff0a..678caa1c78 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -79,66 +79,64 @@ protected: OSystem::MutexRef m_csModifyInterface; protected: - // Prepara l'immagine dell'inventario. Va richiamato ogni volta - // che l'inventario cambia + // Prepare the image inventory. It should be recalled whenever the inventory changes void Prepare(void); - // Controlla se la posizione Y del mouse corretta, anche in base - // alla posizione dell'inventario su schermo + // Check if the mouse Y position is conrrect, even under the inventory portion of the screen bool CheckPointInside(const RMPoint &pt); public: RMInventory(); virtual ~RMInventory(); - // Prepara un frame + // Prepare a frame void DoFrame(RMGfxTargetBuffer& bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); - // Inizializzazione e chiusura + // Initialisation and closing void Init(void); void Close(void); void Reset(void); - // Overload per la rimozione da otlist + // Overload test for removal from OT list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overload per il disegno (per la posizione x&y e l'interfaccina) + // Overload the drawing of the inventory virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Metodo per determinare se l'inventario sta comandando gli input + // Method for determining whether the inventory currently has the focus bool HaveFocus(const RMPoint &mpos); - // Metodo per determinare se la mini interfaccia attiva + // Method for determining if the mini interface is active bool MiniActive(void); - // Gestisce il click sinistro del mouse (solo quando c'ha focus) + // Handle the left mouse click (only when the inventory has the focus) bool LeftClick(const RMPoint &mpos, int &nCombineObj); - // Gestisce il tasto destro del mouse (solo quando c'ha focus) + // Handle the right mouse button (only when the inventory has the focus) void RightClick(const RMPoint &mpos); bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); - // Avverte che finito il combine + // Warn that an item combine is over void EndCombine(void); public: - // Aggiunta di un oggetto all'inventario + // Add an item to the inventory void AddItem(int code); RMInventory& operator+=(RMItem *item) { AddItem(item->MpalCode()); return *this; } RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } RMInventory& operator+=(int code) { AddItem(code); return *this; } - // Rimozione di oggetto + // Removes an item void RemoveItem(int code); - // Siamo sopra un oggetto? + // We are on an object? RMItem *WhichItemIsIn(const RMPoint &mpt); bool ItemInFocus(const RMPoint &mpt); - // Cambia l'icona di un oggetto + // Change the icon of an item void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); - // Salvataggio + // Save methods int GetSaveStateSize(void); void SaveState(byte *state); int LoadState(byte *state); @@ -158,34 +156,34 @@ private: int m_lastHotZone; protected: - // Dice su quale zona calda si trova il punto + // Return which box a given point is in int OnWhichBox(RMPoint pt); public: virtual ~RMInterface(); - // Il solito DoFrame (polling del motore grafico) + // The usual DoFrame (poll the graphics engine) void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); - // TRUE se attiva (non si pu selezionare oggetti) + // TRUE if it is active (you can select items) bool Active(); - // Inizializzazione + // Initialisation void Init(void); void Close(void); - // Resetta l'interfaccia + // Reset the interface void Reset(void); - // Avverte dei click e rilasci del mouse + // Warns of mouse clicks and releases void Clicked(const RMPoint &mousepos); bool Released(const RMPoint &mousepos, RMTonyAction &action); - // Attiva o disattiva il quinto verbo + // Enalbes or disables the fifth verb void SetPalesati(bool bOn); bool GetPalesati(void); - // Overloading del Draw per il posizionamente + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; -- cgit v1.2.3 From 316ca0021bbf9629ae5cd592f28f8b30b24a2b00 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 15:45:18 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 147 ++++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 76 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 93359688f6..a31c1a28bc 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -40,11 +40,11 @@ namespace Tony { #define RM_SX 640 #define RM_SY 480 -// X&Y dimensions of bigbuf +// X & Y dimensions of bigbuf #define RM_BBX (RM_SX) #define RM_BBY (RM_SY) -// Skipping X&Y +// Skipping X & Y #define RM_SKIPY ((RM_BBY - RM_SY) / 2) #define RM_SKIPX 0 diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d38f840011..4b3c533a92 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -130,14 +130,14 @@ void LoadChangedHotspot(Common::InSaveFile *f) { } -/* - Classi richieste per le funzioni custom! - - Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s - - SendMessage -> Direi che basta theEngine.SendMessage() - ChangeLocation -> theEngine.ChangeLocation() - AddInventory -> theEngine.AddInventory() +/** + * @defgroup Classes required for custom functions + * + * Tony (To Move him) -> You can do MPAL through the animation? I really think so + * + * SendMessage -> I'd say just theEngine.SendMessage() + * ChangeLocation -> theEngine.ChangeLocation() + * AddInventory -> theEngine.AddInventory() */ void MCharResetCodes(void) { @@ -272,10 +272,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Is positioned within the database of entries beginning at the first _ctx->curOffset = _ctx->curVoc->offset; - // PRIMA VOLTA PREALLOCA + // First time allocation g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); @@ -308,28 +308,28 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.SetInput(GLOBALS.Input); - // Allineamento + // Alignment _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colore + // Colour _ctx->text.SetColor(0, 255, 0); - // Scrive il testo + // Writes the text _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); - // Setta la posizione + // Set the position if (nX == 0 && nY == 0) _ctx->text.SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); else _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); - // Setta l'always display + // Handling for always display if (GLOBALS.bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(&_ctx->text); if (_ctx->curVoc) { @@ -351,7 +351,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - // Aspetta la fine della visualizzazione + // Wait for the end of the display _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); @@ -427,32 +427,32 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.SetInput(GLOBALS.Input); - // Allineamento + // Alignment _ctx->text.SetAlignType(RMText::HCENTER, RMText::VCENTER); - // Forza il testo a scomparire a tempo + // Forces the text to disappear in time _ctx->text.ForceTime(); - // Colore + // Colour _ctx->text.SetColor(255, 255, 255); - // Scrive il testo + // Write the text if (nFont == 0) _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 1); else if (nFont == 1) _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 0); - // Setta la posizione + // Set the position _ctx->text.SetPosition(RMPoint(320, 240)); _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(&_ctx->clear); GLOBALS.LinkGraphicTask(&_ctx->text); - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } @@ -1223,7 +1223,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_BEGIN_CODE(_ctx); - // Prende le coordinate di quanto scrollare + // Take the scroll coordinates _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; @@ -1272,7 +1272,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_BEGIN_CODE(_ctx); - // Prende le coordinate di quanto scrollare + // Take the scroll coordinates _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; _ctx->dimx = _ctx->lx; @@ -1356,7 +1356,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } - // Setta la posizione finale + // Set the position finale if (sX) { if (_ctx->lx > 0) _ctx->pt.x = _ctx->startpt.x + _ctx->dimx; @@ -1519,7 +1519,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Position within the database of entries, beginning at the first // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); @@ -1540,25 +1540,25 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Skipping _ctx->text->SetSkipStatus(!bIsBack); - // Allineamento + // Alignment _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colore + // Colour _ctx->text->SetColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); - // Scrive il testo + // Write the text _ctx->text->WriteText((*_ctx->msg)[_ctx->i], 0); - // Setta la posizione + // Set the position _ctx->text->SetPosition(_ctx->pt); - // Setta l'always display + // Set the always display if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { @@ -1574,7 +1574,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); @@ -1618,7 +1618,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 /* - * Mastri Personaggi + * Master Characters */ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { @@ -1714,17 +1714,17 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; - // Calcola la posizione del testo in base al frame corrente + // Calculates the position of the text according to the current frame if (GLOBALS.MCharacter[nChar].x == -1) _ctx->pt = GLOBALS.MCharacter[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); else _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); - // Parametro per le azioni speciali: random tra le parlate + // Parameter for special actions: random between the spoken _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; - // Cerca di eseguire la funzione custom per inizializzare la parlata + // Try to run the custom function to initialise the speech if (GLOBALS.MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { @@ -1735,7 +1735,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Position within the database of entries, beginning at the first g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); @@ -1744,7 +1744,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - // Crea l'oggetto diverso se back o no + // Create a different object depending on whether it's background or not if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) @@ -1757,25 +1757,25 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Skipping _ctx->text->SetSkipStatus(!bIsBack); - // Allineamento + // Alignment _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colore + // Colour _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); - // Scrive il testo + // Write the text _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); - // Setta la posizione + // Set the position _ctx->text->SetPosition(_ctx->pt); - // Setta l'always display + // Set the always display if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { @@ -1791,7 +1791,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); @@ -1807,7 +1807,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } - // Cerca di eseguire la funzione custom per chiudere la parlata + // Try to run the custom function to close the speech if (GLOBALS.MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -1844,8 +1844,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->bIsBack = false; - // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato - // con la SetAlwaysBack + // The SendDialogMessage can go in the background if it is a character if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) _ctx->bIsBack = true; @@ -1853,7 +1852,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Position within the database of entries, beginning at the first g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); @@ -1912,14 +1911,14 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg else _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); - // Parametro per le azioni speciali: random tra le parlate + // Parameter for special actions. Random between the spoken. _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { GLOBALS.MCharacter[nPers].numtexts--; } else { - // Cerca di eseguire la funzione custom per inizializzare la parlata + // Try to run the custom function to initialise the speech _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -1961,7 +1960,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } @@ -1985,7 +1984,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } else { if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { - // Cerca di eseguire la funzione custom per chiudere la parlata + // Try to run the custom function to close the speech GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->MpalCode(), GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -2036,12 +2035,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); while (_ctx->nChoice != (uint32) - 1) { - // Si fa dare la lista di opzioni e le conta + // Get the list of options _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) ; - // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta + // If there is only one option, do it automatically, and wait for the next choice if (_ctx->num == 1) { mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); @@ -2051,11 +2050,11 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr continue; } - // Crea una scelta per il dialogo + // Making a choice for dialog _ctx->dc.Init(); _ctx->dc.SetNumChoices(_ctx->num); - // Scrive tutte le possibili opzioni + // Writeall the possible options for (_ctx->i = 0; _ctx->i < _ctx->num; _ctx->i++) { _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); @@ -2063,11 +2062,11 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr GlobalFree(_ctx->string); } - // Attiva l'oggetto + // Activate the object GLOBALS.LinkGraphicTask(&_ctx->dc); CORO_INVOKE_0(_ctx->dc.Show); - // Disegna il puntatore + // Draw the pointer GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); @@ -2078,13 +2077,13 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr GLOBALS.Unfreeze(); } - // Nascondi il puntatore + // Hide the pointer MainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); - // Chiude la scelta + // Closes the choice _ctx->dc.Close(); GlobalFree(_ctx->sl); @@ -2098,7 +2097,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr /* - * Sync tra idle e mpal + * Sync between idle and mpal */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2124,11 +2123,11 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 * Musica * ------ * - * Effetti di fade supportati: + * Fadeout effects supposed: * - * nFX = 0 - La nuova musica si sostituisce a quella vecchia - * nFX=1 - La nuova musica si interfade con quella vecchia - * nFX=2 - La nuova musica subentra a tempo con quella vecchia + * nFX = 0 - The new music replaces the old one + * nFX=1 - The new music interfades with the old one + * nFX=2 - The new music takes over in time from the old * */ @@ -2181,7 +2180,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (!GLOBALS.bFadeOutStop) _vm->SetMusicVolume(nChannel, 0); - // Se uno stacchetto ferma tutto + // If there is a stacchetto, stop all if (nChannel == 2) _vm->StopMusic(2); @@ -2400,15 +2399,15 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 } - // Setta la posizione + // Set the position _ctx->text[_ctx->i].SetAlwaysDisplay(); _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); _ctx->text[_ctx->i].SetNoTab(); - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } @@ -2651,7 +2650,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation - // Crea l'evento per skippare le idle + // Create an event for the idle skipping GLOBALS.hSkipIdle = CoroScheduler.createEvent(true, false); } -- cgit v1.2.3 From 8322da03c04d7994601973364599081447a7ccde Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 16:03:09 +1000 Subject: TONY: Converting Italian comments to English --- engines/tony/custom.cpp | 1 - engines/tony/font.cpp | 8 ++++---- engines/tony/game.h | 4 ++-- engines/tony/loc.cpp | 7 +++---- engines/tony/mpal/mpal.cpp | 12 ++++++------ engines/tony/tony.cpp | 2 +- engines/tony/tonychar.cpp | 6 +++--- 7 files changed, 19 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 4b3c533a92..254fab91da 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -139,7 +139,6 @@ void LoadChangedHotspot(Common::InSaveFile *f) { * ChangeLocation -> theEngine.ChangeLocation() * AddInventory -> theEngine.AddInventory() */ - void MCharResetCodes(void) { for (int i = 0; i < 10; i++) GLOBALS.MCharacter[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[i].code); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 972bd081bf..efca78301c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -51,8 +51,8 @@ RMFont::~RMFont() { /** * Dumps a font to a buffer - * @param buf Buffer contenente il font - * @param nChars Numero di caratteri (max 256) + * @param buf Buffer for font contents + * @param nChars Number of characters (max 256) * @param dimx X dimension in pixels * @param dimy Y dimension in pixels * @@ -2209,7 +2209,7 @@ void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri } void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { - // Non dobbiamo fare nulla! + // We must not do anything! } @@ -2283,7 +2283,7 @@ void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - // Se non c'e' testo, e' inutile continuare + // If there is no text, it's pointless to continue if (m_buf == NULL) return; diff --git a/engines/tony/game.h b/engines/tony/game.h index 532a457b8f..20b5f347bc 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -283,12 +283,12 @@ public: protected: - // Inizializza tutto per il nuovo stato + // Initialisation and state change void InitState(CORO_PARAM); void CloseState(void); void ChangeState(CORO_PARAM, STATE newState); - // Repaaint the options menu + // Repaint the options menu void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); }; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index ef59b3f916..43e673b046 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1520,7 +1520,7 @@ void RMCharacter::Stop(CORO_PARAM) { bMoving = false; - // Non si sa mai... + // You never know.. status = STAND; minpath = 0; @@ -1609,9 +1609,8 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { pathcount = 1; pathend = pt; } else { - // @@@ Questo caso se un hotspot dentro un box - // ma non c' un path per arrivarci. Usiamo quindi - // la invscanline per cercare un punto intorno + // @@@ This case is whether a hotspot is inside a box, but there is + // a path to get there. We use the InvScanLine to search around a point _ctx->dest = InvScanLine(pt); pt = _ctx->dest; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 5cb6546343..0b56317f6f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -647,7 +647,7 @@ void ScriptThread(CORO_PARAM, const void *param) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { - // Dorme il tempo necessario per arrivare al momento successivo + // Sleep for the required time if (s->Moment[_ctx->i].dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = _vm->GetTime(); @@ -878,7 +878,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } UnlockItems(); - /* Se non e' rimasto nessuno possiamo uscire */ + /* If there is nothing left, we can exit */ if (_ctx->nRealItems == 0) { GlobalFree(_ctx->il); CORO_KILL_SELF(); @@ -1170,7 +1170,7 @@ void GroupThread(CORO_PARAM, const void *param) { } } - /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ + /* If we are here, it means that we have not found the requested group */ GLOBALS.mpalError = 1; UnlockDialogs(); @@ -2750,7 +2750,7 @@ const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, case num: \ if (nPers >= (int)(sizeof(DLG##num) / sizeof(const char *)) || DLG##num[nPers] == NULL) \ { \ - warning("ERROR: Il personaggio #%d non esiste nel dialogo %d!\n", nPers, nDlg); \ + warning("ERROR: The character #%d does not exist in dialog %d!\n", nPers, nDlg); \ return "ERROR"; \ } \ else \ @@ -2819,7 +2819,7 @@ const char *GetPersonName(uint16 nDlg, int nPers) { HANDLE_DIALOG(600); default: - warning("ERROR: Il dialogo %d non esiste!\n", (int)nDlg); + warning("ERROR: Dialog %d does not exist!", (int)nDlg); return "ERROR"; } } @@ -2872,7 +2872,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { break; if (dlg->Periods[j] == NULL) - warning("ERROR: Dialogo %d, Periodo %d non trovato!\n", (int)dlg->nObj, (int)curCmd->arg2); + warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->arg2); else { frase = (char *)GlobalLock(dlg->Periods[j]); strcpy(copia, frase); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c9abea04e0..e539fa1a39 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -609,7 +609,7 @@ void TonyEngine::PauseLoop(void) { } void TonyEngine::Pause(bool bPause) { - // Se non e' cambiato lo stato di pausing, non fare nulla + // If the new status already matches the current one, do nothing if (m_bPaused == bPause) return; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 04b6193cd2..593a05d863 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -178,7 +178,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); - // Richiama il Draw() della classe madre se tony visibile + // Call the Draw() of the parent class if Tony is visible if (m_bShow && bDrawNow) { if (m_bCorpoDavanti) { prim->Dst().SetEmpty(); @@ -189,7 +189,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } if (m_bIsTalking || m_bIsStaticTalk) { - // Offset inverso per lo scrolling + // Offest direction from scrolling prim->Dst().SetEmpty(); prim->Dst().Offset(-m_curScroll); prim->Dst().Offset(m_pos); @@ -217,7 +217,7 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, CORO_BEGIN_CODE(_ctx); - // Fa il movimento normale, ma si ricorda se deve poi eseguire un azione + // Makes normal movement, but remember if you must then perform an action if (item == NULL) { m_bActionPending = false; m_ActionItem = NULL; -- cgit v1.2.3 From c38bbce20cf69748012863dcd08c575ba6b56c9d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 16:11:25 +1000 Subject: TONY: Remove original header --- engines/tony/mpal/expr.cpp | 31 +++++-------------------------- engines/tony/mpal/expr.h | 31 +++++-------------------------- engines/tony/mpal/loadmpc.cpp | 31 +++++-------------------------- engines/tony/mpal/loadmpc.h | 31 +++++-------------------------- engines/tony/mpal/mpal.cpp | 31 +++++-------------------------- engines/tony/mpal/mpal.h | 40 ++-------------------------------------- engines/tony/mpal/mpaldll.h | 31 +++++-------------------------- 7 files changed, 32 insertions(+), 194 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index cf688341be..aaec74fb4c 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor...... * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Gestisce le espressioni * - * 4> ^R$oue# d matematiche............ * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 3a9f0f3208..7d7ca09c41 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor heade * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Gestisce le espressioni * - * 4> ^R$oue# d matematiche............ * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef MPAL_EXPR_H #define MPAL_EXPR_H diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6329a2090a..a60c9f5f16 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPC Loader............. * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Legge un file compilato * - * 4> ^R$oue# d di MPAL................ * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ /* #include "lzo1x.h" diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 6aea3de16b..2f8a1121ec 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPC Loader Header...... * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Legge un file compilato * - * 4> ^R$oue# d MPC.................... * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef __LOADMPC_H #define __LOADMPC_H diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 0b56317f6f..a5b7593e68 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: Mpal Query Library..... * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Libreria principale di * - * 4> ^R$oue# d MPAL, contenente il * - * '$ "" @ codice per le query.... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/scummsys.h" #include "common/file.h" diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index a14bfd1895..1bf19ef1bb 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -20,46 +20,10 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPAL Main Include file. * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Main Include file for * - * 4> ^R$oue# d using MPAL.DLL......... * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ - - -/****************************************************************************\ -* Copyright Notice -\****************************************************************************/ - /* - * A Spyral Software Production: - * - * MPAL - MultiPurpose Adventure Language - * (C) 1997 Giovanni Bajo and Luca Giusti - * ALL RIGHTS RESERVED - * + * This code is based on original Tony Tough source code * + * Copyright (c) 1997-2003 Nayma Software */ diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index dc42b597bc..8216e7b166 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPAL DLL Header........ * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Header per i moduli per * - * 4> ^R$oue# d la DLL di query di MPAL * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef __MPALDLL_H #define __MPALDLL_H -- cgit v1.2.3 From 7da213cd32b702ad8f4d0a10020eae10666a64ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 16:34:38 +1000 Subject: TONY: Removal of code that was commented out in the original source --- engines/tony/custom.cpp | 47 ++------------ engines/tony/font.cpp | 18 +----- engines/tony/game.cpp | 3 - engines/tony/gfxcore.cpp | 12 ---- engines/tony/gfxengine.cpp | 150 ++++----------------------------------------- engines/tony/gfxengine.h | 3 - engines/tony/inventory.cpp | 34 +++------- engines/tony/loc.cpp | 50 --------------- engines/tony/tony.cpp | 12 ---- 9 files changed, 29 insertions(+), 300 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 254fab91da..0127494007 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -276,11 +276,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // First time allocation g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - // _ctx->curOffset = ftell(_vm->m_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); @@ -337,11 +336,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - // _ctx->curOffset = ftell(_vm->m_vdbFP); + _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); @@ -517,7 +515,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 _vm->StopMusic(4); - // On Exit e lascia freezzato + // On exit, unload and unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); GLOBALS.Unfreeze(); @@ -541,7 +539,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _vm->StopMusic(4); } - // On Exit e lascia freezzato + // On exit, unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); GLOBALS.curChangedHotspot = 0; @@ -1314,37 +1312,6 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } -/* - sX = _ctx->stepX * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); - sY = _ctx->stepY * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); - - if (_ctx->lx > 0) { - _ctx->lx -= sX; - if (_ctx->lx < 0) - _ctx->lx = 0; - _ctx->pt.Offset(sX, 0); - } else if (_ctx->lx < 0) { - _ctx->lx += sX; - - if (_ctx->lx > 0) - _ctx->lx = 0; - - _ctx->pt.Offset(-sX, 0); - } - - if (_ctx->ly > 0) { - _ctx->ly -= sY; - if (_ctx->ly < 0) - _ctx->ly = 0; - _ctx->pt.Offset(0, sY); - } else if (_ctx->ly < 0) { - _ctx->ly += sY; - if (_ctx->ly > 0) - _ctx->ly = 0; - - _ctx->pt.Offset(0, -sY); - } -*/ CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); @@ -1519,7 +1486,6 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; @@ -1853,7 +1819,6 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -2119,8 +2084,8 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 /* - * Musica - * ------ + * Music + * ----- * * Fadeout effects supposed: * diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index efca78301c..a15a79b16c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -66,23 +66,7 @@ void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, i void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; -#if 0 - if (nChars == 112 && palResID == RES_F_PAL) { - // Font parla - DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } else if (nChars == 102 && palResID == RES_F_PAL) { - // Font macc - DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } else if (nChars == 85 && palResID == RES_F_PAL) { - // Font obj - DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } else if (nChars == 112 && palResID == RES_F_CPAL) { - // Font credits - DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } -#endif - - // Initialisation the fonts + // Initialise the fonts for (int i = 0; i < nChars; i++) { // Initialise the buffer with the letters m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4fe1ea374e..02eb996562 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1194,9 +1194,6 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { m_nEditPos = _ctx->i; strcpy(m_EditName, m_curThumbName[_ctx->i]); _ctx->bRefresh = true; - - //_vm->SaveState(m_statePos+_ctx->i,"No name"); - //Close(); } break; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 8c992eb150..170870a89b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -162,18 +162,6 @@ void RMGfxSourceBuffer::PrepareImage(void) { bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { int destw, desth; -/* - OBSOLETE CODE: - - if (buf == NULL) { - destw=RM_SX; - desth=RM_SY; - } else { - destw = buf->Dimx(); - desth = buf->Dimy(); - } -*/ - destw = buf->Dimx(); desth = buf->Dimy(); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e4f4cfb22d..3fa33d78ff 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -227,14 +227,11 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Left Click // ************** if (m_input.MouseLeftClicked() && !m_inter.Active()) { - // If click inside an item, perform action - //if (m_itemName.IsItemSelected()) - { - if (m_curAction != TA_COMBINE) - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); - else if (m_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); - } + + if (m_curAction != TA_COMBINE) + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + else if (m_itemName.GetSelectedItem() != NULL) + CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); if (m_curAction == TA_COMBINE) { m_inv.EndCombine(); @@ -380,80 +377,6 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { } } -/* - // WINBUG: This is a special case for the file open/save dialog, - // which sometimes pumps while it is coming up but before it has - // disabled the main window. - HWND hWndFocus = ::GetFocus(); - bool bEnableParent = false; - m_ofn.hwndOwner = PreModal(); - AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { - bEnableParent = true; - ::EnableWindow(m_ofn.hwndOwner, false); - } - - _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - - if (m_ofn.Flags & OFN_EXPLORER) - pThreadState->m_pAlternateWndInit = this; - else - AfxHookWindowCreate(this); - - int nResult; - if (m_bOpenFileDialog) - nResult = ::GetOpenFileName(&m_ofn); - else - nResult = ::GetSaveFileName(&m_ofn); - - if (nResult) - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - pThreadState->m_pAlternateWndInit = NULL; - - // WINBUG: Second part of special case for file open/save dialog. - if (bEnableParent) - ::EnableWindow(m_ofn.hwndOwner, true); - if (::IsWindow(hWndFocus)) - ::SetFocus(hWndFocus); -*/ - - -void RMGfxEngine::SelectLocation(const RMPoint &ptTonyStart, const RMPoint &start) { -#if 0 - OPENFILENAME ofn; - char lpszFileName[512]; - - // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione - - // Sceglie la locazione - ZeroMemory(lpszFileName, 512); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = NULL; - ofn.lpstrFilter = "Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; - ofn.lpstrCustomFilter = NULL; - ofn.nFilterIndex = 1; - ofn.lpstrFile = lpszFileName; - ofn.nMaxFile = 512; - ofn.lpstrInitialDir = NULL; - ofn.lpstrTitle = "Load Location"; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; - - if (!GetOpenFileName(&ofn)) - ASSERT(0); - - // Carica la locazione - m_loc.Load(lpszFileName); - m_bLocationLoaded = true; - m_nCurLoc = m_loc.TEMPGetNumLoc(); - - if (ptTonyStart.x == -1 && ptTonyStart.y == -1) - InitForNewLocation(m_loc.TEMPGetNumLoc(), m_loc.TEMPGetTonyStart(), RMPoint(-1, -1)); - else - InitForNewLocation(m_loc.TEMPGetNumLoc(), ptTonyStart, start); -#endif -} void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start.x == -1 || start.y == -1) { @@ -487,18 +410,11 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bLoaded = false; for (i = 0; i < 5; i++) { - // Retry the loading of the location + // Try the loading of the location RMRes res(m_nCurLoc); if (!res.IsValid()) continue; -#if 0 - // codice per dumpare una locazione in caso serva una modifica - if (nLoc == 106) { - FILE *f = fopen("loc106.lox", "wb"); - fwrite(res.DataPointer(), res.Size(), 1, f); - fclose(f); - } -#endif + m_loc.Load(res); InitForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; @@ -506,7 +422,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { } if (!bLoaded) - SelectLocation(ptTonyStart, start); + error("Location was not loaded"); if (m_bOption) m_opt.ReInit(m_bigBuf); @@ -547,19 +463,8 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_END_CODE; } -void RMGfxEngine::Init(/*HINSTANCE hInst*/) { - /* - //RECUPERARE UNA LOCAZIONE: - - RMRes res(5); - ASSERT(res.IsValid()); - FILE *f; - f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); - fwrite(res,1,5356900,f); - fclose(f); - */ - - // Schermata di loading +void RMGfxEngine::Init() { + // Screen loading RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); @@ -573,7 +478,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { GLOBALS.bPatIrqFreeze = true; - // GUI attivabile + // Activate GUI m_bGUIOption = true; m_bGUIInterface = true; m_bGUIInventory = true; @@ -593,7 +498,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { mpalInstallItemIrq(ItemIrq); // Initialise the input - m_input.Init(/*hInst*/); + m_input.Init(); // Initialise the mouse pointer m_point.Init(); @@ -608,40 +513,11 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { // Download the location and set priorities @@@@@ m_bLocationLoaded = false; - /* - m_nCurLoc=1; - RMRes res(m_nCurLoc); - m_loc.Load(res); - m_loc.SetPriority(1); - m_tony.SetPosition(RMPoint(201,316),1); - //m_tony.SetPosition(RMPoint(522,305),2); - //m_tony.SetPosition(RMPoint(158,398),4); - m_tony.SetPattern(m_tony.PAT_STANDDOWN); - m_curAction=TA_GOTO; - */ + EnableInput(); // Starting the game - //m_tony.ExecuteAction(4,1,0); //PREGAME - m_tony.ExecuteAction(20, 1, 0); - -// theLog << "Seleziona la locazione\n"; - //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); - //SelectLocation(); - //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); - //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); - //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); - //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); - //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); - //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); - //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); - - // CASTELLO - - //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); } void RMGfxEngine::Close(void) { diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 06eb3cc4ba..b9ab411d2b 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -136,9 +136,6 @@ public: void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name); void LoadState(CORO_PARAM, const Common::String &fn); - // Selects a location - void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1)); - // Pauses sound void PauseSound(bool bPause); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index a2a4923093..e090faacdc 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -149,15 +149,10 @@ void RMInventory::Init(void) { RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); - m_hints[1].WriteText(msg2[0], 1); - m_hints[2].WriteText(msg3[0], 1); + m_hints[0].WriteText(msg1[0], 1); // Examine + m_hints[1].WriteText(msg2[0], 1); // Take + m_hints[2].WriteText(msg3[0], 1); // Use - /* - m_hints[0].WriteText("Examine",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); - */ // Prepare initial inventory Prepare(); @@ -251,7 +246,6 @@ void RMInventory::RemoveItem(int code) { g_system->lockMutex(m_csModifyInterface); Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); -// m_inv[m_nInv-1]=0; m_nInv--; Prepare(); @@ -260,8 +254,6 @@ void RMInventory::RemoveItem(int code) { g_system->unlockMutex(m_csModifyInterface); return; } - - //MessageBox(NULL,"Specified object is not in the inventory","INTERNAL ERROR",MB_OK|MB_ICONEXCLAMATION); } void RMInventory::AddItem(int code) { @@ -313,8 +305,6 @@ void RMInventory::Prepare(void) { // Frecce AddPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); AddPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); - - //AddPrim(new RMGfxPrimitive(&m_items[0].icon,RMPoint(0,0))); } bool RMInventory::MiniActive(void) { @@ -931,18 +921,12 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); - m_hints[1].WriteText(msg1[0], 1); - m_hints[2].WriteText(msg2[0], 1); - m_hints[3].WriteText(msg3[0], 1); - m_hints[4].WriteText(msg4[0], 1); - /* - m_hints[0].WriteText("Take",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); - m_hints[3].WriteText("Examine",1); - m_hints[4].WriteText("Palesati",1); - */ + m_hints[0].WriteText(msg0[0], 1); // Take + m_hints[1].WriteText(msg1[0], 1); // Talk + m_hints[2].WriteText(msg2[0], 1); // Use + m_hints[3].WriteText(msg3[0], 1); // Examine + m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_bActive = false; m_bPalesati = false; m_lastHotZone = 0; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 43e673b046..a90b1ecdb5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -892,8 +892,6 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { } void RMWipe::CloseFade(void) { -// m_bUnregister = true; -// WaitForSingleObject(m_hUnregistered,CORO_INFINITE); m_wip0r.Unload(); } @@ -1122,7 +1120,6 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { olddx = dx; olddy = dy; - // ResetEvent(hTonyEndMovement); @@@ CORO_END_CODE; } @@ -1186,28 +1183,6 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { -/* - RMPoint tofind; - signed short difx,dify; - - difx = m_pos.x-punto.x; - dify = m_pos.y-punto.y; - - if ((difx>0) && (dify>0)) tofind=Searching(0,1,1,0,punto); - if ((difx>0) && (dify<0)) tofind=Searching(1,0,1,0,punto); - if ((difx<0) && (dify>0)) tofind=Searching(0,1,0,1,punto); - if ((difx<0) && (dify<0)) tofind=Searching(1,0,0,1,punto); - - // Could be removed? Think @@@@ - if ((difx= = 0) && (dify>0)) tofind=Searching(0,1,1,1,punto); - if ((difx= = 0) && (dify<0)) tofind=Searching(1,0,1,1,punto); - if ((dify= = 0) && (difx>0)) tofind=Searching(1,1,1,0,punto); - if ((dify= = 0) && (difx<0)) tofind=Searching(1,1,0,1,punto); - - if ((dify= = 0) && (difx= = 0)) tofind=punto; - - return tofind; -*/ return Searching(1, 1, 1, 1, punto); } @@ -1547,8 +1522,6 @@ void RMCharacter::Stop(CORO_PARAM) { break; default: -// assert(0); -// MessageBox(NULL,"E' lo stesso errore di prima, ma non crasha","Ehi!",MB_OK); SetPattern(PAT_STANDDOWN); break; } @@ -1989,28 +1962,12 @@ bool RMLocation::Load(const char *lpszFileName) { */ bool RMLocation::Load(Common::File &file) { int size; -// byte *buf; -// uint32 dwReadBytes; bool bRet; // Calcola la lunghezza del file size = file.size(); file.seek(0); -/* - // Alloca la memoria per caricare il file in memoria - buf=(LPBYTE)GlobalAlloc(GMEM_FIXED,size); - - // Legge il file in memoria - ReadFile(hFile,buf,size,&dwReadBytes,0); - - // Parsing del file, utilizzando la funzione di load da memorira - bRet=Load(buf); - - // Free della memoria - GlobalFree(buf); -*/ - RMFileStreamSlow fs; fs.OpenFile(file); @@ -2112,10 +2069,6 @@ bool RMLocation::Load(RMDataStream &ds) { ds >> m_items[i]; _vm->UnfreezeTime(); - // Sets the initial pattern @@@ duplication! - //for (i = 0;iInit(ds, dimx, dimy, true); - // Check the size of the location -// assert(dimy!=512); - // Number of items ds >> m_nItems; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e539fa1a39..04e81d3a31 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -311,15 +311,6 @@ void TonyEngine::PreloadSFX(int nChannel, const char *fn) { _theSound.CreateSfx(&m_sfx[nChannel]); -/* - // Mette il path giusto - GetDataDirectory(DD_UTILSFX, path_buffer); - _splitpath(path_buffer,drive,dir,NULL,NULL); - _splitpath(fn,NULL,NULL,fname,ext); - _makepath(path_buffer,drive,dir,fname,ext); - - m_sfx[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM); -*/ m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } @@ -360,9 +351,6 @@ void TonyEngine::InitMusic() { // csMusic = g_system->createMutex(); // Preload sound effects -// PreloadUtilSFX(0,"AccendiOpzione.ADP"); -// PreloadUtilSFX(1,"ApriInterfaccia.ADP"); - PreloadUtilSFX(0, "U01.ADP"); // Reversed!! PreloadUtilSFX(1, "U02.ADP"); } -- cgit v1.2.3 From 29cbb3f824a7dc197c396e44de4efc702f04c89a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 17:01:20 +1000 Subject: TONY: Miscellaneous comment translations and comment cleanup --- engines/tony/font.h | 2 +- engines/tony/game.cpp | 2 +- engines/tony/gfxcore.cpp | 2 +- engines/tony/loc.cpp | 2 +- engines/tony/mpal/mpaldll.h | 62 ++++----------------------------------------- 5 files changed, 9 insertions(+), 61 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.h b/engines/tony/font.h index b7488399a4..6acfea7295 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -341,7 +341,7 @@ public: /** - * Gestisce la schermata di scelta delle voci di un dialogo + * Manages the selection of screen items in a box */ class RMDialogChoice : public RMGfxWoodyBuffer { private: diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 02eb996562..8fe05abb3b 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1422,7 +1422,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS cmpbuf = new byte[160 * 120 * 4]; - // Se la versione >= 5, compresso! + // Read in the compressed data cmpsize = f->readUint32LE(); f->read(cmpbuf, cmpsize); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 170870a89b..6ec10b3aaa 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1800,7 +1800,7 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, boo RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { - // Carica la maschera di antialiasing + // Load the anti-aliasing mask m_aabuf = new byte[dimx * dimy]; ds.Read(m_aabuf, dimx * dimy); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a90b1ecdb5..d14b6972c8 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1964,7 +1964,7 @@ bool RMLocation::Load(Common::File &file) { int size; bool bRet; - // Calcola la lunghezza del file + // Get the file size size = file.size(); file.seek(0); diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 8216e7b166..90fa31ef1d 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -44,20 +44,11 @@ namespace MPAL { #define HEX_VERSION 0x0170 -/* - Safe - -#define MAX_ACTIONS_PER_ITEM 40 -#define MAX_COMMANDS_PER_ITEM 256 -#define MAX_COMMANDS_PER_ACTION 64 -#define MAX_DESCRIBE_SIZE 128 -*/ #define MAX_ACTIONS_PER_ITEM 40 #define MAX_COMMANDS_PER_ITEM 128 #define MAX_COMMANDS_PER_ACTION 128 -#define MAX_DESCRIBE_SIZE 64 - +#define MAX_DESCRIBE_SIZE 64 #define MAX_MOMENTS_PER_SCRIPT 256 @@ -65,22 +56,6 @@ namespace MPAL { #define MAX_COMMANDS_PER_MOMENT 32 - - - -/* - Secure version! - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 640 -#define MAX_COMMANDS_PER_GROUP 64 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 33 -#define MAX_PLAYGROUPS_PER_SELECT 9 -#define MAX_PERIODS_PER_DIALOG 640 - -*/ - #define MAX_GROUPS_PER_DIALOG 128 #define MAX_COMMANDS_PER_DIALOG 480 #define MAX_COMMANDS_PER_GROUP 64 @@ -89,17 +64,6 @@ namespace MPAL { #define MAX_PLAYGROUPS_PER_SELECT 9 #define MAX_PERIODS_PER_DIALOG 400 -/* - Before Rufus: - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 512 -#define MAX_COMMANDS_PER_GROUP 32 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 32 -#define MAX_PLAYGROUPS_PER_SELECT 4 -#define MAX_PERIODS_PER_DIALOG 512 -*/ #define NEED_LOCK_MSGS @@ -242,29 +206,13 @@ struct MPALITEM { struct command Command[MAX_COMMANDS_PER_ITEM]; - // Array of structures containing various managed activities. In practice, of - // every action we know what commands to run, including those defined in - // structures above -/* - struct - { - byte num; // Numero dell'azione - uint16 wTime; // In caso di idle, il tempo che deve passare - byte perc; // Percentuale di eseguire l'idle - HGLOBAL when; // Espressione da calcolare: se !=0, allora - // l'azione puo' essere eseguita - uint16 wParm; // Parametro per l'azione - - byte nCmds; // Numero comandi da eseguire - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire - - } Action[MAX_ACTIONS_PER_ITEM]; - */ + // Pointer to array of structures containing various managed activities. In practice, of + // every action we know what commands to run, including those defined in structures above struct ItemAction *Action; } PACKED_STRUCT; -typedef MPALITEM* LPMPALITEM; -typedef LPMPALITEM* LPLPMPALITEM; +typedef MPALITEM *LPMPALITEM; +typedef LPMPALITEM *LPLPMPALITEM; /** -- cgit v1.2.3 From 7303849490881f75c990edba895118ec03152320 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 21 May 2012 00:11:14 +1000 Subject: TONY: Removed redundant pause code. The original paused the game whilst dragging the window, and ScummVM takes care of that automatically. --- engines/tony/tony.cpp | 42 ------------------------------------------ engines/tony/tony.h | 7 ------- 2 files changed, 49 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 04e81d3a31..b60a196ed1 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -503,10 +503,6 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Game loop. We rely on the outer main process to detect if a shutdown is required, // and kill the scheudler and all the processes, including this one for (;;) { - // Se siamo in pausa, entra nel loop appropriato - if (_vm->m_bPaused) - _vm->PauseLoop(); - // If a savegame needs to be loaded, then do so if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber); @@ -576,44 +572,6 @@ void TonyEngine::GDIControl(bool bCon) { } -void TonyEngine::PauseLoop(void) { - warning("TODO: TonyEngine::PauseLoop"); - -#if 0 - MSG msg; - int st,et; - - st = GetTime(); - - while (m_bPaused && GetMessage(&msg,_window,0,0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - et = GetTime(); - - m_startTime += et - st; -#endif -} - -void TonyEngine::Pause(bool bPause) { - // If the new status already matches the current one, do nothing - if (m_bPaused == bPause) - return; - -warning("TODO: TonyEninge::Pause"); -/* - m_bPaused = bPause; - theEngine.GDIControl(m_bPaused); - - if (m_bPaused) { - SetWindowText(_window, "Tony Tough and the night of Roasted Moths - PAUSED"); - } else { - SetWindowText(_window, "Tony Tough and the night of Roasted Moths"); - } -*/ -} - void TonyEngine::FreezeTime(void) { m_bTimeFreezed = true; m_nTimeFreezed = GetTime() - m_startTime; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 8d4e357079..23c235d058 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -152,9 +152,6 @@ public: // Warn when are being controlled by the GDI void GDIControl(bool bCon); - // Loop that handles messages when the game is paused - void PauseLoop(void); - void Play(); void Close(); void Abort(); @@ -167,10 +164,6 @@ public: void ShowLocation(void) { m_bDrawLocation = true; } void HideLocation(void) { m_bDrawLocation = false; } - // Handle pause mode - void Pause(bool bPause); - bool IsPaused() { return m_bPaused; } - // Reads the time uint32 GetTime(void); void FreezeTime(void); -- cgit v1.2.3 From 3f00f51ef3239b02e01fed80c9205835b2d654e9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 21 May 2012 23:11:59 +1000 Subject: TONY: Improve the screen wipe logic. The circular area now properly reaches to the edge of the screen when changing scenes. --- engines/tony/window.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 481393c5ed..0f36c72f97 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -138,8 +138,17 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, rcBoundEllipse.top + rcBoundEllipse.height() / 2); - int radius = rcBoundEllipse.width() / 2; + // The rectangle technically defines the area inside the ellipse, with the corners touching + // the ellipse boundary. Since we're currently simulating the ellipse using a plain circle, + // we need to calculate a necessary width using the hypotenuse of X/2 & Y/2 + int x2y2 = (rcBoundEllipse.width() / 2) * (rcBoundEllipse.width() / 2) + + (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); + int radius = 0; + while ((radius * radius) < x2y2) + ++radius; + + // Proceed copying a circular area of the frame with the calculated radius onto the screen int error = -radius; int x = radius; int y = 0; @@ -177,17 +186,19 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, return; const byte *pSrc; + int xs = MAX(center.x - x, 0); + int width = MIN(RM_SX - xs, x * 2); if ((center.y - y) >= 0) { // Draw line in top half of circle - pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + (center.x - x) * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y - y, x * 2, 1); + pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + xs * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y - y, width, 1); } if ((center.y + y) < RM_SY) { // Draw line in bottom half of circle - pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + (center.x - x) * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y + y, x * 2, 1); + pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + xs * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y + y, width, 1); } } -- cgit v1.2.3 From 6856fa2447195e8a65f6d5c7efa73543668d85b0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 May 2012 00:29:27 +1000 Subject: TONY: Implemented ScummVM debugger, with an initial 'scene' command --- engines/tony/debugger.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/debugger.h | 42 +++++++++++++++++ engines/tony/input.cpp | 11 ++++- engines/tony/loc.h | 1 + engines/tony/module.mk | 1 + engines/tony/tony.cpp | 7 +++ engines/tony/tony.h | 2 + 7 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 engines/tony/debugger.cpp create mode 100644 engines/tony/debugger.h (limited to 'engines') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp new file mode 100644 index 0000000000..f358d51223 --- /dev/null +++ b/engines/tony/debugger.cpp @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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/coroutines.h" +#include "tony/debugger.h" +#include "tony/globals.h" +#include "tony/tony.h" + +namespace Tony { + +Debugger::Debugger() : GUI::Debugger() { + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); +} + +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +/** + * Support process for changing the scene + */ +struct ChangeSceneDetails { + int sceneNumber; + int x; + int y; +}; + +void DebugChangeScene(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 result; + const ChangeSceneDetails *details = (const ChangeSceneDetails *)param; + RMPoint scenePos(details->x, details->y); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result); + + GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); + + MainEnableGUI(); + + CORO_END_CODE; +} + + +/** + * This command loads up the specified new scene number + */ +bool Debugger::Cmd_Scene(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("Usage: %s [ ]\n", argv[0]); + return true; + } + + int sceneNumber = strToInt(argv[1]); + if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) { + DebugPrintf("Invalid scene\n"); + return true; + } + + RMPoint scenePos; + if (argc >= 4) { + scenePos.x = strToInt(argv[2]); + scenePos.y = strToInt(argv[3]); + } else { + // Get the box areas for the scene, and choose one so as to have a default + // position for Tony that will be in the walkable areas + RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber); + scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + } + + // Set up a process to change the scene + ChangeSceneDetails details; + details.sceneNumber = sceneNumber; + details.x = scenePos.x; + details.y = scenePos.y; + CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails)); + + return false; +} + +} // End of namespace Tony diff --git a/engines/tony/debugger.h b/engines/tony/debugger.h new file mode 100644 index 0000000000..c5ed5e417e --- /dev/null +++ b/engines/tony/debugger.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. + * + */ + +#ifndef TONY_DEBUGGER_H +#define TONY_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" + +namespace Tony { + +class Debugger : public GUI::Debugger { +public: + Debugger(); + virtual ~Debugger() {} + +protected: + bool Cmd_Scene(int argc, const char **argv); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 7663774ee4..c1104204b5 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -27,6 +27,7 @@ */ #include "tony/gfxengine.h" +#include "tony/tony.h" namespace Tony { @@ -79,7 +80,15 @@ void RMInput::Poll(void) { return; case Common::EVENT_KEYDOWN: - _keyDown[(int)_event.kbd.keycode] = true; + // Check for debugger + if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _vm->_debugger->attach(); + _vm->_debugger->onFrame(); + } else { + // Flag the given key as being down + _keyDown[(int)_event.kbd.keycode] = true; + } return; case Common::EVENT_KEYUP: diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4b9a18f406..7085c81dcb 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -353,6 +353,7 @@ public: // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); + int GetLocBoxesCount() const { return m_nLocBoxes; } // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 719a598ee4..d66cf6f065 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,6 +2,7 @@ MODULE := engines/tony MODULE_OBJS := \ custom.o \ + debugger.o \ detection.o \ font.o \ game.o \ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b60a196ed1..e5988e7c9b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -28,6 +28,7 @@ #include "common/file.h" #include "tony/tony.h" #include "tony/custom.h" +#include "tony/debugger.h" #include "tony/game.h" #include "tony/mpal/mpal.h" @@ -40,6 +41,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng _vm = this; _loadSlotNumber = -1; + _debugger = new Debugger(); DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); @@ -60,6 +62,8 @@ TonyEngine::~TonyEngine() { // Reset the coroutine scheduler CoroScheduler.reset(); + + delete _debugger; } /** @@ -529,6 +533,9 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Paint the frame onto the screen _vm->_window.Repaint(); + + // Signal the ScummVM debugger + _vm->_debugger->onFrame(); } CORO_END_CODE; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 23c235d058..bdaffee7c9 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -34,6 +34,7 @@ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" +#include "tony/debugger.h" #include "tony/gfxengine.h" #include "tony/loc.h" #include "tony/utils.h" @@ -101,6 +102,7 @@ public: Common::Array _voices; FPSOUND _theSound; Globals _globals; + Debugger *_debugger; enum DATADIR { DD_BASE = 1, -- cgit v1.2.3 From 94d3c8ebb29699a6c7a76c08986b984523761d63 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 21 May 2012 23:53:13 +0200 Subject: TONY: Some more code formatting --- engines/tony/detection.cpp | 2 +- engines/tony/font.cpp | 30 +- engines/tony/game.cpp | 2 +- engines/tony/gfxcore.cpp | 16 +- engines/tony/gfxcore.h | 2 +- engines/tony/inventory.cpp | 18 +- engines/tony/inventory.h | 35 ++- engines/tony/loc.cpp | 463 +++++++++++++++--------------- engines/tony/loc.h | 218 +++++++++------ engines/tony/resid.h | 20 +- engines/tony/sound.cpp | 669 ++++++++++++++++++++++---------------------- engines/tony/sound.h | 680 ++++++++++++++++++++++----------------------- engines/tony/tony.cpp | 75 +++-- engines/tony/tony.h | 26 +- engines/tony/tonychar.cpp | 167 +++++------ engines/tony/tonychar.h | 42 ++- engines/tony/utils.cpp | 188 ++++++------- engines/tony/utils.h | 305 ++++++++++---------- engines/tony/window.cpp | 44 +-- engines/tony/window.h | 6 +- 20 files changed, 1544 insertions(+), 1464 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 63bb02a5f2..a87dd9bd07 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -147,7 +147,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Tony::RMString saveName; byte difficulty; - byte thumbData[160 * 120 * 2]; + byte thumbData[160 * 120 * 2]; if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { // Convert the 565 thumbnail data to the needed overlay format diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a15a79b16c..66f1ccdcd9 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -51,10 +51,10 @@ RMFont::~RMFont() { /** * Dumps a font to a buffer - * @param buf Buffer for font contents - * @param nChars Number of characters (max 256) - * @param dimx X dimension in pixels - * @param dimy Y dimension in pixels + * @param buf Buffer for font contents + * @param nChars Number of characters (max 256) + * @param dimx X dimension in pixels + * @param dimy Y dimension in pixels * \****************************************************************************/ @@ -323,7 +323,7 @@ void RMFontParla::Init(void) { lTable['E'] = 10; lTable['F'] = 11; - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -370,7 +370,7 @@ void RMFontParla::Init(void) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 130; @@ -575,7 +575,7 @@ void RMFontParla::Init(void) { lTable[(byte)''] = 13; lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (_vm->getLanguage() == Common::FR_FRA) { // French cTable[(byte)''] = 226; @@ -687,7 +687,7 @@ void RMFontMacc::Init(void) { //cTable[(byte)''] = 100; // u with ball cTable[(byte)''] = 101; - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -733,7 +733,7 @@ void RMFontMacc::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 120; cTable[(byte)''] = 121; @@ -1183,7 +1183,7 @@ void RMFontCredits::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; @@ -1581,7 +1581,7 @@ void RMFontObj::Init(void) { SetBothCase('R', 'R', 1); SetBothCase('R', 'U', 3); - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz @@ -1614,8 +1614,8 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = cTable[(byte)''] = 85; @@ -1725,7 +1725,7 @@ void RMFontObj::Init(void) { lTable[(byte)''] = lTable[(byte)''] = 16; lTable[(byte)''] = lTable[(byte)''] = 16; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters @@ -1854,7 +1854,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Back to the first usable space // // BERNIE: In the original, sentences containing words that exceed the - // width of a line caused discontinuation of the whole sentence. + // width of a line caused discontinuation of the whole sentence. // This workaround has the partial word broken up so it will still display // old_p = p; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 8fe05abb3b..dc5e412f00 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,7 +43,7 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Global functions */ +/* Global functions */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6ec10b3aaa..be59a2d9a5 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -173,7 +173,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int if (x1 > destw - 1) return false; - + if (y1 > desth - 1) return false; @@ -206,11 +206,11 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int /** * Initialises a surface by resource Id * - * @param resID Resource ID - * @param dimx Buffer X dimension - * @param dimy Buffer Y dimension + * @param resID Resource ID + * @param dimx Buffer X dimension + * @param dimy Buffer Y dimension */ - int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } @@ -478,7 +478,7 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer4::Bpp() { return 4; @@ -565,7 +565,7 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer8::Bpp() { return 8; @@ -1894,7 +1894,7 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer16::Bpp() { return 16; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index f7ea40fa9b..ffeb7724b2 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -39,7 +39,7 @@ namespace Tony { * Prototipi di classi \****************************************************************************/ -// Class Name Family Treee Abstract? +// Class Name Family Treee Abstract? class RMGfxTask; // Yes class RMGfxTaskSetPrior; // Task Yes class RMGfxBuffer; // diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index e090faacdc..539dd4e81b 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -100,7 +100,7 @@ void RMInventory::Init(void) { assert(res.IsValid()); - // Initialise the MPAL inventory item by reading it in. + // Initialise the MPAL inventory item by reading it in. m_items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); ds >> m_items[i].icon; @@ -149,9 +149,9 @@ void RMInventory::Init(void) { RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); // Examine - m_hints[1].WriteText(msg2[0], 1); // Take - m_hints[2].WriteText(msg3[0], 1); // Use + m_hints[0].WriteText(msg1[0], 1); // Examine + m_hints[1].WriteText(msg2[0], 1); // Take + m_hints[2].WriteText(msg3[0], 1); // Use // Prepare initial inventory @@ -921,11 +921,11 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); // Take - m_hints[1].WriteText(msg1[0], 1); // Talk - m_hints[2].WriteText(msg2[0], 1); // Use - m_hints[3].WriteText(msg3[0], 1); // Examine - m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_hints[0].WriteText(msg0[0], 1); // Take + m_hints[1].WriteText(msg1[0], 1); // Talk + m_hints[2].WriteText(msg2[0], 1); // Use + m_hints[3].WriteText(msg3[0], 1); // Examine + m_hints[4].WriteText(msg4[0], 1); // Show Yourself m_bActive = false; m_bPalesati = false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 678caa1c78..a5f02603e7 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -40,7 +40,7 @@ namespace Tony { struct RMInventoryItem { RMItem icon; - RMGfxSourceBuffer8RLEByteAA *pointer; + RMGfxSourceBuffer8RLEByteAA *pointer; int status; }; @@ -57,7 +57,7 @@ private: protected: int m_nItems; RMInventoryItem *m_items; - + int m_inv[256]; int m_nInv; int m_curPutY; @@ -69,13 +69,13 @@ protected: int m_nSelectObj; int m_nCombine; bool m_bCombining; - + bool m_bBlinkingRight, m_bBlinkingLeft; int miniAction; RMItem miniInterface; RMText m_hints[3]; - + OSystem::MutexRef m_csModifyInterface; protected: @@ -90,7 +90,7 @@ public: virtual ~RMInventory(); // Prepare a frame - void DoFrame(RMGfxTargetBuffer& bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); + void DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); // Initialisation and closing void Init(void); @@ -111,20 +111,29 @@ public: // Handle the left mouse click (only when the inventory has the focus) bool LeftClick(const RMPoint &mpos, int &nCombineObj); - + // Handle the right mouse button (only when the inventory has the focus) void RightClick(const RMPoint &mpos); bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Warn that an item combine is over void EndCombine(void); - -public: + +public: // Add an item to the inventory void AddItem(int code); - RMInventory& operator+=(RMItem *item) { AddItem(item->MpalCode()); return *this; } - RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } - RMInventory& operator+=(int code) { AddItem(code); return *this; } + RMInventory &operator+=(RMItem *item) { + AddItem(item->MpalCode()); + return *this; + } + RMInventory &operator+=(RMItem &item) { + AddItem(item.MpalCode()); + return *this; + } + RMInventory &operator+=(int code) { + AddItem(code); + return *this; + } // Removes an item void RemoveItem(int code); @@ -163,10 +172,10 @@ public: virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) - void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); + void DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); // TRUE if it is active (you can select items) - bool Active(); + bool Active(); // Initialisation void Init(void); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d14b6972c8..f0dd30b1a9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -44,13 +44,13 @@ using namespace ::Tony::MPAL; /** * Operator for reading palette information from a data stream. * - * @param ds Data stream - * @param pal Destination palette + * @param ds Data stream + * @param pal Destination palette * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal.m_data,1024); + ds.Read(pal.m_data, 1024); return ds; } @@ -61,10 +61,10 @@ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { /** * Operator for reading slot information from a data stream. * - * @param ds Data stream - * @param slot Destination slot + * @param ds Data stream + * @param slot Destination slot * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { slot.ReadFromStream(ds); @@ -78,7 +78,7 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { // Type ds >> type; m_type = (RMPattern::RMSlotType)type; - + // Dati ds >> m_data; @@ -97,10 +97,10 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { /** * Operator for reading pattern information from a data stream * - * @param ds Data stream - * @param pat Destination pattern + * @param ds Data stream + * @param pat Destination pattern * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { pat.ReadFromStream(ds); @@ -170,35 +170,35 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { m_nCurSprite = m_slots[i].m_data; if (bFlag) *bFlag = m_slots[i].m_flag; - + // Calculate the current coordinates UpdateCoord(); - + // Check for sound: // If the slot is 0, play // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop - for (i = 0;i < m_nSlots; i++) { + for (i = 0; i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { if (i == 0) { if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } else { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } } else if (m_speed == 0) { if (bPlayP0) { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } } else { if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } } @@ -214,13 +214,13 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { // If the speed is 0, then the pattern never advances if (m_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); - bFlag=m_slots[m_nCurSlot].m_flag; + bFlag = m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } // Is it time to change the slots? while (m_nStartTime + m_speed <= (uint32)CurTime) { - m_nStartTime += m_speed; + m_nStartTime += m_speed; if (m_slots[m_nCurSlot].m_type == SPRITE) m_nCurSlot++; if (m_nCurSlot == m_nSlots) { @@ -234,7 +234,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (!m_bLoop) { m_nCurSlot = m_nSlots - 1; bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + return m_nCurSprite; } } @@ -243,7 +243,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case SPRITE: // Read the next sprite m_nCurSprite = m_slots[m_nCurSlot].m_data; - + // Update the parent & child coordinates UpdateCoord(); break; @@ -262,7 +262,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case COMMAND: assert(0); break; - + default: assert(0); break; @@ -271,11 +271,11 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (m_slots[m_nCurSlot].m_type == SPRITE) break; m_nCurSlot++; - } + } } // Return the current sprite - bFlag=m_slots[m_nCurSlot].m_flag; + bFlag = m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -283,11 +283,11 @@ RMPattern::RMPattern() { m_slots = NULL; m_speed = 0; m_bLoop = 0; - m_nSlots = 0; + m_nSlots = 0; m_nCurSlot = 0; m_nCurSprite = 0; m_nStartTime = 0; - m_slots = NULL; + m_slots = NULL; } RMPattern::~RMPattern() { @@ -307,10 +307,10 @@ RMPattern::~RMPattern() { /** * Operator for reading sprite information from a data stream. * - * @param ds Data stream - * @param sprite Destination slot + * @param ds Data stream + * @param sprite Destination slot * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { sprite.ReadFromStream(ds); @@ -339,8 +339,8 @@ void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { } void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { - int dimx,dimy; - + int dimx, dimy; + // Sprite name if (!bLOX) ds >> m_name; @@ -364,11 +364,11 @@ void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) } void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal*)m_buf)->LoadPalette(buf); + ((RMGfxSourceBufferPal *)m_buf)->LoadPalette(buf); } RMSprite::RMSprite() { - m_buf= NULL; + m_buf = NULL; } RMSprite::~RMSprite() { @@ -386,10 +386,10 @@ RMSprite::~RMSprite() { /** * Operator for reading SFX information from a data stream. * - * @param ds Data stream - * @param sfx Destination SFX + * @param ds Data stream + * @param sfx Destination SFX * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { sfx.ReadFromStream(ds); @@ -400,10 +400,10 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { char id[4]; int size; byte *raw; - + // sfx name ds >> m_name; - + ds >> size; // Upload the sound effect identifier from the buffer @@ -416,7 +416,7 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds >> size; // Read the raw WAV data - raw = new byte[size]; + raw = new byte[size]; ds.Read(raw, size); // Create the sound effect @@ -477,10 +477,10 @@ void RMSfx::Stop(void) { /** * Operator for reading item information from a data stream. * - * @param ds Data stream - * @param tem Destination item + * @param ds Data stream + * @param tem Destination item * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { item.ReadFromStream(ds); @@ -491,15 +491,15 @@ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (m_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; - - if (m_FX == 2) { // AB + + if (m_FX == 2) { // AB spr = new RMGfxSourceBuffer8RLEWordAB; - } else if (m_FX == 1) { // OMBRA+AA + } else if (m_FX == 1) { // OMBRA+AA if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWordAA; else spr = new RMGfxSourceBuffer8RLEByteAA; - + spr->SetAlphaBlendColor(m_FXparm); if (bPreRLE) spr->SetAlreadyCompressed(); @@ -518,25 +518,25 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(const RMPoint &pt, int *size) { +bool RMItem::IsIn(const RMPoint &pt, int *size) { RMRect rc; - - if (!m_bIsActive) - return false; - + + if (!m_bIsActive) + return false; + // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) - rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); + rc = m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); else if (!m_rcBox.IsEmpty()) rc = m_rcBox; // If no box, return immediately else return false; - - if (size != NULL) - *size = rc.Size(); - - return rc.PtInRect(pt + m_curScroll); + + if (size != NULL) + *size = rc.Size(); + + return rc.PtInRect(pt + m_curScroll); } @@ -566,7 +566,8 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { ds >> m_nSprites >> m_nSfx >> m_nPatterns; // Color mode - ds >> cm; m_cm=(RMColorMode)cm; + ds >> cm; + m_cm = (RMColorMode)cm; // Flag for the presence of custom palette differences ds >> m_bPal; @@ -580,40 +581,40 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // MPAL data if (!bLOX) ds += 20; - + ds >> m_FX; ds >> m_FXparm; if (!bLOX) - ds += 106; - + ds += 106; + // Create sub-classes if (m_nSprites > 0) - m_sprites = new RMSprite[m_nSprites]; + m_sprites = new RMSprite[m_nSprites]; if (m_nSfx > 0) m_sfx = new RMSfx[m_nSfx]; - m_patterns = new RMPattern[m_nPatterns+1]; + m_patterns = new RMPattern[m_nPatterns + 1]; // Read in class data if (!ds.IsError()) for (i = 0; i < m_nSprites && !ds.IsError(); i++) { - // Download the sprites - if (bLOX) { - m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); - m_sprites[i].ReadFromStream(ds, true); - } else { - m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); - m_sprites[i].ReadFromStream(ds, false); - } - - if (m_cm == CM_256 && m_bPal) + // Download the sprites + if (bLOX) { + m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); + m_sprites[i].ReadFromStream(ds, true); + } else { + m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); + m_sprites[i].ReadFromStream(ds, false); + } + + if (m_cm == CM_256 && m_bPal) m_sprites[i].SetPalette(m_pal.m_data); - } + } if (!ds.IsError()) - for (i = 0;i < m_nSfx && !ds.IsError(); i++) { + for (i = 0; i < m_nSfx && !ds.IsError(); i++) { if (bLOX) m_sfx[i].ReadFromStream(ds, true); else @@ -622,7 +623,7 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // Read the pattern from pattern 1 if (!ds.IsError()) - for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { + for (i = 1; i <= m_nPatterns && !ds.IsError(); i++) { if (bLOX) m_patterns[i].ReadFromStream(ds, true); else @@ -692,8 +693,8 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // If CurSprite == -1, then the pattern is finished if (m_nCurSprite == -1) - return; - + return; + // Set the flag prim->SetFlag(m_bCurFlag); @@ -730,9 +731,9 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { assert(nPattern >= 0 && nPattern <= m_nPatterns); if (m_sfx) - if (m_nCurPattern>0) + if (m_nCurPattern > 0) m_patterns[m_nCurPattern].StopSfx(m_sfx); - + // Remember the current pattern m_nCurPattern = nPattern; @@ -741,10 +742,10 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); else { m_nCurSprite = -1; - + // Look for the sound effect for pattern 0 if (bPlayP0) - for (i = 0;i < m_nSfx; i++) + for (i = 0; i < m_nSfx; i++) if (strcmp(m_sfx[i].m_name, "p0") == 0) m_sfx[i].Play(); } @@ -758,7 +759,7 @@ bool RMItem::GetName(RMString &name) { name = buf; if (buf[0] == '\0') return false; - return true; + return true; } @@ -767,12 +768,12 @@ void RMItem::Unload(void) { delete[] m_patterns; m_patterns = NULL; } - + if (m_sprites != NULL) { delete[] m_sprites; m_sprites = NULL; } - + if (m_sfx != NULL) { delete[] m_sfx; m_sfx = NULL; @@ -809,7 +810,7 @@ RMItem::~RMItem() { void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; - uint32 h[2]; + uint32 h[2]; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -880,7 +881,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); m_bEndFade = true; m_bFading = false; @@ -910,7 +911,7 @@ void RMWipe::InitFade(int type) { ds.OpenBuffer(res); ds >> m_wip0r; ds.Close(); - + m_wip0r.SetPattern(1); m_bFading = true; @@ -921,12 +922,12 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); m_bMustRegister = false; } - + if (m_bFading) { m_wip0r.DoFrame(&bigBuf, false); m_nFadeStep++; - + if (m_nFadeStep == 10) { CoroScheduler.setEvent(m_hEndOfFade); } @@ -961,17 +962,17 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes + static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated static short NEXT[MAXBOXES]; // Prossimo Nodo short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; - g_system->lockMutex(csMove); + g_system->lockMutex(csMove); if (source == -1 || destination == -1) { - g_system->unlockMutex(csMove); + g_system->unlockMutex(csMove); return 0; } @@ -983,37 +984,37 @@ short RMCharacter::FindPath(short source, short destination) { memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->numbbox; i++) VALIDO[i] = 0; - + // Prepare source and variables for the procedure COSTO[source] = 0; VALIDO[source] = 1; fine = 0; - - // Find the shortest path - while(!fine) { - costominimo = 32000; // Reset the minimum cost - errore = 1; // Possible error + + // Find the shortest path + while (!fine) { + costominimo = 32000; // Reset the minimum cost + errore = 1; // Possible error // 1st cycle: explore possible new nodes for (i = 0; i < cur->numbbox; i++) if (VALIDO[i] == 1) { - errore = 0; // Failure de-bunked + errore = 0; // Failure de-bunked j = 0; - while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) j++; - - if (j >= cur->numbbox) + + if (j >= cur->numbbox) VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; - if (COSTO[i] + 1 < costominimo) + if (COSTO[i] + 1 < costominimo) costominimo = COSTO[i] + 1; } } - if (errore) + if (errore) fine = 1; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes @@ -1023,10 +1024,10 @@ short RMCharacter::FindPath(short source, short destination) { COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; for (j = 0; j < cur->numbbox; j++) - if (BOX[j].adj[NEXT[i]] == 1) + if (BOX[j].adj[NEXT[i]] == 1) BOX[j].adj[NEXT[i]] = 0; - - if (NEXT[i] == destination) + + if (NEXT[i] == destination) fine = 1; } } @@ -1036,7 +1037,7 @@ short RMCharacter::FindPath(short source, short destination) { pathlenght = COSTO[destination]; k = pathlenght; path[k] = destination; - + while (path[k] != source) { i = 0; while (BOX[i].adj[path[k]] != 2) @@ -1044,7 +1045,7 @@ short RMCharacter::FindPath(short source, short destination) { k--; path[k] = i; } - + pathlenght++; } @@ -1081,38 +1082,38 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkcount = 0; if (bReversed) { - while (0) ; + while (0) ; } int nPatt = GetCurPattern(); if (dx > dy) { slope = fy / fx; - if (lineend.x < linestart.x) + if (lineend.x < linestart.x) walkspeed = -walkspeed; walkstatus = 1; - + // Change the pattern for the new direction bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { - if (nPatt != PAT_WALKLEFT) - SetPattern(PAT_WALKLEFT); + if (nPatt != PAT_WALKLEFT) + SetPattern(PAT_WALKLEFT); } else { - if (nPatt != PAT_WALKRIGHT) + if (nPatt != PAT_WALKRIGHT) SetPattern(PAT_WALKRIGHT); } } else { slope = fx / fy; - if (lineend.y < linestart.y) + if (lineend.y < linestart.y) walkspeed = -walkspeed; walkstatus = 0; - + bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { - if (nPatt != PAT_WALKUP) - SetPattern(PAT_WALKUP); + if (nPatt != PAT_WALKUP) + SetPattern(PAT_WALKUP); } else { - if (nPatt != PAT_WALKDOWN) + if (nPatt != PAT_WALKDOWN) SetPattern(PAT_WALKDOWN); } } @@ -1132,9 +1133,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo)&& - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + while ((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { + nuovo.y--; + passi++; + } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.y--; // to avoid error? trovato = nuovo; @@ -1144,9 +1148,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { + nuovo.y++; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.y++; // to avoid error? trovato = nuovo; @@ -1156,9 +1163,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { + nuovo.x++; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.x++; // to avoid error? trovato = nuovo; @@ -1168,9 +1178,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { + nuovo.x--; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.x--; // to avoid error? trovato = nuovo; @@ -1210,7 +1223,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed =- Lspeed; + if (Lend.y < Lstart.y) Lspeed = - Lspeed; Lstatus = 0; } @@ -1227,7 +1240,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; - + if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; } @@ -1253,11 +1266,11 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { Ldy = ABS(Ldy); Lspeed = 1; Lcount = 0; - + if (Ldx > Ldy) { Lslope = Lfy / Lfx; if (Lend.x < Lstart.x) Lspeed = -Lspeed; - Lstatus=1; + Lstatus = 1; } else { Lslope = Lfx / Lfy; if (Lend.y < Lstart.y) Lspeed = -Lspeed; @@ -1268,9 +1281,9 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { for (;;) { if (InWhichBox(Lscan) != -1) { if (InWhichBox(Lscan) != Lbox) { - if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos),InWhichBox(Lscan))) + if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos), InWhichBox(Lscan))) return Lscan; - else + else Lbox = InWhichBox(Lscan); } } @@ -1279,10 +1292,10 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { if (Lstatus) { Ldx = Lspeed * Lcount; Ldy = Lslope * Ldx; - } else { + } else { Ldy = Lspeed * Lcount; Ldx = Lslope * Ldy; - } + } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; } @@ -1299,19 +1312,19 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { int x, y, distanzaminima; distanzaminima = 10000000; RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); - + for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); - + if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; } } - + return puntocaldo; } @@ -1333,7 +1346,7 @@ void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMCharacter::NewBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; - + // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); @@ -1371,11 +1384,11 @@ void RMCharacter::NewBoxEntered(int nBox) { // Recall On EnterBox mpalQueryDoAction(2, curLocation, curbox); } - -void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { + +void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CONTEXT; - bool bEndNow; - RMBoxLoc *cur; + bool bEndNow; + RMBoxLoc *cur; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1402,7 +1415,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { _ctx->bEndNow = true; } } - + // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; @@ -1431,11 +1444,11 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } - + walkcount++; // Update the character Z. @@@ Should remove only if the Z was changed - + // Check if the box was changed if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) NewBoxEntered(InWhichBox(m_pos)); @@ -1454,10 +1467,10 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { // If we still have to go through a box if (pathcount < pathlenght) { // Check if the box we're going into is active - if (_ctx->cur->boxes[path[pathcount-1]].attivo) { + if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); + CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); pathcount++; } else { // If the box is off, we can only block all @@ -1470,7 +1483,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { CoroScheduler.pulseEvent(hEndOfPath); } } else { - // If we have already entered the last box, we just have to move in a straight line towards the + // If we have already entered the last box, we just have to move in a straight line towards the // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; @@ -1520,7 +1533,7 @@ void RMCharacter::Stop(CORO_PARAM) { case PAT_WALKRIGHT: SetPattern(PAT_STANDRIGHT); break; - + default: SetPattern(PAT_STANDDOWN); break; @@ -1529,22 +1542,22 @@ void RMCharacter::Stop(CORO_PARAM) { CORO_END_CODE; } -inline int RMCharacter::InWhichBox(const RMPoint &pt) { - return theBoxes->WhichBox(curLocation, pt); +inline int RMCharacter::InWhichBox(const RMPoint &pt) { + return theBoxes->WhichBox(curLocation, pt); } void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CONTEXT; - RMPoint dest; - int numbox; - RMBoxLoc *cur; + RMPoint dest; + int numbox; + RMBoxLoc *cur; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); bMoving = true; - + // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { minpath = 0; @@ -1556,7 +1569,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { } // If clicked outside the box - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = InWhichBox(pt); if (_ctx->numbox == -1) { // Find neareste point inside the box _ctx->dest = NearestPoint(pt); @@ -1574,7 +1587,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { minpath = 0; status = STAND; bMovingWithoutMinpath = true; - if (ScanLine(pt)) + if (ScanLine(pt)) CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; @@ -1586,8 +1599,8 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { // a path to get there. We use the InvScanLine to search around a point _ctx->dest = InvScanLine(pt); pt = _ctx->dest; - - if (ScanLine(pt)) + + if (ScanLine(pt)) CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; @@ -1612,11 +1625,11 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; - + minpath = 0; status = STAND; m_pos = pt; - + if (newloc != -1) curLocation = newloc; @@ -1628,14 +1641,14 @@ void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { bRemoveFromOT = true; } -void RMCharacter::WaitForEndMovement(CORO_PARAM) { +void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (bMoving) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); + if (bMoving) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1722,9 +1735,12 @@ void RMBox::ReadFromStream(RMDataStream &ds) { // Hotspots for (i = 0; i < numhotspot; i++) { - ds >> w; hotspot[i].hotx = w; - ds >> w; hotspot[i].hoty = w; - ds >> w; hotspot[i].destination = w; + ds >> w; + hotspot[i].hotx = w; + ds >> w; + hotspot[i].hoty = w; + ds >> w; + hotspot[i].destination = w; } } @@ -1811,7 +1827,7 @@ void RMGameBoxes::Init(void) { RMRes res(10000 + i); ds.OpenBuffer(res); - + m_allBoxes[i] = new RMBoxLoc(); ds >> *m_allBoxes[i]; @@ -1832,7 +1848,7 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = GetBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && - (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) return true; else return false; @@ -1841,20 +1857,20 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { int i; RMBoxLoc *cur = GetBoxes(nLoc); - + if (!cur) return -1; - for (i = 0; inumbbox; i++) + for (i = 0; i < cur->numbbox; i++) if (cur->boxes[i].attivo) - if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && - (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && + (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) return i; return -1; } void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { - m_allBoxes[nLoc]->boxes[nBox].attivo=status; + m_allBoxes[nLoc]->boxes[nBox].attivo = status; m_allBoxes[nLoc]->RecalcAllAdj(); } @@ -1863,9 +1879,9 @@ int RMGameBoxes::GetSaveStateSize(void) { int size; int i; - size=4; + size = 4; - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { size += 4; size += m_allBoxes[i]->numbbox; } @@ -1874,17 +1890,17 @@ int RMGameBoxes::GetSaveStateSize(void) { } void RMGameBoxes::SaveState(byte *state) { - int i,j; - + int i, j; + // Save the number of locations with boxes WRITE_LE_UINT32(state, m_nLocBoxes); state += 4; // For each location, write out the number of boxes and their status - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); state += 4; - + for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; } @@ -1905,8 +1921,8 @@ void RMGameBoxes::LoadState(byte *state) { nbox = READ_LE_UINT32(state); state += 4; - for (j = 0; jnumbbox) + for (j = 0; j < nbox ; j++) { + if (j < m_allBoxes[i]->numbbox) m_allBoxes[i]->boxes[j].attivo = *state; state++; @@ -1933,7 +1949,7 @@ RMLocation::RMLocation() { /** * Load a location (.LOC) from a file that is provided. * - * @param lpszFileName Name of the file + * @param lpszFileName Name of the file */ bool RMLocation::Load(const char *lpszFileName) { Common::File f; @@ -1956,9 +1972,9 @@ bool RMLocation::Load(const char *lpszFileName) { /** * Load a location (.LOC) from a given open file * - * @param hFile File reference + * @param hFile File reference * - * @returns True if succeeded OK, false in case of error. + * @returns True if succeeded OK, false in case of error. */ bool RMLocation::Load(Common::File &file) { int size; @@ -1973,7 +1989,7 @@ bool RMLocation::Load(Common::File &file) { fs.OpenFile(file); bRet = Load(fs); fs.Close(); - + return bRet; } @@ -1992,8 +2008,8 @@ bool RMLocation::Load(const byte *buf) { /** * Load a location (.LOC) from a given data stream * - * @param ds Data stream - * @returns True if succeeded OK, false in case of error. + * @param ds Data stream + * @returns True if succeeded OK, false in case of error. */ bool RMLocation::Load(RMDataStream &ds) { char id[3]; @@ -2004,14 +2020,14 @@ bool RMLocation::Load(RMDataStream &ds) { // Check the ID ds >> id[0] >> id[1] >> id[2]; - + // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') return LoadLOX(ds); - + // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') - return false; + return false; // Version ds >> ver; @@ -2033,10 +2049,11 @@ bool RMLocation::Load(RMDataStream &ds) { m_curScroll.Set(0, 0); // Read the colour mode - ds >> cm; m_cmode = (RMColorMode)cm; + ds >> cm; + m_cmode = (RMColorMode)cm; // Initialise the source buffer and read the location - switch (m_cmode) { + switch (m_cmode) { case CM_256: m_buf = new RMGfxSourceBuffer8; break; @@ -2044,7 +2061,7 @@ bool RMLocation::Load(RMDataStream &ds) { case CM_65K: m_buf = new RMGfxSourceBuffer16; break; - + default: assert(0); break; @@ -2052,7 +2069,7 @@ bool RMLocation::Load(RMDataStream &ds) { // Initialise the surface, loading the palette if necessary m_buf->Init(ds, dimx, dimy, true); - + // Check the size of the location // assert(dimy!=512); @@ -2065,7 +2082,7 @@ bool RMLocation::Load(RMDataStream &ds) { _vm->FreezeTime(); - for (i = 0;i < m_nItems && !ds.IsError(); i++) + for (i = 0; i < m_nItems && !ds.IsError(); i++) ds >> m_items[i]; _vm->UnfreezeTime(); @@ -2099,14 +2116,14 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { // Initialise the surface, loading in the palette if necessary m_buf->Init(ds, dimx, dimy, true); - + // Number of items ds >> m_nItems; // Create and read objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; - + for (i = 0; i < m_nItems && !ds.IsError(); i++) m_items[i].ReadFromStream(ds, true); @@ -2124,12 +2141,12 @@ void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { - prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); + if (m_buf->Dimy() > RM_SY || m_buf->Dimx() > RM_SX) { + prim->SetSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); } prim->SetDst(m_fixedScroll); - + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); @@ -2148,33 +2165,33 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->AddPrim(new RMGfxPrimitive(this)); // Process all the location items - for (i = 0;i < m_nItems; i++) + for (i = 0; i < m_nItems; i++) m_items[i].DoFrame(bigBuf); } RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { int i; - + for (i = 0; i < m_nItems; i++) if (m_items[i].MpalCode() == (int)dwCode) return &m_items[i]; - - return NULL; + + return NULL; } RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; - + for (int i = 0; i < m_nItems; i++) { size = 0; if (m_items[i].IsIn(pt, &size)) { if (found == -1 || size < foundSize) { foundSize = size; found = i; - } + } } } @@ -2249,8 +2266,8 @@ void RMLocation::SetScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX>m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; - if (pt.y + RM_SY>m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + if (pt.x + RM_SX > m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; + if (pt.y + RM_SY > m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; m_curScroll = pt; @@ -2271,7 +2288,7 @@ void RMLocation::PauseSound(bool bPause) { * RMMessage Methods \****************************************************************************/ -RMMessage::RMMessage(uint32 dwId) { +RMMessage::RMMessage(uint32 dwId) { Load(dwId); } @@ -2287,19 +2304,19 @@ RMMessage::~RMMessage() { void RMMessage::Load(uint32 dwId) { lpMessage = mpalQueryMessage(dwId); assert(lpMessage != NULL); - + if (lpMessage) ParseMessage(); } void RMMessage::ParseMessage(void) { char *p; - + assert(lpMessage != NULL); - + nPeriods = 1; p = lpPeriods[0] = lpMessage; - + for (;;) { // Find the end of the current period while (*p != '\0') diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7085c81dcb..612e7b5d3e 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -62,7 +62,7 @@ public: byte m_data[1024]; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); + friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); }; @@ -79,14 +79,14 @@ public: RMSfx(); virtual ~RMSfx(); - friend RMDataStream& operator>>(RMDataStream &ds, RMSfx &sfx); + friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); void Play(bool bLoop = false); void SetVolume(int vol); void Pause(bool bPause); void Stop(void); - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -111,44 +111,46 @@ public: RMPoint m_pos; // Child co-ordinates public: - RMSlotType m_type; + RMSlotType m_type; int m_data; byte m_flag; public: - friend RMDataStream& operator>>(RMDataStream& ds, RMSlot& slot); + friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint Pos() { return m_pos; } + RMPoint Pos() { + return m_pos; + } - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; public: - RMString m_name; + RMString m_name; private: - int m_speed; - RMPoint m_pos; // Parent coordinates - RMPoint m_curPos; // Parent + child coordinates - int m_bLoop; - int m_nSlots; + int m_speed; + RMPoint m_pos; // Parent coordinates + RMPoint m_curPos; // Parent + child coordinates + int m_bLoop; + int m_nSlots; int m_nCurSlot; int m_nCurSprite; - RMSlot *m_slots; + RMSlot *m_slots; uint32 m_nStartTime; public: RMPattern(); virtual ~RMPattern(); - - friend RMDataStream& operator>>(RMDataStream& ds, RMPattern& pat); + + friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); // A warning that the pattern now and the current - int Init(RMSfx* sfx, bool bPlayP0=false, byte* bFlag=NULL); + int Init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); - // Update the pattern, checking to see if it's time to change slot and executing + // Update the pattern, checking to see if it's time to change slot and executing // any associated commands int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); @@ -156,9 +158,11 @@ public: void StopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint Pos() { return m_curPos; } + RMPoint Pos() { + return m_curPos; + } - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); private: void UpdateCoord(void); @@ -170,24 +174,24 @@ private: */ class RMSprite : public RMGfxTask { public: - RMString m_name; - RMRect m_rcBox; + RMString m_name; + RMRect m_rcBox; protected: - RMGfxSourceBuffer* m_buf; + RMGfxSourceBuffer *m_buf; public: RMSprite(); virtual ~RMSprite(); - void Init(RMGfxSourceBuffer* buf); - friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); + void Init(RMGfxSourceBuffer *buf); + friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); - void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); - void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -196,31 +200,33 @@ public: */ class RMItem : public RMGfxTask { public: - RMString m_name; + RMString m_name; protected: - int m_z; - RMPoint m_pos; // Coordinate nonno + int m_z; + RMPoint m_pos; // Coordinate nonno RMColorMode m_cm; RMPoint m_curScroll; byte m_FX; byte m_FXparm; - virtual int GetCurPattern() { return m_nCurPattern; } + virtual int GetCurPattern() { + return m_nCurPattern; + } private: int m_nCurPattern; int m_mpalCode; - RMPoint m_hot; + RMPoint m_hot; RMRect m_rcBox; - int m_nSprites,m_nSfx,m_nPatterns; - byte m_bPal; - RMPalette m_pal; + int m_nSprites, m_nSfx, m_nPatterns; + byte m_bPal; + RMPalette m_pal; - RMSprite *m_sprites; - RMSfx *m_sfx; - RMPattern *m_patterns; + RMSprite *m_sprites; + RMSfx *m_sfx; + RMPattern *m_patterns; byte m_bCurFlag; int m_nCurSprite; @@ -235,7 +241,7 @@ public: RMItem(); virtual ~RMItem(); - friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); + friend RMDataStream &operator>>(RMDataStream &ds, RMItem &item); // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame @@ -246,15 +252,19 @@ public: // Overloading of check whether to remove from active list virtual void RemoveThis(CORO_PARAM, bool &result); - + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int Priority() { return m_z; } + virtual int Priority() { + return m_z; + } // Pattern number - int NumPattern() { return m_nPatterns; } + int NumPattern() { + return m_nPatterns; + } // Set anew animation pattern, changing abruptly from the current virtual void SetPattern(int nPattern, bool bPlayP0 = false); @@ -263,9 +273,13 @@ public: void SetStatus(int nStatus); bool IsIn(const RMPoint &pt, int *size = NULL); - RMPoint Hotspot() { return m_hot; } + RMPoint Hotspot() { + return m_hot; + } bool GetName(RMString &name); - int MpalCode() { return m_mpalCode; } + int MpalCode() { + return m_mpalCode; + } // Unload void Unload(void); @@ -276,11 +290,13 @@ public: // Sets a new hotspot fro the object void ChangeHotspot(const RMPoint &pt); - void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } + void SetInitCurPattern(bool status) { + m_bInitCurPattern = status; + } void PlaySfx(int nSfx); -void ReadFromStream(RMDataStream& ds, bool bLOX=false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); void PauseSound(bool bPause); @@ -293,8 +309,8 @@ protected: }; -#define MAXBOXES 50 // Maximum number of allowed boxes -#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots +#define MAXBOXES 50 // Maximum number of allowed boxes +#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots class RMBox { public: @@ -304,11 +320,11 @@ public: }; public: - int left, top, right, bottom; // Vertici bounding boxes - int adj[MAXBOXES]; // List of adjacent bounding boxes - int numhotspot; // Hotspot number - uint8 Zvalue; // Z value for the bounding box - T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots + int left, top, right, bottom; // Vertici bounding boxes + int adj[MAXBOXES]; // List of adjacent bounding boxes + int numhotspot; // Hotspot number + uint8 Zvalue; // Z value for the bounding box + T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots bool attivo; bool bReversed; @@ -327,19 +343,19 @@ public: RMBox *boxes; private: - void ReadFromStream(RMDataStream& ds); + void ReadFromStream(RMDataStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); - friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); + friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); void RecalcAllAdj(void); }; #define GAME_BOXES_SIZE 200 -class RMGameBoxes { +class RMGameBoxes { protected: RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; int m_nLocBoxes; @@ -348,19 +364,19 @@ public: RMGameBoxes(); ~RMGameBoxes(); - void Init(void); + void Init(void); void Close(void); // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); int GetLocBoxesCount() const { return m_nLocBoxes; } - + // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); // Check whether a point is inside a given box bool IsInBox(int nLoc, int nBox, const RMPoint &pt); - + // Change the status of a box void ChangeBoxStatus(int nLoc, int nBox, int status); @@ -380,7 +396,7 @@ public: PAT_WALKUP, PAT_WALKDOWN, PAT_WALKLEFT, - PAT_WALKRIGHT + PAT_WALKRIGHT }; private: @@ -399,7 +415,7 @@ private: short path[MAXBOXES]; short pathlenght, pathcount; int curbox; - + STATUS status; int curSpeed; bool bEndOfPath; @@ -409,17 +425,17 @@ private: bool bRemoveFromOT; bool bMovingWithoutMinpath; RMGameBoxes *theBoxes; - + RMPoint m_fixedScroll; - + private: - int InWhichBox(const RMPoint &pt); - + int InWhichBox(const RMPoint &pt); + short FindPath(short source, short destination); RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); RMPoint NearestPoint(const RMPoint &punto); - - void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); + + void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); short ScanLine(const RMPoint &punto); RMPoint InvScanLine(const RMPoint &punto); RMPoint NearestHotSpot(int sourcebox, int destbox); @@ -439,21 +455,25 @@ public: void LinkToBoxes(RMGameBoxes *theBoxes); virtual void RemoveThis(CORO_PARAM, bool &result); - + // Update the position of a character - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool EndOfPath() { return bEndOfPath; } + bool EndOfPath() { + return bEndOfPath; + } // Change the pattern of a character to STOP virtual void Stop(CORO_PARAM); // Check if the character is moving - bool IsMoving() { return bMoving; } + bool IsMoving() { + return bMoving; + } // Move the character to a certain position void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); @@ -464,8 +484,12 @@ public: // Wait for the end of movement void WaitForEndMovement(CORO_PARAM); - void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } - void SetSpeed(int speed) { curSpeed = speed; } + void SetFixedScroll(const RMPoint &fix) { + m_fixedScroll = fix; + } + void SetSpeed(int speed) { + curSpeed = speed; + } }; @@ -485,9 +509,9 @@ public: RMWipe(); virtual ~RMWipe(); - void DoFrame(RMGfxTargetBuffer& bigBuf); + void DoFrame(RMGfxTargetBuffer &bigBuf); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - + void InitFade(int type); void CloseFade(void); void WaitForFadeEnd(CORO_PARAM); @@ -503,25 +527,29 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Name + RMString m_name; // Name - private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer *m_buf; // Location picture +private: + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer *m_buf; // Location picture - int m_nItems; // Number of objects - RMItem *m_items; // Objects + int m_nItems; // Number of objects + RMItem *m_items; // Objects - RMPoint m_curScroll; // Current scroll position + RMPoint m_curScroll; // Current scroll position RMPoint m_fixedScroll; public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; - RMPoint TEMPGetTonyStart() { return TEMPTonyStart; } + RMPoint TEMPGetTonyStart() { + return TEMPTonyStart; + } int TEMPNumLoc; - int TEMPGetNumLoc() { return TEMPNumLoc; } + int TEMPGetNumLoc() { + return TEMPNumLoc; + } public: RMLocation(); @@ -559,7 +587,9 @@ public: void UpdateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint ScrollPosition() { return m_curScroll; } + RMPoint ScrollPosition() { + return m_curScroll; + } // Pause sound void PauseSound(bool bPause); @@ -584,10 +614,18 @@ public: virtual ~RMMessage(); void Load(uint32 dwId); - bool IsValid() { return lpMessage != NULL; } - int NumPeriods() { return nPeriods; } - char *Period(int num) { return lpPeriods[num]; } - char *operator[](int num) { return lpPeriods[num]; } + bool IsValid() { + return lpMessage != NULL; + } + int NumPeriods() { + return nPeriods; + } + char *Period(int num) { + return lpPeriods[num]; + } + char *operator[](int num) { + return lpPeriods[num]; + } }; } // End of namespace Tony diff --git a/engines/tony/resid.h b/engines/tony/resid.h index aec4d4c38c..5215801d5d 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -27,7 +27,7 @@ */ /* - Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli + Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli */ #ifndef TONY_RESID_H #define TONY_RESID_H @@ -42,18 +42,18 @@ #define RES_I_INTERP4 10306 #define RES_I_INTERP5 10307 -#define RES_I_DLGTEXT 10350 +#define RES_I_DLGTEXT 10350 #define RES_I_DLGTEXTLINE 10351 -#define RES_I_DLGTEXTPAL 10352 +#define RES_I_DLGTEXTPAL 10352 -#define RES_I_MINIINTER 10360 +#define RES_I_MINIINTER 10360 -#define RES_P_PAL 10410 -#define RES_P_GO 10400 -#define RES_P_TAKE 10401 -#define RES_P_USE 10402 -#define RES_P_EXAM 10403 -#define RES_P_TALK 10404 +#define RES_P_PAL 10410 +#define RES_P_GO 10400 +#define RES_P_TAKE 10401 +#define RES_P_USE 10402 +#define RES_P_EXAM 10403 +#define RES_P_TALK 10404 #define RES_P_PAP1 10420 #define RES_P_PAP2 10421 diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 33dd6e1497..2f55bfad42 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -151,8 +151,7 @@ CODEC::CODEC(bool loop) { bEndReached = false; } -CODEC::~CODEC() -{ +CODEC::~CODEC() { } @@ -228,24 +227,21 @@ uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { bEndReached = false; dwEOF = 0; - ReadFile(hStream,lpBuf,dwSize, &dwRead, NULL); - - if (dwRead>4)&0xF; - } - else - delta=cache&0xF; - - /* Trova il nuovo indice */ - index+=indexTable[delta]; - if (index<0) index = 0; - if (index>88) index=88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign=delta&8; - delta=delta&7; - - /* Trova la differenza dal valore precedente */ - vpdiff=step>>3; - if (delta&4) vpdiff+=step; - if (delta&2) vpdiff+=step>>1; - if (delta&1) vpdiff+=step>>2; - - if (sign) - valpred-=vpdiff; - else - valpred+=vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred<-32768) - valpred=-32768; - - /* Aggiorna lo step */ - step=stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf++ = (signed short)valpred; - - bufferstep=!bufferstep; - } - - return eof/2; + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + uint32 dwRead; + + bufferstep = 1; + step = stepSizeTable[index]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = (cache >> 4) & 0xF; + } else + delta = cache & 0xF; + + /* Trova il nuovo indice */ + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step >> 3; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred = -32768; + + /* Aggiorna lo step */ + step = stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf++ = (signed short)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; #endif - return 0; + return 0; } uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { @@ -489,9 +479,9 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { bufferstep = 1; step = stepSizeTable[index]; - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); inp = lpTemp; @@ -506,18 +496,18 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { eof = 0; dwSize /= 2; - for (i = 0;i < dwSize; i++) { + for (i = 0; i < dwSize; i++) { /* Controlla se siamo alla fine del file, e bisogna loopare */ if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step = stepSizeTable[index]; } /* Legge il delta (4 bit) */ if (bufferstep) { cache = *inp++; - delta = (cache>>4)&0xF; + delta = (cache >> 4) & 0xF; } else delta = cache & 0xF; @@ -527,14 +517,14 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { if (index > 88) index = 88; /* Legge il segno e lo separa dall'ampliamento */ - sign = delta&8; - delta = delta&7; + sign = delta & 8; + delta = delta & 7; /* Trova la differenza dal valore precedente */ vpdiff = step >> 3; - if (delta&4) vpdiff += step; - if (delta&2) vpdiff += step >> 1; - if (delta&1) vpdiff += step >> 2; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; if (sign) valpred -= vpdiff; @@ -545,13 +535,13 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { if (valpred > 32767) valpred = 32767; else if (valpred < -32768) - valpred =- 32768; + valpred = - 32768; /* Aggiorna lo step */ step = stepSizeTable[index]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred; + *lpBuf ++ = (signed short)valpred; bufferstep = !bufferstep; } @@ -596,7 +586,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { /* Controlla se siamo alla fine del file, e bisogna loopare */ if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step[0] = stepSizeTable[index[0]]; step[1] = stepSizeTable[index[1]]; } @@ -609,7 +599,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { delta = (cache >> 4) & 0xF; /* Trova il nuovo indice */ - index[bufferstep]+=indexTable[delta]; + index[bufferstep] += indexTable[delta]; if (index[bufferstep] < 0) index[bufferstep] = 0; if (index[bufferstep] > 88) index[bufferstep] = 88; @@ -620,13 +610,13 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { /* Trova la differenza dal valore precedente */ vpdiff = step[bufferstep] >> 3; if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep]>>1; - if (delta & 1) vpdiff += step[bufferstep]>>2; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; if (sign) - valpred[bufferstep]-=vpdiff; + valpred[bufferstep] -= vpdiff; else - valpred[bufferstep]+=vpdiff; + valpred[bufferstep] += vpdiff; /* Controlla i limiti del valore trovato */ if (valpred[bufferstep] > 32767) @@ -638,9 +628,9 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { step[bufferstep] = stepSizeTable[index[bufferstep]]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred[bufferstep]; + *lpBuf ++ = (signed short)valpred[bufferstep]; - bufferstep=!bufferstep; + bufferstep = !bufferstep; } return eof / 2; @@ -655,7 +645,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) int delta; int sign; int vpdiff; - uint32 eof,i; + uint32 eof, i; int step[2]; bufferstep = 1; @@ -663,8 +653,8 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) step[1] = stepSizeTable[index[1]]; /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); inp = lpTemp; @@ -681,9 +671,9 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) dwSize /= 2; for (i = 0; i < dwSize; i++) { /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i==eof) { + if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step[0] = stepSizeTable[index[0]]; step[1] = stepSizeTable[index[1]]; } @@ -705,15 +695,15 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) delta = delta & 7; /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep]>>3; + vpdiff = step[bufferstep] >> 3; if (delta & 4) vpdiff += step[bufferstep]; if (delta & 2) vpdiff += step[bufferstep] >> 1; if (delta & 1) vpdiff += step[bufferstep] >> 2; if (sign) - valpred[bufferstep]-=vpdiff; + valpred[bufferstep] -= vpdiff; else - valpred[bufferstep]+=vpdiff; + valpred[bufferstep] += vpdiff; /* Controlla i limiti del valore trovato */ if (valpred[bufferstep] > 32767) @@ -725,7 +715,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) step[bufferstep] = stepSizeTable[index[bufferstep]]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred[bufferstep]; + *lpBuf ++ = (signed short)valpred[bufferstep]; bufferstep = !bufferstep; } @@ -775,17 +765,17 @@ bool FPSOUND::Init(/*HWND hWnd*/) { static char errbuf[128]; /* Salva l'handle della finestra nella variabile globale. DirectSound ha - bisogno dell'handle per effetuare il multitasking sonoro. */ + bisogno dell'handle per effetuare il multitasking sonoro. */ hwnd = hWnd; /* Di default, disabilita il sonoro. Se non troveremo problemi, lo - riabiliteremo alla fine della routine */ + riabiliteremo alla fine della routine */ bSoundSupported = false; /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. - In realta' sarebbe possibile richiedere una lista delle schede sonore - presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra - una perdita di tempo. */ + In realta' sarebbe possibile richiedere una lista delle schede sonore + presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra + una perdita di tempo. */ if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { return false; } @@ -799,50 +789,50 @@ bool FPSOUND::Init(/*HWND hWnd*/) { error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco - sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed - eventuali player in background saranno automaticamente stoppati. - Inoltre in questo modo e' possibile settare il formato di output sonoro - del primary buffer */ + sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed + eventuali player in background saranno automaticamente stoppati. + Inoltre in questo modo e' possibile settare il formato di output sonoro + del primary buffer */ if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { - MessageBox(hwnd,"Cannot set exclusive mode!","soundInit()", MB_OK); + MessageBox(hwnd, "Cannot set exclusive mode!", "soundInit()", MB_OK); return false; } /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, - ma noi vogliamo il pointer al primary perche' dobbiamo settare il - formato di output */ - ZeroMemory(&dsbdesc,sizeof(dsbdesc)); - dsbdesc.dwSize=sizeof(dsbdesc); - dsbdesc.dwFlags=DSBCAPS_CTRLVOLUME|DSBCAPS_PRIMARYBUFFER; + ma noi vogliamo il pointer al primary perche' dobbiamo settare il + formato di output */ + ZeroMemory(&dsbdesc, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_PRIMARYBUFFER; if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { - MessageBox(hwnd,"Cannot create primary buffer!","soundInit()", MB_OK); + MessageBox(hwnd, "Cannot create primary buffer!", "soundInit()", MB_OK); return false; } /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz - stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda - sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. - Inoltre in seguito sara' possibile lasciare scegliere all'utente il - formato da utilizzare */ - pcmwf.wBitsPerSample = ((dscaps.dwFlags&DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); + stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda + sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. + Inoltre in seguito sara' possibile lasciare scegliere all'utente il + formato da utilizzare */ + pcmwf.wBitsPerSample = ((dscaps.dwFlags & DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = ((dscaps.dwFlags&DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); + pcmwf.wf.nChannels = ((dscaps.dwFlags & DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); pcmwf.wf.nSamplesPerSec = 44100; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { - wsprintf(errbuf,"Error setting the output format (%lx)",err); - MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + wsprintf(errbuf, "Error setting the output format (%lx)", err); + MessageBox(hwnd, errbuf, "soundInit()", MB_OK); return false; } /* Controlla che il driver DirectSound supporti buffer secondari con - play di stream 16bit, 44khz stereo */ + play di stream 16bit, 44khz stereo */ if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { - wsprintf(errbuf,"Driver does not support 16bit 44khz stereo mixing! (%lu)",dscaps.dwMaxSecondarySampleRate); - MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + wsprintf(errbuf, "Driver does not support 16bit 44khz stereo mixing! (%lu)", dscaps.dwMaxSecondarySampleRate); + MessageBox(hwnd, errbuf, "soundInit()", MB_OK); return false; } @@ -911,7 +901,7 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { * * Return: true se tutto OK, false in caso di errore * -* Note: Vedi le note di CreateStream() +* Note: Vedi le note di CreateStream() * \****************************************************************************/ @@ -940,7 +930,7 @@ void FPSOUND::SetMasterVolume(int dwVolume) { return; if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); #endif @@ -961,7 +951,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { #ifdef REFACTOR_ME if (!bSoundSupported) return; - + lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; @@ -1026,8 +1016,8 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { * Function: ~FPSFX(); * * Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. * \****************************************************************************/ @@ -1076,7 +1066,7 @@ void FPSFX::Release() { * * Description: Apre un file di effetto sonoro e lo carica. * -* Input: byte *lpBuf Buffer dove si trova l'sfx +* Input: byte *lpBuf Buffer dove si trova l'sfx * uint32 dwCoded CODEC da utilizzare per decomprimere * i campioni sonori * @@ -1115,7 +1105,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') return false; - WAVHeader = (WAVH*)(lpBuf+8); + WAVHeader = (WAVH *)(lpBuf + 8); lpBuf += 8 + sizeof(WAVH); if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') @@ -1130,11 +1120,11 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { dwFreq = WAVHeader->nSamplesPerSec; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = (bStereo ? 2 : 1); pcmwf.wf.nSamplesPerSec = dwFreq; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1146,14 +1136,14 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } // Riempie il buffer - if ((err = lpDSBuffer->Lock(0,dwSize, &lpLock,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + if ((err = lpDSBuffer->Lock(0, dwSize, &lpLock, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1203,20 +1193,20 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { b16bit = true; bStereo = false; bIsVoice = true; - + // fread(&dwSize,1,4,vdbFP); // fread(&dwFreq,1,4,vdbFP); - ReadFile(vdbFP, &dwSize,4, &dwHi, NULL); - ReadFile(vdbFP, &dwFreq,4, &dwHi, NULL); + ReadFile(vdbFP, &dwSize, 4, &dwHi, NULL); + ReadFile(vdbFP, &dwFreq, 4, &dwHi, NULL); dwSize *= 4; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = (bStereo ? 2 : 1); pcmwf.wf.nSamplesPerSec = dwFreq; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1228,8 +1218,8 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } @@ -1239,10 +1229,10 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { return false; lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - + /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0,dwSize, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1255,10 +1245,10 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { delete lpCodec; /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { - wsprintf(errbuf,"Error creating notify object! (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::LoadVoiceFromVDB()", MB_OK); + wsprintf(errbuf, "Error creating notify object! (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::LoadVoiceFromVDB()", MB_OK); return false; } @@ -1268,7 +1258,7 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { dspnHot[0].hEventNotify = hEndOfBuffer; lpDSNotify->SetNotificationPositions(1, dspnHot); - + /* Tutto a posto, possiamo uscire */ bFileLoaded = true; SetVolume(62); @@ -1327,8 +1317,8 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { dwSize *= 4; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; @@ -1337,14 +1327,14 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwSize = sizeof(dsbdesc); dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; dsbdesc.dwBufferBytes = dwSize; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } @@ -1360,18 +1350,19 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { case FPCODEC_ADPCM: if (bStereo) - lpCodec = new CODECADPCMSTEREO(bLoop,lpTempBuffer); - else - lpCodec = new CODECADPCMMONO(bLoop,lpTempBuffer); - break; + lpCodec = new CODECADPCMSTEREO(bLoop, lpTempBuffer); + else + lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); + break; default: - return false;G + return false; + G } /* Riempie il buffer */ if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1504,7 +1495,7 @@ void FPSFX::SetVolume(int dwVolume) { if (!GLOBALS.bCfgDubbing) dwVolume = 0; else { dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; - if (dwVolume<0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; } } else { if (!GLOBALS.bCfgSFX) dwVolume = 0; @@ -1515,7 +1506,7 @@ void FPSFX::SetVolume(int dwVolume) { } #ifdef REFACTOR_ME if (bFileLoaded) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX-DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); #endif } @@ -1560,7 +1551,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; - lpDS=LPDS; + lpDS = LPDS; bSoundSupported = bSoundOn; bFileLoaded = false; bIsPlaying = false; @@ -1583,12 +1574,12 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { return true; /* Setta le strutture necessarie per la creazione di un secondary buffer - per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre - il controllo del volume, in modo da poter abbassare e alzare il volume - della musica indipendentemente da quello generale. Ovviamente si tratta - di un buffer in RAM */ + per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre + il controllo del volume, in modo da poter abbassare e alzare il volume + della musica indipendentemente da quello generale. Ovviamente si tratta + di un buffer in RAM */ pcmwf.wBitsPerSample = 16; - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = 2; pcmwf.wf.nSamplesPerSec = 44100; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1596,12 +1587,12 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { dsbdesc.dwSize = sizeof(dsbdesc); dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dwBufferSize=dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; + dwBufferSize = dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); bSoundSupported = false; return false; } @@ -1609,20 +1600,20 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave - all'interno dello stream. Le posizioni chiave si trovano rispettivamente - subito dopo l'inizio e subito dopo la meta' del buffer */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + all'interno dello stream. Le posizioni chiave si trovano rispettivamente + subito dopo l'inizio e subito dopo la meta' del buffer */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { - wsprintf(errbuf,"Error creating notify object! (%lx)",err); - MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + wsprintf(errbuf, "Error creating notify object! (%lx)", err); + MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); bSoundSupported = false; return false; } - hHot1=CreateEvent(NULL, false, false, NULL); - hHot2=CreateEvent(NULL, false, false, NULL); - hHot3=CreateEvent(NULL, false, false, NULL); + hHot1 = CreateEvent(NULL, false, false, NULL); + hHot2 = CreateEvent(NULL, false, false, NULL); + hHot3 = CreateEvent(NULL, false, false, NULL); hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); dspnHot[0].dwOffset = 32; @@ -1634,7 +1625,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - lpDSNotify->SetNotificationPositions(3,dspnHot); + lpDSNotify->SetNotificationPositions(3, dspnHot); #endif return true; } @@ -1681,7 +1672,7 @@ FPSTREAM::~FPSTREAM() { CloseHandle(hPlayThread_PlayNormal); hPlayThread_PlayNormal = NULL; } - + SyncToPlay = NULL; RELEASE(lpDSNotify); @@ -1743,18 +1734,18 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize if (!_file.open(lpszFileName)) //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); return false; - } +} - /* Si salva la lunghezza dello stream */ - dwSize = _file.size(); - _file.seek(0); +/* Si salva la lunghezza dello stream */ +dwSize = _file.size(); +_file.seek(0); - /* Tutto a posto, possiamo uscire */ - bFileLoaded = true; - bIsPlaying = false; - bPaused = false; +/* Tutto a posto, possiamo uscire */ +bFileLoaded = true; +bIsPlaying = false; +bPaused = false; #endif - return true; +return true; } @@ -1832,36 +1823,36 @@ void FPSTREAM::Prefetch(void) { /* Riempie il buffer per avere i dati gia' pronti */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock stream buffer!","soundLoadStream()", MB_OK); + MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); return; } - + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - + /* Unlocka il buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - + /* Crea il thread che fa il play dello stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - + /* Start il play del buffer DirectSound */ lpDSBuffer->SetCurrentPosition(0); bIsPlaying = true; dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { - int a=1; + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { + int a = 1; } #endif } @@ -1870,16 +1861,16 @@ void FPSTREAM::PlayFast(void) { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - + lpDSBuffer->Stop(); - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { warning("PlayFast SNP failed!"); } @@ -1908,58 +1899,57 @@ bool FPSTREAM::Play() { case FPCODEC_RAW: lpCodec = new CODECRAW(bLoop); break; - + case FPCODEC_ADPCM: lpCodec = new CODECADPCMSTEREO(bLoop); break; - + default: return false; } - + /* Posiziona lo stream file all'inizio */ _file.seek(0); lpDSBuffer->Stop(); lpDSBuffer->SetCurrentPosition(0); - + /* Riempie il buffer per avere i dati gia' pronti */ - if ((err = lpDSBuffer->Lock(0,dwBufferSize/2, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - error("Cannot lock stream buffer!","soundLoadStream()"); + if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + error("Cannot lock stream buffer!", "soundLoadStream()"); } - + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - + /* Unlocka il buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - + /* Crea il thread che fa il play dello stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); SetEvent(hPlayThread_PlayFast); - + #if 0 - /* Start il play del buffer DirectSound */ - lpDSBuffer->SetCurrentPosition(0); - - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize/2+32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) - { - int a=1; - } - - - lpDSBuffer->Play(0, 0,DSBPLAY_LOOPING); + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { + int a = 1; + } + + + lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING); #endif bIsPlaying = true; @@ -1996,9 +1986,9 @@ bool FPSTREAM::Stop(bool bSync) { // lpDSBuffer->Play(0, 0, 0); return true; } else { - /* Ferma il buffer DirectSound */ + /* Ferma il buffer DirectSound */ lpDSBuffer->Stop(); - + /* Avverte il thread che deve uscire e aspetta che si chiuda */ SetEvent(hThreadEnd); WaitForSingleObject(hPlayThread, CORO_INFINITE); @@ -2033,8 +2023,8 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { bSyncExit = true; char buf[1024]; - sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", - this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); + sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", + this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); warning(buf); WaitForSingleObject(hPlayThread, CORO_INFINITE); @@ -2043,7 +2033,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - + /* Disalloca e chiude il CODEC */ delete lpCodec; #endif @@ -2068,7 +2058,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { uint32 countEnd; bool bPrecache; char buf[1024]; - + /* Eventi che segnalano quando bisogna eseguire qualcosa */ HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; @@ -2077,7 +2067,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { while (cicla) { if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { countEnd++; - if (countEnd==3) + if (countEnd == 3) break; } @@ -2086,7 +2076,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); else if (bPrecache) This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); - + bPrecache = false; /* Attende il set di un evento. Dato che sono tutti in automatic reset, @@ -2100,12 +2090,12 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { // warning(buf); dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); -/* uint32 dwPlay, dwWrite; - This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); - sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); - warning(buf); */ + /* uint32 dwPlay, dwWrite; + This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); + sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); + warning(buf); */ - /* Fa uno switch per stabilire quale evento e' stato settato */ + /* Fa uno switch per stabilire quale evento e' stato settato */ switch (dwResult - WAIT_OBJECT_0) { case 0: /* Bisogna uscire dal thread */ @@ -2113,16 +2103,16 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { break; case 1: - /* Bisogna riempire la seconda meta' del buffer */ + /* Bisogna riempire la seconda meta' del buffer */ // if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) { // sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); // warning(buf); - This->lpDSBuffer->Lock(This->dwBufferSize/2,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult,(void **)&lpLockBuf2, &dwResult2, 0); - // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); - // warning(buf); - CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); - This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2,lpLockBuf2, 0); + This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); + // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); + // warning(buf); + CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); bPrecache = true; } break; @@ -2130,33 +2120,32 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { case 2: /* Bisogna riempire la prima meta' del buffer */ // if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) - { + { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); // warning(buf); - This->lpDSBuffer->Lock(0,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); - This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2, NULL, NULL); - bPrecache = true; - } - break; + This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); + CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); + bPrecache = true; + } + break; - case 3: - { + case 3: { // sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); // warning(buf); - if (This->bSyncExit) { + if (This->bSyncExit) { // sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); // warning(buf); - //This->SyncToPlay->PlayFast(); - SetEvent(This->SyncToPlay->hPlayThread_PlayFast); - // Transfer immediatly control to the other threads - Sleep(0); - This->bSyncExit = false; - cicla = false; - break; - } + //This->SyncToPlay->PlayFast(); + SetEvent(This->SyncToPlay->hPlayThread_PlayFast); + // Transfer immediatly control to the other threads + Sleep(0); + This->bSyncExit = false; + cicla = false; + break; } - break; + } + break; case 4: This->PlayFast(); @@ -2164,7 +2153,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { } } - /* Ferma il buffer DirectSound */ + /* Ferma il buffer DirectSound */ // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); @@ -2206,17 +2195,17 @@ void FPSTREAM::Pause(bool bPause) { } else if (!bPause && bPaused) { dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; } - + lpDSBuffer->Play(0, 0, bLoop); bIsPlaying = true; bPaused = false; @@ -2244,13 +2233,13 @@ void FPSTREAM::SetVolume(int dwVolume) { #ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; - + lastVolume = dwVolume; if (!GLOBALS.bCfgMusic) dwVolume = 0; else { dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; - if (dwVolume<0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; } if (lpDSBuffer) diff --git a/engines/tony/sound.h b/engines/tony/sound.h index bfa48f4d78..7defeb1149 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -73,144 +73,144 @@ private: DSCAPS dscaps; HWND hwnd; -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSOUND::FPSOUND(); -* -* Description: Costruttore di default. Inizializza gli attributi. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSOUND::FPSOUND(); + * + * Description: Costruttore di default. Inizializza gli attributi. + * + \****************************************************************************/ FPSOUND(); -/****************************************************************************\ -* -* Function: FPSOUND::~FPSOUND(); -* -* Description: Deinizializza l'oggetto, disallocando la memoria. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSOUND::~FPSOUND(); + * + * Description: Deinizializza l'oggetto, disallocando la memoria. + * + \****************************************************************************/ ~FPSOUND(); -/****************************************************************************\ -* -* Function: bool FPSOUND::Init(HWND hWnd); -* -* Description: Inizializza l'oggetto, e prepara tutto il necessario per -* creare stream e effetti sonori. -* -* Input: HWND hWnd Handle della finestra principale -* -* Return: True se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool FPSOUND::Init(HWND hWnd); + * + * Description: Inizializza l'oggetto, e prepara tutto il necessario per + * creare stream e effetti sonori. + * + * Input: HWND hWnd Handle della finestra principale + * + * Return: True se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Init(/*HWND hWnd*/); -/****************************************************************************\ -* -* Function: bool CreateStream(FPSTREAM** lplpStream); -* -* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo -* puntatore dopo averlo inizializzato. -* -* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto -* appena creato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPSTREAM -* e FPSFX richiedono che DirectSound sia gia' stato -* inzializzato. In questo modo quindi si evitano dei bugs -* che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPSTREAM o FPSFX globale (o cmq prima della -* inizializzazione di DirectSound). -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool CreateStream(FPSTREAM** lplpStream); + * + * Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo + * puntatore dopo averlo inizializzato. + * + * Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto + * appena creato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), + * sono dovute al fatto che i costruttori delle classi FPSTREAM + * e FPSFX richiedono che DirectSound sia gia' stato + * inzializzato. In questo modo quindi si evitano dei bugs + * che si verrebbero a creare se venisse dichiarata un oggetto + * di tipo FPSTREAM o FPSFX globale (o cmq prima della + * inizializzazione di DirectSound). + * + \****************************************************************************/ bool CreateStream(FPSTREAM **lplpStream); -/****************************************************************************\ -* -* Function: bool CreateSfx(FPSFX** lplpSfx); -* -* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo -* puntatore dopo averlo inizializzato. -* -* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto -* appena creato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -* Note: Vedi le note di CreateStream() -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool CreateSfx(FPSFX** lplpSfx); + * + * Description: Alloca un oggetti di tipo FPSFX e ritorna il suo + * puntatore dopo averlo inizializzato. + * + * Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto + * appena creato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + * Note: Vedi le note di CreateStream() + * + \****************************************************************************/ bool CreateSfx(FPSFX **lplpSfx); -/****************************************************************************\ -* -* Function: void SetMasterVolume(int dwVolume); -* -* Description: Setta il volume generale -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetMasterVolume(int dwVolume); + * + * Description: Setta il volume generale + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ void SetMasterVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetMasterVolume(LPINT lpdwVolume); -* -* Description: Richiede il volume generale -* -* Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetMasterVolume(LPINT lpdwVolume); + * + * Description: Richiede il volume generale + * + * Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) + * + \****************************************************************************/ void GetMasterVolume(int *lpdwVolume); }; class FPSFX { -/****************************************************************************\ -* Attributi -\****************************************************************************/ + /****************************************************************************\ + * Attributi + \****************************************************************************/ private: -/* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound -*/ + /* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound + */ bool bSoundSupported; // TRUE se il suono e' attivo bool bFileLoaded; // TRUE se e' stato aperto un file bool bLoop; // TRUE se bisogna loopare l'effetto sonoro bool bPaused; int lastVolume; - bool bStereo; // TRUE se stereo - bool b16bit; // TRUE se 16 bit - uint32 dwFreq; // Frequenza originale di campionamento + bool bStereo; // TRUE se stereo + bool b16bit; // TRUE se 16 bit + uint32 dwFreq; // Frequenza originale di campionamento // CODEC* lpCodec; // CODEC da utilizzare. bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro @@ -219,178 +219,178 @@ private: // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer // DSBPOSITIONNOTIFY dspnHot[2]; - + public: uint32 hEndOfBuffer; private: -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() -* -\****************************************************************************/ - - FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); - - -/****************************************************************************\ -* -* Function: ~FPSFX(); -* -* Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. -* -\****************************************************************************/ - - ~FPSFX(); - + /****************************************************************************\ + * + * Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); + * + * Description: Costruttore di default. *NON* bisogna dichiarare direttamente + * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() + * + \****************************************************************************/ + + FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + + + /****************************************************************************\ + * + * Function: ~FPSFX(); + * + * Description: Distruttore di default. Si preoccupa anche di fermare il sound + * effect eventualmente in esecuzione, e disallocare la memoria + * da esso occupata. + * + \****************************************************************************/ + + ~FPSFX(); + + + /****************************************************************************\ + * + * Function: Release(); + * + * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando + * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato + * creato con la FPSOUND::CreateStream(). + * + * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo + * questa chiamata. + * + \****************************************************************************/ -/****************************************************************************\ -* -* Function: Release(); -* -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). -* -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. -* -\****************************************************************************/ - - void Release(); + void Release(); -/****************************************************************************\ -* -* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Apre un file di effetto sonoro e lo carica. -* -* Input: char *lpszFile Nome del file di sfx da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * + * Description: Apre un file di effetto sonoro e lo carica. + * + * Input: char *lpszFile Nome del file di sfx da aprire + * uint32 dwCodec CODEC da utilizzare per decomprimere + * i campioni sonori + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); bool LoadVoiceFromVDB(Common::File &vdbFP); -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Suona lo sfx caricato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Play(); + * + * Description: Suona lo sfx caricato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ - bool Play(); + bool Play(); -/****************************************************************************\ -* -* Function: bool Stop(); -* -* Description: Ferma il play dello sfx. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Stop(); + * + * Description: Ferma il play dello sfx. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ - bool Stop(); + bool Stop(); -/****************************************************************************\ -* -* Function: void Pause(bool bPause); -* -* Description: Pause dell'effetto sonoro -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void Pause(bool bPause); + * + * Description: Pause dell'effetto sonoro + * + \****************************************************************************/ - void Pause(bool bPause); + void Pause(bool bPause); -/****************************************************************************\ -* -* Function: bool SetLoop(bool bLoop); -* -* Description: Attiva o disattiva il loop dello sfx. -* -* Input: bool bLoop TRUE per attivare il loop, FALSE per -* disattivarlo -* -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello sfx. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo sfx non viene fermato, -* e poi rimesso in play. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool SetLoop(bool bLoop); + * + * Description: Attiva o disattiva il loop dello sfx. + * + * Input: bool bLoop TRUE per attivare il loop, FALSE per + * disattivarlo + * + * Note: Il loop deve essere attivato PRIMA di eseguire il play + * dello sfx. Qualsiasi modifica effettuata durante il play + * non avra' effetto fino a che lo sfx non viene fermato, + * e poi rimesso in play. + * + \****************************************************************************/ - void SetLoop(bool bLoop); + void SetLoop(bool bLoop); -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Cambia il volume dello sfx -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetVolume(int dwVolume); + * + * Description: Cambia il volume dello sfx + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ - void SetVolume(int dwVolume); + void SetVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetVolume(int * lpdwVolume); -* -* Description: Chiede il volume dello sfx -* -* Input: int * lpdwVolume Variabile in cui verra' inserito -* il volume corrente -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetVolume(int * lpdwVolume); + * + * Description: Chiede il volume dello sfx + * + * Input: int * lpdwVolume Variabile in cui verra' inserito + * il volume corrente + * + \****************************************************************************/ - void GetVolume(int * lpdwVolume); + void GetVolume(int *lpdwVolume); }; class FPSTREAM { -/****************************************************************************\ -* Attributi -\****************************************************************************/ + /****************************************************************************\ + * Attributi + \****************************************************************************/ private: -/* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer -*/ + /* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer + */ byte *lpTempBuffer; // Buffer temporaneo per decompressione uint32 dwBufferSize; // Dimensione del buffer in bytes @@ -424,171 +424,171 @@ private: static void PlayThread(FPSTREAM *This); -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); + * + * Description: Costruttore di default. *NON* bisogna dichiarare direttamente + * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() + * + \****************************************************************************/ FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); -/****************************************************************************\ -* -* Function: ~FPSTREAM(); -* -* Description: Distruttore di default. Si preoccupa anche di fermare stream -* eventualmente in esecuzione, e disallocare la memoria da -* essi occupata. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: ~FPSTREAM(); + * + * Description: Distruttore di default. Si preoccupa anche di fermare stream + * eventualmente in esecuzione, e disallocare la memoria da + * essi occupata. + * + \****************************************************************************/ ~FPSTREAM(); -/****************************************************************************\ -* -* Function: Release(); -* -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). -* -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: Release(); + * + * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando + * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato + * creato con la FPSOUND::CreateStream(). + * + * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo + * questa chiamata. + * + \****************************************************************************/ void Release(); -/****************************************************************************\ -* -* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Apre un file di stream. -* -* Input: char *lpszFile Nome del file di stream da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * + * Description: Apre un file di stream. + * + * Input: char *lpszFile Nome del file di stream da aprire + * uint32 dwCodec CODEC da utilizzare per decomprimere + * i campioni sonori + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); -/****************************************************************************\ -* -* Function: UnloadFile(); -* -* Description: Chiude un file di stream eventualmente aperto. E' necessario -* richiamare questa funzione per disallocare la memoria -* occupata dallo stream. -* -* Return: Il distruttore della classe per sicurezza richiama la -* UnloadFile() se non e' stata richiamata esplicitamente. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: UnloadFile(); + * + * Description: Chiude un file di stream eventualmente aperto. E' necessario + * richiamare questa funzione per disallocare la memoria + * occupata dallo stream. + * + * Return: Il distruttore della classe per sicurezza richiama la + * UnloadFile() se non e' stata richiamata esplicitamente. + * + \****************************************************************************/ bool UnloadFile(); -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Suona lo stream caricato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Play(); + * + * Description: Suona lo stream caricato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Play(); void PlayFast(void); void Prefetch(void); -/****************************************************************************\ -* -* Function: bool Stop(); -* -* Description: Ferma il play dello stream. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Stop(); + * + * Description: Ferma il play dello stream. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Stop(bool bSync = false); - void WaitForSync(FPSTREAM* toplay); + void WaitForSync(FPSTREAM *toplay); -/****************************************************************************\ -* -* Function: void Pause(bool bPause); -* -* Description: Pause dell'effetto sonoro -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void Pause(bool bPause); + * + * Description: Pause dell'effetto sonoro + * + \****************************************************************************/ void Pause(bool bPause); -/****************************************************************************\ -* -* Function: bool SetLoop(bool bLoop); -* -* Description: Attiva o disattiva il loop dello stream. -* -* Input: bool bLoop TRUE per attivare il loop, FALSE per -* disattivarlo -* -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello stream. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo stream non viene fermato, -* e poi rimesso in play. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool SetLoop(bool bLoop); + * + * Description: Attiva o disattiva il loop dello stream. + * + * Input: bool bLoop TRUE per attivare il loop, FALSE per + * disattivarlo + * + * Note: Il loop deve essere attivato PRIMA di eseguire il play + * dello stream. Qualsiasi modifica effettuata durante il play + * non avra' effetto fino a che lo stream non viene fermato, + * e poi rimesso in play. + * + \****************************************************************************/ void SetLoop(bool bLoop); -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Cambia il volume dello stream -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetVolume(int dwVolume); + * + * Description: Cambia il volume dello stream + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ void SetVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetVolume(LPINT lpdwVolume); -* -* Description: Chiede il volume dello stream -* -* Input: LPINT lpdwVolume Variabile in cui verra' inserito -* il volume corrente -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetVolume(LPINT lpdwVolume); + * + * Description: Chiede il volume dello stream + * + * Input: LPINT lpdwVolume Variabile in cui verra' inserito + * il volume corrente + * + \****************************************************************************/ void GetVolume(int *lpdwVolume); }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e5988e7c9b..e5c30ffcec 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,8 +36,8 @@ namespace Tony { TonyEngine *_vm; -TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony") { +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), + _gameDescription(gameDesc), _randomSource("tony") { _vm = this; _loadSlotNumber = -1; @@ -90,7 +90,7 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); - // Init static class fields + // Init static class fields RMText::InitStatics(); RMTony::InitStatics(); @@ -174,7 +174,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in if (nChannel < 4) if (GLOBALS.flipflop) nChannel = nChannel + 1; - + switch (nFX) { case 0: case 1: @@ -186,62 +186,57 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 22: break; } - -#ifdef REFACTOR_ME + +#ifdef REFACTOR_ME // Mette il path giusto if (nChannel < 4) GetDataDirectory(DD_MUSIC, path_buffer); else GetDataDirectory(DD_LAYER, path_buffer); - _splitpath(path_buffer,drive,dir,NULL,NULL); - _splitpath(fn,NULL,NULL,fname,ext); - _makepath(path_buffer,drive,dir,fname,ext); + _splitpath(path_buffer, drive, dir, NULL, NULL); + _splitpath(fn, NULL, NULL, fname, ext); + _makepath(path_buffer, drive, dir, fname, ext); - _makepath(path_buffer,drive,dir,fname,ext); + _makepath(path_buffer, drive, dir, fname, ext); - if (nFX==22) // Sync a tempo - { - curChannel=nChannel; + if (nFX == 22) { // Sync a tempo + curChannel = nChannel; strcpy(nextMusic, path_buffer); - nextLoop=bLoop; - nextSync=nSync; + nextLoop = bLoop; + nextSync = nSync; if (flipflop) - nextChannel=nChannel-1; + nextChannel = nChannel - 1; else - nextChannel=nChannel+1; + nextChannel = nChannel + 1; DWORD id; - HANDLE hThread=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)DoNextMusic,m_stream,0,&id); - SetThreadPriority(hThread,THREAD_PRIORITY_HIGHEST); - } - else if (nFX==44) // Cambia canale e lascia finire il primo - { + HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, m_stream, 0, &id); + SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); + } else if (nFX == 44) { // Cambia canale e lascia finire il primo if (flipflop) - nextChannel=nChannel-1; + nextChannel = nChannel - 1; else - nextChannel=nChannel+1; + nextChannel = nChannel + 1; m_stream[nextChannel]->Stop(); m_stream[nextChannel]->UnloadFile(); if (!getIsDemo()) { - if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + if (!m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } m_stream[nextChannel]->SetLoop(bLoop); m_stream[nextChannel]->Play(); - flipflop = 1-flipflop; - } - else - { + flipflop = 1 - flipflop; + } else { if (!getIsDemo()) { - if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + if (!m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } m_stream[nChannel]->SetLoop(bLoop); @@ -320,9 +315,9 @@ void TonyEngine::PreloadSFX(int nChannel, const char *fn) { FPSFX *TonyEngine::CreateSFX(byte *buf) { FPSFX *sfx; - + _theSound.CreateSfx(&sfx); - sfx->LoadFile(buf,FPCODEC_WAV); + sfx->LoadFile(buf, FPCODEC_WAV); return sfx; } @@ -343,7 +338,7 @@ void TonyEngine::InitMusic() { _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); - + for (i = 0; i < 6; i++) _theSound.CreateStream(&m_stream[i]); @@ -389,7 +384,7 @@ Common::String TonyEngine::GetSaveStateFileName(int n) { void TonyEngine::AutoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; - Common::String buf; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -414,7 +409,7 @@ void TonyEngine::SaveState(int n, const char *name) { void TonyEngine::LoadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; - Common::String buf; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -491,14 +486,14 @@ void TonyEngine::Abort(void) { /** * Main process for playing the game. * - * @remarks This needs to be in a separate process, since there are some things that can briefly + * @remarks This needs to be in a separate process, since there are some things that can briefly * block the execution of process. For now, all ScummVm event handling is dispatched to within the context of this * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain * in the outer 'main' process. */ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - Common::String fn; + Common::String fn; CORO_END_CONTEXT(_ctx); @@ -517,7 +512,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); - // Call the engine to handle the next frame + // Call the engine to handle the next frame CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished diff --git a/engines/tony/tony.h b/engines/tony/tony.h index bdaffee7c9..f4d9d83674 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -69,7 +69,7 @@ enum { struct TonyGameDescription; -#define MAX_SFX_CHANNELS 32 +#define MAX_SFX_CHANNELS 32 struct VoiceHeader { int offset; @@ -100,7 +100,7 @@ public: uint32 m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; - FPSOUND _theSound; + FPSOUND _theSound; Globals _globals; Debugger *_debugger; @@ -143,7 +143,9 @@ public: Common::Language getLanguage() const; uint16 getVersion() const; bool getIsDemo() const; - RMGfxEngine *GetEngine() { return &_theEngine; } + RMGfxEngine *GetEngine() { + return &_theEngine; + } void GUIError(const Common::String &msg); virtual bool canLoadGameStateCurrently(); @@ -163,8 +165,12 @@ public: void SwitchFullscreen(bool bFull); void OptionScreen(void); - void ShowLocation(void) { m_bDrawLocation = true; } - void HideLocation(void) { m_bDrawLocation = false; } + void ShowLocation(void) { + m_bDrawLocation = true; + } + void HideLocation(void) { + m_bDrawLocation = false; + } // Reads the time uint32 GetTime(void); @@ -186,7 +192,7 @@ public: void PreloadSFX(int nSfx, const char *fn); void UnloadAllSFX(void); - + void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); @@ -204,9 +210,13 @@ public: // Get a thumbnail void GrabThumbnail(void); - uint16 *GetThumbnail(void) { return m_curThumbnail; } + uint16 *GetThumbnail(void) { + return m_curThumbnail; + } - void Quit(void) { m_bQuitNow = true; } + void Quit(void) { + m_bQuitNow = true; + } void OpenInitLoadMenu(CORO_PARAM); void OpenInitOptions(CORO_PARAM); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 593a05d863..71f95f8133 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -79,7 +79,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { RMGfxSourceBuffer8RLE *spr; - + assert(m_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; spr->SetAlphaBlendColor(1); @@ -109,7 +109,7 @@ void RMTony::Init(void) { // Reads his details from the stream ReadFromStream(ds, true); - + // Closes the buffer ds.Close(); @@ -130,15 +130,15 @@ void RMTony::Close(void) { void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CONTEXT; - int time; + int time; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); - - SetSpeed(GLOBALS.nCfgTonySpeed); + + SetSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->GetTime(); @@ -152,7 +152,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { // Check if we are at the end of a path if (EndOfPath() && m_bActionPending) { // Must perform the action on which we clicked - m_bActionPending = false; + m_bActionPending = false; } if (m_bIsTalking || m_bIsStaticTalk) @@ -192,9 +192,9 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Offest direction from scrolling prim->Dst().SetEmpty(); prim->Dst().Offset(-m_curScroll); - prim->Dst().Offset(m_pos); + prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); - prim->Dst() += m_nBodyOffset; + prim->Dst() += m_nBodyOffset; CORO_INVOKE_2(m_body.Draw, bigBuf, prim); } @@ -212,7 +212,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { CORO_BEGIN_CONTEXT; - bool result; + bool result; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -240,46 +240,46 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { uint32 pid; - + if (nAction == TA_COMBINE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); - + // If you failed the combine, we have RECEIVECOMBINE as a fallback if (pid == CORO_INVALID_PID_VALUE) { - pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); - + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + // If you failed with that, go with the generic // @@@ CombineGive! if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - - if (pid == CORO_INVALID_PID_VALUE){ + + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } } } else { // Perform the action - pid = mpalQueryDoAction(nAction, nActionItem, 0); + pid = mpalQueryDoAction(nAction, nActionItem, 0); } - + if (pid != CORO_INVALID_PID_VALUE) { m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { - pid = mpalQueryDoAction(6, 1, 0); + pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); - m_bAction = true; + m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + hActionThread = pid; } else { - pid = mpalQueryDoAction(5, 1, 0); + pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; @@ -306,7 +306,7 @@ void RMTony::StopNoAction(CORO_PARAM) { void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; - uint32 pid; + uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -318,7 +318,7 @@ void RMTony::Stop(CORO_PARAM) { if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { - bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). + bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } @@ -332,7 +332,7 @@ void RMTony::Stop(CORO_PARAM) { m_bActionPending = false; ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); - + m_ActionItem = NULL; CORO_END_CODE; @@ -344,7 +344,7 @@ int RMTony::GetCurPattern(void) { if (!m_bPastorella) return nPatt; - + switch (nPatt) { case PAT_PAST_STANDUP: return PAT_STANDUP; @@ -371,28 +371,28 @@ void RMTony::SetPattern(int nPatt, bool bPlayP0) { if (m_bPastorella) { switch (nPatt) { case PAT_STANDUP: - nPatt=PAT_PAST_STANDUP; + nPatt = PAT_PAST_STANDUP; break; case PAT_STANDDOWN: - nPatt=PAT_PAST_STANDDOWN; + nPatt = PAT_PAST_STANDDOWN; break; case PAT_STANDLEFT: - nPatt=PAT_PAST_STANDLEFT; + nPatt = PAT_PAST_STANDLEFT; break; case PAT_STANDRIGHT: - nPatt=PAT_PAST_STANDRIGHT; + nPatt = PAT_PAST_STANDRIGHT; break; case PAT_WALKUP: - nPatt=PAT_PAST_WALKUP; + nPatt = PAT_PAST_WALKUP; break; case PAT_WALKDOWN: - nPatt=PAT_PAST_WALKDOWN; + nPatt = PAT_PAST_WALKDOWN; break; case PAT_WALKLEFT: - nPatt=PAT_PAST_WALKLEFT; + nPatt = PAT_PAST_WALKLEFT; break; case PAT_WALKRIGHT: - nPatt=PAT_PAST_WALKRIGHT; + nPatt = PAT_PAST_WALKRIGHT; break; } } @@ -405,7 +405,7 @@ void RMTony::Take(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - assert(0); // Not while you're doing a StandDown + assert(0); // Not while you're doing a StandDown break; case PAT_STANDUP: @@ -552,7 +552,7 @@ void RMTony::Put(int nWhere, int nPart) { bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat) { + int &headLoopPat, int &bodyLoopPat) { assert(!m_bIsTalking); m_bIsTalking = true; @@ -573,7 +573,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_STANDLEFT: m_TalkDirection = LEFT; break; - + case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: @@ -605,7 +605,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: SetPattern(PAT_PAST_TALKDOWN); break; - + case LEFT: SetPattern(PAT_PAST_TALKLEFT); break; @@ -622,7 +622,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = 0; switch (nTalkType) { - case TALK_NORMAL: + case TALK_NORMAL: m_bCorpoDavanti = false; headStartPat = 0; bodyStartPat = 0; @@ -654,7 +654,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_FIANCHI: + case TALK_FIANCHI: m_bCorpoDavanti = false; switch (m_TalkDirection) { case UP: @@ -760,7 +760,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body m_nBodyOffset.Set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; - break; + break; } break; @@ -966,7 +966,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - // The beard is the only case in which the head is animated separately while the body is the standard + // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: switch (m_TalkDirection) { case LEFT: @@ -984,7 +984,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } break; - + case TALK_SCHIFATO: switch (m_TalkDirection) { case LEFT: @@ -1112,8 +1112,8 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_BEGIN_CONTEXT; - int headStartPat, bodyStartPat; - int headLoopPat, bodyLoopPat; + int headStartPat, bodyStartPat; + int headLoopPat, bodyLoopPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1122,7 +1122,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headLoopPat = _ctx->bodyLoopPat = 0; if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, - _ctx->headLoopPat, _ctx->bodyLoopPat)) + _ctx->headLoopPat, _ctx->bodyLoopPat)) return; // Perform the set pattern @@ -1131,13 +1131,13 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { SetPattern(_ctx->headStartPat); m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - + if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(m_body.WaitForEndPattern); if (_ctx->headStartPat != 0) CORO_INVOKE_0(WaitForEndPattern); } - + MainFreeze(); SetPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) @@ -1151,7 +1151,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; - + switch (m_TalkDirection) { case UP: finalPat = PAT_STANDUP; @@ -1178,7 +1178,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa MainFreeze(); SetPattern(finalPat); MainUnfreeze(); - m_bIsTalking = false; + m_bIsTalking = false; return false; } @@ -1203,7 +1203,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = BPAT_FIANCHILEFT_END; break; - case RIGHT: + case RIGHT: bodyEndPat = BPAT_FIANCHIRIGHT_END; break; } @@ -1219,12 +1219,12 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_RIDELEFT_END; else if (m_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; - + bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1235,12 +1235,12 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_SCHIFATORIGHT_END; break; } - + bodyEndPat = 0; break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1251,7 +1251,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_NAAHRIGHT_END; break; } - + bodyEndPat = 0; break; @@ -1259,7 +1259,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1282,7 +1282,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: bodyEndPat = 0; break; @@ -1305,7 +1305,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1321,7 +1321,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1337,7 +1337,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1353,7 +1353,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1396,7 +1396,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1427,9 +1427,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa void RMTony::EndTalk(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int headStandPat, headEndPat; - int bodyEndPat, finalPat; - bool bStatic; + int headStandPat, headEndPat; + int bodyEndPat, finalPat; + bool bStatic; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1465,7 +1465,7 @@ void RMTony::EndTalk(CORO_PARAM) { CORO_INVOKE_0(m_body.WaitForEndPattern); } - m_bIsTalking = false; + m_bIsTalking = false; return; } @@ -1480,7 +1480,7 @@ void RMTony::EndTalk(CORO_PARAM) { MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - + CORO_INVOKE_0(WaitForEndPattern); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->bodyEndPat != 0) { @@ -1493,7 +1493,7 @@ void RMTony::EndTalk(CORO_PARAM) { MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - + CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(m_body.WaitForEndPattern); @@ -1514,13 +1514,13 @@ void RMTony::EndTalk(CORO_PARAM) { MainUnfreeze(); } - m_bIsTalking = false; + m_bIsTalking = false; CORO_END_CODE; } void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat) { + int &bodyStartPat, int &bodyLoopPat) { int nPat = GetCurPattern(); headLoopPat = -1; @@ -1539,7 +1539,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat m_TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; - + case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: @@ -1728,8 +1728,8 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; - int headPat, headLoopPat; - int bodyStartPat, bodyLoopPat; + int headPat, headLoopPat; + int bodyStartPat, bodyLoopPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1745,7 +1745,7 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); CORO_INVOKE_0(WaitForEndPattern); MainFreeze(); @@ -1774,7 +1774,8 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: switch (m_TalkDirection) { - case UP: case LEFT: + case UP: + case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; break; @@ -1812,7 +1813,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; } break; - + case TALK_CONCARTESTATIC: switch (m_TalkDirection) { case UP: @@ -1895,9 +1896,9 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; - int bodyEndPat; - int finalPat; - int headEndPat; + int bodyEndPat; + int finalPat; + int headEndPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1913,21 +1914,21 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { SetPattern(_ctx->headEndPat); MainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(WaitForEndPattern); } else { // Play please MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); } MainFreeze(); SetPattern(_ctx->finalPat); m_body.SetPattern(0); MainUnfreeze(); - + m_bIsStaticTalk = false; CORO_END_CODE; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a7109256f5..a1c7fc152b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -112,7 +112,7 @@ protected: // Watch thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); -public: +public: enum PATTERNS { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, @@ -120,7 +120,7 @@ public: PAT_TAKEUP_MID2, PAT_TAKEUP_DOWN1, PAT_TAKEUP_DOWN2, - + PAT_TAKELEFT_UP1, PAT_TAKELEFT_UP2, PAT_TAKELEFT_MID1, @@ -242,7 +242,7 @@ public: PAT_PUTUP_MID2, PAT_PUTUP_DOWN1, PAT_PUTUP_DOWN2, - + PAT_CONSEGRETARIA }; @@ -363,7 +363,7 @@ public: // Initialise Tony void Init(void); - + // Free all memory void Close(void); @@ -391,21 +391,29 @@ public: int GetCurPattern(); // Waits until the end of a pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } // Check if currently in an action - bool InAction() { return (m_bActionPending && m_Action != 0) | m_bAction; } + bool InAction() { + return (m_bActionPending && m_Action != 0) | m_bAction; + } // Check if there needs to be an update for scrolling movement - bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } + bool MustUpdateScrolling() { + return ((!InAction()) || (IsMoving())); + } // Returns Tony's position - RMPoint Position() { return m_pos; } + RMPoint Position() { + return m_pos; + } // Set the scrolling position - void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } + void SetScrollPosition(const RMPoint &pt) { + RMCharacter::SetScrollPosition(pt); + } // Set the take animation void Take(int nWhere, int nPart); @@ -413,26 +421,32 @@ public: // Start or End Talk bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat); + int &headLoopPat, int &bodyLoopPat); void StartTalk(CORO_PARAM, TALKTYPE nTalkType); bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void EndTalk(CORO_PARAM); // Start or End Static void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat); + int &bodyStartPat, int &bodyLoopPat); void StartStatic(CORO_PARAM, TALKTYPE nTalkType); void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void EndStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } - int GetPastorella(void) { return m_bPastorella; } + void SetPastorella(bool bIsPast) { + m_bPastorella = bIsPast; + } + int GetPastorella(void) { + return m_bPastorella; + } // Perform an action void ExecuteAction(int nAction, int nActionItem, int nParm); - void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } + void PlaySfx(int nSfx) { + RMItem::PlaySfx(nSfx); + } }; } // End of namespace Tony diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 9aaffefceb..92b896b180 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -67,7 +67,7 @@ RMString::RMString(const RMString &str) { /** * Constructor from a char * */ -RMString::RMString(const char* str) { +RMString::RMString(const char *str) { // Use the overloaded '=' when copying m_string = NULL; m_length = 0; @@ -88,16 +88,16 @@ RMString::RMString(const int ch) { /** * Returns the length of the string - * @returns Length + * @returns Length */ int RMString::Length() const { - return m_length; + return m_length; } /** * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character + * @param nIndex Position of the character to return + * @returns Character */ char RMString::GetAt(int nIndex) { assert(nIndex < m_length); @@ -106,8 +106,8 @@ char RMString::GetAt(int nIndex) { /** * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character + * @param nIndex Position of the character to change + * @param c Character */ void RMString::SetAt(int nIndex, char c) { assert(nIndex < m_length); @@ -116,8 +116,8 @@ void RMString::SetAt(int nIndex, char c) { /** * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character + * @param nIndex Position of the charactre to reference + * @params Reference to the character */ char &RMString::operator[](int nIndex) { assert(nIndex < m_length); @@ -126,8 +126,8 @@ char &RMString::operator[](int nIndex) { /** * Copies a string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -147,16 +147,16 @@ const RMString &RMString::operator=(const RMString &str) { // Copy the string Common::copy(str.m_string, str.m_string + m_length + 1, m_string); } - + return *this; } /** * Copies a char * string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const char* str) { +const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { if (m_realLength > 0) { @@ -180,11 +180,11 @@ const RMString& RMString::operator=(const char* str) { /** * Forms a string from a passed character - * @param ch Character to copy - * @returns Refrence to our string + * @param ch Character to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const int ch) { - if (ch=='\0') { +const RMString &RMString::operator=(const int ch) { + if (ch == '\0') { // Destroy the current string if (m_realLength > 0) { delete [] m_string; @@ -203,17 +203,17 @@ const RMString& RMString::operator=(const int ch) { return *this; } -/** +/** * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string + * @param str String to concatenate + * @param size Length of the string */ void RMString::Connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length+size; + nlen = m_length + size; // Resize Resize(nlen + 1, true); @@ -228,18 +228,18 @@ void RMString::Connect(const char *str, int size) { /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str,str.Length()); + Connect(str, str.Length()); return *this; } /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { Connect(str, strlen(str)); @@ -248,8 +248,8 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character - * @param ch Character to concatenate - * @returns Refrence to our string + * @param ch Character to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -264,17 +264,17 @@ const RMString &RMString::operator+=(const int ch) { /** * Casts a string as char * - * @returns char * reference to string + * @returns char * reference to string */ -RMString::operator char*() const { +RMString::operator char *() const { return m_string; } /** * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. + * @param size New size necessary (in bytes) + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -282,7 +282,7 @@ void RMString::Resize(int size, bool bMantain) { m_realLength = size; } else if (size > m_realLength) { if (bMantain) { - char* app; + char *app; app = new char[size]; Common::copy(m_string, m_string + m_length + 1, app); @@ -346,13 +346,13 @@ RMString operator+(RMString &str, const char *s) { RMString operator+(const char *s, RMString &str) { RMString ret(s); - return (ret+=str); + return (ret += str); } /** * Extracts a string from a data stream - * @param df data stream - * @param var String + * @param df data stream + * @param var String */ RMDataStream &operator>>(RMDataStream &df, RMString &var) { uint8 len; @@ -360,14 +360,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { df >> len; var.Resize(len + 1); - var.m_length=len+1; - + var.m_length = len + 1; + for (i = 0; i < len; i++) df >> var[i]; - var[i] = '\0'; + var[i] = '\0'; var.m_length = len; - + return df; } @@ -422,7 +422,7 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { } -RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { +RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { Seek(nBytes); return *this; } @@ -440,7 +440,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); - + case END: return _stream->seek(nBytes, SEEK_END); @@ -467,7 +467,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var,1); + df.Read(&var, 1); return df; } @@ -487,7 +487,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v,4); + df.Read(&v, 4); var = FROM_LE_32(v); return df; } @@ -530,10 +530,10 @@ void RMDataStream::Close(void) { /** * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. */ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { m_length = size; @@ -544,7 +544,7 @@ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { /** * Returns the length of the stream - * @returns Stream length + * @returns Stream length */ int RMDataStream::Length() { return m_length; @@ -552,7 +552,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -560,9 +560,9 @@ bool RMDataStream::IsEOF() { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { df.Read(&var, 1); @@ -571,9 +571,9 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { df.Read(&var, 1); @@ -582,9 +582,9 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; @@ -596,9 +596,9 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; @@ -610,9 +610,9 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; @@ -624,9 +624,9 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; @@ -638,9 +638,9 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { /** * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -659,19 +659,19 @@ bool RMDataStream::Read(void *lpBuf, int size) { /** * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream + * @param nBytres Number of bytes to skip + * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos+=nBytes; + m_pos += nBytes; return *this; } /** * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes */ int RMDataStream::Seek(int nBytes, RMDSPos origin) { switch (origin) { @@ -689,13 +689,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; } - m_pos+=nBytes; + m_pos += nBytes; return m_pos; } /** * Returns the current position of the stream - * @returns The current position + * @returns The current position */ int RMDataStream::Pos() { return m_pos; @@ -703,7 +703,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -711,7 +711,7 @@ bool RMDataStream::IsError() { /** * Sets an error code for the stream - * @param code Error code + * @param code Error code */ void RMDataStream::SetError(int code) { m_bError = true; @@ -720,7 +720,7 @@ void RMDataStream::SetError(int code) { /** * Returns the error code for the stream - * @returns Error code + * @returns Error code */ int RMDataStream::GetError() { return m_ecode; @@ -903,11 +903,11 @@ RMPoint &RMRect::TopLeft() { RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad - return *((RMPoint*)this + 1); + return *((RMPoint *)this + 1); } RMPoint RMRect::Center() { - return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); + return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } int RMRect::Width() const { @@ -926,7 +926,7 @@ bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } -const RMRect& RMRect::operator=(const RMRect &rc) { +const RMRect &RMRect::operator=(const RMRect &rc) { CopyRect(rc); return *this; } @@ -960,29 +960,29 @@ RMRect operator+(const RMRect &rc, RMPoint p) { return (r += p); } -RMRect operator-(const RMRect& rc, RMPoint p) { +RMRect operator-(const RMRect &rc, RMPoint p) { RMRect r(rc); return (r -= p); } -RMRect operator+(RMPoint p, const RMRect& rc) { +RMRect operator+(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -RMRect operator-(RMPoint p, const RMRect& rc) { +RMRect operator-(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -bool RMRect::operator==(const RMRect& rc) { +bool RMRect::operator==(const RMRect &rc) { return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); } -bool RMRect::operator!=(const RMRect& rc) { +bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } @@ -1050,7 +1050,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // Found the index break; - if (i==_numUpd) + if (i == _numUpd) // Couldn't find a matching resource, so return NULL return NULL; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c823421c62..2eb6c5c2da 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -45,58 +45,58 @@ using namespace ::Tony::MPAL; class RMDataStream { protected: const byte *m_buf; - int m_length; - int m_pos; - bool m_bError; - int m_ecode; + int m_length; + int m_pos; + bool m_bError; + int m_ecode; public: - enum RMDSPos { - CUR, - START, - END - }; + enum RMDSPos { + CUR, + START, + END + }; private: - enum { - SIZENOTKNOWN = 0x7FFFFFFF - }; + enum { + SIZENOTKNOWN = 0x7FFFFFFF + }; public: - // Constructor and destructor - RMDataStream(); - virtual ~RMDataStream(); + // Constructor and destructor + RMDataStream(); + virtual ~RMDataStream(); - // Loading buffer - void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); + // Loading buffer + void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); void Close(void); - // Attributei - int Length(); - virtual int Pos(); - - // EOF - virtual bool IsEOF(); + // Attributei + int Length(); + virtual int Pos(); - // Read methods - friend RMDataStream &operator>>(RMDataStream &df, char &var); - friend RMDataStream &operator>>(RMDataStream &df, byte &var); - friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int &var); - friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - - // General read - virtual bool Read(void *buf, int size); - - // Skipping & Seeking - virtual RMDataStream &operator+=(int nBytes); - virtual int Seek(int nBytes, RMDSPos origin = CUR); + // EOF + virtual bool IsEOF(); - // Error handling - void SetError(int ecode); - int GetError(); - bool IsError(); + // Read methods + friend RMDataStream &operator>>(RMDataStream &df, char &var); + friend RMDataStream &operator>>(RMDataStream &df, byte &var); + friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int &var); + friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); + + // General read + virtual bool Read(void *buf, int size); + + // Skipping & Seeking + virtual RMDataStream &operator+=(int nBytes); + virtual int Seek(int nBytes, RMDSPos origin = CUR); + + // Error handling + void SetError(int ecode); + int GetError(); + bool IsError(); }; @@ -131,20 +131,20 @@ public: void Close(void); - RMDataStream& operator+=(int nBytes); - int Seek(int nBytes, RMDSPos where = CUR); + RMDataStream &operator+=(int nBytes); + int Seek(int nBytes, RMDSPos where = CUR); int Pos(); virtual bool IsEOF(); bool Read(void *buf, int size); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, char &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, byte &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint16 &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int16 &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint32 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); }; /** @@ -154,57 +154,57 @@ class RMString { private: char *m_string; int m_length; - int m_realLength; + int m_realLength; public: - RMString(); - ~RMString(); + RMString(); + ~RMString(); - // Assignment constructors - RMString(const RMString &str); - RMString(const char *str); - RMString(const int ch); + // Assignment constructors + RMString(const RMString &str); + RMString(const char *str); + RMString(const int ch); - // General methods - int Length() const; - void Compact(); + // General methods + int Length() const; + void Compact(); - // Access characters within string - char GetAt(int nIndex); - void SetAt(int nIndex, char c); - char& operator[](int nIndex); + // Access characters within string + char GetAt(int nIndex); + void SetAt(int nIndex, char c); + char &operator[](int nIndex); - // String cast - operator char*() const; + // String cast + operator char *() const; - // String assignments - const RMString &operator=(const RMString &str); - const RMString &operator=(const char *str); - const RMString &operator=(const int ch); + // String assignments + const RMString &operator=(const RMString &str); + const RMString &operator=(const char *str); + const RMString &operator=(const int ch); - // String concatenation - const RMString &operator+=(RMString &str); - const RMString &operator+=(const char *str); - const RMString &operator+=(const int ch); + // String concatenation + const RMString &operator+=(RMString &str); + const RMString &operator+=(const char *str); + const RMString &operator+=(const int ch); - // Concatentation of string or character - friend RMString operator+(const RMString &str1, const RMString &str2); + // Concatentation of string or character + friend RMString operator+(const RMString &str1, const RMString &str2); - friend RMString operator+(RMString& str, const int ch); - friend RMString operator+(const int ch, RMString &str); + friend RMString operator+(RMString &str, const int ch); + friend RMString operator+(const int ch, RMString &str); - friend RMString operator+(RMString &str, const char *s); - friend RMString operator+(const char *s, RMString &str); + friend RMString operator+(RMString &str, const char *s); + friend RMString operator+(const char *s, RMString &str); - // Extraction from data streams - friend RMDataStream& operator>>(RMDataStream& df, RMString &var); + // Extraction from data streams + friend RMDataStream &operator>>(RMDataStream &df, RMString &var); // String formatting void Format(const char *str, ...); private: - void Resize(int size, bool bMantain = false); - void Connect(const char* str, int size); + void Resize(int size, bool bMantain = false); + void Connect(const char *str, int size); }; /** @@ -215,89 +215,94 @@ public: int x, y; public: - // Constructor - RMPoint(); - RMPoint(const RMPoint &p); - RMPoint(int x1, int y1); + // Constructor + RMPoint(); + RMPoint(const RMPoint &p); + RMPoint(int x1, int y1); - // Copy - RMPoint& operator=(RMPoint p); + // Copy + RMPoint &operator=(RMPoint p); // Set - void Set(int x1, int y1) { x = x1; y = y1; } - - // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); - friend RMPoint operator+(RMPoint p1, RMPoint p2); - friend RMPoint operator-(RMPoint p1, RMPoint p2); - RMPoint &operator+=(RMPoint p); - RMPoint &operator-=(RMPoint p); - RMPoint operator-(); - - // Comparison - bool operator==(RMPoint p); - bool operator!=(RMPoint p); - - // Casting a POINT + void Set(int x1, int y1) { + x = x1; + y = y1; + } + + // Offset + void Offset(int xOff, int yOff); + void Offset(const RMPoint &p); + friend RMPoint operator+(RMPoint p1, RMPoint p2); + friend RMPoint operator-(RMPoint p1, RMPoint p2); + RMPoint &operator+=(RMPoint p); + RMPoint &operator-=(RMPoint p); + RMPoint operator-(); + + // Comparison + bool operator==(RMPoint p); + bool operator!=(RMPoint p); + + // Casting a POINT operator Common::Point() const; - // Extraction from data streams - friend RMDataStream& operator>>(RMDataStream &ds, RMPoint &p); + // Extraction from data streams + friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); }; class RMRect { public: - int x1,y1; - int x2,y2; + int x1, y1; + int x2, y2; public: - RMRect(); - RMRect(int x1, int y1, int x2, int y2); - RMRect(const RMPoint &p1, const RMPoint &p2); - RMRect(const RMRect &rc); - - // Attributes - RMPoint &TopLeft(); - RMPoint &BottomRight(); - RMPoint Center(); - int Width() const; - int Height() const; - bool IsEmpty() const; + RMRect(); + RMRect(int x1, int y1, int x2, int y2); + RMRect(const RMPoint &p1, const RMPoint &p2); + RMRect(const RMRect &rc); + + // Attributes + RMPoint &TopLeft(); + RMPoint &BottomRight(); + RMPoint Center(); + int Width() const; + int Height() const; + bool IsEmpty() const; int Size() const; - // Set - void SetRect(int x1, int y1, int x2, int y2); - void SetRect(const RMPoint &p1, const RMPoint &p2); - void SetEmpty(void); - - // Copiers - void SetRect(const RMRect &rc); - void CopyRect(const RMRect &rc); - const RMRect &operator=(const RMRect &rc); - - // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); - friend RMRect operator+(const RMRect &rc, RMPoint p); - friend RMRect operator-(const RMRect &rc, RMPoint p); - friend RMRect operator+(RMPoint p, const RMRect &rc); - friend RMRect operator-(RMPoint p, const RMRect &rc); - const RMRect &operator+=(RMPoint p); - const RMRect &operator-=(RMPoint p); - - // Comparison - bool operator==(const RMRect &rc); - bool operator!=(const RMRect &rc); - - // Normalise - void NormalizeRect(); + // Set + void SetRect(int x1, int y1, int x2, int y2); + void SetRect(const RMPoint &p1, const RMPoint &p2); + void SetEmpty(void); + + // Copiers + void SetRect(const RMRect &rc); + void CopyRect(const RMRect &rc); + const RMRect &operator=(const RMRect &rc); + + // Offset + void Offset(int xOff, int yOff); + void Offset(const RMPoint &p); + friend RMRect operator+(const RMRect &rc, RMPoint p); + friend RMRect operator-(const RMRect &rc, RMPoint p); + friend RMRect operator+(RMPoint p, const RMRect &rc); + friend RMRect operator-(RMPoint p, const RMRect &rc); + const RMRect &operator+=(RMPoint p); + const RMRect &operator-=(RMPoint p); + + // Comparison + bool operator==(const RMRect &rc); + bool operator!=(const RMRect &rc); + + // Normalise + void NormalizeRect(); // Point in rect - bool PtInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } + bool PtInRect(const RMPoint &pt) { + return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); + } - // Extract from data stream - friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); + // Extract from data stream + friend RMDataStream &operator>>(RMDataStream &ds, RMRect &rc); }; /** diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 0f36c72f97..6b61d25ea2 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -39,7 +39,7 @@ namespace Tony { * RMWindow Methods \****************************************************************************/ -RMWindow::RMWindow() { +RMWindow::RMWindow() { } @@ -93,7 +93,7 @@ void RMWindow::Unlock() { */ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && - (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { + (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { // Full screen clear wanted, so use shortcut method g_system->fillScreen(0); } else { @@ -136,14 +136,14 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { if (!rcBoundEllipse.isValidRect()) return; - Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, - rcBoundEllipse.top + rcBoundEllipse.height() / 2); + Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, + rcBoundEllipse.top + rcBoundEllipse.height() / 2); // The rectangle technically defines the area inside the ellipse, with the corners touching // the ellipse boundary. Since we're currently simulating the ellipse using a plain circle, // we need to calculate a necessary width using the hypotenuse of X/2 & Y/2 int x2y2 = (rcBoundEllipse.width() / 2) * (rcBoundEllipse.width() / 2) + - (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); + (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); int radius = 0; while ((radius * radius) < x2y2) ++radius; @@ -155,11 +155,11 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { while (x >= y) { plotSplices(lpBuf, center, x, y); - + error += y; ++y; error += y; - + if (error >= 0) { error -= x; --x; @@ -173,7 +173,7 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { */ void RMWindow::plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y) { plotLines(lpBuf, center, x, y); - if (x != y) + if (x != y) plotLines(lpBuf, center, y, x); } @@ -206,11 +206,11 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; +byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; - + int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; @@ -219,13 +219,13 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; - + if (lpDestBuf == NULL) src += (RM_SY - 1) * RM_BBX; if (dezoom == 1 && 0) { byte *curOut = rgb; - + for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x]; @@ -242,32 +242,32 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src -= RM_BBX; else src += RM_BBX; - } + } } else { for (int y = 0; y < dimy; y++) { - for(int x = 0; x < dimx; x++) { + for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; sommar = sommab = sommag = 0; - + for (v = 0; v < dezoom; v++) { for (u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else curv = v; - + sommab += cursrc[curv * RM_BBX + u] & 0x1F; sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } - rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); + rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); - if (lpDestBuf!=NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + if (lpDestBuf != NULL) + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); k += 3; } diff --git a/engines/tony/window.h b/engines/tony/window.h index 73cc6d2005..0f614fca97 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -42,7 +42,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer used to convert to RGB - static byte rgb[RM_SX * RM_SY * 3]; + static byte rgb[RM_SX *RM_SY * 3]; public: // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); @@ -95,7 +95,9 @@ public: // Request a thumbnail be grabbed during the next frame void GrabThumbnail(uint16 *buf); - int getFps() const { return fps; } + int getFps() const { + return fps; + } }; } // End of namespace Tony -- cgit v1.2.3 From 75a0b0c6296af6600ce1a4e585fb7c5b9a0ea203 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 23 May 2012 00:19:46 +0200 Subject: TONY: Some more code formatting --- engines/tony/custom.cpp | 10 ---- engines/tony/font.cpp | 56 ++++++++++++------- engines/tony/mpal/expr.cpp | 64 +++++++++++----------- engines/tony/mpal/expr.h | 2 - engines/tony/mpal/loadmpc.cpp | 124 ++++++++++++++++++++++++++---------------- engines/tony/mpal/mpal.cpp | 44 +++++++-------- engines/tony/mpal/mpaldll.h | 4 +- 7 files changed, 166 insertions(+), 138 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0127494007..a6381e0937 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2073,16 +2073,6 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } - - - - - - - - - - /* * Music * ----- diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 66f1ccdcd9..6b6778044d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1430,8 +1430,8 @@ void RMFontCredits::Init(void) { * Metodi di RMFontObj \****************************************************************************/ -#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) -#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) +#define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) +#define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1849,7 +1849,8 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { j += font->StringLen(*p); if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { j -= font->StringLen(*p, p[1]); - if (j > x) x = j; + if (j > x) + x = j; // Back to the first usable space // @@ -1858,13 +1859,15 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // This workaround has the partial word broken up so it will still display // old_p = p; - while (*p != ' ' && *p != '-' && p > string) p--; + while (*p != ' ' && *p != '-' && p > string) + p--; if (p == string) p = old_p; // Check if there are any blanks to end - while (*p == ' ' && *p != '\0') p++; + while (*p == ' ' && *p != '\0') + p++; if (*p == '\0') break; p--; @@ -1875,7 +1878,8 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { p++; } - if (j > x) x = j; + if (j > x) + x = j; i++; numlines = i; @@ -1948,10 +1952,14 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { void RMText::ClipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; - if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1 + m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 < 5) + prim->Dst().x1 = 5; + if (prim->Dst().y1 < 5) + prim->Dst().y1 = 5; + if (prim->Dst().x1 + m_dimx > 635) + prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1 + m_dimy > 475) + prim->Dst().y1 = 475 - m_dimy; } void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2068,34 +2076,40 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Don't erase the background if (m_bSkipStatus) { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { - if (!m_bForceNoTime) + if (!m_bForceNoTime) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; + } } + } - if (!m_bNoTab) + if (!m_bNoTab) { if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; + } - if (!m_bNoTab) - if (m_input) + if (!m_bNoTab) { + if (m_input) { if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) return; + } + } } // Erase the background - else { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) - if (!m_bForceNoTime) - if (_vm->GetTime() > (uint32)m_time + m_startTime) - return; + else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (!m_bForceNoTime) { + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return; + } } // If time is forced - if (m_bForceTime) + if (m_bForceTime) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; + } if (hCustomSkip != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index aaec74fb4c..ae6dfac482 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -43,37 +43,36 @@ namespace MPAL { * @defgroup Mathamatical operations */ -#define OP_MUL ((1<<4)|0) -#define OP_DIV ((1<<4)|1) -#define OP_MODULE ((1<<4)|2) -#define OP_ADD ((2<<4)|0) -#define OP_SUB ((2<<4)|1) -#define OP_SHL ((3<<4)|0) -#define OP_SHR ((3<<4)|1) -#define OP_MINOR ((4<<4)|0) -#define OP_MAJOR ((4<<4)|1) -#define OP_MINEQ ((4<<4)|2) -#define OP_MAJEQ ((4<<4)|3) -#define OP_EQUAL ((5<<4)|0) -#define OP_NOEQUAL ((5<<4)|1) -#define OP_BITAND ((6<<4)|0) -#define OP_BITXOR ((7<<4)|0) -#define OP_BITOR ((8<<4)|0) -#define OP_AND ((9<<4)|0) -#define OP_OR ((10<<4)|0) +#define OP_MUL ((1 << 4) | 0) +#define OP_DIV ((1 << 4) | 1) +#define OP_MODULE ((1 << 4) | 2) +#define OP_ADD ((2 << 4) | 0) +#define OP_SUB ((2 << 4) | 1) +#define OP_SHL ((3 << 4) | 0) +#define OP_SHR ((3 << 4) | 1) +#define OP_MINOR ((4 << 4) | 0) +#define OP_MAJOR ((4 << 4) | 1) +#define OP_MINEQ ((4 << 4) | 2) +#define OP_MAJEQ ((4 << 4) | 3) +#define OP_EQUAL ((5 << 4) | 0) +#define OP_NOEQUAL ((5 << 4) | 1) +#define OP_BITAND ((6 << 4) | 0) +#define OP_BITXOR ((7 << 4) | 0) +#define OP_BITOR ((8 << 4) | 0) +#define OP_AND ((9 << 4) | 0) +#define OP_OR ((10 << 4) | 0) /** * Object types that can be contained in an EXPRESSION structure */ enum ExprListTypes { - ELT_NUMBER = 1, - ELT_VAR = 2, - ELT_PARENTH = 3, + ELT_NUMBER = 1, + ELT_VAR = 2, + ELT_PARENTH = 3, ELT_PARENTH2 = 4 }; - /** * @defgroup Structures */ @@ -95,7 +94,7 @@ typedef struct { byte symbol; // Simbolo matematico (vedi #define OP_*) } EXPRESSION; -typedef EXPRESSION* LPEXPRESSION; +typedef EXPRESSION *LPEXPRESSION; /** @@ -186,13 +185,13 @@ static void Solve(LPEXPRESSION one, int num) { while (num > 1) { two=one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num=Compute(one->val.num, two->val.num,one->symbol); + two->val.num = Compute(one->val.num, two->val.num,one->symbol); CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { j = 1; three = two + 1; - while ((three->symbol != 0) && (two->symbol & 0xF0)>(three->symbol & 0xF0)) { + while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { two++; three++; j++; @@ -221,10 +220,10 @@ static int EvaluateAndFreeExpression(byte *expr) { one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i=0, cur=one; i < num; i++, cur++) { - if (cur->type==ELT_VAR) { - cur->type=ELT_NUMBER; - cur->val.num=varGetValue(cur->val.name); + for (i = 0, cur = one; i < num; i++, cur++) { + if (cur->type == ELT_VAR) { + cur->type = ELT_NUMBER; + cur->val.num = varGetValue(cur->val.name); } } @@ -265,7 +264,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); - if (*h==NULL) + if (*h == NULL) return NULL; start = (byte *)GlobalLock(*h); @@ -332,7 +331,6 @@ int EvaluateExpression(HGLOBAL h) { return ret; } - /** * Compare two mathematical expressions together * @@ -356,8 +354,8 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one = (LPEXPRESSION)(e1+1); - two = (LPEXPRESSION)(e2+1); + one = (LPEXPRESSION)(e1 + 1); + two = (LPEXPRESSION)(e2 + 1); for (i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 7d7ca09c41..17e9c1264b 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -47,7 +47,6 @@ namespace MPAL { */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); - /** * Calculate the value of a mathamatical expression * @@ -56,7 +55,6 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); */ int EvaluateExpression(HGLOBAL h); - /** * Compare two mathematical expressions together * diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a60c9f5f16..a80c85eb75 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -38,7 +38,6 @@ namespace Tony { namespace MPAL { - /****************************************************************************\ * Funzioni statiche \****************************************************************************/ @@ -54,7 +53,6 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); } - /** * Parses a script from the MPC file, and inserts its data into a structure * @@ -64,7 +62,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - int curCmd,j,len; + int curCmd, j, len; uint i; lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); @@ -76,31 +74,40 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { curCmd = 0; for (i = 0; i < lpmsScript->nMoments; i++) { - lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; + lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Moment[i].nCmds = *lpBuf; + lpBuf++; for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->Command[curCmd].type = *lpBuf; lpBuf++; + lpmsScript->Command[curCmd].type = *lpBuf; + lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; break; case 2: // Variable assign - len=*lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + len = *lpBuf; + lpBuf++; + lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->Command[curCmd].lpszVarName == NULL) return NULL; CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); - lpBuf+=len; + lpBuf += len; lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); if (lpBuf == NULL) - return NULL; + return NULL; break; default: @@ -111,11 +118,9 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { curCmd++; } } - return lpBuf; } - /** * Parses a dialog from the MPC file, and inserts its data into a structure * @@ -131,16 +136,19 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpBuf += 4; /* Periodi */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); @@ -152,14 +160,16 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Periods[i] = NULL; /* Gruppi */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) @@ -172,11 +182,16 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { switch (lpmdDialog->Command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpBuf += 4; break; // Variable assign @@ -197,7 +212,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpBuf += 2; break; default: @@ -222,13 +238,15 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpBuf += 2; num2 = *lpBuf++; @@ -256,16 +274,19 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); + lpBuf += 4; // PlayGroup - num3 = *lpBuf; *lpBuf++; + num3 = *lpBuf; + *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { - lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpBuf += 2; } lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; @@ -353,11 +374,16 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; break; case 2: // Variable assign @@ -385,7 +411,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - if (kk==curCmd) { + if (kk == curCmd) { lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; @@ -397,7 +423,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - lpmiItem->dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->dwRes = READ_LE_UINT32(lpBuf); + lpBuf += 4; return lpBuf; } @@ -418,7 +445,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) lpBuf += 2; lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -551,14 +578,15 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nItems = 0; GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nItems = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory and read them in GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; - GLOBALS.lpmiItems=(LPMPALITEM)GlobalLock(GLOBALS.hItems); + GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); for (i = 0; i < GLOBALS.nItems; i++) if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) @@ -570,8 +598,9 @@ bool ParseMpc(const byte *lpBuf) { // Check the locations GLOBALS.nLocations = 0; GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; - if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { - GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; + if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8) == 0) { + GLOBALS.nLocations = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory and read them in GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); @@ -591,7 +620,8 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nScripts = 0; GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nScripts = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); @@ -611,7 +641,6 @@ bool ParseMpc(const byte *lpBuf) { //sizeof(GLOBALS.lpmsScripts[i].Moment[0]), //(int (*)(const void *, const void *))CompareMoments //); - } GlobalUnlock(GLOBALS.hScripts); @@ -623,7 +652,6 @@ bool ParseMpc(const byte *lpBuf) { return true; } - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a5b7593e68..12fc78c60c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -345,7 +345,7 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; - int i,j; + int i, j; for (j = 0; dialog->Periods[j] != NULL; j++) if (dialog->PeriodNums[j] == nPeriod) { @@ -457,7 +457,7 @@ static uint32 *GetItemList(uint32 nLoc) { LPMPALVAR v = GLOBALS.lpmvVars; num = 0; - for (i = 0; i < GLOBALS.nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -468,8 +468,8 @@ static uint32 *GetItemList(uint32 nLoc) { v = GLOBALS.lpmvVars; j = 0; - for (i = 0; i < GLOBALS.nVars; i++,v++) { - if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { + for (i = 0; i < GLOBALS.nVars; i++, v++) { + if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; } @@ -504,7 +504,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { if (i >= 0x10) { // From 1.0, there's a destination point for each object ret->destX = (int16)READ_LE_UINT16(dat); ret->destY = (int16)READ_LE_UINT16(dat + 2); - dat+=4; + dat += 4; } if (i >= 0x11) { // From 1.1, there's animation speed @@ -514,9 +514,9 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->speed = 150; } - ret->numframe=*dat++; - ret->numpattern=*dat++; - ret->Zvalue=*dat++; + ret->numframe = *dat++; + ret->numpattern = *dat++; + ret->Zvalue = *dat++; // Upload the left & top co-ordinates of each frame for (i = 0; i < ret->numframe; i++) { @@ -529,7 +529,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; - dat+=4; + dat += 4; } // Upload the bounding boxes of each frame @@ -538,12 +538,12 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); - dat+=8; + dat += 8; } // Load the animation pattern patlength = dat; - dat+=ret->numpattern; + dat += ret->numpattern; for (i = 1; i < ret->numpattern; i++) { for (j = 0; j < patlength[i]; j++) @@ -639,7 +639,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } _ctx->numHandles = 0; - for (_ctx->j = 0; _ctx->jMoment[_ctx->i].nCmds; _ctx->j++) { + for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; if (s->Command[_ctx->k].type == 1) { @@ -1048,9 +1048,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { } - - - /** * Wait for the end of the dialog execution thread, and then restore global * variables indicating that the dialogue has finished. @@ -1847,7 +1844,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) - n[0]='\0'; + n[0] = '\0'; else { LockItems(); y = itemGetOrderFromNum(x); @@ -2288,7 +2285,7 @@ void mpalDumpMessages(void) { } // Now make a loop over all the periods - for (j = 0;j -// -// 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 "agos/installshield_cab.h" - -#include "common/debug.h" -#include "common/file.h" -#include "common/memstream.h" -#include "common/zlib.h" - -namespace AGOS { - -class InstallShieldCabinet : public Common::Archive { - Common::String _installShieldFilename; - -public: - InstallShieldCabinet(const Common::String &filename); - ~InstallShieldCabinet(); - - // Common::Archive API implementation - bool hasFile(const Common::String &name) const; - int listMembers(Common::ArchiveMemberList &list) const; - const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; - -private: - struct FileEntry { - uint32 uncompressedSize; - uint32 compressedSize; - uint32 offset; - uint16 flags; - }; - - typedef Common::HashMap FileMap; - FileMap _map; -}; - -InstallShieldCabinet::~InstallShieldCabinet() { - _map.clear(); -} - -InstallShieldCabinet::InstallShieldCabinet(const Common::String &filename) : _installShieldFilename(filename) { - Common::File installShieldFile; - - if (!installShieldFile.open(_installShieldFilename)) { - warning("InstallShieldCabinet::InstallShieldCabinet(): Could not find the archive file %s", _installShieldFilename.c_str()); - return; - } - - // Note that we only support a limited subset of cabinet files - // Only single cabinet files and ones without data shared between - // cabinets. - - // Check for the magic uint32 - if (installShieldFile.readUint32LE() != 0x28635349) { - warning("InstallShieldCabinet::InstallShieldCabinet(): Magic ID doesn't match"); - return; - } - - uint32 version = installShieldFile.readUint32LE(); - - if (version != 0x01000004) { - warning("Unsupported CAB version %08x", version); - return; - } - - /* uint32 volumeInfo = */ installShieldFile.readUint32LE(); - uint32 cabDescriptorOffset = installShieldFile.readUint32LE(); - /* uint32 cabDescriptorSize = */ installShieldFile.readUint32LE(); - - installShieldFile.seek(cabDescriptorOffset); - - installShieldFile.skip(12); - uint32 fileTableOffset = installShieldFile.readUint32LE(); - installShieldFile.skip(4); - uint32 fileTableSize = installShieldFile.readUint32LE(); - uint32 fileTableSize2 = installShieldFile.readUint32LE(); - uint32 directoryCount = installShieldFile.readUint32LE(); - installShieldFile.skip(8); - uint32 fileCount = installShieldFile.readUint32LE(); - - if (fileTableSize != fileTableSize2) - warning("file table sizes do not match"); - - // We're ignoring file groups and components since we - // should not need them. Moving on to the files... - - installShieldFile.seek(cabDescriptorOffset + fileTableOffset); - uint32 fileTableCount = directoryCount + fileCount; - uint32 *fileTableOffsets = new uint32[fileTableCount]; - for (uint32 i = 0; i < fileTableCount; i++) - fileTableOffsets[i] = installShieldFile.readUint32LE(); - - for (uint32 i = directoryCount; i < fileCount + directoryCount; i++) { - installShieldFile.seek(cabDescriptorOffset + fileTableOffset + fileTableOffsets[i]); - uint32 nameOffset = installShieldFile.readUint32LE(); - /* uint32 directoryIndex = */ installShieldFile.readUint32LE(); - - // First read in data needed by us to get at the file data - FileEntry entry; - entry.flags = installShieldFile.readUint16LE(); - entry.uncompressedSize = installShieldFile.readUint32LE(); - entry.compressedSize = installShieldFile.readUint32LE(); - installShieldFile.skip(20); - entry.offset = installShieldFile.readUint32LE(); - - // Then let's get the string - installShieldFile.seek(cabDescriptorOffset + fileTableOffset + nameOffset); - Common::String fileName; - - char c = installShieldFile.readByte(); - while (c) { - fileName += c; - c = installShieldFile.readByte(); - } - _map[fileName] = entry; - } - - delete[] fileTableOffsets; -} - -bool InstallShieldCabinet::hasFile(const Common::String &name) const { - return _map.contains(name); -} - -int InstallShieldCabinet::listMembers(Common::ArchiveMemberList &list) const { - for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++) - list.push_back(getMember(it->_key)); - - return _map.size(); -} - -const Common::ArchiveMemberPtr InstallShieldCabinet::getMember(const Common::String &name) const { - return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); -} - -Common::SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(const Common::String &name) const { - if (!_map.contains(name)) - return 0; - - const FileEntry &entry = _map[name]; - - Common::File archiveFile; - archiveFile.open(_installShieldFilename); - archiveFile.seek(entry.offset); - - if (!(entry.flags & 0x04)) { - // Not compressed - return archiveFile.readStream(entry.uncompressedSize); - } - -#ifdef USE_ZLIB - byte *src = (byte *)malloc(entry.compressedSize); - byte *dst = (byte *)malloc(entry.uncompressedSize); - - archiveFile.read(src, entry.compressedSize); - - bool result = Common::inflateZlibHeaderless(dst, entry.uncompressedSize, src, entry.compressedSize); - free(src); - - if (!result) { - warning("failed to inflate CAB file '%s'", name.c_str()); - free(dst); - return 0; - } - - return new Common::MemoryReadStream(dst, entry.uncompressedSize, DisposeAfterUse::YES); -#else - warning("zlib required to extract compressed CAB file '%s'", name.c_str()); - return 0; -#endif -} - -Common::Archive *makeInstallShieldArchive(const Common::String &name) { - return new InstallShieldCabinet(name); -} - -} // End of namespace AGOS diff --git a/engines/agos/installshield_cab.h b/engines/agos/installshield_cab.h deleted file mode 100644 index f7e8bed277..0000000000 --- a/engines/agos/installshield_cab.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. - * - */ - -#include "common/archive.h" -#include "common/str.h" - -#ifndef AGOS_INSTALLSHIELD_CAB_H -#define AGOS_INSTALLSHIELD_CAB_H - -namespace AGOS { - -/** - * This factory method creates an Archive instance corresponding to the content - * of the InstallShield compressed file with the given name. - * - * May return 0 in case of a failure. - */ -Common::Archive *makeInstallShieldArchive(const Common::String &name); - -} // End of namespace AGOS - -#endif diff --git a/engines/agos/module.mk b/engines/agos/module.mk index 7ae5e17bf2..7069d8005b 100644 --- a/engines/agos/module.mk +++ b/engines/agos/module.mk @@ -51,7 +51,6 @@ ifdef ENABLE_AGOS2 MODULE_OBJS += \ animation.o \ feeble.o \ - installshield_cab.o \ oracle.o \ script_dp.o \ script_ff.o \ diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index 0305879390..2e44a6575c 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -23,6 +23,8 @@ // Resource file routines for Simon1/Simon2 +#include "common/archive.h" +#include "common/installshield_cab.h" #include "common/file.h" #include "common/memstream.h" #include "common/textconsole.h" @@ -31,7 +33,6 @@ #include "agos/agos.h" #include "agos/intern.h" #include "agos/sound.h" -#include "agos/installshield_cab.h" #include "common/zlib.h" @@ -43,7 +44,10 @@ ArchiveMan::ArchiveMan() { #ifdef ENABLE_AGOS2 void ArchiveMan::registerArchive(const Common::String &filename, int priority) { - add(filename, makeInstallShieldArchive(filename), priority); + Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(filename); + + if (stream) + add(filename, makeInstallShieldArchive(stream, DisposeAfterUse::YES), priority); } #endif -- cgit v1.2.3 From 6e104f0883eaf060e66dadc07cf546b5f1dee1b7 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 28 May 2012 16:56:31 -0400 Subject: TONY: Add support for using the compressed version of the demo --- engines/tony/detection.cpp | 9 ++++++++- engines/tony/detection_tables.h | 17 +++++++++++++++++ engines/tony/tony.cpp | 13 +++++++++++++ engines/tony/tony.h | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index a87dd9bd07..1de1b70968 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -32,9 +32,12 @@ #include "tony/tony.h" #include "tony/game.h" - namespace Tony { +enum { + GF_COMPRESSED = (1 << 0) +}; + struct TonyGameDescription { ADGameDescription desc; }; @@ -51,8 +54,12 @@ bool TonyEngine::getIsDemo() const { return _gameDescription->desc.flags & ADGF_DEMO; } +bool TonyEngine::isCompressed() const { + return _gameDescription->desc.flags & GF_COMPRESSED; } +} // End of namespace Tony + static const PlainGameDescriptor tonyGames[] = { {"tony", "Tony Tough and the Night of Roasted Moths"}, {0, 0} diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index afcf787ca1..3510178474 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -41,6 +41,23 @@ static const TonyGameDescription gameDescriptions[] = { }, }, + { + // Tony Tough English Demo (Compressed) + { + "tony", + "Demo", + AD_ENTRY1s("data1.cab", "7d8b6d308f96aee3968ad7910fb11e6d", 58660608), + Common::EN_ANY, + Common::kPlatformPC, +#ifdef TEMPORARY_DISABLED + ADGF_DEMO | GF_COMPRESSED, +#else + ADGF_NO_FLAGS | GF_COMPRESSED, +#endif + GUIO1(GUIO_NONE) + }, + }, + { AD_TABLE_END_MARKER } }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e5c30ffcec..da63c23bab 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -26,6 +26,7 @@ #include "common/debug-channels.h" #include "common/events.h" #include "common/file.h" +#include "common/installshield_cab.h" #include "tony/tony.h" #include "tony/custom.h" #include "tony/debugger.h" @@ -84,6 +85,18 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { + if (isCompressed()) { + Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab"); + if (!stream) + error("Failed to open data1.cab"); + + Common::Archive *cabinet = Common::makeInstallShieldArchive(stream); + if (!cabinet) + error("Failed to parse data1.cab"); + + SearchMan.add("data1.cab", cabinet); + } + m_hEndOfFrame = CoroScheduler.createEvent(false, false); m_bPaused = false; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f4d9d83674..78e9abd476 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -143,6 +143,7 @@ public: Common::Language getLanguage() const; uint16 getVersion() const; bool getIsDemo() const; + bool isCompressed() const; RMGfxEngine *GetEngine() { return &_theEngine; } -- cgit v1.2.3 From 01df8ae0e81a25c14b0f17e82af9d0ce407846e0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 10:39:00 +1000 Subject: TONY: Fix compiler warning of not using a deferenced pointer --- engines/tony/mpal/loadmpc.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a80c85eb75..02571bd30f 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -278,10 +278,9 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpBuf += 4; // PlayGroup - num3 = *lpBuf; - *lpBuf++; + num3 = *lpBuf++; - if (num3 >= MAX_PLAYGROUPS_PER_SELECT) + if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { -- cgit v1.2.3 From be320760bd2b3f8f7ada1f27eb4e9997bbb25f4a Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 2 Jun 2012 01:44:34 +0100 Subject: TONY: Remove TEMPORARY_DISABLED define from detection tables. --- engines/tony/detection_tables.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 3510178474..498dcb4eb5 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -32,11 +32,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, -#ifdef TEMPORARY_DISABLED ADGF_DEMO, -#else - ADGF_NO_FLAGS, -#endif GUIO1(GUIO_NONE) }, }, @@ -49,11 +45,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("data1.cab", "7d8b6d308f96aee3968ad7910fb11e6d", 58660608), Common::EN_ANY, Common::kPlatformPC, -#ifdef TEMPORARY_DISABLED ADGF_DEMO | GF_COMPRESSED, -#else - ADGF_NO_FLAGS | GF_COMPRESSED, -#endif GUIO1(GUIO_NONE) }, }, -- cgit v1.2.3 From 22b432643743bda52665e7f733e149633cab96bf Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 2 Jun 2012 01:47:33 +0100 Subject: TONY: Add detection entries for full english game release. Also, now versions using uncompressed game data will be marked with "Extracted" in the launcher detection description. This should help in detecting any performance issues in future bug reports from user using compressed vs. extracted game data. --- engines/tony/detection_tables.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 498dcb4eb5..23defb57c0 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -23,12 +23,37 @@ namespace Tony { static const TonyGameDescription gameDescriptions[] = { + { + // Tony Tough English + { + "tony", + "Extracted", + AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + + { + // Tony Tough English (Compressed) + { + "tony", + "", + AD_ENTRY1s("data1.cab", "ce82907242166bfb594d97bdb68f96d2", 4350), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_NO_FLAGS | GF_COMPRESSED, + GUIO1(GUIO_NONE) + }, + }, { // Tony Tough English Demo { "tony", - "Demo", + "Extracted Demo", AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, -- cgit v1.2.3 From 6ecd71270da3e3ddaadf181e37a17419c74cdef2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 11:07:56 +1000 Subject: TONY: Removed redundant vdb mutex --- engines/tony/custom.cpp | 16 ---------------- engines/tony/globals.cpp | 1 - engines/tony/globals.h | 1 - 3 files changed, 18 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a6381e0937..03c6405d2e 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -275,7 +275,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _ctx->curVoc->offset; // First time allocation - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -283,7 +282,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); - g_system->unlockMutex(GLOBALS.vdb); } if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { @@ -335,7 +333,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -344,7 +341,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->SetLoop(false); _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); - g_system->unlockMutex(GLOBALS.vdb); } } @@ -1486,10 +1482,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(GLOBALS.vdb); } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1527,7 +1521,6 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1536,7 +1529,6 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(GLOBALS.vdb); } // Wait for the end of display @@ -1701,11 +1693,9 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(GLOBALS.vdb); } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1744,7 +1734,6 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1753,7 +1742,6 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(GLOBALS.vdb); } // Wait for the end of display @@ -1818,13 +1806,11 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); _ctx->voice->SetLoop(false); if (_ctx->bIsBack) _ctx->voice->SetVolume(55); - g_system->unlockMutex(GLOBALS.vdb); } _ctx->string = mpalQueryDialogPeriod(nMsg); @@ -2559,8 +2545,6 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.EnableGUI = MainEnableGUI; GLOBALS.SetPalesati = MainSetPalesati; - GLOBALS.vdb = g_system->createMutex(); - GLOBALS.bAlwaysDisplay = false; int i; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 7c801a787d..1a4467ef28 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -91,7 +91,6 @@ Globals::Globals() { lastTappeto = 0; Common::fill(&tappeti[0], &tappeti[200], 0); SFM_nLoc = 0; - vdb = NULL; // MPAL global variables mpalError = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index d2d47d392a..76a54e07c8 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -241,7 +241,6 @@ public: RMPoint StartLocPos[256]; OSystem::MutexRef cs[10]; - OSystem::MutexRef vdb; uint32 mut[10]; bool bSkipIdle; -- cgit v1.2.3 From 3367679ae80e89dcdbc424af477ee743007050ac Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 2 Jun 2012 03:10:33 +0100 Subject: TONY: Correcting full english version detection entries. Though the CD contains installshield cabinets, these don't contain the required datafiles. These are instead already found on the CD in the directories named "Music", "Voices" and "Roasted". The last of these contains the main datafiles and executables. It appears the installshield cabinet format here is using a rare "external" link format pointing to the files and folders on the CD. Since the files are on the CD anyway, the "compressed" entry is not required. However, the detection entry is likely to need some more changes to support detection of these in the original CD folder structure.. --- engines/tony/detection_tables.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 23defb57c0..63a6d044ae 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -27,7 +27,7 @@ static const TonyGameDescription gameDescriptions[] = { // Tony Tough English { "tony", - "Extracted", + "", AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071), Common::EN_ANY, Common::kPlatformPC, @@ -36,19 +36,6 @@ static const TonyGameDescription gameDescriptions[] = { }, }, - { - // Tony Tough English (Compressed) - { - "tony", - "", - AD_ENTRY1s("data1.cab", "ce82907242166bfb594d97bdb68f96d2", 4350), - Common::EN_ANY, - Common::kPlatformPC, - ADGF_NO_FLAGS | GF_COMPRESSED, - GUIO1(GUIO_NONE) - }, - }, - { // Tony Tough English Demo { -- cgit v1.2.3 From c1e6913fedf05d18edf6ef64c5a7c1c2cabedd4e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 16:59:58 +1000 Subject: TONY: Fixed memory leaks with the Options screen --- engines/tony/game.cpp | 6 +++++- engines/tony/game.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index dc5e412f00..a1954b95b2 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -139,6 +139,7 @@ RMOptionButton::RMOptionButton(const RMRect &pt) { m_bActive = false; m_bHasGfx = false; m_bDoubleState = false; + m_buf = NULL; } RMOptionButton::~RMOptionButton() { @@ -321,7 +322,7 @@ void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { \****************************************************************************/ RMOptionScreen::RMOptionScreen(void) { - m_nState = MENUGAME; + m_nState = MENUNONE; m_menu = NULL; m_HideLoadSave = NULL; m_QuitConfirm = NULL; @@ -379,6 +380,7 @@ RMOptionScreen::RMOptionScreen(void) { RMOptionScreen::~RMOptionScreen(void) { + CloseState(); } void RMOptionScreen::RefreshAll(CORO_PARAM) { @@ -856,6 +858,8 @@ void RMOptionScreen::CloseState(void) { m_ButtonSound_SFXOn = NULL; } } + + m_nState = MENUNONE; } void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 20b5f347bc..c920b88ee5 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -252,7 +252,8 @@ private: MENUGFX, MENUSOUND, MENULOAD, - MENUSAVE + MENUSAVE, + MENUNONE }; STATE m_nState; -- cgit v1.2.3 From ea8c4960c7139440df9416366a78094f4753aa12 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 17:15:24 +1000 Subject: TONY: Fix Valgrind warnings of checks on uninitialised variables --- engines/tony/input.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index c1104204b5..fc98544e14 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -35,11 +35,12 @@ RMInput::RMInput() { // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); - _leftButton = _rightButton = false;; - + _leftButton = _rightButton = false; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + Common::fill((byte *)&_event, (byte *)&_event + sizeof(Common::Event), 0); + // Setup keyboard fields Common::fill(&_keyDown[0], &_keyDown[350], 0); } -- cgit v1.2.3 From a850eabf07bd5c620a7329529f464deb4930a127 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 17:40:01 +1000 Subject: TONY: Fix memory leak when game exited whilst credits are active --- engines/tony/custom.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 03c6405d2e..96b78d0e83 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2315,6 +2315,12 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 uint32 hDisable; int i; uint32 startTime; + + ~CoroContextTag() { + delete msg; + delete[] text; + } + CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2368,6 +2374,8 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 delete[] _ctx->text; delete _ctx->msg; + _ctx->text = NULL; + _ctx->msg = NULL; CORO_END_CODE; } -- cgit v1.2.3 From 3927d9020613682a7e38e5c387835e27e170fb66 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 18:37:41 +1000 Subject: TONY: Extra initialisation of globals --- engines/tony/globals.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 1a4467ef28..742d4376d5 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -26,6 +26,7 @@ namespace Tony { Globals::Globals() { + Common::fill(nextMusic, nextMusic + MAX_PATH, 0); nextLoop = false; nextChannel = 0; nextSync = 0; @@ -71,6 +72,7 @@ Globals::Globals() { bCfgDubbing = false; bCfgMusic = false; bCfgSFX = false; + bAlwaysDisplay = false; nCfgTonySpeed = 0; nCfgTextSpeed = 0; nCfgDubbingVolume = 0; @@ -129,6 +131,15 @@ Globals::Globals() { nExecutingDialog = 0; nExecutingChoice = 0; nSelectedChoice = 0; + nTonyNextTalkType = RMTony::TALK_NORMAL; + saveTonyLoc = 0; + + for (int i = 0; i < 16; ++i) + Common::fill((byte *)&Character[i], (byte *)&Character[i] + sizeof(CharacterStruct), 0); + for (int i = 0; i < 10; ++i) + Common::fill((byte *)&MCharacter[i], (byte *)&MCharacter[i] + sizeof(MCharacterStruct), 0); + for (int i = 0; i < 256; ++i) + Common::fill((byte *)&ChangedHotspot[i], (byte *)&ChangedHotspot[i] + sizeof(ChangedHotspotStruct), 0); } } // End of namespace Tony -- cgit v1.2.3 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 b566583e3231b70512b7954a7b00cc0f02f9f24c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jun 2012 21:16:25 +1000 Subject: TONY: Workaround for hang on title screen if you click with a y = 0 --- engines/tony/loc.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index f0dd30b1a9..512c28605e 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1298,6 +1298,10 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; + + // WORKAROUND: Handles cases where the points never fall inside a bounding box + if (Lscan.x < -100 || Lscan.y < -100 || Lscan.x >= 1000 || Lscan.y >= 1000) + return punto; } } -- cgit v1.2.3 From dbebaaf50d2b07d7657d7c1210587e009f6d7f06 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 c17af63aacda4b18ca6e756fb710cecb3b25fc88 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Jun 2012 22:18:50 +0200 Subject: TONY: Modify detection in order to use roasted.mpc too. Add French, German, Italian and Polish versions. This also breaks the English game detection. To be fixed! --- engines/tony/detection_tables.h | 85 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 63a6d044ae..36548c4e3c 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -27,8 +27,13 @@ static const TonyGameDescription gameDescriptions[] = { // Tony Tough English { "tony", - "", - AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071), + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + // Fake md5 : to be fixed! + {"roasted.mpc", 0, "bad97eae03a4db3e99565e39b0b3c06a", 16384}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, @@ -41,7 +46,11 @@ static const TonyGameDescription gameDescriptions[] = { { "tony", "Extracted Demo", - AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409}, + {"roasted.mpc", 0, "1e247922ec869712bfd96625bc4d3c7c", 39211}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, @@ -54,14 +63,80 @@ static const TonyGameDescription gameDescriptions[] = { { "tony", "Demo", - AD_ENTRY1s("data1.cab", "7d8b6d308f96aee3968ad7910fb11e6d", 58660608), + { + {"data1.cab", 0, "7d8b6d308f96aee3968ad7910fb11e6d", 58660608}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO | GF_COMPRESSED, GUIO1(GUIO_NONE) }, }, - + { + // Tony Tough French "Collection Aventure" provided by Strangerke + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "e890c6a41238827bdfa9874a65618b69", 374135}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + { + // Tony Tough German "Shoe Box" provided by Strangerke + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "ccf7ab939a34de1b13df538596431684", 389554}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + { + // Tony Tough Italian provided by Fabio Barzagli + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "1dc896cdb945170d7408598f803411c1", 380001}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + { + // Tony Tough Polish provided by Fabio Barzagli + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "89733ea710669acc8e7900b115f4afef", 389625}, + AD_LISTEND + }, + Common::PL_POL, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, { AD_TABLE_END_MARKER } }; -- cgit v1.2.3 From a1f6f8ceb19d65619dfd8e2477bffad773ba49ba Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Jun 2012 23:45:36 +0200 Subject: TONY: Rename variables and functions in tony.h --- engines/tony/custom.cpp | 70 ++++++------- engines/tony/detection.cpp | 2 +- engines/tony/font.cpp | 18 ++-- engines/tony/game.cpp | 62 ++++++------ engines/tony/gfxengine.cpp | 6 +- engines/tony/inventory.cpp | 32 +++--- engines/tony/loc.cpp | 10 +- engines/tony/mpal/mpal.cpp | 14 +-- engines/tony/tony.cpp | 248 ++++++++++++++++++++++----------------------- engines/tony/tony.h | 126 +++++++++++------------ engines/tony/tonychar.cpp | 4 +- 11 files changed, 294 insertions(+), 298 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 96b78d0e83..47089f3214 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -240,7 +240,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { return NULL; for (i = 0; i < _vm->_voices.size(); i++) - if (_vm->_voices[i].code == code) + if (_vm->_voices[i]._code == code) return &_vm->_voices[i]; return NULL; @@ -272,7 +272,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice = NULL; if (_ctx->curVoc) { // Is positioned within the database of entries beginning at the first - _ctx->curOffset = _ctx->curVoc->offset; + _ctx->curOffset = _ctx->curVoc->_offset; // First time allocation _vm->_vdbFP.seek(_ctx->curOffset); @@ -509,7 +509,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - _vm->StopMusic(4); + _vm->stopMusic(4); // On exit, unload and unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); @@ -532,7 +532,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { - _vm->StopMusic(4); + _vm->stopMusic(4); } // On exit, unfreeze @@ -547,7 +547,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { GLOBALS.lastTappeto = GLOBALS.tappeti[nLoc]; if (GLOBALS.lastTappeto != 0) - _vm->PlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); + _vm->playMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); } if (!GLOBALS.bNoOcchioDiBue) { @@ -1281,7 +1281,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->startpt = GLOBALS.Loc->ScrollPosition(); - _ctx->dwStartTime = _vm->GetTime(); + _ctx->dwStartTime = _vm->getTime(); if (sX) _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; @@ -1289,7 +1289,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { - _ctx->dwCurTime = _vm->GetTime() - _ctx->dwStartTime; + _ctx->dwCurTime = _vm->getTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1362,11 +1362,11 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->AutoSave(coroParam); + _vm->autoSave(coroParam); } -DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->Abort(); +DECLARE_CUSTOM_FUNCTION(AbortGame)(CORO_PARAM, uint32, uint32, uint32, uint32) { + _vm->abortGame(); } DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { @@ -1378,12 +1378,12 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); _ctx->dirx = 1; _ctx->diry = 1; - while (_vm->GetTime() < _ctx->curTime + nScosse) { + while (_vm->getTime() < _ctx->curTime + nScosse) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); @@ -1482,8 +1482,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->offset); - _ctx->curOffset = _ctx->curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->_offset); + _ctx->curOffset = _ctx->curVoc->_offset; } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1694,8 +1694,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (_ctx->curVoc) { // Position within the database of entries, beginning at the first // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(_ctx->curVoc->offset); - _ctx->curOffset = _ctx->curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->_offset); + _ctx->curOffset = _ctx->curVoc->_offset; } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1806,7 +1806,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->offset); + _vm->_vdbFP.seek(_ctx->curVoc->_offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); _ctx->voice->SetLoop(false); @@ -2083,11 +2083,11 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeIn Music"); for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { - _vm->SetMusicVolume(nChannel, _ctx->i * 4); + _vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - _vm->SetMusicVolume(nChannel, 64); + _vm->setMusicVolume(nChannel, 64); debug("End FadeIn Music"); @@ -2106,23 +2106,23 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CODE(_ctx); - _ctx->startVolume = _vm->GetMusicVolume(nChannel); + _ctx->startVolume = _vm->getMusicVolume(nChannel); debug("Start FadeOut Music"); for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS.bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) - _vm->SetMusicVolume(nChannel, _ctx->i * 4); + _vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } if (!GLOBALS.bFadeOutStop) - _vm->SetMusicVolume(nChannel, 0); + _vm->setMusicVolume(nChannel, 0); // If there is a stacchetto, stop all if (nChannel == 2) - _vm->StopMusic(2); + _vm->stopMusic(2); debug("End FadeOut Music"); @@ -2152,28 +2152,28 @@ DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->StopMusic(GLOBALS.curSonoriz); + _vm->stopMusic(GLOBALS.curSonoriz); } DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->StopMusic(2); + _vm->stopMusic(2); } DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(GLOBALS.curSonoriz, 0); + _vm->setMusicVolume(GLOBALS.curSonoriz, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS.bFadeOutStop = true; - _vm->SetMusicVolume(GLOBALS.curSonoriz, 64); + _vm->setMusicVolume(GLOBALS.curSonoriz, 64); } DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(2, 0); + _vm->setMusicVolume(2, 0); } DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(2, 64); + _vm->setMusicVolume(2, 64); } @@ -2288,7 +2288,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->OpenInitLoadMenu); + CORO_INVOKE_0(_vm->openInitLoadMenu); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2301,7 +2301,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->OpenInitOptions); + CORO_INVOKE_0(_vm->openInitOptions); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2357,13 +2357,13 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } - _ctx->startTime = _vm->GetTime(); + _ctx->startTime = _vm->getTime(); - while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { + while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); if (GLOBALS.Input->MouseLeftClicked() || GLOBALS.Input->MouseRightClicked()) break; - if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; } @@ -2510,7 +2510,7 @@ ASSIGN(130, StacchettoFadeEnd) ASSIGN(120, TremaSchermo) ASSIGN(121, AutoSave) -ASSIGN(122, Abort) +ASSIGN(122, AbortGame) ASSIGN(131, NoOcchioDiBue) ASSIGN(132, SendFullscreenMsgStart) ASSIGN(133, SendFullscreenMsgEnd) diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 1de1b70968..be45aba19f 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -146,7 +146,7 @@ int TonyMetaEngine::getMaximumSaveSlot() const { } void TonyMetaEngine::removeSaveState(const char *target, int slot) const { - Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); + Common::String filename = Tony::TonyEngine::getSaveStateFileName(slot); g_system->getSavefileManager()->removeSavefile(filename); } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 6b6778044d..567da3041c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2079,14 +2079,14 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { if (!m_bForceNoTime) { - if (_vm->GetTime() > (uint32)m_time + m_startTime) + if (_vm->getTime() > (uint32)m_time + m_startTime) return; } } } if (!m_bNoTab) { - if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; } @@ -2100,14 +2100,14 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Erase the background else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!m_bForceNoTime) { - if (_vm->GetTime() > (uint32)m_time + m_startTime) + if (_vm->getTime() > (uint32)m_time + m_startTime) return; } } // If time is forced if (m_bForceTime) { - if (_vm->GetTime() > (uint32)m_time + m_startTime) + if (_vm->getTime() > (uint32)m_time + m_startTime) return; } @@ -2143,7 +2143,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_BEGIN_CODE(_ctx); if (m_startTime == 0) - m_startTime = _vm->GetTime(); + m_startTime = _vm->getTime(); if (m_bShowed) { if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { @@ -2483,7 +2483,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { if (0) { m_bShow = true; } else { - _ctx->starttime = _vm->GetTime(); + _ctx->starttime = _vm->getTime(); _ctx->deltay = 480 - m_ptDrawPos.y; _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); @@ -2496,7 +2496,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { while (_ctx->elaps < 700) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->elaps = _vm->GetTime() - _ctx->starttime; + _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; MainUnfreeze(); } @@ -2533,14 +2533,14 @@ void RMDialogChoice::Hide(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (1) { - _ctx->starttime = _vm->GetTime(); + _ctx->starttime = _vm->getTime(); _ctx->deltay = 480 - m_ptDrawPos.y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->elaps = _vm->GetTime() - _ctx->starttime; + _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; MainUnfreeze(); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index a1954b95b2..42c33f2259 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,75 +47,75 @@ using namespace MPAL; /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->GetEngine()->LoadLocation(nLoc, pt, start); + return _vm->getEngine()->LoadLocation(nLoc, pt, start); } void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - _vm->GetEngine()->UnloadLocation(coroParam, bDoOnExit, result); + _vm->getEngine()->UnloadLocation(coroParam, bDoOnExit, result); } void MainLinkGraphicTask(RMGfxTask *task) { - _vm->GetEngine()->LinkGraphicTask(task); + _vm->getEngine()->LinkGraphicTask(task); } void MainFreeze(void) { - _vm->GetEngine()->Freeze(); + _vm->getEngine()->Freeze(); } void MainUnfreeze(void) { - _vm->GetEngine()->Unfreeze(); + _vm->getEngine()->Unfreeze(); } void MainWaitFrame(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, _vm->m_hEndOfFrame, CORO_INFINITE); + CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); } void MainShowMouse(void) { - _vm->GetEngine()->EnableMouse(); + _vm->getEngine()->EnableMouse(); } void MainHideMouse(void) { - _vm->GetEngine()->DisableMouse(); + _vm->getEngine()->DisableMouse(); } void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { - _vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync); + _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } void MainDisableInput(void) { - _vm->GetEngine()->DisableInput(); + _vm->getEngine()->DisableInput(); } void MainEnableInput(void) { - _vm->GetEngine()->EnableInput(); + _vm->getEngine()->EnableInput(); } void MainInitWipe(int type) { - _vm->GetEngine()->InitWipe(type); + _vm->getEngine()->InitWipe(type); } void MainCloseWipe(void) { - _vm->GetEngine()->CloseWipe(); + _vm->getEngine()->CloseWipe(); } void MainWaitWipeEnd(CORO_PARAM) { - _vm->GetEngine()->WaitWipeEnd(coroParam); + _vm->getEngine()->WaitWipeEnd(coroParam); } void MainEnableGUI(void) { - _vm->GetEngine()->m_bGUIInterface = true; - _vm->GetEngine()->m_bGUIInventory = true; - _vm->GetEngine()->m_bGUIOption = true; + _vm->getEngine()->m_bGUIInterface = true; + _vm->getEngine()->m_bGUIInventory = true; + _vm->getEngine()->m_bGUIOption = true; } void MainDisableGUI(void) { - _vm->GetEngine()->m_bGUIInterface = false; - _vm->GetEngine()->m_bGUIInventory = false; - _vm->GetEngine()->m_bGUIOption = false; + _vm->getEngine()->m_bGUIInterface = false; + _vm->getEngine()->m_bGUIInventory = false; + _vm->getEngine()->m_bGUIOption = false; } void MainSetPalesati(bool bPalesati) { - _vm->GetEngine()->SetPalesati(bPalesati); + _vm->getEngine()->SetPalesati(bPalesati); } /****************************************************************************\ @@ -491,7 +491,7 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { if (m_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; - _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + _ctx->thumb->Init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); if (m_nEditPos == 0) AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); @@ -989,7 +989,7 @@ bool RMOptionScreen::Close(void) { // Start fade out m_FadeStep++; - m_FadeTime = _vm->GetTime(); + m_FadeTime = _vm->getTime(); return true; } @@ -1097,7 +1097,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) +#define KEYPRESS(c) (_vm->getEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } @@ -1154,7 +1154,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { m_bEditSaveName = false; - _vm->SaveState(m_statePos + m_nEditPos, m_EditName); + _vm->saveState(m_statePos + m_nEditPos, m_EditName); Close(); } @@ -1190,7 +1190,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // There by saving or loading!!! if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento - CORO_INVOKE_1(_vm->LoadState, m_statePos + _ctx->i); + CORO_INVOKE_1(_vm->loadState, m_statePos + _ctx->i); Close(); } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { // Turn on edit mode @@ -1214,7 +1214,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { m_bQuitConfirm = false; _ctx->bRefresh = true; - _vm->Quit(); + _vm->quitGame(); } } else { if (m_ButtonQuit->IsActive()) { @@ -1280,7 +1280,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); #define FADE_SPEED 20 #define SYNC (_ctx->curTime-m_FadeTime) / 25 @@ -1336,7 +1336,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (m_FadeY > 480) { m_FadeY = 480; m_FadeStep++; - _vm->HideLocation(); + _vm->hideLocation(); } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); @@ -1346,7 +1346,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } else if (m_FadeStep == 7) { // Menu OFF - _vm->ShowLocation(); + _vm->showLocation(); m_FadeStep++; } else if (m_FadeStep == 8) { @@ -1398,7 +1398,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS diff = 10; // Get the savegame filename for the given slot - buf = _vm->GetSaveStateFileName(nState); + buf = _vm->getSaveStateFileName(nState); // Try and open the savegame f = g_system->getSavefileManager()->openForLoading(buf); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 3fa33d78ff..4642ee0ab7 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -109,7 +109,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); if (_ctx->bRes) { - _vm->PauseSound(true); + _vm->pauseSound(true); DisableInput(); m_inv.EndCombine(); @@ -119,7 +119,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { m_point.SetSpecialPointer(RMPointer::PTR_NONE); m_point.SetCustomPointer(NULL); EnableMouse(); - _vm->GrabThumbnail(); + _vm->grabThumbnail(); // Exists the IDLE to avoid premature death in loading m_bMustEnterMenu = true; @@ -161,7 +161,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { DisableMouse(); EnableInput(); mpalStartIdlePoll(m_nCurLoc); - _vm->PauseSound(false); + _vm->pauseSound(false); } } diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 539dd4e81b..1a245d9aba 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -343,7 +343,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { m_nCombine = m_inv[n - 1 + m_curPos]; nCombineObj = m_nCombine + 10000; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); return true; } } @@ -409,7 +409,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { miniAction = 0; m_nSelectObj = n - 1; - _vm->PlayUtilSFX(0); + _vm->playUtilSFX(0); } } @@ -530,7 +530,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { + if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } @@ -544,7 +544,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = RM_SY - 1; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = OPENED; m_curPutY = RM_SY - 68; @@ -554,13 +554,13 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = RM_SY - 68; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = CLOSED; } } } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY -= 3; m_curPutTime += INVSPEED; } @@ -571,7 +571,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY += 3; m_curPutTime += INVSPEED; } @@ -584,7 +584,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = - 68; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = OPENED; m_curPutY = 0; @@ -594,13 +594,13 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = -2; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = CLOSED; } } } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY += 3; m_curPutTime += INVSPEED; } @@ -610,7 +610,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_curPutY = 0; } } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY -= 3; m_curPutTime += INVSPEED; } @@ -635,19 +635,19 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (miniAction != 1) { miniInterface.SetPattern(2); miniAction = 1; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { if (miniAction != 2) { miniInterface.SetPattern(3); miniAction = 2; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { if (miniAction != 3) { miniInterface.SetPattern(4); miniAction = 3; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } } else { miniInterface.SetPattern(1); @@ -799,7 +799,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (m_lastHotZone != _ctx->h) { m_lastHotZone = _ctx->h; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } if (GLOBALS.bCfgInterTips) { @@ -836,7 +836,7 @@ void RMInterface::Clicked(const RMPoint &mousepos) { if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; // Play the sound effect - _vm->PlayUtilSFX(0); + _vm->playUtilSFX(0); } bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 512c28605e..b3768ca330 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -156,7 +156,7 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; // Read the current time - m_nStartTime = _vm->GetTime(); + m_nStartTime = _vm->getTime(); m_nCurSlot = 0; // Find the first frame of the pattern @@ -209,7 +209,7 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { } int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { - int CurTime = _vm->GetTime(); + int CurTime = _vm->getTime(); // If the speed is 0, then the pattern never advances if (m_speed == 0) { @@ -420,7 +420,7 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds.Read(raw, size); // Create the sound effect - m_fx = _vm->CreateSFX(raw); + m_fx = _vm->createSFX(raw); m_fx->SetLoop(false); // Close the read buffer which is no longer needed @@ -2085,10 +2085,10 @@ bool RMLocation::Load(RMDataStream &ds) { m_items = new RMItem[m_nItems]; - _vm->FreezeTime(); + _vm->freezeTime(); for (i = 0; i < m_nItems && !ds.IsError(); i++) ds >> m_items[i]; - _vm->UnfreezeTime(); + _vm->unfreezeTime(); return ds.IsError(); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 12fc78c60c..16c530206c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -621,7 +621,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - _ctx->dwStartTime = _vm->GetTime(); + _ctx->dwStartTime = _vm->getTime(); _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); @@ -629,9 +629,9 @@ void ScriptThread(CORO_PARAM, const void *param) { // Sleep for the required time if (s->Moment[_ctx->i].dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); - _ctx->dwStartTime = _vm->GetTime(); + _ctx->dwStartTime = _vm->getTime(); } else { - _ctx->dwCurTime = _vm->GetTime(); + _ctx->dwCurTime = _vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); @@ -771,7 +771,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { _ctx->slotNumber = _vm->_initialLoadSlotNumber; _vm->_initialLoadSlotNumber = -1; - CORO_INVOKE_1(_vm->LoadState, _ctx->slotNumber); + CORO_INVOKE_1(_vm->loadState, _ctx->slotNumber); } @@ -903,7 +903,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = _vm->GetTime(); + _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); _ctx->k++; } } @@ -918,7 +918,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) @@ -944,7 +944,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = 0; } - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); /* Loop through all the necessary idle actions */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index da63c23bab..c2350d14e4 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -59,7 +59,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng TonyEngine::~TonyEngine() { // Close the voice database - CloseVoiceDatabase(); + closeVoiceDatabase(); // Reset the coroutine scheduler CoroScheduler.reset(); @@ -71,12 +71,12 @@ TonyEngine::~TonyEngine() { * Run the game */ Common::Error TonyEngine::run() { - Common::ErrorCode result = Init(); + Common::ErrorCode result = init(); if (result != Common::kNoError) return result; - Play(); - Close(); + play(); + close(); return Common::kNoError; } @@ -84,7 +84,7 @@ Common::Error TonyEngine::run() { /** * Initialise the game */ -Common::ErrorCode TonyEngine::Init() { +Common::ErrorCode TonyEngine::init() { if (isCompressed()) { Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab"); if (!stream) @@ -97,11 +97,11 @@ Common::ErrorCode TonyEngine::Init() { SearchMan.add("data1.cab", cabinet); } - m_hEndOfFrame = CoroScheduler.createEvent(false, false); + _hEndOfFrame = CoroScheduler.createEvent(false, false); - m_bPaused = false; - m_bDrawLocation = true; - m_startTime = g_system->getMillis(); + _bPaused = false; + _bDrawLocation = true; + _startTime = g_system->getMillis(); // Init static class fields RMText::InitStatics(); @@ -114,8 +114,8 @@ Common::ErrorCode TonyEngine::Init() { _window.Init(); // Initialise the function list - Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); - InitCustomFunctionMap(); + Common::fill(_funcList, _funcList + 300, (LPCUSTOMFUNCTION)NULL); + initCustomFunctionMap(); // Initializes MPAL system, passing the custom functions list Common::File f; @@ -123,17 +123,17 @@ Common::ErrorCode TonyEngine::Init() { return Common::kReadingFailed; f.close(); - if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList, FuncListStrings)) + if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", _funcList, _funcListStrings)) return Common::kUnknownError; // Initialise the update resources _resUpdate.Init("ROASTED.MPU"); // Initialise the music - InitMusic(); + initMusic(); // Initialise the voices database - if (!OpenVoiceDatabase()) + if (!openVoiceDatabase()) return Common::kReadingFailed; // Initialise the boxes @@ -144,7 +144,7 @@ Common::ErrorCode TonyEngine::Init() { _theEngine.Init(); // Allocate space for thumbnails when saving the game - m_curThumbnail = new uint16[160 * 120]; + _curThumbnail = new uint16[160 * 120]; // Set up global defaults GLOBALS.bCfgInvLocked = false; @@ -164,13 +164,13 @@ Common::ErrorCode TonyEngine::Init() { GLOBALS.nCfgDubbingVolume = 10; GLOBALS.nCfgMusicVolume = 7; GLOBALS.nCfgSFXVolume = 10; - m_bQuitNow = false; + _bQuitNow = false; return Common::kNoError; } -void TonyEngine::InitCustomFunctionMap() { - INIT_CUSTOM_FUNCTION(FuncList, FuncListStrings); +void TonyEngine::initCustomFunctionMap() { + INIT_CUSTOM_FUNCTION(_funcList, _funcListStrings); } /** @@ -180,8 +180,8 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { - warning("TODO: TonyEngine::PlayMusic"); +void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { + warning("TODO: TonyEngine::playMusic"); // g_system->lockMutex(csMusic); if (nChannel < 4) @@ -192,8 +192,8 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 0: case 1: case 2: - m_stream[nChannel]->Stop(); - m_stream[nChannel]->UnloadFile(); + _stream[nChannel]->Stop(); + _stream[nChannel]->UnloadFile(); break; case 22: @@ -222,7 +222,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in else nextChannel = nChannel + 1; DWORD id; - HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, m_stream, 0, &id); + HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, _stream, 0, &id); SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); } else if (nFX == 44) { // Cambia canale e lascia finire il primo if (flipflop) @@ -230,103 +230,103 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in else nextChannel = nChannel + 1; - m_stream[nextChannel]->Stop(); - m_stream[nextChannel]->UnloadFile(); + _stream[nextChannel]->Stop(); + _stream[nextChannel]->UnloadFile(); if (!getIsDemo()) { - if (!m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) + if (!_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } - m_stream[nextChannel]->SetLoop(bLoop); - m_stream[nextChannel]->Play(); + _stream[nextChannel]->SetLoop(bLoop); + _stream[nextChannel]->Play(); flipflop = 1 - flipflop; } else { if (!getIsDemo()) { - if (!m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) + if (!_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } - m_stream[nChannel]->SetLoop(bLoop); - m_stream[nChannel]->Play(); + _stream[nChannel]->SetLoop(bLoop); + _stream[nChannel]->Play(); } #endif // g_system->unlockMutex(csMusic); } -void TonyEngine::PlaySFX(int nChannel, int nFX) { - if (m_sfx[nChannel] == NULL) +void TonyEngine::playSFX(int nChannel, int nFX) { + if (_sfx[nChannel] == NULL) return; switch (nFX) { case 0: - m_sfx[nChannel]->SetLoop(false); + _sfx[nChannel]->SetLoop(false); break; case 1: - m_sfx[nChannel]->SetLoop(true); + _sfx[nChannel]->SetLoop(true); break; } - m_sfx[nChannel]->Play(); + _sfx[nChannel]->Play(); } -void TonyEngine::StopMusic(int nChannel) { +void TonyEngine::stopMusic(int nChannel) { // g_system->lockMutex(csMusic); if (nChannel < 4) - m_stream[nChannel + GLOBALS.flipflop]->Stop(); + _stream[nChannel + GLOBALS.flipflop]->Stop(); else - m_stream[nChannel]->Stop(); + _stream[nChannel]->Stop(); // g_system->unlockMutex(csMusic); } -void TonyEngine::StopSFX(int nChannel) { - m_sfx[nChannel]->Stop(); +void TonyEngine::stopSFX(int nChannel) { + _sfx[nChannel]->Stop(); } -void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - if (m_utilSfx[nChannel] == NULL) +void TonyEngine::playUtilSFX(int nChannel, int nFX) { + if (_utilSfx[nChannel] == NULL) return; switch (nFX) { case 0: - m_utilSfx[nChannel]->SetLoop(false); + _utilSfx[nChannel]->SetLoop(false); break; case 1: - m_utilSfx[nChannel]->SetLoop(true); + _utilSfx[nChannel]->SetLoop(true); break; } - m_utilSfx[nChannel]->SetVolume(52); - m_utilSfx[nChannel]->Play(); + _utilSfx[nChannel]->SetVolume(52); + _utilSfx[nChannel]->Play(); } -void TonyEngine::StopUtilSFX(int nChannel) { - m_utilSfx[nChannel]->Stop(); +void TonyEngine::stopUtilSFX(int nChannel) { + _utilSfx[nChannel]->Stop(); } -void TonyEngine::PreloadSFX(int nChannel, const char *fn) { - if (m_sfx[nChannel] != NULL) { - m_sfx[nChannel]->Stop(); - m_sfx[nChannel]->Release(); - m_sfx[nChannel] = NULL; +void TonyEngine::preloadSFX(int nChannel, const char *fn) { + if (_sfx[nChannel] != NULL) { + _sfx[nChannel]->Stop(); + _sfx[nChannel]->Release(); + _sfx[nChannel] = NULL; } - _theSound.CreateSfx(&m_sfx[nChannel]); + _theSound.CreateSfx(&_sfx[nChannel]); - m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); + _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::CreateSFX(byte *buf) { +FPSFX *TonyEngine::createSFX(byte *buf) { FPSFX *sfx; _theSound.CreateSfx(&sfx); @@ -334,106 +334,105 @@ FPSFX *TonyEngine::CreateSFX(byte *buf) { return sfx; } -void TonyEngine::PreloadUtilSFX(int nChannel, const char *fn) { - warning("TonyEngine::PreloadUtilSFX"); +void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { + warning("TonyEngine::preloadUtilSFX"); } -void TonyEngine::UnloadAllSFX(void) { - warning("TonyEngine::UnloadAllSFX"); +void TonyEngine::unloadAllSFX(void) { + warning("TonyEngine::unloadAllSFX"); } -void TonyEngine::UnloadAllUtilSFX(void) { - warning("TonyEngine::UnloadAllUtilSFX"); +void TonyEngine::unloadAllUtilSFX(void) { + warning("TonyEngine::unloadAllUtilSFX"); } -void TonyEngine::InitMusic() { +void TonyEngine::initMusic() { int i; _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); for (i = 0; i < 6; i++) - _theSound.CreateStream(&m_stream[i]); + _theSound.CreateStream(&_stream[i]); for (i = 0; i < MAX_SFX_CHANNELS; i++) { - m_sfx[i] = m_utilSfx[i] = NULL; + _sfx[i] = _utilSfx[i] = NULL; } // Create the mutex for controlling music access // csMusic = g_system->createMutex(); // Preload sound effects - PreloadUtilSFX(0, "U01.ADP"); // Reversed!! - PreloadUtilSFX(1, "U02.ADP"); + preloadUtilSFX(0, "U01.ADP"); // Reversed!! + preloadUtilSFX(1, "U02.ADP"); } -void TonyEngine::CloseMusic() { +void TonyEngine::closeMusic() { for (int i = 0; i < 6; i++) { - m_stream[i]->Stop(); - m_stream[i]->UnloadFile(); - m_stream[i]->Release(); + _stream[i]->Stop(); + _stream[i]->UnloadFile(); + _stream[i]->Release(); } // g_system->deleteMutex(csMusic); - UnloadAllSFX(); - UnloadAllUtilSFX(); + unloadAllSFX(); + unloadAllUtilSFX(); } -void TonyEngine::PauseSound(bool bPause) { +void TonyEngine::pauseSound(bool bPause) { } -void TonyEngine::SetMusicVolume(int nChannel, int volume) { +void TonyEngine::setMusicVolume(int nChannel, int volume) { } -int TonyEngine::GetMusicVolume(int nChannel) { +int TonyEngine::getMusicVolume(int nChannel) { return 255; } - -Common::String TonyEngine::GetSaveStateFileName(int n) { +Common::String TonyEngine::getSaveStateFileName(int n) { return Common::String::format("tony.%03d", n); } -void TonyEngine::AutoSave(CORO_PARAM) { +void TonyEngine::autoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GrabThumbnail(); + grabThumbnail(); CORO_INVOKE_0(MainWaitFrame); CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->buf = GetSaveStateFileName(0); - _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave"); + _ctx->buf = getSaveStateFileName(0); + _theEngine.SaveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); MainUnfreeze(); CORO_END_CODE; } -void TonyEngine::SaveState(int n, const char *name) { - Common::String buf = GetSaveStateFileName(n); - _theEngine.SaveState(buf.c_str(), (byte *)m_curThumbnail, name); +void TonyEngine::saveState(int n, const char *name) { + Common::String buf = getSaveStateFileName(n); + _theEngine.SaveState(buf.c_str(), (byte *)_curThumbnail, name); } -void TonyEngine::LoadState(CORO_PARAM, int n) { +void TonyEngine::loadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - _ctx->buf = GetSaveStateFileName(n); + _ctx->buf = getSaveStateFileName(n); CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf.c_str()); CORO_END_CODE; } -bool TonyEngine::OpenVoiceDatabase() { +bool TonyEngine::openVoiceDatabase() { char id[4]; uint32 numfiles; @@ -459,9 +458,9 @@ bool TonyEngine::OpenVoiceDatabase() { for (uint32 i = 0; i < numfiles; ++i) { VoiceHeader vh; - vh.offset = _vdbFP.readUint32LE(); - vh.code = _vdbFP.readUint32LE(); - vh.parts = _vdbFP.readUint32LE(); + vh._offset = _vdbFP.readUint32LE(); + vh._code = _vdbFP.readUint32LE(); + vh._parts = _vdbFP.readUint32LE(); _voices.push_back(vh); } @@ -469,7 +468,7 @@ bool TonyEngine::OpenVoiceDatabase() { return true; } -void TonyEngine::CloseVoiceDatabase() { +void TonyEngine::closeVoiceDatabase() { if (_vdbFP.isOpen()) _vdbFP.close(); @@ -477,23 +476,23 @@ void TonyEngine::CloseVoiceDatabase() { _voices.clear(); } -void TonyEngine::GrabThumbnail(void) { - _window.GrabThumbnail(m_curThumbnail); +void TonyEngine::grabThumbnail(void) { + _window.GrabThumbnail(_curThumbnail); } -void TonyEngine::OptionScreen(void) { +void TonyEngine::optionScreen(void) { } -void TonyEngine::OpenInitLoadMenu(CORO_PARAM) { +void TonyEngine::openInitLoadMenu(CORO_PARAM) { _theEngine.OpenOptionScreen(coroParam, 1); } -void TonyEngine::OpenInitOptions(CORO_PARAM) { +void TonyEngine::openInitOptions(CORO_PARAM) { _theEngine.OpenOptionScreen(coroParam, 2); } -void TonyEngine::Abort(void) { - m_bQuitNow = true; +void TonyEngine::abortGame(void) { + _bQuitNow = true; } /** @@ -504,7 +503,7 @@ void TonyEngine::Abort(void) { * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain * in the outer 'main' process. */ -void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { +void TonyEngine::playProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; Common::String fn; CORO_END_CONTEXT(_ctx); @@ -517,7 +516,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { for (;;) { // If a savegame needs to be loaded, then do so if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { - _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber); + _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn); _vm->_loadSlotNumber = -1; } @@ -526,13 +525,13 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); + CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->_bDrawLocation); // Warns that a frame is finished - CoroScheduler.pulseEvent(_vm->m_hEndOfFrame); + CoroScheduler.pulseEvent(_vm->_hEndOfFrame); // Handle drawing the frame - if (!_vm->m_bPaused) { + if (!_vm->_bPaused) { if (!_vm->_theEngine.m_bWiping) _vm->_window.GetNewFrame(_vm->_theEngine, NULL); else @@ -552,12 +551,12 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { /** * Play the game */ -void TonyEngine::Play(void) { +void TonyEngine::play(void) { // Create the game player process - CoroScheduler.createProcess(PlayProcess, NULL); + CoroScheduler.createProcess(playProcess, NULL); // Loop through calling the scheduler until it's time for the game to quit - while (!shouldQuit() && !m_bQuitNow) { + while (!shouldQuit() && !_bQuitNow) { // Delay for a brief amount g_system->delayMillis(10); @@ -566,18 +565,16 @@ void TonyEngine::Play(void) { } } - - -void TonyEngine::Close(void) { - CloseMusic(); - CoroScheduler.closeEvent(m_hEndOfFrame); +void TonyEngine::close(void) { + closeMusic(); + CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); _window.Close(); - delete[] m_curThumbnail; + delete[] _curThumbnail; } -void TonyEngine::SwitchFullscreen(bool bFull) { +void TonyEngine::switchFullscreen(bool bFull) { _window.SwitchFullscreen(bFull); _theEngine.SwitchFullscreen(bFull); } @@ -586,21 +583,20 @@ void TonyEngine::GDIControl(bool bCon) { _theEngine.GDIControl(bCon); } - -void TonyEngine::FreezeTime(void) { - m_bTimeFreezed = true; - m_nTimeFreezed = GetTime() - m_startTime; +void TonyEngine::freezeTime(void) { + _bTimeFreezed = true; + _nTimeFreezed = getTime() - _startTime; } -void TonyEngine::UnfreezeTime(void) { - m_bTimeFreezed = false; +void TonyEngine::unfreezeTime(void) { + _bTimeFreezed = false; } /** * Returns the millisecond timer */ -uint32 TonyEngine::GetTime() { +uint32 TonyEngine::getTime() { return g_system->getMillis(); } @@ -621,9 +617,9 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { return Common::kUnknownError; RMSnapshot s; - s.GrabScreenshot(*GLOBALS.GfxEngine, 4, m_curThumbnail); + s.GrabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); - GLOBALS.GfxEngine->SaveState(GetSaveStateFileName(slot), (byte *)m_curThumbnail, desc); + GLOBALS.GfxEngine->SaveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 78e9abd476..83543f8022 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -72,32 +72,32 @@ struct TonyGameDescription; #define MAX_SFX_CHANNELS 32 struct VoiceHeader { - int offset; - int code; - int parts; + int _offset; + int _code; + int _parts; }; #define VOICE_HEADER_SIZE 12 class TonyEngine : public Engine { private: - Common::ErrorCode Init(); - void InitMusic(); - void CloseMusic(); - bool OpenVoiceDatabase(); - void CloseVoiceDatabase(); - void InitCustomFunctionMap(); - static void PlayProcess(CORO_PARAM, const void *param); + Common::ErrorCode init(); + void initMusic(); + void closeMusic(); + bool openVoiceDatabase(); + void closeVoiceDatabase(); + void initCustomFunctionMap(); + static void playProcess(CORO_PARAM, const void *param); protected: // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; public: - LPCUSTOMFUNCTION FuncList[300]; - Common::String FuncListStrings[300]; + LPCUSTOMFUNCTION _funcList[300]; + Common::String _funcListStrings[300]; Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; - uint32 m_hEndOfFrame; + uint32 _hEndOfFrame; Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; @@ -115,14 +115,14 @@ public: DD_BASE2 }; - FPSTREAM *m_stream[6]; - FPSFX *m_sfx[MAX_SFX_CHANNELS]; - FPSFX *m_utilSfx[MAX_SFX_CHANNELS]; - RMFont *fonts[2]; - bool m_bPaused; - bool m_bDrawLocation; - int m_startTime; - uint16 *m_curThumbnail; + FPSTREAM *_stream[6]; + FPSFX *_sfx[MAX_SFX_CHANNELS]; + FPSFX *_utilSfx[MAX_SFX_CHANNELS]; +// RMFont *_fonts[2]; + bool _bPaused; + bool _bDrawLocation; + int _startTime; + uint16 *_curThumbnail; int _initialLoadSlotNumber; int _loadSlotNumber; @@ -131,9 +131,9 @@ public: RMWindow _window; RMGfxEngine _theEngine; - bool m_bQuitNow; - bool m_bTimeFreezed; - int m_nTimeFreezed; + bool _bQuitNow; + bool _bTimeFreezed; + int _nTimeFreezed; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); @@ -144,7 +144,7 @@ public: uint16 getVersion() const; bool getIsDemo() const; bool isCompressed() const; - RMGfxEngine *GetEngine() { + RMGfxEngine *getEngine() { return &_theEngine; } void GUIError(const Common::String &msg); @@ -157,70 +157,70 @@ public: // Warn when are being controlled by the GDI void GDIControl(bool bCon); - void Play(); - void Close(); - void Abort(); + void play(); + void close(); + void abortGame(); - void GetDataDirectory(DATADIR dir, char *path); + void getDataDirectory(DATADIR dir, char *path); - void SwitchFullscreen(bool bFull); - void OptionScreen(void); + void switchFullscreen(bool bFull); + void optionScreen(void); - void ShowLocation(void) { - m_bDrawLocation = true; + void showLocation(void) { + _bDrawLocation = true; } - void HideLocation(void) { - m_bDrawLocation = false; + void hideLocation(void) { + _bDrawLocation = false; } // Reads the time - uint32 GetTime(void); - void FreezeTime(void); - void UnfreezeTime(void); + uint32 getTime(void); + void freezeTime(void); + void unfreezeTime(void); // Music // ****** - void PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); - void StopMusic(int nChannel); + void playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); + void stopMusic(int nChannel); - void PlaySFX(int nSfx, int nFX = 0); - void StopSFX(int nSfx); + void playSFX(int nSfx, int nFX = 0); + void stopSFX(int nSfx); - void PlayUtilSFX(int nSfx, int nFX = 0); - void StopUtilSFX(int nSfx); + void playUtilSFX(int nSfx, int nFX = 0); + void stopUtilSFX(int nSfx); - FPSFX *CreateSFX(byte *buf); + FPSFX *createSFX(byte *buf); - void PreloadSFX(int nSfx, const char *fn); - void UnloadAllSFX(void); + void preloadSFX(int nSfx, const char *fn); + void unloadAllSFX(void); - void PreloadUtilSFX(int nSfx, const char *fn); - void UnloadAllUtilSFX(void); + void preloadUtilSFX(int nSfx, const char *fn); + void unloadAllUtilSFX(void); // Stop all the audio - void PauseSound(bool bPause); + void pauseSound(bool bPause); - void SetMusicVolume(int nChannel, int volume); - int GetMusicVolume(int nChannel); + void setMusicVolume(int nChannel, int volume); + int getMusicVolume(int nChannel); // Handle saving - void AutoSave(CORO_PARAM); - void SaveState(int n, const char *name); - void LoadState(CORO_PARAM, int n); - static Common::String GetSaveStateFileName(int n); + void autoSave(CORO_PARAM); + void saveState(int n, const char *name); + void loadState(CORO_PARAM, int n); + static Common::String getSaveStateFileName(int n); // Get a thumbnail - void GrabThumbnail(void); - uint16 *GetThumbnail(void) { - return m_curThumbnail; + void grabThumbnail(void); + uint16 *getThumbnail(void) { + return _curThumbnail; } - void Quit(void) { - m_bQuitNow = true; + void quitGame(void) { + _bQuitNow = true; } - void OpenInitLoadMenu(CORO_PARAM); - void OpenInitOptions(CORO_PARAM); + void openInitLoadMenu(CORO_PARAM); + void openInitOptions(CORO_PARAM); }; // Global reference to the TonyEngine object diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 71f95f8133..212899cde3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -119,7 +119,7 @@ void RMTony::Init(void) { ds.Close(); m_body.SetPattern(0); - m_nTimeLastStep = _vm->GetTime(); + m_nTimeLastStep = _vm->getTime(); } @@ -141,7 +141,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { SetSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement - _ctx->time = _vm->GetTime(); + _ctx->time = _vm->getTime(); do { m_nTimeLastStep += (1000 / 40); -- cgit v1.2.3 From 7b547a78cc08627dfedd6a08a3e1afb58d8193fd Mon Sep 17 00:00:00 2001 From: D G Turner Date: Mon, 4 Jun 2012 22:54:53 +0100 Subject: TONY: Fix english CD detection entry. --- engines/tony/detection_tables.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 36548c4e3c..97bcc30f4b 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -30,8 +30,7 @@ static const TonyGameDescription gameDescriptions[] = { 0, { {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, - // Fake md5 : to be fixed! - {"roasted.mpc", 0, "bad97eae03a4db3e99565e39b0b3c06a", 16384}, + {"roasted.mpc", 0, "57c4a3860cf899443c357e0078ea6f49", 366773}, AD_LISTEND }, Common::EN_ANY, -- cgit v1.2.3 From 014330a538244b0e33bcf230cc5e84c28977f096 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 00:02:15 +0200 Subject: TONY: Rename variables and functions in input.h --- engines/tony/custom.cpp | 8 ++++---- engines/tony/font.cpp | 4 ++-- engines/tony/game.cpp | 8 ++++---- engines/tony/gfxengine.cpp | 50 +++++++++++++++++++++++----------------------- engines/tony/input.cpp | 12 +++++------ engines/tony/input.h | 26 ++++++++++++------------ engines/tony/inventory.cpp | 2 +- 7 files changed, 55 insertions(+), 55 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 47089f3214..1ed7c8b5a6 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2020,10 +2020,10 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); - while (!(GLOBALS.Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { + while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->MousePos()); + CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->mousePos()); GLOBALS.Unfreeze(); } @@ -2361,9 +2361,9 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); - if (GLOBALS.Input->MouseLeftClicked() || GLOBALS.Input->MouseRightClicked()) + if (GLOBALS.Input->mouseLeftClicked() || GLOBALS.Input->mouseRightClicked()) break; - if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 567da3041c..a9f7759156 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2086,13 +2086,13 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) { - if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } if (!m_bNoTab) { if (m_input) { - if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) + if (m_input->mouseLeftClicked() || m_input->mouseRightClicked()) return; } } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 42c33f2259..28d7cd5e8c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1032,9 +1032,9 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { return; // Reads input - _ctx->mousePos = input->MousePos(); - _ctx->bLeftClick = input->MouseLeftClicked(); - _ctx->bRightClick = input->MouseRightClicked(); + _ctx->mousePos = input->mousePos(); + _ctx->bLeftClick = input->mouseLeftClicked(); + _ctx->bRightClick = input->mouseRightClicked(); _ctx->bRefresh = false; @@ -1097,7 +1097,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->getEngine()->GetInput().GetAsyncKeyState(c)) +#define KEYPRESS(c) (_vm->getEngine()->GetInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4642ee0ab7..2ff57bf804 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -146,7 +146,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { g_system->lockMutex(csMainLoop); // Poll of input devices - m_input.Poll(); + m_input.poll(); if (m_bMustEnterMenu && GLOBALS.bIdleExited) { m_bOption = true; @@ -172,12 +172,12 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Check the mouse input if (m_bInput && !m_tony.InAction()) { // If we are on the inventory, it is it who controls all input - if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { + if (m_inv.HaveFocus(m_input.mousePos()) && !m_inter.Active()) { // Left Click // ********** - if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + if (m_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click activates the combine, if we are on an object - if (m_inv.LeftClick(m_input.MousePos(), m_curActionObj)) { + if (m_inv.LeftClick(m_input.mousePos(), m_curActionObj)) { m_curAction = TA_COMBINE; m_point.SetAction(m_curAction); } @@ -185,18 +185,18 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Right Click // *********** - if (m_input.MouseRightClicked()) { + if (m_input.mouseRightClicked()) { if (m_itemName.IsItemSelected()) { m_curActionObj = 0; - m_inv.RightClick(m_input.MousePos()); + m_inv.RightClick(m_input.mousePos()); } else - m_inv.RightClick(m_input.MousePos()); + m_inv.RightClick(m_input.mousePos()); } else // Right Release // ************* - if (m_input.MouseRightReleased()) { - if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + if (m_input.mouseRightReleased()) { + if (m_inv.RightRelease(m_input.mousePos(), m_curAction)) { CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); m_curAction = TA_GOTO; @@ -208,16 +208,16 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // ************ if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { - if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { + if ((m_input.mouseLeftClicked() && m_input.mousePos().x < 3 && m_input.mousePos().y < 3)) { CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if (m_input.GetAsyncKeyState(Common::KEYCODE_ESCAPE)) + } else if (m_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(OpenOptionScreen, 0); else if (!_vm->getIsDemo()) { - if (m_input.GetAsyncKeyState(Common::KEYCODE_F3) || m_input.GetAsyncKeyState(Common::KEYCODE_F5)) + if (m_input.getAsyncKeyState(Common::KEYCODE_F3) || m_input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen CORO_INVOKE_1(OpenOptionScreen, 3); - else if (m_input.GetAsyncKeyState(Common::KEYCODE_F2) || m_input.GetAsyncKeyState(Common::KEYCODE_F7)) + else if (m_input.getAsyncKeyState(Common::KEYCODE_F2) || m_input.getAsyncKeyState(Common::KEYCODE_F7)) // Load game screen CORO_INVOKE_1(OpenOptionScreen, 4); } @@ -226,7 +226,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Left Click // ************** - if (m_input.MouseLeftClicked() && !m_inter.Active()) { + if (m_input.mouseLeftClicked() && !m_inter.Active()) { if (m_curAction != TA_COMBINE) CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); @@ -247,29 +247,29 @@ SKIPCLICKSINISTRO: // ************ if (m_curAction == TA_COMBINE) { // During a combine, it cancels it - if (m_input.MouseRightClicked()) { + if (m_input.mouseRightClicked()) { m_inv.EndCombine(); m_curActionObj = 0; m_curAction = TA_GOTO; m_point.SetAction(m_curAction); m_point.SetSpecialPointer(RMPointer::PTR_NONE); } - } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { + } else if (m_input.mouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { if (m_bGUIInterface) { // Before opening the interface, replaces GOTO m_curAction = TA_GOTO; m_curActionObj = 0; m_point.SetAction(m_curAction); - m_inter.Clicked(m_input.MousePos()); + m_inter.Clicked(m_input.mousePos()); } } // Right Release // ************* - if (m_input.MouseRightReleased()) { + if (m_input.mouseRightReleased()) { if (m_bGUIInterface) { - if (m_inter.Released(m_input.MousePos(), m_curAction)) { + if (m_inter.Released(m_input.mousePos(), m_curAction)) { m_point.SetAction(m_curAction); CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); @@ -281,14 +281,14 @@ SKIPCLICKSINISTRO: } // Update the name under the mouse pointer - m_itemName.SetMouseCoord(m_input.MousePos()); + m_itemName.SetMouseCoord(m_input.mousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } // Interface & Inventory - m_inter.DoFrame(m_bigBuf, m_input.MousePos()); - m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + m_inter.DoFrame(m_bigBuf, m_input.mousePos()); + m_inv.DoFrame(m_bigBuf, m_point, m_input.mousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); } // Animate Tony @@ -305,7 +305,7 @@ SKIPCLICKSINISTRO: m_tony.SetScrollPosition(m_loc.ScrollPosition()); if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { - m_point.SetCoord(m_input.MousePos()); + m_point.SetCoord(m_input.mousePos()); m_point.DoFrame(&m_bigBuf); } @@ -498,7 +498,7 @@ void RMGfxEngine::Init() { mpalInstallItemIrq(ItemIrq); // Initialise the input - m_input.Init(); + m_input.init(); // Initialise the mouse pointer m_point.Init(); @@ -527,7 +527,7 @@ void RMGfxEngine::Close(void) { m_inv.Close(); m_tony.Close(); m_point.Close(); - m_input.Close(); + m_input.close(); } void RMGfxEngine::SwitchFullscreen(bool bFull) { diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index fc98544e14..4990b379b9 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,7 +49,7 @@ RMInput::~RMInput() { } -void RMInput::Poll(void) { +void RMInput::poll(void) { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events @@ -102,24 +102,24 @@ void RMInput::Poll(void) { } } -void RMInput::Init() { +void RMInput::init() { } -void RMInput::Close(void) { +void RMInput::close(void) { } -bool RMInput::MouseLeft() { +bool RMInput::mouseLeft() { return _leftButton; } -bool RMInput::MouseRight() { +bool RMInput::mouseRight() { return _rightButton; } /** * Return true if a key has been pressed */ -bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { +bool RMInput::getAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames bool result = _keyDown[(int)kc]; diff --git a/engines/tony/input.h b/engines/tony/input.h index 524f604ec2..e7e200e1b7 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -55,45 +55,45 @@ public: ~RMInput(); // Class initialisation - void Init(/*uint32 hInst*/); + void init(/*uint32 hInst*/); // Closes the class - void Close(void); + void close(void); // Polling (must be performed once per frame) - void Poll(void); + void poll(void); // Reading of the mouse - RMPoint MousePos() { + RMPoint mousePos() { return _mousePos; } // Current status of the mouse buttons - bool MouseLeft(); - bool MouseRight(); + bool mouseLeft(); + bool mouseRight(); // Events of mouse clicks - bool MouseLeftClicked() { + bool mouseLeftClicked() { return _leftClickMouse; } - bool MouseRightClicked() { + bool mouseRightClicked() { return _rightClickMouse; } - bool MouseBothClicked() { + bool mouseBothClicked() { return _leftClickMouse && _rightClickMouse; } - bool MouseLeftReleased() { + bool mouseLeftReleased() { return _leftReleaseMouse; } - bool MouseRightReleased() { + bool mouseRightReleased() { return _rightReleaseMouse; } - bool MouseBothReleased() { + bool mouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } // Returns true if the given key is pressed - bool GetAsyncKeyState(Common::KeyCode kc); + bool getAsyncKeyState(Common::KeyCode kc); }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 1a245d9aba..aec1e1a57b 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -530,7 +530,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { + if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } -- cgit v1.2.3 From a5cb751f7ab82a089207025810e3aaa0f0748dbd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 01:04:53 +0200 Subject: TONY: Rename variables and functions in gfxengine.h --- engines/tony/custom.cpp | 4 +- engines/tony/custom.h | 2 +- engines/tony/font.cpp | 2 +- engines/tony/game.cpp | 42 ++-- engines/tony/gfxengine.cpp | 500 ++++++++++++++++++++++----------------------- engines/tony/gfxengine.h | 122 +++++------ engines/tony/inventory.cpp | 2 +- engines/tony/tony.cpp | 32 +-- 8 files changed, 352 insertions(+), 354 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 1ed7c8b5a6..59de6909dc 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2363,7 +2363,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_INVOKE_0(GLOBALS.WaitFrame); if (GLOBALS.Input->mouseLeftClicked() || GLOBALS.Input->mouseRightClicked()) break; - if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; } @@ -2531,7 +2531,7 @@ ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() -void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { +void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { GLOBALS.Tony = tony; GLOBALS.Pointer = ptr; GLOBALS.Boxes = box; diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 9b53dc32d7..514af1223c 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -72,7 +72,7 @@ class RMInventory; class RMInput; void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap); -void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); +void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); #endif diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a9f7759156..71cffab26b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2086,7 +2086,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) { - if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 28d7cd5e8c..71dbb68c73 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,23 +47,23 @@ using namespace MPAL; /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->getEngine()->LoadLocation(nLoc, pt, start); + return _vm->getEngine()->loadLocation(nLoc, pt, start); } void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - _vm->getEngine()->UnloadLocation(coroParam, bDoOnExit, result); + _vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); } void MainLinkGraphicTask(RMGfxTask *task) { - _vm->getEngine()->LinkGraphicTask(task); + _vm->getEngine()->linkGraphicTask(task); } void MainFreeze(void) { - _vm->getEngine()->Freeze(); + _vm->getEngine()->freeze(); } void MainUnfreeze(void) { - _vm->getEngine()->Unfreeze(); + _vm->getEngine()->unfreeze(); } void MainWaitFrame(CORO_PARAM) { @@ -71,11 +71,11 @@ void MainWaitFrame(CORO_PARAM) { } void MainShowMouse(void) { - _vm->getEngine()->EnableMouse(); + _vm->getEngine()->enableMouse(); } void MainHideMouse(void) { - _vm->getEngine()->DisableMouse(); + _vm->getEngine()->disableMouse(); } void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { @@ -83,39 +83,39 @@ void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int } void MainDisableInput(void) { - _vm->getEngine()->DisableInput(); + _vm->getEngine()->disableInput(); } void MainEnableInput(void) { - _vm->getEngine()->EnableInput(); + _vm->getEngine()->enableInput(); } void MainInitWipe(int type) { - _vm->getEngine()->InitWipe(type); + _vm->getEngine()->initWipe(type); } void MainCloseWipe(void) { - _vm->getEngine()->CloseWipe(); + _vm->getEngine()->closeWipe(); } void MainWaitWipeEnd(CORO_PARAM) { - _vm->getEngine()->WaitWipeEnd(coroParam); + _vm->getEngine()->waitWipeEnd(coroParam); } void MainEnableGUI(void) { - _vm->getEngine()->m_bGUIInterface = true; - _vm->getEngine()->m_bGUIInventory = true; - _vm->getEngine()->m_bGUIOption = true; + _vm->getEngine()->_bGUIInterface = true; + _vm->getEngine()->_bGUIInventory = true; + _vm->getEngine()->_bGUIOption = true; } void MainDisableGUI(void) { - _vm->getEngine()->m_bGUIInterface = false; - _vm->getEngine()->m_bGUIInventory = false; - _vm->getEngine()->m_bGUIOption = false; + _vm->getEngine()->_bGUIInterface = false; + _vm->getEngine()->_bGUIInventory = false; + _vm->getEngine()->_bGUIOption = false; } void MainSetPalesati(bool bPalesati) { - _vm->getEngine()->SetPalesati(bPalesati); + _vm->getEngine()->setPalesati(bPalesati); } /****************************************************************************\ @@ -1097,9 +1097,9 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->getEngine()->GetInput().getAsyncKeyState(c)) +#define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } + m_EditName[strlen(m_EditName) + 1] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } /**************** State Buttons **************/ if (m_bEditSaveName) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 2ff57bf804..75eb6de883 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -61,34 +61,34 @@ void ExitAllIdles(CORO_PARAM, const void *param) { RMGfxEngine::RMGfxEngine() { // Create big buffer where the frame will be rendered - m_bigBuf.Create(RM_BBX, RM_BBY, 16); - m_bigBuf.OffsetY(RM_SKIPY); - - csMainLoop = NULL; - m_nCurLoc = 0; - m_curAction = TA_GOTO; - m_curActionObj = 0; - m_nWipeType = 0; - m_hWipeEvent = 0; - m_nWipeStep = 0; - m_bMustEnterMenu = false; - m_bWiping = false; - m_bGUIOption = false; - m_bGUIInterface = false; - m_bGUIInventory = false; - m_bAlwaysDrawMouse = false; - m_bOption = false; - m_bLocationLoaded = false; - m_bInput = false; + _bigBuf.Create(RM_BBX, RM_BBY, 16); + _bigBuf.OffsetY(RM_SKIPY); + + _csMainLoop = NULL; + _nCurLoc = 0; + _curAction = TA_GOTO; + _curActionObj = 0; + _nWipeType = 0; + _hWipeEvent = 0; + _nWipeStep = 0; + _bMustEnterMenu = false; + _bWiping = false; + _bGUIOption = false; + _bGUIInterface = false; + _bGUIInventory = false; + _bAlwaysDrawMouse = false; + _bOption = false; + _bLocationLoaded = false; + _bInput = false; } RMGfxEngine::~RMGfxEngine() { // Close the buffer - m_bigBuf.Destroy(); - g_system->deleteMutex(csMainLoop); + _bigBuf.Destroy(); + g_system->deleteMutex(_csMainLoop); } -void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { +void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { CORO_BEGIN_CONTEXT; bool bRes; CORO_END_CONTEXT(_ctx); @@ -98,271 +98,271 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - CORO_INVOKE_2(m_opt.Init, m_bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.Init, _bigBuf, _ctx->bRes); else if (type == 1) - CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, true, _ctx->bRes); + CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, true, _ctx->bRes); else if (type == 2) - CORO_INVOKE_2(m_opt.InitNoLoadSave, m_bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.InitNoLoadSave, _bigBuf, _ctx->bRes); else if (type == 3) - CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, false, _ctx->bRes); else if (type == 4) - CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.InitSaveMenuOnly, _bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->pauseSound(true); - DisableInput(); - m_inv.EndCombine(); - m_curActionObj = 0; - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetCustomPointer(NULL); - EnableMouse(); + disableInput(); + _inv.EndCombine(); + _curActionObj = 0; + _curAction = TA_GOTO; + _point.SetAction(_curAction); + _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.SetCustomPointer(NULL); + enableMouse(); _vm->grabThumbnail(); // Exists the IDLE to avoid premature death in loading - m_bMustEnterMenu = true; + _bMustEnterMenu = true; if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; } else { - CORO_INVOKE_0(m_tony.StopNoAction); + CORO_INVOKE_0(_tony.StopNoAction); GLOBALS.bIdleExited = false; - CoroScheduler.createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); + CoroScheduler.createProcess(ExitAllIdles, &_nCurLoc, sizeof(int)); } } CORO_END_CODE; } -void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { +void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - g_system->lockMutex(csMainLoop); + g_system->lockMutex(_csMainLoop); // Poll of input devices - m_input.poll(); + _input.poll(); - if (m_bMustEnterMenu && GLOBALS.bIdleExited) { - m_bOption = true; - m_bMustEnterMenu = false; + if (_bMustEnterMenu && GLOBALS.bIdleExited) { + _bOption = true; + _bMustEnterMenu = false; GLOBALS.bIdleExited = false; } - if (m_bOption) { - CORO_INVOKE_1(m_opt.DoFrame, &m_input); - m_bOption = !m_opt.IsClosing(); - if (!m_bOption) { - DisableMouse(); - EnableInput(); - mpalStartIdlePoll(m_nCurLoc); + if (_bOption) { + CORO_INVOKE_1(_opt.DoFrame, &_input); + _bOption = !_opt.IsClosing(); + if (!_bOption) { + disableMouse(); + enableInput(); + mpalStartIdlePoll(_nCurLoc); _vm->pauseSound(false); } } - if (bDrawLocation && m_bLocationLoaded) { + if (bDrawLocation && _bLocationLoaded) { // Location and objects - m_loc.DoFrame(&m_bigBuf); + _loc.DoFrame(&_bigBuf); // Check the mouse input - if (m_bInput && !m_tony.InAction()) { + if (_bInput && !_tony.InAction()) { // If we are on the inventory, it is it who controls all input - if (m_inv.HaveFocus(m_input.mousePos()) && !m_inter.Active()) { + if (_inv.HaveFocus(_input.mousePos()) && !_inter.Active()) { // Left Click // ********** - if (m_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + if (_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click activates the combine, if we are on an object - if (m_inv.LeftClick(m_input.mousePos(), m_curActionObj)) { - m_curAction = TA_COMBINE; - m_point.SetAction(m_curAction); + if (_inv.LeftClick(_input.mousePos(), _curActionObj)) { + _curAction = TA_COMBINE; + _point.SetAction(_curAction); } } else // Right Click // *********** - if (m_input.mouseRightClicked()) { - if (m_itemName.IsItemSelected()) { - m_curActionObj = 0; - m_inv.RightClick(m_input.mousePos()); + if (_input.mouseRightClicked()) { + if (_itemName.IsItemSelected()) { + _curActionObj = 0; + _inv.RightClick(_input.mousePos()); } else - m_inv.RightClick(m_input.mousePos()); + _inv.RightClick(_input.mousePos()); } else // Right Release // ************* - if (m_input.mouseRightReleased()) { - if (m_inv.RightRelease(m_input.mousePos(), m_curAction)) { - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + if (_input.mouseRightReleased()) { + if (_inv.RightRelease(_input.mousePos(), _curAction)) { + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); + _curAction = TA_GOTO; + _point.SetAction(_curAction); } } } else { // Options Menu // ************ - if (m_bGUIOption) { - if (!m_tony.InAction() && m_bInput) { - if ((m_input.mouseLeftClicked() && m_input.mousePos().x < 3 && m_input.mousePos().y < 3)) { - CORO_INVOKE_1(OpenOptionScreen, 0); + if (_bGUIOption) { + if (!_tony.InAction() && _bInput) { + if ((_input.mouseLeftClicked() && _input.mousePos().x < 3 && _input.mousePos().y < 3)) { + CORO_INVOKE_1(openOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if (m_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) - CORO_INVOKE_1(OpenOptionScreen, 0); + } else if (_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) + CORO_INVOKE_1(openOptionScreen, 0); else if (!_vm->getIsDemo()) { - if (m_input.getAsyncKeyState(Common::KEYCODE_F3) || m_input.getAsyncKeyState(Common::KEYCODE_F5)) + if (_input.getAsyncKeyState(Common::KEYCODE_F3) || _input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen - CORO_INVOKE_1(OpenOptionScreen, 3); - else if (m_input.getAsyncKeyState(Common::KEYCODE_F2) || m_input.getAsyncKeyState(Common::KEYCODE_F7)) + CORO_INVOKE_1(openOptionScreen, 3); + else if (_input.getAsyncKeyState(Common::KEYCODE_F2) || _input.getAsyncKeyState(Common::KEYCODE_F7)) // Load game screen - CORO_INVOKE_1(OpenOptionScreen, 4); + CORO_INVOKE_1(openOptionScreen, 4); } } } // Left Click // ************** - if (m_input.mouseLeftClicked() && !m_inter.Active()) { + if (_input.mouseLeftClicked() && !_inter.Active()) { - if (m_curAction != TA_COMBINE) - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); - else if (m_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + if (_curAction != TA_COMBINE) + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.CurAction()); + else if (_itemName.GetSelectedItem() != NULL) + CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), TA_COMBINE, _curActionObj); - if (m_curAction == TA_COMBINE) { - m_inv.EndCombine(); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); + if (_curAction == TA_COMBINE) { + _inv.EndCombine(); + _point.SetSpecialPointer(RMPointer::PTR_NONE); } - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); + _curAction = TA_GOTO; + _point.SetAction(_curAction); } SKIPCLICKSINISTRO: // Right Click // ************ - if (m_curAction == TA_COMBINE) { + if (_curAction == TA_COMBINE) { // During a combine, it cancels it - if (m_input.mouseRightClicked()) { - m_inv.EndCombine(); - m_curActionObj = 0; - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); + if (_input.mouseRightClicked()) { + _inv.EndCombine(); + _curActionObj = 0; + _curAction = TA_GOTO; + _point.SetAction(_curAction); + _point.SetSpecialPointer(RMPointer::PTR_NONE); } - } else if (m_input.mouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { - if (m_bGUIInterface) { + } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.GetSpecialPointer() == RMPointer::PTR_NONE) { + if (_bGUIInterface) { // Before opening the interface, replaces GOTO - m_curAction = TA_GOTO; - m_curActionObj = 0; - m_point.SetAction(m_curAction); - m_inter.Clicked(m_input.mousePos()); + _curAction = TA_GOTO; + _curActionObj = 0; + _point.SetAction(_curAction); + _inter.Clicked(_input.mousePos()); } } // Right Release // ************* - if (m_input.mouseRightReleased()) { - if (m_bGUIInterface) { - if (m_inter.Released(m_input.mousePos(), m_curAction)) { - m_point.SetAction(m_curAction); - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); + if (_input.mouseRightReleased()) { + if (_bGUIInterface) { + if (_inter.Released(_input.mousePos(), _curAction)) { + _point.SetAction(_curAction); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); + + _curAction = TA_GOTO; + _point.SetAction(_curAction); } } } } // Update the name under the mouse pointer - m_itemName.SetMouseCoord(m_input.mousePos()); - if (!m_inter.Active() && !m_inv.MiniActive()) - CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); + _itemName.SetMouseCoord(_input.mousePos()); + if (!_inter.Active() && !_inv.MiniActive()) + CORO_INVOKE_4(_itemName.DoFrame, _bigBuf, _loc, _point, _inv); } // Interface & Inventory - m_inter.DoFrame(m_bigBuf, m_input.mousePos()); - m_inv.DoFrame(m_bigBuf, m_point, m_input.mousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + _inter.DoFrame(_bigBuf, _input.mousePos()); + _inv.DoFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); } // Animate Tony - CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); + CORO_INVOKE_2(_tony.DoFrame, &_bigBuf, _nCurLoc); // Update screen scrolling to keep Tony in focus - if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { - RMPoint showThis = m_tony.Position(); + if (_tony.MustUpdateScrolling() && _bLocationLoaded) { + RMPoint showThis = _tony.Position(); showThis.y -= 60; - m_loc.UpdateScrolling(showThis); + _loc.UpdateScrolling(showThis); } - if (m_bLocationLoaded) - m_tony.SetScrollPosition(m_loc.ScrollPosition()); + if (_bLocationLoaded) + _tony.SetScrollPosition(_loc.ScrollPosition()); - if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { - m_point.SetCoord(m_input.mousePos()); - m_point.DoFrame(&m_bigBuf); + if ((!_tony.InAction() && _bInput) || _bAlwaysDrawMouse) { + _point.SetCoord(_input.mousePos()); + _point.DoFrame(&_bigBuf); } // ********************** // Draw the list in the OT // ********************** - CORO_INVOKE_0(m_bigBuf.DrawOT); + CORO_INVOKE_0(_bigBuf.DrawOT); #define FSTEP (480/32) // Wipe - if (m_bWiping) { - switch (m_nWipeType) { + if (_bWiping) { + switch (_nWipeType) { case 1: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; + if (!(_rcWipeEllipse.bottom - _rcWipeEllipse.top >= FSTEP * 2)) { + CoroScheduler.setEvent(_hWipeEvent); + _nWipeType = 3; break; } - m_rcWipeEllipse.top += FSTEP; - m_rcWipeEllipse.left += FSTEP; - m_rcWipeEllipse.right -= FSTEP; - m_rcWipeEllipse.bottom -= FSTEP; + _rcWipeEllipse.top += FSTEP; + _rcWipeEllipse.left += FSTEP; + _rcWipeEllipse.right -= FSTEP; + _rcWipeEllipse.bottom -= FSTEP; break; case 2: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; + if (!(_rcWipeEllipse.bottom - _rcWipeEllipse.top < 480 - FSTEP)) { + CoroScheduler.setEvent(_hWipeEvent); + _nWipeType = 3; break; } - m_rcWipeEllipse.top -= FSTEP; - m_rcWipeEllipse.left -= FSTEP; - m_rcWipeEllipse.right += FSTEP; - m_rcWipeEllipse.bottom += FSTEP; + _rcWipeEllipse.top -= FSTEP; + _rcWipeEllipse.left -= FSTEP; + _rcWipeEllipse.right += FSTEP; + _rcWipeEllipse.bottom += FSTEP; break; } } - g_system->unlockMutex(csMainLoop); + g_system->unlockMutex(_csMainLoop); CORO_END_CODE; } -void RMGfxEngine::InitCustomDll(void) { - SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); +void RMGfxEngine::initCustomDll(void) { + setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); } -void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { +void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { RMItem *item; assert(GLOBALS.GfxEngine); - if (GLOBALS.GfxEngine->m_bLocationLoaded) { - item = GLOBALS.GfxEngine->m_loc.GetItemFromCode(dwItem); + if (GLOBALS.GfxEngine->_bLocationLoaded) { + item = GLOBALS.GfxEngine->_loc.GetItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) @@ -378,45 +378,45 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { } -void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { +void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start.x == -1 || start.y == -1) { start.x = ptTonyStart.x - RM_SX / 2; start.y = ptTonyStart.y - RM_SY / 2; } - m_loc.SetScrollPosition(start); + _loc.SetScrollPosition(start); if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { } else { - m_tony.SetPosition(ptTonyStart, nLoc); - m_tony.SetScrollPosition(start); + _tony.SetPosition(ptTonyStart, nLoc); + _tony.SetScrollPosition(start); } - m_curAction = TA_GOTO; - m_point.SetCustomPointer(NULL); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetAction(m_curAction); - m_inter.Reset(); - m_inv.Reset(); + _curAction = TA_GOTO; + _point.SetCustomPointer(NULL); + _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.SetAction(_curAction); + _inter.Reset(); + _inv.Reset(); - mpalStartIdlePoll(m_nCurLoc); + mpalStartIdlePoll(_nCurLoc); } -uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { +uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bool bLoaded; int i; - m_nCurLoc = nLoc; + _nCurLoc = nLoc; bLoaded = false; for (i = 0; i < 5; i++) { // Try the loading of the location - RMRes res(m_nCurLoc); + RMRes res(_nCurLoc); if (!res.IsValid()) continue; - m_loc.Load(res); - InitForNewLocation(nLoc, ptTonyStart, start); + _loc.Load(res); + initForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; } @@ -424,16 +424,16 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (!bLoaded) error("Location was not loaded"); - if (m_bOption) - m_opt.ReInit(m_bigBuf); + if (_bOption) + _opt.ReInit(_bigBuf); - m_bLocationLoaded = true; + _bLocationLoaded = true; // On entering the location return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { +void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CONTEXT; uint32 h; CORO_END_CONTEXT(_ctx); @@ -441,21 +441,21 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CODE(_ctx); // Release the location - CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); + CORO_INVOKE_2(mpalEndIdlePoll, _nCurLoc, NULL); // On Exit? if (bDoOnExit) { - _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); + _ctx->h = mpalQueryDoAction(1, _nCurLoc, 0); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } MainFreeze(); - m_bLocationLoaded = false; + _bLocationLoaded = false; - m_bigBuf.ClearOT(); - m_loc.Unload(); + _bigBuf.ClearOT(); + _loc.Unload(); if (result != NULL) *result = CORO_INVALID_PID_VALUE; @@ -463,102 +463,100 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_END_CODE; } -void RMGfxEngine::Init() { +void RMGfxEngine::init() { // Screen loading RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); - m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(Common::nullContext); - m_bigBuf.ClearOT(); + _bigBuf.AddPrim(new RMGfxPrimitive(load)); + _bigBuf.DrawOT(Common::nullContext); + _bigBuf.ClearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); - - GLOBALS.bPatIrqFreeze = true; // Activate GUI - m_bGUIOption = true; - m_bGUIInterface = true; - m_bGUIInventory = true; + _bGUIOption = true; + _bGUIInterface = true; + _bGUIInventory = true; GLOBALS.bSkipSfxNoLoop = false; - m_bMustEnterMenu = false; + _bMustEnterMenu = false; GLOBALS.bIdleExited = false; - m_bOption = false; - m_bWiping = false; - m_hWipeEvent = CoroScheduler.createEvent(false, false); + _bOption = false; + _bWiping = false; + _hWipeEvent = CoroScheduler.createEvent(false, false); // Create the freeze event - csMainLoop = g_system->createMutex(); + _csMainLoop = g_system->createMutex(); // Initialise the IRQ function for items for MPAL GLOBALS.GfxEngine = this; - mpalInstallItemIrq(ItemIrq); + mpalInstallItemIrq(itemIrq); // Initialise the input - m_input.init(); + _input.init(); // Initialise the mouse pointer - m_point.Init(); + _point.Init(); // Initialise Tony - m_tony.Init(); - m_tony.LinkToBoxes(&_vm->_theBoxes); + _tony.Init(); + _tony.LinkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface - m_inv.Init(); - m_inter.Init(); + _inv.Init(); + _inter.Init(); // Download the location and set priorities @@@@@ - m_bLocationLoaded = false; + _bLocationLoaded = false; - EnableInput(); + enableInput(); // Starting the game - m_tony.ExecuteAction(20, 1, 0); + _tony.ExecuteAction(20, 1, 0); } -void RMGfxEngine::Close(void) { - m_bigBuf.ClearOT(); +void RMGfxEngine::close(void) { + _bigBuf.ClearOT(); - m_inter.Close(); - m_inv.Close(); - m_tony.Close(); - m_point.Close(); - m_input.close(); + _inter.Close(); + _inv.Close(); + _tony.Close(); + _point.Close(); + _input.close(); } -void RMGfxEngine::SwitchFullscreen(bool bFull) { +void RMGfxEngine::switchFullscreen(bool bFull) { } void RMGfxEngine::GDIControl(bool bCon) { } -void RMGfxEngine::EnableInput(void) { - m_bInput = true; +void RMGfxEngine::enableInput(void) { + _bInput = true; } -void RMGfxEngine::DisableInput(void) { - m_bInput = false; - m_inter.Reset(); +void RMGfxEngine::disableInput(void) { + _bInput = false; + _inter.Reset(); } -void RMGfxEngine::EnableMouse(void) { - m_bAlwaysDrawMouse = true; +void RMGfxEngine::enableMouse(void) { + _bAlwaysDrawMouse = true; } -void RMGfxEngine::DisableMouse(void) { - m_bAlwaysDrawMouse = false; +void RMGfxEngine::disableMouse(void) { + _bAlwaysDrawMouse = false; } -void RMGfxEngine::Freeze(void) { - g_system->lockMutex(csMainLoop); +void RMGfxEngine::freeze(void) { + g_system->lockMutex(_csMainLoop); } -void RMGfxEngine::Unfreeze(void) { - g_system->unlockMutex(csMainLoop); +void RMGfxEngine::unfreeze(void) { + g_system->unlockMutex(_csMainLoop); } void CharsSaveAll(Common::OutSaveFile *f); @@ -574,14 +572,14 @@ void LoadMusic(Common::InSaveFile *f); #define TONY_SAVEGAME_VERSION 8 -void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Common::String &name) { +void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Common::String &name) { Common::OutSaveFile *f; byte *state; uint thumbsize; uint size; int i; char buf[4]; - RMPoint tp = m_tony.Position(); + RMPoint tp = _tony.Position(); // Saving: MPAL variables, current location, and Tony inventory position @@ -612,7 +610,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm i = strlen(name.c_str()); f->writeByte(i); f->write(name.c_str(), i); - f->writeUint32LE(m_nCurLoc); + f->writeUint32LE(_nCurLoc); f->writeUint32LE(tp.x); f->writeUint32LE(tp.y); @@ -621,9 +619,9 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // Inventory - size = m_inv.GetSaveStateSize(); + size = _inv.GetSaveStateSize(); state = new byte[size]; - m_inv.SaveState(state); + _inv.SaveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -640,9 +638,9 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm bool bStat; // Saves the state of the shepherdess and show yourself - bStat = m_tony.GetPastorella(); + bStat = _tony.GetPastorella(); f->writeByte(bStat); - bStat = m_inter.GetPalesati(); + bStat = _inter.GetPalesati(); f->writeByte(bStat); // Save the chars @@ -677,7 +675,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm delete f; } -void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { +void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { // PROBLEM: You should change the location in a separate process to do the OnEnter CORO_BEGIN_CONTEXT; Common::InSaveFile *f; @@ -760,7 +758,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - m_inv.LoadState(_ctx->state); + _inv.LoadState(_ctx->state); delete[] _ctx->state; if (_ctx->ver >= 0x2) { // Versione 2: box please @@ -776,9 +774,9 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { bool bStat = false; bStat = _ctx->f->readByte(); - m_tony.SetPastorella(bStat); + _tony.SetPastorella(bStat); bStat = _ctx->f->readByte(); - m_inter.SetPalesati(bStat); + _inter.SetPalesati(bStat); CharsLoadAll(_ctx->f); } @@ -813,9 +811,9 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { delete _ctx->f; - CORO_INVOKE_2(UnloadLocation, false, NULL); - LoadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); - m_tony.SetPattern(RMTony::PAT_STANDRIGHT); + CORO_INVOKE_2(unloadLocation, false, NULL); + loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); + _tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); // On older versions, need to an enter action @@ -831,39 +829,39 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_0(RestoreMusic); - m_bGUIInterface = true; - m_bGUIInventory = true; - m_bGUIOption = true; + _bGUIInterface = true; + _bGUIInventory = true; + _bGUIOption = true; CORO_END_CODE; } -void RMGfxEngine::PauseSound(bool bPause) { - if (m_bLocationLoaded) - m_loc.PauseSound(bPause); +void RMGfxEngine::pauseSound(bool bPause) { + if (_bLocationLoaded) + _loc.PauseSound(bPause); } -void RMGfxEngine::InitWipe(int type) { - m_bWiping = true; - m_nWipeType = type; - m_nWipeStep = 0; +void RMGfxEngine::initWipe(int type) { + _bWiping = true; + _nWipeType = type; + _nWipeStep = 0; - if (m_nWipeType == 1) - m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); - else if (m_nWipeType == 2) - m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); + if (_nWipeType == 1) + _rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); + else if (_nWipeType == 2) + _rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); } -void RMGfxEngine::CloseWipe(void) { - m_bWiping = false; +void RMGfxEngine::closeWipe(void) { + _bWiping = false; } -void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE); +void RMGfxEngine::waitWipeEnd(CORO_PARAM) { + CoroScheduler.waitForSingleObject(coroParam, _hWipeEvent, CORO_INFINITE); } -bool RMGfxEngine::CanLoadSave() { - return m_bInput && !m_tony.InAction() && !_vm->getIsDemo(); +bool RMGfxEngine::canLoadSave() { + return _bInput && !_tony.InAction() && !_vm->getIsDemo(); } } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index b9ab411d2b..695c5af58f 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -44,110 +44,110 @@ namespace Tony { class RMGfxEngine { private: - RMGfxTargetBuffer m_bigBuf; - RMInput m_input; - RMPointer m_point; - RMLocation m_loc; - RMOptionScreen m_opt; - RMTony m_tony; - RMInventory m_inv; - RMInterface m_inter; - RMTextItemName m_itemName; - - bool m_bOption; - bool m_bLocationLoaded; - - bool m_bInput; - bool m_bAlwaysDrawMouse; - - int m_nCurLoc; - RMTonyAction m_curAction; - int m_curActionObj; - OSystem::MutexRef csMainLoop; - - int m_nWipeType; - uint32 m_hWipeEvent; - int m_nWipeStep; - - bool m_bMustEnterMenu; + RMGfxTargetBuffer _bigBuf; + RMInput _input; + RMPointer _point; + RMLocation _loc; + RMOptionScreen _opt; + RMTony _tony; + RMInventory _inv; + RMInterface _inter; + RMTextItemName _itemName; + + bool _bOption; + bool _bLocationLoaded; + + bool _bInput; + bool _bAlwaysDrawMouse; + + int _nCurLoc; + RMTonyAction _curAction; + int _curActionObj; + OSystem::MutexRef _csMainLoop; + + int _nWipeType; + uint32 _hWipeEvent; + int _nWipeStep; + + bool _bMustEnterMenu; protected: - static void ItemIrq(uint32 dwItem, int nPattern, int nStatus); - void InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); + static void itemIrq(uint32 dwItem, int nPattern, int nStatus); + void initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); public: - bool m_bWiping; - Common::Rect m_rcWipeEllipse; - bool m_bGUIOption; - bool m_bGUIInterface; - bool m_bGUIInventory; + bool _bWiping; + Common::Rect _rcWipeEllipse; + bool _bGUIOption; + bool _bGUIInterface; + bool _bGUIInventory; public: RMGfxEngine(); virtual ~RMGfxEngine(); // Draw the next frame - void DoFrame(CORO_PARAM, bool bDrawLocation); + void doFrame(CORO_PARAM, bool bDrawLocation); // Initialises the graphics engine - void Init(); + void init(); // Closes the graphics engine - void Close(void); + void close(void); // Warns when changing - void SwitchFullscreen(bool bFull); + void switchFullscreen(bool bFull); // Warn that we are guided by the GDI void GDIControl(bool bCon); // Warns when entering or exits the options menu - void OpenOptionScreen(CORO_PARAM, int type); + void openOptionScreen(CORO_PARAM, int type); // Enables or disables mouse input - void EnableInput(void); - void DisableInput(void); + void enableInput(void); + void disableInput(void); // Enables and disables mouse draw - void EnableMouse(void); - void DisableMouse(void); + void enableMouse(void); + void disableMouse(void); operator byte *() { - return (byte *)m_bigBuf; + return (byte *)_bigBuf; } - RMInput &GetInput() { - return m_input; + RMInput &getInput() { + return _input; } // Link to the custom function list - void InitCustomDll(void); + void initCustomDll(void); // Link to graphic task - void LinkGraphicTask(RMGfxTask *task) { - m_bigBuf.AddPrim(new RMGfxPrimitive(task)); + void linkGraphicTask(RMGfxTask *task) { + _bigBuf.AddPrim(new RMGfxPrimitive(task)); }; // Manage a location - uint32 LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); - void UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); + uint32 loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); + void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); // Freeze and unfreeze - void Freeze(void); - void Unfreeze(void); + void freeze(void); + void unfreeze(void); // State management - void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name); - void LoadState(CORO_PARAM, const Common::String &fn); + void saveState(const Common::String &fn, byte *curThumb, const Common::String &name); + void loadState(CORO_PARAM, const Common::String &fn); // Pauses sound - void PauseSound(bool bPause); + void pauseSound(bool bPause); // Wipe - void InitWipe(int type); - void CloseWipe(void); - void WaitWipeEnd(CORO_PARAM); + void initWipe(int type); + void closeWipe(void); + void waitWipeEnd(CORO_PARAM); - void SetPalesati(bool bpal) { - m_inter.SetPalesati(bpal); + void setPalesati(bool bpal) { + _inter.SetPalesati(bpal); } - bool CanLoadSave(); + bool canLoadSave(); }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index aec1e1a57b..5fb375da81 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -530,7 +530,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_i)) { + if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c2350d14e4..ab8eb53969 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -140,8 +140,8 @@ Common::ErrorCode TonyEngine::init() { _theBoxes.Init(); // Link to the custom graphics engine - _theEngine.InitCustomDll(); - _theEngine.Init(); + _theEngine.initCustomDll(); + _theEngine.init(); // Allocate space for thumbnails when saving the game _curThumbnail = new uint16[160 * 120]; @@ -406,7 +406,7 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); _ctx->buf = getSaveStateFileName(0); - _theEngine.SaveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); + _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); MainUnfreeze(); CORO_END_CODE; @@ -415,7 +415,7 @@ void TonyEngine::autoSave(CORO_PARAM) { void TonyEngine::saveState(int n, const char *name) { Common::String buf = getSaveStateFileName(n); - _theEngine.SaveState(buf.c_str(), (byte *)_curThumbnail, name); + _theEngine.saveState(buf.c_str(), (byte *)_curThumbnail, name); } @@ -427,7 +427,7 @@ void TonyEngine::loadState(CORO_PARAM, int n) { CORO_BEGIN_CODE(_ctx); _ctx->buf = getSaveStateFileName(n); - CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf.c_str()); + CORO_INVOKE_1(_theEngine.loadState, _ctx->buf.c_str()); CORO_END_CODE; } @@ -484,11 +484,11 @@ void TonyEngine::optionScreen(void) { } void TonyEngine::openInitLoadMenu(CORO_PARAM) { - _theEngine.OpenOptionScreen(coroParam, 1); + _theEngine.openOptionScreen(coroParam, 1); } void TonyEngine::openInitOptions(CORO_PARAM) { - _theEngine.OpenOptionScreen(coroParam, 2); + _theEngine.openOptionScreen(coroParam, 2); } void TonyEngine::abortGame(void) { @@ -517,7 +517,7 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // If a savegame needs to be loaded, then do so if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); - CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn); + CORO_INVOKE_1(GLOBALS.GfxEngine->loadState, _ctx->fn); _vm->_loadSlotNumber = -1; } @@ -525,17 +525,17 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->_bDrawLocation); + CORO_INVOKE_1(_vm->_theEngine.doFrame, _vm->_bDrawLocation); // Warns that a frame is finished CoroScheduler.pulseEvent(_vm->_hEndOfFrame); // Handle drawing the frame if (!_vm->_bPaused) { - if (!_vm->_theEngine.m_bWiping) + if (!_vm->_theEngine._bWiping) _vm->_window.GetNewFrame(_vm->_theEngine, NULL); else - _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine.m_rcWipeEllipse); + _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); } // Paint the frame onto the screen @@ -569,14 +569,14 @@ void TonyEngine::close(void) { closeMusic(); CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.Close(); - _theEngine.Close(); + _theEngine.close(); _window.Close(); delete[] _curThumbnail; } void TonyEngine::switchFullscreen(bool bFull) { _window.SwitchFullscreen(bFull); - _theEngine.SwitchFullscreen(bFull); + _theEngine.switchFullscreen(bFull); } void TonyEngine::GDIControl(bool bCon) { @@ -601,10 +601,10 @@ uint32 TonyEngine::getTime() { } bool TonyEngine::canLoadGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); } bool TonyEngine::canSaveGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); } Common::Error TonyEngine::loadGameState(int slot) { @@ -619,7 +619,7 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { RMSnapshot s; s.GrabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); - GLOBALS.GfxEngine->SaveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); + GLOBALS.GfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; } -- cgit v1.2.3 From 93cba6d88049d73b965143130a1f7751e3dc79db Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 01:15:25 +0200 Subject: TONY: Rename variables and functions in adv.h --- engines/tony/adv.h | 34 +++++++++++------------ engines/tony/custom.cpp | 37 ++++++++++++------------- engines/tony/debugger.cpp | 2 +- engines/tony/font.cpp | 12 ++++---- engines/tony/game.cpp | 34 +++++++++++------------ engines/tony/gfxengine.cpp | 8 +++--- engines/tony/loc.cpp | 4 +-- engines/tony/tony.cpp | 8 +++--- engines/tony/tonychar.cpp | 68 +++++++++++++++++++++++----------------------- 9 files changed, 102 insertions(+), 105 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index a31c1a28bc..0bdef25ea8 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -64,23 +64,23 @@ enum RMTonyAction { }; // Global Functions -uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); -void MainLinkGraphicTask(RMGfxTask *task); -void MainFreeze(void); -void MainUnfreeze(void); -void MainWaitFrame(CORO_PARAM); -void MainShowMouse(void); -void MainHideMouse(void); -void MainEnableInput(void); -void MainDisableInput(void); -void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); -void MainInitWipe(int type); -void MainCloseWipe(void); -void MainWaitWipeEnd(CORO_PARAM); -void MainEnableGUI(void); -void MainDisableGUI(void); -void MainSetPalesati(bool bPalesati); +uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); +void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); +void mainLinkGraphicTask(RMGfxTask *task); +void mainFreeze(void); +void mainUnfreeze(void); +void mainWaitFrame(CORO_PARAM); +void mainShowMouse(void); +void mainHideMouse(void); +void mainEnableInput(void); +void mainDisableInput(void); +void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); +void mainInitWipe(int type); +void mainCloseWipe(void); +void mainWaitWipeEnd(CORO_PARAM); +void mainEnableGUI(void); +void mainDisableGUI(void); +void mainSetPalesati(bool bPalesati); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 59de6909dc..579532d9bc 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -595,21 +595,18 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_END_CODE; } - DECLARE_CUSTOM_FUNCTION(DisableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - MainDisableInput(); + mainDisableInput(); } - DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - MainEnableInput(); + mainEnableInput(); } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS.Tony->StopNoAction(coroParam); } - DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS.EnableGUI(); } @@ -2018,7 +2015,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Draw the pointer GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); - MainShowMouse(); + mainShowMouse(); while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); @@ -2028,7 +2025,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Hide the pointer - MainHideMouse(); + mainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); @@ -2539,19 +2536,19 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.Inventory = inv; GLOBALS.Input = input; - GLOBALS.LoadLocation = MainLoadLocation; - GLOBALS.UnloadLocation = MainUnloadLocation; - GLOBALS.LinkGraphicTask = MainLinkGraphicTask; - GLOBALS.Freeze = MainFreeze; - GLOBALS.Unfreeze = MainUnfreeze; - GLOBALS.WaitFrame = MainWaitFrame; - GLOBALS.PlayMusic = MainPlayMusic; - GLOBALS.InitWipe = MainInitWipe; - GLOBALS.CloseWipe = MainCloseWipe; - GLOBALS.WaitWipeEnd = MainWaitWipeEnd; - GLOBALS.DisableGUI = MainDisableGUI; - GLOBALS.EnableGUI = MainEnableGUI; - GLOBALS.SetPalesati = MainSetPalesati; + GLOBALS.LoadLocation = mainLoadLocation; + GLOBALS.UnloadLocation = mainUnloadLocation; + GLOBALS.LinkGraphicTask = mainLinkGraphicTask; + GLOBALS.Freeze = mainFreeze; + GLOBALS.Unfreeze = mainUnfreeze; + GLOBALS.WaitFrame = mainWaitFrame; + GLOBALS.PlayMusic = mainPlayMusic; + GLOBALS.InitWipe = mainInitWipe; + GLOBALS.CloseWipe = mainCloseWipe; + GLOBALS.WaitWipeEnd = mainWaitWipeEnd; + GLOBALS.DisableGUI = mainDisableGUI; + GLOBALS.EnableGUI = mainEnableGUI; + GLOBALS.SetPalesati = mainSetPalesati; GLOBALS.bAlwaysDisplay = false; int i; diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index f358d51223..7dc32d9f61 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -71,7 +71,7 @@ void DebugChangeScene(CORO_PARAM, const void *param) { GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); - MainEnableGUI(); + mainEnableGUI(); CORO_END_CODE; } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 71cffab26b..80837be34d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2494,11 +2494,11 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(MainWaitFrame); - MainFreeze(); + CORO_INVOKE_0(mainWaitFrame); + mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; - MainUnfreeze(); + mainUnfreeze(); } m_ptDrawPos.y = _ctx->destpt.y; @@ -2538,11 +2538,11 @@ void RMDialogChoice::Hide(CORO_PARAM) { _ctx->deltay = 480 - m_ptDrawPos.y; _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(MainWaitFrame); - MainFreeze(); + CORO_INVOKE_0(mainWaitFrame); + mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; - MainUnfreeze(); + mainUnfreeze(); } } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 71dbb68c73..220f41a558 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -46,75 +46,75 @@ using namespace MPAL; /* Global functions */ /****************************************/ -uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { +uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->getEngine()->loadLocation(nLoc, pt, start); } -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { +void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); } -void MainLinkGraphicTask(RMGfxTask *task) { +void mainLinkGraphicTask(RMGfxTask *task) { _vm->getEngine()->linkGraphicTask(task); } -void MainFreeze(void) { +void mainFreeze(void) { _vm->getEngine()->freeze(); } -void MainUnfreeze(void) { +void mainUnfreeze(void) { _vm->getEngine()->unfreeze(); } -void MainWaitFrame(CORO_PARAM) { +void mainWaitFrame(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); } -void MainShowMouse(void) { +void mainShowMouse(void) { _vm->getEngine()->enableMouse(); } -void MainHideMouse(void) { +void mainHideMouse(void) { _vm->getEngine()->disableMouse(); } -void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { +void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } -void MainDisableInput(void) { +void mainDisableInput(void) { _vm->getEngine()->disableInput(); } -void MainEnableInput(void) { +void mainEnableInput(void) { _vm->getEngine()->enableInput(); } -void MainInitWipe(int type) { +void mainInitWipe(int type) { _vm->getEngine()->initWipe(type); } -void MainCloseWipe(void) { +void mainCloseWipe(void) { _vm->getEngine()->closeWipe(); } -void MainWaitWipeEnd(CORO_PARAM) { +void mainWaitWipeEnd(CORO_PARAM) { _vm->getEngine()->waitWipeEnd(coroParam); } -void MainEnableGUI(void) { +void mainEnableGUI(void) { _vm->getEngine()->_bGUIInterface = true; _vm->getEngine()->_bGUIInventory = true; _vm->getEngine()->_bGUIOption = true; } -void MainDisableGUI(void) { +void mainDisableGUI(void) { _vm->getEngine()->_bGUIInterface = false; _vm->getEngine()->_bGUIInventory = false; _vm->getEngine()->_bGUIOption = false; } -void MainSetPalesati(bool bPalesati) { +void mainSetPalesati(bool bPalesati) { _vm->getEngine()->setPalesati(bPalesati); } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 75eb6de883..dd448fdc93 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -366,10 +366,10 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { if (item != NULL) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) - MainFreeze(); + mainFreeze(); item->SetPattern(nPattern, true); if (GLOBALS.bPatIrqFreeze) - MainUnfreeze(); + mainUnfreeze(); } if (nStatus != -1) item->SetStatus(nStatus); @@ -450,7 +450,7 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } - MainFreeze(); + mainFreeze(); _bLocationLoaded = false; @@ -814,7 +814,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_2(unloadLocation, false, NULL); loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); _tony.SetPattern(RMTony::PAT_STANDRIGHT); - MainUnfreeze(); + mainUnfreeze(); // On older versions, need to an enter action if (_ctx->ver < 5) diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b3768ca330..601ae3f09b 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -886,8 +886,8 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { m_bEndFade = true; m_bFading = false; - CORO_INVOKE_0(MainWaitFrame); - CORO_INVOKE_0(MainWaitFrame); + CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_0(mainWaitFrame); CORO_END_CODE; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ab8eb53969..98171b2544 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -402,12 +402,12 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); grabThumbnail(); - CORO_INVOKE_0(MainWaitFrame); - CORO_INVOKE_0(MainWaitFrame); - MainFreeze(); + CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_0(mainWaitFrame); + mainFreeze(); _ctx->buf = getSaveStateFileName(0); _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); - MainUnfreeze(); + mainUnfreeze(); CORO_END_CODE; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 212899cde3..419f5a251f 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -596,7 +596,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (m_bPastorella) { // Talking whilst a shepherdess - MainFreeze(); + mainFreeze(); switch (m_TalkDirection) { case UP: SetPattern(PAT_PAST_TALKUP); @@ -614,7 +614,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body SetPattern(PAT_PAST_TALKRIGHT); break; } - MainUnfreeze(); + mainUnfreeze(); return false; } @@ -1127,10 +1127,10 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headStartPat); m_body.SetPattern(_ctx->bodyStartPat); - MainUnfreeze(); + mainUnfreeze(); if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(m_body.WaitForEndPattern); @@ -1138,11 +1138,11 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_INVOKE_0(WaitForEndPattern); } - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) m_body.SetPattern(_ctx->bodyLoopPat); - MainUnfreeze(); + mainUnfreeze(); CORO_END_CODE; } @@ -1175,9 +1175,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa } if (m_bPastorella) { - MainFreeze(); + mainFreeze(); SetPattern(finalPat); - MainUnfreeze(); + mainUnfreeze(); m_bIsTalking = false; return false; } @@ -1447,7 +1447,7 @@ void RMTony::EndTalk(CORO_PARAM) { // Handles the end of an animated and static, leaving everything unchanged if (m_bIsStaticTalk) { if (m_nTalkType == TALK_CONBARBASTATIC) { - MainFreeze(); + mainFreeze(); SetPattern(0); if (m_TalkDirection == UP || m_TalkDirection == LEFT) { m_body.SetPattern(BPAT_CONBARBALEFT_STATIC); @@ -1456,11 +1456,11 @@ void RMTony::EndTalk(CORO_PARAM) { m_body.SetPattern(BPAT_CONBARBARIGHT_STATIC); m_nBodyOffset.Set(-26, -14); } - MainUnfreeze(); + mainUnfreeze(); } else { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headStandPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); } @@ -1471,36 +1471,36 @@ void RMTony::EndTalk(CORO_PARAM) { // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); - MainFreeze(); + mainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(WaitForEndPattern); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->bodyEndPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headStandPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); - MainFreeze(); + mainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(m_body.WaitForEndPattern); - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(WaitForEndPattern); } else { @@ -1508,10 +1508,10 @@ void RMTony::EndTalk(CORO_PARAM) { } if (_ctx->finalPat != 0) { - MainFreeze(); + mainFreeze(); m_body.SetPattern(0); SetPattern(_ctx->finalPat); - MainUnfreeze(); + mainUnfreeze(); } m_bIsTalking = false; @@ -1740,19 +1740,19 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { // e vai con i pattern m_bIsStaticTalk = true; - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headPat); m_body.SetPattern(_ctx->bodyStartPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); CORO_INVOKE_0(WaitForEndPattern); - MainFreeze(); + mainFreeze(); if (_ctx->headLoopPat != -1) SetPattern(_ctx->headLoopPat); m_body.SetPattern(_ctx->bodyLoopPat); - MainUnfreeze(); + mainUnfreeze(); CORO_END_CODE; } @@ -1910,24 +1910,24 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { EndStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); if (_ctx->headEndPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(WaitForEndPattern); } else { // Play please - MainFreeze(); + mainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); } - MainFreeze(); + mainFreeze(); SetPattern(_ctx->finalPat); m_body.SetPattern(0); - MainUnfreeze(); + mainUnfreeze(); m_bIsStaticTalk = false; -- cgit v1.2.3 From 23c95d7014ee9875bb1b55c696d0245d7f114ba8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 08:39:55 +0200 Subject: TONY: Some more renaming --- engines/tony/custom.cpp | 2 +- engines/tony/font.cpp | 154 ++++++------- engines/tony/font.h | 26 +-- engines/tony/game.cpp | 156 +++++++------ engines/tony/game.h | 12 +- engines/tony/gfxcore.cpp | 551 +++++++++++++++++++++++---------------------- engines/tony/gfxcore.h | 282 +++++++++++------------ engines/tony/gfxengine.cpp | 20 +- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 108 ++++----- engines/tony/inventory.h | 4 +- engines/tony/loc.cpp | 86 +++---- engines/tony/loc.h | 10 +- engines/tony/tony.cpp | 6 +- engines/tony/tonychar.cpp | 22 +- engines/tony/tonychar.h | 6 +- engines/tony/window.cpp | 2 +- engines/tony/window.h | 4 +- 18 files changed, 731 insertions(+), 722 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 579532d9bc..8092109ef5 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1998,7 +1998,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Making a choice for dialog - _ctx->dc.Init(); + _ctx->dc.init(); _ctx->dc.SetNumChoices(_ctx->num); // Writeall the possible options diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 80837be34d..16cf4497fc 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -69,8 +69,8 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes // Initialise the fonts for (int i = 0; i < nChars; i++) { // Initialise the buffer with the letters - m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); - m_letter[i].LoadPaletteWA(palResID); + m_letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); + m_letter[i].loadPaletteWA(palResID); } m_fontDimx = dimx; @@ -114,7 +114,7 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { return prim; } -void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { +void RMFont::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -124,7 +124,7 @@ void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) // Call the draw method of the letter assigned to the primitive if (prim->m_nChar != -1) - CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); + CORO_INVOKE_2(m_letter[prim->m_nChar].draw, bigBuf, prim); CORO_END_CODE; } @@ -197,7 +197,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { // Puts in all the letters for (i = 0; i < nLetters; i++) - m_letter[i].LoadPaletteWA(pal); + m_letter[i].loadPaletteWA(pal); } @@ -205,7 +205,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { * RMFontParla Methods \****************************************************************************/ -void RMFontParla::Init(void) { +void RMFontParla::init(void) { int i; // bernie: Number of characters in the font @@ -612,7 +612,7 @@ void RMFontParla::Init(void) { * RMFontMacc Methods \****************************************************************************/ -void RMFontMacc::Init(void) { +void RMFontMacc::init(void) { int i; // bernie: Number of characters in the font @@ -976,7 +976,7 @@ void RMFontMacc::Init(void) { * RMFontCredits Methods \****************************************************************************/ -void RMFontCredits::Init(void) { +void RMFontCredits::init(void) { int i; // bernie: Number of characters in the font @@ -1441,7 +1441,7 @@ void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { } -void RMFontObj::Init(void) { +void RMFontObj::init(void) { int i; //bernie: Number of characters in the font (solo maiuscolo) @@ -1763,7 +1763,7 @@ void RMFontObj::Init(void) { RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; RMGfxClearTask RMText::m_clear; -void RMText::InitStatics() { +void RMText::initStatics() { Common::fill(&m_fonts[0], &m_fonts[4], (RMFontColor *)NULL); } @@ -1774,10 +1774,10 @@ RMText::RMText() { // Default length maxLineLength = 350; - m_bTrasp0 = true; + _bTrasp0 = true; aHorType = HCENTER; aVerType = VTOP; - SetPriority(150); + setPriority(150); } RMText::~RMText() { @@ -1808,13 +1808,13 @@ void RMText::WriteText(const RMString &text, int nFont, int *time) { // Initialises the font (only once) if (m_fonts[0] == NULL) { m_fonts[0] = new RMFontParla; - m_fonts[0]->Init(); + m_fonts[0]->init(); m_fonts[1] = new RMFontObj; - m_fonts[1]->Init(); + m_fonts[1]->init(); m_fonts[2] = new RMFontMacc; - m_fonts[2]->Init(); + m_fonts[2]->init(); m_fonts[3] = new RMFontCredits; - m_fonts[3]->Init(); + m_fonts[3]->init(); } WriteText(text, m_fonts[nFont], time); @@ -1835,7 +1835,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { font->SetBaseColor(m_r, m_g, m_b); // Destroy the buffer before starting - Destroy(); + destroy(); // If the string is empty, do nothing if (text == NULL || text[0] == '\0') @@ -1893,7 +1893,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Create the surface Create(width, height); //AddPrim(new RMGfxPrimitive(&m_clear)); - Common::fill(m_buf, m_buf + width * height * 2, 0); + Common::fill(_buf, _buf + width * height * 2, 0); p = string; @@ -1935,7 +1935,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { prim = font->MakeLetterPrimitive(*p, len); prim->Dst().x1 = x; prim->Dst().y1 = y; - AddPrim(prim); + addPrim(prim); numchar++; @@ -1956,37 +1956,37 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { prim->Dst().x1 = 5; if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1 + m_dimx > 635) - prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1 + m_dimy > 475) - prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 + _dimx > 635) + prim->Dst().x1 = 635 - _dimx; + if (prim->Dst().y1 + _dimy > 475) + prim->Dst().y1 = 475 - _dimy; } -void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // Horizontally if (aHorType == HCENTER) - prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); + prim->Dst().TopLeft() -= RMPoint(_dimx / 2, 0); else if (aHorType == HRIGHT) - prim->Dst().TopLeft() -= RMPoint(m_dimx, 0); + prim->Dst().TopLeft() -= RMPoint(_dimx, 0); // Vertically if (aVerType == VTOP) { } else if (aVerType == VCENTER) { - prim->Dst().y1 -= m_dimy / 2; + prim->Dst().y1 -= _dimy / 2; } else if (aVerType == VBOTTOM) { - prim->Dst().y1 -= m_dimy; + prim->Dst().y1 -= _dimy; } ClipOnScreen(prim); - CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); CORO_END_CODE; } @@ -2132,11 +2132,11 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); - assert(m_nInList == 0); + assert(_nInList == 0); CoroScheduler.setEvent(hEndDisplay); } -void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -2148,7 +2148,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (m_bShowed) { if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; - CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2187,7 +2187,7 @@ RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { RMTextDialogScrolling::~RMTextDialogScrolling() { } -void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; RMPoint curDst; CORO_END_CONTEXT(_ctx); @@ -2199,7 +2199,7 @@ void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri if (curLoc != NULL) dst -= curLoc->ScrollPosition() - startScroll; - CORO_INVOKE_2(RMTextDialog::Draw, bigBuf, prim); + CORO_INVOKE_2(RMTextDialog::draw, bigBuf, prim); dst = _ctx->curDst; @@ -2217,7 +2217,7 @@ void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { RMTextItemName::RMTextItemName() : RMText() { m_item = NULL; - SetPriority(220); + setPriority(220); } RMTextItemName::~RMTextItemName() { @@ -2237,8 +2237,8 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _ctx->lastItem = m_item; // Adds to the list if there is need - if (!m_nInList) - bigBuf.AddPrim(new RMGfxPrimitive(this)); + if (!_nInList) + bigBuf.addPrim(new RMGfxPrimitive(this)); // Update the scrolling co-ordinates m_curscroll = loc.ScrollPosition(); @@ -2275,20 +2275,20 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & } -void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // If there is no text, it's pointless to continue - if (m_buf == NULL) + if (_buf == NULL) return; // Set the destination coordinates of the mouse prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); - CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + CORO_INVOKE_2(RMText::draw, bigBuf, prim); CORO_END_CODE; } @@ -2322,11 +2322,11 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - DlgText.Init(dlg1, dlg1.Width(), dlg1.Height()); - DlgTextLine.Init(dlg2, dlg2.Width(), dlg2.Height()); + DlgText.init(dlg1, dlg1.Width(), dlg1.Height()); + DlgTextLine.init(dlg2, dlg2.Width(), dlg2.Height()); - DlgText.LoadPaletteWA(dlgpal); - DlgTextLine.LoadPaletteWA(dlgpal); + DlgText.loadPaletteWA(dlgpal); + DlgTextLine.loadPaletteWA(dlgpal); hUnreg = CoroScheduler.createEvent(false, false); bRemoveFromOT = false; @@ -2338,20 +2338,20 @@ RMDialogChoice::~RMDialogChoice() { void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); - assert(!m_nInList); + assert(!_nInList); CoroScheduler.pulseEvent(hUnreg); bRemoveFromOT = false; } -void RMDialogChoice::Init(void) { +void RMDialogChoice::init(void) { m_numChoices = 0; m_drawedStrings = NULL; m_ptDrawStrings = NULL; m_curSelection = -1; Create(640, 477); - SetPriority(140); + setPriority(140); } @@ -2366,7 +2366,7 @@ void RMDialogChoice::Close(void) { m_ptDrawStrings = NULL; } - Destroy(); + destroy(); } void RMDialogChoice::SetNumChoices(int num) { @@ -2384,7 +2384,7 @@ void RMDialogChoice::SetNumChoices(int num) { m_drawedStrings[i].SetColor(0, 255, 0); m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); m_drawedStrings[i].SetMaxLineLength(600); - m_drawedStrings[i].SetPriority(10); + m_drawedStrings[i].setPriority(10); } } @@ -2402,22 +2402,22 @@ void RMDialogChoice::Prepare(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - AddPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); + addPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); _ctx->ptPos.Set(20, 90); for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); + addPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); m_ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].Dimy() + 15); + _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].getDimy() + 15); } - CORO_INVOKE_0(DrawOT); - ClearOT(); + CORO_INVOKE_0(drawOT); + clearOT(); m_ptDrawPos.Set(0, 480 - _ctx->ptPos.y); @@ -2435,29 +2435,29 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { if (pos == m_curSelection) return; - _ctx->box.SetPriority(5); + _ctx->box.setPriority(5); if (m_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[m_curSelection].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); - AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].getDimy()); + addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); - CORO_INVOKE_0(DrawOT); - ClearOT(); + addPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); + CORO_INVOKE_0(drawOT); + clearOT(); } if (pos != -1) { _ctx->box.SetColor(100, 100, 100); _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].Dimy()); - AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].getDimy()); + addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); + addPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } - CORO_INVOKE_0(DrawOT); - ClearOT(); + CORO_INVOKE_0(drawOT); + clearOT(); m_curSelection = pos; @@ -2477,8 +2477,8 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_INVOKE_0(Prepare); m_bShow = false; - if (!m_nInList && bigBuf != NULL) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && bigBuf != NULL) + bigBuf->addPrim(new RMGfxPrimitive(this)); if (0) { m_bShow = true; @@ -2488,8 +2488,8 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); - if (!m_nInList && bigBuf != NULL) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && bigBuf != NULL) + bigBuf->addPrim(new RMGfxPrimitive(this)); m_bShow = true; _ctx->elaps = 0; @@ -2507,7 +2507,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_END_CODE; } -void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMDialogChoice::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -2516,8 +2516,8 @@ void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (m_bShow == false) return; - prim->SetDst(m_ptDrawPos); - CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + prim->setDst(m_ptDrawPos); + CORO_INVOKE_2(RMGfxSourceBuffer16::draw, bigBuf, prim); CORO_END_CODE; } @@ -2567,7 +2567,7 @@ void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { if (ptMousePos.y > m_ptDrawPos.y) { for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].Dimy())) { + if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].getDimy())) { CORO_INVOKE_1(SetSelected, _ctx->i); break; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 82ce686ec0..0faaec89d4 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -90,11 +90,11 @@ public: virtual ~RMFont(); // Initialisation and closing - virtual void Init(void) = 0; + virtual void init(void) = 0; virtual void Close(void); // Drawing - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Create a primitive for a letter RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); @@ -143,7 +143,7 @@ public: class RMFontParla : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void init(void); virtual ~RMFontParla() {} }; @@ -152,19 +152,19 @@ private: void SetBothCase(int nChar, int nNext, signed char spiazz); public: - void Init(void); + void init(void); virtual ~RMFontObj() {} }; class RMFontMacc : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void init(void); virtual ~RMFontMacc() {} }; class RMFontCredits : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void init(void); virtual ~RMFontCredits() {} virtual void SetBaseColor(byte r, byte g, byte b) {} }; @@ -203,7 +203,7 @@ protected: public: RMText(); virtual ~RMText(); - static void InitStatics(); + static void initStatics(); static void Unload(); // Set the alignment type @@ -223,7 +223,7 @@ public: virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading of the Draw to center the text, if necessary - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the base colour void SetColor(byte r, byte g, byte b) { @@ -267,7 +267,7 @@ public: virtual void Unregister(void); // Overloading of the Draw to center the text, if necessary - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the position void SetPosition(const RMPoint &pt) { @@ -304,7 +304,7 @@ public: RMTextDialogScrolling(RMLocation *loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -327,7 +327,7 @@ public: } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); RMPoint GetHotspot(); RMItem *GetSelectedItem(); @@ -363,7 +363,7 @@ protected: public: virtual void RemoveThis(CORO_PARAM, bool &result); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void Unregister(void); public: @@ -372,7 +372,7 @@ public: virtual ~RMDialogChoice(); // Initialisation and closure - void Init(void); + void init(void); void Close(void); // Sets the number of possible sentences, which then be added with AddChoice() diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 220f41a558..c22706cc6d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -126,7 +126,7 @@ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { RMResRaw raw(dwRes); assert(raw.IsValid()); m_buf = new RMGfxSourceBuffer16(false); - m_buf->Init(raw, raw.Width(), raw.Height()); + m_buf->init(raw, raw.Width(), raw.Height()); m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); m_bActive = false; @@ -170,9 +170,7 @@ bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRig return false; } - - -void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionButton::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -182,14 +180,14 @@ void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; if (m_bHasGfx) - CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + CORO_INVOKE_2(m_buf->draw, bigBuf, prim); CORO_END_CODE; } void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { if (m_bHasGfx) - bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); + bigBuf.addPrim(new RMGfxPrimitive(this, m_rect)); } /****************************************************************************\ @@ -272,7 +270,7 @@ bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRigh return bRefresh; } -void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int i; int val; @@ -290,21 +288,21 @@ void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * else if (_ctx->val > 100) _ctx->val = 100; if (_ctx->val == 1) { - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderSingle->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderSingle->draw, bigBuf, prim); } else { - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderLeft->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderLeft->draw, bigBuf, prim); _ctx->pos.x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderCenter->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderCenter->draw, bigBuf, prim); _ctx->pos.x += 3; } - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderRight->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderRight->draw, bigBuf, prim); _ctx->pos.x += 3; } @@ -312,7 +310,7 @@ void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * } void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); } @@ -392,15 +390,15 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - ClearOT(); + clearOT(); - AddPrim(new RMGfxPrimitive(m_menu)); + addPrim(new RMGfxPrimitive(m_menu)); if (m_bNoLoadSave) - AddPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); + addPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); if (m_bQuitConfirm) { - AddPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); + addPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); m_ButtonQuitYes->AddToList(*this); m_ButtonQuitNo->AddToList(*this); } @@ -449,62 +447,62 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { _ctx->title->WriteText(msg[0], 1); } - AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); + addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (m_curThumbDiff[0] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); else if (m_curThumbDiff[0] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); if (m_curThumbDiff[1] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); else if (m_curThumbDiff[1] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); if (m_curThumbDiff[2] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); else if (m_curThumbDiff[2] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); if (m_curThumbDiff[3] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); else if (m_curThumbDiff[3] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); if (m_curThumbDiff[4] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); else if (m_curThumbDiff[4] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); if (m_curThumbDiff[5] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); else if (m_curThumbDiff[5] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) - AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) - AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) - AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) - AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) - AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) - AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; - _ctx->thumb->Init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); + _ctx->thumb->init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); if (m_nEditPos == 0) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); else if (m_nEditPos == 1) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); else if (m_nEditPos == 2) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); else if (m_nEditPos == 3) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); else if (m_nEditPos == 4) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); else if (m_nEditPos == 5) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { @@ -524,18 +522,18 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { _ctx->num[_ctx->i]->WriteText(s, 2); } - AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[2], RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[3], RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[2], RMPoint(439 - 3, 180 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[3], RMPoint(55 - 3, 362 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - CORO_INVOKE_0(DrawOT); + CORO_INVOKE_0(drawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (_ctx->thumb) delete _ctx->thumb; @@ -588,7 +586,7 @@ void RMOptionScreen::InitState(CORO_PARAM) { assert(_ctx->raw->IsValid()); assert(m_menu == NULL); m_menu = new RMGfxSourceBuffer16(false); - m_menu->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + m_menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; if (m_nState == MENULOAD || m_nState == MENUSAVE) { @@ -650,22 +648,22 @@ void RMOptionScreen::InitState(CORO_PARAM) { assert(_ctx->raw->IsValid()); assert(m_QuitConfirm == NULL); m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + m_QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; assert(m_ButtonQuitYes == NULL); m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); - m_ButtonQuitYes->SetPriority(30); + m_ButtonQuitYes->setPriority(30); assert(m_ButtonQuitNo == NULL); m_ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); - m_ButtonQuitNo->SetPriority(30); + m_ButtonQuitNo->setPriority(30); if (m_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); assert(_ctx->raw->IsValid()); assert(m_HideLoadSave == NULL); m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + m_HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; } @@ -863,7 +861,7 @@ void RMOptionScreen::CloseState(void) { } void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); } void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { @@ -885,7 +883,7 @@ void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { m_bNoLoadSave = false; m_bAlterGfx = false; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); if (m_nState == MENULOAD || m_nState == MENUSAVE) m_nState = MENUGAME; @@ -916,7 +914,7 @@ void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_bNoLoadSave = false; m_bAlterGfx = bAlternateGfx; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_nState = MENULOAD; CORO_INVOKE_0(InitState); @@ -945,7 +943,7 @@ void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_bNoLoadSave = false; m_bAlterGfx = bAlternateGfx; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_nState = MENUSAVE; CORO_INVOKE_0(InitState); @@ -973,7 +971,7 @@ void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool m_bLoadMenuOnly = false; m_bNoLoadSave = true; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_nState = MENUGAME; CORO_INVOKE_0(InitState); @@ -1273,7 +1271,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } -void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int curTime; CORO_END_CONTEXT(_ctx); @@ -1300,7 +1298,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } // Set the part to draw the scrolling - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 2) { // Bounce 1 @@ -1310,7 +1308,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 3) { m_FadeY -= FADE_SPEED / 4 * SYNC; @@ -1319,7 +1317,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 4) { // Bounce 1 - 2 @@ -1329,7 +1327,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 5) { m_FadeY += FADE_SPEED / 2 * SYNC; @@ -1339,7 +1337,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _vm->hideLocation(); } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 6) { // Menu ON @@ -1355,7 +1353,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeY = 0; m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 9) { // Hello hello! @@ -1372,7 +1370,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeTime = _ctx->curTime; - CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); CORO_END_CODE; } @@ -1483,8 +1481,8 @@ void RMPointer::Init(void) { RMResRaw res(RES_P_GO + i); m_pointer[i] = new RMGfxSourceBuffer8RLEByteAA; - m_pointer[i]->Init(res, res.Width(), res.Height(), false); - m_pointer[i]->LoadPaletteWA(RES_P_PAL); + m_pointer[i]->init(res, res.Width(), res.Height(), false); + m_pointer[i]->loadPaletteWA(RES_P_PAL); } for (i = 0; i < 5; i++) { @@ -1530,7 +1528,7 @@ int RMPointer::Priority() { return 200; } -void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int n; CORO_END_CONTEXT(_ctx); @@ -1542,20 +1540,20 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copy the destination coordinates in the primitive - prim->SetDst(m_pos); + prim->setDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Call the Draw method of the poitner prim->Dst() -= m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { - CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); + CORO_INVOKE_2(m_pointer[_ctx->n]->draw, bigBuf, prim); } else { if (m_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); + CORO_INVOKE_2(m_nCurCustomPointer->draw, bigBuf, prim); else // Call the draw on the special pointer - CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->Draw, bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->draw, bigBuf, prim); } } @@ -1564,7 +1562,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { // Add it to the list of primitives - bigBuf->AddPrim(new RMGfxPrimitive(this)); + bigBuf->addPrim(new RMGfxPrimitive(this)); // If there is a special pointer, does DoFrame if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) diff --git a/engines/tony/game.h b/engines/tony/game.h index c920b88ee5..d42a3805c8 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -42,7 +42,7 @@ namespace Tony { assert(raw->IsValid()); \ assert((buf16) == NULL); \ (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->Init(*raw,raw->Width(),raw->Height()); \ + (buf16)->init(*raw,raw->Width(),raw->Height()); \ delete raw; #define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ @@ -50,7 +50,7 @@ namespace Tony { assert(raw->IsValid()); \ assert((buf8) == NULL); \ (buf8) = new RMGfxSourceBuffer8RLEByte(); \ - (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ + (buf8)->init(*raw, raw->Width(), raw->Height(), true); \ delete raw; @@ -96,7 +96,7 @@ public: int Priority(); // Overloading draw method - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates void SetCoord(const RMPoint &pt) { @@ -144,7 +144,7 @@ public: virtual ~RMOptionButton(); bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; @@ -173,7 +173,7 @@ public: virtual ~RMOptionSlide(); bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); int GetValue() { @@ -273,7 +273,7 @@ public: // Overloaded methods virtual int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void RemoveThis(CORO_PARAM, bool &result); // Polling for the option screen diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index be59a2d9a5..2076e2af47 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -37,15 +37,15 @@ namespace Tony { \****************************************************************************/ RMGfxTask::RMGfxTask() { - m_nPrior = 0; - m_nInList = 0; + _nPrior = 0; + _nInList = 0; } -int RMGfxTask::Priority() { - return m_nPrior; +int RMGfxTask::priority() { + return _nPrior; } -void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { +void RMGfxTask::removeThis(CORO_PARAM, bool &result) { result = true; } @@ -54,8 +54,8 @@ void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { * RMGfxTaskSetPrior Methods \****************************************************************************/ -void RMGfxTaskSetPrior::SetPriority(int nPrior) { - m_nPrior = nPrior; +void RMGfxTaskSetPrior::setPriority(int nPrior) { + _nPrior = nPrior; } @@ -64,111 +64,111 @@ void RMGfxTaskSetPrior::SetPriority(int nPrior) { \****************************************************************************/ RMGfxBuffer::RMGfxBuffer() { - m_dimx = m_dimy = 0; - m_bUseDDraw = false; - m_origBuf = m_buf = NULL; + _dimx = _dimy = 0; + _bUseDDraw = false; + _origBuf = _buf = NULL; } RMGfxBuffer::~RMGfxBuffer() { - Destroy(); + destroy(); } -void RMGfxBuffer::Create(int dimx, int dimy, int nBpp, bool bUseDDraw) { +void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { // Destroy the buffer it is already exists - if (m_buf != NULL) - Destroy(); + if (_buf != NULL) + destroy(); // Copy the parameters in the private members - m_dimx = dimx; - m_dimy = dimy; - m_bUseDDraw = bUseDDraw; + _dimx = dimx; + _dimy = dimy; + _bUseDDraw = bUseDDraw; - if (!m_bUseDDraw) { + if (!_bUseDDraw) { // Allocate a buffer - m_origBuf = m_buf = new byte[m_dimx * m_dimy * nBpp / 8]; - assert(m_buf != NULL); - Common::fill(m_origBuf, m_origBuf + m_dimx * m_dimy * nBpp / 8, 0); + _origBuf = _buf = new byte[_dimx * _dimy * nBpp / 8]; + assert(_buf != NULL); + Common::fill(_origBuf, _origBuf + _dimx * _dimy * nBpp / 8, 0); } } -void RMGfxBuffer::Destroy(void) { - if (!m_bUseDDraw) { - if (m_origBuf != NULL && m_origBuf == m_buf) { - delete[] m_origBuf; - m_origBuf = m_buf = NULL; +void RMGfxBuffer::destroy(void) { + if (!_bUseDDraw) { + if (_origBuf != NULL && _origBuf == _buf) { + delete[] _origBuf; + _origBuf = _buf = NULL; } } } -void RMGfxBuffer::Lock(void) { - if (m_bUseDDraw) { +void RMGfxBuffer::lock(void) { + if (_bUseDDraw) { // Manages acceleration } } -void RMGfxBuffer::Unlock(void) { - if (m_bUseDDraw) { +void RMGfxBuffer::unlock(void) { + if (_bUseDDraw) { // Manages acceleration } } -void RMGfxBuffer::OffsetY(int nLines, int nBpp) { - m_buf += nLines * Dimx() * nBpp / 8; +void RMGfxBuffer::offsetY(int nLines, int nBpp) { + _buf += nLines * getDimx() * nBpp / 8; } RMGfxBuffer::operator byte *() { - return m_buf; + return _buf; } RMGfxBuffer::operator void *() { - return (void *)m_buf; + return (void *)_buf; } RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { - Create(dimx, dimy, nBpp, bUseDDraw); + create(dimx, dimy, nBpp, bUseDDraw); } /****************************************************************************\ * RMGfxSourceBuffer Methods \****************************************************************************/ -int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - Create(dimx, dimy, Bpp()); - CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); +int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + create(dimx, dimy, Bpp()); + CopyMemory(_buf, buf, dimx * dimy * Bpp() / 8); // Invokes the method for preparing the surface (inherited) - PrepareImage(); + prepareImage(); return dimx * dimy * Bpp() / 8; } -void RMGfxSourceBuffer::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - Create(dimx, dimy, Bpp()); - ds.Read(m_buf, dimx * dimy * Bpp() / 8); +void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + create(dimx, dimy, Bpp()); + ds.Read(_buf, dimx * dimy * Bpp() / 8); // Invokes the method for preparing the surface (inherited) - PrepareImage(); + prepareImage(); } RMGfxSourceBuffer::~RMGfxSourceBuffer() { } -void RMGfxSourceBuffer::PrepareImage(void) { +void RMGfxSourceBuffer::prepareImage(void) { // Do nothing. Can be overloaded if necessary } -bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { +bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { int destw, desth; - destw = buf->Dimx(); - desth = buf->Dimy(); + destw = buf->getDimx(); + desth = buf->getDimy(); if (!bUseSrc) { u = v = 0; - width = m_dimx; - height = m_dimy; + width = _dimx; + height = _dimy; } if (x1 > destw - 1) @@ -210,8 +210,8 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int * @param dimx Buffer X dimension * @param dimy Buffer Y dimension */ -int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { - return Init(RMRes(resID), dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer::init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { + return init(RMRes(resID), dimx, dimy, bLoadPalette); } /****************************************************************************\ @@ -222,17 +222,17 @@ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { } -void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxWoodyBuffer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // Draw the OT list - CORO_INVOKE_0(DrawOT); + CORO_INVOKE_0(drawOT); // Draw itself into the target buffer - CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::draw, bigBuf, prim); CORO_END_CODE; } @@ -255,16 +255,16 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; - m_otSize = 0; + _otSize = 0; // csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { - ClearOT(); + clearOT(); // g_system->deleteMutex(csModifyingOT); } -void RMGfxTargetBuffer::ClearOT(void) { +void RMGfxTargetBuffer::clearOT(void) { OTList *cur, *n; // g_system->lockMutex(csModifyingOT); @@ -272,7 +272,7 @@ void RMGfxTargetBuffer::ClearOT(void) { cur = otlist; while (cur != NULL) { - cur->prim->m_task->Unregister(); + cur->prim->_task->Unregister(); delete cur->prim; n = cur->next; delete cur; @@ -284,7 +284,7 @@ void RMGfxTargetBuffer::ClearOT(void) { // g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { +void RMGfxTargetBuffer::drawOT(CORO_PARAM) { CORO_BEGIN_CONTEXT; OTList *cur; OTList *prev; @@ -299,20 +299,20 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { _ctx->cur = otlist; // Lock the buffer to access it - Lock(); + lock(); // g_system->lockMutex(csModifyingOT); while (_ctx->cur != NULL) { // Call the task Draw method, passing it a copy of the original - _ctx->myprim = _ctx->cur->prim->Duplicate(); - CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); + _ctx->myprim = _ctx->cur->prim->duplicate(); + CORO_INVOKE_2(_ctx->cur->prim->_task->draw, *this, _ctx->myprim); delete _ctx->myprim; // Check if it's time to remove the task from the OT list - CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); + CORO_INVOKE_1(_ctx->cur->prim->_task->removeThis, _ctx->result); if (_ctx->result) { // De-register the task - _ctx->cur->prim->m_task->Unregister(); + _ctx->cur->prim->_task->Unregister(); // Delete task, freeing the memory delete _ctx->cur->prim; @@ -337,22 +337,22 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // g_system->unlockMutex(csModifyingOT); //Unlock after writing - Unlock(); + unlock(); CORO_END_CODE; } -void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { +void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { int nPrior; OTList *cur, *n; // g_system->lockMutex(csModifyingOT); // Warn of the OT listing - prim->m_task->Register(); + prim->_task->Register(); // Check the priority - nPrior = prim->m_task->Priority(); + nPrior = prim->_task->priority(); n = new OTList(prim); // Empty list @@ -361,12 +361,12 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { otlist->next = NULL; } // Inclusion in the head - else if (nPrior < otlist->prim->m_task->Priority()) { + else if (nPrior < otlist->prim->_task->priority()) { n->next = otlist; otlist = n; } else { cur = otlist; - while (cur->next != NULL && nPrior > cur->next->prim->m_task->Priority()) + while (cur->next != NULL && nPrior > cur->next->prim->_task->priority()) cur = cur->next; n->next = cur->next; @@ -376,8 +376,8 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { // g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::AddClearTask(void) { - AddPrim(new RMGfxPrimitive(&taskClear)); +void RMGfxTargetBuffer::addClearTask(void) { + addPrim(new RMGfxPrimitive(&taskClear)); } @@ -389,89 +389,89 @@ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { } -int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { +int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { int i; if (bSwapped) for (i = 0; i < (1 << Bpp()); i++) { - m_pal[i * 3 + 0] = buf[i * 3 + 2]; - m_pal[i * 3 + 1] = buf[i * 3 + 1]; - m_pal[i * 3 + 2] = buf[i * 3 + 0]; + _pal[i * 3 + 0] = buf[i * 3 + 2]; + _pal[i * 3 + 1] = buf[i * 3 + 1]; + _pal[i * 3 + 2] = buf[i * 3 + 0]; } else - CopyMemory(m_pal, buf, (1 << Bpp()) * 3); + CopyMemory(_pal, buf, (1 << Bpp()) * 3); - PreparePalette(); + preparePalette(); return (1 << Bpp()) * 3; } -int RMGfxSourceBufferPal::LoadPalette(const byte *buf) { +int RMGfxSourceBufferPal::loadPalette(const byte *buf) { int i; for (i = 0; i < 256; i++) - CopyMemory(m_pal + i * 3, buf + i * 4, 3); + CopyMemory(_pal + i * 3, buf + i * 4, 3); - PreparePalette(); + preparePalette(); return (1 << Bpp()) * 4; } -void RMGfxSourceBufferPal::PreparePalette(void) { +void RMGfxSourceBufferPal::preparePalette(void) { int i; for (i = 0; i < 256; i++) { - m_palFinal[i] = (((int)m_pal[i * 3 + 0] >> 3) << 10) | - (((int)m_pal[i * 3 + 1] >> 3) << 5) | - (((int)m_pal[i * 3 + 2] >> 3) << 0); + _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 10) | + (((int)_pal[i * 3 + 1] >> 3) << 5) | + (((int)_pal[i * 3 + 2] >> 3) << 0); } } -int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBufferPal::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { int read; // Load the RAW image - read = RMGfxSourceBuffer::Init(buf, dimx, dimy); + read = RMGfxSourceBuffer::init(buf, dimx, dimy); // Load the palette if necessary if (bLoadPalette) - read += LoadPaletteWA(&buf[read]); + read += loadPaletteWA(&buf[read]); return read; } -void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBufferPal::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { // Load the RAW image - RMGfxSourceBuffer::Init(ds, dimx, dimy); + RMGfxSourceBuffer::init(ds, dimx, dimy); // Load the palette if necessary if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; ds.Read(suxpal, 256 * 3); - LoadPaletteWA(suxpal); + loadPaletteWA(suxpal); delete[] suxpal; } } -int RMGfxSourceBufferPal::LoadPalette(uint32 resID) { - return LoadPalette(RMRes(resID)); +int RMGfxSourceBufferPal::loadPalette(uint32 resID) { + return loadPalette(RMRes(resID)); } -int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { - return LoadPaletteWA(RMRes(resID), bSwapped); +int RMGfxSourceBufferPal::loadPaletteWA(uint32 resID, bool bSwapped) { + return loadPaletteWA(RMRes(resID), bSwapped); } /****************************************************************************\ * RMGfxSourceBuffer4 Methods \****************************************************************************/ -void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer4::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 4, bUseDDraw) { - SetPriority(0); + setPriority(0); } @@ -485,7 +485,7 @@ int RMGfxSourceBuffer4::Bpp() { } void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx, dimy, 4, bUseDDraw); + RMGfxBuffer::create(dimx, dimy, 4, bUseDDraw); } /****************************************************************************\ @@ -496,19 +496,19 @@ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { } -void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; - int bufx = bigBuf.Dimx(); + int bufx = bigBuf.getDimx(); uint16 *buf = bigBuf; - byte *raw = m_buf; + byte *raw = _buf; // Destination buffer RMRect dst; - if (prim->HaveDst()) + if (prim->haveDst()) dst = prim->Dst(); // Clipping - if (prim->HaveSrc()) { + if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -516,19 +516,20 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit height = prim->Src().Height(); } - if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; // Normal step - if (m_bTrasp0) { + if (_bTrasp0) { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x++) { - if (*raw) *buf = m_palFinal[*raw]; + if (*raw) + *buf = _palFinal[*raw]; buf++; raw++; } @@ -537,11 +538,11 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit } } else { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x += 2) { - buf[0] = m_palFinal[raw[0]]; - buf[1] = m_palFinal[raw[1]]; + buf[0] = _palFinal[raw[0]]; + buf[1] = _palFinal[raw[1]]; buf += 2; raw += 2; @@ -554,11 +555,11 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { - SetPriority(0); + setPriority(0); } RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { - m_bTrasp0 = bTrasp0; + _bTrasp0 = bTrasp0; } @@ -571,8 +572,8 @@ int RMGfxSourceBuffer8::Bpp() { return 8; } -void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw); +void RMGfxSourceBuffer8::create(int dimx, int dimy, bool bUseDDraw) { + RMGfxBuffer::create(dimx, dimy, 8, bUseDDraw); } #define GETRED(x) (((x) >> 10) & 0x1F) @@ -588,7 +589,7 @@ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { } -int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { +int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) { int r, g, b; r = (GETRED(fore) >> 2) + (GETRED(back) >> 1); @@ -603,19 +604,19 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { } -void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; - int bufx = bigBuf.Dimx(); + int bufx = bigBuf.getDimx(); uint16 *buf = bigBuf; - byte *raw = m_buf; + byte *raw = _buf; // Destination buffer RMRect dst; - if (prim->HaveDst()) + if (prim->haveDst()) dst = prim->Dst(); // Clipping - if (prim->HaveSrc()) { + if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -623,19 +624,21 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim height = prim->Src().Height(); } - if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; // Passaggio normale - if (m_bTrasp0) { + if (_bTrasp0) { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x++) { - if (*raw) *buf = CalcTrasp(m_palFinal[*raw], *buf); + if (*raw) + *buf = calcTrasp(_palFinal[*raw], *buf); + buf++; raw++; } @@ -644,11 +647,11 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim } } else { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x += 2) { - buf[0] = CalcTrasp(m_palFinal[raw[0]], buf[0]); - buf[1] = CalcTrasp(m_palFinal[raw[1]], buf[1]); + buf[0] = calcTrasp(_palFinal[raw[0]], buf[0]); + buf[1] = calcTrasp(_palFinal[raw[1]], buf[1]); buf += 2; raw += 2; @@ -669,69 +672,69 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; -void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) { +void RMGfxSourceBuffer8RLE::setAlphaBlendColor(int color) { alphaBlendColor = color; } RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { alphaBlendColor = -1; bNeedRLECompress = true; - m_buf = NULL; + _buf = NULL; } RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { - if (m_buf != NULL) { - delete[] m_buf; - m_buf = NULL; + if (_buf != NULL) { + delete[] _buf; + _buf = NULL; } } -int RMGfxSourceBuffer8RLE::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBufferPal::Init(buf, dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer8RLE::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBufferPal::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { if (bNeedRLECompress) { - RMGfxSourceBufferPal::Init(ds, dimx, dimy, bLoadPalette); + RMGfxSourceBufferPal::init(ds, dimx, dimy, bLoadPalette); } else { int size; ds >> size; - m_buf = new byte[size]; - ds.Read(m_buf, size); + _buf = new byte[size]; + ds.Read(_buf, size); - m_dimx = dimx; - m_dimy = dimy; + _dimx = dimx; + _dimy = dimy; } } -void RMGfxSourceBuffer8RLE::PreparePalette(void) { +void RMGfxSourceBuffer8RLE::preparePalette(void) { // Invoke the parent method - RMGfxSourceBuffer8::PreparePalette(); + RMGfxSourceBuffer8::preparePalette(); // Handle RGB alpha blending if (alphaBlendColor != -1) { - alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; - alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; - alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; + alphaR = (_palFinal[alphaBlendColor] >> 10) & 0x1F; + alphaG = (_palFinal[alphaBlendColor] >> 5) & 0x1F; + alphaB = (_palFinal[alphaBlendColor]) & 0x1F; } } -void RMGfxSourceBuffer8RLE::PrepareImage(void) { +void RMGfxSourceBuffer8RLE::prepareImage(void) { // Invoke the parent method - RMGfxSourceBuffer::PrepareImage(); + RMGfxSourceBuffer::prepareImage(); // Compress - CompressRLE(); + compressRLE(); } -void RMGfxSourceBuffer8RLE::SetAlreadyCompressed(void) { +void RMGfxSourceBuffer8RLE::setAlreadyCompressed(void) { bNeedRLECompress = false; } -void RMGfxSourceBuffer8RLE::CompressRLE(void) { +void RMGfxSourceBuffer8RLE::compressRLE(void) { int x, y; byte *startline; byte *cur; @@ -742,8 +745,8 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { // Perform RLE compression for lines cur = MegaRLEBuf; - src = m_buf; - for (y = 0; y < m_dimy; y++) { + src = _buf; + for (y = 0; y < _dimy; y++) { // Save the beginning of the line startline = cur; @@ -754,7 +757,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { curdata = 0; rep = 0; startsrc = src; - for (x = 0; x < m_dimx;) { + for (x = 0; x < _dimx;) { if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { src++; @@ -795,15 +798,15 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { } // Delete the original image - delete[] m_buf; + delete[] _buf; // Copy the compressed image x = cur - MegaRLEBuf; - m_buf = new byte[x]; - Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); + _buf = new byte[x]; + Common::copy(MegaRLEBuf, MegaRLEBuf + x, _buf); } -void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int y; byte *src; uint16 *buf = bigBuf; @@ -812,26 +815,26 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Clipping x1 = prim->Dst().x1; y1 = prim->Dst().y1; - if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) + if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; // Go forward through the RLE lines - src = m_buf; + src = _buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); // Calculate the position in the destination buffer - buf += y1 * bigBuf.Dimx(); + buf += y1 * bigBuf.getDimx(); // Loop - if (prim->IsFlipped()) { + if (prim->isFlipped()) { // Eliminate horizontal clipping // width = m_dimx; // x1=prim->Dst().x1; // Clipping - u = m_dimx - (width + u); - x1 = (prim->Dst().x1 + m_dimx - 1) - u; + u = _dimx - (width + u); + x1 = (prim->Dst().x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { // Decompressione @@ -841,7 +844,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skip to the next line - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } } else { for (y = 0; y < height; y++) { @@ -852,7 +855,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skip to the next line - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } } } @@ -990,7 +993,7 @@ RLEByteDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst ++ = m_palFinal[*src++]; + *dst ++ = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1096,7 +1099,7 @@ RLEByteFlippedDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst -- = m_palFinal[*src++]; + *dst-- = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1247,7 +1250,7 @@ RLEWordDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst ++ = m_palFinal[*src++]; + *dst++ = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1365,7 +1368,7 @@ RLEWordFlippedDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst -- = m_palFinal[*src++]; + *dst-- = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1500,9 +1503,9 @@ RLEWordDoCopy2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r2 = (m_palFinal[*src] >> 10) & 0x1F; - g2 = (m_palFinal[*src] >> 5) & 0x1F; - b2 = m_palFinal[*src] & 0x1F; + r2 = (_palFinal[*src] >> 10) & 0x1F; + g2 = (_palFinal[*src] >> 5) & 0x1F; + b2 = _palFinal[*src] & 0x1F; r = (r >> 1) + (r2 >> 1); g = (g >> 1) + (g2 >> 1); @@ -1529,16 +1532,16 @@ RLEWordDoCopy2: byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; -void RMGfxSourceBuffer8AA::PrepareImage(void) { +void RMGfxSourceBuffer8AA::prepareImage(void) { // Invoke the parent method - RMGfxSourceBuffer::PrepareImage(); + RMGfxSourceBuffer::prepareImage(); // Prepare the buffer for anti-aliasing - CalculateAA(); + calculateAA(); } -void RMGfxSourceBuffer8AA::CalculateAA(void) { +void RMGfxSourceBuffer8AA::calculateAA(void) { // I suck, you suck, he sucks, we suck, they all suck ---> ANTI ALIASING SUX! // ************************************************************ @@ -1546,17 +1549,17 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { byte *src, *srcaa; /* First pass: fill the edges */ - Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); + Common::fill(MegaAABuf, MegaAABuf + _dimx * _dimy, 0); - src = m_buf; + src = _buf; srcaa = MegaAABuf; - for (y = 0; y < m_dimy; y++) { - for (x = 0; x < m_dimx; x++) { + for (y = 0; y < _dimy; y++) { + for (x = 0; x < _dimx; x++) { if (*src == 0) { - if ((y > 0 && src[-m_dimx] != 0) || - (y < m_dimy - 1 && src[m_dimx] != 0) || + if ((y > 0 && src[-_dimx] != 0) || + (y < _dimy - 1 && src[_dimx] != 0) || (x > 0 && src[-1] != 0) || - (x < m_dimx - 1 && src[1] != 0)) + (x < _dimx - 1 && src[1] != 0)) *srcaa = 1; } @@ -1565,15 +1568,15 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { } } - src = m_buf; + src = _buf; srcaa = MegaAABuf; - for (y = 0; y < m_dimy; y++) { - for (x = 0; x < m_dimx; x++) { + for (y = 0; y < _dimy; y++) { + for (x = 0; x < _dimx; x++) { if (*src != 0) { - if ((y > 0 && srcaa[-m_dimx] == 1) || - (y < m_dimy - 1 && srcaa[m_dimx] == 1) || + if ((y > 0 && srcaa[-_dimx] == 1) || + (y < _dimy - 1 && srcaa[_dimx] == 1) || (x > 0 && srcaa[-1] == 1) || - (x < m_dimx - 1 && srcaa[1] == 1)) + (x < _dimx - 1 && srcaa[1] == 1)) *srcaa = 2; } @@ -1582,23 +1585,23 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { } } - if (m_aabuf != NULL) - delete[] m_aabuf; + if (_aabuf != NULL) + delete[] _aabuf; - m_aabuf = new byte[m_dimx * m_dimy]; - CopyMemory(m_aabuf, MegaAABuf, m_dimx * m_dimy); + _aabuf = new byte[_dimx * _dimy]; + CopyMemory(_aabuf, MegaAABuf, _dimx * _dimy); } RMGfxSourceBuffer8AA::RMGfxSourceBuffer8AA() : RMGfxSourceBuffer8() { - m_aabuf = NULL; + _aabuf = NULL; } RMGfxSourceBuffer8AA::~RMGfxSourceBuffer8AA() { - if (m_aabuf != NULL) - delete[] m_aabuf; + if (_aabuf != NULL) + delete[] _aabuf; } -void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; byte *src; uint16 *mybuf; @@ -1610,35 +1613,35 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Clip the sprite x1 = prim->Dst().x1; y1 = prim->Dst().y1; - if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) + if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; // Go forward through the RLE lines - src = m_buf; + src = _buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); // Eliminate horizontal clipping - if (prim->IsFlipped()) { - u = m_dimx - (width + u); - x1 = (prim->Dst().x1 + m_dimx - 1) - u; + if (prim->isFlipped()) { + u = _dimx - (width + u); + x1 = (prim->Dst().x1 + _dimx - 1) - u; } -// width = m_dimx; -// x1=prim->Dst().x1; +// width = _dimx; +// x1 = prim->Dst().x1; // Poisition into the destination buffer buf = bigBuf; - buf += y1 * bigBuf.Dimx(); + buf += y1 * bigBuf.getDimx(); - if (prim->IsFlipped()) + if (prim->isFlipped()) step = -1; else step = 1; // Loop - buf += bigBuf.Dimx(); // Skip the first line + buf += bigBuf.getDimx(); // Skip the first line for (y = 1; y < height - 1; y++) { /* if (prim->IsFlipped()) @@ -1648,10 +1651,10 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) - if (m_aabuf[(y + v) * m_dimx + x + u] == 2 && x != 0 && x != width - 1) { - r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); - g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); - b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + if (_aabuf[(y + v) * _dimx + x + u] == 2 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.getDimx()]) + GETBLUE(mybuf[bigBuf.getDimx()]); r += GETRED(mybuf[0]); g += GETGREEN(mybuf[0]); @@ -1669,15 +1672,15 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri } // Skip to the next line - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } // Position into the destination buffer buf = bigBuf; - buf += y1 * bigBuf.Dimx(); + buf += y1 * bigBuf.getDimx(); // Looppone - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); for (y = 1; y < height - 1; y++) { /* if (prim->IsFlipped()) @@ -1687,10 +1690,10 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) - if (m_aabuf[(y + v) * m_dimx + x + u] == 1 && x != 0 && x != width - 1) { - r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); - g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); - b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + if (_aabuf[(y + v) * _dimx + x + u] == 1 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.getDimx()]) + GETBLUE(mybuf[bigBuf.getDimx()]); r += GETRED(mybuf[0]) * 2; g += GETGREEN(mybuf[0]) * 2; @@ -1708,20 +1711,20 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri } // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } } -void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(RMGfxSourceBuffer8::Draw, bigBuf, prim); - DrawAA(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8::draw, bigBuf, prim); + drawAA(bigBuf, prim); CORO_END_CODE; } @@ -1735,36 +1738,36 @@ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { } -void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { - RMGfxSourceBuffer::PrepareImage(); - CalculateAA(); - CompressRLE(); +void RMGfxSourceBuffer8RLEByteAA::prepareImage(void) { + RMGfxSourceBuffer::prepareImage(); + calculateAA(); + compressRLE(); } -void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLEByteAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf, prim); + drawAA(bigBuf, prim); CORO_END_CODE; } -int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer8RLEByteAA::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); +void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Load the anti-aliasing mask - m_aabuf = new byte[dimx * dimy]; - ds.Read(m_aabuf, dimx * dimy); + _aabuf = new byte[dimx * dimy]; + ds.Read(_aabuf, dimx * dimy); } } @@ -1773,36 +1776,36 @@ RMGfxSourceBuffer8RLEWordAA::~RMGfxSourceBuffer8RLEWordAA() { } -void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { - RMGfxSourceBuffer::PrepareImage(); - CalculateAA(); - CompressRLE(); +void RMGfxSourceBuffer8RLEWordAA::prepareImage(void) { + RMGfxSourceBuffer::prepareImage(); + calculateAA(); + compressRLE(); } -void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLEWordAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf, prim); + drawAA(bigBuf, prim); CORO_END_CODE; } -int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer8RLEWordAA::init(byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); +void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Load the anti-aliasing mask - m_aabuf = new byte[dimx * dimy]; - ds.Read(m_aabuf, dimx * dimy); + _aabuf = new byte[dimx * dimy]; + ds.Read(_aabuf, dimx * dimy); } } @@ -1812,46 +1815,46 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, boo \****************************************************************************/ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { - m_bTrasp0 = bTrasp0; + _bTrasp0 = bTrasp0; } RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } -void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; - uint16 *raw = (uint16 *)m_buf; + uint16 *raw = (uint16 *)_buf; int dimx, dimy; int u, v; int x1, y1; - dimx = m_dimx; - dimy = m_dimy; + dimx = _dimx; + dimy = _dimy; u = 0; v = 0; x1 = 0; y1 = 0; - if (prim->HaveSrc()) { + if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; dimx = prim->Src().Width(); dimy = prim->Src().Height(); } - if (prim->HaveDst()) { + if (prim->haveDst()) { x1 = prim->Dst().x1; y1 = prim->Dst().y1; } - if (!Clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) + if (!clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) return; - raw += v * m_dimx + u; - buf += y1 * bigBuf.Dimx() + x1; + raw += v * _dimx + u; + buf += y1 * bigBuf.getDimx() + x1; - if (m_bTrasp0) { + if (_bTrasp0) { for (y = 0; y < dimy; y++) { for (x = 0; x < dimx;) { while (x < dimx && raw[x] == 0) @@ -1863,14 +1866,14 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } } - raw += m_dimx; - buf += bigBuf.Dimx(); + raw += _dimx; + buf += bigBuf.getDimx(); } } else { for (y = 0; y < dimy; y++) { Common::copy(raw, raw + dimx, buf); - buf += bigBuf.Dimx(); - raw += m_dimx; + buf += bigBuf.getDimx(); + raw += _dimx; } } } @@ -1878,16 +1881,16 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi void RMGfxSourceBuffer16::PrepareImage(void) { // Colour space conversion if necessary! int i; - uint16 *buf = (uint16 *)m_buf; + uint16 *buf = (uint16 *)_buf; - for (i = 0; i < m_dimx * m_dimy; i++) + for (i = 0; i < _dimx * _dimy; i++) WRITE_LE_UINT16(&buf[i], FROM_LE_16(buf[i]) & 0x7FFF); } RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { - SetPriority(0); + setPriority(0); } @@ -1901,14 +1904,14 @@ int RMGfxSourceBuffer16::Bpp() { } void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx, dimy, 16, bUseDDraw); + RMGfxBuffer::create(dimx, dimy, 16, bUseDDraw); } /****************************************************************************\ * RMGfxBox Methods \****************************************************************************/ -void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { +void RMGfxBox::removeThis(CORO_PARAM, bool &result) { result = true; } @@ -1919,21 +1922,21 @@ void RMGfxBox::SetColor(byte r, byte g, byte b) { wFillColor = (r << 10) | (g << 5) | b; } -void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int i, j; uint16 *buf = bigBuf; RMRect rcDst; // It takes the destination rectangle rcDst = prim->Dst(); - buf += rcDst.y1 * bigBuf.Dimx() + rcDst.x1; + buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; // Loop through the pixels for (j = 0; j < rcDst.Height(); j++) { for (i = 0; i < rcDst.Width(); i++) *buf ++ = wFillColor; - buf += bigBuf.Dimx() - rcDst.Width(); + buf += bigBuf.getDimx() - rcDst.Width(); } } @@ -1947,12 +1950,12 @@ int RMGfxClearTask::Priority() { return 1; } -void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Clean the target buffer - Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); + Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.getDimx() * bigBuf.getDimy() * 2), 0x0); } -void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { +void RMGfxClearTask::removeThis(CORO_PARAM, bool &result) { // The task is fine to be removed result = true; } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index ffeb7724b2..51d27b7311 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -58,10 +58,10 @@ class RMGfxClearTask; // Task */ class RMGfxBuffer { protected: - int m_dimx, m_dimy; - byte *m_buf; - byte *m_origBuf; - bool m_bUseDDraw; + int _dimx, _dimy; + byte *_buf; + byte *_origBuf; + bool _bUseDDraw; public: RMGfxBuffer(); @@ -69,27 +69,27 @@ public: virtual ~RMGfxBuffer(); // Attributes - int Dimx() { - return m_dimx; + int getDimx() { + return _dimx; } - int Dimy() { - return m_dimy; + int getDimy() { + return _dimy; } // Creation - virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual void Destroy(void); + virtual void create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void destroy(void); // Buffer access - void Lock(void); - void Unlock(void); + void lock(void); + void unlock(void); // These are valid only if the buffer is locked operator byte *(); operator void *(); // Getting the offset for a given Y position - void OffsetY(int nLines, int nBpp); + void offsetY(int nLines, int nBpp); }; /** @@ -97,116 +97,116 @@ public: */ class RMGfxPrimitive { public: - RMGfxTask *m_task; + RMGfxTask *_task; protected: - RMRect m_src; - RMRect m_dst; + RMRect _src; + RMRect _dst; - bool m_bStretch; - byte m_bFlag; + bool _bStretch; + byte _bFlag; public: RMGfxPrimitive() { - m_bFlag = 0; - m_task = NULL; - m_src.SetEmpty(); - m_dst.SetEmpty(); + _bFlag = 0; + _task = NULL; + _src.SetEmpty(); + _dst.SetEmpty(); } RMGfxPrimitive(RMGfxTask *task) { - m_task = task; - m_bFlag = 0; + _task = task; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { - m_task = task; - m_src = src; - m_dst = dst; - m_bFlag = 0; - m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); + _task = task; + _src = src; + _dst = dst; + _bFlag = 0; + _bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { - m_task = task; - m_src.TopLeft() = src; - m_dst = dst; - m_bFlag = 0; + _task = task; + _src.TopLeft() = src; + _dst = dst; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { - m_task = task; - m_src.TopLeft() = src; - m_dst.TopLeft() = dst; - m_bFlag = 0; + _task = task; + _src.TopLeft() = src; + _dst.TopLeft() = dst; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { - m_task = task; - m_src = src; - m_dst.TopLeft() = dst; - m_bFlag = 0; + _task = task; + _src = src; + _dst.TopLeft() = dst; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { - m_task = task; - m_dst = dst; - m_src.SetEmpty(); - m_bFlag = 0; + _task = task; + _dst = dst; + _src.SetEmpty(); + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { - m_task = task; - m_dst.TopLeft() = dst; - m_src.SetEmpty(); - m_bFlag = 0; + _task = task; + _dst.TopLeft() = dst; + _src.SetEmpty(); + _bFlag = 0; } virtual ~RMGfxPrimitive() { } - void SetFlag(byte bFlag) { - m_bFlag = bFlag; + void setFlag(byte bFlag) { + _bFlag = bFlag; } - void SetTask(RMGfxTask *task) { - m_task = task; + void setTask(RMGfxTask *task) { + _task = task; } - void SetSrc(const RMRect &src) { - m_src = src; + void setSrc(const RMRect &src) { + _src = src; } - void SetSrc(const RMPoint &src) { - m_src.TopLeft() = src; + void setSrc(const RMPoint &src) { + _src.TopLeft() = src; } - void SetDst(const RMRect &dst) { - m_dst = dst; + void setDst(const RMRect &dst) { + _dst = dst; } - void SetDst(const RMPoint &dst) { - m_dst.TopLeft() = dst; + void setDst(const RMPoint &dst) { + _dst.TopLeft() = dst; } - void SetStrecth(bool bStretch) { - m_bStretch = bStretch; + void setStrecth(bool bStretch) { + _bStretch = bStretch; } - bool HaveDst() { - return !m_dst.IsEmpty(); + bool haveDst() { + return !_dst.IsEmpty(); } RMRect &Dst() { - return m_dst; + return _dst; } - bool HaveSrc() { - return !m_src.IsEmpty(); + bool haveSrc() { + return !_src.IsEmpty(); } RMRect &Src() { - return m_src; + return _src; } // Flags - bool IsFlipped() { - return m_bFlag & 1; + bool isFlipped() { + return _bFlag & 1; } // Duplicate - virtual RMGfxPrimitive *Duplicate() { + virtual RMGfxPrimitive *duplicate() { return new RMGfxPrimitive(*this); } }; @@ -217,25 +217,25 @@ public: */ class RMGfxTask { protected: - int m_nPrior; - int m_nInList; + int _nPrior; + int _nInList; public: // Standard constructor RMGfxTask(); virtual ~RMGfxTask() { } - virtual int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual int priority(); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void removeThis(CORO_PARAM, bool &result); // Registration virtual void Register(void) { - m_nInList++; + _nInList++; } virtual void Unregister(void) { - m_nInList--; - assert(m_nInList >= 0); + _nInList--; + assert(_nInList >= 0); } }; @@ -246,7 +246,7 @@ public: class RMGfxTaskSetPrior : public RMGfxTask { public: virtual ~RMGfxTaskSetPrior() { } - void SetPriority(int nPrior); + void setPriority(int nPrior); }; @@ -258,8 +258,8 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void removeThis(CORO_PARAM, bool &result); }; @@ -274,8 +274,8 @@ public: virtual ~RMGfxBox() { } void SetColor(byte r, byte g, byte b); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void removeThis(CORO_PARAM, bool &result); }; @@ -285,17 +285,17 @@ public: class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: // Load the data for the surface - virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); protected: - virtual void PrepareImage(void); - bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); - void OffsetY(int nLines) { - RMGfxBuffer::OffsetY(nLines, Bpp()); + virtual void prepareImage(void); + bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); + void offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, Bpp()); } public: @@ -309,7 +309,7 @@ public: class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: virtual void PrepareImage(void); - bool m_bTrasp0; + bool _bTrasp0; public: RMGfxSourceBuffer16(bool bUseTrasp = false); @@ -320,7 +320,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -330,22 +330,22 @@ public: class RMGfxSourceBufferPal : public RMGfxSourceBuffer { protected: // The size of the palette is (1 << Bpp()) * 4 - byte m_pal[256 * 3]; - uint16 m_palFinal[256]; + byte _pal[256 * 3]; + uint16 _palFinal[256]; // Post process to prepare the palette for drawing - virtual void PreparePalette(void); + virtual void preparePalette(void); public: virtual ~RMGfxSourceBufferPal(); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - int LoadPaletteWA(uint32 resID, bool bSwapped = false); - int LoadPaletteWA(const byte *buf, bool bSwapped = false); - int LoadPalette(uint32 resID); - int LoadPalette(const byte *buf); + int loadPaletteWA(uint32 resID, bool bSwapped = false); + int loadPaletteWA(const byte *buf, bool bSwapped = false); + int loadPalette(uint32 resID); + int loadPalette(const byte *buf); }; @@ -354,7 +354,7 @@ public: */ class RMGfxSourceBuffer8 : public RMGfxSourceBufferPal { protected: - bool m_bTrasp0; + bool _bTrasp0; public: RMGfxSourceBuffer8(bool bTrasp0 = true); @@ -362,10 +362,10 @@ public: virtual ~RMGfxSourceBuffer8(); // Initialisation - void Create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -374,11 +374,11 @@ public: */ class RMGfxSourceBuffer8AB : public RMGfxSourceBuffer8 { protected: - int CalcTrasp(int f, int b); + int calcTrasp(int f, int b); public: virtual ~RMGfxSourceBuffer8AB(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -403,29 +403,29 @@ protected: virtual void RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) = 0; // Perform image compression in RLE - void CompressRLE(void); + void compressRLE(void); protected: // Overriding initialisation methods - virtual void PrepareImage(void); - virtual void PreparePalette(void); + virtual void prepareImage(void); + virtual void preparePalette(void); public: RMGfxSourceBuffer8RLE(); virtual ~RMGfxSourceBuffer8RLE(); // Overload of the initialisation method - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the color that will be alpha blended - void SetAlphaBlendColor(int color); + void setAlphaBlendColor(int color); // Warn if the data is already compressed - void SetAlreadyCompressed(void); + void setAlreadyCompressed(void); }; class RMGfxSourceBuffer8RLEByte : public RMGfxSourceBuffer8RLE { @@ -470,50 +470,50 @@ class RMGfxSourceBuffer8AA : public virtual RMGfxSourceBuffer8 { protected: static byte MegaAABuf[]; static byte MegaAABuf2[]; - byte *m_aabuf; + byte *_aabuf; // Calculate the buffer for the anti-aliasing - void CalculateAA(void); + void calculateAA(void); // Draw the AA - void DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); protected: - void PrepareImage(void); + void prepareImage(void); public: RMGfxSourceBuffer8AA(); virtual ~RMGfxSourceBuffer8AA(); // Draw with anti-aliasing - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; class RMGfxSourceBuffer8RLEByteAA : public RMGfxSourceBuffer8RLEByte, public RMGfxSourceBuffer8AA { protected: - void PrepareImage(void); + void prepareImage(void); public: - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); }; class RMGfxSourceBuffer8RLEWordAA : public RMGfxSourceBuffer8RLEWord, public RMGfxSourceBuffer8AA { protected: - void PrepareImage(void); + void prepareImage(void); public: - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEWordAA(); }; @@ -531,7 +531,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -557,34 +557,34 @@ private: protected: OTList *otlist; - int m_otSize; + int _otSize; public: RMGfxTargetBuffer(); virtual ~RMGfxTargetBuffer(); // management of the OT list - void ClearOT(void); - void DrawOT(CORO_PARAM); - void AddPrim(RMGfxPrimitive *prim); // The pointer must be delted + void clearOT(void); + void drawOT(CORO_PARAM); + void addPrim(RMGfxPrimitive *prim); // The pointer must be delted // Adds a task to clear the screen - void AddClearTask(void); + void addClearTask(void); operator byte *() { - return m_buf; + return _buf; } operator void *() { - return (void *)m_buf; + return (void *)_buf; } operator uint16 *() { // FIXME: This may not be endian safe - return (uint16 *)m_buf; + return (uint16 *)_buf; } // Offseting buffer - void OffsetY(int nLines) { - RMGfxBuffer::OffsetY(nLines, 16); + void offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, 16); } }; @@ -598,7 +598,7 @@ public: RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index dd448fdc93..2d1c0663a6 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -61,8 +61,8 @@ void ExitAllIdles(CORO_PARAM, const void *param) { RMGfxEngine::RMGfxEngine() { // Create big buffer where the frame will be rendered - _bigBuf.Create(RM_BBX, RM_BBY, 16); - _bigBuf.OffsetY(RM_SKIPY); + _bigBuf.create(RM_BBX, RM_BBY, 16); + _bigBuf.offsetY(RM_SKIPY); _csMainLoop = NULL; _nCurLoc = 0; @@ -84,7 +84,7 @@ RMGfxEngine::RMGfxEngine() { RMGfxEngine::~RMGfxEngine() { // Close the buffer - _bigBuf.Destroy(); + _bigBuf.destroy(); g_system->deleteMutex(_csMainLoop); } @@ -312,7 +312,7 @@ SKIPCLICKSINISTRO: // ********************** // Draw the list in the OT // ********************** - CORO_INVOKE_0(_bigBuf.DrawOT); + CORO_INVOKE_0(_bigBuf.drawOT); #define FSTEP (480/32) @@ -454,7 +454,7 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _bLocationLoaded = false; - _bigBuf.ClearOT(); + _bigBuf.clearOT(); _loc.Unload(); if (result != NULL) @@ -468,9 +468,9 @@ void RMGfxEngine::init() { RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); - _bigBuf.AddPrim(new RMGfxPrimitive(load)); - _bigBuf.DrawOT(Common::nullContext); - _bigBuf.ClearOT(); + _bigBuf.addPrim(new RMGfxPrimitive(load)); + _bigBuf.drawOT(Common::nullContext); + _bigBuf.clearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); @@ -502,7 +502,7 @@ void RMGfxEngine::init() { _point.Init(); // Initialise Tony - _tony.Init(); + _tony.init(); _tony.LinkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface @@ -519,7 +519,7 @@ void RMGfxEngine::init() { } void RMGfxEngine::close(void) { - _bigBuf.ClearOT(); + _bigBuf.clearOT(); _inter.Close(); _inv.Close(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 695c5af58f..69d36cbbc0 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -121,7 +121,7 @@ public: // Link to graphic task void linkGraphicTask(RMGfxTask *task) { - _bigBuf.AddPrim(new RMGfxPrimitive(task)); + _bigBuf.addPrim(new RMGfxPrimitive(task)); }; // Manage a location diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 5fb375da81..9b8f346aaf 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -79,7 +79,7 @@ void RMInventory::Init(void) { // Create the main buffer Create(RM_SX, 68); - SetPriority(185); + setPriority(185); // Setup the inventory m_nInv = 0; @@ -122,7 +122,7 @@ void RMInventory::Init(void) { assert(raw.IsValid()); - m_items[i].pointer[j].Init((const byte *)raw, raw.Width(), raw.Height(), true); + m_items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); curres++; } } @@ -156,8 +156,8 @@ void RMInventory::Init(void) { // Prepare initial inventory Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); } void RMInventory::Close(void) { @@ -172,7 +172,7 @@ void RMInventory::Close(void) { m_items = NULL; } - Destroy(); + destroy(); } void RMInventory::Reset(void) { @@ -180,7 +180,7 @@ void RMInventory::Reset(void) { EndCombine(); } -void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; RMPoint pos; RMPoint pos2; @@ -191,12 +191,12 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); if (m_state == OPENING || m_state == CLOSING) - prim->SetDst(RMPoint(0, m_curPutY)); + prim->setDst(RMPoint(0, m_curPutY)); else - prim->SetDst(RMPoint(0, m_curPutY)); + prim->setDst(RMPoint(0, m_curPutY)); g_system->lockMutex(m_csModifyInterface); - CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); g_system->unlockMutex(m_csModifyInterface); if (m_state == SELECTING) { @@ -209,19 +209,19 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); } - _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); - _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); + _ctx->p = new RMGfxPrimitive(prim->_task, _ctx->pos); + _ctx->p2 = new RMGfxPrimitive(prim->_task, _ctx->pos2); // Draw the mini interface - CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); + CORO_INVOKE_2(miniInterface.draw, bigBuf, _ctx->p); if (GLOBALS.bCfgInterTips) { if (miniAction == 1) // Examine - CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(m_hints[0].draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Talk - CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(m_hints[1].draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Use - CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(m_hints[2].draw, bigBuf, _ctx->p2); } delete _ctx->p; @@ -249,8 +249,8 @@ void RMInventory::RemoveItem(int code) { m_nInv--; Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); return; } @@ -270,8 +270,8 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++] = code - 10000; Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } } @@ -285,8 +285,8 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].status = dwStatus; Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } } @@ -297,14 +297,14 @@ void RMInventory::Prepare(void) { for (i = 1; i < RM_SX / 64 - 1; i++) { if (i - 1 + m_curPos < m_nInv) - AddPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); else - AddPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); } // Frecce - AddPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); - AddPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); + addPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); } bool RMInventory::MiniActive(void) { @@ -364,8 +364,8 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } // Click the left arrow @@ -385,8 +385,8 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -430,8 +430,8 @@ void RMInventory::RightClick(const RMPoint &mpos) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } else if ((m_state == OPENED) && m_bBlinkingLeft) { assert(m_curPos > 0); @@ -450,8 +450,8 @@ void RMInventory::RightClick(const RMPoint &mpos) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } } @@ -484,7 +484,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (m_state != CLOSED) { // Clean up the OT list g_system->lockMutex(m_csModifyInterface); - ClearOT(); + clearOT(); // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help @@ -662,8 +662,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniInterface.DoFrame(&bigBuf, false); } - if ((m_state != CLOSED) && !m_nInList) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + if ((m_state != CLOSED) && !_nInList) { + bigBuf.addPrim(new RMGfxPrimitive(this)); } } @@ -744,8 +744,8 @@ int RMInventory::LoadState(byte *state) { m_items[28].icon.SetPattern(1); Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); return GetSaveStateSize(); } @@ -781,7 +781,7 @@ int RMInterface::OnWhichBox(RMPoint pt) { return -1; } -void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int h; CORO_END_CONTEXT(_ctx); @@ -789,13 +789,13 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); prim->Dst().TopLeft() = m_openStart; - CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone _ctx->h = OnWhichBox(m_mpos); if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; - CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); + CORO_INVOKE_2(m_hotzone[_ctx->h].draw, bigBuf, prim); if (m_lastHotZone != _ctx->h) { m_lastHotZone = _ctx->h; @@ -804,7 +804,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (GLOBALS.bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); + CORO_INVOKE_2(m_hints[_ctx->h].draw, bigBuf, prim); } } else m_lastHotZone = -1; @@ -815,8 +815,8 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { // If needed, add to the OT schedule list - if (!m_nInList && m_bActive) - bigBuf.AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && m_bActive) + bigBuf.addPrim(new RMGfxPrimitive(this)); m_mpos = mousepos; } @@ -826,14 +826,14 @@ void RMInterface::Clicked(const RMPoint &mousepos) { m_openPos = mousepos; // Calculate the top left corner of the interface - m_openStart = m_openPos - RMPoint(m_dimx / 2, m_dimy / 2); + m_openStart = m_openPos - RMPoint(_dimx / 2, _dimy / 2); m_lastHotZone = -1; // Keep it inside the screen if (m_openStart.x < 0) m_openStart.x = 0; if (m_openStart.y < 0) m_openStart.y = 0; - if (m_openStart.x + m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; - if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; + if (m_openStart.x + _dimx > RM_SX) m_openStart.x = RM_SX - _dimx; + if (m_openStart.y + _dimy > RM_SY) m_openStart.y = RM_SY - _dimy; // Play the sound effect _vm->playUtilSFX(0); @@ -890,16 +890,16 @@ void RMInterface::Init(void) { RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); - SetPriority(191); + setPriority(191); - RMGfxSourceBuffer::Init(inter, inter.Width(), inter.Height()); - LoadPaletteWA(RES_I_INTERPAL); + RMGfxSourceBuffer::init(inter, inter.Width(), inter.Height()); + loadPaletteWA(RES_I_INTERPAL); for (i = 0; i < 5; i++) { RMResRaw part(RES_I_INTERP1 + i); - m_hotzone[i].Init(part, part.Width(), part.Height()); - m_hotzone[i].LoadPaletteWA(pal); + m_hotzone[i].init(part, part.Width(), part.Height()); + m_hotzone[i].loadPaletteWA(pal); } m_hotbbox[0].SetRect(126, 123, 159, 208); // Take @@ -935,10 +935,10 @@ void RMInterface::Init(void) { void RMInterface::Close(void) { int i; - Destroy(); + destroy(); for (i = 0; i < 5; i++) - m_hotzone[i].Destroy(); + m_hotzone[i].destroy(); } } // End of namespace Tony diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index a5f02603e7..87ccaa33b4 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -101,7 +101,7 @@ public: virtual void RemoveThis(CORO_PARAM, bool &result); // Overload the drawing of the inventory - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Method for determining whether the inventory currently has the focus bool HaveFocus(const RMPoint &mpos); @@ -193,7 +193,7 @@ public: bool GetPalesati(void); // Overloaded Draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 601ae3f09b..1a7933a03d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -356,15 +356,15 @@ void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { ds += 32; // Create buffer and read - m_buf->Init(ds, dimx, dimy); + m_buf->init(ds, dimx, dimy); } -void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->Draw(coroParam, bigBuf, prim); +void RMSprite::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->draw(coroParam, bigBuf, prim); } void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal *)m_buf)->LoadPalette(buf); + ((RMGfxSourceBufferPal *)m_buf)->loadPalette(buf); } RMSprite::RMSprite() { @@ -500,9 +500,9 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) else spr = new RMGfxSourceBuffer8RLEByteAA; - spr->SetAlphaBlendColor(m_FXparm); + spr->setAlphaBlendColor(m_FXparm); if (bPreRLE) - spr->SetAlreadyCompressed(); + spr->setAlreadyCompressed(); } else { if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWord; @@ -510,7 +510,7 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) spr = new RMGfxSourceBuffer8RLEByte; if (bPreRLE) - spr->SetAlreadyCompressed(); + spr->setAlreadyCompressed(); } return spr; @@ -675,8 +675,8 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { } // If we are not in the OT list, add ourselves - if (!m_nInList && bAddToList) - bigBuf->AddPrim(NewItemPrimitive()); + if (!_nInList && bAddToList) + bigBuf->addPrim(NewItemPrimitive()); return oldSprite != m_nCurSprite; } @@ -685,7 +685,7 @@ RMPoint RMItem::CalculatePos(void) { return m_pos + m_patterns[m_nCurPattern].Pos(); } -void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -696,7 +696,7 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { return; // Set the flag - prim->SetFlag(m_bCurFlag); + prim->setFlag(m_bCurFlag); // Offset direction for scrolling prim->Dst().Offset(-m_curScroll); @@ -706,10 +706,10 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(CalculatePos()); // No stretching, please - prim->SetStrecth(false); + prim->setStrecth(false); // Now we turn to the generic surface drawing routines - CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); + CORO_INVOKE_2(m_sprites[m_nCurSprite].draw, bigBuf, prim); CORO_END_CODE; } @@ -867,7 +867,7 @@ int RMWipe::Priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); - assert(m_nInList == 0); + assert(_nInList == 0); CoroScheduler.setEvent(m_hUnregistered); } @@ -919,7 +919,7 @@ void RMWipe::InitFade(int type) { void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { if (m_bMustRegister) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_bMustRegister = false; } @@ -934,18 +934,18 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } } -void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (m_bFading) { - CORO_INVOKE_2(m_wip0r.Draw, bigBuf, prim); + CORO_INVOKE_2(m_wip0r.draw, bigBuf, prim); } if (m_bEndFade) - Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); + Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.getDimx() * bigBuf.getDimy() * 2, 0x0); CORO_END_CODE; } @@ -1332,7 +1332,7 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { return puntocaldo; } -void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1341,7 +1341,7 @@ void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (bDrawNow) { prim->Dst() += m_fixedScroll; - CORO_INVOKE_2(RMItem::Draw, bigBuf, prim); + CORO_INVOKE_2(RMItem::draw, bigBuf, prim); } CORO_END_CODE; @@ -2072,7 +2072,7 @@ bool RMLocation::Load(RMDataStream &ds) { }; // Initialise the surface, loading the palette if necessary - m_buf->Init(ds, dimx, dimy, true); + m_buf->init(ds, dimx, dimy, true); // Check the size of the location // assert(dimy!=512); @@ -2119,7 +2119,7 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { m_buf = new RMGfxSourceBuffer16; // Initialise the surface, loading in the palette if necessary - m_buf->Init(ds, dimx, dimy, true); + m_buf->init(ds, dimx, dimy, true); // Number of items ds >> m_nItems; @@ -2138,21 +2138,21 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { /** * Draw method overloaded from RMGfxSourceBUffer8 */ -void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->Dimy() > RM_SY || m_buf->Dimx() > RM_SX) { - prim->SetSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); + if (m_buf->getDimy() > RM_SY || m_buf->getDimx() > RM_SX) { + prim->setSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); } - prim->SetDst(m_fixedScroll); + prim->setDst(m_fixedScroll); // Invoke the drawing method fo the image class, which will draw the location background - CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + CORO_INVOKE_2(m_buf->draw, bigBuf, prim); CORO_END_CODE; } @@ -2165,8 +2165,8 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { int i; // If the location is not in the OT list, add it in - if (!m_nInList) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList) + bigBuf->addPrim(new RMGfxPrimitive(this)); // Process all the location items for (i = 0; i < m_nItems; i++) @@ -2231,7 +2231,7 @@ void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { m_curScroll.x = ptShowThis.x - 250; } else if (m_curScroll.x + RM_SX - 250 < ptShowThis.x) { m_curScroll.x = ptShowThis.x + 250 - RM_SX; - } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->Dimx() > RM_SX) { + } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->getDimx() > RM_SX) { if (m_curScroll.x + RM_SX / 2 < ptShowThis.x) m_curScroll.x++; else @@ -2242,17 +2242,21 @@ void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { m_curScroll.y = ptShowThis.y - 180; } else if (m_curScroll.y + RM_SY - 180 < ptShowThis.y) { m_curScroll.y = ptShowThis.y + 180 - RM_SY; - } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->Dimy() > RM_SY) { + } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->getDimy() > RM_SY) { if (m_curScroll.y + RM_SY / 2 < ptShowThis.y) m_curScroll.y++; else m_curScroll.y--; } - if (m_curScroll.x < 0) m_curScroll.x = 0; - if (m_curScroll.y < 0) m_curScroll.y = 0; - if (m_curScroll.x + RM_SX > m_buf->Dimx()) m_curScroll.x = m_buf->Dimx() - RM_SX; - if (m_curScroll.y + RM_SY > m_buf->Dimy()) m_curScroll.y = m_buf->Dimy() - RM_SY; + if (m_curScroll.x < 0) + m_curScroll.x = 0; + if (m_curScroll.y < 0) + m_curScroll.y = 0; + if (m_curScroll.x + RM_SX > m_buf->getDimx()) + m_curScroll.x = m_buf->getDimx() - RM_SX; + if (m_curScroll.y + RM_SY > m_buf->getDimy()) + m_curScroll.y = m_buf->getDimy() - RM_SY; if (oldScroll != m_curScroll) for (int i = 0; i < m_nItems; i++) @@ -2268,10 +2272,14 @@ void RMLocation::SetFixedScroll(const RMPoint &scroll) { void RMLocation::SetScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; - if (pt.x < 0) pt.x = 0; - if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX > m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; - if (pt.y + RM_SY > m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + if (pt.x < 0) + pt.x = 0; + if (pt.y < 0) + pt.y = 0; + if (pt.x + RM_SX > m_buf->getDimx()) + pt.x = m_buf->getDimx() - RM_SX; + if (pt.y + RM_SY > m_buf->getDimy()) + pt.y = m_buf->getDimy() - RM_SY; m_curScroll = pt; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 612e7b5d3e..c11dac4782 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -186,7 +186,7 @@ public: void Init(RMGfxSourceBuffer *buf); friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); @@ -254,7 +254,7 @@ public: virtual void RemoveThis(CORO_PARAM, bool &result); // Overloaded Draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering virtual int Priority() { @@ -460,7 +460,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped bool EndOfPath() { @@ -510,7 +510,7 @@ public: virtual ~RMWipe(); void DoFrame(RMGfxTargetBuffer &bigBuf); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void InitFade(int type); void CloseFade(void); @@ -566,7 +566,7 @@ public: void Unload(void); // Overloaded draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepare a frame by drawing the location and all it's items void DoFrame(RMGfxTargetBuffer *bigBuf); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 98171b2544..cc323eb5d2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -104,14 +104,14 @@ Common::ErrorCode TonyEngine::init() { _startTime = g_system->getMillis(); // Init static class fields - RMText::InitStatics(); - RMTony::InitStatics(); + RMText::initStatics(); + RMTony::initStatics(); // Reset the scheduler CoroScheduler.reset(); // Initialise the graphics window - _window.Init(); + _window.init(); // Initialise the function list Common::fill(_funcList, _funcList + 300, (LPCUSTOMFUNCTION)NULL); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 419f5a251f..f135cff7c3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -40,7 +40,7 @@ namespace Tony { bool RMTony::m_bAction = false; -void RMTony::InitStatics() { +void RMTony::initStatics() { m_bAction = false; } @@ -82,13 +82,13 @@ RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) assert(m_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; - spr->SetAlphaBlendColor(1); + spr->setAlphaBlendColor(1); if (bPreRLE) - spr->SetAlreadyCompressed(); + spr->setAlreadyCompressed(); return spr; } -void RMTony::Init(void) { +void RMTony::init(void) { RMRes tony(0); RMRes body(9999); RMDataStream ds; @@ -125,7 +125,7 @@ void RMTony::Init(void) { void RMTony::Close(void) { // Disalloca @@@ Deallocation of missing item - m_ombra.Destroy(); + m_ombra.destroy(); } void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { @@ -135,8 +135,8 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CODE(_ctx); - if (!m_nInList && m_bShow) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && m_bShow) + bigBuf->addPrim(new RMGfxPrimitive(this)); SetSpeed(GLOBALS.nCfgTonySpeed); @@ -172,7 +172,7 @@ void RMTony::Hide(bool bShowOmbra) { } -void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -185,7 +185,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(1, 4); - CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); + CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } if (m_bIsTalking || m_bIsStaticTalk) { @@ -195,7 +195,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); prim->Dst() += m_nBodyOffset; - CORO_INVOKE_2(m_body.Draw, bigBuf, prim); + CORO_INVOKE_2(m_body.draw, bigBuf, prim); } if (!m_bCorpoDavanti) { @@ -203,7 +203,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(0, 3); - CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); + CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a1c7fc152b..e7b4227fc5 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -358,11 +358,11 @@ public: }; public: - static void InitStatics(); + static void initStatics(); RMTony(); // Initialise Tony - void Init(void); + void init(void); // Free all memory void Close(void); @@ -371,7 +371,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Draw method, which controls chararacter display - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Show or hide void Show(void); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 6b61d25ea2..5d73443167 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -51,7 +51,7 @@ RMWindow::~RMWindow() { /** * Initialises the graphics window */ -void RMWindow::Init() { +void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); diff --git a/engines/tony/window.h b/engines/tony/window.h index 0f614fca97..70e74eb54d 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -79,8 +79,8 @@ public: ~RMWindow(); // Initialisation - void Init(/*HINSTANCE hInst*/); - void InitDirectDraw(void); + void init(/*HINSTANCE hInst*/); + void initDirectDraw(void); void Close(void); // Drawing -- cgit v1.2.3 From 380c86fd4073415ee485c244383cc15d3b45b703 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 18:51:20 +0200 Subject: TONY: Some renaming --- engines/tony/font.cpp | 6 +++--- engines/tony/font.h | 8 ++++---- engines/tony/game.cpp | 8 ++++---- engines/tony/game.h | 8 ++++---- engines/tony/gfxcore.cpp | 2 +- engines/tony/gfxcore.h | 2 +- engines/tony/inventory.cpp | 2 +- engines/tony/inventory.h | 2 +- engines/tony/loc.cpp | 10 +++++----- engines/tony/loc.h | 10 +++++----- 10 files changed, 29 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 16cf4497fc..47cdcb56b5 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1798,7 +1798,7 @@ void RMText::SetMaxLineLength(int max) { maxLineLength = max; } -void RMText::RemoveThis(CORO_PARAM, bool &result) { +void RMText::removeThis(CORO_PARAM, bool &result) { // Here we can do checks on the number of frames, time spent, etc. result = true; } @@ -2064,7 +2064,7 @@ void RMTextDialog::SetAlwaysDisplay(void) { m_bAlwaysDisplay = true; } -void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { +void RMTextDialog::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; bool expired; CORO_END_CONTEXT(_ctx); @@ -2554,7 +2554,7 @@ void RMDialogChoice::Hide(CORO_PARAM) { } -void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { +void RMDialogChoice::removeThis(CORO_PARAM, bool &result) { result = bRemoveFromOT; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 0faaec89d4..752f142cf1 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -220,7 +220,7 @@ public: void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overloading of the Draw to center the text, if necessary virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -261,7 +261,7 @@ public: void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overloaded de-registration virtual void Unregister(void); @@ -334,7 +334,7 @@ public: bool IsItemSelected(); bool IsNormalItemSelected(); - virtual void RemoveThis(CORO_PARAM, bool &result) { + virtual void removeThis(CORO_PARAM, bool &result) { result = true; } }; @@ -362,7 +362,7 @@ protected: void SetSelected(CORO_PARAM, int pos); public: - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void Unregister(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c22706cc6d..5f8f238bff 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -995,7 +995,7 @@ bool RMOptionScreen::IsClosing(void) { return m_bExit; } -int RMOptionScreen::Priority() { +int RMOptionScreen::priority() { // Just below the mouse return 190; } @@ -1375,7 +1375,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_END_CODE; } -void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { +void RMOptionScreen::removeThis(CORO_PARAM, bool &result) { if (m_bExit) result = true; else @@ -1523,7 +1523,7 @@ void RMPointer::Close(void) { } -int RMPointer::Priority() { +int RMPointer::priority() { // Pointer has minimum priority so it will be drawn last return 200; } @@ -1569,7 +1569,7 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); } -void RMPointer::RemoveThis(CORO_PARAM, bool &result) { +void RMPointer::removeThis(CORO_PARAM, bool &result) { // Always remove from the OT list, to support disabling the pointer result = true; } diff --git a/engines/tony/game.h b/engines/tony/game.h index d42a3805c8..5dbd81c079 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -93,7 +93,7 @@ public: void DoFrame(RMGfxTargetBuffer *bigBuf); // Overloading of priorities - int Priority(); + int priority(); // Overloading draw method virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -104,7 +104,7 @@ public: } // Overloading of the method to see if rising from the list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Sets a new action as current void SetAction(RMTonyAction action) { @@ -272,9 +272,9 @@ public: bool IsClosing(); // Overloaded methods - virtual int Priority(); + virtual int priority(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Polling for the option screen void DoFrame(CORO_PARAM, RMInput *m_input); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 2076e2af47..6369d91207 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1945,7 +1945,7 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) * RMGfxClearTask Methods \****************************************************************************/ -int RMGfxClearTask::Priority() { +int RMGfxClearTask::priority() { // Maximum priority (must be done first) return 1; } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 51d27b7311..2daa7edc6d 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -257,7 +257,7 @@ class RMGfxClearTask : public RMGfxTask { public: virtual ~RMGfxClearTask() { } - int Priority(); + int priority(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void removeThis(CORO_PARAM, bool &result); }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 9b8f346aaf..a660ad736e 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -231,7 +231,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_END_CODE; } -void RMInventory::RemoveThis(CORO_PARAM, bool &result) { +void RMInventory::removeThis(CORO_PARAM, bool &result) { if (m_state == CLOSED) result = true; else diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 87ccaa33b4..9ed250592d 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -98,7 +98,7 @@ public: void Reset(void); // Overload test for removal from OT list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overload the drawing of the inventory virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 1a7933a03d..6ede99b57d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -715,7 +715,7 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -void RMItem::RemoveThis(CORO_PARAM, bool &result) { +void RMItem::removeThis(CORO_PARAM, bool &result) { // Remove from the OT list if the current frame is -1 (pattern over) result = (m_nCurSprite == -1); } @@ -861,7 +861,7 @@ RMWipe::~RMWipe() { CoroScheduler.closeEvent(m_hEndOfFade); } -int RMWipe::Priority(void) { +int RMWipe::priority(void) { return 200; } @@ -871,7 +871,7 @@ void RMWipe::Unregister(void) { CoroScheduler.setEvent(m_hUnregistered); } -void RMWipe::RemoveThis(CORO_PARAM, bool &result) { +void RMWipe::removeThis(CORO_PARAM, bool &result) { result = m_bUnregister; } @@ -1657,7 +1657,7 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_END_CODE; } -void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { +void RMCharacter::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1666,7 +1666,7 @@ void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { if (bRemoveFromOT) result = true; else - CORO_INVOKE_1(RMItem::RemoveThis, result); + CORO_INVOKE_1(RMItem::removeThis, result); CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index c11dac4782..282ea0fa4a 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -251,13 +251,13 @@ public: void SetScrollPosition(const RMPoint &scroll); // Overloading of check whether to remove from active list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overloaded Draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int Priority() { + virtual int priority() { return m_z; } @@ -454,7 +454,7 @@ public: void LinkToBoxes(RMGameBoxes *theBoxes); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Update the position of a character void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); @@ -517,8 +517,8 @@ public: void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); - virtual void RemoveThis(CORO_PARAM, bool &result); - virtual int Priority(void); + virtual void removeThis(CORO_PARAM, bool &result); + virtual int priority(void); }; -- cgit v1.2.3 From 334dc91e279d01b264ae7454f39faa557a250428 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 6 Jun 2012 01:37:06 +0200 Subject: TONY: Rename variables and functions in game.h --- engines/tony/custom.cpp | 14 +- engines/tony/detection.cpp | 4 +- engines/tony/font.cpp | 4 +- engines/tony/game.cpp | 1444 ++++++++++++++++++++++---------------------- engines/tony/game.h | 236 ++++---- engines/tony/gfxengine.cpp | 60 +- engines/tony/inventory.cpp | 14 +- engines/tony/loc.cpp | 10 +- engines/tony/loc.h | 4 +- engines/tony/tonychar.cpp | 2 +- 10 files changed, 898 insertions(+), 894 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 8092109ef5..24caaa1e29 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -209,23 +209,23 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); break; case 2: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); break; case 3: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); break; case 4: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); break; case 5: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); break; default: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); break; } } @@ -2014,7 +2014,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_INVOKE_0(_ctx->dc.Show); // Draw the pointer - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); mainShowMouse(); while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index be45aba19f..c408da3f24 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -131,7 +131,7 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { Tony::RMString saveName; byte difficulty; - if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { + if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { // Add the save name to the savegame list saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); } @@ -156,7 +156,7 @@ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int s byte difficulty; byte thumbData[160 * 120 * 2]; - if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { + if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { // Convert the 565 thumbnail data to the needed overlay format Common::MemoryReadStream thumbStream(thumbData, 160 * 120 * 2); Graphics::PixelFormat destFormat = g_system->getOverlayFormat(); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 47cdcb56b5..e0eca3b4e2 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2261,11 +2261,11 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != m_item) { if (m_item == NULL) - ptr.SetSpecialPointer(RMPointer::PTR_NONE); + ptr.setSpecialPointer(RMPointer::PTR_NONE); else { _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) - ptr.SetSpecialPointer(RMPointer::PTR_NONE); + ptr.setSpecialPointer(RMPointer::PTR_NONE); else CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->hThread, CORO_INFINITE); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 5f8f238bff..c729a4e8c0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -125,44 +125,44 @@ void mainSetPalesati(bool bPalesati) { RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { RMResRaw raw(dwRes); assert(raw.IsValid()); - m_buf = new RMGfxSourceBuffer16(false); - m_buf->init(raw, raw.Width(), raw.Height()); + _buf = new RMGfxSourceBuffer16(false); + _buf->init(raw, raw.Width(), raw.Height()); - m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); - m_bActive = false; - m_bHasGfx = true; - m_bDoubleState = bDoubleState; + _rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); + _bActive = false; + _bHasGfx = true; + _bDoubleState = bDoubleState; } RMOptionButton::RMOptionButton(const RMRect &pt) { - m_rect = pt; - m_bActive = false; - m_bHasGfx = false; - m_bDoubleState = false; - m_buf = NULL; + _rect = pt; + _bActive = false; + _bHasGfx = false; + _bDoubleState = false; + _buf = NULL; } RMOptionButton::~RMOptionButton() { - if (m_bHasGfx) - delete m_buf; + if (_bHasGfx) + delete _buf; } -bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { - if (!m_bDoubleState) { - if (m_rect.PtInRect(mousePos)) { - if (!m_bActive) { - m_bActive = true; +bool RMOptionButton::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { + if (!_bDoubleState) { + if (_rect.PtInRect(mousePos)) { + if (!_bActive) { + _bActive = true; return true; } } else { - if (m_bActive) { - m_bActive = false; + if (_bActive) { + _bActive = false; return true; } } } else { - if (bLeftClick && m_rect.PtInRect(mousePos)) { - m_bActive = !m_bActive; + if (bLeftClick && _rect.PtInRect(mousePos)) { + _bActive = !_bActive; return true; } } @@ -176,18 +176,18 @@ void RMOptionButton::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - if (!m_bActive) + if (!_bActive) return; - if (m_bHasGfx) - CORO_INVOKE_2(m_buf->draw, bigBuf, prim); + if (_bHasGfx) + CORO_INVOKE_2(_buf->draw, bigBuf, prim); CORO_END_CODE; } -void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { - if (m_bHasGfx) - bigBuf.addPrim(new RMGfxPrimitive(this, m_rect)); +void RMOptionButton::addToList(RMGfxTargetBuffer &bigBuf) { + if (_bHasGfx) + bigBuf.addPrim(new RMGfxPrimitive(this, _rect)); } /****************************************************************************\ @@ -197,74 +197,74 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int slideSize) { RMResRaw *raw; - m_pos = pt; - m_nSlideSize = slideSize; - m_nMax = nRange; - m_nStep = 100 / m_nMax; - m_nValue = nStartValue; + _pos = pt; + _nSlideSize = slideSize; + _nMax = nRange; + _nStep = 100 / _nMax; + _nValue = nStartValue; - m_SliderCenter = NULL; - m_SliderLeft = NULL; - m_SliderRight = NULL; - m_SliderSingle = NULL; + _SliderCenter = NULL; + _SliderLeft = NULL; + _SliderRight = NULL; + _SliderSingle = NULL; // Sliders - INIT_GFX16_FROMRAW(20029, m_SliderCenter); - INIT_GFX16_FROMRAW(20030, m_SliderLeft); - INIT_GFX16_FROMRAW(20031, m_SliderRight); - INIT_GFX16_FROMRAW(20032, m_SliderSingle); + INIT_GFX16_FROMRAW(20029, _SliderCenter); + INIT_GFX16_FROMRAW(20030, _SliderLeft); + INIT_GFX16_FROMRAW(20031, _SliderRight); + INIT_GFX16_FROMRAW(20032, _SliderSingle); // Buttons - m_PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); - m_PushRight = new RMOptionButton(RMRect(pt.x + m_nSlideSize, pt.y, pt.x + m_nSlideSize + 5 + 22, pt.y + 26)); + _PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); + _PushRight = new RMOptionButton(RMRect(pt.x + _nSlideSize, pt.y, pt.x + _nSlideSize + 5 + 22, pt.y + 26)); } RMOptionSlide::~RMOptionSlide() { - delete m_SliderCenter; - m_SliderCenter = NULL; - delete m_SliderLeft; - m_SliderLeft = NULL; - delete m_SliderRight; - m_SliderRight = NULL; - delete m_SliderSingle; - m_SliderSingle = NULL; - - delete m_PushLeft; - m_PushLeft = NULL; - delete m_PushRight; - m_PushRight = NULL; + delete _SliderCenter; + _SliderCenter = NULL; + delete _SliderLeft; + _SliderLeft = NULL; + delete _SliderRight; + _SliderRight = NULL; + delete _SliderSingle; + _SliderSingle = NULL; + + delete _PushLeft; + _PushLeft = NULL; + delete _PushRight; + _PushRight = NULL; } -bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { +bool RMOptionSlide::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; // Do the button DoFrame's - m_PushLeft->DoFrame(mousePos, bLeftClick, bRightClick); - m_PushRight->DoFrame(mousePos, bLeftClick, bRightClick); + _PushLeft->doFrame(mousePos, bLeftClick, bRightClick); + _PushRight->doFrame(mousePos, bLeftClick, bRightClick); - if (m_PushLeft->IsActive()) { + if (_PushLeft->isActive()) { if (bLeftClick) { bRefresh = true; - m_nValue--; + _nValue--; } else if (bRightClick) { bRefresh = true; - m_nValue -= 3; + _nValue -= 3; } - if (m_nValue < 1) - m_nValue = 1; - } else if (m_PushRight->IsActive()) { + if (_nValue < 1) + _nValue = 1; + } else if (_PushRight->isActive()) { bRefresh = true; if (bLeftClick) { bRefresh = true; - m_nValue++; + _nValue++; } else if (bRightClick) { bRefresh = true; - m_nValue += 3; + _nValue += 3; } - if (m_nValue > m_nMax) - m_nValue = m_nMax; + if (_nValue > _nMax) + _nValue = _nMax; } return bRefresh; @@ -279,37 +279,39 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * CORO_BEGIN_CODE(_ctx); - _ctx->pos = m_pos; + _ctx->pos = _pos; _ctx->pos.x += 4; _ctx->pos.y += 4; - _ctx->val = m_nValue * m_nStep; - if (_ctx->val < 1) _ctx->val = 1; - else if (_ctx->val > 100) _ctx->val = 100; + _ctx->val = _nValue * _nStep; + if (_ctx->val < 1) + _ctx->val = 1; + else if (_ctx->val > 100) + _ctx->val = 100; if (_ctx->val == 1) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderSingle->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderSingle->draw, bigBuf, prim); } else { prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderLeft->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderLeft->draw, bigBuf, prim); _ctx->pos.x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderCenter->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderCenter->draw, bigBuf, prim); _ctx->pos.x += 3; } prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderRight->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderRight->draw, bigBuf, prim); _ctx->pos.x += 3; } CORO_END_CODE; } -void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { +void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } @@ -320,68 +322,68 @@ void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { \****************************************************************************/ RMOptionScreen::RMOptionScreen(void) { - m_nState = MENUNONE; - m_menu = NULL; - m_HideLoadSave = NULL; - m_QuitConfirm = NULL; - m_bQuitConfirm = false; + _nState = MENUNONE; + _menu = NULL; + _HideLoadSave = NULL; + _QuitConfirm = NULL; + _bQuitConfirm = false; Create(RM_SX, RM_SY); - m_ButtonExit = NULL; - m_ButtonLoad = NULL; - m_ButtonSave = NULL; - m_ButtonGameMenu = NULL; - m_ButtonGfxMenu = NULL; - m_ButtonSoundMenu = NULL; - m_ButtonSave_ArrowLeft = NULL; - m_ButtonSave_ArrowRight = NULL; - m_bEditSaveName = false; + _ButtonExit = NULL; + _ButtonLoad = NULL; + _ButtonSave = NULL; + _ButtonGameMenu = NULL; + _ButtonGfxMenu = NULL; + _ButtonSoundMenu = NULL; + _ButtonSave_ArrowLeft = NULL; + _ButtonSave_ArrowRight = NULL; + _bEditSaveName = false; int i; for (i = 0; i < 6; i++) { - m_curThumb[i] = NULL; - m_ButtonSave_States[i] = NULL; + _curThumb[i] = NULL; + _ButtonSave_States[i] = NULL; } - m_statePos = 0; - m_ButtonQuitYes = NULL; - m_ButtonQuitNo = NULL; - m_ButtonQuit = NULL; - m_SaveEasy = NULL; - m_SaveHard = NULL; - m_ButtonGfx_Tips = NULL; - m_ButtonSound_DubbingOn = NULL; - m_ButtonSound_MusicOn = NULL; - m_ButtonSound_SFXOn = NULL; - m_SlideTonySpeed = NULL; - m_SlideTextSpeed = NULL; - m_ButtonGame_Lock = NULL; - m_ButtonGfx_Anni30 = NULL; - m_SliderSound_Music = NULL; - m_ButtonGame_TimerizedText = NULL; - m_ButtonGfx_AntiAlias = NULL; - m_SliderSound_SFX = NULL; - m_ButtonGame_Scrolling = NULL; - m_ButtonGfx_Sottotitoli = NULL; - m_SliderSound_Dubbing = NULL; - m_ButtonGame_InterUp = NULL; - m_ButtonGfx_Trans = NULL; - - m_FadeStep = 0; - m_FadeY = 0; - m_FadeTime = 0; - m_nEditPos = 0; - m_nLastState = MENUGAME; + _statePos = 0; + _ButtonQuitYes = NULL; + _ButtonQuitNo = NULL; + _ButtonQuit = NULL; + _SaveEasy = NULL; + _SaveHard = NULL; + _ButtonGfx_Tips = NULL; + _ButtonSound_DubbingOn = NULL; + _ButtonSound_MusicOn = NULL; + _ButtonSound_SFXOn = NULL; + _SlideTonySpeed = NULL; + _SlideTextSpeed = NULL; + _ButtonGame_Lock = NULL; + _ButtonGfx_Anni30 = NULL; + _SliderSound_Music = NULL; + _ButtonGame_TimerizedText = NULL; + _ButtonGfx_AntiAlias = NULL; + _SliderSound_SFX = NULL; + _ButtonGame_Scrolling = NULL; + _ButtonGfx_Sottotitoli = NULL; + _SliderSound_Dubbing = NULL; + _ButtonGame_InterUp = NULL; + _ButtonGfx_Trans = NULL; + + _FadeStep = 0; + _FadeY = 0; + _FadeTime = 0; + _nEditPos = 0; + _nLastState = MENUGAME; } RMOptionScreen::~RMOptionScreen(void) { - CloseState(); + closeState(); } -void RMOptionScreen::RefreshAll(CORO_PARAM) { +void RMOptionScreen::refreshAll(CORO_PARAM) { CORO_BEGIN_CONTEXT; RMGfxSourceBuffer16 *thumb; RMText *title; @@ -392,54 +394,54 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); clearOT(); - addPrim(new RMGfxPrimitive(m_menu)); + addPrim(new RMGfxPrimitive(_menu)); - if (m_bNoLoadSave) - addPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); + if (_bNoLoadSave) + addPrim(new RMGfxPrimitive(_HideLoadSave, RMPoint(0, 401))); - if (m_bQuitConfirm) { - addPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); - m_ButtonQuitYes->AddToList(*this); - m_ButtonQuitNo->AddToList(*this); + if (_bQuitConfirm) { + addPrim(new RMGfxPrimitive(_QuitConfirm, RMPoint(270, 200))); + _ButtonQuitYes->addToList(*this); + _ButtonQuitNo->addToList(*this); } - m_ButtonExit->AddToList(*this); + _ButtonExit->addToList(*this); - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - m_ButtonQuit->AddToList(*this); - m_ButtonLoad->AddToList(*this); - m_ButtonSave->AddToList(*this); + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + _ButtonQuit->addToList(*this); + _ButtonLoad->addToList(*this); + _ButtonSave->addToList(*this); } - if (m_nState == MENUGAME) { - m_ButtonGame_Lock->AddToList(*this); - m_ButtonGame_TimerizedText->AddToList(*this); - m_ButtonGame_Scrolling->AddToList(*this); - m_ButtonGame_InterUp->AddToList(*this); - m_SlideTextSpeed->AddToList(*this); - m_SlideTonySpeed->AddToList(*this); - } else if (m_nState == MENUGFX) { - m_ButtonGfx_Anni30->AddToList(*this); - m_ButtonGfx_AntiAlias->AddToList(*this); - m_ButtonGfx_Sottotitoli->AddToList(*this); - m_ButtonGfx_Trans->AddToList(*this); - m_ButtonGfx_Tips->AddToList(*this); - } else if (m_nState == MENUSOUND) { - m_SliderSound_Dubbing->AddToList(*this); - m_SliderSound_Music->AddToList(*this); - m_SliderSound_SFX->AddToList(*this); - m_ButtonSound_DubbingOn->AddToList(*this); - m_ButtonSound_MusicOn->AddToList(*this); - m_ButtonSound_SFXOn->AddToList(*this); + if (_nState == MENUGAME) { + _ButtonGame_Lock->addToList(*this); + _ButtonGame_TimerizedText->addToList(*this); + _ButtonGame_Scrolling->addToList(*this); + _ButtonGame_InterUp->addToList(*this); + _SlideTextSpeed->addToList(*this); + _SlideTonySpeed->addToList(*this); + } else if (_nState == MENUGFX) { + _ButtonGfx_Anni30->addToList(*this); + _ButtonGfx_AntiAlias->addToList(*this); + _ButtonGfx_Sottotitoli->addToList(*this); + _ButtonGfx_Trans->addToList(*this); + _ButtonGfx_Tips->addToList(*this); + } else if (_nState == MENUSOUND) { + _SliderSound_Dubbing->addToList(*this); + _SliderSound_Music->addToList(*this); + _SliderSound_SFX->addToList(*this); + _ButtonSound_DubbingOn->addToList(*this); + _ButtonSound_MusicOn->addToList(*this); + _ButtonSound_SFXOn->addToList(*this); } _ctx->thumb = NULL; _ctx->title = NULL; Common::fill(&_ctx->num[0], &_ctx->num[6], (RMText *)NULL); - if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENULOAD || _nState == MENUSAVE) { _ctx->title = new RMText; - if (m_nState == MENULOAD) { + if (_nState == MENULOAD) { RMMessage msg(10); _ctx->title->WriteText(msg[0], 1); } else { @@ -449,72 +451,72 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); - if (m_curThumbDiff[0] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); - else if (m_curThumbDiff[0] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); - if (m_curThumbDiff[1] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); - else if (m_curThumbDiff[1] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); - if (m_curThumbDiff[2] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); - else if (m_curThumbDiff[2] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); - if (m_curThumbDiff[3] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); - else if (m_curThumbDiff[3] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); - if (m_curThumbDiff[4] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); - else if (m_curThumbDiff[4] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); - if (m_curThumbDiff[5] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); - else if (m_curThumbDiff[5] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); - - if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) - addPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); - if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) - addPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); - if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) - addPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); - if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) - addPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); - if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) - addPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); - if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) - addPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); - - if (m_bEditSaveName) { + if (_curThumbDiff[0] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 57))); + else if (_curThumbDiff[0] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 57))); + if (_curThumbDiff[1] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 57))); + else if (_curThumbDiff[1] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 57))); + if (_curThumbDiff[2] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 57))); + else if (_curThumbDiff[2] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 57))); + if (_curThumbDiff[3] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 239))); + else if (_curThumbDiff[3] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 239))); + if (_curThumbDiff[4] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 239))); + else if (_curThumbDiff[4] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 239))); + if (_curThumbDiff[5] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 239))); + else if (_curThumbDiff[5] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 239))); + + if (_curThumb[0] && !(_bEditSaveName && _nEditPos == 0)) + addPrim(new RMGfxPrimitive(_curThumb[0], RMPoint(48, 57))); + if (_curThumb[1] && !(_bEditSaveName && _nEditPos == 1)) + addPrim(new RMGfxPrimitive(_curThumb[1], RMPoint(240, 57))); + if (_curThumb[2] && !(_bEditSaveName && _nEditPos == 2)) + addPrim(new RMGfxPrimitive(_curThumb[2], RMPoint(432, 57))); + if (_curThumb[3] && !(_bEditSaveName && _nEditPos == 3)) + addPrim(new RMGfxPrimitive(_curThumb[3], RMPoint(48, 239))); + if (_curThumb[4] && !(_bEditSaveName && _nEditPos == 4)) + addPrim(new RMGfxPrimitive(_curThumb[4], RMPoint(240, 239))); + if (_curThumb[5] && !(_bEditSaveName && _nEditPos == 5)) + addPrim(new RMGfxPrimitive(_curThumb[5], RMPoint(432, 239))); + + if (_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; _ctx->thumb->init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); - if (m_nEditPos == 0) + if (_nEditPos == 0) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); - else if (m_nEditPos == 1) + else if (_nEditPos == 1) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); - else if (m_nEditPos == 2) + else if (_nEditPos == 2) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); - else if (m_nEditPos == 3) + else if (_nEditPos == 3) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); - else if (m_nEditPos == 4) + else if (_nEditPos == 4) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); - else if (m_nEditPos == 5) + else if (_nEditPos == 5) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - if (m_bEditSaveName && m_nEditPos == _ctx->i) - s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); + if (_bEditSaveName && _nEditPos == _ctx->i) + s.Format("%02d)%s*", _statePos + _ctx->i, _EditName); else { - if (m_statePos == 0 && _ctx->i == 0) + if (_statePos == 0 && _ctx->i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); + s.Format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); } _ctx->num[_ctx->i] = new RMText; @@ -529,13 +531,13 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); addPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); - m_ButtonSave_ArrowLeft->AddToList(*this); - m_ButtonSave_ArrowRight->AddToList(*this); + _ButtonSave_ArrowLeft->addToList(*this); + _ButtonSave_ArrowRight->addToList(*this); } CORO_INVOKE_0(drawOT); - if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENULOAD || _nState == MENUSAVE) { if (_ctx->thumb) delete _ctx->thumb; if (_ctx->title) delete _ctx->title; @@ -546,36 +548,36 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_END_CODE; } -void RMOptionScreen::RefreshThumbnails(void) { +void RMOptionScreen::refreshThumbnails(void) { int i; for (i = 0; i < 6; i++) { - if (m_curThumb[i]) - delete m_curThumb[i]; - - m_curThumb[i] = new RMGfxSourceBuffer16; - m_curThumb[i]->Create(640 / 4, 480 / 4); - if (!LoadThumbnailFromSaveState(m_statePos + i, *m_curThumb[i], m_curThumbName[i], m_curThumbDiff[i])) { - delete m_curThumb[i]; - m_curThumb[i] = NULL; - m_curThumbName[i] = ""; - m_curThumbDiff[i] = 11; + if (_curThumb[i]) + delete _curThumb[i]; + + _curThumb[i] = new RMGfxSourceBuffer16; + _curThumb[i]->Create(640 / 4, 480 / 4); + if (!loadThumbnailFromSaveState(_statePos + i, *_curThumb[i], _curThumbName[i], _curThumbDiff[i])) { + delete _curThumb[i]; + _curThumb[i] = NULL; + _curThumbName[i] = ""; + _curThumbDiff[i] = 11; } } } -void RMOptionScreen::InitState(CORO_PARAM) { +void RMOptionScreen::initState(CORO_PARAM) { CORO_BEGIN_CONTEXT; RMResRaw *raw; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - _ctx->raw = new RMResRaw(20000 + m_nState); - else if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (m_bAlterGfx) + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) + _ctx->raw = new RMResRaw(20000 + _nState); + else if (_nState == MENULOAD || _nState == MENUSAVE) { + if (_bAlterGfx) _ctx->raw = new RMResRaw(20024); else _ctx->raw = new RMResRaw(20003); @@ -584,415 +586,415 @@ void RMOptionScreen::InitState(CORO_PARAM) { } assert(_ctx->raw->IsValid()); - assert(m_menu == NULL); - m_menu = new RMGfxSourceBuffer16(false); - m_menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + assert(_menu == NULL); + _menu = new RMGfxSourceBuffer16(false); + _menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; - if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (m_bAlterGfx) { - assert(m_ButtonExit == NULL); - m_ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); + if (_nState == MENULOAD || _nState == MENUSAVE) { + if (_bAlterGfx) { + assert(_ButtonExit == NULL); + _ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); } else { - assert(m_ButtonExit == NULL); - m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); + assert(_ButtonExit == NULL); + _ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(_ctx->raw, 20036, m_SaveEasy); - INIT_GFX8_FROMRAW(_ctx->raw, 20037, m_SaveHard); - - RefreshThumbnails(); - - assert(m_ButtonSave_States[0] == NULL); - m_ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); - assert(m_ButtonSave_States[1] == NULL); - m_ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); - assert(m_ButtonSave_States[2] == NULL); - m_ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); - assert(m_ButtonSave_States[3] == NULL); - m_ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); - assert(m_ButtonSave_States[4] == NULL); - m_ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); - assert(m_ButtonSave_States[5] == NULL); - m_ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); - - if (m_bAlterGfx) { - assert(m_ButtonSave_ArrowLeft == NULL); - m_ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); - assert(m_ButtonSave_ArrowRight == NULL); - m_ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, _SaveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, _SaveHard); + + refreshThumbnails(); + + assert(_ButtonSave_States[0] == NULL); + _ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); + assert(_ButtonSave_States[1] == NULL); + _ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); + assert(_ButtonSave_States[2] == NULL); + _ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); + assert(_ButtonSave_States[3] == NULL); + _ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); + assert(_ButtonSave_States[4] == NULL); + _ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); + assert(_ButtonSave_States[5] == NULL); + _ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); + + if (_bAlterGfx) { + assert(_ButtonSave_ArrowLeft == NULL); + _ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); + assert(_ButtonSave_ArrowRight == NULL); + _ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); } else { - assert(m_ButtonSave_ArrowLeft == NULL); - m_ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); - assert(m_ButtonSave_ArrowRight == NULL); - m_ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); + assert(_ButtonSave_ArrowLeft == NULL); + _ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); + assert(_ButtonSave_ArrowRight == NULL); + _ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); } - } else if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - assert(m_ButtonExit == NULL); - m_ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); - assert(m_ButtonQuit == NULL); - m_ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); - assert(m_ButtonLoad == NULL); - m_ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); - assert(m_ButtonSave == NULL); - m_ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); - - assert(m_ButtonGameMenu == NULL); - m_ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); - assert(m_ButtonGfxMenu == NULL); - m_ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); - assert(m_ButtonSoundMenu == NULL); - m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); + } else if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + assert(_ButtonExit == NULL); + _ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); + assert(_ButtonQuit == NULL); + _ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); + assert(_ButtonLoad == NULL); + _ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); + assert(_ButtonSave == NULL); + _ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); + + assert(_ButtonGameMenu == NULL); + _ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); + assert(_ButtonGfxMenu == NULL); + _ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); + assert(_ButtonSoundMenu == NULL); + _ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); _ctx->raw = new RMResRaw(20021); assert(_ctx->raw->IsValid()); - assert(m_QuitConfirm == NULL); - m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + assert(_QuitConfirm == NULL); + _QuitConfirm = new RMGfxSourceBuffer16(false); + _QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; - assert(m_ButtonQuitYes == NULL); - m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); - m_ButtonQuitYes->setPriority(30); - assert(m_ButtonQuitNo == NULL); - m_ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); - m_ButtonQuitNo->setPriority(30); + assert(_ButtonQuitYes == NULL); + _ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); + _ButtonQuitYes->setPriority(30); + assert(_ButtonQuitNo == NULL); + _ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); + _ButtonQuitNo->setPriority(30); - if (m_bNoLoadSave) { + if (_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); assert(_ctx->raw->IsValid()); - assert(m_HideLoadSave == NULL); - m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + assert(_HideLoadSave == NULL); + _HideLoadSave = new RMGfxSourceBuffer16(false); + _HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; } // Menu GAME - if (m_nState == MENUGAME) { - assert(m_ButtonGame_Lock == NULL); - m_ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); - m_ButtonGame_Lock->SetActiveState(GLOBALS.bCfgInvLocked); - assert(m_ButtonGame_TimerizedText == NULL); - m_ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); - m_ButtonGame_TimerizedText->SetActiveState(!GLOBALS.bCfgTimerizedText); - assert(m_ButtonGame_Scrolling == NULL); - m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - m_ButtonGame_Scrolling->SetActiveState(GLOBALS.bCfgInvNoScroll); - assert(m_ButtonGame_InterUp == NULL); - m_ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); - m_ButtonGame_InterUp->SetActiveState(GLOBALS.bCfgInvUp); - - assert(m_SlideTextSpeed == NULL); - m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); - assert(m_SlideTonySpeed == NULL); - m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); + if (_nState == MENUGAME) { + assert(_ButtonGame_Lock == NULL); + _ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); + _ButtonGame_Lock->setActiveState(GLOBALS.bCfgInvLocked); + assert(_ButtonGame_TimerizedText == NULL); + _ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); + _ButtonGame_TimerizedText->setActiveState(!GLOBALS.bCfgTimerizedText); + assert(_ButtonGame_Scrolling == NULL); + _ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); + _ButtonGame_Scrolling->setActiveState(GLOBALS.bCfgInvNoScroll); + assert(_ButtonGame_InterUp == NULL); + _ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); + _ButtonGame_InterUp->setActiveState(GLOBALS.bCfgInvUp); + + assert(_SlideTextSpeed == NULL); + _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); + assert(_SlideTonySpeed == NULL); + _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); } // Menu Graphics - else if (m_nState == MENUGFX) { - assert(m_ButtonGfx_Anni30 == NULL); - m_ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); - m_ButtonGfx_Anni30->SetActiveState(GLOBALS.bCfgAnni30); - assert(m_ButtonGfx_AntiAlias == NULL); - m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - m_ButtonGfx_AntiAlias->SetActiveState(!GLOBALS.bCfgAntiAlias); - assert(m_ButtonGfx_Sottotitoli == NULL); - m_ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - m_ButtonGfx_Sottotitoli->SetActiveState(!GLOBALS.bCfgSottotitoli); - assert(m_ButtonGfx_Tips == NULL); - m_ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); - m_ButtonGfx_Tips->SetActiveState(GLOBALS.bCfgInterTips); - assert(m_ButtonGfx_Trans == NULL); - m_ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); - m_ButtonGfx_Trans->SetActiveState(!GLOBALS.bCfgTransparence); - - } else if (m_nState == MENUSOUND) { - assert(m_SliderSound_Dubbing == NULL); - m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); - assert(m_SliderSound_Music == NULL); - m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); - assert(m_SliderSound_SFX == NULL); - m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); - - assert(m_ButtonSound_DubbingOn == NULL); - m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - m_ButtonSound_DubbingOn->SetActiveState(GLOBALS.bCfgDubbing); - assert(m_ButtonSound_MusicOn == NULL); - m_ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); - m_ButtonSound_MusicOn->SetActiveState(GLOBALS.bCfgMusic); - assert(m_ButtonSound_SFXOn == NULL); - m_ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); - m_ButtonSound_SFXOn->SetActiveState(GLOBALS.bCfgSFX); + else if (_nState == MENUGFX) { + assert(_ButtonGfx_Anni30 == NULL); + _ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); + _ButtonGfx_Anni30->setActiveState(GLOBALS.bCfgAnni30); + assert(_ButtonGfx_AntiAlias == NULL); + _ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); + _ButtonGfx_AntiAlias->setActiveState(!GLOBALS.bCfgAntiAlias); + assert(_ButtonGfx_Sottotitoli == NULL); + _ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); + _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS.bCfgSottotitoli); + assert(_ButtonGfx_Tips == NULL); + _ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); + _ButtonGfx_Tips->setActiveState(GLOBALS.bCfgInterTips); + assert(_ButtonGfx_Trans == NULL); + _ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); + _ButtonGfx_Trans->setActiveState(!GLOBALS.bCfgTransparence); + + } else if (_nState == MENUSOUND) { + assert(_SliderSound_Dubbing == NULL); + _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); + assert(_SliderSound_Music == NULL); + _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); + assert(_SliderSound_SFX == NULL); + _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); + + assert(_ButtonSound_DubbingOn == NULL); + _ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); + _ButtonSound_DubbingOn->setActiveState(GLOBALS.bCfgDubbing); + assert(_ButtonSound_MusicOn == NULL); + _ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); + _ButtonSound_MusicOn->setActiveState(GLOBALS.bCfgMusic); + assert(_ButtonSound_SFXOn == NULL); + _ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); + _ButtonSound_SFXOn->setActiveState(GLOBALS.bCfgSFX); } } - CORO_INVOKE_0(RefreshAll); + CORO_INVOKE_0(refreshAll); CORO_END_CODE; } -void RMOptionScreen::CloseState(void) { - delete m_menu; - m_menu = NULL; +void RMOptionScreen::closeState(void) { + delete _menu; + _menu = NULL; - delete m_ButtonExit; - m_ButtonExit = NULL; + delete _ButtonExit; + _ButtonExit = NULL; - if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENULOAD || _nState == MENUSAVE) { int i; for (i = 0; i < 6; i++) { - if (m_curThumb[i] != NULL) { - delete m_curThumb[i]; - m_curThumb[i] = NULL; + if (_curThumb[i] != NULL) { + delete _curThumb[i]; + _curThumb[i] = NULL; } - delete m_ButtonSave_States[i]; - m_ButtonSave_States[i] = NULL; + delete _ButtonSave_States[i]; + _ButtonSave_States[i] = NULL; } - delete m_ButtonSave_ArrowLeft; - m_ButtonSave_ArrowLeft = NULL; - delete m_ButtonSave_ArrowRight; - m_ButtonSave_ArrowRight = NULL; + delete _ButtonSave_ArrowLeft; + _ButtonSave_ArrowLeft = NULL; + delete _ButtonSave_ArrowRight; + _ButtonSave_ArrowRight = NULL; - delete m_SaveEasy; - m_SaveEasy = NULL; - delete m_SaveHard; - m_SaveHard = NULL; + delete _SaveEasy; + _SaveEasy = NULL; + delete _SaveHard; + _SaveHard = NULL; } - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - delete m_ButtonQuit; - m_ButtonQuit = NULL; - delete m_ButtonLoad; - m_ButtonLoad = NULL; - delete m_ButtonSave; - m_ButtonSave = NULL; - delete m_ButtonGameMenu; - m_ButtonGameMenu = NULL; - delete m_ButtonGfxMenu; - m_ButtonGfxMenu = NULL; - delete m_ButtonSoundMenu; - m_ButtonSoundMenu = NULL; - delete m_QuitConfirm; - m_QuitConfirm = NULL; - delete m_ButtonQuitYes; - m_ButtonQuitYes = NULL; - delete m_ButtonQuitNo; - m_ButtonQuitNo = NULL; - - if (m_bNoLoadSave) { - delete m_HideLoadSave; - m_HideLoadSave = NULL; + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + delete _ButtonQuit; + _ButtonQuit = NULL; + delete _ButtonLoad; + _ButtonLoad = NULL; + delete _ButtonSave; + _ButtonSave = NULL; + delete _ButtonGameMenu; + _ButtonGameMenu = NULL; + delete _ButtonGfxMenu; + _ButtonGfxMenu = NULL; + delete _ButtonSoundMenu; + _ButtonSoundMenu = NULL; + delete _QuitConfirm; + _QuitConfirm = NULL; + delete _ButtonQuitYes; + _ButtonQuitYes = NULL; + delete _ButtonQuitNo; + _ButtonQuitNo = NULL; + + if (_bNoLoadSave) { + delete _HideLoadSave; + _HideLoadSave = NULL; } - if (m_nState == MENUGAME) { - GLOBALS.bCfgInvLocked = m_ButtonGame_Lock->IsActive(); - delete m_ButtonGame_Lock; - m_ButtonGame_Lock = NULL; - - GLOBALS.bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); - delete m_ButtonGame_TimerizedText; - m_ButtonGame_TimerizedText = NULL; - - GLOBALS.bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); - delete m_ButtonGame_Scrolling; - m_ButtonGame_Scrolling = NULL; - - GLOBALS.bCfgInvUp = m_ButtonGame_InterUp->IsActive(); - delete m_ButtonGame_InterUp; - m_ButtonGame_InterUp = NULL; - - GLOBALS.nCfgTextSpeed = m_SlideTextSpeed->GetValue(); - delete m_SlideTextSpeed; - m_SlideTextSpeed = NULL; - - GLOBALS.nCfgTonySpeed = m_SlideTonySpeed->GetValue(); - delete m_SlideTonySpeed; - m_SlideTonySpeed = NULL; - } else if (m_nState == MENUGFX) { - GLOBALS.bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); - delete m_ButtonGfx_Anni30; - m_ButtonGfx_Anni30 = NULL; - - GLOBALS.bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); - delete m_ButtonGfx_AntiAlias; - m_ButtonGfx_AntiAlias = NULL; - - GLOBALS.bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); - delete m_ButtonGfx_Sottotitoli; - m_ButtonGfx_Sottotitoli = NULL; - - GLOBALS.bCfgInterTips = m_ButtonGfx_Tips->IsActive(); - delete m_ButtonGfx_Tips; - m_ButtonGfx_Tips = NULL; - - GLOBALS.bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); - delete m_ButtonGfx_Trans; - m_ButtonGfx_Trans = NULL; - } else if (m_nState == MENUSOUND) { - GLOBALS.nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); - delete m_SliderSound_Dubbing; - m_SliderSound_Dubbing = NULL; - - GLOBALS.nCfgMusicVolume = m_SliderSound_Music->GetValue(); - delete m_SliderSound_Music; - m_SliderSound_Music = NULL; - - GLOBALS.nCfgSFXVolume = m_SliderSound_SFX->GetValue(); - delete m_SliderSound_SFX; - m_SliderSound_SFX = NULL; - - GLOBALS.bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); - delete m_ButtonSound_DubbingOn; - m_ButtonSound_DubbingOn = NULL; - - GLOBALS.bCfgMusic = m_ButtonSound_MusicOn->IsActive(); - delete m_ButtonSound_MusicOn; - m_ButtonSound_MusicOn = NULL; - - GLOBALS.bCfgSFX = m_ButtonSound_SFXOn->IsActive(); - delete m_ButtonSound_SFXOn; - m_ButtonSound_SFXOn = NULL; + if (_nState == MENUGAME) { + GLOBALS.bCfgInvLocked = _ButtonGame_Lock->isActive(); + delete _ButtonGame_Lock; + _ButtonGame_Lock = NULL; + + GLOBALS.bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); + delete _ButtonGame_TimerizedText; + _ButtonGame_TimerizedText = NULL; + + GLOBALS.bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); + delete _ButtonGame_Scrolling; + _ButtonGame_Scrolling = NULL; + + GLOBALS.bCfgInvUp = _ButtonGame_InterUp->isActive(); + delete _ButtonGame_InterUp; + _ButtonGame_InterUp = NULL; + + GLOBALS.nCfgTextSpeed = _SlideTextSpeed->getValue(); + delete _SlideTextSpeed; + _SlideTextSpeed = NULL; + + GLOBALS.nCfgTonySpeed = _SlideTonySpeed->getValue(); + delete _SlideTonySpeed; + _SlideTonySpeed = NULL; + } else if (_nState == MENUGFX) { + GLOBALS.bCfgAnni30 = _ButtonGfx_Anni30->isActive(); + delete _ButtonGfx_Anni30; + _ButtonGfx_Anni30 = NULL; + + GLOBALS.bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); + delete _ButtonGfx_AntiAlias; + _ButtonGfx_AntiAlias = NULL; + + GLOBALS.bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); + delete _ButtonGfx_Sottotitoli; + _ButtonGfx_Sottotitoli = NULL; + + GLOBALS.bCfgInterTips = _ButtonGfx_Tips->isActive(); + delete _ButtonGfx_Tips; + _ButtonGfx_Tips = NULL; + + GLOBALS.bCfgTransparence = !_ButtonGfx_Trans->isActive(); + delete _ButtonGfx_Trans; + _ButtonGfx_Trans = NULL; + } else if (_nState == MENUSOUND) { + GLOBALS.nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); + delete _SliderSound_Dubbing; + _SliderSound_Dubbing = NULL; + + GLOBALS.nCfgMusicVolume = _SliderSound_Music->getValue(); + delete _SliderSound_Music; + _SliderSound_Music = NULL; + + GLOBALS.nCfgSFXVolume = _SliderSound_SFX->getValue(); + delete _SliderSound_SFX; + _SliderSound_SFX = NULL; + + GLOBALS.bCfgDubbing = _ButtonSound_DubbingOn->isActive(); + delete _ButtonSound_DubbingOn; + _ButtonSound_DubbingOn = NULL; + + GLOBALS.bCfgMusic = _ButtonSound_MusicOn->isActive(); + delete _ButtonSound_MusicOn; + _ButtonSound_MusicOn = NULL; + + GLOBALS.bCfgSFX = _ButtonSound_SFXOn->isActive(); + delete _ButtonSound_SFXOn; + _ButtonSound_SFXOn = NULL; } } - m_nState = MENUNONE; + _nState = MENUNONE; } -void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { +void RMOptionScreen::reInit(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } -void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { +void RMOptionScreen::init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = false; - m_bNoLoadSave = false; - m_bAlterGfx = false; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = false; + _bNoLoadSave = false; + _bAlterGfx = false; bigBuf.addPrim(new RMGfxPrimitive(this)); - if (m_nState == MENULOAD || m_nState == MENUSAVE) - m_nState = MENUGAME; + if (_nState == MENULOAD || _nState == MENUSAVE) + _nState = MENUGAME; - CORO_INVOKE_0(InitState); + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { +void RMOptionScreen::initLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = true; - m_bNoLoadSave = false; - m_bAlterGfx = bAlternateGfx; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = true; + _bNoLoadSave = false; + _bAlterGfx = bAlternateGfx; bigBuf.addPrim(new RMGfxPrimitive(this)); - m_nState = MENULOAD; - CORO_INVOKE_0(InitState); + _nState = MENULOAD; + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { +void RMOptionScreen::initSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = true; - m_bNoLoadSave = false; - m_bAlterGfx = bAlternateGfx; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = true; + _bNoLoadSave = false; + _bAlterGfx = bAlternateGfx; bigBuf.addPrim(new RMGfxPrimitive(this)); - m_nState = MENUSAVE; - CORO_INVOKE_0(InitState); + _nState = MENUSAVE; + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { +void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = false; - m_bNoLoadSave = true; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = false; + _bNoLoadSave = true; bigBuf.addPrim(new RMGfxPrimitive(this)); - m_nState = MENUGAME; - CORO_INVOKE_0(InitState); + _nState = MENUGAME; + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -bool RMOptionScreen::Close(void) { - if (m_FadeStep != 6) +bool RMOptionScreen::close(void) { + if (_FadeStep != 6) return false; // Start fade out - m_FadeStep++; - m_FadeTime = _vm->getTime(); + _FadeStep++; + _FadeTime = _vm->getTime(); return true; } -bool RMOptionScreen::IsClosing(void) { - return m_bExit; +bool RMOptionScreen::isClosing(void) { + return _bExit; } int RMOptionScreen::priority() { @@ -1000,21 +1002,21 @@ int RMOptionScreen::priority() { return 190; } -void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { +void RMOptionScreen::changeState(CORO_PARAM, STATE newState) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CloseState(); - m_nLastState = m_nState; - m_nState = newState; - CORO_INVOKE_0(InitState); + closeState(); + _nLastState = _nState; + _nState = newState; + CORO_INVOKE_0(initState); CORO_END_CODE; } -void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { +void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { CORO_BEGIN_CONTEXT; bool bLeftClick, bRightClick; RMPoint mousePos; @@ -1026,7 +1028,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // If it is fully open, do nothing - if (m_FadeStep != 6) + if (_FadeStep != 6) return; // Reads input @@ -1036,79 +1038,79 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh = false; - if (m_bQuitConfirm) { - _ctx->bRefresh |= m_ButtonQuitYes->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonQuitNo->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + if (_bQuitConfirm) { + _ctx->bRefresh |= _ButtonQuitYes->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonQuitNo->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else { - _ctx->bRefresh |= m_ButtonExit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonExit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Check if you have clicked on the output - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { // Buttons without graphics... - m_ButtonGameMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - m_ButtonGfxMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - m_ButtonSoundMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonGameMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonGfxMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonSoundMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Buttons with graphics - if (!m_bNoLoadSave) { + if (!_bNoLoadSave) { if (!_vm->getIsDemo()) { - _ctx->bRefresh |= m_ButtonLoad->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSave->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } - _ctx->bRefresh |= m_ButtonQuit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonQuit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } - if (m_nState == MENUGAME) { - _ctx->bRefresh |= m_ButtonGame_Lock->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGame_TimerizedText->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGame_Scrolling->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGame_InterUp->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SlideTextSpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SlideTonySpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - - } else if (m_nState == MENUGFX) { - _ctx->bRefresh |= m_ButtonGfx_Anni30->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_Tips->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_Trans->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - - } else if (m_nState == MENUSOUND) { - _ctx->bRefresh |= m_SliderSound_Dubbing->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SliderSound_Music->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SliderSound_SFX->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSound_DubbingOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSound_MusicOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSound_SFXOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - - } else if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENUGAME) { + _ctx->bRefresh |= _ButtonGame_Lock->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGame_TimerizedText->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGame_Scrolling->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGame_InterUp->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SlideTextSpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SlideTonySpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (_nState == MENUGFX) { + _ctx->bRefresh |= _ButtonGfx_Anni30->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_AntiAlias->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_Sottotitoli->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_Tips->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_Trans->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (_nState == MENUSOUND) { + _ctx->bRefresh |= _SliderSound_Dubbing->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SliderSound_Music->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SliderSound_SFX->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSound_DubbingOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSound_MusicOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSound_SFXOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (_nState == MENULOAD || _nState == MENUSAVE) { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - m_ButtonSave_States[_ctx->i]->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonSave_States[_ctx->i]->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - if (m_statePos > 0) - _ctx->bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - if (m_statePos < 90) - _ctx->bRefresh |= m_ButtonSave_ArrowRight->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + if (_statePos > 0) + _ctx->bRefresh |= _ButtonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + if (_statePos < 90) + _ctx->bRefresh |= _ButtonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } #define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) + 1] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } + _EditName[strlen(_EditName) + 1] = '\0'; _EditName[strlen(_EditName)] = c; _ctx->bRefresh = true; } /**************** State Buttons **************/ - if (m_bEditSaveName) { + if (_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { - if (m_EditName[0] != '\0') { - m_EditName[strlen(m_EditName) - 1] = '\0'; + if (_EditName[0] != '\0') { + _EditName[strlen(_EditName) - 1] = '\0'; _ctx->bRefresh = true; } } - for (_ctx->i = 0; _ctx->i < 26 && strlen(m_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(_EditName) < 12; _ctx->i++) if (KEYPRESS(Common::KEYCODE_LSHIFT) || KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); @@ -1116,85 +1118,87 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } - for (_ctx->i = 0; _ctx->i < 10 && strlen(m_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 10 && strlen(_EditName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_SPACE, ' '); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); // Cancel if (KEYPRESS(Common::KEYCODE_ESCAPE)) { - m_bEditSaveName = false; + _bEditSaveName = false; _ctx->bRefresh = true; } // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { - m_bEditSaveName = false; - _vm->saveState(m_statePos + m_nEditPos, m_EditName); - Close(); + _bEditSaveName = false; + _vm->saveState(_statePos + _nEditPos, _EditName); + close(); } } else if (_ctx->bLeftClick) { - if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (m_ButtonExit->IsActive()) { - if (m_bLoadMenuOnly) { + if (_nState == MENULOAD || _nState == MENUSAVE) { + if (_ButtonExit->isActive()) { + if (_bLoadMenuOnly) { // If only the loading menu, close - Close(); + close(); } else { - CORO_INVOKE_1(ChangeState, m_nLastState); + CORO_INVOKE_1(changeState, _nLastState); _ctx->bRefresh = true; } - } else if (m_ButtonSave_ArrowLeft->IsActive()) { - if (m_statePos > 0) { - m_statePos -= 6; - if (m_statePos < 0) m_statePos = 0; - m_ButtonSave_ArrowLeft->SetActiveState(false); + } else if (_ButtonSave_ArrowLeft->isActive()) { + if (_statePos > 0) { + _statePos -= 6; + if (_statePos < 0) + _statePos = 0; + _ButtonSave_ArrowLeft->setActiveState(false); _ctx->bRefresh = true; - RefreshThumbnails(); + refreshThumbnails(); } - } else if (m_ButtonSave_ArrowRight->IsActive()) { - if (m_statePos < 90) { - m_statePos += 6; - if (m_statePos > 90) m_statePos = 90; - m_ButtonSave_ArrowRight->SetActiveState(false); + } else if (_ButtonSave_ArrowRight->isActive()) { + if (_statePos < 90) { + _statePos += 6; + if (_statePos > 90) + _statePos = 90; + _ButtonSave_ArrowRight->setActiveState(false); _ctx->bRefresh = true; - RefreshThumbnails(); + refreshThumbnails(); } } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (m_ButtonSave_States[_ctx->i]->IsActive()) { + if (_ButtonSave_States[_ctx->i]->isActive()) { // There by saving or loading!!! - if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { + if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { // Caricamento - CORO_INVOKE_1(_vm->loadState, m_statePos + _ctx->i); - Close(); - } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { + CORO_INVOKE_1(_vm->loadState, _statePos + _ctx->i); + close(); + } else if (_nState == MENUSAVE && (_statePos != 0 || _ctx->i != 0)) { // Turn on edit mode - m_bEditSaveName = true; - m_nEditPos = _ctx->i; - strcpy(m_EditName, m_curThumbName[_ctx->i]); + _bEditSaveName = true; + _nEditPos = _ctx->i; + strcpy(_EditName, _curThumbName[_ctx->i]); _ctx->bRefresh = true; } @@ -1203,55 +1207,55 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - if (m_bQuitConfirm) { - if (m_ButtonQuitNo->IsActive()) { - m_bQuitConfirm = false; + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + if (_bQuitConfirm) { + if (_ButtonQuitNo->isActive()) { + _bQuitConfirm = false; _ctx->bRefresh = true; - } else if (m_ButtonQuitYes->IsActive()) { - m_bQuitConfirm = false; + } else if (_ButtonQuitYes->isActive()) { + _bQuitConfirm = false; _ctx->bRefresh = true; _vm->quitGame(); } } else { - if (m_ButtonQuit->IsActive()) { - m_bQuitConfirm = true; - m_ButtonQuitNo->SetActiveState(false); - m_ButtonQuitYes->SetActiveState(false); + if (_ButtonQuit->isActive()) { + _bQuitConfirm = true; + _ButtonQuitNo->setActiveState(false); + _ButtonQuitYes->setActiveState(false); _ctx->bRefresh = true; - } else if (m_ButtonExit->IsActive()) - Close(); - else if (m_ButtonLoad->IsActive()) { - CORO_INVOKE_1(ChangeState, MENULOAD); + } else if (_ButtonExit->isActive()) + close(); + else if (_ButtonLoad->isActive()) { + CORO_INVOKE_1(changeState, MENULOAD); _ctx->bRefresh = true; - } else if (m_ButtonSave->IsActive()) { - CORO_INVOKE_1(ChangeState, MENUSAVE); + } else if (_ButtonSave->isActive()) { + CORO_INVOKE_1(changeState, MENUSAVE); _ctx->bRefresh = true; - } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { - CORO_INVOKE_1(ChangeState, MENUGAME); + } else if (_ButtonGameMenu->isActive() && _nState != MENUGAME) { + CORO_INVOKE_1(changeState, MENUGAME); _ctx->bRefresh = true; - } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { - CORO_INVOKE_1(ChangeState, MENUGFX); + } else if (_ButtonGfxMenu->isActive() && _nState != MENUGFX) { + CORO_INVOKE_1(changeState, MENUGFX); _ctx->bRefresh = true; - } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { - CORO_INVOKE_1(ChangeState, MENUSOUND); + } else if (_ButtonSoundMenu->isActive() && _nState != MENUSOUND) { + CORO_INVOKE_1(changeState, MENUSOUND); _ctx->bRefresh = true; } - if (m_nState == MENUGFX) { + if (_nState == MENUGFX) { // These options take effect immediately - if (m_ButtonGfx_Anni30->IsActive()) + if (_ButtonGfx_Anni30->isActive()) GLOBALS.bCfgAnni30 = true; else GLOBALS.bCfgAnni30 = false; - if (m_ButtonGfx_AntiAlias->IsActive()) + if (_ButtonGfx_AntiAlias->isActive()) GLOBALS.bCfgAntiAlias = false; else GLOBALS.bCfgAntiAlias = true; - if (m_ButtonGfx_Trans->IsActive()) + if (_ButtonGfx_Trans->isActive()) GLOBALS.bCfgTransparence = false; else GLOBALS.bCfgTransparence = true; @@ -1260,12 +1264,12 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - if (!m_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) - Close(); + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) + if (!_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) + close(); if (_ctx->bRefresh) - CORO_INVOKE_0(RefreshAll); + CORO_INVOKE_0(refreshAll); CORO_END_CODE; } @@ -1281,94 +1285,94 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _ctx->curTime = _vm->getTime(); #define FADE_SPEED 20 -#define SYNC (_ctx->curTime-m_FadeTime) / 25 +#define SYNC (_ctx->curTime - _FadeTime) / 25 - if (m_bExit) + if (_bExit) return; - if (m_FadeStep == 1) { + if (_FadeStep == 1) { // Downhill fast - if (m_FadeTime == -1) - m_FadeY += FADE_SPEED; + if (_FadeTime == -1) + _FadeY += FADE_SPEED; else - m_FadeY += FADE_SPEED * SYNC; - if (m_FadeY > 480) { - m_FadeY = 480; - m_FadeStep++; + _FadeY += FADE_SPEED * SYNC; + if (_FadeY > 480) { + _FadeY = 480; + _FadeStep++; } // Set the part to draw the scrolling - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 2) { + } else if (_FadeStep == 2) { // Bounce 1 - m_FadeY -= FADE_SPEED / 2 * SYNC; - if (m_FadeY < 400) { - m_FadeY = 400; - m_FadeStep++; + _FadeY -= FADE_SPEED / 2 * SYNC; + if (_FadeY < 400) { + _FadeY = 400; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 3) { - m_FadeY -= FADE_SPEED / 4 * SYNC; - if (m_FadeY < 380) { - m_FadeY = 380; - m_FadeStep++; + } else if (_FadeStep == 3) { + _FadeY -= FADE_SPEED / 4 * SYNC; + if (_FadeY < 380) { + _FadeY = 380; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 4) { + } else if (_FadeStep == 4) { // Bounce 1 - 2 - m_FadeY += FADE_SPEED / 3 * SYNC; - if (m_FadeY > 420) { - m_FadeY = 420; - m_FadeStep++; + _FadeY += FADE_SPEED / 3 * SYNC; + if (_FadeY > 420) { + _FadeY = 420; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 5) { - m_FadeY += FADE_SPEED / 2 * SYNC; - if (m_FadeY > 480) { - m_FadeY = 480; - m_FadeStep++; + } else if (_FadeStep == 5) { + _FadeY += FADE_SPEED / 2 * SYNC; + if (_FadeY > 480) { + _FadeY = 480; + _FadeStep++; _vm->hideLocation(); } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 6) { + } else if (_FadeStep == 6) { // Menu ON - } else if (m_FadeStep == 7) { + } else if (_FadeStep == 7) { // Menu OFF _vm->showLocation(); - m_FadeStep++; + _FadeStep++; - } else if (m_FadeStep == 8) { - m_FadeY -= FADE_SPEED * SYNC; - if (m_FadeY < 0) { - m_FadeY = 0; - m_FadeStep++; + } else if (_FadeStep == 8) { + _FadeY -= FADE_SPEED * SYNC; + if (_FadeY < 0) { + _FadeY = 0; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 9) { + } else if (_FadeStep == 9) { // Hello hello! - m_bExit = true; - m_FadeStep = 0; + _bExit = true; + _FadeStep = 0; // Free memory - CloseState(); + closeState(); return; } else { - m_FadeStep = 0; + _FadeStep = 0; } - m_FadeTime = _ctx->curTime; + _FadeTime = _ctx->curTime; CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); @@ -1376,14 +1380,14 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } void RMOptionScreen::removeThis(CORO_PARAM, bool &result) { - if (m_bExit) + if (_bExit) result = true; else result = false; } -bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { +bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { Common::String buf; char namebuf[256]; int i; @@ -1466,23 +1470,23 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS \****************************************************************************/ RMPointer::RMPointer() { - Common::fill(m_pointer, m_pointer + 16, (RMGfxSourceBuffer8 *)NULL); - Common::fill(m_specialPointer, m_specialPointer + 16, (RMItem *)NULL); + Common::fill(_pointer, _pointer + 16, (RMGfxSourceBuffer8 *)NULL); + Common::fill(_specialPointer, _specialPointer + 16, (RMItem *)NULL); } RMPointer::~RMPointer() { - Close(); + close(); } -void RMPointer::Init(void) { +void RMPointer::init(void) { int i; for (i = 0; i < 5; i++) { RMResRaw res(RES_P_GO + i); - m_pointer[i] = new RMGfxSourceBuffer8RLEByteAA; - m_pointer[i]->init(res, res.Width(), res.Height(), false); - m_pointer[i]->loadPaletteWA(RES_P_PAL); + _pointer[i] = new RMGfxSourceBuffer8RLEByteAA; + _pointer[i]->init(res, res.Width(), res.Height(), false); + _pointer[i]->loadPaletteWA(RES_P_PAL); } for (i = 0; i < 5; i++) { @@ -1490,34 +1494,34 @@ void RMPointer::Init(void) { RMDataStream ds; ds.OpenBuffer(res); - m_specialPointer[i] = new RMItem; - ds >> *m_specialPointer[i]; + _specialPointer[i] = new RMItem; + ds >> *_specialPointer[i]; } //m_hotspot[0].Set(19,5); - m_hotspot[0].Set(5, 1); - m_hotspot[1].Set(32, 28); - m_hotspot[2].Set(45, 23); - m_hotspot[3].Set(35, 25); - m_hotspot[4].Set(32, 28); + _hotspot[0].Set(5, 1); + _hotspot[1].Set(32, 28); + _hotspot[2].Set(45, 23); + _hotspot[3].Set(35, 25); + _hotspot[4].Set(32, 28); // Default=GO - m_nCurPointer = 0; - m_nCurSpecialPointer = 0; + _nCurPointer = 0; + _nCurSpecialPointer = 0; } -void RMPointer::Close(void) { +void RMPointer::close(void) { int i; for (i = 0; i < 5; i++) { - if (m_pointer[i] != NULL) { - delete m_pointer[i]; - m_pointer[i] = NULL; + if (_pointer[i] != NULL) { + delete _pointer[i]; + _pointer[i] = NULL; } - if (m_specialPointer[i] != NULL) { - delete m_specialPointer[i]; - m_specialPointer[i] = NULL; + if (_specialPointer[i] != NULL) { + delete _specialPointer[i]; + _specialPointer[i] = NULL; } } } @@ -1536,37 +1540,37 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_BEGIN_CODE(_ctx); // Check the pointer - _ctx->n = m_nCurPointer; + _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copy the destination coordinates in the primitive - prim->setDst(m_pos); + prim->setDst(_pos); - if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { + if (_pos.x >= 0 && _pos.y >= 0 && _pos.x < RM_SX && _pos.y < RM_SY) { // Call the Draw method of the poitner - prim->Dst() -= m_hotspot[_ctx->n]; + prim->Dst() -= _hotspot[_ctx->n]; - if (m_nCurSpecialPointer == 0) { - CORO_INVOKE_2(m_pointer[_ctx->n]->draw, bigBuf, prim); + if (_nCurSpecialPointer == 0) { + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); } else { - if (m_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(m_nCurCustomPointer->draw, bigBuf, prim); + if (_nCurSpecialPointer == PTR_CUSTOM) + CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); else // Call the draw on the special pointer - CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->draw, bigBuf, prim); + CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); } } CORO_END_CODE; } -void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { +void RMPointer::doFrame(RMGfxTargetBuffer *bigBuf) { // Add it to the list of primitives bigBuf->addPrim(new RMGfxPrimitive(this)); // If there is a special pointer, does DoFrame - if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) - m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); + if (_nCurSpecialPointer != 0 && _nCurSpecialPointer != PTR_CUSTOM) + _specialPointer[_nCurSpecialPointer - 1]->doFrame(bigBuf, false); } void RMPointer::removeThis(CORO_PARAM, bool &result) { @@ -1574,11 +1578,11 @@ void RMPointer::removeThis(CORO_PARAM, bool &result) { result = true; } -int RMPointer::CurAction(void) { - if (m_nCurSpecialPointer != 0) +int RMPointer::curAction(void) { + if (_nCurSpecialPointer != 0) return 0; - return m_nCurPointer; + return _nCurPointer; } } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index 5dbd81c079..34e99c369e 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -56,16 +56,16 @@ namespace Tony { class RMPointer : public RMGfxTask { private: - RMGfxSourceBuffer8 *m_pointer[16]; - RMPoint m_hotspot[16]; - RMPoint m_pos; + RMGfxSourceBuffer8 *_pointer[16]; + RMPoint _hotspot[16]; + RMPoint _pos; - RMItem *m_specialPointer[16]; + RMItem *_specialPointer[16]; - int m_nCurPointer; - int m_nCurSpecialPointer; + int _nCurPointer; + int _nCurSpecialPointer; - RMGfxSourceBuffer8 *m_nCurCustomPointer; + RMGfxSourceBuffer8 *_nCurCustomPointer; public: enum POINTER { @@ -84,13 +84,13 @@ public: virtual ~RMPointer(); // Initialisation - void Init(void); + void init(void); // Deinitialisation - void Close(void); + void close(void); // Process a frame - void DoFrame(RMGfxTargetBuffer *bigBuf); + void doFrame(RMGfxTargetBuffer *bigBuf); // Overloading of priorities int priority(); @@ -99,153 +99,153 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates - void SetCoord(const RMPoint &pt) { - m_pos = pt; + void setCoord(const RMPoint &pt) { + _pos = pt; } // Overloading of the method to see if rising from the list virtual void removeThis(CORO_PARAM, bool &result); // Sets a new action as current - void SetAction(RMTonyAction action) { - m_nCurPointer = action; + void setAction(RMTonyAction action) { + _nCurPointer = action; } // Sets a new pointer - void SetSpecialPointer(POINTER ptr) { - m_nCurSpecialPointer = ptr; - if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) - m_specialPointer[ptr - 1]->SetPattern(1); + void setSpecialPointer(POINTER ptr) { + _nCurSpecialPointer = ptr; + if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) + _specialPointer[ptr - 1]->SetPattern(1); } - POINTER GetSpecialPointer(void) { - return (POINTER)m_nCurSpecialPointer; + POINTER getSpecialPointer(void) { + return (POINTER)_nCurSpecialPointer; } // Set the new custom pointer - void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { - m_nCurCustomPointer = ptr; + void setCustomPointer(RMGfxSourceBuffer8 *ptr) { + _nCurCustomPointer = ptr; } // Return the current action to be applied according to the pointer - int CurAction(void); + int curAction(void); }; class RMOptionButton: public RMGfxTaskSetPrior { public: - RMRect m_rect; - RMGfxSourceBuffer16 *m_buf; - bool m_bActive; - bool m_bHasGfx; - bool m_bDoubleState; + RMRect _rect; + RMGfxSourceBuffer16 *_buf; + bool _bActive; + bool _bHasGfx; + bool _bDoubleState; public: RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false); RMOptionButton(const RMRect &pt); virtual ~RMOptionButton(); - bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); + bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void AddToList(RMGfxTargetBuffer &bigBuf); - bool IsActive() { - return m_bActive; + void addToList(RMGfxTargetBuffer &bigBuf); + bool isActive() { + return _bActive; } - void SetActiveState(bool bState) { - m_bActive = bState; + void setActiveState(bool bState) { + _bActive = bState; } }; class RMOptionSlide : public RMGfxTaskSetPrior { private: - RMOptionButton *m_PushLeft; - RMOptionButton *m_PushRight; - RMGfxSourceBuffer16 *m_SliderCenter; - RMGfxSourceBuffer16 *m_SliderLeft; - RMGfxSourceBuffer16 *m_SliderRight; - RMGfxSourceBuffer16 *m_SliderSingle; - int m_nSlideSize; - RMPoint m_pos; - int m_nValue; - int m_nMax; - int m_nStep; + RMOptionButton *_PushLeft; + RMOptionButton *_PushRight; + RMGfxSourceBuffer16 *_SliderCenter; + RMGfxSourceBuffer16 *_SliderLeft; + RMGfxSourceBuffer16 *_SliderRight; + RMGfxSourceBuffer16 *_SliderSingle; + int _nSlideSize; + RMPoint _pos; + int _nValue; + int _nMax; + int _nStep; public: RMOptionSlide(const RMPoint &pt, int m_nRange = 100, int m_nStartValue = 0, int slideSize = 300); virtual ~RMOptionSlide(); - bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); + bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void AddToList(RMGfxTargetBuffer &bigBuf); + void addToList(RMGfxTargetBuffer &bigBuf); - int GetValue() { - return m_nValue; + int getValue() { + return _nValue; } }; class RMOptionScreen : public RMGfxWoodyBuffer { private: - RMGfxSourceBuffer16 *m_menu; - RMGfxSourceBuffer16 *m_QuitConfirm; - RMGfxSourceBuffer16 *m_HideLoadSave; - RMOptionButton *m_ButtonQuitYes; - RMOptionButton *m_ButtonQuitNo; - RMOptionButton *m_ButtonExit; - RMOptionButton *m_ButtonQuit; - RMOptionButton *m_ButtonLoad; - RMOptionButton *m_ButtonSave; - RMOptionButton *m_ButtonGameMenu; - RMOptionButton *m_ButtonGfxMenu; - RMOptionButton *m_ButtonSoundMenu; - RMGfxSourceBuffer8 *m_SaveEasy; - RMGfxSourceBuffer8 *m_SaveHard; - RMGfxSourceBuffer16 *m_curThumb[6]; - RMString m_curThumbName[6]; - byte m_curThumbDiff[6]; - RMOptionButton *m_ButtonSave_States[6]; - RMOptionButton *m_ButtonSave_ArrowLeft; - RMOptionButton *m_ButtonSave_ArrowRight; - RMOptionButton *m_ButtonGfx_Tips; - - RMOptionButton *m_ButtonSound_DubbingOn; - RMOptionButton *m_ButtonSound_MusicOn; - RMOptionButton *m_ButtonSound_SFXOn; - - RMOptionSlide *m_SlideTonySpeed; - RMOptionSlide *m_SlideTextSpeed; - - - int m_statePos; - bool m_bEditSaveName; - int m_nEditPos; - char m_EditName[256]; + RMGfxSourceBuffer16 *_menu; + RMGfxSourceBuffer16 *_QuitConfirm; + RMGfxSourceBuffer16 *_HideLoadSave; + RMOptionButton *_ButtonQuitYes; + RMOptionButton *_ButtonQuitNo; + RMOptionButton *_ButtonExit; + RMOptionButton *_ButtonQuit; + RMOptionButton *_ButtonLoad; + RMOptionButton *_ButtonSave; + RMOptionButton *_ButtonGameMenu; + RMOptionButton *_ButtonGfxMenu; + RMOptionButton *_ButtonSoundMenu; + RMGfxSourceBuffer8 *_SaveEasy; + RMGfxSourceBuffer8 *_SaveHard; + RMGfxSourceBuffer16 *_curThumb[6]; + RMString _curThumbName[6]; + byte _curThumbDiff[6]; + RMOptionButton *_ButtonSave_States[6]; + RMOptionButton *_ButtonSave_ArrowLeft; + RMOptionButton *_ButtonSave_ArrowRight; + RMOptionButton *_ButtonGfx_Tips; + + RMOptionButton *_ButtonSound_DubbingOn; + RMOptionButton *_ButtonSound_MusicOn; + RMOptionButton *_ButtonSound_SFXOn; + + RMOptionSlide *_SlideTonySpeed; + RMOptionSlide *_SlideTextSpeed; + + + int _statePos; + bool _bEditSaveName; + int _nEditPos; + char _EditName[256]; union { - RMOptionButton *m_ButtonGame_Lock; - RMOptionButton *m_ButtonGfx_Anni30; - RMOptionSlide *m_SliderSound_Music; + RMOptionButton *_ButtonGame_Lock; + RMOptionButton *_ButtonGfx_Anni30; + RMOptionSlide *_SliderSound_Music; }; union { - RMOptionButton *m_ButtonGame_TimerizedText; - RMOptionButton *m_ButtonGfx_AntiAlias; - RMOptionSlide *m_SliderSound_SFX; + RMOptionButton *_ButtonGame_TimerizedText; + RMOptionButton *_ButtonGfx_AntiAlias; + RMOptionSlide *_SliderSound_SFX; }; union { - RMOptionButton *m_ButtonGame_Scrolling; - RMOptionButton *m_ButtonGfx_Sottotitoli; - RMOptionSlide *m_SliderSound_Dubbing; + RMOptionButton *_ButtonGame_Scrolling; + RMOptionButton *_ButtonGfx_Sottotitoli; + RMOptionSlide *_SliderSound_Dubbing; }; union { - RMOptionButton *m_ButtonGame_InterUp; - RMOptionButton *m_ButtonGfx_Trans; + RMOptionButton *_ButtonGame_InterUp; + RMOptionButton *_ButtonGfx_Trans; }; - int m_FadeStep; - bool m_bExit; - bool m_bQuitConfirm; - int m_FadeY; - int m_FadeTime; - bool m_bLoadMenuOnly; - bool m_bNoLoadSave; - bool m_bAlterGfx; + int _FadeStep; + bool _bExit; + bool _bQuitConfirm; + int _FadeY; + int _FadeTime; + bool _bLoadMenuOnly; + bool _bNoLoadSave; + bool _bAlterGfx; enum STATE { MENUGAME, @@ -256,20 +256,20 @@ private: MENUNONE }; - STATE m_nState; - STATE m_nLastState; + STATE _nState; + STATE _nLastState; public: RMOptionScreen(); virtual ~RMOptionScreen(); - void Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); - void InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); - void InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); - void InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); - void ReInit(RMGfxTargetBuffer &bigBuf); - bool Close(); - bool IsClosing(); + void init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void initLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void initSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void reInit(RMGfxTargetBuffer &bigBuf); + bool close(); + bool isClosing(); // Overloaded methods virtual int priority(); @@ -277,21 +277,21 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Polling for the option screen - void DoFrame(CORO_PARAM, RMInput *m_input); + void doFrame(CORO_PARAM, RMInput *m_input); // Retrieves a savegame's thumbnail, description, and difficulty level - static bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); protected: // Initialisation and state change - void InitState(CORO_PARAM); - void CloseState(void); - void ChangeState(CORO_PARAM, STATE newState); + void initState(CORO_PARAM); + void closeState(void); + void changeState(CORO_PARAM, STATE newState); // Repaint the options menu - void RefreshAll(CORO_PARAM); - void RefreshThumbnails(void); + void refreshAll(CORO_PARAM); + void refreshThumbnails(void); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 2d1c0663a6..ca7e645825 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -98,15 +98,15 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - CORO_INVOKE_2(_opt.Init, _bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.init, _bigBuf, _ctx->bRes); else if (type == 1) - CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, true, _ctx->bRes); + CORO_INVOKE_3(_opt.initLoadMenuOnly, _bigBuf, true, _ctx->bRes); else if (type == 2) - CORO_INVOKE_2(_opt.InitNoLoadSave, _bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.initNoLoadSave, _bigBuf, _ctx->bRes); else if (type == 3) - CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.initLoadMenuOnly, _bigBuf, false, _ctx->bRes); else if (type == 4) - CORO_INVOKE_3(_opt.InitSaveMenuOnly, _bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.initSaveMenuOnly, _bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->pauseSound(true); @@ -115,9 +115,9 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _inv.EndCombine(); _curActionObj = 0; _curAction = TA_GOTO; - _point.SetAction(_curAction); - _point.SetSpecialPointer(RMPointer::PTR_NONE); - _point.SetCustomPointer(NULL); + _point.setAction(_curAction); + _point.setSpecialPointer(RMPointer::PTR_NONE); + _point.setCustomPointer(NULL); enableMouse(); _vm->grabThumbnail(); @@ -155,8 +155,8 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { } if (_bOption) { - CORO_INVOKE_1(_opt.DoFrame, &_input); - _bOption = !_opt.IsClosing(); + CORO_INVOKE_1(_opt.doFrame, &_input); + _bOption = !_opt.isClosing(); if (!_bOption) { disableMouse(); enableInput(); @@ -167,7 +167,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (bDrawLocation && _bLocationLoaded) { // Location and objects - _loc.DoFrame(&_bigBuf); + _loc.doFrame(&_bigBuf); // Check the mouse input if (_bInput && !_tony.InAction()) { @@ -179,7 +179,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Left click activates the combine, if we are on an object if (_inv.LeftClick(_input.mousePos(), _curActionObj)) { _curAction = TA_COMBINE; - _point.SetAction(_curAction); + _point.setAction(_curAction); } } else @@ -200,7 +200,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); _curAction = TA_GOTO; - _point.SetAction(_curAction); + _point.setAction(_curAction); } } } else { @@ -229,17 +229,17 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseLeftClicked() && !_inter.Active()) { if (_curAction != TA_COMBINE) - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.CurAction()); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.curAction()); else if (_itemName.GetSelectedItem() != NULL) CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { _inv.EndCombine(); - _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.setSpecialPointer(RMPointer::PTR_NONE); } _curAction = TA_GOTO; - _point.SetAction(_curAction); + _point.setAction(_curAction); } SKIPCLICKSINISTRO: @@ -251,15 +251,15 @@ SKIPCLICKSINISTRO: _inv.EndCombine(); _curActionObj = 0; _curAction = TA_GOTO; - _point.SetAction(_curAction); - _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.setAction(_curAction); + _point.setSpecialPointer(RMPointer::PTR_NONE); } - } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.GetSpecialPointer() == RMPointer::PTR_NONE) { + } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.getSpecialPointer() == RMPointer::PTR_NONE) { if (_bGUIInterface) { // Before opening the interface, replaces GOTO _curAction = TA_GOTO; _curActionObj = 0; - _point.SetAction(_curAction); + _point.setAction(_curAction); _inter.Clicked(_input.mousePos()); } } @@ -270,11 +270,11 @@ SKIPCLICKSINISTRO: if (_input.mouseRightReleased()) { if (_bGUIInterface) { if (_inter.Released(_input.mousePos(), _curAction)) { - _point.SetAction(_curAction); + _point.setAction(_curAction); CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); _curAction = TA_GOTO; - _point.SetAction(_curAction); + _point.setAction(_curAction); } } } @@ -305,8 +305,8 @@ SKIPCLICKSINISTRO: _tony.SetScrollPosition(_loc.ScrollPosition()); if ((!_tony.InAction() && _bInput) || _bAlwaysDrawMouse) { - _point.SetCoord(_input.mousePos()); - _point.DoFrame(&_bigBuf); + _point.setCoord(_input.mousePos()); + _point.doFrame(&_bigBuf); } // ********************** @@ -393,9 +393,9 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star } _curAction = TA_GOTO; - _point.SetCustomPointer(NULL); - _point.SetSpecialPointer(RMPointer::PTR_NONE); - _point.SetAction(_curAction); + _point.setCustomPointer(NULL); + _point.setSpecialPointer(RMPointer::PTR_NONE); + _point.setAction(_curAction); _inter.Reset(); _inv.Reset(); @@ -425,7 +425,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { error("Location was not loaded"); if (_bOption) - _opt.ReInit(_bigBuf); + _opt.reInit(_bigBuf); _bLocationLoaded = true; @@ -499,7 +499,7 @@ void RMGfxEngine::init() { _input.init(); // Initialise the mouse pointer - _point.Init(); + _point.init(); // Initialise Tony _tony.init(); @@ -524,7 +524,7 @@ void RMGfxEngine::close(void) { _inter.Close(); _inv.Close(); _tony.Close(); - _point.Close(); + _point.close(); _input.close(); } diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index a660ad736e..cd302f8259 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -110,7 +110,7 @@ void RMInventory::Init(void) { m_items[i].pointer = NULL; m_items[i].status = 1; m_items[i].icon.SetPattern(1); - m_items[i].icon.DoFrame(this, false); + m_items[i].icon.doFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; @@ -489,7 +489,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help for (i = 0; i < m_nInv; i++) - if (m_items[m_inv[i]].icon.DoFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) + if (m_items[m_inv[i]].icon.doFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) bNeedRedraw = true; if ((m_state == CLOSING || m_state == OPENING || m_state == OPENED) && CheckPointInside(mpos)) { @@ -518,10 +518,10 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } - if (m_items[28].icon.DoFrame(this, false)) + if (m_items[28].icon.doFrame(this, false)) bNeedRedraw = true; - if (m_items[29].icon.DoFrame(this, false)) + if (m_items[29].icon.doFrame(this, false)) bNeedRedraw = true; if (bNeedRedraw) @@ -535,8 +535,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (m_bCombining) {//m_state == COMBINING) - ptr.SetCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); - ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); + ptr.setCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); + ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } if (!GLOBALS.bCfgInvUp) { @@ -659,7 +659,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } // Update the mini-interface - miniInterface.DoFrame(&bigBuf, false); + miniInterface.doFrame(&bigBuf, false); } if ((m_state != CLOSED) && !_nInList) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 6ede99b57d..ae34c577aa 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -647,7 +647,7 @@ void RMItem::SetScrollPosition(const RMPoint &scroll) { m_curScroll = scroll; } -bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { +bool RMItem::doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { int oldSprite = m_nCurSprite; // Pattern 0 = Do not draw anything! @@ -924,7 +924,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } if (m_bFading) { - m_wip0r.DoFrame(&bigBuf, false); + m_wip0r.doFrame(&bigBuf, false); m_nFadeStep++; @@ -1499,7 +1499,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { g_system->unlockMutex(csMove); // Invoke the DoFrame of the item - RMItem::DoFrame(bigBuf); + RMItem::doFrame(bigBuf); CORO_END_CODE; } @@ -2161,7 +2161,7 @@ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri /** * Prepare a frame, adding the location to the OT list, and all the items that have changed animation frame. */ -void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { +void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) { int i; // If the location is not in the OT list, add it in @@ -2170,7 +2170,7 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { // Process all the location items for (i = 0; i < m_nItems; i++) - m_items[i].DoFrame(bigBuf); + m_items[i].doFrame(bigBuf); } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 282ea0fa4a..abcdcb85a2 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -245,7 +245,7 @@ public: // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame - bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); + bool doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); // Sets the current scrolling position void SetScrollPosition(const RMPoint &scroll); @@ -569,7 +569,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepare a frame by drawing the location and all it's items - void DoFrame(RMGfxTargetBuffer *bigBuf); + void doFrame(RMGfxTargetBuffer *bigBuf); // Return the item at a given point RMItem *WhichItemIsIn(const RMPoint &pt); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index f135cff7c3..8bca6fe7f6 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -156,7 +156,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { } if (m_bIsTalking || m_bIsStaticTalk) - m_body.DoFrame(bigBuf, false); + m_body.doFrame(bigBuf, false); CORO_END_CODE; } -- cgit v1.2.3 From f1ac5d5acdbc0349850377619d8056be22871b42 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 6 Jun 2012 08:04:33 +0200 Subject: TONY: More renaming --- engines/tony/custom.cpp | 170 +++++++++--------- engines/tony/font.cpp | 434 ++++++++++++++++++++++----------------------- engines/tony/font.h | 160 ++++++++--------- engines/tony/game.cpp | 8 +- engines/tony/gfxengine.cpp | 28 +-- engines/tony/inventory.cpp | 65 ++++--- engines/tony/inventory.h | 10 +- engines/tony/tony.cpp | 14 +- engines/tony/window.cpp | 40 ++--- engines/tony/window.h | 30 ++-- 10 files changed, 479 insertions(+), 480 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 24caaa1e29..84bafc2cd1 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -297,32 +297,32 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } if (GLOBALS.curBackText) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); GLOBALS.bTonyIsSpeaking = true; for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(GLOBALS.Input); + _ctx->text.setInput(GLOBALS.Input); // Alignment - _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text.setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text.SetColor(0, 255, 0); + _ctx->text.setColor(0, 255, 0); // Writes the text - _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); + _ctx->text.writeText(_ctx->msg[_ctx->i], 0); // Set the position if (nX == 0 && nY == 0) - _ctx->text.SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); else - _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); // Handling for always display if (GLOBALS.bAlwaysDisplay) { - _ctx->text.SetAlwaysDisplay(); - _ctx->text.ForceTime(); + _ctx->text.setAlwaysDisplay(); + _ctx->text.forceTime(); } // Record the text @@ -331,7 +331,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->Play(); - _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -340,13 +340,13 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); - _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } } // Wait for the end of the display - _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); + _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text.waitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -357,7 +357,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS.bTonyIsSpeaking = false; if (GLOBALS.curBackText) - GLOBALS.curBackText->Show(); + GLOBALS.curBackText->show(); CORO_INVOKE_0(GLOBALS.Tony->EndTalk); @@ -418,36 +418,36 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 GLOBALS.Unfreeze(); for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(GLOBALS.Input); + _ctx->text.setInput(GLOBALS.Input); // Alignment - _ctx->text.SetAlignType(RMText::HCENTER, RMText::VCENTER); + _ctx->text.setAlignType(RMText::HCENTER, RMText::VCENTER); // Forces the text to disappear in time - _ctx->text.ForceTime(); + _ctx->text.forceTime(); // Colour - _ctx->text.SetColor(255, 255, 255); + _ctx->text.setColor(255, 255, 255); // Write the text if (nFont == 0) - _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 1); + _ctx->text.writeText((*_ctx->msg)[_ctx->i], 1); else if (nFont == 1) - _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 0); + _ctx->text.writeText((*_ctx->msg)[_ctx->i], 0); // Set the position - _ctx->text.SetPosition(RMPoint(320, 240)); + _ctx->text.setPosition(RMPoint(320, 240)); - _ctx->text.SetAlwaysDisplay(); - _ctx->text.ForceTime(); + _ctx->text.setAlwaysDisplay(); + _ctx->text.forceTime(); // Record the text GLOBALS.LinkGraphicTask(&_ctx->clear); GLOBALS.LinkGraphicTask(&_ctx->text); // Wait for the end of display - _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); + _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text.waitForEndDisplay); } delete _ctx->msg; @@ -1487,31 +1487,31 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS.Input); // Skipping - _ctx->text->SetSkipStatus(!bIsBack); + _ctx->text->setSkipStatus(!bIsBack); // Alignment - _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->SetColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); + _ctx->text->setColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); // Write the text - _ctx->text->WriteText((*_ctx->msg)[_ctx->i], 0); + _ctx->text->writeText((*_ctx->msg)[_ctx->i], 0); // Set the position - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setPosition(_ctx->pt); // Set the always display if (GLOBALS.bAlwaysDisplay) { - _ctx->text->SetAlwaysDisplay(); - _ctx->text->ForceTime(); + _ctx->text->setAlwaysDisplay(); + _ctx->text->forceTime(); } // Record the text @@ -1524,13 +1524,13 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->SetLoop(false); if (bIsBack) _ctx->voice->SetVolume(55); _ctx->voice->Play(); - _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } // Wait for the end of display - _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); + _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -1700,31 +1700,31 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS.Input); // Skipping - _ctx->text->SetSkipStatus(!bIsBack); + _ctx->text->setSkipStatus(!bIsBack); // Alignment - _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); + _ctx->text->setColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); // Write the text - _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); + _ctx->text->writeText((*_ctx->msg)[_ctx->i], nFont); // Set the position - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setPosition(_ctx->pt); // Set the always display if (GLOBALS.bAlwaysDisplay) { - _ctx->text->SetAlwaysDisplay(); - _ctx->text->ForceTime(); + _ctx->text->setAlwaysDisplay(); + _ctx->text->forceTime(); } // Record the text @@ -1737,13 +1737,13 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice->SetLoop(false); if (bIsBack) _ctx->voice->SetVolume(55); _ctx->voice->Play(); - _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } // Wait for the end of display - _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); + _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -1814,9 +1814,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; - _ctx->text->SetColor(0, 255, 0); - _ctx->text->SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); - _ctx->text->WriteText(_ctx->string, 0); + _ctx->text->setColor(0, 255, 0); + _ctx->text->setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text->writeText(_ctx->string, 0); if (GLOBALS.dwTonyNumTexts > 0) { if (!GLOBALS.bTonyInTexts) { @@ -1849,9 +1849,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); - _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); - _ctx->text->WriteText(_ctx->string, 0); - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); + _ctx->text->writeText(_ctx->string, 0); + _ctx->text->setPosition(_ctx->pt); } else { if (GLOBALS.MCharacter[nPers].x == -1) _ctx->pt = GLOBALS.MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); @@ -1881,35 +1881,35 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (GLOBALS.MCharacter[nPers].bAlwaysBack) { _ctx->text = GLOBALS.curBackText = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; - _ctx->text->SetSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); - _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); - _ctx->text->WriteText(_ctx->string, 0); - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); + _ctx->text->setColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); + _ctx->text->writeText(_ctx->string, 0); + _ctx->text->setPosition(_ctx->pt); } if (!GLOBALS.bSkipIdle) { - _ctx->text->SetInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS.Input); if (GLOBALS.bAlwaysDisplay) { - _ctx->text->SetAlwaysDisplay(); - _ctx->text->ForceTime(); + _ctx->text->setAlwaysDisplay(); + _ctx->text->forceTime(); } - _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { _ctx->voice->Play(); - _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } // Wait for the end of display - _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); + _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text->waitForEndDisplay); } if (_ctx->curVoc) { @@ -1999,39 +1999,39 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Making a choice for dialog _ctx->dc.init(); - _ctx->dc.SetNumChoices(_ctx->num); + _ctx->dc.setNumChoices(_ctx->num); // Writeall the possible options for (_ctx->i = 0; _ctx->i < _ctx->num; _ctx->i++) { _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); - _ctx->dc.AddChoice(_ctx->string); + _ctx->dc.addChoice(_ctx->string); GlobalFree(_ctx->string); } // Activate the object GLOBALS.LinkGraphicTask(&_ctx->dc); - CORO_INVOKE_0(_ctx->dc.Show); + CORO_INVOKE_0(_ctx->dc.show); // Draw the pointer GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); mainShowMouse(); - while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { + while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->mousePos()); + CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS.Input->mousePos()); GLOBALS.Unfreeze(); } // Hide the pointer mainHideMouse(); - CORO_INVOKE_0(_ctx->dc.Hide); + CORO_INVOKE_0(_ctx->dc.hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Closes the choice - _ctx->dc.Close(); + _ctx->dc.close(); GlobalFree(_ctx->sl); @@ -2328,27 +2328,27 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { - _ctx->text[_ctx->i].SetInput(GLOBALS.Input); + _ctx->text[_ctx->i].setInput(GLOBALS.Input); // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { - _ctx->text[_ctx->i].SetAlignType(RMText::HCENTER, RMText::VTOP); - _ctx->text[_ctx->i].WriteText(&(*_ctx->msg)[_ctx->i][1], 3); - _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 + _ctx->text[_ctx->i].setAlignType(RMText::HCENTER, RMText::VTOP); + _ctx->text[_ctx->i].writeText(&(*_ctx->msg)[_ctx->i][1], 3); + _ctx->text[_ctx->i].setPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { - _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT, RMText::VTOP); - _ctx->text[_ctx->i].WriteText((*_ctx->msg)[_ctx->i], 3); - _ctx->text[_ctx->i].SetPosition(RMPoint(260, 70 + _ctx->i * 26)); + _ctx->text[_ctx->i].setAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->text[_ctx->i].writeText((*_ctx->msg)[_ctx->i], 3); + _ctx->text[_ctx->i].setPosition(RMPoint(260, 70 + _ctx->i * 26)); } // Set the position - _ctx->text[_ctx->i].SetAlwaysDisplay(); - _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); - _ctx->text[_ctx->i].SetNoTab(); + _ctx->text[_ctx->i].setAlwaysDisplay(); + _ctx->text[_ctx->i].setForcedTime(dwTime * 1000); + _ctx->text[_ctx->i].setNoTab(); // Wait for the end of display - _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); + _ctx->text[_ctx->i].setCustomSkipHandle(_ctx->hDisable); // Record the text GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index e0eca3b4e2..e967f38199 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -41,11 +41,11 @@ namespace Tony { \****************************************************************************/ RMFont::RMFont() { - m_letter = NULL; + _letter = NULL; } RMFont::~RMFont() { - Unload(); + unload(); } @@ -63,53 +63,53 @@ void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, i } -void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { - m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; +void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { + _letter = new RMGfxSourceBuffer8RLEByte[nChars]; // Initialise the fonts for (int i = 0; i < nChars; i++) { // Initialise the buffer with the letters - m_letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); - m_letter[i].loadPaletteWA(palResID); + _letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); + _letter[i].loadPaletteWA(palResID); } - m_fontDimx = dimx; - m_fontDimy = dimy; + _fontDimx = dimx; + _fontDimy = dimy; nLetters = nChars; } -void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { +void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { RMRes res(resID); if ((int)res.Size() < nChars * (dimy * dimx + 8)) nChars = res.Size() / (dimy * dimx + 8); - Load(res, nChars, dimx, dimy, palResID); + load(res, nChars, dimx, dimy, palResID); } -void RMFont::Unload(void) { - if (m_letter != NULL) { - delete[] m_letter; - m_letter = NULL; +void RMFont::unload(void) { + if (_letter != NULL) { + delete[] _letter; + _letter = NULL; } } -RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { +RMGfxPrimitive *RMFont::makeLetterPrimitive(byte bChar, int &nLength) { RMFontPrimitive *prim; int nLett; // Convert from character to glyph index - nLett = ConvertToLetter(bChar); + nLett = convertToLetter(bChar); assert(nLett < nLetters); // Create primitive font prim = new RMFontPrimitive(this); - prim->m_nChar = nLett; + prim->_nChar = nLett; // Get the length of the character in pixels - nLength = LetterLength(bChar); + nLength = letterLength(bChar); return prim; } @@ -123,29 +123,29 @@ void RMFont::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) CORO_BEGIN_CODE(_ctx); // Call the draw method of the letter assigned to the primitive - if (prim->m_nChar != -1) - CORO_INVOKE_2(m_letter[prim->m_nChar].draw, bigBuf, prim); + if (prim->_nChar != -1) + CORO_INVOKE_2(_letter[prim->_nChar].draw, bigBuf, prim); CORO_END_CODE; } -void RMFont::Close(void) { - Unload(); +void RMFont::close(void) { + unload(); } -int RMFont::StringLen(const RMString &text) { +int RMFont::stringLen(const RMString &text) { int len, i; len = 0; for (i = 0; i < text.Length() - 1; i++) - len += LetterLength(text[i], text[i + 1]); - len += LetterLength(text[i]); + len += letterLength(text[i], text[i + 1]); + len += letterLength(text[i]); return len; } -int RMFont::StringLen(char bChar, char bNext) { - return LetterLength(bChar, bNext); +int RMFont::stringLen(char bChar, char bNext) { + return letterLength(bChar, bNext); } /****************************************************************************\ @@ -197,7 +197,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { // Puts in all the letters for (i = 0; i < nLetters; i++) - m_letter[i].loadPaletteWA(pal); + _letter[i].loadPaletteWA(pal); } @@ -217,7 +217,7 @@ void RMFontParla::init(void) { + 8 // french + 5; // deutsch - Load(RES_F_PARL, nchars, 20, 20); + load(RES_F_PARL, nchars, 20, 20); // Initialise the f**king table lDefault = 13; @@ -625,7 +625,7 @@ void RMFontMacc::init(void) { + 5; // deutsch - Load(RES_F_MACC, nchars, 11, 16); + load(RES_F_MACC, nchars, 11, 16); // Default lDefault = 10; @@ -989,7 +989,7 @@ void RMFontCredits::init(void) { + 2; // deutsch - Load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); + load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); // Default lDefault = 10; @@ -1433,7 +1433,7 @@ void RMFontCredits::init(void) { #define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) #define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) -void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { +void RMFontObj::setBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1454,7 +1454,7 @@ void RMFontObj::init(void) { + 1; // deutsch - Load(RES_F_OBJ, nchars, 25, 30); + load(RES_F_OBJ, nchars, 25, 30); // Initialise the f**king table lDefault = 26; @@ -1569,17 +1569,17 @@ void RMFontObj::init(void) { lTable[(byte)''] = 17; /* Casi particolari */ - SetBothCase('C', 'C', 2); - SetBothCase('A', 'T', -2); - SetBothCase('R', 'S', 2); - SetBothCase('H', 'I', -2); - SetBothCase('T', 'S', 2); - SetBothCase('O', 'R', 2); - SetBothCase('O', 'L', 2); - SetBothCase('O', 'G', 2); - SetBothCase('Z', 'A', -1); - SetBothCase('R', 'R', 1); - SetBothCase('R', 'U', 3); + setBothCase('C', 'C', 2); + setBothCase('A', 'T', -2); + setBothCase('R', 'S', 2); + setBothCase('H', 'I', -2); + setBothCase('T', 'S', 2); + setBothCase('O', 'R', 2); + setBothCase('O', 'L', 2); + setBothCase('O', 'G', 2); + setBothCase('Z', 'A', -1); + setBothCase('R', 'R', 1); + setBothCase('R', 'U', 3); if (_vm->getLanguage() == Common::PL_POL) { // Polish characters @@ -1760,11 +1760,11 @@ void RMFontObj::init(void) { * RMText Methods \****************************************************************************/ -RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; -RMGfxClearTask RMText::m_clear; +RMFontColor *RMText::_fonts[4] = { NULL, NULL, NULL, NULL }; +RMGfxClearTask RMText::_clear; void RMText::initStatics() { - Common::fill(&m_fonts[0], &m_fonts[4], (RMFontColor *)NULL); + Common::fill(&_fonts[0], &_fonts[4], (RMFontColor *)NULL); } RMText::RMText() { @@ -1784,17 +1784,17 @@ RMText::~RMText() { } -void RMText::Unload() { - if (m_fonts[0] != NULL) { - delete m_fonts[0]; - delete m_fonts[1]; - delete m_fonts[2]; - delete m_fonts[3]; - m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0; +void RMText::unload() { + if (_fonts[0] != NULL) { + delete _fonts[0]; + delete _fonts[1]; + delete _fonts[2]; + delete _fonts[3]; + _fonts[0] = _fonts[1] = _fonts[2] = _fonts[3] = 0; } } -void RMText::SetMaxLineLength(int max) { +void RMText::setMaxLineLength(int max) { maxLineLength = max; } @@ -1804,24 +1804,24 @@ void RMText::removeThis(CORO_PARAM, bool &result) { } -void RMText::WriteText(const RMString &text, int nFont, int *time) { +void RMText::writeText(const RMString &text, int nFont, int *time) { // Initialises the font (only once) - if (m_fonts[0] == NULL) { - m_fonts[0] = new RMFontParla; - m_fonts[0]->init(); - m_fonts[1] = new RMFontObj; - m_fonts[1]->init(); - m_fonts[2] = new RMFontMacc; - m_fonts[2]->init(); - m_fonts[3] = new RMFontCredits; - m_fonts[3]->init(); + if (_fonts[0] == NULL) { + _fonts[0] = new RMFontParla; + _fonts[0]->init(); + _fonts[1] = new RMFontObj; + _fonts[1]->init(); + _fonts[2] = new RMFontMacc; + _fonts[2]->init(); + _fonts[3] = new RMFontCredits; + _fonts[3]->init(); } - WriteText(text, m_fonts[nFont], time); + writeText(text, _fonts[nFont], time); } -void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { +void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; char *p, *old_p; int i, j, x, y; @@ -1846,9 +1846,9 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { string = p = text; i = j = x = 0; while (*p != '\0') { - j += font->StringLen(*p); + j += font->stringLen(*p); if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { - j -= font->StringLen(*p, p[1]); + j -= font->stringLen(*p, p[1]); if (j > x) x = j; @@ -1888,7 +1888,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Starting position for the surface: X1, Y width = x; - height = (numlines - 1) * font->LetterHeight() + font->m_fontDimy; + height = (numlines - 1) * font->letterHeight() + font->_fontDimy; // Create the surface Create(width, height); @@ -1902,7 +1902,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { for (; i > 0; i--) { // Measure the length of the line x = 0; - j = font->StringLen(RMString(p)); + j = font->stringLen(RMString(p)); switch (aHorType) { case HLEFT: @@ -1927,30 +1927,30 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { while (*p != '\0') { if (*p == ' ') { - x += font->StringLen(*p); + x += font->stringLen(*p); p++; continue; } - prim = font->MakeLetterPrimitive(*p, len); + prim = font->makeLetterPrimitive(*p, len); prim->Dst().x1 = x; prim->Dst().y1 = y; addPrim(prim); numchar++; - x += font->StringLen(*p, p[1]); + x += font->stringLen(*p, p[1]); p++; } p++; - y += font->LetterHeight(); + y += font->letterHeight(); } if (time != NULL) *time = 1000 + numchar * (11 - GLOBALS.nCfgTextSpeed) * 14; } -void RMText::ClipOnScreen(RMGfxPrimitive *prim) { +void RMText::clipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; @@ -1984,7 +1984,7 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().y1 -= _dimy; } - ClipOnScreen(prim); + clipOnScreen(prim); CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); @@ -1996,18 +1996,18 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { \****************************************************************************/ RMTextDialog::RMTextDialog() : RMText() { - m_startTime = 0; + _startTime = 0; dst = RMPoint(0, 0); - m_bSkipStatus = true; - m_bShowed = true; - m_bForceTime = false; - m_bForceNoTime = false; - m_bAlwaysDisplay = false; - m_bNoTab = false; + _bSkipStatus = true; + _bShowed = true; + _bForceTime = false; + _bForceNoTime = false; + _bAlwaysDisplay = false; + _bNoTab = false; hCustomSkip = CORO_INVALID_PID_VALUE; hCustomSkip2 = CORO_INVALID_PID_VALUE; - m_input = NULL; + _input = NULL; // Create the event for displaying the end hEndDisplay = CoroScheduler.createEvent(false, false); @@ -2017,51 +2017,51 @@ RMTextDialog::~RMTextDialog() { CoroScheduler.closeEvent(hEndDisplay); } -void RMTextDialog::Show(void) { - m_bShowed = true; +void RMTextDialog::show(void) { + _bShowed = true; } -void RMTextDialog::Hide(CORO_PARAM) { - m_bShowed = false; +void RMTextDialog::hide(CORO_PARAM) { + _bShowed = false; } -void RMTextDialog::WriteText(const RMString &text, int font, int *time) { - RMText::WriteText(text, font, &m_time); +void RMTextDialog::writeText(const RMString &text, int font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) - *time = m_time; + *time = _time; } -void RMTextDialog::WriteText(const RMString &text, RMFontColor *font, int *time) { - RMText::WriteText(text, font, &m_time); +void RMTextDialog::writeText(const RMString &text, RMFontColor *font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) - *time = m_time; + *time = _time; } -void RMTextDialog::SetSkipStatus(bool bEnabled) { - m_bSkipStatus = bEnabled; +void RMTextDialog::setSkipStatus(bool bEnabled) { + _bSkipStatus = bEnabled; } -void RMTextDialog::ForceTime(void) { - m_bForceTime = true; +void RMTextDialog::forceTime(void) { + _bForceTime = true; } -void RMTextDialog::ForceNoTime(void) { - m_bForceNoTime = true; +void RMTextDialog::forceNoTime(void) { + _bForceNoTime = true; } -void RMTextDialog::SetNoTab(void) { - m_bNoTab = true; +void RMTextDialog::setNoTab(void) { + _bNoTab = true; } -void RMTextDialog::SetForcedTime(uint32 dwTime) { - m_time = dwTime; +void RMTextDialog::setForcedTime(uint32 dwTime) { + _time = dwTime; } -void RMTextDialog::SetAlwaysDisplay(void) { - m_bAlwaysDisplay = true; +void RMTextDialog::setAlwaysDisplay(void) { + _bAlwaysDisplay = true; } void RMTextDialog::removeThis(CORO_PARAM, bool &result) { @@ -2075,39 +2075,39 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { result = true; // Don't erase the background - if (m_bSkipStatus) { + if (_bSkipStatus) { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { - if (!m_bForceNoTime) { - if (_vm->getTime() > (uint32)m_time + m_startTime) + if (!_bForceNoTime) { + if (_vm->getTime() > (uint32)_time + _startTime) return; } } } - if (!m_bNoTab) { + if (!_bNoTab) { if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } - if (!m_bNoTab) { - if (m_input) { - if (m_input->mouseLeftClicked() || m_input->mouseRightClicked()) + if (!_bNoTab) { + if (_input) { + if (_input->mouseLeftClicked() || _input->mouseRightClicked()) return; } } } // Erase the background else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { - if (!m_bForceNoTime) { - if (_vm->getTime() > (uint32)m_time + m_startTime) + if (!_bForceNoTime) { + if (_vm->getTime() > (uint32)_time + _startTime) return; } } // If time is forced - if (m_bForceTime) { - if (_vm->getTime() > (uint32)m_time + m_startTime) + if (_bForceTime) { + if (_vm->getTime() > (uint32)_time + _startTime) return; } @@ -2142,11 +2142,11 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_BEGIN_CODE(_ctx); - if (m_startTime == 0) - m_startTime = _vm->getTime(); + if (_startTime == 0) + _startTime = _vm->getTime(); - if (m_bShowed) { - if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { + if (_bShowed) { + if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { prim->Dst().TopLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } @@ -2155,20 +2155,20 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_END_CODE; } -void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { +void RMTextDialog::setCustomSkipHandle(uint32 hCustom) { hCustomSkip = hCustom; } -void RMTextDialog::SetCustomSkipHandle2(uint32 hCustom) { +void RMTextDialog::setCustomSkipHandle2(uint32 hCustom) { hCustomSkip2 = hCustom; } -void RMTextDialog::WaitForEndDisplay(CORO_PARAM) { +void RMTextDialog::waitForEndDisplay(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, hEndDisplay, CORO_INFINITE); } -void RMTextDialog::SetInput(RMInput *input) { - m_input = input; +void RMTextDialog::setInput(RMInput *input) { + _input = input; } /****************************************************************************\ @@ -2206,7 +2206,7 @@ void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri CORO_END_CODE; } -void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { +void RMTextDialogScrolling::clipOnScreen(RMGfxPrimitive *prim) { // We must not do anything! } @@ -2216,7 +2216,7 @@ void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { \****************************************************************************/ RMTextItemName::RMTextItemName() : RMText() { - m_item = NULL; + _item = NULL; setPriority(220); } @@ -2224,7 +2224,7 @@ RMTextItemName::~RMTextItemName() { } -void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { +void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { CORO_BEGIN_CONTEXT; RMItem *lastItem; uint32 hThread; @@ -2234,36 +2234,36 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & CORO_BEGIN_CODE(_ctx); - _ctx->lastItem = m_item; + _ctx->lastItem = _item; // Adds to the list if there is need if (!_nInList) bigBuf.addPrim(new RMGfxPrimitive(this)); // Update the scrolling co-ordinates - m_curscroll = loc.ScrollPosition(); + _curscroll = loc.ScrollPosition(); // Check if we are on the inventory - if (inv.ItemInFocus(m_mpos)) - m_item = inv.WhichItemIsIn(m_mpos); + if (inv.ItemInFocus(_mpos)) + _item = inv.WhichItemIsIn(_mpos); else - m_item = loc.WhichItemIsIn(m_mpos); + _item = loc.WhichItemIsIn(_mpos); itemName = ""; // If there an item, get its name - if (m_item != NULL) - m_item->GetName(itemName); + if (_item != NULL) + _item->GetName(itemName); // Write it - WriteText(itemName, 1); + writeText(itemName, 1); // Handle the change If the selected item is different from the previous one - if (_ctx->lastItem != m_item) { - if (m_item == NULL) + if (_ctx->lastItem != _item) { + if (_item == NULL) ptr.setSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, _item->MpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.setSpecialPointer(RMPointer::PTR_NONE); else @@ -2286,30 +2286,30 @@ void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Set the destination coordinates of the mouse - prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); + prim->Dst().TopLeft() = _mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::draw, bigBuf, prim); CORO_END_CODE; } -RMPoint RMTextItemName::GetHotspot() { - if (m_item == NULL) - return m_mpos + m_curscroll; +RMPoint RMTextItemName::getHotspot() { + if (_item == NULL) + return _mpos + _curscroll; else - return m_item->Hotspot(); + return _item->Hotspot(); } -RMItem *RMTextItemName::GetSelectedItem() { - return m_item; +RMItem *RMTextItemName::getSelectedItem() { + return _item; } -bool RMTextItemName::IsItemSelected() { - return m_item != NULL; +bool RMTextItemName::isItemSelected() { + return _item != NULL; } -bool RMTextItemName::IsNormalItemSelected() { - return m_item != NULL && m_itemName.Length() > 0; +bool RMTextItemName::isNormalItemSelected() { + return _item != NULL && _itemName.Length() > 0; } @@ -2345,56 +2345,56 @@ void RMDialogChoice::Unregister(void) { } void RMDialogChoice::init(void) { - m_numChoices = 0; - m_drawedStrings = NULL; - m_ptDrawStrings = NULL; - m_curSelection = -1; + _numChoices = 0; + _drawedStrings = NULL; + _ptDrawStrings = NULL; + _curSelection = -1; Create(640, 477); setPriority(140); } -void RMDialogChoice::Close(void) { - if (m_drawedStrings != NULL) { - delete[] m_drawedStrings; - m_drawedStrings = NULL; +void RMDialogChoice::close(void) { + if (_drawedStrings != NULL) { + delete[] _drawedStrings; + _drawedStrings = NULL; } - if (m_ptDrawStrings != NULL) { - delete[] m_ptDrawStrings; - m_ptDrawStrings = NULL; + if (_ptDrawStrings != NULL) { + delete[] _ptDrawStrings; + _ptDrawStrings = NULL; } destroy(); } -void RMDialogChoice::SetNumChoices(int num) { +void RMDialogChoice::setNumChoices(int num) { int i; - m_numChoices = num; - m_curAdded = 0; + _numChoices = num; + _curAdded = 0; // Allocate space for drawn strings - m_drawedStrings = new RMText[num]; - m_ptDrawStrings = new RMPoint[num]; + _drawedStrings = new RMText[num]; + _ptDrawStrings = new RMPoint[num]; // Initialisation - for (i = 0; i < m_numChoices; i++) { - m_drawedStrings[i].SetColor(0, 255, 0); - m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); - m_drawedStrings[i].SetMaxLineLength(600); - m_drawedStrings[i].setPriority(10); + for (i = 0; i < _numChoices; i++) { + _drawedStrings[i].setColor(0, 255, 0); + _drawedStrings[i].setAlignType(RMText::HLEFTPAR, RMText::VTOP); + _drawedStrings[i].setMaxLineLength(600); + _drawedStrings[i].setPriority(10); } } -void RMDialogChoice::AddChoice(const RMString &string) { +void RMDialogChoice::addChoice(const RMString &string) { // Draw the string - assert(m_curAdded < m_numChoices); - m_drawedStrings[m_curAdded++].WriteText(string, 0); + assert(_curAdded < _numChoices); + _drawedStrings[_curAdded++].writeText(string, 0); } -void RMDialogChoice::Prepare(CORO_PARAM) { +void RMDialogChoice::prepare(CORO_PARAM) { CORO_BEGIN_CONTEXT; int i; RMPoint ptPos; @@ -2410,21 +2410,21 @@ void RMDialogChoice::Prepare(CORO_PARAM) { _ctx->ptPos.Set(20, 90); - for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - addPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); - m_ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].getDimy() + 15); + for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { + addPrim(new RMGfxPrimitive(&_drawedStrings[_ctx->i], _ctx->ptPos)); + _ptDrawStrings[_ctx->i] = _ctx->ptPos; + _ctx->ptPos.Offset(0, _drawedStrings[_ctx->i].getDimy() + 15); } CORO_INVOKE_0(drawOT); clearOT(); - m_ptDrawPos.Set(0, 480 - _ctx->ptPos.y); + _ptDrawPos.Set(0, 480 - _ctx->ptPos.y); CORO_END_CODE; } -void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { +void RMDialogChoice::setSelected(CORO_PARAM, int pos) { CORO_BEGIN_CONTEXT; RMGfxBox box; RMRect rc; @@ -2432,39 +2432,39 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { CORO_BEGIN_CODE(_ctx); - if (pos == m_curSelection) + if (pos == _curSelection) return; _ctx->box.setPriority(5); - if (m_curSelection != -1) { + if (_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); - _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[m_curSelection].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].getDimy()); + _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - addPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); + addPrim(new RMGfxPrimitive(&_drawedStrings[_curSelection], _ptDrawStrings[_curSelection])); CORO_INVOKE_0(drawOT); clearOT(); } if (pos != -1) { _ctx->box.SetColor(100, 100, 100); - _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].getDimy()); + _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - addPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); + addPrim(new RMGfxPrimitive(&_drawedStrings[pos], _ptDrawStrings[pos])); } CORO_INVOKE_0(drawOT); clearOT(); - m_curSelection = pos; + _curSelection = pos; CORO_END_CODE; } -void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { +void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CONTEXT; RMPoint destpt; int deltay; @@ -2474,34 +2474,34 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_0(Prepare); - m_bShow = false; + CORO_INVOKE_0(prepare); + _bShow = false; if (!_nInList && bigBuf != NULL) bigBuf->addPrim(new RMGfxPrimitive(this)); if (0) { - m_bShow = true; + _bShow = true; } else { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - m_ptDrawPos.y; - _ctx->destpt = m_ptDrawPos; - m_ptDrawPos.Set(0, 480); + _ctx->deltay = 480 - _ptDrawPos.y; + _ctx->destpt = _ptDrawPos; + _ptDrawPos.Set(0, 480); if (!_nInList && bigBuf != NULL) bigBuf->addPrim(new RMGfxPrimitive(this)); - m_bShow = true; + _bShow = true; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; + _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; mainUnfreeze(); } - m_ptDrawPos.y = _ctx->destpt.y; + _ptDrawPos.y = _ctx->destpt.y; } CORO_END_CODE; @@ -2513,17 +2513,17 @@ void RMDialogChoice::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - if (m_bShow == false) + if (_bShow == false) return; - prim->setDst(m_ptDrawPos); + prim->setDst(_ptDrawPos); CORO_INVOKE_2(RMGfxSourceBuffer16::draw, bigBuf, prim); CORO_END_CODE; } -void RMDialogChoice::Hide(CORO_PARAM) { +void RMDialogChoice::hide(CORO_PARAM) { CORO_BEGIN_CONTEXT; int deltay; int starttime; @@ -2535,18 +2535,18 @@ void RMDialogChoice::Hide(CORO_PARAM) { if (1) { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - m_ptDrawPos.y; + _ctx->deltay = 480 - _ptDrawPos.y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; + _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; mainUnfreeze(); } } - m_bShow = false; + _bShow = false; bRemoveFromOT = true; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hUnreg, CORO_INFINITE); @@ -2558,30 +2558,30 @@ void RMDialogChoice::removeThis(CORO_PARAM, bool &result) { result = bRemoveFromOT; } -void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { +void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_BEGIN_CONTEXT; int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (ptMousePos.y > m_ptDrawPos.y) { - for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].getDimy())) { - CORO_INVOKE_1(SetSelected, _ctx->i); + if (ptMousePos.y > _ptDrawPos.y) { + for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { + if ((ptMousePos.y >= _ptDrawPos.y + _ptDrawStrings[_ctx->i].y) && (ptMousePos.y < _ptDrawPos.y + _ptDrawStrings[_ctx->i].y + _drawedStrings[_ctx->i].getDimy())) { + CORO_INVOKE_1(setSelected, _ctx->i); break; } } - if (_ctx->i == m_numChoices) - CORO_INVOKE_1(SetSelected, -1); + if (_ctx->i == _numChoices) + CORO_INVOKE_1(setSelected, -1); } CORO_END_CODE; } -int RMDialogChoice::GetSelection(void) { - return m_curSelection; +int RMDialogChoice::getSelection(void) { + return _curSelection; } } // End of namespace Tony diff --git a/engines/tony/font.h b/engines/tony/font.h index 752f142cf1..d39b9752a7 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -48,12 +48,12 @@ class RMPointer; class RMFont : public RMGfxTaskSetPrior { protected: int nLetters; - RMGfxSourceBuffer8RLEByte *m_letter; + RMGfxSourceBuffer8RLEByte *_letter; public: - int m_fontDimx, m_fontDimy; + int _fontDimx, _fontDimy; private: - int m_dimx, m_dimy; + int _dimx, _dimy; class RMFontPrimitive : public RMGfxPrimitive { public: @@ -64,26 +64,26 @@ private: return new RMFontPrimitive(*this); } - int m_nChar; + int _nChar; }; protected: // Loads the font - void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); // Remove the font - void Unload(void); + void unload(void); protected: // Conversion form character to font index - virtual int ConvertToLetter(byte nChar) = 0; + virtual int convertToLetter(byte nChar) = 0; // Character width - virtual int LetterLength(int nChar, int nNext = 0) = 0; + virtual int letterLength(int nChar, int nNext = 0) = 0; public: - virtual int LetterHeight(void) = 0; + virtual int letterHeight(void) = 0; public: RMFont(); @@ -91,17 +91,17 @@ public: // Initialisation and closing virtual void init(void) = 0; - virtual void Close(void); + virtual void close(void); // Drawing virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Create a primitive for a letter - RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); + RMGfxPrimitive *makeLetterPrimitive(byte bChar, int &nLength); // Length in pixels of a string with the current font - int StringLen(const RMString &text); - int StringLen(char bChar, char bNext = 0); + int stringLen(const RMString &text); + int stringLen(char bChar, char bNext = 0); }; @@ -126,15 +126,15 @@ protected: protected: // Overloaded methods - int ConvertToLetter(byte nChar) { + int convertToLetter(byte nChar) { return cTable[nChar]; } - int LetterLength(int nChar, int nNext = 0) { + int letterLength(int nChar, int nNext = 0) { return (nChar != -1 ? lTable[(byte)nChar] + l2Table[(byte)nChar][(byte)nNext] : lDefault); } public: - int LetterHeight() { + int letterHeight() { return hDefault; } virtual ~RMFontWithTables() {} @@ -149,7 +149,7 @@ public: class RMFontObj : public RMFontColor, public RMFontWithTables { private: - void SetBothCase(int nChar, int nNext, signed char spiazz); + void setBothCase(int nChar, int nNext, signed char spiazz); public: void init(void); @@ -166,7 +166,7 @@ class RMFontCredits : public RMFontColor, public RMFontWithTables { public: void init(void); virtual ~RMFontCredits() {} - virtual void SetBaseColor(byte r, byte g, byte b) {} + virtual void setBaseColor(byte r, byte g, byte b) {} }; /** @@ -174,8 +174,8 @@ public: */ class RMText : public RMGfxWoodyBuffer { private: - static RMFontColor *m_fonts[4]; - static RMGfxClearTask m_clear; + static RMFontColor *_fonts[4]; + static RMGfxClearTask _clear; int maxLineLength; public: @@ -198,26 +198,26 @@ private: byte m_r, m_g, m_b; protected: - virtual void ClipOnScreen(RMGfxPrimitive *prim); + virtual void clipOnScreen(RMGfxPrimitive *prim); public: RMText(); virtual ~RMText(); static void initStatics(); - static void Unload(); + static void unload(); // Set the alignment type - void SetAlignType(HORALIGN aHor, VERALIGN aVer) { + void setAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType = aHor; aVerType = aVer; } // Sets the maximum length of a line in pixels (used to format the text) - void SetMaxLineLength(int max); + void setMaxLineLength(int max); // Write the text - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const RMString &text, int font, int *time = NULL); + void writeText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); @@ -226,7 +226,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the base colour - void SetColor(byte r, byte g, byte b) { + void setColor(byte r, byte g, byte b) { m_r = r; m_g = g; m_b = b; @@ -238,27 +238,27 @@ public: */ class RMTextDialog : public RMText { protected: - int m_startTime; - int m_time; - bool m_bSkipStatus; + int _startTime; + int _time; + bool _bSkipStatus; RMPoint dst; uint32 hEndDisplay; - bool m_bShowed; - bool m_bForceTime; - bool m_bForceNoTime; + bool _bShowed; + bool _bForceTime; + bool _bForceNoTime; uint32 hCustomSkip; uint32 hCustomSkip2; - RMInput *m_input; - bool m_bAlwaysDisplay; - bool m_bNoTab; + RMInput *_input; + bool _bAlwaysDisplay; + bool _bNoTab; public: RMTextDialog(); virtual ~RMTextDialog(); // Write the text - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const RMString &text, int font, int *time = NULL); + void writeText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); @@ -270,26 +270,26 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the position - void SetPosition(const RMPoint &pt) { + void setPosition(const RMPoint &pt) { dst = pt; } // Waiting - void WaitForEndDisplay(CORO_PARAM); - void SetCustomSkipHandle(uint32 hCustomSkip); - void SetCustomSkipHandle2(uint32 hCustomSkip); - void SetSkipStatus(bool bEnabled); - void SetForcedTime(uint32 dwTime); - void SetNoTab(void); - void ForceTime(void); - void ForceNoTime(void); - void SetAlwaysDisplay(void); + void waitForEndDisplay(CORO_PARAM); + void setCustomSkipHandle(uint32 hCustomSkip); + void setCustomSkipHandle2(uint32 hCustomSkip); + void setSkipStatus(bool bEnabled); + void setForcedTime(uint32 dwTime); + void setNoTab(void); + void forceTime(void); + void forceNoTime(void); + void setAlwaysDisplay(void); // Set the input device, to allow skip from mouse - void SetInput(RMInput *input); + void setInput(RMInput *input); - void Show(void); - void Hide(CORO_PARAM); + void show(void); + void hide(CORO_PARAM); }; class RMTextDialogScrolling : public RMTextDialog { @@ -297,7 +297,7 @@ protected: RMLocation *curLoc; RMPoint startScroll; - virtual void ClipOnScreen(RMGfxPrimitive *prim); + virtual void clipOnScreen(RMGfxPrimitive *prim); public: RMTextDialogScrolling(); @@ -313,26 +313,26 @@ public: */ class RMTextItemName : protected RMText { protected: - RMPoint m_mpos; - RMPoint m_curscroll; - RMItem *m_item; - RMString m_itemName; + RMPoint _mpos; + RMPoint _curscroll; + RMItem *_item; + RMString _itemName; public: RMTextItemName(); virtual ~RMTextItemName(); - void SetMouseCoord(const RMPoint &m) { - m_mpos = m; + void setMouseCoord(const RMPoint &m) { + _mpos = m; } - void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + void doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - RMPoint GetHotspot(); - RMItem *GetSelectedItem(); - bool IsItemSelected(); - bool IsNormalItemSelected(); + RMPoint getHotspot(); + RMItem *getSelectedItem(); + bool isItemSelected(); + bool isNormalItemSelected(); virtual void removeThis(CORO_PARAM, bool &result) { result = true; @@ -345,21 +345,21 @@ public: */ class RMDialogChoice : public RMGfxWoodyBuffer { private: - int m_curSelection; - int m_numChoices; - RMText *m_drawedStrings; - RMPoint *m_ptDrawStrings; - int m_curAdded; - bool m_bShow; + int _curSelection; + int _numChoices; + RMText *_drawedStrings; + RMPoint *_ptDrawStrings; + int _curAdded; + bool _bShow; RMGfxSourceBuffer8 DlgText; RMGfxSourceBuffer8 DlgTextLine; - RMPoint m_ptDrawPos; + RMPoint _ptDrawPos; uint32 hUnreg; bool bRemoveFromOT; protected: - void Prepare(CORO_PARAM); - void SetSelected(CORO_PARAM, int pos); + void prepare(CORO_PARAM); + void setSelected(CORO_PARAM, int pos); public: virtual void removeThis(CORO_PARAM, bool &result); @@ -373,25 +373,25 @@ public: // Initialisation and closure void init(void); - void Close(void); + void close(void); // Sets the number of possible sentences, which then be added with AddChoice() - void SetNumChoices(int num); + void setNumChoices(int num); // Adds a string with the choice - void AddChoice(const RMString &string); + void addChoice(const RMString &string); // Show and hide the selection, with possible animations. // NOTE: If no parameter is passed to Show(), it is the obligation of // caller to ensure that the class is inserted into OT list - void Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); - void Hide(CORO_PARAM); + void show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); + void hide(CORO_PARAM); // Polling Update - void DoFrame(CORO_PARAM, RMPoint ptMousePos); + void doFrame(CORO_PARAM, RMPoint ptMousePos); // Returns the currently selected item, or -1 if none is selected - int GetSelection(void); + int getSelection(void); }; } // End of namespace Tony diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c729a4e8c0..bf708ec075 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -443,10 +443,10 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { _ctx->title = new RMText; if (_nState == MENULOAD) { RMMessage msg(10); - _ctx->title->WriteText(msg[0], 1); + _ctx->title->writeText(msg[0], 1); } else { RMMessage msg(11); - _ctx->title->WriteText(msg[0], 1); + _ctx->title->writeText(msg[0], 1); } addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); @@ -520,8 +520,8 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { } _ctx->num[_ctx->i] = new RMText; - _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); - _ctx->num[_ctx->i]->WriteText(s, 2); + _ctx->num[_ctx->i]->setAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->num[_ctx->i]->writeText(s, 2); } addPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index ca7e645825..08976e6092 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -186,7 +186,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Right Click // *********** if (_input.mouseRightClicked()) { - if (_itemName.IsItemSelected()) { + if (_itemName.isItemSelected()) { _curActionObj = 0; _inv.RightClick(_input.mousePos()); } else @@ -197,7 +197,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // ************* if (_input.mouseRightReleased()) { if (_inv.RightRelease(_input.mousePos(), _curAction)) { - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -229,9 +229,9 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseLeftClicked() && !_inter.Active()) { if (_curAction != TA_COMBINE) - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.curAction()); - else if (_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), TA_COMBINE, _curActionObj); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); + else if (_itemName.getSelectedItem() != NULL) + CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { _inv.EndCombine(); @@ -254,7 +254,7 @@ SKIPCLICKSINISTRO: _point.setAction(_curAction); _point.setSpecialPointer(RMPointer::PTR_NONE); } - } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.getSpecialPointer() == RMPointer::PTR_NONE) { + } else if (_input.mouseRightClicked() && _itemName.isItemSelected() && _point.getSpecialPointer() == RMPointer::PTR_NONE) { if (_bGUIInterface) { // Before opening the interface, replaces GOTO _curAction = TA_GOTO; @@ -271,7 +271,7 @@ SKIPCLICKSINISTRO: if (_bGUIInterface) { if (_inter.Released(_input.mousePos(), _curAction)) { _point.setAction(_curAction); - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -281,14 +281,14 @@ SKIPCLICKSINISTRO: } // Update the name under the mouse pointer - _itemName.SetMouseCoord(_input.mousePos()); + _itemName.setMouseCoord(_input.mousePos()); if (!_inter.Active() && !_inv.MiniActive()) - CORO_INVOKE_4(_itemName.DoFrame, _bigBuf, _loc, _point, _inv); + CORO_INVOKE_4(_itemName.doFrame, _bigBuf, _loc, _point, _inv); } // Interface & Inventory _inter.DoFrame(_bigBuf, _input.mousePos()); - _inv.DoFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); + _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); } // Animate Tony @@ -397,7 +397,7 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star _point.setSpecialPointer(RMPointer::PTR_NONE); _point.setAction(_curAction); _inter.Reset(); - _inv.Reset(); + _inv.reset(); mpalStartIdlePoll(_nCurLoc); } @@ -472,7 +472,7 @@ void RMGfxEngine::init() { _bigBuf.drawOT(Common::nullContext); _bigBuf.clearOT(); delete load; - _vm->_window.GetNewFrame(*this, NULL); + _vm->_window.getNewFrame(*this, NULL); GLOBALS.bPatIrqFreeze = true; @@ -506,7 +506,7 @@ void RMGfxEngine::init() { _tony.LinkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface - _inv.Init(); + _inv.init(); _inter.Init(); // Download the location and set priorities @@@@@ @@ -522,7 +522,7 @@ void RMGfxEngine::close(void) { _bigBuf.clearOT(); _inter.Close(); - _inv.Close(); + _inv.close(); _tony.Close(); _point.close(); _input.close(); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index cd302f8259..360e53803e 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -60,7 +60,7 @@ RMInventory::RMInventory() { } RMInventory::~RMInventory() { - Close(); + close(); g_system->deleteMutex(m_csModifyInterface); } @@ -72,8 +72,7 @@ bool RMInventory::CheckPointInside(const RMPoint &pt) { } - -void RMInventory::Init(void) { +void RMInventory::init(void) { int i, j; int curres; @@ -140,27 +139,27 @@ void RMInventory::Init(void) { ds.Close(); // Create the text for hints on the mini interface - m_hints[0].SetAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[1].SetAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[2].SetAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[1].setAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[2].setAlignType(RMText::HCENTER, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); // Examine - m_hints[1].WriteText(msg2[0], 1); // Take - m_hints[2].WriteText(msg3[0], 1); // Use + m_hints[0].writeText(msg1[0], 1); // Examine + m_hints[1].writeText(msg2[0], 1); // Take + m_hints[2].writeText(msg3[0], 1); // Use // Prepare initial inventory - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); } -void RMInventory::Close(void) { +void RMInventory::close(void) { // Has memory if (m_items != NULL) { // Delete the item pointers @@ -175,7 +174,7 @@ void RMInventory::Close(void) { destroy(); } -void RMInventory::Reset(void) { +void RMInventory::reset(void) { m_state = CLOSED; EndCombine(); } @@ -248,7 +247,7 @@ void RMInventory::RemoveItem(int code) { Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); m_nInv--; - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -269,7 +268,7 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++] = code - 10000; - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -284,7 +283,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].icon.SetPattern(dwStatus); m_items[code - 10000].status = dwStatus; - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -292,7 +291,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { } -void RMInventory::Prepare(void) { +void RMInventory::prepare(void) { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { @@ -363,7 +362,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { m_items[29].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -384,7 +383,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { m_items[28].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -429,7 +428,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { m_items[29].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -449,7 +448,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { m_items[28].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -477,7 +476,7 @@ bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction &curAction) { #define INVSPEED 20 -void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { +void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { int i; bool bNeedRedraw = false; @@ -525,7 +524,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bNeedRedraw = true; if (bNeedRedraw) - Prepare(); + prepare(); g_system->unlockMutex(m_csModifyInterface); } @@ -743,7 +742,7 @@ int RMInventory::LoadState(byte *state) { else m_items[28].icon.SetPattern(1); - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); @@ -908,11 +907,11 @@ void RMInterface::Init(void) { m_hotbbox[3].SetRect(56, 51, 93, 99); m_hotbbox[4].SetRect(51, 105, 82, 172); - m_hints[0].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[1].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[2].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[3].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[4].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[2].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[3].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[4].setAlignType(RMText::HRIGHT, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg0(12); @@ -921,11 +920,11 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); // Take - m_hints[1].WriteText(msg1[0], 1); // Talk - m_hints[2].WriteText(msg2[0], 1); // Use - m_hints[3].WriteText(msg3[0], 1); // Examine - m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_hints[0].writeText(msg0[0], 1); // Take + m_hints[1].writeText(msg1[0], 1); // Talk + m_hints[2].writeText(msg2[0], 1); // Use + m_hints[3].writeText(msg3[0], 1); // Examine + m_hints[4].writeText(msg4[0], 1); // Show Yourself m_bActive = false; m_bPalesati = false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 9ed250592d..3548317dcc 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -80,7 +80,7 @@ protected: protected: // Prepare the image inventory. It should be recalled whenever the inventory changes - void Prepare(void); + void prepare(void); // Check if the mouse Y position is conrrect, even under the inventory portion of the screen bool CheckPointInside(const RMPoint &pt); @@ -90,12 +90,12 @@ public: virtual ~RMInventory(); // Prepare a frame - void DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); + void doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); // Initialisation and closing - void Init(void); - void Close(void); - void Reset(void); + void init(void); + void close(void); + void reset(void); // Overload test for removal from OT list virtual void removeThis(CORO_PARAM, bool &result); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index cc323eb5d2..ea378e0fc3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -477,7 +477,7 @@ void TonyEngine::closeVoiceDatabase() { } void TonyEngine::grabThumbnail(void) { - _window.GrabThumbnail(_curThumbnail); + _window.grabThumbnail(_curThumbnail); } void TonyEngine::optionScreen(void) { @@ -533,13 +533,13 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // Handle drawing the frame if (!_vm->_bPaused) { if (!_vm->_theEngine._bWiping) - _vm->_window.GetNewFrame(_vm->_theEngine, NULL); + _vm->_window.getNewFrame(_vm->_theEngine, NULL); else - _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); + _vm->_window.getNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); } // Paint the frame onto the screen - _vm->_window.Repaint(); + _vm->_window.repaint(); // Signal the ScummVM debugger _vm->_debugger->onFrame(); @@ -570,12 +570,12 @@ void TonyEngine::close(void) { CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.Close(); _theEngine.close(); - _window.Close(); + _window.close(); delete[] _curThumbnail; } void TonyEngine::switchFullscreen(bool bFull) { - _window.SwitchFullscreen(bFull); + _window.switchFullscreen(bFull); _theEngine.switchFullscreen(bFull); } @@ -617,7 +617,7 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { return Common::kUnknownError; RMSnapshot s; - s.GrabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); + s.grabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); GLOBALS.GfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 5d73443167..cfa9d088e3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -44,8 +44,8 @@ RMWindow::RMWindow() { } RMWindow::~RMWindow() { - Close(); - RMText::Unload(); + close(); + RMText::unload(); } /** @@ -58,40 +58,40 @@ void RMWindow::init() { // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; - m_bGrabScreenshot = false; - m_bGrabThumbnail = false; - m_bGrabMovie = false; + _bGrabScreenshot = false; + _bGrabThumbnail = false; + _bGrabMovie = false; } /** * Close the window */ -void RMWindow::Close(void) { +void RMWindow::close(void) { } -void RMWindow::GrabThumbnail(uint16 *thumbmem) { - m_bGrabThumbnail = true; - m_wThumbBuf = thumbmem; +void RMWindow::grabThumbnail(uint16 *thumbmem) { + _bGrabThumbnail = true; + _wThumbBuf = thumbmem; } /** * Repaint the screen */ -void RMWindow::Repaint(void) { +void RMWindow::repaint(void) { g_system->updateScreen(); } -bool RMWindow::Lock() { +bool RMWindow::lock() { return true; } -void RMWindow::Unlock() { +void RMWindow::unlock() { } /** * Wipes an area of the screen */ -void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { +void RMWindow::wipeEffect(Common::Rect &rcBoundEllipse) { if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { // Full screen clear wanted, so use shortcut method @@ -108,28 +108,28 @@ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { } } -void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { +void RMWindow::getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { if (rcBoundEllipse != NULL) { // Circular wipe effect - GetNewFrameWipe(lpBuf, *rcBoundEllipse); + getNewFrameWipe(lpBuf, *rcBoundEllipse); } else { // Standard screen copy g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); } - if (m_bGrabThumbnail) { + if (_bGrabThumbnail) { // Need to generate a thumbnail RMSnapshot s; - s.GrabScreenshot(lpBuf, 4, m_wThumbBuf); - m_bGrabThumbnail = false; + s.grabScreenshot(lpBuf, 4, _wThumbBuf); + _bGrabThumbnail = false; } } /** * Copies a section of the game frame in a circle bounded by the specified rectangle */ -void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { +void RMWindow::getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { // Clear the screen g_system->fillScreen(0); @@ -208,7 +208,7 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; -void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { +void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; int dimx = RM_SX / dezoom; diff --git a/engines/tony/window.h b/engines/tony/window.h index 70e74eb54d..3d1199482f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -45,14 +45,14 @@ private: static byte rgb[RM_SX *RM_SY * 3]; public: // Take a screenshot - void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); + void grabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); }; class RMWindow { private: - bool Lock(); - void Unlock(); + bool lock(); + void unlock(); void plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y); void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); @@ -65,14 +65,14 @@ protected: int mskRed, mskGreen, mskBlue; - bool m_bGrabScreenshot; - bool m_bGrabThumbnail; - bool m_bGrabMovie; - uint16 *m_wThumbBuf; + bool _bGrabScreenshot; + bool _bGrabThumbnail; + bool _bGrabMovie; + uint16 *_wThumbBuf; - void CreateBWPrecalcTable(void); - void WipeEffect(Common::Rect &rcBoundEllipse); - void GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); + void createBWPrecalcTable(void); + void wipeEffect(Common::Rect &rcBoundEllipse); + void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); public: RMWindow(); @@ -81,19 +81,19 @@ public: // Initialisation void init(/*HINSTANCE hInst*/); void initDirectDraw(void); - void Close(void); + void close(void); // Drawing - void Repaint(void); + void repaint(void); // Switch between windowed and fullscreen - void SwitchFullscreen(bool bFull) {} + void switchFullscreen(bool bFull) {} // Reads the next frame - void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + void getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); // Request a thumbnail be grabbed during the next frame - void GrabThumbnail(uint16 *buf); + void grabThumbnail(uint16 *buf); int getFps() const { return fps; -- cgit v1.2.3 From 53e38106b73e6ad9e6f725857483bfd35e961326 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 6 Jun 2012 08:31:06 +0200 Subject: TONY: Rename variables and functions in inventory.h That fixes the regression in the credits --- engines/tony/custom.cpp | 6 +- engines/tony/font.cpp | 9 +- engines/tony/font.h | 4 +- engines/tony/gfxengine.cpp | 46 ++-- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 639 +++++++++++++++++++++++---------------------- engines/tony/inventory.h | 104 ++++---- 7 files changed, 407 insertions(+), 403 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 84bafc2cd1..2725f2565e 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1559,15 +1559,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->AddItem(dwCode); + GLOBALS.Inventory->addItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->RemoveItem(dwCode); + GLOBALS.Inventory->removeItem(dwCode); } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - GLOBALS.Inventory->ChangeItemStatus(dwCode, dwStatus); + GLOBALS.Inventory->changeItemStatus(dwCode, dwStatus); } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index e967f38199..bc32939061 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -157,10 +157,9 @@ RMFontColor::RMFontColor() : RMFont() { } RMFontColor::~RMFontColor() { - } -void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { +void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { int r = (int)r1 << 16; int g = (int)g1 << 16; int b = (int)b1 << 16; @@ -1832,7 +1831,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { int numlines; // Set the base colour - font->SetBaseColor(m_r, m_g, m_b); + font->setBaseColor(m_r, m_g, m_b); // Destroy the buffer before starting destroy(); @@ -2244,8 +2243,8 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _curscroll = loc.ScrollPosition(); // Check if we are on the inventory - if (inv.ItemInFocus(_mpos)) - _item = inv.WhichItemIsIn(_mpos); + if (inv.itemInFocus(_mpos)) + _item = inv.whichItemIsIn(_mpos); else _item = loc.WhichItemIsIn(_mpos); diff --git a/engines/tony/font.h b/engines/tony/font.h index d39b9752a7..2e2b1724a9 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -60,7 +60,7 @@ private: RMFontPrimitive() : RMGfxPrimitive() {} RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} virtual ~RMFontPrimitive() { } - virtual RMGfxPrimitive *Duplicate() { + virtual RMGfxPrimitive *duplicate() { return new RMFontPrimitive(*this); } @@ -112,7 +112,7 @@ private: public: RMFontColor(); virtual ~RMFontColor(); - virtual void SetBaseColor(byte r, byte g, byte b); + virtual void setBaseColor(byte r, byte g, byte b); }; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 08976e6092..a80552b1d1 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -112,7 +112,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _vm->pauseSound(true); disableInput(); - _inv.EndCombine(); + _inv.endCombine(); _curActionObj = 0; _curAction = TA_GOTO; _point.setAction(_curAction); @@ -172,12 +172,12 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Check the mouse input if (_bInput && !_tony.InAction()) { // If we are on the inventory, it is it who controls all input - if (_inv.HaveFocus(_input.mousePos()) && !_inter.Active()) { + if (_inv.haveFocus(_input.mousePos()) && !_inter.active()) { // Left Click // ********** if (_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click activates the combine, if we are on an object - if (_inv.LeftClick(_input.mousePos(), _curActionObj)) { + if (_inv.leftClick(_input.mousePos(), _curActionObj)) { _curAction = TA_COMBINE; _point.setAction(_curAction); } @@ -188,15 +188,15 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseRightClicked()) { if (_itemName.isItemSelected()) { _curActionObj = 0; - _inv.RightClick(_input.mousePos()); + _inv.rightClick(_input.mousePos()); } else - _inv.RightClick(_input.mousePos()); + _inv.rightClick(_input.mousePos()); } else // Right Release // ************* if (_input.mouseRightReleased()) { - if (_inv.RightRelease(_input.mousePos(), _curAction)) { + if (_inv.rightRelease(_input.mousePos(), _curAction)) { CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; @@ -226,7 +226,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Left Click // ************** - if (_input.mouseLeftClicked() && !_inter.Active()) { + if (_input.mouseLeftClicked() && !_inter.active()) { if (_curAction != TA_COMBINE) CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); @@ -234,7 +234,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { - _inv.EndCombine(); + _inv.endCombine(); _point.setSpecialPointer(RMPointer::PTR_NONE); } @@ -248,7 +248,7 @@ SKIPCLICKSINISTRO: if (_curAction == TA_COMBINE) { // During a combine, it cancels it if (_input.mouseRightClicked()) { - _inv.EndCombine(); + _inv.endCombine(); _curActionObj = 0; _curAction = TA_GOTO; _point.setAction(_curAction); @@ -260,7 +260,7 @@ SKIPCLICKSINISTRO: _curAction = TA_GOTO; _curActionObj = 0; _point.setAction(_curAction); - _inter.Clicked(_input.mousePos()); + _inter.clicked(_input.mousePos()); } } @@ -269,7 +269,7 @@ SKIPCLICKSINISTRO: // ************* if (_input.mouseRightReleased()) { if (_bGUIInterface) { - if (_inter.Released(_input.mousePos(), _curAction)) { + if (_inter.released(_input.mousePos(), _curAction)) { _point.setAction(_curAction); CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); @@ -282,13 +282,13 @@ SKIPCLICKSINISTRO: // Update the name under the mouse pointer _itemName.setMouseCoord(_input.mousePos()); - if (!_inter.Active() && !_inv.MiniActive()) + if (!_inter.active() && !_inv.miniActive()) CORO_INVOKE_4(_itemName.doFrame, _bigBuf, _loc, _point, _inv); } // Interface & Inventory - _inter.DoFrame(_bigBuf, _input.mousePos()); - _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); + _inter.doFrame(_bigBuf, _input.mousePos()); + _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.active() && _bGUIInventory)); } // Animate Tony @@ -396,7 +396,7 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star _point.setCustomPointer(NULL); _point.setSpecialPointer(RMPointer::PTR_NONE); _point.setAction(_curAction); - _inter.Reset(); + _inter.reset(); _inv.reset(); mpalStartIdlePoll(_nCurLoc); @@ -507,7 +507,7 @@ void RMGfxEngine::init() { // Initialise the inventory and the interface _inv.init(); - _inter.Init(); + _inter.init(); // Download the location and set priorities @@@@@ _bLocationLoaded = false; @@ -521,7 +521,7 @@ void RMGfxEngine::init() { void RMGfxEngine::close(void) { _bigBuf.clearOT(); - _inter.Close(); + _inter.close(); _inv.close(); _tony.Close(); _point.close(); @@ -540,7 +540,7 @@ void RMGfxEngine::enableInput(void) { void RMGfxEngine::disableInput(void) { _bInput = false; - _inter.Reset(); + _inter.reset(); } void RMGfxEngine::enableMouse(void) { @@ -619,9 +619,9 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // Inventory - size = _inv.GetSaveStateSize(); + size = _inv.getSaveStateSize(); state = new byte[size]; - _inv.SaveState(state); + _inv.saveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -640,7 +640,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm // Saves the state of the shepherdess and show yourself bStat = _tony.GetPastorella(); f->writeByte(bStat); - bStat = _inter.GetPalesati(); + bStat = _inter.getPalesati(); f->writeByte(bStat); // Save the chars @@ -758,7 +758,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - _inv.LoadState(_ctx->state); + _inv.loadState(_ctx->state); delete[] _ctx->state; if (_ctx->ver >= 0x2) { // Versione 2: box please @@ -776,7 +776,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bStat = _ctx->f->readByte(); _tony.SetPastorella(bStat); bStat = _ctx->f->readByte(); - _inter.SetPalesati(bStat); + _inter.setPalesati(bStat); CharsLoadAll(_ctx->f); } diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 69d36cbbc0..8d9648c454 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -145,7 +145,7 @@ public: void waitWipeEnd(CORO_PARAM); void setPalesati(bool bpal) { - _inter.SetPalesati(bpal); + _inter.setPalesati(bpal); } bool canLoadSave(); }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 360e53803e..595a1ba0f2 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -40,31 +40,31 @@ namespace Tony { \****************************************************************************/ RMInventory::RMInventory() { - m_items = NULL; - m_state = CLOSED; - m_bCombining = false; - m_csModifyInterface = g_system->createMutex(); - m_nItems = 0; - - Common::fill(m_inv, m_inv + 256, 0); - m_nInv = 0; - m_curPutY = 0; - m_curPutTime = 0; - m_curPos = 0; - m_bHasFocus = false; - m_nSelectObj = 0; - m_nCombine = 0; - m_bBlinkingRight = false; - m_bBlinkingLeft = false; + _items = NULL; + _state = CLOSED; + _bCombining = false; + _csModifyInterface = g_system->createMutex(); + _nItems = 0; + + Common::fill(_inv, _inv + 256, 0); + _nInv = 0; + _curPutY = 0; + _curPutTime = 0; + _curPos = 0; + _bHasFocus = false; + _nSelectObj = 0; + _nCombine = 0; + _bBlinkingRight = false; + _bBlinkingLeft = false; miniAction = 0; } RMInventory::~RMInventory() { close(); - g_system->deleteMutex(m_csModifyInterface); + g_system->deleteMutex(_csModifyInterface); } -bool RMInventory::CheckPointInside(const RMPoint &pt) { +bool RMInventory::checkPointInside(const RMPoint &pt) { if (!GLOBALS.bCfgInvUp) return pt.y > RM_SY - 70; else @@ -81,18 +81,18 @@ void RMInventory::init(void) { setPriority(185); // Setup the inventory - m_nInv = 0; - m_curPos = 0; - m_bCombining = false; + _nInv = 0; + _curPos = 0; + _bCombining = false; // New items - m_nItems = 78; // @@@ Number of takeable items - m_items = new RMInventoryItem[m_nItems + 1]; + _nItems = 78; // @@@ Number of takeable items + _items = new RMInventoryItem[_nItems + 1]; curres = 10500; // Loop through the items - for (i = 0; i <= m_nItems; i++) { + for (i = 0; i <= _nItems; i++) { // Load the items from the resource RMRes res(curres); RMDataStream ds; @@ -100,34 +100,35 @@ void RMInventory::init(void) { assert(res.IsValid()); // Initialise the MPAL inventory item by reading it in. - m_items[i].icon.SetInitCurPattern(false); + _items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); - ds >> m_items[i].icon; + ds >> _items[i].icon; ds.Close(); // Puts in the default pattern 1 - m_items[i].pointer = NULL; - m_items[i].status = 1; - m_items[i].icon.SetPattern(1); - m_items[i].icon.doFrame(this, false); + _items[i].pointer = NULL; + _items[i].status = 1; + _items[i].icon.SetPattern(1); + _items[i].icon.doFrame(this, false); curres++; - if (i == 0 || i == 28 || i == 29) continue; + if (i == 0 || i == 28 || i == 29) + continue; - m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; + _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.NumPattern()]; - for (j = 0; j < m_items[i].icon.NumPattern(); j++) { + for (j = 0; j < _items[i].icon.NumPattern(); j++) { RMResRaw raw(curres); assert(raw.IsValid()); - m_items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); + _items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); curres++; } } - m_items[28].icon.SetPattern(1); - m_items[29].icon.SetPattern(1); + _items[28].icon.SetPattern(1); + _items[29].icon.SetPattern(1); // Download interface RMDataStream ds; @@ -139,18 +140,18 @@ void RMInventory::init(void) { ds.Close(); // Create the text for hints on the mini interface - m_hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[1].setAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[2].setAlignType(RMText::HCENTER, RMText::VTOP); + _hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); + _hints[1].setAlignType(RMText::HCENTER, RMText::VTOP); + _hints[2].setAlignType(RMText::HCENTER, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].writeText(msg1[0], 1); // Examine - m_hints[1].writeText(msg2[0], 1); // Take - m_hints[2].writeText(msg3[0], 1); // Use + _hints[0].writeText(msg1[0], 1); // Examine + _hints[1].writeText(msg2[0], 1); // Take + _hints[2].writeText(msg3[0], 1); // Use // Prepare initial inventory @@ -161,22 +162,22 @@ void RMInventory::init(void) { void RMInventory::close(void) { // Has memory - if (m_items != NULL) { + if (_items != NULL) { // Delete the item pointers - for (int i = 0; i <= m_nItems; i++) - delete[] m_items[i].pointer; + for (int i = 0; i <= _nItems; i++) + delete[] _items[i].pointer; // Delete the items array - delete[] m_items; - m_items = NULL; + delete[] _items; + _items = NULL; } destroy(); } void RMInventory::reset(void) { - m_state = CLOSED; - EndCombine(); + _state = CLOSED; + endCombine(); } void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -189,23 +190,23 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - if (m_state == OPENING || m_state == CLOSING) - prim->setDst(RMPoint(0, m_curPutY)); + if (_state == OPENING || _state == CLOSING) + prim->setDst(RMPoint(0, _curPutY)); else - prim->setDst(RMPoint(0, m_curPutY)); + prim->setDst(RMPoint(0, _curPutY)); - g_system->lockMutex(m_csModifyInterface); + g_system->lockMutex(_csModifyInterface); CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); - if (m_state == SELECTING) { + if (_state == SELECTING) { if (!GLOBALS.bCfgInvUp) { - _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, RM_SY - 113); - _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, RM_SY - 150); + _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); + _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( - _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); + _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( + _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, 119 - 4); } _ctx->p = new RMGfxPrimitive(prim->_task, _ctx->pos); @@ -216,11 +217,11 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (GLOBALS.bCfgInterTips) { if (miniAction == 1) // Examine - CORO_INVOKE_2(m_hints[0].draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(_hints[0].draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Talk - CORO_INVOKE_2(m_hints[1].draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(_hints[1].draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Use - CORO_INVOKE_2(m_hints[2].draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(_hints[2].draw, bigBuf, _ctx->p2); } delete _ctx->p; @@ -231,62 +232,62 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr } void RMInventory::removeThis(CORO_PARAM, bool &result) { - if (m_state == CLOSED) + if (_state == CLOSED) result = true; else result = false; } -void RMInventory::RemoveItem(int code) { +void RMInventory::removeItem(int code) { int i; - for (i = 0; i < m_nInv; i++) - if (m_inv[i] == code - 10000) { - g_system->lockMutex(m_csModifyInterface); + for (i = 0; i < _nInv; i++) + if (_inv[i] == code - 10000) { + g_system->lockMutex(_csModifyInterface); - Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); - m_nInv--; + Common::copy(&_inv[i + 1], &_inv[i + 1] + (_nInv - i), &_inv[i]); + _nInv--; prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); return; } } -void RMInventory::AddItem(int code) { +void RMInventory::addItem(int code) { if (code <= 10000 && code >= 10101) { // If we are here, it means that we are adding an item that should not be in the inventory warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { - g_system->lockMutex(m_csModifyInterface); - if (m_curPos + 8 == m_nInv) { + g_system->lockMutex(_csModifyInterface); + if (_curPos + 8 == _nInv) { // Break through the inventory! On the flashing pattern - m_items[28].icon.SetPattern(2); + _items[28].icon.SetPattern(2); } - m_inv[m_nInv++] = code - 10000; + _inv[_nInv++] = code - 10000; prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } } -void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { +void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { if (code <= 10000 && code >= 10101) { error("Specified object code is not valid"); } else { - g_system->lockMutex(m_csModifyInterface); - m_items[code - 10000].icon.SetPattern(dwStatus); - m_items[code - 10000].status = dwStatus; + g_system->lockMutex(_csModifyInterface); + _items[code - 10000].icon.SetPattern(dwStatus); + _items[code - 10000].status = dwStatus; prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } } @@ -295,52 +296,52 @@ void RMInventory::prepare(void) { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { - if (i - 1 + m_curPos < m_nInv) - addPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); + if (i - 1 + _curPos < _nInv) + addPrim(new RMGfxPrimitive(&_items[_inv[i - 1 + _curPos]].icon, RMPoint(i * 64, 0))); else - addPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&_items[0].icon, RMPoint(i * 64, 0))); } // Frecce - addPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); - addPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); + addPrim(new RMGfxPrimitive(&_items[29].icon, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&_items[28].icon, RMPoint(640 - 64, 0))); } -bool RMInventory::MiniActive(void) { - return m_state == SELECTING; +bool RMInventory::miniActive(void) { + return _state == SELECTING; } -bool RMInventory::HaveFocus(const RMPoint &mpos) { +bool RMInventory::haveFocus(const RMPoint &mpos) { // When we combine, have the focus only if we are on an arrow (to scroll) - if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) + if (_state == OPENED && _bCombining && checkPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) return true; // If the inventory is open, focus we we go over it - if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) + if (_state == OPENED && !_bCombining && checkPointInside(mpos)) return true; // If we are selecting a verb (and then right down), we always focus - if (m_state == SELECTING) + if (_state == SELECTING) return true; return false; } -void RMInventory::EndCombine(void) { - m_bCombining = false; +void RMInventory::endCombine(void) { + _bCombining = false; } -bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { +bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { int n; // The left click picks an item from your inventory to use it with the background n = mpos.x / 64; - if (m_state == OPENED) { - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { - m_bCombining = true; //m_state = COMBINING; - m_nCombine = m_inv[n - 1 + m_curPos]; - nCombineObj = m_nCombine + 10000; + if (_state == OPENED) { + if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { + _bCombining = true; //m_state = COMBINING; + _nCombine = _inv[n - 1 + _curPos]; + nCombineObj = _nCombine + 10000; _vm->playUtilSFX(1); return true; @@ -348,116 +349,116 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } // Click the right arrow - if ((m_state == OPENED) && m_bBlinkingRight) { - g_system->lockMutex(m_csModifyInterface); - m_curPos++; + if ((_state == OPENED) && _bBlinkingRight) { + g_system->lockMutex(_csModifyInterface); + _curPos++; - if (m_curPos + 8 >= m_nInv) { - m_bBlinkingRight = false; - m_items[28].icon.SetPattern(1); + if (_curPos + 8 >= _nInv) { + _bBlinkingRight = false; + _items[28].icon.SetPattern(1); } - if (m_curPos > 0) { - m_bBlinkingLeft = true; - m_items[29].icon.SetPattern(2); + if (_curPos > 0) { + _bBlinkingLeft = true; + _items[29].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } // Click the left arrow - else if ((m_state == OPENED) && m_bBlinkingLeft) { - assert(m_curPos > 0); - g_system->lockMutex(m_csModifyInterface); - m_curPos--; - - if (m_curPos == 0) { - m_bBlinkingLeft = false; - m_items[29].icon.SetPattern(1); + else if ((_state == OPENED) && _bBlinkingLeft) { + assert(_curPos > 0); + g_system->lockMutex(_csModifyInterface); + _curPos--; + + if (_curPos == 0) { + _bBlinkingLeft = false; + _items[29].icon.SetPattern(1); } - if (m_curPos + 8 < m_nInv) { - m_bBlinkingRight = true; - m_items[28].icon.SetPattern(2); + if (_curPos + 8 < _nInv) { + _bBlinkingRight = true; + _items[28].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } return false; } - -void RMInventory::RightClick(const RMPoint &mpos) { +void RMInventory::rightClick(const RMPoint &mpos) { int n; - assert(CheckPointInside(mpos)); + assert(checkPointInside(mpos)); - if (m_state == OPENED && !m_bCombining) { + if (_state == OPENED && !_bCombining) { // Open the context interface n = mpos.x / 64; - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { - m_state = SELECTING; + if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { + _state = SELECTING; miniAction = 0; - m_nSelectObj = n - 1; + _nSelectObj = n - 1; _vm->playUtilSFX(0); } } - if ((m_state == OPENED) && m_bBlinkingRight) { - g_system->lockMutex(m_csModifyInterface); - m_curPos += 7; - if (m_curPos + 8 > m_nInv) - m_curPos = m_nInv - 8; + if ((_state == OPENED) && _bBlinkingRight) { + g_system->lockMutex(_csModifyInterface); + _curPos += 7; + if (_curPos + 8 > _nInv) + _curPos = _nInv - 8; - if (m_curPos + 8 <= m_nInv) { - m_bBlinkingRight = false; - m_items[28].icon.SetPattern(1); + if (_curPos + 8 <= _nInv) { + _bBlinkingRight = false; + _items[28].icon.SetPattern(1); } - if (m_curPos > 0) { - m_bBlinkingLeft = true; - m_items[29].icon.SetPattern(2); + if (_curPos > 0) { + _bBlinkingLeft = true; + _items[29].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); - } else if ((m_state == OPENED) && m_bBlinkingLeft) { - assert(m_curPos > 0); - g_system->lockMutex(m_csModifyInterface); - m_curPos -= 7; - if (m_curPos < 0) m_curPos = 0; - - if (m_curPos == 0) { - m_bBlinkingLeft = false; - m_items[29].icon.SetPattern(1); + g_system->unlockMutex(_csModifyInterface); + } else if ((_state == OPENED) && _bBlinkingLeft) { + assert(_curPos > 0); + g_system->lockMutex(_csModifyInterface); + _curPos -= 7; + if (_curPos < 0) + _curPos = 0; + + if (_curPos == 0) { + _bBlinkingLeft = false; + _items[29].icon.SetPattern(1); } - if (m_curPos + 8 < m_nInv) { - m_bBlinkingRight = true; - m_items[28].icon.SetPattern(2); + if (_curPos + 8 < _nInv) { + _bBlinkingRight = true; + _items[28].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } } -bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction &curAction) { - if (m_state == SELECTING) { - m_state = OPENED; +bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { + if (_state == SELECTING) { + _state = OPENED; if (miniAction == 1) { // Esamina curAction = TA_EXAMINE; @@ -480,147 +481,147 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo int i; bool bNeedRedraw = false; - if (m_state != CLOSED) { + if (_state != CLOSED) { // Clean up the OT list - g_system->lockMutex(m_csModifyInterface); + g_system->lockMutex(_csModifyInterface); clearOT(); // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help - for (i = 0; i < m_nInv; i++) - if (m_items[m_inv[i]].icon.doFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) + for (i = 0; i < _nInv; i++) + if (_items[_inv[i]].icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) bNeedRedraw = true; - if ((m_state == CLOSING || m_state == OPENING || m_state == OPENED) && CheckPointInside(mpos)) { + if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos.x > RM_SX - 64) { - if (m_curPos + 8 < m_nInv && !m_bBlinkingRight) { - m_items[28].icon.SetPattern(3); - m_bBlinkingRight = true; + if (_curPos + 8 < _nInv && !_bBlinkingRight) { + _items[28].icon.SetPattern(3); + _bBlinkingRight = true; bNeedRedraw = true; } - } else if (m_bBlinkingRight) { - m_items[28].icon.SetPattern(2); - m_bBlinkingRight = false; + } else if (_bBlinkingRight) { + _items[28].icon.SetPattern(2); + _bBlinkingRight = false; bNeedRedraw = true; } if (mpos.x < 64) { - if (m_curPos > 0 && !m_bBlinkingLeft) { - m_items[29].icon.SetPattern(3); - m_bBlinkingLeft = true; + if (_curPos > 0 && !_bBlinkingLeft) { + _items[29].icon.SetPattern(3); + _bBlinkingLeft = true; bNeedRedraw = true; } - } else if (m_bBlinkingLeft) { - m_items[29].icon.SetPattern(2); - m_bBlinkingLeft = false; + } else if (_bBlinkingLeft) { + _items[29].icon.SetPattern(2); + _bBlinkingLeft = false; bNeedRedraw = true; } } - if (m_items[28].icon.doFrame(this, false)) + if (_items[28].icon.doFrame(this, false)) bNeedRedraw = true; - if (m_items[29].icon.doFrame(this, false)) + if (_items[29].icon.doFrame(this, false)) bNeedRedraw = true; if (bNeedRedraw) prepare(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } - if (m_bCombining) {//m_state == COMBINING) - ptr.setCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); + if (_bCombining) {//m_state == COMBINING) + ptr.setCustomPointer(&_items[_nCombine].pointer[_items[_nCombine].status - 1]); ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } if (!GLOBALS.bCfgInvUp) { - if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = OPENING; - m_curPutY = RM_SY - 1; - m_curPutTime = _vm->getTime(); + _state = OPENING; + _curPutY = RM_SY - 1; + _curPutTime = _vm->getTime(); } else { - m_state = OPENED; - m_curPutY = RM_SY - 68; + _state = OPENED; + _curPutY = RM_SY - 68; } - } else if (m_state == OPENED) { + } else if (_state == OPENED) { if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = CLOSING; - m_curPutY = RM_SY - 68; - m_curPutTime = _vm->getTime(); + _state = CLOSING; + _curPutY = RM_SY - 68; + _curPutTime = _vm->getTime(); } else { - m_state = CLOSED; + _state = CLOSED; } } - } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY -= 3; - m_curPutTime += INVSPEED; + } else if (_state == OPENING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY -= 3; + _curPutTime += INVSPEED; } - if (m_curPutY <= RM_SY - 68) { - m_state = OPENED; - m_curPutY = RM_SY - 68; + if (_curPutY <= RM_SY - 68) { + _state = OPENED; + _curPutY = RM_SY - 68; } - } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY += 3; - m_curPutTime += INVSPEED; + } else if (_state == CLOSING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY += 3; + _curPutTime += INVSPEED; } - if (m_curPutY > 480) - m_state = CLOSED; + if (_curPutY > 480) + _state = CLOSED; } } else { - if ((m_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = OPENING; - m_curPutY = - 68; - m_curPutTime = _vm->getTime(); + _state = OPENING; + _curPutY = - 68; + _curPutTime = _vm->getTime(); } else { - m_state = OPENED; - m_curPutY = 0; + _state = OPENED; + _curPutY = 0; } - } else if (m_state == OPENED) { + } else if (_state == OPENED) { if ((mpos.y > 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = CLOSING; - m_curPutY = -2; - m_curPutTime = _vm->getTime(); + _state = CLOSING; + _curPutY = -2; + _curPutTime = _vm->getTime(); } else { - m_state = CLOSED; + _state = CLOSED; } } - } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY += 3; - m_curPutTime += INVSPEED; + } else if (_state == OPENING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY += 3; + _curPutTime += INVSPEED; } - if (m_curPutY >= 0) { - m_state = OPENED; - m_curPutY = 0; + if (_curPutY >= 0) { + _state = OPENED; + _curPutY = 0; } - } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY -= 3; - m_curPutTime += INVSPEED; + } else if (_state == CLOSING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY -= 3; + _curPutTime += INVSPEED; } - if (m_curPutY < -68) - m_state = CLOSED; + if (_curPutY < -68) + _state = CLOSED; } } - if (m_state == SELECTING) { - int startx = (m_nSelectObj + 1) * 64 - 20; + if (_state == SELECTING) { + int startx = (_nSelectObj + 1) * 64 - 20; int starty; if (!GLOBALS.bCfgInvUp) @@ -661,27 +662,27 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniInterface.doFrame(&bigBuf, false); } - if ((m_state != CLOSED) && !_nInList) { + if ((_state != CLOSED) && !_nInList) { bigBuf.addPrim(new RMGfxPrimitive(this)); } } -bool RMInventory::ItemInFocus(const RMPoint &mpt) { - if ((m_state == OPENED || m_state == OPENING) && CheckPointInside(mpt)) +bool RMInventory::itemInFocus(const RMPoint &mpt) { + if ((_state == OPENED || _state == OPENING) && checkPointInside(mpt)) return true; else return false; } -RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { +RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { int n; - if (m_state == OPENED) { - if (CheckPointInside(mpt)) { + if (_state == OPENED) { + if (checkPointInside(mpt)) { n = mpt.x / 64; - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) - return &m_items[m_inv[n - 1 + m_curPos]].icon; + if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) + return &_items[_inv[n - 1 + _curPos]].icon; } } @@ -690,22 +691,22 @@ RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { -int RMInventory::GetSaveStateSize(void) { +int RMInventory::getSaveStateSize(void) { // m_inv pattern m_nInv return 256 * 4 + 256 * 4 + 4 ; } -void RMInventory::SaveState(byte *state) { +void RMInventory::saveState(byte *state) { int i, x; - WRITE_LE_UINT32(state, m_nInv); + WRITE_LE_UINT32(state, _nInv); state += 4; - Common::copy(m_inv, m_inv + 256, (uint32 *)state); + Common::copy(_inv, _inv + 256, (uint32 *)state); state += 256 * 4; for (i = 0; i < 256; i++) { - if (i < m_nItems) - x = m_items[i].status; + if (i < _nItems) + x = _items[i].status; else x = 0; @@ -714,39 +715,39 @@ void RMInventory::SaveState(byte *state) { } } -int RMInventory::LoadState(byte *state) { +int RMInventory::loadState(byte *state) { int i, x; - m_nInv = READ_LE_UINT32(state); + _nInv = READ_LE_UINT32(state); state += 4; - Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); + Common::copy((uint32 *)state, (uint32 *)state + 256, _inv); state += 256 * 4; for (i = 0; i < 256; i++) { x = READ_LE_UINT32(state); state += 4; - if (i < m_nItems) { - m_items[i].status = x; - m_items[i].icon.SetPattern(x); + if (i < _nItems) { + _items[i].status = x; + _items[i].icon.SetPattern(x); } } - m_curPos = 0; - m_bCombining = false; - - m_items[29].icon.SetPattern(1); + _curPos = 0; + _bCombining = false; + + _items[29].icon.SetPattern(1); - if (m_nInv > 8) - m_items[28].icon.SetPattern(2); + if (_nInv > 8) + _items[28].icon.SetPattern(2); else - m_items[28].icon.SetPattern(1); + _items[28].icon.SetPattern(1); prepare(); drawOT(Common::nullContext); clearOT(); - return GetSaveStateSize(); + return getSaveStateSize(); } @@ -758,22 +759,22 @@ RMInterface::~RMInterface() { } -bool RMInterface::Active() { - return m_bActive; +bool RMInterface::active() { + return _bActive; } -int RMInterface::OnWhichBox(RMPoint pt) { +int RMInterface::onWhichBox(RMPoint pt) { int max, i; - pt -= m_openStart; + pt -= _openStart; // Check how many verbs you have to consider max = 4; - if (m_bPalesati) max = 5; + if (_bPalesati) max = 5; // Find the verb for (i = 0; i < max; i++) - if (m_hotbbox[i].PtInRect(pt)) + if (_hotbbox[i].PtInRect(pt)) return i; // Found no verb @@ -787,64 +788,68 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - prim->Dst().TopLeft() = m_openStart; + prim->Dst().TopLeft() = _openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone - _ctx->h = OnWhichBox(m_mpos); + _ctx->h = onWhichBox(_mpos); if (_ctx->h != -1) { - prim->Dst().TopLeft() = m_openStart; - CORO_INVOKE_2(m_hotzone[_ctx->h].draw, bigBuf, prim); + prim->Dst().TopLeft() = _openStart; + CORO_INVOKE_2(_hotzone[_ctx->h].draw, bigBuf, prim); - if (m_lastHotZone != _ctx->h) { - m_lastHotZone = _ctx->h; + if (_lastHotZone != _ctx->h) { + _lastHotZone = _ctx->h; _vm->playUtilSFX(1); } if (GLOBALS.bCfgInterTips) { - prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - CORO_INVOKE_2(m_hints[_ctx->h].draw, bigBuf, prim); + prim->Dst().TopLeft() = _openStart + RMPoint(70, 177); + CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } } else - m_lastHotZone = -1; + _lastHotZone = -1; CORO_END_CODE; } -void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { +void RMInterface::doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { // If needed, add to the OT schedule list - if (!_nInList && m_bActive) + if (!_nInList && _bActive) bigBuf.addPrim(new RMGfxPrimitive(this)); - m_mpos = mousepos; + _mpos = mousepos; } -void RMInterface::Clicked(const RMPoint &mousepos) { - m_bActive = true; - m_openPos = mousepos; +void RMInterface::clicked(const RMPoint &mousepos) { + _bActive = true; + _openPos = mousepos; // Calculate the top left corner of the interface - m_openStart = m_openPos - RMPoint(_dimx / 2, _dimy / 2); - m_lastHotZone = -1; + _openStart = _openPos - RMPoint(_dimx / 2, _dimy / 2); + _lastHotZone = -1; // Keep it inside the screen - if (m_openStart.x < 0) m_openStart.x = 0; - if (m_openStart.y < 0) m_openStart.y = 0; - if (m_openStart.x + _dimx > RM_SX) m_openStart.x = RM_SX - _dimx; - if (m_openStart.y + _dimy > RM_SY) m_openStart.y = RM_SY - _dimy; + if (_openStart.x < 0) + _openStart.x = 0; + if (_openStart.y < 0) + _openStart.y = 0; + if (_openStart.x + _dimx > RM_SX) + _openStart.x = RM_SX - _dimx; + if (_openStart.y + _dimy > RM_SY) + _openStart.y = RM_SY - _dimy; // Play the sound effect _vm->playUtilSFX(0); } -bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { - if (!m_bActive) +bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { + if (!_bActive) return false; - m_bActive = false; + _bActive = false; - switch (OnWhichBox(mousepos)) { + switch (onWhichBox(mousepos)) { case 0: action = TA_TAKE; break; @@ -872,19 +877,19 @@ bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { return true; } -void RMInterface::Reset(void) { - m_bActive = false; +void RMInterface::reset(void) { + _bActive = false; } -void RMInterface::SetPalesati(bool bOn) { - m_bPalesati = bOn; +void RMInterface::setPalesati(bool bOn) { + _bPalesati = bOn; } -bool RMInterface::GetPalesati(void) { - return m_bPalesati; +bool RMInterface::getPalesati(void) { + return _bPalesati; } -void RMInterface::Init(void) { +void RMInterface::init(void) { int i; RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); @@ -897,21 +902,21 @@ void RMInterface::Init(void) { for (i = 0; i < 5; i++) { RMResRaw part(RES_I_INTERP1 + i); - m_hotzone[i].init(part, part.Width(), part.Height()); - m_hotzone[i].loadPaletteWA(pal); + _hotzone[i].init(part, part.Width(), part.Height()); + _hotzone[i].loadPaletteWA(pal); } - m_hotbbox[0].SetRect(126, 123, 159, 208); // Take - m_hotbbox[1].SetRect(90, 130, 125, 186); // About - m_hotbbox[2].SetRect(110, 60, 152, 125); - m_hotbbox[3].SetRect(56, 51, 93, 99); - m_hotbbox[4].SetRect(51, 105, 82, 172); + _hotbbox[0].SetRect(126, 123, 159, 208); // Take + _hotbbox[1].SetRect(90, 130, 125, 186); // About + _hotbbox[2].SetRect(110, 60, 152, 125); + _hotbbox[3].SetRect(56, 51, 93, 99); + _hotbbox[4].SetRect(51, 105, 82, 172); - m_hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[2].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[3].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[4].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[2].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[3].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[4].setAlignType(RMText::HRIGHT, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg0(12); @@ -920,24 +925,24 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].writeText(msg0[0], 1); // Take - m_hints[1].writeText(msg1[0], 1); // Talk - m_hints[2].writeText(msg2[0], 1); // Use - m_hints[3].writeText(msg3[0], 1); // Examine - m_hints[4].writeText(msg4[0], 1); // Show Yourself + _hints[0].writeText(msg0[0], 1); // Take + _hints[1].writeText(msg1[0], 1); // Talk + _hints[2].writeText(msg2[0], 1); // Use + _hints[3].writeText(msg3[0], 1); // Examine + _hints[4].writeText(msg4[0], 1); // Show Yourself - m_bActive = false; - m_bPalesati = false; - m_lastHotZone = 0; + _bActive = false; + _bPalesati = false; + _lastHotZone = 0; } -void RMInterface::Close(void) { +void RMInterface::close(void) { int i; destroy(); for (i = 0; i < 5; i++) - m_hotzone[i].destroy(); + _hotzone[i].destroy(); } } // End of namespace Tony diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 3548317dcc..6ffb33dd21 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -55,35 +55,35 @@ private: }; protected: - int m_nItems; - RMInventoryItem *m_items; + int _nItems; + RMInventoryItem *_items; - int m_inv[256]; - int m_nInv; - int m_curPutY; - uint32 m_curPutTime; + int _inv[256]; + int _nInv; + int _curPutY; + uint32 _curPutTime; - int m_curPos; - STATE m_state; - bool m_bHasFocus; - int m_nSelectObj; - int m_nCombine; - bool m_bCombining; + int _curPos; + STATE _state; + bool _bHasFocus; + int _nSelectObj; + int _nCombine; + bool _bCombining; - bool m_bBlinkingRight, m_bBlinkingLeft; + bool _bBlinkingRight, _bBlinkingLeft; int miniAction; RMItem miniInterface; - RMText m_hints[3]; + RMText _hints[3]; - OSystem::MutexRef m_csModifyInterface; + OSystem::MutexRef _csModifyInterface; protected: // Prepare the image inventory. It should be recalled whenever the inventory changes void prepare(void); // Check if the mouse Y position is conrrect, even under the inventory portion of the screen - bool CheckPointInside(const RMPoint &pt); + bool checkPointInside(const RMPoint &pt); public: RMInventory(); @@ -104,93 +104,93 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Method for determining whether the inventory currently has the focus - bool HaveFocus(const RMPoint &mpos); + bool haveFocus(const RMPoint &mpos); // Method for determining if the mini interface is active - bool MiniActive(void); + bool miniActive(void); // Handle the left mouse click (only when the inventory has the focus) - bool LeftClick(const RMPoint &mpos, int &nCombineObj); + bool leftClick(const RMPoint &mpos, int &nCombineObj); // Handle the right mouse button (only when the inventory has the focus) - void RightClick(const RMPoint &mpos); - bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); + void rightClick(const RMPoint &mpos); + bool rightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Warn that an item combine is over - void EndCombine(void); + void endCombine(void); public: // Add an item to the inventory - void AddItem(int code); + void addItem(int code); RMInventory &operator+=(RMItem *item) { - AddItem(item->MpalCode()); + addItem(item->MpalCode()); return *this; } RMInventory &operator+=(RMItem &item) { - AddItem(item.MpalCode()); + addItem(item.MpalCode()); return *this; } RMInventory &operator+=(int code) { - AddItem(code); + addItem(code); return *this; } // Removes an item - void RemoveItem(int code); + void removeItem(int code); // We are on an object? - RMItem *WhichItemIsIn(const RMPoint &mpt); - bool ItemInFocus(const RMPoint &mpt); + RMItem *whichItemIsIn(const RMPoint &mpt); + bool itemInFocus(const RMPoint &mpt); // Change the icon of an item - void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); + void changeItemStatus(uint32 dwCode, uint32 dwStatus); // Save methods - int GetSaveStateSize(void); - void SaveState(byte *state); - int LoadState(byte *state); + int getSaveStateSize(void); + void saveState(byte *state); + int loadState(byte *state); }; class RMInterface : public RMGfxSourceBuffer8RLEByte { private: - bool m_bActive; - RMPoint m_mpos; - RMPoint m_openPos; - RMPoint m_openStart; - RMText m_hints[5]; - RMGfxSourceBuffer8RLEByte m_hotzone[5]; - RMRect m_hotbbox[5]; - bool m_bPalesati; - int m_lastHotZone; + bool _bActive; + RMPoint _mpos; + RMPoint _openPos; + RMPoint _openStart; + RMText _hints[5]; + RMGfxSourceBuffer8RLEByte _hotzone[5]; + RMRect _hotbbox[5]; + bool _bPalesati; + int _lastHotZone; protected: // Return which box a given point is in - int OnWhichBox(RMPoint pt); + int onWhichBox(RMPoint pt); public: virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) - void DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); + void doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); // TRUE if it is active (you can select items) - bool Active(); + bool active(); // Initialisation - void Init(void); - void Close(void); + void init(void); + void close(void); // Reset the interface - void Reset(void); + void reset(void); // Warns of mouse clicks and releases - void Clicked(const RMPoint &mousepos); - bool Released(const RMPoint &mousepos, RMTonyAction &action); + void clicked(const RMPoint &mousepos); + bool released(const RMPoint &mousepos, RMTonyAction &action); // Enalbes or disables the fifth verb - void SetPalesati(bool bOn); - bool GetPalesati(void); + void setPalesati(bool bOn); + bool getPalesati(void); // Overloaded Draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); -- cgit v1.2.3 From 3a28323ba26786c89689f8ad637fcc5f4e0cdd9e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Jun 2012 23:18:56 +1000 Subject: TONY: Added sub-folders for full English game and revised detection entry --- engines/tony/detection_tables.h | 7 +++++-- engines/tony/tony.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 97bcc30f4b..bf4af08d2f 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -29,8 +29,11 @@ static const TonyGameDescription gameDescriptions[] = { "tony", 0, { - {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, - {"roasted.mpc", 0, "57c4a3860cf899443c357e0078ea6f49", 366773}, + // TODO: AdvancedDetector seems to have a problem where it thinks data1.cab is unrecognised. + // Is it perhaps because the Agos engine also has detection entries for data1.cab? + {"data1.cab", 0, "ce82907242166bfb594d97bdb68f96d2", 4350}, + /*{"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "57c4a3860cf899443c357e0078ea6f49", 366773},*/ AD_LISTEND }, Common::EN_ANY, diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ea378e0fc3..3549b54c2c 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -48,6 +48,12 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); + // Add folders to the search directory list + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "Voices"); + SearchMan.addSubDirectoryMatching(gameDataDir, "Roasted"); + SearchMan.addSubDirectoryMatching(gameDataDir, "Music"); + // Set up load slot number _initialLoadSlotNumber = -1; if (ConfMan.hasKey("save_slot")) { @@ -436,10 +442,6 @@ bool TonyEngine::openVoiceDatabase() { char id[4]; uint32 numfiles; - // Add the voices folder to the search directory list - const Common::FSNode gameDataDir(ConfMan.get("path")); - SearchMan.addSubDirectoryMatching(gameDataDir, "voices"); - // Open the voices database if (!_vdbFP.open("voices.vdb")) return false; -- cgit v1.2.3 From 53bd99ce870ac5bd7f65d1e45641e13070f652d0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 07:58:01 +0200 Subject: TONY: Rename variables and functions in loc.h and tonychar.h --- engines/tony/custom.cpp | 253 +++++------ engines/tony/debugger.cpp | 4 +- engines/tony/font.cpp | 14 +- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 68 +-- engines/tony/inventory.cpp | 60 +-- engines/tony/inventory.h | 4 +- engines/tony/loc.cpp | 1077 ++++++++++++++++++++++---------------------- engines/tony/loc.h | 326 +++++++------- engines/tony/tony.cpp | 4 +- engines/tony/tonychar.cpp | 677 ++++++++++++++-------------- engines/tony/tonychar.h | 120 ++--- 12 files changed, 1299 insertions(+), 1310 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 2725f2565e..d42ef94a17 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -109,7 +109,7 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; for (i = 0; i < GLOBALS.curChangedHotspot; i++) - GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); + GLOBALS.Loc->getItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->changeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { @@ -141,9 +141,9 @@ void LoadChangedHotspot(Common::InSaveFile *f) { */ void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - GLOBALS.MCharacter[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[i].code); + GLOBALS.MCharacter[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[i].code); for (int i = 0; i < 10; i++) - GLOBALS.Character[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.Character[i].code); + GLOBALS.Character[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.Character[i].code); } void CharsSaveAll(Common::OutSaveFile *f) { @@ -168,19 +168,19 @@ void CharsLoadAll(Common::InSaveFile *f) { } DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDDOWN); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDDOWN); } DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDUP); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDUP); } DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDLEFT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDLEFT); } DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); } @@ -263,8 +263,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (GLOBALS.bSkipIdle) return; - _ctx->msg.Load(dwMessage); - if (!_ctx->msg.IsValid()) { + _ctx->msg.load(dwMessage); + if (!_ctx->msg.isValid()) { return; } @@ -285,15 +285,15 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else { - if (_ctx->msg.NumPeriods() > 1) - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_FIANCHI); + if (_ctx->msg.numPeriods() > 1) + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_FIANCHI); else - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); } if (GLOBALS.curBackText) @@ -301,7 +301,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS.bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS.Input); // Alignment @@ -315,9 +315,9 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Set the position if (nX == 0 && nY == 0) - _ctx->text.setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); else - _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->scrollPosition()); // Handling for always display if (GLOBALS.bAlwaysDisplay) { @@ -359,13 +359,13 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (GLOBALS.curBackText) GLOBALS.curBackText->show(); - CORO_INVOKE_0(GLOBALS.Tony->EndTalk); + CORO_INVOKE_0(GLOBALS.Tony->endTalk); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { - GLOBALS.Boxes->ChangeBoxStatus(nLoc, nBox, nStatus); + GLOBALS.Boxes->changeBoxStatus(nLoc, nBox, nStatus); } @@ -408,16 +408,16 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); - GLOBALS.SFM_pt = GLOBALS.Tony->Position(); + GLOBALS.SFM_pt = GLOBALS.Tony->position(); if (GLOBALS.bSkipIdle) return; CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); - GLOBALS.Tony->Hide(); + GLOBALS.Tony->hide(); GLOBALS.Unfreeze(); - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS.Input); // Alignment @@ -474,7 +474,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, GLOBALS.Freeze(); GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); if (!bNotEnableTony) - GLOBALS.Tony->Show(); + GLOBALS.Tony->show(); GLOBALS.Unfreeze(); MCharResetCodes(); @@ -578,7 +578,7 @@ DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.saveTonyPos = GLOBALS.Tony->Position(); + GLOBALS.saveTonyPos = GLOBALS.Tony->position(); GLOBALS.saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); } @@ -604,7 +604,7 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->StopNoAction(coroParam); + GLOBALS.Tony->stopNoAction(coroParam); } DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -624,11 +624,11 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection, 0); + GLOBALS.Tony->take(nDirection, 0); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_END_CODE; } @@ -640,14 +640,14 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection, 1); + GLOBALS.Tony->take(nDirection, 1); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection, 2); + GLOBALS.Tony->take(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -660,11 +660,11 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection, 0); + GLOBALS.Tony->put(nDirection, 0); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_END_CODE; } @@ -676,14 +676,14 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection, 1); + GLOBALS.Tony->put(nDirection, 1); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection, 2); + GLOBALS.Tony->put(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -749,9 +749,9 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRALEFT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRALEFT); else - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { @@ -761,18 +761,18 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); else - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS.Tony->SetPastorella(bIsPast); + GLOBALS.Tony->setPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -781,11 +781,11 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); CORO_END_CODE; } @@ -834,31 +834,31 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMARTELLO; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONMARTELLO); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONMARTELLO); } DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBICCHIERE; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONBICCHIERE); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONBICCHIERE); } DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONVERME; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONVERME); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONVERME); } DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCORDA; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONCORDA); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONCORDA); } DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONSEGRETARIA; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); } DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -889,7 +889,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); CORO_END_CODE; } @@ -900,7 +900,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -915,7 +915,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32 GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); CORO_END_CODE; } @@ -926,7 +926,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -941,7 +941,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTASTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); CORO_END_CODE; } @@ -952,7 +952,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -967,7 +967,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, u GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTESTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); CORO_END_CODE; } @@ -978,7 +978,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -993,7 +993,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32 GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONTACCUINOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); CORO_END_CODE; } @@ -1004,7 +1004,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1019,7 +1019,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32 GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMEGAFONOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); CORO_END_CODE; } @@ -1030,7 +1030,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1045,7 +1045,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, u GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBARBASTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); CORO_END_CODE; } @@ -1056,7 +1056,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1071,7 +1071,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); CORO_END_CODE; } @@ -1082,7 +1082,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1101,8 +1101,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1114,8 +1114,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1160,11 +1160,11 @@ DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, ui DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->Show(); + GLOBALS.Tony->show(); } DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - GLOBALS.Tony->Hide(bShowOmbra); + GLOBALS.Tony->hide(bShowOmbra); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -1174,17 +1174,17 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uin CORO_BEGIN_CODE(_ctx); - _ctx->item = GLOBALS.Loc->GetItemFromCode(nItem); + _ctx->item = GLOBALS.Loc->getItemFromCode(nItem); if (!GLOBALS.bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); + CORO_INVOKE_1(_ctx->item->waitForEndPattern, GLOBALS.hSkipIdle); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { - GLOBALS.Tony->SetPosition(RMPoint(nX, nY), nLoc); + GLOBALS.Tony->setPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { @@ -1193,16 +1193,16 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->Move, RMPoint(nX, nY)); + CORO_INVOKE_1(GLOBALS.Tony->move, RMPoint(nX, nY)); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndMovement); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndMovement); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - GLOBALS.Tony->Move(coroParam, RMPoint(nX, nY)); + GLOBALS.Tony->move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1217,7 +1217,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; - _ctx->pt = GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Loc->scrollPosition(); while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { if (_ctx->lx > 0) { @@ -1243,8 +1243,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->SetScrollPosition(_ctx->pt); - GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Loc->setScrollPosition(_ctx->pt); + GLOBALS.Tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1276,7 +1276,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->stepX = sX; _ctx->stepY = sY; - _ctx->startpt = GLOBALS.Loc->ScrollPosition(); + _ctx->startpt = GLOBALS.Loc->scrollPosition(); _ctx->dwStartTime = _vm->getTime(); @@ -1308,8 +1308,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->SetScrollPosition(_ctx->pt); - GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Loc->setScrollPosition(_ctx->pt); + GLOBALS.Tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1329,8 +1329,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } GLOBALS.Freeze(); - GLOBALS.Loc->SetScrollPosition(_ctx->pt); - GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Loc->setScrollPosition(_ctx->pt); + GLOBALS.Tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1354,7 +1354,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin GLOBALS.curChangedHotspot++; } - GLOBALS.Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); + GLOBALS.Loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); } @@ -1384,8 +1384,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - GLOBALS.Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS.Unfreeze(); _ctx->i = _vm->_randomSource.getRandomNumber(2); @@ -1397,8 +1397,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 } GLOBALS.Freeze(); - GLOBALS.Loc->SetFixedScroll(RMPoint(0, 0)); - GLOBALS.Tony->SetFixedScroll(RMPoint(0, 0)); + GLOBALS.Loc->setFixedScroll(RMPoint(0, 0)); + GLOBALS.Tony->setFixedScroll(RMPoint(0, 0)); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1413,7 +1413,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); GLOBALS.Character[nChar].code = nCode; - GLOBALS.Character[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.Character[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); GLOBALS.Character[nChar].r = 255; GLOBALS.Character[nChar].g = 255; GLOBALS.Character[nChar].b = 255; @@ -1461,18 +1461,18 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = GLOBALS.Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); if (GLOBALS.Character[nChar].starttalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].starttalkpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].starttalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].talkpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].talkpattern); GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); @@ -1483,7 +1483,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) @@ -1545,13 +1545,13 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess if (GLOBALS.Character[nChar].endtalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].endtalkpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].endtalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].standpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].standpattern); GLOBALS.Unfreeze(); delete _ctx->msg; @@ -1581,7 +1581,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui if (nCode == 0) GLOBALS.MCharacter[nChar].item = NULL; else - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); GLOBALS.MCharacter[nChar].r = 255; GLOBALS.MCharacter[nChar].g = 255; GLOBALS.MCharacter[nChar].b = 255; @@ -1598,7 +1598,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[nChar].code); } @@ -1670,7 +1670,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Calculates the position of the text according to the current frame if (GLOBALS.MCharacter[nChar].x == -1) - _ctx->pt = GLOBALS.MCharacter[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.MCharacter[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); @@ -1680,7 +1680,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Try to run the custom function to initialise the speech if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1695,7 +1695,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { // Create a different object depending on whether it's background or not if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); @@ -1759,7 +1759,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Try to run the custom function to close the speech if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1767,11 +1767,6 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes CORO_END_CODE; } - - - - - /* * Dialoghi */ @@ -1815,46 +1810,46 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; _ctx->text->setColor(0, 255, 0); - _ctx->text->setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text->setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); _ctx->text->writeText(_ctx->string, 0); if (GLOBALS.dwTonyNumTexts > 0) { if (!GLOBALS.bTonyInTexts) { if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); GLOBALS.bTonyInTexts = true; } GLOBALS.dwTonyNumTexts--; } else { - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } } else if (!GLOBALS.IsMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = GLOBALS.Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); if (GLOBALS.Character[nPers].starttalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].starttalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); } - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].talkpattern); _ctx->text->setColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); _ctx->text->writeText(_ctx->string, 0); _ctx->text->setPosition(_ctx->pt); } else { if (GLOBALS.MCharacter[nPers].x == -1) - _ctx->pt = GLOBALS.MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.MCharacter[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); @@ -1866,7 +1861,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg GLOBALS.MCharacter[nPers].numtexts--; } else { // Try to run the custom function to initialise the speech - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -1922,18 +1917,18 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (!GLOBALS.IsMChar[nPers]) { if (GLOBALS.Character[nPers].endtalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].endtalkpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].endtalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); } - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].standpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].standpattern); delete _ctx->text; } else { if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { // Try to run the custom function to close the speech GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->MpalCode(), GLOBALS.MCharacter[nPers].curTalk); + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->mpalCode(), GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -1946,7 +1941,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } } else { if ((GLOBALS.dwTonyNumTexts == 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { - CORO_INVOKE_0(GLOBALS.Tony->EndTalk); + CORO_INVOKE_0(GLOBALS.Tony->endTalk); GLOBALS.dwTonyNumTexts = 0; GLOBALS.bTonyInTexts = false; } @@ -2201,11 +2196,11 @@ DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, u DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem == 0) { - GLOBALS.Tony->PlaySfx(nSFX); + GLOBALS.Tony->playSfx(nSFX); } else { - RMItem *item = GLOBALS.Loc->GetItemFromCode(nItem); + RMItem *item = GLOBALS.Loc->getItemFromCode(nItem); if (item) - item->PlaySfx(nSFX); + item->playSfx(nSFX); } } @@ -2325,9 +2320,9 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->msg = new RMMessage(nMsg); _ctx->hDisable = CoroScheduler.createEvent(true, false); - _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; + _ctx->text = new RMTextDialog[_ctx->msg->numPeriods()]; - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods(); _ctx->i++) { _ctx->text[_ctx->i].setInput(GLOBALS.Input); // Alignment diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 7dc32d9f61..66fddf2834 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -87,7 +87,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } int sceneNumber = strToInt(argv[1]); - if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) { + if (sceneNumber >= _vm->_theBoxes.getLocBoxesCount()) { DebugPrintf("Invalid scene\n"); return true; } @@ -99,7 +99,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas - RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber); + RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index bc32939061..e056484e54 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2180,7 +2180,7 @@ RMTextDialogScrolling::RMTextDialogScrolling() { RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { curLoc = loc; - startScroll = loc->ScrollPosition(); + startScroll = loc->scrollPosition(); } RMTextDialogScrolling::~RMTextDialogScrolling() { @@ -2196,7 +2196,7 @@ void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri _ctx->curDst = dst; if (curLoc != NULL) - dst -= curLoc->ScrollPosition() - startScroll; + dst -= curLoc->scrollPosition() - startScroll; CORO_INVOKE_2(RMTextDialog::draw, bigBuf, prim); @@ -2240,19 +2240,19 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & bigBuf.addPrim(new RMGfxPrimitive(this)); // Update the scrolling co-ordinates - _curscroll = loc.ScrollPosition(); + _curscroll = loc.scrollPosition(); // Check if we are on the inventory if (inv.itemInFocus(_mpos)) _item = inv.whichItemIsIn(_mpos); else - _item = loc.WhichItemIsIn(_mpos); + _item = loc.whichItemIsIn(_mpos); itemName = ""; // If there an item, get its name if (_item != NULL) - _item->GetName(itemName); + _item->getName(itemName); // Write it writeText(itemName, 1); @@ -2262,7 +2262,7 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & if (_item == NULL) ptr.setSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoAction(20, _item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, _item->mpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.setSpecialPointer(RMPointer::PTR_NONE); else @@ -2296,7 +2296,7 @@ RMPoint RMTextItemName::getHotspot() { if (_item == NULL) return _mpos + _curscroll; else - return _item->Hotspot(); + return _item->hotspot(); } RMItem *RMTextItemName::getSelectedItem() { diff --git a/engines/tony/game.h b/engines/tony/game.h index 34e99c369e..5f387d558b 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -115,7 +115,7 @@ public: void setSpecialPointer(POINTER ptr) { _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[ptr - 1]->SetPattern(1); + _specialPointer[ptr - 1]->setPattern(1); } POINTER getSpecialPointer(void) { return (POINTER)_nCurSpecialPointer; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index a80552b1d1..56ce8a47e1 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -126,7 +126,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; } else { - CORO_INVOKE_0(_tony.StopNoAction); + CORO_INVOKE_0(_tony.stopNoAction); GLOBALS.bIdleExited = false; @@ -170,7 +170,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { _loc.doFrame(&_bigBuf); // Check the mouse input - if (_bInput && !_tony.InAction()) { + if (_bInput && !_tony.inAction()) { // If we are on the inventory, it is it who controls all input if (_inv.haveFocus(_input.mousePos()) && !_inter.active()) { // Left Click @@ -197,7 +197,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // ************* if (_input.mouseRightReleased()) { if (_inv.rightRelease(_input.mousePos(), _curAction)) { - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -207,7 +207,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Options Menu // ************ if (_bGUIOption) { - if (!_tony.InAction() && _bInput) { + if (!_tony.inAction() && _bInput) { if ((_input.mouseLeftClicked() && _input.mousePos().x < 3 && _input.mousePos().y < 3)) { CORO_INVOKE_1(openOptionScreen, 0); goto SKIPCLICKSINISTRO; @@ -229,9 +229,9 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseLeftClicked() && !_inter.active()) { if (_curAction != TA_COMBINE) - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); + CORO_INVOKE_3(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); else if (_itemName.getSelectedItem() != NULL) - CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); + CORO_INVOKE_4(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { _inv.endCombine(); @@ -271,7 +271,7 @@ SKIPCLICKSINISTRO: if (_bGUIInterface) { if (_inter.released(_input.mousePos(), _curAction)) { _point.setAction(_curAction); - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -288,23 +288,23 @@ SKIPCLICKSINISTRO: // Interface & Inventory _inter.doFrame(_bigBuf, _input.mousePos()); - _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.active() && _bGUIInventory)); + _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.inAction() && !_inter.active() && _bGUIInventory)); } // Animate Tony - CORO_INVOKE_2(_tony.DoFrame, &_bigBuf, _nCurLoc); + CORO_INVOKE_2(_tony.doFrame, &_bigBuf, _nCurLoc); // Update screen scrolling to keep Tony in focus - if (_tony.MustUpdateScrolling() && _bLocationLoaded) { - RMPoint showThis = _tony.Position(); + if (_tony.mustUpdateScrolling() && _bLocationLoaded) { + RMPoint showThis = _tony.position(); showThis.y -= 60; - _loc.UpdateScrolling(showThis); + _loc.updateScrolling(showThis); } if (_bLocationLoaded) - _tony.SetScrollPosition(_loc.ScrollPosition()); + _tony.setScrollPosition(_loc.scrollPosition()); - if ((!_tony.InAction() && _bInput) || _bAlwaysDrawMouse) { + if ((!_tony.inAction() && _bInput) || _bAlwaysDrawMouse) { _point.setCoord(_input.mousePos()); _point.doFrame(&_bigBuf); } @@ -362,17 +362,17 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { assert(GLOBALS.GfxEngine); if (GLOBALS.GfxEngine->_bLocationLoaded) { - item = GLOBALS.GfxEngine->_loc.GetItemFromCode(dwItem); + item = GLOBALS.GfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) mainFreeze(); - item->SetPattern(nPattern, true); + item->setPattern(nPattern, true); if (GLOBALS.bPatIrqFreeze) mainUnfreeze(); } if (nStatus != -1) - item->SetStatus(nStatus); + item->setStatus(nStatus); } } } @@ -384,12 +384,12 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star start.y = ptTonyStart.y - RM_SY / 2; } - _loc.SetScrollPosition(start); + _loc.setScrollPosition(start); if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { } else { - _tony.SetPosition(ptTonyStart, nLoc); - _tony.SetScrollPosition(start); + _tony.setPosition(ptTonyStart, nLoc); + _tony.setScrollPosition(start); } _curAction = TA_GOTO; @@ -415,7 +415,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (!res.IsValid()) continue; - _loc.Load(res); + _loc.load(res); initForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; @@ -455,7 +455,7 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _bLocationLoaded = false; _bigBuf.clearOT(); - _loc.Unload(); + _loc.unload(); if (result != NULL) *result = CORO_INVALID_PID_VALUE; @@ -503,7 +503,7 @@ void RMGfxEngine::init() { // Initialise Tony _tony.init(); - _tony.LinkToBoxes(&_vm->_theBoxes); + _tony.linkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface _inv.init(); @@ -515,7 +515,7 @@ void RMGfxEngine::init() { enableInput(); // Starting the game - _tony.ExecuteAction(20, 1, 0); + _tony.executeAction(20, 1, 0); } void RMGfxEngine::close(void) { @@ -523,7 +523,7 @@ void RMGfxEngine::close(void) { _inter.close(); _inv.close(); - _tony.Close(); + _tony.close(); _point.close(); _input.close(); } @@ -579,7 +579,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm uint size; int i; char buf[4]; - RMPoint tp = _tony.Position(); + RMPoint tp = _tony.position(); // Saving: MPAL variables, current location, and Tony inventory position @@ -627,9 +627,9 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // boxes - size = _vm->_theBoxes.GetSaveStateSize(); + size = _vm->_theBoxes.getSaveStateSize(); state = new byte[size]; - _vm->_theBoxes.SaveState(state); + _vm->_theBoxes.saveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -638,7 +638,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm bool bStat; // Saves the state of the shepherdess and show yourself - bStat = _tony.GetPastorella(); + bStat = _tony.getPastorella(); f->writeByte(bStat); bStat = _inter.getPalesati(); f->writeByte(bStat); @@ -765,7 +765,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - _vm->_theBoxes.LoadState(_ctx->state); + _vm->_theBoxes.loadState(_ctx->state); delete[] _ctx->state; } @@ -774,7 +774,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bool bStat = false; bStat = _ctx->f->readByte(); - _tony.SetPastorella(bStat); + _tony.setPastorella(bStat); bStat = _ctx->f->readByte(); _inter.setPalesati(bStat); @@ -813,7 +813,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_2(unloadLocation, false, NULL); loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); - _tony.SetPattern(RMTony::PAT_STANDRIGHT); + _tony.setPattern(RMTony::PAT_STANDRIGHT); mainUnfreeze(); // On older versions, need to an enter action @@ -838,7 +838,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { void RMGfxEngine::pauseSound(bool bPause) { if (_bLocationLoaded) - _loc.PauseSound(bPause); + _loc.pauseSound(bPause); } void RMGfxEngine::initWipe(int type) { @@ -861,7 +861,7 @@ void RMGfxEngine::waitWipeEnd(CORO_PARAM) { } bool RMGfxEngine::canLoadSave() { - return _bInput && !_tony.InAction() && !_vm->getIsDemo(); + return _bInput && !_tony.inAction() && !_vm->getIsDemo(); } } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 595a1ba0f2..5ff4f6cd10 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -100,7 +100,7 @@ void RMInventory::init(void) { assert(res.IsValid()); // Initialise the MPAL inventory item by reading it in. - _items[i].icon.SetInitCurPattern(false); + _items[i].icon.setInitCurPattern(false); ds.OpenBuffer(res); ds >> _items[i].icon; ds.Close(); @@ -108,16 +108,16 @@ void RMInventory::init(void) { // Puts in the default pattern 1 _items[i].pointer = NULL; _items[i].status = 1; - _items[i].icon.SetPattern(1); + _items[i].icon.setPattern(1); _items[i].icon.doFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; - _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.NumPattern()]; + _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.numPattern()]; - for (j = 0; j < _items[i].icon.NumPattern(); j++) { + for (j = 0; j < _items[i].icon.numPattern(); j++) { RMResRaw raw(curres); assert(raw.IsValid()); @@ -127,8 +127,8 @@ void RMInventory::init(void) { } } - _items[28].icon.SetPattern(1); - _items[29].icon.SetPattern(1); + _items[28].icon.setPattern(1); + _items[29].icon.setPattern(1); // Download interface RMDataStream ds; @@ -136,7 +136,7 @@ void RMInventory::init(void) { assert(res.IsValid()); ds.OpenBuffer(res); ds >> miniInterface; - miniInterface.SetPattern(1); + miniInterface.setPattern(1); ds.Close(); // Create the text for hints on the mini interface @@ -264,7 +264,7 @@ void RMInventory::addItem(int code) { g_system->lockMutex(_csModifyInterface); if (_curPos + 8 == _nInv) { // Break through the inventory! On the flashing pattern - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); } _inv[_nInv++] = code - 10000; @@ -281,7 +281,7 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { error("Specified object code is not valid"); } else { g_system->lockMutex(_csModifyInterface); - _items[code - 10000].icon.SetPattern(dwStatus); + _items[code - 10000].icon.setPattern(dwStatus); _items[code - 10000].status = dwStatus; prepare(); @@ -355,12 +355,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos + 8 >= _nInv) { _bBlinkingRight = false; - _items[28].icon.SetPattern(1); + _items[28].icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.SetPattern(2); + _items[29].icon.setPattern(2); } prepare(); @@ -376,12 +376,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.SetPattern(1); + _items[29].icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); } prepare(); @@ -420,12 +420,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos + 8 <= _nInv) { _bBlinkingRight = false; - _items[28].icon.SetPattern(1); + _items[28].icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.SetPattern(2); + _items[29].icon.setPattern(2); } prepare(); @@ -441,12 +441,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.SetPattern(1); + _items[29].icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); } prepare(); @@ -495,24 +495,24 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos.x > RM_SX - 64) { if (_curPos + 8 < _nInv && !_bBlinkingRight) { - _items[28].icon.SetPattern(3); + _items[28].icon.setPattern(3); _bBlinkingRight = true; bNeedRedraw = true; } } else if (_bBlinkingRight) { - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); _bBlinkingRight = false; bNeedRedraw = true; } if (mpos.x < 64) { if (_curPos > 0 && !_bBlinkingLeft) { - _items[29].icon.SetPattern(3); + _items[29].icon.setPattern(3); _bBlinkingLeft = true; bNeedRedraw = true; } } else if (_bBlinkingLeft) { - _items[29].icon.SetPattern(2); + _items[29].icon.setPattern(2); _bBlinkingLeft = false; bNeedRedraw = true; } @@ -633,28 +633,28 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (mpos.y > starty && mpos.y < starty + 45) { if (mpos.x > startx && mpos.x < startx + 40) { if (miniAction != 1) { - miniInterface.SetPattern(2); + miniInterface.setPattern(2); miniAction = 1; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { if (miniAction != 2) { - miniInterface.SetPattern(3); + miniInterface.setPattern(3); miniAction = 2; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { if (miniAction != 3) { - miniInterface.SetPattern(4); + miniInterface.setPattern(4); miniAction = 3; _vm->playUtilSFX(1); } } else { - miniInterface.SetPattern(1); + miniInterface.setPattern(1); miniAction = 0; } } else { - miniInterface.SetPattern(1); + miniInterface.setPattern(1); miniAction = 0; } @@ -729,19 +729,19 @@ int RMInventory::loadState(byte *state) { if (i < _nItems) { _items[i].status = x; - _items[i].icon.SetPattern(x); + _items[i].icon.setPattern(x); } } _curPos = 0; _bCombining = false; - _items[29].icon.SetPattern(1); + _items[29].icon.setPattern(1); if (_nInv > 8) - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); else - _items[28].icon.SetPattern(1); + _items[28].icon.setPattern(1); prepare(); drawOT(Common::nullContext); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 6ffb33dd21..d8b20827b4 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -123,11 +123,11 @@ public: // Add an item to the inventory void addItem(int code); RMInventory &operator+=(RMItem *item) { - addItem(item->MpalCode()); + addItem(item->mpalCode()); return *this; } RMInventory &operator+=(RMItem &item) { - addItem(item.MpalCode()); + addItem(item.mpalCode()); return *this; } RMInventory &operator+=(int code) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index ae34c577aa..d2688140fb 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -50,7 +50,7 @@ using namespace ::Tony::MPAL; * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal.m_data, 1024); + ds.Read(pal._data, 1024); return ds; } @@ -67,26 +67,26 @@ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { - slot.ReadFromStream(ds); + slot.readFromStream(ds); return ds; } -void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::RMSlot::readFromStream(RMDataStream &ds, bool bLOX) { byte type; // Type ds >> type; - m_type = (RMPattern::RMSlotType)type; + _type = (RMPattern::RMSlotType)type; // Dati - ds >> m_data; + ds >> _data; // Posizione - ds >> m_pos; + ds >> _pos; // Flag generica - ds >> m_flag; + ds >> _flag; } @@ -103,159 +103,159 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { - pat.ReadFromStream(ds); + pat.readFromStream(ds); return ds; } -void RMPattern::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { int i; // Pattern name if (!bLOX) - ds >> m_name; + ds >> _name; // Velocity - ds >> m_speed; + ds >> _speed; // Position - ds >> m_pos; + ds >> _pos; // Flag for pattern looping - ds >> m_bLoop; + ds >> _bLoop; // Number of slots - ds >> m_nSlots; + ds >> _nSlots; // Create and read the slots - m_slots = new RMSlot[m_nSlots]; + _slots = new RMSlot[_nSlots]; - for (i = 0; i < m_nSlots && !ds.IsError(); i++) { + for (i = 0; i < _nSlots && !ds.IsError(); i++) { if (bLOX) - m_slots[i].ReadFromStream(ds, true); + _slots[i].readFromStream(ds, true); else - m_slots[i].ReadFromStream(ds, false); + _slots[i].readFromStream(ds, false); } } -void RMPattern::UpdateCoord(void) { - m_curPos = m_pos + m_slots[m_nCurSlot].Pos(); +void RMPattern::updateCoord(void) { + _curPos = _pos + _slots[_nCurSlot].pos(); } -void RMPattern::StopSfx(RMSfx *sfx) { - for (int i = 0; i < m_nSlots; i++) { - if (m_slots[i].m_type == SOUND) { - if (sfx[m_slots[i].m_data].m_name[0] == '_') - sfx[m_slots[i].m_data].Stop(); +void RMPattern::stopSfx(RMSfx *sfx) { + for (int i = 0; i < _nSlots; i++) { + if (_slots[i]._type == SOUND) { + if (sfx[_slots[i]._data]._name[0] == '_') + sfx[_slots[i]._data].stop(); else if (GLOBALS.bSkipSfxNoLoop) - sfx[m_slots[i].m_data].Stop(); + sfx[_slots[i]._data].stop(); } } } -int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { +int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; // Read the current time - m_nStartTime = _vm->getTime(); - m_nCurSlot = 0; + _nStartTime = _vm->getTime(); + _nCurSlot = 0; // Find the first frame of the pattern i = 0; - while (m_slots[i].m_type != SPRITE) { - assert(i + 1 < m_nSlots); + while (_slots[i]._type != SPRITE) { + assert(i + 1 < _nSlots); i++; } - m_nCurSlot = i; - m_nCurSprite = m_slots[i].m_data; + _nCurSlot = i; + _nCurSprite = _slots[i]._data; if (bFlag) - *bFlag = m_slots[i].m_flag; + *bFlag = _slots[i]._flag; // Calculate the current coordinates - UpdateCoord(); + updateCoord(); // Check for sound: // If the slot is 0, play // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop - for (i = 0; i < m_nSlots; i++) { - if (m_slots[i].m_type == SOUND) { + for (i = 0; i < _nSlots; i++) { + if (_slots[i]._type == SOUND) { if (i == 0) { - if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(true); + if (sfx[_slots[i]._data]._name[0] == '_') { + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(true); } else { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(); + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(); } - } else if (m_speed == 0) { + } else if (_speed == 0) { if (bPlayP0) { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(); - } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(true); + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(); + } else if (sfx[_slots[i]._data]._name[0] == '_') { + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(true); } } else { - if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(true); + if (_bLoop && sfx[_slots[i]._data]._name[0] == '_') { + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(true); } } } } - return m_nCurSprite; + return _nCurSprite; } -int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { +int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { int CurTime = _vm->getTime(); // If the speed is 0, then the pattern never advances - if (m_speed == 0) { + if (_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); - bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + bFlag = _slots[_nCurSlot]._flag; + return _nCurSprite; } // Is it time to change the slots? - while (m_nStartTime + m_speed <= (uint32)CurTime) { - m_nStartTime += m_speed; - if (m_slots[m_nCurSlot].m_type == SPRITE) - m_nCurSlot++; - if (m_nCurSlot == m_nSlots) { - m_nCurSlot = 0; - bFlag = m_slots[m_nCurSlot].m_flag; + while (_nStartTime + _speed <= (uint32)CurTime) { + _nStartTime += _speed; + if (_slots[_nCurSlot]._type == SPRITE) + _nCurSlot++; + if (_nCurSlot == _nSlots) { + _nCurSlot = 0; + bFlag = _slots[_nCurSlot]._flag; CoroScheduler.pulseEvent(hEndPattern); // @@@ If there is no loop pattern, and there's a warning that it's the final // frame, then remain on the last frame - if (!m_bLoop) { - m_nCurSlot = m_nSlots - 1; - bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + if (!_bLoop) { + _nCurSlot = _nSlots - 1; + bFlag = _slots[_nCurSlot]._flag; + return _nCurSprite; } } for (;;) { - switch (m_slots[m_nCurSlot].m_type) { + switch (_slots[_nCurSlot]._type) { case SPRITE: // Read the next sprite - m_nCurSprite = m_slots[m_nCurSlot].m_data; + _nCurSprite = _slots[_nCurSlot]._data; // Update the parent & child coordinates - UpdateCoord(); + updateCoord(); break; case SOUND: if (sfx != NULL) { - sfx[m_slots[m_nCurSlot].m_data].SetVolume(m_slots[m_nCurSlot].Pos().x); + sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos().x); - if (sfx[m_slots[m_nCurSlot].m_data].m_name[0] != '_') - sfx[m_slots[m_nCurSlot].m_data].Play(false); + if (sfx[_slots[_nCurSlot]._data]._name[0] != '_') + sfx[_slots[_nCurSlot]._data].play(false); else - sfx[m_slots[m_nCurSlot].m_data].Play(true); + sfx[_slots[_nCurSlot]._data].play(true); } break; @@ -268,38 +268,35 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { break; } - if (m_slots[m_nCurSlot].m_type == SPRITE) + if (_slots[_nCurSlot]._type == SPRITE) break; - m_nCurSlot++; + _nCurSlot++; } } // Return the current sprite - bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + bFlag = _slots[_nCurSlot]._flag; + return _nCurSprite; } RMPattern::RMPattern() { - m_slots = NULL; - m_speed = 0; - m_bLoop = 0; - m_nSlots = 0; - m_nCurSlot = 0; - m_nCurSprite = 0; - m_nStartTime = 0; - m_slots = NULL; + _slots = NULL; + _speed = 0; + _bLoop = 0; + _nSlots = 0; + _nCurSlot = 0; + _nCurSprite = 0; + _nStartTime = 0; + _slots = NULL; } RMPattern::~RMPattern() { - if (m_slots != NULL) { - delete[] m_slots; - m_slots = NULL; + if (_slots != NULL) { + delete[] _slots; + _slots = NULL; } } - - - /****************************************************************************\ * RMSprite Methods \****************************************************************************/ @@ -313,12 +310,12 @@ RMPattern::~RMPattern() { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { - sprite.ReadFromStream(ds); + sprite.readFromStream(ds); return ds; } -void RMSprite::Init(RMGfxSourceBuffer *buf) { - m_buf = buf; +void RMSprite::init(RMGfxSourceBuffer *buf) { + _buf = buf; } void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { @@ -329,52 +326,52 @@ void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { ds.Seek(pos, ds.START); } -void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { +void RMSprite::getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { int pos = ds.Pos(); - ds >> m_name; + ds >> _name; ds >> *dimx >> *dimy; ds.Seek(pos, ds.START); } -void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMSprite::readFromStream(RMDataStream &ds, bool bLOX) { int dimx, dimy; // Sprite name if (!bLOX) - ds >> m_name; + ds >> _name; // Dimensions ds >> dimx >> dimy; // Bounding box - ds >> m_rcBox; + ds >> _rcBox; // Unused space if (!bLOX) ds += 32; // Create buffer and read - m_buf->init(ds, dimx, dimy); + _buf->init(ds, dimx, dimy); } void RMSprite::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->draw(coroParam, bigBuf, prim); + _buf->draw(coroParam, bigBuf, prim); } -void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal *)m_buf)->loadPalette(buf); +void RMSprite::setPalette(byte *buf) { + ((RMGfxSourceBufferPal *)_buf)->loadPalette(buf); } RMSprite::RMSprite() { - m_buf = NULL; + _buf = NULL; } RMSprite::~RMSprite() { - if (m_buf) { - delete m_buf; - m_buf = NULL; + if (_buf) { + delete _buf; + _buf = NULL; } } @@ -392,17 +389,17 @@ RMSprite::~RMSprite() { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { - sfx.ReadFromStream(ds); + sfx.readFromStream(ds); return ds; } -void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { char id[4]; int size; byte *raw; // sfx name - ds >> m_name; + ds >> _name; ds >> size; @@ -420,51 +417,51 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds.Read(raw, size); // Create the sound effect - m_fx = _vm->createSFX(raw); - m_fx->SetLoop(false); + _fx = _vm->createSFX(raw); + _fx->SetLoop(false); // Close the read buffer which is no longer needed delete[] raw; } RMSfx::RMSfx() { - m_fx = NULL; - m_bPlayingLoop = false; + _fx = NULL; + _bPlayingLoop = false; } RMSfx::~RMSfx() { - if (m_fx) { - m_fx->Release(); - m_fx = NULL; + if (_fx) { + _fx->Release(); + _fx = NULL; } } -void RMSfx::Play(bool bLoop) { - if (m_fx && !m_bPlayingLoop) { - m_fx->SetLoop(bLoop); - m_fx->Play(); +void RMSfx::play(bool bLoop) { + if (_fx && !_bPlayingLoop) { + _fx->SetLoop(bLoop); + _fx->Play(); if (bLoop) - m_bPlayingLoop = true; + _bPlayingLoop = true; } } -void RMSfx::SetVolume(int vol) { - if (m_fx) { - m_fx->SetVolume(vol); +void RMSfx::setVolume(int vol) { + if (_fx) { + _fx->SetVolume(vol); } } -void RMSfx::Pause(bool bPause) { - if (m_fx) { - m_fx->Pause(bPause); +void RMSfx::pause(bool bPause) { + if (_fx) { + _fx->Pause(bPause); } } -void RMSfx::Stop(void) { - if (m_fx) { - m_fx->Stop(); - m_bPlayingLoop = false; +void RMSfx::stop(void) { + if (_fx) { + _fx->Stop(); + _bPlayingLoop = false; } } @@ -483,24 +480,24 @@ void RMSfx::Stop(void) { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { - item.ReadFromStream(ds); + item.readFromStream(ds); return ds; } -RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { - if (m_cm == CM_256) { +RMGfxSourceBuffer *RMItem::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { + if (_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; - if (m_FX == 2) { // AB + if (_FX == 2) { // AB spr = new RMGfxSourceBuffer8RLEWordAB; - } else if (m_FX == 1) { // OMBRA+AA + } else if (_FX == 1) { // OMBRA+AA if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWordAA; else spr = new RMGfxSourceBuffer8RLEByteAA; - spr->setAlphaBlendColor(m_FXparm); + spr->setAlphaBlendColor(_FXparm); if (bPreRLE) spr->setAlreadyCompressed(); } else { @@ -518,17 +515,17 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(const RMPoint &pt, int *size) { +bool RMItem::isIn(const RMPoint &pt, int *size) { RMRect rc; - if (!m_bIsActive) + if (!_bIsActive) return false; // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one - if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) - rc = m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); - else if (!m_rcBox.IsEmpty()) - rc = m_rcBox; + if (_nCurPattern != 0 && !_sprites[_nCurSprite]._rcBox.IsEmpty()) + rc = _sprites[_nCurSprite]._rcBox + calculatePos(); + else if (!_rcBox.IsEmpty()) + rc = _rcBox; // If no box, return immediately else return false; @@ -536,153 +533,152 @@ bool RMItem::IsIn(const RMPoint &pt, int *size) { if (size != NULL) *size = rc.Size(); - return rc.PtInRect(pt + m_curScroll); + return rc.PtInRect(pt + _curScroll); } - -void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { int i, dimx, dimy; byte cm; // MPAL code - ds >> m_mpalCode; + ds >> _mpalCode; // Object name - ds >> m_name; + ds >> _name; // Z (signed) - ds >> m_z; + ds >> _z; // Parent position - ds >> m_pos; + ds >> _pos; // Hotspot - ds >> m_hot; + ds >> _hot; // Bounding box - ds >> m_rcBox; + ds >> _rcBox; // Number of sprites, sound effects, and patterns - ds >> m_nSprites >> m_nSfx >> m_nPatterns; + ds >> _nSprites >> _nSfx >> _nPatterns; // Color mode ds >> cm; - m_cm = (RMColorMode)cm; + _cm = (RMColorMode)cm; // Flag for the presence of custom palette differences - ds >> m_bPal; + ds >> _bPal; - if (m_cm == CM_256) { + if (_cm == CM_256) { // If there is a palette, read it in - if (m_bPal) - ds >> m_pal; + if (_bPal) + ds >> _pal; } // MPAL data if (!bLOX) ds += 20; - ds >> m_FX; - ds >> m_FXparm; + ds >> _FX; + ds >> _FXparm; if (!bLOX) ds += 106; // Create sub-classes - if (m_nSprites > 0) - m_sprites = new RMSprite[m_nSprites]; - if (m_nSfx > 0) - m_sfx = new RMSfx[m_nSfx]; - m_patterns = new RMPattern[m_nPatterns + 1]; + if (_nSprites > 0) + _sprites = new RMSprite[_nSprites]; + if (_nSfx > 0) + _sfx = new RMSfx[_nSfx]; + _patterns = new RMPattern[_nPatterns + 1]; // Read in class data if (!ds.IsError()) - for (i = 0; i < m_nSprites && !ds.IsError(); i++) { + for (i = 0; i < _nSprites && !ds.IsError(); i++) { // Download the sprites if (bLOX) { - m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); - m_sprites[i].ReadFromStream(ds, true); + _sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + _sprites[i].init(newItemSpriteBuffer(dimx, dimy, true)); + _sprites[i].readFromStream(ds, true); } else { - m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); - m_sprites[i].ReadFromStream(ds, false); + _sprites[i].getSizeFromStream(ds, &dimx, &dimy); + _sprites[i].init(newItemSpriteBuffer(dimx, dimy, false)); + _sprites[i].readFromStream(ds, false); } - if (m_cm == CM_256 && m_bPal) - m_sprites[i].SetPalette(m_pal.m_data); + if (_cm == CM_256 && _bPal) + _sprites[i].setPalette(_pal._data); } if (!ds.IsError()) - for (i = 0; i < m_nSfx && !ds.IsError(); i++) { + for (i = 0; i < _nSfx && !ds.IsError(); i++) { if (bLOX) - m_sfx[i].ReadFromStream(ds, true); + _sfx[i].readFromStream(ds, true); else - m_sfx[i].ReadFromStream(ds, false); + _sfx[i].readFromStream(ds, false); } // Read the pattern from pattern 1 if (!ds.IsError()) - for (i = 1; i <= m_nPatterns && !ds.IsError(); i++) { + for (i = 1; i <= _nPatterns && !ds.IsError(); i++) { if (bLOX) - m_patterns[i].ReadFromStream(ds, true); + _patterns[i].readFromStream(ds, true); else - m_patterns[i].ReadFromStream(ds, false); + _patterns[i].readFromStream(ds, false); } // Initialise the current pattern - if (m_bInitCurPattern) - SetPattern(mpalQueryItemPattern(m_mpalCode)); + if (_bInitCurPattern) + setPattern(mpalQueryItemPattern(_mpalCode)); // Initailise the current activation state - m_bIsActive = mpalQueryItemIsActive(m_mpalCode); + _bIsActive = mpalQueryItemIsActive(_mpalCode); } -RMGfxPrimitive *RMItem::NewItemPrimitive() { +RMGfxPrimitive *RMItem::newItemPrimitive() { return new RMGfxPrimitive(this); } -void RMItem::SetScrollPosition(const RMPoint &scroll) { - m_curScroll = scroll; +void RMItem::setScrollPosition(const RMPoint &scroll) { + _curScroll = scroll; } bool RMItem::doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { - int oldSprite = m_nCurSprite; + int oldSprite = _nCurSprite; // Pattern 0 = Do not draw anything! - if (m_nCurPattern == 0) + if (_nCurPattern == 0) return false; // We do an update of the pattern, which also returns the current frame - if (m_nCurPattern != 0) { - m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); + if (_nCurPattern != 0) { + _nCurSprite = _patterns[_nCurPattern].update(_hEndPattern, _bCurFlag, _sfx); // WORKAROUND: Currently, m_nCurSprite = -1 is used to flag that an item should be removed. // However, this seems to be done inside a process waiting on an event pulsed inside the pattern // Update method. So the value of m_nCurSprite = -1 is being destroyed with the return value // replacing it. It may be that the current coroutine PulseEvent implementation is wrong somehow. // In any case, a special check here is done for items that have ended - if (m_nCurPattern == 0) - m_nCurSprite = -1; + if (_nCurPattern == 0) + _nCurSprite = -1; } // If the function returned -1, it means that the pattern has finished - if (m_nCurSprite == -1) { + if (_nCurSprite == -1) { // We have pattern 0, so leave. The class will self de-register from the OT list - m_nCurPattern = 0; + _nCurPattern = 0; return false; } // If we are not in the OT list, add ourselves if (!_nInList && bAddToList) - bigBuf->addPrim(NewItemPrimitive()); + bigBuf->addPrim(newItemPrimitive()); - return oldSprite != m_nCurSprite; + return oldSprite != _nCurSprite; } -RMPoint RMItem::CalculatePos(void) { - return m_pos + m_patterns[m_nCurPattern].Pos(); +RMPoint RMItem::calculatePos(void) { + return _pos + _patterns[_nCurPattern].pos(); } void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -692,24 +688,24 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // If CurSprite == -1, then the pattern is finished - if (m_nCurSprite == -1) + if (_nCurSprite == -1) return; // Set the flag - prim->setFlag(m_bCurFlag); + prim->setFlag(_bCurFlag); // Offset direction for scrolling - prim->Dst().Offset(-m_curScroll); + prim->Dst().Offset(-_curScroll); // We must offset the cordinates of the item inside the primitive // It is estimated as nonno + (babbo + figlio) - prim->Dst().Offset(CalculatePos()); + prim->Dst().Offset(calculatePos()); // No stretching, please prim->setStrecth(false); // Now we turn to the generic surface drawing routines - CORO_INVOKE_2(m_sprites[m_nCurSprite].draw, bigBuf, prim); + CORO_INVOKE_2(_sprites[_nCurSprite].draw, bigBuf, prim); CORO_END_CODE; } @@ -717,45 +713,45 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMItem::removeThis(CORO_PARAM, bool &result) { // Remove from the OT list if the current frame is -1 (pattern over) - result = (m_nCurSprite == -1); + result = (_nCurSprite == -1); } -void RMItem::SetStatus(int nStatus) { - m_bIsActive = (nStatus > 0); +void RMItem::setStatus(int nStatus) { + _bIsActive = (nStatus > 0); } -void RMItem::SetPattern(int nPattern, bool bPlayP0) { +void RMItem::setPattern(int nPattern, bool bPlayP0) { int i; - assert(nPattern >= 0 && nPattern <= m_nPatterns); + assert(nPattern >= 0 && nPattern <= _nPatterns); - if (m_sfx) - if (m_nCurPattern > 0) - m_patterns[m_nCurPattern].StopSfx(m_sfx); + if (_sfx) + if (_nCurPattern > 0) + _patterns[_nCurPattern].stopSfx(_sfx); // Remember the current pattern - m_nCurPattern = nPattern; + _nCurPattern = nPattern; // Start the pattern to start the animation - if (m_nCurPattern != 0) - m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); + if (_nCurPattern != 0) + _nCurSprite = _patterns[_nCurPattern].init(_sfx, bPlayP0, &_bCurFlag); else { - m_nCurSprite = -1; + _nCurSprite = -1; // Look for the sound effect for pattern 0 if (bPlayP0) - for (i = 0; i < m_nSfx; i++) - if (strcmp(m_sfx[i].m_name, "p0") == 0) - m_sfx[i].Play(); + for (i = 0; i < _nSfx; i++) + if (strcmp(_sfx[i]._name, "p0") == 0) + _sfx[i].play(); } } -bool RMItem::GetName(RMString &name) { +bool RMItem::getName(RMString &name) { char buf[256]; - mpalQueryItemName(m_mpalCode, buf); + mpalQueryItemName(_mpalCode, buf); name = buf; if (buf[0] == '\0') return false; @@ -763,64 +759,64 @@ bool RMItem::GetName(RMString &name) { } -void RMItem::Unload(void) { - if (m_patterns != NULL) { - delete[] m_patterns; - m_patterns = NULL; +void RMItem::unload(void) { + if (_patterns != NULL) { + delete[] _patterns; + _patterns = NULL; } - if (m_sprites != NULL) { - delete[] m_sprites; - m_sprites = NULL; + if (_sprites != NULL) { + delete[] _sprites; + _sprites = NULL; } - if (m_sfx != NULL) { - delete[] m_sfx; - m_sfx = NULL; + if (_sfx != NULL) { + delete[] _sfx; + _sfx = NULL; } } RMItem::RMItem() { - m_bCurFlag = 0; - m_patterns = NULL; - m_sprites = NULL; - m_sfx = NULL; - m_curScroll.Set(0, 0); - m_bInitCurPattern = true; - m_nCurPattern = 0; - m_z = 0; - m_cm = CM_256; - m_FX = 0; - m_FXparm = 0; - m_mpalCode = 0; - m_nSprites = 0; - m_nSfx = 0; - m_nPatterns = 0; - m_bPal = 0; - m_nCurSprite = 0; - - m_hEndPattern = CoroScheduler.createEvent(false, false); + _bCurFlag = 0; + _patterns = NULL; + _sprites = NULL; + _sfx = NULL; + _curScroll.Set(0, 0); + _bInitCurPattern = true; + _nCurPattern = 0; + _z = 0; + _cm = CM_256; + _FX = 0; + _FXparm = 0; + _mpalCode = 0; + _nSprites = 0; + _nSfx = 0; + _nPatterns = 0; + _bPal = 0; + _nCurSprite = 0; + + _hEndPattern = CoroScheduler.createEvent(false, false); } RMItem::~RMItem() { - Unload(); - CoroScheduler.closeEvent(m_hEndPattern); + unload(); + CoroScheduler.closeEvent(_hEndPattern); } -void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { +void RMItem::waitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; uint32 h[2]; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_nCurPattern != 0) { + if (_nCurPattern != 0) { if (hCustomSkip == CORO_INVALID_PID_VALUE) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndPattern, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hEndPattern, CORO_INFINITE); else { _ctx->h[0] = hCustomSkip; - _ctx->h[1] = m_hEndPattern; + _ctx->h[1] = _hEndPattern; CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, CORO_INFINITE); } } @@ -828,20 +824,20 @@ void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_END_CODE; } -void RMItem::ChangeHotspot(const RMPoint &pt) { - m_hot = pt; +void RMItem::changeHotspot(const RMPoint &pt) { + _hot = pt; } -void RMItem::PlaySfx(int nSfx) { - if (nSfx < m_nSfx) - m_sfx[nSfx].Play(); +void RMItem::playSfx(int nSfx) { + if (nSfx < _nSfx) + _sfx[nSfx].play(); } -void RMItem::PauseSound(bool bPause) { +void RMItem::pauseSound(bool bPause) { int i; - for (i = 0; i < m_nSfx; i++) - m_sfx[i].Pause(bPause); + for (i = 0; i < _nSfx; i++) + _sfx[i].pause(bPause); } @@ -852,13 +848,13 @@ void RMItem::PauseSound(bool bPause) { RMWipe::RMWipe() { - m_hUnregistered = CoroScheduler.createEvent(false, false); - m_hEndOfFade = CoroScheduler.createEvent(false, false); + _hUnregistered = CoroScheduler.createEvent(false, false); + _hEndOfFade = CoroScheduler.createEvent(false, false); } RMWipe::~RMWipe() { - CoroScheduler.closeEvent(m_hUnregistered); - CoroScheduler.closeEvent(m_hEndOfFade); + CoroScheduler.closeEvent(_hUnregistered); + CoroScheduler.closeEvent(_hEndOfFade); } int RMWipe::priority(void) { @@ -868,23 +864,23 @@ int RMWipe::priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); assert(_nInList == 0); - CoroScheduler.setEvent(m_hUnregistered); + CoroScheduler.setEvent(_hUnregistered); } void RMWipe::removeThis(CORO_PARAM, bool &result) { - result = m_bUnregister; + result = _bUnregister; } -void RMWipe::WaitForFadeEnd(CORO_PARAM) { +void RMWipe::waitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hEndOfFade, CORO_INFINITE); - m_bEndFade = true; - m_bFading = false; + _bEndFade = true; + _bFading = false; CORO_INVOKE_0(mainWaitFrame); CORO_INVOKE_0(mainWaitFrame); @@ -892,44 +888,44 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_END_CODE; } -void RMWipe::CloseFade(void) { - m_wip0r.Unload(); +void RMWipe::closeFade(void) { + _wip0r.unload(); } -void RMWipe::InitFade(int type) { +void RMWipe::initFade(int type) { // Activate the fade - m_bUnregister = false; - m_bEndFade = false; + _bUnregister = false; + _bEndFade = false; - m_nFadeStep = 0; + _nFadeStep = 0; - m_bMustRegister = true; + _bMustRegister = true; RMRes res(RES_W_CERCHIO); RMDataStream ds; ds.OpenBuffer(res); - ds >> m_wip0r; + ds >> _wip0r; ds.Close(); - m_wip0r.SetPattern(1); + _wip0r.setPattern(1); - m_bFading = true; + _bFading = true; } -void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { - if (m_bMustRegister) { +void RMWipe::doFrame(RMGfxTargetBuffer &bigBuf) { + if (_bMustRegister) { bigBuf.addPrim(new RMGfxPrimitive(this)); - m_bMustRegister = false; + _bMustRegister = false; } - if (m_bFading) { - m_wip0r.doFrame(&bigBuf, false); + if (_bFading) { + _wip0r.doFrame(&bigBuf, false); - m_nFadeStep++; + _nFadeStep++; - if (m_nFadeStep == 10) { - CoroScheduler.setEvent(m_hEndOfFade); + if (_nFadeStep == 10) { + CoroScheduler.setEvent(_hEndOfFade); } } } @@ -940,18 +936,16 @@ void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); - if (m_bFading) { - CORO_INVOKE_2(m_wip0r.draw, bigBuf, prim); + if (_bFading) { + CORO_INVOKE_2(_wip0r.draw, bigBuf, prim); } - if (m_bEndFade) + if (_bEndFade) Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.getDimx() * bigBuf.getDimy() * 2, 0x0); CORO_END_CODE; } - - /****************************************************************************\ * RMCharacter Methods \****************************************************************************/ @@ -961,7 +955,7 @@ void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /* Returns path along the vector path path[] */ /****************************************************************************/ -short RMCharacter::FindPath(short source, short destination) { +short RMCharacter::findPath(short source, short destination) { static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated @@ -977,7 +971,7 @@ short RMCharacter::FindPath(short source, short destination) { } // Get the boxes - cur = theBoxes->GetBoxes(curLocation); + cur = theBoxes->getBoxes(curLocation); // Make a backup copy to work on for (i = 0; i < cur->numbbox; i++) @@ -1055,22 +1049,22 @@ short RMCharacter::FindPath(short source, short destination) { } -void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { +void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_pos == destcoord) { + if (_pos == destcoord) { if (minpath == 0) { - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); CoroScheduler.pulseEvent(hEndOfPath); return; } } status = WALK; - linestart = m_pos; + linestart = _pos; lineend = destcoord; dx = linestart.x - lineend.x; dy = linestart.y - lineend.y; @@ -1085,7 +1079,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { while (0) ; } - int nPatt = GetCurPattern(); + int nPatt = getCurPattern(); if (dx > dy) { slope = fy / fx; @@ -1097,10 +1091,10 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKLEFT) - SetPattern(PAT_WALKLEFT); + setPattern(PAT_WALKLEFT); } else { if (nPatt != PAT_WALKRIGHT) - SetPattern(PAT_WALKRIGHT); + setPattern(PAT_WALKRIGHT); } } else { slope = fx / fy; @@ -1111,10 +1105,10 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKUP) - SetPattern(PAT_WALKUP); + setPattern(PAT_WALKUP); } else { if (nPatt != PAT_WALKDOWN) - SetPattern(PAT_WALKDOWN); + setPattern(PAT_WALKDOWN); } } @@ -1125,7 +1119,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { } -RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto) { +RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto) { short passi, minimo; RMPoint nuovo, trovato; minimo = 32000; @@ -1133,12 +1127,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.y--; // to avoid error? trovato = nuovo; @@ -1148,12 +1142,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.y++; // to avoid error? trovato = nuovo; @@ -1163,12 +1157,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.x++; // to avoid error? trovato = nuovo; @@ -1178,12 +1172,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.x--; // to avoid error? trovato = nuovo; @@ -1195,18 +1189,18 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin } -RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { - return Searching(1, 1, 1, 1, punto); +RMPoint RMCharacter::nearestPoint(const RMPoint &punto) { + return searching(1, 1, 1, 1, punto); } -short RMCharacter::ScanLine(const RMPoint &punto) { +short RMCharacter::scanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; signed char Lspeed, Lstatus; - Lstart = m_pos; + Lstart = _pos; Lend = punto; Ldx = Lstart.x - Lend.x; Ldy = Lstart.y - Lend.y; @@ -1228,7 +1222,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { } Lscan = Lstart; // Start scanning - while (InWhichBox(Lscan) != -1) { + while (inWhichBox(Lscan) != -1) { Lcount++; if (Lstatus) { Ldx = Lspeed * Lcount; @@ -1250,14 +1244,14 @@ short RMCharacter::ScanLine(const RMPoint &punto) { /** * Calculates intersections between the straight line and the closest BBOX */ -RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { +RMPoint RMCharacter::invScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; signed char Lspeed, Lstatus, Lbox = -1; Lstart = punto; // Exchange! - Lend = m_pos; // :-) + Lend = _pos; // :-) Ldx = Lstart.x - Lend.x; Ldy = Lstart.y - Lend.y; Lfx = Ldx; @@ -1279,12 +1273,12 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { Lscan = Lstart; for (;;) { - if (InWhichBox(Lscan) != -1) { - if (InWhichBox(Lscan) != Lbox) { - if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos), InWhichBox(Lscan))) + if (inWhichBox(Lscan) != -1) { + if (inWhichBox(Lscan) != Lbox) { + if (inWhichBox(_pos) == inWhichBox(Lscan) || findPath(inWhichBox(_pos), inWhichBox(Lscan))) return Lscan; else - Lbox = InWhichBox(Lscan); + Lbox = inWhichBox(Lscan); } } @@ -1310,17 +1304,17 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { * Returns the HotSpot coordinate closest to the player */ -RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { +RMPoint RMCharacter::nearestHotSpot(int sourcebox, int destbox) { RMPoint puntocaldo; short cc; int x, y, distanzaminima; distanzaminima = 10000000; - RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + RMBoxLoc *cur = theBoxes->getBoxes(curLocation); for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { - x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); - y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); + x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - _pos.x); + y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - _pos.y); if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; @@ -1339,7 +1333,7 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); if (bDrawNow) { - prim->Dst() += m_fixedScroll; + prim->Dst() += _fixedScroll; CORO_INVOKE_2(RMItem::draw, bigBuf, prim); } @@ -1347,39 +1341,39 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_END_CODE; } -void RMCharacter::NewBoxEntered(int nBox) { +void RMCharacter::newBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); - cur = theBoxes->GetBoxes(curLocation); + cur = theBoxes->getBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; curbox = nBox; // If Z is changed, we must remove it from the OT - if (cur->boxes[curbox].Zvalue != m_z) { + if (cur->boxes[curbox].Zvalue != _z) { bRemoveFromOT = true; - m_z = cur->boxes[curbox].Zvalue; + _z = cur->boxes[curbox].Zvalue; } // Movement management is reversed, only if we are not in the shortest path. If we are in the shortest // path, directly do the DoFrame if (bMovingWithoutMinpath) { if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_WALKUP: - SetPattern(PAT_WALKDOWN); + setPattern(PAT_WALKDOWN); break; case PAT_WALKDOWN: - SetPattern(PAT_WALKUP); + setPattern(PAT_WALKUP); break; case PAT_WALKRIGHT: - SetPattern(PAT_WALKLEFT); + setPattern(PAT_WALKLEFT); break; case PAT_WALKLEFT: - SetPattern(PAT_WALKRIGHT); + setPattern(PAT_WALKRIGHT); break; } } @@ -1389,7 +1383,7 @@ void RMCharacter::NewBoxEntered(int nBox) { mpalQueryDoAction(2, curLocation, curbox); } -void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { +void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CONTEXT; bool bEndNow; RMBoxLoc *cur; @@ -1409,12 +1403,12 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (walkstatus == 1) { dx = walkspeed * walkcount; dy = slope * dx; - m_pos.x = linestart.x + dx; - m_pos.y = linestart.y + dy; + _pos.x = linestart.x + dx; + _pos.y = linestart.y + dy; // Right - if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { - m_pos = lineend; + if (((walkspeed > 0) && (_pos.x > lineend.x)) || ((walkspeed < 0) && (_pos.x < lineend.x))) { + _pos = lineend; status = STAND; _ctx->bEndNow = true; } @@ -1424,27 +1418,27 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (walkstatus == 0) { dy = walkspeed * walkcount; dx = slope * dy; - m_pos.x = linestart.x + dx; - m_pos.y = linestart.y + dy; + _pos.x = linestart.x + dx; + _pos.y = linestart.y + dy; // Down - if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { - m_pos = lineend; + if (((walkspeed > 0) && (_pos.y > lineend.y)) || ((walkspeed < 0) && (_pos.y < lineend.y))) { + _pos = lineend; status = STAND; _ctx->bEndNow = true; } } // Check if the character came out of the BOX in error, in which case he returns immediately - if (InWhichBox(m_pos) == -1) { - m_pos.x = linestart.x + olddx; - m_pos.y = linestart.y + olddy; + if (inWhichBox(_pos) == -1) { + _pos.x = linestart.x + olddx; + _pos.y = linestart.y + olddy; } // If we have just moved to a temporary location, and is over the shortest path, we stop permanently if (_ctx->bEndNow && minpath == 0) { if (!bEndOfPath) - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } @@ -1454,8 +1448,8 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // Update the character Z. @@@ Should remove only if the Z was changed // Check if the box was changed - if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) - NewBoxEntered(InWhichBox(m_pos)); + if (!theBoxes->isInBox(curLocation, curbox, _pos)) + newBoxEntered(inWhichBox(_pos)); // Update the old coordinates olddx = dx; @@ -1466,7 +1460,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (status == STAND) { // Check if there is still the shortest path to calculate if (minpath == 1) { - _ctx->cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->getBoxes(curLocation); // If we still have to go through a box if (pathcount < pathlenght) { @@ -1474,7 +1468,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); + CORO_INVOKE_2(goTo, nearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); pathcount++; } else { // If the box is off, we can only block all @@ -1482,7 +1476,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // the search for the minimum path minpath = 0; if (!bEndOfPath) - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } @@ -1491,7 +1485,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; - CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed); + CORO_INVOKE_2(goTo, pathend, _ctx->cur->boxes[inWhichBox(pathend)].bReversed); } } } @@ -1504,7 +1498,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_END_CODE; } -void RMCharacter::Stop(CORO_PARAM) { +void RMCharacter::stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1521,37 +1515,37 @@ void RMCharacter::Stop(CORO_PARAM) { bNeedToStop = false; - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_WALKUP: - SetPattern(PAT_STANDUP); + setPattern(PAT_STANDUP); break; case PAT_WALKDOWN: - SetPattern(PAT_STANDDOWN); + setPattern(PAT_STANDDOWN); break; case PAT_WALKLEFT: - SetPattern(PAT_STANDLEFT); + setPattern(PAT_STANDLEFT); break; case PAT_WALKRIGHT: - SetPattern(PAT_STANDRIGHT); + setPattern(PAT_STANDRIGHT); break; default: - SetPattern(PAT_STANDDOWN); + setPattern(PAT_STANDDOWN); break; } CORO_END_CODE; } -inline int RMCharacter::InWhichBox(const RMPoint &pt) { - return theBoxes->WhichBox(curLocation, pt); +inline int RMCharacter::inWhichBox(const RMPoint &pt) { + return theBoxes->whichBox(curLocation, pt); } -void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { +void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CONTEXT; RMPoint dest; int numbox; @@ -1566,34 +1560,34 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { if (pt.x == 0 && pt.y == 0) { minpath = 0; status = STAND; - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); if (result) *result = true; return; } // If clicked outside the box - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = inWhichBox(pt); if (_ctx->numbox == -1) { // Find neareste point inside the box - _ctx->dest = NearestPoint(pt); + _ctx->dest = nearestPoint(pt); // ???!?? if (_ctx->dest == pt) - _ctx->dest = InvScanLine(pt); + _ctx->dest = invScanLine(pt); pt = _ctx->dest; - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = inWhichBox(pt); } - _ctx->cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->getBoxes(curLocation); minpath = 0; status = STAND; bMovingWithoutMinpath = true; - if (ScanLine(pt)) - CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); - else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + if (scanLine(pt)) + CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; pathcount = 1; @@ -1601,12 +1595,12 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { } else { // @@@ This case is whether a hotspot is inside a box, but there is // a path to get there. We use the InvScanLine to search around a point - _ctx->dest = InvScanLine(pt); + _ctx->dest = invScanLine(pt); pt = _ctx->dest; - if (ScanLine(pt)) - CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); - else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + if (scanLine(pt)) + CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; pathcount = 1; @@ -1627,25 +1621,25 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_END_CODE; } -void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { +void RMCharacter::setPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; minpath = 0; status = STAND; - m_pos = pt; + _pos = pt; if (newloc != -1) curLocation = newloc; // Update the character's Z value - box = theBoxes->GetBoxes(curLocation); - curbox = InWhichBox(m_pos); + box = theBoxes->getBoxes(curLocation); + curbox = inWhichBox(_pos); assert(curbox != -1); - m_z = box->boxes[curbox].Zvalue; + _z = box->boxes[curbox].Zvalue; bRemoveFromOT = true; } -void RMCharacter::WaitForEndMovement(CORO_PARAM) { +void RMCharacter::waitForEndMovement(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1694,7 +1688,7 @@ RMCharacter::RMCharacter() { bDrawNow = false; bNeedToStop = false; - m_pos.Set(0, 0); + _pos.Set(0, 0); } RMCharacter::~RMCharacter() { @@ -1702,7 +1696,7 @@ RMCharacter::~RMCharacter() { CoroScheduler.closeEvent(hEndOfPath); } -void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { +void RMCharacter::linkToBoxes(RMGameBoxes *boxes) { theBoxes = boxes; } @@ -1710,7 +1704,7 @@ void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { * RMBox Methods \****************************************************************************/ -void RMBox::ReadFromStream(RMDataStream &ds) { +void RMBox::readFromStream(RMDataStream &ds) { uint16 w; int i; byte b; @@ -1749,7 +1743,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { } RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { - box.ReadFromStream(ds); + box.readFromStream(ds); return ds; } @@ -1766,7 +1760,7 @@ RMBoxLoc::~RMBoxLoc() { delete[] boxes; } -void RMBoxLoc::ReadFromStream(RMDataStream &ds) { +void RMBoxLoc::readFromStream(RMDataStream &ds) { int i; char buf[2]; byte ver; @@ -1788,7 +1782,7 @@ void RMBoxLoc::ReadFromStream(RMDataStream &ds) { } -void RMBoxLoc::RecalcAllAdj(void) { +void RMBoxLoc::recalcAllAdj(void) { int i, j; for (i = 0; i < numbbox; i++) { @@ -1801,7 +1795,7 @@ void RMBoxLoc::RecalcAllAdj(void) { } RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { - bl.ReadFromStream(ds); + bl.readFromStream(ds); return ds; } @@ -1811,45 +1805,45 @@ RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { \****************************************************************************/ RMGameBoxes::RMGameBoxes() { - m_nLocBoxes = 0; - Common::fill(m_allBoxes, m_allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL); + _nLocBoxes = 0; + Common::fill(_allBoxes, _allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL); } RMGameBoxes::~RMGameBoxes() { - for (int i = 1; i <= m_nLocBoxes; ++i) - delete m_allBoxes[i]; + for (int i = 1; i <= _nLocBoxes; ++i) + delete _allBoxes[i]; } -void RMGameBoxes::Init(void) { +void RMGameBoxes::init(void) { int i; RMString fn; RMDataStream ds; // Load boxes from disk - m_nLocBoxes = 130; - for (i = 1; i <= m_nLocBoxes; i++) { + _nLocBoxes = 130; + for (i = 1; i <= _nLocBoxes; i++) { RMRes res(10000 + i); ds.OpenBuffer(res); - m_allBoxes[i] = new RMBoxLoc(); - ds >> *m_allBoxes[i]; + _allBoxes[i] = new RMBoxLoc(); + ds >> *_allBoxes[i]; - m_allBoxes[i]->RecalcAllAdj(); + _allBoxes[i]->recalcAllAdj(); ds.Close(); } } -void RMGameBoxes::Close(void) { +void RMGameBoxes::close(void) { } -RMBoxLoc *RMGameBoxes::GetBoxes(int nLoc) { - return m_allBoxes[nLoc]; +RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { + return _allBoxes[nLoc]; } -bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { - RMBoxLoc *cur = GetBoxes(nLoc); +bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { + RMBoxLoc *cur = getBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) @@ -1858,11 +1852,12 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { return false; } -int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { +int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { int i; - RMBoxLoc *cur = GetBoxes(nLoc); + RMBoxLoc *cur = getBoxes(nLoc); - if (!cur) return -1; + if (!cur) + return -1; for (i = 0; i < cur->numbbox; i++) if (cur->boxes[i].attivo) @@ -1873,44 +1868,44 @@ int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { return -1; } -void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { - m_allBoxes[nLoc]->boxes[nBox].attivo = status; - m_allBoxes[nLoc]->RecalcAllAdj(); +void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { + _allBoxes[nLoc]->boxes[nBox].attivo = status; + _allBoxes[nLoc]->recalcAllAdj(); } -int RMGameBoxes::GetSaveStateSize(void) { +int RMGameBoxes::getSaveStateSize(void) { int size; int i; size = 4; - for (i = 1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= _nLocBoxes; i++) { size += 4; - size += m_allBoxes[i]->numbbox; + size += _allBoxes[i]->numbbox; } return size; } -void RMGameBoxes::SaveState(byte *state) { +void RMGameBoxes::saveState(byte *state) { int i, j; // Save the number of locations with boxes - WRITE_LE_UINT32(state, m_nLocBoxes); + WRITE_LE_UINT32(state, _nLocBoxes); state += 4; // For each location, write out the number of boxes and their status - for (i = 1; i <= m_nLocBoxes; i++) { - WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); + for (i = 1; i <= _nLocBoxes; i++) { + WRITE_LE_UINT32(state, _allBoxes[i]->numbbox); state += 4; - for (j = 0; j < m_allBoxes[i]->numbbox; j++) - *state++ = m_allBoxes[i]->boxes[j].attivo; + for (j = 0; j < _allBoxes[i]->numbbox; j++) + *state++ = _allBoxes[i]->boxes[j].attivo; } } -void RMGameBoxes::LoadState(byte *state) { +void RMGameBoxes::loadState(byte *state) { int i, j; int nloc, nbox; @@ -1918,7 +1913,7 @@ void RMGameBoxes::LoadState(byte *state) { nloc = READ_LE_UINT32(state); state += 4; - assert(nloc <= m_nLocBoxes); + assert(nloc <= _nLocBoxes); // For each location, read the number of boxes and their status for (i = 1; i <= nloc; i++) { @@ -1926,13 +1921,13 @@ void RMGameBoxes::LoadState(byte *state) { state += 4; for (j = 0; j < nbox ; j++) { - if (j < m_allBoxes[i]->numbbox) - m_allBoxes[i]->boxes[j].attivo = *state; + if (j < _allBoxes[i]->numbbox) + _allBoxes[i]->boxes[j].attivo = *state; state++; } - m_allBoxes[i]->RecalcAllAdj(); + _allBoxes[i]->recalcAllAdj(); } } @@ -1944,9 +1939,9 @@ void RMGameBoxes::LoadState(byte *state) { * Standard constructor */ RMLocation::RMLocation() { - m_nItems = 0; - m_items = NULL; - m_buf = NULL; + _nItems = 0; + _items = NULL; + _buf = NULL; } @@ -1955,7 +1950,7 @@ RMLocation::RMLocation() { * * @param lpszFileName Name of the file */ -bool RMLocation::Load(const char *lpszFileName) { +bool RMLocation::load(const char *lpszFileName) { Common::File f; bool bRet; @@ -1964,7 +1959,7 @@ bool RMLocation::Load(const char *lpszFileName) { return false; // Passes to the method variation for loading from the opened file - bRet = Load(f); + bRet = load(f); // Close the file f.close(); @@ -1980,7 +1975,7 @@ bool RMLocation::Load(const char *lpszFileName) { * * @returns True if succeeded OK, false in case of error. */ -bool RMLocation::Load(Common::File &file) { +bool RMLocation::load(Common::File &file) { int size; bool bRet; @@ -1991,19 +1986,19 @@ bool RMLocation::Load(Common::File &file) { RMFileStreamSlow fs; fs.OpenFile(file); - bRet = Load(fs); + bRet = load(fs); fs.Close(); return bRet; } -bool RMLocation::Load(const byte *buf) { +bool RMLocation::load(const byte *buf) { RMDataStream ds; bool bRet; ds.OpenBuffer(buf); - bRet = Load(ds); + bRet = load(ds); ds.Close(); return bRet; } @@ -2015,7 +2010,7 @@ bool RMLocation::Load(const byte *buf) { * @param ds Data stream * @returns True if succeeded OK, false in case of error. */ -bool RMLocation::Load(RMDataStream &ds) { +bool RMLocation::load(RMDataStream &ds) { char id[3]; int dimx, dimy; byte ver; @@ -2027,7 +2022,7 @@ bool RMLocation::Load(RMDataStream &ds) { // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') - return LoadLOX(ds); + return loadLOX(ds); // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') @@ -2038,7 +2033,7 @@ bool RMLocation::Load(RMDataStream &ds) { assert(ver == 6); // Location name - ds >> m_name; + ds >> _name; // Skip the MPAL bailouts (64 bytes) ds >> TEMPNumLoc; @@ -2050,20 +2045,20 @@ bool RMLocation::Load(RMDataStream &ds) { // Location dimensions ds >> dimx >> dimy; - m_curScroll.Set(0, 0); + _curScroll.Set(0, 0); // Read the colour mode ds >> cm; - m_cmode = (RMColorMode)cm; + _cmode = (RMColorMode)cm; // Initialise the source buffer and read the location - switch (m_cmode) { + switch (_cmode) { case CM_256: - m_buf = new RMGfxSourceBuffer8; + _buf = new RMGfxSourceBuffer8; break; case CM_65K: - m_buf = new RMGfxSourceBuffer16; + _buf = new RMGfxSourceBuffer16; break; default: @@ -2072,29 +2067,29 @@ bool RMLocation::Load(RMDataStream &ds) { }; // Initialise the surface, loading the palette if necessary - m_buf->init(ds, dimx, dimy, true); + _buf->init(ds, dimx, dimy, true); // Check the size of the location // assert(dimy!=512); // Number of objects - ds >> m_nItems; + ds >> _nItems; // Create and read in the objects - if (m_nItems > 0) - m_items = new RMItem[m_nItems]; + if (_nItems > 0) + _items = new RMItem[_nItems]; _vm->freezeTime(); - for (i = 0; i < m_nItems && !ds.IsError(); i++) - ds >> m_items[i]; + for (i = 0; i < _nItems && !ds.IsError(); i++) + ds >> _items[i]; _vm->unfreezeTime(); return ds.IsError(); } -bool RMLocation::LoadLOX(RMDataStream &ds) { +bool RMLocation::loadLOX(RMDataStream &ds) { int dimx, dimy; byte ver; int i; @@ -2104,7 +2099,7 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { assert(ver == 1); // Location name - ds >> m_name; + ds >> _name; // Location number ds >> TEMPNumLoc; @@ -2112,24 +2107,24 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { // Dimensions ds >> dimx >> dimy; - m_curScroll.Set(0, 0); + _curScroll.Set(0, 0); // It's always 65K (16-bit) mode - m_cmode = CM_65K; - m_buf = new RMGfxSourceBuffer16; + _cmode = CM_65K; + _buf = new RMGfxSourceBuffer16; // Initialise the surface, loading in the palette if necessary - m_buf->init(ds, dimx, dimy, true); + _buf->init(ds, dimx, dimy, true); // Number of items - ds >> m_nItems; + ds >> _nItems; // Create and read objects - if (m_nItems > 0) - m_items = new RMItem[m_nItems]; + if (_nItems > 0) + _items = new RMItem[_nItems]; - for (i = 0; i < m_nItems && !ds.IsError(); i++) - m_items[i].ReadFromStream(ds, true); + for (i = 0; i < _nItems && !ds.IsError(); i++) + _items[i].readFromStream(ds, true); return ds.IsError(); } @@ -2145,14 +2140,14 @@ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->getDimy() > RM_SY || m_buf->getDimx() > RM_SX) { - prim->setSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); + if (_buf->getDimy() > RM_SY || _buf->getDimx() > RM_SX) { + prim->setSrc(RMRect(_curScroll, _curScroll + RMPoint(640, 480))); } - prim->setDst(m_fixedScroll); + prim->setDst(_fixedScroll); // Invoke the drawing method fo the image class, which will draw the location background - CORO_INVOKE_2(m_buf->draw, bigBuf, prim); + CORO_INVOKE_2(_buf->draw, bigBuf, prim); CORO_END_CODE; } @@ -2169,29 +2164,29 @@ void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->addPrim(new RMGfxPrimitive(this)); // Process all the location items - for (i = 0; i < m_nItems; i++) - m_items[i].doFrame(bigBuf); + for (i = 0; i < _nItems; i++) + _items[i].doFrame(bigBuf); } -RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { +RMItem *RMLocation::getItemFromCode(uint32 dwCode) { int i; - for (i = 0; i < m_nItems; i++) - if (m_items[i].MpalCode() == (int)dwCode) - return &m_items[i]; + for (i = 0; i < _nItems; i++) + if (_items[i].mpalCode() == (int)dwCode) + return &_items[i]; return NULL; } -RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { +RMItem *RMLocation::whichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; - for (int i = 0; i < m_nItems; i++) { + for (int i = 0; i < _nItems; i++) { size = 0; - if (m_items[i].IsIn(pt, &size)) { + if (_items[i].isIn(pt, &size)) { if (found == -1 || size < foundSize) { foundSize = size; found = i; @@ -2202,97 +2197,97 @@ RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { if (found == -1) return NULL; else - return &m_items[found]; + return &_items[found]; } RMLocation::~RMLocation() { - Unload(); + unload(); } -void RMLocation::Unload(void) { +void RMLocation::unload(void) { // Clear memory - if (m_items) { - delete[] m_items; - m_items = NULL; + if (_items) { + delete[] _items; + _items = NULL; } // Destroy the buffer - if (m_buf) { - delete m_buf; - m_buf = NULL; + if (_buf) { + delete _buf; + _buf = NULL; } } -void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { - RMPoint oldScroll = m_curScroll; +void RMLocation::updateScrolling(const RMPoint &ptShowThis) { + RMPoint oldScroll = _curScroll; - if (m_curScroll.x + 250 > ptShowThis.x) { - m_curScroll.x = ptShowThis.x - 250; - } else if (m_curScroll.x + RM_SX - 250 < ptShowThis.x) { - m_curScroll.x = ptShowThis.x + 250 - RM_SX; - } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->getDimx() > RM_SX) { - if (m_curScroll.x + RM_SX / 2 < ptShowThis.x) - m_curScroll.x++; + if (_curScroll.x + 250 > ptShowThis.x) { + _curScroll.x = ptShowThis.x - 250; + } else if (_curScroll.x + RM_SX - 250 < ptShowThis.x) { + _curScroll.x = ptShowThis.x + 250 - RM_SX; + } else if (ABS(_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && _buf->getDimx() > RM_SX) { + if (_curScroll.x + RM_SX / 2 < ptShowThis.x) + _curScroll.x++; else - m_curScroll.x--; + _curScroll.x--; } - if (m_curScroll.y + 180 > ptShowThis.y) { - m_curScroll.y = ptShowThis.y - 180; - } else if (m_curScroll.y + RM_SY - 180 < ptShowThis.y) { - m_curScroll.y = ptShowThis.y + 180 - RM_SY; - } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->getDimy() > RM_SY) { - if (m_curScroll.y + RM_SY / 2 < ptShowThis.y) - m_curScroll.y++; + if (_curScroll.y + 180 > ptShowThis.y) { + _curScroll.y = ptShowThis.y - 180; + } else if (_curScroll.y + RM_SY - 180 < ptShowThis.y) { + _curScroll.y = ptShowThis.y + 180 - RM_SY; + } else if (ABS(_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && _buf->getDimy() > RM_SY) { + if (_curScroll.y + RM_SY / 2 < ptShowThis.y) + _curScroll.y++; else - m_curScroll.y--; + _curScroll.y--; } - if (m_curScroll.x < 0) - m_curScroll.x = 0; - if (m_curScroll.y < 0) - m_curScroll.y = 0; - if (m_curScroll.x + RM_SX > m_buf->getDimx()) - m_curScroll.x = m_buf->getDimx() - RM_SX; - if (m_curScroll.y + RM_SY > m_buf->getDimy()) - m_curScroll.y = m_buf->getDimy() - RM_SY; + if (_curScroll.x < 0) + _curScroll.x = 0; + if (_curScroll.y < 0) + _curScroll.y = 0; + if (_curScroll.x + RM_SX > _buf->getDimx()) + _curScroll.x = _buf->getDimx() - RM_SX; + if (_curScroll.y + RM_SY > _buf->getDimy()) + _curScroll.y = _buf->getDimy() - RM_SY; - if (oldScroll != m_curScroll) - for (int i = 0; i < m_nItems; i++) - m_items[i].SetScrollPosition(m_curScroll); + if (oldScroll != _curScroll) + for (int i = 0; i < _nItems; i++) + _items[i].setScrollPosition(_curScroll); } -void RMLocation::SetFixedScroll(const RMPoint &scroll) { - m_fixedScroll = scroll; +void RMLocation::setFixedScroll(const RMPoint &scroll) { + _fixedScroll = scroll; - for (int i = 0; i < m_nItems; i++) - m_items[i].SetScrollPosition(m_curScroll - m_fixedScroll); + for (int i = 0; i < _nItems; i++) + _items[i].setScrollPosition(_curScroll - _fixedScroll); } -void RMLocation::SetScrollPosition(const RMPoint &scroll) { +void RMLocation::setScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX > m_buf->getDimx()) - pt.x = m_buf->getDimx() - RM_SX; - if (pt.y + RM_SY > m_buf->getDimy()) - pt.y = m_buf->getDimy() - RM_SY; + if (pt.x + RM_SX > _buf->getDimx()) + pt.x = _buf->getDimx() - RM_SX; + if (pt.y + RM_SY > _buf->getDimy()) + pt.y = _buf->getDimy() - RM_SY; - m_curScroll = pt; + _curScroll = pt; - for (int i = 0; i < m_nItems; i++) - m_items[i].SetScrollPosition(m_curScroll); + for (int i = 0; i < _nItems; i++) + _items[i].setScrollPosition(_curScroll); } -void RMLocation::PauseSound(bool bPause) { +void RMLocation::pauseSound(bool bPause) { int i; - for (i = 0; i < m_nItems; i++) - m_items[i].PauseSound(bPause); + for (i = 0; i < _nItems; i++) + _items[i].pauseSound(bPause); } @@ -2301,7 +2296,7 @@ void RMLocation::PauseSound(bool bPause) { \****************************************************************************/ RMMessage::RMMessage(uint32 dwId) { - Load(dwId); + load(dwId); } RMMessage::RMMessage() { @@ -2313,15 +2308,15 @@ RMMessage::~RMMessage() { GlobalFree(lpMessage); } -void RMMessage::Load(uint32 dwId) { +void RMMessage::load(uint32 dwId) { lpMessage = mpalQueryMessage(dwId); assert(lpMessage != NULL); if (lpMessage) - ParseMessage(); + parseMessage(); } -void RMMessage::ParseMessage(void) { +void RMMessage::parseMessage(void) { char *p; assert(lpMessage != NULL); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index abcdcb85a2..e465b113b2 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -59,7 +59,7 @@ typedef enum { */ class RMPalette { public: - byte m_data[1024]; + byte _data[1024]; public: friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); @@ -71,9 +71,9 @@ public: */ class RMSfx { public: - RMString m_name; - FPSFX *m_fx; - bool m_bPlayingLoop; + RMString _name; + FPSFX *_fx; + bool _bPlayingLoop; public: RMSfx(); @@ -81,12 +81,12 @@ public: friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); - void Play(bool bLoop = false); - void SetVolume(int vol); - void Pause(bool bPause); - void Stop(void); + void play(bool bLoop = false); + void setVolume(int vol); + void pause(bool bPause); + void stop(void); - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -108,38 +108,38 @@ public: // Class slot class RMSlot { private: - RMPoint m_pos; // Child co-ordinates + RMPoint _pos; // Child co-ordinates public: - RMSlotType m_type; - int m_data; - byte m_flag; + RMSlotType _type; + int _data; + byte _flag; public: friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint Pos() { - return m_pos; + RMPoint pos() { + return _pos; } - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); }; public: - RMString m_name; + RMString _name; private: - int m_speed; - RMPoint m_pos; // Parent coordinates - RMPoint m_curPos; // Parent + child coordinates - int m_bLoop; - int m_nSlots; - int m_nCurSlot; - int m_nCurSprite; + int _speed; + RMPoint _pos; // Parent coordinates + RMPoint _curPos; // Parent + child coordinates + int _bLoop; + int _nSlots; + int _nCurSlot; + int _nCurSprite; - RMSlot *m_slots; + RMSlot *_slots; - uint32 m_nStartTime; + uint32 _nStartTime; public: RMPattern(); @@ -148,24 +148,24 @@ public: friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); // A warning that the pattern now and the current - int Init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); + int init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); // Update the pattern, checking to see if it's time to change slot and executing // any associated commands - int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); + int update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); // Stop a sound effect - void StopSfx(RMSfx *sfx); + void stopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint Pos() { - return m_curPos; + RMPoint pos() { + return _curPos; } - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); private: - void UpdateCoord(void); + void updateCoord(void); }; @@ -174,24 +174,24 @@ private: */ class RMSprite : public RMGfxTask { public: - RMString m_name; - RMRect m_rcBox; + RMString _name; + RMRect _rcBox; protected: - RMGfxSourceBuffer *m_buf; + RMGfxSourceBuffer *_buf; public: RMSprite(); virtual ~RMSprite(); - void Init(RMGfxSourceBuffer *buf); + void init(RMGfxSourceBuffer *buf); friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void SetPalette(byte *lpBuf); - void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void setPalette(byte *lpBuf); + void getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -200,42 +200,42 @@ public: */ class RMItem : public RMGfxTask { public: - RMString m_name; + RMString _name; protected: - int m_z; - RMPoint m_pos; // Coordinate nonno - RMColorMode m_cm; - RMPoint m_curScroll; + int _z; + RMPoint _pos; // Coordinate nonno + RMColorMode _cm; + RMPoint _curScroll; - byte m_FX; - byte m_FXparm; + byte _FX; + byte _FXparm; - virtual int GetCurPattern() { - return m_nCurPattern; + virtual int getCurPattern() { + return _nCurPattern; } private: - int m_nCurPattern; - int m_mpalCode; - RMPoint m_hot; - RMRect m_rcBox; - int m_nSprites, m_nSfx, m_nPatterns; - byte m_bPal; - RMPalette m_pal; - - RMSprite *m_sprites; - RMSfx *m_sfx; - RMPattern *m_patterns; - - byte m_bCurFlag; - int m_nCurSprite; - bool m_bIsActive; - uint32 m_hEndPattern; - bool m_bInitCurPattern; + int _nCurPattern; + int _mpalCode; + RMPoint _hot; + RMRect _rcBox; + int _nSprites, _nSfx, _nPatterns; + byte _bPal; + RMPalette _pal; + + RMSprite *_sprites; + RMSfx *_sfx; + RMPattern *_patterns; + + byte _bCurFlag; + int _nCurSprite; + bool _bIsActive; + uint32 _hEndPattern; + bool _bInitCurPattern; public: - RMPoint CalculatePos(void); + RMPoint calculatePos(void); public: RMItem(); @@ -248,7 +248,7 @@ public: bool doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); // Sets the current scrolling position - void SetScrollPosition(const RMPoint &scroll); + void setScrollPosition(const RMPoint &scroll); // Overloading of check whether to remove from active list virtual void removeThis(CORO_PARAM, bool &result); @@ -258,54 +258,54 @@ public: // Overloaded priority: it's based on Z ordering virtual int priority() { - return m_z; + return _z; } // Pattern number - int NumPattern() { - return m_nPatterns; + int numPattern() { + return _nPatterns; } // Set anew animation pattern, changing abruptly from the current - virtual void SetPattern(int nPattern, bool bPlayP0 = false); + virtual void setPattern(int nPattern, bool bPlayP0 = false); // Set a new status - void SetStatus(int nStatus); + void setStatus(int nStatus); - bool IsIn(const RMPoint &pt, int *size = NULL); - RMPoint Hotspot() { - return m_hot; + bool isIn(const RMPoint &pt, int *size = NULL); + RMPoint hotspot() { + return _hot; } - bool GetName(RMString &name); - int MpalCode() { - return m_mpalCode; + bool getName(RMString &name); + int mpalCode() { + return _mpalCode; } // Unload - void Unload(void); + void unload(void); // Wait for the end of the current pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); + void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); // Sets a new hotspot fro the object - void ChangeHotspot(const RMPoint &pt); + void changeHotspot(const RMPoint &pt); - void SetInitCurPattern(bool status) { - m_bInitCurPattern = status; + void setInitCurPattern(bool status) { + _bInitCurPattern = status; } - void PlaySfx(int nSfx); + void playSfx(int nSfx); - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); - void PauseSound(bool bPause); + void pauseSound(bool bPause); protected: // Create a primitive that has as it's task this item - virtual RMGfxPrimitive *NewItemPrimitive(); + virtual RMGfxPrimitive *newItemPrimitive(); // Allocate memory for the sprites - virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + virtual RMGfxSourceBuffer *newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); }; @@ -330,7 +330,7 @@ public: bool bReversed; private: - void ReadFromStream(RMDataStream &ds); + void readFromStream(RMDataStream &ds); public: friend RMDataStream &operator>>(RMDataStream &ds, RMBox &box); @@ -343,47 +343,47 @@ public: RMBox *boxes; private: - void ReadFromStream(RMDataStream &ds); + void readFromStream(RMDataStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); - void RecalcAllAdj(void); + void recalcAllAdj(void); }; #define GAME_BOXES_SIZE 200 class RMGameBoxes { protected: - RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; - int m_nLocBoxes; + RMBoxLoc *_allBoxes[GAME_BOXES_SIZE]; + int _nLocBoxes; public: RMGameBoxes(); ~RMGameBoxes(); - void Init(void); - void Close(void); + void init(void); + void close(void); // Get binding boxes for a given location - RMBoxLoc *GetBoxes(int nLoc); - int GetLocBoxesCount() const { return m_nLocBoxes; } + RMBoxLoc *getBoxes(int nLoc); + int getLocBoxesCount() const { return _nLocBoxes; } // Return the box which contains a given point - int WhichBox(int nLoc, const RMPoint &pt); + int whichBox(int nLoc, const RMPoint &pt); // Check whether a point is inside a given box - bool IsInBox(int nLoc, int nBox, const RMPoint &pt); + bool isInBox(int nLoc, int nBox, const RMPoint &pt); // Change the status of a box - void ChangeBoxStatus(int nLoc, int nBox, int status); + void changeBoxStatus(int nLoc, int nBox, int status); // Save state handling - int GetSaveStateSize(void); - void SaveState(byte *buf); - void LoadState(byte *buf); + int getSaveStateSize(void); + void saveState(byte *buf); + void loadState(byte *buf); }; class RMCharacter : protected RMItem { @@ -426,21 +426,21 @@ private: bool bMovingWithoutMinpath; RMGameBoxes *theBoxes; - RMPoint m_fixedScroll; + RMPoint _fixedScroll; private: - int InWhichBox(const RMPoint &pt); + int inWhichBox(const RMPoint &pt); - short FindPath(short source, short destination); - RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); - RMPoint NearestPoint(const RMPoint &punto); + short findPath(short source, short destination); + RMPoint searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); + RMPoint nearestPoint(const RMPoint &punto); - void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); - short ScanLine(const RMPoint &punto); - RMPoint InvScanLine(const RMPoint &punto); - RMPoint NearestHotSpot(int sourcebox, int destbox); + void goTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); + short scanLine(const RMPoint &punto); + RMPoint invScanLine(const RMPoint &punto); + RMPoint nearestHotSpot(int sourcebox, int destbox); - void NewBoxEntered(int nBox); + void newBoxEntered(int nBox); protected: bool bMoving; @@ -452,42 +452,42 @@ public: RMCharacter(); virtual ~RMCharacter(); - void LinkToBoxes(RMGameBoxes *theBoxes); + void linkToBoxes(RMGameBoxes *theBoxes); virtual void removeThis(CORO_PARAM, bool &result); // Update the position of a character - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); + void doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool EndOfPath() { + bool endOfPath() { return bEndOfPath; } // Change the pattern of a character to STOP - virtual void Stop(CORO_PARAM); + virtual void stop(CORO_PARAM); // Check if the character is moving - bool IsMoving() { + bool isMoving() { return bMoving; } // Move the character to a certain position - void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); + void move(CORO_PARAM, RMPoint pt, bool *result = NULL); // Place the character in a certain position WITHOUT moving - void SetPosition(const RMPoint &pt, int newloc = -1); + void setPosition(const RMPoint &pt, int newloc = -1); // Wait for the end of movement - void WaitForEndMovement(CORO_PARAM); + void waitForEndMovement(CORO_PARAM); - void SetFixedScroll(const RMPoint &fix) { - m_fixedScroll = fix; + void setFixedScroll(const RMPoint &fix) { + _fixedScroll = fix; } - void SetSpeed(int speed) { + void setSpeed(int speed) { curSpeed = speed; } }; @@ -495,26 +495,26 @@ public: class RMWipe : public RMGfxTask { private: - bool m_bFading; - bool m_bEndFade; - bool m_bUnregister; - uint32 m_hUnregistered; - int m_nFadeStep; - uint32 m_hEndOfFade; - bool m_bMustRegister; + bool _bFading; + bool _bEndFade; + bool _bUnregister; + uint32 _hUnregistered; + int _nFadeStep; + uint32 _hEndOfFade; + bool _bMustRegister; - RMItem m_wip0r; + RMItem _wip0r; public: RMWipe(); virtual ~RMWipe(); - void DoFrame(RMGfxTargetBuffer &bigBuf); + void doFrame(RMGfxTargetBuffer &bigBuf); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void InitFade(int type); - void CloseFade(void); - void WaitForFadeEnd(CORO_PARAM); + void initFade(int type); + void closeFade(void); + void waitForFadeEnd(CORO_PARAM); virtual void Unregister(void); virtual void removeThis(CORO_PARAM, bool &result); @@ -527,17 +527,17 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Name + RMString _name; // Name private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer *m_buf; // Location picture + RMColorMode _cmode; // Color mode + RMGfxSourceBuffer *_buf; // Location picture - int m_nItems; // Number of objects - RMItem *m_items; // Objects + int _nItems; // Number of objects + RMItem *_items; // Objects - RMPoint m_curScroll; // Current scroll position - RMPoint m_fixedScroll; + RMPoint _curScroll; // Current scroll position + RMPoint _fixedScroll; public: // @@@@@@@@@@@@@@@@@@@@@@@ @@ -556,14 +556,14 @@ public: virtual ~RMLocation(); // Load variations - bool Load(const char *lpszFileName); - bool Load(Common::File &file); - bool Load(const byte *buf); - bool Load(RMDataStream &ds); - bool LoadLOX(RMDataStream &ds); + bool load(const char *lpszFileName); + bool load(Common::File &file); + bool load(const byte *buf); + bool load(RMDataStream &ds); + bool loadLOX(RMDataStream &ds); // Unload - void Unload(void); + void unload(void); // Overloaded draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -572,27 +572,27 @@ public: void doFrame(RMGfxTargetBuffer *bigBuf); // Return the item at a given point - RMItem *WhichItemIsIn(const RMPoint &pt); + RMItem *whichItemIsIn(const RMPoint &pt); // Return the item based on it's MPAL code - RMItem *GetItemFromCode(uint32 dwCode); + RMItem *getItemFromCode(uint32 dwCode); // Set the current scroll position - void SetScrollPosition(const RMPoint &scroll); + void setScrollPosition(const RMPoint &scroll); // Sets an additinal offset for scrolling - void SetFixedScroll(const RMPoint &scroll); + void setFixedScroll(const RMPoint &scroll); // Update the scrolling coordinates to display the specified point - void UpdateScrolling(const RMPoint &ptShowThis); + void updateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint ScrollPosition() { - return m_curScroll; + RMPoint scrollPosition() { + return _curScroll; } // Pause sound - void PauseSound(bool bPause); + void pauseSound(bool bPause); }; @@ -606,21 +606,21 @@ private: int nPeriods; private: - void ParseMessage(void); + void parseMessage(void); public: RMMessage(); RMMessage(uint32 dwId); virtual ~RMMessage(); - void Load(uint32 dwId); - bool IsValid() { + void load(uint32 dwId); + bool isValid() { return lpMessage != NULL; } - int NumPeriods() { + int numPeriods() { return nPeriods; } - char *Period(int num) { + char *period(int num) { return lpPeriods[num]; } char *operator[](int num) { diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ea378e0fc3..abc3033993 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -137,7 +137,7 @@ Common::ErrorCode TonyEngine::init() { return Common::kReadingFailed; // Initialise the boxes - _theBoxes.Init(); + _theBoxes.init(); // Link to the custom graphics engine _theEngine.initCustomDll(); @@ -568,7 +568,7 @@ void TonyEngine::play(void) { void TonyEngine::close(void) { closeMusic(); CoroScheduler.closeEvent(_hEndOfFrame); - _theBoxes.Close(); + _theBoxes.close(); _theEngine.close(); _window.close(); delete[] _curThumbnail; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 8bca6fe7f6..dc771b08aa 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -38,31 +38,31 @@ namespace Tony { * Metodi di RMTony \****************************************************************************/ -bool RMTony::m_bAction = false; +bool RMTony::_bAction = false; void RMTony::initStatics() { - m_bAction = false; + _bAction = false; } RMTony::RMTony() { - m_bShow = false; - m_bShowOmbra = false; - m_bCorpoDavanti = false; - m_bActionPending = false; - m_ActionItem = NULL; - m_Action = 0; - m_ActionParm = 0; - m_bPastorella = false; - m_bIsStaticTalk = false; - m_bIsTalking = false; - m_nPatB4Talking = 0; - m_nTalkType = TALK_NORMAL; - m_TalkDirection = UP; - m_nTimeLastStep = 0; + _bShow = false; + _bShowOmbra = false; + _bCorpoDavanti = false; + _bActionPending = false; + _ActionItem = NULL; + _Action = 0; + _ActionParm = 0; + _bPastorella = false; + _bIsStaticTalk = false; + _bIsTalking = false; + _nPatB4Talking = 0; + _nTalkType = TALK_NORMAL; + _TalkDirection = UP; + _nTimeLastStep = 0; hActionThread = CORO_INVALID_PID_VALUE; } -void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { +void RMTony::waitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -72,15 +72,15 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - m_bAction = false; + _bAction = false; CORO_END_CODE; } -RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { +RMGfxSourceBuffer *RMTony::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { RMGfxSourceBuffer8RLE *spr; - assert(m_cm == CM_256); + assert(_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; spr->setAlphaBlendColor(1); if (bPreRLE) @@ -94,81 +94,80 @@ void RMTony::init(void) { RMDataStream ds; // Tony is shown by default - m_bShow = m_bShowOmbra = true; + _bShow = _bShowOmbra = true; // No action pending - m_bActionPending = false; - m_bAction = false; + _bActionPending = false; + _bAction = false; - m_bPastorella = false; - m_bIsTalking = false; - m_bIsStaticTalk = false; + _bPastorella = false; + _bIsTalking = false; + _bIsStaticTalk = false; // Opens the buffer ds.OpenBuffer(tony); // Reads his details from the stream - ReadFromStream(ds, true); + readFromStream(ds, true); // Closes the buffer ds.Close(); // Reads Tony's body ds.OpenBuffer(body); - m_body.ReadFromStream(ds, true); + _body.readFromStream(ds, true); ds.Close(); - m_body.SetPattern(0); + _body.setPattern(0); - m_nTimeLastStep = _vm->getTime(); + _nTimeLastStep = _vm->getTime(); } -void RMTony::Close(void) { +void RMTony::close(void) { // Disalloca @@@ Deallocation of missing item - m_ombra.destroy(); + _ombra.destroy(); } -void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { +void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CONTEXT; int time; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (!_nInList && m_bShow) + if (!_nInList && _bShow) bigBuf->addPrim(new RMGfxPrimitive(this)); - SetSpeed(GLOBALS.nCfgTonySpeed); + setSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->getTime(); do { - m_nTimeLastStep += (1000 / 40); - CORO_INVOKE_2(RMCharacter::DoFrame, bigBuf, curLoc); - - } while (_ctx->time > m_nTimeLastStep + (1000 / 40)); + _nTimeLastStep += (1000 / 40); + CORO_INVOKE_2(RMCharacter::doFrame, bigBuf, curLoc); + } while (_ctx->time > _nTimeLastStep + (1000 / 40)); // Check if we are at the end of a path - if (EndOfPath() && m_bActionPending) { + if (endOfPath() && _bActionPending) { // Must perform the action on which we clicked - m_bActionPending = false; + _bActionPending = false; } - if (m_bIsTalking || m_bIsStaticTalk) - m_body.doFrame(bigBuf, false); + if (_bIsTalking || _bIsStaticTalk) + _body.doFrame(bigBuf, false); CORO_END_CODE; } -void RMTony::Show(void) { - m_bShow = true; - m_bShowOmbra = true; +void RMTony::show(void) { + _bShow = true; + _bShowOmbra = true; } -void RMTony::Hide(bool bShowOmbra) { - m_bShow = false; - m_bShowOmbra = bShowOmbra; +void RMTony::hide(bool bShowOmbra) { + _bShow = false; + _bShowOmbra = bShowOmbra; } @@ -179,29 +178,29 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Call the Draw() of the parent class if Tony is visible - if (m_bShow && bDrawNow) { - if (m_bCorpoDavanti) { + if (_bShow && bDrawNow) { + if (_bCorpoDavanti) { prim->Dst().SetEmpty(); prim->Dst().Offset(-44, -134); - if (m_bPastorella) + if (_bPastorella) prim->Dst().Offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } - if (m_bIsTalking || m_bIsStaticTalk) { + if (_bIsTalking || _bIsStaticTalk) { // Offest direction from scrolling prim->Dst().SetEmpty(); - prim->Dst().Offset(-m_curScroll); - prim->Dst().Offset(m_pos); + prim->Dst().Offset(-_curScroll); + prim->Dst().Offset(_pos); prim->Dst().Offset(-44, -134); - prim->Dst() += m_nBodyOffset; - CORO_INVOKE_2(m_body.draw, bigBuf, prim); + prim->Dst() += _nBodyOffset; + CORO_INVOKE_2(_body.draw, bigBuf, prim); } - if (!m_bCorpoDavanti) { + if (!_bCorpoDavanti) { prim->Dst().SetEmpty(); prim->Dst().Offset(-44, -134); - if (m_bPastorella) + if (_bPastorella) prim->Dst().Offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } @@ -210,7 +209,7 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CODE; } -void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { +void RMTony::moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { CORO_BEGIN_CONTEXT; bool result; CORO_END_CONTEXT(_ctx); @@ -219,26 +218,26 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, // Makes normal movement, but remember if you must then perform an action if (item == NULL) { - m_bActionPending = false; - m_ActionItem = NULL; + _bActionPending = false; + _ActionItem = NULL; } else { - m_ActionItem = item; - m_Action = nAction; - m_ActionParm = nActionParm; - m_bActionPending = true; + _ActionItem = item; + _Action = nAction; + _ActionParm = nActionParm; + _bActionPending = true; } - CORO_INVOKE_2(RMCharacter::Move, dst, &_ctx->result); + CORO_INVOKE_2(RMCharacter::move, dst, &_ctx->result); if (!_ctx->result) { - m_bActionPending = false; - m_ActionItem = NULL; + _bActionPending = false; + _ActionItem = NULL; } CORO_END_CODE; } -void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { +void RMTony::executeAction(int nAction, int nActionItem, int nParm) { uint32 pid; if (nAction == TA_COMBINE) { @@ -264,85 +263,85 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { } if (pid != CORO_INVALID_PID_VALUE) { - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { pid = mpalQueryDoAction(6, 1, 0); - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else { pid = mpalQueryDoAction(5, 1, 0); - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } } } -void RMTony::StopNoAction(CORO_PARAM) { +void RMTony::stopNoAction(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_bAction) + if (_bAction) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE); - m_bActionPending = false; - m_ActionItem = NULL; - CORO_INVOKE_0(Stop); + _bActionPending = false; + _ActionItem = NULL; + CORO_INVOKE_0(stop); CORO_END_CODE; } -void RMTony::Stop(CORO_PARAM) { +void RMTony::stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_ActionItem != NULL) { + if (_ActionItem != NULL) { // Call MPAL to choose the direction - _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); + _ctx->pid = mpalQueryDoAction(21, _ActionItem->mpalCode(), 0); if (_ctx->pid == CORO_INVALID_PID_VALUE) - CORO_INVOKE_0(RMCharacter::Stop); + CORO_INVOKE_0(RMCharacter::stop); else { bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } } else { - CORO_INVOKE_0(RMCharacter::Stop); + CORO_INVOKE_0(RMCharacter::stop); } - if (!m_bActionPending) + if (!_bActionPending) return; - m_bActionPending = false; + _bActionPending = false; - ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); + executeAction(_Action, _ActionItem->mpalCode(), _ActionParm); - m_ActionItem = NULL; + _ActionItem = NULL; CORO_END_CODE; } -int RMTony::GetCurPattern(void) { - int nPatt = RMCharacter::GetCurPattern(); +int RMTony::getCurPattern(void) { + int nPatt = RMCharacter::getCurPattern(); - if (!m_bPastorella) + if (!_bPastorella) return nPatt; switch (nPatt) { @@ -367,8 +366,8 @@ int RMTony::GetCurPattern(void) { return nPatt; } -void RMTony::SetPattern(int nPatt, bool bPlayP0) { - if (m_bPastorella) { +void RMTony::setPattern(int nPatt, bool bPlayP0) { + if (_bPastorella) { switch (nPatt) { case PAT_STANDUP: nPatt = PAT_PAST_STANDUP; @@ -397,13 +396,13 @@ void RMTony::SetPattern(int nPatt, bool bPlayP0) { } } - RMCharacter::SetPattern(nPatt, bPlayP0); + RMCharacter::setPattern(nPatt, bPlayP0); } -void RMTony::Take(int nWhere, int nPart) { +void RMTony::take(int nWhere, int nPart) { if (nPart == 0) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_STANDDOWN: assert(0); // Not while you're doing a StandDown break; @@ -411,13 +410,13 @@ void RMTony::Take(int nWhere, int nPart) { case PAT_STANDUP: switch (nWhere) { case 0: - SetPattern(PAT_TAKEUP_UP1); + setPattern(PAT_TAKEUP_UP1); break; case 1: - SetPattern(PAT_TAKEUP_MID1); + setPattern(PAT_TAKEUP_MID1); break; case 2: - SetPattern(PAT_TAKEUP_DOWN1); + setPattern(PAT_TAKEUP_DOWN1); break; } break; @@ -425,13 +424,13 @@ void RMTony::Take(int nWhere, int nPart) { case PAT_STANDRIGHT: switch (nWhere) { case 0: - SetPattern(PAT_TAKERIGHT_UP1); + setPattern(PAT_TAKERIGHT_UP1); break; case 1: - SetPattern(PAT_TAKERIGHT_MID1); + setPattern(PAT_TAKERIGHT_MID1); break; case 2: - SetPattern(PAT_TAKERIGHT_DOWN1); + setPattern(PAT_TAKERIGHT_DOWN1); break; } break; @@ -439,46 +438,46 @@ void RMTony::Take(int nWhere, int nPart) { case PAT_STANDLEFT: switch (nWhere) { case 0: - SetPattern(PAT_TAKELEFT_UP1); + setPattern(PAT_TAKELEFT_UP1); break; case 1: - SetPattern(PAT_TAKELEFT_MID1); + setPattern(PAT_TAKELEFT_MID1); break; case 2: - SetPattern(PAT_TAKELEFT_DOWN1); + setPattern(PAT_TAKELEFT_DOWN1); break; } break; } } else if (nPart == 1) { - SetPattern(GetCurPattern() + 1); + setPattern(getCurPattern() + 1); } else if (nPart == 2) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: - SetPattern(PAT_STANDUP); + setPattern(PAT_STANDUP); break; case PAT_TAKELEFT_UP2: case PAT_TAKELEFT_MID2: case PAT_TAKELEFT_DOWN2: - SetPattern(PAT_STANDLEFT); + setPattern(PAT_STANDLEFT); break; case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: - SetPattern(PAT_STANDRIGHT); + setPattern(PAT_STANDRIGHT); break; } } } -void RMTony::Put(int nWhere, int nPart) { +void RMTony::put(int nWhere, int nPart) { if (nPart == 0) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_STANDDOWN: //assert(0); break; @@ -486,13 +485,13 @@ void RMTony::Put(int nWhere, int nPart) { case PAT_STANDUP: switch (nWhere) { case 0: - SetPattern(PAT_PUTUP_UP1); + setPattern(PAT_PUTUP_UP1); break; case 1: - SetPattern(PAT_PUTUP_MID1); + setPattern(PAT_PUTUP_MID1); break; case 2: - SetPattern(PAT_PUTUP_DOWN1); + setPattern(PAT_PUTUP_DOWN1); break; } break; @@ -500,13 +499,13 @@ void RMTony::Put(int nWhere, int nPart) { case PAT_STANDRIGHT: switch (nWhere) { case 0: - SetPattern(PAT_PUTRIGHT_UP1); + setPattern(PAT_PUTRIGHT_UP1); break; case 1: - SetPattern(PAT_PUTRIGHT_MID1); + setPattern(PAT_PUTRIGHT_MID1); break; case 2: - SetPattern(PAT_PUTRIGHT_DOWN1); + setPattern(PAT_PUTRIGHT_DOWN1); break; } break; @@ -514,56 +513,56 @@ void RMTony::Put(int nWhere, int nPart) { case PAT_STANDLEFT: switch (nWhere) { case 0: - SetPattern(PAT_PUTLEFT_UP1); + setPattern(PAT_PUTLEFT_UP1); break; case 1: - SetPattern(PAT_PUTLEFT_MID1); + setPattern(PAT_PUTLEFT_MID1); break; case 2: - SetPattern(PAT_PUTLEFT_DOWN1); + setPattern(PAT_PUTLEFT_DOWN1); break; } break; } } else if (nPart == 1) { - SetPattern(GetCurPattern() + 1); + setPattern(getCurPattern() + 1); } else if (nPart == 2) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_PUTUP_UP2: case PAT_PUTUP_MID2: case PAT_PUTUP_DOWN2: - SetPattern(PAT_STANDUP); + setPattern(PAT_STANDUP); break; case PAT_PUTLEFT_UP2: case PAT_PUTLEFT_MID2: case PAT_PUTLEFT_DOWN2: - SetPattern(PAT_STANDLEFT); + setPattern(PAT_STANDLEFT); break; case PAT_PUTRIGHT_UP2: case PAT_PUTRIGHT_MID2: case PAT_PUTRIGHT_DOWN2: - SetPattern(PAT_STANDRIGHT); + setPattern(PAT_STANDRIGHT); break; } } } -bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, +bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat) { - assert(!m_bIsTalking); + assert(!_bIsTalking); - m_bIsTalking = true; - m_nPatB4Talking = GetCurPattern(); - m_nTalkType = nTalkType; + _bIsTalking = true; + _nPatB4Talking = getCurPattern(); + _nTalkType = nTalkType; // Set the direction of speech ONLY if we are not in a static animation (since it would have already been done) - if (!m_bIsStaticTalk) { - switch (m_nPatB4Talking) { + if (!_bIsStaticTalk) { + switch (_nPatB4Talking) { case PAT_STANDDOWN: - m_TalkDirection = DOWN; + _TalkDirection = DOWN; break; case PAT_TAKELEFT_UP2: @@ -571,7 +570,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection = LEFT; + _TalkDirection = LEFT; break; case PAT_TAKERIGHT_UP2: @@ -579,39 +578,39 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection = RIGHT; + _TalkDirection = RIGHT; break; case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection = UP; + _TalkDirection = UP; break; } // Puts the body in front by default - m_bCorpoDavanti = true; + _bCorpoDavanti = true; } - if (m_bPastorella) { + if (_bPastorella) { // Talking whilst a shepherdess mainFreeze(); - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: - SetPattern(PAT_PAST_TALKUP); + setPattern(PAT_PAST_TALKUP); break; case DOWN: - SetPattern(PAT_PAST_TALKDOWN); + setPattern(PAT_PAST_TALKDOWN); break; case LEFT: - SetPattern(PAT_PAST_TALKLEFT); + setPattern(PAT_PAST_TALKLEFT); break; case RIGHT: - SetPattern(PAT_PAST_TALKRIGHT); + setPattern(PAT_PAST_TALKRIGHT); break; } mainUnfreeze(); @@ -623,42 +622,42 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (nTalkType) { case TALK_NORMAL: - m_bCorpoDavanti = false; + _bCorpoDavanti = false; headStartPat = 0; bodyStartPat = 0; - switch (m_TalkDirection) { + switch (_TalkDirection) { case DOWN: headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_STANDDOWN; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); break; case LEFT: headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case RIGHT: headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case UP: headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_STANDUP; - m_nBodyOffset.Set(6, 53); + _nBodyOffset.Set(6, 53); break; } break; case TALK_FIANCHI: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: - m_nBodyOffset.Set(2, 42); + _nBodyOffset.Set(2, 42); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_FIANCHIUP_START; headLoopPat = PAT_TALK_UP; @@ -666,7 +665,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - m_nBodyOffset.Set(2, 48); + _nBodyOffset.Set(2, 48); headStartPat = PAT_TESTA_DOWN; bodyStartPat = BPAT_FIANCHIDOWN_START; headLoopPat = PAT_TALK_DOWN; @@ -674,7 +673,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - m_nBodyOffset.Set(-3, 53); + _nBodyOffset.Set(-3, 53); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_FIANCHILEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -682,7 +681,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - m_nBodyOffset.Set(2, 53); + _nBodyOffset.Set(2, 53); headStartPat = PAT_TESTA_RIGHT; bodyStartPat = BPAT_FIANCHIRIGHT_START; headLoopPat = PAT_TALK_RIGHT; @@ -693,7 +692,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CANTA: - m_nBodyOffset.Set(-10, 25); + _nBodyOffset.Set(-10, 25); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_CANTALEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -701,12 +700,12 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_RIDE: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: case DOWN: case LEFT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; @@ -714,7 +713,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -724,19 +723,19 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_RIDE2: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: case DOWN: case LEFT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; break; case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -747,17 +746,17 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SIINDICA: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case DOWN: case LEFT: - m_nBodyOffset.Set(-4, 40); + _nBodyOffset.Set(-4, 40); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_SIINDICALEFT; break; case RIGHT: - m_nBodyOffset.Set(5, 40); + _nBodyOffset.Set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; break; @@ -765,9 +764,9 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: - m_nBodyOffset.Set(-4, -11); + _nBodyOffset.Set(-4, -11); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_SPAVENTOUP_START; headLoopPat = PAT_TALK_UP; @@ -775,7 +774,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - m_nBodyOffset.Set(-5, 45); + _nBodyOffset.Set(-5, 45); headStartPat = PAT_SPAVENTODOWN_START; bodyStartPat = BPAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -783,7 +782,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - m_nBodyOffset.Set(-4, 41); + _nBodyOffset.Set(-4, 41); headStartPat = PAT_SPAVENTORIGHT_START; bodyStartPat = BPAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -791,7 +790,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - m_nBodyOffset.Set(-10, 41); + _nBodyOffset.Set(-10, 41); headStartPat = PAT_SPAVENTOLEFT_START; bodyStartPat = BPAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -801,12 +800,12 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SPAVENTATO2: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; - m_nBodyOffset.Set(6, 53); + _nBodyOffset.Set(6, 53); headStartPat = PAT_TESTA_UP; headLoopPat = PAT_TALK_UP; @@ -815,7 +814,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); headStartPat = PAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -824,7 +823,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -833,7 +832,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -842,36 +841,36 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONBICCHIERE: - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_BICCHIERE; break; case TALK_CONVERME: - m_nBodyOffset.Set(9, 56); + _nBodyOffset.Set(9, 56); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_VERME; break; case TALK_CONMARTELLO: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MARTELLO; break; case TALK_CONCORDA: - m_nBodyOffset.Set(-3, 38); + _nBodyOffset.Set(-3, 38); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CORDA; break; case TALK_CONSEGRETARIA: - m_nBodyOffset.Set(-17, 12); + _nBodyOffset.Set(-17, 12); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONSEGRETARIA; break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-21, -5); + _nBodyOffset.Set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; @@ -879,7 +878,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -5); + _nBodyOffset.Set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; @@ -888,10 +887,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-61, -7); + _nBodyOffset.Set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; @@ -899,7 +898,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-5, -7); + _nBodyOffset.Set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; @@ -908,10 +907,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-34, -2); + _nBodyOffset.Set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; @@ -919,7 +918,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -2); + _nBodyOffset.Set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; @@ -928,10 +927,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-35, 2); + _nBodyOffset.Set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; @@ -939,7 +938,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-14, 2); + _nBodyOffset.Set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; @@ -953,7 +952,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CONCARTESTATIC: case TALK_CONTACCUINOSTATIC: case TALK_CONMEGAFONOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: headLoopPat = PAT_TALK_LEFT; @@ -968,28 +967,28 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: headLoopPat = PAT_TALKBARBA_LEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case DOWN: case RIGHT: headLoopPat = PAT_TALKBARBA_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; } break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SCHIFATOLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SCHIFATOLEFT_LOOP; @@ -997,7 +996,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SCHIFATORIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SCHIFATORIGHT_LOOP; @@ -1006,10 +1005,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_NAAHLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_NAAHLEFT_LOOP; @@ -1017,7 +1016,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_NAAHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_NAAHRIGHT_LOOP; @@ -1026,58 +1025,58 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_MACBETH1: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH1; break; case TALK_MACBETH2: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH2; break; case TALK_MACBETH3: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH3; break; case TALK_MACBETH4: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH4; break; case TALK_MACBETH5: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH5; break; case TALK_MACBETH6: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH6; break; case TALK_MACBETH7: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH7; break; case TALK_MACBETH8: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH8; break; case TALK_MACBETH9: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH9; break; case TALK_SPAVENTATOSTATIC: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); headStartPat = PAT_SPAVENTODOWN_STAND; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -1086,7 +1085,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTORIGHT_STAND; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -1095,7 +1094,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTOLEFT_STAND; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -1110,7 +1109,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body return true; } -void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { +void RMTony::startTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_BEGIN_CONTEXT; int headStartPat, bodyStartPat; int headLoopPat, bodyLoopPat; @@ -1121,38 +1120,38 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headStartPat = _ctx->bodyStartPat = 0; _ctx->headLoopPat = _ctx->bodyLoopPat = 0; - if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, + if (!startTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, _ctx->headLoopPat, _ctx->bodyLoopPat)) return; // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { mainFreeze(); - SetPattern(_ctx->headStartPat); - m_body.SetPattern(_ctx->bodyStartPat); + setPattern(_ctx->headStartPat); + _body.setPattern(_ctx->bodyStartPat); mainUnfreeze(); if (_ctx->bodyStartPat != 0) - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); if (_ctx->headStartPat != 0) - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); } mainFreeze(); - SetPattern(_ctx->headLoopPat); + setPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) - m_body.SetPattern(_ctx->bodyLoopPat); + _body.setPattern(_ctx->bodyLoopPat); mainUnfreeze(); CORO_END_CODE; } -bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { +bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: finalPat = PAT_STANDUP; headStandPat = PAT_TESTA_UP; @@ -1174,23 +1173,23 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; } - if (m_bPastorella) { + if (_bPastorella) { mainFreeze(); - SetPattern(finalPat); + setPattern(finalPat); mainUnfreeze(); - m_bIsTalking = false; + _bIsTalking = false; return false; } bStatic = false; - switch (m_nTalkType) { + switch (_nTalkType) { case TALK_NORMAL: bodyEndPat = 0; break; case TALK_FIANCHI: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: bodyEndPat = BPAT_FIANCHIUP_END; break; @@ -1215,16 +1214,16 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_RIDE: case TALK_RIDE2: - if (m_TalkDirection == LEFT) + if (_TalkDirection == LEFT) headEndPat = PAT_RIDELEFT_END; - else if (m_TalkDirection == RIGHT) + else if (_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1240,7 +1239,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1259,7 +1258,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1282,7 +1281,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: bodyEndPat = 0; break; @@ -1305,7 +1304,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1321,7 +1320,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1337,7 +1336,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1353,7 +1352,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1396,7 +1395,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1425,7 +1424,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa return true; } -void RMTony::EndTalk(CORO_PARAM) { +void RMTony::endTalk(CORO_PARAM) { CORO_BEGIN_CONTEXT; int headStandPat, headEndPat; int bodyEndPat, finalPat; @@ -1441,93 +1440,93 @@ void RMTony::EndTalk(CORO_PARAM) { _ctx->bodyEndPat = 0; _ctx->headEndPat = 0; - if (!EndTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) + if (!endTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) return; // Handles the end of an animated and static, leaving everything unchanged - if (m_bIsStaticTalk) { - if (m_nTalkType == TALK_CONBARBASTATIC) { + if (_bIsStaticTalk) { + if (_nTalkType == TALK_CONBARBASTATIC) { mainFreeze(); - SetPattern(0); - if (m_TalkDirection == UP || m_TalkDirection == LEFT) { - m_body.SetPattern(BPAT_CONBARBALEFT_STATIC); - m_nBodyOffset.Set(-41, -14); - } else if (m_TalkDirection == DOWN || m_TalkDirection == RIGHT) { - m_body.SetPattern(BPAT_CONBARBARIGHT_STATIC); - m_nBodyOffset.Set(-26, -14); + setPattern(0); + if (_TalkDirection == UP || _TalkDirection == LEFT) { + _body.setPattern(BPAT_CONBARBALEFT_STATIC); + _nBodyOffset.Set(-41, -14); + } else if (_TalkDirection == DOWN || _TalkDirection == RIGHT) { + _body.setPattern(BPAT_CONBARBARIGHT_STATIC); + _nBodyOffset.Set(-26, -14); } mainUnfreeze(); } else { mainFreeze(); - SetPattern(_ctx->headStandPat); + setPattern(_ctx->headStandPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } - m_bIsTalking = false; + _bIsTalking = false; return; } // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { mainFreeze(); - SetPattern(_ctx->headEndPat); + setPattern(_ctx->headEndPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); mainFreeze(); - m_body.SetPattern(_ctx->bodyEndPat); + _body.setPattern(_ctx->bodyEndPat); mainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->bodyEndPat != 0) { mainFreeze(); - SetPattern(_ctx->headStandPat); + setPattern(_ctx->headStandPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); mainFreeze(); - m_body.SetPattern(_ctx->bodyEndPat); + _body.setPattern(_ctx->bodyEndPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->headEndPat != 0) { - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); mainFreeze(); - SetPattern(_ctx->headEndPat); + setPattern(_ctx->headEndPat); mainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); } else { - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } if (_ctx->finalPat != 0) { mainFreeze(); - m_body.SetPattern(0); - SetPattern(_ctx->finalPat); + _body.setPattern(0); + setPattern(_ctx->finalPat); mainUnfreeze(); } - m_bIsTalking = false; + _bIsTalking = false; CORO_END_CODE; } -void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, +void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat) { - int nPat = GetCurPattern(); + int nPat = getCurPattern(); headLoopPat = -1; switch (nPat) { case PAT_STANDDOWN: - m_TalkDirection = DOWN; + _TalkDirection = DOWN; headPat = PAT_TESTA_RIGHT; break; @@ -1536,7 +1535,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection = LEFT; + _TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; @@ -1545,7 +1544,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection = RIGHT; + _TalkDirection = RIGHT; headPat = PAT_TESTA_RIGHT; break; @@ -1553,26 +1552,26 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection = UP; + _TalkDirection = UP; headPat = PAT_TESTA_LEFT; break; } - m_bCorpoDavanti = true; + _bCorpoDavanti = true; switch (nTalk) { case TALK_CONCONIGLIOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-21, -5); + _nBodyOffset.Set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -5); + _nBodyOffset.Set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; break; @@ -1580,17 +1579,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONCARTESTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-34, -2); + _nBodyOffset.Set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -2); + _nBodyOffset.Set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; break; @@ -1598,17 +1597,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONRICETTASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-61, -7); + _nBodyOffset.Set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-5, -7); + _nBodyOffset.Set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; break; @@ -1616,17 +1615,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONPUPAZZOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-35, 2); + _nBodyOffset.Set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-14, 2); + _nBodyOffset.Set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; break; @@ -1634,17 +1633,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONTACCUINOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-16, -9); + _nBodyOffset.Set(-16, -9); bodyStartPat = BPAT_CONTACCUINOLEFT_START; bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-6, -9); + _nBodyOffset.Set(-6, -9); bodyStartPat = BPAT_CONTACCUINORIGHT_START; bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; break; @@ -1652,17 +1651,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONMEGAFONOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-41, -8); + _nBodyOffset.Set(-41, -8); bodyStartPat = BPAT_CONMEGAFONOLEFT_START; bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-14, -8); + _nBodyOffset.Set(-14, -8); bodyStartPat = BPAT_CONMEGAFONORIGHT_START; bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; break; @@ -1670,10 +1669,10 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONBARBASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-41, -14); + _nBodyOffset.Set(-41, -14); bodyStartPat = BPAT_CONBARBALEFT_START; bodyLoopPat = BPAT_STANDLEFT; headLoopPat = PAT_TALKBARBA_LEFT; @@ -1682,7 +1681,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case DOWN: case RIGHT: - m_nBodyOffset.Set(-26, -14); + _nBodyOffset.Set(-26, -14); bodyStartPat = BPAT_CONBARBARIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; headLoopPat = PAT_TALKBARBA_RIGHT; @@ -1692,13 +1691,13 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case DOWN: headPat = PAT_SPAVENTODOWN_START; bodyLoopPat = BPAT_STANDDOWN; bodyStartPat = BPAT_STANDDOWN; headLoopPat = PAT_SPAVENTODOWN_STAND; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); break; case LEFT: @@ -1706,7 +1705,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDLEFT; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SPAVENTOLEFT_STAND; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case RIGHT: @@ -1714,7 +1713,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDRIGHT; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SPAVENTORIGHT_STAND; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; default: @@ -1726,7 +1725,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat } } -void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; int headPat, headLoopPat; int bodyStartPat, bodyLoopPat; @@ -1738,28 +1737,28 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { _ctx->bodyStartPat = _ctx->bodyLoopPat = 0; // e vai con i pattern - m_bIsStaticTalk = true; + _bIsStaticTalk = true; mainFreeze(); - SetPattern(_ctx->headPat); - m_body.SetPattern(_ctx->bodyStartPat); + setPattern(_ctx->headPat); + _body.setPattern(_ctx->bodyStartPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); mainFreeze(); if (_ctx->headLoopPat != -1) - SetPattern(_ctx->headLoopPat); - m_body.SetPattern(_ctx->bodyLoopPat); + setPattern(_ctx->headLoopPat); + _body.setPattern(_ctx->bodyLoopPat); mainUnfreeze(); CORO_END_CODE; } -void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { - switch (m_TalkDirection) { +void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1773,7 +1772,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; @@ -1787,7 +1786,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONRICETTASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONRICETTALEFT_END; @@ -1801,7 +1800,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCONIGLIOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCONIGLIOLEFT_END; @@ -1815,7 +1814,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCARTESTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCARTELEFT_END; @@ -1829,7 +1828,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONTACCUINOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONTACCUINOLEFT_END; @@ -1843,7 +1842,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONMEGAFONOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONMEGAFONOLEFT_END; @@ -1857,7 +1856,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONBARBASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONBARBALEFT_END; @@ -1871,7 +1870,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: headEndPat = PAT_SPAVENTOLEFT_END; break; @@ -1894,7 +1893,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } } -void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::endStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; int bodyEndPat; int finalPat; @@ -1907,29 +1906,29 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { _ctx->finalPat = 0; _ctx->headEndPat = 0; - EndStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); + endStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); if (_ctx->headEndPat != 0) { mainFreeze(); - SetPattern(_ctx->headEndPat); + setPattern(_ctx->headEndPat); mainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); } else { // Play please mainFreeze(); - m_body.SetPattern(_ctx->bodyEndPat); + _body.setPattern(_ctx->bodyEndPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } mainFreeze(); - SetPattern(_ctx->finalPat); - m_body.SetPattern(0); + setPattern(_ctx->finalPat); + _body.setPattern(0); mainUnfreeze(); - m_bIsStaticTalk = false; + _bIsStaticTalk = false; CORO_END_CODE; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index e7b4227fc5..5179230b4c 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -81,36 +81,36 @@ public: }; private: - bool m_bShow; - bool m_bShowOmbra; - bool m_bCorpoDavanti; - RMGfxSourceBuffer8AB m_ombra; - bool m_bActionPending; - RMItem *m_ActionItem; - int m_Action; - int m_ActionParm; - static bool m_bAction; - - bool m_bPastorella; - - bool m_bIsStaticTalk; - bool m_bIsTalking; - int m_nPatB4Talking; - TALKTYPE m_nTalkType; - DIRECTION m_TalkDirection; - RMPoint m_nBodyOffset; - - int m_nTimeLastStep; - - RMItem m_body; + bool _bShow; + bool _bShowOmbra; + bool _bCorpoDavanti; + RMGfxSourceBuffer8AB _ombra; + bool _bActionPending; + RMItem *_ActionItem; + int _Action; + int _ActionParm; + static bool _bAction; + + bool _bPastorella; + + bool _bIsStaticTalk; + bool _bIsTalking; + int _nPatB4Talking; + TALKTYPE _nTalkType; + DIRECTION _TalkDirection; + RMPoint _nBodyOffset; + + int _nTimeLastStep; + + RMItem _body; uint32 hActionThread; protected: // Overload of the allocation allocation of sprites - virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + virtual RMGfxSourceBuffer *newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); // Watch thread which waits for the end of an action - static void WaitEndOfAction(CORO_PARAM, const void *param); + static void waitEndOfAction(CORO_PARAM, const void *param); public: enum PATTERNS { @@ -365,87 +365,87 @@ public: void init(void); // Free all memory - void Close(void); + void close(void); // Tony makes a frame, updating the movement, etc. - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); + void doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Draw method, which controls chararacter display virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Show or hide - void Show(void); - void Hide(bool bShowOmbra = false); + void show(void); + void hide(bool bShowOmbra = false); // Move and make an action, if necessary - void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); + void moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); // Tony stops (on the right side with respect to any subject) - virtual void Stop(CORO_PARAM); - void StopNoAction(CORO_PARAM); + virtual void stop(CORO_PARAM); + void stopNoAction(CORO_PARAM); // Set a pattern - void SetPattern(int npatt, bool bPlayP0 = false); + void setPattern(int npatt, bool bPlayP0 = false); // Reads the current pattern - int GetCurPattern(); + int getCurPattern(); // Waits until the end of a pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { - RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); + void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { + RMCharacter::waitForEndPattern(coroParam, hCustomSkip); } // Check if currently in an action - bool InAction() { - return (m_bActionPending && m_Action != 0) | m_bAction; + bool inAction() { + return (_bActionPending && _Action != 0) | _bAction; } // Check if there needs to be an update for scrolling movement - bool MustUpdateScrolling() { - return ((!InAction()) || (IsMoving())); + bool mustUpdateScrolling() { + return ((!inAction()) || (isMoving())); } // Returns Tony's position - RMPoint Position() { - return m_pos; + RMPoint position() { + return _pos; } // Set the scrolling position - void SetScrollPosition(const RMPoint &pt) { - RMCharacter::SetScrollPosition(pt); + void setScrollPosition(const RMPoint &pt) { + RMCharacter::setScrollPosition(pt); } // Set the take animation - void Take(int nWhere, int nPart); - void Put(int nWhere, int nPart); + void take(int nWhere, int nPart); + void put(int nWhere, int nPart); // Start or End Talk - bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + bool startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); - void StartTalk(CORO_PARAM, TALKTYPE nTalkType); - bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); - void EndTalk(CORO_PARAM); + void startTalk(CORO_PARAM, TALKTYPE nTalkType); + bool endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); + void endTalk(CORO_PARAM); // Start or End Static - void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + void startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); - void StartStatic(CORO_PARAM, TALKTYPE nTalkType); - void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); - void EndStatic(CORO_PARAM, TALKTYPE nTalkType); + void startStatic(CORO_PARAM, TALKTYPE nTalkType); + void endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); + void endStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void SetPastorella(bool bIsPast) { - m_bPastorella = bIsPast; + void setPastorella(bool bIsPast) { + _bPastorella = bIsPast; } - int GetPastorella(void) { - return m_bPastorella; + int getPastorella(void) { + return _bPastorella; } // Perform an action - void ExecuteAction(int nAction, int nActionItem, int nParm); + void executeAction(int nAction, int nActionItem, int nParm); - void PlaySfx(int nSfx) { - RMItem::PlaySfx(nSfx); + void playSfx(int nSfx) { + RMItem::playSfx(nSfx); } }; -- cgit v1.2.3 From f12ab3e521b01ed2b40e7d517753dd14bc6e6f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 08:42:35 +0200 Subject: TONY: Rename variables and functions in utils.h --- engines/tony/custom.cpp | 10 +- engines/tony/debugger.cpp | 2 +- engines/tony/font.cpp | 36 ++--- engines/tony/game.cpp | 44 +++--- engines/tony/game.h | 8 +- engines/tony/gfxcore.cpp | 28 ++-- engines/tony/gfxcore.h | 28 ++-- engines/tony/gfxengine.cpp | 2 +- engines/tony/input.cpp | 4 +- engines/tony/inventory.cpp | 46 +++--- engines/tony/loc.cpp | 72 ++++----- engines/tony/mpal/mpalutils.cpp | 36 ++--- engines/tony/mpal/mpalutils.h | 14 +- engines/tony/tony.cpp | 2 +- engines/tony/tonychar.cpp | 174 ++++++++++----------- engines/tony/utils.cpp | 338 ++++++++++++++++++++-------------------- engines/tony/utils.h | 114 +++++++------- engines/tony/window.h | 4 +- 18 files changed, 481 insertions(+), 481 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d42ef94a17..eaf125c973 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -574,7 +574,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - GLOBALS.StartLocPos[nLoc].Set(lX, lY); + GLOBALS.StartLocPos[nLoc].set(lX, lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1223,21 +1223,21 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; - _ctx->pt.Offset((int32)sX, 0); + _ctx->pt.offset((int32)sX, 0); } else if (_ctx->lx < 0) { _ctx->lx += (int32)sX; if (_ctx->lx > 0) _ctx->lx = 0; - _ctx->pt.Offset(-(int32)sX, 0); + _ctx->pt.offset(-(int32)sX, 0); } if (_ctx->ly > 0) { _ctx->ly -= sY; if (_ctx->ly < 0) _ctx->ly = 0; - _ctx->pt.Offset(0, sY); + _ctx->pt.offset(0, sY); } else if (_ctx->ly < 0) { _ctx->ly += sY; if (_ctx->ly > 0) _ctx->ly = 0; - _ctx->pt.Offset(0, -(int32)sY); + _ctx->pt.offset(0, -(int32)sY); } CORO_INVOKE_0(GLOBALS.WaitFrame); diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 66fddf2834..af2bffc459 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); - scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + scenePos.set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); } // Set up a process to change the scene diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index e056484e54..623aab5ab4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -82,8 +82,8 @@ void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { RMRes res(resID); - if ((int)res.Size() < nChars * (dimy * dimx + 8)) - nChars = res.Size() / (dimy * dimx + 8); + if ((int)res.size() < nChars * (dimy * dimx + 8)) + nChars = res.size() / (dimy * dimx + 8); load(res, nChars, dimx, dimy, palResID); } @@ -137,7 +137,7 @@ int RMFont::stringLen(const RMString &text) { int len, i; len = 0; - for (i = 0; i < text.Length() - 1; i++) + for (i = 0; i < text.length() - 1; i++) len += letterLength(text[i], text[i + 1]); len += letterLength(text[i]); @@ -1968,9 +1968,9 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Horizontally if (aHorType == HCENTER) - prim->Dst().TopLeft() -= RMPoint(_dimx / 2, 0); + prim->Dst().topLeft() -= RMPoint(_dimx / 2, 0); else if (aHorType == HRIGHT) - prim->Dst().TopLeft() -= RMPoint(_dimx, 0); + prim->Dst().topLeft() -= RMPoint(_dimx, 0); // Vertically @@ -2146,7 +2146,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (_bShowed) { if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { - prim->Dst().TopLeft() = dst; + prim->Dst().topLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2285,7 +2285,7 @@ void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Set the destination coordinates of the mouse - prim->Dst().TopLeft() = _mpos - RMPoint(0, 30); + prim->Dst().topLeft() = _mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::draw, bigBuf, prim); @@ -2308,7 +2308,7 @@ bool RMTextItemName::isItemSelected() { } bool RMTextItemName::isNormalItemSelected() { - return _item != NULL && _itemName.Length() > 0; + return _item != NULL && _itemName.length() > 0; } @@ -2321,8 +2321,8 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - DlgText.init(dlg1, dlg1.Width(), dlg1.Height()); - DlgTextLine.init(dlg2, dlg2.Width(), dlg2.Height()); + DlgText.init(dlg1, dlg1.width(), dlg1.height()); + DlgTextLine.init(dlg2, dlg2.width(), dlg2.height()); DlgText.loadPaletteWA(dlgpal); DlgTextLine.loadPaletteWA(dlgpal); @@ -2407,18 +2407,18 @@ void RMDialogChoice::prepare(CORO_PARAM) { addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); - _ctx->ptPos.Set(20, 90); + _ctx->ptPos.set(20, 90); for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { addPrim(new RMGfxPrimitive(&_drawedStrings[_ctx->i], _ctx->ptPos)); _ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0, _drawedStrings[_ctx->i].getDimy() + 15); + _ctx->ptPos.offset(0, _drawedStrings[_ctx->i].getDimy() + 15); } CORO_INVOKE_0(drawOT); clearOT(); - _ptDrawPos.Set(0, 480 - _ctx->ptPos.y); + _ptDrawPos.set(0, 480 - _ctx->ptPos.y); CORO_END_CODE; } @@ -2438,8 +2438,8 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); - _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); + _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); addPrim(new RMGfxPrimitive(&_drawedStrings[_curSelection], _ptDrawStrings[_curSelection])); @@ -2449,8 +2449,8 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (pos != -1) { _ctx->box.SetColor(100, 100, 100); - _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos].y); + _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); addPrim(new RMGfxPrimitive(&_drawedStrings[pos], _ptDrawStrings[pos])); } @@ -2485,7 +2485,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->starttime = _vm->getTime(); _ctx->deltay = 480 - _ptDrawPos.y; _ctx->destpt = _ptDrawPos; - _ptDrawPos.Set(0, 480); + _ptDrawPos.set(0, 480); if (!_nInList && bigBuf != NULL) bigBuf->addPrim(new RMGfxPrimitive(this)); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index bf708ec075..c8a70d7b0f 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -124,11 +124,11 @@ void mainSetPalesati(bool bPalesati) { RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { RMResRaw raw(dwRes); - assert(raw.IsValid()); + assert(raw.isValid()); _buf = new RMGfxSourceBuffer16(false); - _buf->init(raw, raw.Width(), raw.Height()); + _buf->init(raw, raw.width(), raw.height()); - _rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); + _rect.setRect(pt.x, pt.y, pt.x + raw.width() - 1, pt.y + raw.height() - 1); _bActive = false; _bHasGfx = true; _bDoubleState = bDoubleState; @@ -149,7 +149,7 @@ RMOptionButton::~RMOptionButton() { bool RMOptionButton::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { if (!_bDoubleState) { - if (_rect.PtInRect(mousePos)) { + if (_rect.ptInRect(mousePos)) { if (!_bActive) { _bActive = true; return true; @@ -161,7 +161,7 @@ bool RMOptionButton::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRig } } } else { - if (bLeftClick && _rect.PtInRect(mousePos)) { + if (bLeftClick && _rect.ptInRect(mousePos)) { _bActive = !_bActive; return true; } @@ -511,12 +511,12 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { RMString s; if (_bEditSaveName && _nEditPos == _ctx->i) - s.Format("%02d)%s*", _statePos + _ctx->i, _EditName); + s.format("%02d)%s*", _statePos + _ctx->i, _EditName); else { if (_statePos == 0 && _ctx->i == 0) - s.Format("Autosave"); + s.format("Autosave"); else - s.Format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); + s.format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); } _ctx->num[_ctx->i] = new RMText; @@ -585,10 +585,10 @@ void RMOptionScreen::initState(CORO_PARAM) { error("Invalid state"); } - assert(_ctx->raw->IsValid()); + assert(_ctx->raw->isValid()); assert(_menu == NULL); _menu = new RMGfxSourceBuffer16(false); - _menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + _menu->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; if (_nState == MENULOAD || _nState == MENUSAVE) { @@ -647,10 +647,10 @@ void RMOptionScreen::initState(CORO_PARAM) { _ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); _ctx->raw = new RMResRaw(20021); - assert(_ctx->raw->IsValid()); + assert(_ctx->raw->isValid()); assert(_QuitConfirm == NULL); _QuitConfirm = new RMGfxSourceBuffer16(false); - _QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + _QuitConfirm->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; assert(_ButtonQuitYes == NULL); @@ -662,10 +662,10 @@ void RMOptionScreen::initState(CORO_PARAM) { if (_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); - assert(_ctx->raw->IsValid()); + assert(_ctx->raw->isValid()); assert(_HideLoadSave == NULL); _HideLoadSave = new RMGfxSourceBuffer16(false); - _HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + _HideLoadSave->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; } @@ -1485,7 +1485,7 @@ void RMPointer::init(void) { RMResRaw res(RES_P_GO + i); _pointer[i] = new RMGfxSourceBuffer8RLEByteAA; - _pointer[i]->init(res, res.Width(), res.Height(), false); + _pointer[i]->init(res, res.width(), res.height(), false); _pointer[i]->loadPaletteWA(RES_P_PAL); } @@ -1493,17 +1493,17 @@ void RMPointer::init(void) { RMRes res(RES_P_PAP1 + i); RMDataStream ds; - ds.OpenBuffer(res); + ds.openBuffer(res); _specialPointer[i] = new RMItem; ds >> *_specialPointer[i]; } - //m_hotspot[0].Set(19,5); - _hotspot[0].Set(5, 1); - _hotspot[1].Set(32, 28); - _hotspot[2].Set(45, 23); - _hotspot[3].Set(35, 25); - _hotspot[4].Set(32, 28); + //m_hotspot[0].set(19,5); + _hotspot[0].set(5, 1); + _hotspot[1].set(32, 28); + _hotspot[2].set(45, 23); + _hotspot[3].set(35, 25); + _hotspot[4].set(32, 28); // Default=GO _nCurPointer = 0; diff --git a/engines/tony/game.h b/engines/tony/game.h index 5f387d558b..2d8f73f79b 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -39,18 +39,18 @@ namespace Tony { #define INIT_GFX16_FROMRAW(dwRes, buf16) \ raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ + assert(raw->isValid()); \ assert((buf16) == NULL); \ (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->init(*raw,raw->Width(),raw->Height()); \ + (buf16)->init(*raw,raw->width(),raw->height()); \ delete raw; #define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ + assert(raw->isValid()); \ assert((buf8) == NULL); \ (buf8) = new RMGfxSourceBuffer8RLEByte(); \ - (buf8)->init(*raw, raw->Width(), raw->Height(), true); \ + (buf8)->init(*raw, raw->width(), raw->height(), true); \ delete raw; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6369d91207..55a15a5961 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -146,7 +146,7 @@ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalet void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, Bpp()); - ds.Read(_buf, dimx * dimy * Bpp() / 8); + ds.read(_buf, dimx * dimy * Bpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); @@ -448,7 +448,7 @@ void RMGfxSourceBufferPal::init(RMDataStream &ds, int dimx, int dimy, bool bLoad // Load the palette if necessary if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; - ds.Read(suxpal, 256 * 3); + ds.read(suxpal, 256 * 3); loadPaletteWA(suxpal); delete[] suxpal; } @@ -512,8 +512,8 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit u = prim->Src().x1; v = prim->Src().y1; - width = prim->Src().Width(); - height = prim->Src().Height(); + width = prim->Src().width(); + height = prim->Src().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -620,8 +620,8 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim u = prim->Src().x1; v = prim->Src().y1; - width = prim->Src().Width(); - height = prim->Src().Height(); + width = prim->Src().width(); + height = prim->Src().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -702,7 +702,7 @@ void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoa ds >> size; _buf = new byte[size]; - ds.Read(_buf, size); + ds.read(_buf, size); _dimx = dimx; _dimy = dimy; @@ -1767,7 +1767,7 @@ void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, boo if (!bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; - ds.Read(_aabuf, dimx * dimy); + ds.read(_aabuf, dimx * dimy); } } @@ -1805,7 +1805,7 @@ void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, boo if (!bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; - ds.Read(_aabuf, dimx * dimy); + ds.read(_aabuf, dimx * dimy); } } @@ -1839,8 +1839,8 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; - dimx = prim->Src().Width(); - dimy = prim->Src().Height(); + dimx = prim->Src().width(); + dimy = prim->Src().height(); } if (prim->haveDst()) { @@ -1932,11 +1932,11 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; // Loop through the pixels - for (j = 0; j < rcDst.Height(); j++) { - for (i = 0; i < rcDst.Width(); i++) + for (j = 0; j < rcDst.height(); j++) { + for (i = 0; i < rcDst.width(); i++) *buf ++ = wFillColor; - buf += bigBuf.getDimx() - rcDst.Width(); + buf += bigBuf.getDimx() - rcDst.width(); } } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 2daa7edc6d..82f8383131 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -110,8 +110,8 @@ public: RMGfxPrimitive() { _bFlag = 0; _task = NULL; - _src.SetEmpty(); - _dst.SetEmpty(); + _src.setEmpty(); + _dst.setEmpty(); } RMGfxPrimitive(RMGfxTask *task) { @@ -124,41 +124,41 @@ public: _src = src; _dst = dst; _bFlag = 0; - _bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); + _bStretch = (src.width() != dst.width() || src.height() != dst.height()); } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { _task = task; - _src.TopLeft() = src; + _src.topLeft() = src; _dst = dst; _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { _task = task; - _src.TopLeft() = src; - _dst.TopLeft() = dst; + _src.topLeft() = src; + _dst.topLeft() = dst; _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { _task = task; _src = src; - _dst.TopLeft() = dst; + _dst.topLeft() = dst; _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { _task = task; _dst = dst; - _src.SetEmpty(); + _src.setEmpty(); _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { _task = task; - _dst.TopLeft() = dst; - _src.SetEmpty(); + _dst.topLeft() = dst; + _src.setEmpty(); _bFlag = 0; } @@ -174,27 +174,27 @@ public: _src = src; } void setSrc(const RMPoint &src) { - _src.TopLeft() = src; + _src.topLeft() = src; } void setDst(const RMRect &dst) { _dst = dst; } void setDst(const RMPoint &dst) { - _dst.TopLeft() = dst; + _dst.topLeft() = dst; } void setStrecth(bool bStretch) { _bStretch = bStretch; } bool haveDst() { - return !_dst.IsEmpty(); + return !_dst.isEmpty(); } RMRect &Dst() { return _dst; } bool haveSrc() { - return !_src.IsEmpty(); + return !_src.isEmpty(); } RMRect &Src() { return _src; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 56ce8a47e1..b102323dce 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -412,7 +412,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { for (i = 0; i < 5; i++) { // Try the loading of the location RMRes res(_nCurLoc); - if (!res.IsValid()) + if (!res.isValid()) continue; _loc.load(res); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 4990b379b9..36cad4c6a1 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -34,7 +34,7 @@ namespace Tony { RMInput::RMInput() { // Setup mouse fields _clampMouse = false; - _mousePos.Set(0, 0); + _mousePos.set(0, 0); _leftButton = _rightButton = false; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; @@ -60,7 +60,7 @@ void RMInput::poll(void) { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: - _mousePos.Set(_event.mouse.x, _event.mouse.y); + _mousePos.set(_event.mouse.x, _event.mouse.y); if (_event.type == Common::EVENT_LBUTTONDOWN) { _leftButton = true; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 5ff4f6cd10..c83402e724 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -97,13 +97,13 @@ void RMInventory::init(void) { RMRes res(curres); RMDataStream ds; - assert(res.IsValid()); + assert(res.isValid()); // Initialise the MPAL inventory item by reading it in. _items[i].icon.setInitCurPattern(false); - ds.OpenBuffer(res); + ds.openBuffer(res); ds >> _items[i].icon; - ds.Close(); + ds.close(); // Puts in the default pattern 1 _items[i].pointer = NULL; @@ -120,9 +120,9 @@ void RMInventory::init(void) { for (j = 0; j < _items[i].icon.numPattern(); j++) { RMResRaw raw(curres); - assert(raw.IsValid()); + assert(raw.isValid()); - _items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); + _items[i].pointer[j].init((const byte *)raw, raw.width(), raw.height(), true); curres++; } } @@ -133,11 +133,11 @@ void RMInventory::init(void) { // Download interface RMDataStream ds; RMRes res(RES_I_MINIINTER); - assert(res.IsValid()); - ds.OpenBuffer(res); + assert(res.isValid()); + ds.openBuffer(res); ds >> miniInterface; miniInterface.setPattern(1); - ds.Close(); + ds.close(); // Create the text for hints on the mini interface _hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); @@ -202,11 +202,11 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_state == SELECTING) { if (!GLOBALS.bCfgInvUp) { - _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); - _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); + _ctx->pos.set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); + _ctx->pos2.set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( - _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, 119 - 4); + _ctx->pos.set((_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( + _ctx->pos2.set((_nSelectObj + 1) * 64 + 34, 119 - 4); } _ctx->p = new RMGfxPrimitive(prim->_task, _ctx->pos); @@ -774,7 +774,7 @@ int RMInterface::onWhichBox(RMPoint pt) { // Find the verb for (i = 0; i < max; i++) - if (_hotbbox[i].PtInRect(pt)) + if (_hotbbox[i].ptInRect(pt)) return i; // Found no verb @@ -788,13 +788,13 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - prim->Dst().TopLeft() = _openStart; + prim->Dst().topLeft() = _openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone _ctx->h = onWhichBox(_mpos); if (_ctx->h != -1) { - prim->Dst().TopLeft() = _openStart; + prim->Dst().topLeft() = _openStart; CORO_INVOKE_2(_hotzone[_ctx->h].draw, bigBuf, prim); if (_lastHotZone != _ctx->h) { @@ -803,7 +803,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr } if (GLOBALS.bCfgInterTips) { - prim->Dst().TopLeft() = _openStart + RMPoint(70, 177); + prim->Dst().topLeft() = _openStart + RMPoint(70, 177); CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } } else @@ -896,21 +896,21 @@ void RMInterface::init(void) { setPriority(191); - RMGfxSourceBuffer::init(inter, inter.Width(), inter.Height()); + RMGfxSourceBuffer::init(inter, inter.width(), inter.height()); loadPaletteWA(RES_I_INTERPAL); for (i = 0; i < 5; i++) { RMResRaw part(RES_I_INTERP1 + i); - _hotzone[i].init(part, part.Width(), part.Height()); + _hotzone[i].init(part, part.width(), part.height()); _hotzone[i].loadPaletteWA(pal); } - _hotbbox[0].SetRect(126, 123, 159, 208); // Take - _hotbbox[1].SetRect(90, 130, 125, 186); // About - _hotbbox[2].SetRect(110, 60, 152, 125); - _hotbbox[3].SetRect(56, 51, 93, 99); - _hotbbox[4].SetRect(51, 105, 82, 172); + _hotbbox[0].setRect(126, 123, 159, 208); // Take + _hotbbox[1].setRect(90, 130, 125, 186); // About + _hotbbox[2].setRect(110, 60, 152, 125); + _hotbbox[3].setRect(56, 51, 93, 99); + _hotbbox[4].setRect(51, 105, 82, 172); _hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); _hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d2688140fb..48480389bb 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -50,7 +50,7 @@ using namespace ::Tony::MPAL; * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal._data, 1024); + ds.read(pal._data, 1024); return ds; } @@ -129,7 +129,7 @@ void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { // Create and read the slots _slots = new RMSlot[_nSlots]; - for (i = 0; i < _nSlots && !ds.IsError(); i++) { + for (i = 0; i < _nSlots && !ds.isError(); i++) { if (bLOX) _slots[i].readFromStream(ds, true); else @@ -319,20 +319,20 @@ void RMSprite::init(RMGfxSourceBuffer *buf) { } void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.Pos(); + int pos = ds.pos(); ds >> *dimx >> *dimy; - ds.Seek(pos, ds.START); + ds.seek(pos, ds.START); } void RMSprite::getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.Pos(); + int pos = ds.pos(); ds >> _name; ds >> *dimx >> *dimy; - ds.Seek(pos, ds.START); + ds.seek(pos, ds.START); } void RMSprite::readFromStream(RMDataStream &ds, bool bLOX) { @@ -404,7 +404,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { ds >> size; // Upload the sound effect identifier from the buffer - ds.Read(id, 4); + ds.read(id, 4); // Ensure it's a RIFF assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); @@ -414,7 +414,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { // Read the raw WAV data raw = new byte[size]; - ds.Read(raw, size); + ds.read(raw, size); // Create the sound effect _fx = _vm->createSFX(raw); @@ -522,18 +522,18 @@ bool RMItem::isIn(const RMPoint &pt, int *size) { return false; // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one - if (_nCurPattern != 0 && !_sprites[_nCurSprite]._rcBox.IsEmpty()) + if (_nCurPattern != 0 && !_sprites[_nCurSprite]._rcBox.isEmpty()) rc = _sprites[_nCurSprite]._rcBox + calculatePos(); - else if (!_rcBox.IsEmpty()) + else if (!_rcBox.isEmpty()) rc = _rcBox; // If no box, return immediately else return false; if (size != NULL) - *size = rc.Size(); + *size = rc.size(); - return rc.PtInRect(pt + _curScroll); + return rc.ptInRect(pt + _curScroll); } void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { @@ -592,8 +592,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _patterns = new RMPattern[_nPatterns + 1]; // Read in class data - if (!ds.IsError()) - for (i = 0; i < _nSprites && !ds.IsError(); i++) { + if (!ds.isError()) + for (i = 0; i < _nSprites && !ds.isError(); i++) { // Download the sprites if (bLOX) { _sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); @@ -609,8 +609,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _sprites[i].setPalette(_pal._data); } - if (!ds.IsError()) - for (i = 0; i < _nSfx && !ds.IsError(); i++) { + if (!ds.isError()) + for (i = 0; i < _nSfx && !ds.isError(); i++) { if (bLOX) _sfx[i].readFromStream(ds, true); else @@ -618,8 +618,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { } // Read the pattern from pattern 1 - if (!ds.IsError()) - for (i = 1; i <= _nPatterns && !ds.IsError(); i++) { + if (!ds.isError()) + for (i = 1; i <= _nPatterns && !ds.isError(); i++) { if (bLOX) _patterns[i].readFromStream(ds, true); else @@ -695,11 +695,11 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->setFlag(_bCurFlag); // Offset direction for scrolling - prim->Dst().Offset(-_curScroll); + prim->Dst().offset(-_curScroll); // We must offset the cordinates of the item inside the primitive // It is estimated as nonno + (babbo + figlio) - prim->Dst().Offset(calculatePos()); + prim->Dst().offset(calculatePos()); // No stretching, please prim->setStrecth(false); @@ -781,7 +781,7 @@ RMItem::RMItem() { _patterns = NULL; _sprites = NULL; _sfx = NULL; - _curScroll.Set(0, 0); + _curScroll.set(0, 0); _bInitCurPattern = true; _nCurPattern = 0; _z = 0; @@ -904,9 +904,9 @@ void RMWipe::initFade(int type) { RMRes res(RES_W_CERCHIO); RMDataStream ds; - ds.OpenBuffer(res); + ds.openBuffer(res); ds >> _wip0r; - ds.Close(); + ds.close(); _wip0r.setPattern(1); @@ -1688,7 +1688,7 @@ RMCharacter::RMCharacter() { bDrawNow = false; bNeedToStop = false; - _pos.Set(0, 0); + _pos.set(0, 0); } RMCharacter::~RMCharacter() { @@ -1824,14 +1824,14 @@ void RMGameBoxes::init(void) { for (i = 1; i <= _nLocBoxes; i++) { RMRes res(10000 + i); - ds.OpenBuffer(res); + ds.openBuffer(res); _allBoxes[i] = new RMBoxLoc(); ds >> *_allBoxes[i]; _allBoxes[i]->recalcAllAdj(); - ds.Close(); + ds.close(); } } @@ -1985,9 +1985,9 @@ bool RMLocation::load(Common::File &file) { RMFileStreamSlow fs; - fs.OpenFile(file); + fs.openFile(file); bRet = load(fs); - fs.Close(); + fs.close(); return bRet; } @@ -1997,9 +1997,9 @@ bool RMLocation::load(const byte *buf) { RMDataStream ds; bool bRet; - ds.OpenBuffer(buf); + ds.openBuffer(buf); bRet = load(ds); - ds.Close(); + ds.close(); return bRet; } @@ -2045,7 +2045,7 @@ bool RMLocation::load(RMDataStream &ds) { // Location dimensions ds >> dimx >> dimy; - _curScroll.Set(0, 0); + _curScroll.set(0, 0); // Read the colour mode ds >> cm; @@ -2081,11 +2081,11 @@ bool RMLocation::load(RMDataStream &ds) { _vm->freezeTime(); - for (i = 0; i < _nItems && !ds.IsError(); i++) + for (i = 0; i < _nItems && !ds.isError(); i++) ds >> _items[i]; _vm->unfreezeTime(); - return ds.IsError(); + return ds.isError(); } @@ -2107,7 +2107,7 @@ bool RMLocation::loadLOX(RMDataStream &ds) { // Dimensions ds >> dimx >> dimy; - _curScroll.Set(0, 0); + _curScroll.set(0, 0); // It's always 65K (16-bit) mode _cmode = CM_65K; @@ -2123,10 +2123,10 @@ bool RMLocation::loadLOX(RMDataStream &ds) { if (_nItems > 0) _items = new RMItem[_nItems]; - for (i = 0; i < _nItems && !ds.IsError(); i++) + for (i = 0; i < _nItems && !ds.isError(); i++) _items[i].readFromStream(ds, true); - return ds.IsError(); + return ds.isError(); } diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index 2e3bd07383..edc6e65ca1 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -37,42 +37,42 @@ namespace MPAL { * @param resId MPAL resource to open */ RMRes::RMRes(uint32 resID) { - m_h = _vm->_resUpdate.QueryResource(resID); - if (m_h == NULL) - m_h = mpalQueryResource(resID); - if (m_h != NULL) - m_buf = (byte *)GlobalLock(m_h); + _h = _vm->_resUpdate.queryResource(resID); + if (_h == NULL) + _h = mpalQueryResource(resID); + if (_h != NULL) + _buf = (byte *)GlobalLock(_h); } /** * Destructor */ RMRes::~RMRes() { - if (m_h != NULL) { - GlobalUnlock(m_h); - GlobalFree(m_h); + if (_h != NULL) { + GlobalUnlock(_h); + GlobalFree(_h); } } /** * Returns a pointer to the resource */ -const byte *RMRes::DataPointer() { - return m_buf; +const byte *RMRes::dataPointer() { + return _buf; } /** * Returns a pointer to the resource */ RMRes::operator const byte *() { - return DataPointer(); + return dataPointer(); } /** * Returns the size of the resource */ -unsigned int RMRes::Size() { - return GlobalSize(m_h); +unsigned int RMRes::size() { + return GlobalSize(_h); } /****************************************************************************\ @@ -86,19 +86,19 @@ RMResRaw::~RMResRaw() { } const byte *RMResRaw::DataPointer() { - return m_buf + 8; + return _buf + 8; } RMResRaw::operator const byte *() { return DataPointer(); } -int RMResRaw::Width() { - return READ_LE_UINT16(m_buf + 4); +int RMResRaw::width() { + return READ_LE_UINT16(_buf + 4); } -int RMResRaw::Height() { - return READ_LE_UINT16(m_buf + 6); +int RMResRaw::height() { + return READ_LE_UINT16(_buf + 6); } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index a9f8403fcd..a428a40a64 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -33,17 +33,17 @@ namespace MPAL { class RMRes { protected: - HGLOBAL m_h; - byte *m_buf; + HGLOBAL _h; + byte *_buf; public: RMRes(uint32 resID); virtual ~RMRes(); // Attributes - unsigned int Size(); - const byte *DataPointer(); - bool IsValid() { return m_h != NULL; } + unsigned int size(); + const byte *dataPointer(); + bool isValid() { return _h != NULL; } // Casting for access to data operator const byte*(); @@ -57,8 +57,8 @@ public: const byte *DataPointer(); operator const byte*(); - int Width(); - int Height(); + int width(); + int height(); }; } // end of namespace MPAL diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index abc3033993..72ea389e59 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -127,7 +127,7 @@ Common::ErrorCode TonyEngine::init() { return Common::kUnknownError; // Initialise the update resources - _resUpdate.Init("ROASTED.MPU"); + _resUpdate.init("ROASTED.MPU"); // Initialise the music initMusic(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index dc771b08aa..fb53d68615 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -105,18 +105,18 @@ void RMTony::init(void) { _bIsStaticTalk = false; // Opens the buffer - ds.OpenBuffer(tony); + ds.openBuffer(tony); // Reads his details from the stream readFromStream(ds, true); // Closes the buffer - ds.Close(); + ds.close(); // Reads Tony's body - ds.OpenBuffer(body); + ds.openBuffer(body); _body.readFromStream(ds, true); - ds.Close(); + ds.close(); _body.setPattern(0); _nTimeLastStep = _vm->getTime(); @@ -180,28 +180,28 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Call the Draw() of the parent class if Tony is visible if (_bShow && bDrawNow) { if (_bCorpoDavanti) { - prim->Dst().SetEmpty(); - prim->Dst().Offset(-44, -134); + prim->Dst().setEmpty(); + prim->Dst().offset(-44, -134); if (_bPastorella) - prim->Dst().Offset(1, 4); + prim->Dst().offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } if (_bIsTalking || _bIsStaticTalk) { // Offest direction from scrolling - prim->Dst().SetEmpty(); - prim->Dst().Offset(-_curScroll); - prim->Dst().Offset(_pos); - prim->Dst().Offset(-44, -134); + prim->Dst().setEmpty(); + prim->Dst().offset(-_curScroll); + prim->Dst().offset(_pos); + prim->Dst().offset(-44, -134); prim->Dst() += _nBodyOffset; CORO_INVOKE_2(_body.draw, bigBuf, prim); } if (!_bCorpoDavanti) { - prim->Dst().SetEmpty(); - prim->Dst().Offset(-44, -134); + prim->Dst().setEmpty(); + prim->Dst().offset(-44, -134); if (_bPastorella) - prim->Dst().Offset(0, 3); + prim->Dst().offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } } @@ -630,25 +630,25 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_STANDDOWN; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); break; case LEFT: headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case RIGHT: headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case UP: headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_STANDUP; - _nBodyOffset.Set(6, 53); + _nBodyOffset.set(6, 53); break; } break; @@ -657,7 +657,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body _bCorpoDavanti = false; switch (_TalkDirection) { case UP: - _nBodyOffset.Set(2, 42); + _nBodyOffset.set(2, 42); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_FIANCHIUP_START; headLoopPat = PAT_TALK_UP; @@ -665,7 +665,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - _nBodyOffset.Set(2, 48); + _nBodyOffset.set(2, 48); headStartPat = PAT_TESTA_DOWN; bodyStartPat = BPAT_FIANCHIDOWN_START; headLoopPat = PAT_TALK_DOWN; @@ -673,7 +673,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - _nBodyOffset.Set(-3, 53); + _nBodyOffset.set(-3, 53); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_FIANCHILEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -681,7 +681,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - _nBodyOffset.Set(2, 53); + _nBodyOffset.set(2, 53); headStartPat = PAT_TESTA_RIGHT; bodyStartPat = BPAT_FIANCHIRIGHT_START; headLoopPat = PAT_TALK_RIGHT; @@ -692,7 +692,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CANTA: - _nBodyOffset.Set(-10, 25); + _nBodyOffset.set(-10, 25); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_CANTALEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -705,7 +705,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: case DOWN: case LEFT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; @@ -713,7 +713,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -728,14 +728,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: case DOWN: case LEFT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; break; case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -750,13 +750,13 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: case DOWN: case LEFT: - _nBodyOffset.Set(-4, 40); + _nBodyOffset.set(-4, 40); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_SIINDICALEFT; break; case RIGHT: - _nBodyOffset.Set(5, 40); + _nBodyOffset.set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; break; @@ -766,7 +766,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SPAVENTATO: switch (_TalkDirection) { case UP: - _nBodyOffset.Set(-4, -11); + _nBodyOffset.set(-4, -11); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_SPAVENTOUP_START; headLoopPat = PAT_TALK_UP; @@ -774,7 +774,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - _nBodyOffset.Set(-5, 45); + _nBodyOffset.set(-5, 45); headStartPat = PAT_SPAVENTODOWN_START; bodyStartPat = BPAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -782,7 +782,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - _nBodyOffset.Set(-4, 41); + _nBodyOffset.set(-4, 41); headStartPat = PAT_SPAVENTORIGHT_START; bodyStartPat = BPAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -790,7 +790,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - _nBodyOffset.Set(-10, 41); + _nBodyOffset.set(-10, 41); headStartPat = PAT_SPAVENTOLEFT_START; bodyStartPat = BPAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -805,7 +805,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; - _nBodyOffset.Set(6, 53); + _nBodyOffset.set(6, 53); headStartPat = PAT_TESTA_UP; headLoopPat = PAT_TALK_UP; @@ -814,7 +814,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); headStartPat = PAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -823,7 +823,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -832,7 +832,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -841,27 +841,27 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONBICCHIERE: - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_BICCHIERE; break; case TALK_CONVERME: - _nBodyOffset.Set(9, 56); + _nBodyOffset.set(9, 56); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_VERME; break; case TALK_CONMARTELLO: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MARTELLO; break; case TALK_CONCORDA: - _nBodyOffset.Set(-3, 38); + _nBodyOffset.set(-3, 38); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CORDA; break; case TALK_CONSEGRETARIA: - _nBodyOffset.Set(-17, 12); + _nBodyOffset.set(-17, 12); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONSEGRETARIA; break; @@ -870,7 +870,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-21, -5); + _nBodyOffset.set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; @@ -878,7 +878,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -5); + _nBodyOffset.set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; @@ -890,7 +890,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-61, -7); + _nBodyOffset.set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; @@ -898,7 +898,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-5, -7); + _nBodyOffset.set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; @@ -910,7 +910,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-34, -2); + _nBodyOffset.set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; @@ -918,7 +918,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -2); + _nBodyOffset.set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; @@ -930,7 +930,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-35, 2); + _nBodyOffset.set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; @@ -938,7 +938,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-14, 2); + _nBodyOffset.set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; @@ -972,14 +972,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: headLoopPat = PAT_TALKBARBA_LEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case DOWN: case RIGHT: headLoopPat = PAT_TALKBARBA_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; } break; @@ -988,7 +988,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SCHIFATOLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SCHIFATOLEFT_LOOP; @@ -996,7 +996,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SCHIFATORIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SCHIFATORIGHT_LOOP; @@ -1008,7 +1008,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_NAAHLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_NAAHLEFT_LOOP; @@ -1016,7 +1016,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_NAAHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_NAAHRIGHT_LOOP; @@ -1025,47 +1025,47 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_MACBETH1: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH1; break; case TALK_MACBETH2: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH2; break; case TALK_MACBETH3: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH3; break; case TALK_MACBETH4: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH4; break; case TALK_MACBETH5: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH5; break; case TALK_MACBETH6: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH6; break; case TALK_MACBETH7: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH7; break; case TALK_MACBETH8: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH8; break; case TALK_MACBETH9: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH9; break; @@ -1076,7 +1076,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); headStartPat = PAT_SPAVENTODOWN_STAND; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -1085,7 +1085,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTORIGHT_STAND; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -1094,7 +1094,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTOLEFT_STAND; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -1450,10 +1450,10 @@ void RMTony::endTalk(CORO_PARAM) { setPattern(0); if (_TalkDirection == UP || _TalkDirection == LEFT) { _body.setPattern(BPAT_CONBARBALEFT_STATIC); - _nBodyOffset.Set(-41, -14); + _nBodyOffset.set(-41, -14); } else if (_TalkDirection == DOWN || _TalkDirection == RIGHT) { _body.setPattern(BPAT_CONBARBARIGHT_STATIC); - _nBodyOffset.Set(-26, -14); + _nBodyOffset.set(-26, -14); } mainUnfreeze(); } else { @@ -1564,14 +1564,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-21, -5); + _nBodyOffset.set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -5); + _nBodyOffset.set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; break; @@ -1582,14 +1582,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-34, -2); + _nBodyOffset.set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -2); + _nBodyOffset.set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; break; @@ -1600,14 +1600,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-61, -7); + _nBodyOffset.set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-5, -7); + _nBodyOffset.set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; break; @@ -1618,14 +1618,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-35, 2); + _nBodyOffset.set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-14, 2); + _nBodyOffset.set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; break; @@ -1636,14 +1636,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-16, -9); + _nBodyOffset.set(-16, -9); bodyStartPat = BPAT_CONTACCUINOLEFT_START; bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-6, -9); + _nBodyOffset.set(-6, -9); bodyStartPat = BPAT_CONTACCUINORIGHT_START; bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; break; @@ -1654,14 +1654,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-41, -8); + _nBodyOffset.set(-41, -8); bodyStartPat = BPAT_CONMEGAFONOLEFT_START; bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-14, -8); + _nBodyOffset.set(-14, -8); bodyStartPat = BPAT_CONMEGAFONORIGHT_START; bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; break; @@ -1672,7 +1672,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-41, -14); + _nBodyOffset.set(-41, -14); bodyStartPat = BPAT_CONBARBALEFT_START; bodyLoopPat = BPAT_STANDLEFT; headLoopPat = PAT_TALKBARBA_LEFT; @@ -1681,7 +1681,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case DOWN: case RIGHT: - _nBodyOffset.Set(-26, -14); + _nBodyOffset.set(-26, -14); bodyStartPat = BPAT_CONBARBARIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; headLoopPat = PAT_TALKBARBA_RIGHT; @@ -1697,7 +1697,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDDOWN; bodyStartPat = BPAT_STANDDOWN; headLoopPat = PAT_SPAVENTODOWN_STAND; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); break; case LEFT: @@ -1705,7 +1705,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDLEFT; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SPAVENTOLEFT_STAND; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case RIGHT: @@ -1713,7 +1713,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDRIGHT; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SPAVENTORIGHT_STAND; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; default: diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 92b896b180..f11c9e6a2f 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -40,17 +40,17 @@ namespace Tony { * Constructor */ RMString::RMString() { - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; } /** * Destructor */ RMString::~RMString() { - if (m_string != NULL) - delete[] m_string; + if (_string != NULL) + delete[] _string; } /** @@ -58,9 +58,9 @@ RMString::~RMString() { */ RMString::RMString(const RMString &str) { // Richiama l'overload su '=' per copiare - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = str; } @@ -69,9 +69,9 @@ RMString::RMString(const RMString &str) { */ RMString::RMString(const char *str) { // Use the overloaded '=' when copying - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = str; } @@ -80,9 +80,9 @@ RMString::RMString(const char *str) { */ RMString::RMString(const int ch) { // Use the overloaded '=' when copying - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = ch; } @@ -90,8 +90,8 @@ RMString::RMString(const int ch) { * Returns the length of the string * @returns Length */ -int RMString::Length() const { - return m_length; +int RMString::length() const { + return _length; } /** @@ -99,9 +99,9 @@ int RMString::Length() const { * @param nIndex Position of the character to return * @returns Character */ -char RMString::GetAt(int nIndex) { - assert(nIndex < m_length); - return m_string[nIndex]; +char RMString::getAt(int nIndex) { + assert(nIndex < _length); + return _string[nIndex]; } /** @@ -109,9 +109,9 @@ char RMString::GetAt(int nIndex) { * @param nIndex Position of the character to change * @param c Character */ -void RMString::SetAt(int nIndex, char c) { - assert(nIndex < m_length); - m_string[nIndex] = c; +void RMString::setAt(int nIndex, char c) { + assert(nIndex < _length); + _string[nIndex] = c; } /** @@ -120,8 +120,8 @@ void RMString::SetAt(int nIndex, char c) { * @params Reference to the character */ char &RMString::operator[](int nIndex) { - assert(nIndex < m_length); - return m_string[nIndex]; + assert(nIndex < _length); + return _string[nIndex]; } /** @@ -131,21 +131,21 @@ char &RMString::operator[](int nIndex) { */ const RMString &RMString::operator=(const RMString &str) { // Set the new length - m_length = str.m_length; + _length = str._length; // If the source is empty, then destroy the current string buffer - if (m_length == 0) { - if (m_realLength > 0) { - delete[] m_string; - m_string = NULL; - m_realLength = 0; + if (_length == 0) { + if (_realLength > 0) { + delete[] _string; + _string = NULL; + _realLength = 0; } } else { // Resize if necessary - Resize(m_length + 1); + resize(_length + 1); // Copy the string - Common::copy(str.m_string, str.m_string + m_length + 1, m_string); + Common::copy(str._string, str._string + _length + 1, _string); } return *this; @@ -159,20 +159,20 @@ const RMString &RMString::operator=(const RMString &str) { const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { - if (m_realLength > 0) { - delete[] m_string; - m_string = NULL; - m_realLength = m_length = 0; + if (_realLength > 0) { + delete[] _string; + _string = NULL; + _realLength = _length = 0; } } else { // Calculate the new length - m_length = strlen(str); + _length = strlen(str); // Resize if necessary - Resize(m_length + 1); + resize(_length + 1); // Copy the string - Common::copy(str, str + m_length + 1, m_string); + Common::copy(str, str + _length + 1, _string); } return *this; @@ -186,18 +186,18 @@ const RMString &RMString::operator=(const char *str) { const RMString &RMString::operator=(const int ch) { if (ch == '\0') { // Destroy the current string - if (m_realLength > 0) { - delete [] m_string; - m_string = NULL; - m_length = m_realLength = 0; + if (_realLength > 0) { + delete [] _string; + _string = NULL; + _length = _realLength = 0; } } else { // Resize if necessary - Resize(2); + resize(2); - m_string[0] = ch; - m_string[1] = '\0'; - m_length = 1; + _string[0] = ch; + _string[1] = '\0'; + _length = 1; } return *this; @@ -208,21 +208,21 @@ const RMString &RMString::operator=(const int ch) { * @param str String to concatenate * @param size Length of the string */ -void RMString::Connect(const char *str, int size) { +void RMString::connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length + size; + nlen = _length + size; // Resize - Resize(nlen + 1, true); + resize(nlen + 1, true); // Linkage with '\0' - Common::copy(str, str + size + 1, m_string + m_length); + Common::copy(str, str + size + 1, _string + _length); // Save the new length - m_length = nlen; + _length = nlen; } } @@ -232,7 +232,7 @@ void RMString::Connect(const char *str, int size) { * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str, str.Length()); + connect(str, str.length()); return *this; } @@ -242,7 +242,7 @@ const RMString &RMString::operator+=(RMString &str) { * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { - Connect(str, strlen(str)); + connect(str, strlen(str)); return *this; } @@ -258,7 +258,7 @@ const RMString &RMString::operator+=(const int ch) { str[0] = ch; str[1] = '\0'; - Connect(str, 1); + connect(str, 1); return *this; } @@ -267,7 +267,7 @@ const RMString &RMString::operator+=(const int ch) { * @returns char * reference to string */ RMString::operator char *() const { - return m_string; + return _string; } /** @@ -276,21 +276,21 @@ RMString::operator char *() const { * @param bMaintain If true we must keep the original string, if false we can destroy. */ -void RMString::Resize(int size, bool bMantain) { - if (m_realLength == 0) { - m_string = new char[size]; - m_realLength = size; - } else if (size > m_realLength) { +void RMString::resize(int size, bool bMantain) { + if (_realLength == 0) { + _string = new char[size]; + _realLength = size; + } else if (size > _realLength) { if (bMantain) { char *app; app = new char[size]; - Common::copy(m_string, m_string + m_length + 1, app); - delete[] m_string; - m_string = app; + Common::copy(_string, _string + _length + 1, app); + delete[] _string; + _string = app; } else { - delete[] m_string; - m_string = new char[size]; + delete[] _string; + _string = new char[size]; } } } @@ -298,15 +298,15 @@ void RMString::Resize(int size, bool bMantain) { /** * Compacts the string to occupy less memory if possible. */ -void RMString::Compact(void) { - if (m_realLength + 1 > m_length) { +void RMString::compact(void) { + if (_realLength + 1 > _length) { char *app; - app = new char[m_length + 1]; - Common::copy(m_string, m_string + m_length + 1, app); + app = new char[_length + 1]; + Common::copy(_string, _string + _length + 1, app); - delete[] m_string; - m_string = app; + delete[] _string; + _string = app; } } @@ -359,14 +359,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { int i; df >> len; - var.Resize(len + 1); - var.m_length = len + 1; + var.resize(len + 1); + var._length = len + 1; for (i = 0; i < len; i++) df >> var[i]; var[i] = '\0'; - var.m_length = len; + var._length = len; return df; } @@ -374,7 +374,7 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { /** * Formats a string */ -void RMString::Format(const char *str, ...) { +void RMString::format(const char *str, ...) { static char buf[2048]; va_list argList; @@ -393,29 +393,29 @@ RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { } RMFileStreamSlow::~RMFileStreamSlow() { - Close(); + close(); } -void RMFileStreamSlow::Close() { +void RMFileStreamSlow::close() { delete _stream; } -bool RMFileStreamSlow::OpenFile(Common::File &file) { +bool RMFileStreamSlow::openFile(Common::File &file) { _stream = file.readStream(file.size()); - m_length = _stream->pos(); + _length = _stream->pos(); return true; } -bool RMFileStreamSlow::OpenFile(const char *lpFN) { +bool RMFileStreamSlow::openFile(const char *lpFN) { // Open file for reading Common::File f; if (!f.open(lpFN)) return false; - m_length = f.size(); + _length = f.size(); _stream = f.readStream(f.size()); return true; @@ -423,20 +423,20 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { - Seek(nBytes); + seek(nBytes); return *this; } -int RMFileStreamSlow::Pos() { +int RMFileStreamSlow::pos() { return _stream->pos(); } -bool RMFileStreamSlow::IsEOF() { - return (Pos() >= m_length); +bool RMFileStreamSlow::isEOF() { + return (pos() >= _length); } -int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { +int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); @@ -453,7 +453,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { } -bool RMFileStreamSlow::Read(void *buf, int size) { +bool RMFileStreamSlow::read(void *buf, int size) { uint32 dwRead; dwRead = _stream->read(buf, size); @@ -462,39 +462,39 @@ bool RMFileStreamSlow::Read(void *buf, int size) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); v = FROM_LE_16(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = (int16)FROM_LE_16(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; } @@ -508,24 +508,24 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { * Constructor */ RMDataStream::RMDataStream() { - m_length = 0; - m_pos = 0; - m_bError = false; + _length = 0; + _pos = 0; + _bError = false; } /** * Destructor */ RMDataStream::~RMDataStream() { - Close(); + close(); } /** * Close a stream */ -void RMDataStream::Close(void) { - m_length = 0; - m_pos = 0; +void RMDataStream::close(void) { + _length = 0; + _pos = 0; } /** @@ -535,27 +535,27 @@ void RMDataStream::Close(void) { * @remarks If the length of the buffer is not known, and cannot be * specified, then EOF() and Seek() to end won't work. */ -void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { - m_length = size; - m_buf = lpBuf; - m_bError = false; - m_pos = 0; +void RMDataStream::openBuffer(const byte *lpBuf, int size) { + _length = size; + _buf = lpBuf; + _bError = false; + _pos = 0; } /** * Returns the length of the stream * @returns Stream length */ -int RMDataStream::Length() { - return m_length; +int RMDataStream::length() { + return _length; } /** * Determines if the end of the stream has been reached * @returns true if end of stream reached, false if not */ -bool RMDataStream::IsEOF() { - return (m_pos >= m_length); +bool RMDataStream::isEOF() { + return (_pos >= _length); } /** @@ -565,7 +565,7 @@ bool RMDataStream::IsEOF() { * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } @@ -576,7 +576,7 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } @@ -588,7 +588,7 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = FROM_LE_16(v); return df; @@ -602,7 +602,7 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = (int16)FROM_LE_16(v); return df; @@ -616,7 +616,7 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = (int)FROM_LE_32(v); return df; @@ -630,7 +630,7 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; @@ -642,17 +642,17 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { * @param size Size of the buffer * @returns true if we have reached the end, false if not */ -bool RMDataStream::Read(void *lpBuf, int size) { +bool RMDataStream::read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; - if ((m_pos + size) > m_length) { - Common::copy(m_buf + m_pos, m_buf + m_pos + (m_length - m_pos), dest); + if ((_pos + size) > _length) { + Common::copy(_buf + _pos, _buf + _pos + (_length - _pos), dest); return true; } else { - Common::copy(m_buf + m_pos, m_buf + m_pos + size, dest); + Common::copy(_buf + _pos, _buf + _pos + size, dest); - m_pos += size; + _pos += size; return false; } } @@ -663,7 +663,7 @@ bool RMDataStream::Read(void *lpBuf, int size) { * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos += nBytes; + _pos += nBytes; return *this; } @@ -673,57 +673,57 @@ RMDataStream &RMDataStream::operator+=(int nBytes) { * @param origin Origin to do offset from * @returns The absolute current position in bytes */ -int RMDataStream::Seek(int nBytes, RMDSPos origin) { +int RMDataStream::seek(int nBytes, RMDSPos origin) { switch (origin) { case CUR: break; case START: - m_pos = 0; + _pos = 0; break; case END: - if (m_length == SIZENOTKNOWN) - return m_pos; - m_pos = m_length; + if (_length == SIZENOTKNOWN) + return _pos; + _pos = _length; break; } - m_pos += nBytes; - return m_pos; + _pos += nBytes; + return _pos; } /** * Returns the current position of the stream * @returns The current position */ -int RMDataStream::Pos() { - return m_pos; +int RMDataStream::pos() { + return _pos; } /** * Check if an error occurred during reading the stream * @returns true if there was an error, false otherwise */ -bool RMDataStream::IsError() { - return m_bError; +bool RMDataStream::isError() { + return _bError; } /** * Sets an error code for the stream * @param code Error code */ -void RMDataStream::SetError(int code) { - m_bError = true; - m_ecode = code; +void RMDataStream::setError(int code) { + _bError = true; + _ecode = code; } /** * Returns the error code for the stream * @returns Error code */ -int RMDataStream::GetError() { - return m_ecode; +int RMDataStream::getError() { + return _ecode; } /****************************************************************************\ @@ -766,7 +766,7 @@ RMPoint &RMPoint::operator=(RMPoint p) { /** * Offsets the point by another point */ -void RMPoint::Offset(const RMPoint &p) { +void RMPoint::offset(const RMPoint &p) { x += p.x; y += p.y; } @@ -774,7 +774,7 @@ void RMPoint::Offset(const RMPoint &p) { /** * Offsets the point by a specified offset */ -void RMPoint::Offset(int xOff, int yOff) { +void RMPoint::offset(int xOff, int yOff) { x += xOff; y += yOff; } @@ -801,7 +801,7 @@ RMPoint operator-(RMPoint p1, RMPoint p2) { * Sum (offset) of a point */ RMPoint &RMPoint::operator+=(RMPoint p) { - Offset(p); + offset(p); return *this; } @@ -809,7 +809,7 @@ RMPoint &RMPoint::operator+=(RMPoint p) { * Subtract (offset) of a point */ RMPoint &RMPoint::operator-=(RMPoint p) { - Offset(-p); + offset(-p); return *this; } @@ -852,93 +852,93 @@ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { \****************************************************************************/ RMRect::RMRect() { - SetEmpty(); + setEmpty(); } -void RMRect::SetEmpty(void) { +void RMRect::setEmpty(void) { x1 = y1 = x2 = y2 = 0; } RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { - SetRect(p1, p2); + setRect(p1, p2); } RMRect::RMRect(int X1, int Y1, int X2, int Y2) { - SetRect(X1, Y1, X2, Y2); + setRect(X1, Y1, X2, Y2); } RMRect::RMRect(const RMRect &rc) { - CopyRect(rc); + copyRect(rc); } -void RMRect::SetRect(const RMPoint &p1, const RMPoint &p2) { +void RMRect::setRect(const RMPoint &p1, const RMPoint &p2) { x1 = p1.x; y1 = p1.y; x2 = p2.x; y2 = p2.y; } -void RMRect::SetRect(int X1, int Y1, int X2, int Y2) { +void RMRect::setRect(int X1, int Y1, int X2, int Y2) { x1 = X1; y1 = Y1; x2 = X2; y2 = Y2; } -void RMRect::SetRect(const RMRect &rc) { - CopyRect(rc); +void RMRect::setRect(const RMRect &rc) { + copyRect(rc); } -void RMRect::CopyRect(const RMRect &rc) { +void RMRect::copyRect(const RMRect &rc) { x1 = rc.x1; y1 = rc.y1; x2 = rc.x2; y2 = rc.y2; } -RMPoint &RMRect::TopLeft() { +RMPoint &RMRect::topLeft() { // FIXME: This seems very bad return *((RMPoint *)this); } -RMPoint &RMRect::BottomRight() { +RMPoint &RMRect::bottomRight() { // FIXME: This seems very bad return *((RMPoint *)this + 1); } -RMPoint RMRect::Center() { +RMPoint RMRect::center() { return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } -int RMRect::Width() const { +int RMRect::width() const { return x2 - x1; } -int RMRect::Height() const { +int RMRect::height() const { return y2 - y1; } -int RMRect::Size() const { - return Width() * Height(); +int RMRect::size() const { + return width() * height(); } -bool RMRect::IsEmpty() const { +bool RMRect::isEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } const RMRect &RMRect::operator=(const RMRect &rc) { - CopyRect(rc); + copyRect(rc); return *this; } -void RMRect::Offset(int xOff, int yOff) { +void RMRect::offset(int xOff, int yOff) { x1 += xOff; y1 += yOff; x2 += xOff; y2 += yOff; } -void RMRect::Offset(const RMPoint &p) { +void RMRect::offset(const RMPoint &p) { x1 += p.x; y1 += p.y; x2 += p.x; @@ -946,12 +946,12 @@ void RMRect::Offset(const RMPoint &p) { } const RMRect &RMRect::operator+=(RMPoint p) { - Offset(p); + offset(p); return *this; } const RMRect &RMRect::operator-=(RMPoint p) { - Offset(-p); + offset(-p); return *this; } @@ -986,8 +986,8 @@ bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } -void RMRect::NormalizeRect(void) { - SetRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); +void RMRect::normalizeRect(void) { + setRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { @@ -1014,7 +1014,7 @@ RMResUpdate::~RMResUpdate() { _hFile.close(); } -void RMResUpdate::Init(const Common::String &fileName) { +void RMResUpdate::init(const Common::String &fileName) { // Open the resource update file if (!_hFile.open(fileName)) // It doesn't exist, so exit immediately @@ -1039,7 +1039,7 @@ void RMResUpdate::Init(const Common::String &fileName) { } } -HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { +HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 2eb6c5c2da..e649000e58 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -44,11 +44,11 @@ using namespace ::Tony::MPAL; */ class RMDataStream { protected: - const byte *m_buf; - int m_length; - int m_pos; - bool m_bError; - int m_ecode; + const byte *_buf; + int _length; + int _pos; + bool _bError; + int _ecode; public: enum RMDSPos { @@ -68,15 +68,15 @@ public: virtual ~RMDataStream(); // Loading buffer - void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); - void Close(void); + void openBuffer(const byte *buf, int size = SIZENOTKNOWN); + void close(void); // Attributei - int Length(); - virtual int Pos(); + int length(); + virtual int pos(); // EOF - virtual bool IsEOF(); + virtual bool isEOF(); // Read methods friend RMDataStream &operator>>(RMDataStream &df, char &var); @@ -87,16 +87,16 @@ public: friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); // General read - virtual bool Read(void *buf, int size); + virtual bool read(void *buf, int size); // Skipping & Seeking virtual RMDataStream &operator+=(int nBytes); - virtual int Seek(int nBytes, RMDSPos origin = CUR); + virtual int seek(int nBytes, RMDSPos origin = CUR); // Error handling - void SetError(int ecode); - int GetError(); - bool IsError(); + void setError(int ecode); + int getError(); + bool isError(); }; @@ -105,17 +105,17 @@ public: */ class RMFileStream : public RMDataStream { private: - byte *m_buf; + byte *_buf; public: RMFileStream(); virtual ~RMFileStream(); // Methods for opening file - bool OpenFile(const char *lpFN); - bool OpenFile(Common::File &file); + bool openFile(const char *lpFN); + bool openFile(Common::File &file); - void Close(void); + void close(void); }; @@ -126,18 +126,18 @@ public: RMFileStreamSlow(); virtual ~RMFileStreamSlow(); - bool OpenFile(const char *lpFN); - bool OpenFile(Common::File &file); + bool openFile(const char *lpFN); + bool openFile(Common::File &file); - void Close(void); + void close(void); RMDataStream &operator+=(int nBytes); - int Seek(int nBytes, RMDSPos where = CUR); + int seek(int nBytes, RMDSPos where = CUR); - int Pos(); - virtual bool IsEOF(); + int pos(); + virtual bool isEOF(); - bool Read(void *buf, int size); + bool read(void *buf, int size); friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); @@ -152,9 +152,9 @@ public: */ class RMString { private: - char *m_string; - int m_length; - int m_realLength; + char *_string; + int _length; + int _realLength; public: RMString(); @@ -166,12 +166,12 @@ public: RMString(const int ch); // General methods - int Length() const; - void Compact(); + int length() const; + void compact(); // Access characters within string - char GetAt(int nIndex); - void SetAt(int nIndex, char c); + char getAt(int nIndex); + void setAt(int nIndex, char c); char &operator[](int nIndex); // String cast @@ -200,11 +200,11 @@ public: friend RMDataStream &operator>>(RMDataStream &df, RMString &var); // String formatting - void Format(const char *str, ...); + void format(const char *str, ...); private: - void Resize(int size, bool bMantain = false); - void Connect(const char *str, int size); + void resize(int size, bool bMantain = false); + void connect(const char *str, int size); }; /** @@ -224,14 +224,14 @@ public: RMPoint &operator=(RMPoint p); // Set - void Set(int x1, int y1) { + void set(int x1, int y1) { x = x1; y = y1; } // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); + void offset(int xOff, int yOff); + void offset(const RMPoint &p); friend RMPoint operator+(RMPoint p1, RMPoint p2); friend RMPoint operator-(RMPoint p1, RMPoint p2); RMPoint &operator+=(RMPoint p); @@ -261,27 +261,27 @@ public: RMRect(const RMRect &rc); // Attributes - RMPoint &TopLeft(); - RMPoint &BottomRight(); - RMPoint Center(); - int Width() const; - int Height() const; - bool IsEmpty() const; - int Size() const; + RMPoint &topLeft(); + RMPoint &bottomRight(); + RMPoint center(); + int width() const; + int height() const; + bool isEmpty() const; + int size() const; // Set - void SetRect(int x1, int y1, int x2, int y2); - void SetRect(const RMPoint &p1, const RMPoint &p2); - void SetEmpty(void); + void setRect(int x1, int y1, int x2, int y2); + void setRect(const RMPoint &p1, const RMPoint &p2); + void setEmpty(void); // Copiers - void SetRect(const RMRect &rc); - void CopyRect(const RMRect &rc); + void setRect(const RMRect &rc); + void copyRect(const RMRect &rc); const RMRect &operator=(const RMRect &rc); // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); + void offset(int xOff, int yOff); + void offset(const RMPoint &p); friend RMRect operator+(const RMRect &rc, RMPoint p); friend RMRect operator-(const RMRect &rc, RMPoint p); friend RMRect operator+(RMPoint p, const RMRect &rc); @@ -294,10 +294,10 @@ public: bool operator!=(const RMRect &rc); // Normalise - void NormalizeRect(); + void normalizeRect(); // Point in rect - bool PtInRect(const RMPoint &pt) { + bool ptInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } @@ -324,8 +324,8 @@ public: RMResUpdate(); ~RMResUpdate(); - void Init(const Common::String &fileName); - HGLOBAL QueryResource(uint32 dwRes); + void init(const Common::String &fileName); + HGLOBAL queryResource(uint32 dwRes); }; } // End of namespace Tony diff --git a/engines/tony/window.h b/engines/tony/window.h index 3d1199482f..34f0c1cb51 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -57,8 +57,8 @@ private: void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: - void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; - void * /*LPDIRECTDRAWCLIPPER*/ m_BackClipper; +// void * /*LPDIRECTDRAWCLIPPER*/ _MainClipper; +// void * /*LPDIRECTDRAWCLIPPER*/ _BackClipper; int fps, fcount; int lastsecond, lastfcount; -- 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 a7a619e1b41b771726b6fb611ddb640e38a78185 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Jun 2012 21:19:57 +1000 Subject: TONY: Fix to correctly show the loading screen at the start of the game --- engines/tony/gfxengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b102323dce..e61e6a8b84 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -472,7 +472,12 @@ void RMGfxEngine::init() { _bigBuf.drawOT(Common::nullContext); _bigBuf.clearOT(); delete load; + + // Display 'Loading' screen + // TODO: The loading screen isn't currently optimal, since the game doesn't respond to events + // whilst the mpalInit code is being executed. _vm->_window.getNewFrame(*this, NULL); + _vm->_window.repaint(); GLOBALS.bPatIrqFreeze = true; -- 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 cd15e483ed64274049142a2e6838962d794c3ff5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 21:14:59 +0200 Subject: TONY: Some more renaming --- engines/tony/custom.cpp | 8 +- engines/tony/font.cpp | 40 ++-- engines/tony/game.cpp | 6 +- engines/tony/gfxcore.cpp | 190 ++++++++-------- engines/tony/gfxcore.h | 39 ++-- engines/tony/inventory.cpp | 8 +- engines/tony/loc.cpp | 8 +- engines/tony/mpal/expr.cpp | 78 +++---- engines/tony/mpal/expr.h | 6 +- engines/tony/mpal/loadmpc.cpp | 184 +++++++-------- engines/tony/mpal/memory.cpp | 12 +- engines/tony/mpal/memory.h | 20 +- engines/tony/mpal/mpal.cpp | 482 ++++++++++++++++++++-------------------- engines/tony/mpal/mpal.h | 4 +- engines/tony/mpal/mpaldll.h | 16 +- engines/tony/mpal/mpalutils.cpp | 8 +- engines/tony/sound.cpp | 10 +- engines/tony/tonychar.cpp | 22 +- engines/tony/utils.cpp | 6 +- 19 files changed, 574 insertions(+), 573 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index eaf125c973..a50807822c 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1949,7 +1949,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } - GlobalFree(_ctx->string); + globalFree(_ctx->string); CORO_END_CODE; } @@ -1985,7 +1985,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // If there is only one option, do it automatically, and wait for the next choice if (_ctx->num == 1) { mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); - GlobalFree(_ctx->sl); + globalFree(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); @@ -2001,7 +2001,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); _ctx->dc.addChoice(_ctx->string); - GlobalFree(_ctx->string); + globalFree(_ctx->string); } // Activate the object @@ -2028,7 +2028,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Closes the choice _ctx->dc.close(); - GlobalFree(_ctx->sl); + globalFree(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 623aab5ab4..398389ebcd 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1890,7 +1890,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { height = (numlines - 1) * font->letterHeight() + font->_fontDimy; // Create the surface - Create(width, height); + create(width, height); //AddPrim(new RMGfxPrimitive(&m_clear)); Common::fill(_buf, _buf + width * height * 2, 0); @@ -1932,8 +1932,8 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { } prim = font->makeLetterPrimitive(*p, len); - prim->Dst().x1 = x; - prim->Dst().y1 = y; + prim->getDst().x1 = x; + prim->getDst().y1 = y; addPrim(prim); numchar++; @@ -1951,14 +1951,14 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { void RMText::clipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->Dst().x1 < 5) - prim->Dst().x1 = 5; - if (prim->Dst().y1 < 5) - prim->Dst().y1 = 5; - if (prim->Dst().x1 + _dimx > 635) - prim->Dst().x1 = 635 - _dimx; - if (prim->Dst().y1 + _dimy > 475) - prim->Dst().y1 = 475 - _dimy; + if (prim->getDst().x1 < 5) + prim->getDst().x1 = 5; + if (prim->getDst().y1 < 5) + prim->getDst().y1 = 5; + if (prim->getDst().x1 + _dimx > 635) + prim->getDst().x1 = 635 - _dimx; + if (prim->getDst().y1 + _dimy > 475) + prim->getDst().y1 = 475 - _dimy; } void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -1968,19 +1968,19 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Horizontally if (aHorType == HCENTER) - prim->Dst().topLeft() -= RMPoint(_dimx / 2, 0); + prim->getDst().topLeft() -= RMPoint(_dimx / 2, 0); else if (aHorType == HRIGHT) - prim->Dst().topLeft() -= RMPoint(_dimx, 0); + prim->getDst().topLeft() -= RMPoint(_dimx, 0); // Vertically if (aVerType == VTOP) { } else if (aVerType == VCENTER) { - prim->Dst().y1 -= _dimy / 2; + prim->getDst().y1 -= _dimy / 2; } else if (aVerType == VBOTTOM) { - prim->Dst().y1 -= _dimy; + prim->getDst().y1 -= _dimy; } clipOnScreen(prim); @@ -2146,7 +2146,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (_bShowed) { if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { - prim->Dst().topLeft() = dst; + prim->getDst().topLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2285,7 +2285,7 @@ void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Set the destination coordinates of the mouse - prim->Dst().topLeft() = _mpos - RMPoint(0, 30); + prim->getDst().topLeft() = _mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::draw, bigBuf, prim); @@ -2349,7 +2349,7 @@ void RMDialogChoice::init(void) { _ptDrawStrings = NULL; _curSelection = -1; - Create(640, 477); + create(640, 477); setPriority(140); } @@ -2437,7 +2437,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { _ctx->box.setPriority(5); if (_curSelection != -1) { - _ctx->box.SetColor(0xCC, 0xCC, 0xFF); + _ctx->box.setColor(0xCC, 0xCC, 0xFF); _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); @@ -2448,7 +2448,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { } if (pos != -1) { - _ctx->box.SetColor(100, 100, 100); + _ctx->box.setColor(100, 100, 100); _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos].y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c8a70d7b0f..886b5f0859 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -328,7 +328,7 @@ RMOptionScreen::RMOptionScreen(void) { _QuitConfirm = NULL; _bQuitConfirm = false; - Create(RM_SX, RM_SY); + create(RM_SX, RM_SY); _ButtonExit = NULL; _ButtonLoad = NULL; @@ -556,7 +556,7 @@ void RMOptionScreen::refreshThumbnails(void) { delete _curThumb[i]; _curThumb[i] = new RMGfxSourceBuffer16; - _curThumb[i]->Create(640 / 4, 480 / 4); + _curThumb[i]->create(640 / 4, 480 / 4); if (!loadThumbnailFromSaveState(_statePos + i, *_curThumb[i], _curThumbName[i], _curThumbDiff[i])) { delete _curThumb[i]; _curThumb[i] = NULL; @@ -1548,7 +1548,7 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (_pos.x >= 0 && _pos.y >= 0 && _pos.x < RM_SX && _pos.y < RM_SY) { // Call the Draw method of the poitner - prim->Dst() -= _hotspot[_ctx->n]; + prim->getDst() -= _hotspot[_ctx->n]; if (_nCurSpecialPointer == 0) { CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 55a15a5961..09b102db11 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -134,19 +134,19 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { \****************************************************************************/ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - create(dimx, dimy, Bpp()); - CopyMemory(_buf, buf, dimx * dimy * Bpp() / 8); + create(dimx, dimy, getBpp()); + copyMemory(_buf, buf, dimx * dimy * getBpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); - return dimx * dimy * Bpp() / 8; + return dimx * dimy * getBpp() / 8; } void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - create(dimx, dimy, Bpp()); - ds.read(_buf, dimx * dimy * Bpp() / 8); + create(dimx, dimy, getBpp()); + ds.read(_buf, dimx * dimy * getBpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); @@ -254,7 +254,7 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { - otlist = NULL; + _otlist = NULL; _otSize = 0; // csModifyingOT = g_system->createMutex(); } @@ -269,7 +269,7 @@ void RMGfxTargetBuffer::clearOT(void) { // g_system->lockMutex(csModifyingOT); - cur = otlist; + cur = _otlist; while (cur != NULL) { cur->prim->_task->Unregister(); @@ -279,7 +279,7 @@ void RMGfxTargetBuffer::clearOT(void) { cur = n; } - otlist = NULL; + _otlist = NULL; // g_system->unlockMutex(csModifyingOT); } @@ -296,7 +296,7 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); _ctx->prev = NULL; - _ctx->cur = otlist; + _ctx->cur = _otlist; // Lock the buffer to access it lock(); @@ -321,7 +321,7 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { // If it was the first item, update the list head if (_ctx->prev == NULL) - otlist = _ctx->next; + _otlist = _ctx->next; // Otherwise update the next pinter of the previous item else _ctx->prev->next = _ctx->next; @@ -356,16 +356,16 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { n = new OTList(prim); // Empty list - if (otlist == NULL) { - otlist = n; - otlist->next = NULL; + if (_otlist == NULL) { + _otlist = n; + _otlist->next = NULL; } // Inclusion in the head - else if (nPrior < otlist->prim->_task->priority()) { - n->next = otlist; - otlist = n; + else if (nPrior < _otlist->prim->_task->priority()) { + n->next = _otlist; + _otlist = n; } else { - cur = otlist; + cur = _otlist; while (cur->next != NULL && nPrior > cur->next->prim->_task->priority()) cur = cur->next; @@ -393,28 +393,28 @@ int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { int i; if (bSwapped) - for (i = 0; i < (1 << Bpp()); i++) { + for (i = 0; i < (1 << getBpp()); i++) { _pal[i * 3 + 0] = buf[i * 3 + 2]; _pal[i * 3 + 1] = buf[i * 3 + 1]; _pal[i * 3 + 2] = buf[i * 3 + 0]; } else - CopyMemory(_pal, buf, (1 << Bpp()) * 3); + copyMemory(_pal, buf, (1 << getBpp()) * 3); preparePalette(); - return (1 << Bpp()) * 3; + return (1 << getBpp()) * 3; } int RMGfxSourceBufferPal::loadPalette(const byte *buf) { int i; for (i = 0; i < 256; i++) - CopyMemory(_pal + i * 3, buf + i * 4, 3); + copyMemory(_pal + i * 3, buf + i * 4, 3); preparePalette(); - return (1 << Bpp()) * 4; + return (1 << getBpp()) * 4; } @@ -480,11 +480,11 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) * * @returns Bit per pixel */ -int RMGfxSourceBuffer4::Bpp() { +int RMGfxSourceBuffer4::getBpp() { return 4; } -void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer4::create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::create(dimx, dimy, 4, bUseDDraw); } @@ -505,15 +505,15 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit // Destination buffer RMRect dst; if (prim->haveDst()) - dst = prim->Dst(); + dst = prim->getDst(); // Clipping if (prim->haveSrc()) { - u = prim->Src().x1; - v = prim->Src().y1; + u = prim->getSrc().x1; + v = prim->getSrc().y1; - width = prim->Src().width(); - height = prim->Src().height(); + width = prim->getSrc().width(); + height = prim->getSrc().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -568,7 +568,7 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { * * @returns Bit per pixel */ -int RMGfxSourceBuffer8::Bpp() { +int RMGfxSourceBuffer8::getBpp() { return 8; } @@ -578,7 +578,7 @@ void RMGfxSourceBuffer8::create(int dimx, int dimy, bool bUseDDraw) { #define GETRED(x) (((x) >> 10) & 0x1F) #define GETGREEN(x) (((x) >> 5) & 0x1F) -#define GETBLUE(x) ((x) & 0x1F) +#define GETBLUE(x) ((x) & 0x1F) /****************************************************************************\ @@ -613,15 +613,15 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim // Destination buffer RMRect dst; if (prim->haveDst()) - dst = prim->Dst(); + dst = prim->getDst(); // Clipping if (prim->haveSrc()) { - u = prim->Src().x1; - v = prim->Src().y1; + u = prim->getSrc().x1; + v = prim->getSrc().y1; - width = prim->Src().width(); - height = prim->Src().height(); + width = prim->getSrc().width(); + height = prim->getSrc().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -670,15 +670,15 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim * RMGfxSourceBuffer8RLE Methods \****************************************************************************/ -byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; +byte RMGfxSourceBuffer8RLE::_megaRLEBuf[512 * 1024]; void RMGfxSourceBuffer8RLE::setAlphaBlendColor(int color) { - alphaBlendColor = color; + _alphaBlendColor = color; } RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { - alphaBlendColor = -1; - bNeedRLECompress = true; + _alphaBlendColor = -1; + _bNeedRLECompress = true; _buf = NULL; } @@ -695,7 +695,7 @@ int RMGfxSourceBuffer8RLE::init(const byte *buf, int dimx, int dimy, bool bLoadP } void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - if (bNeedRLECompress) { + if (_bNeedRLECompress) { RMGfxSourceBufferPal::init(ds, dimx, dimy, bLoadPalette); } else { int size; @@ -714,10 +714,10 @@ void RMGfxSourceBuffer8RLE::preparePalette(void) { RMGfxSourceBuffer8::preparePalette(); // Handle RGB alpha blending - if (alphaBlendColor != -1) { - alphaR = (_palFinal[alphaBlendColor] >> 10) & 0x1F; - alphaG = (_palFinal[alphaBlendColor] >> 5) & 0x1F; - alphaB = (_palFinal[alphaBlendColor]) & 0x1F; + if (_alphaBlendColor != -1) { + _alphaR = (_palFinal[_alphaBlendColor] >> 10) & 0x1F; + _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x1F; + _alphaB = (_palFinal[_alphaBlendColor]) & 0x1F; } } @@ -730,7 +730,7 @@ void RMGfxSourceBuffer8RLE::prepareImage(void) { } void RMGfxSourceBuffer8RLE::setAlreadyCompressed(void) { - bNeedRLECompress = false; + _bNeedRLECompress = false; } @@ -744,7 +744,7 @@ void RMGfxSourceBuffer8RLE::compressRLE(void) { int rep; // Perform RLE compression for lines - cur = MegaRLEBuf; + cur = _megaRLEBuf; src = _buf; for (y = 0; y < _dimy; y++) { // Save the beginning of the line @@ -758,8 +758,8 @@ void RMGfxSourceBuffer8RLE::compressRLE(void) { rep = 0; startsrc = src; for (x = 0; x < _dimx;) { - if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) - || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { + if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == _alphaBlendColor) + || (curdata == 2 && (*src != _alphaBlendColor && *src != 0))) { src++; rep++; x++; @@ -801,9 +801,9 @@ void RMGfxSourceBuffer8RLE::compressRLE(void) { delete[] _buf; // Copy the compressed image - x = cur - MegaRLEBuf; + x = cur - _megaRLEBuf; _buf = new byte[x]; - Common::copy(MegaRLEBuf, MegaRLEBuf + x, _buf); + Common::copy(_megaRLEBuf, _megaRLEBuf + x, _buf); } void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -813,8 +813,8 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri int x1, y1, u, v, width, height; // Clipping - x1 = prim->Dst().x1; - y1 = prim->Dst().y1; + x1 = prim->getDst().x1; + y1 = prim->getDst().y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -834,7 +834,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Clipping u = _dimx - (width + u); - x1 = (prim->Dst().x1 + _dimx - 1) - u; + x1 = (prim->getDst().x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { // Decompressione @@ -884,7 +884,7 @@ void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { *cur ++ = rep; if (rep > 0) { - CopyMemory(cur, src, rep); + copyMemory(cur, src, rep); cur += rep; src += rep; } @@ -972,9 +972,9 @@ RLEByteDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst ++ = (r << 10) | (g << 5) | b; } @@ -1078,9 +1078,9 @@ RLEByteFlippedDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst-- = (r << 10) | (g << 5) | b; } @@ -1132,7 +1132,7 @@ void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { cur += 2; if (rep > 0) { - CopyMemory(cur, src, rep); + copyMemory(cur, src, rep); cur += rep; src += rep; } @@ -1227,9 +1227,9 @@ RLEWordDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst++ = (r << 10) | (g << 5) | b; } @@ -1345,9 +1345,9 @@ RLEWordFlippedDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst-- = (r << 10) | (g << 5) | b; } @@ -1476,9 +1476,9 @@ RLEWordDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst++ = (r << 10) | (g << 5) | b; } @@ -1529,8 +1529,8 @@ RLEWordDoCopy2: * Metodi di RMGfxSourceBuffer8AA \****************************************************************************/ -byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; -byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; +byte RMGfxSourceBuffer8AA::_megaAABuf[256 * 1024]; +byte RMGfxSourceBuffer8AA::_megaAABuf2[64 * 1024]; void RMGfxSourceBuffer8AA::prepareImage(void) { // Invoke the parent method @@ -1549,10 +1549,10 @@ void RMGfxSourceBuffer8AA::calculateAA(void) { byte *src, *srcaa; /* First pass: fill the edges */ - Common::fill(MegaAABuf, MegaAABuf + _dimx * _dimy, 0); + Common::fill(_megaAABuf, _megaAABuf + _dimx * _dimy, 0); src = _buf; - srcaa = MegaAABuf; + srcaa = _megaAABuf; for (y = 0; y < _dimy; y++) { for (x = 0; x < _dimx; x++) { if (*src == 0) { @@ -1569,7 +1569,7 @@ void RMGfxSourceBuffer8AA::calculateAA(void) { } src = _buf; - srcaa = MegaAABuf; + srcaa = _megaAABuf; for (y = 0; y < _dimy; y++) { for (x = 0; x < _dimx; x++) { if (*src != 0) { @@ -1589,7 +1589,7 @@ void RMGfxSourceBuffer8AA::calculateAA(void) { delete[] _aabuf; _aabuf = new byte[_dimx * _dimy]; - CopyMemory(_aabuf, MegaAABuf, _dimx * _dimy); + copyMemory(_aabuf, _megaAABuf, _dimx * _dimy); } RMGfxSourceBuffer8AA::RMGfxSourceBuffer8AA() : RMGfxSourceBuffer8() { @@ -1611,8 +1611,8 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri int step; // Clip the sprite - x1 = prim->Dst().x1; - y1 = prim->Dst().y1; + x1 = prim->getDst().x1; + y1 = prim->getDst().y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -1625,7 +1625,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (prim->isFlipped()) { u = _dimx - (width + u); - x1 = (prim->Dst().x1 + _dimx - 1) - u; + x1 = (prim->getDst().x1 + _dimx - 1) - u; } // width = _dimx; // x1 = prim->Dst().x1; @@ -1764,7 +1764,7 @@ int RMGfxSourceBuffer8RLEByteAA::init(const byte *buf, int dimx, int dimy, bool void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); - if (!bNeedRLECompress) { + if (!_bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; ds.read(_aabuf, dimx * dimy); @@ -1802,7 +1802,7 @@ int RMGfxSourceBuffer8RLEWordAA::init(byte *buf, int dimx, int dimy, bool bLoadP void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); - if (!bNeedRLECompress) { + if (!_bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; ds.read(_aabuf, dimx * dimy); @@ -1837,15 +1837,15 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi y1 = 0; if (prim->haveSrc()) { - u = prim->Src().x1; - v = prim->Src().y1; - dimx = prim->Src().width(); - dimy = prim->Src().height(); + u = prim->getSrc().x1; + v = prim->getSrc().y1; + dimx = prim->getSrc().width(); + dimy = prim->getSrc().height(); } if (prim->haveDst()) { - x1 = prim->Dst().x1; - y1 = prim->Dst().y1; + x1 = prim->getDst().x1; + y1 = prim->getDst().y1; } if (!clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) @@ -1878,7 +1878,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } } -void RMGfxSourceBuffer16::PrepareImage(void) { +void RMGfxSourceBuffer16::prepareImage(void) { // Colour space conversion if necessary! int i; uint16 *buf = (uint16 *)_buf; @@ -1899,11 +1899,11 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) * * @returns Bit per pixel */ -int RMGfxSourceBuffer16::Bpp() { +int RMGfxSourceBuffer16::getBpp() { return 16; } -void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer16::create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::create(dimx, dimy, 16, bUseDDraw); } @@ -1915,11 +1915,11 @@ void RMGfxBox::removeThis(CORO_PARAM, bool &result) { result = true; } -void RMGfxBox::SetColor(byte r, byte g, byte b) { +void RMGfxBox::setColor(byte r, byte g, byte b) { r >>= 3; g >>= 3; b >>= 3; - wFillColor = (r << 10) | (g << 5) | b; + _wFillColor = (r << 10) | (g << 5) | b; } void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -1928,13 +1928,13 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) RMRect rcDst; // It takes the destination rectangle - rcDst = prim->Dst(); + rcDst = prim->getDst(); buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; // Loop through the pixels for (j = 0; j < rcDst.height(); j++) { for (i = 0; i < rcDst.width(); i++) - *buf ++ = wFillColor; + *buf++ = _wFillColor; buf += bigBuf.getDimx() - rcDst.width(); } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 82f8383131..a1bf537e3b 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -189,14 +189,15 @@ public: bool haveDst() { return !_dst.isEmpty(); } - RMRect &Dst() { + + RMRect &getDst() { return _dst; } bool haveSrc() { return !_src.isEmpty(); } - RMRect &Src() { + RMRect &getSrc() { return _src; } @@ -268,12 +269,12 @@ public: */ class RMGfxBox : public RMGfxTaskSetPrior { protected: - uint16 wFillColor; + uint16 _wFillColor; public: virtual ~RMGfxBox() { } - void SetColor(byte r, byte g, byte b); + void setColor(byte r, byte g, byte b); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void removeThis(CORO_PARAM, bool &result); }; @@ -295,11 +296,11 @@ protected: virtual void prepareImage(void); bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); void offsetY(int nLines) { - RMGfxBuffer::offsetY(nLines, Bpp()); + RMGfxBuffer::offsetY(nLines, getBpp()); } public: - virtual int Bpp() = 0; + virtual int getBpp() = 0; }; @@ -308,7 +309,7 @@ public: */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: - virtual void PrepareImage(void); + virtual void prepareImage(void); bool _bTrasp0; public: @@ -317,9 +318,9 @@ public: virtual ~RMGfxSourceBuffer16(); // Initialisation - void Create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); + int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -364,7 +365,7 @@ public: // Initialisation void create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); + int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -388,12 +389,12 @@ public: class RMGfxSourceBuffer8RLE : public virtual RMGfxSourceBuffer8 { protected: - int alphaBlendColor; - int alphaR, alphaB, alphaG; - bool bNeedRLECompress; + int _alphaBlendColor; + int _alphaR, _alphaB, _alphaG; + bool _bNeedRLECompress; protected: - static byte MegaRLEBuf[]; + static byte _megaRLEBuf[]; virtual void RLEWriteTrasp(byte *&cur, int rep) = 0; virtual void RLEWriteData(byte *&cur, int rep, byte *src) = 0; @@ -468,8 +469,8 @@ public: */ class RMGfxSourceBuffer8AA : public virtual RMGfxSourceBuffer8 { protected: - static byte MegaAABuf[]; - static byte MegaAABuf2[]; + static byte _megaAABuf[]; + static byte _megaAABuf2[]; byte *_aabuf; // Calculate the buffer for the anti-aliasing @@ -528,9 +529,9 @@ public: RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); // Initialisation - void Create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); + int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -556,7 +557,7 @@ private: // OSystem::MutexRef csModifyingOT; protected: - OTList *otlist; + OTList *_otlist; int _otSize; public: diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index c83402e724..bbc74afa01 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -77,7 +77,7 @@ void RMInventory::init(void) { int curres; // Create the main buffer - Create(RM_SX, 68); + create(RM_SX, 68); setPriority(185); // Setup the inventory @@ -788,13 +788,13 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - prim->Dst().topLeft() = _openStart; + prim->getDst().topLeft() = _openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone _ctx->h = onWhichBox(_mpos); if (_ctx->h != -1) { - prim->Dst().topLeft() = _openStart; + prim->getDst().topLeft() = _openStart; CORO_INVOKE_2(_hotzone[_ctx->h].draw, bigBuf, prim); if (_lastHotZone != _ctx->h) { @@ -803,7 +803,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr } if (GLOBALS.bCfgInterTips) { - prim->Dst().topLeft() = _openStart + RMPoint(70, 177); + prim->getDst().topLeft() = _openStart + RMPoint(70, 177); CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } } else diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 48480389bb..2700a05831 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -695,11 +695,11 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->setFlag(_bCurFlag); // Offset direction for scrolling - prim->Dst().offset(-_curScroll); + prim->getDst().offset(-_curScroll); // We must offset the cordinates of the item inside the primitive // It is estimated as nonno + (babbo + figlio) - prim->Dst().offset(calculatePos()); + prim->getDst().offset(calculatePos()); // No stretching, please prim->setStrecth(false); @@ -1333,7 +1333,7 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); if (bDrawNow) { - prim->Dst() += _fixedScroll; + prim->getDst() += _fixedScroll; CORO_INVOKE_2(RMItem::draw, bigBuf, prim); } @@ -2305,7 +2305,7 @@ RMMessage::RMMessage() { RMMessage::~RMMessage() { if (lpMessage) - GlobalFree(lpMessage); + globalFree(lpMessage); } void RMMessage::load(uint32 dwId) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index ae6dfac482..0b51724330 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -103,32 +103,32 @@ typedef EXPRESSION *LPEXPRESSION; * @param h Handle to the original expression * @retruns Pointer to the cloned expression */ -static byte *DuplicateExpression(HGLOBAL h) { +static byte *duplicateExpression(HGLOBAL h) { int i, num; byte *orig, *clone; LPEXPRESSION one, two; - orig = (byte *)GlobalLock(h); + orig = (byte *)globalLock(h); num = *(byte *)orig; one = (LPEXPRESSION)(orig+1); - clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); + clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); two = (LPEXPRESSION)(clone + 1); - CopyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); + copyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); for (i = 0; i < num; i++) { if (one->type == ELT_PARENTH) { two->type = ELT_PARENTH2; - two->val.pson = DuplicateExpression(two->val.son); + two->val.pson = duplicateExpression(two->val.son); } one++; two++; } - GlobalUnlock(h); + globalUnlock(h); return clone; } @@ -178,7 +178,7 @@ static int Compute(int a, int b, byte symbol) { return 0; } -static void Solve(LPEXPRESSION one, int num) { +static void solve(LPEXPRESSION one, int num) { LPEXPRESSION two, three; int j; @@ -186,7 +186,7 @@ static void Solve(LPEXPRESSION one, int num) { two=one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { two->val.num = Compute(one->val.num, two->val.num,one->symbol); - CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); + copyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { j = 1; @@ -198,7 +198,7 @@ static void Solve(LPEXPRESSION one, int num) { } three->val.num = Compute(two->val.num, three->val.num, two->symbol); - CopyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); + copyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); num--; } } @@ -212,7 +212,7 @@ static void Solve(LPEXPRESSION one, int num) { * @param expr Pointer to an expression duplicated by DuplicateExpression * @returns Value */ -static int EvaluateAndFreeExpression(byte *expr) { +static int evaluateAndFreeExpression(byte *expr) { int i,num,val; LPEXPRESSION one,cur; @@ -231,14 +231,14 @@ static int EvaluateAndFreeExpression(byte *expr) { for (i = 0, cur = one; i < num; i++, cur++) { if (cur->type == ELT_PARENTH2) { cur->type = ELT_NUMBER; - cur->val.num = EvaluateAndFreeExpression(cur->val.pson); + cur->val.num = evaluateAndFreeExpression(cur->val.pson); } } // 3) Risoluzione algebrica - Solve(one, num); + solve(one, num); val = one->val.num; - GlobalFree(expr); + globalFree(expr); return val; } @@ -252,7 +252,7 @@ static int EvaluateAndFreeExpression(byte *expr) { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { +const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; uint32 num, i; @@ -263,11 +263,11 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h == NULL) return NULL; - start = (byte *)GlobalLock(*h); + start = (byte *)globalLock(*h); *start = (byte)num; cur = (LPEXPRESSION)(start + 1); @@ -283,15 +283,15 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { break; case ELT_VAR: - cur->val.name = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); + cur->val.name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); if (cur->val.name == NULL) return NULL; - CopyMemory(cur->val.name, lpBuf + 1, *lpBuf); + copyMemory(cur->val.name, lpBuf + 1, *lpBuf); lpBuf += *lpBuf + 1; break; case ELT_PARENTH: - lpBuf=ParseExpression(lpBuf, &cur->val.son); + lpBuf = parseExpression(lpBuf, &cur->val.son); if (lpBuf == NULL) return NULL; break; @@ -321,12 +321,12 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { * @param h Handle to the expression * @returns Numeric value */ -int EvaluateExpression(HGLOBAL h) { +int evaluateExpression(HGLOBAL h) { int ret; - LockVar(); - ret=EvaluateAndFreeExpression(DuplicateExpression(h)); - UnlockVar(); + lockVar(); + ret = evaluateAndFreeExpression(duplicateExpression(h)); + unlockVar(); return ret; } @@ -337,20 +337,20 @@ int EvaluateExpression(HGLOBAL h) { * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { +bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { int i, num1, num2; byte *e1, *e2; LPEXPRESSION one, two; - e1 = (byte *)GlobalLock(h1); - e2 = (byte *)GlobalLock(h2); + e1 = (byte *)globalLock(h1); + e2 = (byte *)globalLock(h2); num1 = *(byte *)e1; num2 = *(byte *)e2; if (num1 != num2) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } @@ -359,32 +359,32 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { for (i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } switch (one->type) { case ELT_NUMBER: if (one->val.num != two->val.num) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } break; case ELT_VAR: if (strcmp(one->val.name, two->val.name) != 0) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } break; case ELT_PARENTH: - if (!CompareExpressions(one->val.son, two->val.son)) { - GlobalUnlock(h1); - GlobalUnlock(h2); + if (!compareExpressions(one->val.son, two->val.son)) { + globalUnlock(h1); + globalUnlock(h2); return false; } break; @@ -394,8 +394,8 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { two++; } - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return true; } diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 17e9c1264b..7d33e5c8ca 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -45,7 +45,7 @@ namespace MPAL { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); +const byte *parseExpression(const byte *lpBuf, HGLOBAL *h); /** * Calculate the value of a mathamatical expression @@ -53,7 +53,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); * @param h Handle to the expression * @returns Numeric value */ -int EvaluateExpression(HGLOBAL h); +int evaluateExpression(HGLOBAL h); /** * Compare two mathematical expressions together @@ -61,7 +61,7 @@ int EvaluateExpression(HGLOBAL h); * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); +bool compareExpressions(HGLOBAL h1, HGLOBAL h2); } // end of namespace MPAL diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 02571bd30f..8f07102aa3 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -42,10 +42,10 @@ namespace MPAL { * Funzioni statiche \****************************************************************************/ -static bool CompareCommands(struct command *cmd1, struct command *cmd2) { +static bool compareCommands(struct command *cmd1, struct command *cmd2) { if (cmd1->type == 2 && cmd2->type == 2) { if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - CompareExpressions(cmd1->expr, cmd2->expr)) + compareExpressions(cmd1->expr, cmd2->expr)) return true; else return false; @@ -80,32 +80,32 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpBuf++; for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->Command[curCmd].type = *lpBuf; + lpmsScript->_command[curCmd].type = *lpBuf; lpBuf++; - switch (lpmsScript->Command[curCmd].type) { + switch (lpmsScript->_command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmsScript->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmsScript->Command[curCmd].lpszVarName == NULL) + lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmsScript->_command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); + copyMemory(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); if (lpBuf == NULL) return NULL; break; @@ -129,7 +129,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { * data of the dialog. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 i, j, z, kk; uint32 num, num2, num3; byte *lpLock; @@ -147,17 +147,17 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); + lpmdDialog->_periodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); - lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); + lpmdDialog->_periods[i] = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); + lpLock = (byte *)globalLock(lpmdDialog->_periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); - GlobalUnlock(lpmdDialog->Periods[i]); + globalUnlock(lpmdDialog->_periods[i]); lpBuf += (*lpBuf) + 1; } - lpmdDialog->PeriodNums[i] = 0; - lpmdDialog->Periods[i] = NULL; + lpmdDialog->_periodNums[i] = 0; + lpmdDialog->_periods[i] = NULL; /* Gruppi */ num = READ_LE_UINT16(lpBuf); @@ -168,29 +168,29 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); + lpmdDialog->_group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; + lpmdDialog->_group[i].nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) - error("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); + if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); - for (j = 0; j < lpmdDialog->Group[i].nCmds; j++) { - lpmdDialog->Command[curCmd].type = *lpBuf; + for (j = 0; j < lpmdDialog->_group[i].nCmds; j++) { + lpmdDialog->_command[curCmd].type = *lpBuf; lpBuf++; - switch (lpmdDialog->Command[curCmd].type) { + switch (lpmdDialog->_command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -198,21 +198,21 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { case 2: len = *lpBuf; lpBuf++; - lpmdDialog->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmdDialog->Command[curCmd].lpszVarName == NULL) + lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->_command[curCmd].lpszVarName == NULL) return NULL; - Common::copy(lpBuf, lpBuf + len, lpmdDialog->Command[curCmd].lpszVarName); + Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd].lpszVarName); lpBuf += len; - lpBuf = ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd].expr); if (lpBuf == NULL) return NULL; break; // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; @@ -221,14 +221,14 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } for (kk = 0;kk < curCmd; kk++) { - if (CompareCommands(&lpmdDialog->Command[kk], &lpmdDialog->Command[curCmd])) { - lpmdDialog->Group[i].CmdNum[j] = kk; + if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { + lpmdDialog->_group[i].CmdNum[j] = kk; break; } } if (kk == curCmd) { - lpmdDialog->Group[i].CmdNum[j] = curCmd; + lpmdDialog->_group[i].CmdNum[j] = curCmd; curCmd++; } } @@ -245,23 +245,23 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) - error("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); for (j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: - lpmdDialog->Choice[i].Select[j].when = NULL; + lpmdDialog->_choice[i]._select[j].when = NULL; break; case 1: - lpBuf = ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j].when); if (lpBuf == NULL) return NULL; break; @@ -271,31 +271,31 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; + lpmdDialog->_choice[i]._select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); + lpmdDialog->_choice[i]._select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup num3 = *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) - error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { - lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; + lpmdDialog->_choice[i]._select[j].wPlayGroup[num3] = 0; } // Mark the last selection - lpmdDialog->Choice[i].Select[num2].dwData = 0; + lpmdDialog->_choice[i]._select[num2].dwData = 0; } - lpmdDialog->Choice[num].nChoice = 0; + lpmdDialog->_choice[num].nChoice = 0; return lpBuf; } @@ -311,7 +311,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * @remarks It's necessary that the structure that is passed has been * completely initialised to 0 beforehand. */ -static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { +static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; uint32 i, j, kk; uint32 curCmd; @@ -321,7 +321,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { len = *lpBuf; lpBuf++; - CopyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + copyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) @@ -332,7 +332,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { /* Alloca le azioni */ if (lpmiItem->nActions > 0) - lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); + lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); curCmd = 0; @@ -357,7 +357,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].when = NULL; } else { lpBuf++; - lpBuf = ParseExpression(lpBuf,&lpmiItem->Action[i].when); + lpBuf = parseExpression(lpBuf,&lpmiItem->Action[i].when); if (lpBuf == NULL) return NULL; } @@ -369,32 +369,32 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); for (j = 0; j < lpmiItem->Action[i].nCmds; j++) { - lpmiItem->Command[curCmd].type = *lpBuf; + lpmiItem->_command[curCmd].type = *lpBuf; lpBuf++; - switch (lpmiItem->Command[curCmd].type) { + switch (lpmiItem->_command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmiItem->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmiItem->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmiItem->Command[curCmd].lpszVarName == NULL) + lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->_command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmiItem->Command[curCmd].lpszVarName, lpBuf, len); + copyMemory(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; - lpBuf=ParseExpression(lpBuf, &lpmiItem->Command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); if (lpBuf == NULL) return NULL; break; @@ -404,7 +404,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } for (kk = 0; kk < curCmd; kk++) { - if (CompareCommands(&lpmiItem->Command[kk],&lpmiItem->Command[curCmd])) { + if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; break; } @@ -478,16 +478,16 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); + GLOBALS.hVars = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); if (GLOBALS.hVars == NULL) return false; - GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); + GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); for (i = 0; i < GLOBALS.nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - CopyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + copyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; GLOBALS.lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; @@ -496,7 +496,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.lpmvVars++; } - GlobalUnlock(GLOBALS.hVars); + globalUnlock(GLOBALS.hVars); /* 2. Messages */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') @@ -507,11 +507,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS.hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); + GLOBALS.hMsgs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); if (GLOBALS.hMsgs == NULL) return false; - GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); #else GLOBALS.lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)GLOBALS.nMsgs); if (GLOBALS.lpmmMsgs==NULL) @@ -525,11 +525,11 @@ bool ParseMpc(const byte *lpBuf) { for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - GLOBALS.lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)GlobalLock(GLOBALS.lpmmMsgs->hText); + GLOBALS.lpmmMsgs->hText = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS.lpmmMsgs->hText); for (j = 0; lpBuf[j] != 0;) { - CopyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); + copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); lpTemp += lpBuf[j]; *lpTemp ++= '\0'; j += lpBuf[j] + 1; @@ -538,12 +538,12 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += j + 1; *lpTemp = '\0'; - GlobalUnlock(GLOBALS.lpmmMsgs->hText); + globalUnlock(GLOBALS.lpmmMsgs->hText); GLOBALS.lpmmMsgs++; } #ifdef NEED_LOCK_MSGS - GlobalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS.hMsgs); #endif /* 3. Objects */ @@ -560,17 +560,17 @@ bool ParseMpc(const byte *lpBuf) { if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); + GLOBALS.hDialogs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); if (GLOBALS.hDialogs == NULL) return false; - GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); + GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); for (i = 0;i < GLOBALS.nDialogs; i++) - if ((lpBuf = ParseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) + if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) return false; - GlobalUnlock(GLOBALS.hDialogs); + globalUnlock(GLOBALS.hDialogs); } // Check the items @@ -581,17 +581,17 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); + GLOBALS.hItems = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; - GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); + GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); for (i = 0; i < GLOBALS.nItems; i++) - if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) + if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) return false; - GlobalUnlock(GLOBALS.hItems); + globalUnlock(GLOBALS.hItems); } // Check the locations @@ -602,17 +602,17 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); + GLOBALS.hLocations = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); if (GLOBALS.hLocations == NULL) return false; - GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); + GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); for (i = 0; i < GLOBALS.nLocations; i++) if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS.lpmlLocations[i])) == NULL) return false; - GlobalUnlock(GLOBALS.hLocations); + globalUnlock(GLOBALS.hLocations); } // Check the scripts @@ -623,11 +623,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); + GLOBALS.hScripts = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); if (GLOBALS.hScripts == NULL) return false; - GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); for (i = 0; i < GLOBALS.nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) @@ -642,7 +642,7 @@ bool ParseMpc(const byte *lpBuf) { //); } - GlobalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS.hScripts); } if (lpBuf[0] != 'E' || lpBuf[1] != 'N' || lpBuf[2] != 'D' || lpBuf[3] != '0') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 04cb906431..b5bd77f838 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -53,7 +53,7 @@ MemoryItem::~MemoryItem() { * Returns a pointer to the resource */ MemoryItem::operator void *() { - return DataPointer(); + return dataPointer(); } /****************************************************************************\ @@ -81,7 +81,7 @@ MemoryManager::~MemoryManager() { MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { MemoryItem *newItem = new MemoryItem(size); if ((flags & GMEM_ZEROINIT) != 0) { - byte *dataP = (byte *)newItem->DataPointer(); + byte *dataP = (byte *)newItem->dataPointer(); Common::fill(dataP, dataP + size, 0); } @@ -96,7 +96,7 @@ MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { */ HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { MemoryItem &newItem = allocate(size, flags); - return (HGLOBAL)newItem.DataPointer(); + return (HGLOBAL)newItem.dataPointer(); } /** @@ -107,7 +107,7 @@ MemoryItem &MemoryManager::getItem(HGLOBAL handle) { Common::List::iterator i; for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { MemoryItem *item = *i; - if (item->DataPointer() == handle) + if (item->dataPointer() == handle) return *item; } @@ -127,7 +127,7 @@ MemoryItem &MemoryManager::operator[](HGLOBAL handle) { */ uint32 MemoryManager::getSize(HGLOBAL handle) { MemoryItem &item = getItem(handle); - return item.Size(); + return item.size(); } /** @@ -150,7 +150,7 @@ void MemoryManager::erase(HGLOBAL handle) { * Stand-alone methods \****************************************************************************/ -void CopyMemory(void *dst, const void *first, int size) { +void copyMemory(void *dst, const void *first, int size) { Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); } diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 8d8411c6a1..7f95f8d86f 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -42,9 +42,9 @@ public: MemoryItem(uint32 size); virtual ~MemoryItem(); - uint32 Size() { return _size; } - void *DataPointer() { return (void *)_buffer; } - bool IsValid() { return _buffer != NULL; } + uint32 size() { return _size; } + void *dataPointer() { return (void *)_buffer; } + bool isValid() { return _buffer != NULL; } // Casting for access to data operator void *(); @@ -68,19 +68,19 @@ public: }; // defines -#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) -#define GlobalAllocate(size) _vm->_memoryManager.allocate(size, 0) -#define GlobalFree(handle) _vm->_memoryManager.erase(handle) -#define GlobalLock(handle) (_vm->_memoryManager.getItem(handle).DataPointer()) -#define GlobalUnlock(handle) {} -#define GlobalSize(handle) (_vm->_memoryManager.getItem(handle).Size()) +#define globalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) +#define globalAllocate(size) _vm->_memoryManager.allocate(size, 0) +#define globalFree(handle) _vm->_memoryManager.erase(handle) +#define globalLock(handle) (_vm->_memoryManager.getItem(handle).dataPointer()) +#define globalUnlock(handle) {} +#define globalSize(handle) (_vm->_memoryManager.getItem(handle).size()) #define GMEM_FIXED 1 #define GMEM_MOVEABLE 2 #define GMEM_ZEROINIT 4 // Stand-alone methods -extern void CopyMemory(void *dst, const void *first, int size); +extern void copyMemory(void *dst, const void *first, int size); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 16c530206c..95c0b067d5 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -59,16 +59,16 @@ const char *mpalCopyright = /** * Locks the variables for access */ -void LockVar(void) { - GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); +void lockVar(void) { + GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); } /** * Unlocks variables after use */ -void UnlockVar(void) { - GlobalUnlock(GLOBALS.hVars); +void unlockVar(void) { + globalUnlock(GLOBALS.hVars); } @@ -77,7 +77,7 @@ void UnlockVar(void) { */ static void LockMsg(void) { #ifdef NEED_LOCK_MSGS - GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); #endif } @@ -87,7 +87,7 @@ static void LockMsg(void) { */ static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS - GlobalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS.hMsgs); #endif } @@ -95,48 +95,48 @@ static void UnlockMsg(void) { /** * Locks the dialogs for access */ -static void LockDialogs(void) { - GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); +static void lockDialogs(void) { + GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); } /** * Unlocks the dialogs after use */ -static void UnlockDialogs(void) { - GlobalUnlock(GLOBALS.hDialogs); +static void unlockDialogs(void) { + globalUnlock(GLOBALS.hDialogs); } /** * Locks the location data structures for access */ -static void LockLocations(void) { - GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); +static void lockLocations(void) { + GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); } /** * Unlocks the location structures after use */ -static void UnlockLocations(void) { - GlobalUnlock(GLOBALS.hLocations); +static void unlockLocations(void) { + globalUnlock(GLOBALS.hLocations); } /** * Locks the items structures for use */ -static void LockItems(void) { - GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); +static void lockItems(void) { + GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); } /** * Unlocks the items structures after use */ -static void UnlockItems(void) { - GlobalUnlock(GLOBALS.hItems); +static void unlockItems(void) { + globalUnlock(GLOBALS.hItems); } @@ -144,15 +144,15 @@ static void UnlockItems(void) { * Locks the script data structures for use */ static void LockScripts(void) { - GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); } /** * Unlocks the script data structures after use */ -static void UnlockScripts(void) { - GlobalUnlock(GLOBALS.hScripts); +static void unlockScripts(void) { + globalUnlock(GLOBALS.hScripts); } @@ -161,7 +161,7 @@ static void UnlockScripts(void) { * * @param lpszVarName Name of the variable * @returns Current value - * @remarks Before using this method, you must call LockVar() to + * @remarks Before using this method, you must call lockVar() to * lock the global variablves for use. Then afterwards, you will * need to remember to call UnlockVar() */ @@ -316,19 +316,19 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (nMsgOrd == (uint32)-1) return NULL; - origmsg = (const char *)GlobalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + origmsg = (const char *)globalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') j++; j += 2; - clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); + clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); if (clonemsg == NULL) return NULL; - CopyMemory(clonemsg, origmsg, j); - GlobalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + copyMemory(clonemsg, origmsg, j); + globalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); return clonemsg; } @@ -341,28 +341,28 @@ static char *DuplicateMessage(uint32 nMsgOrd) { * @returns Pointer to the duplicated phrase. Remember to free it * when done with it. */ -static char *DuplicateDialogPeriod(uint32 nPeriod) { +static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; int i, j; - for (j = 0; dialog->Periods[j] != NULL; j++) - if (dialog->PeriodNums[j] == nPeriod) { + for (j = 0; dialog->_periods[j] != NULL; j++) + if (dialog->_periodNums[j] == nPeriod) { /* Found the phrase, it should be duplicated */ - origmsg = (const char *)GlobalLock(dialog->Periods[j]); + origmsg = (const char *)globalLock(dialog->_periods[j]); /* Calculate the length and allocate memory */ i = 0; while (origmsg[i] != '\0') i++; - clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); + clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); if (clonemsg == NULL) return NULL; - CopyMemory(clonemsg, origmsg, i); + copyMemory(clonemsg, origmsg, i); - GlobalUnlock(dialog->Periods[j]); + globalUnlock(dialog->_periods[j]); return clonemsg; } @@ -402,9 +402,9 @@ HGLOBAL resLoad(uint32 dwId) { if (GLOBALS.hMpr.err()) return NULL; - h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); - buf = (byte *)GlobalLock(h); - temp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); + h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); + buf = (byte *)globalLock(h); + temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); nBytesRead = GLOBALS.hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -414,38 +414,38 @@ HGLOBAL resLoad(uint32 dwId) { if (nBytesRead != nSizeDecomp) return NULL; - GlobalFree(temp); - GlobalUnlock(h); + globalFree(temp); + globalUnlock(h); return h; } return NULL; } -static uint32 *GetSelectList(uint32 i) { +static uint32 *getSelectList(uint32 i) { uint32 *sl; - int j,k,num; - LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + int j, k, num; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; /* Count how many are active selects */ num = 0; - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].curActive) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + if (dialog->_choice[i]._select[j].curActive) num++; /* If there are 0, it's a mistake */ if (num == 0) return NULL; - sl= (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + sl= (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (sl == NULL) return NULL; /* Copy all the data inside the active select list */ k = 0; - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].curActive) - sl[k++] = dialog->Choice[i].Select[j].dwData; + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + if (dialog->_choice[i]._select[j].curActive) + sl[k++] = dialog->_choice[i]._select[j].dwData; sl[k] = (uint32)NULL; return sl; @@ -462,7 +462,7 @@ static uint32 *GetItemList(uint32 nLoc) { num++; } - il = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + il = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (il == NULL) return NULL; @@ -479,7 +479,7 @@ static uint32 *GetItemList(uint32 nLoc) { return il; } -static LPITEM GetItemData(uint32 nOrdItem) { +static LPITEM getItemData(uint32 nOrdItem) { LPMPALITEM curitem = GLOBALS.lpmiItems+nOrdItem; LPITEM ret; HGLOBAL hDat; @@ -489,13 +489,13 @@ static LPITEM GetItemData(uint32 nOrdItem) { uint32 dim; // Zeroing out the allocated memory is required!!! - ret = (LPITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); + ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); if (ret == NULL) return NULL; ret->speed = 150; hDat = resLoad(curitem->dwRes); - dat = (char *)GlobalLock(hDat); + dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { i = dat[3]; // For version 1.0!! @@ -556,11 +556,11 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 1; i < ret->numframe; i++) { dim = (uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); - ret->frames[i] = (char *)GlobalAlloc(GMEM_FIXED,dim); + ret->frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); if (ret->frames[i] == NULL) return NULL; - CopyMemory(ret->frames[i], dat, dim); + copyMemory(ret->frames[i], dat, dim); dat += dim; } @@ -569,8 +569,8 @@ static LPITEM GetItemData(uint32 nOrdItem) { if (i != 0xABCD) return NULL; - GlobalUnlock(hDat); - GlobalFree(hDat); + globalUnlock(hDat); + globalFree(hDat); return ret; } @@ -594,7 +594,7 @@ void CustomThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); - GlobalFree(_ctx->p); + globalFree(_ctx->p); CORO_END_CODE; } @@ -642,8 +642,8 @@ void ScriptThread(CORO_PARAM, const void *param) { for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; - if (s->Command[_ctx->k].type == 1) { - _ctx->p = (LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + if (s->_command[_ctx->k].type == 1) { + _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS.mpalError = 1; @@ -651,11 +651,11 @@ void ScriptThread(CORO_PARAM, const void *param) { return; } - _ctx->p->nCf=s->Command[_ctx->k].nCf; - _ctx->p->arg1=s->Command[_ctx->k].arg1; - _ctx->p->arg2=s->Command[_ctx->k].arg2; - _ctx->p->arg3=s->Command[_ctx->k].arg3; - _ctx->p->arg4=s->Command[_ctx->k].arg4; + _ctx->p->nCf=s->_command[_ctx->k].nCf; + _ctx->p->arg1=s->_command[_ctx->k].arg1; + _ctx->p->arg2=s->_command[_ctx->k].arg2; + _ctx->p->arg3=s->_command[_ctx->k].arg3; + _ctx->p->arg4=s->_command[_ctx->k].arg4; // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { @@ -664,17 +664,17 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_KILL_SELF(); return; } - } else if (s->Command[_ctx->k].type == 2) { - LockVar(); + } else if (s->_command[_ctx->k].type == 2) { + lockVar(); varSetValue( - s->Command[_ctx->k].lpszVarName, - EvaluateExpression(s->Command[_ctx->k].expr) + s->_command[_ctx->k].lpszVarName, + evaluateExpression(s->_command[_ctx->k].expr) ); - UnlockVar(); + unlockVar(); } else { GLOBALS.mpalError = 1; - GlobalFree(s); + globalFree(s); CORO_KILL_SELF(); return; @@ -682,7 +682,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } } - GlobalFree(s); + globalFree(s); CORO_KILL_SELF(); @@ -711,29 +711,29 @@ void ActionThread(CORO_PARAM, const void *param) { for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; - if (item->Command[_ctx->k].type == 1) { + if (item->_command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), - item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, - item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 + CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->_command[_ctx->k].nCf].c_str(), + item->_command[_ctx->k].arg1, item->_command[_ctx->k].arg2, + item->_command[_ctx->k].arg3, item->_command[_ctx->k].arg4 ); - CORO_INVOKE_4(GLOBALS.lplpFunctions[item->Command[_ctx->k].nCf], - item->Command[_ctx->k].arg1, - item->Command[_ctx->k].arg2, - item->Command[_ctx->k].arg3, - item->Command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS.lplpFunctions[item->_command[_ctx->k].nCf], + item->_command[_ctx->k].arg1, + item->_command[_ctx->k].arg2, + item->_command[_ctx->k].arg3, + item->_command[_ctx->k].arg4 ); - } else if (item->Command[_ctx->k].type == 2) { + } else if (item->_command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), item->_command[_ctx->k].lpszVarName); - LockVar(); - varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); - UnlockVar(); + lockVar(); + varSetValue(item->_command[_ctx->k].lpszVarName, evaluateExpression(item->_command[_ctx->k].expr)); + unlockVar(); } else { GLOBALS.mpalError = 1; @@ -741,7 +741,7 @@ void ActionThread(CORO_PARAM, const void *param) { } } - GlobalFree(item); + globalFree(item); debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); @@ -832,7 +832,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { ; /* We look for items without idle actions, and eliminate them from the list */ - LockItems(); + lockItems(); _ctx->nIdleActions = 0; _ctx->nRealItems = 0; for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { @@ -855,18 +855,18 @@ void LocationPollThread(CORO_PARAM, const void *param) { else _ctx->nRealItems++; } - UnlockItems(); + unlockItems(); /* If there is nothing left, we can exit */ if (_ctx->nRealItems == 0) { - GlobalFree(_ctx->il); + globalFree(_ctx->il); CORO_KILL_SELF(); return; } - _ctx->MyThreads = (MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); if (_ctx->MyThreads == NULL) { - GlobalFree(_ctx->il); + globalFree(_ctx->il); CORO_KILL_SELF(); return; } @@ -874,15 +874,15 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* We have established that there is at least one item that contains idle actions. Now we created the mirrored copies of the idle actions. */ - _ctx->MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->il); + globalFree(_ctx->MyThreads); + globalFree(_ctx->il); CORO_KILL_SELF(); return; } - LockItems(); + lockItems(); _ctx->k = 0; for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { @@ -900,7 +900,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + copyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); @@ -908,10 +908,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { } } - UnlockItems(); + unlockItems(); /* We don't need the item list anymore */ - GlobalFree(_ctx->il); + globalFree(_ctx->il); /* Here's the main loop */ @@ -967,33 +967,33 @@ void LocationPollThread(CORO_PARAM, const void *param) { continue; /* Ok, we are the only ones :) */ - LockItems(); + lockItems(); _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; if (_ctx->curItem->Action[_ctx->j].when != NULL) - if (!EvaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { - UnlockItems(); + if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { + unlockItems(); continue; } /* Ok, we can perform the action. For convenience, we do it in a new process */ - _ctx->newItem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->MyActions); + globalFree(_ctx->MyThreads); + globalFree(_ctx->MyActions); CORO_KILL_SELF(); return; } - CopyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); - UnlockItems(); + copyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + unlockItems(); /* We copy the action in #0 */ // _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; -// CopyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); +// copyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; /* We will create an action, and will provide the necessary details */ @@ -1006,9 +1006,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) - GlobalFree(_ctx->newItem); - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->MyActions); + globalFree(_ctx->newItem); + globalFree(_ctx->MyThreads); + globalFree(_ctx->MyActions); CORO_KILL_SELF(); return; @@ -1039,8 +1039,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); /* We're finished */ - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->MyActions); + globalFree(_ctx->MyThreads); + globalFree(_ctx->MyActions); CORO_KILL_SELF(); @@ -1078,7 +1078,7 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_END_CODE; } -void DoChoice(CORO_PARAM, uint32 nChoice); +void doChoice(CORO_PARAM, uint32 nChoice); /** @@ -1097,41 +1097,41 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Lock the _ctx->dialog - LockDialogs(); + lockDialogs(); // Find the pointer to the current _ctx->dialog _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; // Search inside the group requesting the _ctx->dialog - for (_ctx->i = 0; _ctx->dialog->Group[_ctx->i].num != 0; _ctx->i++) { - if (_ctx->dialog->Group[_ctx->i].num == nGroup) { + for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { + if (_ctx->dialog->_group[_ctx->i].num == nGroup) { // Cycle through executing the commands of the group - for (_ctx->j = 0; _ctx->j < _ctx->dialog->Group[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = _ctx->dialog->Group[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i].nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->_group[_ctx->i].CmdNum[_ctx->j]; - _ctx->type = _ctx->dialog->Command[_ctx->k].type; + _ctx->type = _ctx->dialog->_command[_ctx->k].type; if (_ctx->type == 1) { // Call custom function - CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], - _ctx->dialog->Command[_ctx->k].arg1, - _ctx->dialog->Command[_ctx->k].arg2, - _ctx->dialog->Command[_ctx->k].arg3, - _ctx->dialog->Command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->_command[_ctx->k].nCf], + _ctx->dialog->_command[_ctx->k].arg1, + _ctx->dialog->_command[_ctx->k].arg2, + _ctx->dialog->_command[_ctx->k].arg3, + _ctx->dialog->_command[_ctx->k].arg4 ); } else if (_ctx->type == 2) { // Set a variable - LockVar(); - varSetValue(_ctx->dialog->Command[_ctx->k].lpszVarName, EvaluateExpression(_ctx->dialog->Command[_ctx->k].expr)); - UnlockVar(); + lockVar(); + varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); + unlockVar(); } else if (_ctx->type == 3) { // DoChoice: call the chosen function - CORO_INVOKE_1(DoChoice, (uint32)_ctx->dialog->Command[_ctx->k].nChoice); + CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); } else { GLOBALS.mpalError = 1; - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); return; @@ -1148,7 +1148,7 @@ void GroupThread(CORO_PARAM, const void *param) { /* If we are here, it means that we have not found the requested group */ GLOBALS.mpalError = 1; - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); @@ -1161,7 +1161,7 @@ void GroupThread(CORO_PARAM, const void *param) { * * @param nChoice Number of choice to perform */ -void DoChoice(CORO_PARAM, uint32 nChoice) { +void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; LPMPALDIALOG dialog; int i, j, k; @@ -1171,21 +1171,21 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CODE(_ctx); /* Lock the dialogs */ - LockDialogs(); + lockDialogs(); /* Get a pointer to the current dialog */ _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; /* Search the choice between those required in the dialog */ - for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) - if (_ctx->dialog->Choice[_ctx->i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) + if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) break; /* If nothing has been found, exit with an error */ - if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { + if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { /* If we're here, we did not find the required choice */ GLOBALS.mpalError = 1; - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); return; @@ -1199,19 +1199,19 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; /* Calculate the expression of each selection, to see if they're active or inactive */ - for (_ctx->j = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].dwData != 0; _ctx->j++) - if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when == NULL) { - _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; _ctx->k++; - } else if (EvaluateExpression(_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when)) { - _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when)) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; _ctx->k++; } else - _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 0; + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; /* If there are no choices activated, then the dialog is finished. */ if (_ctx->k == 0) { - UnlockDialogs(); + unlockDialogs(); break; } @@ -1223,21 +1223,21 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq */ _ctx->j = GLOBALS.nSelectedChoice; - for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { - _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; + for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } /* Control attribute */ - if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 0)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { /* Bit 0 set: the end of the choice */ - UnlockDialogs(); + unlockDialogs(); break; } - if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 1)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { /* Bit 1 set: the end of the dialog */ - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); return; @@ -1265,7 +1265,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * the itemGetOrderFromNum() function. The items list must first be locked * by calling LockItem(). */ -static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { +static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = GLOBALS.lpmiItems; int i; LPMPALITEM newitem; @@ -1284,20 +1284,20 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { continue; if (item->Action[i].when != NULL) { - if (!EvaluateExpression(item->Action[i].when)) + if (!evaluateExpression(item->Action[i].when)) continue; } // Now we find the right action to be performed // Duplicate the item and copy the current action in #i into #0 - newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; - CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + copyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ newitem->dwRes = i; @@ -1331,7 +1331,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. */ -static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { +static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { uint32 h; // Store the running dialog in a global variable @@ -1368,15 +1368,15 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { * @param dwData Since combined with select selection * @returns True if everything is OK, false on failure */ -bool DoSelection(uint32 i, uint32 dwData) { +bool doSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].dwData == dwData && dialog->Choice[i].Select[j].curActive != 0) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) break; - if (dialog->Choice[i].Select[j].dwData == 0) + if (dialog->_choice[i]._select[j].dwData == 0) return false; GLOBALS.nSelectedChoice = j; @@ -1433,7 +1433,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeDecomp + 16); + byte *lpMpcImage = (byte *)globalAlloc(GMEM_FIXED, dwSizeDecomp + 16); if (lpMpcImage == NULL) return false; @@ -1443,7 +1443,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeComp); + cmpbuf = (byte *)globalAlloc(GMEM_FIXED, dwSizeComp); if (cmpbuf == NULL) return false; @@ -1456,7 +1456,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeDecomp) return false; - GlobalFree(cmpbuf); + globalFree(cmpbuf); } else { /* If the file is not compressed, we directly read in the data */ nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); @@ -1471,7 +1471,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (ParseMpc(lpMpcImage) == false) return false; - GlobalFree(lpMpcImage); + globalFree(lpMpcImage); /* Calculate memory usage */ /* @@ -1513,11 +1513,11 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Move to the start of the resources header */ GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); - GLOBALS.lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); + GLOBALS.lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); if (GLOBALS.lpResources == NULL) return false; - cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); + cmpbuf = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf == NULL) return false; @@ -1529,7 +1529,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != (uint32)GLOBALS.nResources * 8) return false; - GlobalFree(cmpbuf); + globalFree(cmpbuf); /* Reset back to the start of the file, leaving it open */ GLOBALS.hMpr.seek(0, SEEK_SET); @@ -1580,9 +1580,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); */ - LockVar(); + lockVar(); dwRet = (uint32)varGetValue(GETARG(char *)); - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_MESSAGE) { /* @@ -1595,16 +1595,16 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); */ - LockVar(); + lockVar(); buf = Common::String::format("Pattern.%u", GETARG(uint32)); dwRet = (uint32)varGetValue(buf.c_str()); - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_LOCATION_SIZE) { /* * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ - LockLocations(); + lockLocations(); x = locGetOrderFromNum(GETARG(uint32)); y = GETARG(uint32); if (x != -1) { @@ -1617,7 +1617,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { } else GLOBALS.mpalError = 1; - UnlockLocations(); + unlockLocations(); } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* @@ -1647,7 +1647,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); */ - LockVar(); + lockVar(); x = GETARG(uint32); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) @@ -1655,26 +1655,26 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else dwRet = (uint32)true; - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_ITEM_NAME) { /* * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); */ - LockVar(); + lockVar(); x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0]='\0'; else { - LockItems(); + lockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); - UnlockItems(); + copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + unlockItems(); } - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_DIALOG_PERIOD) { /* @@ -1698,43 +1698,43 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); */ - LockDialogs(); + lockDialogs(); x = GETARG(uint32); y = GETARG(uint32); - dwRet = (uint32)DoSelection(x, y); + dwRet = (uint32)doSelection(x, y); - UnlockDialogs(); + unlockDialogs(); } else if (wQueryType == MPQ_DO_ACTION) { /* * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); */ - LockItems(); - LockVar(); + lockItems(); + lockVar(); x = GETARG(uint32); z = GETARG(uint32); y = itemGetOrderFromNum(z); if (y != -1) { - dwRet = DoAction(x, y, GETARG(uint32)); + dwRet = doAction(x, y, GETARG(uint32)); } else { dwRet = CORO_INVALID_PID_VALUE; GLOBALS.mpalError = 1; } - UnlockVar(); - UnlockItems(); + unlockVar(); + unlockItems(); } else if (wQueryType == MPQ_DO_DIALOG) { /* * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); */ if (!GLOBALS.bExecutingDialog) { - LockDialogs(); + lockDialogs(); x = dialogGetOrderFromNum(GETARG(uint32)); y = GETARG(uint32); - dwRet = DoDialog(x, y); - UnlockDialogs(); + dwRet = doDialog(x, y); + unlockDialogs(); } } else { /* @@ -1802,10 +1802,10 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); */ - LockLocations(); + lockLocations(); x = locGetOrderFromNum(GETARG(uint32)); hRet = resLoad(GLOBALS.lpmlLocations[x].dwPicRes); - UnlockLocations(); + unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { /* @@ -1817,17 +1817,17 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); */ - LockVar(); + lockVar(); hRet = GetItemList(GETARG(uint32)); - LockVar(); + lockVar(); } else if (wQueryType == MPQ_ITEM_DATA) { /* * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ - LockItems(); - hRet = GetItemData(itemGetOrderFromNum(GETARG(uint32))); - UnlockItems(); + lockItems(); + hRet = getItemData(itemGetOrderFromNum(GETARG(uint32))); + unlockItems(); } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { /* @@ -1839,29 +1839,29 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName); */ - LockVar(); + lockVar(); x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0] = '\0'; else { - LockItems(); + lockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); - UnlockItems(); + copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + unlockItems(); } - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_DIALOG_PERIOD) { /* * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); */ - LockDialogs(); + lockDialogs(); y = GETARG(uint32); - hRet = DuplicateDialogPeriod(y); - UnlockDialogs(); + hRet = duplicateDialogPeriod(y); + unlockDialogs(); } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { /* @@ -1873,9 +1873,9 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); */ - LockDialogs(); - hRet = GetSelectList(GETARG(uint32)); - UnlockDialogs(); + lockDialogs(); + hRet = getSelectList(GETARG(uint32)); + unlockDialogs(); } else if (wQueryType == MPQ_DIALOG_SELECTION) { /* @@ -1969,12 +1969,12 @@ bool mpalExecuteScript(int nScript) { LockScripts(); n = scriptGetOrderFromNum(nScript); - s = (LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); if (s == NULL) return false; - CopyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); - UnlockScripts(); + copyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); + unlockScripts(); // !!! New process management if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) @@ -2082,10 +2082,10 @@ int mpalGetSaveStateSize(void) { * @param buf Buffer where to store the state */ void mpalSaveState(byte *buf) { - LockVar(); + lockVar(); WRITE_LE_UINT32(buf, GLOBALS.nVars); - CopyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); - UnlockVar(); + copyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); + unlockVar(); } @@ -2097,14 +2097,14 @@ void mpalSaveState(byte *buf) { */ int mpalLoadState(byte *buf) { // We must destroy and recreate all the variables - GlobalFree(GLOBALS.hVars); + globalFree(GLOBALS.hVars); GLOBALS.nVars = READ_LE_UINT32(buf); - GLOBALS.hVars = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); - LockVar(); - CopyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); - UnlockVar(); + GLOBALS.hVars = globalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); + lockVar(); + copyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); + unlockVar(); return GLOBALS.nVars * sizeof(MPALVAR) + 4; } @@ -2170,7 +2170,7 @@ const MsgCommentsStruct MsgComments[] = { { 0, 0, NULL } }; -void OutputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { +void outputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { int i; for (i = 0; MsgComments[i].wStart != 0; i++) @@ -2225,7 +2225,7 @@ int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { } -void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { +void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { int i; for (i = 0; MsgComments[i].wStart != 0; i++) @@ -2258,7 +2258,7 @@ void mpalDumpMessages(void) { f->writeString("\n\n
\n"); for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); + lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { // bernie: debug /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { @@ -2266,9 +2266,9 @@ void mpalDumpMessages(void) { }*/ nPeriods = 1; - p=lpPeriods[0] = lpMessage; + p = lpPeriods[0] = lpMessage; - OutputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); + outputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); while (1) { // Find the end of the current period @@ -2313,7 +2313,7 @@ void mpalDumpMessages(void) { OutputEndMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); - GlobalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS.lpmmMsgs[i].hText); } } @@ -2351,10 +2351,10 @@ void mpalDumpOthers(void) { f->writeString("\n\n"); for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); + lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { nPeriods = 1; - p=lpPeriods[0] = lpMessage; + p = lpPeriods[0] = lpMessage; if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { while (1) { @@ -2399,9 +2399,9 @@ void mpalDumpOthers(void) { } } - OutputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); + outputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); - GlobalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS.lpmmMsgs[i].hText); } } @@ -2735,7 +2735,7 @@ case num: \ return DLG##num[nPers]; -const char *GetPersonName(uint16 nDlg, int nPers) { +const char *getPersonName(uint16 nDlg, int nPers) { switch (nDlg) { HANDLE_DIALOG(10); HANDLE_DIALOG(51); @@ -2821,11 +2821,11 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString("\n\n"); - for (g = 0;dlg->Group[g].num != 0; g++) { + for (g = 0; dlg->_group[g].num != 0; g++) { bAtLeastOne = false; - for (c = 0; cGroup[g].nCmds; c++) { - curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + for (c = 0; c_group[g].nCmds; c++) { + curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; if (curCmd->type == 1 && curCmd->nCf == 71) { bAtLeastOne = true; break; @@ -2838,23 +2838,23 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); f->writeString("

\n"); - for (c = 0;cGroup[g].nCmds; c++) { - curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + for (c = 0; c < dlg->_group[g].nCmds; c++) { + curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; // If it's a custom function, call SendDialogMessage(nPers, nMsg) if (curCmd->type == 1 && curCmd->nCf == 71) { sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); - for (j = 0; dlg->Periods[j] != NULL; j++) - if (dlg->PeriodNums[j] == curCmd->arg2) + for (j = 0; dlg->_periods[j] != NULL; j++) + if (dlg->_periodNums[j] == curCmd->arg2) break; - if (dlg->Periods[j] == NULL) + if (dlg->_periods[j] == NULL) warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->arg2); else { - frase = (char *)GlobalLock(dlg->Periods[j]); + frase = (char *)globalLock(dlg->_periods[j]); strcpy(copia, frase); - GlobalUnlock(dlg->Periods[j]); + globalUnlock(dlg->_periods[j]); while ((p = strchr(copia,'^')) != NULL) *p = '\"'; @@ -2869,7 +2869,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString("\t\n"); f->writeString(Common::String::format("\t\t\n", fname)); f->writeString(Common::String::format("\t\t\n", - GetPersonName(dlg->nObj, curCmd->arg1))); + getPersonName(dlg->nObj, curCmd->arg1))); f->writeString(Common::String::format("\t\t\n",copia)); f->writeString("\t\n"); //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); @@ -2890,12 +2890,12 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { void mpalDumpDialogs(void) { int i; - LockDialogs(); + lockDialogs(); for (i = 0; i < GLOBALS.nDialogs; i++) mpalDumpDialog(&GLOBALS.lpmdDialogs[i]); - UnlockDialogs(); + unlockDialogs(); } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1bf19ef1bb..fb3d019051 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -519,13 +519,13 @@ int mpalGetSaveStateSize(void); /** * Locks the variables for access */ -void LockVar(void); +void lockVar(void); /** * Unlocks variables after use */ -void UnlockVar(void); +void unlockVar(void); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 44d817d748..e331335315 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -144,7 +144,7 @@ struct command { struct MPALDIALOG { uint32 nObj; // Dialog number - struct command Command[MAX_COMMANDS_PER_DIALOG]; + struct command _command[MAX_COMMANDS_PER_DIALOG]; struct { uint16 num; @@ -152,7 +152,7 @@ struct MPALDIALOG { byte nCmds; uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; - } Group[MAX_GROUPS_PER_DIALOG]; + } _group[MAX_GROUPS_PER_DIALOG]; struct { // The last choice has nChoice == 0 @@ -170,12 +170,12 @@ struct MPALDIALOG { // Modified at run-time: 0 if the select is currently disabled, // and 1 if currently active byte curActive; - } Select[MAX_SELECTS_PER_CHOICE]; + } _select[MAX_SELECTS_PER_CHOICE]; - } Choice[MAX_CHOICES_PER_DIALOG]; + } _choice[MAX_CHOICES_PER_DIALOG]; - uint16 PeriodNums[MAX_PERIODS_PER_DIALOG]; - HGLOBAL Periods[MAX_PERIODS_PER_DIALOG]; + uint16 _periodNums[MAX_PERIODS_PER_DIALOG]; + HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; typedef MPALDIALOG *LPMPALDIALOG; @@ -204,7 +204,7 @@ struct MPALITEM { byte nActions; // Number of managed actions uint32 dwRes; // Resource that contains frames and patterns - struct command Command[MAX_COMMANDS_PER_ITEM]; + struct command _command[MAX_COMMANDS_PER_ITEM]; // Pointer to array of structures containing various managed activities. In practice, of // every action we know what commands to run, including those defined in structures above @@ -223,7 +223,7 @@ struct MPALSCRIPT { uint32 nMoments; - struct command Command[MAX_COMMANDS_PER_SCRIPT]; + struct command _command[MAX_COMMANDS_PER_SCRIPT]; struct { int32 dwTime; diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index edc6e65ca1..bce623e43c 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -41,7 +41,7 @@ RMRes::RMRes(uint32 resID) { if (_h == NULL) _h = mpalQueryResource(resID); if (_h != NULL) - _buf = (byte *)GlobalLock(_h); + _buf = (byte *)globalLock(_h); } /** @@ -49,8 +49,8 @@ RMRes::RMRes(uint32 resID) { */ RMRes::~RMRes() { if (_h != NULL) { - GlobalUnlock(_h); - GlobalFree(_h); + globalUnlock(_h); + globalFree(_h); } } @@ -72,7 +72,7 @@ RMRes::operator const byte *() { * Returns the size of the resource */ unsigned int RMRes::size() { - return GlobalSize(_h); + return globalSize(_h); } /****************************************************************************\ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 2f55bfad42..93b5e90706 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -307,7 +307,7 @@ CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { if (lpTempBuffer != NULL) { lpTemp = lpTempBuffer; } else { - lpTemp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); + lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); if (lpTemp == NULL) { error("Insufficient memory!"); @@ -344,7 +344,7 @@ CODECADPCMSTEREO::~CODECADPCMSTEREO() { \****************************************************************************/ CODECADPCM::~CODECADPCM() { - GlobalFree(lpTemp); + globalFree(lpTemp); } @@ -1148,7 +1148,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { } /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - CopyMemory(lpLock, lpBuf, dwSize); + copyMemory(lpLock, lpBuf, dwSize); /* Unlocka il buffer */ lpDSBuffer->Unlock(lpLock, dwSize, NULL, NULL); @@ -2111,7 +2111,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); // warning(buf); - CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); bPrecache = true; } @@ -2124,7 +2124,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); // warning(buf); This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); bPrecache = true; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index fb53d68615..9f34276c41 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -180,28 +180,28 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Call the Draw() of the parent class if Tony is visible if (_bShow && bDrawNow) { if (_bCorpoDavanti) { - prim->Dst().setEmpty(); - prim->Dst().offset(-44, -134); + prim->getDst().setEmpty(); + prim->getDst().offset(-44, -134); if (_bPastorella) - prim->Dst().offset(1, 4); + prim->getDst().offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } if (_bIsTalking || _bIsStaticTalk) { // Offest direction from scrolling - prim->Dst().setEmpty(); - prim->Dst().offset(-_curScroll); - prim->Dst().offset(_pos); - prim->Dst().offset(-44, -134); - prim->Dst() += _nBodyOffset; + prim->getDst().setEmpty(); + prim->getDst().offset(-_curScroll); + prim->getDst().offset(_pos); + prim->getDst().offset(-44, -134); + prim->getDst() += _nBodyOffset; CORO_INVOKE_2(_body.draw, bigBuf, prim); } if (!_bCorpoDavanti) { - prim->Dst().setEmpty(); - prim->Dst().offset(-44, -134); + prim->getDst().setEmpty(); + prim->getDst().offset(-44, -134); if (_bPastorella) - prim->Dst().offset(0, 3); + prim->getDst().offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } } diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index f11c9e6a2f..98b23001c0 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -1069,8 +1069,8 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = GlobalAllocate(info.size); - byte *lpDestBuf = (byte *)GlobalLock(destBuf); + HGLOBAL destBuf = globalAllocate(info.size); + byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; // Decompress the data @@ -1080,7 +1080,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { delete [] cmpBuf; // Return the resource - GlobalUnlock(destBuf); + globalUnlock(destBuf); return lpDestBuf; } -- cgit v1.2.3 From 088a6b7b45b08f3257329e3da99fda699ba3aedc Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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 1866cbd0fb0d7df1c1a4059e98b5d0f6d851c2d4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 8 Jun 2012 08:44:14 +0200 Subject: TONY: start renaming globals --- engines/tony/custom.cpp | 304 ++++++++++++++++++++-------------------- engines/tony/globals.cpp | 28 ++-- engines/tony/globals.h | 186 ++++++++++++------------ engines/tony/mpal/mpalutils.cpp | 4 +- engines/tony/mpal/mpalutils.h | 2 +- engines/tony/tony.cpp | 4 +- 6 files changed, 264 insertions(+), 264 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a50807822c..810e6a9353 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -108,24 +108,24 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; - for (i = 0; i < GLOBALS.curChangedHotspot; i++) - GLOBALS.Loc->getItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->changeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); + for (i = 0; i < GLOBALS._curChangedHotspot; i++) + GLOBALS.Loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { - f->writeByte(GLOBALS.curChangedHotspot); - if (GLOBALS.curChangedHotspot > 0) { - for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) - GLOBALS.ChangedHotspot[i].Save(f); + f->writeByte(GLOBALS._curChangedHotspot); + if (GLOBALS._curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS._curChangedHotspot; ++i) + GLOBALS._changedHotspot[i].save(f); } } void LoadChangedHotspot(Common::InSaveFile *f) { - GLOBALS.curChangedHotspot = f->readByte(); + GLOBALS._curChangedHotspot = f->readByte(); - if (GLOBALS.curChangedHotspot > 0) { - for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) - GLOBALS.ChangedHotspot[i].Load(f); + if (GLOBALS._curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS._curChangedHotspot; ++i) + GLOBALS._changedHotspot[i].load(f); } } @@ -141,29 +141,29 @@ void LoadChangedHotspot(Common::InSaveFile *f) { */ void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - GLOBALS.MCharacter[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[i].code); + GLOBALS._mCharacter[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[i]._code); for (int i = 0; i < 10; i++) - GLOBALS.Character[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.Character[i].code); + GLOBALS._character[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._character[i]._code); } void CharsSaveAll(Common::OutSaveFile *f) { for (int i = 0; i < 10; i++) { - f->writeByte(GLOBALS.IsMChar[i]); - if (GLOBALS.IsMChar[i]) { - GLOBALS.MCharacter[i].Save(f); + f->writeByte(GLOBALS._isMChar[i]); + if (GLOBALS._isMChar[i]) { + GLOBALS._mCharacter[i].save(f); } else { - GLOBALS.Character[i].Save(f); + GLOBALS._character[i].save(f); } } } void CharsLoadAll(Common::InSaveFile *f) { for (int i = 0; i < 10; i++) { - GLOBALS.IsMChar[i] = f->readByte(); - if (GLOBALS.IsMChar[i]) - GLOBALS.MCharacter[i].Load(f); + GLOBALS._isMChar[i] = f->readByte(); + if (GLOBALS._isMChar[i]) + GLOBALS._mCharacter[i].load(f); else - GLOBALS.Character[i].Load(f); + GLOBALS._character[i].load(f); } } @@ -202,7 +202,7 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint } DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { - GLOBALS.bAlwaysDisplay = (val != 0); + GLOBALS._bAlwaysDisplay = (val != 0); } @@ -296,10 +296,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); } - if (GLOBALS.curBackText) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + if (GLOBALS._curBackText) + CORO_INVOKE_0(GLOBALS._curBackText->hide); - GLOBALS.bTonyIsSpeaking = true; + GLOBALS._bTonyIsSpeaking = true; for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS.Input); @@ -320,7 +320,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->scrollPosition()); // Handling for always display - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text.setAlwaysDisplay(); _ctx->text.forceTime(); } @@ -355,9 +355,9 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - GLOBALS.bTonyIsSpeaking = false; - if (GLOBALS.curBackText) - GLOBALS.curBackText->show(); + GLOBALS._bTonyIsSpeaking = false; + if (GLOBALS._curBackText) + GLOBALS._curBackText->show(); CORO_INVOKE_0(GLOBALS.Tony->endTalk); @@ -378,7 +378,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui GLOBALS.Freeze(); - GLOBALS.curChangedHotspot = 0; + GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else @@ -538,7 +538,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint // On exit, unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); - GLOBALS.curChangedHotspot = 0; + GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else @@ -578,8 +578,8 @@ DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.saveTonyPos = GLOBALS.Tony->position(); - GLOBALS.saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); + GLOBALS._saveTonyPos = GLOBALS.Tony->position(); + GLOBALS._saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); } DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -588,7 +588,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(ChangeLocation, GLOBALS.saveTonyLoc, GLOBALS.saveTonyPos.x, GLOBALS.saveTonyPos.y, 0); + CORO_INVOKE_4(ChangeLocation, GLOBALS._saveTonyLoc, GLOBALS._saveTonyPos.x, GLOBALS._saveTonyPos.y, 0); MCharResetCodes(); @@ -1340,18 +1340,18 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; - for (i = 0; i < GLOBALS.curChangedHotspot; i++) - if (GLOBALS.ChangedHotspot[i].dwCode == dwCode) { - GLOBALS.ChangedHotspot[i].nX = nX; - GLOBALS.ChangedHotspot[i].nY = nY; + for (i = 0; i < GLOBALS._curChangedHotspot; i++) + if (GLOBALS._changedHotspot[i]._dwCode == dwCode) { + GLOBALS._changedHotspot[i]._nX = nX; + GLOBALS._changedHotspot[i]._nY = nY; break; } - if (i == GLOBALS.curChangedHotspot) { - GLOBALS.ChangedHotspot[i].dwCode = dwCode; - GLOBALS.ChangedHotspot[i].nX = nX; - GLOBALS.ChangedHotspot[i].nY = nY; - GLOBALS.curChangedHotspot++; + if (i == GLOBALS._curChangedHotspot) { + GLOBALS._changedHotspot[i]._dwCode = dwCode; + GLOBALS._changedHotspot[i]._nX = nX; + GLOBALS._changedHotspot[i]._nY = nY; + GLOBALS._curChangedHotspot++; } GLOBALS.Loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); @@ -1412,36 +1412,36 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); - GLOBALS.Character[nChar].code = nCode; - GLOBALS.Character[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); - GLOBALS.Character[nChar].r = 255; - GLOBALS.Character[nChar].g = 255; - GLOBALS.Character[nChar].b = 255; - GLOBALS.Character[nChar].talkpattern = 0; - GLOBALS.Character[nChar].starttalkpattern = 0; - GLOBALS.Character[nChar].endtalkpattern = 0; - GLOBALS.Character[nChar].standpattern = 0; + GLOBALS._character[nChar]._code = nCode; + GLOBALS._character[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._character[nChar]._r = 255; + GLOBALS._character[nChar]._g = 255; + GLOBALS._character[nChar]._b = 255; + GLOBALS._character[nChar]._talkPattern = 0; + GLOBALS._character[nChar]._startTalkPattern = 0; + GLOBALS._character[nChar]._endTalkPattern = 0; + GLOBALS._character[nChar]._standPattern = 0; - GLOBALS.IsMChar[nChar] = false; + GLOBALS._isMChar[nChar] = false; } DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 16); - GLOBALS.Character[nChar].r = r; - GLOBALS.Character[nChar].g = g; - GLOBALS.Character[nChar].b = b; + GLOBALS._character[nChar]._r = r; + GLOBALS._character[nChar]._g = g; + GLOBALS._character[nChar]._b = b; } DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { assert(nChar < 16); - GLOBALS.Character[nChar].talkpattern = tp; - GLOBALS.Character[nChar].standpattern = sp; + GLOBALS._character[nChar]._talkPattern = tp; + GLOBALS._character[nChar]._standPattern = sp; } DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { assert(nChar < 16); - GLOBALS.Character[nChar].starttalkpattern = sp; - GLOBALS.Character[nChar].endtalkpattern = ep; + GLOBALS._character[nChar]._startTalkPattern = sp; + GLOBALS._character[nChar]._endTalkPattern = ep; } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { @@ -1461,18 +1461,18 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = GLOBALS.Character[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); - if (GLOBALS.Character[nChar].starttalkpattern != 0) { + if (GLOBALS._character[nChar]._startTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].starttalkpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._startTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].talkpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._talkPattern); GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); @@ -1485,9 +1485,9 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { - GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); - if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS._bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; @@ -1500,7 +1500,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->setColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); + _ctx->text->setColor(GLOBALS._character[nChar]._r, GLOBALS._character[nChar]._g, GLOBALS._character[nChar]._b); // Write the text _ctx->text->writeText((*_ctx->msg)[_ctx->i], 0); @@ -1509,7 +1509,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->setPosition(_ctx->pt); // Set the always display - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); } @@ -1539,19 +1539,19 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } - GLOBALS.curBackText = NULL; + GLOBALS._curBackText = NULL; delete _ctx->text; } - if (GLOBALS.Character[nChar].endtalkpattern != 0) { + if (GLOBALS._character[nChar]._endTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].endtalkpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._endTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].standpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._standPattern); GLOBALS.Unfreeze(); delete _ctx->msg; @@ -1577,43 +1577,43 @@ DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].code = nCode; + GLOBALS._mCharacter[nChar]._code = nCode; if (nCode == 0) - GLOBALS.MCharacter[nChar].item = NULL; + GLOBALS._mCharacter[nChar]._item = NULL; else - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); - GLOBALS.MCharacter[nChar].r = 255; - GLOBALS.MCharacter[nChar].g = 255; - GLOBALS.MCharacter[nChar].b = 255; - GLOBALS.MCharacter[nChar].x = -1; - GLOBALS.MCharacter[nChar].y = -1; - GLOBALS.MCharacter[nChar].bAlwaysBack = 0; + GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._mCharacter[nChar]._r = 255; + GLOBALS._mCharacter[nChar]._g = 255; + GLOBALS._mCharacter[nChar]._b = 255; + GLOBALS._mCharacter[nChar]._x = -1; + GLOBALS._mCharacter[nChar]._y = -1; + GLOBALS._mCharacter[nChar]._bAlwaysBack = 0; for (int i = 0; i < 10; i++) - GLOBALS.MCharacter[nChar].numtalks[i] = 1; + GLOBALS._mCharacter[nChar]._numTalks[i] = 1; - GLOBALS.MCharacter[nChar].curgroup = 0; + GLOBALS._mCharacter[nChar]._curGroup = 0; - GLOBALS.IsMChar[nChar] = true; + GLOBALS._isMChar[nChar] = true; } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[nChar].code); + GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[nChar]._code); } DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].x = nX; - GLOBALS.MCharacter[nChar].y = nY; + GLOBALS._mCharacter[nChar]._x = nX; + GLOBALS._mCharacter[nChar]._y = nY; } DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].r = r; - GLOBALS.MCharacter[nChar].g = g; - GLOBALS.MCharacter[nChar].b = b; + GLOBALS._mCharacter[nChar]._r = r; + GLOBALS._mCharacter[nChar]._g = g; + GLOBALS._mCharacter[nChar]._b = b; } @@ -1621,7 +1621,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint3 assert(nChar < 10); assert(nGroup < 10); - GLOBALS.MCharacter[nChar].numtalks[nGroup] = nTalks; + GLOBALS._mCharacter[nChar]._numTalks[nGroup] = nTalks; } @@ -1629,20 +1629,20 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 n assert(nChar < 10); assert(nGroup < 10); - GLOBALS.MCharacter[nChar].curgroup = nGroup; + GLOBALS._mCharacter[nChar]._curGroup = nGroup; } DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].numtexts = nTexts - 1; - GLOBALS.MCharacter[nChar].bInTexts = false; + GLOBALS._mCharacter[nChar]._numTexts = nTexts - 1; + GLOBALS._mCharacter[nChar]._bInTexts = false; } DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].bAlwaysBack = bAlwaysBack; + GLOBALS._mCharacter[nChar]._bAlwaysBack = bAlwaysBack; } @@ -1666,21 +1666,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes assert(nChar < 10); - bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; + bIsBack |= GLOBALS._mCharacter[nChar]._bAlwaysBack ? 1 : 0; // Calculates the position of the text according to the current frame - if (GLOBALS.MCharacter[nChar].x == -1) - _ctx->pt = GLOBALS.MCharacter[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + if (GLOBALS._mCharacter[nChar]._x == -1) + _ctx->pt = GLOBALS._mCharacter[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else - _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); + _ctx->pt = RMPoint(GLOBALS._mCharacter[nChar]._x, GLOBALS._mCharacter[nChar]._y); // Parameter for special actions: random between the spoken - _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS._mCharacter[nChar]._numTalks[GLOBALS._mCharacter[nChar]._curGroup] - 1) + 1; // Try to run the custom function to initialise the speech - if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); + if (GLOBALS._mCharacter[nChar]._item) { + _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nChar]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1698,9 +1698,9 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { // Create a different object depending on whether it's background or not if (bIsBack) { - GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); - if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS._bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; @@ -1713,7 +1713,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->setColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); + _ctx->text->setColor(GLOBALS._mCharacter[nChar]._r, GLOBALS._mCharacter[nChar]._g, GLOBALS._mCharacter[nChar]._b); // Write the text _ctx->text->writeText((*_ctx->msg)[_ctx->i], nFont); @@ -1722,7 +1722,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->setPosition(_ctx->pt); // Set the always display - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); } @@ -1751,15 +1751,15 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; } - GLOBALS.curBackText = NULL; + GLOBALS._curBackText = NULL; delete _ctx->text; delete _ctx->msg; } // Try to run the custom function to close the speech - if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); + if (GLOBALS._mCharacter[nChar]._item) { + _ctx->h = mpalQueryDoAction(31, GLOBALS._mCharacter[nChar]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1790,7 +1790,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->bIsBack = false; // The SendDialogMessage can go in the background if it is a character - if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) + if (nPers != 0 && GLOBALS._isMChar[nPers] && GLOBALS._mCharacter[nPers]._bAlwaysBack) _ctx->bIsBack = true; _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); @@ -1830,67 +1830,67 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } - } else if (!GLOBALS.IsMChar[nPers]) { + } else if (!GLOBALS._isMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = GLOBALS.Character[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); - if (GLOBALS.Character[nPers].starttalkpattern != 0) { + if (GLOBALS._character[nPers]._startTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._startTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].talkpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._talkPattern); - _ctx->text->setColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); + _ctx->text->setColor(GLOBALS._character[nPers]._r, GLOBALS._character[nPers]._g, GLOBALS._character[nPers]._b); _ctx->text->writeText(_ctx->string, 0); _ctx->text->setPosition(_ctx->pt); } else { - if (GLOBALS.MCharacter[nPers].x == -1) - _ctx->pt = GLOBALS.MCharacter[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + if (GLOBALS._mCharacter[nPers]._x == -1) + _ctx->pt = GLOBALS._mCharacter[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else - _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); + _ctx->pt = RMPoint(GLOBALS._mCharacter[nPers]._x, GLOBALS._mCharacter[nPers]._y); // Parameter for special actions. Random between the spoken. - _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS._mCharacter[nPers]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS._mCharacter[nPers]._numTalks[GLOBALS._mCharacter[nPers]._curGroup] - 1) + 1; - if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { - GLOBALS.MCharacter[nPers].numtexts--; + if (GLOBALS._mCharacter[nPers]._numTexts != 0 && GLOBALS._mCharacter[nPers]._bInTexts) { + GLOBALS._mCharacter[nPers]._numTexts--; } else { // Try to run the custom function to initialise the speech - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->mpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nPers]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - GLOBALS.MCharacter[nPers].curTalk = _ctx->parm; + GLOBALS._mCharacter[nPers]._curTalk = _ctx->parm; - if (GLOBALS.MCharacter[nPers].numtexts != 0) { - GLOBALS.MCharacter[nPers].bInTexts = true; - GLOBALS.MCharacter[nPers].numtexts--; + if (GLOBALS._mCharacter[nPers]._numTexts != 0) { + GLOBALS._mCharacter[nPers]._bInTexts = true; + GLOBALS._mCharacter[nPers]._numTexts--; } } - if (GLOBALS.MCharacter[nPers].bAlwaysBack) { - _ctx->text = GLOBALS.curBackText = new RMTextDialogScrolling(GLOBALS.Loc); - if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + if (GLOBALS._mCharacter[nPers]._bAlwaysBack) { + _ctx->text = GLOBALS._curBackText = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS._bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS._curBackText->hide); _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; - _ctx->text->setSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); - _ctx->text->setColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); + _ctx->text->setSkipStatus(!GLOBALS._mCharacter[nPers]._bAlwaysBack); + _ctx->text->setColor(GLOBALS._mCharacter[nPers]._r, GLOBALS._mCharacter[nPers]._g, GLOBALS._mCharacter[nPers]._b); _ctx->text->writeText(_ctx->string, 0); _ctx->text->setPosition(_ctx->pt); } if (!GLOBALS.bSkipIdle) { _ctx->text->setInput(GLOBALS.Input); - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); } @@ -1914,29 +1914,29 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (nPers != 0) { - if (!GLOBALS.IsMChar[nPers]) { - if (GLOBALS.Character[nPers].endtalkpattern != 0) { + if (!GLOBALS._isMChar[nPers]) { + if (GLOBALS._character[nPers]._endTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].endtalkpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._endTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].standpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._standPattern); delete _ctx->text; } else { - if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { + if ((GLOBALS._mCharacter[nPers]._bInTexts && GLOBALS._mCharacter[nPers]._numTexts == 0) || !GLOBALS._mCharacter[nPers]._bInTexts) { // Try to run the custom function to close the speech - GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->mpalCode(), GLOBALS.MCharacter[nPers].curTalk); + GLOBALS._mCharacter[nPers]._curTalk = (GLOBALS._mCharacter[nPers]._curTalk % 10) + GLOBALS._mCharacter[nPers]._curGroup * 10; + _ctx->h = mpalQueryDoAction(31, GLOBALS._mCharacter[nPers]._item->mpalCode(), GLOBALS._mCharacter[nPers]._curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - GLOBALS.MCharacter[nPers].bInTexts = false; - GLOBALS.MCharacter[nPers].numtexts = 0; + GLOBALS._mCharacter[nPers]._bInTexts = false; + GLOBALS._mCharacter[nPers]._numTexts = 0; } - GLOBALS.curBackText = NULL; + GLOBALS._curBackText = NULL; delete _ctx->text; } } else { @@ -2545,7 +2545,7 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.EnableGUI = mainEnableGUI; GLOBALS.SetPalesati = mainSetPalesati; - GLOBALS.bAlwaysDisplay = false; + GLOBALS._bAlwaysDisplay = false; int i; for (i = 0; i < 10; i++) diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 742d4376d5..37a5a20454 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -26,15 +26,15 @@ namespace Tony { Globals::Globals() { - Common::fill(nextMusic, nextMusic + MAX_PATH, 0); - nextLoop = false; - nextChannel = 0; - nextSync = 0; - curChannel = 0; - flipflop = 0; - curBackText = NULL; - bTonyIsSpeaking = false; - curChangedHotspot = 0; + Common::fill(_nextMusic, _nextMusic + MAX_PATH, 0); + _nextLoop = false; + _nextChannel = 0; + _nextSync = 0; + _curChannel = 0; + _flipflop = 0; + _curBackText = NULL; + _bTonyIsSpeaking = false; + _curChangedHotspot = 0; Tony = NULL; Pointer = NULL; Boxes = NULL; @@ -72,7 +72,7 @@ Globals::Globals() { bCfgDubbing = false; bCfgMusic = false; bCfgSFX = false; - bAlwaysDisplay = false; + _bAlwaysDisplay = false; nCfgTonySpeed = 0; nCfgTextSpeed = 0; nCfgDubbingVolume = 0; @@ -132,14 +132,14 @@ Globals::Globals() { nExecutingChoice = 0; nSelectedChoice = 0; nTonyNextTalkType = RMTony::TALK_NORMAL; - saveTonyLoc = 0; + _saveTonyLoc = 0; for (int i = 0; i < 16; ++i) - Common::fill((byte *)&Character[i], (byte *)&Character[i] + sizeof(CharacterStruct), 0); + Common::fill((byte *)&_character[i], (byte *)&_character[i] + sizeof(CharacterStruct), 0); for (int i = 0; i < 10; ++i) - Common::fill((byte *)&MCharacter[i], (byte *)&MCharacter[i] + sizeof(MCharacterStruct), 0); + Common::fill((byte *)&_mCharacter[i], (byte *)&_mCharacter[i] + sizeof(MCharacterStruct), 0); for (int i = 0; i < 256; ++i) - Common::fill((byte *)&ChangedHotspot[i], (byte *)&ChangedHotspot[i] + sizeof(ChangedHotspotStruct), 0); + Common::fill((byte *)&_changedHotspot[i], (byte *)&_changedHotspot[i] + sizeof(ChangedHotspotStruct), 0); } } // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 76a54e07c8..84c5d7398c 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -48,101 +48,101 @@ namespace Tony { struct CharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int talkpattern; - int standpattern; - int starttalkpattern, endtalkpattern; - int numtexts; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); + uint32 _code; + RMItem *_item; + byte _r, _g, _b; + int _talkPattern; + int _standPattern; + int _startTalkPattern, _endTalkPattern; + int _numTexts; + + void save(Common::OutSaveFile *f) { + f->writeUint32LE(_code); f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(talkpattern); - f->writeUint32LE(standpattern); - f->writeUint32LE(starttalkpattern); - f->writeUint32LE(endtalkpattern); - f->writeUint32LE(numtexts); + f->writeByte(_r); + f->writeByte(_g); + f->writeByte(_b); + f->writeUint32LE(_talkPattern); + f->writeUint32LE(_standPattern); + f->writeUint32LE(_startTalkPattern); + f->writeUint32LE(_endTalkPattern); + f->writeUint32LE(_numTexts); } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); + void load(Common::InSaveFile *f) { + _code = f->readUint32LE(); f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - talkpattern = f->readUint32LE(); - standpattern = f->readUint32LE(); - starttalkpattern = f->readUint32LE(); - endtalkpattern = f->readUint32LE(); - numtexts = f->readUint32LE(); + _item = NULL; + _r = f->readByte(); + _g = f->readByte(); + _b = f->readByte(); + _talkPattern = f->readUint32LE(); + _standPattern = f->readUint32LE(); + _startTalkPattern = f->readUint32LE(); + _endTalkPattern = f->readUint32LE(); + _numTexts = f->readUint32LE(); } }; struct MCharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int x, y; - int numtalks[10]; - int curgroup; - int numtexts; - bool bInTexts; - int curTalk; - bool bAlwaysBack; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); + uint32 _code; + RMItem *_item; + byte _r, _g, _b; + int _x, _y; + int _numTalks[10]; + int _curGroup; + int _numTexts; + bool _bInTexts; + int _curTalk; + bool _bAlwaysBack; + + void save(Common::OutSaveFile *f) { + f->writeUint32LE(_code); f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(x); - f->writeUint32LE(y); + f->writeByte(_r); + f->writeByte(_g); + f->writeByte(_b); + f->writeUint32LE(_x); + f->writeUint32LE(_y); for (int i = 0; i < 10; ++i) - f->writeUint32LE(numtalks[i]); - f->writeUint32LE(curgroup); - f->writeUint32LE(numtexts); - f->writeByte(bInTexts); - f->writeUint32LE(curTalk); - f->writeByte(bAlwaysBack); + f->writeUint32LE(_numTalks[i]); + f->writeUint32LE(_curGroup); + f->writeUint32LE(_numTexts); + f->writeByte(_bInTexts); + f->writeUint32LE(_curTalk); + f->writeByte(_bAlwaysBack); } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); + void load(Common::InSaveFile *f) { + _code = f->readUint32LE(); f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - x = f->readUint32LE(); - y = f->readUint32LE(); + _item = NULL; + _r = f->readByte(); + _g = f->readByte(); + _b = f->readByte(); + _x = f->readUint32LE(); + _y = f->readUint32LE(); for (int i = 0; i < 10; ++i) - numtalks[i] = f->readUint32LE(); - curgroup = f->readUint32LE(); - numtexts = f->readUint32LE(); - bInTexts = f->readByte(); - curTalk = f->readUint32LE(); - bAlwaysBack = f->readByte(); + _numTalks[i] = f->readUint32LE(); + _curGroup = f->readUint32LE(); + _numTexts = f->readUint32LE(); + _bInTexts = f->readByte(); + _curTalk = f->readUint32LE(); + _bAlwaysBack = f->readByte(); } }; struct ChangedHotspotStruct { - uint32 dwCode; - uint32 nX, nY; + uint32 _dwCode; + uint32 _nX, _nY; - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(dwCode); - f->writeUint32LE(nX); - f->writeUint32LE(nY); + void save(Common::OutSaveFile *f) { + f->writeUint32LE(_dwCode); + f->writeUint32LE(_nX); + f->writeUint32LE(_nY); } - void Load(Common::InSaveFile *f) { - dwCode = f->readUint32LE(); - nX = f->readUint32LE(); - nY = f->readUint32LE(); + void load(Common::InSaveFile *f) { + _dwCode = f->readUint32LE(); + _nX = f->readUint32LE(); + _nY = f->readUint32LE(); } }; @@ -170,23 +170,23 @@ class Globals { public: Globals(); - char nextMusic[MAX_PATH]; - bool nextLoop; - int nextChannel; - int nextSync; - int curChannel; - int flipflop; + char _nextMusic[MAX_PATH]; + bool _nextLoop; + int _nextChannel; + int _nextSync; + int _curChannel; + int _flipflop; // OSystem::MutexRef csMusic; - CharacterStruct Character[16]; - MCharacterStruct MCharacter[10]; - ChangedHotspotStruct ChangedHotspot[256]; - bool IsMChar[16]; - bool bAlwaysDisplay; - RMPoint saveTonyPos; - int saveTonyLoc; - RMTextDialog *curBackText; - bool bTonyIsSpeaking; - int curChangedHotspot; + CharacterStruct _character[16]; + MCharacterStruct _mCharacter[10]; + ChangedHotspotStruct _changedHotspot[256]; + bool _isMChar[16]; + bool _bAlwaysDisplay; + RMPoint _saveTonyPos; + int _saveTonyLoc; + RMTextDialog *_curBackText; + bool _bTonyIsSpeaking; + int _curChangedHotspot; bool bPatIrqFreeze; bool bCfgInvLocked; bool bCfgInvNoScroll; diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index bce623e43c..aba92a86cd 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -85,12 +85,12 @@ RMResRaw::RMResRaw(uint32 resID) : RMRes(resID) { RMResRaw::~RMResRaw() { } -const byte *RMResRaw::DataPointer() { +const byte *RMResRaw::dataPointer() { return _buf + 8; } RMResRaw::operator const byte *() { - return DataPointer(); + return dataPointer(); } int RMResRaw::width() { diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index a428a40a64..19810cf3a1 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -54,7 +54,7 @@ public: RMResRaw(uint32 resID); virtual ~RMResRaw(); - const byte *DataPointer(); + const byte *dataPointer(); operator const byte*(); int width(); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e763877d97..e53177513a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -191,7 +191,7 @@ void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, in // g_system->lockMutex(csMusic); if (nChannel < 4) - if (GLOBALS.flipflop) + if (GLOBALS._flipflop) nChannel = nChannel + 1; switch (nFX) { @@ -287,7 +287,7 @@ void TonyEngine::stopMusic(int nChannel) { // g_system->lockMutex(csMusic); if (nChannel < 4) - _stream[nChannel + GLOBALS.flipflop]->Stop(); + _stream[nChannel + GLOBALS._flipflop]->Stop(); else _stream[nChannel]->Stop(); -- cgit v1.2.3 From d4777379d23b70aa07feec3ef2e90fcf376f4117 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Jun 2012 23:00:48 +1000 Subject: TONY: Refactored the memory manager to increase performance --- engines/tony/loc.cpp | 2 +- engines/tony/mpal/expr.cpp | 4 +- engines/tony/mpal/expr.h | 2 + engines/tony/mpal/loadmpc.cpp | 16 +++--- engines/tony/mpal/memory.cpp | 128 +++++++++++++++++------------------------- engines/tony/mpal/memory.h | 53 ++++++++--------- engines/tony/mpal/mpal.cpp | 15 ++--- engines/tony/mpal/mpal.h | 7 +-- engines/tony/tony.h | 1 - engines/tony/utils.cpp | 4 +- 10 files changed, 99 insertions(+), 133 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 2700a05831..afde5403b5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -2305,7 +2305,7 @@ RMMessage::RMMessage() { RMMessage::~RMMessage() { if (lpMessage) - globalFree(lpMessage); + globalDestroy(lpMessage); } void RMMessage::load(uint32 dwId) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 0b51724330..5ba2fff442 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -238,7 +238,7 @@ static int evaluateAndFreeExpression(byte *expr) { // 3) Risoluzione algebrica solve(one, num); val = one->val.num; - globalFree(expr); + globalDestroy(expr); return val; } @@ -263,7 +263,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h == NULL) return NULL; diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 7d33e5c8ca..9844add822 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -29,6 +29,8 @@ #ifndef MPAL_EXPR_H #define MPAL_EXPR_H +#include "tony/mpal/memory.h" + namespace Tony { namespace MPAL { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 8f07102aa3..5a338b24b0 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -149,7 +149,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { for (i = 0; i < num; i++) { lpmdDialog->_periodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_periods[i] = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); + lpmdDialog->_periods[i] = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)globalLock(lpmdDialog->_periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); globalUnlock(lpmdDialog->_periods[i]); @@ -478,7 +478,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hVars = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); + GLOBALS.hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); if (GLOBALS.hVars == NULL) return false; @@ -507,7 +507,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS.hMsgs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); + GLOBALS.hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); if (GLOBALS.hMsgs == NULL) return false; @@ -525,7 +525,7 @@ bool ParseMpc(const byte *lpBuf) { for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - GLOBALS.lpmmMsgs->hText = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + GLOBALS.lpmmMsgs->hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS.lpmmMsgs->hText); for (j = 0; lpBuf[j] != 0;) { @@ -560,7 +560,7 @@ bool ParseMpc(const byte *lpBuf) { if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hDialogs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); + GLOBALS.hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); if (GLOBALS.hDialogs == NULL) return false; @@ -581,7 +581,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hItems = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); + GLOBALS.hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; @@ -602,7 +602,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hLocations = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); + GLOBALS.hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); if (GLOBALS.hLocations == NULL) return false; @@ -623,7 +623,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS.hScripts = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); + GLOBALS.hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); if (GLOBALS.hScripts == NULL) return false; diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index b5bd77f838..b50f9d7c37 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -29,123 +29,101 @@ namespace Tony { namespace MPAL { -/****************************************************************************\ -* MemoryItem methods -\****************************************************************************/ - -/** - * Constructor - * @param Data sizee - */ -MemoryItem::MemoryItem(uint32 size) { - _size = size; - _buffer = (size == 0) ? NULL : new byte[size]; -} - -/** - * Destructor - */ -MemoryItem::~MemoryItem() { - delete[] _buffer; -} - -/** - * Returns a pointer to the resource - */ -MemoryItem::operator void *() { - return dataPointer(); -} - /****************************************************************************\ * MemoryManager methods \****************************************************************************/ -MemoryManager::MemoryManager() { -} - -/** - * Destructor - */ -MemoryManager::~MemoryManager() { - Common::List::iterator i; - for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { - MemoryItem *item = *i; - delete item; - } -} +const int BLOCK_ID = 0x12345678; /** * Allocates a new memory block - * @returns Returns a MemoryItem instance for the new block + * @return Returns a MemoryItem instance for the new block */ -MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { - MemoryItem *newItem = new MemoryItem(size); +HANDLE MemoryManager::allocate(uint32 size, uint flags) { + MemoryItem *newItem = (MemoryItem *)malloc(sizeof(MemoryItem) + size); + newItem->_id = BLOCK_ID; + newItem->_size = size; + newItem->_lockCount = 0; + + // If requested, clear the allocated data block if ((flags & GMEM_ZEROINIT) != 0) { - byte *dataP = (byte *)newItem->dataPointer(); + byte *dataP = newItem->_data; Common::fill(dataP, dataP + size, 0); } - _memoryBlocks.push_back(newItem); - - return *newItem; + return (HANDLE)newItem; } /** * Allocates a new memory block and returns its data pointer - * @returns Data pointer to allocated block + * @return Data pointer to allocated block */ -HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { - MemoryItem &newItem = allocate(size, flags); - return (HGLOBAL)newItem.dataPointer(); +void *MemoryManager::alloc(uint32 size, uint flags) { + MemoryItem *item = (MemoryItem *)allocate(size, flags); + ++item->_lockCount; + return &item->_data[0]; } +#define OFFSETOF(type, field) ((unsigned long) &(((type *) 0)->field)) + /** * Returns a reference to the MemoryItem for a gien byte pointer * @param block Byte pointer */ -MemoryItem &MemoryManager::getItem(HGLOBAL handle) { - Common::List::iterator i; - for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { - MemoryItem *item = *i; - if (item->dataPointer() == handle) - return *item; - } - - error("Could not locate a memory block"); +MemoryItem *MemoryManager::getItem(HGLOBAL handle) { + MemoryItem *rec = (MemoryItem *)((byte *)handle - OFFSETOF(MemoryItem, _data)); + assert(rec->_id == BLOCK_ID); + return rec; } /** - * Square bracketes operator - * @param block Byte pointer + * Returns a size of a memory block given its pointer */ -MemoryItem &MemoryManager::operator[](HGLOBAL handle) { - return getItem(handle); +uint32 MemoryManager::getSize(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + return item->_size; } /** - * Returns a size of a memory block given its pointer + * Erases a given item */ -uint32 MemoryManager::getSize(HGLOBAL handle) { - MemoryItem &item = getItem(handle); - return item.size(); +void MemoryManager::freeBlock(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + free(item); } /** * Erases a given item */ -void MemoryManager::erase(MemoryItem *item) { - delete item; - _memoryBlocks.remove(item); +void MemoryManager::destroyItem(HANDLE handle) { + MemoryItem *item = getItem(handle); + assert(item->_id == BLOCK_ID); + free(item); } /** - * Erases a given item + * Locks an item for access */ -void MemoryManager::erase(HGLOBAL handle) { - MemoryItem &item = getItem(handle); - erase(&item); +byte *MemoryManager::lockItem(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + ++item->_lockCount; + return &item->_data[0]; } +/** + * Unlocks a locked item + */ +void MemoryManager::unlockItem(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + assert(item->_lockCount > 0); + --item->_lockCount; +} + + /****************************************************************************\ * Stand-alone methods \****************************************************************************/ diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 7f95f8d86f..52d527544a 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -34,46 +34,37 @@ namespace MPAL { typedef void *HANDLE; typedef HANDLE HGLOBAL; -class MemoryItem { -protected: - byte *_buffer; +struct MemoryItem { + uint32 _id; uint32 _size; -public: - MemoryItem(uint32 size); - virtual ~MemoryItem(); - - uint32 size() { return _size; } - void *dataPointer() { return (void *)_buffer; } - bool isValid() { return _buffer != NULL; } - - // Casting for access to data - operator void *(); + int _lockCount; + byte _data[1]; + + // Casting for access to data + operator void *() { return &_data[0]; } }; class MemoryManager { private: - Common::List _memoryBlocks; + static MemoryItem *getItem(HGLOBAL handle); public: - MemoryManager(); - virtual ~MemoryManager(); - - MemoryItem &allocate(uint32 size, uint flags); - HGLOBAL alloc(uint32 size, uint flags); - MemoryItem &getItem(HGLOBAL handle); - MemoryItem &operator[](HGLOBAL handle); - void erase(MemoryItem *item); - void erase(HGLOBAL handle); - - uint32 getSize(HANDLE handle); + static HANDLE allocate(uint32 size, uint flags); + static void *alloc(uint32 size, uint flags); + static void freeBlock(HANDLE handle); + static void destroyItem(HANDLE handle); + static uint32 getSize(HANDLE handle); + static byte *lockItem(HANDLE handle); + static void unlockItem(HANDLE handle); }; // defines -#define globalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) -#define globalAllocate(size) _vm->_memoryManager.allocate(size, 0) -#define globalFree(handle) _vm->_memoryManager.erase(handle) -#define globalLock(handle) (_vm->_memoryManager.getItem(handle).dataPointer()) -#define globalUnlock(handle) {} -#define globalSize(handle) (_vm->_memoryManager.getItem(handle).size()) +#define globalAlloc(flags, size) MemoryManager::alloc(size, flags) +#define globalAllocate(flags, size) MemoryManager::allocate(size, flags) +#define globalFree(handle) MemoryManager::freeBlock(handle) +#define globalDestroy(handle) MemoryManager::destroyItem(handle) +#define globalLock(handle) MemoryManager::lockItem(handle) +#define globalUnlock(handle) MemoryManager::unlockItem(handle) +#define globalSize(handle) MemoryManager::getSize(handle) #define GMEM_FIXED 1 #define GMEM_MOVEABLE 2 diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 95c0b067d5..425fe187fc 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -402,7 +402,7 @@ HGLOBAL resLoad(uint32 dwId) { if (GLOBALS.hMpr.err()) return NULL; - h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); + h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); @@ -414,7 +414,7 @@ HGLOBAL resLoad(uint32 dwId) { if (nBytesRead != nSizeDecomp) return NULL; - globalFree(temp); + globalDestroy(temp); globalUnlock(h); return h; } @@ -741,7 +741,7 @@ void ActionThread(CORO_PARAM, const void *param) { } } - globalFree(item); + globalDestroy(item); debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); @@ -803,6 +803,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } MYTHREAD; CORO_BEGIN_CONTEXT; + // TODO: Requires endian fix uint32 *il; int i, j, k; int numitems; @@ -859,7 +860,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* If there is nothing left, we can exit */ if (_ctx->nRealItems == 0) { - globalFree(_ctx->il); + globalDestroy(_ctx->il); CORO_KILL_SELF(); return; } @@ -1456,7 +1457,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeDecomp) return false; - globalFree(cmpbuf); + globalDestroy(cmpbuf); } else { /* If the file is not compressed, we directly read in the data */ nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); @@ -1471,7 +1472,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (ParseMpc(lpMpcImage) == false) return false; - globalFree(lpMpcImage); + globalDestroy(lpMpcImage); /* Calculate memory usage */ /* @@ -1529,7 +1530,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != (uint32)GLOBALS.nResources * 8) return false; - globalFree(cmpbuf); + globalDestroy(cmpbuf); /* Reset back to the start of the file, leaving it open */ GLOBALS.hMpr.seek(0, SEEK_SET); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index fb3d019051..f23eaf8e4a 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -85,17 +85,12 @@ #include "common/coroutines.h" #include "common/rect.h" #include "common/str.h" +#include "tony/mpal/memory.h" namespace Tony { namespace MPAL { -/****************************************************************************\ -* Type definitions -\****************************************************************************/ - -typedef void *HANDLE; - /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 83543f8022..68730fa91b 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -95,7 +95,6 @@ public: LPCUSTOMFUNCTION _funcList[300]; Common::String _funcListStrings[300]; Common::RandomSource _randomSource; - MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; uint32 _hEndOfFrame; Common::File _vdbFP; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 98b23001c0..fa100d681e 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -1069,7 +1069,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(info.size); + HGLOBAL destBuf = globalAllocate(0, info.size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; @@ -1081,7 +1081,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { // Return the resource globalUnlock(destBuf); - return lpDestBuf; + return destBuf; } } // End of namespace Tony -- cgit v1.2.3 From 739983f42fae768dfee574122adbac93ac8b15d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Jun 2012 23:21:12 +1000 Subject: TONY: Fixed sign of block identifier constant --- engines/tony/mpal/memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index b50f9d7c37..c5e752d390 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -33,7 +33,7 @@ namespace MPAL { * MemoryManager methods \****************************************************************************/ -const int BLOCK_ID = 0x12345678; +const uint32 BLOCK_ID = 0x12345678; /** * Allocates a new memory block -- cgit v1.2.3 From 83f1cad02be38e56161350aabc29176f24c901a0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 01:20:08 +1000 Subject: TONY: Added code to free parsed MPC file data when the game ends --- engines/tony/mpal/expr.cpp | 30 +++++++++++- engines/tony/mpal/expr.h | 7 +++ engines/tony/mpal/loadmpc.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++ engines/tony/mpal/loadmpc.h | 4 ++ engines/tony/mpal/mpal.cpp | 1 - engines/tony/tony.cpp | 1 + 6 files changed, 149 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 5ba2fff442..a9d48e2016 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -84,7 +84,7 @@ typedef struct { byte type; // Tipo di oggetto (vedi enum ExprListTypes) byte unary; // Unary operatore (NON SUPPORTATO) - union { + union { int num; // Numero (se type==ELT_NUMBER) char *name; // Nome variabile (se type==ELT_VAR) HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) @@ -400,6 +400,34 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return true; } +/** + * Frees an expression that was previously parsed + * + * @param h Handle for the expression + */ +void freeExpression(HGLOBAL h) { + byte *data = (byte *)globalLock(h); + int num = *data; + LPEXPRESSION cur = (LPEXPRESSION)(data + 1); + + for (int i = 0; i < num; ++i, ++cur) { + switch (cur->type) { + case ELT_VAR: + globalDestroy(cur->val.name); + break; + + case ELT_PARENTH: + freeExpression(cur->val.son); + break; + + default: + break; + } + } + + globalUnlock(h); + globalFree(h); +} } // end of namespace MPAL diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 9844add822..3130539000 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -65,6 +65,13 @@ int evaluateExpression(HGLOBAL h); */ bool compareExpressions(HGLOBAL h1, HGLOBAL h2); +/** + * Frees an expression that was previously parsed + * + * @param h Handle for the expression + */ +void freeExpression(HGLOBAL h); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 5a338b24b0..aa048c0b2f 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -121,6 +121,21 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return lpBuf; } +/** + * Frees a script allocated via a previous call to ParseScript + * + * @param lpmsScript Pointer to a script structure + */ +static void FreeScript(LPMPALSCRIPT lpmsScript) { + for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i].type); ++i, ++lpmsScript) { + if (lpmsScript->_command[i].type == 2) { + // Variable Assign + globalDestroy(lpmsScript->_command[i].lpszVarName); + freeExpression(lpmsScript->_command[i].expr); + } + } +} + /** * Parses a dialog from the MPC file, and inserts its data into a structure * @@ -428,6 +443,25 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { return lpBuf; } +/** + * Frees an item parsed from a prior call to ParseItem + * + * @param lpmiItem Pointer to an item structure + */ +static void freeItem(LPMPALITEM lpmiItem) { + // Free the actions + if (lpmiItem->Action) + globalDestroy(lpmiItem->Action); + + // Free the commands + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i, ++lpmiItem) { + if (lpmiItem->_command[i].type == 2) { + // Variable Assign + globalDestroy(lpmiItem->_command[i].lpszVarName); + freeExpression(lpmiItem->_command[i].expr); + } + } +} /** * Parses a location from the MPC file, and inserts its data into a structure @@ -651,6 +685,80 @@ bool ParseMpc(const byte *lpBuf) { return true; } +/** + * Free the given dialog + */ +static void freeDialog(LPMPALDIALOG lpmdDialog) { + // Free the periods + int i; + + for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) + globalFree(lpmdDialog->_periods[i]); + + for (i = 0; i < MAX_COMMANDS_PER_GROUP && (lpmdDialog->_command[i].type); i++) { + if (lpmdDialog->_command[i].type == 2) { + // Variable assign + globalDestroy(lpmdDialog->_command[i].lpszVarName); + freeExpression(lpmdDialog->_command[i].expr); + } + } +} + +/** + * Frees any data allocated from the parsing of the MPC file + */ +void FreeMpc() { + int i; + + // Free variables + globalFree(GLOBALS.hVars); + + // Free messages + LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); + for (i = 0; i < GLOBALS.nMsgs; i++, ++lpmmMsgs) + globalFree(lpmmMsgs->hText); + + globalUnlock(GLOBALS.hMsgs); + globalFree(GLOBALS.hMsgs); + + // Free objects + if (GLOBALS.hDialogs) { + LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + + for (i = 0; i < GLOBALS.nDialogs; i++, ++lpmdDialogs) + freeDialog(lpmdDialogs); + + globalFree(GLOBALS.hDialogs); + } + + // Free items + if (GLOBALS.hItems) { + LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + + for (i = 0; i < GLOBALS.nItems; ++i, ++lpmiItems) + freeItem(lpmiItems); + + globalUnlock(GLOBALS.hItems); + globalFree(GLOBALS.hItems); + } + + // Free the locations + if (GLOBALS.hLocations) { + globalFree(GLOBALS.hLocations); + } + + // Free the scripts + if (GLOBALS.hScripts) { + LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + + for (i = 0; i < GLOBALS.nScripts; ++i, ++lpmsScripts) { + FreeScript(lpmsScripts); + } + + globalUnlock(GLOBALS.hScripts); + } +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 2f8a1121ec..83463f0092 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -46,6 +46,10 @@ namespace MPAL { */ bool ParseMpc(const byte *lpBuf); +/** + * Frees any data allocated from the parsing of the MPC file + */ +void FreeMpc(); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 425fe187fc..04d562ffc9 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -803,7 +803,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { } MYTHREAD; CORO_BEGIN_CONTEXT; - // TODO: Requires endian fix uint32 *il; int i, j, k; int numitems; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e53177513a..7f7930c5d7 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -573,6 +573,7 @@ void TonyEngine::close(void) { _theBoxes.close(); _theEngine.close(); _window.close(); + FreeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3 From 1d5e59766fc1e6083921741a1ad270dd8d9363d1 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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 c52aca5ac407c498eb0a287697199a97f7c18bae Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Jun 2012 00:52:38 +0200 Subject: TONY: Rename more globals --- engines/tony/custom.cpp | 38 +++++++++---------- engines/tony/font.cpp | 12 +++--- engines/tony/game.cpp | 80 ++++++++++++++++++++-------------------- engines/tony/gfxcore.cpp | 6 +-- engines/tony/gfxengine.cpp | 92 +++++++++++++++++++++++----------------------- engines/tony/globals.cpp | 48 ++++++++++++------------ engines/tony/globals.h | 48 ++++++++++++------------ engines/tony/inventory.cpp | 30 +++++++-------- engines/tony/loc.cpp | 2 +- engines/tony/sound.cpp | 8 ++-- engines/tony/tony.cpp | 34 ++++++++--------- engines/tony/tonychar.cpp | 2 +- 12 files changed, 200 insertions(+), 200 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 810e6a9353..7482ac0db8 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -495,7 +495,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 n } DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bNoOcchioDiBue = true; + GLOBALS._bNoOcchioDiBue = true; } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -504,7 +504,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -526,7 +526,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -550,7 +550,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _vm->playMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); } - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { GLOBALS.InitWipe(2); } @@ -559,12 +559,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _ctx->h = mpalQueryDoAction(0, nLoc, 0); - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { CORO_INVOKE_0(GLOBALS.WaitWipeEnd); GLOBALS.CloseWipe(); } - GLOBALS.bNoOcchioDiBue = false; + GLOBALS._bNoOcchioDiBue = false; // On Enter? if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -2102,14 +2102,14 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeOut Music"); - for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS.bFadeOutStop; _ctx->i--) { + for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS._bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) _vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - if (!GLOBALS.bFadeOutStop) + if (!GLOBALS._bFadeOutStop) _vm->setMusicVolume(nChannel, 0); // If there is a stacchetto, stop all @@ -2124,16 +2124,16 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS.curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS._curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bFadeOutStop = false; - CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS.curSonoriz, sizeof(int)); + GLOBALS._bFadeOutStop = false; + CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS._curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bFadeOutStop = false; + GLOBALS._bFadeOutStop = false; int channel = 2; CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } @@ -2144,7 +2144,7 @@ DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(GLOBALS.curSonoriz); + _vm->stopMusic(GLOBALS._curSonoriz); } DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2152,12 +2152,12 @@ DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint } DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(GLOBALS.curSonoriz, 0); + _vm->setMusicVolume(GLOBALS._curSonoriz, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bFadeOutStop = true; - _vm->setMusicVolume(GLOBALS.curSonoriz, 64); + GLOBALS._bFadeOutStop = true; + _vm->setMusicVolume(GLOBALS._curSonoriz, 64); } DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2183,11 +2183,11 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX == 2) { debug("PlaySonoriz stop fadeout"); - GLOBALS.bFadeOutStop = true; + GLOBALS._bFadeOutStop = true; } GLOBALS.lastMusic = nMusic; - CustPlayMusic(GLOBALS.curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); + CustPlayMusic(GLOBALS._curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { @@ -2270,7 +2270,7 @@ DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uin } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.bPatIrqFreeze = bStatus; + GLOBALS._bPatIrqFreeze = bStatus; } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 398389ebcd..23a92c5f30 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1946,7 +1946,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { } if (time != NULL) - *time = 1000 + numchar * (11 - GLOBALS.nCfgTextSpeed) * 14; + *time = 1000 + numchar * (11 - GLOBALS._nCfgTextSpeed) * 14; } void RMText::clipOnScreen(RMGfxPrimitive *prim) { @@ -2075,8 +2075,8 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { // Don't erase the background if (_bSkipStatus) { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { - if (GLOBALS.bCfgTimerizedText) { + if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (GLOBALS._bCfgTimerizedText) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) return; @@ -2097,7 +2097,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { } } // Erase the background - else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + else if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) return; @@ -2117,7 +2117,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { return; } - if (GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { + if (GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) @@ -2145,7 +2145,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p _startTime = _vm->getTime(); if (_bShowed) { - if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { + if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) { prim->getDst().topLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 886b5f0859..f3aee0f183 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -673,57 +673,57 @@ void RMOptionScreen::initState(CORO_PARAM) { if (_nState == MENUGAME) { assert(_ButtonGame_Lock == NULL); _ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); - _ButtonGame_Lock->setActiveState(GLOBALS.bCfgInvLocked); + _ButtonGame_Lock->setActiveState(GLOBALS._bCfgInvLocked); assert(_ButtonGame_TimerizedText == NULL); _ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); - _ButtonGame_TimerizedText->setActiveState(!GLOBALS.bCfgTimerizedText); + _ButtonGame_TimerizedText->setActiveState(!GLOBALS._bCfgTimerizedText); assert(_ButtonGame_Scrolling == NULL); _ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - _ButtonGame_Scrolling->setActiveState(GLOBALS.bCfgInvNoScroll); + _ButtonGame_Scrolling->setActiveState(GLOBALS._bCfgInvNoScroll); assert(_ButtonGame_InterUp == NULL); _ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); - _ButtonGame_InterUp->setActiveState(GLOBALS.bCfgInvUp); + _ButtonGame_InterUp->setActiveState(GLOBALS._bCfgInvUp); assert(_SlideTextSpeed == NULL); - _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); + _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgTextSpeed); assert(_SlideTonySpeed == NULL); - _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); + _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS._nCfgTonySpeed); } // Menu Graphics else if (_nState == MENUGFX) { assert(_ButtonGfx_Anni30 == NULL); _ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); - _ButtonGfx_Anni30->setActiveState(GLOBALS.bCfgAnni30); + _ButtonGfx_Anni30->setActiveState(GLOBALS._bCfgAnni30); assert(_ButtonGfx_AntiAlias == NULL); _ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - _ButtonGfx_AntiAlias->setActiveState(!GLOBALS.bCfgAntiAlias); + _ButtonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); assert(_ButtonGfx_Sottotitoli == NULL); _ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS.bCfgSottotitoli); + _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); assert(_ButtonGfx_Tips == NULL); _ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); - _ButtonGfx_Tips->setActiveState(GLOBALS.bCfgInterTips); + _ButtonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); assert(_ButtonGfx_Trans == NULL); _ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); - _ButtonGfx_Trans->setActiveState(!GLOBALS.bCfgTransparence); + _ButtonGfx_Trans->setActiveState(!GLOBALS._bCfgTransparence); } else if (_nState == MENUSOUND) { assert(_SliderSound_Dubbing == NULL); - _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); + _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgDubbingVolume); assert(_SliderSound_Music == NULL); - _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); + _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS._nCfgMusicVolume); assert(_SliderSound_SFX == NULL); - _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); + _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS._nCfgSFXVolume); assert(_ButtonSound_DubbingOn == NULL); _ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - _ButtonSound_DubbingOn->setActiveState(GLOBALS.bCfgDubbing); + _ButtonSound_DubbingOn->setActiveState(GLOBALS._bCfgDubbing); assert(_ButtonSound_MusicOn == NULL); _ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); - _ButtonSound_MusicOn->setActiveState(GLOBALS.bCfgMusic); + _ButtonSound_MusicOn->setActiveState(GLOBALS._bCfgMusic); assert(_ButtonSound_SFXOn == NULL); _ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); - _ButtonSound_SFXOn->setActiveState(GLOBALS.bCfgSFX); + _ButtonSound_SFXOn->setActiveState(GLOBALS._bCfgSFX); } } @@ -789,71 +789,71 @@ void RMOptionScreen::closeState(void) { } if (_nState == MENUGAME) { - GLOBALS.bCfgInvLocked = _ButtonGame_Lock->isActive(); + GLOBALS._bCfgInvLocked = _ButtonGame_Lock->isActive(); delete _ButtonGame_Lock; _ButtonGame_Lock = NULL; - GLOBALS.bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); + GLOBALS._bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); delete _ButtonGame_TimerizedText; _ButtonGame_TimerizedText = NULL; - GLOBALS.bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); + GLOBALS._bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); delete _ButtonGame_Scrolling; _ButtonGame_Scrolling = NULL; - GLOBALS.bCfgInvUp = _ButtonGame_InterUp->isActive(); + GLOBALS._bCfgInvUp = _ButtonGame_InterUp->isActive(); delete _ButtonGame_InterUp; _ButtonGame_InterUp = NULL; - GLOBALS.nCfgTextSpeed = _SlideTextSpeed->getValue(); + GLOBALS._nCfgTextSpeed = _SlideTextSpeed->getValue(); delete _SlideTextSpeed; _SlideTextSpeed = NULL; - GLOBALS.nCfgTonySpeed = _SlideTonySpeed->getValue(); + GLOBALS._nCfgTonySpeed = _SlideTonySpeed->getValue(); delete _SlideTonySpeed; _SlideTonySpeed = NULL; } else if (_nState == MENUGFX) { - GLOBALS.bCfgAnni30 = _ButtonGfx_Anni30->isActive(); + GLOBALS._bCfgAnni30 = _ButtonGfx_Anni30->isActive(); delete _ButtonGfx_Anni30; _ButtonGfx_Anni30 = NULL; - GLOBALS.bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); + GLOBALS._bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); delete _ButtonGfx_AntiAlias; _ButtonGfx_AntiAlias = NULL; - GLOBALS.bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); + GLOBALS._bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); delete _ButtonGfx_Sottotitoli; _ButtonGfx_Sottotitoli = NULL; - GLOBALS.bCfgInterTips = _ButtonGfx_Tips->isActive(); + GLOBALS._bCfgInterTips = _ButtonGfx_Tips->isActive(); delete _ButtonGfx_Tips; _ButtonGfx_Tips = NULL; - GLOBALS.bCfgTransparence = !_ButtonGfx_Trans->isActive(); + GLOBALS._bCfgTransparence = !_ButtonGfx_Trans->isActive(); delete _ButtonGfx_Trans; _ButtonGfx_Trans = NULL; } else if (_nState == MENUSOUND) { - GLOBALS.nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); + GLOBALS._nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); delete _SliderSound_Dubbing; _SliderSound_Dubbing = NULL; - GLOBALS.nCfgMusicVolume = _SliderSound_Music->getValue(); + GLOBALS._nCfgMusicVolume = _SliderSound_Music->getValue(); delete _SliderSound_Music; _SliderSound_Music = NULL; - GLOBALS.nCfgSFXVolume = _SliderSound_SFX->getValue(); + GLOBALS._nCfgSFXVolume = _SliderSound_SFX->getValue(); delete _SliderSound_SFX; _SliderSound_SFX = NULL; - GLOBALS.bCfgDubbing = _ButtonSound_DubbingOn->isActive(); + GLOBALS._bCfgDubbing = _ButtonSound_DubbingOn->isActive(); delete _ButtonSound_DubbingOn; _ButtonSound_DubbingOn = NULL; - GLOBALS.bCfgMusic = _ButtonSound_MusicOn->isActive(); + GLOBALS._bCfgMusic = _ButtonSound_MusicOn->isActive(); delete _ButtonSound_MusicOn; _ButtonSound_MusicOn = NULL; - GLOBALS.bCfgSFX = _ButtonSound_SFXOn->isActive(); + GLOBALS._bCfgSFX = _ButtonSound_SFXOn->isActive(); delete _ButtonSound_SFXOn; _ButtonSound_SFXOn = NULL; } @@ -1246,19 +1246,19 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { if (_nState == MENUGFX) { // These options take effect immediately if (_ButtonGfx_Anni30->isActive()) - GLOBALS.bCfgAnni30 = true; + GLOBALS._bCfgAnni30 = true; else - GLOBALS.bCfgAnni30 = false; + GLOBALS._bCfgAnni30 = false; if (_ButtonGfx_AntiAlias->isActive()) - GLOBALS.bCfgAntiAlias = false; + GLOBALS._bCfgAntiAlias = false; else - GLOBALS.bCfgAntiAlias = true; + GLOBALS._bCfgAntiAlias = true; if (_ButtonGfx_Trans->isActive()) - GLOBALS.bCfgTransparence = false; + GLOBALS._bCfgTransparence = false; else - GLOBALS.bCfgTransparence = true; + GLOBALS._bCfgTransparence = true; } } } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 09b102db11..fdc435e3e9 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1390,7 +1390,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int int i, n; int r, g, b, r2, g2, b2; - if (!GLOBALS.bCfgTransparence) { + if (!GLOBALS._bCfgTransparence) { RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); return; } @@ -1751,7 +1751,7 @@ void RMGfxSourceBuffer8RLEByteAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); - if (GLOBALS.bCfgAntiAlias) + if (GLOBALS._bCfgAntiAlias) drawAA(bigBuf, prim); CORO_END_CODE; @@ -1789,7 +1789,7 @@ void RMGfxSourceBuffer8RLEWordAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); - if (GLOBALS.bCfgAntiAlias) + if (GLOBALS._bCfgAntiAlias) drawAA(bigBuf, prim); CORO_END_CODE; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e61e6a8b84..801b4d35fb 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -49,12 +49,12 @@ void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Closes idle - GLOBALS.bSkipSfxNoLoop = true; + GLOBALS._bSkipSfxNoLoop = true; CORO_INVOKE_2(mpalEndIdlePoll, nCurLoc, NULL); - GLOBALS.bIdleExited = true; - GLOBALS.bSkipSfxNoLoop = false; + GLOBALS._bIdleExited = true; + GLOBALS._bSkipSfxNoLoop = false; CORO_END_CODE; } @@ -124,11 +124,11 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { // Exists the IDLE to avoid premature death in loading _bMustEnterMenu = true; if (type == 1 || type == 2) { - GLOBALS.bIdleExited = true; + GLOBALS._bIdleExited = true; } else { CORO_INVOKE_0(_tony.stopNoAction); - GLOBALS.bIdleExited = false; + GLOBALS._bIdleExited = false; CoroScheduler.createProcess(ExitAllIdles, &_nCurLoc, sizeof(int)); } @@ -148,10 +148,10 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Poll of input devices _input.poll(); - if (_bMustEnterMenu && GLOBALS.bIdleExited) { + if (_bMustEnterMenu && GLOBALS._bIdleExited) { _bOption = true; _bMustEnterMenu = false; - GLOBALS.bIdleExited = false; + GLOBALS._bIdleExited = false; } if (_bOption) { @@ -365,10 +365,10 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { item = GLOBALS.GfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { - if (GLOBALS.bPatIrqFreeze) + if (GLOBALS._bPatIrqFreeze) mainFreeze(); item->setPattern(nPattern, true); - if (GLOBALS.bPatIrqFreeze) + if (GLOBALS._bPatIrqFreeze) mainUnfreeze(); } if (nStatus != -1) @@ -479,16 +479,16 @@ void RMGfxEngine::init() { _vm->_window.getNewFrame(*this, NULL); _vm->_window.repaint(); - GLOBALS.bPatIrqFreeze = true; + GLOBALS._bPatIrqFreeze = true; // Activate GUI _bGUIOption = true; _bGUIInterface = true; _bGUIInventory = true; - GLOBALS.bSkipSfxNoLoop = false; + GLOBALS._bSkipSfxNoLoop = false; _bMustEnterMenu = false; - GLOBALS.bIdleExited = false; + GLOBALS._bIdleExited = false; _bOption = false; _bWiping = false; _hWipeEvent = CoroScheduler.createEvent(false, false); @@ -652,23 +652,23 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm CharsSaveAll(f); // Save the options - f->writeByte(GLOBALS.bCfgInvLocked); - f->writeByte(GLOBALS.bCfgInvNoScroll); - f->writeByte(GLOBALS.bCfgTimerizedText); - f->writeByte(GLOBALS.bCfgInvUp); - f->writeByte(GLOBALS.bCfgAnni30); - f->writeByte(GLOBALS.bCfgAntiAlias); - f->writeByte(GLOBALS.bCfgSottotitoli); - f->writeByte(GLOBALS.bCfgTransparence); - f->writeByte(GLOBALS.bCfgInterTips); - f->writeByte(GLOBALS.bCfgDubbing); - f->writeByte(GLOBALS.bCfgMusic); - f->writeByte(GLOBALS.bCfgSFX); - f->writeByte(GLOBALS.nCfgTonySpeed); - f->writeByte(GLOBALS.nCfgTextSpeed); - f->writeByte(GLOBALS.nCfgDubbingVolume); - f->writeByte(GLOBALS.nCfgMusicVolume); - f->writeByte(GLOBALS.nCfgSFXVolume); + f->writeByte(GLOBALS._bCfgInvLocked); + f->writeByte(GLOBALS._bCfgInvNoScroll); + f->writeByte(GLOBALS._bCfgTimerizedText); + f->writeByte(GLOBALS._bCfgInvUp); + f->writeByte(GLOBALS._bCfgAnni30); + f->writeByte(GLOBALS._bCfgAntiAlias); + f->writeByte(GLOBALS._bCfgSottotitoli); + f->writeByte(GLOBALS._bCfgTransparence); + f->writeByte(GLOBALS._bCfgInterTips); + f->writeByte(GLOBALS._bCfgDubbing); + f->writeByte(GLOBALS._bCfgMusic); + f->writeByte(GLOBALS._bCfgSFX); + f->writeByte(GLOBALS._nCfgTonySpeed); + f->writeByte(GLOBALS._nCfgTextSpeed); + f->writeByte(GLOBALS._nCfgDubbingVolume); + f->writeByte(GLOBALS._nCfgMusicVolume); + f->writeByte(GLOBALS._nCfgSFXVolume); // Save the hotspots SaveChangedHotspot(f); @@ -788,23 +788,23 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { if (_ctx->ver >= 6) { // Load options - GLOBALS.bCfgInvLocked = _ctx->f->readByte(); - GLOBALS.bCfgInvNoScroll = _ctx->f->readByte(); - GLOBALS.bCfgTimerizedText = _ctx->f->readByte(); - GLOBALS.bCfgInvUp = _ctx->f->readByte(); - GLOBALS.bCfgAnni30 = _ctx->f->readByte(); - GLOBALS.bCfgAntiAlias = _ctx->f->readByte(); - GLOBALS.bCfgSottotitoli = _ctx->f->readByte(); - GLOBALS.bCfgTransparence = _ctx->f->readByte(); - GLOBALS.bCfgInterTips = _ctx->f->readByte(); - GLOBALS.bCfgDubbing = _ctx->f->readByte(); - GLOBALS.bCfgMusic = _ctx->f->readByte(); - GLOBALS.bCfgSFX = _ctx->f->readByte(); - GLOBALS.nCfgTonySpeed = _ctx->f->readByte(); - GLOBALS.nCfgTextSpeed = _ctx->f->readByte(); - GLOBALS.nCfgDubbingVolume = _ctx->f->readByte(); - GLOBALS.nCfgMusicVolume = _ctx->f->readByte(); - GLOBALS.nCfgSFXVolume = _ctx->f->readByte(); + GLOBALS._bCfgInvLocked = _ctx->f->readByte(); + GLOBALS._bCfgInvNoScroll = _ctx->f->readByte(); + GLOBALS._bCfgTimerizedText = _ctx->f->readByte(); + GLOBALS._bCfgInvUp = _ctx->f->readByte(); + GLOBALS._bCfgAnni30 = _ctx->f->readByte(); + GLOBALS._bCfgAntiAlias = _ctx->f->readByte(); + GLOBALS._bCfgSottotitoli = _ctx->f->readByte(); + GLOBALS._bCfgTransparence = _ctx->f->readByte(); + GLOBALS._bCfgInterTips = _ctx->f->readByte(); + GLOBALS._bCfgDubbing = _ctx->f->readByte(); + GLOBALS._bCfgMusic = _ctx->f->readByte(); + GLOBALS._bCfgSFX = _ctx->f->readByte(); + GLOBALS._nCfgTonySpeed = _ctx->f->readByte(); + GLOBALS._nCfgTextSpeed = _ctx->f->readByte(); + GLOBALS._nCfgDubbingVolume = _ctx->f->readByte(); + GLOBALS._nCfgMusicVolume = _ctx->f->readByte(); + GLOBALS._nCfgSFXVolume = _ctx->f->readByte(); // Load hotspots LoadChangedHotspot(_ctx->f); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 37a5a20454..6f81e81a48 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -59,31 +59,31 @@ Globals::Globals() { dwTonyNumTexts = 0; bTonyInTexts = false; bStaticTalk = false; - bPatIrqFreeze = false; - bCfgInvLocked = false; - bCfgInvNoScroll = false; - bCfgTimerizedText = false; - bCfgInvUp = false; - bCfgAnni30 = false; - bCfgAntiAlias = false; - bCfgSottotitoli = false; - bCfgTransparence = false; - bCfgInterTips = false; - bCfgDubbing = false; - bCfgMusic = false; - bCfgSFX = false; + _bPatIrqFreeze = false; + _bCfgInvLocked = false; + _bCfgInvNoScroll = false; + _bCfgTimerizedText = false; + _bCfgInvUp = false; + _bCfgAnni30 = false; + _bCfgAntiAlias = false; + _bCfgSottotitoli = false; + _bCfgTransparence = false; + _bCfgInterTips = false; + _bCfgDubbing = false; + _bCfgMusic = false; + _bCfgSFX = false; _bAlwaysDisplay = false; - nCfgTonySpeed = 0; - nCfgTextSpeed = 0; - nCfgDubbingVolume = 0; - nCfgMusicVolume = 0; - nCfgSFXVolume = 0; - bIdleExited = false; - bSkipSfxNoLoop = false; - bNoOcchioDiBue = false; - curDialog = 0; - curSonoriz = 0; - bFadeOutStop = false; + _nCfgTonySpeed = 0; + _nCfgTextSpeed = 0; + _nCfgDubbingVolume = 0; + _nCfgMusicVolume = 0; + _nCfgSFXVolume = 0; + _bIdleExited = false; + _bSkipSfxNoLoop = false; + _bNoOcchioDiBue = false; + _curDialog = 0; + _curSonoriz = 0; + _bFadeOutStop = false; // OSystem::MutexRef vdb; Common::fill(&mut[0], &mut[10], 0); diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 84c5d7398c..a675066bc1 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -187,30 +187,30 @@ public: RMTextDialog *_curBackText; bool _bTonyIsSpeaking; int _curChangedHotspot; - bool bPatIrqFreeze; - bool bCfgInvLocked; - bool bCfgInvNoScroll; - bool bCfgTimerizedText; - bool bCfgInvUp; - bool bCfgAnni30; - bool bCfgAntiAlias; - bool bCfgSottotitoli; - bool bCfgTransparence; - bool bCfgInterTips; - bool bCfgDubbing; - bool bCfgMusic; - bool bCfgSFX; - int nCfgTonySpeed; - int nCfgTextSpeed; - int nCfgDubbingVolume; - int nCfgMusicVolume; - int nCfgSFXVolume; - bool bSkipSfxNoLoop; - bool bIdleExited; - bool bNoOcchioDiBue; - int curDialog; - int curSonoriz; - bool bFadeOutStop; + bool _bPatIrqFreeze; + bool _bCfgInvLocked; + bool _bCfgInvNoScroll; + bool _bCfgTimerizedText; + bool _bCfgInvUp; + bool _bCfgAnni30; + bool _bCfgAntiAlias; + bool _bCfgSottotitoli; + bool _bCfgTransparence; + bool _bCfgInterTips; + bool _bCfgDubbing; + bool _bCfgMusic; + bool _bCfgSFX; + int _nCfgTonySpeed; + int _nCfgTextSpeed; + int _nCfgDubbingVolume; + int _nCfgMusicVolume; + int _nCfgSFXVolume; + bool _bSkipSfxNoLoop; + bool _bIdleExited; + bool _bNoOcchioDiBue; + int _curDialog; + int _curSonoriz; + bool _bFadeOutStop; RMTony *Tony; RMPointer *Pointer; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index bbc74afa01..162443d0bd 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -65,7 +65,7 @@ RMInventory::~RMInventory() { } bool RMInventory::checkPointInside(const RMPoint &pt) { - if (!GLOBALS.bCfgInvUp) + if (!GLOBALS._bCfgInvUp) return pt.y > RM_SY - 70; else return pt.y < 70; @@ -201,7 +201,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_state == SELECTING) { - if (!GLOBALS.bCfgInvUp) { + if (!GLOBALS._bCfgInvUp) { _ctx->pos.set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); _ctx->pos2.set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { @@ -215,7 +215,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr // Draw the mini interface CORO_INVOKE_2(miniInterface.draw, bigBuf, _ctx->p); - if (GLOBALS.bCfgInterTips) { + if (GLOBALS._bCfgInterTips) { if (miniAction == 1) // Examine CORO_INVOKE_2(_hints[0].draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Talk @@ -531,7 +531,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { - GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; + GLOBALS._bCfgInvLocked = !GLOBALS._bCfgInvLocked; } if (_bCombining) {//m_state == COMBINING) @@ -539,9 +539,9 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } - if (!GLOBALS.bCfgInvUp) { - if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if (!GLOBALS._bCfgInvUp) { + if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = RM_SY - 1; _curPutTime = _vm->getTime(); @@ -550,8 +550,8 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = RM_SY - 68; } } else if (_state == OPENED) { - if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if ((mpos.y < RM_SY - 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = RM_SY - 68; _curPutTime = _vm->getTime(); @@ -580,8 +580,8 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _state = CLOSED; } } else { - if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = - 68; _curPutTime = _vm->getTime(); @@ -590,8 +590,8 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = 0; } } else if (_state == OPENED) { - if ((mpos.y > 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if ((mpos.y > 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = -2; _curPutTime = _vm->getTime(); @@ -624,7 +624,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo int startx = (_nSelectObj + 1) * 64 - 20; int starty; - if (!GLOBALS.bCfgInvUp) + if (!GLOBALS._bCfgInvUp) starty = RM_SY - 109; else starty = 70; @@ -802,7 +802,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _vm->playUtilSFX(1); } - if (GLOBALS.bCfgInterTips) { + if (GLOBALS._bCfgInterTips) { prim->getDst().topLeft() = _openStart + RMPoint(70, 177); CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index afde5403b5..146ca65533 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -146,7 +146,7 @@ void RMPattern::stopSfx(RMSfx *sfx) { if (_slots[i]._type == SOUND) { if (sfx[_slots[i]._data]._name[0] == '_') sfx[_slots[i]._data].stop(); - else if (GLOBALS.bSkipSfxNoLoop) + else if (GLOBALS._bSkipSfxNoLoop) sfx[_slots[i]._data].stop(); } } diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 93b5e90706..6d9eaf350b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1492,15 +1492,15 @@ void FPSFX::SetVolume(int dwVolume) { lastVolume = dwVolume; if (bIsVoice) { - if (!GLOBALS.bCfgDubbing) dwVolume = 0; + if (!GLOBALS._bCfgDubbing) dwVolume = 0; else { - dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; + dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } else { - if (!GLOBALS.bCfgSFX) dwVolume = 0; + if (!GLOBALS._bCfgSFX) dwVolume = 0; else { - dwVolume -= (10 - GLOBALS.nCfgSFXVolume) * 2; + dwVolume -= (10 - GLOBALS._nCfgSFXVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 7f7930c5d7..eab52c6b4b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -153,23 +153,23 @@ Common::ErrorCode TonyEngine::init() { _curThumbnail = new uint16[160 * 120]; // Set up global defaults - GLOBALS.bCfgInvLocked = false; - GLOBALS.bCfgInvNoScroll = false; - GLOBALS.bCfgTimerizedText = true; - GLOBALS.bCfgInvUp = false; - GLOBALS.bCfgAnni30 = false; - GLOBALS.bCfgAntiAlias = false; - GLOBALS.bCfgTransparence = true; - GLOBALS.bCfgInterTips = true; - GLOBALS.bCfgSottotitoli = true; - GLOBALS.nCfgTonySpeed = 3; - GLOBALS.nCfgTextSpeed = 5; - GLOBALS.bCfgDubbing = true; - GLOBALS.bCfgMusic = true; - GLOBALS.bCfgSFX = true; - GLOBALS.nCfgDubbingVolume = 10; - GLOBALS.nCfgMusicVolume = 7; - GLOBALS.nCfgSFXVolume = 10; + GLOBALS._bCfgInvLocked = false; + GLOBALS._bCfgInvNoScroll = false; + GLOBALS._bCfgTimerizedText = true; + GLOBALS._bCfgInvUp = false; + GLOBALS._bCfgAnni30 = false; + GLOBALS._bCfgAntiAlias = false; + GLOBALS._bCfgTransparence = true; + GLOBALS._bCfgInterTips = true; + GLOBALS._bCfgSottotitoli = true; + GLOBALS._nCfgTonySpeed = 3; + GLOBALS._nCfgTextSpeed = 5; + GLOBALS._bCfgDubbing = true; + GLOBALS._bCfgMusic = true; + GLOBALS._bCfgSFX = true; + GLOBALS._nCfgDubbingVolume = 10; + GLOBALS._nCfgMusicVolume = 7; + GLOBALS._nCfgSFXVolume = 10; _bQuitNow = false; return Common::kNoError; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 9f34276c41..a63d2d69c3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -138,7 +138,7 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { if (!_nInList && _bShow) bigBuf->addPrim(new RMGfxPrimitive(this)); - setSpeed(GLOBALS.nCfgTonySpeed); + setSpeed(GLOBALS._nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->getTime(); -- cgit v1.2.3 From dd8b4b519a2a61e010d9aa4d71b5f123dfeffc6b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 10:44:51 +1000 Subject: TONY: Added more freeing of MPC data when the game ends --- engines/tony/mpal/loadmpc.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index aa048c0b2f..e222891170 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -690,7 +690,7 @@ bool ParseMpc(const byte *lpBuf) { */ static void freeDialog(LPMPALDIALOG lpmdDialog) { // Free the periods - int i; + int i, j; for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); @@ -702,6 +702,14 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { freeExpression(lpmdDialog->_command[i].expr); } } + + // Free the choices + for (i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { + for (j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { + if (lpmdDialog->_choice[i]._select[j].when) + freeExpression(lpmdDialog->_choice[i]._select[j].when); + } + } } /** -- cgit v1.2.3 From 5e062ce86c87c0253fc237c6c26ed9d9293ef571 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 11:57:07 +1000 Subject: TONY: Properly free items during loading when there is duplicates --- engines/tony/mpal/loadmpc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index e222891170..bb2c999984 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -421,6 +421,16 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; + + // Free any data allocated for the duplictaed command + if (lpmiItem->_command[curCmd].type == 2) { + globalDestroy(lpmiItem->_command[curCmd].lpszVarName); + freeExpression(lpmiItem->_command[curCmd].expr); + + lpmiItem->_command[curCmd].lpszVarName = NULL; + lpmiItem->_command[curCmd].expr = 0; + lpmiItem->_command[curCmd].type = 0; + } break; } } -- cgit v1.2.3 From 8d6f50463ee0541e2d4609f80443537adefdd35e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 12:29:34 +1000 Subject: TONY: Properly free dialog commands during loading when there is duplicates --- engines/tony/mpal/loadmpc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index bb2c999984..d0b6a75f72 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -238,6 +238,16 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { lpmdDialog->_group[i].CmdNum[j] = kk; + + // Free any data allocated for the duplictaed command + if (lpmdDialog->_command[curCmd].type == 2) { + globalDestroy(lpmdDialog->_command[curCmd].lpszVarName); + freeExpression(lpmdDialog->_command[curCmd].expr); + + lpmdDialog->_command[curCmd].lpszVarName = NULL; + lpmdDialog->_command[curCmd].expr = 0; + lpmdDialog->_command[curCmd].type = 0; + } break; } } -- cgit v1.2.3 From a50b1f32c1de667cd2d73535b07e62b000cf4483 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 13:05:48 +1000 Subject: TONY: Fixes for deallocating MPC and MPAL data --- engines/tony/mpal/loadmpc.cpp | 12 +++++++++--- engines/tony/mpal/mpal.cpp | 7 +++++++ engines/tony/mpal/mpal.h | 4 ++++ engines/tony/tony.cpp | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index d0b6a75f72..1f610a8d2c 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -470,11 +470,17 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { */ static void freeItem(LPMPALITEM lpmiItem) { // Free the actions - if (lpmiItem->Action) + if (lpmiItem->Action) { + for (int i = 0; i < lpmiItem->nActions; ++i) { + if (lpmiItem->Action[i].when != 0) + freeExpression(lpmiItem->Action[i].when); + } + globalDestroy(lpmiItem->Action); + } // Free the commands - for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i, ++lpmiItem) { + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i) { if (lpmiItem->_command[i].type == 2) { // Variable Assign globalDestroy(lpmiItem->_command[i].lpszVarName); @@ -715,7 +721,7 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (i = 0; i < MAX_COMMANDS_PER_GROUP && (lpmdDialog->_command[i].type); i++) { + for (i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { if (lpmdDialog->_command[i].type == 2) { // Variable assign globalDestroy(lpmdDialog->_command[i].lpszVarName); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 04d562ffc9..4aac53bb8e 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1548,6 +1548,13 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return true; } +/** + * Frees resources allocated by the MPAL subsystem + */ +void mpalFree() { + // Free the resource list + globalDestroy(GLOBALS.lpResources); +} /** * This is a general function to communicate with the library, to request information diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index f23eaf8e4a..198083f851 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -402,6 +402,10 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); +/** + * Frees resources allocated by the MPAL subsystem + */ +void mpalFree(); /** * This is a general function to communicate with the library, to request information diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index eab52c6b4b..a66e7b0684 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -573,6 +573,7 @@ void TonyEngine::close(void) { _theBoxes.close(); _theEngine.close(); _window.close(); + mpalFree(); FreeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3 From 10621fded8eee2da03a2a9f93bfa1546bcb7c748 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 17:51:58 +1000 Subject: TONY: Fix some calls from globalFree to globalDestroy --- engines/tony/custom.cpp | 2 +- engines/tony/mpal/mpal.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 7482ac0db8..858479ca7f 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1949,7 +1949,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } - globalFree(_ctx->string); + globalDestroy(_ctx->string); CORO_END_CODE; } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 4aac53bb8e..9f9a4c203b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -911,7 +911,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { unlockItems(); /* We don't need the item list anymore */ - globalFree(_ctx->il); + globalDestroy(_ctx->il); /* Here's the main loop */ @@ -2108,7 +2108,7 @@ int mpalLoadState(byte *buf) { GLOBALS.nVars = READ_LE_UINT32(buf); - GLOBALS.hVars = globalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); + GLOBALS.hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); lockVar(); copyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); unlockVar(); -- cgit v1.2.3 From da39f4d758f0952e207665244023d2f3f91c6c6e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 17:52:42 +1000 Subject: TONY: Fix the dialogs displayed for the different function keys --- engines/tony/gfxengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 801b4d35fb..4bfdc1333f 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -216,10 +216,10 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { else if (!_vm->getIsDemo()) { if (_input.getAsyncKeyState(Common::KEYCODE_F3) || _input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen - CORO_INVOKE_1(openOptionScreen, 3); + CORO_INVOKE_1(openOptionScreen, 4); else if (_input.getAsyncKeyState(Common::KEYCODE_F2) || _input.getAsyncKeyState(Common::KEYCODE_F7)) // Load game screen - CORO_INVOKE_1(openOptionScreen, 4); + CORO_INVOKE_1(openOptionScreen, 3); } } } -- cgit v1.2.3 From 7758b1a432fcd31e5e608cb7720225f7a0cc633c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 22:14:38 +1000 Subject: TONY: Fix operation of TakeOwnership/ReleaseOwnership --- engines/tony/custom.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 858479ca7f..6db6d5f858 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2043,12 +2043,25 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.waitForSingleObject(coroParam, GLOBALS.mut[num], CORO_INFINITE); + CORO_BEGIN_CONTEXT; + bool expired; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + // The event is operating as a mutex, so if the event is already set, wait until it's reset + do { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.mut[num], 0, &_ctx->expired); + } while (!_ctx->expired); + + // Set the event to flag ownership + CoroScheduler.setEvent(GLOBALS.mut[num]); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.pulseEvent(GLOBALS.mut[num]); - warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); + CoroScheduler.resetEvent(GLOBALS.mut[num]); } /* -- cgit v1.2.3 From 4a3518dc92762cbcd8bda8786c975af021564b37 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 22:20:16 +1000 Subject: TONY: Fix data freeing in LocationPollThread --- engines/tony/mpal/mpal.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 9f9a4c203b..5a4310c15b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -866,7 +866,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); if (_ctx->MyThreads == NULL) { - globalFree(_ctx->il); + globalDestroy(_ctx->il); CORO_KILL_SELF(); return; } @@ -876,8 +876,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { Now we created the mirrored copies of the idle actions. */ _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { - globalFree(_ctx->MyThreads); - globalFree(_ctx->il); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->il); CORO_KILL_SELF(); return; } @@ -981,8 +981,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ok, we can perform the action. For convenience, we do it in a new process */ _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { - globalFree(_ctx->MyThreads); - globalFree(_ctx->MyActions); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->MyActions); CORO_KILL_SELF(); return; @@ -1006,9 +1006,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) - globalFree(_ctx->newItem); - globalFree(_ctx->MyThreads); - globalFree(_ctx->MyActions); + globalDestroy(_ctx->newItem); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->MyActions); CORO_KILL_SELF(); return; @@ -1039,8 +1039,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); /* We're finished */ - globalFree(_ctx->MyThreads); - globalFree(_ctx->MyActions); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->MyActions); CORO_KILL_SELF(); -- cgit v1.2.3 From 060449042a532e6cd7319ea36376021d76dde470 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 17:31:18 -0400 Subject: TONY: Silence some gcc warnings --- engines/tony/loc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 146ca65533..61271d7f39 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1226,10 +1226,10 @@ short RMCharacter::scanLine(const RMPoint &punto) { Lcount++; if (Lstatus) { Ldx = Lspeed * Lcount; - Ldy = Lslope * Ldx; + Ldy = (int)(Lslope * Ldx); } else { Ldy = Lspeed * Lcount; - Ldx = Lslope * Ldy; + Ldx = (int)(Lslope * Ldy); } Lscan.x = Lstart.x + Ldx; @@ -1285,10 +1285,10 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { Lcount++; if (Lstatus) { Ldx = Lspeed * Lcount; - Ldy = Lslope * Ldx; + Ldy = (int)(Lslope * Ldx); } else { Ldy = Lspeed * Lcount; - Ldx = Lslope * Ldy; + Ldx = (int)(Lslope * Ldy); } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; @@ -1402,7 +1402,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // If we are going horizontally if (walkstatus == 1) { dx = walkspeed * walkcount; - dy = slope * dx; + dy = (int)(slope * dx); _pos.x = linestart.x + dx; _pos.y = linestart.y + dy; @@ -1417,7 +1417,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; - dx = slope * dy; + dx = (int)(slope * dy); _pos.x = linestart.x + dx; _pos.y = linestart.y + dy; -- cgit v1.2.3 From 9b3df4de21d96324a2b9fcf8a16bf133188afccd Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 18:09:54 -0400 Subject: TONY: Rework the way wave files are loaded We'll let our own sound code take care of the RIFF header --- engines/tony/loc.cpp | 24 ++++++------------------ engines/tony/sound.cpp | 10 ++++------ engines/tony/sound.h | 5 ++--- engines/tony/tony.cpp | 4 ++-- engines/tony/tony.h | 2 +- 5 files changed, 15 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 61271d7f39..ac238193e0 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -26,6 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ +#include "common/memstream.h" #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" #include "tony/adv.h" @@ -394,34 +395,21 @@ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { } void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { - char id[4]; int size; - byte *raw; // sfx name ds >> _name; ds >> size; - // Upload the sound effect identifier from the buffer - ds.read(id, 4); - - // Ensure it's a RIFF - assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); - - // Read the size - ds >> size; - - // Read the raw WAV data - raw = new byte[size]; - ds.read(raw, size); + // Read the entire buffer into a MemoryReadStream + byte *buffer = (byte *)malloc(size); + ds.read(buffer, size); + Common::SeekableReadStream *stream = new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); // Create the sound effect - _fx = _vm->createSFX(raw); + _fx = _vm->createSFX(stream); _fx->SetLoop(false); - - // Close the read buffer which is no longer needed - delete[] raw; } RMSfx::RMSfx() { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 6d9eaf350b..df633e3be2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1062,7 +1062,7 @@ void FPSFX::Release() { /****************************************************************************\ * -* Function: bool LoadFile(byte *lpBuf); +* Function: bool loadWave(Common::SeekableReadStream *stream); * * Description: Apre un file di effetto sonoro e lo carica. * @@ -1074,7 +1074,7 @@ void FPSFX::Release() { * \****************************************************************************/ -bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { +bool FPSFX::loadWave(Common::SeekableReadStream *stream) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; @@ -1096,10 +1096,6 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { if (!bSoundSupported) return true; - /* Nel buffer troviamo un file WAV completo, almeno per ora */ - if (dwCodec != FPCODEC_WAV) - return false; - if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') return false; if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') @@ -1158,6 +1154,8 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { bFileLoaded = true; #endif + + delete stream; // Just so we don't leak it return true; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 7defeb1149..8be1fb42f5 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -50,8 +50,7 @@ class CODEC; enum CODECS { FPCODEC_RAW, - FPCODEC_ADPCM, - FPCODEC_WAV + FPCODEC_ADPCM }; @@ -288,7 +287,7 @@ public: \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); - bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool loadWave(Common::SeekableReadStream *stream); bool LoadVoiceFromVDB(Common::File &vdbFP); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a66e7b0684..0c0bcf331a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -332,11 +332,11 @@ void TonyEngine::preloadSFX(int nChannel, const char *fn) { _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::createSFX(byte *buf) { +FPSFX *TonyEngine::createSFX(Common::SeekableReadStream *stream) { FPSFX *sfx; _theSound.CreateSfx(&sfx); - sfx->LoadFile(buf, FPCODEC_WAV); + sfx->loadWave(stream); return sfx; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 68730fa91b..cee15d07a4 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -188,7 +188,7 @@ public: void playUtilSFX(int nSfx, int nFX = 0); void stopUtilSFX(int nSfx); - FPSFX *createSFX(byte *buf); + FPSFX *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); void unloadAllSFX(void); -- cgit v1.2.3 From 05340fa4ca300794d73436fd2456af9ffd8307f0 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 18:14:18 -0400 Subject: TONY: Remove custom sound CODEC classes We already have our own raw PCM and IMA ADPCM classes that we will use --- engines/tony/sound.cpp | 685 ------------------------------------------------- 1 file changed, 685 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index df633e3be2..450384b341 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -37,693 +37,8 @@ namespace Tony { * Defines \****************************************************************************/ -/* Massimo numero di bytes da decodificare in una singola chiamata a CODEC */ -#define MAXDECODESIZE (44100 * 2 * 2) - #define RELEASE(x) {if ((x) != NULL) { (x)->Release(); x = NULL; }} -/****************************************************************************\ -***************************************************************************** -* class CODEC (ABSTRACT) -* ----------- -* Description: classe base per CODEC. -***************************************************************************** -\****************************************************************************/ - -class CODEC { -protected: - bool bEndReached; - -public: - bool bLoop; - CODEC(bool bLoop = true); - virtual ~CODEC(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; - virtual void LoopReset() = 0; - bool EndOfStream(); -}; - - -/****************************************************************************\ -***************************************************************************** -* class CODECRAW -* -------------- -* Description: CODEC di play da disco di campioni puri -***************************************************************************** -\****************************************************************************/ - -class CODECRAW : public CODEC { -public: - CODECRAW(bool bLoop = true); - virtual ~CODECRAW(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); - virtual void LoopReset(); -}; - - -/****************************************************************************\ -***************************************************************************** -* class CODECADPCM -* ---------------- -* Description: CODEC per play di compressione ADPCM -***************************************************************************** -\****************************************************************************/ - -class CODECADPCM : public CODECRAW { -protected: - byte *lpTemp; - static const int indexTable[16]; - static const int stepSizeTable[89]; - -public: - CODECADPCM(bool bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCM(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; - virtual void LoopReset() = 0; -}; - -class CODECADPCMSTEREO : public CODECADPCM { -protected: - int valpred[2], index[2]; - -public: - CODECADPCMSTEREO(bool bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMSTEREO(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); - virtual void LoopReset(); -}; - -class CODECADPCMMONO : public CODECADPCM { -protected: - int valpred, index; - -public: - CODECADPCMMONO(bool bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMMONO(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); - virtual void LoopReset(); -}; - -/****************************************************************************\ -* Metodi per CODEC -\****************************************************************************/ - - -/****************************************************************************\ -* -* Function: CODEC::CODEC(bool loop = true); -* -* Description: Costruttore standard. E' possibile specificare se si vuole -* attivare o disattivare il loop (che di default e' attivo). -* -* Input: bool loop true se si vuole attivare il loop, -* false per disattivarlo -* -\****************************************************************************/ - -CODEC::CODEC(bool loop) { - bLoop = loop; - bEndReached = false; -} - -CODEC::~CODEC() { - -} - -/****************************************************************************\ -* -* Function: bool CODEC::EndOfStream() -* -* Description: Informa se abbiamo raggiunto la fine dello stream -* -* Return: true se siamo arrivati alla fine, false altrimenti -* -\****************************************************************************/ - -bool CODEC::EndOfStream() { - return bEndReached; -} - - -/****************************************************************************\ -* Metodi per CODECRAW -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: CODECRAW::CODECRAW(bool loop = true); -* -* Description: Costruttore standard. Richiama solamente il costruttore della -* classe astratta CODEC. -* -* Input: bool loop true se si vuole attivare il loop, -* false per disattivarlo -* -\****************************************************************************/ - -CODECRAW::CODECRAW(bool loop) : CODEC(loop) { -} - -CODECRAW::~CODECRAW() { - -} - -/****************************************************************************\ -* -* Function: CODECRAW::LoopReset(); -* -* Description: Resetta il playing prima di iniziare di nuovo il file. -* Nel caso dei file RAW non fa nulla. -* -\****************************************************************************/ - -void CODECRAW::LoopReset() { -} - -/****************************************************************************\ -* -* Function: uint32 CODECRAW::Decompress(HANDLE hStream, void *lpBuf, -* uint32 dwSize) -* -* Description: Gestisce il formato RAW: semplicemente copia dal file -* stream nel buffer. -* -* Return: Se e' stata raggiunta la fine del file, indica quale byte, -* tra quelli letti, e' l'inizio del nuovo loop. Altrimenti -* il valore non e' determinato. -* -\****************************************************************************/ - -uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { -#if 0 - byte *lpBuf = (byte *)buf; - uint32 dwRead; - uint32 dwEOF; - - bEndReached = false; - dwEOF = 0; - ReadFile(hStream, lpBuf, dwSize, &dwRead, NULL); - - if (dwRead < dwSize) { - dwEOF = dwRead; - bEndReached = true; - - if (!bLoop) { - ZeroMemory(lpBuf + dwRead, dwSize - dwRead); - } else { - SetFilePointer(hStream, 0, NULL, FILE_BEGIN); - ReadFile(hStream, lpBuf + dwRead, dwSize - dwRead, &dwRead, NULL); - } - } - - return dwEOF; -#endif - return 0; -} - -uint32 CODECRAW::Decompress(Common::File &fp, void *buf, uint32 dwSize) { - byte *lpBuf = (byte *)buf; - uint32 dwRead; - uint32 dwEOF; - - bEndReached = false; - dwEOF = 0; - - dwRead = fp.read(lpBuf, dwSize); - - if (dwRead < dwSize) { - dwEOF = dwRead; - bEndReached = true; - - if (!bLoop) { - Common::fill(lpBuf + dwRead, lpBuf + dwRead + (dwSize - dwRead), 0); - } else { - fp.seek(0); - fp.read(lpBuf + dwRead, dwSize - dwRead); - } - } - - return dwEOF; -} - -/****************************************************************************\ -* Metodi per CODECADPCM -\****************************************************************************/ - -const int CODECADPCM::indexTable[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -const int CODECADPCM::stepSizeTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - - -/****************************************************************************\ -* -* Function: CODECADPCM::CODECADPCM() -* -* Description: Costruttore. Inizializza le tabelle e alloca la memoria -* temporanea. -* -\****************************************************************************/ - -CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { - /* Alloca la memoria temporanea */ - if (lpTempBuffer != NULL) { - lpTemp = lpTempBuffer; - } else { - lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); - - if (lpTemp == NULL) { - error("Insufficient memory!"); - return; - } - } -} - - -CODECADPCMMONO::CODECADPCMMONO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { - /* Inizializza per il playing */ - LoopReset(); -} - -CODECADPCMMONO::~CODECADPCMMONO() { -} - - -CODECADPCMSTEREO::CODECADPCMSTEREO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { - /* Inizializza per il playing */ - LoopReset(); -} - -CODECADPCMSTEREO::~CODECADPCMSTEREO() { - -} - -/****************************************************************************\ -* -* Function: CODECADPCM::~CODECADPCM() -* -* Description: Distruttore. Libera la memoria temporanea. -* -\****************************************************************************/ - -CODECADPCM::~CODECADPCM() { - globalFree(lpTemp); -} - - -/****************************************************************************\ -* -* Function: CODECADPCM::LoopReset() -* -* Description: Resetta il player prima di ogni play o loop. -* -\****************************************************************************/ - -void CODECADPCMSTEREO::LoopReset() { - valpred[0] = 0; - valpred[1] = 0; - index[0] = 0; - index[1] = 0; -} - -void CODECADPCMMONO::LoopReset() { - valpred = 0; - index = 0; -} - -/****************************************************************************\ -* -* Function: CODECADPCM::Decompress(HANDLE hStream, void *lpBuf, -* uint32 dwSize); -* -* Description: Gestisce il formato ADPCM 16:4. La routine dovrebbe essere -* ottimizzata in Assembler per garantire migliori performance. -* -\****************************************************************************/ - -uint32 CODECADPCMMONO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { -#if 0 - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step; - uint32 dwRead; - - bufferstep = 1; - step = stepSizeTable[index]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = (cache >> 4) & 0xF; - } else - delta = cache & 0xF; - - /* Trova il nuovo indice */ - index += indexTable[delta]; - if (index < 0) index = 0; - if (index > 88) index = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step >> 3; - if (delta & 4) vpdiff += step; - if (delta & 2) vpdiff += step >> 1; - if (delta & 1) vpdiff += step >> 2; - - if (sign) - valpred -= vpdiff; - else - valpred += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred < -32768) - valpred = -32768; - - /* Aggiorna lo step */ - step = stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf++ = (signed short)valpred; - - bufferstep = !bufferstep; - } - - return eof / 2; -#endif - return 0; -} - -uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step; - - bufferstep = 1; - step = stepSizeTable[index]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = (cache >> 4) & 0xF; - } else - delta = cache & 0xF; - - /* Trova il nuovo indice */ - index += indexTable[delta]; - if (index < 0) index = 0; - if (index > 88) index = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step >> 3; - if (delta & 4) vpdiff += step; - if (delta & 2) vpdiff += step >> 1; - if (delta & 1) vpdiff += step >> 2; - - if (sign) - valpred -= vpdiff; - else - valpred += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred < -32768) - valpred = - 32768; - - /* Aggiorna lo step */ - step = stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf ++ = (signed short)valpred; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - -uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step[2]; - - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = cache & 0xF; - } else - delta = (cache >> 4) & 0xF; - - /* Trova il nuovo indice */ - index[bufferstep] += indexTable[delta]; - if (index[bufferstep] < 0) index[bufferstep] = 0; - if (index[bufferstep] > 88) index[bufferstep] = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep] >> 3; - if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep] >> 1; - if (delta & 1) vpdiff += step[bufferstep] >> 2; - - if (sign) - valpred[bufferstep] -= vpdiff; - else - valpred[bufferstep] += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred[bufferstep] > 32767) - valpred[bufferstep] = 32767; - else if (valpred[bufferstep] < -32768) - valpred[bufferstep] = -32768; - - /* Aggiorna lo step */ - step[bufferstep] = stepSizeTable[index[bufferstep]]; - - /* Scrive il valore trovato */ - *lpBuf ++ = (signed short)valpred[bufferstep]; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - - -uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step[2]; - - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = cache & 0xF; - } else - delta = (cache >> 4) & 0xF; - - /* Trova il nuovo indice */ - index[bufferstep] += indexTable[delta]; - if (index[bufferstep] < 0) index[bufferstep] = 0; - if (index[bufferstep] > 88) index[bufferstep] = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep] >> 3; - if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep] >> 1; - if (delta & 1) vpdiff += step[bufferstep] >> 2; - - if (sign) - valpred[bufferstep] -= vpdiff; - else - valpred[bufferstep] += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred[bufferstep] > 32767) - valpred[bufferstep] = 32767; - else if (valpred[bufferstep] < -32768) - valpred[bufferstep] = -32768; - - /* Aggiorna lo step */ - step[bufferstep] = stepSizeTable[index[bufferstep]]; - - /* Scrive il valore trovato */ - *lpBuf ++ = (signed short)valpred[bufferstep]; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - - /****************************************************************************\ * Metodi per FPSOUND \****************************************************************************/ -- cgit v1.2.3 From 1668a231926d3ff8b464417bd8023d7a93839d21 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 18:35:08 -0400 Subject: TONY: Make FPSOUND work in ScummVM --- engines/tony/sound.cpp | 121 +++++-------------------------------------------- engines/tony/sound.h | 29 +++--------- 2 files changed, 17 insertions(+), 133 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 450384b341..2d4ff824f0 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -26,6 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ +#include "audio/mixer.h" #include "common/textconsole.h" #include "tony/game.h" #include "tony/tony.h" @@ -52,109 +53,24 @@ namespace Tony { \****************************************************************************/ FPSOUND::FPSOUND() { - lpDS = NULL; - lpDSBPrimary = NULL; - hwnd = 0; bSoundSupported = false; } /****************************************************************************\ * -* Function: bool FPSOUND::Init(HWND hWnd); +* Function: bool FPSOUND::Init(); * * Description: Inizializza l'oggetto, e prepara tutto il necessario per * creare stream e effetti sonori. * -* Input: HWND hWnd Handle della finestra principale -* * Return: True se tutto OK, false in caso di errore. * \****************************************************************************/ -bool FPSOUND::Init(/*HWND hWnd*/) { -#ifdef REFACTOR_ME - HRESULT err; - static DSBUFFERDESC dsbdesc; - static PCMWAVEFORMAT pcmwf; - static char errbuf[128]; - - /* Salva l'handle della finestra nella variabile globale. DirectSound ha - bisogno dell'handle per effetuare il multitasking sonoro. */ - hwnd = hWnd; - - /* Di default, disabilita il sonoro. Se non troveremo problemi, lo - riabiliteremo alla fine della routine */ - bSoundSupported = false; - - /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. - In realta' sarebbe possibile richiedere una lista delle schede sonore - presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra - una perdita di tempo. */ - if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { - return false; - } - - /* Richiede le caratteristiche del driver sonoro */ - dscaps.dwSize = sizeof(dscaps); - lpDS->GetCaps(&dscaps); - - /* Controlla se siamo in emulazione, e in caso affermativo avverte l'utente */ - if ((dscaps.dwFlags & DSCAPS_EMULDRIVER)) - error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); - - /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco - sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed - eventuali player in background saranno automaticamente stoppati. - Inoltre in questo modo e' possibile settare il formato di output sonoro - del primary buffer */ - if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { - MessageBox(hwnd, "Cannot set exclusive mode!", "soundInit()", MB_OK); - return false; - } - - - /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, - ma noi vogliamo il pointer al primary perche' dobbiamo settare il - formato di output */ - ZeroMemory(&dsbdesc, sizeof(dsbdesc)); - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_PRIMARYBUFFER; - if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { - MessageBox(hwnd, "Cannot create primary buffer!", "soundInit()", MB_OK); - return false; - } - - /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz - stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda - sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. - Inoltre in seguito sara' possibile lasciare scegliere all'utente il - formato da utilizzare */ - pcmwf.wBitsPerSample = ((dscaps.dwFlags & DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = ((dscaps.dwFlags & DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); - pcmwf.wf.nSamplesPerSec = 44100; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { - wsprintf(errbuf, "Error setting the output format (%lx)", err); - MessageBox(hwnd, errbuf, "soundInit()", MB_OK); - return false; - } - - /* Controlla che il driver DirectSound supporti buffer secondari con - play di stream 16bit, 44khz stereo */ - if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { - wsprintf(errbuf, "Driver does not support 16bit 44khz stereo mixing! (%lu)", dscaps.dwMaxSecondarySampleRate); - MessageBox(hwnd, errbuf, "soundInit()", MB_OK); - return false; - } - - /* Tutto OK. */ - bSoundSupported = true; -#endif - return true; +bool FPSOUND::Init() { + bSoundSupported = g_system->getMixer()->isReady(); + return bSoundSupported; } @@ -167,10 +83,6 @@ bool FPSOUND::Init(/*HWND hWnd*/) { \****************************************************************************/ FPSOUND::~FPSOUND() { -#ifdef REFACTOR_ME - RELEASE(lpDSBPrimary); - RELEASE(lpDS); -#endif } @@ -197,7 +109,7 @@ FPSOUND::~FPSOUND() { \****************************************************************************/ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { - (*lplpStream) = new FPSTREAM(lpDS, hwnd, bSoundSupported); + (*lplpStream) = new FPSTREAM(bSoundSupported); return (*lplpStream != NULL); } @@ -221,7 +133,7 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { \****************************************************************************/ bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { - (*lplpSfx) = new FPSFX(lpDS, hwnd, bSoundSupported); + (*lplpSfx) = new FPSFX(bSoundSupported); return (*lplpSfx != NULL); } @@ -239,16 +151,10 @@ bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { \****************************************************************************/ void FPSOUND::SetMasterVolume(int dwVolume) { -#ifdef REFACTOR_ME - if (!bSoundSupported) return; - if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; - - lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); -#endif + g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); } @@ -263,15 +169,10 @@ void FPSOUND::SetMasterVolume(int dwVolume) { \****************************************************************************/ void FPSOUND::GetMasterVolume(int *lpdwVolume) { -#ifdef REFACTOR_ME if (!bSoundSupported) return; - lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); - *lpdwVolume -= (DSBVOLUME_MIN); - *lpdwVolume *= 64; - *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endif + *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; } @@ -288,7 +189,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { * \****************************************************************************/ -FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { +FPSFX::FPSFX(bool bSoundOn) { #ifdef REFACTOR_ME static char errbuf[128]; @@ -861,7 +762,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { * \****************************************************************************/ -FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { +FPSTREAM::FPSTREAM(bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; lpDS = LPDS; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 8be1fb42f5..be3c2da319 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -36,17 +36,8 @@ namespace Tony { -// Dummy type declarations -typedef void *LPDIRECTSOUND; -typedef void *LPDIRECTSOUNDBUFFER; -typedef uint32 HWND; -struct DSCAPS { -}; - - class FPSTREAM; class FPSFX; -class CODEC; enum CODECS { FPCODEC_RAW, @@ -67,10 +58,6 @@ class FPSOUND { private: bool bSoundSupported; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBPrimary; - DSCAPS dscaps; - HWND hwnd; /****************************************************************************\ * Metodi @@ -102,19 +89,17 @@ public: /****************************************************************************\ * - * Function: bool FPSOUND::Init(HWND hWnd); + * Function: bool FPSOUND::Init(); * * Description: Inizializza l'oggetto, e prepara tutto il necessario per * creare stream e effetti sonori. * - * Input: HWND hWnd Handle della finestra principale - * * Return: True se tutto OK, FALSE in caso di errore. * \****************************************************************************/ - bool Init(/*HWND hWnd*/); + bool Init(); /****************************************************************************\ @@ -211,7 +196,6 @@ private: bool b16bit; // TRUE se 16 bit uint32 dwFreq; // Frequenza originale di campionamento -// CODEC* lpCodec; // CODEC da utilizzare. bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro bool bIsVoice; @@ -233,14 +217,14 @@ public: /****************************************************************************\ * - * Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); + * Function: FPSFX(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() * \****************************************************************************/ - FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + FPSFX(bool bSoundOn); /****************************************************************************\ @@ -413,7 +397,6 @@ private: FPSTREAM *SyncToPlay; // DSBPOSITIONNOTIFY dspnHot[3]; - CODEC *lpCodec; // CODEC da utilizzare. bool CreateBuffer(int nBufSize); public: @@ -431,14 +414,14 @@ public: /****************************************************************************\ * - * Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); + * Function: FPSTREAM(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() * \****************************************************************************/ - FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); + FPSTREAM(bool bSoundOn); /****************************************************************************\ -- cgit v1.2.3 From e37319a28753f9b885e7c9d0a0e607d8090ae041 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jun 2012 17:56:52 +1000 Subject: TONY: Fix data freeing in DialogStart --- engines/tony/custom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6db6d5f858..e00db701f3 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1985,7 +1985,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // If there is only one option, do it automatically, and wait for the next choice if (_ctx->num == 1) { mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); - globalFree(_ctx->sl); + globalDestroy(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); @@ -2001,7 +2001,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); _ctx->dc.addChoice(_ctx->string); - globalFree(_ctx->string); + globalDestroy(_ctx->string); } // Activate the object @@ -2028,7 +2028,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Closes the choice _ctx->dc.close(); - globalFree(_ctx->sl); + globalDestroy(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); -- cgit v1.2.3 From f64700b27fa8f083697a16459e8237bf6c48f1dc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 00:24:52 +1000 Subject: TONY: Fixed display of static animations, and some variable renaming --- engines/tony/custom.cpp | 14 +++++++------- engines/tony/tonychar.cpp | 9 ++++++--- engines/tony/tonychar.h | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e00db701f3..185fc64e94 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -985,26 +985,26 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithNotebookStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONTACCUINOSTATIC; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_WITH_NOTEBOOK; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithNotebookEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -2459,8 +2459,8 @@ ASSIGN(98, TonyConRicettaStart) ASSIGN(99, TonyConRicettaEnd) ASSIGN(100, TonyConCarteStart) ASSIGN(101, TonyConCarteEnd) -ASSIGN(102, TonyConTaccuinoStart) -ASSIGN(103, TonyConTaccuinoEnd) +ASSIGN(102, TonyWithNotebookStart) +ASSIGN(103, TonyWithNotebookEnd) ASSIGN(104, TonyConMegafonoStart) ASSIGN(105, TonyConMegafonoEnd) ASSIGN(106, TonyConBarbaStart) diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index a63d2d69c3..f0357ad15d 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -950,7 +950,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CONRICETTASTATIC: case TALK_CONCONIGLIOSTATIC: case TALK_CONCARTESTATIC: - case TALK_CONTACCUINOSTATIC: + case TALK_WITH_NOTEBOOK: case TALK_CONMEGAFONOSTATIC: switch (_TalkDirection) { case LEFT: @@ -1632,7 +1632,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat } break; - case TALK_CONTACCUINOSTATIC: + case TALK_WITH_NOTEBOOK: switch (_TalkDirection) { case UP: case LEFT: @@ -1736,6 +1736,9 @@ void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { _ctx->headPat = _ctx->headLoopPat = 0; _ctx->bodyStartPat = _ctx->bodyLoopPat = 0; + startStaticCalculate(nTalk, _ctx->headPat, _ctx->headLoopPat, + _ctx->bodyStartPat, _ctx->bodyLoopPat); + // e vai con i pattern _bIsStaticTalk = true; @@ -1827,7 +1830,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } break; - case TALK_CONTACCUINOSTATIC: + case TALK_WITH_NOTEBOOK: switch (_TalkDirection) { case UP: case LEFT: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 5179230b4c..4e0a0f0d93 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -61,7 +61,7 @@ public: TALK_CONCONIGLIOSTATIC, TALK_CONRICETTASTATIC, TALK_CONCARTESTATIC, - TALK_CONTACCUINOSTATIC, + TALK_WITH_NOTEBOOK, TALK_CONMEGAFONOSTATIC, TALK_CONBARBASTATIC, TALK_RIDE2, -- cgit v1.2.3 From 2b02a45ce16960644e1d5e297066f8040cd48cbc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jun 2012 22:02:31 +0200 Subject: TONY: Rename variables in globals.h --- engines/tony/custom.cpp | 574 +++++++++++++++++++++--------------------- engines/tony/gfxengine.cpp | 8 +- engines/tony/globals.cpp | 106 ++++---- engines/tony/globals.h | 114 ++++----- engines/tony/mpal/expr.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 195 +++++++------- engines/tony/mpal/mpal.cpp | 389 ++++++++++++++-------------- engines/tony/mpal/mpaldll.h | 10 +- engines/tony/tony.cpp | 14 +- 9 files changed, 707 insertions(+), 705 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 185fc64e94..2e408a01aa 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -109,7 +109,7 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; for (i = 0; i < GLOBALS._curChangedHotspot; i++) - GLOBALS.Loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); + GLOBALS._loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { @@ -141,9 +141,9 @@ void LoadChangedHotspot(Common::InSaveFile *f) { */ void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - GLOBALS._mCharacter[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[i]._code); + GLOBALS._mCharacter[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[i]._code); for (int i = 0; i < 10; i++) - GLOBALS._character[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._character[i]._code); + GLOBALS._character[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._character[i]._code); } void CharsSaveAll(Common::OutSaveFile *f) { @@ -168,19 +168,19 @@ void CharsLoadAll(Common::InSaveFile *f) { } DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDDOWN); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDDOWN); } DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDUP); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDUP); } DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDLEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDLEFT); } DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDRIGHT); } @@ -195,7 +195,7 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - if (!GLOBALS.bSkipIdle) + if (!GLOBALS._bSkipIdle) CORO_INVOKE_1(CoroScheduler.sleep, dwTime); CORO_END_CODE; @@ -209,23 +209,23 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASU); break; case 2: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAGIU); break; case 3: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASINISTRA); break; case 4: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIADESTRA); break; case 5: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAMAPPA); break; default: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_NONE); break; } } @@ -261,12 +261,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = 0; - if (GLOBALS.bSkipIdle) return; + if (GLOBALS._bSkipIdle) + return; _ctx->msg.load(dwMessage); - if (!_ctx->msg.isValid()) { + if (!_ctx->msg.isValid()) return; - } _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; @@ -284,16 +284,16 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->SetLoop(false); } - if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); + if (GLOBALS._nTonyNextTalkType != GLOBALS._tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._nTonyNextTalkType); - if (!GLOBALS.bStaticTalk) - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + if (!GLOBALS._bStaticTalk) + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } else { if (_ctx->msg.numPeriods() > 1) - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_FIANCHI); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_FIANCHI); else - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_NORMAL); } if (GLOBALS._curBackText) @@ -301,8 +301,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS._bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.setInput(GLOBALS.Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { + _ctx->text.setInput(GLOBALS._input); // Alignment _ctx->text.setAlignType(RMText::HCENTER, RMText::VBOTTOM); @@ -315,9 +315,9 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Set the position if (nX == 0 && nY == 0) - _ctx->text.setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); + _ctx->text.setPosition(GLOBALS._tony->position() - RMPoint(0, 130) - GLOBALS._loc->scrollPosition()); else - _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->scrollPosition()); + _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS._loc->scrollPosition()); // Handling for always display if (GLOBALS._bAlwaysDisplay) { @@ -345,7 +345,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } // Wait for the end of the display - _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text.setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text.waitForEndDisplay); if (_ctx->curVoc) { @@ -359,13 +359,13 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (GLOBALS._curBackText) GLOBALS._curBackText->show(); - CORO_INVOKE_0(GLOBALS.Tony->endTalk); + CORO_INVOKE_0(GLOBALS._tony->endTalk); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { - GLOBALS.Boxes->changeBoxStatus(nLoc, nBox, nStatus); + GLOBALS._boxes->changeBoxStatus(nLoc, nBox, nStatus); } @@ -380,7 +380,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); @@ -407,18 +407,18 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); - GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); - GLOBALS.SFM_pt = GLOBALS.Tony->position(); + GLOBALS.SFM_nLoc = GLOBALS._loc->TEMPGetNumLoc(); + GLOBALS.SFM_pt = GLOBALS._tony->position(); - if (GLOBALS.bSkipIdle) + if (GLOBALS._bSkipIdle) return; CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); - GLOBALS.Tony->hide(); + GLOBALS._tony->hide(); GLOBALS.Unfreeze(); - for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.setInput(GLOBALS.Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { + _ctx->text.setInput(GLOBALS._input); // Alignment _ctx->text.setAlignType(RMText::HCENTER, RMText::VCENTER); @@ -446,7 +446,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 GLOBALS.LinkGraphicTask(&_ctx->text); // Wait for the end of display - _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text.setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text.waitForEndDisplay); } @@ -474,7 +474,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, GLOBALS.Freeze(); GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); if (!bNotEnableTony) - GLOBALS.Tony->show(); + GLOBALS._tony->show(); GLOBALS.Unfreeze(); MCharResetCodes(); @@ -531,7 +531,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { + if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { _vm->stopMusic(4); } @@ -540,14 +540,14 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { - GLOBALS.lastTappeto = GLOBALS.tappeti[nLoc]; - if (GLOBALS.lastTappeto != 0) - _vm->playMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); + if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { + GLOBALS._lastTappeto = GLOBALS._tappeti[nLoc]; + if (GLOBALS._lastTappeto != 0) + _vm->playMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true, 2000); } if (!GLOBALS._bNoOcchioDiBue) { @@ -574,12 +574,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - GLOBALS.StartLocPos[nLoc].set(lX, lY); + GLOBALS._startLocPos[nLoc].set(lX, lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS._saveTonyPos = GLOBALS.Tony->position(); - GLOBALS._saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); + GLOBALS._saveTonyPos = GLOBALS._tony->position(); + GLOBALS._saveTonyLoc = GLOBALS._loc->TEMPGetNumLoc(); } DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -604,7 +604,7 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->stopNoAction(coroParam); + GLOBALS._tony->stopNoAction(coroParam); } DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -624,11 +624,11 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->take(nDirection, 0); + GLOBALS._tony->take(nDirection, 0); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_END_CODE; } @@ -640,14 +640,14 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->take(nDirection, 1); + GLOBALS._tony->take(nDirection, 1); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->take(nDirection, 2); + GLOBALS._tony->take(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -660,11 +660,11 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->put(nDirection, 0); + GLOBALS._tony->put(nDirection, 0); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_END_CODE; } @@ -676,14 +676,14 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->put(nDirection, 1); + GLOBALS._tony->put(nDirection, 1); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->put(nDirection, 2); + GLOBALS._tony->put(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -749,9 +749,9 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRALEFT); else - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { @@ -761,18 +761,18 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZALEFT); else - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZARIGHT); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS.Tony->setPastorella(bIsPast); + GLOBALS._tony->setPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -781,104 +781,104 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_FISCHIETTORIGHT); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDRIGHT); CORO_END_CODE; } void TonySetNumTexts(uint32 dwText) { - GLOBALS.dwTonyNumTexts = dwText; - GLOBALS.bTonyInTexts = false; + GLOBALS._dwTonyNumTexts = dwText; + GLOBALS._bTonyInTexts = false; } DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE; } DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE2; } DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_FIANCHI; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_FIANCHI; } DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CANTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CANTA; } DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SIINDICA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SIINDICA; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO2; } DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMARTELLO; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONMARTELLO); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMARTELLO; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONMARTELLO); } DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBICCHIERE; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONBICCHIERE); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBICCHIERE; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONBICCHIERE); } DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONVERME; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONVERME); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONVERME; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONVERME); } DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCORDA; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONCORDA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCORDA; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONCORDA); } DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONSEGRETARIA; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONSEGRETARIA; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONSEGRETARIA); } DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIO; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTA; } DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTE; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZO; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -887,9 +887,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); CORO_END_CODE; } @@ -900,9 +900,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -913,9 +913,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); CORO_END_CODE; } @@ -926,9 +926,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -939,9 +939,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTASTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTASTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); CORO_END_CODE; } @@ -952,9 +952,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -965,9 +965,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTESTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTESTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCARTESTATIC); CORO_END_CODE; } @@ -978,9 +978,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCARTESTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -991,9 +991,9 @@ DECLARE_CUSTOM_FUNCTION(TonyWithNotebookStart)(CORO_PARAM, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_WITH_NOTEBOOK; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITH_NOTEBOOK; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITH_NOTEBOOK); CORO_END_CODE; } @@ -1004,9 +1004,9 @@ DECLARE_CUSTOM_FUNCTION(TonyWithNotebookEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITH_NOTEBOOK); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1017,9 +1017,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMEGAFONOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMEGAFONOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); CORO_END_CODE; } @@ -1030,9 +1030,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1043,9 +1043,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBARBASTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBARBASTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONBARBASTATIC); CORO_END_CODE; } @@ -1056,9 +1056,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONBARBASTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1069,9 +1069,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); CORO_END_CODE; } @@ -1082,9 +1082,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1092,7 +1092,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SCHIFATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCHIFATO; } DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1101,8 +1101,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_LEFT); + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1114,8 +1114,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_RIGHT); + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1123,48 +1123,48 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NAAH; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NAAH; } DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { switch (nPos) { case 1: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH1; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH1; break; case 2: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH2; break; case 3: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH3; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH3; break; case 4: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH4; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH4; break; case 5: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH5; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH5; break; case 6: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH6; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH6; break; case 7: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH7; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH7; break; case 8: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH8; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH8; break; case 9: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH9; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH9; break; } } DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->show(); + GLOBALS._tony->show(); } DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - GLOBALS.Tony->hide(bShowOmbra); + GLOBALS._tony->hide(bShowOmbra); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -1174,17 +1174,17 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uin CORO_BEGIN_CODE(_ctx); - _ctx->item = GLOBALS.Loc->getItemFromCode(nItem); + _ctx->item = GLOBALS._loc->getItemFromCode(nItem); - if (!GLOBALS.bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->waitForEndPattern, GLOBALS.hSkipIdle); + if (!GLOBALS._bSkipIdle && _ctx->item != NULL) + CORO_INVOKE_1(_ctx->item->waitForEndPattern, GLOBALS._hSkipIdle); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { - GLOBALS.Tony->setPosition(RMPoint(nX, nY), nLoc); + GLOBALS._tony->setPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { @@ -1193,16 +1193,16 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->move, RMPoint(nX, nY)); + CORO_INVOKE_1(GLOBALS._tony->move, RMPoint(nX, nY)); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndMovement); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndMovement); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - GLOBALS.Tony->move(coroParam, RMPoint(nX, nY)); + GLOBALS._tony->move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1217,9 +1217,9 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; - _ctx->pt = GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._loc->scrollPosition(); - while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; @@ -1243,8 +1243,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->setScrollPosition(_ctx->pt); - GLOBALS.Tony->setScrollPosition(_ctx->pt); + GLOBALS._loc->setScrollPosition(_ctx->pt); + GLOBALS._tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1276,7 +1276,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->stepX = sX; _ctx->stepY = sY; - _ctx->startpt = GLOBALS.Loc->scrollPosition(); + _ctx->startpt = GLOBALS._loc->scrollPosition(); _ctx->dwStartTime = _vm->getTime(); @@ -1285,7 +1285,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui else _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; - while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { _ctx->dwCurTime = _vm->getTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1308,8 +1308,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->setScrollPosition(_ctx->pt); - GLOBALS.Tony->setScrollPosition(_ctx->pt); + GLOBALS._loc->setScrollPosition(_ctx->pt); + GLOBALS._tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1329,8 +1329,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } GLOBALS.Freeze(); - GLOBALS.Loc->setScrollPosition(_ctx->pt); - GLOBALS.Tony->setScrollPosition(_ctx->pt); + GLOBALS._loc->setScrollPosition(_ctx->pt); + GLOBALS._tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1354,7 +1354,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin GLOBALS._curChangedHotspot++; } - GLOBALS.Loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); + GLOBALS._loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); } @@ -1384,8 +1384,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - GLOBALS.Tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS.Unfreeze(); _ctx->i = _vm->_randomSource.getRandomNumber(2); @@ -1397,8 +1397,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 } GLOBALS.Freeze(); - GLOBALS.Loc->setFixedScroll(RMPoint(0, 0)); - GLOBALS.Tony->setFixedScroll(RMPoint(0, 0)); + GLOBALS._loc->setFixedScroll(RMPoint(0, 0)); + GLOBALS._tony->setFixedScroll(RMPoint(0, 0)); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1413,7 +1413,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); GLOBALS._character[nChar]._code = nCode; - GLOBALS._character[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._character[nChar]._item = GLOBALS._loc->getItemFromCode(nCode); GLOBALS._character[nChar]._r = 255; GLOBALS._character[nChar]._g = 255; GLOBALS._character[nChar]._b = 255; @@ -1461,7 +1461,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nChar]._startTalkPattern != 0) { GLOBALS.Freeze(); @@ -1483,15 +1483,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { if (bIsBack) { - GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS._loc); if (GLOBALS._bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->setInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS._input); // Skipping _ctx->text->setSkipStatus(!bIsBack); @@ -1529,7 +1529,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } // Wait for the end of display - _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text->setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { @@ -1559,15 +1559,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->addItem(dwCode); + GLOBALS._inventory->addItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->removeItem(dwCode); + GLOBALS._inventory->removeItem(dwCode); } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - GLOBALS.Inventory->changeItemStatus(dwCode, dwStatus); + GLOBALS._inventory->changeItemStatus(dwCode, dwStatus); } @@ -1581,7 +1581,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui if (nCode == 0) GLOBALS._mCharacter[nChar]._item = NULL; else - GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._mCharacter[nChar]._item = GLOBALS._loc->getItemFromCode(nCode); GLOBALS._mCharacter[nChar]._r = 255; GLOBALS._mCharacter[nChar]._g = 255; GLOBALS._mCharacter[nChar]._b = 255; @@ -1598,7 +1598,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[nChar]._code); + GLOBALS._mCharacter[nChar]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[nChar]._code); } @@ -1670,7 +1670,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Calculates the position of the text according to the current frame if (GLOBALS._mCharacter[nChar]._x == -1) - _ctx->pt = GLOBALS._mCharacter[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._mCharacter[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS._mCharacter[nChar]._x, GLOBALS._mCharacter[nChar]._y); @@ -1695,16 +1695,16 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { // Create a different object depending on whether it's background or not if (bIsBack) { - GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS._loc); if (GLOBALS._bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->setInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS._input); // Skipping _ctx->text->setSkipStatus(!bIsBack); @@ -1742,7 +1742,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } // Wait for the end of display - _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text->setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { @@ -1810,30 +1810,30 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; _ctx->text->setColor(0, 255, 0); - _ctx->text->setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); + _ctx->text->setPosition(GLOBALS._tony->position() - RMPoint(0, 130) - GLOBALS._loc->scrollPosition()); _ctx->text->writeText(_ctx->string, 0); - if (GLOBALS.dwTonyNumTexts > 0) { - if (!GLOBALS.bTonyInTexts) { - if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); - if (!GLOBALS.bStaticTalk) - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + if (GLOBALS._dwTonyNumTexts > 0) { + if (!GLOBALS._bTonyInTexts) { + if (GLOBALS._nTonyNextTalkType != GLOBALS._tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._nTonyNextTalkType); + if (!GLOBALS._bStaticTalk) + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } else - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_NORMAL); - GLOBALS.bTonyInTexts = true; + GLOBALS._bTonyInTexts = true; } - GLOBALS.dwTonyNumTexts--; + GLOBALS._dwTonyNumTexts--; } else { - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); - if (!GLOBALS.bStaticTalk) - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._nTonyNextTalkType); + if (!GLOBALS._bStaticTalk) + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } } else if (!GLOBALS._isMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nPers]._startTalkPattern != 0) { GLOBALS.Freeze(); @@ -1849,7 +1849,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->setPosition(_ctx->pt); } else { if (GLOBALS._mCharacter[nPers]._x == -1) - _ctx->pt = GLOBALS._mCharacter[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._mCharacter[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS._mCharacter[nPers]._x, GLOBALS._mCharacter[nPers]._y); @@ -1874,7 +1874,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (GLOBALS._mCharacter[nPers]._bAlwaysBack) { - _ctx->text = GLOBALS._curBackText = new RMTextDialogScrolling(GLOBALS.Loc); + _ctx->text = GLOBALS._curBackText = new RMTextDialogScrolling(GLOBALS._loc); if (GLOBALS._bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS._curBackText->hide); @@ -1888,8 +1888,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->setPosition(_ctx->pt); } - if (!GLOBALS.bSkipIdle) { - _ctx->text->setInput(GLOBALS.Input); + if (!GLOBALS._bSkipIdle) { + _ctx->text->setInput(GLOBALS._input); if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); @@ -1903,7 +1903,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } // Wait for the end of display - _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text->setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text->waitForEndDisplay); } @@ -1940,10 +1940,10 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } } else { - if ((GLOBALS.dwTonyNumTexts == 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { - CORO_INVOKE_0(GLOBALS.Tony->endTalk); - GLOBALS.dwTonyNumTexts = 0; - GLOBALS.bTonyInTexts = false; + if ((GLOBALS._dwTonyNumTexts == 0 && GLOBALS._bTonyInTexts) || !GLOBALS._bTonyInTexts) { + CORO_INVOKE_0(GLOBALS._tony->endTalk); + GLOBALS._dwTonyNumTexts = 0; + GLOBALS._bTonyInTexts = false; } delete _ctx->text; @@ -2009,13 +2009,13 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_INVOKE_0(_ctx->dc.show); // Draw the pointer - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_NONE); mainShowMouse(); - while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { + while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS.Input->mousePos()); + CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos()); GLOBALS.Unfreeze(); } @@ -2051,17 +2051,17 @@ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, u // The event is operating as a mutex, so if the event is already set, wait until it's reset do { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.mut[num], 0, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._mut[num], 0, &_ctx->expired); } while (!_ctx->expired); // Set the event to flag ownership - CoroScheduler.setEvent(GLOBALS.mut[num]); + CoroScheduler.setEvent(GLOBALS._mut[num]); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.resetEvent(GLOBALS.mut[num]); + CoroScheduler.resetEvent(GLOBALS._mut[num]); } /* @@ -2199,7 +2199,7 @@ DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint GLOBALS._bFadeOutStop = true; } - GLOBALS.lastMusic = nMusic; + GLOBALS._lastMusic = nMusic; CustPlayMusic(GLOBALS._curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } @@ -2209,9 +2209,9 @@ DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, u DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem == 0) { - GLOBALS.Tony->playSfx(nSFX); + GLOBALS._tony->playSfx(nSFX); } else { - RMItem *item = GLOBALS.Loc->getItemFromCode(nItem); + RMItem *item = GLOBALS._loc->getItemFromCode(nItem); if (item) item->playSfx(nSFX); } @@ -2224,22 +2224,22 @@ void RestoreMusic(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(PlaySonoriz, GLOBALS.lastMusic, 0, 0, 0); + CORO_INVOKE_4(PlaySonoriz, GLOBALS._lastMusic, 0, 0, 0); - if (GLOBALS.lastTappeto != 0) - CustPlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true); + if (GLOBALS._lastTappeto != 0) + CustPlayMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true); CORO_END_CODE; } void SaveMusic(Common::OutSaveFile *f) { - f->writeByte(GLOBALS.lastMusic); - f->writeByte(GLOBALS.lastTappeto); + f->writeByte(GLOBALS._lastMusic); + f->writeByte(GLOBALS._lastTappeto); } void LoadMusic(Common::InSaveFile *f) { - GLOBALS.lastMusic = f->readByte(); - GLOBALS.lastTappeto = f->readByte(); + GLOBALS._lastMusic = f->readByte(); + GLOBALS._lastTappeto = f->readByte(); } @@ -2273,13 +2273,13 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bSkipIdle = true; - CoroScheduler.setEvent(GLOBALS.hSkipIdle); + GLOBALS._bSkipIdle = true; + CoroScheduler.setEvent(GLOBALS._hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bSkipIdle = false; - CoroScheduler.resetEvent(GLOBALS.hSkipIdle); + GLOBALS._bSkipIdle = false; + CoroScheduler.resetEvent(GLOBALS._hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { @@ -2336,7 +2336,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text = new RMTextDialog[_ctx->msg->numPeriods()]; for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods(); _ctx->i++) { - _ctx->text[_ctx->i].setInput(GLOBALS.Input); + _ctx->text[_ctx->i].setInput(GLOBALS._input); // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { @@ -2366,7 +2366,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); - if (GLOBALS.Input->mouseLeftClicked() || GLOBALS.Input->mouseRightClicked()) + if (GLOBALS._input->mouseLeftClicked() || GLOBALS._input->mouseRightClicked()) break; if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; @@ -2537,12 +2537,12 @@ ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { - GLOBALS.Tony = tony; - GLOBALS.Pointer = ptr; - GLOBALS.Boxes = box; - GLOBALS.Loc = loc; - GLOBALS.Inventory = inv; - GLOBALS.Input = input; + GLOBALS._tony = tony; + GLOBALS._pointer = ptr; + GLOBALS._boxes = box; + GLOBALS._loc = loc; + GLOBALS._inventory = inv; + GLOBALS._input = input; GLOBALS.LoadLocation = mainLoadLocation; GLOBALS.UnloadLocation = mainUnloadLocation; @@ -2562,47 +2562,47 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation int i; for (i = 0; i < 10; i++) - GLOBALS.mut[i] = CoroScheduler.createEvent(false, false); + GLOBALS._mut[i] = CoroScheduler.createEvent(false, false); for (i = 0; i < 200; i++) - GLOBALS.tappeti[i] = 0; - - GLOBALS.tappeti[6] = T_GRILLI; - GLOBALS.tappeti[7] = T_GRILLI; - GLOBALS.tappeti[8] = T_GRILLIOV; - GLOBALS.tappeti[10] = T_GRILLI; - GLOBALS.tappeti[12] = T_GRILLI; - GLOBALS.tappeti[13] = T_GRILLIOV; - GLOBALS.tappeti[15] = T_GRILLI; - GLOBALS.tappeti[16] = T_GRILLIVENTO; - GLOBALS.tappeti[18] = T_GRILLI; - GLOBALS.tappeti[19] = T_GRILLIVENTO; - GLOBALS.tappeti[20] = T_GRILLI; - GLOBALS.tappeti[23] = T_GRILLI; - GLOBALS.tappeti[26] = T_MAREMETA; - GLOBALS.tappeti[27] = T_GRILLI; - GLOBALS.tappeti[28] = T_GRILLIVENTO; - GLOBALS.tappeti[31] = T_GRILLI; - GLOBALS.tappeti[33] = T_MARE; - GLOBALS.tappeti[35] = T_MARE; - GLOBALS.tappeti[36] = T_GRILLI; - GLOBALS.tappeti[37] = T_GRILLI; - GLOBALS.tappeti[40] = T_GRILLI; - GLOBALS.tappeti[41] = T_GRILLI; - GLOBALS.tappeti[42] = T_GRILLI; - GLOBALS.tappeti[45] = T_GRILLI; - GLOBALS.tappeti[51] = T_GRILLI; - GLOBALS.tappeti[52] = T_GRILLIVENTO1; - GLOBALS.tappeti[53] = T_GRILLI; - GLOBALS.tappeti[54] = T_GRILLI; - GLOBALS.tappeti[57] = T_VENTO; - GLOBALS.tappeti[58] = T_VENTO; - GLOBALS.tappeti[60] = T_VENTO; + GLOBALS._tappeti[i] = 0; + + GLOBALS._tappeti[6] = T_GRILLI; + GLOBALS._tappeti[7] = T_GRILLI; + GLOBALS._tappeti[8] = T_GRILLIOV; + GLOBALS._tappeti[10] = T_GRILLI; + GLOBALS._tappeti[12] = T_GRILLI; + GLOBALS._tappeti[13] = T_GRILLIOV; + GLOBALS._tappeti[15] = T_GRILLI; + GLOBALS._tappeti[16] = T_GRILLIVENTO; + GLOBALS._tappeti[18] = T_GRILLI; + GLOBALS._tappeti[19] = T_GRILLIVENTO; + GLOBALS._tappeti[20] = T_GRILLI; + GLOBALS._tappeti[23] = T_GRILLI; + GLOBALS._tappeti[26] = T_MAREMETA; + GLOBALS._tappeti[27] = T_GRILLI; + GLOBALS._tappeti[28] = T_GRILLIVENTO; + GLOBALS._tappeti[31] = T_GRILLI; + GLOBALS._tappeti[33] = T_MARE; + GLOBALS._tappeti[35] = T_MARE; + GLOBALS._tappeti[36] = T_GRILLI; + GLOBALS._tappeti[37] = T_GRILLI; + GLOBALS._tappeti[40] = T_GRILLI; + GLOBALS._tappeti[41] = T_GRILLI; + GLOBALS._tappeti[42] = T_GRILLI; + GLOBALS._tappeti[45] = T_GRILLI; + GLOBALS._tappeti[51] = T_GRILLI; + GLOBALS._tappeti[52] = T_GRILLIVENTO1; + GLOBALS._tappeti[53] = T_GRILLI; + GLOBALS._tappeti[54] = T_GRILLI; + GLOBALS._tappeti[57] = T_VENTO; + GLOBALS._tappeti[58] = T_VENTO; + GLOBALS._tappeti[60] = T_VENTO; // Create an event for the idle skipping - GLOBALS.hSkipIdle = CoroScheduler.createEvent(true, false); + GLOBALS._hSkipIdle = CoroScheduler.createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4bfdc1333f..e8f32edac7 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -359,10 +359,10 @@ void RMGfxEngine::initCustomDll(void) { void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { RMItem *item; - assert(GLOBALS.GfxEngine); + assert(GLOBALS._gfxEngine); - if (GLOBALS.GfxEngine->_bLocationLoaded) { - item = GLOBALS.GfxEngine->_loc.getItemFromCode(dwItem); + if (GLOBALS._gfxEngine->_bLocationLoaded) { + item = GLOBALS._gfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { if (GLOBALS._bPatIrqFreeze) @@ -497,7 +497,7 @@ void RMGfxEngine::init() { _csMainLoop = g_system->createMutex(); // Initialise the IRQ function for items for MPAL - GLOBALS.GfxEngine = this; + GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); // Initialise the input diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 6f81e81a48..e676f33174 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -35,13 +35,13 @@ Globals::Globals() { _curBackText = NULL; _bTonyIsSpeaking = false; _curChangedHotspot = 0; - Tony = NULL; - Pointer = NULL; - Boxes = NULL; - Loc = NULL; - Inventory = NULL; - Input = NULL; - GfxEngine = NULL; + _tony = NULL; + _pointer = NULL; + _boxes = NULL; + _loc = NULL; + _inventory = NULL; + _input = NULL; + _gfxEngine = NULL; LoadLocation = NULL; UnloadLocation = NULL; LinkGraphicTask = NULL; @@ -56,9 +56,9 @@ Globals::Globals() { DisableGUI = NULL; SetPalesati = NULL; - dwTonyNumTexts = 0; - bTonyInTexts = false; - bStaticTalk = false; + _dwTonyNumTexts = 0; + _bTonyInTexts = false; + _bStaticTalk = false; _bPatIrqFreeze = false; _bCfgInvLocked = false; _bCfgInvNoScroll = false; @@ -86,52 +86,52 @@ Globals::Globals() { _bFadeOutStop = false; // OSystem::MutexRef vdb; - Common::fill(&mut[0], &mut[10], 0); - bSkipIdle = false; - hSkipIdle = 0; - lastMusic = 0; - lastTappeto = 0; - Common::fill(&tappeti[0], &tappeti[200], 0); + Common::fill(&_mut[0], &_mut[10], 0); + _bSkipIdle = false; + _hSkipIdle = 0; + _lastMusic = 0; + _lastTappeto = 0; + Common::fill(&_tappeti[0], &_tappeti[200], 0); SFM_nLoc = 0; // MPAL global variables - mpalError = 0; - lpiifCustom = NULL; - lplpFunctions = NULL; - lplpFunctionStrings = NULL; - nObjs = 0; - nVars = 0; - hVars = NULL; - lpmvVars = NULL; - nMsgs = 0; - hMsgs = NULL; - lpmmMsgs = NULL; - nDialogs = 0; - hDialogs = NULL; - lpmdDialogs = NULL; - nItems = 0; - hItems = NULL; - lpmiItems = NULL; - nLocations = 0; - hLocations = NULL; - lpmlLocations = NULL; - nScripts = 0; - hScripts = NULL; - lpmsScripts = NULL; - nResources = 0; - lpResources = NULL; - bExecutingAction = false; - bExecutingDialog = false; - Common::fill(&nPollingLocations[0], &nPollingLocations[MAXPOLLINGLOCATIONS], 0); - Common::fill(&hEndPollingLocations[0], &hEndPollingLocations[MAXPOLLINGLOCATIONS], 0); - Common::fill(&PollingThreads[0], &PollingThreads[MAXPOLLINGLOCATIONS], 0); - hAskChoice = 0; - hDoneChoice = 0; - nExecutingAction = 0; - nExecutingDialog = 0; - nExecutingChoice = 0; - nSelectedChoice = 0; - nTonyNextTalkType = RMTony::TALK_NORMAL; + _mpalError = 0; + _lpiifCustom = NULL; + _lplpFunctions = NULL; + _lplpFunctionStrings = NULL; + _nObjs = 0; + _nVars = 0; + _hVars = NULL; + _lpmvVars = NULL; + _nMsgs = 0; + _hMsgs = NULL; + _lpmmMsgs = NULL; + _nDialogs = 0; + _hDialogs = NULL; + _lpmdDialogs = NULL; + _nItems = 0; + _hItems = NULL; + _lpmiItems = NULL; + _nLocations = 0; + _hLocations = NULL; + _lpmlLocations = NULL; + _nScripts = 0; + _hScripts = NULL; + _lpmsScripts = NULL; + _nResources = 0; + _lpResources = NULL; + _bExecutingAction = false; + _bExecutingDialog = false; + Common::fill(&_nPollingLocations[0], &_nPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&_hEndPollingLocations[0], &_hEndPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&_pollingThreads[0], &_pollingThreads[MAXPOLLINGLOCATIONS], 0); + _hAskChoice = 0; + _hDoneChoice = 0; + _nExecutingAction = 0; + _nExecutingDialog = 0; + _nExecutingChoice = 0; + _nSelectedChoice = 0; + _nTonyNextTalkType = RMTony::TALK_NORMAL; _saveTonyLoc = 0; for (int i = 0; i < 16; ++i) diff --git a/engines/tony/globals.h b/engines/tony/globals.h index a675066bc1..e924678df0 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -151,9 +151,9 @@ struct ChangedHotspotStruct { * Description of a call to a custom function. */ typedef struct { - int nCf; + int _nCf; - int arg1, arg2, arg3, arg4; + int _arg1, _arg2, _arg3, _arg4; } CFCALL; typedef CFCALL *LPCFCALL; typedef LPCFCALL *LPLPCFCALL; @@ -212,13 +212,13 @@ public: int _curSonoriz; bool _bFadeOutStop; - RMTony *Tony; - RMPointer *Pointer; - RMGameBoxes *Boxes; - RMLocation *Loc; - RMInventory *Inventory; - RMInput *Input; - RMGfxEngine *GfxEngine; + RMTony *_tony; + RMPointer *_pointer; + RMGameBoxes *_boxes; + RMLocation *_loc; + RMInventory *_inventory; + RMInput *_input; + RMGfxEngine *_gfxEngine; uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); @@ -234,21 +234,21 @@ public: void (*DisableGUI)(void); void (*SetPalesati)(bool bpal); - uint32 dwTonyNumTexts; - bool bTonyInTexts; - bool bStaticTalk; - RMTony::TALKTYPE nTonyNextTalkType; + uint32 _dwTonyNumTexts; + bool _bTonyInTexts; + bool _bStaticTalk; + RMTony::TALKTYPE _nTonyNextTalkType; - RMPoint StartLocPos[256]; - OSystem::MutexRef cs[10]; - uint32 mut[10]; + RMPoint _startLocPos[256]; + OSystem::MutexRef _cs[10]; + uint32 _mut[10]; - bool bSkipIdle; - uint32 hSkipIdle; + bool _bSkipIdle; + uint32 _hSkipIdle; - int lastMusic, lastTappeto; + int _lastMusic, _lastTappeto; - int tappeti[200]; + int _tappeti[200]; RMPoint SFM_pt; int SFM_nLoc; @@ -256,43 +256,43 @@ public: * @defgroup MPAL variables * */ - uint32 mpalError; - LPITEMIRQFUNCTION lpiifCustom; - LPLPCUSTOMFUNCTION lplpFunctions; - Common::String *lplpFunctionStrings; - uint16 nObjs; - uint16 nVars; - HGLOBAL hVars; - LPMPALVAR lpmvVars; - uint16 nMsgs; - HGLOBAL hMsgs; - LPMPALMSG lpmmMsgs; - uint16 nDialogs; - HGLOBAL hDialogs; - LPMPALDIALOG lpmdDialogs; - uint16 nItems; - HGLOBAL hItems; - LPMPALITEM lpmiItems; - uint16 nLocations; - HGLOBAL hLocations; - LPMPALLOCATION lpmlLocations; - uint16 nScripts; - HGLOBAL hScripts; - LPMPALSCRIPT lpmsScripts; - Common::File hMpr; - uint16 nResources; - uint32 *lpResources; - bool bExecutingAction; - bool bExecutingDialog; - uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 PollingThreads[MAXPOLLINGLOCATIONS]; - uint32 hAskChoice; - uint32 hDoneChoice; - uint32 nExecutingAction; - uint32 nExecutingDialog; - uint32 nExecutingChoice; - uint32 nSelectedChoice; + uint32 _mpalError; + LPITEMIRQFUNCTION _lpiifCustom; + LPLPCUSTOMFUNCTION _lplpFunctions; + Common::String *_lplpFunctionStrings; + uint16 _nObjs; + uint16 _nVars; + HGLOBAL _hVars; + LPMPALVAR _lpmvVars; + uint16 _nMsgs; + HGLOBAL _hMsgs; + LPMPALMSG _lpmmMsgs; + uint16 _nDialogs; + HGLOBAL _hDialogs; + LPMPALDIALOG _lpmdDialogs; + uint16 _nItems; + HGLOBAL _hItems; + LPMPALITEM _lpmiItems; + uint16 _nLocations; + HGLOBAL _hLocations; + LPMPALLOCATION _lpmlLocations; + uint16 _nScripts; + HGLOBAL _hScripts; + LPMPALSCRIPT _lpmsScripts; + Common::File _hMpr; + uint16 _nResources; + uint32 *_lpResources; + bool _bExecutingAction; + bool _bExecutingDialog; + uint32 _nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _pollingThreads[MAXPOLLINGLOCATIONS]; + uint32 _hAskChoice; + uint32 _hDoneChoice; + uint32 _nExecutingAction; + uint32 _nExecutingDialog; + uint32 _nExecutingChoice; + uint32 _nSelectedChoice; }; } // End of namespace Tony diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index a9d48e2016..516da98bb1 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -171,7 +171,7 @@ static int Compute(int a, int b, byte symbol) { case OP_OR: return a || b; default: - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; break; } diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 1f610a8d2c..6ed4545d67 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -84,15 +84,15 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpBuf++; switch (lpmsScript->_command[curCmd].type) { case 1: - lpmsScript->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmsScript->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -197,15 +197,15 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { switch (lpmdDialog->_command[curCmd].type) { // Call custom function case 1: - lpmdDialog->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->_command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->_command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->_command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -398,15 +398,15 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->_command[curCmd].type) { case 1: // Call custom function - lpmiItem->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmiItem->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -535,58 +535,58 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - GLOBALS.nVars = READ_LE_UINT16(lpBuf); + GLOBALS._nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); - if (GLOBALS.hVars == NULL) + GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS._nVars); + if (GLOBALS._hVars == NULL) return false; - GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); + GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); - for (i = 0; i < GLOBALS.nVars; i++) { + for (i = 0; i < GLOBALS._nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - copyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + copyMemory(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - GLOBALS.lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Salta 'ext' - GLOBALS.lpmvVars++; + GLOBALS._lpmvVars++; } - globalUnlock(GLOBALS.hVars); + globalUnlock(GLOBALS._hVars); /* 2. Messages */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; lpBuf += 4; - GLOBALS.nMsgs = READ_LE_UINT16(lpBuf); + GLOBALS._nMsgs = READ_LE_UINT16(lpBuf); lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS.hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); - if (GLOBALS.hMsgs == NULL) + GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + if (GLOBALS._hMsgs == NULL) return false; - GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); + GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); #else - GLOBALS.lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)GLOBALS.nMsgs); - if (GLOBALS.lpmmMsgs==NULL) + GLOBALS._lpmmMsgs=(LPMPALMSG)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + if (GLOBALS._lpmmMsgs==NULL) return false; #endif - for (i = 0; i < GLOBALS.nMsgs; i++) { - GLOBALS.lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); + for (i = 0; i < GLOBALS._nMsgs; i++) { + GLOBALS._lpmmMsgs->_wNum = READ_LE_UINT16(lpBuf); lpBuf += 2; for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - GLOBALS.lpmmMsgs->hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS.lpmmMsgs->hText); + GLOBALS._lpmmMsgs->_hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); for (j = 0; lpBuf[j] != 0;) { copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); @@ -598,12 +598,12 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += j + 1; *lpTemp = '\0'; - globalUnlock(GLOBALS.lpmmMsgs->hText); - GLOBALS.lpmmMsgs++; + globalUnlock(GLOBALS._lpmmMsgs->_hText); + GLOBALS._lpmmMsgs++; } #ifdef NEED_LOCK_MSGS - globalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS._hMsgs); #endif /* 3. Objects */ @@ -611,86 +611,89 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - GLOBALS.nObjs = READ_LE_UINT16(lpBuf); + GLOBALS._nObjs = READ_LE_UINT16(lpBuf); lpBuf += 2; // Check out the dialogs - GLOBALS.nDialogs = 0; - GLOBALS.hDialogs = GLOBALS.lpmdDialogs = NULL; + GLOBALS._nDialogs = 0; + GLOBALS._hDialogs = GLOBALS._lpmdDialogs = NULL; if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { - GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS._nDialogs = READ_LE_UINT16(lpBuf); + lpBuf += 2; - GLOBALS.hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); - if (GLOBALS.hDialogs == NULL) + GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MPALDIALOG)); + if (GLOBALS._hDialogs == NULL) return false; - GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0;i < GLOBALS.nDialogs; i++) - if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) + for (i = 0;i < GLOBALS._nDialogs; i++) + if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) return false; - globalUnlock(GLOBALS.hDialogs); + globalUnlock(GLOBALS._hDialogs); } // Check the items - GLOBALS.nItems = 0; - GLOBALS.hItems = GLOBALS.lpmiItems = NULL; - if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - GLOBALS.nItems = READ_LE_UINT16(lpBuf); + GLOBALS._nItems = 0; + GLOBALS._hItems = GLOBALS._lpmiItems = NULL; + if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4) == 0) { + GLOBALS._nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; // Allocate memory and read them in - GLOBALS.hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); - if (GLOBALS.hItems == NULL) + GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MPALITEM)); + if (GLOBALS._hItems == NULL) return false; - GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS.nItems; i++) - if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) + for (i = 0; i < GLOBALS._nItems; i++) { + if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) return false; + } - globalUnlock(GLOBALS.hItems); + globalUnlock(GLOBALS._hItems); } // Check the locations - GLOBALS.nLocations = 0; - GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; + GLOBALS._nLocations = 0; + GLOBALS._hLocations = GLOBALS._lpmlLocations = NULL; if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8) == 0) { - GLOBALS.nLocations = READ_LE_UINT16(lpBuf); + GLOBALS._nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; // Allocate memory and read them in - GLOBALS.hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); - if (GLOBALS.hLocations == NULL) + GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MPALLOCATION)); + if (GLOBALS._hLocations == NULL) return false; - GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); + GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); - for (i = 0; i < GLOBALS.nLocations; i++) - if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS.lpmlLocations[i])) == NULL) + for (i = 0; i < GLOBALS._nLocations; i++) { + if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) return false; + } - globalUnlock(GLOBALS.hLocations); + globalUnlock(GLOBALS._hLocations); } // Check the scripts - GLOBALS.nScripts = 0; - GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; + GLOBALS._nScripts = 0; + GLOBALS._hScripts = GLOBALS._lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - GLOBALS.nScripts = READ_LE_UINT16(lpBuf); + GLOBALS._nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; // Allocate memory - GLOBALS.hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); - if (GLOBALS.hScripts == NULL) + GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MPALSCRIPT)); + if (GLOBALS._hScripts == NULL) return false; - GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS.nScripts; i++) { - if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) + for (i = 0; i < GLOBALS._nScripts; i++) { + if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) return false; // Sort the various moments of the script @@ -702,7 +705,7 @@ bool ParseMpc(const byte *lpBuf) { //); } - globalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS._hScripts); } if (lpBuf[0] != 'E' || lpBuf[1] != 'N' || lpBuf[2] != 'D' || lpBuf[3] != '0') @@ -745,51 +748,51 @@ void FreeMpc() { int i; // Free variables - globalFree(GLOBALS.hVars); + globalFree(GLOBALS._hVars); // Free messages - LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); - for (i = 0; i < GLOBALS.nMsgs; i++, ++lpmmMsgs) - globalFree(lpmmMsgs->hText); + LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + for (i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) + globalFree(lpmmMsgs->_hText); - globalUnlock(GLOBALS.hMsgs); - globalFree(GLOBALS.hMsgs); + globalUnlock(GLOBALS._hMsgs); + globalFree(GLOBALS._hMsgs); // Free objects - if (GLOBALS.hDialogs) { - LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + if (GLOBALS._hDialogs) { + LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0; i < GLOBALS.nDialogs; i++, ++lpmdDialogs) + for (i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); - globalFree(GLOBALS.hDialogs); + globalFree(GLOBALS._hDialogs); } // Free items - if (GLOBALS.hItems) { - LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + if (GLOBALS._hItems) { + LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS.nItems; ++i, ++lpmiItems) + for (i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); - globalUnlock(GLOBALS.hItems); - globalFree(GLOBALS.hItems); + globalUnlock(GLOBALS._hItems); + globalFree(GLOBALS._hItems); } // Free the locations - if (GLOBALS.hLocations) { - globalFree(GLOBALS.hLocations); + if (GLOBALS._hLocations) { + globalFree(GLOBALS._hLocations); } // Free the scripts - if (GLOBALS.hScripts) { - LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + if (GLOBALS._hScripts) { + LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS.nScripts; ++i, ++lpmsScripts) { + for (i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); } - globalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS._hScripts); } } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 5a4310c15b..162ba4c776 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -60,24 +60,22 @@ const char *mpalCopyright = * Locks the variables for access */ void lockVar(void) { - GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); + GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); } - /** * Unlocks variables after use */ void unlockVar(void) { - globalUnlock(GLOBALS.hVars); + globalUnlock(GLOBALS._hVars); } - /** * Locks the messages for access */ static void LockMsg(void) { #ifdef NEED_LOCK_MSGS - GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); + GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); #endif } @@ -87,7 +85,7 @@ static void LockMsg(void) { */ static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS - globalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS._hMsgs); #endif } @@ -96,7 +94,7 @@ static void UnlockMsg(void) { * Locks the dialogs for access */ static void lockDialogs(void) { - GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); } @@ -104,7 +102,7 @@ static void lockDialogs(void) { * Unlocks the dialogs after use */ static void unlockDialogs(void) { - globalUnlock(GLOBALS.hDialogs); + globalUnlock(GLOBALS._hDialogs); } @@ -112,7 +110,7 @@ static void unlockDialogs(void) { * Locks the location data structures for access */ static void lockLocations(void) { - GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); + GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); } @@ -120,7 +118,7 @@ static void lockLocations(void) { * Unlocks the location structures after use */ static void unlockLocations(void) { - globalUnlock(GLOBALS.hLocations); + globalUnlock(GLOBALS._hLocations); } @@ -128,7 +126,7 @@ static void unlockLocations(void) { * Locks the items structures for use */ static void lockItems(void) { - GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); } @@ -136,7 +134,7 @@ static void lockItems(void) { * Unlocks the items structures after use */ static void unlockItems(void) { - globalUnlock(GLOBALS.hItems); + globalUnlock(GLOBALS._hItems); } @@ -144,7 +142,7 @@ static void unlockItems(void) { * Locks the script data structures for use */ static void LockScripts(void) { - GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); } @@ -152,7 +150,7 @@ static void LockScripts(void) { * Unlocks the script data structures after use */ static void unlockScripts(void) { - globalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS._hScripts); } @@ -167,13 +165,13 @@ static void unlockScripts(void) { */ int32 varGetValue(const char *lpszVarName) { int i; - LPMPALVAR v=GLOBALS.lpmvVars; + LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS.nVars; v++, i++) + for (i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; return 0; } @@ -185,24 +183,24 @@ int32 varGetValue(const char *lpszVarName) { */ void varSetValue(const char *lpszVarName, int32 val) { uint i; - LPMPALVAR v = GLOBALS.lpmvVars; + LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS.nVars; v++, i++) + for (i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) { v->dwVal = val; - if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { i = 0; sscanf(v->lpszVarName, "Pattern.%u", &i); - GLOBALS.lpiifCustom(i, val, -1); - } else if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + GLOBALS._lpiifCustom(i, val, -1); + } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { i = 0; sscanf(v->lpszVarName,"Status.%u", &i); - GLOBALS.lpiifCustom(i, -1, val); + GLOBALS._lpiifCustom(i, -1, val); } return; } - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; return; } @@ -217,9 +215,9 @@ void varSetValue(const char *lpszVarName, int32 val) { */ static int locGetOrderFromNum(uint32 nLoc) { int i; - LPMPALLOCATION loc = GLOBALS.lpmlLocations; + LPMPALLOCATION loc = GLOBALS._lpmlLocations; - for (i = 0; i < GLOBALS.nLocations; i++, loc++) + for (i = 0; i < GLOBALS._nLocations; i++, loc++) if (loc->nObj == nLoc) return i; @@ -236,10 +234,10 @@ static int locGetOrderFromNum(uint32 nLoc) { */ static int msgGetOrderFromNum(uint32 nMsg) { int i; - LPMPALMSG msg = GLOBALS.lpmmMsgs; + LPMPALMSG msg = GLOBALS._lpmmMsgs; - for (i = 0; i < GLOBALS.nMsgs; i++, msg++) - if (msg->wNum == nMsg) + for (i = 0; i < GLOBALS._nMsgs; i++, msg++) + if (msg->_wNum == nMsg) return i; return -1; @@ -254,9 +252,9 @@ static int msgGetOrderFromNum(uint32 nMsg) { */ static int itemGetOrderFromNum(uint32 nItem) { int i; - LPMPALITEM item = GLOBALS.lpmiItems; + LPMPALITEM item = GLOBALS._lpmiItems; - for (i = 0; i < GLOBALS.nItems; i++, item++) + for (i = 0; i < GLOBALS._nItems; i++, item++) if (item->nObj == nItem) return i; @@ -273,9 +271,9 @@ static int itemGetOrderFromNum(uint32 nItem) { */ static int scriptGetOrderFromNum(uint32 nScript) { int i; - LPMPALSCRIPT script = GLOBALS.lpmsScripts; + LPMPALSCRIPT script = GLOBALS._lpmsScripts; - for (i = 0; i < GLOBALS.nScripts; i++, script++) + for (i = 0; i < GLOBALS._nScripts; i++, script++) if (script->nObj == nScript) return i; @@ -292,9 +290,9 @@ static int scriptGetOrderFromNum(uint32 nScript) { */ static int dialogGetOrderFromNum(uint32 nDialog) { int i; - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; - for (i = 0; i < GLOBALS.nDialogs; i++, dialog++) + for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) if (dialog->nObj == nDialog) return i; @@ -316,7 +314,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (nMsgOrd == (uint32)-1) return NULL; - origmsg = (const char *)globalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + origmsg = (const char *)globalLock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') @@ -328,7 +326,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { return NULL; copyMemory(clonemsg, origmsg, j); - globalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + globalUnlock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); return clonemsg; } @@ -344,7 +342,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int i, j; for (j = 0; dialog->_periods[j] != NULL; j++) @@ -385,28 +383,28 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i = 0; i < GLOBALS.nResources; i++) - if (GLOBALS.lpResources[i * 2] == dwId) { - GLOBALS.hMpr.seek(GLOBALS.lpResources[i * 2 + 1]); - nBytesRead = GLOBALS.hMpr.read(head, 4); + for (i = 0; i < GLOBALS._nResources; i++) + if (GLOBALS._lpResources[i * 2] == dwId) { + GLOBALS._hMpr.seek(GLOBALS._lpResources[i * 2 + 1]); + nBytesRead = GLOBALS._hMpr.read(head, 4); if (nBytesRead != 4) return NULL; if (head[0] != 'R' || head[1] != 'E' || head[2] != 'S' || head[3] != 'D') return NULL; - nSizeDecomp = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + nSizeDecomp = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return NULL; - nSizeComp = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + nSizeComp = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return NULL; h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); - nBytesRead = GLOBALS.hMpr.read(temp, nSizeComp); + nBytesRead = GLOBALS._hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) return NULL; @@ -425,7 +423,7 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; int j, k, num; - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Count how many are active selects */ num = 0; @@ -454,10 +452,10 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; uint32 num,i,j; - LPMPALVAR v = GLOBALS.lpmvVars; + LPMPALVAR v = GLOBALS._lpmvVars; num = 0; - for (i = 0; i < GLOBALS.nVars; i++, v++) { + for (i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -466,9 +464,9 @@ static uint32 *GetItemList(uint32 nLoc) { if (il == NULL) return NULL; - v = GLOBALS.lpmvVars; + v = GLOBALS._lpmvVars; j = 0; - for (i = 0; i < GLOBALS.nVars; i++, v++) { + for (i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; @@ -480,7 +478,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM getItemData(uint32 nOrdItem) { - LPMPALITEM curitem = GLOBALS.lpmiItems+nOrdItem; + LPMPALITEM curitem = GLOBALS._lpmiItems + nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -592,7 +590,7 @@ void CustomThread(CORO_PARAM, const void *param) { _ctx->p = *(LPCFCALL *)param; - CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); + CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->p->_nCf], _ctx->p->_arg1, _ctx->p->_arg2, _ctx->p->_arg3, _ctx->p->_arg4); globalFree(_ctx->p); @@ -645,21 +643,21 @@ void ScriptThread(CORO_PARAM, const void *param) { if (s->_command[_ctx->k].type == 1) { _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; CORO_KILL_SELF(); return; } - _ctx->p->nCf=s->_command[_ctx->k].nCf; - _ctx->p->arg1=s->_command[_ctx->k].arg1; - _ctx->p->arg2=s->_command[_ctx->k].arg2; - _ctx->p->arg3=s->_command[_ctx->k].arg3; - _ctx->p->arg4=s->_command[_ctx->k].arg4; + _ctx->p->_nCf = s->_command[_ctx->k]._nCf; + _ctx->p->_arg1 = s->_command[_ctx->k]._arg1; + _ctx->p->_arg2 = s->_command[_ctx->k]._arg2; + _ctx->p->_arg3 = s->_command[_ctx->k]._arg3; + _ctx->p->_arg4 = s->_command[_ctx->k]._arg4; // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; CORO_KILL_SELF(); return; @@ -673,7 +671,7 @@ void ScriptThread(CORO_PARAM, const void *param) { unlockVar(); } else { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; globalFree(s); CORO_KILL_SELF(); @@ -707,23 +705,23 @@ void ActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - GLOBALS.mpalError = 0; + GLOBALS._mpalError = 0; for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; if (item->_command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->_command[_ctx->k].nCf].c_str(), - item->_command[_ctx->k].arg1, item->_command[_ctx->k].arg2, - item->_command[_ctx->k].arg3, item->_command[_ctx->k].arg4 + CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[item->_command[_ctx->k]._nCf].c_str(), + item->_command[_ctx->k]._arg1, item->_command[_ctx->k]._arg2, + item->_command[_ctx->k]._arg3, item->_command[_ctx->k]._arg4 ); - CORO_INVOKE_4(GLOBALS.lplpFunctions[item->_command[_ctx->k].nCf], - item->_command[_ctx->k].arg1, - item->_command[_ctx->k].arg2, - item->_command[_ctx->k].arg3, - item->_command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS._lplpFunctions[item->_command[_ctx->k]._nCf], + item->_command[_ctx->k]._arg1, + item->_command[_ctx->k]._arg2, + item->_command[_ctx->k]._arg3, + item->_command[_ctx->k]._arg4 ); } else if (item->_command[_ctx->k].type == 2) { @@ -736,7 +734,7 @@ void ActionThread(CORO_PARAM, const void *param) { unlockVar(); } else { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; break; } } @@ -765,7 +763,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - GLOBALS.bExecutingAction = false; + GLOBALS._bExecutingAction = false; if (_vm->_initialLoadSlotNumber != -1) { _ctx->slotNumber = _vm->_initialLoadSlotNumber; @@ -825,7 +823,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); /* To begin with, we need to request the item list from the location */ - _ctx->il = mpalQueryItemList(GLOBALS.nPollingLocations[id]); + _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); /* Count the items */ for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) @@ -840,7 +838,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->ord == -1) continue; - _ctx->curItem = GLOBALS.lpmiItems + _ctx->ord; + _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) @@ -889,9 +887,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->il[_ctx->i] == 0) continue; - _ctx->curItem = GLOBALS.lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; _ctx->MyActions[_ctx->k].nAction = _ctx->j; @@ -906,6 +904,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); _ctx->k++; } + } } unlockItems(); @@ -929,7 +928,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); /* We fall alseep, but always checking that the event is set when prompted for closure */ - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) if (!_ctx->expired) @@ -955,7 +954,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Check if there is an action running on the item */ - if ((GLOBALS.bExecutingAction) && (GLOBALS.nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; /* Check to see if there already another idle funning running on the item */ @@ -968,7 +967,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ok, we are the only ones :) */ lockItems(); - _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; @@ -1021,7 +1020,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip on - CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { @@ -1036,7 +1035,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } // Set idle skip off - CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); /* We're finished */ globalDestroy(_ctx->MyThreads); @@ -1067,11 +1066,11 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - GLOBALS.bExecutingDialog = false; - GLOBALS.nExecutingDialog = 0; - GLOBALS.nExecutingChoice = 0; + GLOBALS._bExecutingDialog = false; + GLOBALS._nExecutingDialog = 0; + GLOBALS._nExecutingChoice = 0; - CoroScheduler.setEvent(GLOBALS.hAskChoice); + CoroScheduler.setEvent(GLOBALS._hAskChoice); CORO_KILL_SELF(); @@ -1100,7 +1099,7 @@ void GroupThread(CORO_PARAM, const void *param) { lockDialogs(); // Find the pointer to the current _ctx->dialog - _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; + _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search inside the group requesting the _ctx->dialog for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { @@ -1112,11 +1111,11 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->type = _ctx->dialog->_command[_ctx->k].type; if (_ctx->type == 1) { // Call custom function - CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->_command[_ctx->k].nCf], - _ctx->dialog->_command[_ctx->k].arg1, - _ctx->dialog->_command[_ctx->k].arg2, - _ctx->dialog->_command[_ctx->k].arg3, - _ctx->dialog->_command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], + _ctx->dialog->_command[_ctx->k]._arg1, + _ctx->dialog->_command[_ctx->k]._arg2, + _ctx->dialog->_command[_ctx->k]._arg3, + _ctx->dialog->_command[_ctx->k]._arg4 ); } else if (_ctx->type == 2) { @@ -1130,7 +1129,7 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); } else { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockDialogs(); CORO_KILL_SELF(); @@ -1147,7 +1146,7 @@ void GroupThread(CORO_PARAM, const void *param) { } /* If we are here, it means that we have not found the requested group */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockDialogs(); CORO_KILL_SELF(); @@ -1174,7 +1173,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { lockDialogs(); /* Get a pointer to the current dialog */ - _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; + _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Search the choice between those required in the dialog */ for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) @@ -1184,7 +1183,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { /* If nothing has been found, exit with an error */ if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { /* If we're here, we did not find the required choice */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockDialogs(); CORO_KILL_SELF(); @@ -1192,10 +1191,10 @@ void doChoice(CORO_PARAM, uint32 nChoice) { } /* We've found the requested choice. Remember what in global variables */ - GLOBALS.nExecutingChoice = _ctx->i; + GLOBALS._nExecutingChoice = _ctx->i; while (1) { - GLOBALS.nExecutingChoice = _ctx->i; + GLOBALS._nExecutingChoice = _ctx->i; _ctx->k = 0; /* Calculate the expression of each selection, to see if they're active or inactive */ @@ -1216,13 +1215,13 @@ void doChoice(CORO_PARAM, uint32 nChoice) { } /* There are choices available to the user, so wait for them to make one */ - CoroScheduler.resetEvent(GLOBALS.hDoneChoice); - CoroScheduler.setEvent(GLOBALS.hAskChoice); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hDoneChoice, CORO_INFINITE); + CoroScheduler.resetEvent(GLOBALS._hDoneChoice); + CoroScheduler.setEvent(GLOBALS._hAskChoice); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hDoneChoice, CORO_INFINITE); /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq */ - _ctx->j = GLOBALS.nSelectedChoice; + _ctx->j = GLOBALS._nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); @@ -1266,7 +1265,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { * by calling LockItem(). */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = GLOBALS.lpmiItems; + LPMPALITEM item = GLOBALS._lpmiItems; int i; LPMPALITEM newitem; uint32 h; @@ -1311,8 +1310,8 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - GLOBALS.nExecutingAction = item->nObj; - GLOBALS.bExecutingAction = true; + GLOBALS._nExecutingAction = item->nObj; + GLOBALS._bExecutingAction = true; return h; } @@ -1335,13 +1334,13 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { uint32 h; // Store the running dialog in a global variable - GLOBALS.nExecutingDialog = nDlgOrd; + GLOBALS._nExecutingDialog = nDlgOrd; // Enables the flag to indicate that there is' a running dialogue - GLOBALS.bExecutingDialog = true; + GLOBALS._bExecutingDialog = true; - CoroScheduler.resetEvent(GLOBALS.hAskChoice); - CoroScheduler.resetEvent(GLOBALS.hDoneChoice); + CoroScheduler.resetEvent(GLOBALS._hAskChoice); + CoroScheduler.resetEvent(GLOBALS._hDoneChoice); // Create a thread that performs the dialogue group @@ -1369,7 +1368,7 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool doSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) @@ -1379,8 +1378,8 @@ bool doSelection(uint32 i, uint32 dwData) { if (dialog->_choice[i]._select[j].dwData == 0) return false; - GLOBALS.nSelectedChoice = j; - CoroScheduler.setEvent(GLOBALS.hDoneChoice); + GLOBALS._nSelectedChoice = j; + CoroScheduler.setEvent(GLOBALS._hDoneChoice); return true; } @@ -1411,8 +1410,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Save the array of custom functions */ - GLOBALS.lplpFunctions = lplpcfArray; - GLOBALS.lplpFunctionStrings = lpcfStrings; + GLOBALS._lplpFunctions = lplpcfArray; + GLOBALS._lplpFunctionStrings = lpcfStrings; /* OPen the MPC file for reading */ if (!hMpc.open(lpszMpcFileName)) @@ -1489,61 +1488,61 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, */ /* Open the MPR file */ - if (!GLOBALS.hMpr.open(lpszMprFileName)) + if (!GLOBALS._hMpr.open(lpszMprFileName)) return false; /* Seek to the end of the file to read overall information */ - GLOBALS.hMpr.seek(-12, SEEK_END); + GLOBALS._hMpr.seek(-12, SEEK_END); - dwSizeComp = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + dwSizeComp = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return false; - GLOBALS.nResources = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + GLOBALS._nResources = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return false; - nBytesRead = GLOBALS.hMpr.read(buf, 4); - if (GLOBALS.hMpr.err()) + nBytesRead = GLOBALS._hMpr.read(buf, 4); + if (GLOBALS._hMpr.err()) return false; if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; /* Move to the start of the resources header */ - GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); + GLOBALS._hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); - GLOBALS.lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); - if (GLOBALS.lpResources == NULL) + GLOBALS._lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS._nResources * 8); + if (GLOBALS._lpResources == NULL) return false; cmpbuf = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf == NULL) return false; - nBytesRead = GLOBALS.hMpr.read(cmpbuf, dwSizeComp); + nBytesRead = GLOBALS._hMpr.read(cmpbuf, dwSizeComp); if (nBytesRead != dwSizeComp) return false; - lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS.lpResources, (uint32 *)&nBytesRead); - if (nBytesRead != (uint32)GLOBALS.nResources * 8) + lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS._lpResources, (uint32 *)&nBytesRead); + if (nBytesRead != (uint32)GLOBALS._nResources * 8) return false; globalDestroy(cmpbuf); /* Reset back to the start of the file, leaving it open */ - GLOBALS.hMpr.seek(0, SEEK_SET); + GLOBALS._hMpr.seek(0, SEEK_SET); /* There is no action or dialog running by default */ - GLOBALS.bExecutingAction = false; - GLOBALS.bExecutingDialog = false; + GLOBALS._bExecutingAction = false; + GLOBALS._bExecutingDialog = false; /* There's no polling location */ - Common::fill(GLOBALS.nPollingLocations, GLOBALS.nPollingLocations + MAXPOLLINGLOCATIONS, 0); + Common::fill(GLOBALS._nPollingLocations, GLOBALS._nPollingLocations + MAXPOLLINGLOCATIONS, 0); /* Create the event that will be used to co-ordinate making choices and choices finishing */ - GLOBALS.hAskChoice = CoroScheduler.createEvent(true, false); - GLOBALS.hDoneChoice = CoroScheduler.createEvent(true, false); + GLOBALS._hAskChoice = CoroScheduler.createEvent(true, false); + GLOBALS._hDoneChoice = CoroScheduler.createEvent(true, false); return true; } @@ -1553,7 +1552,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, */ void mpalFree() { // Free the resource list - globalDestroy(GLOBALS.lpResources); + globalDestroy(GLOBALS._lpResources); } /** @@ -1574,7 +1573,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { va_list v; va_start(v, wQueryType); - GLOBALS.mpalError = OK; + GLOBALS._mpalError = OK; if (wQueryType == MPQ_VERSION) { @@ -1616,13 +1615,13 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = GLOBALS.lpmlLocations[x].dwXlen; + dwRet = GLOBALS._lpmlLocations[x].dwXlen; else if (y == MPQ_Y) - dwRet = GLOBALS.lpmlLocations[x].dwYlen; + dwRet = GLOBALS._lpmlLocations[x].dwYlen; else - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } else - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockLocations(); @@ -1677,7 +1676,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1725,7 +1724,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { dwRet = doAction(x, y, GETARG(uint32)); } else { dwRet = CORO_INVALID_PID_VALUE; - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } unlockVar(); @@ -1735,7 +1734,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); */ - if (!GLOBALS.bExecutingDialog) { + if (!GLOBALS._bExecutingDialog) { lockDialogs(); x = dialogGetOrderFromNum(GETARG(uint32)); @@ -1747,7 +1746,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } va_end(v); @@ -1771,7 +1770,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { va_start(v, wQueryType); void *hRet = NULL; - GLOBALS.mpalError = OK; + GLOBALS._mpalError = OK; if (wQueryType == MPQ_VERSION) { /* @@ -1811,7 +1810,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ lockLocations(); x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(GLOBALS.lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -1855,7 +1854,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1905,7 +1904,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } va_end(v); @@ -1936,12 +1935,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hAskChoice, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hAskChoice, CORO_INFINITE); - CoroScheduler.resetEvent(GLOBALS.hAskChoice); + CoroScheduler.resetEvent(GLOBALS._hAskChoice); - if (GLOBALS.bExecutingDialog) - *dwRet = (uint32)GLOBALS.nExecutingChoice; + if (GLOBALS._bExecutingDialog) + *dwRet = (uint32)GLOBALS._nExecutingChoice; else *dwRet = (uint32)((int)-1); } else { @@ -1960,7 +1959,7 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { * @returns Error code */ uint32 mpalGetError(void) { - return GLOBALS.mpalError; + return GLOBALS._mpalError; } @@ -1980,7 +1979,7 @@ bool mpalExecuteScript(int nScript) { if (s == NULL) return false; - copyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); + copyMemory(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); unlockScripts(); // !!! New process management @@ -1998,7 +1997,7 @@ bool mpalExecuteScript(int nScript) { * @param lpiifCustom Custom function to install */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { - GLOBALS.lpiifCustom = lpiifCus; + GLOBALS._lpiifCustom = lpiifCus; } @@ -2015,16 +2014,16 @@ bool mpalStartIdlePoll(int nLoc) { uint32 i; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) - if (GLOBALS.nPollingLocations[i] == (uint32)nLoc) + if (GLOBALS._nPollingLocations[i] == (uint32)nLoc) return false; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { - if (GLOBALS.nPollingLocations[i] == 0) { - GLOBALS.nPollingLocations[i] = nLoc; + if (GLOBALS._nPollingLocations[i] == 0) { + GLOBALS._nPollingLocations[i] = nLoc; - GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); + GLOBALS._hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! New process management - if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) + if ((GLOBALS._pollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) // if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240,(void *)i))= = (void*)-1) return false; @@ -2051,13 +2050,13 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_BEGIN_CODE(_ctx); for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { - if (GLOBALS.nPollingLocations[_ctx->i] == (uint32)nLoc) { - CoroScheduler.setEvent(GLOBALS.hEndPollingLocations[_ctx->i]); + if (GLOBALS._nPollingLocations[_ctx->i] == (uint32)nLoc) { + CoroScheduler.setEvent(GLOBALS._hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.PollingThreads[_ctx->i], CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._pollingThreads[_ctx->i], CORO_INFINITE); - CoroScheduler.closeEvent(GLOBALS.hEndPollingLocations[_ctx->i]); - GLOBALS.nPollingLocations[_ctx->i] = 0; + CoroScheduler.closeEvent(GLOBALS._hEndPollingLocations[_ctx->i]); + GLOBALS._nPollingLocations[_ctx->i] = 0; if (result) *result = true; @@ -2078,7 +2077,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { * @returns Length in bytes */ int mpalGetSaveStateSize(void) { - return GLOBALS.nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MPALVAR) + 4; } @@ -2090,8 +2089,8 @@ int mpalGetSaveStateSize(void) { */ void mpalSaveState(byte *buf) { lockVar(); - WRITE_LE_UINT32(buf, GLOBALS.nVars); - copyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); + WRITE_LE_UINT32(buf, GLOBALS._nVars); + copyMemory(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); } @@ -2104,16 +2103,16 @@ void mpalSaveState(byte *buf) { */ int mpalLoadState(byte *buf) { // We must destroy and recreate all the variables - globalFree(GLOBALS.hVars); + globalFree(GLOBALS._hVars); - GLOBALS.nVars = READ_LE_UINT32(buf); + GLOBALS._nVars = READ_LE_UINT32(buf); - GLOBALS.hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); lockVar(); - copyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); + copyMemory((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); - return GLOBALS.nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MPALVAR) + 4; } bool bDontOutput; @@ -2264,8 +2263,8 @@ void mpalDumpMessages(void) { f = g_system->getSavefileManager()->openForSaving("Messages.htm"); f->writeString("\n\n
%s %s %s
\n"); - for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS._nMsgs; i++) { + lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); if (*lpMessage != '\0') { // bernie: debug /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { @@ -2275,7 +2274,7 @@ void mpalDumpMessages(void) { nPeriods = 1; p = lpPeriods[0] = lpMessage; - outputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); + outputStartMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); while (1) { // Find the end of the current period @@ -2294,9 +2293,9 @@ void mpalDumpMessages(void) { // Now make a loop over all the periods for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); + sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS.lpmmMsgs[i].wNum,j); + sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); strcpy(frase, lpPeriods[j]); @@ -2318,9 +2317,9 @@ void mpalDumpMessages(void) { } } - OutputEndMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); + OutputEndMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); - globalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS._lpmmMsgs[i]._hText); } } @@ -2357,13 +2356,13 @@ void mpalDumpOthers(void) { f->writeString("\n\n"); - for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS._nMsgs; i++) { + lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); if (*lpMessage != '\0') { nPeriods = 1; p = lpPeriods[0] = lpMessage; - if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { + if (OutputStartOther(GLOBALS._lpmmMsgs[i]._wNum, f)) { while (1) { // Find the end of the current period while (*p != '\0') @@ -2381,9 +2380,9 @@ void mpalDumpOthers(void) { // Now loop over all the periods for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); + sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS.lpmmMsgs[i].wNum,j); + sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); strcpy(frase,lpPeriods[j]); @@ -2406,9 +2405,9 @@ void mpalDumpOthers(void) { } } - outputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); + outputEndOther(GLOBALS._lpmmMsgs[i]._wNum, f); - globalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS._lpmmMsgs[i]._hText); } } @@ -2833,7 +2832,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { for (c = 0; c_group[g].nCmds; c++) { curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; - if (curCmd->type == 1 && curCmd->nCf == 71) { + if (curCmd->type == 1 && curCmd->_nCf == 71) { bAtLeastOne = true; break; } @@ -2849,15 +2848,15 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; // If it's a custom function, call SendDialogMessage(nPers, nMsg) - if (curCmd->type == 1 && curCmd->nCf == 71) { - sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); + if (curCmd->type == 1 && curCmd->_nCf == 71) { + sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->_arg2); for (j = 0; dlg->_periods[j] != NULL; j++) - if (dlg->_periodNums[j] == curCmd->arg2) + if (dlg->_periodNums[j] == curCmd->_arg2) break; if (dlg->_periods[j] == NULL) - warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->arg2); + warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->_arg2); else { frase = (char *)globalLock(dlg->_periods[j]); strcpy(copia, frase); @@ -2876,7 +2875,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString("\t\n"); f->writeString(Common::String::format("\t\t\n", fname)); f->writeString(Common::String::format("\t\t\n", - getPersonName(dlg->nObj, curCmd->arg1))); + getPersonName(dlg->nObj, curCmd->_arg1))); f->writeString(Common::String::format("\t\t\n",copia)); f->writeString("\t\n"); //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); @@ -2899,8 +2898,8 @@ void mpalDumpDialogs(void) { lockDialogs(); - for (i = 0; i < GLOBALS.nDialogs; i++) - mpalDumpDialog(&GLOBALS.lpmdDialogs[i]); + for (i = 0; i < GLOBALS._nDialogs; i++) + mpalDumpDialog(&GLOBALS._lpmdDialogs[i]); unlockDialogs(); } diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index e331335315..952a0957c5 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -89,8 +89,8 @@ typedef LPMPALVAR *LPLPMPALVAR; * MPAL Messages */ struct MPALMSG { - HGLOBAL hText; // Handle to the message text - uint16 wNum; // Message number + HGLOBAL _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; typedef MPALMSG *LPMPALMSG; typedef LPMPALMSG *LPLPMPALMSG; @@ -124,17 +124,17 @@ struct command { byte type; // Type of control union { - int32 nCf; // Custom function call [#1] + int32 _nCf; // Custom function call [#1] char *lpszVarName; // Variable name [#2] int32 nChoice; // Number of choice you make [#3] }; union { - int32 arg1; // Argument for custom function [#1] + int32 _arg1; // Argument for custom function [#1] HGLOBAL expr; // Expression to assign to a variable [#2] }; - int32 arg2, arg3, arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 0c0bcf331a..2b9d8fbc20 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -517,9 +517,9 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // and kill the scheudler and all the processes, including this one for (;;) { // If a savegame needs to be loaded, then do so - if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { + if (_vm->_loadSlotNumber != -1 && GLOBALS._gfxEngine != NULL) { _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); - CORO_INVOKE_1(GLOBALS.GfxEngine->loadState, _ctx->fn); + CORO_INVOKE_1(GLOBALS._gfxEngine->loadState, _ctx->fn); _vm->_loadSlotNumber = -1; } @@ -605,10 +605,10 @@ uint32 TonyEngine::getTime() { } bool TonyEngine::canLoadGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); + return GLOBALS._gfxEngine != NULL && GLOBALS._gfxEngine->canLoadSave(); } bool TonyEngine::canSaveGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); + return GLOBALS._gfxEngine != NULL && GLOBALS._gfxEngine->canLoadSave(); } Common::Error TonyEngine::loadGameState(int slot) { @@ -617,13 +617,13 @@ Common::Error TonyEngine::loadGameState(int slot) { } Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { - if (!GLOBALS.GfxEngine) + if (!GLOBALS._gfxEngine) return Common::kUnknownError; RMSnapshot s; - s.grabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); + s.grabScreenshot(*GLOBALS._gfxEngine, 4, _curThumbnail); - GLOBALS.GfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); + GLOBALS._gfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; } -- cgit v1.2.3 From 44ee26e6c99383dd9cec1392afae958faaf87b12 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jun 2012 23:56:37 +0200 Subject: TONY: Rename variables in loc.h and mpal.h --- engines/tony/debugger.cpp | 2 +- engines/tony/loc.cpp | 406 ++++++++++++++++++++++----------------------- engines/tony/loc.h | 86 +++++----- engines/tony/mpal/mpal.cpp | 58 +++---- engines/tony/mpal/mpal.h | 48 +++--- engines/tony/tonychar.cpp | 6 +- 6 files changed, 303 insertions(+), 303 deletions(-) (limited to 'engines') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index af2bffc459..1a4dc16b75 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); - scenePos.set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty); } // Set up a process to change the scene diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index ac238193e0..81fb0d307f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -951,19 +951,19 @@ short RMCharacter::findPath(short source, short destination) { short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; - g_system->lockMutex(csMove); + g_system->lockMutex(_csMove); if (source == -1 || destination == -1) { - g_system->unlockMutex(csMove); + g_system->unlockMutex(_csMove); return 0; } // Get the boxes - cur = theBoxes->getBoxes(curLocation); + cur = _theBoxes->getBoxes(_curLocation); // Make a backup copy to work on for (i = 0; i < cur->numbbox; i++) - memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); + memcpy(&BOX[i], &cur->_boxes[i], sizeof(RMBox)); // Invalidate all nodes for (i = 0; i < cur->numbbox; i++) @@ -984,7 +984,7 @@ short RMCharacter::findPath(short source, short destination) { if (VALIDO[i] == 1) { errore = 0; // Failure de-bunked j = 0; - while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i]._adj[j]) != 1) && (j < cur->numbbox)) j++; if (j >= cur->numbbox) @@ -1002,12 +1002,12 @@ short RMCharacter::findPath(short source, short destination) { // 2nd cycle: adding new nodes that were found, saturate old nodes for (i = 0; i < cur->numbbox; i++) if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { - BOX[i].adj[NEXT[i]] = 2; + BOX[i]._adj[NEXT[i]] = 2; COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; for (j = 0; j < cur->numbbox; j++) - if (BOX[j].adj[NEXT[i]] == 1) - BOX[j].adj[NEXT[i]] = 0; + if (BOX[j]._adj[NEXT[i]] == 1) + BOX[j]._adj[NEXT[i]] = 0; if (NEXT[i] == destination) fine = 1; @@ -1016,22 +1016,22 @@ short RMCharacter::findPath(short source, short destination) { // Remove the path from the adjacent modified matrixes if (!errore) { - pathlenght = COSTO[destination]; - k = pathlenght; - path[k] = destination; + _pathLength = COSTO[destination]; + k = _pathLength; + _path[k] = destination; - while (path[k] != source) { + while (_path[k] != source) { i = 0; - while (BOX[i].adj[path[k]] != 2) + while (BOX[i]._adj[_path[k]] != 2) i++; k--; - path[k] = i; + _path[k] = i; } - pathlenght++; + _pathLength++; } - g_system->unlockMutex(csMove); + g_system->unlockMutex(_csMove); return !errore; } @@ -1044,24 +1044,24 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { CORO_BEGIN_CODE(_ctx); if (_pos == destcoord) { - if (minpath == 0) { + if (_minPath == 0) { CORO_INVOKE_0(stop); - CoroScheduler.pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(_hEndOfPath); return; } } - status = WALK; - linestart = _pos; - lineend = destcoord; - dx = linestart.x - lineend.x; - dy = linestart.y - lineend.y; - fx = dx; - fy = dy; - dx = ABS(dx); - dy = ABS(dy); - walkspeed = curSpeed; - walkcount = 0; + _status = WALK; + _lineStart = _pos; + _lineEnd = destcoord; + _dx = _lineStart.x - _lineEnd.x; + _dy = _lineStart.y - _lineEnd.y; + _fx = _dx; + _fy = _dy; + _dx = ABS(_dx); + _dy = ABS(_dy); + _walkSpeed = _curSpeed; + _walkCount = 0; if (bReversed) { while (0) ; @@ -1069,15 +1069,15 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { int nPatt = getCurPattern(); - if (dx > dy) { - slope = fy / fx; - if (lineend.x < linestart.x) - walkspeed = -walkspeed; - walkstatus = 1; + if (_dx > _dy) { + _slope = _fy / _fx; + if (_lineEnd.x < _lineStart.x) + _walkSpeed = -_walkSpeed; + _walkStatus = 1; // Change the pattern for the new direction - bNeedToStop = true; - if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + _bNeedToStop = true; + if ((_walkSpeed < 0 && !bReversed) || (_walkSpeed >= 0 && bReversed)) { if (nPatt != PAT_WALKLEFT) setPattern(PAT_WALKLEFT); } else { @@ -1085,13 +1085,13 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { setPattern(PAT_WALKRIGHT); } } else { - slope = fx / fy; - if (lineend.y < linestart.y) - walkspeed = -walkspeed; - walkstatus = 0; + _slope = _fx / _fy; + if (_lineEnd.y < _lineStart.y) + _walkSpeed = -_walkSpeed; + _walkStatus = 0; - bNeedToStop = true; - if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + _bNeedToStop = true; + if ((_walkSpeed < 0 && !bReversed) || (_walkSpeed >= 0 && bReversed)) { if (nPatt != PAT_WALKUP) setPattern(PAT_WALKUP); } else { @@ -1100,8 +1100,8 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { } } - olddx = dx; - olddy = dy; + _olddx = _dx; + _olddy = _dy; CORO_END_CODE; } @@ -1297,17 +1297,17 @@ RMPoint RMCharacter::nearestHotSpot(int sourcebox, int destbox) { short cc; int x, y, distanzaminima; distanzaminima = 10000000; - RMBoxLoc *cur = theBoxes->getBoxes(curLocation); + RMBoxLoc *cur = _theBoxes->getBoxes(_curLocation); - for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) - if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { - x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - _pos.x); - y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - _pos.y); + for (cc = 0; cc < cur->_boxes[sourcebox]._numHotspot; cc++) + if ((cur->_boxes[sourcebox]._hotspot[cc]._destination) == destbox) { + x = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hotx - _pos.x); + y = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hoty - _pos.y); if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; - puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; - puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; + puntocaldo.x = cur->_boxes[sourcebox]._hotspot[cc]._hotx; + puntocaldo.y = cur->_boxes[sourcebox]._hotspot[cc]._hoty; } } @@ -1320,7 +1320,7 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - if (bDrawNow) { + if (_bDrawNow) { prim->getDst() += _fixedScroll; CORO_INVOKE_2(RMItem::draw, bigBuf, prim); @@ -1334,22 +1334,22 @@ void RMCharacter::newBoxEntered(int nBox) { bool bOldReverse; // Recall on ExitBox - mpalQueryDoAction(3, curLocation, curbox); + mpalQueryDoAction(3, _curLocation, _curBox); - cur = theBoxes->getBoxes(curLocation); - bOldReverse = cur->boxes[curbox].bReversed; - curbox = nBox; + cur = _theBoxes->getBoxes(_curLocation); + bOldReverse = cur->_boxes[_curBox]._bReversed; + _curBox = nBox; // If Z is changed, we must remove it from the OT - if (cur->boxes[curbox].Zvalue != _z) { - bRemoveFromOT = true; - _z = cur->boxes[curbox].Zvalue; + if (cur->_boxes[_curBox]._destZ != _z) { + _bRemoveFromOT = true; + _z = cur->_boxes[_curBox]._destZ; } // Movement management is reversed, only if we are not in the shortest path. If we are in the shortest // path, directly do the DoFrame - if (bMovingWithoutMinpath) { - if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { + if (_bMovingWithoutMinpath) { + if ((cur->_boxes[_curBox]._bReversed && !bOldReverse) || (!cur->_boxes[_curBox]._bReversed && bOldReverse)) { switch (getCurPattern()) { case PAT_WALKUP: setPattern(PAT_WALKDOWN); @@ -1368,7 +1368,7 @@ void RMCharacter::newBoxEntered(int nBox) { } // Recall On EnterBox - mpalQueryDoAction(2, curLocation, curbox); + mpalQueryDoAction(2, _curLocation, _curBox); } void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { @@ -1380,105 +1380,105 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CODE(_ctx); _ctx->bEndNow = false; - bEndOfPath = false; - bDrawNow = (curLocation == loc); + _bEndOfPath = false; + _bDrawNow = (_curLocation == loc); - g_system->lockMutex(csMove); + g_system->lockMutex(_csMove); // If we're walking.. - if (status != STAND) { + if (_status != STAND) { // If we are going horizontally - if (walkstatus == 1) { - dx = walkspeed * walkcount; - dy = (int)(slope * dx); - _pos.x = linestart.x + dx; - _pos.y = linestart.y + dy; + if (_walkStatus == 1) { + _dx = _walkSpeed * _walkCount; + _dy = (int)(_slope * _dx); + _pos.x = _lineStart.x + _dx; + _pos.y = _lineStart.y + _dy; // Right - if (((walkspeed > 0) && (_pos.x > lineend.x)) || ((walkspeed < 0) && (_pos.x < lineend.x))) { - _pos = lineend; - status = STAND; + if (((_walkSpeed > 0) && (_pos.x > _lineEnd.x)) || ((_walkSpeed < 0) && (_pos.x < _lineEnd.x))) { + _pos = _lineEnd; + _status = STAND; _ctx->bEndNow = true; } } // If we are going vertical - if (walkstatus == 0) { - dy = walkspeed * walkcount; - dx = (int)(slope * dy); - _pos.x = linestart.x + dx; - _pos.y = linestart.y + dy; + if (_walkStatus == 0) { + _dy = _walkSpeed * _walkCount; + _dx = (int)(_slope * _dy); + _pos.x = _lineStart.x + _dx; + _pos.y = _lineStart.y + _dy; // Down - if (((walkspeed > 0) && (_pos.y > lineend.y)) || ((walkspeed < 0) && (_pos.y < lineend.y))) { - _pos = lineend; - status = STAND; + if (((_walkSpeed > 0) && (_pos.y > _lineEnd.y)) || ((_walkSpeed < 0) && (_pos.y < _lineEnd.y))) { + _pos = _lineEnd; + _status = STAND; _ctx->bEndNow = true; } } // Check if the character came out of the BOX in error, in which case he returns immediately if (inWhichBox(_pos) == -1) { - _pos.x = linestart.x + olddx; - _pos.y = linestart.y + olddy; + _pos.x = _lineStart.x + _olddx; + _pos.y = _lineStart.y + _olddy; } // If we have just moved to a temporary location, and is over the shortest path, we stop permanently - if (_ctx->bEndNow && minpath == 0) { - if (!bEndOfPath) + if (_ctx->bEndNow && _minPath == 0) { + if (!_bEndOfPath) CORO_INVOKE_0(stop); - bEndOfPath = true; - CoroScheduler.pulseEvent(hEndOfPath); + _bEndOfPath = true; + CoroScheduler.pulseEvent(_hEndOfPath); } - walkcount++; + _walkCount++; // Update the character Z. @@@ Should remove only if the Z was changed // Check if the box was changed - if (!theBoxes->isInBox(curLocation, curbox, _pos)) + if (!_theBoxes->isInBox(_curLocation, _curBox, _pos)) newBoxEntered(inWhichBox(_pos)); // Update the old coordinates - olddx = dx; - olddy = dy; + _olddx = _dx; + _olddy = _dy; } // If we stop - if (status == STAND) { + if (_status == STAND) { // Check if there is still the shortest path to calculate - if (minpath == 1) { - _ctx->cur = theBoxes->getBoxes(curLocation); + if (_minPath == 1) { + _ctx->cur = _theBoxes->getBoxes(_curLocation); // If we still have to go through a box - if (pathcount < pathlenght) { + if (_pathCount < _pathLength) { // Check if the box we're going into is active - if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { + if (_ctx->cur->_boxes[_path[_pathCount - 1]]._attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(goTo, nearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); - pathcount++; + CORO_INVOKE_2(goTo, nearestHotSpot(_path[_pathCount - 1], _path[_pathCount]), _ctx->cur->_boxes[_path[_pathCount - 1]]._bReversed); + _pathCount++; } else { // If the box is off, we can only block all // @@@ Whilst this should not happen, because have improved // the search for the minimum path - minpath = 0; - if (!bEndOfPath) + _minPath = 0; + if (!_bEndOfPath) CORO_INVOKE_0(stop); - bEndOfPath = true; - CoroScheduler.pulseEvent(hEndOfPath); + _bEndOfPath = true; + CoroScheduler.pulseEvent(_hEndOfPath); } } else { // If we have already entered the last box, we just have to move in a straight line towards the // point of arrival // NEWBOX = InWhichBox(pathend) - minpath = 0; - CORO_INVOKE_2(goTo, pathend, _ctx->cur->boxes[inWhichBox(pathend)].bReversed); + _minPath = 0; + CORO_INVOKE_2(goTo, _pathEnd, _ctx->cur->_boxes[inWhichBox(_pathEnd)]._bReversed); } } } - g_system->unlockMutex(csMove); + g_system->unlockMutex(_csMove); // Invoke the DoFrame of the item RMItem::doFrame(bigBuf); @@ -1492,16 +1492,16 @@ void RMCharacter::stop(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - bMoving = false; + _bMoving = false; // You never know.. - status = STAND; - minpath = 0; + _status = STAND; + _minPath = 0; - if (!bNeedToStop) + if (!_bNeedToStop) return; - bNeedToStop = false; + _bNeedToStop = false; switch (getCurPattern()) { case PAT_WALKUP: @@ -1529,7 +1529,7 @@ void RMCharacter::stop(CORO_PARAM) { } inline int RMCharacter::inWhichBox(const RMPoint &pt) { - return theBoxes->whichBox(curLocation, pt); + return _theBoxes->whichBox(_curLocation, pt); } @@ -1542,12 +1542,12 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CODE(_ctx); - bMoving = true; + _bMoving = true; // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { - minpath = 0; - status = STAND; + _minPath = 0; + _status = STAND; CORO_INVOKE_0(stop); if (result) *result = true; @@ -1568,18 +1568,18 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { _ctx->numbox = inWhichBox(pt); } - _ctx->cur = theBoxes->getBoxes(curLocation); + _ctx->cur = _theBoxes->getBoxes(_curLocation); - minpath = 0; - status = STAND; - bMovingWithoutMinpath = true; + _minPath = 0; + _status = STAND; + _bMovingWithoutMinpath = true; if (scanLine(pt)) - CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + CORO_INVOKE_2(goTo, pt, _ctx->cur->_boxes[_ctx->numbox]._bReversed); else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { - bMovingWithoutMinpath = false; - minpath = 1; - pathcount = 1; - pathend = pt; + _bMovingWithoutMinpath = false; + _minPath = 1; + _pathCount = 1; + _pathEnd = pt; } else { // @@@ This case is whether a hotspot is inside a box, but there is // a path to get there. We use the InvScanLine to search around a point @@ -1587,12 +1587,12 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { pt = _ctx->dest; if (scanLine(pt)) - CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + CORO_INVOKE_2(goTo, pt, _ctx->cur->_boxes[_ctx->numbox]._bReversed); else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { - bMovingWithoutMinpath = false; - minpath = 1; - pathcount = 1; - pathend = pt; + _bMovingWithoutMinpath = false; + _minPath = 1; + _pathCount = 1; + _pathEnd = pt; if (result) *result = true; } else { @@ -1612,19 +1612,19 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { void RMCharacter::setPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; - minpath = 0; - status = STAND; + _minPath = 0; + _status = STAND; _pos = pt; if (newloc != -1) - curLocation = newloc; + _curLocation = newloc; // Update the character's Z value - box = theBoxes->getBoxes(curLocation); - curbox = inWhichBox(_pos); - assert(curbox != -1); - _z = box->boxes[curbox].Zvalue; - bRemoveFromOT = true; + box = _theBoxes->getBoxes(_curLocation); + _curBox = inWhichBox(_pos); + assert(_curBox != -1); + _z = box->_boxes[_curBox]._destZ; + _bRemoveFromOT = true; } void RMCharacter::waitForEndMovement(CORO_PARAM) { @@ -1633,8 +1633,8 @@ void RMCharacter::waitForEndMovement(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - if (bMoving) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); + if (_bMoving) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1645,7 +1645,7 @@ void RMCharacter::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CODE(_ctx); - if (bRemoveFromOT) + if (_bRemoveFromOT) result = true; else CORO_INVOKE_1(RMItem::removeThis, result); @@ -1654,38 +1654,38 @@ void RMCharacter::removeThis(CORO_PARAM, bool &result) { } RMCharacter::RMCharacter() { - csMove = g_system->createMutex(); - hEndOfPath = CoroScheduler.createEvent(false, false); - minpath = 0; - curSpeed = 3; - bRemoveFromOT = false; - bMoving = false; - curLocation = 0; - curbox = 0; - dx = dy = 0; - olddx = olddy = 0; - fx = fy = slope = 0; - walkspeed = walkstatus = 0; - nextbox = 0; - pathlenght = pathcount = 0; - status = STAND; - theBoxes = NULL; - walkcount = 0; - bEndOfPath = false; - bMovingWithoutMinpath = false; - bDrawNow = false; - bNeedToStop = false; + _csMove = g_system->createMutex(); + _hEndOfPath = CoroScheduler.createEvent(false, false); + _minPath = 0; + _curSpeed = 3; + _bRemoveFromOT = false; + _bMoving = false; + _curLocation = 0; + _curBox = 0; + _dx = _dy = 0; + _olddx = _olddy = 0; + _fx = _fy = _slope = 0; + _walkSpeed = _walkStatus = 0; + _nextBox = 0; + _pathLength = _pathCount = 0; + _status = STAND; + _theBoxes = NULL; + _walkCount = 0; + _bEndOfPath = false; + _bMovingWithoutMinpath = false; + _bDrawNow = false; + _bNeedToStop = false; _pos.set(0, 0); } RMCharacter::~RMCharacter() { - g_system->deleteMutex(csMove); - CoroScheduler.closeEvent(hEndOfPath); + g_system->deleteMutex(_csMove); + CoroScheduler.closeEvent(_hEndOfPath); } void RMCharacter::linkToBoxes(RMGameBoxes *boxes) { - theBoxes = boxes; + _theBoxes = boxes; } /****************************************************************************\ @@ -1698,35 +1698,35 @@ void RMBox::readFromStream(RMDataStream &ds) { byte b; // Bbox - ds >> left; - ds >> top; - ds >> right; - ds >> bottom; + ds >> _left; + ds >> _top; + ds >> _right; + ds >> _bottom; // Adjacency for (i = 0; i < MAXBOXES; i++) { - ds >> adj[i]; + ds >> _adj[i]; } // Misc - ds >> numhotspot; - ds >> Zvalue; + ds >> _numHotspot; + ds >> _destZ; ds >> b; - attivo = b; + _attivo = b; ds >> b; - bReversed = b; + _bReversed = b; // Reversed expansion space ds += 30; // Hotspots - for (i = 0; i < numhotspot; i++) { + for (i = 0; i < _numHotspot; i++) { ds >> w; - hotspot[i].hotx = w; + _hotspot[i]._hotx = w; ds >> w; - hotspot[i].hoty = w; + _hotspot[i]._hoty = w; ds >> w; - hotspot[i].destination = w; + _hotspot[i]._destination = w; } } @@ -1741,11 +1741,11 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { \****************************************************************************/ RMBoxLoc::RMBoxLoc() { - boxes = NULL; + _boxes = NULL; } RMBoxLoc::~RMBoxLoc() { - delete[] boxes; + delete[] _boxes; } void RMBoxLoc::readFromStream(RMDataStream &ds) { @@ -1762,11 +1762,11 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { ds >> numbbox; // Allocate memory for the boxes - boxes = new RMBox[numbbox]; + _boxes = new RMBox[numbbox]; // Read in boxes for (i = 0; i < numbbox; i++) - ds >> boxes[i]; + ds >> _boxes[i]; } @@ -1774,11 +1774,11 @@ void RMBoxLoc::recalcAllAdj(void) { int i, j; for (i = 0; i < numbbox; i++) { - Common::fill(boxes[i].adj, boxes[i].adj + MAXBOXES, 0); + Common::fill(_boxes[i]._adj, _boxes[i]._adj + MAXBOXES, 0); - for (j = 0; j < boxes[i].numhotspot; j++) - if (boxes[boxes[i].hotspot[j].destination].attivo) - boxes[i].adj[boxes[i].hotspot[j].destination] = 1; + for (j = 0; j < _boxes[i]._numHotspot; j++) + if (_boxes[_boxes[i]._hotspot[j]._destination]._attivo) + _boxes[i]._adj[_boxes[i]._hotspot[j]._destination] = 1; } } @@ -1833,8 +1833,8 @@ RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = getBoxes(nLoc); - if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && - (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + if ((pt.x >= cur->_boxes[nBox]._left) && (pt.x <= cur->_boxes[nBox]._right) && + (pt.y >= cur->_boxes[nBox]._top) && (pt.y <= cur->_boxes[nBox]._bottom)) return true; else return false; @@ -1848,16 +1848,16 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { return -1; for (i = 0; i < cur->numbbox; i++) - if (cur->boxes[i].attivo) - if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && - (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + if (cur->_boxes[i]._attivo) + if ((punto.x >= cur->_boxes[i]._left) && (punto.x <= cur->_boxes[i]._right) && + (punto.y >= cur->_boxes[i]._top) && (punto.y <= cur->_boxes[i]._bottom)) return i; return -1; } void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { - _allBoxes[nLoc]->boxes[nBox].attivo = status; + _allBoxes[nLoc]->_boxes[nBox]._attivo = status; _allBoxes[nLoc]->recalcAllAdj(); } @@ -1889,7 +1889,7 @@ void RMGameBoxes::saveState(byte *state) { state += 4; for (j = 0; j < _allBoxes[i]->numbbox; j++) - *state++ = _allBoxes[i]->boxes[j].attivo; + *state++ = _allBoxes[i]->_boxes[j]._attivo; } } @@ -1910,7 +1910,7 @@ void RMGameBoxes::loadState(byte *state) { for (j = 0; j < nbox ; j++) { if (j < _allBoxes[i]->numbbox) - _allBoxes[i]->boxes[j].attivo = *state; + _allBoxes[i]->_boxes[j]._attivo = *state; state++; } @@ -2288,29 +2288,29 @@ RMMessage::RMMessage(uint32 dwId) { } RMMessage::RMMessage() { - lpMessage = NULL; + _lpMessage = NULL; } RMMessage::~RMMessage() { - if (lpMessage) - globalDestroy(lpMessage); + if (_lpMessage) + globalDestroy(_lpMessage); } void RMMessage::load(uint32 dwId) { - lpMessage = mpalQueryMessage(dwId); - assert(lpMessage != NULL); + _lpMessage = mpalQueryMessage(dwId); + assert(_lpMessage != NULL); - if (lpMessage) + if (_lpMessage) parseMessage(); } void RMMessage::parseMessage(void) { char *p; - assert(lpMessage != NULL); + assert(_lpMessage != NULL); - nPeriods = 1; - p = lpPeriods[0] = lpMessage; + _nPeriods = 1; + p = _lpPeriods[0] = _lpMessage; for (;;) { // Find the end of the current period @@ -2323,7 +2323,7 @@ void RMMessage::parseMessage(void) { break; // Otherwise there is another line, and remember it's start - lpPeriods[nPeriods++] = p; + _lpPeriods[_nPeriods++] = p; } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index e465b113b2..79eb936d9b 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -315,19 +315,19 @@ protected: class RMBox { public: struct T_HOTSPOT { - int hotx, hoty; // Hotspot coordinates - int destination; // Hotspot destination + int _hotx, _hoty; // Hotspot coordinates + int _destination; // Hotspot destination }; public: - int left, top, right, bottom; // Vertici bounding boxes - int adj[MAXBOXES]; // List of adjacent bounding boxes - int numhotspot; // Hotspot number - uint8 Zvalue; // Z value for the bounding box - T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots + int _left, _top, _right, _bottom; // Vertici bounding boxes + int _adj[MAXBOXES]; // List of adjacent bounding boxes + int _numHotspot; // Hotspot number + uint8 _destZ; // Z value for the bounding box + T_HOTSPOT _hotspot[MAXHOTSPOT]; // List of hotspots - bool attivo; - bool bReversed; + bool _attivo; + bool _bReversed; private: void readFromStream(RMDataStream &ds); @@ -340,7 +340,7 @@ public: class RMBoxLoc { public: int numbbox; - RMBox *boxes; + RMBox *_boxes; private: void readFromStream(RMDataStream &ds); @@ -405,26 +405,26 @@ private: WALK }; - signed short walkcount; - int dx, dy, olddx, olddy; - float fx, fy, slope; - RMPoint linestart, lineend, pathend; - signed char walkspeed, walkstatus; - char minpath; - short nextbox; - short path[MAXBOXES]; - short pathlenght, pathcount; - int curbox; - - STATUS status; - int curSpeed; - bool bEndOfPath; - uint32 hEndOfPath; - OSystem::MutexRef csMove; - int curLocation; - bool bRemoveFromOT; - bool bMovingWithoutMinpath; - RMGameBoxes *theBoxes; + signed short _walkCount; + int _dx, _dy, _olddx, _olddy; + float _fx, _fy, _slope; + RMPoint _lineStart, _lineEnd, _pathEnd; + signed char _walkSpeed, _walkStatus; + char _minPath; + short _nextBox; + short _path[MAXBOXES]; + short _pathLength, _pathCount; + int _curBox; + + STATUS _status; + int _curSpeed; + bool _bEndOfPath; + uint32 _hEndOfPath; + OSystem::MutexRef _csMove; + int _curLocation; + bool _bRemoveFromOT; + bool _bMovingWithoutMinpath; + RMGameBoxes *_theBoxes; RMPoint _fixedScroll; @@ -443,9 +443,9 @@ private: void newBoxEntered(int nBox); protected: - bool bMoving; - bool bDrawNow; - bool bNeedToStop; + bool _bMoving; + bool _bDrawNow; + bool _bNeedToStop; // virtual RMGfxPrimitive *NewItemPrimitive(); public: @@ -464,7 +464,7 @@ public: // TRUE if you just stopped bool endOfPath() { - return bEndOfPath; + return _bEndOfPath; } // Change the pattern of a character to STOP @@ -472,7 +472,7 @@ public: // Check if the character is moving bool isMoving() { - return bMoving; + return _bMoving; } // Move the character to a certain position @@ -488,7 +488,7 @@ public: _fixedScroll = fix; } void setSpeed(int speed) { - curSpeed = speed; + _curSpeed = speed; } }; @@ -601,9 +601,9 @@ public: */ class RMMessage { private: - char *lpMessage; - char *lpPeriods[256]; - int nPeriods; + char *_lpMessage; + char *_lpPeriods[256]; + int _nPeriods; private: void parseMessage(void); @@ -615,16 +615,16 @@ public: void load(uint32 dwId); bool isValid() { - return lpMessage != NULL; + return _lpMessage != NULL; } int numPeriods() { - return nPeriods; + return _nPeriods; } char *period(int num) { - return lpPeriods[num]; + return _lpPeriods[num]; } char *operator[](int num) { - return lpPeriods[num]; + return _lpPeriods[num]; } }; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 162ba4c776..3b798b8071 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -490,7 +490,7 @@ static LPITEM getItemData(uint32 nOrdItem) { ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); if (ret == NULL) return NULL; - ret->speed = 150; + ret->_speed = 150; hDat = resLoad(curitem->dwRes); dat = (char *)globalLock(hDat); @@ -500,65 +500,65 @@ static LPITEM getItemData(uint32 nOrdItem) { dat += 4; if (i >= 0x10) { // From 1.0, there's a destination point for each object - ret->destX = (int16)READ_LE_UINT16(dat); - ret->destY = (int16)READ_LE_UINT16(dat + 2); + ret->_destX = (int16)READ_LE_UINT16(dat); + ret->_destY = (int16)READ_LE_UINT16(dat + 2); dat += 4; } if (i >= 0x11) { // From 1.1, there's animation speed - ret->speed = READ_LE_UINT16(dat); + ret->_speed = READ_LE_UINT16(dat); dat += 2; } else - ret->speed = 150; + ret->_speed = 150; } - ret->numframe = *dat++; - ret->numpattern = *dat++; - ret->Zvalue = *dat++; + ret->_numframe = *dat++; + ret->_numpattern = *dat++; + ret->_destZ = *dat++; // Upload the left & top co-ordinates of each frame - for (i = 0; i < ret->numframe; i++) { - ret->frameslocations[i].left = (int16)READ_LE_UINT16(dat); - ret->frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); + for (i = 0; i < ret->_numframe; i++) { + ret->_frameslocations[i].left = (int16)READ_LE_UINT16(dat); + ret->_frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); dat += 4; } // Upload the size of each frame and calculate the right & bottom - for (i = 0; i < ret->numframe; i++) { - ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; - ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; + for (i = 0; i < ret->_numframe; i++) { + ret->_frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->_frameslocations[i].left; + ret->_frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->_frameslocations[i].top; dat += 4; } // Upload the bounding boxes of each frame - for (i = 0; i < ret->numframe; i++) { - ret->bbox[i].left = (int16)READ_LE_UINT16(dat); - ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); - ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); - ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); + for (i = 0; i < ret->_numframe; i++) { + ret->_bbox[i].left = (int16)READ_LE_UINT16(dat); + ret->_bbox[i].top = (int16)READ_LE_UINT16(dat + 2); + ret->_bbox[i].right = (int16)READ_LE_UINT16(dat + 4); + ret->_bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); dat += 8; } // Load the animation pattern patlength = dat; - dat += ret->numpattern; + dat += ret->_numpattern; - for (i = 1; i < ret->numpattern; i++) { + for (i = 1; i < ret->_numpattern; i++) { for (j = 0; j < patlength[i]; j++) - ret->pattern[i][j] = dat[j]; - ret->pattern[i][(int)patlength[i]] = 255; // Terminate pattern + ret->_pattern[i][j] = dat[j]; + ret->_pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } // Upload the individual frames of animations - for (i = 1; i < ret->numframe; i++) { - dim = (uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * - (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); - ret->frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); + for (i = 1; i < ret->_numframe; i++) { + dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * + (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); + ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); - if (ret->frames[i] == NULL) + if (ret->_frames[i] == NULL) return NULL; - copyMemory(ret->frames[i], dat, dim); + copyMemory(ret->_frames[i], dat, dim); dat += dim; } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 198083f851..9ea0c40bbc 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -152,19 +152,19 @@ enum QueryTypes { * Framework to manage the animation of an item */ typedef struct { - char *frames[MAXFRAMES]; - Common::Rect frameslocations[MAXFRAMES]; - Common::Rect bbox[MAXFRAMES]; - short pattern[MAXPATTERN][MAXFRAMES]; - short speed; - char numframe; - char numpattern; - char curframe; - char curpattern; - short destX, destY; - signed char Zvalue; - short objectID; - char TAG; + char *_frames[MAXFRAMES]; + Common::Rect _frameslocations[MAXFRAMES]; + Common::Rect _bbox[MAXFRAMES]; + short _pattern[MAXPATTERN][MAXFRAMES]; + short _speed; + char _numframe; + char _numpattern; + char _curframe; + char _curpattern; + short _destX, _destY; + signed char _destZ; + short _objectID; +// char TAG; } ITEM; typedef ITEM *LPITEM; @@ -247,7 +247,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Size */ #define mpalQueryLocationSize(nLoc,dwCoord) \ - mpalQueryDWORD(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + mpalQueryDWORD(MPQ_LOCATION_SIZE, (uint32)(nLoc), (uint32)(dwCoord)) /** @@ -258,7 +258,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; */ // TODO: Determine if this is endian safe #define mpalQueryItemList(nLoc) \ - (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST,(uint32)(nLoc)) + (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST, (uint32)(nLoc)) /** @@ -268,7 +268,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Structure filled with requested information */ #define mpalQueryItemData(nItem) \ - (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA,(uint32)(nItem)) + (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) /** @@ -279,7 +279,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @remarks By default, the pattern of 0 indicates that we should do nothing. */ #define mpalQueryItemPattern(nItem) \ - mpalQueryDWORD(MPQ_ITEM_PATTERN,(uint32)(nItem)) + mpalQueryDWORD(MPQ_ITEM_PATTERN, (uint32)(nItem)) /** @@ -289,7 +289,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns TRUE if the item is active, FALSE otherwise */ #define mpalQueryItemIsActive(nItem) \ - (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE, (uint32)(nItem)) /** @@ -302,7 +302,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * is less than or equal to 0), the string will be empty. */ #define mpalQueryItemName(nItem, lpszName) \ - mpalQueryHANDLE(MPQ_ITEM_NAME,(uint32)(nItem), (LPSTR)(lpszName)) + mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (LPSTR)(lpszName)) /** @@ -337,7 +337,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * The pointer msut be freed after use using the memory memory. */ #define mpalQueryDialogSelectList(nChoice) \ - (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) /** @@ -351,11 +351,11 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * Groups according to the execution of the dialogue. And necessary so the game * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). */ -#define mpalQueryDialogSelection(nChoice,dwData) \ - (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) +#define mpalQueryDialogSelection(nChoice, dwData) \ + (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) -#define mpalQueryDialogSelectionDWORD(nChoice,dwData) \ - mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) +#define mpalQueryDialogSelectionDWORD(nChoice, dwData) \ + mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) /** diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index f0357ad15d..6852369c64 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -178,7 +178,7 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Call the Draw() of the parent class if Tony is visible - if (_bShow && bDrawNow) { + if (_bShow && _bDrawNow) { if (_bCorpoDavanti) { prim->getDst().setEmpty(); prim->getDst().offset(-44, -134); @@ -317,8 +317,8 @@ void RMTony::stop(CORO_PARAM) { if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::stop); else { - bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). - bMoving = false; + _bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). + _bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } } else { -- cgit v1.2.3 From 7ace80b0d046126bb2d5f1199fe9f0606c05c11b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 00:34:45 +0200 Subject: TONY: Rename variables in font.h --- engines/tony/font.cpp | 2688 ++++++++++++++++++++++++------------------------- engines/tony/font.h | 60 +- 2 files changed, 1374 insertions(+), 1374 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 23a92c5f30..6652e77e13 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -76,7 +76,7 @@ void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes _fontDimx = dimx; _fontDimy = dimy; - nLetters = nChars; + _nLetters = nChars; } void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { @@ -102,7 +102,7 @@ RMGfxPrimitive *RMFont::makeLetterPrimitive(byte bChar, int &nLength) { // Convert from character to glyph index nLett = convertToLetter(bChar); - assert(nLett < nLetters); + assert(nLett < _nLetters); // Create primitive font prim = new RMFontPrimitive(this); @@ -153,7 +153,7 @@ int RMFont::stringLen(char bChar, char bNext) { \****************************************************************************/ RMFontColor::RMFontColor() : RMFont() { - m_r = m_g = m_b = 255; + _fontR = _fontG = _fontB = 255; } RMFontColor::~RMFontColor() { @@ -172,12 +172,12 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { byte pal[768 * 3]; // Check if we are already on the right colour - if (m_r == r1 && m_g == g1 && m_b == b1) + if (_fontR == r1 && _fontG == g1 && _fontB == b1) return; - m_r = r1; - m_g = g1; - m_b = b1; + _fontR = r1; + _fontG = g1; + _fontB = b1; // Constructs a new paletter for the font for (i = 1; i < 16; i++) { @@ -195,7 +195,7 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { pal[15 * 3 + 2] += 8; // Puts in all the letters - for (i = 0; i < nLetters; i++) + for (i = 0; i < _nLetters; i++) _letter[i].loadPaletteWA(pal); } @@ -219,151 +219,151 @@ void RMFontParla::init(void) { load(RES_F_PARL, nchars, 20, 20); // Initialise the f**king table - lDefault = 13; - hDefault = 18; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 13; + _hDefault = 18; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) - cTable['A' + i] = i + 0; + _cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a' + i] = i + 26; + _cTable['a' + i] = i + 26; for (i = 0; i < 10; i++) - cTable['0' + i] = i + 52; - - cTable[';'] = 62; - cTable[','] = 63; - cTable['.'] = 64; - cTable[':'] = 65; - cTable['-'] = 66; - cTable['_'] = 67; - cTable['+'] = 68; - cTable['<'] = 69; - cTable['>'] = 70; - cTable['!'] = 71; - //cTable['!'] = 72; Exclamation countdown - cTable['?'] = 73; - //cTable['?'] = 74; Question down - cTable['('] = 75; - cTable[')'] = 76; - cTable['\"'] = 77; - cTable['^'] = 77; - cTable['/'] = 78; - cTable[(byte)''] = 79; - cTable['$'] = 80; - cTable['%'] = 81; - cTable['&'] = 82; - cTable['='] = 83; - cTable[(byte)''] = 84; - cTable[(byte)''] = 85; - cTable[(byte)''] = 86; - cTable[(byte)''] = 87; - cTable[(byte)''] = 88; - cTable[(byte)''] = 89; - cTable[(byte)''] = 89; - cTable[(byte)''] = 90; - cTable[(byte)''] = 91; - cTable[(byte)''] = 92; - cTable[(byte)''] = 93; - cTable[(byte)''] = 94; - cTable[(byte)''] = 95; - cTable[(byte)''] = 96; - cTable[(byte)''] = 97; - cTable[(byte)''] = 98; - cTable[(byte)''] = 99; - //cTable[' '] = 100; e circlet - //cTable[' '] = 101; i circlet - //cTable[' '] = 102; o circlet - //cTable[' '] = 103; u circlet - cTable[(byte)''] = 104; - cTable[(byte)''] = 105; - cTable[(byte)''] = 106; - cTable[(byte)''] = 107; - cTable[(byte)''] = 108; - cTable[(byte)''] = 109; - //cTable[''] = 110; integral - cTable['\''] = 111; + _cTable['0' + i] = i + 52; + + _cTable[';'] = 62; + _cTable[','] = 63; + _cTable['.'] = 64; + _cTable[':'] = 65; + _cTable['-'] = 66; + _cTable['_'] = 67; + _cTable['+'] = 68; + _cTable['<'] = 69; + _cTable['>'] = 70; + _cTable['!'] = 71; + //_cTable['!'] = 72; Exclamation countdown + _cTable['?'] = 73; + //_cTable['?'] = 74; Question down + _cTable['('] = 75; + _cTable[')'] = 76; + _cTable['\"'] = 77; + _cTable['^'] = 77; + _cTable['/'] = 78; + _cTable[(byte)''] = 79; + _cTable['$'] = 80; + _cTable['%'] = 81; + _cTable['&'] = 82; + _cTable['='] = 83; + _cTable[(byte)''] = 84; + _cTable[(byte)''] = 85; + _cTable[(byte)''] = 86; + _cTable[(byte)''] = 87; + _cTable[(byte)''] = 88; + _cTable[(byte)''] = 89; + _cTable[(byte)''] = 89; + _cTable[(byte)''] = 90; + _cTable[(byte)''] = 91; + _cTable[(byte)''] = 92; + _cTable[(byte)''] = 93; + _cTable[(byte)''] = 94; + _cTable[(byte)''] = 95; + _cTable[(byte)''] = 96; + _cTable[(byte)''] = 97; + _cTable[(byte)''] = 98; + _cTable[(byte)''] = 99; + //_cTable[' '] = 100; e circlet + //_cTable[' '] = 101; i circlet + //_cTable[' '] = 102; o circlet + //_cTable[' '] = 103; u circlet + _cTable[(byte)''] = 104; + _cTable[(byte)''] = 105; + _cTable[(byte)''] = 106; + _cTable[(byte)''] = 107; + _cTable[(byte)''] = 108; + _cTable[(byte)''] = 109; + //_cTable[''] = 110; integral + _cTable['\''] = 111; // Little lengths - lTable[' '] = 9; - lTable['\''] = 5; - lTable['.'] = 5; - lTable[','] = 5; - lTable[':'] = 5; - lTable[';'] = 5; - lTable['!'] = 5; - lTable['?'] = 10; - lTable['\"'] = 5; - lTable['^'] = 5; - lTable['('] = 7; - lTable[')'] = 7; - - lTable['4'] = 10; - - lTable['a'] = 14; - lTable['b'] = 15; - lTable['c'] = 12; - lTable['e'] = 12; - lTable['i'] = 6; - lTable[''] = 6; - lTable['l'] = 5; - lTable['m'] = 16; - lTable['n'] = 12; - lTable['o'] = 11; - lTable['p'] = 11; - lTable['s'] = 12; - lTable['u'] = 12; - - lTable['E'] = 10; - lTable['F'] = 11; + _lTable[' '] = 9; + _lTable['\''] = 5; + _lTable['.'] = 5; + _lTable[','] = 5; + _lTable[':'] = 5; + _lTable[';'] = 5; + _lTable['!'] = 5; + _lTable['?'] = 10; + _lTable['\"'] = 5; + _lTable['^'] = 5; + _lTable['('] = 7; + _lTable[')'] = 7; + + _lTable['4'] = 10; + + _lTable['a'] = 14; + _lTable['b'] = 15; + _lTable['c'] = 12; + _lTable['e'] = 12; + _lTable['i'] = 6; + _lTable[''] = 6; + _lTable['l'] = 5; + _lTable['m'] = 16; + _lTable['n'] = 12; + _lTable['o'] = 11; + _lTable['p'] = 11; + _lTable['s'] = 12; + _lTable['u'] = 12; + + _lTable['E'] = 10; + _lTable['F'] = 11; if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; + _cTable[(byte)''] = 112; + _cTable[(byte)''] = 113; + _cTable[(byte)''] = 114; + _cTable[(byte)''] = 115; + _cTable[(byte)''] = 116; + _cTable[(byte)''] = 117; + _cTable[(byte)''] = 118; + _cTable[(byte)''] = 119; + _cTable[(byte)''] = 120; + _cTable[(byte)''] = 121; + _cTable[(byte)''] = 122; + _cTable[(byte)''] = 123; + _cTable[(byte)''] = 124; + _cTable[(byte)''] = 125; + _cTable[(byte)''] = 126; + _cTable[(byte)''] = 127; + _cTable[(byte)''] = 128; + _cTable[(byte)''] = 129; + + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; } else if (_vm->getLanguage() == Common::RU_RUS) { @@ -372,237 +372,237 @@ void RMFontParla::init(void) { // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 18; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 18; - lTable[(byte)''] = 19; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 9; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; + _cTable[(byte)''] = 130; + _cTable[(byte)''] = 131; + _cTable[(byte)''] = 132; + _cTable[(byte)''] = 133; + _cTable[(byte)''] = 134; + _cTable[(byte)''] = 135; + _cTable[(byte)''] = 136; + _cTable[(byte)''] = 137; + _cTable[(byte)''] = 138; + _cTable[(byte)''] = 139; + _cTable[(byte)''] = 140; + _cTable[(byte)''] = 141; + _cTable[(byte)''] = 142; + _cTable[(byte)''] = 143; + _cTable[(byte)''] = 144; + _cTable[(byte)''] = 145; + _cTable[(byte)''] = 146; + _cTable[(byte)''] = 147; + _cTable[(byte)''] = 148; + _cTable[(byte)''] = 149; + _cTable[(byte)''] = 150; + _cTable[(byte)''] = 151; + _cTable[(byte)''] = 152; + _cTable[(byte)''] = 153; + _cTable[(byte)''] = 154; + _cTable[(byte)''] = 155; + _cTable[(byte)''] = 156; + _cTable[(byte)''] = 157; + _cTable[(byte)''] = 158; + _cTable[(byte)''] = 159; + _cTable[(byte)''] = 160; + _cTable[(byte)''] = 161; + _cTable[(byte)''] = 162; + + _cTable[(byte)''] = 163; + _cTable[(byte)''] = 164; + _cTable[(byte)''] = 165; + _cTable[(byte)''] = 166; + _cTable[(byte)''] = 167; + _cTable[(byte)''] = 168; + _cTable[(byte)''] = 169; + _cTable[(byte)''] = 170; + _cTable[(byte)''] = 171; + _cTable[(byte)''] = 172; + _cTable[(byte)''] = 173; + _cTable[(byte)''] = 174; + _cTable[(byte)''] = 175; + _cTable[(byte)''] = 176; + _cTable[(byte)''] = 177; + _cTable[(byte)''] = 178; + _cTable[(byte)''] = 179; + _cTable[(byte)''] = 180; + _cTable[(byte)''] = 181; + _cTable[(byte)''] = 182; + _cTable[(byte)''] = 183; + _cTable[(byte)''] = 184; + _cTable[(byte)''] = 185; + _cTable[(byte)''] = 186; + _cTable[(byte)''] = 187; + _cTable[(byte)''] = 188; + _cTable[(byte)''] = 189; + _cTable[(byte)''] = 190; + _cTable[(byte)''] = 191; + _cTable[(byte)''] = 192; + _cTable[(byte)''] = 193; + _cTable[(byte)''] = 194; + _cTable[(byte)''] = 195; + + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 17; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 19; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 8; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 14; } else if (_vm->getLanguage() == Common::CZ_CZE) { // Czech - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 19; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 7; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; + _cTable[(byte)''] = 196; + _cTable[(byte)''] = 197; + _cTable[(byte)''] = 198; + _cTable[(byte)''] = 199; + _cTable[(byte)''] = 200; + _cTable[(byte)''] = 201; + _cTable[(byte)''] = 202; + _cTable[(byte)''] = 203; + _cTable[(byte)''] = 204; + _cTable[(byte)''] = 205; + _cTable[(byte)''] = 206; + _cTable[(byte)''] = 207; + _cTable[(byte)''] = 208; + _cTable[(byte)''] = 209; + _cTable[(byte)''] = 210; + + _cTable[(byte)''] = 211; + _cTable[(byte)''] = 212; + _cTable[(byte)''] = 213; + _cTable[(byte)''] = 214; + _cTable[(byte)''] = 215; + _cTable[(byte)''] = 216; + _cTable[(byte)''] = 217; + _cTable[(byte)''] = 218; + _cTable[(byte)''] = 219; + _cTable[(byte)''] = 220; + _cTable[(byte)''] = 221; + _cTable[(byte)''] = 222; + _cTable[(byte)''] = 223; + _cTable[(byte)''] = 224; + _cTable[(byte)''] = 225; + + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 19; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 7; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 17; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; } else if (_vm->getLanguage() == Common::FR_FRA) { // French - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 9; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 226; + _cTable[(byte)''] = 227; + _cTable[(byte)''] = 228; + _cTable[(byte)''] = 229; + _cTable[(byte)''] = 230; + _cTable[(byte)''] = 231; + _cTable[(byte)''] = 232; + _cTable[(byte)''] = 233; + + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::DE_DEU) { - cTable[(byte)''] = 234; + _cTable[(byte)''] = 234; // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; + _cTable[(byte)''] = 236; + _cTable[(byte)''] = 237; + _cTable[(byte)''] = 238; - lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; } } @@ -627,347 +627,347 @@ void RMFontMacc::init(void) { load(RES_F_MACC, nchars, 11, 16); // Default - lDefault = 10; - hDefault = 17; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 10; + _hDefault = 17; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) - cTable['A' + i] = i + 0; + _cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a' + i] = i + 26; + _cTable['a' + i] = i + 26; for (i = 0; i < 10; i++) - cTable['0' + i] = i + 52; - - cTable['!'] = 62; - //cTable['!'] = 63; // ! rovescia - cTable['\"'] = 64; - cTable['$'] = 65; - cTable['%'] = 66; - cTable['&'] = 67; - cTable['/'] = 68; - cTable['('] = 69; - cTable[')'] = 70; - cTable['='] = 71; - cTable['?'] = 72; - //cTable['?'] = 73; // ? rovescia - cTable['*'] = 74; - cTable['+'] = 75; - cTable[(byte)''] = 76; - cTable[';'] = 77; - cTable[','] = 78; - cTable['.'] = 79; - cTable[':'] = 80; - cTable['-'] = 81; - cTable['<'] = 82; - cTable['>'] = 83; - cTable['/'] = 84; - cTable[(byte)''] = 85; - cTable[(byte)''] = 86; - cTable[(byte)''] = 87; - cTable[(byte)''] = 88; - cTable[(byte)''] = 89; - cTable[(byte)''] = 90; - //cTable[(byte)''] = 91; // e with ball - cTable[(byte)''] = 92; - cTable[(byte)''] = 93; - //cTable[(byte)''] = 94; // i with ball - cTable[(byte)''] = 95; - cTable[(byte)''] = 96; - //cTable[(byte)''] = 97; // o with ball - cTable[(byte)''] = 98; - cTable[(byte)''] = 99; - //cTable[(byte)''] = 100; // u with ball - cTable[(byte)''] = 101; + _cTable['0' + i] = i + 52; + + _cTable['!'] = 62; + //_cTable['!'] = 63; // ! rovescia + _cTable['\"'] = 64; + _cTable['$'] = 65; + _cTable['%'] = 66; + _cTable['&'] = 67; + _cTable['/'] = 68; + _cTable['('] = 69; + _cTable[')'] = 70; + _cTable['='] = 71; + _cTable['?'] = 72; + //_cTable['?'] = 73; // ? rovescia + _cTable['*'] = 74; + _cTable['+'] = 75; + _cTable[(byte)''] = 76; + _cTable[';'] = 77; + _cTable[','] = 78; + _cTable['.'] = 79; + _cTable[':'] = 80; + _cTable['-'] = 81; + _cTable['<'] = 82; + _cTable['>'] = 83; + _cTable['/'] = 84; + _cTable[(byte)''] = 85; + _cTable[(byte)''] = 86; + _cTable[(byte)''] = 87; + _cTable[(byte)''] = 88; + _cTable[(byte)''] = 89; + _cTable[(byte)''] = 90; + //_cTable[(byte)''] = 91; // e with ball + _cTable[(byte)''] = 92; + _cTable[(byte)''] = 93; + //_cTable[(byte)''] = 94; // i with ball + _cTable[(byte)''] = 95; + _cTable[(byte)''] = 96; + //_cTable[(byte)''] = 97; // o with ball + _cTable[(byte)''] = 98; + _cTable[(byte)''] = 99; + //_cTable[(byte)''] = 100; // u with ball + _cTable[(byte)''] = 101; if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[(byte)''] = 102; - cTable[(byte)''] = 103; - cTable[(byte)''] = 104; - cTable[(byte)''] = 105; - cTable[(byte)''] = 106; - cTable[(byte)''] = 107; - cTable[(byte)''] = 108; - cTable[(byte)''] = 109; - cTable[(byte)''] = 110; - cTable[(byte)''] = 111; - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; + _cTable[(byte)''] = 102; + _cTable[(byte)''] = 103; + _cTable[(byte)''] = 104; + _cTable[(byte)''] = 105; + _cTable[(byte)''] = 106; + _cTable[(byte)''] = 107; + _cTable[(byte)''] = 108; + _cTable[(byte)''] = 109; + _cTable[(byte)''] = 110; + _cTable[(byte)''] = 111; + _cTable[(byte)''] = 112; + _cTable[(byte)''] = 113; + _cTable[(byte)''] = 114; + _cTable[(byte)''] = 115; + _cTable[(byte)''] = 116; + _cTable[(byte)''] = 117; + _cTable[(byte)''] = 118; + _cTable[(byte)''] = 119; + + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 8; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 120; + _cTable[(byte)''] = 121; + _cTable[(byte)''] = 122; + _cTable[(byte)''] = 123; + _cTable[(byte)''] = 124; + _cTable[(byte)''] = 125; + _cTable[(byte)''] = 126; + _cTable[(byte)''] = 127; + _cTable[(byte)''] = 128; + _cTable[(byte)''] = 129; + _cTable[(byte)''] = 130; + _cTable[(byte)''] = 131; + _cTable[(byte)''] = 132; + _cTable[(byte)''] = 133; + _cTable[(byte)''] = 134; + _cTable[(byte)''] = 135; + _cTable[(byte)''] = 136; + _cTable[(byte)''] = 137; + _cTable[(byte)''] = 138; + _cTable[(byte)''] = 139; + _cTable[(byte)''] = 140; + _cTable[(byte)''] = 141; + _cTable[(byte)''] = 142; + _cTable[(byte)''] = 143; + _cTable[(byte)''] = 144; + _cTable[(byte)''] = 145; + _cTable[(byte)''] = 146; + _cTable[(byte)''] = 147; + _cTable[(byte)''] = 148; + _cTable[(byte)''] = 149; + _cTable[(byte)''] = 150; + _cTable[(byte)''] = 151; + _cTable[(byte)''] = 152; + + _cTable[(byte)''] = 153; + _cTable[(byte)''] = 154; + _cTable[(byte)''] = 155; + _cTable[(byte)''] = 156; + _cTable[(byte)''] = 157; + _cTable[(byte)''] = 158; + _cTable[(byte)''] = 159; + _cTable[(byte)''] = 160; + _cTable[(byte)''] = 161; + _cTable[(byte)''] = 162; + _cTable[(byte)''] = 163; + _cTable[(byte)''] = 164; + _cTable[(byte)''] = 165; + _cTable[(byte)''] = 166; + _cTable[(byte)''] = 167; + _cTable[(byte)''] = 168; + _cTable[(byte)''] = 169; + _cTable[(byte)''] = 170; + _cTable[(byte)''] = 171; + _cTable[(byte)''] = 172; + _cTable[(byte)''] = 173; + _cTable[(byte)''] = 174; + _cTable[(byte)''] = 175; + _cTable[(byte)''] = 176; + _cTable[(byte)''] = 177; + _cTable[(byte)''] = 178; + _cTable[(byte)''] = 179; + _cTable[(byte)''] = 180; + _cTable[(byte)''] = 181; + _cTable[(byte)''] = 182; + _cTable[(byte)''] = 183; + _cTable[(byte)''] = 184; + _cTable[(byte)''] = 185; + + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 8; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::CZ_CZE) { // Czech - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 186; + _cTable[(byte)''] = 187; + _cTable[(byte)''] = 188; + _cTable[(byte)''] = 189; + _cTable[(byte)''] = 190; + _cTable[(byte)''] = 191; + _cTable[(byte)''] = 192; + _cTable[(byte)''] = 193; + _cTable[(byte)''] = 194; + _cTable[(byte)''] = 195; + _cTable[(byte)''] = 196; + _cTable[(byte)''] = 197; + _cTable[(byte)''] = 198; + _cTable[(byte)''] = 199; + _cTable[(byte)''] = 200; + + _cTable[(byte)''] = 201; + _cTable[(byte)''] = 202; + _cTable[(byte)''] = 203; + _cTable[(byte)''] = 204; + _cTable[(byte)''] = 205; + _cTable[(byte)''] = 206; + _cTable[(byte)''] = 207; + _cTable[(byte)''] = 208; + _cTable[(byte)''] = 209; + _cTable[(byte)''] = 210; + _cTable[(byte)''] = 211; + _cTable[(byte)''] = 212; + _cTable[(byte)''] = 213; + _cTable[(byte)''] = 214; + _cTable[(byte)''] = 215; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::FR_FRA) { // French - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; + _cTable[(byte)''] = 226; + _cTable[(byte)''] = 227; + _cTable[(byte)''] = 228; + _cTable[(byte)''] = 229; + _cTable[(byte)''] = 230; + _cTable[(byte)''] = 231; + _cTable[(byte)''] = 232; + _cTable[(byte)''] = 233; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 8; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::DE_DEU) { // German - cTable[(byte)''] = 234; + _cTable[(byte)''] = 234; // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; + _cTable[(byte)''] = 236; + _cTable[(byte)''] = 237; + _cTable[(byte)''] = 238; - lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } } @@ -991,435 +991,435 @@ void RMFontCredits::init(void) { load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); // Default - lDefault = 10; - hDefault = 28; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 10; + _hDefault = 28; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) - cTable['A' + i] = i + 0; + _cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a' + i] = i + 26; - - - - cTable[(byte)''] = 52; - cTable[(byte)''] = 53; -// cTable[''] = 54; // a ^ -// cTable[''] = 55; // a pallini - cTable[(byte)''] = 56; - cTable[(byte)''] = 57; -// cTable[''] = 58; // e ^ -// cTable[''] = 59; // e pallini - cTable[(byte)''] = 60; - cTable[(byte)''] = 61; -// cTable[''] = 62; // i ^ -// cTable[''] = 63; // i pallini - cTable[(byte)''] = 64; - cTable[(byte)''] = 65; -// cTable[''] = 66; // o ^ -// cTable[''] = 67; // o pallini - cTable[(byte)''] = 68; - cTable[(byte)''] = 69; -// cTable[''] = 70; // u ^ -// cTable[''] = 71; // u pallini -// cTable[''] = 72; // y pallini - cTable[(byte)''] = 73; - cTable[(byte)''] = 74; -// cTable[''] = 75; // o barrato -// cTable[''] = 76; // ac - cTable[(byte)''] = 77; -// cTable[''] = 78; // ? rovesciato - cTable['?'] = 79; -// cTable[''] = 80; // ! rovesciato - cTable['!'] = 81; -// cTable[''] = 82; // 1/2 -// cTable[''] = 83; // 1/4 - cTable['('] = 84; - cTable[')'] = 85; - cTable[(byte)''] = 86; - cTable[(byte)''] = 87; -// cTable[''] = 88; // AE - cTable[':'] = 89; - cTable['%'] = 90; - cTable['&'] = 91; - cTable['/'] = 92; - cTable['+'] = 93; - cTable[';'] = 94; - cTable[','] = 95; - cTable['^'] = 96; - cTable['='] = 97; - cTable['_'] = 98; - cTable['*'] = 99; - cTable['.'] = 100; + _cTable['a' + i] = i + 26; + + + + _cTable[(byte)''] = 52; + _cTable[(byte)''] = 53; +// _cTable[''] = 54; // a ^ +// _cTable[''] = 55; // a pallini + _cTable[(byte)''] = 56; + _cTable[(byte)''] = 57; +// _cTable[''] = 58; // e ^ +// _cTable[''] = 59; // e pallini + _cTable[(byte)''] = 60; + _cTable[(byte)''] = 61; +// _cTable[''] = 62; // i ^ +// _cTable[''] = 63; // i pallini + _cTable[(byte)''] = 64; + _cTable[(byte)''] = 65; +// _cTable[''] = 66; // o ^ +// _cTable[''] = 67; // o pallini + _cTable[(byte)''] = 68; + _cTable[(byte)''] = 69; +// _cTable[''] = 70; // u ^ +// _cTable[''] = 71; // u pallini +// _cTable[''] = 72; // y pallini + _cTable[(byte)''] = 73; + _cTable[(byte)''] = 74; +// _cTable[''] = 75; // o barrato +// _cTable[''] = 76; // ac + _cTable[(byte)''] = 77; +// _cTable[''] = 78; // ? rovesciato + _cTable['?'] = 79; +// _cTable[''] = 80; // ! rovesciato + _cTable['!'] = 81; +// _cTable[''] = 82; // 1/2 +// _cTable[''] = 83; // 1/4 + _cTable['('] = 84; + _cTable[')'] = 85; + _cTable[(byte)''] = 86; + _cTable[(byte)''] = 87; +// _cTable[''] = 88; // AE + _cTable[':'] = 89; + _cTable['%'] = 90; + _cTable['&'] = 91; + _cTable['/'] = 92; + _cTable['+'] = 93; + _cTable[';'] = 94; + _cTable[','] = 95; + _cTable['^'] = 96; + _cTable['='] = 97; + _cTable['_'] = 98; + _cTable['*'] = 99; + _cTable['.'] = 100; for (i = 0; i < 10; i++) - cTable['0' + i] = i + 101; - cTable['\''] = 111; - - lTable[' '] = 11; - lTable[(byte)''] = lTable['A'] = 19; - lTable['B'] = 15; - lTable['C'] = 14; - lTable['D'] = 13; - lTable['E'] = 14; - lTable['F'] = 13; - lTable['G'] = 16; - lTable['H'] = 15; - lTable['I'] = 5; - lTable['J'] = 8; - lTable['K'] = 15; - lTable['L'] = 13; - lTable['M'] = 17; - lTable['N'] = 15; - lTable[''] = lTable['O'] = 14; - lTable['P'] = 12; - lTable['Q'] = 14; - lTable['R'] = 14; - lTable['S'] = 15; - lTable['T'] = 11; - lTable[''] = lTable['U'] = 12; - lTable['V'] = 12; - lTable['W'] = 16; - lTable['X'] = 12; - lTable['Y'] = 13; - lTable['Z'] = 14; - - lTable['a'] = 11; - lTable['b'] = 9; - lTable['c'] = 9; - lTable['d'] = 10; - lTable['e'] = 9; - lTable['f'] = 8; - lTable['g'] = 9; - lTable['h'] = 10; - lTable['i'] = 5; - lTable['j'] = 6; - lTable['k'] = 12; - lTable['l'] = 6; - lTable['m'] = 14; - lTable['n'] = 10; - lTable['o'] = 11; - lTable['p'] = 11; - lTable['q'] = 9; - lTable['r'] = 9; - lTable['s'] = 9; - lTable['t'] = 6; - lTable['u'] = 9; - lTable['v'] = 10; - lTable['w'] = 14; - lTable['x'] = 9; - lTable['y'] = 10; - lTable['z'] = 9; - - lTable['0'] = 12; - lTable['1'] = 8; - lTable['2'] = 10; - lTable['3'] = 11; - lTable['4'] = 12; - lTable['5'] = 11; - lTable['6'] = 12; - lTable['7'] = 10; - lTable['8'] = 11; - lTable['9'] = 10; - - lTable['/'] = 10; - lTable['^'] = 9; - lTable[','] = 5; - lTable['.'] = 5; - lTable[';'] = 5; - lTable[':'] = 5; - lTable['\''] = 5; + _cTable['0' + i] = i + 101; + _cTable['\''] = 111; + + _lTable[' '] = 11; + _lTable[(byte)''] = _lTable['A'] = 19; + _lTable['B'] = 15; + _lTable['C'] = 14; + _lTable['D'] = 13; + _lTable['E'] = 14; + _lTable['F'] = 13; + _lTable['G'] = 16; + _lTable['H'] = 15; + _lTable['I'] = 5; + _lTable['J'] = 8; + _lTable['K'] = 15; + _lTable['L'] = 13; + _lTable['M'] = 17; + _lTable['N'] = 15; + _lTable[''] = _lTable['O'] = 14; + _lTable['P'] = 12; + _lTable['Q'] = 14; + _lTable['R'] = 14; + _lTable['S'] = 15; + _lTable['T'] = 11; + _lTable[''] = _lTable['U'] = 12; + _lTable['V'] = 12; + _lTable['W'] = 16; + _lTable['X'] = 12; + _lTable['Y'] = 13; + _lTable['Z'] = 14; + + _lTable['a'] = 11; + _lTable['b'] = 9; + _lTable['c'] = 9; + _lTable['d'] = 10; + _lTable['e'] = 9; + _lTable['f'] = 8; + _lTable['g'] = 9; + _lTable['h'] = 10; + _lTable['i'] = 5; + _lTable['j'] = 6; + _lTable['k'] = 12; + _lTable['l'] = 6; + _lTable['m'] = 14; + _lTable['n'] = 10; + _lTable['o'] = 11; + _lTable['p'] = 11; + _lTable['q'] = 9; + _lTable['r'] = 9; + _lTable['s'] = 9; + _lTable['t'] = 6; + _lTable['u'] = 9; + _lTable['v'] = 10; + _lTable['w'] = 14; + _lTable['x'] = 9; + _lTable['y'] = 10; + _lTable['z'] = 9; + + _lTable['0'] = 12; + _lTable['1'] = 8; + _lTable['2'] = 10; + _lTable['3'] = 11; + _lTable['4'] = 12; + _lTable['5'] = 11; + _lTable['6'] = 12; + _lTable['7'] = 10; + _lTable['8'] = 11; + _lTable['9'] = 10; + + _lTable['/'] = 10; + _lTable['^'] = 9; + _lTable[','] = 5; + _lTable['.'] = 5; + _lTable[';'] = 5; + _lTable[':'] = 5; + _lTable['\''] = 5; if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; + _cTable[(byte)''] = 112; + _cTable[(byte)''] = 113; + _cTable[(byte)''] = 114; + _cTable[(byte)''] = 115; + _cTable[(byte)''] = 116; + _cTable[(byte)''] = 117; + _cTable[(byte)''] = 118; + _cTable[(byte)''] = 119; + _cTable[(byte)''] = 120; + _cTable[(byte)''] = 121; + _cTable[(byte)''] = 122; + _cTable[(byte)''] = 123; + _cTable[(byte)''] = 124; + _cTable[(byte)''] = 125; + _cTable[(byte)''] = 126; + _cTable[(byte)''] = 127; + _cTable[(byte)''] = 128; + _cTable[(byte)''] = 129; + + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 22; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 22; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 23; - lTable[(byte)''] = 23; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 20; - lTable[(byte)''] = 15; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 130; + _cTable[(byte)''] = 131; + _cTable[(byte)''] = 132; + _cTable[(byte)''] = 133; + _cTable[(byte)''] = 134; + _cTable[(byte)''] = 135; + _cTable[(byte)''] = 136; + _cTable[(byte)''] = 137; + _cTable[(byte)''] = 138; + _cTable[(byte)''] = 139; + _cTable[(byte)''] = 140; + _cTable[(byte)''] = 141; + _cTable[(byte)''] = 142; + _cTable[(byte)''] = 143; + _cTable[(byte)''] = 144; + _cTable[(byte)''] = 145; + _cTable[(byte)''] = 146; + _cTable[(byte)''] = 147; + _cTable[(byte)''] = 148; + _cTable[(byte)''] = 149; + _cTable[(byte)''] = 150; + _cTable[(byte)''] = 151; + _cTable[(byte)''] = 152; + _cTable[(byte)''] = 153; + _cTable[(byte)''] = 154; + _cTable[(byte)''] = 155; + _cTable[(byte)''] = 156; + _cTable[(byte)''] = 157; + _cTable[(byte)''] = 158; + _cTable[(byte)''] = 159; + _cTable[(byte)''] = 160; + _cTable[(byte)''] = 161; + _cTable[(byte)''] = 162; + + _cTable[(byte)''] = 163; + _cTable[(byte)''] = 164; + _cTable[(byte)''] = 165; + _cTable[(byte)''] = 166; + _cTable[(byte)''] = 167; + _cTable[(byte)''] = 168; + _cTable[(byte)''] = 169; + _cTable[(byte)''] = 170; + _cTable[(byte)''] = 171; + _cTable[(byte)''] = 172; + _cTable[(byte)''] = 173; + _cTable[(byte)''] = 174; + _cTable[(byte)''] = 175; + _cTable[(byte)''] = 176; + _cTable[(byte)''] = 177; + _cTable[(byte)''] = 178; + _cTable[(byte)''] = 179; + _cTable[(byte)''] = 180; + _cTable[(byte)''] = 181; + _cTable[(byte)''] = 182; + _cTable[(byte)''] = 183; + _cTable[(byte)''] = 184; + _cTable[(byte)''] = 185; + _cTable[(byte)''] = 186; + _cTable[(byte)''] = 187; + _cTable[(byte)''] = 188; + _cTable[(byte)''] = 189; + _cTable[(byte)''] = 190; + _cTable[(byte)''] = 191; + _cTable[(byte)''] = 192; + _cTable[(byte)''] = 193; + _cTable[(byte)''] = 194; + _cTable[(byte)''] = 195; + + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 22; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 22; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 23; + _lTable[(byte)''] = 23; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 15; + + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::CZ_CZE) { // CZECH Language - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 20; - lTable[(byte)''] = 7; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 19; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; + _cTable[(byte)''] = 196; + _cTable[(byte)''] = 197; + _cTable[(byte)''] = 198; + _cTable[(byte)''] = 199; + _cTable[(byte)''] = 200; + _cTable[(byte)''] = 201; + _cTable[(byte)''] = 202; + _cTable[(byte)''] = 203; + _cTable[(byte)''] = 204; + _cTable[(byte)''] = 205; + _cTable[(byte)''] = 206; + _cTable[(byte)''] = 207; + _cTable[(byte)''] = 208; + _cTable[(byte)''] = 209; + _cTable[(byte)''] = 210; + + _cTable[(byte)''] = 211; + _cTable[(byte)''] = 212; + _cTable[(byte)''] = 213; + _cTable[(byte)''] = 214; + _cTable[(byte)''] = 215; + _cTable[(byte)''] = 216; + _cTable[(byte)''] = 217; + _cTable[(byte)''] = 218; + _cTable[(byte)''] = 219; + _cTable[(byte)''] = 220; + _cTable[(byte)''] = 221; + _cTable[(byte)''] = 222; + _cTable[(byte)''] = 223; + _cTable[(byte)''] = 224; + _cTable[(byte)''] = 225; + + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 7; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 19; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 6; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::FR_FRA) { // French - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 226; + _cTable[(byte)''] = 227; + _cTable[(byte)''] = 228; + _cTable[(byte)''] = 229; + _cTable[(byte)''] = 230; + _cTable[(byte)''] = 231; + _cTable[(byte)''] = 232; + _cTable[(byte)''] = 233; + + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 6; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::DE_DEU) { // German - cTable[(byte)''] = 234; + _cTable[(byte)''] = 234; // 'SS' = 235 // old chars overrides - cTable[(byte)''] = cTable[(byte)''] = 55; - cTable[(byte)''] = cTable[(byte)''] = 67; - cTable[(byte)''] = cTable[(byte)''] = 71; + _cTable[(byte)''] = _cTable[(byte)''] = 55; + _cTable[(byte)''] = _cTable[(byte)''] = 67; + _cTable[(byte)''] = _cTable[(byte)''] = 71; - lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } } @@ -1433,10 +1433,10 @@ void RMFontCredits::init(void) { #define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) void RMFontObj::setBothCase(int nChar, int nNext, signed char spiazz) { - l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; - l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; - l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; - l2Table[TOLOWER(nChar)][TOLOWER(nNext)] = spiazz; + _l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; + _l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; + _l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; + _l2Table[TOLOWER(nChar)][TOLOWER(nNext)] = spiazz; } @@ -1456,116 +1456,116 @@ void RMFontObj::init(void) { load(RES_F_OBJ, nchars, 25, 30); // Initialise the f**king table - lDefault = 26; - hDefault = 30; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 26; + _hDefault = 30; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) { - cTable['A' + i] = i + 0; - cTable['a' + i] = i + 0; + _cTable['A' + i] = i + 0; + _cTable['a' + i] = i + 0; } for (i = 0; i < 10; i++) - cTable['0' + i] = i + 26; - - cTable[','] = 36; - cTable[';'] = 37; - cTable['.'] = 38; - cTable[':'] = 39; - cTable['-'] = 40; - cTable['+'] = 41; - cTable['!'] = 42; - // cTable['!'] = 43; Exclamation countdown - cTable['?'] = 44; - //cTable['?'] = 45; Interrogativo alla rovescia - cTable['/'] = 46; - cTable['('] = 47; - cTable[')'] = 48; - cTable['='] = 49; - cTable['\''] = 50; - cTable['\"'] = 51; - cTable[(byte)''] = 52; - cTable[(byte)'$'] = 53; - cTable[(byte)'%'] = 54; - cTable[(byte)'&'] = 55; - cTable[(byte)'^'] = 56; - cTable[(byte)'*'] = 57; - cTable[(byte)'<'] = 58; - cTable[(byte)'>'] = 59; - cTable[(byte)''] = 60; - cTable[(byte)''] = 61; - cTable[(byte)''] = 62; - cTable[(byte)''] = 63; - //cTable[(byte)''] = 64; integral - cTable[(byte)''] = 65; - cTable[(byte)''] = 66; - cTable[(byte)''] = 67; - cTable[(byte)''] = 68; - cTable[(byte)''] = 69; - cTable[(byte)''] = cTable[(byte)''] = 70; - cTable[(byte)''] = 71; - cTable[(byte)''] = 72; - cTable[(byte)''] = 73; - //cTable[(byte)' '] = 74; e circlet - cTable[(byte)''] = 75; - cTable[(byte)''] = 76; - //cTable[(byte)' '] = 77; i circlet - cTable[(byte)''] = 78; - cTable[(byte)''] = cTable[(byte)''] = 79; - //cTable[(byte)' '] = 80; o circlet - cTable[(byte)''] = 81; - cTable[(byte)''] = cTable[(byte)''] = 82; - //cTable[' '] = 83; u circlet - //cTable[' '] = 84; y dieresi + _cTable['0' + i] = i + 26; + + _cTable[','] = 36; + _cTable[';'] = 37; + _cTable['.'] = 38; + _cTable[':'] = 39; + _cTable['-'] = 40; + _cTable['+'] = 41; + _cTable['!'] = 42; + // _cTable['!'] = 43; Exclamation countdown + _cTable['?'] = 44; + // _cTable['?'] = 45; Interrogativo alla rovescia + _cTable['/'] = 46; + _cTable['('] = 47; + _cTable[')'] = 48; + _cTable['='] = 49; + _cTable['\''] = 50; + _cTable['\"'] = 51; + _cTable[(byte)''] = 52; + _cTable[(byte)'$'] = 53; + _cTable[(byte)'%'] = 54; + _cTable[(byte)'&'] = 55; + _cTable[(byte)'^'] = 56; + _cTable[(byte)'*'] = 57; + _cTable[(byte)'<'] = 58; + _cTable[(byte)'>'] = 59; + _cTable[(byte)''] = 60; + _cTable[(byte)''] = 61; + _cTable[(byte)''] = 62; + _cTable[(byte)''] = 63; + //_cTable[(byte)''] = 64; integral + _cTable[(byte)''] = 65; + _cTable[(byte)''] = 66; + _cTable[(byte)''] = 67; + _cTable[(byte)''] = 68; + _cTable[(byte)''] = 69; + _cTable[(byte)''] = _cTable[(byte)''] = 70; + _cTable[(byte)''] = 71; + _cTable[(byte)''] = 72; + _cTable[(byte)''] = 73; + //_cTable[(byte)' '] = 74; e circlet + _cTable[(byte)''] = 75; + _cTable[(byte)''] = 76; + //_cTable[(byte)' '] = 77; i circlet + _cTable[(byte)''] = 78; + _cTable[(byte)''] = _cTable[(byte)''] = 79; + //_cTable[(byte)' '] = 80; o circlet + _cTable[(byte)''] = 81; + _cTable[(byte)''] = _cTable[(byte)''] = 82; + //_cTable[' '] = 83; u circlet + //_cTable[' '] = 84; y dieresi /* Little lengths */ - lTable[' '] = 11; - lTable['.'] = 8; - lTable['-'] = 12; - lTable['\''] = 8; - lTable['0'] = 20; - lTable['1'] = 20; - lTable['2'] = 15; - lTable['3'] = 20; - lTable['4'] = 20; - lTable['5'] = 20; - lTable['6'] = 20; - lTable['7'] = 20; - lTable['8'] = 20; - lTable['9'] = 20; - - - lTable['a'] = lTable['A'] = lTable[''] = lTable[''] = 17; - lTable['b'] = lTable['B'] = 17; - lTable['c'] = lTable['C'] = 19; - lTable['d'] = lTable['D'] = 17; - lTable['e'] = lTable['E'] = 15; - lTable['f'] = lTable['F'] = 17; - lTable['g'] = lTable['G'] = 19; - lTable['i'] = lTable['I'] = 16; - lTable['h'] = lTable['H'] = 17; - lTable['k'] = lTable['K'] = 17; - lTable['l'] = lTable['L'] = 14; - lTable['m'] = lTable['M'] = 19; - lTable['n'] = lTable['N'] = 17; - lTable['o'] = lTable['O'] = lTable[''] = lTable[''] = 19; - lTable['p'] = lTable['P'] = 17; - lTable['q'] = lTable['Q'] = 19; - lTable['r'] = lTable['R'] = 14; - lTable['s'] = lTable['S'] = 13; - lTable['t'] = lTable['T'] = 15; - lTable['u'] = lTable['U'] = lTable[''] = lTable[''] = 15; - lTable['v'] = lTable['V'] = 13; - lTable['x'] = lTable['X'] = 15; - lTable['y'] = lTable['Y'] = 13; - lTable['w'] = lTable['W'] = 19; - lTable['z'] = lTable['Z'] = 20; - lTable[(byte)''] = 17; + _lTable[' '] = 11; + _lTable['.'] = 8; + _lTable['-'] = 12; + _lTable['\''] = 8; + _lTable['0'] = 20; + _lTable['1'] = 20; + _lTable['2'] = 15; + _lTable['3'] = 20; + _lTable['4'] = 20; + _lTable['5'] = 20; + _lTable['6'] = 20; + _lTable['7'] = 20; + _lTable['8'] = 20; + _lTable['9'] = 20; + + + _lTable['a'] = _lTable['A'] = _lTable[''] = _lTable[''] = 17; + _lTable['b'] = _lTable['B'] = 17; + _lTable['c'] = _lTable['C'] = 19; + _lTable['d'] = _lTable['D'] = 17; + _lTable['e'] = _lTable['E'] = 15; + _lTable['f'] = _lTable['F'] = 17; + _lTable['g'] = _lTable['G'] = 19; + _lTable['i'] = _lTable['I'] = 16; + _lTable['h'] = _lTable['H'] = 17; + _lTable['k'] = _lTable['K'] = 17; + _lTable['l'] = _lTable['L'] = 14; + _lTable['m'] = _lTable['M'] = 19; + _lTable['n'] = _lTable['N'] = 17; + _lTable['o'] = _lTable['O'] = _lTable[''] = _lTable[''] = 19; + _lTable['p'] = _lTable['P'] = 17; + _lTable['q'] = _lTable['Q'] = 19; + _lTable['r'] = _lTable['R'] = 14; + _lTable['s'] = _lTable['S'] = 13; + _lTable['t'] = _lTable['T'] = 15; + _lTable['u'] = _lTable['U'] = _lTable[''] = _lTable[''] = 15; + _lTable['v'] = _lTable['V'] = 13; + _lTable['x'] = _lTable['X'] = 15; + _lTable['y'] = _lTable['Y'] = 13; + _lTable['w'] = _lTable['W'] = 19; + _lTable['z'] = _lTable['Z'] = 20; + _lTable[(byte)''] = 17; /* Casi particolari */ setBothCase('C', 'C', 2); @@ -1584,32 +1584,32 @@ void RMFontObj::init(void) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; + _cTable[(byte)''] = _cTable[(byte)''] = 85; + _lTable[(byte)''] = _lTable[(byte)''] = 20; - cTable[(byte)''] = cTable[(byte)''] = 86; - lTable[(byte)''] = lTable[(byte)''] = 22; + _cTable[(byte)''] = _cTable[(byte)''] = 86; + _lTable[(byte)''] = _lTable[(byte)''] = 22; - cTable[(byte)''] = cTable[(byte)''] = 87; - lTable[(byte)''] = lTable[(byte)''] = 17; + _cTable[(byte)''] = _cTable[(byte)''] = 87; + _lTable[(byte)''] = _lTable[(byte)''] = 17; - cTable[(byte)''] = cTable[(byte)''] = 88; - lTable[(byte)''] = lTable[(byte)''] = 19; + _cTable[(byte)''] = _cTable[(byte)''] = 88; + _lTable[(byte)''] = _lTable[(byte)''] = 19; - cTable[(byte)''] = cTable[(byte)''] = 89; - lTable[(byte)''] = lTable[(byte)''] = 17; + _cTable[(byte)''] = _cTable[(byte)''] = 89; + _lTable[(byte)''] = _lTable[(byte)''] = 17; - cTable[(byte)''] = cTable[(byte)''] = 90; - lTable[(byte)''] = lTable[(byte)''] = 22; + _cTable[(byte)''] = _cTable[(byte)''] = 90; + _lTable[(byte)''] = _lTable[(byte)''] = 22; - cTable[(byte)''] = cTable[(byte)''] = 91; - lTable[(byte)''] = lTable[(byte)''] = 15; + _cTable[(byte)''] = _cTable[(byte)''] = 91; + _lTable[(byte)''] = _lTable[(byte)''] = 15; - cTable[(byte)''] = cTable[(byte)''] = 92; - lTable[(byte)''] = lTable[(byte)''] = 21; + _cTable[(byte)''] = _cTable[(byte)''] = 92; + _lTable[(byte)''] = _lTable[(byte)''] = 21; - cTable[(byte)''] = cTable[(byte)''] = 93; - lTable[(byte)''] = lTable[(byte)''] = 21; + _cTable[(byte)''] = _cTable[(byte)''] = 93; + _lTable[(byte)''] = _lTable[(byte)''] = 21; } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters @@ -1617,140 +1617,140 @@ void RMFontObj::init(void) { // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; - - cTable[(byte)''] = cTable[(byte)''] = 94; - cTable[(byte)''] = cTable[(byte)''] = 95; - cTable[(byte)''] = cTable[(byte)''] = 96; - cTable[(byte)''] = cTable[(byte)''] = 97; - cTable[(byte)''] = cTable[(byte)''] = 98; - cTable[(byte)''] = cTable[(byte)''] = 99; - cTable[(byte)''] = cTable[(byte)''] = 100; - cTable[(byte)''] = cTable[(byte)''] = 101; - cTable[(byte)''] = cTable[(byte)''] = 102; - cTable[(byte)''] = cTable[(byte)''] = 103; - cTable[(byte)''] = cTable[(byte)''] = 104; - cTable[(byte)''] = cTable[(byte)''] = 105; - cTable[(byte)''] = cTable[(byte)''] = 106; - cTable[(byte)''] = cTable[(byte)''] = 107; - cTable[(byte)''] = cTable[(byte)''] = 108; - cTable[(byte)''] = cTable[(byte)''] = 109; - cTable[(byte)''] = cTable[(byte)''] = 110; - cTable[(byte)''] = cTable[(byte)''] = 111; - cTable[(byte)''] = cTable[(byte)''] = 112; - cTable[(byte)''] = cTable[(byte)''] = 113; - cTable[(byte)''] = cTable[(byte)''] = 114; - cTable[(byte)''] = cTable[(byte)''] = 115; - cTable[(byte)''] = cTable[(byte)''] = 116; - cTable[(byte)''] = cTable[(byte)''] = 117; - cTable[(byte)''] = cTable[(byte)''] = 118; - cTable[(byte)''] = cTable[(byte)''] = 119; - cTable[(byte)''] = cTable[(byte)''] = 120; - cTable[(byte)''] = cTable[(byte)''] = 121; - cTable[(byte)''] = cTable[(byte)''] = 122; - cTable[(byte)''] = cTable[(byte)''] = 123; - cTable[(byte)''] = cTable[(byte)''] = 124; - cTable[(byte)''] = cTable[(byte)''] = 125; - cTable[(byte)''] = cTable[(byte)''] = 126; - - - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; + _cTable[(byte)''] = _cTable[(byte)''] = 85; + _lTable[(byte)''] = _lTable[(byte)''] = 20; + + _cTable[(byte)''] = _cTable[(byte)''] = 94; + _cTable[(byte)''] = _cTable[(byte)''] = 95; + _cTable[(byte)''] = _cTable[(byte)''] = 96; + _cTable[(byte)''] = _cTable[(byte)''] = 97; + _cTable[(byte)''] = _cTable[(byte)''] = 98; + _cTable[(byte)''] = _cTable[(byte)''] = 99; + _cTable[(byte)''] = _cTable[(byte)''] = 100; + _cTable[(byte)''] = _cTable[(byte)''] = 101; + _cTable[(byte)''] = _cTable[(byte)''] = 102; + _cTable[(byte)''] = _cTable[(byte)''] = 103; + _cTable[(byte)''] = _cTable[(byte)''] = 104; + _cTable[(byte)''] = _cTable[(byte)''] = 105; + _cTable[(byte)''] = _cTable[(byte)''] = 106; + _cTable[(byte)''] = _cTable[(byte)''] = 107; + _cTable[(byte)''] = _cTable[(byte)''] = 108; + _cTable[(byte)''] = _cTable[(byte)''] = 109; + _cTable[(byte)''] = _cTable[(byte)''] = 110; + _cTable[(byte)''] = _cTable[(byte)''] = 111; + _cTable[(byte)''] = _cTable[(byte)''] = 112; + _cTable[(byte)''] = _cTable[(byte)''] = 113; + _cTable[(byte)''] = _cTable[(byte)''] = 114; + _cTable[(byte)''] = _cTable[(byte)''] = 115; + _cTable[(byte)''] = _cTable[(byte)''] = 116; + _cTable[(byte)''] = _cTable[(byte)''] = 117; + _cTable[(byte)''] = _cTable[(byte)''] = 118; + _cTable[(byte)''] = _cTable[(byte)''] = 119; + _cTable[(byte)''] = _cTable[(byte)''] = 120; + _cTable[(byte)''] = _cTable[(byte)''] = 121; + _cTable[(byte)''] = _cTable[(byte)''] = 122; + _cTable[(byte)''] = _cTable[(byte)''] = 123; + _cTable[(byte)''] = _cTable[(byte)''] = 124; + _cTable[(byte)''] = _cTable[(byte)''] = 125; + _cTable[(byte)''] = _cTable[(byte)''] = 126; + + + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 20; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 21; + _lTable[(byte)''] = _lTable[(byte)''] = 20; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; } else if (_vm->getLanguage() == Common::CZ_CZE) { // Czech - cTable[(byte)''] = cTable[(byte)''] = 127; - cTable[(byte)''] = cTable[(byte)''] = 128; - cTable[(byte)''] = cTable[(byte)''] = 129; - cTable[(byte)''] = cTable[(byte)''] = 130; - cTable[(byte)''] = cTable[(byte)''] = 131; - cTable[(byte)''] = cTable[(byte)''] = 132; - cTable[(byte)''] = cTable[(byte)''] = 133; - cTable[(byte)''] = cTable[(byte)''] = 134; - cTable[(byte)''] = cTable[(byte)''] = 135; - cTable[(byte)''] = cTable[(byte)''] = 136; - cTable[(byte)''] = cTable[(byte)''] = 137; - cTable[(byte)''] = cTable[(byte)''] = 138; - cTable[(byte)''] = cTable[(byte)''] = 139; - cTable[(byte)''] = cTable[(byte)''] = 140; - cTable[(byte)''] = cTable[(byte)''] = 141; - - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 23; - lTable[(byte)''] = lTable[(byte)''] = 24; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; + _cTable[(byte)''] = _cTable[(byte)''] = 127; + _cTable[(byte)''] = _cTable[(byte)''] = 128; + _cTable[(byte)''] = _cTable[(byte)''] = 129; + _cTable[(byte)''] = _cTable[(byte)''] = 130; + _cTable[(byte)''] = _cTable[(byte)''] = 131; + _cTable[(byte)''] = _cTable[(byte)''] = 132; + _cTable[(byte)''] = _cTable[(byte)''] = 133; + _cTable[(byte)''] = _cTable[(byte)''] = 134; + _cTable[(byte)''] = _cTable[(byte)''] = 135; + _cTable[(byte)''] = _cTable[(byte)''] = 136; + _cTable[(byte)''] = _cTable[(byte)''] = 137; + _cTable[(byte)''] = _cTable[(byte)''] = 138; + _cTable[(byte)''] = _cTable[(byte)''] = 139; + _cTable[(byte)''] = _cTable[(byte)''] = 140; + _cTable[(byte)''] = _cTable[(byte)''] = 141; + + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 21; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 23; + _lTable[(byte)''] = _lTable[(byte)''] = 24; + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 16; } else if (_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; + _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 0; // a + _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 17; - cTable[(byte)''] = cTable[(byte)''] = 4; // e - lTable[(byte)''] = lTable[(byte)''] = 15; + _cTable[(byte)''] = _cTable[(byte)''] = 4; // e + _lTable[(byte)''] = _lTable[(byte)''] = 15; - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; + _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 8; // i + _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 16; - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; + _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 14; // o + _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 19; - cTable[(byte)''] = cTable[(byte)''] = 20; // u - lTable[(byte)''] = lTable[(byte)''] = 15; + _cTable[(byte)''] = _cTable[(byte)''] = 20; // u + _lTable[(byte)''] = _lTable[(byte)''] = 15; } else if (_vm->getLanguage() == Common::DE_DEU) { // German - cTable[''] = 142; + _cTable[''] = 142; // SS = 143 - lTable[''] = 24; + _lTable[''] = 24; } } @@ -1768,14 +1768,14 @@ void RMText::initStatics() { RMText::RMText() { // Default colour: white - m_r = m_g = m_b = 255; + _textR = _textG = _textB = 255; // Default length - maxLineLength = 350; + _maxLineLength = 350; _bTrasp0 = true; - aHorType = HCENTER; - aVerType = VTOP; + _aHorType = HCENTER; + _aVerType = VTOP; setPriority(150); } @@ -1794,7 +1794,7 @@ void RMText::unload() { } void RMText::setMaxLineLength(int max) { - maxLineLength = max; + _maxLineLength = max; } void RMText::removeThis(CORO_PARAM, bool &result) { @@ -1831,7 +1831,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { int numlines; // Set the base colour - font->setBaseColor(m_r, m_g, m_b); + font->setBaseColor(_textR, _textG, _textB); // Destroy the buffer before starting destroy(); @@ -1846,7 +1846,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { i = j = x = 0; while (*p != '\0') { j += font->stringLen(*p); - if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { + if (j > (((_aHorType == HLEFTPAR) && (i > 0)) ? _maxLineLength - 25 : _maxLineLength)) { j -= font->stringLen(*p, p[1]); if (j > x) x = j; @@ -1903,7 +1903,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { x = 0; j = font->stringLen(RMString(p)); - switch (aHorType) { + switch (_aHorType) { case HLEFT: x = 0; break; @@ -1967,19 +1967,19 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Horizontally - if (aHorType == HCENTER) + if (_aHorType == HCENTER) prim->getDst().topLeft() -= RMPoint(_dimx / 2, 0); - else if (aHorType == HRIGHT) + else if (_aHorType == HRIGHT) prim->getDst().topLeft() -= RMPoint(_dimx, 0); // Vertically - if (aVerType == VTOP) { + if (_aVerType == VTOP) { - } else if (aVerType == VCENTER) { + } else if (_aVerType == VCENTER) { prim->getDst().y1 -= _dimy / 2; - } else if (aVerType == VBOTTOM) { + } else if (_aVerType == VBOTTOM) { prim->getDst().y1 -= _dimy; } @@ -1996,7 +1996,7 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMTextDialog::RMTextDialog() : RMText() { _startTime = 0; - dst = RMPoint(0, 0); + _dst = RMPoint(0, 0); _bSkipStatus = true; _bShowed = true; @@ -2004,16 +2004,16 @@ RMTextDialog::RMTextDialog() : RMText() { _bForceNoTime = false; _bAlwaysDisplay = false; _bNoTab = false; - hCustomSkip = CORO_INVALID_PID_VALUE; - hCustomSkip2 = CORO_INVALID_PID_VALUE; + _hCustomSkip = CORO_INVALID_PID_VALUE; + _hCustomSkip2 = CORO_INVALID_PID_VALUE; _input = NULL; // Create the event for displaying the end - hEndDisplay = CoroScheduler.createEvent(false, false); + _hEndDisplay = CoroScheduler.createEvent(false, false); } RMTextDialog::~RMTextDialog() { - CoroScheduler.closeEvent(hEndDisplay); + CoroScheduler.closeEvent(_hEndDisplay); } void RMTextDialog::show(void) { @@ -2075,7 +2075,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { // Don't erase the background if (_bSkipStatus) { - if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS._bCfgTimerizedText) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) @@ -2097,7 +2097,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { } } // Erase the background - else if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + else if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) return; @@ -2110,15 +2110,15 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { return; } - if (hCustomSkip != CORO_INVALID_PID_VALUE) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); + if (_hCustomSkip != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _hCustomSkip, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; } - if (GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); + if (GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; @@ -2132,7 +2132,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); assert(_nInList == 0); - CoroScheduler.setEvent(hEndDisplay); + CoroScheduler.setEvent(_hEndDisplay); } void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2146,7 +2146,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (_bShowed) { if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) { - prim->getDst().topLeft() = dst; + prim->getDst().topLeft() = _dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2155,15 +2155,15 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p } void RMTextDialog::setCustomSkipHandle(uint32 hCustom) { - hCustomSkip = hCustom; + _hCustomSkip = hCustom; } void RMTextDialog::setCustomSkipHandle2(uint32 hCustom) { - hCustomSkip2 = hCustom; + _hCustomSkip2 = hCustom; } void RMTextDialog::waitForEndDisplay(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, hEndDisplay, CORO_INFINITE); + CoroScheduler.waitForSingleObject(coroParam, _hEndDisplay, CORO_INFINITE); } void RMTextDialog::setInput(RMInput *input) { @@ -2175,12 +2175,12 @@ void RMTextDialog::setInput(RMInput *input) { \****************************************************************************/ RMTextDialogScrolling::RMTextDialogScrolling() { - curLoc = NULL; + _curLoc = NULL; } RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { - curLoc = loc; - startScroll = loc->scrollPosition(); + _curLoc = loc; + _startScroll = loc->scrollPosition(); } RMTextDialogScrolling::~RMTextDialogScrolling() { @@ -2193,14 +2193,14 @@ void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri CORO_BEGIN_CODE(_ctx); - _ctx->curDst = dst; + _ctx->curDst = _dst; - if (curLoc != NULL) - dst -= curLoc->scrollPosition() - startScroll; + if (_curLoc != NULL) + _dst -= _curLoc->scrollPosition() - _startScroll; CORO_INVOKE_2(RMTextDialog::draw, bigBuf, prim); - dst = _ctx->curDst; + _dst = _ctx->curDst; CORO_END_CODE; } @@ -2321,26 +2321,26 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - DlgText.init(dlg1, dlg1.width(), dlg1.height()); - DlgTextLine.init(dlg2, dlg2.width(), dlg2.height()); + _dlgText.init(dlg1, dlg1.width(), dlg1.height()); + _dlgTextLine.init(dlg2, dlg2.width(), dlg2.height()); - DlgText.loadPaletteWA(dlgpal); - DlgTextLine.loadPaletteWA(dlgpal); + _dlgText.loadPaletteWA(dlgpal); + _dlgTextLine.loadPaletteWA(dlgpal); - hUnreg = CoroScheduler.createEvent(false, false); - bRemoveFromOT = false; + _hUnreg = CoroScheduler.createEvent(false, false); + _bRemoveFromOT = false; } RMDialogChoice::~RMDialogChoice() { - CoroScheduler.closeEvent(hUnreg); + CoroScheduler.closeEvent(_hUnreg); } void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); assert(!_nInList); - CoroScheduler.pulseEvent(hUnreg); + CoroScheduler.pulseEvent(_hUnreg); - bRemoveFromOT = false; + _bRemoveFromOT = false; } void RMDialogChoice::init(void) { @@ -2401,11 +2401,11 @@ void RMDialogChoice::prepare(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - addPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); + addPrim(new RMGfxPrimitive(&_dlgText, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155 + 83))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155 + 83 + 83))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); _ctx->ptPos.set(20, 90); @@ -2546,15 +2546,15 @@ void RMDialogChoice::hide(CORO_PARAM) { } _bShow = false; - bRemoveFromOT = true; - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hUnreg, CORO_INFINITE); + _bRemoveFromOT = true; + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hUnreg, CORO_INFINITE); CORO_END_CODE; } void RMDialogChoice::removeThis(CORO_PARAM, bool &result) { - result = bRemoveFromOT; + result = _bRemoveFromOT; } void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { diff --git a/engines/tony/font.h b/engines/tony/font.h index 2e2b1724a9..d1423c9749 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -47,7 +47,7 @@ class RMPointer; */ class RMFont : public RMGfxTaskSetPrior { protected: - int nLetters; + int _nLetters; RMGfxSourceBuffer8RLEByte *_letter; public: int _fontDimx, _fontDimy; @@ -107,7 +107,7 @@ public: class RMFontColor : public virtual RMFont { private: - byte m_r, m_g, m_b; + byte _fontR, _fontG, _fontB; public: RMFontColor(); @@ -118,24 +118,24 @@ public: class RMFontWithTables : public virtual RMFont { protected: - int cTable[256]; - int lTable[256]; - int lDefault; - int hDefault; - signed char l2Table[256][256]; + int _cTable[256]; + int _lTable[256]; + int _lDefault; + int _hDefault; + signed char _l2Table[256][256]; protected: // Overloaded methods int convertToLetter(byte nChar) { - return cTable[nChar]; + return _cTable[nChar]; } int letterLength(int nChar, int nNext = 0) { - return (nChar != -1 ? lTable[(byte)nChar] + l2Table[(byte)nChar][(byte)nNext] : lDefault); + return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault); } public: int letterHeight() { - return hDefault; + return _hDefault; } virtual ~RMFontWithTables() {} }; @@ -176,7 +176,7 @@ class RMText : public RMGfxWoodyBuffer { private: static RMFontColor *_fonts[4]; static RMGfxClearTask _clear; - int maxLineLength; + int _maxLineLength; public: enum HORALIGN { @@ -193,9 +193,9 @@ public: }; private: - HORALIGN aHorType; - VERALIGN aVerType; - byte m_r, m_g, m_b; + HORALIGN _aHorType; + VERALIGN _aVerType; + byte _textR, _textG, _textB; protected: virtual void clipOnScreen(RMGfxPrimitive *prim); @@ -208,8 +208,8 @@ public: // Set the alignment type void setAlignType(HORALIGN aHor, VERALIGN aVer) { - aHorType = aHor; - aVerType = aVer; + _aHorType = aHor; + _aVerType = aVer; } // Sets the maximum length of a line in pixels (used to format the text) @@ -227,9 +227,9 @@ public: // Set the base colour void setColor(byte r, byte g, byte b) { - m_r = r; - m_g = g; - m_b = b; + _textR = r; + _textG = g; + _textB = b; } }; @@ -241,13 +241,13 @@ protected: int _startTime; int _time; bool _bSkipStatus; - RMPoint dst; - uint32 hEndDisplay; + RMPoint _dst; + uint32 _hEndDisplay; bool _bShowed; bool _bForceTime; bool _bForceNoTime; - uint32 hCustomSkip; - uint32 hCustomSkip2; + uint32 _hCustomSkip; + uint32 _hCustomSkip2; RMInput *_input; bool _bAlwaysDisplay; bool _bNoTab; @@ -271,7 +271,7 @@ public: // Set the position void setPosition(const RMPoint &pt) { - dst = pt; + _dst = pt; } // Waiting @@ -294,8 +294,8 @@ public: class RMTextDialogScrolling : public RMTextDialog { protected: - RMLocation *curLoc; - RMPoint startScroll; + RMLocation *_curLoc; + RMPoint _startScroll; virtual void clipOnScreen(RMGfxPrimitive *prim); @@ -351,11 +351,11 @@ private: RMPoint *_ptDrawStrings; int _curAdded; bool _bShow; - RMGfxSourceBuffer8 DlgText; - RMGfxSourceBuffer8 DlgTextLine; + RMGfxSourceBuffer8 _dlgText; + RMGfxSourceBuffer8 _dlgTextLine; RMPoint _ptDrawPos; - uint32 hUnreg; - bool bRemoveFromOT; + uint32 _hUnreg; + bool _bRemoveFromOT; protected: void prepare(CORO_PARAM); -- cgit v1.2.3 From 264721a19405920a57fece9b5bd09d773055531c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 00:43:59 +0200 Subject: TONY: Rename variables in inventory.h --- engines/tony/inventory.cpp | 134 ++++++++++++++++++++++----------------------- engines/tony/inventory.h | 10 ++-- 2 files changed, 72 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 162443d0bd..cfa49181e1 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -56,7 +56,7 @@ RMInventory::RMInventory() { _nCombine = 0; _bBlinkingRight = false; _bBlinkingLeft = false; - miniAction = 0; + _miniAction = 0; } RMInventory::~RMInventory() { @@ -100,43 +100,43 @@ void RMInventory::init(void) { assert(res.isValid()); // Initialise the MPAL inventory item by reading it in. - _items[i].icon.setInitCurPattern(false); + _items[i]._icon.setInitCurPattern(false); ds.openBuffer(res); - ds >> _items[i].icon; + ds >> _items[i]._icon; ds.close(); // Puts in the default pattern 1 - _items[i].pointer = NULL; - _items[i].status = 1; - _items[i].icon.setPattern(1); - _items[i].icon.doFrame(this, false); + _items[i]._pointer = NULL; + _items[i]._status = 1; + _items[i]._icon.setPattern(1); + _items[i]._icon.doFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; - _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.numPattern()]; + _items[i]._pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i]._icon.numPattern()]; - for (j = 0; j < _items[i].icon.numPattern(); j++) { + for (j = 0; j < _items[i]._icon.numPattern(); j++) { RMResRaw raw(curres); assert(raw.isValid()); - _items[i].pointer[j].init((const byte *)raw, raw.width(), raw.height(), true); + _items[i]._pointer[j].init((const byte *)raw, raw.width(), raw.height(), true); curres++; } } - _items[28].icon.setPattern(1); - _items[29].icon.setPattern(1); + _items[28]._icon.setPattern(1); + _items[29]._icon.setPattern(1); // Download interface RMDataStream ds; RMRes res(RES_I_MINIINTER); assert(res.isValid()); ds.openBuffer(res); - ds >> miniInterface; - miniInterface.setPattern(1); + ds >> _miniInterface; + _miniInterface.setPattern(1); ds.close(); // Create the text for hints on the mini interface @@ -165,7 +165,7 @@ void RMInventory::close(void) { if (_items != NULL) { // Delete the item pointers for (int i = 0; i <= _nItems; i++) - delete[] _items[i].pointer; + delete[] _items[i]._pointer; // Delete the items array delete[] _items; @@ -213,14 +213,14 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _ctx->p2 = new RMGfxPrimitive(prim->_task, _ctx->pos2); // Draw the mini interface - CORO_INVOKE_2(miniInterface.draw, bigBuf, _ctx->p); + CORO_INVOKE_2(_miniInterface.draw, bigBuf, _ctx->p); if (GLOBALS._bCfgInterTips) { - if (miniAction == 1) // Examine + if (_miniAction == 1) // Examine CORO_INVOKE_2(_hints[0].draw, bigBuf, _ctx->p2); - else if (miniAction == 2) // Talk + else if (_miniAction == 2) // Talk CORO_INVOKE_2(_hints[1].draw, bigBuf, _ctx->p2); - else if (miniAction == 3) // Use + else if (_miniAction == 3) // Use CORO_INVOKE_2(_hints[2].draw, bigBuf, _ctx->p2); } @@ -264,7 +264,7 @@ void RMInventory::addItem(int code) { g_system->lockMutex(_csModifyInterface); if (_curPos + 8 == _nInv) { // Break through the inventory! On the flashing pattern - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); } _inv[_nInv++] = code - 10000; @@ -281,8 +281,8 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { error("Specified object code is not valid"); } else { g_system->lockMutex(_csModifyInterface); - _items[code - 10000].icon.setPattern(dwStatus); - _items[code - 10000].status = dwStatus; + _items[code - 10000]._icon.setPattern(dwStatus); + _items[code - 10000]._status = dwStatus; prepare(); drawOT(Common::nullContext); @@ -297,14 +297,14 @@ void RMInventory::prepare(void) { for (i = 1; i < RM_SX / 64 - 1; i++) { if (i - 1 + _curPos < _nInv) - addPrim(new RMGfxPrimitive(&_items[_inv[i - 1 + _curPos]].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&_items[_inv[i - 1 + _curPos]]._icon, RMPoint(i * 64, 0))); else - addPrim(new RMGfxPrimitive(&_items[0].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&_items[0]._icon, RMPoint(i * 64, 0))); } // Frecce - addPrim(new RMGfxPrimitive(&_items[29].icon, RMPoint(0, 0))); - addPrim(new RMGfxPrimitive(&_items[28].icon, RMPoint(640 - 64, 0))); + addPrim(new RMGfxPrimitive(&_items[29]._icon, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&_items[28]._icon, RMPoint(640 - 64, 0))); } bool RMInventory::miniActive(void) { @@ -355,12 +355,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos + 8 >= _nInv) { _bBlinkingRight = false; - _items[28].icon.setPattern(1); + _items[28]._icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.setPattern(2); + _items[29]._icon.setPattern(2); } prepare(); @@ -376,12 +376,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.setPattern(1); + _items[29]._icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); } prepare(); @@ -405,7 +405,7 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { _state = SELECTING; - miniAction = 0; + _miniAction = 0; _nSelectObj = n - 1; _vm->playUtilSFX(0); @@ -420,12 +420,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos + 8 <= _nInv) { _bBlinkingRight = false; - _items[28].icon.setPattern(1); + _items[28]._icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.setPattern(2); + _items[29]._icon.setPattern(2); } prepare(); @@ -441,12 +441,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.setPattern(1); + _items[29]._icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); } prepare(); @@ -460,13 +460,13 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { if (_state == SELECTING) { _state = OPENED; - if (miniAction == 1) { // Esamina + if (_miniAction == 1) { // Esamina curAction = TA_EXAMINE; return true; - } else if (miniAction == 2) { // Parla + } else if (_miniAction == 2) { // Parla curAction = TA_TALK; return true; - } else if (miniAction == 3) { // Usa + } else if (_miniAction == 3) { // Usa curAction = TA_USE; return true; } @@ -489,39 +489,39 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help for (i = 0; i < _nInv; i++) - if (_items[_inv[i]].icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) + if (_items[_inv[i]]._icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) bNeedRedraw = true; if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos.x > RM_SX - 64) { if (_curPos + 8 < _nInv && !_bBlinkingRight) { - _items[28].icon.setPattern(3); + _items[28]._icon.setPattern(3); _bBlinkingRight = true; bNeedRedraw = true; } } else if (_bBlinkingRight) { - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); _bBlinkingRight = false; bNeedRedraw = true; } if (mpos.x < 64) { if (_curPos > 0 && !_bBlinkingLeft) { - _items[29].icon.setPattern(3); + _items[29]._icon.setPattern(3); _bBlinkingLeft = true; bNeedRedraw = true; } } else if (_bBlinkingLeft) { - _items[29].icon.setPattern(2); + _items[29]._icon.setPattern(2); _bBlinkingLeft = false; bNeedRedraw = true; } } - if (_items[28].icon.doFrame(this, false)) + if (_items[28]._icon.doFrame(this, false)) bNeedRedraw = true; - if (_items[29].icon.doFrame(this, false)) + if (_items[29]._icon.doFrame(this, false)) bNeedRedraw = true; if (bNeedRedraw) @@ -535,7 +535,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (_bCombining) {//m_state == COMBINING) - ptr.setCustomPointer(&_items[_nCombine].pointer[_items[_nCombine].status - 1]); + ptr.setCustomPointer(&_items[_nCombine]._pointer[_items[_nCombine]._status - 1]); ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } @@ -632,34 +632,34 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // Make sure it is on one of the verbs if (mpos.y > starty && mpos.y < starty + 45) { if (mpos.x > startx && mpos.x < startx + 40) { - if (miniAction != 1) { - miniInterface.setPattern(2); - miniAction = 1; + if (_miniAction != 1) { + _miniInterface.setPattern(2); + _miniAction = 1; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { - if (miniAction != 2) { - miniInterface.setPattern(3); - miniAction = 2; + if (_miniAction != 2) { + _miniInterface.setPattern(3); + _miniAction = 2; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { - if (miniAction != 3) { - miniInterface.setPattern(4); - miniAction = 3; + if (_miniAction != 3) { + _miniInterface.setPattern(4); + _miniAction = 3; _vm->playUtilSFX(1); } } else { - miniInterface.setPattern(1); - miniAction = 0; + _miniInterface.setPattern(1); + _miniAction = 0; } } else { - miniInterface.setPattern(1); - miniAction = 0; + _miniInterface.setPattern(1); + _miniAction = 0; } // Update the mini-interface - miniInterface.doFrame(&bigBuf, false); + _miniInterface.doFrame(&bigBuf, false); } if ((_state != CLOSED) && !_nInList) { @@ -682,7 +682,7 @@ RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { if (checkPointInside(mpt)) { n = mpt.x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) - return &_items[_inv[n - 1 + _curPos]].icon; + return &_items[_inv[n - 1 + _curPos]]._icon; } } @@ -706,7 +706,7 @@ void RMInventory::saveState(byte *state) { for (i = 0; i < 256; i++) { if (i < _nItems) - x = _items[i].status; + x = _items[i]._status; else x = 0; @@ -728,20 +728,20 @@ int RMInventory::loadState(byte *state) { state += 4; if (i < _nItems) { - _items[i].status = x; - _items[i].icon.setPattern(x); + _items[i]._status = x; + _items[i]._icon.setPattern(x); } } _curPos = 0; _bCombining = false; - _items[29].icon.setPattern(1); + _items[29]._icon.setPattern(1); if (_nInv > 8) - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); else - _items[28].icon.setPattern(1); + _items[28]._icon.setPattern(1); prepare(); drawOT(Common::nullContext); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index d8b20827b4..2b6248f7eb 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -39,9 +39,9 @@ namespace Tony { struct RMInventoryItem { - RMItem icon; - RMGfxSourceBuffer8RLEByteAA *pointer; - int status; + RMItem _icon; + RMGfxSourceBuffer8RLEByteAA *_pointer; + int _status; }; class RMInventory : public RMGfxWoodyBuffer { @@ -72,8 +72,8 @@ protected: bool _bBlinkingRight, _bBlinkingLeft; - int miniAction; - RMItem miniInterface; + int _miniAction; + RMItem _miniInterface; RMText _hints[3]; OSystem::MutexRef _csModifyInterface; -- cgit v1.2.3 From 42f4fe359c16dfe5291e6274464b76168b117135 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 10 Jun 2012 21:23:28 -0400 Subject: TONY: Convert FPSFX to our mixer code Only thing missing is the hEndOfBuffer code, but this is a good start --- engines/tony/sound.cpp | 387 ++++++++----------------------------------------- engines/tony/sound.h | 22 +-- 2 files changed, 69 insertions(+), 340 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 2d4ff824f0..e63245586d 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -26,7 +26,10 @@ * Copyright (c) 1997-2003 Nayma Software */ -#include "audio/mixer.h" +#include "audio/audiostream.h" +#include "audio/decoders/adpcm.h" +#include "audio/decoders/raw.h" +#include "audio/decoders/wave.h" #include "common/textconsole.h" #include "tony/game.h" #include "tony/tony.h" @@ -182,7 +185,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { /****************************************************************************\ * -* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); +* Function: FPSFX(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() @@ -190,40 +193,13 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { \****************************************************************************/ FPSFX::FPSFX(bool bSoundOn) { -#ifdef REFACTOR_ME - - static char errbuf[128]; - - //hwnd=hWnd; bSoundSupported = bSoundOn; bFileLoaded = false; - bIsPlaying = false; - bPaused = false; - lpDSBuffer = NULL; - lpDSNotify = NULL; - lpDS = lpds; lastVolume = 63; hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; - - if (bSoundSupported == false) - return; - - /* Poich non abbiamo ancora nessun dato sull'effetto sonoro, non possiamo fare nulla */ -#else - bIsVoice = false; - lastVolume = 0; - dwFreq = 0; - hEndOfBuffer = CORO_INVALID_PID_VALUE; - bFileLoaded = false; - bSoundSupported = false; - bLoop = false; + _stream = 0; bPaused = false; - bStereo = false; - b16bit = false; - bIsPlaying = false; - bIsVoice = false; -#endif } @@ -238,21 +214,16 @@ FPSFX::FPSFX(bool bSoundOn) { \****************************************************************************/ FPSFX::~FPSFX() { -#ifdef REFACTOR_ME - if (!bSoundSupported) return; - if (bIsPlaying) - Stop(); - - RELEASE(lpDSNotify); + g_system->getMixer()->stopHandle(_handle); - if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - CloseHandle(hEndOfBuffer); + delete _stream; - RELEASE(lpDSBuffer); -#endif + // FIXME + //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) + // CloseHandle(hEndOfBuffer); } @@ -271,7 +242,6 @@ FPSFX::~FPSFX() { void FPSFX::Release() { delete this; -// return NULL; } @@ -291,87 +261,16 @@ void FPSFX::Release() { \****************************************************************************/ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { -#ifdef REFACTOR_ME - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - static HRESULT err; - static char errbuf[128]; - uint32 dwHi; - struct WAVH { - int nChunckSize; - uint16 wFormatTag; - uint16 nChannels; - int nSamplesPerSec; - int nAvgBytesPerSec; - uint16 nBlockAlign; - uint16 nBitsPerSample; - } *WAVHeader; - uint32 dwSize; - void *lpLock; - - if (!bSoundSupported) - return true; - - if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') - return false; - if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') + if (!stream) return false; - WAVHeader = (WAVH *)(lpBuf + 8); - lpBuf += 8 + sizeof(WAVH); + _stream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); - if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') + if (!_stream) return false; - lpBuf += 4; - - dwSize = READ_LE_UINT32(lpBuf); - lpBuf += 4; - - b16bit = (WAVHeader->nBitsPerSample == 16); - bStereo = (WAVHeader->nChannels == 2); - dwFreq = WAVHeader->nSamplesPerSec; - - /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. - Proviamo a buttarlo in sound ram. */ - pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = (bStereo ? 2 : 1); - pcmwf.wf.nSamplesPerSec = dwFreq; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dsbdesc.dwBufferBytes = dwSize; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); - return false; - } - - // Riempie il buffer - if ((err = lpDSBuffer->Lock(0, dwSize, &lpLock, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); - return false; - } - - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - copyMemory(lpLock, lpBuf, dwSize); - - /* Unlocka il buffer */ - lpDSBuffer->Unlock(lpLock, dwSize, NULL, NULL); - - /* Setta volume iniziale */ - SetVolume(lastVolume); bFileLoaded = true; -#endif - - delete stream; // Just so we don't leak it + SetVolume(lastVolume); return true; } @@ -391,207 +290,59 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { \****************************************************************************/ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { -#ifdef REFACTOR_ME - uint32 dwSize; - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - byte *lpTempBuffer; - static HRESULT err; - uint32 dwHi; - void *lpBuf; - static char errbuf[128]; - if (!bSoundSupported) return true; - b16bit = true; - bStereo = false; + uint32 size = vdbFP.readUint32LE(); + uint32 rate = vdbFP.readUint32LE(); bIsVoice = true; -// fread(&dwSize,1,4,vdbFP); -// fread(&dwFreq,1,4,vdbFP); - ReadFile(vdbFP, &dwSize, 4, &dwHi, NULL); - ReadFile(vdbFP, &dwFreq, 4, &dwHi, NULL); - - dwSize *= 4; - - /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. - Proviamo a buttarlo in sound ram. */ - pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = (bStereo ? 2 : 1); - pcmwf.wf.nSamplesPerSec = dwFreq; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dsbdesc.dwBufferBytes = dwSize; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); - return false; - } - - /* Alloca un buffer temporaneo */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); - if (lpTempBuffer == NULL) - return false; - - lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - - /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); - return false; - } - - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - lpCodec->Decompress(vdbFP, lpBuf, dwSize); + _stream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); - /* Unlocka il buffer */ - lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); - - delete lpCodec; - - /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); - if (FAILED(err)) { - wsprintf(errbuf, "Error creating notify object! (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::LoadVoiceFromVDB()", MB_OK); - return false; - } - - hEndOfBuffer = CreateEvent(NULL, false, false, NULL); - - dspnHot[0].dwOffset = DSBPN_OFFSETSTOP; - dspnHot[0].hEventNotify = hEndOfBuffer; - - lpDSNotify->SetNotificationPositions(1, dspnHot); - - /* Tutto a posto, possiamo uscire */ bFileLoaded = true; SetVolume(62); - -#endif return true; } bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { -#ifdef REFACTOR_ME - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - static HRESULT err; - static char errbuf[128]; - Common::File file; - uint32 dwSize; - byte *lpTempBuffer; - void *lpBuf; - uint32 dwHi; - struct { - char id[4]; - int freq; - int nChan; - } ADPHead; - if (!bSoundSupported) return true; - /* Apre il file di stream in lettura */ + Common::File file; if (!file.open(lpszFileName)) { - warning("FPSFX::LoadFile() : Cannot open sfx file!"); - return false; - } - - /* Leggiamo l'header */ - file.read(ADPHead.id, 4); - ADPHead.freq = file.readUint32LE(); - ADPHead.nChan = file.readUint32LE(); - - if (ADPHead.id[0] != 'A' || ADPHead.id[1] != 'D' || ADPHead.id[2] != 'P' || ADPHead.id[3] != 0x10) { - warning("FPSFX::LoadFile() : Invalid ADP header!"); - file.close(); + warning("FPSFX::LoadFile(): Cannot open sfx file!"); return false; } - b16bit = true; - bStereo = (ADPHead.nChan == 2); - dwFreq = ADPHead.freq; - - /* Si salva la lunghezza dello stream */ - dwSize = file.size() - 12 /*sizeof(ADPHead)*/; - file.seek(0); - - if (dwCodec == FPCODEC_ADPCM) - dwSize *= 4; - - /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. - Proviamo a buttarlo in sound ram. */ - pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = (bStereo ? 2 : 1); - pcmwf.wf.nSamplesPerSec = dwFreq; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dsbdesc.dwBufferBytes = dwSize; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); + if (file.readUint32BE() != MKTAG('A', 'D', 'P', 0x10)) { + warning("FPSFX::LoadFile(): Invalid ADP header!"); return false; } - /* Alloca un buffer temporaneo */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); - if (lpTempBuffer == NULL) - return false; + uint32 rate = file.readUint32LE(); + uint32 channels = file.readUint32LE(); - switch (dwCodec) { - case FPCODEC_RAW: - lpCodec = new CODECRAW(bLoop); - break; + Common::SeekableReadStream *buffer = file.readStream(file.size() - file.pos()); + Audio::RewindableAudioStream *stream; - case FPCODEC_ADPCM: - if (bStereo) - lpCodec = new CODECADPCMSTEREO(bLoop, lpTempBuffer); - else - lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - break; + if (dwCodec == FPCODEC_ADPCM) { + stream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels); + } else { + byte flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN; - default: - return false; - G - } + if (channels == 2) + flags |= Audio::FLAG_STEREO; - /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); - return false; + stream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - lpCodec->Decompress(file, lpBuf, dwSize); - - /* Unlocka il buffer */ - lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); + if (bLoop) + _stream = Audio::makeLoopingAudioStream(stream, 0); + else + _stream = stream; - delete lpCodec; - file.close(); - - /* Tutto a posto, possiamo uscire */ bFileLoaded = true; -#endif return true; } @@ -607,19 +358,22 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { \****************************************************************************/ bool FPSFX::Play() { -#ifdef REFACTOR_ME + Stop(); // sanity check + if (bFileLoaded) { - if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - ResetEvent(hEndOfBuffer); + // FIXME + //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) + // ResetEvent(hEndOfBuffer); - lpDSBuffer->SetCurrentPosition(0); - bIsPlaying = true; + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, + Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - if (!bPaused) { - lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); - } + SetVolume(lastVolume); + + if (bPaused) + g_system->getMixer()->pauseHandle(_handle, true); } -#endif + return true; } @@ -634,17 +388,12 @@ bool FPSFX::Play() { * \****************************************************************************/ -bool FPSFX::Stop(void) { -#ifdef REFACTOR_ME +bool FPSFX::Stop() { if (bFileLoaded) { - if (bPaused || bIsPlaying) { - lpDSBuffer->Stop(); - } - - bIsPlaying = false; + g_system->getMixer()->stopHandle(_handle); bPaused = false; } -#endif + return true; } @@ -671,21 +420,12 @@ void FPSFX::SetLoop(bool bLop) { } void FPSFX::Pause(bool bPause) { -#ifdef REFACTOR_ME if (bFileLoaded) { - if (bPause && bIsPlaying) { - lpDSBuffer->Stop(); - } else if (!bPause && bPaused) { - if (bIsPlaying && bLoop) - lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); - } + if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ bPaused)) + g_system->getMixer()->pauseHandle(_handle, bPause); - // Trucchetto per risettare il volume secondo le - // possibili nuove configurazioni sonore - SetVolume(lastVolume); bPaused = bPause; } -#endif } @@ -718,10 +458,9 @@ void FPSFX::SetVolume(int dwVolume) { if (dwVolume < 0) dwVolume = 0; } } -#ifdef REFACTOR_ME - if (bFileLoaded) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); -#endif + + if (g_system->getMixer()->isSoundHandleActive(_handle)) + g_system->getMixer()->setChannelVolume(_handle, dwVolume * Audio::Mixer::kMaxChannelVolume / 63); } @@ -738,14 +477,10 @@ void FPSFX::SetVolume(int dwVolume) { \****************************************************************************/ void FPSFX::GetVolume(int *lpdwVolume) { -#ifdef REFACTOR_ME - if (bFileLoaded) - lpDSBuffer->GetVolume((uint32 *)lpdwVolume); - - *lpdwVolume -= (DSBVOLUME_MIN); - *lpdwVolume *= 64; - *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endif + if (g_system->getMixer()->isSoundHandleActive(_handle)) + *lpdwVolume = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume; + else + *lpdwVolume = 0; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index be3c2da319..6ebf30f22b 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -29,11 +29,16 @@ #ifndef TONY_SOUND_H #define TONY_SOUND_H +#include "audio/mixer.h" #include "common/file.h" #include "tony/gfxcore.h" #include "tony/loc.h" #include "tony/utils.h" +namespace Audio { +class RewindableAudioStream; +} + namespace Tony { class FPSTREAM; @@ -181,27 +186,16 @@ class FPSFX { \****************************************************************************/ private: - /* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound - */ bool bSoundSupported; // TRUE se il suono e' attivo bool bFileLoaded; // TRUE se e' stato aperto un file bool bLoop; // TRUE se bisogna loopare l'effetto sonoro - bool bPaused; int lastVolume; - bool bStereo; // TRUE se stereo - bool b16bit; // TRUE se 16 bit - uint32 dwFreq; // Frequenza originale di campionamento - - bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro - bool bIsVoice; + bool bPaused; -// LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer -// DSBPOSITIONNOTIFY dspnHot[2]; + Audio::AudioStream *_stream; + Audio::SoundHandle _handle; public: uint32 hEndOfBuffer; -- cgit v1.2.3 From 2da2981682cdc637faf5e2fccc041223d457bdc4 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 10 Jun 2012 22:03:52 -0400 Subject: TONY: Rewind sounds before playing them Fixes sounds in the menu --- engines/tony/sound.cpp | 21 +++++++++++++-------- engines/tony/sound.h | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e63245586d..1fb4bbee1f 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -199,6 +199,7 @@ FPSFX::FPSFX(bool bSoundOn) { hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; _stream = 0; + _rewindableStream = 0; bPaused = false; } @@ -220,6 +221,7 @@ FPSFX::~FPSFX() { g_system->getMixer()->stopHandle(_handle); delete _stream; + // _rewindableStream is deleted by deleting _stream // FIXME //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) @@ -264,11 +266,12 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { if (!stream) return false; - _stream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); + _rewindableStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); - if (!_stream) + if (!_rewindableStream) return false; + _stream = _rewindableStream; bFileLoaded = true; SetVolume(lastVolume); return true; @@ -297,7 +300,8 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { uint32 rate = vdbFP.readUint32LE(); bIsVoice = true; - _stream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); + _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); + _stream = _rewindableStream; bFileLoaded = true; SetVolume(62); @@ -324,23 +328,22 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { uint32 channels = file.readUint32LE(); Common::SeekableReadStream *buffer = file.readStream(file.size() - file.pos()); - Audio::RewindableAudioStream *stream; if (dwCodec == FPCODEC_ADPCM) { - stream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels); + _rewindableStream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels); } else { byte flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN; if (channels == 2) flags |= Audio::FLAG_STEREO; - stream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); + _rewindableStream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } if (bLoop) - _stream = Audio::makeLoopingAudioStream(stream, 0); + _stream = Audio::makeLoopingAudioStream(_rewindableStream, 0); else - _stream = stream; + _stream = _rewindableStream; bFileLoaded = true; return true; @@ -365,6 +368,8 @@ bool FPSFX::Play() { //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) // ResetEvent(hEndOfBuffer); + _rewindableStream->rewind(); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 6ebf30f22b..c64680a9cf 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -195,6 +195,7 @@ private: bool bPaused; Audio::AudioStream *_stream; + Audio::RewindableAudioStream *_rewindableStream; Audio::SoundHandle _handle; public: -- cgit v1.2.3 From 5b5a812d3750cc1e8063ccfc8d1d9bf4db6a127b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 12:20:12 +1000 Subject: TONY: Implemented process to properly set hEndOfBuffer when sound effects end --- engines/tony/sound.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/tony/sound.h | 9 +++++++++ engines/tony/tony.cpp | 3 +++ engines/tony/tony.h | 1 + 4 files changed, 48 insertions(+) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 1fb4bbee1f..487bf54111 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -201,6 +201,8 @@ FPSFX::FPSFX(bool bSoundOn) { _stream = 0; _rewindableStream = 0; bPaused = false; + + _vm->_activeSfx.push_back(this); } @@ -219,6 +221,7 @@ FPSFX::~FPSFX() { return; g_system->getMixer()->stopHandle(_handle); + _vm->_activeSfx.remove(this); delete _stream; // _rewindableStream is deleted by deleting _stream @@ -488,6 +491,38 @@ void FPSFX::GetVolume(int *lpdwVolume) { *lpdwVolume = 0; } +/** + * Returns true if the underlying sound has ended + */ +bool FPSFX::endOfBuffer() const { + return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_stream || _stream->endOfData()); +} + +/** + * Continually checks to see if active sounds have finished playing + * Sets the event signalling the sound has ended + */ +void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + Common::List::iterator i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + for (;;) { + // Check each active sound + for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { + FPSFX *sfx = *_ctx->i; + if (sfx->endOfBuffer()) + CoroScheduler.setEvent(sfx->hEndOfBuffer); + } + + // Delay until the next check is done + CORO_INVOKE_1(CoroScheduler.sleep, 50); + } + + CORO_END_CODE; +} /****************************************************************************\ * Metodi di FPSTREAM diff --git a/engines/tony/sound.h b/engines/tony/sound.h index c64680a9cf..6593470d0c 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -209,6 +209,10 @@ private: \****************************************************************************/ public: + /** + * Check process for whether sounds have finished playing + */ + static void soundCheckProcess(CORO_PARAM, const void *param); /****************************************************************************\ * @@ -353,6 +357,11 @@ public: \****************************************************************************/ void GetVolume(int *lpdwVolume); + + /** + * Returns true if the sound has finished playing + */ + bool endOfBuffer() const; }; class FPSTREAM { diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2b9d8fbc20..b1e45c8bfa 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -371,6 +371,9 @@ void TonyEngine::initMusic() { // Preload sound effects preloadUtilSFX(0, "U01.ADP"); // Reversed!! preloadUtilSFX(1, "U02.ADP"); + + // Start check processes for sound + CoroScheduler.createProcess(FPSFX::soundCheckProcess, NULL); } void TonyEngine::closeMusic() { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index cee15d07a4..43bc23c636 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -100,6 +100,7 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; + Common::List _activeSfx; Globals _globals; Debugger *_debugger; -- cgit v1.2.3 From d20fb7480eaccb59b11e3a5ba02b1a2b60619aaf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 19:22:41 +1000 Subject: TONY: Fix crash in the Tunnel Of Love --- engines/tony/custom.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 2e408a01aa..6627cd6c39 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -467,6 +467,11 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) CORO_INVOKE_0(GLOBALS.WaitFrame); + // WORKAROUND: This fixes a bug in the original source where the linked clear task + // didn't have time to be drawn and removed from the draw list before the method + // ended, thus remaining in the draw list and causing a later crash + CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_END_CODE; } -- cgit v1.2.3 From 71329df502bb07f105f34ac6c4b871ee0e8e19e0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 22:38:03 +1000 Subject: TONY: Removed unused variable --- engines/tony/font.cpp | 2 -- engines/tony/font.h | 1 - 2 files changed, 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 6652e77e13..6f70f41d80 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1760,7 +1760,6 @@ void RMFontObj::init(void) { \****************************************************************************/ RMFontColor *RMText::_fonts[4] = { NULL, NULL, NULL, NULL }; -RMGfxClearTask RMText::_clear; void RMText::initStatics() { Common::fill(&_fonts[0], &_fonts[4], (RMFontColor *)NULL); @@ -1891,7 +1890,6 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { // Create the surface create(width, height); - //AddPrim(new RMGfxPrimitive(&m_clear)); Common::fill(_buf, _buf + width * height * 2, 0); p = string; diff --git a/engines/tony/font.h b/engines/tony/font.h index d1423c9749..daaac84a59 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -175,7 +175,6 @@ public: class RMText : public RMGfxWoodyBuffer { private: static RMFontColor *_fonts[4]; - static RMGfxClearTask _clear; int _maxLineLength; public: -- cgit v1.2.3 From ef2eb685ddc94401d3981af863988f4e084fe02b Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 02c8ccebcb20aa904dba3151d65a7b4fa67998fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 20:24:25 +0200 Subject: TONY: Rename variables in utils.h --- engines/tony/custom.cpp | 23 +++--- engines/tony/debugger.cpp | 8 +- engines/tony/font.cpp | 44 +++++------ engines/tony/game.cpp | 18 ++--- engines/tony/gfxcore.cpp | 38 +++++----- engines/tony/gfxengine.cpp | 20 ++--- engines/tony/inventory.cpp | 48 ++++++------ engines/tony/loc.cpp | 177 +++++++++++++++++++++++---------------------- engines/tony/utils.cpp | 112 ++++++++++++++-------------- engines/tony/utils.h | 20 ++--- 10 files changed, 256 insertions(+), 252 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6627cd6c39..0cf40e5a14 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -477,7 +477,7 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { GLOBALS.Freeze(); - GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); + GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt._x, GLOBALS.SFM_pt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); GLOBALS.Unfreeze(); @@ -593,7 +593,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(ChangeLocation, GLOBALS._saveTonyLoc, GLOBALS._saveTonyPos.x, GLOBALS._saveTonyPos.y, 0); + CORO_INVOKE_4(ChangeLocation, GLOBALS._saveTonyLoc, GLOBALS._saveTonyPos._x, GLOBALS._saveTonyPos._y, 0); MCharResetCodes(); @@ -1299,14 +1299,14 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui if (sX) { if (_ctx->lx > 0) - _ctx->pt.x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; else - _ctx->pt.x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; } else { if (_ctx->ly > 0) - _ctx->pt.y += (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._y += (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; else - _ctx->pt.y -= (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._y -= (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; } @@ -1323,14 +1323,14 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui // Set the position finale if (sX) { if (_ctx->lx > 0) - _ctx->pt.x = _ctx->startpt.x + _ctx->dimx; + _ctx->pt._x = _ctx->startpt._x + _ctx->dimx; else - _ctx->pt.x = _ctx->startpt.x - _ctx->dimx; + _ctx->pt._x = _ctx->startpt._x - _ctx->dimx; } else { if (_ctx->ly > 0) - _ctx->pt.y = _ctx->startpt.y + _ctx->dimy; + _ctx->pt._y = _ctx->startpt._y + _ctx->dimy; else - _ctx->pt.y = _ctx->startpt.y - _ctx->dimy; + _ctx->pt._y = _ctx->startpt._y - _ctx->dimy; } GLOBALS.Freeze(); @@ -1345,12 +1345,13 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; - for (i = 0; i < GLOBALS._curChangedHotspot; i++) + for (i = 0; i < GLOBALS._curChangedHotspot; i++) { if (GLOBALS._changedHotspot[i]._dwCode == dwCode) { GLOBALS._changedHotspot[i]._nX = nX; GLOBALS._changedHotspot[i]._nY = nY; break; } + } if (i == GLOBALS._curChangedHotspot) { GLOBALS._changedHotspot[i]._dwCode = dwCode; diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 1a4dc16b75..8beb7285a4 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -94,8 +94,8 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { RMPoint scenePos; if (argc >= 4) { - scenePos.x = strToInt(argv[2]); - scenePos.y = strToInt(argv[3]); + scenePos._x = strToInt(argv[2]); + scenePos._y = strToInt(argv[3]); } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas @@ -106,8 +106,8 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Set up a process to change the scene ChangeSceneDetails details; details.sceneNumber = sceneNumber; - details.x = scenePos.x; - details.y = scenePos.y; + details.x = scenePos._x; + details.y = scenePos._y; CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails)); return false; diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 6f70f41d80..122c529de3 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1930,8 +1930,8 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { } prim = font->makeLetterPrimitive(*p, len); - prim->getDst().x1 = x; - prim->getDst().y1 = y; + prim->getDst()._x1 = x; + prim->getDst()._y1 = y; addPrim(prim); numchar++; @@ -1949,14 +1949,14 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { void RMText::clipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->getDst().x1 < 5) - prim->getDst().x1 = 5; - if (prim->getDst().y1 < 5) - prim->getDst().y1 = 5; - if (prim->getDst().x1 + _dimx > 635) - prim->getDst().x1 = 635 - _dimx; - if (prim->getDst().y1 + _dimy > 475) - prim->getDst().y1 = 475 - _dimy; + if (prim->getDst()._x1 < 5) + prim->getDst()._x1 = 5; + if (prim->getDst()._y1 < 5) + prim->getDst()._y1 = 5; + if (prim->getDst()._x1 + _dimx > 635) + prim->getDst()._x1 = 635 - _dimx; + if (prim->getDst()._y1 + _dimy > 475) + prim->getDst()._y1 = 475 - _dimy; } void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -1975,10 +1975,10 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { if (_aVerType == VTOP) { } else if (_aVerType == VCENTER) { - prim->getDst().y1 -= _dimy / 2; + prim->getDst()._y1 -= _dimy / 2; } else if (_aVerType == VBOTTOM) { - prim->getDst().y1 -= _dimy; + prim->getDst()._y1 -= _dimy; } clipOnScreen(prim); @@ -2416,7 +2416,7 @@ void RMDialogChoice::prepare(CORO_PARAM) { CORO_INVOKE_0(drawOT); clearOT(); - _ptDrawPos.set(0, 480 - _ctx->ptPos.y); + _ptDrawPos.set(0, 480 - _ctx->ptPos._y); CORO_END_CODE; } @@ -2436,7 +2436,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (_curSelection != -1) { _ctx->box.setColor(0xCC, 0xCC, 0xFF); - _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection]._y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); @@ -2447,7 +2447,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (pos != -1) { _ctx->box.setColor(100, 100, 100); - _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos].y); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos]._y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); addPrim(new RMGfxPrimitive(&_drawedStrings[pos], _ptDrawStrings[pos])); @@ -2481,7 +2481,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _bShow = true; } else { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - _ptDrawPos.y; + _ctx->deltay = 480 - _ptDrawPos._y; _ctx->destpt = _ptDrawPos; _ptDrawPos.set(0, 480); @@ -2494,11 +2494,11 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; + _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; mainUnfreeze(); } - _ptDrawPos.y = _ctx->destpt.y; + _ptDrawPos._y = _ctx->destpt._y; } CORO_END_CODE; @@ -2532,13 +2532,13 @@ void RMDialogChoice::hide(CORO_PARAM) { if (1) { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - _ptDrawPos.y; + _ctx->deltay = 480 - _ptDrawPos._y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; + _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; mainUnfreeze(); } } @@ -2562,9 +2562,9 @@ void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_BEGIN_CODE(_ctx); - if (ptMousePos.y > _ptDrawPos.y) { + if (ptMousePos._y > _ptDrawPos._y) { for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { - if ((ptMousePos.y >= _ptDrawPos.y + _ptDrawStrings[_ctx->i].y) && (ptMousePos.y < _ptDrawPos.y + _ptDrawStrings[_ctx->i].y + _drawedStrings[_ctx->i].getDimy())) { + if ((ptMousePos._y >= _ptDrawPos._y + _ptDrawStrings[_ctx->i]._y) && (ptMousePos._y < _ptDrawPos._y + _ptDrawStrings[_ctx->i]._y + _drawedStrings[_ctx->i].getDimy())) { CORO_INVOKE_1(setSelected, _ctx->i); break; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index f3aee0f183..c6107e2cf4 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -128,7 +128,7 @@ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { _buf = new RMGfxSourceBuffer16(false); _buf->init(raw, raw.width(), raw.height()); - _rect.setRect(pt.x, pt.y, pt.x + raw.width() - 1, pt.y + raw.height() - 1); + _rect.setRect(pt._x, pt._y, pt._x + raw.width() - 1, pt._y + raw.height() - 1); _bActive = false; _bHasGfx = true; _bDoubleState = bDoubleState; @@ -215,8 +215,8 @@ RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int INIT_GFX16_FROMRAW(20032, _SliderSingle); // Buttons - _PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); - _PushRight = new RMOptionButton(RMRect(pt.x + _nSlideSize, pt.y, pt.x + _nSlideSize + 5 + 22, pt.y + 26)); + _PushLeft = new RMOptionButton(RMRect(pt._x - 23, pt._y, pt._x - 23 + 22, pt._y + 26)); + _PushRight = new RMOptionButton(RMRect(pt._x + _nSlideSize, pt._y, pt._x + _nSlideSize + 5 + 22, pt._y + 26)); } @@ -280,8 +280,8 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * CORO_BEGIN_CODE(_ctx); _ctx->pos = _pos; - _ctx->pos.x += 4; - _ctx->pos.y += 4; + _ctx->pos._x += 4; + _ctx->pos._y += 4; _ctx->val = _nValue * _nStep; if (_ctx->val < 1) @@ -295,17 +295,17 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * } else { prim->setDst(_ctx->pos); CORO_INVOKE_2(_SliderLeft->draw, bigBuf, prim); - _ctx->pos.x += 3; + _ctx->pos._x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { prim->setDst(_ctx->pos); CORO_INVOKE_2(_SliderCenter->draw, bigBuf, prim); - _ctx->pos.x += 3; + _ctx->pos._x += 3; } prim->setDst(_ctx->pos); CORO_INVOKE_2(_SliderRight->draw, bigBuf, prim); - _ctx->pos.x += 3; + _ctx->pos._x += 3; } CORO_END_CODE; @@ -1546,7 +1546,7 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim // Copy the destination coordinates in the primitive prim->setDst(_pos); - if (_pos.x >= 0 && _pos.y >= 0 && _pos.x < RM_SX && _pos.y < RM_SY) { + if (_pos._x >= 0 && _pos._y >= 0 && _pos._x < RM_SX && _pos._y < RM_SY) { // Call the Draw method of the poitner prim->getDst() -= _hotspot[_ctx->n]; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index fdc435e3e9..9d3795c760 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -509,18 +509,18 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit // Clipping if (prim->haveSrc()) { - u = prim->getSrc().x1; - v = prim->getSrc().y1; + u = prim->getSrc()._x1; + v = prim->getSrc()._y1; width = prim->getSrc().width(); height = prim->getSrc().height(); } - if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) + if (!clip2D(dst._x1, dst._y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer - buf += dst.y1 * bufx + dst.x1; + buf += dst._y1 * bufx + dst._x1; // Normal step if (_bTrasp0) { @@ -617,18 +617,18 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim // Clipping if (prim->haveSrc()) { - u = prim->getSrc().x1; - v = prim->getSrc().y1; + u = prim->getSrc()._x1; + v = prim->getSrc()._y1; width = prim->getSrc().width(); height = prim->getSrc().height(); } - if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) + if (!clip2D(dst._x1, dst._y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer - buf += dst.y1 * bufx + dst.x1; + buf += dst._y1 * bufx + dst._x1; // Passaggio normale if (_bTrasp0) { @@ -813,8 +813,8 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri int x1, y1, u, v, width, height; // Clipping - x1 = prim->getDst().x1; - y1 = prim->getDst().y1; + x1 = prim->getDst()._x1; + y1 = prim->getDst()._y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -834,7 +834,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Clipping u = _dimx - (width + u); - x1 = (prim->getDst().x1 + _dimx - 1) - u; + x1 = (prim->getDst()._x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { // Decompressione @@ -1611,8 +1611,8 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri int step; // Clip the sprite - x1 = prim->getDst().x1; - y1 = prim->getDst().y1; + x1 = prim->getDst()._x1; + y1 = prim->getDst()._y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -1625,7 +1625,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (prim->isFlipped()) { u = _dimx - (width + u); - x1 = (prim->getDst().x1 + _dimx - 1) - u; + x1 = (prim->getDst()._x1 + _dimx - 1) - u; } // width = _dimx; // x1 = prim->Dst().x1; @@ -1837,15 +1837,15 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi y1 = 0; if (prim->haveSrc()) { - u = prim->getSrc().x1; - v = prim->getSrc().y1; + u = prim->getSrc()._x1; + v = prim->getSrc()._y1; dimx = prim->getSrc().width(); dimy = prim->getSrc().height(); } if (prim->haveDst()) { - x1 = prim->getDst().x1; - y1 = prim->getDst().y1; + x1 = prim->getDst()._x1; + y1 = prim->getDst()._y1; } if (!clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) @@ -1929,7 +1929,7 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) // It takes the destination rectangle rcDst = prim->getDst(); - buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; + buf += rcDst._y1 * bigBuf.getDimx() + rcDst._x1; // Loop through the pixels for (j = 0; j < rcDst.height(); j++) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e8f32edac7..8daf49c4a5 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -208,7 +208,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // ************ if (_bGUIOption) { if (!_tony.inAction() && _bInput) { - if ((_input.mouseLeftClicked() && _input.mousePos().x < 3 && _input.mousePos().y < 3)) { + if ((_input.mouseLeftClicked() && _input.mousePos()._x < 3 && _input.mousePos()._y < 3)) { CORO_INVOKE_1(openOptionScreen, 0); goto SKIPCLICKSINISTRO; } else if (_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) @@ -297,7 +297,7 @@ SKIPCLICKSINISTRO: // Update screen scrolling to keep Tony in focus if (_tony.mustUpdateScrolling() && _bLocationLoaded) { RMPoint showThis = _tony.position(); - showThis.y -= 60; + showThis._y -= 60; _loc.updateScrolling(showThis); } @@ -379,14 +379,14 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { - if (start.x == -1 || start.y == -1) { - start.x = ptTonyStart.x - RM_SX / 2; - start.y = ptTonyStart.y - RM_SY / 2; + if (start._x == -1 || start._y == -1) { + start._x = ptTonyStart._x - RM_SX / 2; + start._y = ptTonyStart._y - RM_SY / 2; } _loc.setScrollPosition(start); - if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { + if (ptTonyStart._x == 0 && ptTonyStart._y == 0) { } else { _tony.setPosition(ptTonyStart, nLoc); _tony.setScrollPosition(start); @@ -616,8 +616,8 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm f->writeByte(i); f->write(name.c_str(), i); f->writeUint32LE(_nCurLoc); - f->writeUint32LE(tp.x); - f->writeUint32LE(tp.y); + f->writeUint32LE(tp._x); + f->writeUint32LE(tp._y); f->writeUint32LE(size); f->write(state, size); @@ -738,8 +738,8 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { } _ctx->loc = _ctx->f->readUint32LE(); - _ctx->tp.x = _ctx->f->readUint32LE(); - _ctx->tp.y = _ctx->f->readUint32LE(); + _ctx->tp._x = _ctx->f->readUint32LE(); + _ctx->tp._y = _ctx->f->readUint32LE(); _ctx->size = _ctx->f->readUint32LE(); if ((_ctx->ver >= 0x5) && (_ctx->ver <= 7)) { diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index cfa49181e1..de8b21748e 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -66,9 +66,9 @@ RMInventory::~RMInventory() { bool RMInventory::checkPointInside(const RMPoint &pt) { if (!GLOBALS._bCfgInvUp) - return pt.y > RM_SY - 70; + return pt._y > RM_SY - 70; else - return pt.y < 70; + return pt._y < 70; } @@ -313,7 +313,7 @@ bool RMInventory::miniActive(void) { bool RMInventory::haveFocus(const RMPoint &mpos) { // When we combine, have the focus only if we are on an arrow (to scroll) - if (_state == OPENED && _bCombining && checkPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) + if (_state == OPENED && _bCombining && checkPointInside(mpos) && (mpos._x < 64 || mpos._x > RM_SX - 64)) return true; // If the inventory is open, focus we we go over it @@ -335,7 +335,7 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { int n; // The left click picks an item from your inventory to use it with the background - n = mpos.x / 64; + n = mpos._x / 64; if (_state == OPENED) { if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { @@ -401,7 +401,7 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_state == OPENED && !_bCombining) { // Open the context interface - n = mpos.x / 64; + n = mpos._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { _state = SELECTING; @@ -493,7 +493,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bNeedRedraw = true; if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { - if (mpos.x > RM_SX - 64) { + if (mpos._x > RM_SX - 64) { if (_curPos + 8 < _nInv && !_bBlinkingRight) { _items[28]._icon.setPattern(3); _bBlinkingRight = true; @@ -505,7 +505,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bNeedRedraw = true; } - if (mpos.x < 64) { + if (mpos._x < 64) { if (_curPos > 0 && !_bBlinkingLeft) { _items[29]._icon.setPattern(3); _bBlinkingLeft = true; @@ -540,7 +540,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (!GLOBALS._bCfgInvUp) { - if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos._y > RM_SY - 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = RM_SY - 1; @@ -550,7 +550,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = RM_SY - 68; } } else if (_state == OPENED) { - if ((mpos.y < RM_SY - 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if ((mpos._y < RM_SY - 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = RM_SY - 68; @@ -580,7 +580,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _state = CLOSED; } } else { - if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos._y < 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = - 68; @@ -590,7 +590,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = 0; } } else if (_state == OPENED) { - if ((mpos.y > 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if ((mpos._y > 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = -2; @@ -630,20 +630,20 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo starty = 70; // Make sure it is on one of the verbs - if (mpos.y > starty && mpos.y < starty + 45) { - if (mpos.x > startx && mpos.x < startx + 40) { + if (mpos._y > starty && mpos._y < starty + 45) { + if (mpos._x > startx && mpos._x < startx + 40) { if (_miniAction != 1) { _miniInterface.setPattern(2); _miniAction = 1; _vm->playUtilSFX(1); } - } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { + } else if (mpos._x >= startx + 40 && mpos._x < startx + 80) { if (_miniAction != 2) { _miniInterface.setPattern(3); _miniAction = 2; _vm->playUtilSFX(1); } - } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { + } else if (mpos._x >= startx + 80 && mpos._x < startx + 108) { if (_miniAction != 3) { _miniInterface.setPattern(4); _miniAction = 3; @@ -680,7 +680,7 @@ RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { if (_state == OPENED) { if (checkPointInside(mpt)) { - n = mpt.x / 64; + n = mpt._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) return &_items[_inv[n - 1 + _curPos]]._icon; } @@ -830,14 +830,14 @@ void RMInterface::clicked(const RMPoint &mousepos) { _lastHotZone = -1; // Keep it inside the screen - if (_openStart.x < 0) - _openStart.x = 0; - if (_openStart.y < 0) - _openStart.y = 0; - if (_openStart.x + _dimx > RM_SX) - _openStart.x = RM_SX - _dimx; - if (_openStart.y + _dimy > RM_SY) - _openStart.y = RM_SY - _dimy; + if (_openStart._x < 0) + _openStart._x = 0; + if (_openStart._y < 0) + _openStart._y = 0; + if (_openStart._x + _dimx > RM_SX) + _openStart._x = RM_SX - _dimx; + if (_openStart._y + _dimy > RM_SY) + _openStart._y = RM_SY - _dimy; // Play the sound effect _vm->playUtilSFX(0); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 81fb0d307f..9c032fe6be 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -183,23 +183,23 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { if (_slots[i]._type == SOUND) { if (i == 0) { if (sfx[_slots[i]._data]._name[0] == '_') { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } else { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(); } } else if (_speed == 0) { if (bPlayP0) { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(); } else if (sfx[_slots[i]._data]._name[0] == '_') { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } } else { if (_bLoop && sfx[_slots[i]._data]._name[0] == '_') { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } } @@ -251,7 +251,7 @@ int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case SOUND: if (sfx != NULL) { - sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos().x); + sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos()._x); if (sfx[_slots[_nCurSlot]._data]._name[0] != '_') sfx[_slots[_nCurSlot]._data].play(false); @@ -1054,8 +1054,8 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { _status = WALK; _lineStart = _pos; _lineEnd = destcoord; - _dx = _lineStart.x - _lineEnd.x; - _dy = _lineStart.y - _lineEnd.y; + _dx = _lineStart._x - _lineEnd._x; + _dy = _lineStart._y - _lineEnd._y; _fx = _dx; _fy = _dy; _dx = ABS(_dx); @@ -1071,7 +1071,7 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { if (_dx > _dy) { _slope = _fy / _fx; - if (_lineEnd.x < _lineStart.x) + if (_lineEnd._x < _lineStart._x) _walkSpeed = -_walkSpeed; _walkStatus = 1; @@ -1086,7 +1086,7 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { } } else { _slope = _fx / _fy; - if (_lineEnd.y < _lineStart.y) + if (_lineEnd._y < _lineStart._y) _walkSpeed = -_walkSpeed; _walkStatus = 0; @@ -1115,14 +1115,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { - nuovo.y--; + while ((inWhichBox(nuovo) == -1) && (nuovo._y >= 0)) { + nuovo._y--; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.y--; // to avoid error? + nuovo._y--; // to avoid error? trovato = nuovo; } } @@ -1130,14 +1130,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.y < 480)) { - nuovo.y++; + while ((inWhichBox(nuovo) == -1) && (nuovo._y < 480)) { + nuovo._y++; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.y++; // to avoid error? + nuovo._y++; // to avoid error? trovato = nuovo; } } @@ -1145,14 +1145,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.x < 640)) { - nuovo.x++; + while ((inWhichBox(nuovo) == -1) && (nuovo._x < 640)) { + nuovo._x++; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.x++; // to avoid error? + nuovo._x++; // to avoid error? trovato = nuovo; } } @@ -1160,14 +1160,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { - nuovo.x--; + while ((inWhichBox(nuovo) == -1) && (nuovo._x >= 0)) { + nuovo._x--; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.x--; // to avoid error? + nuovo._x--; // to avoid error? trovato = nuovo; } } @@ -1190,8 +1190,8 @@ short RMCharacter::scanLine(const RMPoint &punto) { Lstart = _pos; Lend = punto; - Ldx = Lstart.x - Lend.x; - Ldy = Lstart.y - Lend.y; + Ldx = Lstart._x - Lend._x; + Ldy = Lstart._y - Lend._y; Lfx = Ldx; Lfy = Ldy; Ldx = ABS(Ldx); @@ -1201,11 +1201,11 @@ short RMCharacter::scanLine(const RMPoint &punto) { if (Ldx > Ldy) { Lslope = Lfy / Lfx; - if (Lend.x < Lstart.x) Lspeed = -Lspeed; + if (Lend._x < Lstart._x) Lspeed = -Lspeed; Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed = - Lspeed; + if (Lend._y < Lstart._y) Lspeed = - Lspeed; Lstatus = 0; } @@ -1220,10 +1220,11 @@ short RMCharacter::scanLine(const RMPoint &punto) { Ldx = (int)(Lslope * Ldy); } - Lscan.x = Lstart.x + Ldx; - Lscan.y = Lstart.y + Ldy; + Lscan._x = Lstart._x + Ldx; + Lscan._y = Lstart._y + Ldy; - if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; + if ((ABS(Lscan._x - Lend._x) <= 1) && (ABS(Lscan._y - Lend._y) <= 1)) + return 1; } return 0; @@ -1240,8 +1241,8 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { Lstart = punto; // Exchange! Lend = _pos; // :-) - Ldx = Lstart.x - Lend.x; - Ldy = Lstart.y - Lend.y; + Ldx = Lstart._x - Lend._x; + Ldy = Lstart._y - Lend._y; Lfx = Ldx; Lfy = Ldy; Ldx = ABS(Ldx); @@ -1251,11 +1252,13 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { if (Ldx > Ldy) { Lslope = Lfy / Lfx; - if (Lend.x < Lstart.x) Lspeed = -Lspeed; + if (Lend._x < Lstart._x) + Lspeed = -Lspeed; Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed = -Lspeed; + if (Lend._y < Lstart._y) + Lspeed = -Lspeed; Lstatus = 0; } Lscan = Lstart; @@ -1278,11 +1281,11 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { Ldy = Lspeed * Lcount; Ldx = (int)(Lslope * Ldy); } - Lscan.x = Lstart.x + Ldx; - Lscan.y = Lstart.y + Ldy; + Lscan._x = Lstart._x + Ldx; + Lscan._y = Lstart._y + Ldy; // WORKAROUND: Handles cases where the points never fall inside a bounding box - if (Lscan.x < -100 || Lscan.y < -100 || Lscan.x >= 1000 || Lscan.y >= 1000) + if (Lscan._x < -100 || Lscan._y < -100 || Lscan._x >= 1000 || Lscan._y >= 1000) return punto; } } @@ -1301,13 +1304,13 @@ RMPoint RMCharacter::nearestHotSpot(int sourcebox, int destbox) { for (cc = 0; cc < cur->_boxes[sourcebox]._numHotspot; cc++) if ((cur->_boxes[sourcebox]._hotspot[cc]._destination) == destbox) { - x = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hotx - _pos.x); - y = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hoty - _pos.y); + x = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hotx - _pos._x); + y = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hoty - _pos._y); if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; - puntocaldo.x = cur->_boxes[sourcebox]._hotspot[cc]._hotx; - puntocaldo.y = cur->_boxes[sourcebox]._hotspot[cc]._hoty; + puntocaldo._x = cur->_boxes[sourcebox]._hotspot[cc]._hotx; + puntocaldo._y = cur->_boxes[sourcebox]._hotspot[cc]._hoty; } } @@ -1391,11 +1394,11 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (_walkStatus == 1) { _dx = _walkSpeed * _walkCount; _dy = (int)(_slope * _dx); - _pos.x = _lineStart.x + _dx; - _pos.y = _lineStart.y + _dy; + _pos._x = _lineStart._x + _dx; + _pos._y = _lineStart._y + _dy; // Right - if (((_walkSpeed > 0) && (_pos.x > _lineEnd.x)) || ((_walkSpeed < 0) && (_pos.x < _lineEnd.x))) { + if (((_walkSpeed > 0) && (_pos._x > _lineEnd._x)) || ((_walkSpeed < 0) && (_pos._x < _lineEnd._x))) { _pos = _lineEnd; _status = STAND; _ctx->bEndNow = true; @@ -1406,11 +1409,11 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (_walkStatus == 0) { _dy = _walkSpeed * _walkCount; _dx = (int)(_slope * _dy); - _pos.x = _lineStart.x + _dx; - _pos.y = _lineStart.y + _dy; + _pos._x = _lineStart._x + _dx; + _pos._y = _lineStart._y + _dy; // Down - if (((_walkSpeed > 0) && (_pos.y > _lineEnd.y)) || ((_walkSpeed < 0) && (_pos.y < _lineEnd.y))) { + if (((_walkSpeed > 0) && (_pos._y > _lineEnd._y)) || ((_walkSpeed < 0) && (_pos._y < _lineEnd._y))) { _pos = _lineEnd; _status = STAND; _ctx->bEndNow = true; @@ -1419,8 +1422,8 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // Check if the character came out of the BOX in error, in which case he returns immediately if (inWhichBox(_pos) == -1) { - _pos.x = _lineStart.x + _olddx; - _pos.y = _lineStart.y + _olddy; + _pos._x = _lineStart._x + _olddx; + _pos._y = _lineStart._y + _olddy; } // If we have just moved to a temporary location, and is over the shortest path, we stop permanently @@ -1545,7 +1548,7 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { _bMoving = true; // 0, 0 does not do anything, just stops the character - if (pt.x == 0 && pt.y == 0) { + if (pt._x == 0 && pt._y == 0) { _minPath = 0; _status = STAND; CORO_INVOKE_0(stop); @@ -1833,8 +1836,8 @@ RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = getBoxes(nLoc); - if ((pt.x >= cur->_boxes[nBox]._left) && (pt.x <= cur->_boxes[nBox]._right) && - (pt.y >= cur->_boxes[nBox]._top) && (pt.y <= cur->_boxes[nBox]._bottom)) + if ((pt._x >= cur->_boxes[nBox]._left) && (pt._x <= cur->_boxes[nBox]._right) && + (pt._y >= cur->_boxes[nBox]._top) && (pt._y <= cur->_boxes[nBox]._bottom)) return true; else return false; @@ -1849,8 +1852,8 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { for (i = 0; i < cur->numbbox; i++) if (cur->_boxes[i]._attivo) - if ((punto.x >= cur->_boxes[i]._left) && (punto.x <= cur->_boxes[i]._right) && - (punto.y >= cur->_boxes[i]._top) && (punto.y <= cur->_boxes[i]._bottom)) + if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && + (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) return i; return -1; @@ -2025,7 +2028,7 @@ bool RMLocation::load(RMDataStream &ds) { // Skip the MPAL bailouts (64 bytes) ds >> TEMPNumLoc; - ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + ds >> TEMPTonyStart._x >> TEMPTonyStart._y; ds += 64 - 4 * 3; // Skip flag associated with the background (?) @@ -2091,7 +2094,7 @@ bool RMLocation::loadLOX(RMDataStream &ds) { // Location number ds >> TEMPNumLoc; - ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + ds >> TEMPTonyStart._x >> TEMPTonyStart._y; // Dimensions ds >> dimx >> dimy; @@ -2210,36 +2213,36 @@ void RMLocation::unload(void) { void RMLocation::updateScrolling(const RMPoint &ptShowThis) { RMPoint oldScroll = _curScroll; - if (_curScroll.x + 250 > ptShowThis.x) { - _curScroll.x = ptShowThis.x - 250; - } else if (_curScroll.x + RM_SX - 250 < ptShowThis.x) { - _curScroll.x = ptShowThis.x + 250 - RM_SX; - } else if (ABS(_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && _buf->getDimx() > RM_SX) { - if (_curScroll.x + RM_SX / 2 < ptShowThis.x) - _curScroll.x++; + if (_curScroll._x + 250 > ptShowThis._x) { + _curScroll._x = ptShowThis._x - 250; + } else if (_curScroll._x + RM_SX - 250 < ptShowThis._x) { + _curScroll._x = ptShowThis._x + 250 - RM_SX; + } else if (ABS(_curScroll._x + RM_SX / 2 - ptShowThis._x) > 32 && _buf->getDimx() > RM_SX) { + if (_curScroll._x + RM_SX / 2 < ptShowThis._x) + _curScroll._x++; else - _curScroll.x--; + _curScroll._x--; } - if (_curScroll.y + 180 > ptShowThis.y) { - _curScroll.y = ptShowThis.y - 180; - } else if (_curScroll.y + RM_SY - 180 < ptShowThis.y) { - _curScroll.y = ptShowThis.y + 180 - RM_SY; - } else if (ABS(_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && _buf->getDimy() > RM_SY) { - if (_curScroll.y + RM_SY / 2 < ptShowThis.y) - _curScroll.y++; + if (_curScroll._y + 180 > ptShowThis._y) { + _curScroll._y = ptShowThis._y - 180; + } else if (_curScroll._y + RM_SY - 180 < ptShowThis._y) { + _curScroll._y = ptShowThis._y + 180 - RM_SY; + } else if (ABS(_curScroll._y + RM_SY / 2 - ptShowThis._y) > 16 && _buf->getDimy() > RM_SY) { + if (_curScroll._y + RM_SY / 2 < ptShowThis._y) + _curScroll._y++; else - _curScroll.y--; + _curScroll._y--; } - if (_curScroll.x < 0) - _curScroll.x = 0; - if (_curScroll.y < 0) - _curScroll.y = 0; - if (_curScroll.x + RM_SX > _buf->getDimx()) - _curScroll.x = _buf->getDimx() - RM_SX; - if (_curScroll.y + RM_SY > _buf->getDimy()) - _curScroll.y = _buf->getDimy() - RM_SY; + if (_curScroll._x < 0) + _curScroll._x = 0; + if (_curScroll._y < 0) + _curScroll._y = 0; + if (_curScroll._x + RM_SX > _buf->getDimx()) + _curScroll._x = _buf->getDimx() - RM_SX; + if (_curScroll._y + RM_SY > _buf->getDimy()) + _curScroll._y = _buf->getDimy() - RM_SY; if (oldScroll != _curScroll) for (int i = 0; i < _nItems; i++) @@ -2255,14 +2258,14 @@ void RMLocation::setFixedScroll(const RMPoint &scroll) { void RMLocation::setScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; - if (pt.x < 0) - pt.x = 0; - if (pt.y < 0) - pt.y = 0; - if (pt.x + RM_SX > _buf->getDimx()) - pt.x = _buf->getDimx() - RM_SX; - if (pt.y + RM_SY > _buf->getDimy()) - pt.y = _buf->getDimy() - RM_SY; + if (pt._x < 0) + pt._x = 0; + if (pt._y < 0) + pt._y = 0; + if (pt._x + RM_SX > _buf->getDimx()) + pt._x = _buf->getDimx() - RM_SX; + if (pt._y + RM_SY > _buf->getDimy()) + pt._y = _buf->getDimy() - RM_SY; _curScroll = pt; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index fa100d681e..6d790c0e68 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -734,31 +734,31 @@ int RMDataStream::getError() { * Constructor */ RMPoint::RMPoint() { - x = y = 0; + _x = _y = 0; } /** * Copy constructor */ RMPoint::RMPoint(const RMPoint &p) { - x = p.x; - y = p.y; + _x = p._x; + _y = p._y; } /** * Constructor with integer parameters */ RMPoint::RMPoint(int x1, int y1) { - x = x1; - y = y1; + _x = x1; + _y = y1; } /** * Copy operator */ RMPoint &RMPoint::operator=(RMPoint p) { - x = p.x; - y = p.y; + _x = p._x; + _y = p._y; return *this; } @@ -767,16 +767,16 @@ RMPoint &RMPoint::operator=(RMPoint p) { * Offsets the point by another point */ void RMPoint::offset(const RMPoint &p) { - x += p.x; - y += p.y; + _x += p._x; + _y += p._y; } /** * Offsets the point by a specified offset */ void RMPoint::offset(int xOff, int yOff) { - x += xOff; - y += yOff; + _x += xOff; + _y += yOff; } /** @@ -819,8 +819,8 @@ RMPoint &RMPoint::operator-=(RMPoint p) { RMPoint RMPoint::operator-() { RMPoint p; - p.x = -x; - p.y = -y; + p._x = -_x; + p._y = -_y; return p; } @@ -829,21 +829,21 @@ RMPoint RMPoint::operator-() { * Equality operator */ bool RMPoint::operator==(RMPoint p) { - return ((x == p.x) && (y == p.y)); + return ((_x == p._x) && (_y == p._y)); } /** * Not equal operator */ bool RMPoint::operator!=(RMPoint p) { - return ((x != p.x) || (y != p.y)); + return ((_x != p._x) || (_y != p._y)); } /** * Reads a point from a stream */ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { - ds >> p.x >> p.y; + ds >> p._x >> p._y; return ds; } @@ -856,7 +856,7 @@ RMRect::RMRect() { } void RMRect::setEmpty(void) { - x1 = y1 = x2 = y2 = 0; + _x1 = _y1 = _x2 = _y2 = 0; } RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { @@ -872,17 +872,17 @@ RMRect::RMRect(const RMRect &rc) { } void RMRect::setRect(const RMPoint &p1, const RMPoint &p2) { - x1 = p1.x; - y1 = p1.y; - x2 = p2.x; - y2 = p2.y; + _x1 = p1._x; + _y1 = p1._y; + _x2 = p2._x; + _y2 = p2._y; } void RMRect::setRect(int X1, int Y1, int X2, int Y2) { - x1 = X1; - y1 = Y1; - x2 = X2; - y2 = Y2; + _x1 = X1; + _y1 = Y1; + _x2 = X2; + _y2 = Y2; } void RMRect::setRect(const RMRect &rc) { @@ -890,10 +890,10 @@ void RMRect::setRect(const RMRect &rc) { } void RMRect::copyRect(const RMRect &rc) { - x1 = rc.x1; - y1 = rc.y1; - x2 = rc.x2; - y2 = rc.y2; + _x1 = rc._x1; + _y1 = rc._y1; + _x2 = rc._x2; + _y2 = rc._y2; } RMPoint &RMRect::topLeft() { @@ -907,15 +907,15 @@ RMPoint &RMRect::bottomRight() { } RMPoint RMRect::center() { - return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); + return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } int RMRect::width() const { - return x2 - x1; + return _x2 - _x1; } int RMRect::height() const { - return y2 - y1; + return _y2 - _y1; } int RMRect::size() const { @@ -923,7 +923,7 @@ int RMRect::size() const { } bool RMRect::isEmpty() const { - return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); + return (_x1 == 0 && _y1 == 0 && _x2 == 0 && _y2 == 0); } const RMRect &RMRect::operator=(const RMRect &rc) { @@ -932,17 +932,17 @@ const RMRect &RMRect::operator=(const RMRect &rc) { } void RMRect::offset(int xOff, int yOff) { - x1 += xOff; - y1 += yOff; - x2 += xOff; - y2 += yOff; + _x1 += xOff; + _y1 += yOff; + _x2 += xOff; + _y2 += yOff; } void RMRect::offset(const RMPoint &p) { - x1 += p.x; - y1 += p.y; - x2 += p.x; - y2 += p.y; + _x1 += p._x; + _y1 += p._y; + _x2 += p._x; + _y2 += p._y; } const RMRect &RMRect::operator+=(RMPoint p) { @@ -979,19 +979,19 @@ RMRect operator-(RMPoint p, const RMRect &rc) { } bool RMRect::operator==(const RMRect &rc) { - return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); + return ((_x1 == rc._x1) && (_y1 == rc._y1) && (_x2 == rc._x2) && (_y2 == rc._y2)); } bool RMRect::operator!=(const RMRect &rc) { - return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); + return ((_x1 != rc._x1) || (_y1 != rc._y1) || (_x2 != rc._x2) || (_y2 != rc._y2)); } void RMRect::normalizeRect(void) { - setRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); + setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { - ds >> rc.x1 >> rc.y1 >> rc.x2 >> rc.y2; + ds >> rc._x1 >> rc._y1 >> rc._x2 >> rc._y2; return ds; } @@ -1032,10 +1032,10 @@ void RMResUpdate::init(const Common::String &fileName) { for (i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; - info.dwRes = _hFile.readUint32LE(); - info.offset = _hFile.readUint32LE(); - info.size = _hFile.readUint32LE(); - info.cmpSize = _hFile.readUint32LE(); + info._dwRes = _hFile.readUint32LE(); + info._offset = _hFile.readUint32LE(); + info._size = _hFile.readUint32LE(); + info._cmpSize = _hFile.readUint32LE(); } } @@ -1046,7 +1046,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { uint32 i; for (i = 0; i < _numUpd; ++i) - if (_infos[i].dwRes == dwRes) + if (_infos[i]._dwRes == dwRes) // Found the index break; @@ -1055,26 +1055,26 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { return NULL; const ResUpdInfo &info = _infos[i]; - byte *cmpBuf = new byte[info.cmpSize]; + byte *cmpBuf = new byte[info._cmpSize]; uint32 dwRead; // Move to the correct offset and read in the compressed data - _hFile.seek(info.offset); - dwRead = _hFile.read(cmpBuf, info.cmpSize); + _hFile.seek(info._offset); + dwRead = _hFile.read(cmpBuf, info._cmpSize); - if (info.cmpSize > dwRead) { + if (info._cmpSize > dwRead) { // Error occurred reading data, so return NULL delete[] cmpBuf; return NULL; } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(0, info.size); + HGLOBAL destBuf = globalAllocate(0, info._size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; // Decompress the data - lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + lzo1x_decompress(cmpBuf, info._cmpSize, lpDestBuf, &dwSize); // Delete buffer for compressed data delete [] cmpBuf; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index e649000e58..33e2db7d7e 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -212,7 +212,7 @@ private: */ class RMPoint { public: - int x, y; + int _x, _y; public: // Constructor @@ -225,8 +225,8 @@ public: // Set void set(int x1, int y1) { - x = x1; - y = y1; + _x = x1; + _y = y1; } // Offset @@ -251,8 +251,8 @@ public: class RMRect { public: - int x1, y1; - int x2, y2; + int _x1, _y1; + int _x2, _y2; public: RMRect(); @@ -298,7 +298,7 @@ public: // Point in rect bool ptInRect(const RMPoint &pt) { - return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); + return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); } // Extract from data stream @@ -310,10 +310,10 @@ public: */ class RMResUpdate { struct ResUpdInfo { - uint32 dwRes; - uint32 offset; - uint32 size; - uint32 cmpSize; + uint32 _dwRes; + uint32 _offset; + uint32 _size; + uint32 _cmpSize; }; uint32 _numUpd; -- cgit v1.2.3 From 94df38bfb4f2d9831e1cdc7cfe8a873e3ba13f42 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 21:30:47 +0200 Subject: TONY: Rename variables in game.h and gfxcore.h --- engines/tony/game.cpp | 850 +++++++++++++++++++++++------------------------ engines/tony/game.h | 86 ++--- engines/tony/gfxcore.cpp | 36 +- engines/tony/gfxcore.h | 6 +- 4 files changed, 489 insertions(+), 489 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c6107e2cf4..9fc65aa87d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -203,47 +203,47 @@ RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int _nStep = 100 / _nMax; _nValue = nStartValue; - _SliderCenter = NULL; - _SliderLeft = NULL; - _SliderRight = NULL; - _SliderSingle = NULL; + _sliderCenter = NULL; + _sliderLeft = NULL; + _sliderRight = NULL; + _sliderSingle = NULL; // Sliders - INIT_GFX16_FROMRAW(20029, _SliderCenter); - INIT_GFX16_FROMRAW(20030, _SliderLeft); - INIT_GFX16_FROMRAW(20031, _SliderRight); - INIT_GFX16_FROMRAW(20032, _SliderSingle); + INIT_GFX16_FROMRAW(20029, _sliderCenter); + INIT_GFX16_FROMRAW(20030, _sliderLeft); + INIT_GFX16_FROMRAW(20031, _sliderRight); + INIT_GFX16_FROMRAW(20032, _sliderSingle); // Buttons - _PushLeft = new RMOptionButton(RMRect(pt._x - 23, pt._y, pt._x - 23 + 22, pt._y + 26)); - _PushRight = new RMOptionButton(RMRect(pt._x + _nSlideSize, pt._y, pt._x + _nSlideSize + 5 + 22, pt._y + 26)); + _pushLeft = new RMOptionButton(RMRect(pt._x - 23, pt._y, pt._x - 23 + 22, pt._y + 26)); + _pushRight = new RMOptionButton(RMRect(pt._x + _nSlideSize, pt._y, pt._x + _nSlideSize + 5 + 22, pt._y + 26)); } RMOptionSlide::~RMOptionSlide() { - delete _SliderCenter; - _SliderCenter = NULL; - delete _SliderLeft; - _SliderLeft = NULL; - delete _SliderRight; - _SliderRight = NULL; - delete _SliderSingle; - _SliderSingle = NULL; - - delete _PushLeft; - _PushLeft = NULL; - delete _PushRight; - _PushRight = NULL; + delete _sliderCenter; + _sliderCenter = NULL; + delete _sliderLeft; + _sliderLeft = NULL; + delete _sliderRight; + _sliderRight = NULL; + delete _sliderSingle; + _sliderSingle = NULL; + + delete _pushLeft; + _pushLeft = NULL; + delete _pushRight; + _pushRight = NULL; } bool RMOptionSlide::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; // Do the button DoFrame's - _PushLeft->doFrame(mousePos, bLeftClick, bRightClick); - _PushRight->doFrame(mousePos, bLeftClick, bRightClick); + _pushLeft->doFrame(mousePos, bLeftClick, bRightClick); + _pushRight->doFrame(mousePos, bLeftClick, bRightClick); - if (_PushLeft->isActive()) { + if (_pushLeft->isActive()) { if (bLeftClick) { bRefresh = true; _nValue--; @@ -253,7 +253,7 @@ bool RMOptionSlide::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRigh } if (_nValue < 1) _nValue = 1; - } else if (_PushRight->isActive()) { + } else if (_pushRight->isActive()) { bRefresh = true; if (bLeftClick) { @@ -291,20 +291,20 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * if (_ctx->val == 1) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderSingle->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderSingle->draw, bigBuf, prim); } else { prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderLeft->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderLeft->draw, bigBuf, prim); _ctx->pos._x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderCenter->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderCenter->draw, bigBuf, prim); _ctx->pos._x += 3; } prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderRight->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderRight->draw, bigBuf, prim); _ctx->pos._x += 3; } @@ -324,56 +324,56 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { RMOptionScreen::RMOptionScreen(void) { _nState = MENUNONE; _menu = NULL; - _HideLoadSave = NULL; - _QuitConfirm = NULL; + _hideLoadSave = NULL; + _quitConfirm = NULL; _bQuitConfirm = false; create(RM_SX, RM_SY); - _ButtonExit = NULL; - _ButtonLoad = NULL; - _ButtonSave = NULL; - _ButtonGameMenu = NULL; - _ButtonGfxMenu = NULL; - _ButtonSoundMenu = NULL; - _ButtonSave_ArrowLeft = NULL; - _ButtonSave_ArrowRight = NULL; + _buttonExit = NULL; + _buttonLoad = NULL; + _buttonSave = NULL; + _buttonGameMenu = NULL; + _buttonGfxMenu = NULL; + _buttonSoundMenu = NULL; + _buttonSave_ArrowLeft = NULL; + _buttonSave_ArrowRight = NULL; _bEditSaveName = false; int i; for (i = 0; i < 6; i++) { _curThumb[i] = NULL; - _ButtonSave_States[i] = NULL; + _buttonSave_States[i] = NULL; } _statePos = 0; - _ButtonQuitYes = NULL; - _ButtonQuitNo = NULL; - _ButtonQuit = NULL; - _SaveEasy = NULL; - _SaveHard = NULL; - _ButtonGfx_Tips = NULL; - _ButtonSound_DubbingOn = NULL; - _ButtonSound_MusicOn = NULL; - _ButtonSound_SFXOn = NULL; - _SlideTonySpeed = NULL; - _SlideTextSpeed = NULL; - _ButtonGame_Lock = NULL; - _ButtonGfx_Anni30 = NULL; - _SliderSound_Music = NULL; - _ButtonGame_TimerizedText = NULL; - _ButtonGfx_AntiAlias = NULL; - _SliderSound_SFX = NULL; - _ButtonGame_Scrolling = NULL; - _ButtonGfx_Sottotitoli = NULL; - _SliderSound_Dubbing = NULL; - _ButtonGame_InterUp = NULL; - _ButtonGfx_Trans = NULL; - - _FadeStep = 0; - _FadeY = 0; - _FadeTime = 0; + _buttonQuitYes = NULL; + _buttonQuitNo = NULL; + _buttonQuit = NULL; + _saveEasy = NULL; + _saveHard = NULL; + _buttonGfx_Tips = NULL; + _buttonSound_DubbingOn = NULL; + _buttonSound_MusicOn = NULL; + _buttonSound_SFXOn = NULL; + _slideTonySpeed = NULL; + _slideTextSpeed = NULL; + _buttonGame_Lock = NULL; + _buttonGfx_Anni30 = NULL; + _sliderSound_Music = NULL; + _buttonGame_TimerizedText = NULL; + _buttonGfx_AntiAlias = NULL; + _sliderSound_SFX = NULL; + _buttonGame_Scrolling = NULL; + _buttonGfx_Sottotitoli = NULL; + _sliderSound_Dubbing = NULL; + _buttonGame_InterUp = NULL; + _buttonGfx_Trans = NULL; + + _fadeStep = 0; + _fadeY = 0; + _fadeTime = 0; _nEditPos = 0; _nLastState = MENUGAME; } @@ -397,42 +397,42 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_menu)); if (_bNoLoadSave) - addPrim(new RMGfxPrimitive(_HideLoadSave, RMPoint(0, 401))); + addPrim(new RMGfxPrimitive(_hideLoadSave, RMPoint(0, 401))); if (_bQuitConfirm) { - addPrim(new RMGfxPrimitive(_QuitConfirm, RMPoint(270, 200))); - _ButtonQuitYes->addToList(*this); - _ButtonQuitNo->addToList(*this); + addPrim(new RMGfxPrimitive(_quitConfirm, RMPoint(270, 200))); + _buttonQuitYes->addToList(*this); + _buttonQuitNo->addToList(*this); } - _ButtonExit->addToList(*this); + _buttonExit->addToList(*this); if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { - _ButtonQuit->addToList(*this); - _ButtonLoad->addToList(*this); - _ButtonSave->addToList(*this); + _buttonQuit->addToList(*this); + _buttonLoad->addToList(*this); + _buttonSave->addToList(*this); } if (_nState == MENUGAME) { - _ButtonGame_Lock->addToList(*this); - _ButtonGame_TimerizedText->addToList(*this); - _ButtonGame_Scrolling->addToList(*this); - _ButtonGame_InterUp->addToList(*this); - _SlideTextSpeed->addToList(*this); - _SlideTonySpeed->addToList(*this); + _buttonGame_Lock->addToList(*this); + _buttonGame_TimerizedText->addToList(*this); + _buttonGame_Scrolling->addToList(*this); + _buttonGame_InterUp->addToList(*this); + _slideTextSpeed->addToList(*this); + _slideTonySpeed->addToList(*this); } else if (_nState == MENUGFX) { - _ButtonGfx_Anni30->addToList(*this); - _ButtonGfx_AntiAlias->addToList(*this); - _ButtonGfx_Sottotitoli->addToList(*this); - _ButtonGfx_Trans->addToList(*this); - _ButtonGfx_Tips->addToList(*this); + _buttonGfx_Anni30->addToList(*this); + _buttonGfx_AntiAlias->addToList(*this); + _buttonGfx_Sottotitoli->addToList(*this); + _buttonGfx_Trans->addToList(*this); + _buttonGfx_Tips->addToList(*this); } else if (_nState == MENUSOUND) { - _SliderSound_Dubbing->addToList(*this); - _SliderSound_Music->addToList(*this); - _SliderSound_SFX->addToList(*this); - _ButtonSound_DubbingOn->addToList(*this); - _ButtonSound_MusicOn->addToList(*this); - _ButtonSound_SFXOn->addToList(*this); + _sliderSound_Dubbing->addToList(*this); + _sliderSound_Music->addToList(*this); + _sliderSound_SFX->addToList(*this); + _buttonSound_DubbingOn->addToList(*this); + _buttonSound_MusicOn->addToList(*this); + _buttonSound_SFXOn->addToList(*this); } _ctx->thumb = NULL; @@ -452,29 +452,29 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (_curThumbDiff[0] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(48, 57))); else if (_curThumbDiff[0] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(48, 57))); if (_curThumbDiff[1] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(240, 57))); else if (_curThumbDiff[1] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(240, 57))); if (_curThumbDiff[2] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(432, 57))); else if (_curThumbDiff[2] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(432, 57))); if (_curThumbDiff[3] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(48, 239))); else if (_curThumbDiff[3] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(48, 239))); if (_curThumbDiff[4] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(240, 239))); else if (_curThumbDiff[4] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(240, 239))); if (_curThumbDiff[5] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(432, 239))); else if (_curThumbDiff[5] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(432, 239))); if (_curThumb[0] && !(_bEditSaveName && _nEditPos == 0)) addPrim(new RMGfxPrimitive(_curThumb[0], RMPoint(48, 57))); @@ -511,7 +511,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { RMString s; if (_bEditSaveName && _nEditPos == _ctx->i) - s.format("%02d)%s*", _statePos + _ctx->i, _EditName); + s.format("%02d)%s*", _statePos + _ctx->i, _editName); else { if (_statePos == 0 && _ctx->i == 0) s.format("Autosave"); @@ -531,8 +531,8 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); addPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); - _ButtonSave_ArrowLeft->addToList(*this); - _ButtonSave_ArrowRight->addToList(*this); + _buttonSave_ArrowLeft->addToList(*this); + _buttonSave_ArrowRight->addToList(*this); } CORO_INVOKE_0(drawOT); @@ -593,137 +593,137 @@ void RMOptionScreen::initState(CORO_PARAM) { if (_nState == MENULOAD || _nState == MENUSAVE) { if (_bAlterGfx) { - assert(_ButtonExit == NULL); - _ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); + assert(_buttonExit == NULL); + _buttonExit = new RMOptionButton(20025, RMPoint(561, 406)); } else { - assert(_ButtonExit == NULL); - _ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); + assert(_buttonExit == NULL); + _buttonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(_ctx->raw, 20036, _SaveEasy); - INIT_GFX8_FROMRAW(_ctx->raw, 20037, _SaveHard); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, _saveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, _saveHard); refreshThumbnails(); - assert(_ButtonSave_States[0] == NULL); - _ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); - assert(_ButtonSave_States[1] == NULL); - _ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); - assert(_ButtonSave_States[2] == NULL); - _ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); - assert(_ButtonSave_States[3] == NULL); - _ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); - assert(_ButtonSave_States[4] == NULL); - _ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); - assert(_ButtonSave_States[5] == NULL); - _ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); + assert(_buttonSave_States[0] == NULL); + _buttonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); + assert(_buttonSave_States[1] == NULL); + _buttonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); + assert(_buttonSave_States[2] == NULL); + _buttonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); + assert(_buttonSave_States[3] == NULL); + _buttonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); + assert(_buttonSave_States[4] == NULL); + _buttonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); + assert(_buttonSave_States[5] == NULL); + _buttonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); if (_bAlterGfx) { - assert(_ButtonSave_ArrowLeft == NULL); - _ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); - assert(_ButtonSave_ArrowRight == NULL); - _ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); + assert(_buttonSave_ArrowLeft == NULL); + _buttonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); + assert(_buttonSave_ArrowRight == NULL); + _buttonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); } else { - assert(_ButtonSave_ArrowLeft == NULL); - _ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); - assert(_ButtonSave_ArrowRight == NULL); - _ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); + assert(_buttonSave_ArrowLeft == NULL); + _buttonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); + assert(_buttonSave_ArrowRight == NULL); + _buttonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); } } else if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { - assert(_ButtonExit == NULL); - _ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); - assert(_ButtonQuit == NULL); - _ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); - assert(_ButtonLoad == NULL); - _ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); - assert(_ButtonSave == NULL); - _ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); - - assert(_ButtonGameMenu == NULL); - _ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); - assert(_ButtonGfxMenu == NULL); - _ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); - assert(_ButtonSoundMenu == NULL); - _ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); + assert(_buttonExit == NULL); + _buttonExit = new RMOptionButton(20005, RMPoint(560, 405)); + assert(_buttonQuit == NULL); + _buttonQuit = new RMOptionButton(20020, RMPoint(7, 408)); + assert(_buttonLoad == NULL); + _buttonLoad = new RMOptionButton(20006, RMPoint(231, 401)); + assert(_buttonSave == NULL); + _buttonSave = new RMOptionButton(20007, RMPoint(325, 401)); + + assert(_buttonGameMenu == NULL); + _buttonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); + assert(_buttonGfxMenu == NULL); + _buttonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); + assert(_buttonSoundMenu == NULL); + _buttonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); _ctx->raw = new RMResRaw(20021); assert(_ctx->raw->isValid()); - assert(_QuitConfirm == NULL); - _QuitConfirm = new RMGfxSourceBuffer16(false); - _QuitConfirm->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); + assert(_quitConfirm == NULL); + _quitConfirm = new RMGfxSourceBuffer16(false); + _quitConfirm->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; - assert(_ButtonQuitYes == NULL); - _ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); - _ButtonQuitYes->setPriority(30); - assert(_ButtonQuitNo == NULL); - _ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); - _ButtonQuitNo->setPriority(30); + assert(_buttonQuitYes == NULL); + _buttonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); + _buttonQuitYes->setPriority(30); + assert(_buttonQuitNo == NULL); + _buttonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); + _buttonQuitNo->setPriority(30); if (_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); assert(_ctx->raw->isValid()); - assert(_HideLoadSave == NULL); - _HideLoadSave = new RMGfxSourceBuffer16(false); - _HideLoadSave->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); + assert(_hideLoadSave == NULL); + _hideLoadSave = new RMGfxSourceBuffer16(false); + _hideLoadSave->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; } // Menu GAME if (_nState == MENUGAME) { - assert(_ButtonGame_Lock == NULL); - _ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); - _ButtonGame_Lock->setActiveState(GLOBALS._bCfgInvLocked); - assert(_ButtonGame_TimerizedText == NULL); - _ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); - _ButtonGame_TimerizedText->setActiveState(!GLOBALS._bCfgTimerizedText); - assert(_ButtonGame_Scrolling == NULL); - _ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - _ButtonGame_Scrolling->setActiveState(GLOBALS._bCfgInvNoScroll); - assert(_ButtonGame_InterUp == NULL); - _ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); - _ButtonGame_InterUp->setActiveState(GLOBALS._bCfgInvUp); - - assert(_SlideTextSpeed == NULL); - _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgTextSpeed); - assert(_SlideTonySpeed == NULL); - _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS._nCfgTonySpeed); + assert(_buttonGame_Lock == NULL); + _buttonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); + _buttonGame_Lock->setActiveState(GLOBALS._bCfgInvLocked); + assert(_buttonGame_TimerizedText == NULL); + _buttonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); + _buttonGame_TimerizedText->setActiveState(!GLOBALS._bCfgTimerizedText); + assert(_buttonGame_Scrolling == NULL); + _buttonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); + _buttonGame_Scrolling->setActiveState(GLOBALS._bCfgInvNoScroll); + assert(_buttonGame_InterUp == NULL); + _buttonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); + _buttonGame_InterUp->setActiveState(GLOBALS._bCfgInvUp); + + assert(_slideTextSpeed == NULL); + _slideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgTextSpeed); + assert(_slideTonySpeed == NULL); + _slideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS._nCfgTonySpeed); } // Menu Graphics else if (_nState == MENUGFX) { - assert(_ButtonGfx_Anni30 == NULL); - _ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); - _ButtonGfx_Anni30->setActiveState(GLOBALS._bCfgAnni30); - assert(_ButtonGfx_AntiAlias == NULL); - _ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - _ButtonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); - assert(_ButtonGfx_Sottotitoli == NULL); - _ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); - assert(_ButtonGfx_Tips == NULL); - _ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); - _ButtonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); - assert(_ButtonGfx_Trans == NULL); - _ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); - _ButtonGfx_Trans->setActiveState(!GLOBALS._bCfgTransparence); + assert(_buttonGfx_Anni30 == NULL); + _buttonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); + _buttonGfx_Anni30->setActiveState(GLOBALS._bCfgAnni30); + assert(_buttonGfx_AntiAlias == NULL); + _buttonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); + _buttonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); + assert(_buttonGfx_Sottotitoli == NULL); + _buttonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); + _buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); + assert(_buttonGfx_Tips == NULL); + _buttonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); + _buttonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); + assert(_buttonGfx_Trans == NULL); + _buttonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); + _buttonGfx_Trans->setActiveState(!GLOBALS._bCfgTransparence); } else if (_nState == MENUSOUND) { - assert(_SliderSound_Dubbing == NULL); - _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgDubbingVolume); - assert(_SliderSound_Music == NULL); - _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS._nCfgMusicVolume); - assert(_SliderSound_SFX == NULL); - _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS._nCfgSFXVolume); - - assert(_ButtonSound_DubbingOn == NULL); - _ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - _ButtonSound_DubbingOn->setActiveState(GLOBALS._bCfgDubbing); - assert(_ButtonSound_MusicOn == NULL); - _ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); - _ButtonSound_MusicOn->setActiveState(GLOBALS._bCfgMusic); - assert(_ButtonSound_SFXOn == NULL); - _ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); - _ButtonSound_SFXOn->setActiveState(GLOBALS._bCfgSFX); + assert(_sliderSound_Dubbing == NULL); + _sliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgDubbingVolume); + assert(_sliderSound_Music == NULL); + _sliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS._nCfgMusicVolume); + assert(_sliderSound_SFX == NULL); + _sliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS._nCfgSFXVolume); + + assert(_buttonSound_DubbingOn == NULL); + _buttonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); + _buttonSound_DubbingOn->setActiveState(GLOBALS._bCfgDubbing); + assert(_buttonSound_MusicOn == NULL); + _buttonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); + _buttonSound_MusicOn->setActiveState(GLOBALS._bCfgMusic); + assert(_buttonSound_SFXOn == NULL); + _buttonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); + _buttonSound_SFXOn->setActiveState(GLOBALS._bCfgSFX); } } @@ -736,8 +736,8 @@ void RMOptionScreen::closeState(void) { delete _menu; _menu = NULL; - delete _ButtonExit; - _ButtonExit = NULL; + delete _buttonExit; + _buttonExit = NULL; if (_nState == MENULOAD || _nState == MENUSAVE) { int i; @@ -748,114 +748,114 @@ void RMOptionScreen::closeState(void) { _curThumb[i] = NULL; } - delete _ButtonSave_States[i]; - _ButtonSave_States[i] = NULL; + delete _buttonSave_States[i]; + _buttonSave_States[i] = NULL; } - delete _ButtonSave_ArrowLeft; - _ButtonSave_ArrowLeft = NULL; - delete _ButtonSave_ArrowRight; - _ButtonSave_ArrowRight = NULL; + delete _buttonSave_ArrowLeft; + _buttonSave_ArrowLeft = NULL; + delete _buttonSave_ArrowRight; + _buttonSave_ArrowRight = NULL; - delete _SaveEasy; - _SaveEasy = NULL; - delete _SaveHard; - _SaveHard = NULL; + delete _saveEasy; + _saveEasy = NULL; + delete _saveHard; + _saveHard = NULL; } if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { - delete _ButtonQuit; - _ButtonQuit = NULL; - delete _ButtonLoad; - _ButtonLoad = NULL; - delete _ButtonSave; - _ButtonSave = NULL; - delete _ButtonGameMenu; - _ButtonGameMenu = NULL; - delete _ButtonGfxMenu; - _ButtonGfxMenu = NULL; - delete _ButtonSoundMenu; - _ButtonSoundMenu = NULL; - delete _QuitConfirm; - _QuitConfirm = NULL; - delete _ButtonQuitYes; - _ButtonQuitYes = NULL; - delete _ButtonQuitNo; - _ButtonQuitNo = NULL; + delete _buttonQuit; + _buttonQuit = NULL; + delete _buttonLoad; + _buttonLoad = NULL; + delete _buttonSave; + _buttonSave = NULL; + delete _buttonGameMenu; + _buttonGameMenu = NULL; + delete _buttonGfxMenu; + _buttonGfxMenu = NULL; + delete _buttonSoundMenu; + _buttonSoundMenu = NULL; + delete _quitConfirm; + _quitConfirm = NULL; + delete _buttonQuitYes; + _buttonQuitYes = NULL; + delete _buttonQuitNo; + _buttonQuitNo = NULL; if (_bNoLoadSave) { - delete _HideLoadSave; - _HideLoadSave = NULL; + delete _hideLoadSave; + _hideLoadSave = NULL; } if (_nState == MENUGAME) { - GLOBALS._bCfgInvLocked = _ButtonGame_Lock->isActive(); - delete _ButtonGame_Lock; - _ButtonGame_Lock = NULL; + GLOBALS._bCfgInvLocked = _buttonGame_Lock->isActive(); + delete _buttonGame_Lock; + _buttonGame_Lock = NULL; - GLOBALS._bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); - delete _ButtonGame_TimerizedText; - _ButtonGame_TimerizedText = NULL; + GLOBALS._bCfgTimerizedText = !_buttonGame_TimerizedText->isActive(); + delete _buttonGame_TimerizedText; + _buttonGame_TimerizedText = NULL; - GLOBALS._bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); - delete _ButtonGame_Scrolling; - _ButtonGame_Scrolling = NULL; + GLOBALS._bCfgInvNoScroll = _buttonGame_Scrolling->isActive(); + delete _buttonGame_Scrolling; + _buttonGame_Scrolling = NULL; - GLOBALS._bCfgInvUp = _ButtonGame_InterUp->isActive(); - delete _ButtonGame_InterUp; - _ButtonGame_InterUp = NULL; + GLOBALS._bCfgInvUp = _buttonGame_InterUp->isActive(); + delete _buttonGame_InterUp; + _buttonGame_InterUp = NULL; - GLOBALS._nCfgTextSpeed = _SlideTextSpeed->getValue(); - delete _SlideTextSpeed; - _SlideTextSpeed = NULL; + GLOBALS._nCfgTextSpeed = _slideTextSpeed->getValue(); + delete _slideTextSpeed; + _slideTextSpeed = NULL; - GLOBALS._nCfgTonySpeed = _SlideTonySpeed->getValue(); - delete _SlideTonySpeed; - _SlideTonySpeed = NULL; + GLOBALS._nCfgTonySpeed = _slideTonySpeed->getValue(); + delete _slideTonySpeed; + _slideTonySpeed = NULL; } else if (_nState == MENUGFX) { - GLOBALS._bCfgAnni30 = _ButtonGfx_Anni30->isActive(); - delete _ButtonGfx_Anni30; - _ButtonGfx_Anni30 = NULL; + GLOBALS._bCfgAnni30 = _buttonGfx_Anni30->isActive(); + delete _buttonGfx_Anni30; + _buttonGfx_Anni30 = NULL; - GLOBALS._bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); - delete _ButtonGfx_AntiAlias; - _ButtonGfx_AntiAlias = NULL; + GLOBALS._bCfgAntiAlias = !_buttonGfx_AntiAlias->isActive(); + delete _buttonGfx_AntiAlias; + _buttonGfx_AntiAlias = NULL; - GLOBALS._bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); - delete _ButtonGfx_Sottotitoli; - _ButtonGfx_Sottotitoli = NULL; + GLOBALS._bCfgSottotitoli = !_buttonGfx_Sottotitoli->isActive(); + delete _buttonGfx_Sottotitoli; + _buttonGfx_Sottotitoli = NULL; - GLOBALS._bCfgInterTips = _ButtonGfx_Tips->isActive(); - delete _ButtonGfx_Tips; - _ButtonGfx_Tips = NULL; + GLOBALS._bCfgInterTips = _buttonGfx_Tips->isActive(); + delete _buttonGfx_Tips; + _buttonGfx_Tips = NULL; - GLOBALS._bCfgTransparence = !_ButtonGfx_Trans->isActive(); - delete _ButtonGfx_Trans; - _ButtonGfx_Trans = NULL; + GLOBALS._bCfgTransparence = !_buttonGfx_Trans->isActive(); + delete _buttonGfx_Trans; + _buttonGfx_Trans = NULL; } else if (_nState == MENUSOUND) { - GLOBALS._nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); - delete _SliderSound_Dubbing; - _SliderSound_Dubbing = NULL; + GLOBALS._nCfgDubbingVolume = _sliderSound_Dubbing->getValue(); + delete _sliderSound_Dubbing; + _sliderSound_Dubbing = NULL; - GLOBALS._nCfgMusicVolume = _SliderSound_Music->getValue(); - delete _SliderSound_Music; - _SliderSound_Music = NULL; + GLOBALS._nCfgMusicVolume = _sliderSound_Music->getValue(); + delete _sliderSound_Music; + _sliderSound_Music = NULL; - GLOBALS._nCfgSFXVolume = _SliderSound_SFX->getValue(); - delete _SliderSound_SFX; - _SliderSound_SFX = NULL; + GLOBALS._nCfgSFXVolume = _sliderSound_SFX->getValue(); + delete _sliderSound_SFX; + _sliderSound_SFX = NULL; - GLOBALS._bCfgDubbing = _ButtonSound_DubbingOn->isActive(); - delete _ButtonSound_DubbingOn; - _ButtonSound_DubbingOn = NULL; + GLOBALS._bCfgDubbing = _buttonSound_DubbingOn->isActive(); + delete _buttonSound_DubbingOn; + _buttonSound_DubbingOn = NULL; - GLOBALS._bCfgMusic = _ButtonSound_MusicOn->isActive(); - delete _ButtonSound_MusicOn; - _ButtonSound_MusicOn = NULL; + GLOBALS._bCfgMusic = _buttonSound_MusicOn->isActive(); + delete _buttonSound_MusicOn; + _buttonSound_MusicOn = NULL; - GLOBALS._bCfgSFX = _ButtonSound_SFXOn->isActive(); - delete _ButtonSound_SFXOn; - _ButtonSound_SFXOn = NULL; + GLOBALS._bCfgSFX = _buttonSound_SFXOn->isActive(); + delete _buttonSound_SFXOn; + _buttonSound_SFXOn = NULL; } } @@ -872,14 +872,14 @@ void RMOptionScreen::init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = false; _bNoLoadSave = false; @@ -903,14 +903,14 @@ void RMOptionScreen::initLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = true; _bNoLoadSave = false; @@ -932,14 +932,14 @@ void RMOptionScreen::initSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = true; _bNoLoadSave = false; @@ -961,14 +961,14 @@ void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = false; _bNoLoadSave = true; @@ -984,12 +984,12 @@ void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool } bool RMOptionScreen::close(void) { - if (_FadeStep != 6) + if (_fadeStep != 6) return false; // Start fade out - _FadeStep++; - _FadeTime = _vm->getTime(); + _fadeStep++; + _fadeTime = _vm->getTime(); return true; } @@ -1028,7 +1028,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // If it is fully open, do nothing - if (_FadeStep != 6) + if (_fadeStep != 6) return; // Reads input @@ -1039,78 +1039,78 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh = false; if (_bQuitConfirm) { - _ctx->bRefresh |= _ButtonQuitYes->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonQuitNo->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonQuitYes->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonQuitNo->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else { - _ctx->bRefresh |= _ButtonExit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonExit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Check if you have clicked on the output if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { // Buttons without graphics... - _ButtonGameMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ButtonGfxMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ButtonSoundMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonGameMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonGfxMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonSoundMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Buttons with graphics if (!_bNoLoadSave) { if (!_vm->getIsDemo()) { - _ctx->bRefresh |= _ButtonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } - _ctx->bRefresh |= _ButtonQuit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonQuit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } if (_nState == MENUGAME) { - _ctx->bRefresh |= _ButtonGame_Lock->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGame_TimerizedText->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGame_Scrolling->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGame_InterUp->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SlideTextSpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SlideTonySpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_Lock->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_TimerizedText->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_Scrolling->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_InterUp->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _slideTextSpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _slideTonySpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else if (_nState == MENUGFX) { - _ctx->bRefresh |= _ButtonGfx_Anni30->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_AntiAlias->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_Sottotitoli->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_Tips->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_Trans->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Anni30->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_AntiAlias->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Sottotitoli->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Tips->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Trans->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else if (_nState == MENUSOUND) { - _ctx->bRefresh |= _SliderSound_Dubbing->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SliderSound_Music->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SliderSound_SFX->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSound_DubbingOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSound_MusicOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSound_SFXOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _sliderSound_Dubbing->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _sliderSound_Music->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _sliderSound_SFX->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSound_DubbingOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSound_MusicOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSound_SFXOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else if (_nState == MENULOAD || _nState == MENUSAVE) { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - _ButtonSave_States[_ctx->i]->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonSave_States[_ctx->i]->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (_statePos > 0) - _ctx->bRefresh |= _ButtonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (_statePos < 90) - _ctx->bRefresh |= _ButtonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } #define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - _EditName[strlen(_EditName) + 1] = '\0'; _EditName[strlen(_EditName)] = c; _ctx->bRefresh = true; } + _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } /**************** State Buttons **************/ if (_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { - if (_EditName[0] != '\0') { - _EditName[strlen(_EditName) - 1] = '\0'; + if (_editName[0] != '\0') { + _editName[strlen(_editName) - 1] = '\0'; _ctx->bRefresh = true; } } - for (_ctx->i = 0; _ctx->i < 26 && strlen(_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) if (KEYPRESS(Common::KEYCODE_LSHIFT) || KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); @@ -1118,31 +1118,31 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } - for (_ctx->i = 0; _ctx->i < 10 && strlen(_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 10 && strlen(_editName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_SPACE, ' '); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); // Cancel @@ -1154,13 +1154,13 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { _bEditSaveName = false; - _vm->saveState(_statePos + _nEditPos, _EditName); + _vm->saveState(_statePos + _nEditPos, _editName); close(); } } else if (_ctx->bLeftClick) { if (_nState == MENULOAD || _nState == MENUSAVE) { - if (_ButtonExit->isActive()) { + if (_buttonExit->isActive()) { if (_bLoadMenuOnly) { // If only the loading menu, close close(); @@ -1168,27 +1168,27 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { CORO_INVOKE_1(changeState, _nLastState); _ctx->bRefresh = true; } - } else if (_ButtonSave_ArrowLeft->isActive()) { + } else if (_buttonSave_ArrowLeft->isActive()) { if (_statePos > 0) { _statePos -= 6; if (_statePos < 0) _statePos = 0; - _ButtonSave_ArrowLeft->setActiveState(false); + _buttonSave_ArrowLeft->setActiveState(false); _ctx->bRefresh = true; refreshThumbnails(); } - } else if (_ButtonSave_ArrowRight->isActive()) { + } else if (_buttonSave_ArrowRight->isActive()) { if (_statePos < 90) { _statePos += 6; if (_statePos > 90) _statePos = 90; - _ButtonSave_ArrowRight->setActiveState(false); + _buttonSave_ArrowRight->setActiveState(false); _ctx->bRefresh = true; refreshThumbnails(); } } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (_ButtonSave_States[_ctx->i]->isActive()) { + if (_buttonSave_States[_ctx->i]->isActive()) { // There by saving or loading!!! if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { // Caricamento @@ -1198,7 +1198,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // Turn on edit mode _bEditSaveName = true; _nEditPos = _ctx->i; - strcpy(_EditName, _curThumbName[_ctx->i]); + strcpy(_editName, _curThumbName[_ctx->i]); _ctx->bRefresh = true; } @@ -1209,53 +1209,53 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { if (_bQuitConfirm) { - if (_ButtonQuitNo->isActive()) { + if (_buttonQuitNo->isActive()) { _bQuitConfirm = false; _ctx->bRefresh = true; - } else if (_ButtonQuitYes->isActive()) { + } else if (_buttonQuitYes->isActive()) { _bQuitConfirm = false; _ctx->bRefresh = true; _vm->quitGame(); } } else { - if (_ButtonQuit->isActive()) { + if (_buttonQuit->isActive()) { _bQuitConfirm = true; - _ButtonQuitNo->setActiveState(false); - _ButtonQuitYes->setActiveState(false); + _buttonQuitNo->setActiveState(false); + _buttonQuitYes->setActiveState(false); _ctx->bRefresh = true; - } else if (_ButtonExit->isActive()) + } else if (_buttonExit->isActive()) close(); - else if (_ButtonLoad->isActive()) { + else if (_buttonLoad->isActive()) { CORO_INVOKE_1(changeState, MENULOAD); _ctx->bRefresh = true; - } else if (_ButtonSave->isActive()) { + } else if (_buttonSave->isActive()) { CORO_INVOKE_1(changeState, MENUSAVE); _ctx->bRefresh = true; - } else if (_ButtonGameMenu->isActive() && _nState != MENUGAME) { + } else if (_buttonGameMenu->isActive() && _nState != MENUGAME) { CORO_INVOKE_1(changeState, MENUGAME); _ctx->bRefresh = true; - } else if (_ButtonGfxMenu->isActive() && _nState != MENUGFX) { + } else if (_buttonGfxMenu->isActive() && _nState != MENUGFX) { CORO_INVOKE_1(changeState, MENUGFX); _ctx->bRefresh = true; - } else if (_ButtonSoundMenu->isActive() && _nState != MENUSOUND) { + } else if (_buttonSoundMenu->isActive() && _nState != MENUSOUND) { CORO_INVOKE_1(changeState, MENUSOUND); _ctx->bRefresh = true; } if (_nState == MENUGFX) { // These options take effect immediately - if (_ButtonGfx_Anni30->isActive()) + if (_buttonGfx_Anni30->isActive()) GLOBALS._bCfgAnni30 = true; else GLOBALS._bCfgAnni30 = false; - if (_ButtonGfx_AntiAlias->isActive()) + if (_buttonGfx_AntiAlias->isActive()) GLOBALS._bCfgAntiAlias = false; else GLOBALS._bCfgAntiAlias = true; - if (_ButtonGfx_Trans->isActive()) + if (_buttonGfx_Trans->isActive()) GLOBALS._bCfgTransparence = false; else GLOBALS._bCfgTransparence = true; @@ -1285,94 +1285,94 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _ctx->curTime = _vm->getTime(); #define FADE_SPEED 20 -#define SYNC (_ctx->curTime - _FadeTime) / 25 +#define SYNC (_ctx->curTime - _fadeTime) / 25 if (_bExit) return; - if (_FadeStep == 1) { + if (_fadeStep == 1) { // Downhill fast - if (_FadeTime == -1) - _FadeY += FADE_SPEED; + if (_fadeTime == -1) + _fadeY += FADE_SPEED; else - _FadeY += FADE_SPEED * SYNC; - if (_FadeY > 480) { - _FadeY = 480; - _FadeStep++; + _fadeY += FADE_SPEED * SYNC; + if (_fadeY > 480) { + _fadeY = 480; + _fadeStep++; } // Set the part to draw the scrolling - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 2) { + } else if (_fadeStep == 2) { // Bounce 1 - _FadeY -= FADE_SPEED / 2 * SYNC; - if (_FadeY < 400) { - _FadeY = 400; - _FadeStep++; + _fadeY -= FADE_SPEED / 2 * SYNC; + if (_fadeY < 400) { + _fadeY = 400; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 3) { - _FadeY -= FADE_SPEED / 4 * SYNC; - if (_FadeY < 380) { - _FadeY = 380; - _FadeStep++; + } else if (_fadeStep == 3) { + _fadeY -= FADE_SPEED / 4 * SYNC; + if (_fadeY < 380) { + _fadeY = 380; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 4) { + } else if (_fadeStep == 4) { // Bounce 1 - 2 - _FadeY += FADE_SPEED / 3 * SYNC; - if (_FadeY > 420) { - _FadeY = 420; - _FadeStep++; + _fadeY += FADE_SPEED / 3 * SYNC; + if (_fadeY > 420) { + _fadeY = 420; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 5) { - _FadeY += FADE_SPEED / 2 * SYNC; - if (_FadeY > 480) { - _FadeY = 480; - _FadeStep++; + } else if (_fadeStep == 5) { + _fadeY += FADE_SPEED / 2 * SYNC; + if (_fadeY > 480) { + _fadeY = 480; + _fadeStep++; _vm->hideLocation(); } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 6) { + } else if (_fadeStep == 6) { // Menu ON - } else if (_FadeStep == 7) { + } else if (_fadeStep == 7) { // Menu OFF _vm->showLocation(); - _FadeStep++; + _fadeStep++; - } else if (_FadeStep == 8) { - _FadeY -= FADE_SPEED * SYNC; - if (_FadeY < 0) { - _FadeY = 0; - _FadeStep++; + } else if (_fadeStep == 8) { + _fadeY -= FADE_SPEED * SYNC; + if (_fadeY < 0) { + _fadeY = 0; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 9) { + } else if (_fadeStep == 9) { // Hello hello! _bExit = true; - _FadeStep = 0; + _fadeStep = 0; // Free memory closeState(); return; } else { - _FadeStep = 0; + _fadeStep = 0; } - _FadeTime = _ctx->curTime; + _fadeTime = _ctx->curTime; CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); diff --git a/engines/tony/game.h b/engines/tony/game.h index 2d8f73f79b..db182dfa23 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -156,12 +156,12 @@ public: class RMOptionSlide : public RMGfxTaskSetPrior { private: - RMOptionButton *_PushLeft; - RMOptionButton *_PushRight; - RMGfxSourceBuffer16 *_SliderCenter; - RMGfxSourceBuffer16 *_SliderLeft; - RMGfxSourceBuffer16 *_SliderRight; - RMGfxSourceBuffer16 *_SliderSingle; + RMOptionButton *_pushLeft; + RMOptionButton *_pushRight; + RMGfxSourceBuffer16 *_sliderCenter; + RMGfxSourceBuffer16 *_sliderLeft; + RMGfxSourceBuffer16 *_sliderRight; + RMGfxSourceBuffer16 *_sliderSingle; int _nSlideSize; RMPoint _pos; int _nValue; @@ -184,65 +184,65 @@ public: class RMOptionScreen : public RMGfxWoodyBuffer { private: RMGfxSourceBuffer16 *_menu; - RMGfxSourceBuffer16 *_QuitConfirm; - RMGfxSourceBuffer16 *_HideLoadSave; - RMOptionButton *_ButtonQuitYes; - RMOptionButton *_ButtonQuitNo; - RMOptionButton *_ButtonExit; - RMOptionButton *_ButtonQuit; - RMOptionButton *_ButtonLoad; - RMOptionButton *_ButtonSave; - RMOptionButton *_ButtonGameMenu; - RMOptionButton *_ButtonGfxMenu; - RMOptionButton *_ButtonSoundMenu; - RMGfxSourceBuffer8 *_SaveEasy; - RMGfxSourceBuffer8 *_SaveHard; + RMGfxSourceBuffer16 *_quitConfirm; + RMGfxSourceBuffer16 *_hideLoadSave; + RMOptionButton *_buttonQuitYes; + RMOptionButton *_buttonQuitNo; + RMOptionButton *_buttonExit; + RMOptionButton *_buttonQuit; + RMOptionButton *_buttonLoad; + RMOptionButton *_buttonSave; + RMOptionButton *_buttonGameMenu; + RMOptionButton *_buttonGfxMenu; + RMOptionButton *_buttonSoundMenu; + RMGfxSourceBuffer8 *_saveEasy; + RMGfxSourceBuffer8 *_saveHard; RMGfxSourceBuffer16 *_curThumb[6]; RMString _curThumbName[6]; byte _curThumbDiff[6]; - RMOptionButton *_ButtonSave_States[6]; - RMOptionButton *_ButtonSave_ArrowLeft; - RMOptionButton *_ButtonSave_ArrowRight; - RMOptionButton *_ButtonGfx_Tips; + RMOptionButton *_buttonSave_States[6]; + RMOptionButton *_buttonSave_ArrowLeft; + RMOptionButton *_buttonSave_ArrowRight; + RMOptionButton *_buttonGfx_Tips; - RMOptionButton *_ButtonSound_DubbingOn; - RMOptionButton *_ButtonSound_MusicOn; - RMOptionButton *_ButtonSound_SFXOn; + RMOptionButton *_buttonSound_DubbingOn; + RMOptionButton *_buttonSound_MusicOn; + RMOptionButton *_buttonSound_SFXOn; - RMOptionSlide *_SlideTonySpeed; - RMOptionSlide *_SlideTextSpeed; + RMOptionSlide *_slideTonySpeed; + RMOptionSlide *_slideTextSpeed; int _statePos; bool _bEditSaveName; int _nEditPos; - char _EditName[256]; + char _editName[256]; union { - RMOptionButton *_ButtonGame_Lock; - RMOptionButton *_ButtonGfx_Anni30; - RMOptionSlide *_SliderSound_Music; + RMOptionButton *_buttonGame_Lock; + RMOptionButton *_buttonGfx_Anni30; + RMOptionSlide *_sliderSound_Music; }; union { - RMOptionButton *_ButtonGame_TimerizedText; - RMOptionButton *_ButtonGfx_AntiAlias; - RMOptionSlide *_SliderSound_SFX; + RMOptionButton *_buttonGame_TimerizedText; + RMOptionButton *_buttonGfx_AntiAlias; + RMOptionSlide *_sliderSound_SFX; }; union { - RMOptionButton *_ButtonGame_Scrolling; - RMOptionButton *_ButtonGfx_Sottotitoli; - RMOptionSlide *_SliderSound_Dubbing; + RMOptionButton *_buttonGame_Scrolling; + RMOptionButton *_buttonGfx_Sottotitoli; + RMOptionSlide *_sliderSound_Dubbing; }; union { - RMOptionButton *_ButtonGame_InterUp; - RMOptionButton *_ButtonGfx_Trans; + RMOptionButton *_buttonGame_InterUp; + RMOptionButton *_buttonGfx_Trans; }; - int _FadeStep; + int _fadeStep; bool _bExit; bool _bQuitConfirm; - int _FadeY; - int _FadeTime; + int _fadeY; + int _fadeTime; bool _bLoadMenuOnly; bool _bNoLoadSave; bool _bAlterGfx; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 9d3795c760..8be4cbd5f5 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -272,9 +272,9 @@ void RMGfxTargetBuffer::clearOT(void) { cur = _otlist; while (cur != NULL) { - cur->prim->_task->Unregister(); - delete cur->prim; - n = cur->next; + cur->_prim->_task->Unregister(); + delete cur->_prim; + n = cur->_next; delete cur; cur = n; } @@ -304,19 +304,19 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { while (_ctx->cur != NULL) { // Call the task Draw method, passing it a copy of the original - _ctx->myprim = _ctx->cur->prim->duplicate(); - CORO_INVOKE_2(_ctx->cur->prim->_task->draw, *this, _ctx->myprim); + _ctx->myprim = _ctx->cur->_prim->duplicate(); + CORO_INVOKE_2(_ctx->cur->_prim->_task->draw, *this, _ctx->myprim); delete _ctx->myprim; // Check if it's time to remove the task from the OT list - CORO_INVOKE_1(_ctx->cur->prim->_task->removeThis, _ctx->result); + CORO_INVOKE_1(_ctx->cur->_prim->_task->removeThis, _ctx->result); if (_ctx->result) { // De-register the task - _ctx->cur->prim->_task->Unregister(); + _ctx->cur->_prim->_task->Unregister(); // Delete task, freeing the memory - delete _ctx->cur->prim; - _ctx->next = _ctx->cur->next; + delete _ctx->cur->_prim; + _ctx->next = _ctx->cur->_next; delete _ctx->cur; // If it was the first item, update the list head @@ -324,13 +324,13 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { _otlist = _ctx->next; // Otherwise update the next pinter of the previous item else - _ctx->prev->next = _ctx->next; + _ctx->prev->_next = _ctx->next; _ctx->cur = _ctx->next; } else { // Update the pointer to the previous item, and the current to the next _ctx->prev = _ctx->cur; - _ctx->cur = _ctx->cur->next; + _ctx->cur = _ctx->cur->_next; } } @@ -358,19 +358,19 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { // Empty list if (_otlist == NULL) { _otlist = n; - _otlist->next = NULL; + _otlist->_next = NULL; } // Inclusion in the head - else if (nPrior < _otlist->prim->_task->priority()) { - n->next = _otlist; + else if (nPrior < _otlist->_prim->_task->priority()) { + n->_next = _otlist; _otlist = n; } else { cur = _otlist; - while (cur->next != NULL && nPrior > cur->next->prim->_task->priority()) - cur = cur->next; + while (cur->_next != NULL && nPrior > cur->_next->_prim->_task->priority()) + cur = cur->_next; - n->next = cur->next; - cur->next = n; + n->_next = cur->_next; + cur->_next = n; } // g_system->unlockMutex(csModifyingOT); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index a1bf537e3b..17ad303fbd 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -544,12 +544,12 @@ private: static RMGfxClearTask taskClear; struct OTList { - RMGfxPrimitive *prim; - OTList *next; + RMGfxPrimitive *_prim; + OTList *_next; OTList(); OTList(RMGfxPrimitive *pr) { - prim = pr; + _prim = pr; } }; -- cgit v1.2.3 From 5de8b7aa74ad01daea0d41eebd24ad6f63edccd4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 21:43:04 +0200 Subject: TONY: Rename variables in tonychar.h --- engines/tony/tonychar.cpp | 154 +++++++++++++++++++++++----------------------- engines/tony/tonychar.h | 12 ++-- 2 files changed, 83 insertions(+), 83 deletions(-) (limited to 'engines') diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 6852369c64..5d2c4d37bc 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -49,17 +49,17 @@ RMTony::RMTony() { _bShowOmbra = false; _bCorpoDavanti = false; _bActionPending = false; - _ActionItem = NULL; - _Action = 0; - _ActionParm = 0; + _actionItem = NULL; + _action = 0; + _actionParm = 0; _bPastorella = false; _bIsStaticTalk = false; _bIsTalking = false; _nPatB4Talking = 0; _nTalkType = TALK_NORMAL; - _TalkDirection = UP; + _talkDirection = UP; _nTimeLastStep = 0; - hActionThread = CORO_INVALID_PID_VALUE; + _hActionThread = CORO_INVALID_PID_VALUE; } void RMTony::waitEndOfAction(CORO_PARAM, const void *param) { @@ -219,18 +219,18 @@ void RMTony::moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, // Makes normal movement, but remember if you must then perform an action if (item == NULL) { _bActionPending = false; - _ActionItem = NULL; + _actionItem = NULL; } else { - _ActionItem = item; - _Action = nAction; - _ActionParm = nActionParm; + _actionItem = item; + _action = nAction; + _actionParm = nActionParm; _bActionPending = true; } CORO_INVOKE_2(RMCharacter::move, dst, &_ctx->result); if (!_ctx->result) { _bActionPending = false; - _ActionItem = NULL; + _actionItem = NULL; } CORO_END_CODE; @@ -265,23 +265,23 @@ void RMTony::executeAction(int nAction, int nActionItem, int nParm) { if (pid != CORO_INVALID_PID_VALUE) { _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { pid = mpalQueryDoAction(6, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } else { pid = mpalQueryDoAction(5, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } } } @@ -294,10 +294,10 @@ void RMTony::stopNoAction(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (_bAction) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hActionThread, CORO_INFINITE); _bActionPending = false; - _ActionItem = NULL; + _actionItem = NULL; CORO_INVOKE_0(stop); CORO_END_CODE; @@ -310,9 +310,9 @@ void RMTony::stop(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - if (_ActionItem != NULL) { + if (_actionItem != NULL) { // Call MPAL to choose the direction - _ctx->pid = mpalQueryDoAction(21, _ActionItem->mpalCode(), 0); + _ctx->pid = mpalQueryDoAction(21, _actionItem->mpalCode(), 0); if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::stop); @@ -330,9 +330,9 @@ void RMTony::stop(CORO_PARAM) { _bActionPending = false; - executeAction(_Action, _ActionItem->mpalCode(), _ActionParm); + executeAction(_action, _actionItem->mpalCode(), _actionParm); - _ActionItem = NULL; + _actionItem = NULL; CORO_END_CODE; } @@ -562,7 +562,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (!_bIsStaticTalk) { switch (_nPatB4Talking) { case PAT_STANDDOWN: - _TalkDirection = DOWN; + _talkDirection = DOWN; break; case PAT_TAKELEFT_UP2: @@ -570,7 +570,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - _TalkDirection = LEFT; + _talkDirection = LEFT; break; case PAT_TAKERIGHT_UP2: @@ -578,14 +578,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - _TalkDirection = RIGHT; + _talkDirection = RIGHT; break; case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - _TalkDirection = UP; + _talkDirection = UP; break; } @@ -596,7 +596,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (_bPastorella) { // Talking whilst a shepherdess mainFreeze(); - switch (_TalkDirection) { + switch (_talkDirection) { case UP: setPattern(PAT_PAST_TALKUP); break; @@ -626,7 +626,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body headStartPat = 0; bodyStartPat = 0; - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_STANDDOWN; @@ -655,7 +655,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_FIANCHI: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: _nBodyOffset.set(2, 42); headStartPat = PAT_TESTA_UP; @@ -701,7 +701,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_RIDE: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case DOWN: case LEFT: @@ -724,7 +724,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_RIDE2: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case DOWN: case LEFT: @@ -746,7 +746,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SIINDICA: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case DOWN: case LEFT: @@ -764,7 +764,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SPAVENTATO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: _nBodyOffset.set(-4, -11); headStartPat = PAT_TESTA_UP; @@ -801,7 +801,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SPAVENTATO2: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; @@ -867,7 +867,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONCONIGLIO: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-21, -5); @@ -887,7 +887,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONRICETTA: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-61, -7); @@ -907,7 +907,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONCARTE: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-34, -2); @@ -927,7 +927,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONPUPAZZO: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-35, 2); @@ -952,7 +952,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CONCARTESTATIC: case TALK_WITH_NOTEBOOK: case TALK_CONMEGAFONOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: headLoopPat = PAT_TALK_LEFT; @@ -967,7 +967,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: headLoopPat = PAT_TALKBARBA_LEFT; @@ -985,7 +985,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SCHIFATO: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); @@ -1005,7 +1005,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_NAAH: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); @@ -1072,7 +1072,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SPAVENTATOSTATIC: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; @@ -1151,7 +1151,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; headEndPat = 0; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: finalPat = PAT_STANDUP; headStandPat = PAT_TESTA_UP; @@ -1189,7 +1189,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_FIANCHI: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyEndPat = BPAT_FIANCHIUP_END; break; @@ -1214,16 +1214,16 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_RIDE: case TALK_RIDE2: - if (_TalkDirection == LEFT) + if (_talkDirection == LEFT) headEndPat = PAT_RIDELEFT_END; - else if (_TalkDirection == RIGHT) + else if (_talkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1239,7 +1239,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_NAAH: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1258,7 +1258,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1281,7 +1281,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyEndPat = 0; break; @@ -1304,7 +1304,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1320,7 +1320,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1336,7 +1336,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1352,7 +1352,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1395,7 +1395,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1448,10 +1448,10 @@ void RMTony::endTalk(CORO_PARAM) { if (_nTalkType == TALK_CONBARBASTATIC) { mainFreeze(); setPattern(0); - if (_TalkDirection == UP || _TalkDirection == LEFT) { + if (_talkDirection == UP || _talkDirection == LEFT) { _body.setPattern(BPAT_CONBARBALEFT_STATIC); _nBodyOffset.set(-41, -14); - } else if (_TalkDirection == DOWN || _TalkDirection == RIGHT) { + } else if (_talkDirection == DOWN || _talkDirection == RIGHT) { _body.setPattern(BPAT_CONBARBARIGHT_STATIC); _nBodyOffset.set(-26, -14); } @@ -1526,7 +1526,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nPat) { case PAT_STANDDOWN: - _TalkDirection = DOWN; + _talkDirection = DOWN; headPat = PAT_TESTA_RIGHT; break; @@ -1535,7 +1535,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - _TalkDirection = LEFT; + _talkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; @@ -1544,7 +1544,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - _TalkDirection = RIGHT; + _talkDirection = RIGHT; headPat = PAT_TESTA_RIGHT; break; @@ -1552,7 +1552,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - _TalkDirection = UP; + _talkDirection = UP; headPat = PAT_TESTA_LEFT; break; } @@ -1561,7 +1561,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nTalk) { case TALK_CONCONIGLIOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-21, -5); @@ -1579,7 +1579,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONCARTESTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-34, -2); @@ -1597,7 +1597,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONRICETTASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-61, -7); @@ -1615,7 +1615,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONPUPAZZOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-35, 2); @@ -1633,7 +1633,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_WITH_NOTEBOOK: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-16, -9); @@ -1651,7 +1651,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONMEGAFONOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -8); @@ -1669,7 +1669,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONBARBASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -14); @@ -1691,7 +1691,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_SPAVENTATOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: headPat = PAT_SPAVENTODOWN_START; bodyLoopPat = BPAT_STANDDOWN; @@ -1761,7 +1761,7 @@ void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1775,7 +1775,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; @@ -1789,7 +1789,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONRICETTASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONRICETTALEFT_END; @@ -1803,7 +1803,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCONIGLIOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCONIGLIOLEFT_END; @@ -1817,7 +1817,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCARTESTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCARTELEFT_END; @@ -1831,7 +1831,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_WITH_NOTEBOOK: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONTACCUINOLEFT_END; @@ -1845,7 +1845,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONMEGAFONOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONMEGAFONOLEFT_END; @@ -1859,7 +1859,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONBARBASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONBARBALEFT_END; @@ -1873,7 +1873,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_SPAVENTATOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: headEndPat = PAT_SPAVENTOLEFT_END; break; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 4e0a0f0d93..6ba66729a9 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -86,9 +86,9 @@ private: bool _bCorpoDavanti; RMGfxSourceBuffer8AB _ombra; bool _bActionPending; - RMItem *_ActionItem; - int _Action; - int _ActionParm; + RMItem *_actionItem; + int _action; + int _actionParm; static bool _bAction; bool _bPastorella; @@ -97,13 +97,13 @@ private: bool _bIsTalking; int _nPatB4Talking; TALKTYPE _nTalkType; - DIRECTION _TalkDirection; + DIRECTION _talkDirection; RMPoint _nBodyOffset; int _nTimeLastStep; RMItem _body; - uint32 hActionThread; + uint32 _hActionThread; protected: // Overload of the allocation allocation of sprites @@ -397,7 +397,7 @@ public: // Check if currently in an action bool inAction() { - return (_bActionPending && _Action != 0) | _bAction; + return (_bActionPending && _action != 0) | _bAction; } // Check if there needs to be an update for scrolling movement -- cgit v1.2.3 From 34a7c7be984e6d47d83ce71af93402281039405d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 22:22:46 +0200 Subject: TONY: Rename a remaining variable in loc.h --- engines/tony/loc.cpp | 32 ++++++++++++++++---------------- engines/tony/loc.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 9c032fe6be..e70d15695e 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -962,11 +962,11 @@ short RMCharacter::findPath(short source, short destination) { cur = _theBoxes->getBoxes(_curLocation); // Make a backup copy to work on - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) memcpy(&BOX[i], &cur->_boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) VALIDO[i] = 0; // Prepare source and variables for the procedure @@ -980,14 +980,14 @@ short RMCharacter::findPath(short source, short destination) { errore = 1; // Possible error // 1st cycle: explore possible new nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) if (VALIDO[i] == 1) { errore = 0; // Failure de-bunked j = 0; - while (((BOX[i]._adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i]._adj[j]) != 1) && (j < cur->_numbBox)) j++; - if (j >= cur->numbbox) + if (j >= cur->_numbBox) VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; @@ -1000,12 +1000,12 @@ short RMCharacter::findPath(short source, short destination) { fine = 1; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { BOX[i]._adj[NEXT[i]] = 2; COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; - for (j = 0; j < cur->numbbox; j++) + for (j = 0; j < cur->_numbBox; j++) if (BOX[j]._adj[NEXT[i]] == 1) BOX[j]._adj[NEXT[i]] = 0; @@ -1762,13 +1762,13 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { assert(ver == 3); // Number of boxes - ds >> numbbox; + ds >> _numbBox; // Allocate memory for the boxes - _boxes = new RMBox[numbbox]; + _boxes = new RMBox[_numbBox]; // Read in boxes - for (i = 0; i < numbbox; i++) + for (i = 0; i < _numbBox; i++) ds >> _boxes[i]; } @@ -1776,7 +1776,7 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { void RMBoxLoc::recalcAllAdj(void) { int i, j; - for (i = 0; i < numbbox; i++) { + for (i = 0; i < _numbBox; i++) { Common::fill(_boxes[i]._adj, _boxes[i]._adj + MAXBOXES, 0); for (j = 0; j < _boxes[i]._numHotspot; j++) @@ -1850,7 +1850,7 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { if (!cur) return -1; - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) if (cur->_boxes[i]._attivo) if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) @@ -1873,7 +1873,7 @@ int RMGameBoxes::getSaveStateSize(void) { for (i = 1; i <= _nLocBoxes; i++) { size += 4; - size += _allBoxes[i]->numbbox; + size += _allBoxes[i]->_numbBox; } return size; @@ -1888,10 +1888,10 @@ void RMGameBoxes::saveState(byte *state) { // For each location, write out the number of boxes and their status for (i = 1; i <= _nLocBoxes; i++) { - WRITE_LE_UINT32(state, _allBoxes[i]->numbbox); + WRITE_LE_UINT32(state, _allBoxes[i]->_numbBox); state += 4; - for (j = 0; j < _allBoxes[i]->numbbox; j++) + for (j = 0; j < _allBoxes[i]->_numbBox; j++) *state++ = _allBoxes[i]->_boxes[j]._attivo; } } @@ -1912,7 +1912,7 @@ void RMGameBoxes::loadState(byte *state) { state += 4; for (j = 0; j < nbox ; j++) { - if (j < _allBoxes[i]->numbbox) + if (j < _allBoxes[i]->_numbBox) _allBoxes[i]->_boxes[j]._attivo = *state; state++; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 79eb936d9b..7fe02a4f54 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -339,7 +339,7 @@ public: class RMBoxLoc { public: - int numbbox; + int _numbBox; RMBox *_boxes; private: -- cgit v1.2.3 From 985602a72d52acdb99599eaddbed7f7b9fce01ce Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 00:07:50 +0200 Subject: TONY: Rename some Italian into English --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 8 +-- engines/tony/game.cpp | 4 +- engines/tony/gfxengine.cpp | 4 +- engines/tony/gfxengine.h | 4 +- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 2 +- engines/tony/input.h | 2 +- engines/tony/inventory.cpp | 15 +++--- engines/tony/inventory.h | 6 +-- engines/tony/loc.cpp | 16 +++--- engines/tony/loc.h | 2 +- engines/tony/resid.h | 2 +- engines/tony/sound.h | 121 +++++++++++++++++++-------------------------- engines/tony/tonychar.cpp | 2 +- engines/tony/window.cpp | 2 +- 16 files changed, 89 insertions(+), 107 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 0bdef25ea8..b2d61a5da5 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -55,7 +55,7 @@ enum RMTonyAction { TA_USE, TA_EXAMINE, TA_TALK, - TA_PALESATI, + TA_PERORATE, TA_COMBINE = 10, TA_RECEIVECOMBINE, @@ -80,7 +80,7 @@ void mainCloseWipe(void); void mainWaitWipeEnd(CORO_PARAM); void mainEnableGUI(void); void mainDisableGUI(void); -void mainSetPalesati(bool bPalesati); +void mainSetPerorate(bool bPerorate); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0cf40e5a14..964e506099 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -184,8 +184,8 @@ DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { } -DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.SetPalesati(bStatus); +DECLARE_CUSTOM_FUNCTION(TonySetPerorate)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { + GLOBALS.SetPerorate(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { @@ -2529,7 +2529,7 @@ ASSIGN(134, CustEnableGUI) ASSIGN(135, CustDisableGUI) ASSIGN(136, ClearScreen) ASSIGN(137, PatIrqFreeze) -ASSIGN(138, TonySetPalesati) +ASSIGN(138, TonySetPerorate) ASSIGN(139, OpenInitLoadMenu) ASSIGN(140, OpenInitOptions) ASSIGN(141, SyncScrollLocation) @@ -2562,7 +2562,7 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.WaitWipeEnd = mainWaitWipeEnd; GLOBALS.DisableGUI = mainDisableGUI; GLOBALS.EnableGUI = mainEnableGUI; - GLOBALS.SetPalesati = mainSetPalesati; + GLOBALS.SetPerorate = mainSetPerorate; GLOBALS._bAlwaysDisplay = false; int i; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 9fc65aa87d..0ccd2d8dc8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -114,8 +114,8 @@ void mainDisableGUI(void) { _vm->getEngine()->_bGUIOption = false; } -void mainSetPalesati(bool bPalesati) { - _vm->getEngine()->setPalesati(bPalesati); +void mainSetPerorate(bool bPerorate) { + _vm->getEngine()->setPerorate(bPerorate); } /****************************************************************************\ diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 8daf49c4a5..4c09e16678 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -645,7 +645,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm // Saves the state of the shepherdess and show yourself bStat = _tony.getPastorella(); f->writeByte(bStat); - bStat = _inter.getPalesati(); + bStat = _inter.getPerorate(); f->writeByte(bStat); // Save the chars @@ -781,7 +781,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bStat = _ctx->f->readByte(); _tony.setPastorella(bStat); bStat = _ctx->f->readByte(); - _inter.setPalesati(bStat); + _inter.setPerorate(bStat); CharsLoadAll(_ctx->f); } diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 8d9648c454..18c13d8d3d 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -144,8 +144,8 @@ public: void closeWipe(void); void waitWipeEnd(CORO_PARAM); - void setPalesati(bool bpal) { - _inter.setPalesati(bpal); + void setPerorate(bool bpal) { + _inter.setPerorate(bpal); } bool canLoadSave(); }; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index e676f33174..e3d36db11b 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -54,7 +54,7 @@ Globals::Globals() { InitWipe = NULL; EnableGUI = NULL; DisableGUI = NULL; - SetPalesati = NULL; + SetPerorate = NULL; _dwTonyNumTexts = 0; _bTonyInTexts = false; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index e924678df0..24825588e1 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -232,7 +232,7 @@ public: void (*InitWipe)(int type); void (*EnableGUI)(void); void (*DisableGUI)(void); - void (*SetPalesati)(bool bpal); + void (*SetPerorate)(bool bpal); uint32 _dwTonyNumTexts; bool _bTonyInTexts; diff --git a/engines/tony/input.h b/engines/tony/input.h index e7e200e1b7..fd194d0fc5 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -47,7 +47,7 @@ private: // Keyboard related fields bool _keyDown[350]; private: - // Deinizializza DirectInput + // Deinitialize DirectInput void DIClose(void); public: diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index de8b21748e..f29713adbd 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -770,7 +770,8 @@ int RMInterface::onWhichBox(RMPoint pt) { // Check how many verbs you have to consider max = 4; - if (_bPalesati) max = 5; + if (_bPerorate) + max = 5; // Find the verb for (i = 0; i < max; i++) @@ -867,7 +868,7 @@ bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { break; case 4: - action = TA_PALESATI; + action = TA_PERORATE; break; default: // No verb @@ -881,12 +882,12 @@ void RMInterface::reset(void) { _bActive = false; } -void RMInterface::setPalesati(bool bOn) { - _bPalesati = bOn; +void RMInterface::setPerorate(bool bOn) { + _bPerorate = bOn; } -bool RMInterface::getPalesati(void) { - return _bPalesati; +bool RMInterface::getPerorate(void) { + return _bPerorate; } void RMInterface::init(void) { @@ -932,7 +933,7 @@ void RMInterface::init(void) { _hints[4].writeText(msg4[0], 1); // Show Yourself _bActive = false; - _bPalesati = false; + _bPerorate = false; _lastHotZone = 0; } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 2b6248f7eb..5bf35e6eb0 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -161,7 +161,7 @@ private: RMText _hints[5]; RMGfxSourceBuffer8RLEByte _hotzone[5]; RMRect _hotbbox[5]; - bool _bPalesati; + bool _bPerorate; int _lastHotZone; protected: @@ -189,8 +189,8 @@ public: bool released(const RMPoint &mousepos, RMTonyAction &action); // Enalbes or disables the fifth verb - void setPalesati(bool bOn); - bool getPalesati(void); + void setPerorate(bool bOn); + bool getPerorate(void); // Overloaded Draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e70d15695e..b2bf3b3565 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -889,7 +889,7 @@ void RMWipe::initFade(int type) { _bMustRegister = true; - RMRes res(RES_W_CERCHIO); + RMRes res(RES_W_CIRCLE); RMDataStream ds; ds.openBuffer(res); @@ -1456,7 +1456,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // If we still have to go through a box if (_pathCount < _pathLength) { // Check if the box we're going into is active - if (_ctx->cur->_boxes[_path[_pathCount - 1]]._attivo) { + if (_ctx->cur->_boxes[_path[_pathCount - 1]]._bActive) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] CORO_INVOKE_2(goTo, nearestHotSpot(_path[_pathCount - 1], _path[_pathCount]), _ctx->cur->_boxes[_path[_pathCount - 1]]._bReversed); @@ -1715,7 +1715,7 @@ void RMBox::readFromStream(RMDataStream &ds) { ds >> _numHotspot; ds >> _destZ; ds >> b; - _attivo = b; + _bActive = b; ds >> b; _bReversed = b; @@ -1780,7 +1780,7 @@ void RMBoxLoc::recalcAllAdj(void) { Common::fill(_boxes[i]._adj, _boxes[i]._adj + MAXBOXES, 0); for (j = 0; j < _boxes[i]._numHotspot; j++) - if (_boxes[_boxes[i]._hotspot[j]._destination]._attivo) + if (_boxes[_boxes[i]._hotspot[j]._destination]._bActive) _boxes[i]._adj[_boxes[i]._hotspot[j]._destination] = 1; } } @@ -1851,7 +1851,7 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { return -1; for (i = 0; i < cur->_numbBox; i++) - if (cur->_boxes[i]._attivo) + if (cur->_boxes[i]._bActive) if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) return i; @@ -1860,7 +1860,7 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { } void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { - _allBoxes[nLoc]->_boxes[nBox]._attivo = status; + _allBoxes[nLoc]->_boxes[nBox]._bActive = status; _allBoxes[nLoc]->recalcAllAdj(); } @@ -1892,7 +1892,7 @@ void RMGameBoxes::saveState(byte *state) { state += 4; for (j = 0; j < _allBoxes[i]->_numbBox; j++) - *state++ = _allBoxes[i]->_boxes[j]._attivo; + *state++ = _allBoxes[i]->_boxes[j]._bActive; } } @@ -1913,7 +1913,7 @@ void RMGameBoxes::loadState(byte *state) { for (j = 0; j < nbox ; j++) { if (j < _allBoxes[i]->_numbBox) - _allBoxes[i]->_boxes[j]._attivo = *state; + _allBoxes[i]->_boxes[j]._bActive = *state; state++; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7fe02a4f54..4231c99eab 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -326,7 +326,7 @@ public: uint8 _destZ; // Z value for the bounding box T_HOTSPOT _hotspot[MAXHOTSPOT]; // List of hotspots - bool _attivo; + bool _bActive; bool _bReversed; private: diff --git a/engines/tony/resid.h b/engines/tony/resid.h index 5215801d5d..7f2dc7bb54 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -68,6 +68,6 @@ #define RES_F_CREDITS 10704 #define RES_F_CPAL 10705 -#define RES_W_CERCHIO 10800 +#define RES_W_CIRCLE 10800 #endif diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 6593470d0c..4669dff568 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -65,7 +65,7 @@ private: bool bSoundSupported; /****************************************************************************\ - * Metodi + * Methods \****************************************************************************/ public: @@ -74,105 +74,95 @@ public: * * Function: FPSOUND::FPSOUND(); * - * Description: Costruttore di default. Inizializza gli attributi. + * Description: Default constructor. Initializes the attributes * \****************************************************************************/ FPSOUND(); - /****************************************************************************\ * * Function: FPSOUND::~FPSOUND(); * - * Description: Deinizializza l'oggetto, disallocando la memoria. + * Description: Deinitialize the object, free memory * \****************************************************************************/ ~FPSOUND(); - /****************************************************************************\ * * Function: bool FPSOUND::Init(); * - * Description: Inizializza l'oggetto, e prepara tutto il necessario per - * creare stream e effetti sonori. + * Description: Initializes the objects, and prepare everything required to + * create streams and sound effects. * - * Return: True se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise. * \****************************************************************************/ - bool Init(); - /****************************************************************************\ * * Function: bool CreateStream(FPSTREAM** lplpStream); * - * Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo - * puntatore dopo averlo inizializzato. + * Description: Allocates an object of type FPSTREAM, and return its + * pointer after it has been initialized. * - * Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto - * appena creato. + * Input: FPSTREAM** lplpStream Will contain the pointer of the + * object * - * Return: TRUE se tutto OK, FALSE in caso di errore - * - * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), - * sono dovute al fatto che i costruttori delle classi FPSTREAM - * e FPSFX richiedono che DirectSound sia gia' stato - * inzializzato. In questo modo quindi si evitano dei bugs - * che si verrebbero a creare se venisse dichiarata un oggetto - * di tipo FPSTREAM o FPSFX globale (o cmq prima della - * inizializzazione di DirectSound). + * Return: True is everything i OK, False otherwise * + * Note: The use of functions like CreateStream () and CreateSfx () + * are due to the fact that the class constructors and + * FPSTREAM FPSFX require that DirectSound is already initialized. + * In this way, you avoid the bugs that would be created if an + * object type is declared FPSTREAM FPSFX or global + * (or anyway before initializing DirectSound). \****************************************************************************/ bool CreateStream(FPSTREAM **lplpStream); - - /****************************************************************************\ * * Function: bool CreateSfx(FPSFX** lplpSfx); * - * Description: Alloca un oggetti di tipo FPSFX e ritorna il suo - * puntatore dopo averlo inizializzato. + * Description: Allocates an object of type FPSFX and returns a pointer + * pointing to it * - * Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto - * appena creato. + * Input: FPSFX** lplpSfx Will contain the pointer of the + * object * - * Return: TRUE se tutto OK, FALSE in caso di errore + * Return: True is everything i OK, False otherwise * - * Note: Vedi le note di CreateStream() + * Note: See notes about CreateStream() * \****************************************************************************/ bool CreateSfx(FPSFX **lplpSfx); - - /****************************************************************************\ * * Function: void SetMasterVolume(int dwVolume); * - * Description: Setta il volume generale + * Description: Set main volume * - * Input: int dwVolume Volume da settare (0-63) + * Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ void SetMasterVolume(int dwVolume); - /****************************************************************************\ * * Function: void GetMasterVolume(LPINT lpdwVolume); * - * Description: Richiede il volume generale + * Description: Get main volume * - * Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) + * Input: LPINT lpdwVolume This variable will contain the + * current volume (0-63) * \****************************************************************************/ @@ -182,13 +172,13 @@ public: class FPSFX { /****************************************************************************\ - * Attributi + * Attributes \****************************************************************************/ private: - bool bSoundSupported; // TRUE se il suono e' attivo - bool bFileLoaded; // TRUE se e' stato aperto un file - bool bLoop; // TRUE se bisogna loopare l'effetto sonoro + bool bSoundSupported; // True if the sound is active + bool bFileLoaded; // True is a file is opened + bool bLoop; // True is sound effect should loop int lastVolume; bool bIsVoice; @@ -205,7 +195,7 @@ private: /****************************************************************************\ - * Metodi + * Methods \****************************************************************************/ public: @@ -218,54 +208,49 @@ public: * * Function: FPSFX(bool bSoundOn); * - * Description: Costruttore di default. *NON* bisogna dichiarare direttamente - * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() + * Description: Default constructor. *DO NOT* declare the object directly, + * create it though FPSOUND::CreateSfx() instead * \****************************************************************************/ FPSFX(bool bSoundOn); - /****************************************************************************\ * * Function: ~FPSFX(); * - * Description: Distruttore di default. Si preoccupa anche di fermare il sound - * effect eventualmente in esecuzione, e disallocare la memoria - * da esso occupata. + * Description: Default destructor. It also stops the sound effect that + * may be running, and free the memory used. * \****************************************************************************/ ~FPSFX(); - /****************************************************************************\ * * Function: Release(); * - * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando - * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato - * creato con la FPSOUND::CreateStream(). + * Description: Releases the memory object. Must be called when the object + * is no longer useful and **ONLY** when the object was created + * with the FPSOUND :: CreateStream (). * - * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo - * questa chiamata. + * Note: Any object pointers are no longer valid after this call. * \****************************************************************************/ void Release(); - /****************************************************************************\ * * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * - * Description: Apre un file di effetto sonoro e lo carica. + * Description: Opens a file and load sound effect * - * Input: char *lpszFile Nome del file di sfx da aprire - * uint32 dwCodec CODEC da utilizzare per decomprimere - * i campioni sonori + * Input: char *lpszFile SFX filename + * uint32 dwCodec CODEC to be used to decompress + * the sound samples * - * Return: TRUE se tutto OK, FALSE in caso di errore + * Return: True if everything is OK, False otherwise * \****************************************************************************/ @@ -273,44 +258,40 @@ public: bool loadWave(Common::SeekableReadStream *stream); bool LoadVoiceFromVDB(Common::File &vdbFP); - /****************************************************************************\ * * Function: bool Play(); * - * Description: Suona lo sfx caricato. + * Description: Play the loaded FX. * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool Play(); - /****************************************************************************\ * * Function: bool Stop(); * - * Description: Ferma il play dello sfx. + * Description: Stop a FX * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool Stop(); - /****************************************************************************\ * * Function: void Pause(bool bPause); * - * Description: Pause dell'effetto sonoro + * Description: Pause a FX * \****************************************************************************/ void Pause(bool bPause); - /****************************************************************************\ * * Function: bool SetLoop(bool bLoop); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 5d2c4d37bc..e384dfe794 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -272,7 +272,7 @@ void RMTony::executeAction(int nAction, int nActionItem, int nParm) { _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); _hActionThread = pid; - } else if (nAction == TA_PALESATI) { + } else if (nAction == TA_PERORATE) { pid = mpalQueryDoAction(7, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index cfa9d088e3..db21be0ded 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -55,7 +55,7 @@ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); - // Inizializza i conteggi degli FPS + // Initialize FPS counters fps = lastfcount = fcount = lastsecond = 0; _bGrabScreenshot = false; -- cgit v1.2.3 From b8282316712c1969d9f7e8c1d80a673eeb4b2ced Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 08:03:51 +0200 Subject: TONY: Translate some more comments into English --- engines/tony/gfxcore.cpp | 13 ++--- engines/tony/gfxcore.h | 2 +- engines/tony/sound.h | 138 ++++++++++++++++++++--------------------------- engines/tony/utils.cpp | 2 +- 4 files changed, 64 insertions(+), 91 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 8be4cbd5f5..83769ee78b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -837,7 +837,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri x1 = (prim->getDst()._x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { - // Decompressione + // Decompression RLEDecompressLineFlipped(buf + x1, src + 2, u, width); // Next line @@ -1379,7 +1379,7 @@ RLEWordFlippedDoCopy2: } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* Methods for RMGfxSourceBuffer8RLEWord \****************************************************************************/ RMGfxSourceBuffer8RLEWordAB::~RMGfxSourceBuffer8RLEWordAB() { @@ -1526,7 +1526,7 @@ RLEWordDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AA +* Methods for RMGfxSourceBuffer8AA \****************************************************************************/ byte RMGfxSourceBuffer8AA::_megaAABuf[256 * 1024]; @@ -1542,9 +1542,6 @@ void RMGfxSourceBuffer8AA::prepareImage(void) { void RMGfxSourceBuffer8AA::calculateAA(void) { - // I suck, you suck, he sucks, we suck, they all suck ---> ANTI ALIASING SUX! - // ************************************************************ - int x, y; byte *src, *srcaa; @@ -1631,7 +1628,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // x1 = prim->Dst().x1; - // Poisition into the destination buffer + // Position into the destination buffer buf = bigBuf; buf += y1 * bigBuf.getDimx(); @@ -1710,7 +1707,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.getDimx(); } } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 17ad303fbd..9a00ed1646 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -36,7 +36,7 @@ namespace Tony { /****************************************************************************\ -* Prototipi di classi +* Class prototype \****************************************************************************/ // Class Name Family Treee Abstract? diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 4669dff568..8f4a509930 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -296,44 +296,37 @@ public: * * Function: bool SetLoop(bool bLoop); * - * Description: Attiva o disattiva il loop dello sfx. + * Description: Enables or disables SFX loop * - * Input: bool bLoop TRUE per attivare il loop, FALSE per - * disattivarlo + * Input: bool bLoop True to activate the loop, else False * - * Note: Il loop deve essere attivato PRIMA di eseguire il play - * dello sfx. Qualsiasi modifica effettuata durante il play - * non avra' effetto fino a che lo sfx non viene fermato, - * e poi rimesso in play. + * Note: The loop must be activated before the SFX starts to play, + * else the effect will only be noticable next time the SFX is + * played * \****************************************************************************/ void SetLoop(bool bLoop); - - /****************************************************************************\ * * Function: void SetVolume(int dwVolume); * - * Description: Cambia il volume dello sfx + * Description: Set SFX Volume * - * Input: int dwVolume Volume da settare (0-63) + * Input: int dwVolume Volume to set (0-63) * \****************************************************************************/ void SetVolume(int dwVolume); - - /****************************************************************************\ * * Function: void GetVolume(int * lpdwVolume); * - * Description: Chiede il volume dello sfx + * Description: Get SFX volume * - * Input: int * lpdwVolume Variabile in cui verra' inserito - * il volume corrente + * Input: int * lpdwVolume Will contain the current volume * \****************************************************************************/ @@ -348,7 +341,7 @@ public: class FPSTREAM { /****************************************************************************\ - * Attributi + * Attributes \****************************************************************************/ private: @@ -356,26 +349,26 @@ private: /* HWND hwnd; LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer + LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer */ - byte *lpTempBuffer; // Buffer temporaneo per decompressione + byte *lpTempBuffer; // Temporary buffer use for decompression - uint32 dwBufferSize; // Dimensione del buffer in bytes - uint32 dwSize; // Dimensione dello stream in bytes - uint32 dwCodec; // CODEC utilizzato + uint32 dwBufferSize; // Buffer size (bytes) + uint32 dwSize; // Stream size (bytes) + uint32 dwCodec; // CODEC used - HANDLE hThreadEnd; // Evento per chiudere il thread - Common::File _file; // Handle del file di stream - HANDLE hPlayThread; // Handle del thread di play - HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify + HANDLE hThreadEnd; // Event used to close thread + Common::File _file; // File handle used for the stream + HANDLE hPlayThread; // Handle of the Play thread + HANDLE hHot1, hHot2, hHot3; // Events set by DirectSoundNotify HANDLE hPlayThread_PlayFast; HANDLE hPlayThread_PlayNormal; - bool bSoundSupported; // TRUE se il suono e' attivo - bool bFileLoaded; // TRUE se e' stato aperto un file - bool bLoop; // TRUE se bisogna loopare lo stream - bool bDoFadeOut; // TRUE se bisogna fare un fade out + bool bSoundSupported; // True if the sound is active + bool bFileLoaded; // True if the file is open + bool bLoop; // True if the stream should loop + bool bDoFadeOut; // True if fade out is required bool bSyncExit; bool bPaused; int lastVolume; @@ -385,14 +378,14 @@ private: bool CreateBuffer(int nBufSize); public: - bool bIsPlaying; // TRUE se si sta playando lo stream + bool bIsPlaying; // True if the stream is playing private: static void PlayThread(FPSTREAM *This); /****************************************************************************\ - * Metodi + * Methods \****************************************************************************/ public: @@ -401,84 +394,75 @@ public: * * Function: FPSTREAM(bool bSoundOn); * - * Description: Costruttore di default. *NON* bisogna dichiarare direttamente - * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() + * Description: Default contractor. *DO NOT* declare the object directly: use + * FPSOUND::CreateStream() indtead * \****************************************************************************/ FPSTREAM(bool bSoundOn); - /****************************************************************************\ * * Function: ~FPSTREAM(); * - * Description: Distruttore di default. Si preoccupa anche di fermare stream - * eventualmente in esecuzione, e disallocare la memoria da - * essi occupata. + * Description: Destructor by default. Stops the playing stream (if any) and + * frees the memory used by them * \****************************************************************************/ ~FPSTREAM(); - /****************************************************************************\ * * Function: Release(); * - * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando - * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato - * creato con la FPSOUND::CreateStream(). + * Description: Releases memory used by object. Must be used when the object + * is no longer used. *ONLY*for objects created by + * FPSOUND::CreateStream(). * - * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo - * questa chiamata. + * Note: Object pointers are no longer valid after this call. * \****************************************************************************/ void Release(); - /****************************************************************************\ * * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * - * Description: Apre un file di stream. + * Description: Open a file for a stream. * - * Input: char *lpszFile Nome del file di stream da aprire - * uint32 dwCodec CODEC da utilizzare per decomprimere - * i campioni sonori + * Input: char *lpszFile Filename to be opened + * uint32 dwCodec CODEC to be used to decompress + * sound samples * - * Return: TRUE se tutto OK, FALSE in caso di errore + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); - - /****************************************************************************\ * * Function: UnloadFile(); * - * Description: Chiude un file di stream eventualmente aperto. E' necessario - * richiamare questa funzione per disallocare la memoria - * occupata dallo stream. + * Description: Close a file stream (if opened). This function must be + * called to free the memory used by the stream * - * Return: Il distruttore della classe per sicurezza richiama la - * UnloadFile() se non e' stata richiamata esplicitamente. + * Return: Just to be sure, the destructor of this class calls + * UnloadFile() if it has not been mentioned explicitly * \****************************************************************************/ bool UnloadFile(); - /****************************************************************************\ * * Function: bool Play(); * - * Description: Suona lo stream caricato. + * Description: Play the loaded stream. * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ @@ -486,59 +470,52 @@ public: void PlayFast(void); void Prefetch(void); - /****************************************************************************\ * * Function: bool Stop(); * - * Description: Ferma il play dello stream. + * Description: Stops the play of the stream. * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool Stop(bool bSync = false); void WaitForSync(FPSTREAM *toplay); - /****************************************************************************\ * * Function: void Pause(bool bPause); * - * Description: Pause dell'effetto sonoro + * Description: Pause sound effect * \****************************************************************************/ void Pause(bool bPause); - /****************************************************************************\ * * Function: bool SetLoop(bool bLoop); * - * Description: Attiva o disattiva il loop dello stream. + * Description: Enable of disable stream loop * - * Input: bool bLoop TRUE per attivare il loop, FALSE per - * disattivarlo + * Input: bool bLoop True to enable loop, false otherwise * - * Note: Il loop deve essere attivato PRIMA di eseguire il play - * dello stream. Qualsiasi modifica effettuata durante il play - * non avra' effetto fino a che lo stream non viene fermato, - * e poi rimesso in play. + * Note: The loop must be activated BEFORE you play back the stream. + * Any changes made during play will not have 'effect until + * the stream is not stopped, and then comes back into play. * \****************************************************************************/ void SetLoop(bool bLoop); - - /****************************************************************************\ * * Function: void SetVolume(int dwVolume); * - * Description: Cambia il volume dello stream + * Description: Change stream colume * - * Input: int dwVolume Volume da settare (0-63) + * Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ @@ -550,10 +527,9 @@ public: * * Function: void GetVolume(LPINT lpdwVolume); * - * Description: Chiede il volume dello stream + * Description: Get stream volume * - * Input: LPINT lpdwVolume Variabile in cui verra' inserito - * il volume corrente + * Input: LPINT lpdwVolume Will contain the current stream volume * \****************************************************************************/ diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 6d790c0e68..8e751a811a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -57,7 +57,7 @@ RMString::~RMString() { * Copy constructor */ RMString::RMString(const RMString &str) { - // Richiama l'overload su '=' per copiare + // Use the overloaded '=' when copying _string = NULL; _length = 0; _realLength = 0; -- cgit v1.2.3 From 3508829882502b5a4dd5ba21ee47ff347efbf7b8 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 de440e1a714d596feac383dcb256d431d7e81e4b Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 12 Jun 2012 11:35:27 -0400 Subject: TONY: Fix looping some sounds --- engines/tony/sound.cpp | 28 ++++++++++++++++------------ engines/tony/sound.h | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 487bf54111..b3bdd1be9a 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -198,7 +198,7 @@ FPSFX::FPSFX(bool bSoundOn) { lastVolume = 63; hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; - _stream = 0; + _loopStream = 0; _rewindableStream = 0; bPaused = false; @@ -223,8 +223,10 @@ FPSFX::~FPSFX() { g_system->getMixer()->stopHandle(_handle); _vm->_activeSfx.remove(this); - delete _stream; - // _rewindableStream is deleted by deleting _stream + if (_loopStream) + delete _loopStream; // _rewindableStream is deleted by deleting _loopStream + else + delete _rewindableStream; // FIXME //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) @@ -274,7 +276,6 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { if (!_rewindableStream) return false; - _stream = _rewindableStream; bFileLoaded = true; SetVolume(lastVolume); return true; @@ -304,7 +305,6 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { bIsVoice = true; _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); - _stream = _rewindableStream; bFileLoaded = true; SetVolume(62); @@ -343,11 +343,6 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { _rewindableStream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } - if (bLoop) - _stream = Audio::makeLoopingAudioStream(_rewindableStream, 0); - else - _stream = _rewindableStream; - bFileLoaded = true; return true; } @@ -373,7 +368,16 @@ bool FPSFX::Play() { _rewindableStream->rewind(); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, + Audio::AudioStream *stream = _rewindableStream; + + if (bLoop) { + if (!_loopStream) + _loopStream = Audio::makeLoopingAudioStream(_rewindableStream, 0); + + stream = _loopStream; + } + + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); SetVolume(lastVolume); @@ -495,7 +499,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { * Returns true if the underlying sound has ended */ bool FPSFX::endOfBuffer() const { - return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_stream || _stream->endOfData()); + return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_rewindableStream || _rewindableStream->endOfData()); } /** diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 8f4a509930..24e7f34921 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -184,7 +184,7 @@ private: bool bIsVoice; bool bPaused; - Audio::AudioStream *_stream; + Audio::AudioStream *_loopStream; Audio::RewindableAudioStream *_rewindableStream; Audio::SoundHandle _handle; -- cgit v1.2.3 From 2e3aec48adc591d6496823f234631332e2f4af59 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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 876d47e17d84912dbcf3e2f29339b2a792d92e95 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 21:42:46 +0200 Subject: TONY: Translate Italian enums --- engines/tony/custom.cpp | 176 +++++++++++------------ engines/tony/tonychar.cpp | 346 +++++++++++++++++++++++----------------------- engines/tony/tonychar.h | 212 ++++++++++++++-------------- 3 files changed, 367 insertions(+), 367 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 964e506099..81fa5c7ad4 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -786,7 +786,7 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_FISCHIETTORIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WHISTLERIGHT); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -826,164 +826,164 @@ DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SIINDICA; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredWithHands)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCARED; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredWithoutHands)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCARED2; } -DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithHammer)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMARTELLO; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONMARTELLO); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHHAMMER; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHHAMMER); } -DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithGlasses)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBICCHIERE; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONBICCHIERE); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHGLASSES; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHGLASSES); } -DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithWorm)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONVERME; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONVERME); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHWORM; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHWORM); } -DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRope)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCORDA; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONCORDA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHROPE; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHROPE); } -DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSecretary)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONSEGRETARIA; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONSEGRETARIA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHSECRETARY; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHSECRETARY); } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRabbitANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRABBIT; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRecipeANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRECIPE; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithCardsANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHCARDS; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSnowmanANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHSNOWMAN; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSnowmanStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHSNOWMANSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHSNOWMANSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSnowmanEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHSNOWMANSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRabbitStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRABBITSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHRABBITSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRabbitEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHRABBITSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRecipeStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTASTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRECIPESTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHRECIPESTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRecipeEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHRECIPESTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithCardsStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTESTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHCARDSSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHCARDSSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithCardsEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHCARDSSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; @@ -1016,78 +1016,78 @@ DECLARE_CUSTOM_FUNCTION(TonyWithNotebookEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithMegaphoneStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMEGAFONOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHMEGAPHONESTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHMEGAPHONESTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithMegaphoneEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHMEGAPHONESTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithBeardStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBARBASTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHBEARDSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHBEARDSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithBeardEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHBEARDSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCAREDSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_SCAREDSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_SCAREDSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; @@ -2447,39 +2447,39 @@ ASSIGN(40, TonyRide) ASSIGN(41, TonyFianchi) ASSIGN(42, TonyCanta) ASSIGN(43, TonySiIndica) -ASSIGN(44, TonySpaventatoConMani) -ASSIGN(49, TonySpaventatoSenzaMani) -ASSIGN(45, TonyConBicchiere) -ASSIGN(46, TonyConVerme) -ASSIGN(47, TonyConMartello) -ASSIGN(48, TonyConCorda) -ASSIGN(90, TonyConConiglioANIM) -ASSIGN(91, TonyConRicettaANIM) -ASSIGN(92, TonyConCarteANIM) -ASSIGN(93, TonyConPupazzoANIM) -ASSIGN(94, TonyConPupazzoStart) -ASSIGN(95, TonyConPupazzoEnd) -ASSIGN(96, TonyConConiglioStart) -ASSIGN(97, TonyConConiglioEnd) -ASSIGN(98, TonyConRicettaStart) -ASSIGN(99, TonyConRicettaEnd) -ASSIGN(100, TonyConCarteStart) -ASSIGN(101, TonyConCarteEnd) +ASSIGN(44, TonyScaredWithHands) +ASSIGN(49, TonyScaredWithoutHands) +ASSIGN(45, TonyWithGlasses) +ASSIGN(46, TonyWithWorm) +ASSIGN(47, TonyWithHammer) +ASSIGN(48, TonyWithRope) +ASSIGN(90, TonyWithRabbitANIM) +ASSIGN(91, TonyWithRecipeANIM) +ASSIGN(92, TonyWithCardsANIM) +ASSIGN(93, TonyWithSnowmanANIM) +ASSIGN(94, TonyWithSnowmanStart) +ASSIGN(95, TonyWithSnowmanEnd) +ASSIGN(96, TonyWithRabbitStart) +ASSIGN(97, TonyWithRabbitEnd) +ASSIGN(98, TonyWithRecipeStart) +ASSIGN(99, TonyWithRecipeEnd) +ASSIGN(100, TonyWithCardsStart) +ASSIGN(101, TonyWithCardsEnd) ASSIGN(102, TonyWithNotebookStart) ASSIGN(103, TonyWithNotebookEnd) -ASSIGN(104, TonyConMegafonoStart) -ASSIGN(105, TonyConMegafonoEnd) -ASSIGN(106, TonyConBarbaStart) -ASSIGN(107, TonyConBarbaEnd) +ASSIGN(104, TonyWithMegaphoneStart) +ASSIGN(105, TonyWithMegaphoneEnd) +ASSIGN(106, TonyWithBeardStart) +ASSIGN(107, TonyWithBeardEnd) ASSIGN(108, TonyRidacchia) ASSIGN(109, TonySchifato) ASSIGN(110, TonyNaah) ASSIGN(111, TonyMacbeth) ASSIGN(112, TonySniffaLeft) ASSIGN(113, TonySniffaRight) -ASSIGN(114, TonySpaventatoStart) -ASSIGN(115, TonySpaventatoEnd) -ASSIGN(116, TonyConSegretaria) +ASSIGN(114, TonyScaredStart) +ASSIGN(115, TonyScaredEnd) +ASSIGN(116, TonyWithSecretary) ASSIGN(50, CharSetCode) ASSIGN(51, CharSetColor) diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index e384dfe794..f232f56cb2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -763,43 +763,43 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_SPAVENTATO: + case TALK_SCARED: switch (_talkDirection) { case UP: _nBodyOffset.set(-4, -11); headStartPat = PAT_TESTA_UP; - bodyStartPat = BPAT_SPAVENTOUP_START; + bodyStartPat = BPAT_SCAREDUP_START; headLoopPat = PAT_TALK_UP; - bodyLoopPat = BPAT_SPAVENTOUP_LOOP; + bodyLoopPat = BPAT_SCAREDUP_LOOP; break; case DOWN: _nBodyOffset.set(-5, 45); - headStartPat = PAT_SPAVENTODOWN_START; - bodyStartPat = BPAT_SPAVENTODOWN_START; - headLoopPat = PAT_SPAVENTODOWN_LOOP; - bodyLoopPat = BPAT_SPAVENTODOWN_LOOP; + headStartPat = PAT_SCAREDDOWN_START; + bodyStartPat = BPAT_SCAREDDOWN_START; + headLoopPat = PAT_SCAREDDOWN_LOOP; + bodyLoopPat = BPAT_SCAREDDOWN_LOOP; break; case RIGHT: _nBodyOffset.set(-4, 41); - headStartPat = PAT_SPAVENTORIGHT_START; - bodyStartPat = BPAT_SPAVENTORIGHT_START; - headLoopPat = PAT_SPAVENTORIGHT_LOOP; - bodyLoopPat = BPAT_SPAVENTORIGHT_LOOP; + headStartPat = PAT_SCAREDRIGHT_START; + bodyStartPat = BPAT_SCAREDRIGHT_START; + headLoopPat = PAT_SCAREDRIGHT_LOOP; + bodyLoopPat = BPAT_SCAREDRIGHT_LOOP; break; case LEFT: _nBodyOffset.set(-10, 41); - headStartPat = PAT_SPAVENTOLEFT_START; - bodyStartPat = BPAT_SPAVENTOLEFT_START; - headLoopPat = PAT_SPAVENTOLEFT_LOOP; - bodyLoopPat = BPAT_SPAVENTOLEFT_LOOP; + headStartPat = PAT_SCAREDLEFT_START; + bodyStartPat = BPAT_SCAREDLEFT_START; + headLoopPat = PAT_SCAREDLEFT_LOOP; + bodyLoopPat = BPAT_SCAREDLEFT_LOOP; break; } break; - case TALK_SPAVENTATO2: + case TALK_SCARED2: _bCorpoDavanti = false; switch (_talkDirection) { case UP: @@ -816,8 +816,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDDOWN; _nBodyOffset.set(4, 53); - headStartPat = PAT_SPAVENTODOWN_START; - headLoopPat = PAT_SPAVENTODOWN_LOOP; + headStartPat = PAT_SCAREDDOWN_START; + headLoopPat = PAT_SCAREDDOWN_LOOP; break; case RIGHT: @@ -825,8 +825,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDRIGHT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTORIGHT_START; - headLoopPat = PAT_SPAVENTORIGHT_LOOP; + headStartPat = PAT_SCAREDRIGHT_START; + headLoopPat = PAT_SCAREDRIGHT_LOOP; break; case LEFT: @@ -834,124 +834,124 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDLEFT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTOLEFT_START; - headLoopPat = PAT_SPAVENTOLEFT_LOOP; + headStartPat = PAT_SCAREDLEFT_START; + headLoopPat = PAT_SCAREDLEFT_LOOP; break; } break; - case TALK_CONBICCHIERE: + case TALK_WITHGLASSES: _nBodyOffset.set(4, 53); headLoopPat = PAT_TALK_DOWN; - bodyLoopPat = BPAT_BICCHIERE; + bodyLoopPat = BPAT_GLASS; break; - case TALK_CONVERME: + case TALK_WITHWORM: _nBodyOffset.set(9, 56); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_VERME; + bodyLoopPat = BPAT_WORM; break; - case TALK_CONMARTELLO: + case TALK_WITHHAMMER: _nBodyOffset.set(6, 56); headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_MARTELLO; + bodyLoopPat = BPAT_HAMMER; break; - case TALK_CONCORDA: + case TALK_WITHROPE: _nBodyOffset.set(-3, 38); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CORDA; + bodyLoopPat = BPAT_ROPE; break; - case TALK_CONSEGRETARIA: + case TALK_WITHSECRETARY: _nBodyOffset.set(-17, 12); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONSEGRETARIA; + bodyLoopPat = BPAT_WITHSECRETARY; break; - case TALK_CONCONIGLIO: + case TALK_WITHRABBIT: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-21, -5); - bodyStartPat = BPAT_CONCONIGLIOLEFT_START; + bodyStartPat = BPAT_WITHRABBITLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + bodyLoopPat = BPAT_WITHRABBITLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -5); - bodyStartPat = BPAT_CONCONIGLIORIGHT_START; + bodyStartPat = BPAT_WITHRABBITRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + bodyLoopPat = BPAT_WITHRABBITRIGHT_LOOP; break; } break; - case TALK_CONRICETTA: + case TALK_WITHRECIPE: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-61, -7); - bodyStartPat = BPAT_CONRICETTALEFT_START; + bodyStartPat = BPAT_WITHRECIPELEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + bodyLoopPat = BPAT_WITHRECIPELEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-5, -7); - bodyStartPat = BPAT_CONRICETTARIGHT_START; + bodyStartPat = BPAT_WITHRECIPERIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + bodyLoopPat = BPAT_WITHRECIPERIGHT_LOOP; break; } break; - case TALK_CONCARTE: + case TALK_WITHCARDS: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-34, -2); - bodyStartPat = BPAT_CONCARTELEFT_START; + bodyStartPat = BPAT_WITHCARDSLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + bodyLoopPat = BPAT_WITHCARDSLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -2); - bodyStartPat = BPAT_CONCARTERIGHT_START; + bodyStartPat = BPAT_WITHCARDSRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + bodyLoopPat = BPAT_WITHCARDSRIGHT_LOOP; break; } break; - case TALK_CONPUPAZZO: + case TALK_WITHSNOWMAN: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-35, 2); - bodyStartPat = BPAT_CONPUPAZZOLEFT_START; + bodyStartPat = BPAT_WITHSNOWMANLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + bodyLoopPat = BPAT_WITHSNOWMANLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-14, 2); - bodyStartPat = BPAT_CONPUPAZZORIGHT_START; + bodyStartPat = BPAT_WITHSNOWMANRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + bodyLoopPat = BPAT_WITHSNOWMANRIGHT_LOOP; break; } break; - case TALK_CONPUPAZZOSTATIC: - case TALK_CONRICETTASTATIC: - case TALK_CONCONIGLIOSTATIC: - case TALK_CONCARTESTATIC: + case TALK_WITHSNOWMANSTATIC: + case TALK_WITHRECIPESTATIC: + case TALK_WITHRABBITSTATIC: + case TALK_WITHCARDSSTATIC: case TALK_WITH_NOTEBOOK: - case TALK_CONMEGAFONOSTATIC: + case TALK_WITHMEGAPHONESTATIC: switch (_talkDirection) { case LEFT: case UP: @@ -966,18 +966,18 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; // The beard is the only case in which the head is animated separately while the body is the standard - case TALK_CONBARBASTATIC: + case TALK_WITHBEARDSTATIC: switch (_talkDirection) { case LEFT: case UP: - headLoopPat = PAT_TALKBARBA_LEFT; + headLoopPat = PAT_TALKBEARD_LEFT; bodyLoopPat = BPAT_STANDLEFT; _nBodyOffset.set(6, 56); break; case DOWN: case RIGHT: - headLoopPat = PAT_TALKBARBA_RIGHT; + headLoopPat = PAT_TALKBEARD_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; _nBodyOffset.set(6, 56); break; @@ -1070,7 +1070,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_MACBETH9; break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: _bCorpoDavanti = false; switch (_talkDirection) { case DOWN: @@ -1078,8 +1078,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDDOWN; _nBodyOffset.set(4, 53); - headStartPat = PAT_SPAVENTODOWN_STAND; - headLoopPat = PAT_SPAVENTODOWN_LOOP; + headStartPat = PAT_SCAREDDOWN_STAND; + headLoopPat = PAT_SCAREDDOWN_LOOP; break; case RIGHT: @@ -1087,8 +1087,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDRIGHT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTORIGHT_STAND; - headLoopPat = PAT_SPAVENTORIGHT_LOOP; + headStartPat = PAT_SCAREDRIGHT_STAND; + headLoopPat = PAT_SCAREDRIGHT_LOOP; break; case LEFT: @@ -1096,8 +1096,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDLEFT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTOLEFT_STAND; - headLoopPat = PAT_SPAVENTOLEFT_LOOP; + headStartPat = PAT_SCAREDLEFT_STAND; + headLoopPat = PAT_SCAREDLEFT_LOOP; break; default: @@ -1257,130 +1257,130 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_SIINDICA: break; - case TALK_SPAVENTATO: + case TALK_SCARED: switch (_talkDirection) { case UP: - bodyEndPat = BPAT_SPAVENTOUP_END; + bodyEndPat = BPAT_SCAREDUP_END; break; case DOWN: - headEndPat = PAT_SPAVENTODOWN_END; - bodyEndPat = BPAT_SPAVENTODOWN_END; + headEndPat = PAT_SCAREDDOWN_END; + bodyEndPat = BPAT_SCAREDDOWN_END; break; case RIGHT: - headEndPat = PAT_SPAVENTORIGHT_END; - bodyEndPat = BPAT_SPAVENTORIGHT_END; + headEndPat = PAT_SCAREDRIGHT_END; + bodyEndPat = BPAT_SCAREDRIGHT_END; break; case LEFT: - headEndPat = PAT_SPAVENTOLEFT_END; - bodyEndPat = BPAT_SPAVENTOLEFT_END; + headEndPat = PAT_SCAREDLEFT_END; + bodyEndPat = BPAT_SCAREDLEFT_END; break; } break; - case TALK_SPAVENTATO2: + case TALK_SCARED2: switch (_talkDirection) { case UP: bodyEndPat = 0; break; case DOWN: - headEndPat = PAT_SPAVENTODOWN_END; + headEndPat = PAT_SCAREDDOWN_END; bodyEndPat = 0; break; case RIGHT: - headEndPat = PAT_SPAVENTORIGHT_END; + headEndPat = PAT_SCAREDRIGHT_END; bodyEndPat = 0; break; case LEFT: - headEndPat = PAT_SPAVENTOLEFT_END; + headEndPat = PAT_SCAREDLEFT_END; bodyEndPat = 0; break; } break; - case TALK_CONCONIGLIO: + case TALK_WITHRABBIT: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + bodyEndPat = BPAT_WITHRABBITLEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + bodyEndPat = BPAT_WITHRABBITRIGHT_END; break; } break; - case TALK_CONRICETTA: + case TALK_WITHRECIPE: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONRICETTALEFT_END; + bodyEndPat = BPAT_WITHRECIPELEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONRICETTARIGHT_END; + bodyEndPat = BPAT_WITHRECIPERIGHT_END; break; } break; - case TALK_CONCARTE: + case TALK_WITHCARDS: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONCARTELEFT_END; + bodyEndPat = BPAT_WITHCARDSLEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONCARTERIGHT_END; + bodyEndPat = BPAT_WITHCARDSRIGHT_END; break; } break; - case TALK_CONPUPAZZO: + case TALK_WITHSNOWMAN: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + bodyEndPat = BPAT_WITHSNOWMANLEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + bodyEndPat = BPAT_WITHSNOWMANRIGHT_END; break; } break; - case TALK_CONVERME: - finalPat = PAT_CONVERME; + case TALK_WITHWORM: + finalPat = PAT_WITHWORM; break; - case TALK_CONCORDA: - finalPat = PAT_CONCORDA; + case TALK_WITHROPE: + finalPat = PAT_WITHROPE; break; - case TALK_CONSEGRETARIA: - finalPat = PAT_CONSEGRETARIA; + case TALK_WITHSECRETARY: + finalPat = PAT_WITHSECRETARY; break; - case TALK_CONMARTELLO: - finalPat = PAT_CONMARTELLO; + case TALK_WITHHAMMER: + finalPat = PAT_WITHHAMMER; break; - case TALK_CONBICCHIERE: - finalPat = PAT_CONBICCHIERE; + case TALK_WITHGLASSES: + finalPat = PAT_WITHGLASSES; break; case TALK_MACBETH1: @@ -1394,20 +1394,20 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa finalPat = 0; break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: switch (_talkDirection) { case DOWN: - headStandPat = PAT_SPAVENTODOWN_STAND; + headStandPat = PAT_SCAREDDOWN_STAND; bodyEndPat = 0; break; case RIGHT: - headStandPat = PAT_SPAVENTORIGHT_STAND; + headStandPat = PAT_SCAREDRIGHT_STAND; bodyEndPat = 0; break; case LEFT: - headStandPat = PAT_SPAVENTOLEFT_STAND; + headStandPat = PAT_SCAREDLEFT_STAND; bodyEndPat = 0; break; @@ -1445,14 +1445,14 @@ void RMTony::endTalk(CORO_PARAM) { // Handles the end of an animated and static, leaving everything unchanged if (_bIsStaticTalk) { - if (_nTalkType == TALK_CONBARBASTATIC) { + if (_nTalkType == TALK_WITHBEARDSTATIC) { mainFreeze(); setPattern(0); if (_talkDirection == UP || _talkDirection == LEFT) { - _body.setPattern(BPAT_CONBARBALEFT_STATIC); + _body.setPattern(BPAT_WITHBEARDLEFT_STATIC); _nBodyOffset.set(-41, -14); } else if (_talkDirection == DOWN || _talkDirection == RIGHT) { - _body.setPattern(BPAT_CONBARBARIGHT_STATIC); + _body.setPattern(BPAT_WITHBEARDRIGHT_STATIC); _nBodyOffset.set(-26, -14); } mainUnfreeze(); @@ -1560,74 +1560,74 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat _bCorpoDavanti = true; switch (nTalk) { - case TALK_CONCONIGLIOSTATIC: + case TALK_WITHRABBITSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-21, -5); - bodyStartPat = BPAT_CONCONIGLIOLEFT_START; - bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + bodyStartPat = BPAT_WITHRABBITLEFT_START; + bodyLoopPat = BPAT_WITHRABBITLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -5); - bodyStartPat = BPAT_CONCONIGLIORIGHT_START; - bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + bodyStartPat = BPAT_WITHRABBITRIGHT_START; + bodyLoopPat = BPAT_WITHRABBITRIGHT_LOOP; break; } break; - case TALK_CONCARTESTATIC: + case TALK_WITHCARDSSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-34, -2); - bodyStartPat = BPAT_CONCARTELEFT_START; - bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + bodyStartPat = BPAT_WITHCARDSLEFT_START; + bodyLoopPat = BPAT_WITHCARDSLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -2); - bodyStartPat = BPAT_CONCARTERIGHT_START; - bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + bodyStartPat = BPAT_WITHCARDSRIGHT_START; + bodyLoopPat = BPAT_WITHCARDSRIGHT_LOOP; break; } break; - case TALK_CONRICETTASTATIC: + case TALK_WITHRECIPESTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-61, -7); - bodyStartPat = BPAT_CONRICETTALEFT_START; - bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + bodyStartPat = BPAT_WITHRECIPELEFT_START; + bodyLoopPat = BPAT_WITHRECIPELEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-5, -7); - bodyStartPat = BPAT_CONRICETTARIGHT_START; - bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + bodyStartPat = BPAT_WITHRECIPERIGHT_START; + bodyLoopPat = BPAT_WITHRECIPERIGHT_LOOP; break; } break; - case TALK_CONPUPAZZOSTATIC: + case TALK_WITHSNOWMANSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-35, 2); - bodyStartPat = BPAT_CONPUPAZZOLEFT_START; - bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + bodyStartPat = BPAT_WITHSNOWMANLEFT_START; + bodyLoopPat = BPAT_WITHSNOWMANLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-14, 2); - bodyStartPat = BPAT_CONPUPAZZORIGHT_START; - bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + bodyStartPat = BPAT_WITHSNOWMANRIGHT_START; + bodyLoopPat = BPAT_WITHSNOWMANRIGHT_LOOP; break; } break; @@ -1637,82 +1637,82 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case UP: case LEFT: _nBodyOffset.set(-16, -9); - bodyStartPat = BPAT_CONTACCUINOLEFT_START; - bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; + bodyStartPat = BPAT_WITHNOTEBOOKLEFT_START; + bodyLoopPat = BPAT_WITHNOTEBOOKLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-6, -9); - bodyStartPat = BPAT_CONTACCUINORIGHT_START; - bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; + bodyStartPat = BPAT_WITHNOTEBOOKRIGHT_START; + bodyLoopPat = BPAT_WITHNOTEBOOKRIGHT_LOOP; break; } break; - case TALK_CONMEGAFONOSTATIC: + case TALK_WITHMEGAPHONESTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -8); - bodyStartPat = BPAT_CONMEGAFONOLEFT_START; - bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; + bodyStartPat = BPAT_WITHMEGAPHONELEFT_START; + bodyLoopPat = BPAT_WITHMEGAPHONELEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-14, -8); - bodyStartPat = BPAT_CONMEGAFONORIGHT_START; - bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; + bodyStartPat = BPAT_WITHMEGAPHONERIGHT_START; + bodyLoopPat = BPAT_WITHMEGAPHONERIGHT_LOOP; break; } break; - case TALK_CONBARBASTATIC: + case TALK_WITHBEARDSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -14); - bodyStartPat = BPAT_CONBARBALEFT_START; + bodyStartPat = BPAT_WITHBEARDLEFT_START; bodyLoopPat = BPAT_STANDLEFT; - headLoopPat = PAT_TALKBARBA_LEFT; + headLoopPat = PAT_TALKBEARD_LEFT; headPat = 0; break; case DOWN: case RIGHT: _nBodyOffset.set(-26, -14); - bodyStartPat = BPAT_CONBARBARIGHT_START; + bodyStartPat = BPAT_WITHBEARDRIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; - headLoopPat = PAT_TALKBARBA_RIGHT; + headLoopPat = PAT_TALKBEARD_RIGHT; headPat = 0; break; } break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: switch (_talkDirection) { case DOWN: - headPat = PAT_SPAVENTODOWN_START; + headPat = PAT_SCAREDDOWN_START; bodyLoopPat = BPAT_STANDDOWN; bodyStartPat = BPAT_STANDDOWN; - headLoopPat = PAT_SPAVENTODOWN_STAND; + headLoopPat = PAT_SCAREDDOWN_STAND; _nBodyOffset.set(4, 53); break; case LEFT: - headPat = PAT_SPAVENTOLEFT_START; + headPat = PAT_SCAREDLEFT_START; bodyLoopPat = BPAT_STANDLEFT; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_SPAVENTOLEFT_STAND; + headLoopPat = PAT_SCAREDLEFT_STAND; _nBodyOffset.set(6, 56); break; case RIGHT: - headPat = PAT_SPAVENTORIGHT_START; + headPat = PAT_SCAREDRIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_SPAVENTORIGHT_STAND; + headLoopPat = PAT_SCAREDRIGHT_STAND; _nBodyOffset.set(6, 56); break; @@ -1774,58 +1774,58 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } switch (nTalk) { - case TALK_CONPUPAZZOSTATIC: + case TALK_WITHSNOWMANSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + bodyEndPat = BPAT_WITHSNOWMANLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + bodyEndPat = BPAT_WITHSNOWMANRIGHT_END; break; } break; - case TALK_CONRICETTASTATIC: + case TALK_WITHRECIPESTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONRICETTALEFT_END; + bodyEndPat = BPAT_WITHRECIPELEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONRICETTARIGHT_END; + bodyEndPat = BPAT_WITHRECIPERIGHT_END; break; } break; - case TALK_CONCONIGLIOSTATIC: + case TALK_WITHRABBITSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + bodyEndPat = BPAT_WITHRABBITLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + bodyEndPat = BPAT_WITHRABBITRIGHT_END; break; } break; - case TALK_CONCARTESTATIC: + case TALK_WITHCARDSSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONCARTELEFT_END; + bodyEndPat = BPAT_WITHCARDSLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONCARTERIGHT_END; + bodyEndPat = BPAT_WITHCARDSRIGHT_END; break; } break; @@ -1834,56 +1834,56 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONTACCUINOLEFT_END; + bodyEndPat = BPAT_WITHNOTEBOOKLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONTACCUINORIGHT_END; + bodyEndPat = BPAT_WITHNOTEBOOKRIGHT_END; break; } break; - case TALK_CONMEGAFONOSTATIC: + case TALK_WITHMEGAPHONESTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONMEGAFONOLEFT_END; + bodyEndPat = BPAT_WITHMEGAPHONELEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONMEGAFONORIGHT_END; + bodyEndPat = BPAT_WITHMEGAPHONERIGHT_END; break; } break; - case TALK_CONBARBASTATIC: + case TALK_WITHBEARDSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONBARBALEFT_END; + bodyEndPat = BPAT_WITHBEARDLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONBARBARIGHT_END; + bodyEndPat = BPAT_WITHBEARDRIGHT_END; break; } break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: switch (_talkDirection) { case LEFT: - headEndPat = PAT_SPAVENTOLEFT_END; + headEndPat = PAT_SCAREDLEFT_END; break; case DOWN: - headEndPat = PAT_SPAVENTODOWN_END; + headEndPat = PAT_SCAREDDOWN_END; break; case RIGHT: - headEndPat = PAT_SPAVENTORIGHT_END; + headEndPat = PAT_SCAREDRIGHT_END; break; default: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 6ba66729a9..8c5c0f530d 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -47,23 +47,23 @@ public: TALK_CANTA, TALK_RIDE, TALK_SIINDICA, - TALK_SPAVENTATO, - TALK_SPAVENTATO2, - TALK_CONBICCHIERE, - TALK_CONMARTELLO, - TALK_CONVERME, - TALK_CONCORDA, - TALK_CONCONIGLIO, - TALK_CONRICETTA, - TALK_CONCARTE, - TALK_CONPUPAZZO, - TALK_CONPUPAZZOSTATIC, - TALK_CONCONIGLIOSTATIC, - TALK_CONRICETTASTATIC, - TALK_CONCARTESTATIC, + TALK_SCARED, + TALK_SCARED2, + TALK_WITHGLASSES, + TALK_WITHHAMMER, + TALK_WITHWORM, + TALK_WITHROPE, + TALK_WITHRABBIT, + TALK_WITHRECIPE, + TALK_WITHCARDS, + TALK_WITHSNOWMAN, + TALK_WITHSNOWMANSTATIC, + TALK_WITHRABBITSTATIC, + TALK_WITHRECIPESTATIC, + TALK_WITHCARDSSTATIC, TALK_WITH_NOTEBOOK, - TALK_CONMEGAFONOSTATIC, - TALK_CONBARBASTATIC, + TALK_WITHMEGAPHONESTATIC, + TALK_WITHBEARDSTATIC, TALK_RIDE2, TALK_SCHIFATO, TALK_NAAH, @@ -76,8 +76,8 @@ public: TALK_MACBETH7, TALK_MACBETH8, TALK_MACBETH9, - TALK_SPAVENTATOSTATIC, - TALK_CONSEGRETARIA + TALK_SCAREDSTATIC, + TALK_WITHSECRETARY }; private: @@ -178,28 +178,28 @@ public: PAT_PAST_TALKRIGHT, // Fear - PAT_SPAVENTOLEFT_START, - PAT_SPAVENTOLEFT_LOOP, - PAT_SPAVENTOLEFT_END, - PAT_SPAVENTORIGHT_START, - PAT_SPAVENTORIGHT_LOOP, - PAT_SPAVENTORIGHT_END, - PAT_SPAVENTODOWN_START, - PAT_SPAVENTODOWN_LOOP, - PAT_SPAVENTODOWN_END, + PAT_SCAREDLEFT_START, + PAT_SCAREDLEFT_LOOP, + PAT_SCAREDLEFT_END, + PAT_SCAREDRIGHT_START, + PAT_SCAREDRIGHT_LOOP, + PAT_SCAREDRIGHT_END, + PAT_SCAREDDOWN_START, + PAT_SCAREDDOWN_LOOP, + PAT_SCAREDDOWN_END, // With objects: full body - PAT_CONBICCHIERE, - PAT_CONCORDA, - PAT_CONVERME, - PAT_CONMARTELLO, + PAT_WITHGLASSES, + PAT_WITHROPE, + PAT_WITHWORM, + PAT_WITHHAMMER, // Sound the whistle - PAT_FISCHIETTORIGHT, + PAT_WHISTLERIGHT, // Head with beard - PAT_TALKBARBA_LEFT, - PAT_TALKBARBA_RIGHT, + PAT_TALKBEARD_LEFT, + PAT_TALKBEARD_RIGHT, // Sniff PAT_SNIFFA_LEFT, @@ -220,9 +220,9 @@ public: PAT_NAAHRIGHT_END, // Stand scared - PAT_SPAVENTOLEFT_STAND, - PAT_SPAVENTORIGHT_STAND, - PAT_SPAVENTODOWN_STAND, + PAT_SCAREDLEFT_STAND, + PAT_SCAREDRIGHT_STAND, + PAT_SCAREDDOWN_STAND, PAT_PUTLEFT_UP1, PAT_PUTLEFT_UP2, @@ -243,7 +243,7 @@ public: PAT_PUTUP_DOWN1, PAT_PUTUP_DOWN2, - PAT_CONSEGRETARIA + PAT_WITHSECRETARY }; enum BODYPATTERNS { @@ -252,10 +252,10 @@ public: BPAT_STANDLEFT, BPAT_STANDRIGHT, - BPAT_MARTELLO, - BPAT_PUPAZZO, - BPAT_VERME, - BPAT_BICCHIERE, + BPAT_HAMMER, + BPAT_SNOWMAN, + BPAT_WORM, + BPAT_GLASS, BPAT_CANTALEFT_START, BPAT_CANTALEFT_LOOP, @@ -280,69 +280,69 @@ public: BPAT_SIINDICALEFT, BPAT_SIINDICARIGHT, - BPAT_SPAVENTODOWN_START, - BPAT_SPAVENTODOWN_LOOP, - BPAT_SPAVENTODOWN_END, - BPAT_SPAVENTOLEFT_START, - BPAT_SPAVENTOLEFT_LOOP, - BPAT_SPAVENTOLEFT_END, - BPAT_SPAVENTORIGHT_START, - BPAT_SPAVENTORIGHT_LOOP, - BPAT_SPAVENTORIGHT_END, - BPAT_SPAVENTOUP_START, - BPAT_SPAVENTOUP_LOOP, - BPAT_SPAVENTOUP_END, - - BPAT_CORDA, - - BPAT_CONCONIGLIOLEFT_START, - BPAT_CONCONIGLIOLEFT_LOOP, - BPAT_CONCONIGLIOLEFT_END, - BPAT_CONCONIGLIORIGHT_START, - BPAT_CONCONIGLIORIGHT_LOOP, - BPAT_CONCONIGLIORIGHT_END, - - BPAT_CONRICETTALEFT_START, - BPAT_CONRICETTALEFT_LOOP, - BPAT_CONRICETTALEFT_END, - BPAT_CONRICETTARIGHT_START, - BPAT_CONRICETTARIGHT_LOOP, - BPAT_CONRICETTARIGHT_END, - - BPAT_CONCARTELEFT_START, - BPAT_CONCARTELEFT_LOOP, - BPAT_CONCARTELEFT_END, - BPAT_CONCARTERIGHT_START, - BPAT_CONCARTERIGHT_LOOP, - BPAT_CONCARTERIGHT_END, - - BPAT_CONPUPAZZOLEFT_START, - BPAT_CONPUPAZZOLEFT_LOOP, - BPAT_CONPUPAZZOLEFT_END, - BPAT_CONPUPAZZORIGHT_START, - BPAT_CONPUPAZZORIGHT_LOOP, - BPAT_CONPUPAZZORIGHT_END, - - BPAT_CONTACCUINOLEFT_START, - BPAT_CONTACCUINOLEFT_LOOP, - BPAT_CONTACCUINOLEFT_END, - BPAT_CONTACCUINORIGHT_START, - BPAT_CONTACCUINORIGHT_LOOP, - BPAT_CONTACCUINORIGHT_END, - - BPAT_CONMEGAFONOLEFT_START, - BPAT_CONMEGAFONOLEFT_LOOP, - BPAT_CONMEGAFONOLEFT_END, - BPAT_CONMEGAFONORIGHT_START, - BPAT_CONMEGAFONORIGHT_LOOP, - BPAT_CONMEGAFONORIGHT_END, - - BPAT_CONBARBALEFT_START, - BPAT_CONBARBALEFT_END, - BPAT_CONBARBARIGHT_START, - BPAT_CONBARBARIGHT_END, - BPAT_CONBARBALEFT_STATIC, - BPAT_CONBARBARIGHT_STATIC, + BPAT_SCAREDDOWN_START, + BPAT_SCAREDDOWN_LOOP, + BPAT_SCAREDDOWN_END, + BPAT_SCAREDLEFT_START, + BPAT_SCAREDLEFT_LOOP, + BPAT_SCAREDLEFT_END, + BPAT_SCAREDRIGHT_START, + BPAT_SCAREDRIGHT_LOOP, + BPAT_SCAREDRIGHT_END, + BPAT_SCAREDUP_START, + BPAT_SCAREDUP_LOOP, + BPAT_SCAREDUP_END, + + BPAT_ROPE, + + BPAT_WITHRABBITLEFT_START, + BPAT_WITHRABBITLEFT_LOOP, + BPAT_WITHRABBITLEFT_END, + BPAT_WITHRABBITRIGHT_START, + BPAT_WITHRABBITRIGHT_LOOP, + BPAT_WITHRABBITRIGHT_END, + + BPAT_WITHRECIPELEFT_START, + BPAT_WITHRECIPELEFT_LOOP, + BPAT_WITHRECIPELEFT_END, + BPAT_WITHRECIPERIGHT_START, + BPAT_WITHRECIPERIGHT_LOOP, + BPAT_WITHRECIPERIGHT_END, + + BPAT_WITHCARDSLEFT_START, + BPAT_WITHCARDSLEFT_LOOP, + BPAT_WITHCARDSLEFT_END, + BPAT_WITHCARDSRIGHT_START, + BPAT_WITHCARDSRIGHT_LOOP, + BPAT_WITHCARDSRIGHT_END, + + BPAT_WITHSNOWMANLEFT_START, + BPAT_WITHSNOWMANLEFT_LOOP, + BPAT_WITHSNOWMANLEFT_END, + BPAT_WITHSNOWMANRIGHT_START, + BPAT_WITHSNOWMANRIGHT_LOOP, + BPAT_WITHSNOWMANRIGHT_END, + + BPAT_WITHNOTEBOOKLEFT_START, + BPAT_WITHNOTEBOOKLEFT_LOOP, + BPAT_WITHNOTEBOOKLEFT_END, + BPAT_WITHNOTEBOOKRIGHT_START, + BPAT_WITHNOTEBOOKRIGHT_LOOP, + BPAT_WITHNOTEBOOKRIGHT_END, + + BPAT_WITHMEGAPHONELEFT_START, + BPAT_WITHMEGAPHONELEFT_LOOP, + BPAT_WITHMEGAPHONELEFT_END, + BPAT_WITHMEGAPHONERIGHT_START, + BPAT_WITHMEGAPHONERIGHT_LOOP, + BPAT_WITHMEGAPHONERIGHT_END, + + BPAT_WITHBEARDLEFT_START, + BPAT_WITHBEARDLEFT_END, + BPAT_WITHBEARDRIGHT_START, + BPAT_WITHBEARDRIGHT_END, + BPAT_WITHBEARDLEFT_STATIC, + BPAT_WITHBEARDRIGHT_STATIC, BPAT_MACBETH1, BPAT_MACBETH2, @@ -354,7 +354,7 @@ public: BPAT_MACBETH8, BPAT_MACBETH9, - BPAT_CONSEGRETARIA + BPAT_WITHSECRETARY }; public: -- cgit v1.2.3 From 5bafab9ad629595a1d270b60b2a91bd04dc1b7b9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 Jun 2012 08:00:37 +0200 Subject: TONY: Translate some more Italian --- engines/tony/custom.cpp | 136 ++++++++++++++++++++++----------------------- engines/tony/gfxengine.cpp | 4 +- engines/tony/tonychar.cpp | 122 ++++++++++++++++++++-------------------- engines/tony/tonychar.h | 67 +++++++++++----------- 4 files changed, 165 insertions(+), 164 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 81fa5c7ad4..eea134e442 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -752,23 +752,23 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 } -DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyOnTheFloor)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_ONTHEFLOORLEFT); else - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_ONTHEFLOORRIGHT); } -DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyGetUp)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_GETUPLEFT); else - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_GETUPRIGHT); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -776,11 +776,11 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS._tony->setPastorella(bIsPast); +DECLARE_CUSTOM_FUNCTION(TonyShepherdess)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { + GLOBALS._tony->setShepherdess(bIsPast); } -DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWhistle)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -806,7 +806,7 @@ DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uin GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE; } -DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyGiggle)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE2; } @@ -816,14 +816,14 @@ DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_FIANCHI; } -DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySing)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CANTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SING; } -DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyIndicate)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SIINDICA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_INDICATE; } DECLARE_CUSTOM_FUNCTION(TonyScaredWithHands)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -1095,31 +1095,31 @@ DECLARE_CUSTOM_FUNCTION(TonyScaredEnd)(CORO_PARAM, uint32, uint32, uint32, uint3 } -DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyDisgusted)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCHIFATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_DISGUSTED; } -DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_LEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFF_LEFT); CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffRight)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_RIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFF_RIGHT); CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); @@ -1168,8 +1168,8 @@ DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) GLOBALS._tony->show(); } -DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - GLOBALS._tony->hide(bShowOmbra); +DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowShadow, uint32, uint32, uint32) { + GLOBALS._tony->hide(bShowShadow); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -2438,63 +2438,63 @@ ASSIGN(75, TonyPutUp2) ASSIGN(76, TonyPutMid2) ASSIGN(77, TonyPutDown2) -ASSIGN(36, TonyPerTerra) -ASSIGN(37, TonySiRialza) -ASSIGN(38, TonyPastorella) -ASSIGN(39, TonyFischietto) +ASSIGN(36, TonyOnTheFloor) +ASSIGN(37, TonyGetUp) +ASSIGN(38, TonyShepherdess) +ASSIGN(39, TonyWhistle) ASSIGN(40, TonyRide) ASSIGN(41, TonyFianchi) -ASSIGN(42, TonyCanta) -ASSIGN(43, TonySiIndica) -ASSIGN(44, TonyScaredWithHands) -ASSIGN(49, TonyScaredWithoutHands) -ASSIGN(45, TonyWithGlasses) -ASSIGN(46, TonyWithWorm) -ASSIGN(47, TonyWithHammer) -ASSIGN(48, TonyWithRope) -ASSIGN(90, TonyWithRabbitANIM) -ASSIGN(91, TonyWithRecipeANIM) -ASSIGN(92, TonyWithCardsANIM) -ASSIGN(93, TonyWithSnowmanANIM) -ASSIGN(94, TonyWithSnowmanStart) -ASSIGN(95, TonyWithSnowmanEnd) -ASSIGN(96, TonyWithRabbitStart) -ASSIGN(97, TonyWithRabbitEnd) -ASSIGN(98, TonyWithRecipeStart) -ASSIGN(99, TonyWithRecipeEnd) -ASSIGN(100, TonyWithCardsStart) -ASSIGN(101, TonyWithCardsEnd) -ASSIGN(102, TonyWithNotebookStart) -ASSIGN(103, TonyWithNotebookEnd) -ASSIGN(104, TonyWithMegaphoneStart) -ASSIGN(105, TonyWithMegaphoneEnd) -ASSIGN(106, TonyWithBeardStart) -ASSIGN(107, TonyWithBeardEnd) -ASSIGN(108, TonyRidacchia) -ASSIGN(109, TonySchifato) -ASSIGN(110, TonyNaah) -ASSIGN(111, TonyMacbeth) -ASSIGN(112, TonySniffaLeft) -ASSIGN(113, TonySniffaRight) -ASSIGN(114, TonyScaredStart) -ASSIGN(115, TonyScaredEnd) -ASSIGN(116, TonyWithSecretary) +ASSIGN(42, TonySing) +ASSIGN(43, TonyIndicate) +ASSIGN(44, TonyScaredWithHands) +ASSIGN(49, TonyScaredWithoutHands) +ASSIGN(45, TonyWithGlasses) +ASSIGN(46, TonyWithWorm) +ASSIGN(47, TonyWithHammer) +ASSIGN(48, TonyWithRope) +ASSIGN(90, TonyWithRabbitANIM) +ASSIGN(91, TonyWithRecipeANIM) +ASSIGN(92, TonyWithCardsANIM) +ASSIGN(93, TonyWithSnowmanANIM) +ASSIGN(94, TonyWithSnowmanStart) +ASSIGN(95, TonyWithSnowmanEnd) +ASSIGN(96, TonyWithRabbitStart) +ASSIGN(97, TonyWithRabbitEnd) +ASSIGN(98, TonyWithRecipeStart) +ASSIGN(99, TonyWithRecipeEnd) +ASSIGN(100, TonyWithCardsStart) +ASSIGN(101, TonyWithCardsEnd) +ASSIGN(102, TonyWithNotebookStart) +ASSIGN(103, TonyWithNotebookEnd) +ASSIGN(104, TonyWithMegaphoneStart) +ASSIGN(105, TonyWithMegaphoneEnd) +ASSIGN(106, TonyWithBeardStart) +ASSIGN(107, TonyWithBeardEnd) +ASSIGN(108, TonyGiggle) +ASSIGN(109, TonyDisgusted) +ASSIGN(110, TonyNaah) +ASSIGN(111, TonyMacbeth) +ASSIGN(112, TonySniffLeft) +ASSIGN(113, TonySniffRight) +ASSIGN(114, TonyScaredStart) +ASSIGN(115, TonyScaredEnd) +ASSIGN(116, TonyWithSecretary) ASSIGN(50, CharSetCode) -ASSIGN(51, CharSetColor) +ASSIGN(51, CharSetColor) ASSIGN(52, CharSetTalkPattern) ASSIGN(53, CharSendMessage) ASSIGN(54, CharSetStartEndTalkPattern) ASSIGN(60, MCharSetCode) ASSIGN(61, MCharSetColor) -ASSIGN(62, MCharSetCurrentGroup) -ASSIGN(63, MCharSetNumTalksInGroup) -ASSIGN(64, MCharSetNumTexts) -ASSIGN(65, MCharSendMessage) -ASSIGN(66, MCharSetPosition) -ASSIGN(67, MCharSetAlwaysBack) +ASSIGN(62, MCharSetCurrentGroup) +ASSIGN(63, MCharSetNumTalksInGroup) +ASSIGN(64, MCharSetNumTexts) +ASSIGN(65, MCharSendMessage) +ASSIGN(66, MCharSetPosition) +ASSIGN(67, MCharSetAlwaysBack) ASSIGN(68, MCharResetCode) ASSIGN(70, StartDialog) diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4c09e16678..b167d0a546 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -643,7 +643,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm bool bStat; // Saves the state of the shepherdess and show yourself - bStat = _tony.getPastorella(); + bStat = _tony.getShepherdess(); f->writeByte(bStat); bStat = _inter.getPerorate(); f->writeByte(bStat); @@ -779,7 +779,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bool bStat = false; bStat = _ctx->f->readByte(); - _tony.setPastorella(bStat); + _tony.setShepherdess(bStat); bStat = _ctx->f->readByte(); _inter.setPerorate(bStat); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index f232f56cb2..0f16bc45c3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -46,13 +46,13 @@ void RMTony::initStatics() { RMTony::RMTony() { _bShow = false; - _bShowOmbra = false; - _bCorpoDavanti = false; + _bShowShadow = false; + _bBodyFront = false; _bActionPending = false; _actionItem = NULL; _action = 0; _actionParm = 0; - _bPastorella = false; + _bShepherdess = false; _bIsStaticTalk = false; _bIsTalking = false; _nPatB4Talking = 0; @@ -94,13 +94,13 @@ void RMTony::init(void) { RMDataStream ds; // Tony is shown by default - _bShow = _bShowOmbra = true; + _bShow = _bShowShadow = true; // No action pending _bActionPending = false; _bAction = false; - _bPastorella = false; + _bShepherdess = false; _bIsTalking = false; _bIsStaticTalk = false; @@ -125,7 +125,7 @@ void RMTony::init(void) { void RMTony::close(void) { // Disalloca @@@ Deallocation of missing item - _ombra.destroy(); +// _shadow.destroy(); } void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { @@ -162,12 +162,12 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { void RMTony::show(void) { _bShow = true; - _bShowOmbra = true; + _bShowShadow = true; } -void RMTony::hide(bool bShowOmbra) { +void RMTony::hide(bool bShowShadow) { _bShow = false; - _bShowOmbra = bShowOmbra; + _bShowShadow = bShowShadow; } @@ -179,10 +179,10 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Call the Draw() of the parent class if Tony is visible if (_bShow && _bDrawNow) { - if (_bCorpoDavanti) { + if (_bBodyFront) { prim->getDst().setEmpty(); prim->getDst().offset(-44, -134); - if (_bPastorella) + if (_bShepherdess) prim->getDst().offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } @@ -197,10 +197,10 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_INVOKE_2(_body.draw, bigBuf, prim); } - if (!_bCorpoDavanti) { + if (!_bBodyFront) { prim->getDst().setEmpty(); prim->getDst().offset(-44, -134); - if (_bPastorella) + if (_bShepherdess) prim->getDst().offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } @@ -341,7 +341,7 @@ void RMTony::stop(CORO_PARAM) { int RMTony::getCurPattern(void) { int nPatt = RMCharacter::getCurPattern(); - if (!_bPastorella) + if (!_bShepherdess) return nPatt; switch (nPatt) { @@ -367,7 +367,7 @@ int RMTony::getCurPattern(void) { } void RMTony::setPattern(int nPatt, bool bPlayP0) { - if (_bPastorella) { + if (_bShepherdess) { switch (nPatt) { case PAT_STANDUP: nPatt = PAT_PAST_STANDUP; @@ -568,7 +568,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_UP2: case PAT_TAKELEFT_MID2: case PAT_TAKELEFT_DOWN2: - case PAT_SIRIALZALEFT: + case PAT_GETUPLEFT: case PAT_STANDLEFT: _talkDirection = LEFT; break; @@ -576,7 +576,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: - case PAT_SIRIALZARIGHT: + case PAT_GETUPRIGHT: case PAT_STANDRIGHT: _talkDirection = RIGHT; break; @@ -590,10 +590,10 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } // Puts the body in front by default - _bCorpoDavanti = true; + _bBodyFront = true; } - if (_bPastorella) { + if (_bShepherdess) { // Talking whilst a shepherdess mainFreeze(); switch (_talkDirection) { @@ -622,7 +622,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (nTalkType) { case TALK_NORMAL: - _bCorpoDavanti = false; + _bBodyFront = false; headStartPat = 0; bodyStartPat = 0; @@ -654,11 +654,11 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_FIANCHI: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: _nBodyOffset.set(2, 42); - headStartPat = PAT_TESTA_UP; + headStartPat = PAT_HEAD_UP; bodyStartPat = BPAT_FIANCHIUP_START; headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_FIANCHIUP_LOOP; @@ -666,7 +666,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: _nBodyOffset.set(2, 48); - headStartPat = PAT_TESTA_DOWN; + headStartPat = PAT_HEAD_DOWN; bodyStartPat = BPAT_FIANCHIDOWN_START; headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_FIANCHIDOWN_LOOP; @@ -674,7 +674,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: _nBodyOffset.set(-3, 53); - headStartPat = PAT_TESTA_LEFT; + headStartPat = PAT_HEAD_LEFT; bodyStartPat = BPAT_FIANCHILEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_FIANCHILEFT_LOOP; @@ -682,7 +682,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: _nBodyOffset.set(2, 53); - headStartPat = PAT_TESTA_RIGHT; + headStartPat = PAT_HEAD_RIGHT; bodyStartPat = BPAT_FIANCHIRIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_FIANCHIRIGHT_LOOP; @@ -691,16 +691,16 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; - case TALK_CANTA: + case TALK_SING: _nBodyOffset.set(-10, 25); - headStartPat = PAT_TESTA_LEFT; - bodyStartPat = BPAT_CANTALEFT_START; + headStartPat = PAT_HEAD_LEFT; + bodyStartPat = BPAT_SINGLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CANTALEFT_LOOP; + bodyLoopPat = BPAT_SINGLEFT_LOOP; break; case TALK_RIDE: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: @@ -723,7 +723,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_RIDE2: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: @@ -745,20 +745,20 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; - case TALK_SIINDICA: + case TALK_INDICATE: switch (_talkDirection) { case UP: case DOWN: case LEFT: _nBodyOffset.set(-4, 40); headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_SIINDICALEFT; + bodyLoopPat = BPAT_INDICATELEFT; break; case RIGHT: _nBodyOffset.set(5, 40); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_SIINDICARIGHT; + bodyLoopPat = BPAT_INDICATERIGHT; break; } break; @@ -767,7 +767,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_talkDirection) { case UP: _nBodyOffset.set(-4, -11); - headStartPat = PAT_TESTA_UP; + headStartPat = PAT_HEAD_UP; bodyStartPat = BPAT_SCAREDUP_START; headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_SCAREDUP_LOOP; @@ -800,14 +800,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SCARED2: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; _nBodyOffset.set(6, 53); - headStartPat = PAT_TESTA_UP; + headStartPat = PAT_HEAD_UP; headLoopPat = PAT_TALK_UP; break; @@ -984,22 +984,22 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_SCHIFATO: + case TALK_DISGUSTED: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); - headStartPat = PAT_SCHIFATOLEFT_START; + headStartPat = PAT_DISGUSTEDLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_SCHIFATOLEFT_LOOP; + headLoopPat = PAT_DISGUSTEDLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_SCHIFATORIGHT_START; + headStartPat = PAT_DISGUSTEDRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_SCHIFATORIGHT_LOOP; + headLoopPat = PAT_DISGUSTEDRIGHT_LOOP; break; } break; @@ -1071,7 +1071,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SCAREDSTATIC: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case DOWN: bodyStartPat = BPAT_STANDDOWN; @@ -1154,26 +1154,26 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa switch (_talkDirection) { case UP: finalPat = PAT_STANDUP; - headStandPat = PAT_TESTA_UP; + headStandPat = PAT_HEAD_UP; break; case DOWN: finalPat = PAT_STANDDOWN; - headStandPat = PAT_TESTA_DOWN; + headStandPat = PAT_HEAD_DOWN; break; case LEFT: finalPat = PAT_STANDLEFT; - headStandPat = PAT_TESTA_LEFT; + headStandPat = PAT_HEAD_LEFT; break; case RIGHT: finalPat = PAT_STANDRIGHT; - headStandPat = PAT_TESTA_RIGHT; + headStandPat = PAT_HEAD_RIGHT; break; } - if (_bPastorella) { + if (_bShepherdess) { mainFreeze(); setPattern(finalPat); mainUnfreeze(); @@ -1208,8 +1208,8 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa } break; - case TALK_CANTA: - bodyEndPat = BPAT_CANTALEFT_END; + case TALK_SING: + bodyEndPat = BPAT_SINGLEFT_END; break; case TALK_RIDE: @@ -1222,16 +1222,16 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_SCHIFATO: + case TALK_DISGUSTED: switch (_talkDirection) { case UP: case LEFT: - headEndPat = PAT_SCHIFATOLEFT_END; + headEndPat = PAT_DISGUSTEDLEFT_END; break; case DOWN: case RIGHT: - headEndPat = PAT_SCHIFATORIGHT_END; + headEndPat = PAT_DISGUSTEDRIGHT_END; break; } @@ -1254,7 +1254,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_SIINDICA: + case TALK_INDICATE: break; case TALK_SCARED: @@ -1527,25 +1527,25 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nPat) { case PAT_STANDDOWN: _talkDirection = DOWN; - headPat = PAT_TESTA_RIGHT; + headPat = PAT_HEAD_RIGHT; break; case PAT_TAKELEFT_UP2: case PAT_TAKELEFT_MID2: case PAT_TAKELEFT_DOWN2: - case PAT_SIRIALZALEFT: + case PAT_GETUPLEFT: case PAT_STANDLEFT: _talkDirection = LEFT; - headPat = PAT_TESTA_LEFT; + headPat = PAT_HEAD_LEFT; break; case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: - case PAT_SIRIALZARIGHT: + case PAT_GETUPRIGHT: case PAT_STANDRIGHT: _talkDirection = RIGHT; - headPat = PAT_TESTA_RIGHT; + headPat = PAT_HEAD_RIGHT; break; case PAT_TAKEUP_UP2: @@ -1553,11 +1553,11 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_DOWN2: case PAT_STANDUP: _talkDirection = UP; - headPat = PAT_TESTA_LEFT; + headPat = PAT_HEAD_LEFT; break; } - _bCorpoDavanti = true; + _bBodyFront = true; switch (nTalk) { case TALK_WITHRABBITSTATIC: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 8c5c0f530d..e5231d89fd 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -44,9 +44,9 @@ public: enum TALKTYPE { TALK_NORMAL, TALK_FIANCHI, - TALK_CANTA, + TALK_SING, TALK_RIDE, - TALK_SIINDICA, + TALK_INDICATE, TALK_SCARED, TALK_SCARED2, TALK_WITHGLASSES, @@ -65,7 +65,7 @@ public: TALK_WITHMEGAPHONESTATIC, TALK_WITHBEARDSTATIC, TALK_RIDE2, - TALK_SCHIFATO, + TALK_DISGUSTED, TALK_NAAH, TALK_MACBETH1, TALK_MACBETH2, @@ -82,16 +82,17 @@ public: private: bool _bShow; - bool _bShowOmbra; - bool _bCorpoDavanti; - RMGfxSourceBuffer8AB _ombra; + bool _bShowShadow; + bool _bBodyFront; + // Useless variable? + // RMGfxSourceBuffer8AB _shadow; bool _bActionPending; RMItem *_actionItem; int _action; int _actionParm; static bool _bAction; - bool _bPastorella; + bool _bShepherdess; bool _bIsStaticTalk; bool _bIsTalking; @@ -135,10 +136,10 @@ public: PAT_TAKERIGHT_DOWN1, PAT_TAKERIGHT_DOWN2, - PAT_SIRIALZALEFT, - PAT_PERTERRALEFT, - PAT_SIRIALZARIGHT, - PAT_PERTERRARIGHT, + PAT_GETUPLEFT, + PAT_ONTHEFLOORLEFT, + PAT_GETUPRIGHT, + PAT_ONTHEFLOORRIGHT, // Sheperdess! PAT_PAST_WALKUP, @@ -158,10 +159,10 @@ public: PAT_TALK_RIGHT, // Static head - PAT_TESTA_UP, - PAT_TESTA_DOWN, - PAT_TESTA_LEFT, - PAT_TESTA_RIGHT, + PAT_HEAD_UP, + PAT_HEAD_DOWN, + PAT_HEAD_LEFT, + PAT_HEAD_RIGHT, // Laugh PAT_RIDELEFT_START, @@ -202,16 +203,16 @@ public: PAT_TALKBEARD_RIGHT, // Sniff - PAT_SNIFFA_LEFT, - PAT_SNIFFA_RIGHT, + PAT_SNIFF_LEFT, + PAT_SNIFF_RIGHT, // Disgusted - PAT_SCHIFATOLEFT_START, - PAT_SCHIFATOLEFT_LOOP, - PAT_SCHIFATOLEFT_END, - PAT_SCHIFATORIGHT_START, - PAT_SCHIFATORIGHT_LOOP, - PAT_SCHIFATORIGHT_END, + PAT_DISGUSTEDLEFT_START, + PAT_DISGUSTEDLEFT_LOOP, + PAT_DISGUSTEDLEFT_END, + PAT_DISGUSTEDRIGHT_START, + PAT_DISGUSTEDRIGHT_LOOP, + PAT_DISGUSTEDRIGHT_END, PAT_NAAHLEFT_START, PAT_NAAHLEFT_LOOP, PAT_NAAHLEFT_END, @@ -257,9 +258,9 @@ public: BPAT_WORM, BPAT_GLASS, - BPAT_CANTALEFT_START, - BPAT_CANTALEFT_LOOP, - BPAT_CANTALEFT_END, + BPAT_SINGLEFT_START, + BPAT_SINGLEFT_LOOP, + BPAT_SINGLEFT_END, BPAT_FIANCHILEFT_START, BPAT_FIANCHILEFT_LOOP, @@ -277,8 +278,8 @@ public: BPAT_RIDELEFT, BPAT_RIDERIGHT, - BPAT_SIINDICALEFT, - BPAT_SIINDICARIGHT, + BPAT_INDICATELEFT, + BPAT_INDICATERIGHT, BPAT_SCAREDDOWN_START, BPAT_SCAREDDOWN_LOOP, @@ -375,7 +376,7 @@ public: // Show or hide void show(void); - void hide(bool bShowOmbra = false); + void hide(bool bShowShadow = false); // Move and make an action, if necessary void moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); @@ -434,11 +435,11 @@ public: void endStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void setPastorella(bool bIsPast) { - _bPastorella = bIsPast; + void setShepherdess(bool bIsPast) { + _bShepherdess = bIsPast; } - int getPastorella(void) { - return _bPastorella; + int getShepherdess(void) { + return _bShepherdess; } // Perform an action -- cgit v1.2.3 From 746dcf33da340702157dc7aca0f01265648189be Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jun 2012 21:06:57 +1000 Subject: TONY: Refactor RMPointer class to use the ScummVM CursorMan --- engines/tony/game.cpp | 73 ++++++++++++++++++++++++++++------------------ engines/tony/game.h | 28 ++++++++++-------- engines/tony/gfxengine.cpp | 5 ++-- 3 files changed, 64 insertions(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 0ccd2d8dc8..1b13fa98bf 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -29,6 +29,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/textconsole.h" +#include "graphics/cursorman.h" #include "tony/mpal/lzo.h" #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" @@ -1543,46 +1544,62 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // Copy the destination coordinates in the primitive - prim->setDst(_pos); + _cursorHotspot = _hotspot[_ctx->n]; - if (_pos._x >= 0 && _pos._y >= 0 && _pos._x < RM_SX && _pos._y < RM_SY) { - // Call the Draw method of the poitner - prim->getDst() -= _hotspot[_ctx->n]; - - if (_nCurSpecialPointer == 0) { - CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); - } else { - if (_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); - else - // Call the draw on the special pointer - CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); - } + // Call the Draw method of the pointer + if (_nCurSpecialPointer == 0) { + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); + } else { + if (_nCurSpecialPointer == PTR_CUSTOM) + CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); + else + // Call the draw on the special pointer + CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); } CORO_END_CODE; } -void RMPointer::doFrame(RMGfxTargetBuffer *bigBuf) { - // Add it to the list of primitives - bigBuf->addPrim(new RMGfxPrimitive(this)); +int RMPointer::curAction(void) { + if (_nCurSpecialPointer != 0) + return 0; - // If there is a special pointer, does DoFrame - if (_nCurSpecialPointer != 0 && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[_nCurSpecialPointer - 1]->doFrame(bigBuf, false); + return _nCurPointer; } -void RMPointer::removeThis(CORO_PARAM, bool &result) { - // Always remove from the OT list, to support disabling the pointer - result = true; +/** + * Show the cursor + */ +void RMPointer::showCursor() { + if (!CursorMan.isVisible()) { + CursorMan.showMouse(true); + + updateCursor(); + } } -int RMPointer::curAction(void) { - if (_nCurSpecialPointer != 0) - return 0; +/** + * Hide the cursor + */ +void RMPointer::hideCursor() { + if (CursorMan.isVisible()) { + CursorMan.showMouse(false); + } +} - return _nCurPointer; + +void RMPointer::updateCursor() { + // Create an intermediate buffer and draw the cursor onto it + RMGfxTargetBuffer buf; + buf.create(64, 64, 16); + RMGfxPrimitive prim; + + draw(Common::nullContext, buf, &prim); + + // Get the raw pixel data and set the cursor to it + const byte *cursorData = buf; + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index db182dfa23..9ac8f76bcc 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -54,11 +54,11 @@ namespace Tony { delete raw; -class RMPointer : public RMGfxTask { +class RMPointer { private: RMGfxSourceBuffer8 *_pointer[16]; RMPoint _hotspot[16]; - RMPoint _pos; + RMPoint _cursorHotspot; RMItem *_specialPointer[16]; @@ -67,6 +67,8 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; + void updateCursor(); + public: enum POINTER { PTR_NONE = 0, @@ -95,20 +97,13 @@ public: // Overloading of priorities int priority(); - // Overloading draw method - virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - - // Sets the current co-ordinates - void setCoord(const RMPoint &pt) { - _pos = pt; - } - - // Overloading of the method to see if rising from the list - virtual void removeThis(CORO_PARAM, bool &result); + // draw method + void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets a new action as current void setAction(RMTonyAction action) { _nCurPointer = action; + updateCursor(); } // Sets a new pointer @@ -116,6 +111,8 @@ public: _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) _specialPointer[ptr - 1]->setPattern(1); + + updateCursor(); } POINTER getSpecialPointer(void) { return (POINTER)_nCurSpecialPointer; @@ -124,10 +121,17 @@ public: // Set the new custom pointer void setCustomPointer(RMGfxSourceBuffer8 *ptr) { _nCurCustomPointer = ptr; + updateCursor(); } // Return the current action to be applied according to the pointer int curAction(void); + + /** Show the cursor */ + void showCursor(); + + /** Hide the cursor */ + void hideCursor(); }; class RMOptionButton: public RMGfxTaskSetPrior { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b167d0a546..deae0cb641 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -305,8 +305,9 @@ SKIPCLICKSINISTRO: _tony.setScrollPosition(_loc.scrollPosition()); if ((!_tony.inAction() && _bInput) || _bAlwaysDrawMouse) { - _point.setCoord(_input.mousePos()); - _point.doFrame(&_bigBuf); + _point.showCursor(); + } else { + _point.hideCursor(); } // ********************** -- cgit v1.2.3 From 879d6902f4f55db949ea2fe096611f8cbaabc652 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 42a322d671a27406a9dd993f82675dda0ee4780b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 14 Jun 2012 00:11:56 +0200 Subject: TONY: Silent some CppCheck warnings --- engines/tony/font.cpp | 6 +++++- engines/tony/font.h | 4 ++-- engines/tony/game.cpp | 3 +++ engines/tony/gfxcore.cpp | 16 +++++++--------- engines/tony/inventory.cpp | 5 +++++ engines/tony/inventory.h | 1 + 6 files changed, 23 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 122c529de3..a567fe20cd 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -42,6 +42,7 @@ namespace Tony { RMFont::RMFont() { _letter = NULL; + _nLetters = _fontDimx = _fontDimy = _dimx = _dimy = 0; } RMFont::~RMFont() { @@ -1993,7 +1994,7 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { \****************************************************************************/ RMTextDialog::RMTextDialog() : RMText() { - _startTime = 0; + _time = _startTime = 0; _dst = RMPoint(0, 0); _bSkipStatus = true; @@ -2327,6 +2328,9 @@ RMDialogChoice::RMDialogChoice() { _hUnreg = CoroScheduler.createEvent(false, false); _bRemoveFromOT = false; + + _curAdded = 0; + _bShow = false; } RMDialogChoice::~RMDialogChoice() { diff --git a/engines/tony/font.h b/engines/tony/font.h index daaac84a59..328d501e27 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -57,8 +57,8 @@ private: class RMFontPrimitive : public RMGfxPrimitive { public: - RMFontPrimitive() : RMGfxPrimitive() {} - RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} + RMFontPrimitive() : RMGfxPrimitive() { _nChar = 0; } + RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) { _nChar = 0; } virtual ~RMFontPrimitive() { } virtual RMGfxPrimitive *duplicate() { return new RMFontPrimitive(*this); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1b13fa98bf..03479d96a5 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1473,6 +1473,9 @@ bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS RMPointer::RMPointer() { Common::fill(_pointer, _pointer + 16, (RMGfxSourceBuffer8 *)NULL); Common::fill(_specialPointer, _specialPointer + 16, (RMItem *)NULL); + + _nCurPointer = _nCurSpecialPointer = 0; + _nCurCustomPointer = NULL; } RMPointer::~RMPointer() { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 83769ee78b..e168d2b7c9 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -390,16 +390,15 @@ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { } int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { - int i; - - if (bSwapped) - for (i = 0; i < (1 << getBpp()); i++) { + if (bSwapped) { + for (int i = 0; i < (1 << getBpp()); i++) { _pal[i * 3 + 0] = buf[i * 3 + 2]; _pal[i * 3 + 1] = buf[i * 3 + 1]; _pal[i * 3 + 2] = buf[i * 3 + 0]; } - else + } else { copyMemory(_pal, buf, (1 << getBpp()) * 3); + } preparePalette(); @@ -1819,7 +1818,6 @@ RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16 *)_buf; int dimx, dimy; @@ -1852,8 +1850,8 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi buf += y1 * bigBuf.getDimx() + x1; if (_bTrasp0) { - for (y = 0; y < dimy; y++) { - for (x = 0; x < dimx;) { + for (int y = 0; y < dimy; y++) { + for (int x = 0; x < dimx;) { while (x < dimx && raw[x] == 0) x++; @@ -1867,7 +1865,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi buf += bigBuf.getDimx(); } } else { - for (y = 0; y < dimy; y++) { + for (int y = 0; y < dimy; y++) { Common::copy(raw, raw + dimx, buf); buf += bigBuf.getDimx(); raw += _dimx; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index f29713adbd..76d0f0eca9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -755,6 +755,11 @@ int RMInventory::loadState(byte *state) { * RMInterface methods \****************************************************************************/ +RMInterface::RMInterface() : RMGfxSourceBuffer8RLEByte() { + _bActive = _bPerorate = false; + _lastHotZone = -1; +} + RMInterface::~RMInterface() { } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 5bf35e6eb0..b739e16f72 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -169,6 +169,7 @@ protected: int onWhichBox(RMPoint pt); public: + RMInterface(); virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) -- cgit v1.2.3 From c1046889411d4f38babd21b1b38c0cbd457caf10 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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 d4e9aa78aba58ba96d99595410fd46dd351b8aca Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 14 Jun 2012 08:08:13 +0200 Subject: TONY: Silent more CppCheck warnings --- engines/tony/gfxcore.h | 7 +++++++ engines/tony/loc.cpp | 18 +++++++++--------- engines/tony/mpal/expr.cpp | 22 +++++++++++----------- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/window.cpp | 8 +++----- 5 files changed, 32 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 9a00ed1646..4461f41271 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -112,11 +112,13 @@ public: _task = NULL; _src.setEmpty(); _dst.setEmpty(); + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task) { _task = task; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { @@ -132,6 +134,7 @@ public: _src.topLeft() = src; _dst = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { @@ -139,6 +142,7 @@ public: _src.topLeft() = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { @@ -146,6 +150,7 @@ public: _src = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { @@ -153,6 +158,7 @@ public: _dst = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { @@ -160,6 +166,7 @@ public: _dst.topLeft() = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } virtual ~RMGfxPrimitive() { } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b2bf3b3565..0b8398c541 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -710,14 +710,13 @@ void RMItem::setStatus(int nStatus) { } void RMItem::setPattern(int nPattern, bool bPlayP0) { - int i; - assert(nPattern >= 0 && nPattern <= _nPatterns); - if (_sfx) + if (_sfx) { if (_nCurPattern > 0) _patterns[_nCurPattern].stopSfx(_sfx); - + } + // Remember the current pattern _nCurPattern = nPattern; @@ -728,10 +727,12 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { _nCurSprite = -1; // Look for the sound effect for pattern 0 - if (bPlayP0) - for (i = 0; i < _nSfx; i++) + if (bPlayP0) { + for (int i = 0; i < _nSfx; i++) { if (strcmp(_sfx[i]._name, "p0") == 0) _sfx[i].play(); + } + } } } @@ -783,6 +784,8 @@ RMItem::RMItem() { _bPal = 0; _nCurSprite = 0; + _bIsActive = false; + _hEndPattern = CoroScheduler.createEvent(false, false); } @@ -1967,11 +1970,8 @@ bool RMLocation::load(const char *lpszFileName) { * @returns True if succeeded OK, false in case of error. */ bool RMLocation::load(Common::File &file) { - int size; bool bRet; - // Get the file size - size = file.size(); file.seek(0); RMFileStreamSlow fs; diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 516da98bb1..52751120f6 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -124,8 +124,8 @@ static byte *duplicateExpression(HGLOBAL h) { two->val.pson = duplicateExpression(two->val.son); } - one++; - two++; + ++one; + ++two; } globalUnlock(h); @@ -183,23 +183,23 @@ static void solve(LPEXPRESSION one, int num) { int j; while (num > 1) { - two=one + 1; + two = one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num = Compute(one->val.num, two->val.num,one->symbol); + two->val.num = Compute(one->val.num, two->val.num, one->symbol); copyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); - num--; + --num; } else { j = 1; three = two + 1; while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { - two++; - three++; - j++; + ++two; + ++three; + ++j; } three->val.num = Compute(two->val.num, three->val.num, two->symbol); copyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); - num--; + --num; } } } @@ -390,8 +390,8 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; } - one++; - two++; + ++one; + ++two; } globalUnlock(h1); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 3b798b8071..92ece3b0b4 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1565,7 +1565,7 @@ void mpalFree() { * method that returns numeric results. */ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { - int x, y, z; + int x, y; Common::String buf; uint32 dwRet = 0; char *n; @@ -1718,7 +1718,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { lockItems(); lockVar(); x = GETARG(uint32); - z = GETARG(uint32); + int z = GETARG(uint32); y = itemGetOrderFromNum(z); if (y != -1) { dwRet = doAction(x, y, GETARG(uint32)); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index db21be0ded..3b60e480f6 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -214,10 +214,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; - int u, v, curv; - uint32 k = 0; - int sommar, sommab, sommag; uint16 *cursrc; if (lpDestBuf == NULL) @@ -247,10 +244,11 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; + int sommar, sommab, sommag, curv; sommar = sommab = sommag = 0; - for (v = 0; v < dezoom; v++) { - for (u = 0; u < dezoom; u++) { + for (int v = 0; v < dezoom; v++) { + for (int u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else -- cgit v1.2.3 From d14fd7b1a352df6e94247e325f679cc25fef671c Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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 e55a16271e4a686d6a23bdb479cd5cf8ac89594a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Jun 2012 22:07:36 +1000 Subject: TONY: Removed unused global static object and associated method --- engines/tony/gfxcore.cpp | 7 ------- engines/tony/gfxcore.h | 5 ----- 2 files changed, 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index e168d2b7c9..37fc947912 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -251,8 +251,6 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) * RMGfxTargetBuffer Methods \****************************************************************************/ -RMGfxClearTask RMGfxTargetBuffer::taskClear; - RMGfxTargetBuffer::RMGfxTargetBuffer() { _otlist = NULL; _otSize = 0; @@ -376,11 +374,6 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { // g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::addClearTask(void) { - addPrim(new RMGfxPrimitive(&taskClear)); -} - - /****************************************************************************\ * RMGfxSourceBufferPal Methods \****************************************************************************/ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 4461f41271..e221753a47 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -548,8 +548,6 @@ public: */ class RMGfxTargetBuffer : public virtual RMGfxBuffer { private: - static RMGfxClearTask taskClear; - struct OTList { RMGfxPrimitive *_prim; OTList *_next; @@ -576,9 +574,6 @@ public: void drawOT(CORO_PARAM); void addPrim(RMGfxPrimitive *prim); // The pointer must be delted - // Adds a task to clear the screen - void addClearTask(void); - operator byte *() { return _buf; } -- cgit v1.2.3 From fbc71915493f8162a674e0c83d470bfe6eb80a42 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 7951881d46aedb230870d843a3f7278368556657 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 14 Jun 2012 18:30:56 +0200 Subject: TONY: Fix three warnings reported by CppCheck in inventory (reported by eriktorbjorn) --- engines/tony/inventory.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 76d0f0eca9..4109e5f371 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -190,11 +190,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - if (_state == OPENING || _state == CLOSING) - prim->setDst(RMPoint(0, _curPutY)); - else - prim->setDst(RMPoint(0, _curPutY)); - + prim->setDst(RMPoint(0, _curPutY)); g_system->lockMutex(_csModifyInterface); CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); g_system->unlockMutex(_csModifyInterface); @@ -257,9 +253,9 @@ void RMInventory::removeItem(int code) { } void RMInventory::addItem(int code) { - if (code <= 10000 && code >= 10101) { + if (code <= 10000 || code >= 10101) { // If we are here, it means that we are adding an item that should not be in the inventory - warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); + warning("RMInventory::addItem(%d) - Cannot find a valid icon for this item, and then it will not be added to the inventory", code); } else { g_system->lockMutex(_csModifyInterface); if (_curPos + 8 == _nInv) { @@ -277,8 +273,8 @@ void RMInventory::addItem(int code) { } void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { - if (code <= 10000 && code >= 10101) { - error("Specified object code is not valid"); + if (code <= 10000 || code >= 10101) { + error("RMInventory::changeItemStatus(%d) - Specified object code is not valid", code); } else { g_system->lockMutex(_csModifyInterface); _items[code - 10000]._icon.setPattern(dwStatus); -- cgit v1.2.3 From 181414d749080b0c10c441ace945c3965f43fa39 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 7c605c5f69e350e87801912babdf5b3cd65024d3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Jun 2012 08:23:06 +0200 Subject: TONY: Silent more CppCheck warnings, remove an unused global --- engines/tony/gfxcore.cpp | 4 ++++ engines/tony/globals.cpp | 5 ++++- engines/tony/globals.h | 1 - engines/tony/inventory.cpp | 18 +++++++----------- engines/tony/loc.cpp | 16 ++++++++++++++++ 5 files changed, 31 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 37fc947912..2f38f5d05d 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -548,6 +548,7 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { setPriority(0); + _bTrasp0 = false; } RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { @@ -672,6 +673,8 @@ RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { _alphaBlendColor = -1; _bNeedRLECompress = true; _buf = NULL; + + _alphaR = _alphaG = _alphaB = 0; } RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { @@ -1879,6 +1882,7 @@ void RMGfxSourceBuffer16::prepareImage(void) { RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { setPriority(0); + _bTrasp0 = false; } diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index e3d36db11b..45ab5f8722 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -134,8 +134,11 @@ Globals::Globals() { _nTonyNextTalkType = RMTony::TALK_NORMAL; _saveTonyLoc = 0; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { Common::fill((byte *)&_character[i], (byte *)&_character[i] + sizeof(CharacterStruct), 0); + _isMChar[i] = false; + } + for (int i = 0; i < 10; ++i) Common::fill((byte *)&_mCharacter[i], (byte *)&_mCharacter[i] + sizeof(MCharacterStruct), 0); for (int i = 0; i < 256; ++i) diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 24825588e1..2301e621aa 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -240,7 +240,6 @@ public: RMTony::TALKTYPE _nTonyNextTalkType; RMPoint _startLocPos[256]; - OSystem::MutexRef _cs[10]; uint32 _mut[10]; bool _bSkipIdle; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 4109e5f371..4d824bb10a 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -391,13 +391,11 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { } void RMInventory::rightClick(const RMPoint &mpos) { - int n; - assert(checkPointInside(mpos)); if (_state == OPENED && !_bCombining) { // Open the context interface - n = mpos._x / 64; + int n = mpos._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { _state = SELECTING; @@ -456,13 +454,13 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { if (_state == SELECTING) { _state = OPENED; - if (_miniAction == 1) { // Esamina + if (_miniAction == 1) { // Examine curAction = TA_EXAMINE; return true; - } else if (_miniAction == 2) { // Parla + } else if (_miniAction == 2) { // Talk curAction = TA_TALK; return true; - } else if (_miniAction == 3) { // Usa + } else if (_miniAction == 3) { // Use curAction = TA_USE; return true; } @@ -474,7 +472,6 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { #define INVSPEED 20 void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { - int i; bool bNeedRedraw = false; if (_state != CLOSED) { @@ -484,9 +481,10 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help - for (i = 0; i < _nInv; i++) + for (int i = 0; i < _nInv; i++) { if (_items[_inv[i]]._icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) bNeedRedraw = true; + } if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos._x > RM_SX - 64) { @@ -672,11 +670,9 @@ bool RMInventory::itemInFocus(const RMPoint &mpt) { } RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { - int n; - if (_state == OPENED) { if (checkPointInside(mpt)) { - n = mpt._x / 64; + int n = mpt._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) return &_items[_inv[n - 1 + _curPos]]._icon; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 0b8398c541..42c96076f9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -785,6 +785,7 @@ RMItem::RMItem() { _nCurSprite = 0; _bIsActive = false; + memset(_pal._data, 0, sizeof(_pal._data)); _hEndPattern = CoroScheduler.createEvent(false, false); } @@ -841,6 +842,13 @@ void RMItem::pauseSound(bool bPause) { RMWipe::RMWipe() { _hUnregistered = CoroScheduler.createEvent(false, false); _hEndOfFade = CoroScheduler.createEvent(false, false); + + _bMustRegister = false; + _bUnregister = false; + _bEndFade = false; + _bFading = false; + _nFadeStep = 0; + } RMWipe::~RMWipe() { @@ -1681,6 +1689,8 @@ RMCharacter::RMCharacter() { _bMovingWithoutMinpath = false; _bDrawNow = false; _bNeedToStop = false; + + memset(_path, 0, sizeof(_path)); _pos.set(0, 0); } @@ -1748,6 +1758,7 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { RMBoxLoc::RMBoxLoc() { _boxes = NULL; + _numbBox = 0; } RMBoxLoc::~RMBoxLoc() { @@ -1936,6 +1947,8 @@ RMLocation::RMLocation() { _nItems = 0; _items = NULL; _buf = NULL; + TEMPNumLoc = 0; + _cmode = CM_256; } @@ -2292,6 +2305,9 @@ RMMessage::RMMessage(uint32 dwId) { RMMessage::RMMessage() { _lpMessage = NULL; + _nPeriods = 0; + for (int i = 0; i < 256; i++) + _lpPeriods[i] = 0; } RMMessage::~RMMessage() { -- cgit v1.2.3 From 71aa08c7f0f00be2e2c9ca013aa7682d79b6796f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Jun 2012 08:42:24 +0200 Subject: TONY: Silent more CppCheck warnings --- engines/tony/tony.cpp | 15 +++++++++++++++ engines/tony/utils.cpp | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b1e45c8bfa..012dc854b9 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -61,6 +61,21 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng if (slotNumber >= 0 && slotNumber <= 99) _initialLoadSlotNumber = slotNumber; } + + _hEndOfFrame = 0; + for (int i = 0; i < 6; i++) + _stream[i] = NULL; + for (int i = 0; i < MAX_SFX_CHANNELS; i++) { + _sfx[i] = NULL; + _utilSfx[i] = NULL; + } + _bPaused = false; + _bDrawLocation = false; + _startTime = 0; + _curThumbnail = NULL; + _bQuitNow = false; + _bTimeFreezed = false; + _nTimeFreezed = 0; } TonyEngine::~TonyEngine() { diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8e751a811a..b6af8736bd 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -209,11 +209,9 @@ const RMString &RMString::operator=(const int ch) { * @param size Length of the string */ void RMString::connect(const char *str, int size) { - int nlen; - if (size > 0) { // Calculate the new lenght - nlen = _length + size; + int nlen = _length + size; // Resize resize(nlen + 1, true); @@ -511,6 +509,9 @@ RMDataStream::RMDataStream() { _length = 0; _pos = 0; _bError = false; + + _buf = NULL; + _ecode = 0; } /** @@ -1002,6 +1003,7 @@ RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { RMResUpdate::RMResUpdate() { _infos = NULL; + _numUpd = 0; } RMResUpdate::~RMResUpdate() { -- cgit v1.2.3 From bd31b5f20144169c830211db29eac8d4789f1428 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 cdbc4aa28b5c47392369879b209f9635ff431195 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 10:57:35 +1000 Subject: TONY: Initial commit of in progress dirty rect handling --- engines/tony/gfxcore.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++- engines/tony/gfxcore.h | 22 +++++++++++++ engines/tony/gfxengine.cpp | 4 +-- engines/tony/gfxengine.h | 4 +-- engines/tony/loc.cpp | 34 ++++++++++++++------ engines/tony/loc.h | 3 ++ engines/tony/tony.cpp | 3 +- engines/tony/utils.cpp | 4 +++ engines/tony/utils.h | 1 + engines/tony/window.cpp | 35 ++++++++++++++------ engines/tony/window.h | 3 +- 11 files changed, 167 insertions(+), 25 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index e168d2b7c9..d34923e455 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -256,6 +256,7 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { _otlist = NULL; _otSize = 0; + _trackDirtyRects = false; // csModifyingOT = g_system->createMutex(); } @@ -380,6 +381,66 @@ void RMGfxTargetBuffer::addClearTask(void) { addPrim(new RMGfxPrimitive(&taskClear)); } +void RMGfxTargetBuffer::addDirtyRect(const Common::Rect &r) { + assert(r.isValidRect()); + if (_trackDirtyRects && r.width() > 0 && r.height() > 0) + _currentDirtyRects.push_back(r); +} + +Common::List &RMGfxTargetBuffer::getDirtyRects() { + // Copy rects from both the current and previous frame into the output dirty rects list + Common::List::iterator i; + _dirtyRects.clear(); + for (i = _previousDirtyRects.begin(); i != _previousDirtyRects.end(); ++i) + _dirtyRects.push_back(*i); + for (i = _currentDirtyRects.begin(); i != _currentDirtyRects.end(); ++i) + _dirtyRects.push_back(*i); + + mergeDirtyRects(); + return _dirtyRects; +} + +/** + * Move the set of dirty rects from the finished current frame into the previous frame list. + */ +void RMGfxTargetBuffer::clearDirtyRects() { + Common::List::iterator i; + _previousDirtyRects.clear(); + for (i = _currentDirtyRects.begin(); i != _currentDirtyRects.end(); ++i) + _previousDirtyRects.push_back(*i); + + _currentDirtyRects.clear(); +} + +/** + * Merges any clipping rectangles that overlap to try and reduce + * the total number of clip rectangles. + */ +void RMGfxTargetBuffer::mergeDirtyRects() { + if (_dirtyRects.size() <= 1) + return; + + Common::List::iterator rOuter, rInner; + + for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) { + rInner = rOuter; + while (++rInner != _dirtyRects.end()) { + + if ((*rOuter).intersects(*rInner)) { + // these two rectangles overlap or + // are next to each other - merge them + + (*rOuter).extend(*rInner); + + // remove the inner rect from the list + _dirtyRects.erase(rInner); + + // move back to beginning of list + rInner = rOuter; + } + } + } +} /****************************************************************************\ * RMGfxSourceBufferPal Methods @@ -550,6 +611,9 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit buf += bufx - width; } } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(dst._x1, dst._y1, dst._x1 + width, dst._y1 + height)); } RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) @@ -660,7 +724,8 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim } } - return; + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(dst._x1, dst._y1, dst._x1 + width, dst._y1 + height)); } @@ -857,6 +922,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri buf += bigBuf.getDimx(); } } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } @@ -1709,6 +1777,9 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Skip to the next line buf += bigBuf.getDimx(); } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } @@ -1871,6 +1942,9 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi raw += _dimx; } } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + dimx, y1 + dimy)); } void RMGfxSourceBuffer16::prepareImage(void) { @@ -1922,6 +1996,9 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) uint16 *buf = bigBuf; RMRect rcDst; + // Specify the drawn area + bigBuf.addDirtyRect(rcDst); + // It takes the destination rectangle rcDst = prim->getDst(); buf += rcDst._y1 * bigBuf.getDimx() + rcDst._x1; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 9a00ed1646..82862d6846 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -112,11 +112,13 @@ public: _task = NULL; _src.setEmpty(); _dst.setEmpty(); + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task) { _task = task; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { @@ -132,6 +134,7 @@ public: _src.topLeft() = src; _dst = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { @@ -139,6 +142,7 @@ public: _src.topLeft() = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { @@ -146,6 +150,7 @@ public: _src = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { @@ -153,6 +158,7 @@ public: _dst = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { @@ -160,6 +166,7 @@ public: _dst.topLeft() = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } virtual ~RMGfxPrimitive() { } @@ -553,6 +560,10 @@ private: } }; + bool _trackDirtyRects; + Common::List _currentDirtyRects, _previousDirtyRects, _dirtyRects; + + void mergeDirtyRects(); private: // OSystem::MutexRef csModifyingOT; @@ -587,6 +598,17 @@ public: void offsetY(int nLines) { RMGfxBuffer::offsetY(nLines, 16); } + + // Dirty rect methods + void addDirtyRect(const Common::Rect &r); + Common::List &getDirtyRects(); + void clearDirtyRects(); + void setTrackDirtyRects(bool v) { + _trackDirtyRects = v; + } + bool getTrackDirtyRects() const { + return _trackDirtyRects; + } }; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index deae0cb641..3ea83a8867 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -63,6 +63,7 @@ RMGfxEngine::RMGfxEngine() { // Create big buffer where the frame will be rendered _bigBuf.create(RM_BBX, RM_BBY, 16); _bigBuf.offsetY(RM_SKIPY); + _bigBuf.setTrackDirtyRects(true); _csMainLoop = NULL; _nCurLoc = 0; @@ -475,8 +476,7 @@ void RMGfxEngine::init() { delete load; // Display 'Loading' screen - // TODO: The loading screen isn't currently optimal, since the game doesn't respond to events - // whilst the mpalInit code is being executed. + _bigBuf.addDirtyRect(Common::Rect(0, 0, RM_SX, RM_SY)); _vm->_window.getNewFrame(*this, NULL); _vm->_window.repaint(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 18c13d8d3d..1a37de98e1 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -109,8 +109,8 @@ public: void enableMouse(void); void disableMouse(void); - operator byte *() { - return (byte *)_bigBuf; + operator RMGfxTargetBuffer &() { + return _bigBuf; } RMInput &getInput() { return _input; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b2bf3b3565..26a13037c0 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -710,14 +710,13 @@ void RMItem::setStatus(int nStatus) { } void RMItem::setPattern(int nPattern, bool bPlayP0) { - int i; - assert(nPattern >= 0 && nPattern <= _nPatterns); - if (_sfx) + if (_sfx) { if (_nCurPattern > 0) _patterns[_nCurPattern].stopSfx(_sfx); - + } + // Remember the current pattern _nCurPattern = nPattern; @@ -728,10 +727,12 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { _nCurSprite = -1; // Look for the sound effect for pattern 0 - if (bPlayP0) - for (i = 0; i < _nSfx; i++) + if (bPlayP0) { + for (int i = 0; i < _nSfx; i++) { if (strcmp(_sfx[i]._name, "p0") == 0) _sfx[i].play(); + } + } } } @@ -783,6 +784,8 @@ RMItem::RMItem() { _bPal = 0; _nCurSprite = 0; + _bIsActive = false; + _hEndPattern = CoroScheduler.createEvent(false, false); } @@ -1933,6 +1936,8 @@ RMLocation::RMLocation() { _nItems = 0; _items = NULL; _buf = NULL; + _prevScroll.set(-1, -1); + _prevFixedScroll.set(-1, -1); } @@ -1967,11 +1972,8 @@ bool RMLocation::load(const char *lpszFileName) { * @returns True if succeeded OK, false in case of error. */ bool RMLocation::load(Common::File &file) { - int size; bool bRet; - // Get the file size - size = file.size(); file.seek(0); RMFileStreamSlow fs; @@ -2126,6 +2128,8 @@ bool RMLocation::loadLOX(RMDataStream &ds) { */ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; + bool priorTracking; + bool hasChanges; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2137,9 +2141,21 @@ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri prim->setDst(_fixedScroll); + // Check whether dirty rects are being tracked, and if there are changes, leave tracking + // turned on so a dirty rect will be added for the entire background + _ctx->priorTracking = bigBuf.getTrackDirtyRects(); + _ctx->hasChanges = (_prevScroll != _curScroll) || (_prevFixedScroll != _fixedScroll); + bigBuf.setTrackDirtyRects(_ctx->priorTracking && _ctx->hasChanges); + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(_buf->draw, bigBuf, prim); + if (_ctx->hasChanges) { + _prevScroll = _curScroll; + _prevFixedScroll = _fixedScroll; + } + bigBuf.setTrackDirtyRects(_ctx->priorTracking); + CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4231c99eab..944e206ae2 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -539,6 +539,9 @@ private: RMPoint _curScroll; // Current scroll position RMPoint _fixedScroll; + RMPoint _prevScroll; // Previous scroll position + RMPoint _prevFixedScroll; + public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b1e45c8bfa..28726f0a33 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -623,8 +623,9 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { if (!GLOBALS._gfxEngine) return Common::kUnknownError; + RMGfxTargetBuffer &bigBuf = *GLOBALS._gfxEngine; RMSnapshot s; - s.grabScreenshot(*GLOBALS._gfxEngine, 4, _curThumbnail); + s.grabScreenshot(bigBuf, 4, _curThumbnail); GLOBALS._gfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8e751a811a..f9c2622eb2 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -922,6 +922,10 @@ int RMRect::size() const { return width() * height(); } +RMRect::operator Common::Rect() const { + return Common::Rect(_x1, _y1, _x2, _y2); +} + bool RMRect::isEmpty() const { return (_x1 == 0 && _y1 == 0 && _x2 == 0 && _y2 == 0); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 33e2db7d7e..82c5bb020c 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -268,6 +268,7 @@ public: int height() const; bool isEmpty() const; int size() const; + operator Common::Rect() const; // Set void setRect(int x1, int y1, int x2, int y2); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index db21be0ded..bf0094ff2a 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -40,7 +40,6 @@ namespace Tony { \****************************************************************************/ RMWindow::RMWindow() { - } RMWindow::~RMWindow() { @@ -61,6 +60,7 @@ void RMWindow::init() { _bGrabScreenshot = false; _bGrabThumbnail = false; _bGrabMovie = false; + _wiping = false; } /** @@ -108,13 +108,29 @@ void RMWindow::wipeEffect(Common::Rect &rcBoundEllipse) { } } -void RMWindow::getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { +void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllipse) { + // Get a pointer to the bytes of the source buffer + byte *lpBuf = bigBuf; + if (rcBoundEllipse != NULL) { // Circular wipe effect getNewFrameWipe(lpBuf, *rcBoundEllipse); - } else { - // Standard screen copy + _wiping = true; + } else if (_wiping) { + // Just finished a wiping effect, so copy the full screen g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + _wiping = false; + + } else { + // Standard screen copy - iterate through the dirty rects + Common::List dirtyRects = bigBuf.getDirtyRects(); + Common::List::iterator i; + + for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { + Common::Rect &r = *i; + const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); + g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + } } if (_bGrabThumbnail) { @@ -124,6 +140,9 @@ void RMWindow::getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { s.grabScreenshot(lpBuf, 4, _wThumbBuf); _bGrabThumbnail = false; } + + // Clear the dirty rect list + bigBuf.clearDirtyRects(); } /** @@ -214,10 +233,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; - int u, v, curv; - uint32 k = 0; - int sommar, sommab, sommag; uint16 *cursrc; if (lpDestBuf == NULL) @@ -247,10 +263,11 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; + int sommar, sommab, sommag, curv; sommar = sommab = sommag = 0; - for (v = 0; v < dezoom; v++) { - for (u = 0; u < dezoom; u++) { + for (int v = 0; v < dezoom; v++) { + for (int u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else diff --git a/engines/tony/window.h b/engines/tony/window.h index 34f0c1cb51..6189dd391f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -64,6 +64,7 @@ protected: int lastsecond, lastfcount; int mskRed, mskGreen, mskBlue; + bool _wiping; bool _bGrabScreenshot; bool _bGrabThumbnail; @@ -90,7 +91,7 @@ public: void switchFullscreen(bool bFull) {} // Reads the next frame - void getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + void getNewFrame(RMGfxTargetBuffer &lpBuf, Common::Rect *rcBoundEllipse); // Request a thumbnail be grabbed during the next frame void grabThumbnail(uint16 *buf); -- cgit v1.2.3 From 3d4495d1ceb7e4e6fbb4dafa2df388804f2bf783 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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 37f772c2d7acf314fa1b347aae410daa1337edc2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 18:33:38 +1000 Subject: TONY: Bugfix for hanging after giving 'shrimp' to the parrot --- engines/tony/mpal/mpal.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 92ece3b0b4..7e1831ec4d 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1937,6 +1937,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { */ CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hAskChoice, CORO_INFINITE); + // WORKAROUND: Introduce a single frame delay so that if there are multiple actions running, + // they all have time to be signalled before resetting the event. This fixes a problem where + // if you try to use the 'shrimp' on the parrot a second time after trying to first use it + // whilst the parrot was talking, the cursor wouldn't be re-enabled afterwards + CORO_SLEEP(1); + CoroScheduler.resetEvent(GLOBALS._hAskChoice); if (GLOBALS._bExecutingDialog) -- cgit v1.2.3 From 638b06660141677421aa7a342a606b0e4e593389 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 11:09:08 +0200 Subject: TONY: Translate some Italian terms, rename enums --- engines/tony/custom.cpp | 420 +++++++++++++++++++++++----------------------- engines/tony/font.h | 10 +- engines/tony/game.cpp | 2 +- engines/tony/game.h | 26 +-- engines/tony/globals.cpp | 4 +- engines/tony/globals.h | 20 +-- engines/tony/inventory.h | 4 +- engines/tony/loc.h | 10 +- engines/tony/sound.h | 2 +- engines/tony/tony.h | 4 +- engines/tony/tonychar.cpp | 12 +- engines/tony/tonychar.h | 24 +-- 12 files changed, 267 insertions(+), 271 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index eea134e442..9acdc84932 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -92,7 +92,7 @@ const MusicFileEntry musicFiles[] = { }; -const char *staccFileNames[] = { +const char *jingleFileNames[] = { "S00.ADP", "S01.ADP", "S02.ADP", "S03.ADP", "S04.ADP", "S05.ADP", @@ -499,8 +499,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 n CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS._bNoOcchioDiBue = true; +DECLARE_CUSTOM_FUNCTION(NoBullsEye)(CORO_PARAM, uint32, uint32, uint32, uint32) { + GLOBALS._bNoBullsEye = true; } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -509,7 +509,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -531,7 +531,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -555,7 +555,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _vm->playMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true, 2000); } - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { GLOBALS.InitWipe(2); } @@ -564,12 +564,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _ctx->h = mpalQueryDoAction(0, nLoc, 0); - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { CORO_INVOKE_0(GLOBALS.WaitWipeEnd); GLOBALS.CloseWipe(); } - GLOBALS._bNoOcchioDiBue = false; + GLOBALS._bNoBullsEye = false; // On Enter? if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -1372,7 +1372,7 @@ DECLARE_CUSTOM_FUNCTION(AbortGame)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->abortGame(); } -DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; uint32 i; uint32 curTime; @@ -2131,7 +2131,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (!GLOBALS._bFadeOutStop) _vm->setMusicVolume(nChannel, 0); - // If there is a stacchetto, stop all + // If a jingle is played, stop it if (nChannel == 2) _vm->stopMusic(2); @@ -2142,55 +2142,51 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS._curSonoriz, sizeof(int)); +DECLARE_CUSTOM_FUNCTION(FadeInSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS._curSoundEffect, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = false; - CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS._curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS._curSoundEffect, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = false; int channel = 2; CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeInJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { int channel = 2; CoroScheduler.createProcess(ThreadFadeInMusic, &channel, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(GLOBALS._curSonoriz); +DECLARE_CUSTOM_FUNCTION(StopSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { + _vm->stopMusic(GLOBALS._curSoundEffect); } -DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->stopMusic(2); } -DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(GLOBALS._curSonoriz, 0); +DECLARE_CUSTOM_FUNCTION(MuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { + _vm->setMusicVolume(GLOBALS._curSoundEffect, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = true; - _vm->setMusicVolume(GLOBALS._curSonoriz, 64); + _vm->setMusicVolume(GLOBALS._curSoundEffect, 64); } -DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->setMusicVolume(2, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->setMusicVolume(2, 64); } - - - - void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; @@ -2199,18 +2195,18 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int debug("End CustPlayMusic"); } -DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { +DECLARE_CUSTOM_FUNCTION(PlaySoundEffect)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX == 2) { - debug("PlaySonoriz stop fadeout"); + debug("PlaySoundEffect stop fadeout"); GLOBALS._bFadeOutStop = true; } GLOBALS._lastMusic = nMusic; - CustPlayMusic(GLOBALS._curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); + CustPlayMusic(GLOBALS._curSoundEffect, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } -DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { - CustPlayMusic(2, staccFileNames[nMusic], nFX, bLoop); +DECLARE_CUSTOM_FUNCTION(PlayJingle)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { + CustPlayMusic(2, jingleFileNames[nMusic], nFX, bLoop); } DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { @@ -2230,7 +2226,7 @@ void RestoreMusic(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(PlaySonoriz, GLOBALS._lastMusic, 0, 0, 0); + CORO_INVOKE_4(PlaySoundEffect, GLOBALS._lastMusic, 0, 0, 0); if (GLOBALS._lastTappeto != 0) CustPlayMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true); @@ -2249,28 +2245,28 @@ void LoadMusic(Common::InSaveFile *f) { } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(JingleFadeStart)(CORO_PARAM, uint32 nJingle, uint32 bLoop, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(FadeOutSonoriz, 0, 0, 0, 0); - CORO_INVOKE_4(MuteStacchetto, 0, 0, 0, 0); - CORO_INVOKE_4(PlayStacchetto, nStacc, 0, bLoop, 0); - CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(FadeOutSoundEffect, 0, 0, 0, 0); + CORO_INVOKE_4(MuteJingle, 0, 0, 0, 0); + CORO_INVOKE_4(PlayJingle, nJingle, 0, bLoop, 0); + CORO_INVOKE_4(FadeInJingle, 0, 0, 0, 0); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(JingleFadeEnd)(CORO_PARAM, uint32 nJingle, uint32 bLoop, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(FadeOutStacchetto, 0, 0, 0, 0); - CORO_INVOKE_4(FadeInSonoriz, 0, 0, 0, 0); + CORO_INVOKE_4(FadeOutJingle, 0, 0, 0, 0); + CORO_INVOKE_4(FadeInSoundEffect, 0, 0, 0, 0); CORO_END_CODE; } @@ -2396,146 +2392,146 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 BEGIN_CUSTOM_FUNCTION_MAP() ASSIGN(1, CustLoadLocation) -ASSIGN(2, MySleep) +ASSIGN(2, MySleep) ASSIGN(3, SetPointer) ASSIGN(5, MoveTony) -ASSIGN(6, FaceToMe) -ASSIGN(7, BackToMe) -ASSIGN(8, LeftToMe) -ASSIGN(9, RightToMe) -ASSIGN(10, SendTonyMessage) -ASSIGN(11, ChangeBoxStatus) -ASSIGN(12, ChangeLocation) -ASSIGN(13, DisableTony) -ASSIGN(14, EnableTony) -ASSIGN(15, WaitForPatternEnd) -ASSIGN(16, SetLocStartPosition) -ASSIGN(17, ScrollLocation) -ASSIGN(18, MoveTonyAndWait) -ASSIGN(19, ChangeHotspot) -ASSIGN(20, AddInventory) -ASSIGN(21, RemoveInventory) -ASSIGN(22, ChangeInventoryStatus) -ASSIGN(23, SetTonyPosition) -ASSIGN(24, SendFullscreenMessage) -ASSIGN(25, SaveTonyPosition) -ASSIGN(26, RestoreTonyPosition) -ASSIGN(27, DisableInput) -ASSIGN(28, EnableInput) -ASSIGN(29, StopTony) - -ASSIGN(30, TonyTakeUp1) -ASSIGN(31, TonyTakeMid1) -ASSIGN(32, TonyTakeDown1) -ASSIGN(33, TonyTakeUp2) -ASSIGN(34, TonyTakeMid2) -ASSIGN(35, TonyTakeDown2) - -ASSIGN(72, TonyPutUp1) -ASSIGN(73, TonyPutMid1) -ASSIGN(74, TonyPutDown1) -ASSIGN(75, TonyPutUp2) -ASSIGN(76, TonyPutMid2) -ASSIGN(77, TonyPutDown2) - -ASSIGN(36, TonyOnTheFloor) -ASSIGN(37, TonyGetUp) -ASSIGN(38, TonyShepherdess) -ASSIGN(39, TonyWhistle) - -ASSIGN(40, TonyRide) -ASSIGN(41, TonyFianchi) -ASSIGN(42, TonySing) -ASSIGN(43, TonyIndicate) -ASSIGN(44, TonyScaredWithHands) -ASSIGN(49, TonyScaredWithoutHands) -ASSIGN(45, TonyWithGlasses) -ASSIGN(46, TonyWithWorm) -ASSIGN(47, TonyWithHammer) -ASSIGN(48, TonyWithRope) -ASSIGN(90, TonyWithRabbitANIM) -ASSIGN(91, TonyWithRecipeANIM) -ASSIGN(92, TonyWithCardsANIM) -ASSIGN(93, TonyWithSnowmanANIM) -ASSIGN(94, TonyWithSnowmanStart) -ASSIGN(95, TonyWithSnowmanEnd) -ASSIGN(96, TonyWithRabbitStart) -ASSIGN(97, TonyWithRabbitEnd) -ASSIGN(98, TonyWithRecipeStart) -ASSIGN(99, TonyWithRecipeEnd) -ASSIGN(100, TonyWithCardsStart) -ASSIGN(101, TonyWithCardsEnd) -ASSIGN(102, TonyWithNotebookStart) -ASSIGN(103, TonyWithNotebookEnd) -ASSIGN(104, TonyWithMegaphoneStart) -ASSIGN(105, TonyWithMegaphoneEnd) -ASSIGN(106, TonyWithBeardStart) -ASSIGN(107, TonyWithBeardEnd) -ASSIGN(108, TonyGiggle) -ASSIGN(109, TonyDisgusted) -ASSIGN(110, TonyNaah) -ASSIGN(111, TonyMacbeth) -ASSIGN(112, TonySniffLeft) -ASSIGN(113, TonySniffRight) -ASSIGN(114, TonyScaredStart) -ASSIGN(115, TonyScaredEnd) -ASSIGN(116, TonyWithSecretary) - -ASSIGN(50, CharSetCode) -ASSIGN(51, CharSetColor) -ASSIGN(52, CharSetTalkPattern) -ASSIGN(53, CharSendMessage) -ASSIGN(54, CharSetStartEndTalkPattern) - -ASSIGN(60, MCharSetCode) -ASSIGN(61, MCharSetColor) -ASSIGN(62, MCharSetCurrentGroup) -ASSIGN(63, MCharSetNumTalksInGroup) -ASSIGN(64, MCharSetNumTexts) -ASSIGN(65, MCharSendMessage) -ASSIGN(66, MCharSetPosition) -ASSIGN(67, MCharSetAlwaysBack) -ASSIGN(68, MCharResetCode) - -ASSIGN(70, StartDialog) -ASSIGN(71, SendDialogMessage) - -ASSIGN(80, TakeOwnership) -ASSIGN(81, ReleaseOwnership) - -ASSIGN(86, PlaySonoriz) -ASSIGN(87, PlayStacchetto) -ASSIGN(88, FadeInSonoriz) -ASSIGN(89, FadeOutSonoriz) -ASSIGN(123, FadeInStacchetto) -ASSIGN(124, FadeOutStacchetto) -ASSIGN(125, MuteSonoriz) -ASSIGN(126, DemuteSonoriz) -ASSIGN(127, MuteStacchetto) -ASSIGN(128, DemuteStacchetto) -ASSIGN(84, StopSonoriz) -ASSIGN(85, StopStacchetto) -ASSIGN(83, PlayItemSfx) -ASSIGN(129, StacchettoFadeStart) -ASSIGN(130, StacchettoFadeEnd) - -ASSIGN(120, TremaSchermo) -ASSIGN(121, AutoSave) -ASSIGN(122, AbortGame) -ASSIGN(131, NoOcchioDiBue) -ASSIGN(132, SendFullscreenMsgStart) -ASSIGN(133, SendFullscreenMsgEnd) -ASSIGN(134, CustEnableGUI) -ASSIGN(135, CustDisableGUI) -ASSIGN(136, ClearScreen) -ASSIGN(137, PatIrqFreeze) -ASSIGN(138, TonySetPerorate) -ASSIGN(139, OpenInitLoadMenu) -ASSIGN(140, OpenInitOptions) -ASSIGN(141, SyncScrollLocation) -ASSIGN(142, CloseLocation) -ASSIGN(143, SetAlwaysDisplay) -ASSIGN(144, DoCredits) +ASSIGN(6, FaceToMe) +ASSIGN(7, BackToMe) +ASSIGN(8, LeftToMe) +ASSIGN(9, RightToMe) +ASSIGN(10, SendTonyMessage) +ASSIGN(11, ChangeBoxStatus) +ASSIGN(12, ChangeLocation) +ASSIGN(13, DisableTony) +ASSIGN(14, EnableTony) +ASSIGN(15, WaitForPatternEnd) +ASSIGN(16, SetLocStartPosition) +ASSIGN(17, ScrollLocation) +ASSIGN(18, MoveTonyAndWait) +ASSIGN(19, ChangeHotspot) +ASSIGN(20, AddInventory) +ASSIGN(21, RemoveInventory) +ASSIGN(22, ChangeInventoryStatus) +ASSIGN(23, SetTonyPosition) +ASSIGN(24, SendFullscreenMessage) +ASSIGN(25, SaveTonyPosition) +ASSIGN(26, RestoreTonyPosition) +ASSIGN(27, DisableInput) +ASSIGN(28, EnableInput) +ASSIGN(29, StopTony) + +ASSIGN(30, TonyTakeUp1) +ASSIGN(31, TonyTakeMid1) +ASSIGN(32, TonyTakeDown1) +ASSIGN(33, TonyTakeUp2) +ASSIGN(34, TonyTakeMid2) +ASSIGN(35, TonyTakeDown2) + +ASSIGN(72, TonyPutUp1) +ASSIGN(73, TonyPutMid1) +ASSIGN(74, TonyPutDown1) +ASSIGN(75, TonyPutUp2) +ASSIGN(76, TonyPutMid2) +ASSIGN(77, TonyPutDown2) + +ASSIGN(36, TonyOnTheFloor) +ASSIGN(37, TonyGetUp) +ASSIGN(38, TonyShepherdess) +ASSIGN(39, TonyWhistle) + +ASSIGN(40, TonyRide) +ASSIGN(41, TonyFianchi) +ASSIGN(42, TonySing) +ASSIGN(43, TonyIndicate) +ASSIGN(44, TonyScaredWithHands) +ASSIGN(49, TonyScaredWithoutHands) +ASSIGN(45, TonyWithGlasses) +ASSIGN(46, TonyWithWorm) +ASSIGN(47, TonyWithHammer) +ASSIGN(48, TonyWithRope) +ASSIGN(90, TonyWithRabbitANIM) +ASSIGN(91, TonyWithRecipeANIM) +ASSIGN(92, TonyWithCardsANIM) +ASSIGN(93, TonyWithSnowmanANIM) +ASSIGN(94, TonyWithSnowmanStart) +ASSIGN(95, TonyWithSnowmanEnd) +ASSIGN(96, TonyWithRabbitStart) +ASSIGN(97, TonyWithRabbitEnd) +ASSIGN(98, TonyWithRecipeStart) +ASSIGN(99, TonyWithRecipeEnd) +ASSIGN(100, TonyWithCardsStart) +ASSIGN(101, TonyWithCardsEnd) +ASSIGN(102, TonyWithNotebookStart) +ASSIGN(103, TonyWithNotebookEnd) +ASSIGN(104, TonyWithMegaphoneStart) +ASSIGN(105, TonyWithMegaphoneEnd) +ASSIGN(106, TonyWithBeardStart) +ASSIGN(107, TonyWithBeardEnd) +ASSIGN(108, TonyGiggle) +ASSIGN(109, TonyDisgusted) +ASSIGN(110, TonyNaah) +ASSIGN(111, TonyMacbeth) +ASSIGN(112, TonySniffLeft) +ASSIGN(113, TonySniffRight) +ASSIGN(114, TonyScaredStart) +ASSIGN(115, TonyScaredEnd) +ASSIGN(116, TonyWithSecretary) + +ASSIGN(50, CharSetCode) +ASSIGN(51, CharSetColor) +ASSIGN(52, CharSetTalkPattern) +ASSIGN(53, CharSendMessage) +ASSIGN(54, CharSetStartEndTalkPattern) + +ASSIGN(60, MCharSetCode) +ASSIGN(61, MCharSetColor) +ASSIGN(62, MCharSetCurrentGroup) +ASSIGN(63, MCharSetNumTalksInGroup) +ASSIGN(64, MCharSetNumTexts) +ASSIGN(65, MCharSendMessage) +ASSIGN(66, MCharSetPosition) +ASSIGN(67, MCharSetAlwaysBack) +ASSIGN(68, MCharResetCode) + +ASSIGN(70, StartDialog) +ASSIGN(71, SendDialogMessage) + +ASSIGN(80, TakeOwnership) +ASSIGN(81, ReleaseOwnership) + +ASSIGN(86, PlaySoundEffect) +ASSIGN(87, PlayJingle) +ASSIGN(88, FadeInSoundEffect) +ASSIGN(89, FadeOutSoundEffect) +ASSIGN(123, FadeInJingle) +ASSIGN(124, FadeOutJingle) +ASSIGN(125, MuteSoundEffect) +ASSIGN(126, DemuteSoundEffect) +ASSIGN(127, MuteJingle) +ASSIGN(128, DemuteJingle) +ASSIGN(84, StopSoundEffect) +ASSIGN(85, StopJingle) +ASSIGN(83, PlayItemSfx) +ASSIGN(129, JingleFadeStart) +ASSIGN(130, JingleFadeEnd) + +ASSIGN(120, ShakeScreen) +ASSIGN(121, AutoSave) +ASSIGN(122, AbortGame) +ASSIGN(131, NoBullsEye) +ASSIGN(132, SendFullscreenMsgStart) +ASSIGN(133, SendFullscreenMsgEnd) +ASSIGN(134, CustEnableGUI) +ASSIGN(135, CustDisableGUI) +ASSIGN(136, ClearScreen) +ASSIGN(137, PatIrqFreeze) +ASSIGN(138, TonySetPerorate) +ASSIGN(139, OpenInitLoadMenu) +ASSIGN(140, OpenInitOptions) +ASSIGN(141, SyncScrollLocation) +ASSIGN(142, CloseLocation) +ASSIGN(143, SetAlwaysDisplay) +ASSIGN(144, DoCredits) ASSIGN(200, MustSkipIdleStart); ASSIGN(201, MustSkipIdleEnd); @@ -2573,37 +2569,37 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation for (i = 0; i < 200; i++) GLOBALS._tappeti[i] = 0; - GLOBALS._tappeti[6] = T_GRILLI; - GLOBALS._tappeti[7] = T_GRILLI; - GLOBALS._tappeti[8] = T_GRILLIOV; - GLOBALS._tappeti[10] = T_GRILLI; - GLOBALS._tappeti[12] = T_GRILLI; - GLOBALS._tappeti[13] = T_GRILLIOV; - GLOBALS._tappeti[15] = T_GRILLI; - GLOBALS._tappeti[16] = T_GRILLIVENTO; - GLOBALS._tappeti[18] = T_GRILLI; - GLOBALS._tappeti[19] = T_GRILLIVENTO; - GLOBALS._tappeti[20] = T_GRILLI; - GLOBALS._tappeti[23] = T_GRILLI; - GLOBALS._tappeti[26] = T_MAREMETA; - GLOBALS._tappeti[27] = T_GRILLI; - GLOBALS._tappeti[28] = T_GRILLIVENTO; - GLOBALS._tappeti[31] = T_GRILLI; - GLOBALS._tappeti[33] = T_MARE; - GLOBALS._tappeti[35] = T_MARE; - GLOBALS._tappeti[36] = T_GRILLI; - GLOBALS._tappeti[37] = T_GRILLI; - GLOBALS._tappeti[40] = T_GRILLI; - GLOBALS._tappeti[41] = T_GRILLI; - GLOBALS._tappeti[42] = T_GRILLI; - GLOBALS._tappeti[45] = T_GRILLI; - GLOBALS._tappeti[51] = T_GRILLI; - GLOBALS._tappeti[52] = T_GRILLIVENTO1; - GLOBALS._tappeti[53] = T_GRILLI; - GLOBALS._tappeti[54] = T_GRILLI; - GLOBALS._tappeti[57] = T_VENTO; - GLOBALS._tappeti[58] = T_VENTO; - GLOBALS._tappeti[60] = T_VENTO; + GLOBALS._tappeti[6] = TAPPETI_GRILLI; + GLOBALS._tappeti[7] = TAPPETI_GRILLI; + GLOBALS._tappeti[8] = TAPPETI_GRILLIOV; + GLOBALS._tappeti[10] = TAPPETI_GRILLI; + GLOBALS._tappeti[12] = TAPPETI_GRILLI; + GLOBALS._tappeti[13] = TAPPETI_GRILLIOV; + GLOBALS._tappeti[15] = TAPPETI_GRILLI; + GLOBALS._tappeti[16] = TAPPETI_GRILLIVENTO; + GLOBALS._tappeti[18] = TAPPETI_GRILLI; + GLOBALS._tappeti[19] = TAPPETI_GRILLIVENTO; + GLOBALS._tappeti[20] = TAPPETI_GRILLI; + GLOBALS._tappeti[23] = TAPPETI_GRILLI; + GLOBALS._tappeti[26] = TAPPETI_MAREMETA; + GLOBALS._tappeti[27] = TAPPETI_GRILLI; + GLOBALS._tappeti[28] = TAPPETI_GRILLIVENTO; + GLOBALS._tappeti[31] = TAPPETI_GRILLI; + GLOBALS._tappeti[33] = TAPPETI_MARE; + GLOBALS._tappeti[35] = TAPPETI_MARE; + GLOBALS._tappeti[36] = TAPPETI_GRILLI; + GLOBALS._tappeti[37] = TAPPETI_GRILLI; + GLOBALS._tappeti[40] = TAPPETI_GRILLI; + GLOBALS._tappeti[41] = TAPPETI_GRILLI; + GLOBALS._tappeti[42] = TAPPETI_GRILLI; + GLOBALS._tappeti[45] = TAPPETI_GRILLI; + GLOBALS._tappeti[51] = TAPPETI_GRILLI; + GLOBALS._tappeti[52] = TAPPETI_GRILLIVENTO1; + GLOBALS._tappeti[53] = TAPPETI_GRILLI; + GLOBALS._tappeti[54] = TAPPETI_GRILLI; + GLOBALS._tappeti[57] = TAPPETI_VENTO; + GLOBALS._tappeti[58] = TAPPETI_VENTO; + GLOBALS._tappeti[60] = TAPPETI_VENTO; diff --git a/engines/tony/font.h b/engines/tony/font.h index 328d501e27..f24223d551 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -178,22 +178,22 @@ private: int _maxLineLength; public: - enum HORALIGN { + enum HorAlign { HLEFT, HLEFTPAR, HCENTER, HRIGHT }; - enum VERALIGN { + enum VerAlign { VTOP, VCENTER, VBOTTOM }; private: - HORALIGN _aHorType; - VERALIGN _aVerType; + HorAlign _aHorType; + VerAlign _aVerType; byte _textR, _textG, _textB; protected: @@ -206,7 +206,7 @@ public: static void unload(); // Set the alignment type - void setAlignType(HORALIGN aHor, VERALIGN aVer) { + void setAlignType(HorAlign aHor, VerAlign aVer) { _aHorType = aHor; _aVerType = aVer; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 03479d96a5..cca55f00dd 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1003,7 +1003,7 @@ int RMOptionScreen::priority() { return 190; } -void RMOptionScreen::changeState(CORO_PARAM, STATE newState) { +void RMOptionScreen::changeState(CORO_PARAM, OptionScreenState newState) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); diff --git a/engines/tony/game.h b/engines/tony/game.h index 9ac8f76bcc..bd15b962e6 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -70,7 +70,7 @@ private: void updateCursor(); public: - enum POINTER { + enum PointerType { PTR_NONE = 0, PTR_FRECCIASU, PTR_FRECCIAGIU, @@ -107,15 +107,15 @@ public: } // Sets a new pointer - void setSpecialPointer(POINTER ptr) { + void setSpecialPointer(PointerType ptr) { _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) _specialPointer[ptr - 1]->setPattern(1); updateCursor(); } - POINTER getSpecialPointer(void) { - return (POINTER)_nCurSpecialPointer; + PointerType getSpecialPointer(void) { + return (PointerType)_nCurSpecialPointer; } // Set the new custom pointer @@ -251,17 +251,17 @@ private: bool _bNoLoadSave; bool _bAlterGfx; - enum STATE { - MENUGAME, - MENUGFX, - MENUSOUND, - MENULOAD, - MENUSAVE, + enum OptionScreenState { + MENUGAME, + MENUGFX, + MENUSOUND, + MENULOAD, + MENUSAVE, MENUNONE }; - STATE _nState; - STATE _nLastState; + OptionScreenState _nState; + OptionScreenState _nLastState; public: RMOptionScreen(); @@ -291,7 +291,7 @@ protected: // Initialisation and state change void initState(CORO_PARAM); void closeState(void); - void changeState(CORO_PARAM, STATE newState); + void changeState(CORO_PARAM, OptionScreenState newState); // Repaint the options menu void refreshAll(CORO_PARAM); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 45ab5f8722..9115dafd63 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -80,9 +80,9 @@ Globals::Globals() { _nCfgSFXVolume = 0; _bIdleExited = false; _bSkipSfxNoLoop = false; - _bNoOcchioDiBue = false; + _bNoBullsEye = false; _curDialog = 0; - _curSonoriz = 0; + _curSoundEffect = 0; _bFadeOutStop = false; // OSystem::MutexRef vdb; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 2301e621aa..33ed36751a 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -35,13 +35,13 @@ namespace Tony { -#define T_GRILLI 1 -#define T_GRILLIOV 2 -#define T_GRILLIVENTO 3 -#define T_GRILLIVENTO1 4 -#define T_VENTO 5 -#define T_MARE 6 -#define T_MAREMETA 7 +#define TAPPETI_GRILLI 1 +#define TAPPETI_GRILLIOV 2 +#define TAPPETI_GRILLIVENTO 3 +#define TAPPETI_GRILLIVENTO1 4 +#define TAPPETI_VENTO 5 +#define TAPPETI_MARE 6 +#define TAPPETI_MAREMETA 7 #define MAX_PATH 255 @@ -207,9 +207,9 @@ public: int _nCfgSFXVolume; bool _bSkipSfxNoLoop; bool _bIdleExited; - bool _bNoOcchioDiBue; + bool _bNoBullsEye; int _curDialog; - int _curSonoriz; + int _curSoundEffect; bool _bFadeOutStop; RMTony *_tony; @@ -237,7 +237,7 @@ public: uint32 _dwTonyNumTexts; bool _bTonyInTexts; bool _bStaticTalk; - RMTony::TALKTYPE _nTonyNextTalkType; + RMTony::CharacterTalkType _nTonyNextTalkType; RMPoint _startLocPos[256]; uint32 _mut[10]; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index b739e16f72..e010a09dd5 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -46,7 +46,7 @@ struct RMInventoryItem { class RMInventory : public RMGfxWoodyBuffer { private: - enum STATE { + enum InventoryState { CLOSED, OPENING, OPENED, @@ -64,7 +64,7 @@ protected: uint32 _curPutTime; int _curPos; - STATE _state; + InventoryState _state; bool _bHasFocus; int _nSelectObj; int _nCombine; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4231c99eab..00fcb579c8 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -314,7 +314,7 @@ protected: class RMBox { public: - struct T_HOTSPOT { + struct Hotspot { int _hotx, _hoty; // Hotspot coordinates int _destination; // Hotspot destination }; @@ -324,7 +324,7 @@ public: int _adj[MAXBOXES]; // List of adjacent bounding boxes int _numHotspot; // Hotspot number uint8 _destZ; // Z value for the bounding box - T_HOTSPOT _hotspot[MAXHOTSPOT]; // List of hotspots + Hotspot _hotspot[MAXHOTSPOT]; // List of hotspots bool _bActive; bool _bReversed; @@ -388,7 +388,7 @@ public: class RMCharacter : protected RMItem { public: - enum PATTERNS { + enum Patterns { PAT_STANDUP = 1, PAT_STANDDOWN, PAT_STANDLEFT, @@ -400,7 +400,7 @@ public: }; private: - enum STATUS { + enum CharacterStatus { STAND, WALK }; @@ -416,7 +416,7 @@ private: short _pathLength, _pathCount; int _curBox; - STATUS _status; + CharacterStatus _status; int _curSpeed; bool _bEndOfPath; uint32 _hEndOfPath; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 24e7f34921..abd7e06cae 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -44,7 +44,7 @@ namespace Tony { class FPSTREAM; class FPSFX; -enum CODECS { +enum SoundCodecs { FPCODEC_RAW, FPCODEC_ADPCM }; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 43bc23c636..8df2da697c 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -104,7 +104,7 @@ public: Globals _globals; Debugger *_debugger; - enum DATADIR { + enum DataDir { DD_BASE = 1, DD_SAVE, DD_SHOTS, @@ -161,7 +161,7 @@ public: void close(); void abortGame(); - void getDataDirectory(DATADIR dir, char *path); + void getDataDirectory(DataDir dir, char *path); void switchFullscreen(bool bFull); void optionScreen(void); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 0f16bc45c3..17f046fb92 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -550,7 +550,7 @@ void RMTony::put(int nWhere, int nPart) { } -bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, +bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat) { assert(!_bIsTalking); @@ -1109,7 +1109,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body return true; } -void RMTony::startTalk(CORO_PARAM, TALKTYPE nTalkType) { +void RMTony::startTalk(CORO_PARAM, CharacterTalkType nTalkType) { CORO_BEGIN_CONTEXT; int headStartPat, bodyStartPat; int headLoopPat, bodyLoopPat; @@ -1518,7 +1518,7 @@ void RMTony::endTalk(CORO_PARAM) { CORO_END_CODE; } -void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, +void RMTony::startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat) { int nPat = getCurPattern(); @@ -1725,7 +1725,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat } } -void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::startStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_BEGIN_CONTEXT; int headPat, headLoopPat; int bodyStartPat, bodyLoopPat; @@ -1760,7 +1760,7 @@ void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { } -void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { +void RMTony::endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { switch (_talkDirection) { case UP: case LEFT: @@ -1896,7 +1896,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } } -void RMTony::endStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::endStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_BEGIN_CONTEXT; int bodyEndPat; int finalPat; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index e5231d89fd..203d391fbe 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -36,12 +36,12 @@ namespace Tony { class RMTony : public RMCharacter { private: - enum DIRECTION { + enum CharacterDirection { UP, DOWN, LEFT, RIGHT }; public: - enum TALKTYPE { + enum CharacterTalkType { TALK_NORMAL, TALK_FIANCHI, TALK_SING, @@ -97,8 +97,8 @@ private: bool _bIsStaticTalk; bool _bIsTalking; int _nPatB4Talking; - TALKTYPE _nTalkType; - DIRECTION _talkDirection; + CharacterTalkType _nTalkType; + CharacterDirection _talkDirection; RMPoint _nBodyOffset; int _nTimeLastStep; @@ -114,7 +114,7 @@ protected: static void waitEndOfAction(CORO_PARAM, const void *param); public: - enum PATTERNS { + enum CharacterPatterns { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, PAT_TAKEUP_MID1, @@ -247,7 +247,7 @@ public: PAT_WITHSECRETARY }; - enum BODYPATTERNS { + enum CharacterBodyPatterns { BPAT_STANDUP = 1, BPAT_STANDDOWN, BPAT_STANDLEFT, @@ -421,18 +421,18 @@ public: void put(int nWhere, int nPart); // Start or End Talk - bool startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + bool startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); - void startTalk(CORO_PARAM, TALKTYPE nTalkType); + void startTalk(CORO_PARAM, CharacterTalkType nTalkType); bool endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void endTalk(CORO_PARAM); // Start or End Static - void startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + void startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); - void startStatic(CORO_PARAM, TALKTYPE nTalkType); - void endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); - void endStatic(CORO_PARAM, TALKTYPE nTalkType); + void startStatic(CORO_PARAM, CharacterTalkType nTalkType); + void endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); + void endStatic(CORO_PARAM, CharacterTalkType nTalkType); // Tony disguises himself! void setShepherdess(bool bIsPast) { -- cgit v1.2.3 From ddd1414a56568d62348e56ccc907b8ba7bb296eb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 11:32:50 +0200 Subject: TONY: Rename sound functions and class names --- engines/tony/custom.cpp | 72 +++++++++++---------- engines/tony/loc.cpp | 14 ++-- engines/tony/loc.h | 2 +- engines/tony/sound.cpp | 165 +++++++++++++++++++++++++----------------------- engines/tony/sound.h | 152 ++++++++++++++++++++++---------------------- engines/tony/tony.cpp | 54 ++++++++-------- engines/tony/tony.h | 12 ++-- 7 files changed, 239 insertions(+), 232 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 9acdc84932..ef4f889a12 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -253,7 +253,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX int i; int curOffset; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; RMTextDialog text; CORO_END_CONTEXT(_ctx); @@ -276,12 +276,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // First time allocation _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); - _ctx->voice->SetLoop(false); + _ctx->voice->setLoop(false); } if (GLOBALS._nTonyNextTalkType != GLOBALS._tony->TALK_NORMAL) { @@ -330,16 +330,16 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (_ctx->curVoc) { if (_ctx->i == 0) { - _ctx->voice->Play(); + _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.CreateSfx(&_ctx->voice); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); - _ctx->voice->SetLoop(false); - _ctx->voice->Play(); + _ctx->voice->setLoop(false); + _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } } @@ -349,8 +349,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX CORO_INVOKE_0(_ctx->text.waitForEndDisplay); if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } } @@ -1458,7 +1458,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess RMTextDialog *text; int curOffset; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1524,12 +1524,12 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_theSound.createSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - _ctx->voice->SetLoop(false); - if (bIsBack) _ctx->voice->SetVolume(55); - _ctx->voice->Play(); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->setLoop(false); + if (bIsBack) _ctx->voice->setVolume(55); + _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1539,8 +1539,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } @@ -1662,7 +1662,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes RMTextDialog *text; int curOffset; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1737,12 +1737,13 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_theSound.createSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - _ctx->voice->SetLoop(false); - if (bIsBack) _ctx->voice->SetVolume(55); - _ctx->voice->Play(); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->setLoop(false); + if (bIsBack) + _ctx->voice->setVolume(55); + _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1752,8 +1753,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } @@ -1787,7 +1788,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg uint32 h; bool bIsBack; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; RMPoint pt; CORO_END_CONTEXT(_ctx); @@ -1805,10 +1806,11 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first _vm->_vdbFP.seek(_ctx->curVoc->_offset); - _vm->_theSound.CreateSfx(&_ctx->voice); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - _ctx->voice->SetLoop(false); - if (_ctx->bIsBack) _ctx->voice->SetVolume(55); + _vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->setLoop(false); + if (_ctx->bIsBack) + _ctx->voice->setVolume(55); } _ctx->string = mpalQueryDialogPeriod(nMsg); @@ -1904,7 +1906,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _ctx->voice->Play(); + _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } @@ -1914,8 +1916,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 42c96076f9..d36c004baf 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -409,7 +409,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { // Create the sound effect _fx = _vm->createSFX(stream); - _fx->SetLoop(false); + _fx->setLoop(false); } RMSfx::RMSfx() { @@ -419,15 +419,15 @@ RMSfx::RMSfx() { RMSfx::~RMSfx() { if (_fx) { - _fx->Release(); + _fx->release(); _fx = NULL; } } void RMSfx::play(bool bLoop) { if (_fx && !_bPlayingLoop) { - _fx->SetLoop(bLoop); - _fx->Play(); + _fx->setLoop(bLoop); + _fx->play(); if (bLoop) _bPlayingLoop = true; @@ -436,19 +436,19 @@ void RMSfx::play(bool bLoop) { void RMSfx::setVolume(int vol) { if (_fx) { - _fx->SetVolume(vol); + _fx->setVolume(vol); } } void RMSfx::pause(bool bPause) { if (_fx) { - _fx->Pause(bPause); + _fx->pause(bPause); } } void RMSfx::stop(void) { if (_fx) { - _fx->Stop(); + _fx->stop(); _bPlayingLoop = false; } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 00fcb579c8..ac0bb1d69a 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -72,7 +72,7 @@ public: class RMSfx { public: RMString _name; - FPSFX *_fx; + FPSfx *_fx; bool _bPlayingLoop; public: diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index b3bdd1be9a..35db3ced38 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -41,28 +41,28 @@ namespace Tony { * Defines \****************************************************************************/ -#define RELEASE(x) {if ((x) != NULL) { (x)->Release(); x = NULL; }} +#define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} /****************************************************************************\ -* Metodi per FPSOUND +* Metodi per FPSound \****************************************************************************/ /****************************************************************************\ * -* Function: FPSOUND::FPSOUND(); +* Function: FPSound::FPSound(); * * Description: Costruttore di default. Inizializza gli attributi. * \****************************************************************************/ -FPSOUND::FPSOUND() { +FPSound::FPSound() { bSoundSupported = false; } /****************************************************************************\ * -* Function: bool FPSOUND::Init(); +* Function: bool FPSound::Init(); * * Description: Inizializza l'oggetto, e prepara tutto il necessario per * creare stream e effetti sonori. @@ -71,7 +71,7 @@ FPSOUND::FPSOUND() { * \****************************************************************************/ -bool FPSOUND::Init() { +bool FPSound::init() { bSoundSupported = g_system->getMixer()->isReady(); return bSoundSupported; } @@ -79,40 +79,40 @@ bool FPSOUND::Init() { /****************************************************************************\ * -* Function: FPSOUND::~FPSOUND(); +* Function: FPSound::~FPSound(); * * Description: Deinizializza l'oggetto, disallocando la memoria. * \****************************************************************************/ -FPSOUND::~FPSOUND() { +FPSound::~FPSound() { } /****************************************************************************\ * -* Function: bool CreateStream(FPSTREAM** lplpStream); +* Function: bool CreateStream(FPStream** lplpStream); * -* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* Description: Alloca un oggetti di tipo FPStream, e ritorna il suo * puntatore dopo averlo inizializzato. * -* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* Input: FPStream** lplpStream Conterra' il pointer all'oggetto * appena creato. * * Return: true se tutto OK, false in caso di errore * * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPSTREAM -* e FPSFX richiedono che DirectSound sia gia' stato +* sono dovute al fatto che i costruttori delle classi FPStream +* e FPSfx richiedono che DirectSound sia gia' stato * inzializzato. In questo modo quindi si evitano dei bugs * che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* di tipo FPStream o FPSfx globale (o cmq prima della * inizializzazione di DirectSound). * \****************************************************************************/ -bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { - (*lplpStream) = new FPSTREAM(bSoundSupported); +bool FPSound::createStream(FPStream **lplpStream) { + (*lplpStream) = new FPStream(bSoundSupported); return (*lplpStream != NULL); } @@ -121,12 +121,12 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { /****************************************************************************\ * -* Function: bool CreateSfx(FPSFX** lplpSfx); +* Function: bool CreateSfx(FPSfx** lplpSfx); * -* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* Description: Alloca un oggetti di tipo FPSfx e ritorna il suo * puntatore dopo averlo inizializzato. * -* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* Input: FPSfx** lplpSfx Conterra' il pointer all'oggetto * appena creato. * * Return: true se tutto OK, false in caso di errore @@ -135,8 +135,8 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { * \****************************************************************************/ -bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { - (*lplpSfx) = new FPSFX(bSoundSupported); +bool FPSound::createSfx(FPSfx **lplpSfx) { + (*lplpSfx) = new FPSfx(bSoundSupported); return (*lplpSfx != NULL); } @@ -153,7 +153,7 @@ bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { * \****************************************************************************/ -void FPSOUND::SetMasterVolume(int dwVolume) { +void FPSound::setMasterVolume(int dwVolume) { if (!bSoundSupported) return; @@ -171,7 +171,7 @@ void FPSOUND::SetMasterVolume(int dwVolume) { * \****************************************************************************/ -void FPSOUND::GetMasterVolume(int *lpdwVolume) { +void FPSound::getMasterVolume(int *lpdwVolume) { if (!bSoundSupported) return; @@ -180,19 +180,19 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { /****************************************************************************\ -* Metodi di FPSFX +* Metodi di FPSfx \****************************************************************************/ /****************************************************************************\ * -* Function: FPSFX(bool bSoundOn); +* Function: FPSfx(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() +* un oggetto, ma crearlo piuttosto tramite FPSound::CreateSfx() * \****************************************************************************/ -FPSFX::FPSFX(bool bSoundOn) { +FPSfx::FPSfx(bool bSoundOn) { bSoundSupported = bSoundOn; bFileLoaded = false; lastVolume = 63; @@ -208,7 +208,7 @@ FPSFX::FPSFX(bool bSoundOn) { /****************************************************************************\ * -* Function: ~FPSFX(); +* Function: ~FPSfx(); * * Description: Distruttore di default. Si preoccupa anche di fermare il sound * effect eventualmente in esecuzione, e disallocare la memoria @@ -216,7 +216,7 @@ FPSFX::FPSFX(bool bSoundOn) { * \****************************************************************************/ -FPSFX::~FPSFX() { +FPSfx::~FPSfx() { if (!bSoundSupported) return; @@ -240,14 +240,14 @@ FPSFX::~FPSFX() { * * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). +* creato con la FPSound::CreateStream(). * * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo * questa chiamata. * \****************************************************************************/ -void FPSFX::Release() { +void FPSfx::release() { delete this; } @@ -267,7 +267,7 @@ void FPSFX::Release() { * \****************************************************************************/ -bool FPSFX::loadWave(Common::SeekableReadStream *stream) { +bool FPSfx::loadWave(Common::SeekableReadStream *stream) { if (!stream) return false; @@ -277,7 +277,7 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { return false; bFileLoaded = true; - SetVolume(lastVolume); + setVolume(lastVolume); return true; } @@ -296,7 +296,7 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { * \****************************************************************************/ -bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { +bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { if (!bSoundSupported) return true; @@ -307,23 +307,23 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); bFileLoaded = true; - SetVolume(62); + setVolume(62); return true; } -bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { +bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { if (!bSoundSupported) return true; Common::File file; if (!file.open(lpszFileName)) { - warning("FPSFX::LoadFile(): Cannot open sfx file!"); + warning("FPSfx::LoadFile(): Cannot open sfx file!"); return false; } if (file.readUint32BE() != MKTAG('A', 'D', 'P', 0x10)) { - warning("FPSFX::LoadFile(): Invalid ADP header!"); + warning("FPSfx::LoadFile(): Invalid ADP header!"); return false; } @@ -358,8 +358,8 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { * \****************************************************************************/ -bool FPSFX::Play() { - Stop(); // sanity check +bool FPSfx::play() { + stop(); // sanity check if (bFileLoaded) { // FIXME @@ -380,7 +380,7 @@ bool FPSFX::Play() { g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - SetVolume(lastVolume); + setVolume(lastVolume); if (bPaused) g_system->getMixer()->pauseHandle(_handle, true); @@ -400,7 +400,7 @@ bool FPSFX::Play() { * \****************************************************************************/ -bool FPSFX::Stop() { +bool FPSfx::stop() { if (bFileLoaded) { g_system->getMixer()->stopHandle(_handle); bPaused = false; @@ -427,11 +427,11 @@ bool FPSFX::Stop() { * \****************************************************************************/ -void FPSFX::SetLoop(bool bLop) { +void FPSfx::setLoop(bool bLop) { bLoop = bLop; } -void FPSFX::Pause(bool bPause) { +void FPSfx::pause(bool bPause) { if (bFileLoaded) { if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ bPaused)) g_system->getMixer()->pauseHandle(_handle, bPause); @@ -451,23 +451,28 @@ void FPSFX::Pause(bool bPause) { * \****************************************************************************/ -void FPSFX::SetVolume(int dwVolume) { - if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; +void FPSfx::setVolume(int dwVolume) { + if (dwVolume > 63) + dwVolume = 63; + if (dwVolume < 0) + dwVolume = 0; lastVolume = dwVolume; if (bIsVoice) { - if (!GLOBALS._bCfgDubbing) dwVolume = 0; + if (!GLOBALS._bCfgDubbing) + dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } else { - if (!GLOBALS._bCfgSFX) dwVolume = 0; + if (!GLOBALS._bCfgSFX) + dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgSFXVolume) * 2; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) + dwVolume = 0; } } @@ -488,7 +493,7 @@ void FPSFX::SetVolume(int dwVolume) { * \****************************************************************************/ -void FPSFX::GetVolume(int *lpdwVolume) { +void FPSfx::getVolume(int *lpdwVolume) { if (g_system->getMixer()->isSoundHandleActive(_handle)) *lpdwVolume = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume; else @@ -498,7 +503,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { /** * Returns true if the underlying sound has ended */ -bool FPSFX::endOfBuffer() const { +bool FPSfx::endOfBuffer() const { return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_rewindableStream || _rewindableStream->endOfData()); } @@ -506,9 +511,9 @@ bool FPSFX::endOfBuffer() const { * Continually checks to see if active sounds have finished playing * Sets the event signalling the sound has ended */ -void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { +void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - Common::List::iterator i; + Common::List::iterator i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -516,7 +521,7 @@ void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { for (;;) { // Check each active sound for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { - FPSFX *sfx = *_ctx->i; + FPSfx *sfx = *_ctx->i; if (sfx->endOfBuffer()) CoroScheduler.setEvent(sfx->hEndOfBuffer); } @@ -529,19 +534,19 @@ void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { } /****************************************************************************\ -* Metodi di FPSTREAM +* Metodi di FPStream \****************************************************************************/ /****************************************************************************\ * -* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* Function: FPStream(LPDIRECTSOUND lpDS, bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* un oggetto, ma crearlo piuttosto tramite FPSound::CreateStream() * \****************************************************************************/ -FPSTREAM::FPSTREAM(bool bSoundOn) { +FPStream::FPStream(bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; lpDS = LPDS; @@ -556,7 +561,7 @@ FPSTREAM::FPSTREAM(bool bSoundOn) { #endif } -bool FPSTREAM::CreateBuffer(int nBufSize) { +bool FPStream::createBuffer(int nBufSize) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; @@ -585,7 +590,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); + MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); bSoundSupported = false; return false; } @@ -599,7 +604,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { if (FAILED(err)) { wsprintf(errbuf, "Error creating notify object! (%lx)", err); - MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); + MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); bSoundSupported = false; return false; } @@ -626,14 +631,14 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { /****************************************************************************\ * -* Function: ~FPSTREAM(); +* Function: ~FPStream(); * * Description: Distruttore di default. Richiama anche la CloseFile() se ce * ne e' bisogno. * \****************************************************************************/ -FPSTREAM::~FPSTREAM() { +FPStream::~FPStream() { #ifdef REFACTOR_ME if (!bSoundSupported) @@ -680,14 +685,14 @@ FPSTREAM::~FPSTREAM() { * * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). +* creato con la FPSound::CreateStream(). * * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo * questa chiamata. * \****************************************************************************/ -void FPSTREAM::Release() { +void FPStream::release() { delete this; // return NULL; } @@ -707,7 +712,7 @@ void FPSTREAM::Release() { * \****************************************************************************/ -bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { +bool FPStream::loadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { #ifdef REFACTOR_ME HRESULT err; void *lpBuf; @@ -725,7 +730,7 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize /* Apre il file di stream in lettura */ if (!_file.open(lpszFileName)) - //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); + //MessageBox(hwnd,"Cannot open stream file!","FPStream::LoadFile()", MB_OK); return false; } @@ -755,7 +760,7 @@ return true; * \****************************************************************************/ -bool FPSTREAM::UnloadFile() { +bool FPStream::unloadFile() { #ifdef REFACTOR_ME if (!bSoundSupported || !bFileLoaded) @@ -783,7 +788,7 @@ bool FPSTREAM::UnloadFile() { * \****************************************************************************/ -void FPSTREAM::Prefetch(void) { +void FPStream::prefetch(void) { #ifdef REFACTOR_ME uint32 dwId; void *lpBuf; @@ -850,7 +855,7 @@ void FPSTREAM::Prefetch(void) { #endif } -void FPSTREAM::PlayFast(void) { +void FPStream::playFast(void) { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; @@ -873,7 +878,7 @@ void FPSTREAM::PlayFast(void) { #endif } -bool FPSTREAM::Play() { +bool FPStream::play() { #ifdef REFACTOR_ME uint32 dwId; void *lpBuf; @@ -961,7 +966,7 @@ bool FPSTREAM::Play() { * \****************************************************************************/ -bool FPSTREAM::Stop(bool bSync) { +bool FPStream::stop(bool bSync) { #ifdef REFACTOR_ME if (!bSoundSupported) @@ -1001,7 +1006,7 @@ bool FPSTREAM::Stop(bool bSync) { return true; } -void FPSTREAM::WaitForSync(FPSTREAM *toplay) { +void FPStream::waitForSync(FPStream *toplay) { #ifdef REFACTOR_ME if (!bSoundSupported) return; @@ -1035,13 +1040,13 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { /****************************************************************************\ * -* Function: void FPSTREAM::PlayThread(); +* Function: void FPStream::PlayThread(); * * Description: Thread che si occupa del play dello stream * \****************************************************************************/ -void FPSTREAM::PlayThread(FPSTREAM *This) { +void FPStream::playThread(FPStream *This) { #ifdef REFACTOR_ME byte *lpLockBuf; uint32 dwResult; @@ -1172,12 +1177,12 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { * \****************************************************************************/ -void FPSTREAM::SetLoop(bool loop) { +void FPStream::setLoop(bool loop) { bLoop = loop; } -void FPSTREAM::Pause(bool bPause) { +void FPStream::pause(bool bPause) { #ifdef REFACTOR_ME if (bFileLoaded) { @@ -1222,7 +1227,7 @@ void FPSTREAM::Pause(bool bPause) { * \****************************************************************************/ -void FPSTREAM::SetVolume(int dwVolume) { +void FPStream::setVolume(int dwVolume) { #ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; @@ -1253,7 +1258,7 @@ void FPSTREAM::SetVolume(int dwVolume) { * \****************************************************************************/ -void FPSTREAM::GetVolume(int *lpdwVolume) { +void FPStream::getVolume(int *lpdwVolume) { #ifdef REFACTOR_ME if (lpDSBuffer) lpDSBuffer->GetVolume((uint32 *)lpdwVolume); diff --git a/engines/tony/sound.h b/engines/tony/sound.h index abd7e06cae..f47393b86d 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -41,8 +41,8 @@ class RewindableAudioStream; namespace Tony { -class FPSTREAM; -class FPSFX; +class FPStream; +class FPSfx; enum SoundCodecs { FPCODEC_RAW, @@ -58,7 +58,7 @@ enum SoundCodecs { ***************************************************************************** \****************************************************************************/ -class FPSOUND { +class FPSound { private: @@ -72,27 +72,27 @@ public: /****************************************************************************\ * - * Function: FPSOUND::FPSOUND(); + * Function: FPSound::FPSound(); * * Description: Default constructor. Initializes the attributes * \****************************************************************************/ - FPSOUND(); + FPSound(); /****************************************************************************\ * - * Function: FPSOUND::~FPSOUND(); + * Function: FPSound::~FPSound(); * * Description: Deinitialize the object, free memory * \****************************************************************************/ - ~FPSOUND(); + ~FPSound(); /****************************************************************************\ * - * Function: bool FPSOUND::Init(); + * Function: bool FPSound::Init(); * * Description: Initializes the objects, and prepare everything required to * create streams and sound effects. @@ -101,38 +101,38 @@ public: * \****************************************************************************/ - bool Init(); + bool init(); /****************************************************************************\ * - * Function: bool CreateStream(FPSTREAM** lplpStream); + * Function: bool CreateStream(FPStream** lplpStream); * - * Description: Allocates an object of type FPSTREAM, and return its + * Description: Allocates an object of type FPStream, and return its * pointer after it has been initialized. * - * Input: FPSTREAM** lplpStream Will contain the pointer of the + * Input: FPStream** lplpStream Will contain the pointer of the * object * * Return: True is everything i OK, False otherwise * * Note: The use of functions like CreateStream () and CreateSfx () * are due to the fact that the class constructors and - * FPSTREAM FPSFX require that DirectSound is already initialized. + * FPStream FPSfx require that DirectSound is already initialized. * In this way, you avoid the bugs that would be created if an - * object type is declared FPSTREAM FPSFX or global + * object type is declared FPStream FPSfx or global * (or anyway before initializing DirectSound). \****************************************************************************/ - bool CreateStream(FPSTREAM **lplpStream); + bool createStream(FPStream **lplpStream); /****************************************************************************\ * - * Function: bool CreateSfx(FPSFX** lplpSfx); + * Function: bool CreateSfx(FPSfx** lplpSfx); * - * Description: Allocates an object of type FPSFX and returns a pointer + * Description: Allocates an object of type FPSfx and returns a pointer * pointing to it * - * Input: FPSFX** lplpSfx Will contain the pointer of the + * Input: FPSfx** lplpSfx Will contain the pointer of the * object * * Return: True is everything i OK, False otherwise @@ -141,7 +141,7 @@ public: * \****************************************************************************/ - bool CreateSfx(FPSFX **lplpSfx); + bool createSfx(FPSfx **lplpSfx); /****************************************************************************\ * @@ -153,7 +153,7 @@ public: * \****************************************************************************/ - void SetMasterVolume(int dwVolume); + void setMasterVolume(int dwVolume); /****************************************************************************\ * @@ -166,10 +166,10 @@ public: * \****************************************************************************/ - void GetMasterVolume(int *lpdwVolume); + void getMasterVolume(int *lpdwVolume); }; -class FPSFX { +class FPSfx { /****************************************************************************\ * Attributes @@ -206,43 +206,43 @@ public: /****************************************************************************\ * - * Function: FPSFX(bool bSoundOn); + * Function: FPSfx(bool bSoundOn); * * Description: Default constructor. *DO NOT* declare the object directly, - * create it though FPSOUND::CreateSfx() instead + * create it though FPSound::CreateSfx() instead * \****************************************************************************/ - FPSFX(bool bSoundOn); + FPSfx(bool bSoundOn); /****************************************************************************\ * - * Function: ~FPSFX(); + * Function: ~FPSfx(); * * Description: Default destructor. It also stops the sound effect that * may be running, and free the memory used. * \****************************************************************************/ - ~FPSFX(); + ~FPSfx(); /****************************************************************************\ * - * Function: Release(); + * Function: release(); * * Description: Releases the memory object. Must be called when the object * is no longer useful and **ONLY** when the object was created - * with the FPSOUND :: CreateStream (). + * with the FPSound :: CreateStream (). * * Note: Any object pointers are no longer valid after this call. * \****************************************************************************/ - void Release(); + void release(); /****************************************************************************\ * - * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * * Description: Opens a file and load sound effect * @@ -254,13 +254,13 @@ public: * \****************************************************************************/ - bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool loadWave(Common::SeekableReadStream *stream); - bool LoadVoiceFromVDB(Common::File &vdbFP); + bool loadVoiceFromVDB(Common::File &vdbFP); /****************************************************************************\ * - * Function: bool Play(); + * Function: bool play(); * * Description: Play the loaded FX. * @@ -268,11 +268,11 @@ public: * \****************************************************************************/ - bool Play(); + bool play(); /****************************************************************************\ * - * Function: bool Stop(); + * Function: bool stop(); * * Description: Stop a FX * @@ -280,21 +280,21 @@ public: * \****************************************************************************/ - bool Stop(); + bool stop(); /****************************************************************************\ * - * Function: void Pause(bool bPause); + * Function: void pause(bool bPause); * * Description: Pause a FX * \****************************************************************************/ - void Pause(bool bPause); + void pause(bool bPause); /****************************************************************************\ * - * Function: bool SetLoop(bool bLoop); + * Function: bool setLoop(bool bLoop); * * Description: Enables or disables SFX loop * @@ -306,11 +306,11 @@ public: * \****************************************************************************/ - void SetLoop(bool bLoop); + void setLoop(bool bLoop); /****************************************************************************\ * - * Function: void SetVolume(int dwVolume); + * Function: void setVolume(int dwVolume); * * Description: Set SFX Volume * @@ -318,11 +318,11 @@ public: * \****************************************************************************/ - void SetVolume(int dwVolume); + void setVolume(int dwVolume); /****************************************************************************\ * - * Function: void GetVolume(int * lpdwVolume); + * Function: void getVolume(int * lpdwVolume); * * Description: Get SFX volume * @@ -330,7 +330,7 @@ public: * \****************************************************************************/ - void GetVolume(int *lpdwVolume); + void getVolume(int *lpdwVolume); /** * Returns true if the sound has finished playing @@ -338,7 +338,7 @@ public: bool endOfBuffer() const; }; -class FPSTREAM { +class FPStream { /****************************************************************************\ * Attributes @@ -372,17 +372,17 @@ private: bool bSyncExit; bool bPaused; int lastVolume; - FPSTREAM *SyncToPlay; + FPStream *SyncToPlay; // DSBPOSITIONNOTIFY dspnHot[3]; - bool CreateBuffer(int nBufSize); + bool createBuffer(int nBufSize); public: bool bIsPlaying; // True if the stream is playing private: - static void PlayThread(FPSTREAM *This); + static void playThread(FPStream *This); /****************************************************************************\ * Methods @@ -392,43 +392,43 @@ public: /****************************************************************************\ * - * Function: FPSTREAM(bool bSoundOn); + * Function: FPStream(bool bSoundOn); * * Description: Default contractor. *DO NOT* declare the object directly: use - * FPSOUND::CreateStream() indtead + * FPSound::CreateStream() indtead * \****************************************************************************/ - FPSTREAM(bool bSoundOn); + FPStream(bool bSoundOn); /****************************************************************************\ * - * Function: ~FPSTREAM(); + * Function: ~FPStream(); * * Description: Destructor by default. Stops the playing stream (if any) and * frees the memory used by them * \****************************************************************************/ - ~FPSTREAM(); + ~FPStream(); /****************************************************************************\ * - * Function: Release(); + * Function: release(); * * Description: Releases memory used by object. Must be used when the object * is no longer used. *ONLY*for objects created by - * FPSOUND::CreateStream(). + * FPSound::CreateStream(). * * Note: Object pointers are no longer valid after this call. * \****************************************************************************/ - void Release(); + void release(); /****************************************************************************\ * - * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * * Description: Open a file for a stream. * @@ -440,11 +440,11 @@ public: * \****************************************************************************/ - bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); /****************************************************************************\ * - * Function: UnloadFile(); + * Function: unloadFile(); * * Description: Close a file stream (if opened). This function must be * called to free the memory used by the stream @@ -454,11 +454,11 @@ public: * \****************************************************************************/ - bool UnloadFile(); + bool unloadFile(); /****************************************************************************\ * - * Function: bool Play(); + * Function: bool play(); * * Description: Play the loaded stream. * @@ -466,13 +466,13 @@ public: * \****************************************************************************/ - bool Play(); - void PlayFast(void); - void Prefetch(void); + bool play(); + void playFast(void); + void prefetch(void); /****************************************************************************\ * - * Function: bool Stop(); + * Function: bool stop(); * * Description: Stops the play of the stream. * @@ -480,22 +480,22 @@ public: * \****************************************************************************/ - bool Stop(bool bSync = false); - void WaitForSync(FPSTREAM *toplay); + bool stop(bool bSync = false); + void waitForSync(FPStream *toplay); /****************************************************************************\ * - * Function: void Pause(bool bPause); + * Function: void pause(bool bPause); * * Description: Pause sound effect * \****************************************************************************/ - void Pause(bool bPause); + void pause(bool bPause); /****************************************************************************\ * - * Function: bool SetLoop(bool bLoop); + * Function: bool setLoop(bool bLoop); * * Description: Enable of disable stream loop * @@ -507,11 +507,11 @@ public: * \****************************************************************************/ - void SetLoop(bool bLoop); + void setLoop(bool bLoop); /****************************************************************************\ * - * Function: void SetVolume(int dwVolume); + * Function: void setVolume(int dwVolume); * * Description: Change stream colume * @@ -519,13 +519,13 @@ public: * \****************************************************************************/ - void SetVolume(int dwVolume); + void setVolume(int dwVolume); /****************************************************************************\ * - * Function: void GetVolume(LPINT lpdwVolume); + * Function: void getVolume(LPINT lpdwVolume); * * Description: Get stream volume * @@ -533,7 +533,7 @@ public: * \****************************************************************************/ - void GetVolume(int *lpdwVolume); + void getVolume(int *lpdwVolume); }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 012dc854b9..094e1bd038 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -213,8 +213,8 @@ void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 0: case 1: case 2: - _stream[nChannel]->Stop(); - _stream[nChannel]->UnloadFile(); + _stream[nChannel]->stop(); + _stream[nChannel]->unloadFile(); break; case 22: @@ -287,30 +287,30 @@ void TonyEngine::playSFX(int nChannel, int nFX) { switch (nFX) { case 0: - _sfx[nChannel]->SetLoop(false); + _sfx[nChannel]->setLoop(false); break; case 1: - _sfx[nChannel]->SetLoop(true); + _sfx[nChannel]->setLoop(true); break; } - _sfx[nChannel]->Play(); + _sfx[nChannel]->play(); } void TonyEngine::stopMusic(int nChannel) { // g_system->lockMutex(csMusic); if (nChannel < 4) - _stream[nChannel + GLOBALS._flipflop]->Stop(); + _stream[nChannel + GLOBALS._flipflop]->stop(); else - _stream[nChannel]->Stop(); + _stream[nChannel]->stop(); // g_system->unlockMutex(csMusic); } void TonyEngine::stopSFX(int nChannel) { - _sfx[nChannel]->Stop(); + _sfx[nChannel]->stop(); } void TonyEngine::playUtilSFX(int nChannel, int nFX) { @@ -319,38 +319,38 @@ void TonyEngine::playUtilSFX(int nChannel, int nFX) { switch (nFX) { case 0: - _utilSfx[nChannel]->SetLoop(false); + _utilSfx[nChannel]->setLoop(false); break; case 1: - _utilSfx[nChannel]->SetLoop(true); + _utilSfx[nChannel]->setLoop(true); break; } - _utilSfx[nChannel]->SetVolume(52); - _utilSfx[nChannel]->Play(); + _utilSfx[nChannel]->setVolume(52); + _utilSfx[nChannel]->play(); } void TonyEngine::stopUtilSFX(int nChannel) { - _utilSfx[nChannel]->Stop(); + _utilSfx[nChannel]->stop(); } void TonyEngine::preloadSFX(int nChannel, const char *fn) { if (_sfx[nChannel] != NULL) { - _sfx[nChannel]->Stop(); - _sfx[nChannel]->Release(); + _sfx[nChannel]->stop(); + _sfx[nChannel]->release(); _sfx[nChannel] = NULL; } - _theSound.CreateSfx(&_sfx[nChannel]); + _theSound.createSfx(&_sfx[nChannel]); - _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); + _sfx[nChannel]->loadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::createSFX(Common::SeekableReadStream *stream) { - FPSFX *sfx; +FPSfx *TonyEngine::createSFX(Common::SeekableReadStream *stream) { + FPSfx *sfx; - _theSound.CreateSfx(&sfx); + _theSound.createSfx(&sfx); sfx->loadWave(stream); return sfx; } @@ -370,11 +370,11 @@ void TonyEngine::unloadAllUtilSFX(void) { void TonyEngine::initMusic() { int i; - _theSound.Init(/*_window*/); - _theSound.SetMasterVolume(63); + _theSound.init(/*_window*/); + _theSound.setMasterVolume(63); for (i = 0; i < 6; i++) - _theSound.CreateStream(&_stream[i]); + _theSound.createStream(&_stream[i]); for (i = 0; i < MAX_SFX_CHANNELS; i++) { _sfx[i] = _utilSfx[i] = NULL; @@ -388,14 +388,14 @@ void TonyEngine::initMusic() { preloadUtilSFX(1, "U02.ADP"); // Start check processes for sound - CoroScheduler.createProcess(FPSFX::soundCheckProcess, NULL); + CoroScheduler.createProcess(FPSfx::soundCheckProcess, NULL); } void TonyEngine::closeMusic() { for (int i = 0; i < 6; i++) { - _stream[i]->Stop(); - _stream[i]->UnloadFile(); - _stream[i]->Release(); + _stream[i]->stop(); + _stream[i]->unloadFile(); + _stream[i]->release(); } // g_system->deleteMutex(csMusic); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 8df2da697c..93232b950d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -99,8 +99,8 @@ public: uint32 _hEndOfFrame; Common::File _vdbFP; Common::Array _voices; - FPSOUND _theSound; - Common::List _activeSfx; + FPSound _theSound; + Common::List _activeSfx; Globals _globals; Debugger *_debugger; @@ -115,9 +115,9 @@ public: DD_BASE2 }; - FPSTREAM *_stream[6]; - FPSFX *_sfx[MAX_SFX_CHANNELS]; - FPSFX *_utilSfx[MAX_SFX_CHANNELS]; + FPStream *_stream[6]; + FPSfx *_sfx[MAX_SFX_CHANNELS]; + FPSfx *_utilSfx[MAX_SFX_CHANNELS]; // RMFont *_fonts[2]; bool _bPaused; bool _bDrawLocation; @@ -189,7 +189,7 @@ public: void playUtilSFX(int nSfx, int nFX = 0); void stopUtilSFX(int nSfx); - FPSFX *createSFX(Common::SeekableReadStream *stream); + FPSfx *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); void unloadAllSFX(void); -- cgit v1.2.3 From 25d95bd5e357187cde9634b0379b8469cee0397d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 22:05:06 +1000 Subject: TONY: Workaround for original game bug opening the door in the first scene In the original, after moving to the door, the game scripts have Tony start immediately moving back to the desk. Unfortunately, they didn't realise that the _hEndOfPath event would still be briefly set from finishing the walk to the door, so the game didn't wait until Tony had reached the desk to start the conversation. --- engines/tony/custom.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index ef4f889a12..160fafa47f 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1198,6 +1198,11 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); + // WORKAROUND: Delay for a frame before starting the move to give any previous move time to finish. + // This fixes a bug in the first scene where if you immediately 'Use Door', Tony moves to the door, + // and then floats to the right rather than properly walking. + CORO_SLEEP(1); + CORO_INVOKE_1(GLOBALS._tony->move, RMPoint(nX, nY)); if (!GLOBALS._bSkipIdle) -- cgit v1.2.3 From 0f6a87ae95dfa6ef122ba75a0a65a114616189ba Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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 ac4567dcb6608bbcde680df36bba088ce0191dd5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 19:04:19 +0200 Subject: TONY: Rename sound variables --- engines/tony/custom.cpp | 10 +++---- engines/tony/sound.cpp | 72 ++++++++++++++++++++++++------------------------- engines/tony/sound.h | 57 +++++++++++++++++++-------------------- 3 files changed, 68 insertions(+), 71 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 160fafa47f..375b405400 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -331,7 +331,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->play(); - _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } else { _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.createSfx(&_ctx->voice); @@ -340,7 +340,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->setLoop(false); _ctx->voice->play(); - _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } } @@ -1535,7 +1535,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->setLoop(false); if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); - _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1749,7 +1749,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); - _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1912,7 +1912,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { _ctx->voice->play(); - _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } // Wait for the end of display diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 35db3ced38..479cb05a0b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -56,7 +56,7 @@ namespace Tony { \****************************************************************************/ FPSound::FPSound() { - bSoundSupported = false; + _bSoundSupported = false; } @@ -72,8 +72,8 @@ FPSound::FPSound() { \****************************************************************************/ bool FPSound::init() { - bSoundSupported = g_system->getMixer()->isReady(); - return bSoundSupported; + _bSoundSupported = g_system->getMixer()->isReady(); + return _bSoundSupported; } @@ -112,7 +112,7 @@ FPSound::~FPSound() { \****************************************************************************/ bool FPSound::createStream(FPStream **lplpStream) { - (*lplpStream) = new FPStream(bSoundSupported); + (*lplpStream) = new FPStream(_bSoundSupported); return (*lplpStream != NULL); } @@ -136,7 +136,7 @@ bool FPSound::createStream(FPStream **lplpStream) { \****************************************************************************/ bool FPSound::createSfx(FPSfx **lplpSfx) { - (*lplpSfx) = new FPSfx(bSoundSupported); + (*lplpSfx) = new FPSfx(_bSoundSupported); return (*lplpSfx != NULL); } @@ -154,7 +154,7 @@ bool FPSound::createSfx(FPSfx **lplpSfx) { \****************************************************************************/ void FPSound::setMasterVolume(int dwVolume) { - if (!bSoundSupported) + if (!_bSoundSupported) return; g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); @@ -172,7 +172,7 @@ void FPSound::setMasterVolume(int dwVolume) { \****************************************************************************/ void FPSound::getMasterVolume(int *lpdwVolume) { - if (!bSoundSupported) + if (!_bSoundSupported) return; *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; @@ -193,14 +193,14 @@ void FPSound::getMasterVolume(int *lpdwVolume) { \****************************************************************************/ FPSfx::FPSfx(bool bSoundOn) { - bSoundSupported = bSoundOn; - bFileLoaded = false; - lastVolume = 63; - hEndOfBuffer = CORO_INVALID_PID_VALUE; - bIsVoice = false; + _bSoundSupported = bSoundOn; + _bFileLoaded = false; + _lastVolume = 63; + _hEndOfBuffer = CORO_INVALID_PID_VALUE; + _bIsVoice = false; _loopStream = 0; _rewindableStream = 0; - bPaused = false; + _bPaused = false; _vm->_activeSfx.push_back(this); } @@ -217,7 +217,7 @@ FPSfx::FPSfx(bool bSoundOn) { \****************************************************************************/ FPSfx::~FPSfx() { - if (!bSoundSupported) + if (!_bSoundSupported) return; g_system->getMixer()->stopHandle(_handle); @@ -276,8 +276,8 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { if (!_rewindableStream) return false; - bFileLoaded = true; - setVolume(lastVolume); + _bFileLoaded = true; + setVolume(_lastVolume); return true; } @@ -297,23 +297,23 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { \****************************************************************************/ bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { - if (!bSoundSupported) + if (!_bSoundSupported) return true; uint32 size = vdbFP.readUint32LE(); uint32 rate = vdbFP.readUint32LE(); - bIsVoice = true; + _bIsVoice = true; _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); - bFileLoaded = true; + _bFileLoaded = true; setVolume(62); return true; } bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { - if (!bSoundSupported) + if (!_bSoundSupported) return true; Common::File file; @@ -343,7 +343,7 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { _rewindableStream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } - bFileLoaded = true; + _bFileLoaded = true; return true; } @@ -361,7 +361,7 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { bool FPSfx::play() { stop(); // sanity check - if (bFileLoaded) { + if (_bFileLoaded) { // FIXME //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) // ResetEvent(hEndOfBuffer); @@ -370,7 +370,7 @@ bool FPSfx::play() { Audio::AudioStream *stream = _rewindableStream; - if (bLoop) { + if (_bLoop) { if (!_loopStream) _loopStream = Audio::makeLoopingAudioStream(_rewindableStream, 0); @@ -380,9 +380,9 @@ bool FPSfx::play() { g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - setVolume(lastVolume); + setVolume(_lastVolume); - if (bPaused) + if (_bPaused) g_system->getMixer()->pauseHandle(_handle, true); } @@ -401,9 +401,9 @@ bool FPSfx::play() { \****************************************************************************/ bool FPSfx::stop() { - if (bFileLoaded) { + if (_bFileLoaded) { g_system->getMixer()->stopHandle(_handle); - bPaused = false; + _bPaused = false; } return true; @@ -428,15 +428,15 @@ bool FPSfx::stop() { \****************************************************************************/ void FPSfx::setLoop(bool bLop) { - bLoop = bLop; + _bLoop = bLop; } void FPSfx::pause(bool bPause) { - if (bFileLoaded) { - if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ bPaused)) + if (_bFileLoaded) { + if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ _bPaused)) g_system->getMixer()->pauseHandle(_handle, bPause); - bPaused = bPause; + _bPaused = bPause; } } @@ -457,9 +457,9 @@ void FPSfx::setVolume(int dwVolume) { if (dwVolume < 0) dwVolume = 0; - lastVolume = dwVolume; + _lastVolume = dwVolume; - if (bIsVoice) { + if (_bIsVoice) { if (!GLOBALS._bCfgDubbing) dwVolume = 0; else { @@ -523,7 +523,7 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { FPSfx *sfx = *_ctx->i; if (sfx->endOfBuffer()) - CoroScheduler.setEvent(sfx->hEndOfBuffer); + CoroScheduler.setEvent(sfx->_hEndOfBuffer); } // Delay until the next check is done @@ -1035,7 +1035,7 @@ void FPStream::waitForSync(FPStream *toplay) { /* Disalloca e chiude il CODEC */ delete lpCodec; #endif - bIsPlaying = false; + _bIsPlaying = false; } /****************************************************************************\ @@ -1178,7 +1178,7 @@ void FPStream::playThread(FPStream *This) { \****************************************************************************/ void FPStream::setLoop(bool loop) { - bLoop = loop; + _bLoop = loop; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index f47393b86d..5e50c31554 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -62,7 +62,7 @@ class FPSound { private: - bool bSoundSupported; + bool _bSoundSupported; /****************************************************************************\ * Methods @@ -176,20 +176,20 @@ class FPSfx { \****************************************************************************/ private: - bool bSoundSupported; // True if the sound is active - bool bFileLoaded; // True is a file is opened - bool bLoop; // True is sound effect should loop - int lastVolume; + bool _bSoundSupported; // True if the sound is active + bool _bFileLoaded; // True is a file is opened + bool _bLoop; // True is sound effect should loop + int _lastVolume; - bool bIsVoice; - bool bPaused; + bool _bIsVoice; + bool _bPaused; Audio::AudioStream *_loopStream; Audio::RewindableAudioStream *_rewindableStream; Audio::SoundHandle _handle; public: - uint32 hEndOfBuffer; + uint32 _hEndOfBuffer; private: @@ -352,33 +352,33 @@ private: LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer */ - byte *lpTempBuffer; // Temporary buffer use for decompression + byte *_lpTempBuffer; // Temporary buffer use for decompression - uint32 dwBufferSize; // Buffer size (bytes) - uint32 dwSize; // Stream size (bytes) - uint32 dwCodec; // CODEC used + uint32 _dwBufferSize; // Buffer size (bytes) + uint32 _dwSize; // Stream size (bytes) + uint32 _dwCodec; // CODEC used - HANDLE hThreadEnd; // Event used to close thread + HANDLE _hThreadEnd; // Event used to close thread Common::File _file; // File handle used for the stream - HANDLE hPlayThread; // Handle of the Play thread - HANDLE hHot1, hHot2, hHot3; // Events set by DirectSoundNotify - HANDLE hPlayThread_PlayFast; - HANDLE hPlayThread_PlayNormal; - - bool bSoundSupported; // True if the sound is active - bool bFileLoaded; // True if the file is open - bool bLoop; // True if the stream should loop - bool bDoFadeOut; // True if fade out is required - bool bSyncExit; - bool bPaused; - int lastVolume; - FPStream *SyncToPlay; + HANDLE _hPlayThread; // Handle of the Play thread + HANDLE _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify + HANDLE _hPlayThreadPlayFast; + HANDLE _hPlayThreadPlayNormal; + + bool _bSoundSupported; // True if the sound is active + bool _bFileLoaded; // True if the file is open + bool _bLoop; // True if the stream should loop + bool _bDoFadeOut; // True if fade out is required + bool _bSyncExit; + bool _bPaused; + int _lastVolume; + FPStream *_syncToPlay; // DSBPOSITIONNOTIFY dspnHot[3]; bool createBuffer(int nBufSize); public: - bool bIsPlaying; // True if the stream is playing + bool _bIsPlaying; // True if the stream is playing private: @@ -521,8 +521,6 @@ public: void setVolume(int dwVolume); - - /****************************************************************************\ * * Function: void getVolume(LPINT lpdwVolume); @@ -536,7 +534,6 @@ public: void getVolume(int *lpdwVolume); }; - } // End of namespace Tony #endif -- cgit v1.2.3 From 011b15966cb7168ff0087cf8a206f8ea95dbd734 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 23:48:16 +0200 Subject: TONY: Translate comments in sound.cpp --- engines/tony/sound.cpp | 303 +++++++++++++++++++++---------------------------- 1 file changed, 132 insertions(+), 171 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 479cb05a0b..e650a5d74b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -44,14 +44,14 @@ namespace Tony { #define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} /****************************************************************************\ -* Metodi per FPSound +* Methods for FPSound \****************************************************************************/ /****************************************************************************\ * * Function: FPSound::FPSound(); * -* Description: Costruttore di default. Inizializza gli attributi. +* Description: Default constructor. Initializes the attributes. * \****************************************************************************/ @@ -62,12 +62,12 @@ FPSound::FPSound() { /****************************************************************************\ * -* Function: bool FPSound::Init(); +* Function: bool FPSound::init(); * -* Description: Inizializza l'oggetto, e prepara tutto il necessario per -* creare stream e effetti sonori. +* Description: Initializes the object, and prepare everything you need to + create streams and sound effects. * -* Return: True se tutto OK, false in caso di errore. +* Return: True if everything's OK, False otherwise. * \****************************************************************************/ @@ -81,7 +81,7 @@ bool FPSound::init() { * * Function: FPSound::~FPSound(); * -* Description: Deinizializza l'oggetto, disallocando la memoria. +* Description: Destroy the object and free the memory. * \****************************************************************************/ @@ -93,21 +93,12 @@ FPSound::~FPSound() { * * Function: bool CreateStream(FPStream** lplpStream); * -* Description: Alloca un oggetti di tipo FPStream, e ritorna il suo -* puntatore dopo averlo inizializzato. +* Description: Allocates an object of type FPStream, and return its pointer * -* Input: FPStream** lplpStream Conterra' il pointer all'oggetto -* appena creato. +* Input: FPStream** lplpStream Will contain a pointer to the object +* you just created. * -* Return: true se tutto OK, false in caso di errore -* -* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPStream -* e FPSfx richiedono che DirectSound sia gia' stato -* inzializzato. In questo modo quindi si evitano dei bugs -* che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPStream o FPSfx globale (o cmq prima della -* inizializzazione di DirectSound). +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -117,21 +108,16 @@ bool FPSound::createStream(FPStream **lplpStream) { return (*lplpStream != NULL); } - - /****************************************************************************\ * * Function: bool CreateSfx(FPSfx** lplpSfx); * -* Description: Alloca un oggetti di tipo FPSfx e ritorna il suo -* puntatore dopo averlo inizializzato. +* Description: Allocates an object of type FpSfx, and return its pointer * -* Input: FPSfx** lplpSfx Conterra' il pointer all'oggetto -* appena creato. +* Input: FPSfx** lplpSfx Will contain a pointer to the object +* you just created. * -* Return: true se tutto OK, false in caso di errore -* -* Note: Vedi le note di CreateStream() +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -141,15 +127,13 @@ bool FPSound::createSfx(FPSfx **lplpSfx) { return (*lplpSfx != NULL); } - - /****************************************************************************\ * -* Function: void SetMasterVolume(int dwVolume); +* Function: void setMasterVolume(int dwVolume); * -* Description: Setta il volume generale +* Description: Set the general volume * -* Input: int dwVolume Volume da settare (0-63) +* Input: int dwVolume Volume to set (0-63) * \****************************************************************************/ @@ -160,14 +144,14 @@ void FPSound::setMasterVolume(int dwVolume) { g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); } - /****************************************************************************\ * -* Function: void GetMasterVolume(int *lpdwVolume); +* Function: void getMasterVolume(int *lpdwVolume); * -* Description: Richiede il volume generale +* Description: Get the general volume * -* Input: int *lpdwVolume Variabile che conterra' il volume (0-63) +* Input: int *lpdwVolume Variable that will contain the +* volume (0-63) * \****************************************************************************/ @@ -178,17 +162,16 @@ void FPSound::getMasterVolume(int *lpdwVolume) { *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; } - /****************************************************************************\ -* Metodi di FPSfx +* Methods for FPSfx \****************************************************************************/ /****************************************************************************\ * * Function: FPSfx(bool bSoundOn); * -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSound::CreateSfx() +* Description: Default constructor. Do *NOT* declare an object directly, +* but rather create it using FPSound::CreateSfx() * \****************************************************************************/ @@ -210,9 +193,8 @@ FPSfx::FPSfx(bool bSoundOn) { * * Function: ~FPSfx(); * -* Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. +* Description: Default Destructor. It is also stops the sound effect that +* may be currently played, and free the memory it uses. * \****************************************************************************/ @@ -233,17 +215,15 @@ FPSfx::~FPSfx() { // CloseHandle(hEndOfBuffer); } - /****************************************************************************\ * -* Function: Release(); +* Function: release(); * -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSound::CreateStream(). +* Description: Releases the memory used by the object. +* Must be called when the object is no longer used and +* **ONLY** if the object was created by FPSound::CreateStream() * -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. +* Note: Object pointers are no longer valid after this call. * \****************************************************************************/ @@ -251,19 +231,16 @@ void FPSfx::release() { delete this; } - - /****************************************************************************\ * * Function: bool loadWave(Common::SeekableReadStream *stream); * -* Description: Apre un file di effetto sonoro e lo carica. +* Description: Opens a file and loads a sound effect. * -* Input: byte *lpBuf Buffer dove si trova l'sfx -* uint32 dwCoded CODEC da utilizzare per decomprimere -* i campioni sonori +* Input: byte *lpBuf Buffer containing the Sfx +* uint32 dwCodec CODEC used to uncompress the samples * -* Return: true se tutto OK, false in caso di errore +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -284,15 +261,14 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { /****************************************************************************\ * -* Function: bool LoadFile(LPSTR lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* Function: bool LoadFile(const char * lpszFileName, uint32 dwCodec=FPCODEC_RAW); * -* Description: Apre un file di effetto sonoro e lo carica. +* Description: Opens a file and loads a sound effect. * -* Input: LPSTR lpszFile Nome del file di sfx da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori +* Input: LPSTR lpszFile Sfx filename +* uint32 dwCodec CODEC used to uncompress the samples * -* Return: true se tutto OK, false in caso di errore +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -350,11 +326,11 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { /****************************************************************************\ * -* Function: bool Play(); +* Function: bool play(); * -* Description: Suona lo sfx caricato. +* Description: Play the Sfx in memory. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -392,11 +368,11 @@ bool FPSfx::play() { /****************************************************************************\ * -* Function: bool Stop(void); +* Function: bool stop(void); * -* Description: Ferma il play dello sfx. +* Description: Stop an sfx. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -413,17 +389,15 @@ bool FPSfx::stop() { /****************************************************************************\ * -* Function: bool SetLoop(bool bLoop); +* Function: bool setLoop(bool bLoop); * -* Description: Attiva o disattiva il loop dello sfx. +* Description: Enables or disables the Sfx loop. * -* Input: bool bLoop true per attivare il loop, false per -* disattivarlo +* Input: bool bLoop True to enable the loop, False to disable * -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello sfx. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo sfx non viene fermato, -* e poi rimesso in play. +* Note: The loop must be activated BEFORE the sfx starts playing. +* Any changes made during the play will have no effect until +* the sfx is stopped then played again. * \****************************************************************************/ @@ -440,14 +414,13 @@ void FPSfx::pause(bool bPause) { } } - /****************************************************************************\ * -* Function: void SetVolume(int dwVolume); +* Function: void setVolume(int dwVolume); * -* Description: Cambia il volume dello sfx +* Description: Change the volume of Sfx * -* Input: int dwVolume Volume da settare (0-63) +* Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ @@ -486,10 +459,9 @@ void FPSfx::setVolume(int dwVolume) { * * Function: void GetVolume(int *lpdwVolume); * -* Description: Chiede il volume dello sfx +* Description: Gets the Sfx volume * -* Input: int *lpdwVolume Variabile in cui verra' inserito -* il volume corrente +* Input: int *lpdwVolume Will contain the current Sfx volume * \****************************************************************************/ @@ -534,15 +506,15 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { } /****************************************************************************\ -* Metodi di FPStream +* Methods for FPStream \****************************************************************************/ /****************************************************************************\ * * Function: FPStream(LPDIRECTSOUND lpDS, bool bSoundOn); * -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSound::CreateStream() +* Description: Default constructor. Do *NOT* declare an object directly, +* but rather create it using FPSound::CreateStream() * \****************************************************************************/ @@ -571,11 +543,10 @@ bool FPStream::createBuffer(int nBufSize) { if (bSoundSupported == false) return true; - /* Setta le strutture necessarie per la creazione di un secondary buffer - per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre - il controllo del volume, in modo da poter abbassare e alzare il volume - della musica indipendentemente da quello generale. Ovviamente si tratta - di un buffer in RAM */ + /* Set the required structures for the creation of a secondary buffer for the stream containing exactly 1 second of music. + Also activate the volume control, in order to lower and raise the volume of the music regardless of the general volume. + Obviously it is a buffer in RAM */ + pcmwf.wBitsPerSample = 16; pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = 2; @@ -597,9 +568,9 @@ bool FPStream::createBuffer(int nBufSize) { SetVolume(63); - /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave - all'interno dello stream. Le posizioni chiave si trovano rispettivamente - subito dopo l'inizio e subito dopo la meta' del buffer */ + /* Create an alert when key positions are reached in the stream. + Key positions are located, respectively, immediately after + the start and immediately after the middle of the buffer */ err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { @@ -633,8 +604,7 @@ bool FPStream::createBuffer(int nBufSize) { * * Function: ~FPStream(); * -* Description: Distruttore di default. Richiama anche la CloseFile() se ce -* ne e' bisogno. +* Description: Default destructor. It calls CloseFile() if needed. * \****************************************************************************/ @@ -681,14 +651,13 @@ FPStream::~FPStream() { /****************************************************************************\ * -* Function: Release(); +* Function: release(); * -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSound::CreateStream(). +* Description: Releases the memory object. Must be called when the object +* is no longer used and **ONLY** if the object was created by +* FPSound::CreateStream(). * -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. +* Note: Object pointers are no longer valid after this call. * \****************************************************************************/ @@ -700,15 +669,14 @@ void FPStream::release() { /****************************************************************************\ * -* Function: bool LoadFile(LPSTREAM lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* Function: bool loadFile(const char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * -* Description: Apre un file di stream. +* Description: Opens a file stream. * -* Input: LPSTR lpszFile Nome del file di stream da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori +* Input: LPSTR lpszFile Filename to be opened +* uint32 dwCodec CODEC to be used to uncompress samples * -* Return: true se tutto OK, false in caso di errore +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -749,14 +717,13 @@ return true; /****************************************************************************\ * -* Function: UnloadFile(); +* Function: unloadFile(); * -* Description: Chiude un file di stream eventualmente aperto. E' necessario -* richiamare questa funzione per disallocare la memoria -* occupata dallo stream. +* Description: Closes a file stream (opened or not). It is necessary to call +* this function to free the memory used by the stream. * -* Return: Il distruttore della classe per sicurezza richiama la -* UnloadFile() se non e' stata richiamata esplicitamente. +* Return: For safety, the destructor calls unloadFile() if it has not +* been mentioned explicitly. * \****************************************************************************/ @@ -766,13 +733,13 @@ bool FPStream::unloadFile() { if (!bSoundSupported || !bFileLoaded) return true; - /* Chiude gli handle del file di stream */ + /* Closes the file handle stream */ _file.close(); RELEASE(lpDSNotify); RELEASE(lpDSBuffer); - /* Si ricorda che non c'e' piu' nessun file in memoria */ + /* Remember no more file is loaded in memory */ bFileLoaded = false; #endif return true; @@ -782,9 +749,9 @@ bool FPStream::unloadFile() { * * Function: bool Play(); * -* Description: Suona lo stream caricato. +* Description: Play the stream. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -798,7 +765,7 @@ void FPStream::prefetch(void) { if (!bSoundSupported || !bFileLoaded) return; - /* Alloca un buffer temporaneo */ + /* Allocates a temporary buffer */ lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); if (lpTempBuffer == NULL) return; @@ -816,27 +783,27 @@ void FPStream::prefetch(void) { return; } - /* Posiziona lo stream file all'inizio */ + /* reset the file position */ _file.seek(0); - /* Riempie il buffer per avere i dati gia' pronti */ + /* Fills the buffer for the data already ready */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); return; } - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + /* Uncompress the data from the stream directly into the locked buffer */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - /* Unlocka il buffer */ + /* Unlock the buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - /* Crea il thread che fa il play dello stream */ + /* Create a thread to play the stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - /* Start il play del buffer DirectSound */ + /* Start to play the buffer */ lpDSBuffer->SetCurrentPosition(0); bIsPlaying = true; @@ -888,7 +855,7 @@ bool FPStream::play() { if (!bSoundSupported || !bFileLoaded) return false; - /* Alloca un buffer temporaneo */ + /* Allocate a temporary buffer */ lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); if (lpTempBuffer == NULL) return false; @@ -906,23 +873,23 @@ bool FPStream::play() { return false; } - /* Posiziona lo stream file all'inizio */ + /* Reset the file position */ _file.seek(0); lpDSBuffer->Stop(); lpDSBuffer->SetCurrentPosition(0); - /* Riempie il buffer per avere i dati gia' pronti */ + /* Fills the buffer for the data already ready */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { error("Cannot lock stream buffer!", "soundLoadStream()"); } - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + /* Uncompress the data from the stream directly into the locked buffer */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - /* Unlocka il buffer */ + /* Unlock the buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - /* Crea il thread che fa il play dello stream */ + /* Create a thread to play the stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); @@ -930,7 +897,7 @@ bool FPStream::play() { SetEvent(hPlayThread_PlayFast); #if 0 - /* Start il play del buffer DirectSound */ + /* Start to play the buffer */ lpDSBuffer->SetCurrentPosition(0); dspnHot[0].dwOffset = 32; @@ -958,11 +925,11 @@ bool FPStream::play() { /****************************************************************************\ * -* Function: bool Stop(bool bSync); +* Function: bool stop(bool bSync); * -* Description: Ferma il play dello stream. +* Description: Closes the stream. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -984,19 +951,19 @@ bool FPStream::stop(bool bSync) { // lpDSBuffer->Play(0, 0, 0); return true; } else { - /* Ferma il buffer DirectSound */ + /* Close the DirectSound buffer */ lpDSBuffer->Stop(); - /* Avverte il thread che deve uscire e aspetta che si chiuda */ + /* Notify the thread is should stop */ SetEvent(hThreadEnd); WaitForSingleObject(hPlayThread, CORO_INFINITE); - /* Chiude l'handle del thread e disalloca la memoria temporanea */ + /* Closes the handle used by the stream and free its memory */ CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - /* Disalloca e chiude il CODEC */ + /* Close and free the CODEC */ delete lpCodec; bIsPlaying = false; @@ -1027,12 +994,12 @@ void FPStream::waitForSync(FPStream *toplay) { WaitForSingleObject(hPlayThread, CORO_INFINITE); - /* Chiude l'handle del thread e disalloca la memoria temporanea */ + /* Closes the handle used by the stream and free its memory */ CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - /* Disalloca e chiude il CODEC */ + /* Close and free the CODEC */ delete lpCodec; #endif _bIsPlaying = false; @@ -1042,7 +1009,7 @@ void FPStream::waitForSync(FPStream *toplay) { * * Function: void FPStream::PlayThread(); * -* Description: Thread che si occupa del play dello stream +* Description: Thread playing the stream * \****************************************************************************/ @@ -1057,7 +1024,7 @@ void FPStream::playThread(FPStream *This) { bool bPrecache; char buf[1024]; - /* Eventi che segnalano quando bisogna eseguire qualcosa */ + /* Events that signal when you need to do something */ HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; bPrecache = true; @@ -1069,7 +1036,7 @@ void FPStream::playThread(FPStream *This) { break; } - /* Decomprime i dati che stanno per essere scritti dentro il buffer temporaneo */ + /* Uncompresses the data being written into the temporary buffer */ if (This->lastVolume == 0) ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); else if (bPrecache) @@ -1077,8 +1044,7 @@ void FPStream::playThread(FPStream *This) { bPrecache = false; - /* Attende il set di un evento. Dato che sono tutti in automatic reset, - non c'e' bisogno di resettarlo dopo */ + /* Waits for an event. Since they are all in automatic reset, there is no need to reset it after */ // uint32 dwBufStatus; // This->lpDSBuffer->GetStatus(&dwBufStatus); @@ -1093,15 +1059,15 @@ void FPStream::playThread(FPStream *This) { sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); warning(buf); */ - /* Fa uno switch per stabilire quale evento e' stato settato */ + /* Make a switch to determine which event has been set */ switch (dwResult - WAIT_OBJECT_0) { case 0: - /* Bisogna uscire dal thread */ + /* Must leave the thread */ cicla = false; break; case 1: - /* Bisogna riempire la seconda meta' del buffer */ + /* Must fill the second half of the buffer */ // if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) { // sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); @@ -1116,7 +1082,7 @@ void FPStream::playThread(FPStream *This) { break; case 2: - /* Bisogna riempire la prima meta' del buffer */ + /* Must fill the first half of the buffer */ // if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); @@ -1151,7 +1117,7 @@ void FPStream::playThread(FPStream *This) { } } - /* Ferma il buffer DirectSound */ + /* Close the DirectSound buffer */ // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); @@ -1163,17 +1129,15 @@ void FPStream::playThread(FPStream *This) { /****************************************************************************\ * -* Function: bool SetLoop(bool bLoop); +* Function: bool setLoop(bool bLoop); * -* Description: Attiva o disattiva il loop dello stream. +* Description: Unables or disables stream loop. * -* Input: bool bLoop true per attivare il loop, false per -* disattivarlo +* Input: bool bLoop True enable loop, False disables it * -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello stream. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo stream non viene fermato, -* e poi rimesso in play. +* Note: The loop must be activated BEFORE the stream starts playing. +* Any changes made during the play will have no effect until +* the stream is stopped then played again. * \****************************************************************************/ @@ -1208,8 +1172,7 @@ void FPStream::pause(bool bPause) { bIsPlaying = true; bPaused = false; - // Trucchetto per risettare il volume secondo le - // possibili nuove configurazioni sonore + // Trick to reset the volume after a possible new sound configuration SetVolume(lastVolume); } } @@ -1221,9 +1184,9 @@ void FPStream::pause(bool bPause) { * * Function: void SetVolume(int dwVolume); * -* Description: Cambia il volume dello stream +* Description: Change the volume of the stream * -* Input: int dwVolume Volume da settare (0-63) +* Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ @@ -1245,16 +1208,14 @@ void FPStream::setVolume(int dwVolume) { #endif } - - /****************************************************************************\ * * Function: void GetVolume(int *lpdwVolume); * -* Description: Chiede il volume dello stream +* Description: Gets the vgolume of the stream * -* Input: int *lpdwVolume Variabile in cui verra' inserito -* il volume corrente +* Input: int *lpdwVolume Variable that will contain the +* current volume * \****************************************************************************/ -- cgit v1.2.3 From 8335c25cb96f970bbc546caecd845d05df06a778 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 08:45:38 +1000 Subject: TONY: Fix memory leak in ActionThread if game exists whilst it is active --- engines/tony/mpal/mpal.cpp | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 7e1831ec4d..3b98acea59 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -699,38 +699,45 @@ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; int j, k; - CORO_END_CONTEXT(_ctx); + LPMPALITEM item; - const LPMPALITEM item = *(const LPMPALITEM *)param; + ~CoroContextTag() { + if (item) globalDestroy(item); + } + CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); + // The ActionThread owns the data block pointed to, so we need to make sure it's + // freed when the process exits + _ctx->item = *(LPMPALITEM *)param; + GLOBALS._mpalError = 0; - for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { - _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->item->Action[_ctx->item->dwRes].nCmds; _ctx->j++) { + _ctx->k = _ctx->item->Action[_ctx->item->dwRes].CmdNum[_ctx->j]; - if (item->_command[_ctx->k].type == 1) { + if (_ctx->item->_command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[item->_command[_ctx->k]._nCf].c_str(), - item->_command[_ctx->k]._arg1, item->_command[_ctx->k]._arg2, - item->_command[_ctx->k]._arg3, item->_command[_ctx->k]._arg4 + CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[_ctx->item->_command[_ctx->k]._nCf].c_str(), + _ctx->item->_command[_ctx->k]._arg1, _ctx->item->_command[_ctx->k]._arg2, + _ctx->item->_command[_ctx->k]._arg3, _ctx->item->_command[_ctx->k]._arg4 ); - CORO_INVOKE_4(GLOBALS._lplpFunctions[item->_command[_ctx->k]._nCf], - item->_command[_ctx->k]._arg1, - item->_command[_ctx->k]._arg2, - item->_command[_ctx->k]._arg3, - item->_command[_ctx->k]._arg4 + CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->item->_command[_ctx->k]._nCf], + _ctx->item->_command[_ctx->k]._arg1, + _ctx->item->_command[_ctx->k]._arg2, + _ctx->item->_command[_ctx->k]._arg3, + _ctx->item->_command[_ctx->k]._arg4 ); - } else if (item->_command[_ctx->k].type == 2) { + } else if (_ctx->item->_command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), item->_command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k].lpszVarName); lockVar(); - varSetValue(item->_command[_ctx->k].lpszVarName, evaluateExpression(item->_command[_ctx->k].expr)); + varSetValue(_ctx->item->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k].expr)); unlockVar(); } else { @@ -739,7 +746,8 @@ void ActionThread(CORO_PARAM, const void *param) { } } - globalDestroy(item); + globalDestroy(_ctx->item); + _ctx->item = NULL; debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); -- cgit v1.2.3 From a91553efeb0e2beaf942fc3f7db30868ac8c6afa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 09:09:18 +1000 Subject: TONY: Cleaned up the @defgroup comments --- engines/tony/custom.cpp | 3 ++- engines/tony/globals.h | 6 ++++-- engines/tony/mpal/expr.cpp | 5 +++++ engines/tony/mpal/loadmpc.cpp | 3 +++ engines/tony/mpal/mpal.cpp | 3 +++ engines/tony/mpal/mpal.h | 6 +++++- 6 files changed, 22 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 375b405400..6e057cf031 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -131,7 +131,7 @@ void LoadChangedHotspot(Common::InSaveFile *f) { /** - * @defgroup Classes required for custom functions + * Classes required for custom functions * * Tony (To Move him) -> You can do MPAL through the animation? I really think so * @@ -139,6 +139,7 @@ void LoadChangedHotspot(Common::InSaveFile *f) { * ChangeLocation -> theEngine.ChangeLocation() * AddInventory -> theEngine.AddInventory() */ + void MCharResetCodes(void) { for (int i = 0; i < 10; i++) GLOBALS._mCharacter[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[i]._code); diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 33ed36751a..098a98025e 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -253,8 +253,8 @@ public: /** * @defgroup MPAL variables - * - */ + */ + //@{ uint32 _mpalError; LPITEMIRQFUNCTION _lpiifCustom; LPLPCUSTOMFUNCTION _lplpFunctions; @@ -292,6 +292,8 @@ public: uint32 _nExecutingDialog; uint32 _nExecutingChoice; uint32 _nSelectedChoice; + + //@} }; } // End of namespace Tony diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 52751120f6..c2fadd63df 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -42,6 +42,7 @@ namespace MPAL { /** * @defgroup Mathamatical operations */ +//@{ #define OP_MUL ((1 << 4) | 0) #define OP_DIV ((1 << 4) | 1) @@ -73,9 +74,12 @@ enum ExprListTypes { ELT_PARENTH2 = 4 }; +//@} + /** * @defgroup Structures */ +//@{ /** * Mathamatical framework to manage operations @@ -96,6 +100,7 @@ typedef struct { } EXPRESSION; typedef EXPRESSION *LPEXPRESSION; +//@} /** * Duplicate a mathematical expression. diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6ed4545d67..b589827a5a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -517,6 +517,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) /** * @defgroup Exported functions */ +//@{ /** * Reads and interprets the MPC file, and create structures for various directives @@ -796,6 +797,8 @@ void FreeMpc() { } } +//@} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 3b98acea59..72d8d3045c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1395,6 +1395,7 @@ bool doSelection(uint32 i, uint32 dwData) { /** * @defgroup Exported functions */ +//@{ /** * Initialises the MPAL library and opens the .MPC file, which will be used for all queries. @@ -2918,6 +2919,8 @@ void mpalDumpDialogs(void) { unlockDialogs(); } +//@} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 9ea0c40bbc..1ec96c97d0 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -187,6 +187,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * * The following are defines used for simplifying calling the mpalQuery variants */ +//@{ /** * Gets the current version of MPAL @@ -386,11 +387,12 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoDialog(nDialog,nGroup) \ mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) +//@} /** * @defgroup Functions exported to the main game */ - +//@{ /** * Initializes the MPAL library, and opens an .MPC file, which will be 'used for all queries @@ -526,6 +528,8 @@ void lockVar(void); */ void unlockVar(void); +//@} + } // end of namespace MPAL } // end of namespace Tony -- cgit v1.2.3 From d0c649721276e289745124f28005c08d61381070 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 14:22:53 +1000 Subject: TONY: Fix crash opening the Options menu in-game --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index cca55f00dd..2e7297cac3 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -888,7 +888,7 @@ void RMOptionScreen::init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { bigBuf.addPrim(new RMGfxPrimitive(this)); - if (_nState == MENULOAD || _nState == MENUSAVE) + if (_nState == MENULOAD || _nState == MENUSAVE || _nState == MENUNONE) _nState = MENUGAME; CORO_INVOKE_0(initState); -- cgit v1.2.3 From b554063d3018a39f328f0cd818b03546918c60d6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 15:01:13 +1000 Subject: TONY: Moved global initialisations out of TonyEngine and into Globals class --- engines/tony/globals.cpp | 37 +++++++++++++++++++------------------ engines/tony/tony.cpp | 18 ------------------ 2 files changed, 19 insertions(+), 36 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 9115dafd63..3042b5843a 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -60,24 +60,7 @@ Globals::Globals() { _bTonyInTexts = false; _bStaticTalk = false; _bPatIrqFreeze = false; - _bCfgInvLocked = false; - _bCfgInvNoScroll = false; - _bCfgTimerizedText = false; - _bCfgInvUp = false; - _bCfgAnni30 = false; - _bCfgAntiAlias = false; - _bCfgSottotitoli = false; - _bCfgTransparence = false; - _bCfgInterTips = false; - _bCfgDubbing = false; - _bCfgMusic = false; - _bCfgSFX = false; _bAlwaysDisplay = false; - _nCfgTonySpeed = 0; - _nCfgTextSpeed = 0; - _nCfgDubbingVolume = 0; - _nCfgMusicVolume = 0; - _nCfgSFXVolume = 0; _bIdleExited = false; _bSkipSfxNoLoop = false; _bNoBullsEye = false; @@ -85,7 +68,6 @@ Globals::Globals() { _curSoundEffect = 0; _bFadeOutStop = false; -// OSystem::MutexRef vdb; Common::fill(&_mut[0], &_mut[10], 0); _bSkipIdle = false; _hSkipIdle = 0; @@ -143,6 +125,25 @@ Globals::Globals() { Common::fill((byte *)&_mCharacter[i], (byte *)&_mCharacter[i] + sizeof(MCharacterStruct), 0); for (int i = 0; i < 256; ++i) Common::fill((byte *)&_changedHotspot[i], (byte *)&_changedHotspot[i] + sizeof(ChangedHotspotStruct), 0); + + // Set up globals that have explicit initial values + _bCfgInvLocked = false; + _bCfgInvNoScroll = false; + _bCfgTimerizedText = true; + _bCfgInvUp = false; + _bCfgAnni30 = false; + _bCfgAntiAlias = false; + _bCfgTransparence = true; + _bCfgInterTips = true; + _bCfgSottotitoli = true; + _nCfgTonySpeed = 3; + _nCfgTextSpeed = 5; + _bCfgDubbing = true; + _bCfgMusic = true; + _bCfgSFX = true; + _nCfgDubbingVolume = 10; + _nCfgMusicVolume = 7; + _nCfgSFXVolume = 10; } } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 094e1bd038..91204763b3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -167,24 +167,6 @@ Common::ErrorCode TonyEngine::init() { // Allocate space for thumbnails when saving the game _curThumbnail = new uint16[160 * 120]; - // Set up global defaults - GLOBALS._bCfgInvLocked = false; - GLOBALS._bCfgInvNoScroll = false; - GLOBALS._bCfgTimerizedText = true; - GLOBALS._bCfgInvUp = false; - GLOBALS._bCfgAnni30 = false; - GLOBALS._bCfgAntiAlias = false; - GLOBALS._bCfgTransparence = true; - GLOBALS._bCfgInterTips = true; - GLOBALS._bCfgSottotitoli = true; - GLOBALS._nCfgTonySpeed = 3; - GLOBALS._nCfgTextSpeed = 5; - GLOBALS._bCfgDubbing = true; - GLOBALS._bCfgMusic = true; - GLOBALS._bCfgSFX = true; - GLOBALS._nCfgDubbingVolume = 10; - GLOBALS._nCfgMusicVolume = 7; - GLOBALS._nCfgSFXVolume = 10; _bQuitNow = false; return Common::kNoError; -- cgit v1.2.3 From 9405f9eb4aed1d4c248e57ab4972b0132b2253f5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 17:04:10 +1000 Subject: TONY: Added code to load and save the ScummVM sound settings --- engines/tony/font.cpp | 2 +- engines/tony/game.cpp | 7 +++++-- engines/tony/gfxengine.cpp | 4 ++-- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 2 +- engines/tony/tony.cpp | 32 ++++++++++++++++++++++++++++++++ engines/tony/tony.h | 3 +++ 7 files changed, 45 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a567fe20cd..af6f5d687c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2144,7 +2144,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p _startTime = _vm->getTime(); if (_bShowed) { - if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) { + if (GLOBALS._bShowSubtitles || _bAlwaysDisplay) { prim->getDst().topLeft() = _dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 2e7297cac3..7b2834a8fa 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -700,7 +700,7 @@ void RMOptionScreen::initState(CORO_PARAM) { _buttonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); assert(_buttonGfx_Sottotitoli == NULL); _buttonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - _buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); + _buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bShowSubtitles); assert(_buttonGfx_Tips == NULL); _buttonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); _buttonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); @@ -822,7 +822,7 @@ void RMOptionScreen::closeState(void) { delete _buttonGfx_AntiAlias; _buttonGfx_AntiAlias = NULL; - GLOBALS._bCfgSottotitoli = !_buttonGfx_Sottotitoli->isActive(); + GLOBALS._bShowSubtitles = !_buttonGfx_Sottotitoli->isActive(); delete _buttonGfx_Sottotitoli; _buttonGfx_Sottotitoli = NULL; @@ -858,6 +858,9 @@ void RMOptionScreen::closeState(void) { delete _buttonSound_SFXOn; _buttonSound_SFXOn = NULL; } + + // Save the new settings to ScummVM + _vm->saveSoundSettings(); } _nState = MENUNONE; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index deae0cb641..9dab3eeb52 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -659,7 +659,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm f->writeByte(GLOBALS._bCfgInvUp); f->writeByte(GLOBALS._bCfgAnni30); f->writeByte(GLOBALS._bCfgAntiAlias); - f->writeByte(GLOBALS._bCfgSottotitoli); + f->writeByte(GLOBALS._bShowSubtitles); f->writeByte(GLOBALS._bCfgTransparence); f->writeByte(GLOBALS._bCfgInterTips); f->writeByte(GLOBALS._bCfgDubbing); @@ -795,7 +795,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { GLOBALS._bCfgInvUp = _ctx->f->readByte(); GLOBALS._bCfgAnni30 = _ctx->f->readByte(); GLOBALS._bCfgAntiAlias = _ctx->f->readByte(); - GLOBALS._bCfgSottotitoli = _ctx->f->readByte(); + GLOBALS._bShowSubtitles = _ctx->f->readByte(); GLOBALS._bCfgTransparence = _ctx->f->readByte(); GLOBALS._bCfgInterTips = _ctx->f->readByte(); GLOBALS._bCfgDubbing = _ctx->f->readByte(); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 3042b5843a..48b04007b4 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -135,7 +135,7 @@ Globals::Globals() { _bCfgAntiAlias = false; _bCfgTransparence = true; _bCfgInterTips = true; - _bCfgSottotitoli = true; + _bShowSubtitles = true; _nCfgTonySpeed = 3; _nCfgTextSpeed = 5; _bCfgDubbing = true; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 098a98025e..cf231018a6 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -194,7 +194,7 @@ public: bool _bCfgInvUp; bool _bCfgAnni30; bool _bCfgAntiAlias; - bool _bCfgSottotitoli; + bool _bShowSubtitles; bool _bCfgTransparence; bool _bCfgInterTips; bool _bCfgDubbing; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 91204763b3..654a3f8222 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -42,6 +42,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng _vm = this; _loadSlotNumber = -1; + // Set the up the debugger _debugger = new Debugger(); DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); @@ -62,6 +63,9 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng _initialLoadSlotNumber = slotNumber; } + // Load the ScummVM sound settings + syncSoundSettings(); + _hEndOfFrame = 0; for (int i = 0; i < 6; i++) _stream[i] = NULL; @@ -627,4 +631,32 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { return Common::kNoError; } +void TonyEngine::syncSoundSettings() { + Engine::syncSoundSettings(); + + GLOBALS._bCfgDubbing = !ConfMan.getBool("mute") && !ConfMan.getBool("speech_mute"); + GLOBALS._bCfgSFX = !ConfMan.getBool("mute") && !ConfMan.getBool("sfx_mute"); + GLOBALS._bCfgMusic = !ConfMan.getBool("mute") && !ConfMan.getBool("music_mute"); + + GLOBALS._nCfgDubbingVolume = ConfMan.getInt("speech_volume") * 10 / 256; + GLOBALS._nCfgSFXVolume = ConfMan.getInt("sfx_volume") * 10 / 256; + GLOBALS._nCfgMusicVolume = ConfMan.getInt("music_volume") * 10 / 256; + + GLOBALS._bShowSubtitles = ConfMan.getBool("subtitles"); + GLOBALS._nCfgTextSpeed = ConfMan.getInt("talkspeed") * 10 / 256; +} + +void TonyEngine::saveSoundSettings() { + ConfMan.setBool("speech_mute", GLOBALS._bCfgDubbing); + ConfMan.setBool("sfx_mute", GLOBALS._bCfgSFX); + ConfMan.setBool("music_mute", GLOBALS._bCfgMusic); + + ConfMan.setInt("speech_volume", GLOBALS._nCfgDubbingVolume * 256 / 10); + ConfMan.setInt("sfx_volume", GLOBALS._nCfgSFXVolume * 256 / 10); + ConfMan.setInt("music_volume", GLOBALS._nCfgMusicVolume * 256 / 10); + + ConfMan.setBool("subtitles", GLOBALS._bShowSubtitles); + ConfMan.setBool("talkspeed", GLOBALS._nCfgTextSpeed); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 93232b950d..709465ca89 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -221,6 +221,9 @@ public: void openInitLoadMenu(CORO_PARAM); void openInitOptions(CORO_PARAM); + + virtual void syncSoundSettings(); + void saveSoundSettings(); }; // Global reference to the TonyEngine object -- cgit v1.2.3 From d24fc8b5d895b595ec62ba1588d734392bc3a5e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 17:42:29 +1000 Subject: TONY: Fix memory leak in LocationPollThread --- engines/tony/mpal/mpal.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 72d8d3045c..07042ec077 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -824,12 +824,24 @@ void LocationPollThread(CORO_PARAM, const void *param) { MYACTION *MyActions; MYTHREAD *MyThreads; + + ~CoroContextTag() { + // Free data blocks + if (MyThreads) + globalDestroy(MyThreads); + if (MyActions) + globalDestroy(MyActions); + } CORO_END_CONTEXT(_ctx); uint32 id = *((const uint32 *)param); CORO_BEGIN_CODE(_ctx); + /* Initialise data pointers */ + _ctx->MyActions = NULL; + _ctx->MyThreads = NULL; + /* To begin with, we need to request the item list from the location */ _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); @@ -1045,12 +1057,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip off CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); - /* We're finished */ - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); - - CORO_KILL_SELF(); - CORO_END_CODE; } -- cgit v1.2.3 From e36f36168d0e0b6e2abf29386c2761797735d857 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 18:09:52 +0200 Subject: TONY: Doxygen-ify comments in sound files --- engines/tony/sound.cpp | 494 ++++++++++++++++++----------------------------- engines/tony/sound.h | 514 ++++++++++++++++++------------------------------- 2 files changed, 372 insertions(+), 636 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e650a5d74b..d8b3655d2e 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -37,70 +37,43 @@ namespace Tony { -/****************************************************************************\ -* Defines -\****************************************************************************/ - #define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} -/****************************************************************************\ -* Methods for FPSound -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: FPSound::FPSound(); -* -* Description: Default constructor. Initializes the attributes. -* -\****************************************************************************/ +/** + * Default constructor. Initializes the attributes. + * + */ FPSound::FPSound() { _bSoundSupported = false; } - -/****************************************************************************\ -* -* Function: bool FPSound::init(); -* -* Description: Initializes the object, and prepare everything you need to - create streams and sound effects. -* -* Return: True if everything's OK, False otherwise. -* -\****************************************************************************/ +/** + * Initializes the object, and prepare everything you need to create streams and sound effects. + * + * @returns True is everything is OK, False otherwise + */ bool FPSound::init() { _bSoundSupported = g_system->getMixer()->isReady(); return _bSoundSupported; } - -/****************************************************************************\ -* -* Function: FPSound::~FPSound(); -* -* Description: Destroy the object and free the memory. -* -\****************************************************************************/ +/** + * Destroy the object and free the memory + * + */ FPSound::~FPSound() { } - -/****************************************************************************\ -* -* Function: bool CreateStream(FPStream** lplpStream); -* -* Description: Allocates an object of type FPStream, and return its pointer -* -* Input: FPStream** lplpStream Will contain a pointer to the object -* you just created. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Allocates an object of type FPStream, and return its pointer + * + * @param lplpStream Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool FPSound::createStream(FPStream **lplpStream) { (*lplpStream) = new FPStream(_bSoundSupported); @@ -108,18 +81,13 @@ bool FPSound::createStream(FPStream **lplpStream) { return (*lplpStream != NULL); } -/****************************************************************************\ -* -* Function: bool CreateSfx(FPSfx** lplpSfx); -* -* Description: Allocates an object of type FpSfx, and return its pointer -* -* Input: FPSfx** lplpSfx Will contain a pointer to the object -* you just created. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Allocates an object of type FpSfx, and return its pointer + * + * @param lplpSfx Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool FPSound::createSfx(FPSfx **lplpSfx) { (*lplpSfx) = new FPSfx(_bSoundSupported); @@ -127,15 +95,11 @@ bool FPSound::createSfx(FPSfx **lplpSfx) { return (*lplpSfx != NULL); } -/****************************************************************************\ -* -* Function: void setMasterVolume(int dwVolume); -* -* Description: Set the general volume -* -* Input: int dwVolume Volume to set (0-63) -* -\****************************************************************************/ +/** + * Set the general volume + * + * @param dwVolume Volume to set (0-63) + */ void FPSound::setMasterVolume(int dwVolume) { if (!_bSoundSupported) @@ -144,16 +108,11 @@ void FPSound::setMasterVolume(int dwVolume) { g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); } -/****************************************************************************\ -* -* Function: void getMasterVolume(int *lpdwVolume); -* -* Description: Get the general volume -* -* Input: int *lpdwVolume Variable that will contain the -* volume (0-63) -* -\****************************************************************************/ +/** + * Get the general volume + * + * @param lpdwVolume Variable that will contain the volume (0-63) + */ void FPSound::getMasterVolume(int *lpdwVolume) { if (!_bSoundSupported) @@ -162,18 +121,13 @@ void FPSound::getMasterVolume(int *lpdwVolume) { *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; } -/****************************************************************************\ -* Methods for FPSfx -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: FPSfx(bool bSoundOn); -* -* Description: Default constructor. Do *NOT* declare an object directly, -* but rather create it using FPSound::CreateSfx() -* -\****************************************************************************/ +/** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateSfx() + * + */ FPSfx::FPSfx(bool bSoundOn) { _bSoundSupported = bSoundOn; @@ -188,15 +142,13 @@ FPSfx::FPSfx(bool bSoundOn) { _vm->_activeSfx.push_back(this); } - -/****************************************************************************\ -* -* Function: ~FPSfx(); -* -* Description: Default Destructor. It is also stops the sound effect that -* may be currently played, and free the memory it uses. -* -\****************************************************************************/ +/** + * Default Destructor. + * + * @remarks It is also stops the sound effect that may be + * currently played, and free the memory it uses. + * + */ FPSfx::~FPSfx() { if (!_bSoundSupported) @@ -215,35 +167,19 @@ FPSfx::~FPSfx() { // CloseHandle(hEndOfBuffer); } -/****************************************************************************\ -* -* Function: release(); -* -* Description: Releases the memory used by the object. -* Must be called when the object is no longer used and -* **ONLY** if the object was created by FPSound::CreateStream() -* -* Note: Object pointers are no longer valid after this call. -* -\****************************************************************************/ +/** + * Releases the memory used by the object. + * + * @remarks Must be called when the object is no longer used and + * **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void FPSfx::release() { delete this; } -/****************************************************************************\ -* -* Function: bool loadWave(Common::SeekableReadStream *stream); -* -* Description: Opens a file and loads a sound effect. -* -* Input: byte *lpBuf Buffer containing the Sfx -* uint32 dwCodec CODEC used to uncompress the samples -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ - bool FPSfx::loadWave(Common::SeekableReadStream *stream) { if (!stream) return false; @@ -258,20 +194,6 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { return true; } - -/****************************************************************************\ -* -* Function: bool LoadFile(const char * lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Opens a file and loads a sound effect. -* -* Input: LPSTR lpszFile Sfx filename -* uint32 dwCodec CODEC used to uncompress the samples -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ - bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { if (!_bSoundSupported) return true; @@ -287,6 +209,14 @@ bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { return true; } +/** + * Opens a file and loads a sound effect. + * + * @param lpszFileName Sfx filename + * @param dwCodec CODEC used to uncompress the samples + * + * @returns True is everything is OK, False otherwise + */ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { if (!_bSoundSupported) @@ -323,16 +253,11 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { return true; } - -/****************************************************************************\ -* -* Function: bool play(); -* -* Description: Play the Sfx in memory. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Play the Sfx in memory. + * + * @returns True is everything is OK, False otherwise + */ bool FPSfx::play() { stop(); // sanity check @@ -365,16 +290,11 @@ bool FPSfx::play() { return true; } - -/****************************************************************************\ -* -* Function: bool stop(void); -* -* Description: Stop an sfx. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Stops a Sfx. + * + * @returns True is everything is OK, False otherwise + */ bool FPSfx::stop() { if (_bFileLoaded) { @@ -385,26 +305,25 @@ bool FPSfx::stop() { return true; } - - -/****************************************************************************\ -* -* Function: bool setLoop(bool bLoop); -* -* Description: Enables or disables the Sfx loop. -* -* Input: bool bLoop True to enable the loop, False to disable -* -* Note: The loop must be activated BEFORE the sfx starts playing. -* Any changes made during the play will have no effect until -* the sfx is stopped then played again. -* -\****************************************************************************/ +/** + * Enables or disables the Sfx loop. + * + * @param bLoop True to enable the loop, False to disable + * + * @remarks The loop must be activated BEFORE the sfx starts + * playing. Any changes made during the play will have + * no effect until the sfx is stopped then played again. + */ void FPSfx::setLoop(bool bLop) { _bLoop = bLop; } +/** + * Pauses a Sfx. + * + */ + void FPSfx::pause(bool bPause) { if (_bFileLoaded) { if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ _bPaused)) @@ -414,15 +333,12 @@ void FPSfx::pause(bool bPause) { } } -/****************************************************************************\ -* -* Function: void setVolume(int dwVolume); -* -* Description: Change the volume of Sfx -* -* Input: int dwVolume Volume to be set (0-63) -* -\****************************************************************************/ +/** + * Change the volume of Sfx + * + * @param dwVolume Volume to be set (0-63) + * + */ void FPSfx::setVolume(int dwVolume) { if (dwVolume > 63) @@ -453,17 +369,12 @@ void FPSfx::setVolume(int dwVolume) { g_system->getMixer()->setChannelVolume(_handle, dwVolume * Audio::Mixer::kMaxChannelVolume / 63); } - - -/****************************************************************************\ -* -* Function: void GetVolume(int *lpdwVolume); -* -* Description: Gets the Sfx volume -* -* Input: int *lpdwVolume Will contain the current Sfx volume -* -\****************************************************************************/ +/** + * Gets the Sfx volume + * + * @param lpdwVolume Will contain the current Sfx volume + * + */ void FPSfx::getVolume(int *lpdwVolume) { if (g_system->getMixer()->isSoundHandleActive(_handle)) @@ -475,6 +386,7 @@ void FPSfx::getVolume(int *lpdwVolume) { /** * Returns true if the underlying sound has ended */ + bool FPSfx::endOfBuffer() const { return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_rewindableStream || _rewindableStream->endOfData()); } @@ -505,18 +417,12 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { CORO_END_CODE; } -/****************************************************************************\ -* Methods for FPStream -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: FPStream(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Default constructor. Do *NOT* declare an object directly, -* but rather create it using FPSound::CreateStream() -* -\****************************************************************************/ +/** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateStream() + */ FPStream::FPStream(bool bSoundOn) { #ifdef REFACTOR_ME @@ -599,14 +505,11 @@ bool FPStream::createBuffer(int nBufSize) { return true; } - -/****************************************************************************\ -* -* Function: ~FPStream(); -* -* Description: Default destructor. It calls CloseFile() if needed. -* -\****************************************************************************/ +/** + * Default destructor. + * + * @remarks It calls CloseFile() if needed. + */ FPStream::~FPStream() { #ifdef REFACTOR_ME @@ -648,37 +551,27 @@ FPStream::~FPStream() { #endif } - -/****************************************************************************\ -* -* Function: release(); -* -* Description: Releases the memory object. Must be called when the object -* is no longer used and **ONLY** if the object was created by -* FPSound::CreateStream(). -* -* Note: Object pointers are no longer valid after this call. -* -\****************************************************************************/ +/** + * Releases the memory object. + * + * @remarks Must be called when the object is no longer used + * and **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void FPStream::release() { delete this; -// return NULL; } - -/****************************************************************************\ -* -* Function: bool loadFile(const char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Opens a file stream. -* -* Input: LPSTR lpszFile Filename to be opened -* uint32 dwCodec CODEC to be used to uncompress samples -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Opens a file stream + * + * @param lpszFile Filename to be opened + * @param dwCodec CODEC to be used to uncompress samples + * + * @returns True is everything is OK, False otherwise + */ bool FPStream::loadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { #ifdef REFACTOR_ME @@ -714,18 +607,15 @@ bPaused = false; return true; } - -/****************************************************************************\ -* -* Function: unloadFile(); -* -* Description: Closes a file stream (opened or not). It is necessary to call -* this function to free the memory used by the stream. -* -* Return: For safety, the destructor calls unloadFile() if it has not -* been mentioned explicitly. -* -\****************************************************************************/ +/** + * Closes a file stream (opened or not). + * + * @returns For safety, the destructor calls unloadFile() if it has not + * been mentioned explicitly. + * + * @remarks It is necessary to call this function to free the + * memory used by the stream. + */ bool FPStream::unloadFile() { #ifdef REFACTOR_ME @@ -745,16 +635,6 @@ bool FPStream::unloadFile() { return true; } -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Play the stream. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ - void FPStream::prefetch(void) { #ifdef REFACTOR_ME uint32 dwId; @@ -845,6 +725,12 @@ void FPStream::playFast(void) { #endif } +/** + * Play the stream. + * + * @returns True is everything is OK, False otherwise + */ + bool FPStream::play() { #ifdef REFACTOR_ME uint32 dwId; @@ -922,16 +808,12 @@ bool FPStream::play() { return true; } - -/****************************************************************************\ -* -* Function: bool stop(bool bSync); -* -* Description: Closes the stream. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Closes the stream. + * + * @returns True is everything is OK, False otherwise + * + */ bool FPStream::stop(bool bSync) { #ifdef REFACTOR_ME @@ -1005,13 +887,10 @@ void FPStream::waitForSync(FPStream *toplay) { _bIsPlaying = false; } -/****************************************************************************\ -* -* Function: void FPStream::PlayThread(); -* -* Description: Thread playing the stream -* -\****************************************************************************/ +/** + * Thread playing the stream + * + */ void FPStream::playThread(FPStream *This) { #ifdef REFACTOR_ME @@ -1126,26 +1005,27 @@ void FPStream::playThread(FPStream *This) { #endif } - -/****************************************************************************\ -* -* Function: bool setLoop(bool bLoop); -* -* Description: Unables or disables stream loop. -* -* Input: bool bLoop True enable loop, False disables it -* -* Note: The loop must be activated BEFORE the stream starts playing. -* Any changes made during the play will have no effect until -* the stream is stopped then played again. -* -\****************************************************************************/ +/** + * Unables or disables stream loop. + * + * @param bLoop True enable loop, False disables it + * + * @remarks The loop must be activated BEFORE the stream starts + * playing. Any changes made during the play will have no + * effect until the stream is stopped then played again. + */ void FPStream::setLoop(bool loop) { _bLoop = loop; } +/** + * Pause sound effect + * + * @param bPause True enables pause, False disables it + */ + void FPStream::pause(bool bPause) { #ifdef REFACTOR_ME @@ -1179,16 +1059,12 @@ void FPStream::pause(bool bPause) { #endif } - -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Change the volume of the stream -* -* Input: int dwVolume Volume to be set (0-63) -* -\****************************************************************************/ +/** + * Change the volume of the stream + * + * @param dwVolume Volume to be set (0-63) + * + */ void FPStream::setVolume(int dwVolume) { #ifdef REFACTOR_ME @@ -1208,16 +1084,12 @@ void FPStream::setVolume(int dwVolume) { #endif } -/****************************************************************************\ -* -* Function: void GetVolume(int *lpdwVolume); -* -* Description: Gets the vgolume of the stream -* -* Input: int *lpdwVolume Variable that will contain the -* current volume -* -\****************************************************************************/ +/** + * Gets the vgolume of the stream + * + * @param lpdwVolume Variable that will contain the current volume + * + */ void FPStream::getVolume(int *lpdwVolume) { #ifdef REFACTOR_ME diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 5e50c31554..e1f0e40851 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -50,131 +50,77 @@ enum SoundCodecs { }; -/****************************************************************************\ -***************************************************************************** -* class FPSound -* ------------- -* Description: Sound driver per Falling Pumpkins -***************************************************************************** -\****************************************************************************/ +//**************************************************************************** +//* class FPSound +//* ------------- +//* Description: Sound driver For Tony Tough +//**************************************************************************** class FPSound { - private: - bool _bSoundSupported; - /****************************************************************************\ - * Methods - \****************************************************************************/ - public: - - /****************************************************************************\ - * - * Function: FPSound::FPSound(); - * - * Description: Default constructor. Initializes the attributes - * - \****************************************************************************/ + /** + * Default constructor. Initializes the attributes. + * + */ FPSound(); - /****************************************************************************\ - * - * Function: FPSound::~FPSound(); - * - * Description: Deinitialize the object, free memory - * - \****************************************************************************/ + /** + * Destroy the object and free the memory + * + */ ~FPSound(); - /****************************************************************************\ - * - * Function: bool FPSound::Init(); - * - * Description: Initializes the objects, and prepare everything required to - * create streams and sound effects. - * - * Return: True if everything is OK, False otherwise. - * - \****************************************************************************/ + /** + * Initializes the object, and prepare everything you need to create streams and sound effects. + * + * @returns True is everything is OK, False otherwise + */ bool init(); - /****************************************************************************\ - * - * Function: bool CreateStream(FPStream** lplpStream); - * - * Description: Allocates an object of type FPStream, and return its - * pointer after it has been initialized. - * - * Input: FPStream** lplpStream Will contain the pointer of the - * object - * - * Return: True is everything i OK, False otherwise - * - * Note: The use of functions like CreateStream () and CreateSfx () - * are due to the fact that the class constructors and - * FPStream FPSfx require that DirectSound is already initialized. - * In this way, you avoid the bugs that would be created if an - * object type is declared FPStream FPSfx or global - * (or anyway before initializing DirectSound). - \****************************************************************************/ + /** + * Allocates an object of type FPStream, and return its pointer + * + * @param lplpStream Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool createStream(FPStream **lplpStream); - /****************************************************************************\ - * - * Function: bool CreateSfx(FPSfx** lplpSfx); - * - * Description: Allocates an object of type FPSfx and returns a pointer - * pointing to it - * - * Input: FPSfx** lplpSfx Will contain the pointer of the - * object - * - * Return: True is everything i OK, False otherwise - * - * Note: See notes about CreateStream() - * - \****************************************************************************/ + /** + * Allocates an object of type FpSfx, and return its pointer + * + * @param lplpSfx Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool createSfx(FPSfx **lplpSfx); - /****************************************************************************\ - * - * Function: void SetMasterVolume(int dwVolume); - * - * Description: Set main volume - * - * Input: int dwVolume Volume to be set (0-63) - * - \****************************************************************************/ + /** + * Set the general volume + * + * @param dwVolume Volume to set (0-63) + */ void setMasterVolume(int dwVolume); - /****************************************************************************\ - * - * Function: void GetMasterVolume(LPINT lpdwVolume); - * - * Description: Get main volume - * - * Input: LPINT lpdwVolume This variable will contain the - * current volume (0-63) - * - \****************************************************************************/ + /** + * Get the general volume + * + * @param lpdwVolume Variable that will contain the volume (0-63) + */ void getMasterVolume(int *lpdwVolume); }; class FPSfx { - - /****************************************************************************\ - * Attributes - \****************************************************************************/ - private: bool _bSoundSupported; // True if the sound is active bool _bFileLoaded; // True is a file is opened @@ -191,167 +137,121 @@ private: public: uint32 _hEndOfBuffer; -private: - - - /****************************************************************************\ - * Methods - \****************************************************************************/ - -public: /** * Check process for whether sounds have finished playing */ static void soundCheckProcess(CORO_PARAM, const void *param); - /****************************************************************************\ - * - * Function: FPSfx(bool bSoundOn); - * - * Description: Default constructor. *DO NOT* declare the object directly, - * create it though FPSound::CreateSfx() instead - * - \****************************************************************************/ + /** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateSfx() + * + */ FPSfx(bool bSoundOn); - /****************************************************************************\ - * - * Function: ~FPSfx(); - * - * Description: Default destructor. It also stops the sound effect that - * may be running, and free the memory used. - * - \****************************************************************************/ + /** + * Default Destructor. + * + * @remarks It is also stops the sound effect that may be + * currently played, and free the memory it uses. + * + */ ~FPSfx(); - /****************************************************************************\ - * - * Function: release(); - * - * Description: Releases the memory object. Must be called when the object - * is no longer useful and **ONLY** when the object was created - * with the FPSound :: CreateStream (). - * - * Note: Any object pointers are no longer valid after this call. - * - \****************************************************************************/ + /** + * Releases the memory used by the object. + * + * @remarks Must be called when the object is no longer used and + * **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void release(); - /****************************************************************************\ - * - * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); - * - * Description: Opens a file and load sound effect - * - * Input: char *lpszFile SFX filename - * uint32 dwCodec CODEC to be used to decompress - * the sound samples - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Opens a file and loads a sound effect. + * + * @param lpszFileName Sfx filename + * @param dwCodec CODEC used to uncompress the samples + * + * @returns True is everything is OK, False otherwise + */ bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool loadWave(Common::SeekableReadStream *stream); bool loadVoiceFromVDB(Common::File &vdbFP); - /****************************************************************************\ - * - * Function: bool play(); - * - * Description: Play the loaded FX. - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Play the Sfx in memory. + * + * @returns True is everything is OK, False otherwise + */ bool play(); - /****************************************************************************\ - * - * Function: bool stop(); - * - * Description: Stop a FX - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Stops a Sfx. + * + * @returns True is everything is OK, False otherwise + */ bool stop(); - /****************************************************************************\ - * - * Function: void pause(bool bPause); - * - * Description: Pause a FX - * - \****************************************************************************/ + /** + * Pauses a Sfx. + * + */ void pause(bool bPause); - /****************************************************************************\ - * - * Function: bool setLoop(bool bLoop); - * - * Description: Enables or disables SFX loop - * - * Input: bool bLoop True to activate the loop, else False - * - * Note: The loop must be activated before the SFX starts to play, - * else the effect will only be noticable next time the SFX is - * played - * - \****************************************************************************/ + /** + * Enables or disables the Sfx loop. + * + * @param bLoop True to enable the loop, False to disable + * + * @remarks The loop must be activated BEFORE the sfx starts + * playing. Any changes made during the play will have + * no effect until the sfx is stopped then played again. + */ void setLoop(bool bLoop); - /****************************************************************************\ - * - * Function: void setVolume(int dwVolume); - * - * Description: Set SFX Volume - * - * Input: int dwVolume Volume to set (0-63) - * - \****************************************************************************/ + /** + * Change the volume of Sfx + * + * @param dwVolume Volume to be set (0-63) + * + */ void setVolume(int dwVolume); - /****************************************************************************\ - * - * Function: void getVolume(int * lpdwVolume); - * - * Description: Get SFX volume - * - * Input: int * lpdwVolume Will contain the current volume - * - \****************************************************************************/ + /** + * Gets the Sfx volume + * + * @param lpdwVolume Will contain the current Sfx volume + * + */ void getVolume(int *lpdwVolume); /** - * Returns true if the sound has finished playing + * Returns true if the underlying sound has ended */ bool endOfBuffer() const; }; class FPStream { - - /****************************************************************************\ - * Attributes - \****************************************************************************/ - private: + // HWND hwnd; + // LPDIRECTSOUND lpDS; + // LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer + // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer - /* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer - */ byte *_lpTempBuffer; // Temporary buffer use for decompression uint32 _dwBufferSize; // Buffer size (bytes) @@ -373,7 +273,8 @@ private: bool _bPaused; int _lastVolume; FPStream *_syncToPlay; -// DSBPOSITIONNOTIFY dspnHot[3]; + + // DSBPOSITIONNOTIFY dspnHot[3]; bool createBuffer(int nBufSize); @@ -381,155 +282,118 @@ public: bool _bIsPlaying; // True if the stream is playing private: - + /** + * Thread playing the stream + * + */ static void playThread(FPStream *This); - /****************************************************************************\ - * Methods - \****************************************************************************/ - public: - /****************************************************************************\ - * - * Function: FPStream(bool bSoundOn); - * - * Description: Default contractor. *DO NOT* declare the object directly: use - * FPSound::CreateStream() indtead - * - \****************************************************************************/ + /** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateStream() + */ FPStream(bool bSoundOn); - /****************************************************************************\ - * - * Function: ~FPStream(); - * - * Description: Destructor by default. Stops the playing stream (if any) and - * frees the memory used by them - * - \****************************************************************************/ + /** + * Default destructor. + * + * @remarks It calls CloseFile() if needed. + */ ~FPStream(); - /****************************************************************************\ - * - * Function: release(); - * - * Description: Releases memory used by object. Must be used when the object - * is no longer used. *ONLY*for objects created by - * FPSound::CreateStream(). - * - * Note: Object pointers are no longer valid after this call. - * - \****************************************************************************/ + /** + * Releases the memory object. + * + * @remarks Must be called when the object is no longer used + * and **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void release(); - /****************************************************************************\ - * - * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); - * - * Description: Open a file for a stream. - * - * Input: char *lpszFile Filename to be opened - * uint32 dwCodec CODEC to be used to decompress - * sound samples - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Opens a file stream + * + * @param lpszFile Filename to be opened + * @param dwCodec CODEC to be used to uncompress samples + * + * @returns True is everything is OK, False otherwise + */ bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); - /****************************************************************************\ - * - * Function: unloadFile(); - * - * Description: Close a file stream (if opened). This function must be - * called to free the memory used by the stream - * - * Return: Just to be sure, the destructor of this class calls - * UnloadFile() if it has not been mentioned explicitly - * - \****************************************************************************/ + /** + * Closes a file stream (opened or not). + * + * @returns For safety, the destructor calls unloadFile() if it has not + * been mentioned explicitly. + * + * @remarks It is necessary to call this function to free the + * memory used by the stream. + */ bool unloadFile(); - /****************************************************************************\ - * - * Function: bool play(); - * - * Description: Play the loaded stream. - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Play the stream. + * + * @returns True is everything is OK, False otherwise + */ bool play(); void playFast(void); void prefetch(void); - /****************************************************************************\ - * - * Function: bool stop(); - * - * Description: Stops the play of the stream. - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Closes the stream. + * + * @returns True is everything is OK, False otherwise + */ bool stop(bool bSync = false); void waitForSync(FPStream *toplay); - /****************************************************************************\ - * - * Function: void pause(bool bPause); - * - * Description: Pause sound effect - * - \****************************************************************************/ + /** + * Pause sound effect + * + * @param bPause True enables pause, False disables it + */ void pause(bool bPause); - /****************************************************************************\ - * - * Function: bool setLoop(bool bLoop); - * - * Description: Enable of disable stream loop - * - * Input: bool bLoop True to enable loop, false otherwise - * - * Note: The loop must be activated BEFORE you play back the stream. - * Any changes made during play will not have 'effect until - * the stream is not stopped, and then comes back into play. - * - \****************************************************************************/ + /** + * Unables or disables stream loop. + * + * @param bLoop True enable loop, False disables it + * + * @remarks The loop must be activated BEFORE the stream starts + * playing. Any changes made during the play will have no + * effect until the stream is stopped then played again. + */ void setLoop(bool bLoop); - /****************************************************************************\ - * - * Function: void setVolume(int dwVolume); - * - * Description: Change stream colume - * - * Input: int dwVolume Volume to be set (0-63) - * - \****************************************************************************/ + /** + * Change the volume of the stream + * + * @param dwVolume Volume to be set (0-63) + */ void setVolume(int dwVolume); - /****************************************************************************\ - * - * Function: void getVolume(LPINT lpdwVolume); - * - * Description: Get stream volume - * - * Input: LPINT lpdwVolume Will contain the current stream volume - * - \****************************************************************************/ + /** + * Gets the vgolume of the stream + * + * @param lpdwVolume Variable that will contain the current volume + * + */ void getVolume(int *lpdwVolume); }; -- cgit v1.2.3 From b36b66630086044c54f745acfb64f91d90713045 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 18:36:23 +0200 Subject: TONY: American-ification of English used --- engines/tony/custom.cpp | 12 ++++++------ engines/tony/font.cpp | 16 ++++++++-------- engines/tony/font.h | 2 +- engines/tony/gfxcore.cpp | 4 ++-- engines/tony/gfxcore.h | 12 ++++++------ engines/tony/gfxengine.cpp | 10 +++++----- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 2 +- engines/tony/loc.cpp | 10 +++++----- engines/tony/loc.h | 2 +- engines/tony/mpal/loadmpc.cpp | 2 +- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/tony.cpp | 14 +++++++------- engines/tony/tonychar.h | 2 +- engines/tony/utils.h | 2 +- engines/tony/window.cpp | 2 +- 16 files changed, 49 insertions(+), 49 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6e057cf031..fd5d17470b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -308,7 +308,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Alignment _ctx->text.setAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colour + // Color _ctx->text.setColor(0, 255, 0); // Writes the text @@ -427,7 +427,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 // Forces the text to disappear in time _ctx->text.forceTime(); - // Colour + // Color _ctx->text.setColor(255, 255, 255); // Write the text @@ -1511,7 +1511,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Alignment _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colour + // Color _ctx->text->setColor(GLOBALS._character[nChar]._r, GLOBALS._character[nChar]._g, GLOBALS._character[nChar]._b); // Write the text @@ -1690,7 +1690,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + _vm->_randomSource.getRandomNumber( GLOBALS._mCharacter[nChar]._numTalks[GLOBALS._mCharacter[nChar]._curGroup] - 1) + 1; - // Try to run the custom function to initialise the speech + // Try to run the custom function to initialize the speech if (GLOBALS._mCharacter[nChar]._item) { _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nChar]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { @@ -1724,7 +1724,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Alignment _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colour + // Color _ctx->text->setColor(GLOBALS._mCharacter[nChar]._r, GLOBALS._mCharacter[nChar]._g, GLOBALS._mCharacter[nChar]._b); // Write the text @@ -1874,7 +1874,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (GLOBALS._mCharacter[nPers]._numTexts != 0 && GLOBALS._mCharacter[nPers]._bInTexts) { GLOBALS._mCharacter[nPers]._numTexts--; } else { - // Try to run the custom function to initialise the speech + // Try to run the custom function to initialize the speech _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nPers]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index af6f5d687c..874d3d490b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -67,9 +67,9 @@ void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, i void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { _letter = new RMGfxSourceBuffer8RLEByte[nChars]; - // Initialise the fonts + // Initialize the fonts for (int i = 0; i < nChars; i++) { - // Initialise the buffer with the letters + // Initialize the buffer with the letters _letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); _letter[i].loadPaletteWA(palResID); } @@ -172,7 +172,7 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { int i; byte pal[768 * 3]; - // Check if we are already on the right colour + // Check if we are already on the right color if (_fontR == r1 && _fontG == g1 && _fontB == b1) return; @@ -219,7 +219,7 @@ void RMFontParla::init(void) { load(RES_F_PARL, nchars, 20, 20); - // Initialise the f**king table + // Initialize the f**king table _lDefault = 13; _hDefault = 18; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -1456,7 +1456,7 @@ void RMFontObj::init(void) { load(RES_F_OBJ, nchars, 25, 30); - // Initialise the f**king table + // Initialize the f**king table _lDefault = 26; _hDefault = 30; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -1767,7 +1767,7 @@ void RMText::initStatics() { } RMText::RMText() { - // Default colour: white + // Default color: white _textR = _textG = _textB = 255; // Default length @@ -1804,7 +1804,7 @@ void RMText::removeThis(CORO_PARAM, bool &result) { void RMText::writeText(const RMString &text, int nFont, int *time) { - // Initialises the font (only once) + // Initializes the font (only once) if (_fonts[0] == NULL) { _fonts[0] = new RMFontParla; _fonts[0]->init(); @@ -1830,7 +1830,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { char *string; int numlines; - // Set the base colour + // Set the base color font->setBaseColor(_textR, _textG, _textB); // Destroy the buffer before starting diff --git a/engines/tony/font.h b/engines/tony/font.h index f24223d551..1da1e063f7 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -224,7 +224,7 @@ public: // Overloading of the Draw to center the text, if necessary virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Set the base colour + // Set the base color void setColor(byte r, byte g, byte b) { _textR = r; _textG = g; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 2f38f5d05d..e973fe9f6b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -204,7 +204,7 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int /** - * Initialises a surface by resource Id + * Initializes a surface by resource Id * * @param resID Resource ID * @param dimx Buffer X dimension @@ -1870,7 +1870,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } void RMGfxSourceBuffer16::prepareImage(void) { - // Colour space conversion if necessary! + // Color space conversion if necessary! int i; uint16 *buf = (uint16 *)_buf; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index e221753a47..bec33183c6 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -272,7 +272,7 @@ public: /** - * Task that draws a coloured box + * Task that draws a colored box */ class RMGfxBox : public RMGfxTaskSetPrior { protected: @@ -312,7 +312,7 @@ public: /** - * 16-bit colour source + * 16-bit color source */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: @@ -358,7 +358,7 @@ public: /** - * Buffer source with a 256 colour palette + * Buffer source with a 256 color palette */ class RMGfxSourceBuffer8 : public RMGfxSourceBufferPal { protected: @@ -378,7 +378,7 @@ public: /** - * Buffer source with a 256 colour palette, and alpha blending + * Buffer source with a 256 color palette, and alpha blending */ class RMGfxSourceBuffer8AB : public RMGfxSourceBuffer8 { protected: @@ -391,7 +391,7 @@ public: /** - * Buffer source with a 256 colour palette, RLE compressed + * Buffer source with a 256 color palette, RLE compressed */ class RMGfxSourceBuffer8RLE : public virtual RMGfxSourceBuffer8 { @@ -528,7 +528,7 @@ public: /** - * Source buffer with 16 colours + * Source buffer with 16 colors */ class RMGfxSourceBuffer4 : public RMGfxSourceBufferPal { public: diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 9dab3eeb52..bb48be11c4 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -497,21 +497,21 @@ void RMGfxEngine::init() { // Create the freeze event _csMainLoop = g_system->createMutex(); - // Initialise the IRQ function for items for MPAL + // Initialize the IRQ function for items for MPAL GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); - // Initialise the input + // Initialize the input _input.init(); - // Initialise the mouse pointer + // Initialize the mouse pointer _point.init(); - // Initialise Tony + // Initialize Tony _tony.init(); _tony.linkToBoxes(&_vm->_theBoxes); - // Initialise the inventory and the interface + // Initialize the inventory and the interface _inv.init(); _inter.init(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 18c13d8d3d..9cc586d25d 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -86,7 +86,7 @@ public: // Draw the next frame void doFrame(CORO_PARAM, bool bDrawLocation); - // Initialises the graphics engine + // Initializes the graphics engine void init(); // Closes the graphics engine diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 4d824bb10a..7b111f8f58 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -99,7 +99,7 @@ void RMInventory::init(void) { assert(res.isValid()); - // Initialise the MPAL inventory item by reading it in. + // Initialize the MPAL inventory item by reading it in. _items[i]._icon.setInitCurPattern(false); ds.openBuffer(res); ds >> _items[i]._icon; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d36c004baf..d92b28845b 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -614,7 +614,7 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _patterns[i].readFromStream(ds, false); } - // Initialise the current pattern + // Initialize the current pattern if (_bInitCurPattern) setPattern(mpalQueryItemPattern(_mpalCode)); @@ -2051,11 +2051,11 @@ bool RMLocation::load(RMDataStream &ds) { ds >> dimx >> dimy; _curScroll.set(0, 0); - // Read the colour mode + // Read the color mode ds >> cm; _cmode = (RMColorMode)cm; - // Initialise the source buffer and read the location + // Initialize the source buffer and read the location switch (_cmode) { case CM_256: _buf = new RMGfxSourceBuffer8; @@ -2070,7 +2070,7 @@ bool RMLocation::load(RMDataStream &ds) { break; }; - // Initialise the surface, loading the palette if necessary + // Initialize the surface, loading the palette if necessary _buf->init(ds, dimx, dimy, true); // Check the size of the location @@ -2117,7 +2117,7 @@ bool RMLocation::loadLOX(RMDataStream &ds) { _cmode = CM_65K; _buf = new RMGfxSourceBuffer16; - // Initialise the surface, loading in the palette if necessary + // Initialize the surface, loading in the palette if necessary _buf->init(ds, dimx, dimy, true); // Number of items diff --git a/engines/tony/loc.h b/engines/tony/loc.h index ac0bb1d69a..b863a3af1b 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -42,7 +42,7 @@ namespace Tony { \****************************************************************************/ /** - * Valid colour modes + * Valid color modes */ typedef enum { CM_256, diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index b589827a5a..1ec921dbd4 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -334,7 +334,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * data of the item. * @returns Pointer to the buffer after the item, or NULL on failure. * @remarks It's necessary that the structure that is passed has been - * completely initialised to 0 beforehand. + * completely initialized to 0 beforehand. */ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 07042ec077..bb3df1662f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -838,7 +838,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - /* Initialise data pointers */ + /* Initialize data pointers */ _ctx->MyActions = NULL; _ctx->MyThreads = NULL; @@ -1404,7 +1404,7 @@ bool doSelection(uint32 i, uint32 dwData) { //@{ /** - * Initialises the MPAL library and opens the .MPC file, which will be used for all queries. + * Initializes the MPAL library and opens the .MPC file, which will be used for all queries. * * @param lpszMpcFileName Name of the MPC file * @param lpszMprFileName Name of the MPR file diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 654a3f8222..c2f3cc4c89 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -107,7 +107,7 @@ Common::Error TonyEngine::run() { } /** - * Initialise the game + * Initialize the game */ Common::ErrorCode TonyEngine::init() { if (isCompressed()) { @@ -135,10 +135,10 @@ Common::ErrorCode TonyEngine::init() { // Reset the scheduler CoroScheduler.reset(); - // Initialise the graphics window + // Initialize the graphics window _window.init(); - // Initialise the function list + // Initialize the function list Common::fill(_funcList, _funcList + 300, (LPCUSTOMFUNCTION)NULL); initCustomFunctionMap(); @@ -151,17 +151,17 @@ Common::ErrorCode TonyEngine::init() { if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", _funcList, _funcListStrings)) return Common::kUnknownError; - // Initialise the update resources + // Initialize the update resources _resUpdate.init("ROASTED.MPU"); - // Initialise the music + // Initialize the music initMusic(); - // Initialise the voices database + // Initialize the voices database if (!openVoiceDatabase()) return Common::kReadingFailed; - // Initialise the boxes + // Initialize the boxes _theBoxes.init(); // Link to the custom graphics engine diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 203d391fbe..507ff28f6b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -362,7 +362,7 @@ public: static void initStatics(); RMTony(); - // Initialise Tony + // Initialize Tony void init(void); // Free all memory diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 33e2db7d7e..4b0074f94c 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -293,7 +293,7 @@ public: bool operator==(const RMRect &rc); bool operator!=(const RMRect &rc); - // Normalise + // Normalize void normalizeRect(); // Point in rect diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 3b60e480f6..dd7c70fe19 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -49,7 +49,7 @@ RMWindow::~RMWindow() { } /** - * Initialises the graphics window + * Initializes the graphics window */ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); -- cgit v1.2.3 From 31c0210f22bb4cc839abb9fa59539fd97d3a74f6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 18:38:34 +0200 Subject: TONY: Missed one word in previous commit (thanks clone2727) --- engines/tony/detection_tables.h | 2 +- engines/tony/mpal/mpaldll.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index bf4af08d2f..e37ba11dbf 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -29,7 +29,7 @@ static const TonyGameDescription gameDescriptions[] = { "tony", 0, { - // TODO: AdvancedDetector seems to have a problem where it thinks data1.cab is unrecognised. + // TODO: AdvancedDetector seems to have a problem where it thinks data1.cab is unrecognized. // Is it perhaps because the Agos engine also has detection entries for data1.cab? {"data1.cab", 0, "ce82907242166bfb594d97bdb68f96d2", 4350}, /*{"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 952a0957c5..fe1eb2b34a 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -114,7 +114,7 @@ typedef LPMPALLOCATION *LPLPMPALLOCATION; */ struct command { /* - * Types of commands that are recognised + * Types of commands that are recognized * * #1 -> Custom function call (ITEM, SCRIPT, DIALOG) * #2 -> Variable assignment (ITEM, SCRIPT, DIALOG) -- cgit v1.2.3 From a46b06a587cc0b5e5767b55ba0d56264a8078f0c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 19:39:58 +0200 Subject: TONY: Move functions comment to doxygen format --- engines/tony/font.cpp | 2 +- engines/tony/font.h | 6 +-- engines/tony/game.cpp | 8 +--- engines/tony/game.h | 58 ++++++++++++++++++++-------- engines/tony/gfxcore.h | 14 +++---- engines/tony/gfxengine.cpp | 2 - engines/tony/globals.h | 5 --- engines/tony/input.h | 32 ++++++++++++---- engines/tony/inventory.h | 96 ++++++++++++++++++++++++++++++++++------------ engines/tony/resid.h | 4 +- engines/tony/tony.cpp | 3 -- engines/tony/tony.h | 21 +++++++--- engines/tony/tonychar.cpp | 11 +----- engines/tony/tonychar.h | 84 ++++++++++++++++++++++++++++++---------- engines/tony/window.h | 24 +++++++++--- 15 files changed, 249 insertions(+), 121 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 874d3d490b..a16179d507 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2380,7 +2380,7 @@ void RMDialogChoice::setNumChoices(int num) { _drawedStrings = new RMText[num]; _ptDrawStrings = new RMPoint[num]; - // Initialisation + // Initialization for (i = 0; i < _numChoices; i++) { _drawedStrings[i].setColor(0, 255, 0); _drawedStrings[i].setAlignType(RMText::HLEFTPAR, RMText::VTOP); diff --git a/engines/tony/font.h b/engines/tony/font.h index 1da1e063f7..1b10304b5a 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -89,7 +89,7 @@ public: RMFont(); virtual ~RMFont(); - // Initialisation and closing + // Initialization and closing virtual void init(void) = 0; virtual void close(void); @@ -366,11 +366,11 @@ public: void Unregister(void); public: - // Initialisation + // Initialization RMDialogChoice(); virtual ~RMDialogChoice(); - // Initialisation and closure + // Initialization and closure void init(void); void close(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 7b2834a8fa..493887cfa9 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -316,8 +316,6 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } - - /****************************************************************************\ * RMOptionScreen Methods \****************************************************************************/ @@ -379,7 +377,6 @@ RMOptionScreen::RMOptionScreen(void) { _nLastState = MENUGAME; } - RMOptionScreen::~RMOptionScreen(void) { closeState(); } @@ -567,7 +564,6 @@ void RMOptionScreen::refreshThumbnails(void) { } } - void RMOptionScreen::initState(CORO_PARAM) { CORO_BEGIN_CONTEXT; RMResRaw *raw; @@ -1097,7 +1093,6 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh |= _buttonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (_statePos < 90) _ctx->bRefresh |= _buttonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - } } @@ -1195,7 +1190,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { if (_buttonSave_States[_ctx->i]->isActive()) { // There by saving or loading!!! if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { - // Caricamento + // Loading CORO_INVOKE_1(_vm->loadState, _statePos + _ctx->i); close(); } else if (_nState == MENUSAVE && (_statePos != 0 || _ctx->i != 0)) { @@ -1468,7 +1463,6 @@ bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS return true; } - /****************************************************************************\ * RMPointer Methods \****************************************************************************/ diff --git a/engines/tony/game.h b/engines/tony/game.h index bd15b962e6..64f4fb8e30 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -81,32 +81,48 @@ public: }; public: - // Constructor & destructor + /** + * Constructor & destructor + */ RMPointer(); virtual ~RMPointer(); - // Initialisation + /** + * Initialization + */ void init(void); - // Deinitialisation + /** + * Deinitialization + */ void close(void); - // Process a frame + /** + * Process a frame + */ void doFrame(RMGfxTargetBuffer *bigBuf); - // Overloading of priorities + /** + * Overloading of priorities + */ int priority(); - // draw method + /** + * draw method + */ void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Sets a new action as current + /** + * Sets a new action as current + */ void setAction(RMTonyAction action) { _nCurPointer = action; updateCursor(); } - // Sets a new pointer + /** + * Sets a new pointer + */ void setSpecialPointer(PointerType ptr) { _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) @@ -118,19 +134,27 @@ public: return (PointerType)_nCurSpecialPointer; } - // Set the new custom pointer + /** + * Set the new custom pointer + */ void setCustomPointer(RMGfxSourceBuffer8 *ptr) { _nCurCustomPointer = ptr; updateCursor(); } - // Return the current action to be applied according to the pointer + /** + * Return the current action to be applied according to the pointer + */ int curAction(void); - /** Show the cursor */ + /** + * Show the cursor + */ void showCursor(); - /** Hide the cursor */ + /** + * Hide the cursor + */ void hideCursor(); }; @@ -280,15 +304,19 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void removeThis(CORO_PARAM, bool &result); - // Polling for the option screen + /** + * Polling for the option screen + */ void doFrame(CORO_PARAM, RMInput *m_input); - // Retrieves a savegame's thumbnail, description, and difficulty level + /** + * Retrieves a savegame's thumbnail, description, and difficulty level + */ static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); protected: - // Initialisation and state change + // Initialization and state change void initState(CORO_PARAM); void closeState(void); void changeState(CORO_PARAM, OptionScreenState newState); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index bec33183c6..3b8384f614 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -324,7 +324,7 @@ public: RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); - // Initialisation + // Initialization void create(int dimx, int dimy, bool bUseDDraw = false); int getBpp(); @@ -369,7 +369,7 @@ public: RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer8(); - // Initialisation + // Initialization void create(int dimx, int dimy, bool bUseDDraw = false); int getBpp(); @@ -414,7 +414,7 @@ protected: void compressRLE(void); protected: - // Overriding initialisation methods + // Overriding initialization methods virtual void prepareImage(void); virtual void preparePalette(void); @@ -422,7 +422,7 @@ public: RMGfxSourceBuffer8RLE(); virtual ~RMGfxSourceBuffer8RLE(); - // Overload of the initialisation method + // Overload of the initialization method virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); @@ -505,7 +505,7 @@ protected: public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Overloaded initialisation methods + // Overloaded initialization methods virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); @@ -519,7 +519,7 @@ protected: public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Overloaded initialisation methods + // Overloaded initialization methods virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); @@ -535,7 +535,7 @@ public: RMGfxSourceBuffer4(); RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); - // Initialisation + // Initialization void create(int dimx, int dimy, bool bUseDDraw = false); int getBpp(); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index bb48be11c4..08eff0a991 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -353,7 +353,6 @@ SKIPCLICKSINISTRO: CORO_END_CODE; } - void RMGfxEngine::initCustomDll(void) { setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); } @@ -378,7 +377,6 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { } } - void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start._x == -1 || start._y == -1) { start._x = ptTonyStart._x - RM_SX / 2; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index cf231018a6..d3f5eb0849 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -43,10 +43,8 @@ namespace Tony { #define TAPPETI_MARE 6 #define TAPPETI_MAREMETA 7 - #define MAX_PATH 255 - struct CharacterStruct { uint32 _code; RMItem *_item; @@ -254,7 +252,6 @@ public: /** * @defgroup MPAL variables */ - //@{ uint32 _mpalError; LPITEMIRQFUNCTION _lpiifCustom; LPLPCUSTOMFUNCTION _lplpFunctions; @@ -292,8 +289,6 @@ public: uint32 _nExecutingDialog; uint32 _nExecutingChoice; uint32 _nSelectedChoice; - - //@} }; } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index fd194d0fc5..81fa3433c4 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -47,32 +47,46 @@ private: // Keyboard related fields bool _keyDown[350]; private: - // Deinitialize DirectInput + /** + * Deinitialize DirectInput + */ void DIClose(void); public: RMInput(); ~RMInput(); - // Class initialisation + /** + * Class initialization + */ void init(/*uint32 hInst*/); - // Closes the class + /** + * Closes the class + */ void close(void); - // Polling (must be performed once per frame) + /** + * Polling (must be performed once per frame) + */ void poll(void); - // Reading of the mouse + /** + * Reading of the mouse + */ RMPoint mousePos() { return _mousePos; } - // Current status of the mouse buttons + /** + * Current status of the mouse buttons + */ bool mouseLeft(); bool mouseRight(); - // Events of mouse clicks + /** + * Events of mouse clicks + */ bool mouseLeftClicked() { return _leftClickMouse; } @@ -92,7 +106,9 @@ public: return _leftReleaseMouse && _rightReleaseMouse; } - // Returns true if the given key is pressed + /** + * Returns true if the given key is pressed + */ bool getAsyncKeyState(Common::KeyCode kc); }; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index e010a09dd5..dfbde5bad0 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -79,48 +79,72 @@ protected: OSystem::MutexRef _csModifyInterface; protected: - // Prepare the image inventory. It should be recalled whenever the inventory changes + /** + * Prepare the image inventory. It should be recalled whenever the inventory changes + */ void prepare(void); - // Check if the mouse Y position is conrrect, even under the inventory portion of the screen + /** + * Check if the mouse Y position is conrrect, even under the inventory portion of the screen + */ bool checkPointInside(const RMPoint &pt); public: RMInventory(); virtual ~RMInventory(); - // Prepare a frame + /** + * Prepare a frame + */ void doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); - // Initialisation and closing + /** + * Initialization and closing + */ void init(void); void close(void); void reset(void); - // Overload test for removal from OT list + /** + * Overload test for removal from OT list + */ virtual void removeThis(CORO_PARAM, bool &result); - // Overload the drawing of the inventory + /** + * Overload the drawing of the inventory + */ virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Method for determining whether the inventory currently has the focus + /** + * Method for determining whether the inventory currently has the focus + */ bool haveFocus(const RMPoint &mpos); - // Method for determining if the mini interface is active + /** + * Method for determining if the mini interface is active + */ bool miniActive(void); - // Handle the left mouse click (only when the inventory has the focus) + /** + * Handle the left mouse click (only when the inventory has the focus) + */ bool leftClick(const RMPoint &mpos, int &nCombineObj); - // Handle the right mouse button (only when the inventory has the focus) + /** + * Handle the right mouse button (only when the inventory has the focus) + */ void rightClick(const RMPoint &mpos); bool rightRelease(const RMPoint &mpos, RMTonyAction &curAction); - // Warn that an item combine is over + /** + * Warn that an item combine is over + */ void endCombine(void); public: - // Add an item to the inventory + /** + * Add an item to the inventory + */ void addItem(int code); RMInventory &operator+=(RMItem *item) { addItem(item->mpalCode()); @@ -135,17 +159,25 @@ public: return *this; } - // Removes an item + /** + * Removes an item + */ void removeItem(int code); - // We are on an object? + /** + * We are on an object? + */ RMItem *whichItemIsIn(const RMPoint &mpt); bool itemInFocus(const RMPoint &mpt); - // Change the icon of an item + /** + * Change the icon of an item + */ void changeItemStatus(uint32 dwCode, uint32 dwStatus); - // Save methods + /** + * Save methods + */ int getSaveStateSize(void); void saveState(byte *state); int loadState(byte *state); @@ -165,35 +197,51 @@ private: int _lastHotZone; protected: - // Return which box a given point is in + /** + * Return which box a given point is in + */ int onWhichBox(RMPoint pt); public: RMInterface(); virtual ~RMInterface(); - // The usual DoFrame (poll the graphics engine) + /** + * The usual DoFrame (poll the graphics engine) + */ void doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); - // TRUE if it is active (you can select items) + /** + * TRUE if it is active (you can select items) + */ bool active(); - // Initialisation + /** + * Initialization + */ void init(void); void close(void); - // Reset the interface + /** + * Reset the interface + */ void reset(void); - // Warns of mouse clicks and releases + /** + * Warns of mouse clicks and releases + */ void clicked(const RMPoint &mousepos); bool released(const RMPoint &mousepos, RMTonyAction &action); - // Enalbes or disables the fifth verb + /** + * Enables or disables the fifth verb + */ void setPerorate(bool bOn); bool getPerorate(void); - // Overloaded Draw + /** + * Overloaded Draw + */ virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; diff --git a/engines/tony/resid.h b/engines/tony/resid.h index 7f2dc7bb54..f4d2c9a4fa 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -26,9 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ -/* - Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli -*/ +// From 10500 onwards there are .OGG for inventory and scrap #ifndef TONY_RESID_H #define TONY_RESID_H diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c2f3cc4c89..79694b2601 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -422,13 +422,11 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_END_CODE; } - void TonyEngine::saveState(int n, const char *name) { Common::String buf = getSaveStateFileName(n); _theEngine.saveState(buf.c_str(), (byte *)_curThumbnail, name); } - void TonyEngine::loadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; Common::String buf; @@ -600,7 +598,6 @@ void TonyEngine::unfreezeTime(void) { _bTimeFreezed = false; } - /** * Returns the millisecond timer */ diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 709465ca89..817147805a 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -118,7 +118,6 @@ public: FPStream *_stream[6]; FPSfx *_sfx[MAX_SFX_CHANNELS]; FPSfx *_utilSfx[MAX_SFX_CHANNELS]; -// RMFont *_fonts[2]; bool _bPaused; bool _bDrawLocation; int _startTime; @@ -154,7 +153,9 @@ public: Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); - // Warn when are being controlled by the GDI + /** + * Warn when are being controlled by the GDI + */ void GDIControl(bool bCon); void play(); @@ -173,7 +174,9 @@ public: _bDrawLocation = false; } - // Reads the time + /** + * Reads the time + */ uint32 getTime(void); void freezeTime(void); void unfreezeTime(void); @@ -197,19 +200,25 @@ public: void preloadUtilSFX(int nSfx, const char *fn); void unloadAllUtilSFX(void); - // Stop all the audio + /** + * Stop all the audio + */ void pauseSound(bool bPause); void setMusicVolume(int nChannel, int volume); int getMusicVolume(int nChannel); - // Handle saving + /** + * Handle saving + */ void autoSave(CORO_PARAM); void saveState(int n, const char *name); void loadState(CORO_PARAM, int n); static Common::String getSaveStateFileName(int n); - // Get a thumbnail + /** + * Get a thumbnail + */ void grabThumbnail(void); uint16 *getThumbnail(void) { return _curThumbnail; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 17f046fb92..700b69a643 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -34,10 +34,6 @@ namespace Tony { -/****************************************************************************\ -* Metodi di RMTony -\****************************************************************************/ - bool RMTony::_bAction = false; void RMTony::initStatics() { @@ -124,7 +120,7 @@ void RMTony::init(void) { void RMTony::close(void) { - // Disalloca @@@ Deallocation of missing item + // Deallocation of missing item // _shadow.destroy(); } @@ -479,7 +475,6 @@ void RMTony::put(int nWhere, int nPart) { if (nPart == 0) { switch (getCurPattern()) { case PAT_STANDDOWN: - //assert(0); break; case PAT_STANDUP: @@ -690,7 +685,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_SING: _nBodyOffset.set(-10, 25); headStartPat = PAT_HEAD_LEFT; @@ -744,7 +738,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_INDICATE: switch (_talkDirection) { case UP: @@ -1181,7 +1174,6 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa return false; } - bStatic = false; switch (_nTalkType) { case TALK_NORMAL: @@ -1759,7 +1751,6 @@ void RMTony::startStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_END_CODE; } - void RMTony::endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { switch (_talkDirection) { case UP: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 507ff28f6b..70765abfd8 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -107,10 +107,14 @@ private: uint32 _hActionThread; protected: - // Overload of the allocation allocation of sprites + /** + * Overload of the allocation allocation of sprites + */ virtual RMGfxSourceBuffer *newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); - // Watch thread which waits for the end of an action + /** + * Watch thread which waits for the end of an action + */ static void waitEndOfAction(CORO_PARAM, const void *param); public: @@ -362,79 +366,115 @@ public: static void initStatics(); RMTony(); - // Initialize Tony + /** + * Initialize Tony + */ void init(void); - // Free all memory + /** + * Free all memory + */ void close(void); - // Tony makes a frame, updating the movement, etc. + /** + * Tony makes a frame, updating the movement, etc. + */ void doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); - // Draw method, which controls chararacter display + /** + * Draw method, which controls chararacter display + */ virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Show or hide + /** + * Show or hide + */ void show(void); void hide(bool bShowShadow = false); - // Move and make an action, if necessary + /** + * Move and make an action, if necessary + */ void moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); - // Tony stops (on the right side with respect to any subject) + /** + * Tony stops (on the right side with respect to any subject) + */ virtual void stop(CORO_PARAM); void stopNoAction(CORO_PARAM); - // Set a pattern + /** + * Set a pattern + */ void setPattern(int npatt, bool bPlayP0 = false); - // Reads the current pattern + /** + * Reads the current pattern + */ int getCurPattern(); - // Waits until the end of a pattern + /** + * Waits until the end of a pattern + */ void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::waitForEndPattern(coroParam, hCustomSkip); } - // Check if currently in an action + /** + * Check if currently in an action + */ bool inAction() { return (_bActionPending && _action != 0) | _bAction; } - // Check if there needs to be an update for scrolling movement + /** + * Check if there needs to be an update for scrolling movement + */ bool mustUpdateScrolling() { return ((!inAction()) || (isMoving())); } - // Returns Tony's position + /** + * Returns Tony's position + */ RMPoint position() { return _pos; } - // Set the scrolling position + /** + * Set the scrolling position + */ void setScrollPosition(const RMPoint &pt) { RMCharacter::setScrollPosition(pt); } - // Set the take animation + /** + * Set the take animation + */ void take(int nWhere, int nPart); void put(int nWhere, int nPart); - // Start or End Talk + /** + * Start or End Talk + */ bool startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); void startTalk(CORO_PARAM, CharacterTalkType nTalkType); bool endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void endTalk(CORO_PARAM); - // Start or End Static + /** + * Start or End Static + */ void startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); void startStatic(CORO_PARAM, CharacterTalkType nTalkType); void endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void endStatic(CORO_PARAM, CharacterTalkType nTalkType); - // Tony disguises himself! + /** + * Tony disguises himself! + */ void setShepherdess(bool bIsPast) { _bShepherdess = bIsPast; } @@ -442,7 +482,9 @@ public: return _bShepherdess; } - // Perform an action + /** + * Perform an action + */ void executeAction(int nAction, int nActionItem, int nParm); void playSfx(int nSfx) { diff --git a/engines/tony/window.h b/engines/tony/window.h index 34f0c1cb51..876bbf6973 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -44,7 +44,9 @@ private: // Buffer used to convert to RGB static byte rgb[RM_SX *RM_SY * 3]; public: - // Take a screenshot + /** + * Take a screenshot + */ void grabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); }; @@ -78,21 +80,31 @@ public: RMWindow(); ~RMWindow(); - // Initialisation + /** + * Initialization + */ void init(/*HINSTANCE hInst*/); void initDirectDraw(void); void close(void); - // Drawing + /** + * Drawing + */ void repaint(void); - // Switch between windowed and fullscreen + /** + * Switch between windowed and fullscreen + */ void switchFullscreen(bool bFull) {} - // Reads the next frame + /** + * Reads the next frame + */ void getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); - // Request a thumbnail be grabbed during the next frame + /** + * Request a thumbnail be grabbed during the next frame + */ void grabThumbnail(uint16 *buf); int getFps() const { -- cgit v1.2.3 From 6a7fa693ef0e68e08e45bc7b7c8397357deffa04 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 07:58:19 +0200 Subject: TONY: Fix a typo in utils comments --- engines/tony/utils.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index b6af8736bd..6c36781f51 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -127,7 +127,7 @@ char &RMString::operator[](int nIndex) { /** * Copies a string * @param str String to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -154,7 +154,7 @@ const RMString &RMString::operator=(const RMString &str) { /** * Copies a char * string * @param str String to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer @@ -181,7 +181,7 @@ const RMString &RMString::operator=(const char *str) { /** * Forms a string from a passed character * @param ch Character to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const int ch) { if (ch == '\0') { @@ -227,7 +227,7 @@ void RMString::connect(const char *str, int size) { /** * Concatenate a string * @param str String to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(RMString &str) { connect(str, str.length()); @@ -237,7 +237,7 @@ const RMString &RMString::operator+=(RMString &str) { /** * Concatenate a string * @param str String to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(const char *str) { connect(str, strlen(str)); @@ -247,7 +247,7 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character * @param ch Character to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -406,7 +406,6 @@ bool RMFileStreamSlow::openFile(Common::File &file) { return true; } - bool RMFileStreamSlow::openFile(const char *lpFN) { // Open file for reading Common::File f; @@ -419,7 +418,6 @@ bool RMFileStreamSlow::openFile(const char *lpFN) { return true; } - RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { seek(nBytes); return *this; @@ -433,7 +431,6 @@ bool RMFileStreamSlow::isEOF() { return (pos() >= _length); } - int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { switch (where) { case START: @@ -450,7 +447,6 @@ int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { } } - bool RMFileStreamSlow::read(void *buf, int size) { uint32 dwRead; @@ -458,7 +454,6 @@ bool RMFileStreamSlow::read(void *buf, int size) { return ((int)dwRead == size); } - RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { df.read(&var, 1); return df; @@ -497,7 +492,6 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { return df; } - /****************************************************************************\ * RMDataStream methods \****************************************************************************/ @@ -996,7 +990,6 @@ RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { return ds; } - /****************************************************************************\ * Resource Update \****************************************************************************/ -- cgit v1.2.3 From bb55045cc85e1c9b70bd7267de0b578e6662725b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:03:02 +0200 Subject: TONY: Rename two variables --- engines/tony/custom.cpp | 6 +++--- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index fd5d17470b..e91d6873a4 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -408,8 +408,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); - GLOBALS.SFM_nLoc = GLOBALS._loc->TEMPGetNumLoc(); - GLOBALS.SFM_pt = GLOBALS._tony->position(); + GLOBALS._fullScreenMessageLoc = GLOBALS._loc->TEMPGetNumLoc(); + GLOBALS._fullScreenMessagePt = GLOBALS._tony->position(); if (GLOBALS._bSkipIdle) return; @@ -478,7 +478,7 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { GLOBALS.Freeze(); - GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt._x, GLOBALS.SFM_pt._y), RMPoint(-1, -1)); + GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); GLOBALS.Unfreeze(); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 48b04007b4..893322942a 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -74,7 +74,7 @@ Globals::Globals() { _lastMusic = 0; _lastTappeto = 0; Common::fill(&_tappeti[0], &_tappeti[200], 0); - SFM_nLoc = 0; + _fullScreenMessageLoc = 0; // MPAL global variables _mpalError = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index d3f5eb0849..96a61ffd9c 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -246,8 +246,8 @@ public: int _lastMusic, _lastTappeto; int _tappeti[200]; - RMPoint SFM_pt; - int SFM_nLoc; + RMPoint _fullScreenMessagePt; + int _fullScreenMessageLoc; /** * @defgroup MPAL variables -- cgit v1.2.3 From e8a6f61f8815fcf36e7a43383695c74b8925993f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:24:33 +0200 Subject: TONY: Remove useless void in function declaration --- engines/tony/adv.h | 18 +++++----- engines/tony/custom.cpp | 4 +-- engines/tony/font.cpp | 33 +++++++++--------- engines/tony/font.h | 36 ++++++++++---------- engines/tony/game.cpp | 36 ++++++++++---------- engines/tony/game.h | 12 +++---- engines/tony/gfxcore.cpp | 44 +++++++++--------------- engines/tony/gfxcore.h | 34 +++++++++---------- engines/tony/gfxengine.cpp | 22 ++++++------ engines/tony/gfxengine.h | 18 +++++----- engines/tony/globals.h | 84 +++++++++++++++++++++++----------------------- engines/tony/input.cpp | 5 ++- engines/tony/input.h | 6 ++-- engines/tony/inventory.cpp | 28 ++++++---------- engines/tony/inventory.h | 22 ++++++------ engines/tony/loc.cpp | 31 +++++++---------- engines/tony/loc.h | 26 +++++++------- engines/tony/mpal/mpal.cpp | 56 ++++++++++--------------------- engines/tony/mpal/mpal.h | 25 +++----------- engines/tony/sound.cpp | 4 +-- engines/tony/sound.h | 4 +-- engines/tony/tony.cpp | 18 +++++----- engines/tony/tony.h | 22 ++++++------ engines/tony/tonychar.cpp | 8 ++--- engines/tony/tonychar.h | 8 ++--- engines/tony/utils.cpp | 8 ++--- engines/tony/utils.h | 10 +++--- engines/tony/window.cpp | 4 +-- engines/tony/window.h | 8 ++--- 29 files changed, 283 insertions(+), 351 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index b2d61a5da5..fe1dd32eae 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -67,19 +67,19 @@ enum RMTonyAction { uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void mainLinkGraphicTask(RMGfxTask *task); -void mainFreeze(void); -void mainUnfreeze(void); +void mainFreeze(); +void mainUnfreeze(); void mainWaitFrame(CORO_PARAM); -void mainShowMouse(void); -void mainHideMouse(void); -void mainEnableInput(void); -void mainDisableInput(void); +void mainShowMouse(); +void mainHideMouse(); +void mainEnableInput(); +void mainDisableInput(); void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); void mainInitWipe(int type); -void mainCloseWipe(void); +void mainCloseWipe(); void mainWaitWipeEnd(CORO_PARAM); -void mainEnableGUI(void); -void mainDisableGUI(void); +void mainEnableGUI(); +void mainDisableGUI(); void mainSetPerorate(bool bPerorate); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e91d6873a4..016c84ab39 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -106,7 +106,7 @@ const char *jingleFileNames[] = { }; -void ReapplyChangedHotspot(void) { +void ReapplyChangedHotspot() { int i; for (i = 0; i < GLOBALS._curChangedHotspot; i++) GLOBALS._loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); @@ -140,7 +140,7 @@ void LoadChangedHotspot(Common::InSaveFile *f) { * AddInventory -> theEngine.AddInventory() */ -void MCharResetCodes(void) { +void MCharResetCodes() { for (int i = 0; i < 10; i++) GLOBALS._mCharacter[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[i]._code); for (int i = 0; i < 10; i++) diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a16179d507..c4a95d0493 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -89,7 +89,7 @@ void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) load(res, nChars, dimx, dimy, palResID); } -void RMFont::unload(void) { +void RMFont::unload() { if (_letter != NULL) { delete[] _letter; _letter = NULL; @@ -130,7 +130,7 @@ void RMFont::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) CORO_END_CODE; } -void RMFont::close(void) { +void RMFont::close() { unload(); } @@ -200,12 +200,11 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { _letter[i].loadPaletteWA(pal); } - /***************************************************************************\ * RMFontParla Methods \****************************************************************************/ -void RMFontParla::init(void) { +void RMFontParla::init() { int i; // bernie: Number of characters in the font @@ -612,7 +611,7 @@ void RMFontParla::init(void) { * RMFontMacc Methods \****************************************************************************/ -void RMFontMacc::init(void) { +void RMFontMacc::init() { int i; // bernie: Number of characters in the font @@ -976,7 +975,7 @@ void RMFontMacc::init(void) { * RMFontCredits Methods \****************************************************************************/ -void RMFontCredits::init(void) { +void RMFontCredits::init() { int i; // bernie: Number of characters in the font @@ -1441,7 +1440,7 @@ void RMFontObj::setBothCase(int nChar, int nNext, signed char spiazz) { } -void RMFontObj::init(void) { +void RMFontObj::init() { int i; //bernie: Number of characters in the font (solo maiuscolo) @@ -2015,7 +2014,7 @@ RMTextDialog::~RMTextDialog() { CoroScheduler.closeEvent(_hEndDisplay); } -void RMTextDialog::show(void) { +void RMTextDialog::show() { _bShowed = true; } @@ -2042,15 +2041,15 @@ void RMTextDialog::setSkipStatus(bool bEnabled) { _bSkipStatus = bEnabled; } -void RMTextDialog::forceTime(void) { +void RMTextDialog::forceTime() { _bForceTime = true; } -void RMTextDialog::forceNoTime(void) { +void RMTextDialog::forceNoTime() { _bForceNoTime = true; } -void RMTextDialog::setNoTab(void) { +void RMTextDialog::setNoTab() { _bNoTab = true; } @@ -2058,7 +2057,7 @@ void RMTextDialog::setForcedTime(uint32 dwTime) { _time = dwTime; } -void RMTextDialog::setAlwaysDisplay(void) { +void RMTextDialog::setAlwaysDisplay() { _bAlwaysDisplay = true; } @@ -2128,7 +2127,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { CORO_END_CODE; } -void RMTextDialog::Unregister(void) { +void RMTextDialog::Unregister() { RMGfxTask::Unregister(); assert(_nInList == 0); CoroScheduler.setEvent(_hEndDisplay); @@ -2337,7 +2336,7 @@ RMDialogChoice::~RMDialogChoice() { CoroScheduler.closeEvent(_hUnreg); } -void RMDialogChoice::Unregister(void) { +void RMDialogChoice::Unregister() { RMGfxWoodyBuffer::Unregister(); assert(!_nInList); CoroScheduler.pulseEvent(_hUnreg); @@ -2345,7 +2344,7 @@ void RMDialogChoice::Unregister(void) { _bRemoveFromOT = false; } -void RMDialogChoice::init(void) { +void RMDialogChoice::init() { _numChoices = 0; _drawedStrings = NULL; _ptDrawStrings = NULL; @@ -2356,7 +2355,7 @@ void RMDialogChoice::init(void) { } -void RMDialogChoice::close(void) { +void RMDialogChoice::close() { if (_drawedStrings != NULL) { delete[] _drawedStrings; _drawedStrings = NULL; @@ -2581,7 +2580,7 @@ void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_END_CODE; } -int RMDialogChoice::getSelection(void) { +int RMDialogChoice::getSelection() { return _curSelection; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 1b10304b5a..595cb726a6 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -73,7 +73,7 @@ protected: void load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); // Remove the font - void unload(void); + void unload(); protected: // Conversion form character to font index @@ -83,15 +83,15 @@ protected: virtual int letterLength(int nChar, int nNext = 0) = 0; public: - virtual int letterHeight(void) = 0; + virtual int letterHeight() = 0; public: RMFont(); virtual ~RMFont(); // Initialization and closing - virtual void init(void) = 0; - virtual void close(void); + virtual void init() = 0; + virtual void close(); // Drawing virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); @@ -143,7 +143,7 @@ public: class RMFontParla : public RMFontColor, public RMFontWithTables { public: - void init(void); + void init(); virtual ~RMFontParla() {} }; @@ -152,19 +152,19 @@ private: void setBothCase(int nChar, int nNext, signed char spiazz); public: - void init(void); + void init(); virtual ~RMFontObj() {} }; class RMFontMacc : public RMFontColor, public RMFontWithTables { public: - void init(void); + void init(); virtual ~RMFontMacc() {} }; class RMFontCredits : public RMFontColor, public RMFontWithTables { public: - void init(void); + void init(); virtual ~RMFontCredits() {} virtual void setBaseColor(byte r, byte g, byte b) {} }; @@ -263,7 +263,7 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Overloaded de-registration - virtual void Unregister(void); + virtual void Unregister(); // Overloading of the Draw to center the text, if necessary virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -279,15 +279,15 @@ public: void setCustomSkipHandle2(uint32 hCustomSkip); void setSkipStatus(bool bEnabled); void setForcedTime(uint32 dwTime); - void setNoTab(void); - void forceTime(void); - void forceNoTime(void); - void setAlwaysDisplay(void); + void setNoTab(); + void forceTime(); + void forceNoTime(); + void setAlwaysDisplay(); // Set the input device, to allow skip from mouse void setInput(RMInput *input); - void show(void); + void show(); void hide(CORO_PARAM); }; @@ -363,7 +363,7 @@ protected: public: virtual void removeThis(CORO_PARAM, bool &result); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void Unregister(void); + void Unregister(); public: // Initialization @@ -371,8 +371,8 @@ public: virtual ~RMDialogChoice(); // Initialization and closure - void init(void); - void close(void); + void init(); + void close(); // Sets the number of possible sentences, which then be added with AddChoice() void setNumChoices(int num); @@ -390,7 +390,7 @@ public: void doFrame(CORO_PARAM, RMPoint ptMousePos); // Returns the currently selected item, or -1 if none is selected - int getSelection(void); + int getSelection(); }; } // End of namespace Tony diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 493887cfa9..4e9e2abc38 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -59,11 +59,11 @@ void mainLinkGraphicTask(RMGfxTask *task) { _vm->getEngine()->linkGraphicTask(task); } -void mainFreeze(void) { +void mainFreeze() { _vm->getEngine()->freeze(); } -void mainUnfreeze(void) { +void mainUnfreeze() { _vm->getEngine()->unfreeze(); } @@ -71,11 +71,11 @@ void mainWaitFrame(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); } -void mainShowMouse(void) { +void mainShowMouse() { _vm->getEngine()->enableMouse(); } -void mainHideMouse(void) { +void mainHideMouse() { _vm->getEngine()->disableMouse(); } @@ -83,11 +83,11 @@ void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } -void mainDisableInput(void) { +void mainDisableInput() { _vm->getEngine()->disableInput(); } -void mainEnableInput(void) { +void mainEnableInput() { _vm->getEngine()->enableInput(); } @@ -95,7 +95,7 @@ void mainInitWipe(int type) { _vm->getEngine()->initWipe(type); } -void mainCloseWipe(void) { +void mainCloseWipe() { _vm->getEngine()->closeWipe(); } @@ -103,13 +103,13 @@ void mainWaitWipeEnd(CORO_PARAM) { _vm->getEngine()->waitWipeEnd(coroParam); } -void mainEnableGUI(void) { +void mainEnableGUI() { _vm->getEngine()->_bGUIInterface = true; _vm->getEngine()->_bGUIInventory = true; _vm->getEngine()->_bGUIOption = true; } -void mainDisableGUI(void) { +void mainDisableGUI() { _vm->getEngine()->_bGUIInterface = false; _vm->getEngine()->_bGUIInventory = false; _vm->getEngine()->_bGUIOption = false; @@ -320,7 +320,7 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { * RMOptionScreen Methods \****************************************************************************/ -RMOptionScreen::RMOptionScreen(void) { +RMOptionScreen::RMOptionScreen() { _nState = MENUNONE; _menu = NULL; _hideLoadSave = NULL; @@ -377,7 +377,7 @@ RMOptionScreen::RMOptionScreen(void) { _nLastState = MENUGAME; } -RMOptionScreen::~RMOptionScreen(void) { +RMOptionScreen::~RMOptionScreen() { closeState(); } @@ -546,7 +546,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { CORO_END_CODE; } -void RMOptionScreen::refreshThumbnails(void) { +void RMOptionScreen::refreshThumbnails() { int i; for (i = 0; i < 6; i++) { @@ -729,7 +729,7 @@ void RMOptionScreen::initState(CORO_PARAM) { CORO_END_CODE; } -void RMOptionScreen::closeState(void) { +void RMOptionScreen::closeState() { delete _menu; _menu = NULL; @@ -983,7 +983,7 @@ void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool CORO_END_CODE; } -bool RMOptionScreen::close(void) { +bool RMOptionScreen::close() { if (_fadeStep != 6) return false; @@ -993,7 +993,7 @@ bool RMOptionScreen::close(void) { return true; } -bool RMOptionScreen::isClosing(void) { +bool RMOptionScreen::isClosing() { return _bExit; } @@ -1479,7 +1479,7 @@ RMPointer::~RMPointer() { close(); } -void RMPointer::init(void) { +void RMPointer::init() { int i; for (i = 0; i < 5; i++) { @@ -1511,7 +1511,7 @@ void RMPointer::init(void) { _nCurSpecialPointer = 0; } -void RMPointer::close(void) { +void RMPointer::close() { int i; for (i = 0; i < 5; i++) { @@ -1560,7 +1560,7 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_END_CODE; } -int RMPointer::curAction(void) { +int RMPointer::curAction() { if (_nCurSpecialPointer != 0) return 0; diff --git a/engines/tony/game.h b/engines/tony/game.h index 64f4fb8e30..e231287c0f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -90,12 +90,12 @@ public: /** * Initialization */ - void init(void); + void init(); /** * Deinitialization */ - void close(void); + void close(); /** * Process a frame @@ -130,7 +130,7 @@ public: updateCursor(); } - PointerType getSpecialPointer(void) { + PointerType getSpecialPointer() { return (PointerType)_nCurSpecialPointer; } @@ -145,7 +145,7 @@ public: /** * Return the current action to be applied according to the pointer */ - int curAction(void); + int curAction(); /** * Show the cursor @@ -318,12 +318,12 @@ protected: // Initialization and state change void initState(CORO_PARAM); - void closeState(void); + void closeState(); void changeState(CORO_PARAM, OptionScreenState newState); // Repaint the options menu void refreshAll(CORO_PARAM); - void refreshThumbnails(void); + void refreshThumbnails(); }; } // End of namespace Tony diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index e973fe9f6b..a4d8b9332b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -91,7 +91,7 @@ void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { } } -void RMGfxBuffer::destroy(void) { +void RMGfxBuffer::destroy() { if (!_bUseDDraw) { if (_origBuf != NULL && _origBuf == _buf) { delete[] _origBuf; @@ -100,13 +100,13 @@ void RMGfxBuffer::destroy(void) { } } -void RMGfxBuffer::lock(void) { +void RMGfxBuffer::lock() { if (_bUseDDraw) { // Manages acceleration } } -void RMGfxBuffer::unlock(void) { +void RMGfxBuffer::unlock() { if (_bUseDDraw) { // Manages acceleration } @@ -143,7 +143,6 @@ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalet return dimx * dimy * getBpp() / 8; } - void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, getBpp()); ds.read(_buf, dimx * dimy * getBpp() / 8); @@ -155,7 +154,7 @@ void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPal RMGfxSourceBuffer::~RMGfxSourceBuffer() { } -void RMGfxSourceBuffer::prepareImage(void) { +void RMGfxSourceBuffer::prepareImage() { // Do nothing. Can be overloaded if necessary } @@ -243,10 +242,8 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer() { RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { - } - /****************************************************************************\ * RMGfxTargetBuffer Methods \****************************************************************************/ @@ -262,7 +259,7 @@ RMGfxTargetBuffer::~RMGfxTargetBuffer() { // g_system->deleteMutex(csModifyingOT); } -void RMGfxTargetBuffer::clearOT(void) { +void RMGfxTargetBuffer::clearOT() { OTList *cur, *n; // g_system->lockMutex(csModifyingOT); @@ -409,8 +406,7 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) { return (1 << getBpp()) * 4; } - -void RMGfxSourceBufferPal::preparePalette(void) { +void RMGfxSourceBufferPal::preparePalette() { int i; for (i = 0; i < 256; i++) { @@ -704,7 +700,7 @@ void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoa } } -void RMGfxSourceBuffer8RLE::preparePalette(void) { +void RMGfxSourceBuffer8RLE::preparePalette() { // Invoke the parent method RMGfxSourceBuffer8::preparePalette(); @@ -716,7 +712,7 @@ void RMGfxSourceBuffer8RLE::preparePalette(void) { } } -void RMGfxSourceBuffer8RLE::prepareImage(void) { +void RMGfxSourceBuffer8RLE::prepareImage() { // Invoke the parent method RMGfxSourceBuffer::prepareImage(); @@ -724,12 +720,11 @@ void RMGfxSourceBuffer8RLE::prepareImage(void) { compressRLE(); } -void RMGfxSourceBuffer8RLE::setAlreadyCompressed(void) { +void RMGfxSourceBuffer8RLE::setAlreadyCompressed() { _bNeedRLECompress = false; } - -void RMGfxSourceBuffer8RLE::compressRLE(void) { +void RMGfxSourceBuffer8RLE::compressRLE() { int x, y; byte *startline; byte *cur; @@ -1515,11 +1510,9 @@ RLEWordDoCopy2: return; assert(nLength > 0); - } } - /****************************************************************************\ * Methods for RMGfxSourceBuffer8AA \****************************************************************************/ @@ -1527,7 +1520,7 @@ RLEWordDoCopy2: byte RMGfxSourceBuffer8AA::_megaAABuf[256 * 1024]; byte RMGfxSourceBuffer8AA::_megaAABuf2[64 * 1024]; -void RMGfxSourceBuffer8AA::prepareImage(void) { +void RMGfxSourceBuffer8AA::prepareImage() { // Invoke the parent method RMGfxSourceBuffer::prepareImage(); @@ -1535,8 +1528,7 @@ void RMGfxSourceBuffer8AA::prepareImage(void) { calculateAA(); } - -void RMGfxSourceBuffer8AA::calculateAA(void) { +void RMGfxSourceBuffer8AA::calculateAA() { int x, y; byte *src, *srcaa; @@ -1721,16 +1713,14 @@ void RMGfxSourceBuffer8AA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim CORO_END_CODE; } - /****************************************************************************\ * RMGfxSourceBuffer8RLEAA Methods \****************************************************************************/ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { - } -void RMGfxSourceBuffer8RLEByteAA::prepareImage(void) { +void RMGfxSourceBuffer8RLEByteAA::prepareImage() { RMGfxSourceBuffer::prepareImage(); calculateAA(); compressRLE(); @@ -1763,12 +1753,10 @@ void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, boo } } - RMGfxSourceBuffer8RLEWordAA::~RMGfxSourceBuffer8RLEWordAA() { - } -void RMGfxSourceBuffer8RLEWordAA::prepareImage(void) { +void RMGfxSourceBuffer8RLEWordAA::prepareImage() { RMGfxSourceBuffer::prepareImage(); calculateAA(); compressRLE(); @@ -1869,7 +1857,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } } -void RMGfxSourceBuffer16::prepareImage(void) { +void RMGfxSourceBuffer16::prepareImage() { // Color space conversion if necessary! int i; uint16 *buf = (uint16 *)_buf; @@ -1878,14 +1866,12 @@ void RMGfxSourceBuffer16::prepareImage(void) { WRITE_LE_UINT16(&buf[i], FROM_LE_16(buf[i]) & 0x7FFF); } - RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { setPriority(0); _bTrasp0 = false; } - /** * Returns the number of bits per pixel of the surface * diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 3b8384f614..be89c1713c 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -78,11 +78,11 @@ public: // Creation virtual void create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual void destroy(void); + virtual void destroy(); // Buffer access - void lock(void); - void unlock(void); + void lock(); + void unlock(); // These are valid only if the buffer is locked operator byte *(); @@ -238,10 +238,10 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Registration - virtual void Register(void) { + virtual void Register() { _nInList++; } - virtual void Unregister(void) { + virtual void Unregister() { _nInList--; assert(_nInList >= 0); } @@ -300,7 +300,7 @@ public: virtual ~RMGfxSourceBuffer(); protected: - virtual void prepareImage(void); + virtual void prepareImage(); bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); void offsetY(int nLines) { RMGfxBuffer::offsetY(nLines, getBpp()); @@ -316,7 +316,7 @@ public: */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: - virtual void prepareImage(void); + virtual void prepareImage(); bool _bTrasp0; public: @@ -342,7 +342,7 @@ protected: uint16 _palFinal[256]; // Post process to prepare the palette for drawing - virtual void preparePalette(void); + virtual void preparePalette(); public: virtual ~RMGfxSourceBufferPal(); @@ -411,12 +411,12 @@ protected: virtual void RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) = 0; // Perform image compression in RLE - void compressRLE(void); + void compressRLE(); protected: // Overriding initialization methods - virtual void prepareImage(void); - virtual void preparePalette(void); + virtual void prepareImage(); + virtual void preparePalette(); public: RMGfxSourceBuffer8RLE(); @@ -433,7 +433,7 @@ public: void setAlphaBlendColor(int color); // Warn if the data is already compressed - void setAlreadyCompressed(void); + void setAlreadyCompressed(); }; class RMGfxSourceBuffer8RLEByte : public RMGfxSourceBuffer8RLE { @@ -481,13 +481,13 @@ protected: byte *_aabuf; // Calculate the buffer for the anti-aliasing - void calculateAA(void); + void calculateAA(); // Draw the AA void drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); protected: - void prepareImage(void); + void prepareImage(); public: RMGfxSourceBuffer8AA(); @@ -500,7 +500,7 @@ public: class RMGfxSourceBuffer8RLEByteAA : public RMGfxSourceBuffer8RLEByte, public RMGfxSourceBuffer8AA { protected: - void prepareImage(void); + void prepareImage(); public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -514,7 +514,7 @@ public: class RMGfxSourceBuffer8RLEWordAA : public RMGfxSourceBuffer8RLEWord, public RMGfxSourceBuffer8AA { protected: - void prepareImage(void); + void prepareImage(); public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -570,7 +570,7 @@ public: virtual ~RMGfxTargetBuffer(); // management of the OT list - void clearOT(void); + void clearOT(); void drawOT(CORO_PARAM); void addPrim(RMGfxPrimitive *prim); // The pointer must be delted diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 08eff0a991..0785ec534c 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -353,7 +353,7 @@ SKIPCLICKSINISTRO: CORO_END_CODE; } -void RMGfxEngine::initCustomDll(void) { +void RMGfxEngine::initCustomDll() { setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); } @@ -522,7 +522,7 @@ void RMGfxEngine::init() { _tony.executeAction(20, 1, 0); } -void RMGfxEngine::close(void) { +void RMGfxEngine::close() { _bigBuf.clearOT(); _inter.close(); @@ -538,37 +538,37 @@ void RMGfxEngine::switchFullscreen(bool bFull) { void RMGfxEngine::GDIControl(bool bCon) { } -void RMGfxEngine::enableInput(void) { +void RMGfxEngine::enableInput() { _bInput = true; } -void RMGfxEngine::disableInput(void) { +void RMGfxEngine::disableInput() { _bInput = false; _inter.reset(); } -void RMGfxEngine::enableMouse(void) { +void RMGfxEngine::enableMouse() { _bAlwaysDrawMouse = true; } -void RMGfxEngine::disableMouse(void) { +void RMGfxEngine::disableMouse() { _bAlwaysDrawMouse = false; } -void RMGfxEngine::freeze(void) { +void RMGfxEngine::freeze() { g_system->lockMutex(_csMainLoop); } -void RMGfxEngine::unfreeze(void) { +void RMGfxEngine::unfreeze() { g_system->unlockMutex(_csMainLoop); } void CharsSaveAll(Common::OutSaveFile *f); void CharsLoadAll(Common::InSaveFile *f); -void MCharResetCodes(void); +void MCharResetCodes(); void SaveChangedHotspot(Common::OutSaveFile *f); void LoadChangedHotspot(Common::InSaveFile *f); -void ReapplyChangedHotspot(void); +void ReapplyChangedHotspot(); void RestoreMusic(CORO_PARAM); void SaveMusic(Common::OutSaveFile *f); @@ -856,7 +856,7 @@ void RMGfxEngine::initWipe(int type) { _rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); } -void RMGfxEngine::closeWipe(void) { +void RMGfxEngine::closeWipe() { _bWiping = false; } diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 9cc586d25d..74aafd15f6 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -90,7 +90,7 @@ public: void init(); // Closes the graphics engine - void close(void); + void close(); // Warns when changing void switchFullscreen(bool bFull); @@ -102,12 +102,12 @@ public: void openOptionScreen(CORO_PARAM, int type); // Enables or disables mouse input - void enableInput(void); - void disableInput(void); + void enableInput(); + void disableInput(); // Enables and disables mouse draw - void enableMouse(void); - void disableMouse(void); + void enableMouse(); + void disableMouse(); operator byte *() { return (byte *)_bigBuf; @@ -117,7 +117,7 @@ public: } // Link to the custom function list - void initCustomDll(void); + void initCustomDll(); // Link to graphic task void linkGraphicTask(RMGfxTask *task) { @@ -129,8 +129,8 @@ public: void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); // Freeze and unfreeze - void freeze(void); - void unfreeze(void); + void freeze(); + void unfreeze(); // State management void saveState(const Common::String &fn, byte *curThumb, const Common::String &name); @@ -141,7 +141,7 @@ public: // Wipe void initWipe(int type); - void closeWipe(void); + void closeWipe(); void waitWipeEnd(CORO_PARAM); void setPerorate(bool bpal) { diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 96a61ffd9c..7b5d6db9cf 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -221,15 +221,15 @@ public: uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); - void (*Freeze)(void); - void (*Unfreeze)(void); + void (*Freeze)(); + void (*Unfreeze)(); void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); void (*WaitWipeEnd)(CORO_PARAM); - void (*CloseWipe)(void); + void (*CloseWipe)(); void (*InitWipe)(int type); - void (*EnableGUI)(void); - void (*DisableGUI)(void); + void (*EnableGUI)(); + void (*DisableGUI)(); void (*SetPerorate)(bool bpal); uint32 _dwTonyNumTexts; @@ -252,43 +252,43 @@ public: /** * @defgroup MPAL variables */ - uint32 _mpalError; - LPITEMIRQFUNCTION _lpiifCustom; - LPLPCUSTOMFUNCTION _lplpFunctions; - Common::String *_lplpFunctionStrings; - uint16 _nObjs; - uint16 _nVars; - HGLOBAL _hVars; - LPMPALVAR _lpmvVars; - uint16 _nMsgs; - HGLOBAL _hMsgs; - LPMPALMSG _lpmmMsgs; - uint16 _nDialogs; - HGLOBAL _hDialogs; - LPMPALDIALOG _lpmdDialogs; - uint16 _nItems; - HGLOBAL _hItems; - LPMPALITEM _lpmiItems; - uint16 _nLocations; - HGLOBAL _hLocations; - LPMPALLOCATION _lpmlLocations; - uint16 _nScripts; - HGLOBAL _hScripts; - LPMPALSCRIPT _lpmsScripts; - Common::File _hMpr; - uint16 _nResources; - uint32 *_lpResources; - bool _bExecutingAction; - bool _bExecutingDialog; - uint32 _nPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 _hEndPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 _pollingThreads[MAXPOLLINGLOCATIONS]; - uint32 _hAskChoice; - uint32 _hDoneChoice; - uint32 _nExecutingAction; - uint32 _nExecutingDialog; - uint32 _nExecutingChoice; - uint32 _nSelectedChoice; + uint32 _mpalError; + LPITEMIRQFUNCTION _lpiifCustom; + LPLPCUSTOMFUNCTION _lplpFunctions; + Common::String *_lplpFunctionStrings; + uint16 _nObjs; + uint16 _nVars; + HGLOBAL _hVars; + LPMPALVAR _lpmvVars; + uint16 _nMsgs; + HGLOBAL _hMsgs; + LPMPALMSG _lpmmMsgs; + uint16 _nDialogs; + HGLOBAL _hDialogs; + LPMPALDIALOG _lpmdDialogs; + uint16 _nItems; + HGLOBAL _hItems; + LPMPALITEM _lpmiItems; + uint16 _nLocations; + HGLOBAL _hLocations; + LPMPALLOCATION _lpmlLocations; + uint16 _nScripts; + HGLOBAL _hScripts; + LPMPALSCRIPT _lpmsScripts; + Common::File _hMpr; + uint16 _nResources; + uint32 *_lpResources; + bool _bExecutingAction; + bool _bExecutingDialog; + uint32 _nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _pollingThreads[MAXPOLLINGLOCATIONS]; + uint32 _hAskChoice; + uint32 _hDoneChoice; + uint32 _nExecutingAction; + uint32 _nExecutingDialog; + uint32 _nExecutingChoice; + uint32 _nSelectedChoice; }; } // End of namespace Tony diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 36cad4c6a1..2a8cdc10c3 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -46,10 +46,9 @@ RMInput::RMInput() { } RMInput::~RMInput() { - } -void RMInput::poll(void) { +void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events @@ -105,7 +104,7 @@ void RMInput::poll(void) { void RMInput::init() { } -void RMInput::close(void) { +void RMInput::close() { } bool RMInput::mouseLeft() { diff --git a/engines/tony/input.h b/engines/tony/input.h index 81fa3433c4..d9b6dc7e89 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -50,7 +50,7 @@ private: /** * Deinitialize DirectInput */ - void DIClose(void); + void DIClose(); public: RMInput(); @@ -64,12 +64,12 @@ public: /** * Closes the class */ - void close(void); + void close(); /** * Polling (must be performed once per frame) */ - void poll(void); + void poll(); /** * Reading of the mouse diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 7b111f8f58..0438d7252b 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -72,7 +72,7 @@ bool RMInventory::checkPointInside(const RMPoint &pt) { } -void RMInventory::init(void) { +void RMInventory::init() { int i, j; int curres; @@ -160,7 +160,7 @@ void RMInventory::init(void) { clearOT(); } -void RMInventory::close(void) { +void RMInventory::close() { // Has memory if (_items != NULL) { // Delete the item pointers @@ -175,7 +175,7 @@ void RMInventory::close(void) { destroy(); } -void RMInventory::reset(void) { +void RMInventory::reset() { _state = CLOSED; endCombine(); } @@ -288,7 +288,7 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { } -void RMInventory::prepare(void) { +void RMInventory::prepare() { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { @@ -303,7 +303,7 @@ void RMInventory::prepare(void) { addPrim(new RMGfxPrimitive(&_items[28]._icon, RMPoint(640 - 64, 0))); } -bool RMInventory::miniActive(void) { +bool RMInventory::miniActive() { return _state == SELECTING; } @@ -323,7 +323,7 @@ bool RMInventory::haveFocus(const RMPoint &mpos) { return false; } -void RMInventory::endCombine(void) { +void RMInventory::endCombine() { _bCombining = false; } @@ -661,7 +661,6 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } - bool RMInventory::itemInFocus(const RMPoint &mpt) { if ((_state == OPENED || _state == OPENING) && checkPointInside(mpt)) return true; @@ -681,9 +680,7 @@ RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { return NULL; } - - -int RMInventory::getSaveStateSize(void) { +int RMInventory::getSaveStateSize() { // m_inv pattern m_nInv return 256 * 4 + 256 * 4 + 4 ; } @@ -742,7 +739,6 @@ int RMInventory::loadState(byte *state) { return getSaveStateSize(); } - /****************************************************************************\ * RMInterface methods \****************************************************************************/ @@ -753,7 +749,6 @@ RMInterface::RMInterface() : RMGfxSourceBuffer8RLEByte() { } RMInterface::~RMInterface() { - } bool RMInterface::active() { @@ -810,7 +805,6 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_END_CODE; } - void RMInterface::doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { // If needed, add to the OT schedule list if (!_nInList && _bActive) @@ -875,7 +869,7 @@ bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { return true; } -void RMInterface::reset(void) { +void RMInterface::reset() { _bActive = false; } @@ -883,11 +877,11 @@ void RMInterface::setPerorate(bool bOn) { _bPerorate = bOn; } -bool RMInterface::getPerorate(void) { +bool RMInterface::getPerorate() { return _bPerorate; } -void RMInterface::init(void) { +void RMInterface::init() { int i; RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); @@ -934,7 +928,7 @@ void RMInterface::init(void) { _lastHotZone = 0; } -void RMInterface::close(void) { +void RMInterface::close() { int i; destroy(); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index dfbde5bad0..a5b37748c3 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -82,7 +82,7 @@ protected: /** * Prepare the image inventory. It should be recalled whenever the inventory changes */ - void prepare(void); + void prepare(); /** * Check if the mouse Y position is conrrect, even under the inventory portion of the screen @@ -101,9 +101,9 @@ public: /** * Initialization and closing */ - void init(void); - void close(void); - void reset(void); + void init(); + void close(); + void reset(); /** * Overload test for removal from OT list @@ -123,7 +123,7 @@ public: /** * Method for determining if the mini interface is active */ - bool miniActive(void); + bool miniActive(); /** * Handle the left mouse click (only when the inventory has the focus) @@ -139,7 +139,7 @@ public: /** * Warn that an item combine is over */ - void endCombine(void); + void endCombine(); public: /** @@ -178,7 +178,7 @@ public: /** * Save methods */ - int getSaveStateSize(void); + int getSaveStateSize(); void saveState(byte *state); int loadState(byte *state); }; @@ -219,13 +219,13 @@ public: /** * Initialization */ - void init(void); - void close(void); + void init(); + void close(); /** * Reset the interface */ - void reset(void); + void reset(); /** * Warns of mouse clicks and releases @@ -237,7 +237,7 @@ public: * Enables or disables the fifth verb */ void setPerorate(bool bOn); - bool getPerorate(void); + bool getPerorate(); /** * Overloaded Draw diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d92b28845b..e8dbb4fa69 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -138,7 +138,7 @@ void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { } } -void RMPattern::updateCoord(void) { +void RMPattern::updateCoord() { _curPos = _pos + _slots[_nCurSlot].pos(); } @@ -446,7 +446,7 @@ void RMSfx::pause(bool bPause) { } } -void RMSfx::stop(void) { +void RMSfx::stop() { if (_fx) { _fx->stop(); _bPlayingLoop = false; @@ -665,7 +665,7 @@ bool RMItem::doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return oldSprite != _nCurSprite; } -RMPoint RMItem::calculatePos(void) { +RMPoint RMItem::calculatePos() { return _pos + _patterns[_nCurPattern].pos(); } @@ -736,7 +736,6 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { } } - bool RMItem::getName(RMString &name) { char buf[256]; @@ -747,8 +746,7 @@ bool RMItem::getName(RMString &name) { return true; } - -void RMItem::unload(void) { +void RMItem::unload() { if (_patterns != NULL) { delete[] _patterns; _patterns = NULL; @@ -856,11 +854,11 @@ RMWipe::~RMWipe() { CoroScheduler.closeEvent(_hEndOfFade); } -int RMWipe::priority(void) { +int RMWipe::priority() { return 200; } -void RMWipe::Unregister(void) { +void RMWipe::Unregister() { RMGfxTask::Unregister(); assert(_nInList == 0); CoroScheduler.setEvent(_hUnregistered); @@ -887,7 +885,7 @@ void RMWipe::waitForFadeEnd(CORO_PARAM) { CORO_END_CODE; } -void RMWipe::closeFade(void) { +void RMWipe::closeFade() { _wip0r.unload(); } @@ -1786,8 +1784,7 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { ds >> _boxes[i]; } - -void RMBoxLoc::recalcAllAdj(void) { +void RMBoxLoc::recalcAllAdj() { int i, j; for (i = 0; i < _numbBox; i++) { @@ -1819,7 +1816,7 @@ RMGameBoxes::~RMGameBoxes() { delete _allBoxes[i]; } -void RMGameBoxes::init(void) { +void RMGameBoxes::init() { int i; RMString fn; RMDataStream ds; @@ -1840,7 +1837,7 @@ void RMGameBoxes::init(void) { } } -void RMGameBoxes::close(void) { +void RMGameBoxes::close() { } RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { @@ -1878,8 +1875,7 @@ void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { _allBoxes[nLoc]->recalcAllAdj(); } - -int RMGameBoxes::getSaveStateSize(void) { +int RMGameBoxes::getSaveStateSize() { int size; int i; @@ -2204,12 +2200,11 @@ RMItem *RMLocation::whichItemIsIn(const RMPoint &pt) { return &_items[found]; } - RMLocation::~RMLocation() { unload(); } -void RMLocation::unload(void) { +void RMLocation::unload() { // Clear memory if (_items) { delete[] _items; @@ -2323,7 +2318,7 @@ void RMMessage::load(uint32 dwId) { parseMessage(); } -void RMMessage::parseMessage(void) { +void RMMessage::parseMessage() { char *p; assert(_lpMessage != NULL); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index b863a3af1b..35674736dd 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -84,7 +84,7 @@ public: void play(bool bLoop = false); void setVolume(int vol); void pause(bool bPause); - void stop(void); + void stop(); void readFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -165,7 +165,7 @@ public: void readFromStream(RMDataStream &ds, bool bLOX = false); private: - void updateCoord(void); + void updateCoord(); }; @@ -235,7 +235,7 @@ private: bool _bInitCurPattern; public: - RMPoint calculatePos(void); + RMPoint calculatePos(); public: RMItem(); @@ -282,7 +282,7 @@ public: } // Unload - void unload(void); + void unload(); // Wait for the end of the current pattern void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); @@ -350,7 +350,7 @@ public: virtual ~RMBoxLoc(); friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); - void recalcAllAdj(void); + void recalcAllAdj(); }; #define GAME_BOXES_SIZE 200 @@ -364,8 +364,8 @@ public: RMGameBoxes(); ~RMGameBoxes(); - void init(void); - void close(void); + void init(); + void close(); // Get binding boxes for a given location RMBoxLoc *getBoxes(int nLoc); @@ -381,7 +381,7 @@ public: void changeBoxStatus(int nLoc, int nBox, int status); // Save state handling - int getSaveStateSize(void); + int getSaveStateSize(); void saveState(byte *buf); void loadState(byte *buf); }; @@ -513,12 +513,12 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void initFade(int type); - void closeFade(void); + void closeFade(); void waitForFadeEnd(CORO_PARAM); - virtual void Unregister(void); + virtual void Unregister(); virtual void removeThis(CORO_PARAM, bool &result); - virtual int priority(void); + virtual int priority(); }; @@ -563,7 +563,7 @@ public: bool loadLOX(RMDataStream &ds); // Unload - void unload(void); + void unload(); // Overloaded draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -606,7 +606,7 @@ private: int _nPeriods; private: - void parseMessage(void); + void parseMessage(); public: RMMessage(); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index bb3df1662f..7385e60b66 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -59,101 +59,91 @@ const char *mpalCopyright = /** * Locks the variables for access */ -void lockVar(void) { +void lockVar() { GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); } /** * Unlocks variables after use */ -void unlockVar(void) { +void unlockVar() { globalUnlock(GLOBALS._hVars); } /** * Locks the messages for access */ -static void LockMsg(void) { +static void LockMsg() { #ifdef NEED_LOCK_MSGS GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); #endif } - /** * Unlocks the messages after use */ -static void UnlockMsg(void) { +static void UnlockMsg() { #ifdef NEED_LOCK_MSGS globalUnlock(GLOBALS._hMsgs); #endif } - /** * Locks the dialogs for access */ -static void lockDialogs(void) { +static void lockDialogs() { GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); } - /** * Unlocks the dialogs after use */ -static void unlockDialogs(void) { +static void unlockDialogs() { globalUnlock(GLOBALS._hDialogs); } - /** * Locks the location data structures for access */ -static void lockLocations(void) { +static void lockLocations() { GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); } - /** * Unlocks the location structures after use */ -static void unlockLocations(void) { +static void unlockLocations() { globalUnlock(GLOBALS._hLocations); } - /** * Locks the items structures for use */ -static void lockItems(void) { +static void lockItems() { GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); } - /** * Unlocks the items structures after use */ -static void unlockItems(void) { +static void unlockItems() { globalUnlock(GLOBALS._hItems); } - /** * Locks the script data structures for use */ -static void LockScripts(void) { +static void LockScripts() { GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); } - /** * Unlocks the script data structures after use */ -static void unlockScripts(void) { +static void unlockScripts() { globalUnlock(GLOBALS._hScripts); } - /** * Returns the current value of a global variable * @@ -175,7 +165,6 @@ int32 varGetValue(const char *lpszVarName) { return 0; } - /** * Sets the value of a MPAL global variable * @param lpszVarName Name of the variable @@ -204,7 +193,6 @@ void varSetValue(const char *lpszVarName, int32 val) { return; } - /** * Find the index of a location within the location array. Remember to call LockLoc() beforehand. * @@ -1973,17 +1961,15 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { va_end(v); } - /** * Returns the current MPAL error code * * @returns Error code */ -uint32 mpalGetError(void) { +uint32 mpalGetError() { return GLOBALS._mpalError; } - /** * Execute a script. The script runs on multitasking by a thread. * @@ -2091,17 +2077,15 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_END_CODE; } - /** * Retrieve the length of a save state * * @returns Length in bytes */ -int mpalGetSaveStateSize(void) { +int mpalGetSaveStateSize() { return GLOBALS._nVars * sizeof(MPALVAR) + 4; } - /** * Store the save state into a buffer. The buffer must be * length at least the size specified with mpalGetSaveStateSize @@ -2251,7 +2235,6 @@ int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { return 0; } - void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { int i; @@ -2262,8 +2245,7 @@ void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { } } - -void mpalDumpMessages(void) { +void mpalDumpMessages() { int i, j; char *lpMessage; char *p; @@ -2354,9 +2336,7 @@ void mpalDumpMessages(void) { UnlockMsg(); } - - -void mpalDumpOthers(void) { +void mpalDumpOthers() { int i,j; char *lpMessage; char *p; @@ -2914,7 +2894,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { delete v1; } -void mpalDumpDialogs(void) { +void mpalDumpDialogs() { int i; lockDialogs(); @@ -2925,8 +2905,6 @@ void mpalDumpDialogs(void) { unlockDialogs(); } -//@} - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1ec96c97d0..251e78afdf 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -327,7 +327,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogWaitForChoice(dwRet) \ CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) - /** * Requires a list of various options for some choice within the current dialog. * @@ -340,7 +339,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelectList(nChoice) \ (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) - /** * Warns the library that the user has selected, in a certain choice of the current dialog, * corresponding option at a certain given. @@ -358,7 +356,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelectionDWORD(nChoice, dwData) \ mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) - /** * Warns the library an action was performed on a Object. * The library will call custom functions, if necessary. @@ -375,7 +372,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoAction(nAction, nItem, dwParam) \ mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) - /** * Warns the library a dialogue was required. * @@ -387,8 +383,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoDialog(nDialog,nGroup) \ mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) -//@} - /** * @defgroup Functions exported to the main game */ @@ -442,7 +436,6 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); */ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); - /** * Execute a script. The script runs on multitasking by a thread. * @@ -451,14 +444,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); */ bool mpalExecuteScript(int nScript); - /** * Returns the current MPAL error code * * @returns Error code */ -uint32 mpalGetError(void); - +uint32 mpalGetError(); /** * Install a custom routine That will be called by MPAL every time the pattern @@ -468,7 +459,6 @@ uint32 mpalGetError(void); */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); - /** * Process the idle actions of the items on one location. * @@ -480,7 +470,6 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); */ bool mpalStartIdlePoll(int nLoc); - /** * Stop processing the idle actions of the items on one location. * @@ -499,7 +488,6 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); */ int mpalLoadState(byte *buf); - /** * Store the save state into a buffer. The buffer must be * length at least the size specified with mpalGetSaveStateSize @@ -508,27 +496,22 @@ int mpalLoadState(byte *buf); */ void mpalSaveState(byte *buf); - /** * Retrieve the length of a save state * * @returns Length in bytes */ -int mpalGetSaveStateSize(void); - +int mpalGetSaveStateSize(); /** * Locks the variables for access */ -void lockVar(void); - +void lockVar(); /** * Unlocks variables after use */ -void unlockVar(void); - -//@} +void unlockVar(); } // end of namespace MPAL diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index d8b3655d2e..7e786a2f11 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -635,7 +635,7 @@ bool FPStream::unloadFile() { return true; } -void FPStream::prefetch(void) { +void FPStream::prefetch() { #ifdef REFACTOR_ME uint32 dwId; void *lpBuf; @@ -702,7 +702,7 @@ void FPStream::prefetch(void) { #endif } -void FPStream::playFast(void) { +void FPStream::playFast() { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index e1f0e40851..4dd00a3028 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -348,8 +348,8 @@ public: */ bool play(); - void playFast(void); - void prefetch(void); + void playFast(); + void prefetch(); /** * Closes the stream. diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 79694b2601..9e9e032e49 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -345,11 +345,11 @@ void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { warning("TonyEngine::preloadUtilSFX"); } -void TonyEngine::unloadAllSFX(void) { +void TonyEngine::unloadAllSFX() { warning("TonyEngine::unloadAllSFX"); } -void TonyEngine::unloadAllUtilSFX(void) { +void TonyEngine::unloadAllUtilSFX() { warning("TonyEngine::unloadAllUtilSFX"); } @@ -480,11 +480,11 @@ void TonyEngine::closeVoiceDatabase() { _voices.clear(); } -void TonyEngine::grabThumbnail(void) { +void TonyEngine::grabThumbnail() { _window.grabThumbnail(_curThumbnail); } -void TonyEngine::optionScreen(void) { +void TonyEngine::optionScreen() { } void TonyEngine::openInitLoadMenu(CORO_PARAM) { @@ -495,7 +495,7 @@ void TonyEngine::openInitOptions(CORO_PARAM) { _theEngine.openOptionScreen(coroParam, 2); } -void TonyEngine::abortGame(void) { +void TonyEngine::abortGame() { _bQuitNow = true; } @@ -555,7 +555,7 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { /** * Play the game */ -void TonyEngine::play(void) { +void TonyEngine::play() { // Create the game player process CoroScheduler.createProcess(playProcess, NULL); @@ -569,7 +569,7 @@ void TonyEngine::play(void) { } } -void TonyEngine::close(void) { +void TonyEngine::close() { closeMusic(); CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.close(); @@ -589,12 +589,12 @@ void TonyEngine::GDIControl(bool bCon) { _theEngine.GDIControl(bCon); } -void TonyEngine::freezeTime(void) { +void TonyEngine::freezeTime() { _bTimeFreezed = true; _nTimeFreezed = getTime() - _startTime; } -void TonyEngine::unfreezeTime(void) { +void TonyEngine::unfreezeTime() { _bTimeFreezed = false; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 817147805a..5f6fd8cb44 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -165,21 +165,21 @@ public: void getDataDirectory(DataDir dir, char *path); void switchFullscreen(bool bFull); - void optionScreen(void); + void optionScreen(); - void showLocation(void) { + void showLocation() { _bDrawLocation = true; } - void hideLocation(void) { + void hideLocation() { _bDrawLocation = false; } /** * Reads the time */ - uint32 getTime(void); - void freezeTime(void); - void unfreezeTime(void); + uint32 getTime(); + void freezeTime(); + void unfreezeTime(); // Music // ****** @@ -195,10 +195,10 @@ public: FPSfx *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); - void unloadAllSFX(void); + void unloadAllSFX(); void preloadUtilSFX(int nSfx, const char *fn); - void unloadAllUtilSFX(void); + void unloadAllUtilSFX(); /** * Stop all the audio @@ -219,12 +219,12 @@ public: /** * Get a thumbnail */ - void grabThumbnail(void); - uint16 *getThumbnail(void) { + void grabThumbnail(); + uint16 *getThumbnail() { return _curThumbnail; } - void quitGame(void) { + void quitGame() { _bQuitNow = true; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 700b69a643..cd5bbdad8b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -84,7 +84,7 @@ RMGfxSourceBuffer *RMTony::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return spr; } -void RMTony::init(void) { +void RMTony::init() { RMRes tony(0); RMRes body(9999); RMDataStream ds; @@ -119,7 +119,7 @@ void RMTony::init(void) { } -void RMTony::close(void) { +void RMTony::close() { // Deallocation of missing item // _shadow.destroy(); } @@ -156,7 +156,7 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_END_CODE; } -void RMTony::show(void) { +void RMTony::show() { _bShow = true; _bShowShadow = true; } @@ -334,7 +334,7 @@ void RMTony::stop(CORO_PARAM) { } -int RMTony::getCurPattern(void) { +int RMTony::getCurPattern() { int nPatt = RMCharacter::getCurPattern(); if (!_bShepherdess) diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 70765abfd8..a50641bf25 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -369,12 +369,12 @@ public: /** * Initialize Tony */ - void init(void); + void init(); /** * Free all memory */ - void close(void); + void close(); /** * Tony makes a frame, updating the movement, etc. @@ -389,7 +389,7 @@ public: /** * Show or hide */ - void show(void); + void show(); void hide(bool bShowShadow = false); /** @@ -478,7 +478,7 @@ public: void setShepherdess(bool bIsPast) { _bShepherdess = bIsPast; } - int getShepherdess(void) { + int getShepherdess() { return _bShepherdess; } diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 6c36781f51..7661c600da 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -296,7 +296,7 @@ void RMString::resize(int size, bool bMantain) { /** * Compacts the string to occupy less memory if possible. */ -void RMString::compact(void) { +void RMString::compact() { if (_realLength + 1 > _length) { char *app; @@ -518,7 +518,7 @@ RMDataStream::~RMDataStream() { /** * Close a stream */ -void RMDataStream::close(void) { +void RMDataStream::close() { _length = 0; _pos = 0; } @@ -850,7 +850,7 @@ RMRect::RMRect() { setEmpty(); } -void RMRect::setEmpty(void) { +void RMRect::setEmpty() { _x1 = _y1 = _x2 = _y2 = 0; } @@ -981,7 +981,7 @@ bool RMRect::operator!=(const RMRect &rc) { return ((_x1 != rc._x1) || (_y1 != rc._y1) || (_x2 != rc._x2) || (_y2 != rc._y2)); } -void RMRect::normalizeRect(void) { +void RMRect::normalizeRect() { setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 4b0074f94c..c4f7386739 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -69,7 +69,7 @@ public: // Loading buffer void openBuffer(const byte *buf, int size = SIZENOTKNOWN); - void close(void); + void close(); // Attributei int length(); @@ -99,7 +99,6 @@ public: bool isError(); }; - /** * Data stream per lettura di dati aperto da file */ @@ -115,10 +114,9 @@ public: bool openFile(const char *lpFN); bool openFile(Common::File &file); - void close(void); + void close(); }; - class RMFileStreamSlow : public RMDataStream { private: Common::SeekableReadStream *_stream; @@ -129,7 +127,7 @@ public: bool openFile(const char *lpFN); bool openFile(Common::File &file); - void close(void); + void close(); RMDataStream &operator+=(int nBytes); int seek(int nBytes, RMDSPos where = CUR); @@ -272,7 +270,7 @@ public: // Set void setRect(int x1, int y1, int x2, int y2); void setRect(const RMPoint &p1, const RMPoint &p2); - void setEmpty(void); + void setEmpty(); // Copiers void setRect(const RMRect &rc); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index dd7c70fe19..ba030e6a36 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -66,7 +66,7 @@ void RMWindow::init() { /** * Close the window */ -void RMWindow::close(void) { +void RMWindow::close() { } void RMWindow::grabThumbnail(uint16 *thumbmem) { @@ -77,7 +77,7 @@ void RMWindow::grabThumbnail(uint16 *thumbmem) { /** * Repaint the screen */ -void RMWindow::repaint(void) { +void RMWindow::repaint() { g_system->updateScreen(); } diff --git a/engines/tony/window.h b/engines/tony/window.h index 876bbf6973..0d4c20b0fe 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -72,7 +72,7 @@ protected: bool _bGrabMovie; uint16 *_wThumbBuf; - void createBWPrecalcTable(void); + void createBWPrecalcTable(); void wipeEffect(Common::Rect &rcBoundEllipse); void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); @@ -84,13 +84,13 @@ public: * Initialization */ void init(/*HINSTANCE hInst*/); - void initDirectDraw(void); - void close(void); + void initDirectDraw(); + void close(); /** * Drawing */ - void repaint(void); + void repaint(); /** * Switch between windowed and fullscreen -- cgit v1.2.3 From f2e6b4615356d17205a1d4e04100f6de8676a194 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:28:13 +0200 Subject: TONY: Rename RMFontDialog --- engines/tony/font.cpp | 8 +++----- engines/tony/font.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index c4a95d0493..efce8dbe6e 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -201,10 +201,10 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { } /***************************************************************************\ -* RMFontParla Methods +* RMFontDialog Methods \****************************************************************************/ -void RMFontParla::init() { +void RMFontDialog::init() { int i; // bernie: Number of characters in the font @@ -1801,11 +1801,10 @@ void RMText::removeThis(CORO_PARAM, bool &result) { result = true; } - void RMText::writeText(const RMString &text, int nFont, int *time) { // Initializes the font (only once) if (_fonts[0] == NULL) { - _fonts[0] = new RMFontParla; + _fonts[0] = new RMFontDialog; _fonts[0]->init(); _fonts[1] = new RMFontObj; _fonts[1]->init(); @@ -1818,7 +1817,6 @@ void RMText::writeText(const RMString &text, int nFont, int *time) { writeText(text, _fonts[nFont], time); } - void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; char *p, *old_p; diff --git a/engines/tony/font.h b/engines/tony/font.h index 595cb726a6..9971e536ed 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -141,10 +141,10 @@ public: }; -class RMFontParla : public RMFontColor, public RMFontWithTables { +class RMFontDialog : public RMFontColor, public RMFontWithTables { public: void init(); - virtual ~RMFontParla() {} + virtual ~RMFontDialog() {} }; class RMFontObj : public RMFontColor, public RMFontWithTables { -- cgit v1.2.3 From 565bf7383a0000cf8564ac63da08a61778194254 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Jun 2012 19:50:29 +1000 Subject: TONY: Refactored the RMRect topLeft/bottomRight properties into a cleaner implementation --- engines/tony/utils.cpp | 32 ++++++++++++++++++-------------- engines/tony/utils.h | 17 +++++++++++++++-- 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 7661c600da..647ef0ed82 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -842,11 +842,25 @@ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { return ds; } +/****************************************************************************\ +* RMPointReference methods +\****************************************************************************/ + +RMPointReference &RMPointReference::operator=(const RMPoint &p) { + _x = p._x; _y = p._y; + return *this; +} + +RMPointReference &RMPointReference::operator-=(const RMPoint &p) { + _x -= p._x; _y -= p._y; + return *this; +} + /****************************************************************************\ * RMRect methods \****************************************************************************/ -RMRect::RMRect() { +RMRect::RMRect(): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setEmpty(); } @@ -854,15 +868,15 @@ void RMRect::setEmpty() { _x1 = _y1 = _x2 = _y2 = 0; } -RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { +RMRect::RMRect(const RMPoint &p1, const RMPoint &p2): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setRect(p1, p2); } -RMRect::RMRect(int X1, int Y1, int X2, int Y2) { +RMRect::RMRect(int X1, int Y1, int X2, int Y2): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setRect(X1, Y1, X2, Y2); } -RMRect::RMRect(const RMRect &rc) { +RMRect::RMRect(const RMRect &rc): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { copyRect(rc); } @@ -891,16 +905,6 @@ void RMRect::copyRect(const RMRect &rc) { _y2 = rc._y2; } -RMPoint &RMRect::topLeft() { - // FIXME: This seems very bad - return *((RMPoint *)this); -} - -RMPoint &RMRect::bottomRight() { - // FIXME: This seems very bad - return *((RMPoint *)this + 1); -} - RMPoint RMRect::center() { return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c4f7386739..e7f943b231 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -247,10 +247,23 @@ public: friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); }; +class RMPointReference { +public: + int &_x; + int &_y; + + RMPointReference(int &x, int &y): _x(x), _y(y) {} + RMPointReference &operator=(const RMPoint &p); + RMPointReference &operator-=(const RMPoint &p); + operator RMPoint() const { return RMPoint(_x, _y); } +}; + class RMRect { public: int _x1, _y1; int _x2, _y2; + RMPointReference _topLeft; + RMPointReference _bottomRight; public: RMRect(); @@ -259,8 +272,8 @@ public: RMRect(const RMRect &rc); // Attributes - RMPoint &topLeft(); - RMPoint &bottomRight(); + RMPointReference &topLeft() { return _topLeft; } + RMPointReference &bottomRight() { return _bottomRight; } RMPoint center(); int width() const; int height() const; -- cgit v1.2.3 From 0aa3d39cf7034dc35cda9e5062469886b0eb74d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Jun 2012 19:56:28 +1000 Subject: TONY: Remove unused stubs for LZO compression --- engines/tony/mpal/lzo.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 17b059455c..48a0d8ea87 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -506,19 +506,6 @@ lookbehind_overrun: #endif } -int lzo1x_1_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { - warning("TODO: lzo1x_1_compress"); - return 0; -} - -/** - * better compression ratio at the cost of more memory and time - */ -int lzo1x_999_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { - warning("TODO: lzo1x_999_compress"); - return 0; -} - } // end of namespace MPAL } // end of namespace Tony -- cgit v1.2.3 From ece5997fc3cd4e9fcab6062d6959720129a7aeab Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 61d460a854ff4883411846703543bb2f797fcd6b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 20:50:48 +1000 Subject: TONY: Implement more of the music related code from the original --- engines/tony/custom.cpp | 6 +- engines/tony/gfxengine.cpp | 2 - engines/tony/sound.cpp | 809 ++++++++++++++++++++++++++++++++------------- engines/tony/sound.h | 35 +- engines/tony/tony.cpp | 99 +++--- engines/tony/tony.h | 4 +- 6 files changed, 671 insertions(+), 284 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 016c84ab39..ce1c2860f8 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2198,14 +2198,14 @@ DECLARE_CUSTOM_FUNCTION(DemuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32 void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; - debug("Start CustPlayMusic"); + debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "Start CustPlayMusic"); GLOBALS.PlayMusic(nChannel, mFN, nFX, bLoop, nSync); - debug("End CustPlayMusic"); + debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "End CustPlayMusic"); } DECLARE_CUSTOM_FUNCTION(PlaySoundEffect)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX == 2) { - debug("PlaySoundEffect stop fadeout"); + debugC(DEBUG_INTERMEDIATE, kTonyDebugSound, "PlaySoundEffect stop fadeout"); GLOBALS._bFadeOutStop = true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 0785ec534c..cc53a1d8e2 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -473,8 +473,6 @@ void RMGfxEngine::init() { delete load; // Display 'Loading' screen - // TODO: The loading screen isn't currently optimal, since the game doesn't respond to events - // whilst the mpalInit code is being executed. _vm->_window.getNewFrame(*this, NULL); _vm->_window.repaint(); diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 7e786a2f11..484b279cda 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -39,11 +39,406 @@ namespace Tony { #define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} + +/****************************************************************************\ +***************************************************************************** +* class CODECRAW +* -------------- +* Description: CODEC to play hard from pure samples +***************************************************************************** +\****************************************************************************/ + +class CODECRAW : public CODEC { +public: + CODECRAW(bool _bLoop = true); + + virtual ~CODECRAW(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); + virtual void loopReset(); +}; + + +/****************************************************************************\ +***************************************************************************** +* class CODECADPCM +* ---------------- +* Description: Play ADPCM compressed data +***************************************************************************** +\****************************************************************************/ + +class CODECADPCM : public CODECRAW { +protected: + byte *lpTemp; + static const int indexTable[16]; + static const int stepSizeTable[89]; + +public: + CODECADPCM(bool _bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCM(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; + virtual void loopReset() = 0; +}; + +class CODECADPCMSTEREO : public CODECADPCM { +protected: + int valpred[2], index[2]; + +public: + CODECADPCMSTEREO(bool _bLoop=true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMSTEREO(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); + virtual void loopReset(); +}; + +class CODECADPCMMONO : public CODECADPCM { +protected: + int valpred, index; + +public: + CODECADPCMMONO(bool _bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMMONO(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); + virtual void loopReset(); +}; + +/****************************************************************************\ +* CODEC Methods +\****************************************************************************/ + /** - * Default constructor. Initializes the attributes. + * Standard cosntructor. It's possible to specify whether you want to + * enable or disable the loop (which by default, and 'active). + * + * @param loop True if you want to loop, false to disable + */ +CODEC::CODEC(bool loop) { + _bLoop = loop; + _bEndReached = false; +} + +CODEC::~CODEC() { +} + +/** + * Tell whether we have reached the end of the stream * + * @return True if we're done, false otherwise. + */ +bool CODEC::endOfStream() { + return _bEndReached; +} + + +/****************************************************************************\ +* CODECRAW Methods +\****************************************************************************/ + +/** + * Standard cosntructor. Simply calls the inherited constructor + */ +CODECRAW::CODECRAW(bool loop) : CODEC(loop) { +} + +CODECRAW::~CODECRAW() { +} + +/** + * Reset the stream to the beginning of the file. In the case of RAW files, does nothing + */ +void CODECRAW::loopReset() { +} + +/** + * Manage the RAW format. Simply copies the file's stream buffer + * + * @return Indicates the position of the file for the end of the loop + */ +uint32 CODECRAW::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { + byte *lpBuf = (byte *)buf; + uint32 dwRead; + uint32 dwEOF; + + _bEndReached = false; + dwEOF = 0; + dwRead = stream->read(lpBuf, dwSize); + + if (dwRead < dwSize) { + dwEOF = dwRead; + _bEndReached = true; + + if (!_bLoop) { + Common::fill(lpBuf + dwRead, lpBuf + dwRead + (dwSize - dwRead), 0); + } else { + stream->seek(0); + dwRead = stream->read(lpBuf + dwRead, dwSize - dwRead); + } + } + + return dwEOF; +} + +/****************************************************************************\ +* CODECADPCM Methods +\****************************************************************************/ + +const int CODECADPCM::indexTable[16] = { + -1, -1, -1, -1, 2, 4, 6, 8, + -1, -1, -1, -1, 2, 4, 6, 8, +}; + +const int CODECADPCM::stepSizeTable[89] = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, + 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, + 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, + 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, + 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, + 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, + 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 +}; + +#define MAXDECODESIZE (44100 * 2 * 2) + +/** + * Standard constructor. Initialises and allocates temporary memory tables + */ +CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { + // Alloca la memoria temporanea + if (lpTempBuffer != NULL) { + lpTemp = lpTempBuffer; + } else { + lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); + + if (lpTemp == NULL) { + error("Insufficient memory!"); + return; + } + } +} + + +CODECADPCMMONO::CODECADPCMMONO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop,lpTempBuffer) { + // Inizializza per il playing + loopReset(); +} + +CODECADPCMMONO::~CODECADPCMMONO() { +} + + +CODECADPCMSTEREO::CODECADPCMSTEREO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { + // Initialise for playing + loopReset(); +} + +CODECADPCMSTEREO::~CODECADPCMSTEREO() { +} + +/** + * Destructor. Free the buffer + */ +CODECADPCM::~CODECADPCM() { + globalDestroy(lpTemp); +} + + +/** + * Reset the player before each play or loop + */ +void CODECADPCMSTEREO::loopReset() { + valpred[0] = 0; + valpred[1] = 0; + index[0] = 0; + index[1] = 0; +} + +void CODECADPCMMONO::loopReset() { + valpred = 0; + index = 0; +} + + +/** + * Manages decompressing the ADPCM 16:4 format. */ +uint32 CODECADPCMMONO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + + bufferstep = 1; + step = stepSizeTable[index]; + + // Invokes the raw codec to read the stream from disk to loop. + eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + // If you must do an immediate loop + if (endOfStream() && eof == 0) { + loopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!endOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + // Check if we are at the end of the file, and are looping + if (eof != 0 && i == eof) { + loopReset(); + bufferstep=1; + step = stepSizeTable[index]; + } + + // Read the delta (4 bits) + if (bufferstep) { + cache = *inp++; + delta = (cache >> 4) & 0xF; + } else + delta = cache & 0xF; + + // Find the new index + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index = 88; + + // Reads the sign and separates it + sign = delta & 8; + delta = delta & 7; + + // Find the difference from the previous value + vpdiff = step >> 3; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + // Check the limits of the found value + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred = -32768; + + // Update the step + step = stepSizeTable[index]; + + // Write the value found + *lpBuf++ = (uint16)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + +uint32 CODECADPCMSTEREO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { + uint16 *lpBuf=(uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step[2]; + + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + // Invokes the RAW codec to read the stream from disk. + eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + // If you must do an immediate loop + if (endOfStream() && eof == 0) { + loopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + } else if (!endOfStream()) + eof = 0; + + dwSize /= 2; + + for (i = 0;i < dwSize; i++) { + // If you must do an immediate loop + if (eof != 0 && i == eof) { + loopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } + + // Reads the delta (4 bits) + if (bufferstep) { + cache = *inp++; + delta = cache & 0xF; + } else + delta = (cache >> 4) & 0xF; + + // Find the new index + index[bufferstep] += indexTable[delta]; + if (index[bufferstep] < 0) index[bufferstep] = 0; + if (index[bufferstep] > 88) index[bufferstep] = 88; + + // Reads the sign and separates it + sign = delta & 8; + delta = delta & 7; + + // Find the difference from the previous value + vpdiff = step[bufferstep] >> 3; + if (delta & 4) vpdiff += step[bufferstep]; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; + + if (sign) + valpred[bufferstep] -= vpdiff; + else + valpred[bufferstep] += vpdiff; + + // Check the limits of the value + if (valpred[bufferstep] > 32767) + valpred[bufferstep] = 32767; + else if (valpred[bufferstep] < -32768) + valpred[bufferstep] =- 32768; + + // Update the step + step[bufferstep] = stepSizeTable[index[bufferstep]]; + + // Write the found value + *lpBuf++ = (uint16)valpred[bufferstep]; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + +/****************************************************************************\ +* FPSOUND Methods +\****************************************************************************/ +/** + * Default constructor. Initializes the attributes. + * + */ FPSound::FPSound() { _bSoundSupported = false; } @@ -53,7 +448,6 @@ FPSound::FPSound() { * * @returns True is everything is OK, False otherwise */ - bool FPSound::init() { _bSoundSupported = g_system->getMixer()->isReady(); return _bSoundSupported; @@ -308,7 +702,7 @@ bool FPSfx::stop() { /** * Enables or disables the Sfx loop. * - * @param bLoop True to enable the loop, False to disable + * @param _bLoop True to enable the loop, False to disable * * @remarks The loop must be activated BEFORE the sfx starts * playing. Any changes made during the play will have @@ -423,20 +817,19 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { * @remarks Do *NOT* declare an object directly, but rather * create it using FPSound::CreateStream() */ - FPStream::FPStream(bool bSoundOn) { #ifdef REFACTOR_ME - //hwnd=hWnd; + hwnd=hWnd; lpDS = LPDS; - bSoundSupported = bSoundOn; - bFileLoaded = false; - bIsPlaying = false; - bPaused = false; - bSyncExit = false; - lpDSBuffer = NULL; - lpDSNotify = NULL; - hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL; + _lpDSBuffer = NULL; + _lpDSNotify = NULL; #endif + _bSoundSupported = bSoundOn; + _bFileLoaded = false; + _bIsPlaying = false; + _bPaused = false; + _bSyncExit = false; + _hHot1 = _hHot2 = _hHot3 = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; } bool FPStream::createBuffer(int nBufSize) { @@ -512,40 +905,38 @@ bool FPStream::createBuffer(int nBufSize) { */ FPStream::~FPStream() { -#ifdef REFACTOR_ME - - if (!bSoundSupported) + if (!_bSoundSupported) return; - if (bIsPlaying) - Stop(); + if (_bIsPlaying) + stop(); - if (bFileLoaded) - UnloadFile(); + if (_bFileLoaded) + unloadFile(); - if (hHot1) { - CloseHandle(hHot1); - hHot1 = NULL; + if (_hHot1) { + CoroScheduler.closeEvent(_hHot1); + _hHot1 = CORO_INVALID_PID_VALUE; } - if (hHot2) { - CloseHandle(hHot2); - hHot2 = NULL; + if (_hHot2) { + CoroScheduler.closeEvent(_hHot2); + _hHot2 = CORO_INVALID_PID_VALUE; } - if (hHot3) { - CloseHandle(hHot3); - hHot3 = NULL; + if (_hHot3) { + CoroScheduler.closeEvent(_hHot3); + _hHot3 = CORO_INVALID_PID_VALUE; } - if (hPlayThread_PlayFast) { - CloseHandle(hPlayThread_PlayFast); - hPlayThread_PlayFast = NULL; + if (_hPlayThreadPlayFast != CORO_INVALID_PID_VALUE) { + CoroScheduler.closeEvent(_hPlayThreadPlayFast); + _hPlayThreadPlayFast = CORO_INVALID_PID_VALUE; } - if (hPlayThread_PlayNormal) { - CloseHandle(hPlayThread_PlayNormal); - hPlayThread_PlayNormal = NULL; + if (_hPlayThreadPlayNormal != CORO_INVALID_PID_VALUE) { + CoroScheduler.closeEvent(_hPlayThreadPlayNormal); + _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; } - SyncToPlay = NULL; - + _syncToPlay = NULL; +#ifdef REFACTOR_ME RELEASE(lpDSNotify); RELEASE(lpDSBuffer); #endif @@ -559,7 +950,6 @@ FPStream::~FPStream() { * FPSound::CreateStream(). * Object pointers are no longer valid after this call. */ - void FPStream::release() { delete this; } @@ -567,44 +957,35 @@ void FPStream::release() { /** * Opens a file stream * - * @param lpszFile Filename to be opened + * @param fileName Filename to be opened * @param dwCodec CODEC to be used to uncompress samples * * @returns True is everything is OK, False otherwise */ - -bool FPStream::loadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { -#ifdef REFACTOR_ME - HRESULT err; - void *lpBuf; - uint32 dwHi; - - if (!bSoundSupported) +bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nBufSize) { + if (!_bSoundSupported) return true; - /* Si salva il tipo di codec */ - dwCodec = dwCodType; + // Save the codec type + _dwCodec = dwCodType; - /* Crea il buffer */ - if (!CreateBuffer(nBufSize)) + // Create the buffer + if (!createBuffer(nBufSize)) return true; - /* Apre il file di stream in lettura */ - if (!_file.open(lpszFileName)) - //MessageBox(hwnd,"Cannot open stream file!","FPStream::LoadFile()", MB_OK); + // Open the file stream for reading + if (!_file.open(fileName)) return false; -} -/* Si salva la lunghezza dello stream */ -dwSize = _file.size(); -_file.seek(0); + // Save the size of the stream + _dwSize = _file.size(); -/* Tutto a posto, possiamo uscire */ -bFileLoaded = true; -bIsPlaying = false; -bPaused = false; -#endif -return true; + // All done + _bFileLoaded = true; + _bIsPlaying = false; + _bPaused = false; + + return true; } /** @@ -616,85 +997,80 @@ return true; * @remarks It is necessary to call this function to free the * memory used by the stream. */ - bool FPStream::unloadFile() { -#ifdef REFACTOR_ME - - if (!bSoundSupported || !bFileLoaded) + if (!_bSoundSupported || !_bFileLoaded) return true; /* Closes the file handle stream */ _file.close(); - +#ifdef REFACTOR_ME RELEASE(lpDSNotify); RELEASE(lpDSBuffer); - - /* Remember no more file is loaded in memory */ - bFileLoaded = false; #endif + + // Flag that the file is no longer in memory + _bFileLoaded = false; + return true; } void FPStream::prefetch() { -#ifdef REFACTOR_ME - uint32 dwId; void *lpBuf; - uint32 dwHi; - HRESULT err; - if (!bSoundSupported || !bFileLoaded) + if (!_bSoundSupported || !_bFileLoaded) return; - /* Allocates a temporary buffer */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); - if (lpTempBuffer == NULL) + // Allocates a temporary buffer + _lpTempBuffer = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _dwBufferSize / 2); + if (_lpTempBuffer == NULL) return; - switch (dwCodec) { - case FPCODEC_RAW: - lpCodec = new CODECRAW(bLoop); - break; - - case FPCODEC_ADPCM: - lpCodec = new CODECADPCMSTEREO(bLoop); - break; - - default: + if (_dwCodec == FPCODEC_RAW) { + _codec = new CODECRAW(_bLoop); + } else if (_dwCodec == FPCODEC_ADPCM) { + _codec = new CODECADPCMSTEREO(_bLoop); + } else { return; } - /* reset the file position */ + // reset the file position _file.seek(0); - /* Fills the buffer for the data already ready */ +#ifdef REFACTOR_ME + // Fills the buffer for the data already ready if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); + _vm->GUIError("Cannot lock stream buffer!", "soundLoadStream()"); return; } +#endif - /* Uncompress the data from the stream directly into the locked buffer */ - lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - - /* Unlock the buffer */ - lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); + // Uncompress the data from the stream directly into the locked buffer + _codec->decompress(_file.readStream(_file.size()), lpBuf, _dwBufferSize / 2); - /* Create a thread to play the stream */ - hThreadEnd = CreateEvent(NULL, false, false, NULL); - hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); - SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); + // Unlock the buffer +#ifdef REFACTOR_ME + lpDSBuffer->unlock(lpBuf, _dwBufferSize / 2, NULL, NULL); +#endif - /* Start to play the buffer */ - lpDSBuffer->SetCurrentPosition(0); - bIsPlaying = true; + // Create a thread to play the stream + _hThreadEnd = CoroScheduler.createEvent(false, false); + _hPlayThread = CoroScheduler.createProcess(playThread, this, sizeof(FPStream *)); + + // Start to play the buffer +#ifdef REFACTOR_ME + lpDSBuffer->setCurrentPosition(0); +#endif + _bIsPlaying = true; - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; +#ifdef REFACTOR_ME + _dspnHot[0].dwOffset = 32; + _dspnHot[0].hEventNotify = _hHot1; - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; + _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + _dspnHot[1].hEventNotify = _hHot2; - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; + _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + _dspnHot[2].hEventNotify = _hHot3; if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; @@ -748,11 +1124,11 @@ bool FPStream::play() { switch (dwCodec) { case FPCODEC_RAW: - lpCodec = new CODECRAW(bLoop); + _codec = new CODECRAW(_bLoop); break; case FPCODEC_ADPCM: - lpCodec = new CODECADPCMSTEREO(bLoop); + _codec = new CODECADPCMSTEREO(_bLoop); break; default: @@ -770,7 +1146,7 @@ bool FPStream::play() { } /* Uncompress the data from the stream directly into the locked buffer */ - lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); + _codec->Decompress(hFile, lpBuf, dwBufferSize / 2); /* Unlock the buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); @@ -846,7 +1222,7 @@ bool FPStream::stop(bool bSync) { GlobalFree(lpTempBuffer); /* Close and free the CODEC */ - delete lpCodec; + delete _codec; bIsPlaying = false; bPaused = false; @@ -882,7 +1258,7 @@ void FPStream::waitForSync(FPStream *toplay) { GlobalFree(lpTempBuffer); /* Close and free the CODEC */ - delete lpCodec; + delete _codec; #endif _bIsPlaying = false; } @@ -892,129 +1268,110 @@ void FPStream::waitForSync(FPStream *toplay) { * */ -void FPStream::playThread(FPStream *This) { -#ifdef REFACTOR_ME - byte *lpLockBuf; - uint32 dwResult; - byte *lpLockBuf2; - uint32 dwResult2; - bool cicla = true; - uint32 countEnd; - bool bPrecache; - char buf[1024]; +void FPStream::playThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + byte *lpLockBuf; + uint32 dwResult; + byte *lpLockBuf2; + uint32 dwResult2; + bool cicla; + uint32 countEnd; + bool bPrecache; + char buf[1024]; + uint32 hList[5]; + CORO_END_CONTEXT(_ctx); - /* Events that signal when you need to do something */ - HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; +// FPStream *This = *(FPStream **)param; - bPrecache = true; - countEnd = 0; - while (cicla) { - if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { - countEnd++; - if (countEnd == 3) + CORO_BEGIN_CODE(_ctx); +#ifdef REFACTOR_ME + // Events that signal when you need to do something + _ctx->hList[0] = This->_hThreadEnd; + _ctx->hList[1] = This->_hHot1; + _ctx->hList[2] = This->_hHot2; + _ctx->hList[3] = This->_hHot3; + _ctx->hList[4] = This->_hPlayThreadPlayFast; + + _ctx->cicla = true; + _ctx->bPrecache = true; + _ctx->countEnd = 0; + while (_ctx->cicla) { + if (This->_codec->endOfStream() && This->_codec->_bLoop == false) { + _ctx->countEnd++; + if (_ctx->countEnd == 3) break; } - /* Uncompresses the data being written into the temporary buffer */ - if (This->lastVolume == 0) - ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); - else if (bPrecache) - This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); + // Uncompresses the data being written into the temporary buffer + if (This->_lastVolume == 0) + ZeroMemory(This->_lpTempBuffer, This->_dwBufferSize / 2); + else if (_ctx->bPrecache) + This->_codec->decompress(This->_file.readStream(This->_file.size()), This->_lpTempBuffer, This->_dwBufferSize / 2); + + _ctx->bPrecache = false; - bPrecache = false; + // Waits for an event. Since they are all in automatic reset, there is no need to reset it after - /* Waits for an event. Since they are all in automatic reset, there is no need to reset it after */ + uint32 dwBufStatus; -// uint32 dwBufStatus; -// This->lpDSBuffer->GetStatus(&dwBufStatus); + CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 5, _ctx->hList, false, CORO_INFINITE, &_ctx->dwResult); + // Check to determine which event has been set + if (CoroScheduler.getEvent(This->_hThreadEnd)->signalled) { + /* Must leave the thread */ + _ctx->cicla = false; + + } else if (CoroScheduler.getEvent(This->_hHot1)->signalled) { + // Must fill the second half of the buffer + This->lpDSBuffer->Lock(This->_dwBufferSize / 2, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, (void **)&_ctx->lpLockBuf2, &_ctx->dwResult2, 0); -// sprintf(buf, "WFMO: %x (buf status: %x) MyThread: 0x%x\n", This->lpDSBuffer, dwBufStatus, GetCurrentThreadId()); -// warning(buf); - dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); + copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); + This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, _ctx->lpLockBuf2, 0); - /* uint32 dwPlay, dwWrite; - This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); - sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); - warning(buf); */ + _ctx->bPrecache = true; - /* Make a switch to determine which event has been set */ - switch (dwResult - WAIT_OBJECT_0) { - case 0: - /* Must leave the thread */ - cicla = false; - break; - - case 1: - /* Must fill the second half of the buffer */ -// if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) - { -// sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); -// warning(buf); - This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); - // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); - // warning(buf); - copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); - This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); - bPrecache = true; - } - break; + } else if (CoroScheduler.getEvent(This->_hHot2)->signalled) { + This->lpDSBuffer->Lock(0, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, NULL, NULL, 0); - case 2: - /* Must fill the first half of the buffer */ -// if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) - { -// sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); -// warning(buf); - This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); - This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); - bPrecache = true; - } - break; + copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); + This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, NULL, NULL); + + _ctx->bPrecache = true; + + } else if (CoroScheduler.getEvent(This->_hHot3)->signalled) { + + if (This->_bSyncExit) { + CoroScheduler.setEvent(This->_syncToPlay->_hPlayThreadPlayFast); - case 3: { -// sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); -// warning(buf); - if (This->bSyncExit) { -// sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); -// warning(buf); - //This->SyncToPlay->PlayFast(); - SetEvent(This->SyncToPlay->hPlayThread_PlayFast); // Transfer immediatly control to the other threads - Sleep(0); - This->bSyncExit = false; - cicla = false; + CORO_SLEEP(1); + + This->_bSyncExit = false; + _ctx->cicla = false; break; } - } - break; - - case 4: - This->PlayFast(); - break; + } else if (CoroScheduler.getEvent(This->_hPlayThreadPlayFast)->signalled) { + This->playFast(); } } - /* Close the DirectSound buffer */ -// sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); -// warning(buf); + // Close the DirectSound buffer This->lpDSBuffer->Stop(); - - ExitThread(0); #endif + + CORO_END_CODE; } + /** * Unables or disables stream loop. * - * @param bLoop True enable loop, False disables it + * @param _bLoop True enable loop, False disables it * * @remarks The loop must be activated BEFORE the stream starts * playing. Any changes made during the play will have no * effect until the stream is stopped then played again. */ - void FPStream::setLoop(bool loop) { _bLoop = loop; } @@ -1025,38 +1382,38 @@ void FPStream::setLoop(bool loop) { * * @param bPause True enables pause, False disables it */ - void FPStream::pause(bool bPause) { + if (_bFileLoaded) { + if (bPause && _bIsPlaying) { #ifdef REFACTOR_ME + _lpDSBuffer->Stop(); +#endif + _bIsPlaying = false; + _bPaused = true; + } else if (!bPause && _bPaused) { +#ifdef REFACTOR_ME + _dspnHot[0].dwOffset = 32; + _dspnHot[0].hEventNotify = hHot1; - if (bFileLoaded) { - if (bPause && bIsPlaying) { - lpDSBuffer->Stop(); - bIsPlaying = false; - bPaused = true; - } else if (!bPause && bPaused) { - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; + _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + _dspnHot[1].hEventNotify = hHot2; - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; + _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + _dspnHot[2].hEventNotify = hHot3; if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; } - lpDSBuffer->Play(0, 0, bLoop); - bIsPlaying = true; - bPaused = false; + lpDSBuffer->Play(0, 0, _bLoop); +#endif + _bIsPlaying = true; + _bPaused = false; // Trick to reset the volume after a possible new sound configuration - SetVolume(lastVolume); + setVolume(_lastVolume); } } -#endif } /** diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 4dd00a3028..38ce6de2a7 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -245,6 +245,24 @@ public: bool endOfBuffer() const; }; +/** + * Codec base class + */ +class CODEC { +protected: + bool _bEndReached; + +public: + bool _bLoop; + + CODEC(bool _bLoop = true); + virtual ~CODEC(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; + virtual void loopReset() = 0; + bool endOfStream(); +}; + + class FPStream { private: // HWND hwnd; @@ -258,12 +276,12 @@ private: uint32 _dwSize; // Stream size (bytes) uint32 _dwCodec; // CODEC used - HANDLE _hThreadEnd; // Event used to close thread + uint32 _hThreadEnd; // Event used to close thread Common::File _file; // File handle used for the stream - HANDLE _hPlayThread; // Handle of the Play thread - HANDLE _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify - HANDLE _hPlayThreadPlayFast; - HANDLE _hPlayThreadPlayNormal; + uint32 _hPlayThread; // Handle of the Play thread + uint32 _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify + uint32 _hPlayThreadPlayFast; + uint32 _hPlayThreadPlayNormal; bool _bSoundSupported; // True if the sound is active bool _bFileLoaded; // True if the file is open @@ -273,6 +291,7 @@ private: bool _bPaused; int _lastVolume; FPStream *_syncToPlay; + CODEC *_codec; // DSBPOSITIONNOTIFY dspnHot[3]; @@ -286,7 +305,7 @@ private: * Thread playing the stream * */ - static void playThread(FPStream *This); + static void playThread(CORO_PARAM, const void *param); public: @@ -321,13 +340,13 @@ public: /** * Opens a file stream * - * @param lpszFile Filename to be opened + * @param fileName Filename to be opened * @param dwCodec CODEC to be used to uncompress samples * * @returns True is everything is OK, False otherwise */ - bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + bool loadFile(const Common::String &fileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); /** * Closes a file stream (opened or not). diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9e9e032e49..2c102f5c8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -187,10 +187,7 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { - warning("TODO: TonyEngine::playMusic"); -// g_system->lockMutex(csMusic); - +void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, bool bLoop, int nSync) { if (nChannel < 4) if (GLOBALS._flipflop) nChannel = nChannel + 1; @@ -207,64 +204,78 @@ void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, in break; } -#ifdef REFACTOR_ME - // Mette il path giusto - if (nChannel < 4) - GetDataDirectory(DD_MUSIC, path_buffer); - else - GetDataDirectory(DD_LAYER, path_buffer); - _splitpath(path_buffer, drive, dir, NULL, NULL); - _splitpath(fn, NULL, NULL, fname, ext); - _makepath(path_buffer, drive, dir, fname, ext); - - _makepath(path_buffer, drive, dir, fname, ext); - if (nFX == 22) { // Sync a tempo - curChannel = nChannel; - strcpy(nextMusic, path_buffer); - nextLoop = bLoop; - nextSync = nSync; - if (flipflop) - nextChannel = nChannel - 1; + GLOBALS._curChannel = nChannel; + GLOBALS._nextLoop = bLoop; + GLOBALS._nextSync = nSync; + if (GLOBALS._flipflop) + GLOBALS._nextChannel = nChannel - 1; else - nextChannel = nChannel + 1; - DWORD id; - HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, _stream, 0, &id); - SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); + GLOBALS._nextChannel = nChannel + 1; + + uint32 hThread = CoroScheduler.createProcess(doNextMusic, &_stream, sizeof(FPStream ***)); + assert(hThread != CORO_INVALID_PID_VALUE); + } else if (nFX == 44) { // Cambia canale e lascia finire il primo - if (flipflop) - nextChannel = nChannel - 1; + if (GLOBALS._flipflop) + GLOBALS._nextChannel = nChannel - 1; else - nextChannel = nChannel + 1; + GLOBALS._nextChannel = nChannel + 1; - _stream[nextChannel]->Stop(); - _stream[nextChannel]->UnloadFile(); + _stream[GLOBALS._nextChannel]->stop(); + _stream[GLOBALS._nextChannel]->unloadFile(); if (!getIsDemo()) { - if (!_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) - theGame.Abort(); + if (!_stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) + _vm->abortGame(); } else { - _stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } - _stream[nextChannel]->SetLoop(bLoop); - _stream[nextChannel]->Play(); + _stream[GLOBALS._nextChannel]->setLoop(bLoop); + _stream[GLOBALS._nextChannel]->play(); - flipflop = 1 - flipflop; + GLOBALS._flipflop = 1 - GLOBALS._flipflop; } else { if (!getIsDemo()) { - if (!_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) - theGame.Abort(); + if (!_stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) + _vm->abortGame(); } else { - _stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } - _stream[nChannel]->SetLoop(bLoop); - _stream[nChannel]->Play(); + _stream[nChannel]->setLoop(bLoop); + _stream[nChannel]->play(); } -#endif +} -// g_system->unlockMutex(csMusic); +void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + Common::String fn; + CORO_END_CONTEXT(_ctx); + + FPStream **streams = *(FPStream ***)param; + + CORO_BEGIN_CODE(_ctx); + + if (!_vm->getIsDemo()) { + if (!streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync)) + _vm->abortGame(); + } else { + streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync); + } + + streams[GLOBALS._nextChannel]->setLoop(GLOBALS._nextLoop); + streams[GLOBALS._nextChannel]->prefetch(); + + streams[GLOBALS._curChannel]->stop(true); + streams[GLOBALS._curChannel]->waitForSync(streams[GLOBALS._nextChannel]); + + streams[GLOBALS._curChannel]->unloadFile(); + + GLOBALS._flipflop = 1 - GLOBALS._flipflop; + + CORO_END_CODE; } void TonyEngine::playSFX(int nChannel, int nFX) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 5f6fd8cb44..94dc3de92d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -87,6 +87,8 @@ private: void closeVoiceDatabase(); void initCustomFunctionMap(); static void playProcess(CORO_PARAM, const void *param); + static void doNextMusic(CORO_PARAM, const void *param); + protected: // Engine APIs virtual Common::Error run(); @@ -183,7 +185,7 @@ public: // Music // ****** - void playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); + void playMusic(int nChannel, const Common::String &fn, int nFX, bool bLoop, int nSync); void stopMusic(int nChannel); void playSFX(int nSfx, int nFX = 0); -- cgit v1.2.3 From b8d5e17fefd2a36e253a150fee324c912ca35384 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 21:14:56 +1000 Subject: TONY: Added an extra check for shouldQuit into the main event loop --- engines/tony/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 2a8cdc10c3..7d663c1465 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,7 +52,7 @@ void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events - while (g_system->getEventManager()->pollEvent(_event)) { + while (g_system->getEventManager()->pollEvent(_event) && !_vm->shouldQuit()) { switch (_event.type) { case Common::EVENT_MOUSEMOVE: case Common::EVENT_LBUTTONDOWN: -- cgit v1.2.3 From 9d437a26dd296d6cf7e4db4749a90cafe9787377 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 21:19:17 +1000 Subject: TONY: Fix some compiler warnings in the newly added sound code --- engines/tony/sound.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 484b279cda..e4f46af146 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -266,7 +266,7 @@ uint32 CODECADPCMMONO::decompress(Common::SeekableReadStream *stream, void *buf, uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -348,7 +348,7 @@ uint32 CODECADPCMSTEREO::decompress(Common::SeekableReadStream *stream, void *bu uint16 *lpBuf=(uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -1015,7 +1015,7 @@ bool FPStream::unloadFile() { } void FPStream::prefetch() { - void *lpBuf; + void *lpBuf = NULL; if (!_bSoundSupported || !_bFileLoaded) return; @@ -1042,6 +1042,8 @@ void FPStream::prefetch() { _vm->GUIError("Cannot lock stream buffer!", "soundLoadStream()"); return; } +#else + error("lpBuf isn't set"); #endif // Uncompress the data from the stream directly into the locked buffer -- cgit v1.2.3 From d2061f29bef9f2dadd5eda149384b5fdfbcc3ac1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 22:06:30 +1000 Subject: TONY: Added initialisation of FPSound fields in it's constructor --- engines/tony/sound.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e4f46af146..e79b06191e 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -828,8 +828,18 @@ FPStream::FPStream(bool bSoundOn) { _bFileLoaded = false; _bIsPlaying = false; _bPaused = false; + _bLoop = false; + _bDoFadeOut = false; _bSyncExit = false; - _hHot1 = _hHot2 = _hHot3 = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; + _hHot1 = _hHot2 = _hHot3 = CORO_INVALID_PID_VALUE; + _hPlayThread = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; + _hThreadEnd = CORO_INVALID_PID_VALUE; + _dwBufferSize = _dwSize = 0; + _dwCodec = 0; + _lastVolume = 0; + _lpTempBuffer = NULL; + _syncToPlay = NULL; + _codec = NULL; } bool FPStream::createBuffer(int nBufSize) { -- cgit v1.2.3 From aa775b4497746d978599dda06ca9a385c5e6dc59 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 22:37:56 +1000 Subject: TONY: Some bugfixes and cleanup for the music support code --- engines/tony/globals.cpp | 1 - engines/tony/globals.h | 4 +--- engines/tony/sound.cpp | 3 ++- engines/tony/tony.cpp | 6 ++++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 893322942a..f28a22e4a5 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -26,7 +26,6 @@ namespace Tony { Globals::Globals() { - Common::fill(_nextMusic, _nextMusic + MAX_PATH, 0); _nextLoop = false; _nextChannel = 0; _nextSync = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 7b5d6db9cf..b63dce7c45 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -43,8 +43,6 @@ namespace Tony { #define TAPPETI_MARE 6 #define TAPPETI_MAREMETA 7 -#define MAX_PATH 255 - struct CharacterStruct { uint32 _code; RMItem *_item; @@ -168,7 +166,7 @@ class Globals { public: Globals(); - char _nextMusic[MAX_PATH]; + Common::String _nextMusic; bool _nextLoop; int _nextChannel; int _nextSync; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e79b06191e..75ae82298d 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1053,7 +1053,8 @@ void FPStream::prefetch() { return; } #else - error("lpBuf isn't set"); + // Return, since lpBuf hasn't been set + return; #endif // Uncompress the data from the stream directly into the locked buffer diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2c102f5c8b..8ae95af862 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -208,12 +208,14 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b GLOBALS._curChannel = nChannel; GLOBALS._nextLoop = bLoop; GLOBALS._nextSync = nSync; + GLOBALS._nextMusic = fname; + if (GLOBALS._flipflop) GLOBALS._nextChannel = nChannel - 1; else GLOBALS._nextChannel = nChannel + 1; - uint32 hThread = CoroScheduler.createProcess(doNextMusic, &_stream, sizeof(FPStream ***)); + uint32 hThread = CoroScheduler.createProcess(doNextMusic, NULL, 0); assert(hThread != CORO_INVALID_PID_VALUE); } else if (nFX == 44) { // Cambia canale e lascia finire il primo @@ -254,7 +256,7 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { Common::String fn; CORO_END_CONTEXT(_ctx); - FPStream **streams = *(FPStream ***)param; + FPStream **streams = _vm->_stream; CORO_BEGIN_CODE(_ctx); -- cgit v1.2.3 From 1ee68078c1272287db82f819f2fdc99c6fe04622 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 20 Jun 2012 17:58:01 +0200 Subject: TONY: Replace the FPStream code. This just removes the original code and replaces it with a quickly- written trivial implementation similar to clone2727's sfx code. It seems to at least sort of work. :-) --- engines/tony/sound.cpp | 937 ++++--------------------------------------------- engines/tony/sound.h | 32 +- engines/tony/tony.cpp | 2 +- 3 files changed, 79 insertions(+), 892 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 75ae82298d..b0a2c69fd6 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -36,401 +36,6 @@ namespace Tony { - -#define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} - - -/****************************************************************************\ -***************************************************************************** -* class CODECRAW -* -------------- -* Description: CODEC to play hard from pure samples -***************************************************************************** -\****************************************************************************/ - -class CODECRAW : public CODEC { -public: - CODECRAW(bool _bLoop = true); - - virtual ~CODECRAW(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); - virtual void loopReset(); -}; - - -/****************************************************************************\ -***************************************************************************** -* class CODECADPCM -* ---------------- -* Description: Play ADPCM compressed data -***************************************************************************** -\****************************************************************************/ - -class CODECADPCM : public CODECRAW { -protected: - byte *lpTemp; - static const int indexTable[16]; - static const int stepSizeTable[89]; - -public: - CODECADPCM(bool _bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCM(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; - virtual void loopReset() = 0; -}; - -class CODECADPCMSTEREO : public CODECADPCM { -protected: - int valpred[2], index[2]; - -public: - CODECADPCMSTEREO(bool _bLoop=true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMSTEREO(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); - virtual void loopReset(); -}; - -class CODECADPCMMONO : public CODECADPCM { -protected: - int valpred, index; - -public: - CODECADPCMMONO(bool _bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMMONO(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); - virtual void loopReset(); -}; - -/****************************************************************************\ -* CODEC Methods -\****************************************************************************/ - -/** - * Standard cosntructor. It's possible to specify whether you want to - * enable or disable the loop (which by default, and 'active). - * - * @param loop True if you want to loop, false to disable - */ -CODEC::CODEC(bool loop) { - _bLoop = loop; - _bEndReached = false; -} - -CODEC::~CODEC() { -} - -/** - * Tell whether we have reached the end of the stream - * - * @return True if we're done, false otherwise. - */ -bool CODEC::endOfStream() { - return _bEndReached; -} - - -/****************************************************************************\ -* CODECRAW Methods -\****************************************************************************/ - -/** - * Standard cosntructor. Simply calls the inherited constructor - */ -CODECRAW::CODECRAW(bool loop) : CODEC(loop) { -} - -CODECRAW::~CODECRAW() { -} - -/** - * Reset the stream to the beginning of the file. In the case of RAW files, does nothing - */ -void CODECRAW::loopReset() { -} - -/** - * Manage the RAW format. Simply copies the file's stream buffer - * - * @return Indicates the position of the file for the end of the loop - */ -uint32 CODECRAW::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { - byte *lpBuf = (byte *)buf; - uint32 dwRead; - uint32 dwEOF; - - _bEndReached = false; - dwEOF = 0; - dwRead = stream->read(lpBuf, dwSize); - - if (dwRead < dwSize) { - dwEOF = dwRead; - _bEndReached = true; - - if (!_bLoop) { - Common::fill(lpBuf + dwRead, lpBuf + dwRead + (dwSize - dwRead), 0); - } else { - stream->seek(0); - dwRead = stream->read(lpBuf + dwRead, dwSize - dwRead); - } - } - - return dwEOF; -} - -/****************************************************************************\ -* CODECADPCM Methods -\****************************************************************************/ - -const int CODECADPCM::indexTable[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -const int CODECADPCM::stepSizeTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - -#define MAXDECODESIZE (44100 * 2 * 2) - -/** - * Standard constructor. Initialises and allocates temporary memory tables - */ -CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { - // Alloca la memoria temporanea - if (lpTempBuffer != NULL) { - lpTemp = lpTempBuffer; - } else { - lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); - - if (lpTemp == NULL) { - error("Insufficient memory!"); - return; - } - } -} - - -CODECADPCMMONO::CODECADPCMMONO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop,lpTempBuffer) { - // Inizializza per il playing - loopReset(); -} - -CODECADPCMMONO::~CODECADPCMMONO() { -} - - -CODECADPCMSTEREO::CODECADPCMSTEREO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { - // Initialise for playing - loopReset(); -} - -CODECADPCMSTEREO::~CODECADPCMSTEREO() { -} - -/** - * Destructor. Free the buffer - */ -CODECADPCM::~CODECADPCM() { - globalDestroy(lpTemp); -} - - -/** - * Reset the player before each play or loop - */ -void CODECADPCMSTEREO::loopReset() { - valpred[0] = 0; - valpred[1] = 0; - index[0] = 0; - index[1] = 0; -} - -void CODECADPCMMONO::loopReset() { - valpred = 0; - index = 0; -} - - -/** - * Manages decompressing the ADPCM 16:4 format. - */ -uint32 CODECADPCMMONO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step; - - bufferstep = 1; - step = stepSizeTable[index]; - - // Invokes the raw codec to read the stream from disk to loop. - eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - // If you must do an immediate loop - if (endOfStream() && eof == 0) { - loopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } else if (!endOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - // Check if we are at the end of the file, and are looping - if (eof != 0 && i == eof) { - loopReset(); - bufferstep=1; - step = stepSizeTable[index]; - } - - // Read the delta (4 bits) - if (bufferstep) { - cache = *inp++; - delta = (cache >> 4) & 0xF; - } else - delta = cache & 0xF; - - // Find the new index - index += indexTable[delta]; - if (index < 0) index = 0; - if (index > 88) index = 88; - - // Reads the sign and separates it - sign = delta & 8; - delta = delta & 7; - - // Find the difference from the previous value - vpdiff = step >> 3; - if (delta & 4) vpdiff += step; - if (delta & 2) vpdiff += step >> 1; - if (delta & 1) vpdiff += step >> 2; - - if (sign) - valpred -= vpdiff; - else - valpred += vpdiff; - - // Check the limits of the found value - if (valpred > 32767) - valpred = 32767; - else if (valpred < -32768) - valpred = -32768; - - // Update the step - step = stepSizeTable[index]; - - // Write the value found - *lpBuf++ = (uint16)valpred; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - -uint32 CODECADPCMSTEREO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { - uint16 *lpBuf=(uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step[2]; - - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - // Invokes the RAW codec to read the stream from disk. - eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - // If you must do an immediate loop - if (endOfStream() && eof == 0) { - loopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - } else if (!endOfStream()) - eof = 0; - - dwSize /= 2; - - for (i = 0;i < dwSize; i++) { - // If you must do an immediate loop - if (eof != 0 && i == eof) { - loopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } - - // Reads the delta (4 bits) - if (bufferstep) { - cache = *inp++; - delta = cache & 0xF; - } else - delta = (cache >> 4) & 0xF; - - // Find the new index - index[bufferstep] += indexTable[delta]; - if (index[bufferstep] < 0) index[bufferstep] = 0; - if (index[bufferstep] > 88) index[bufferstep] = 88; - - // Reads the sign and separates it - sign = delta & 8; - delta = delta & 7; - - // Find the difference from the previous value - vpdiff = step[bufferstep] >> 3; - if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep] >> 1; - if (delta & 1) vpdiff += step[bufferstep] >> 2; - - if (sign) - valpred[bufferstep] -= vpdiff; - else - valpred[bufferstep] += vpdiff; - - // Check the limits of the value - if (valpred[bufferstep] > 32767) - valpred[bufferstep] = 32767; - else if (valpred[bufferstep] < -32768) - valpred[bufferstep] =- 32768; - - // Update the step - step[bufferstep] = stepSizeTable[index[bufferstep]]; - - // Write the found value - *lpBuf++ = (uint16)valpred[bufferstep]; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - /****************************************************************************\ * FPSOUND Methods \****************************************************************************/ @@ -818,94 +423,17 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { * create it using FPSound::CreateStream() */ FPStream::FPStream(bool bSoundOn) { -#ifdef REFACTOR_ME - hwnd=hWnd; - lpDS = LPDS; - _lpDSBuffer = NULL; - _lpDSNotify = NULL; -#endif _bSoundSupported = bSoundOn; _bFileLoaded = false; - _bIsPlaying = false; _bPaused = false; _bLoop = false; _bDoFadeOut = false; _bSyncExit = false; - _hHot1 = _hHot2 = _hHot3 = CORO_INVALID_PID_VALUE; - _hPlayThread = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; - _hThreadEnd = CORO_INVALID_PID_VALUE; _dwBufferSize = _dwSize = 0; - _dwCodec = 0; _lastVolume = 0; - _lpTempBuffer = NULL; _syncToPlay = NULL; - _codec = NULL; -} - -bool FPStream::createBuffer(int nBufSize) { -#ifdef REFACTOR_ME - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - static HRESULT err; - static char errbuf[128]; - - if (bSoundSupported == false) - return true; - - /* Set the required structures for the creation of a secondary buffer for the stream containing exactly 1 second of music. - Also activate the volume control, in order to lower and raise the volume of the music regardless of the general volume. - Obviously it is a buffer in RAM */ - - pcmwf.wBitsPerSample = 16; - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = 2; - pcmwf.wf.nSamplesPerSec = 44100; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dwBufferSize = dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); - bSoundSupported = false; - return false; - } - SetVolume(63); - - - /* Create an alert when key positions are reached in the stream. - Key positions are located, respectively, immediately after - the start and immediately after the middle of the buffer */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); - - if (FAILED(err)) { - wsprintf(errbuf, "Error creating notify object! (%lx)", err); - MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); - bSoundSupported = false; - return false; - } - - hHot1 = CreateEvent(NULL, false, false, NULL); - hHot2 = CreateEvent(NULL, false, false, NULL); - hHot3 = CreateEvent(NULL, false, false, NULL); - hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); - - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - lpDSNotify->SetNotificationPositions(3, dspnHot); -#endif - return true; + _loopStream = NULL; + _rewindableStream = NULL; } /** @@ -918,38 +446,13 @@ FPStream::~FPStream() { if (!_bSoundSupported) return; - if (_bIsPlaying) + if (g_system->getMixer()->isSoundHandleActive(_handle)) stop(); if (_bFileLoaded) unloadFile(); - if (_hHot1) { - CoroScheduler.closeEvent(_hHot1); - _hHot1 = CORO_INVALID_PID_VALUE; - } - if (_hHot2) { - CoroScheduler.closeEvent(_hHot2); - _hHot2 = CORO_INVALID_PID_VALUE; - } - if (_hHot3) { - CoroScheduler.closeEvent(_hHot3); - _hHot3 = CORO_INVALID_PID_VALUE; - } - if (_hPlayThreadPlayFast != CORO_INVALID_PID_VALUE) { - CoroScheduler.closeEvent(_hPlayThreadPlayFast); - _hPlayThreadPlayFast = CORO_INVALID_PID_VALUE; - } - if (_hPlayThreadPlayNormal != CORO_INVALID_PID_VALUE) { - CoroScheduler.closeEvent(_hPlayThreadPlayNormal); - _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; - } - _syncToPlay = NULL; -#ifdef REFACTOR_ME - RELEASE(lpDSNotify); - RELEASE(lpDSBuffer); -#endif } /** @@ -976,13 +479,12 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB if (!_bSoundSupported) return true; + if (_bFileLoaded) + unloadFile(); + // Save the codec type _dwCodec = dwCodType; - // Create the buffer - if (!createBuffer(nBufSize)) - return true; - // Open the file stream for reading if (!_file.open(fileName)) return false; @@ -990,11 +492,26 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB // Save the size of the stream _dwSize = _file.size(); + switch (_dwCodec) { + case FPCODEC_RAW: + _rewindableStream = Audio::makeRawStream(&_file, 44100, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO, DisposeAfterUse::NO); + break; + + case FPCODEC_ADPCM: + _rewindableStream = Audio::makeADPCMStream(&_file, DisposeAfterUse::NO, 0, Audio::kADPCMDVI, 44100, 2); + break; + + default: + _file.close(); + return false; + } + // All done _bFileLoaded = true; - _bIsPlaying = false; _bPaused = false; + setVolume(63); + return true; } @@ -1011,12 +528,12 @@ bool FPStream::unloadFile() { if (!_bSoundSupported || !_bFileLoaded) return true; + assert(!g_system->getMixer()->isSoundHandleActive(_handle)); + /* Closes the file handle stream */ + delete _loopStream; + delete _rewindableStream; _file.close(); -#ifdef REFACTOR_ME - RELEASE(lpDSNotify); - RELEASE(lpDSBuffer); -#endif // Flag that the file is no longer in memory _bFileLoaded = false; @@ -1024,96 +541,6 @@ bool FPStream::unloadFile() { return true; } -void FPStream::prefetch() { - void *lpBuf = NULL; - - if (!_bSoundSupported || !_bFileLoaded) - return; - - // Allocates a temporary buffer - _lpTempBuffer = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _dwBufferSize / 2); - if (_lpTempBuffer == NULL) - return; - - if (_dwCodec == FPCODEC_RAW) { - _codec = new CODECRAW(_bLoop); - } else if (_dwCodec == FPCODEC_ADPCM) { - _codec = new CODECADPCMSTEREO(_bLoop); - } else { - return; - } - - // reset the file position - _file.seek(0); - -#ifdef REFACTOR_ME - // Fills the buffer for the data already ready - if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - _vm->GUIError("Cannot lock stream buffer!", "soundLoadStream()"); - return; - } -#else - // Return, since lpBuf hasn't been set - return; -#endif - - // Uncompress the data from the stream directly into the locked buffer - _codec->decompress(_file.readStream(_file.size()), lpBuf, _dwBufferSize / 2); - - // Unlock the buffer -#ifdef REFACTOR_ME - lpDSBuffer->unlock(lpBuf, _dwBufferSize / 2, NULL, NULL); -#endif - - // Create a thread to play the stream - _hThreadEnd = CoroScheduler.createEvent(false, false); - _hPlayThread = CoroScheduler.createProcess(playThread, this, sizeof(FPStream *)); - - // Start to play the buffer -#ifdef REFACTOR_ME - lpDSBuffer->setCurrentPosition(0); -#endif - _bIsPlaying = true; - -#ifdef REFACTOR_ME - _dspnHot[0].dwOffset = 32; - _dspnHot[0].hEventNotify = _hHot1; - - _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - _dspnHot[1].hEventNotify = _hHot2; - - _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - _dspnHot[2].hEventNotify = _hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - int a = 1; - } -#endif -} - -void FPStream::playFast() { -#ifdef REFACTOR_ME - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - lpDSBuffer->Stop(); - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - warning("PlayFast SNP failed!"); - } - - if (FAILED(lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING))) { - warning("PlayFast failed!\n"); - } -#endif -} - /** * Play the stream. * @@ -1121,79 +548,27 @@ void FPStream::playFast() { */ bool FPStream::play() { -#ifdef REFACTOR_ME - uint32 dwId; - void *lpBuf; - uint32 dwHi; - HRESULT err; - - if (!bSoundSupported || !bFileLoaded) - return false; - - /* Allocate a temporary buffer */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); - if (lpTempBuffer == NULL) - return false; - - switch (dwCodec) { - case FPCODEC_RAW: - _codec = new CODECRAW(_bLoop); - break; - - case FPCODEC_ADPCM: - _codec = new CODECADPCMSTEREO(_bLoop); - break; - - default: + if (!_bSoundSupported || !_bFileLoaded) return false; - } - - /* Reset the file position */ - _file.seek(0); - lpDSBuffer->Stop(); - lpDSBuffer->SetCurrentPosition(0); - - /* Fills the buffer for the data already ready */ - if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - error("Cannot lock stream buffer!", "soundLoadStream()"); - } - - /* Uncompress the data from the stream directly into the locked buffer */ - _codec->Decompress(hFile, lpBuf, dwBufferSize / 2); - - /* Unlock the buffer */ - lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - - /* Create a thread to play the stream */ - hThreadEnd = CreateEvent(NULL, false, false, NULL); - hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); - SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - SetEvent(hPlayThread_PlayFast); + stop(); -#if 0 - /* Start to play the buffer */ - lpDSBuffer->SetCurrentPosition(0); + _rewindableStream->rewind(); - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; + Audio::AudioStream *stream = _rewindableStream; - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; + if (_bLoop) { + if (!_loopStream) + _loopStream = new Audio::LoopingAudioStream(_rewindableStream, 0, DisposeAfterUse::NO); - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - int a = 1; + stream = _loopStream; } + // FIXME: Should this be kMusicSoundType or KPlainSoundType? + g_system->getMixer()->playStream(Audio::Mixer::kMusicSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + setVolume(_lastVolume); + _bPaused = false; - lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING); -#endif - - bIsPlaying = true; -#endif return true; } @@ -1205,177 +580,37 @@ bool FPStream::play() { */ bool FPStream::stop(bool bSync) { -#ifdef REFACTOR_ME - - if (!bSoundSupported) + if (!_bSoundSupported) return true; - if (!bFileLoaded) + if (!_bFileLoaded) return false; - if (!bIsPlaying) + if (!g_system->getMixer()->isSoundHandleActive(_handle)) return false; if (bSync) { -// bSyncExit = true; -// lpDSBuffer->Stop(); -// lpDSBuffer->Play(0, 0, 0); + // The caller intends to call waitForSync. + // FIXME: Why call this in that case?! Looks like old code. Remove that parameter. return true; } else { - /* Close the DirectSound buffer */ - lpDSBuffer->Stop(); - - /* Notify the thread is should stop */ - SetEvent(hThreadEnd); - WaitForSingleObject(hPlayThread, CORO_INFINITE); - - /* Closes the handle used by the stream and free its memory */ - CloseHandle(hPlayThread); - CloseHandle(hThreadEnd); - GlobalFree(lpTempBuffer); - - /* Close and free the CODEC */ - delete _codec; + g_system->getMixer()->stopHandle(_handle); - bIsPlaying = false; - bPaused = false; + _bPaused = false; } -#endif + return true; } void FPStream::waitForSync(FPStream *toplay) { -#ifdef REFACTOR_ME - if (!bSoundSupported) - return; - - if (!bFileLoaded) - return; - - if (!bIsPlaying) - return; - - SyncToPlay = toplay; - bSyncExit = true; - - char buf[1024]; - sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", - this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); - warning(buf); - - WaitForSingleObject(hPlayThread, CORO_INFINITE); - - /* Closes the handle used by the stream and free its memory */ - CloseHandle(hPlayThread); - CloseHandle(hThreadEnd); - GlobalFree(lpTempBuffer); - - /* Close and free the CODEC */ - delete _codec; -#endif - _bIsPlaying = false; -} - -/** - * Thread playing the stream - * - */ - -void FPStream::playThread(CORO_PARAM, const void *param) { - CORO_BEGIN_CONTEXT; - byte *lpLockBuf; - uint32 dwResult; - byte *lpLockBuf2; - uint32 dwResult2; - bool cicla; - uint32 countEnd; - bool bPrecache; - char buf[1024]; - uint32 hList[5]; - CORO_END_CONTEXT(_ctx); - -// FPStream *This = *(FPStream **)param; - - CORO_BEGIN_CODE(_ctx); -#ifdef REFACTOR_ME - // Events that signal when you need to do something - _ctx->hList[0] = This->_hThreadEnd; - _ctx->hList[1] = This->_hHot1; - _ctx->hList[2] = This->_hHot2; - _ctx->hList[3] = This->_hHot3; - _ctx->hList[4] = This->_hPlayThreadPlayFast; - - _ctx->cicla = true; - _ctx->bPrecache = true; - _ctx->countEnd = 0; - while (_ctx->cicla) { - if (This->_codec->endOfStream() && This->_codec->_bLoop == false) { - _ctx->countEnd++; - if (_ctx->countEnd == 3) - break; - } - - // Uncompresses the data being written into the temporary buffer - if (This->_lastVolume == 0) - ZeroMemory(This->_lpTempBuffer, This->_dwBufferSize / 2); - else if (_ctx->bPrecache) - This->_codec->decompress(This->_file.readStream(This->_file.size()), This->_lpTempBuffer, This->_dwBufferSize / 2); - - _ctx->bPrecache = false; - - // Waits for an event. Since they are all in automatic reset, there is no need to reset it after - - uint32 dwBufStatus; - - CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 5, _ctx->hList, false, CORO_INFINITE, &_ctx->dwResult); - - // Check to determine which event has been set - if (CoroScheduler.getEvent(This->_hThreadEnd)->signalled) { - /* Must leave the thread */ - _ctx->cicla = false; - - } else if (CoroScheduler.getEvent(This->_hHot1)->signalled) { - // Must fill the second half of the buffer - This->lpDSBuffer->Lock(This->_dwBufferSize / 2, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, (void **)&_ctx->lpLockBuf2, &_ctx->dwResult2, 0); + // FIXME: The idea here is that you wait for this stream to reach + // a buffer which is a multiple of nBufSize/nSync, and then the + // thread stops it and immediately starts the 'toplay' stream. - copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); - This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, _ctx->lpLockBuf2, 0); - - _ctx->bPrecache = true; - - } else if (CoroScheduler.getEvent(This->_hHot2)->signalled) { - This->lpDSBuffer->Lock(0, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, NULL, NULL, 0); - - copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); - This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, NULL, NULL); - - _ctx->bPrecache = true; - - } else if (CoroScheduler.getEvent(This->_hHot3)->signalled) { - - if (This->_bSyncExit) { - CoroScheduler.setEvent(This->_syncToPlay->_hPlayThreadPlayFast); - - // Transfer immediatly control to the other threads - CORO_SLEEP(1); - - This->_bSyncExit = false; - _ctx->cicla = false; - break; - } - } else if (CoroScheduler.getEvent(This->_hPlayThreadPlayFast)->signalled) { - This->playFast(); - } - } - - // Close the DirectSound buffer - This->lpDSBuffer->Stop(); -#endif - - CORO_END_CODE; + stop(); + toplay->play(); } - /** * Unables or disables stream loop. * @@ -1389,44 +624,25 @@ void FPStream::setLoop(bool loop) { _bLoop = loop; } - /** * Pause sound effect * * @param bPause True enables pause, False disables it */ void FPStream::pause(bool bPause) { - if (_bFileLoaded) { - if (bPause && _bIsPlaying) { -#ifdef REFACTOR_ME - _lpDSBuffer->Stop(); -#endif - _bIsPlaying = false; - _bPaused = true; - } else if (!bPause && _bPaused) { -#ifdef REFACTOR_ME - _dspnHot[0].dwOffset = 32; - _dspnHot[0].hEventNotify = hHot1; - - _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - _dspnHot[1].hEventNotify = hHot2; - - _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - _dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - int a = 1; - } - - lpDSBuffer->Play(0, 0, _bLoop); -#endif - _bIsPlaying = true; - _bPaused = false; - - // Trick to reset the volume after a possible new sound configuration - setVolume(_lastVolume); - } - } + if (!_bFileLoaded) + return; + + if (bPause == _bPaused) + return; + + if (g_system->getMixer()->isSoundHandleActive(_handle)) + g_system->getMixer()->pauseHandle(_handle, bPause); + + _bPaused = bPause; + + // Trick to reset the volume after a possible new sound configuration + setVolume(_lastVolume); } /** @@ -1437,38 +653,33 @@ void FPStream::pause(bool bPause) { */ void FPStream::setVolume(int dwVolume) { -#ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; - lastVolume = dwVolume; + _lastVolume = dwVolume; - if (!GLOBALS.bCfgMusic) dwVolume = 0; + if (!GLOBALS._bCfgMusic) dwVolume = 0; else { - dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; + dwVolume -= (10 - GLOBALS._nCfgMusicVolume) * 2; if (dwVolume < 0) dwVolume = 0; } - if (lpDSBuffer) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); -#endif + if (g_system->getMixer()->isSoundHandleActive(_handle)) + g_system->getMixer()->setChannelVolume(_handle, dwVolume * Audio::Mixer::kMaxChannelVolume / 63); } /** - * Gets the vgolume of the stream + * Gets the volume of the stream * * @param lpdwVolume Variable that will contain the current volume * */ void FPStream::getVolume(int *lpdwVolume) { -#ifdef REFACTOR_ME - if (lpDSBuffer) - lpDSBuffer->GetVolume((uint32 *)lpdwVolume); - *lpdwVolume -= (DSBVOLUME_MIN); - *lpdwVolume *= 64; - *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endif + if (g_system->getMixer()->isSoundHandleActive(_handle)) + *lpdwVolume = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume; + else + *lpdwVolume = 0; } } // End of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 38ce6de2a7..585247db83 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -265,23 +265,11 @@ public: class FPStream { private: - // HWND hwnd; - // LPDIRECTSOUND lpDS; - // LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer - // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer - - byte *_lpTempBuffer; // Temporary buffer use for decompression - uint32 _dwBufferSize; // Buffer size (bytes) uint32 _dwSize; // Stream size (bytes) uint32 _dwCodec; // CODEC used - uint32 _hThreadEnd; // Event used to close thread Common::File _file; // File handle used for the stream - uint32 _hPlayThread; // Handle of the Play thread - uint32 _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify - uint32 _hPlayThreadPlayFast; - uint32 _hPlayThreadPlayNormal; bool _bSoundSupported; // True if the sound is active bool _bFileLoaded; // True if the file is open @@ -291,21 +279,10 @@ private: bool _bPaused; int _lastVolume; FPStream *_syncToPlay; - CODEC *_codec; - - // DSBPOSITIONNOTIFY dspnHot[3]; - - bool createBuffer(int nBufSize); -public: - bool _bIsPlaying; // True if the stream is playing - -private: - /** - * Thread playing the stream - * - */ - static void playThread(CORO_PARAM, const void *param); + Audio::AudioStream *_loopStream; + Audio::RewindableAudioStream *_rewindableStream; + Audio::SoundHandle _handle; public: @@ -368,7 +345,6 @@ public: bool play(); void playFast(); - void prefetch(); /** * Closes the stream. @@ -408,7 +384,7 @@ public: void setVolume(int dwVolume); /** - * Gets the vgolume of the stream + * Gets the volume of the stream * * @param lpdwVolume Variable that will contain the current volume * diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 8ae95af862..475683d0f4 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -268,7 +268,7 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { } streams[GLOBALS._nextChannel]->setLoop(GLOBALS._nextLoop); - streams[GLOBALS._nextChannel]->prefetch(); + //streams[GLOBALS._nextChannel]->prefetch(); streams[GLOBALS._curChannel]->stop(true); streams[GLOBALS._curChannel]->waitForSync(streams[GLOBALS._nextChannel]); -- cgit v1.2.3 From 2d1d6630d6caff8fa47559e91c8a9a667dfa2df4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Jun 2012 22:17:41 +0200 Subject: TONY: Remove useless CODEC class definition --- engines/tony/sound.h | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 585247db83..ca71652f20 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -49,7 +49,6 @@ enum SoundCodecs { FPCODEC_ADPCM }; - //**************************************************************************** //* class FPSound //* ------------- @@ -245,24 +244,6 @@ public: bool endOfBuffer() const; }; -/** - * Codec base class - */ -class CODEC { -protected: - bool _bEndReached; - -public: - bool _bLoop; - - CODEC(bool _bLoop = true); - virtual ~CODEC(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; - virtual void loopReset() = 0; - bool endOfStream(); -}; - - class FPStream { private: uint32 _dwBufferSize; // Buffer size (bytes) -- cgit v1.2.3 From 85150232f036d1dead6a0807bac7b10c5ba923e1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Jun 2012 00:20:16 +0200 Subject: TONY: Some more renaming (thanks Hkz) --- engines/tony/custom.cpp | 119 ++++++++++++++++++++++------------------------ engines/tony/game.h | 10 ++-- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 16 +++---- engines/tony/tonychar.cpp | 78 +++++++++++++++--------------- engines/tony/tonychar.h | 62 ++++++++++++------------ 6 files changed, 142 insertions(+), 145 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index ce1c2860f8..78b8f4e798 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -42,7 +42,7 @@ namespace Tony { -const char *tappetiFile[] = { +const char *ambianceFile[] = { "None", "1.ADP", // Grilli.WAV "2.ADP", // Grilli-Ovattati.WAV @@ -50,7 +50,7 @@ const char *tappetiFile[] = { "3.ADP", // Grilli-Vento1.WAV "5.ADP", // Vento1.WAV "4.ADP", // Mare1.WAV - "6.ADP" // Mare1.WAV met volume + "6.ADP" // Mare1.WAV half volume }; struct MusicFileEntry { @@ -210,19 +210,19 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWUP); break; case 2: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAGIU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWDOWN); break; case 3: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASINISTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWLEFT); break; case 4: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIADESTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWRIGHT); break; case 5: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAMAPPA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWMAP); break; default: @@ -232,15 +232,12 @@ DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32 } VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { - uint i; - int code; - - code = (codehi << 16) | codelo; + int code = (codehi << 16) | codelo; if (_vm->_voices.size() == 0) return NULL; - for (i = 0; i < _vm->_voices.size(); i++) + for (uint i = 0; i < _vm->_voices.size(); i++) if (_vm->_voices[i]._code == code) return &_vm->_voices[i]; @@ -292,7 +289,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } else { if (_ctx->msg.numPeriods() > 1) - CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_FIANCHI); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_HIPS); else CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_NORMAL); } @@ -537,7 +534,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { + if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { _vm->stopMusic(4); } @@ -550,10 +547,10 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { - GLOBALS._lastTappeto = GLOBALS._tappeti[nLoc]; + if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { + GLOBALS._lastTappeto = GLOBALS._ambiance[nLoc]; if (GLOBALS._lastTappeto != 0) - _vm->playMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true, 2000); + _vm->playMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true, 2000); } if (!GLOBALS._bNoBullsEye) { @@ -802,19 +799,19 @@ void TonySetNumTexts(uint32 dwText) { GLOBALS._bTonyInTexts = false; } -DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyLaugh)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_LAUGH; } DECLARE_CUSTOM_FUNCTION(TonyGiggle)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_LAUGH2; } -DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyHips)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_FIANCHI; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_HIPS; } DECLARE_CUSTOM_FUNCTION(TonySing)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -1127,9 +1124,9 @@ DECLARE_CUSTOM_FUNCTION(TonySniffRight)(CORO_PARAM, uint32, uint32, uint32, uint CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySarcastic)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NAAH; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SARCASTIC; } DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { @@ -2237,7 +2234,7 @@ void RestoreMusic(CORO_PARAM) { CORO_INVOKE_4(PlaySoundEffect, GLOBALS._lastMusic, 0, 0, 0); if (GLOBALS._lastTappeto != 0) - CustPlayMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true); + CustPlayMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true); CORO_END_CODE; } @@ -2447,8 +2444,8 @@ ASSIGN(37, TonyGetUp) ASSIGN(38, TonyShepherdess) ASSIGN(39, TonyWhistle) -ASSIGN(40, TonyRide) -ASSIGN(41, TonyFianchi) +ASSIGN(40, TonyLaugh) +ASSIGN(41, TonyHips) ASSIGN(42, TonySing) ASSIGN(43, TonyIndicate) ASSIGN(44, TonyScaredWithHands) @@ -2477,7 +2474,7 @@ ASSIGN(106, TonyWithBeardStart) ASSIGN(107, TonyWithBeardEnd) ASSIGN(108, TonyGiggle) ASSIGN(109, TonyDisgusted) -ASSIGN(110, TonyNaah) +ASSIGN(110, TonySarcastic) ASSIGN(111, TonyMacbeth) ASSIGN(112, TonySniffLeft) ASSIGN(113, TonySniffRight) @@ -2575,39 +2572,39 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS._mut[i] = CoroScheduler.createEvent(false, false); for (i = 0; i < 200; i++) - GLOBALS._tappeti[i] = 0; - - GLOBALS._tappeti[6] = TAPPETI_GRILLI; - GLOBALS._tappeti[7] = TAPPETI_GRILLI; - GLOBALS._tappeti[8] = TAPPETI_GRILLIOV; - GLOBALS._tappeti[10] = TAPPETI_GRILLI; - GLOBALS._tappeti[12] = TAPPETI_GRILLI; - GLOBALS._tappeti[13] = TAPPETI_GRILLIOV; - GLOBALS._tappeti[15] = TAPPETI_GRILLI; - GLOBALS._tappeti[16] = TAPPETI_GRILLIVENTO; - GLOBALS._tappeti[18] = TAPPETI_GRILLI; - GLOBALS._tappeti[19] = TAPPETI_GRILLIVENTO; - GLOBALS._tappeti[20] = TAPPETI_GRILLI; - GLOBALS._tappeti[23] = TAPPETI_GRILLI; - GLOBALS._tappeti[26] = TAPPETI_MAREMETA; - GLOBALS._tappeti[27] = TAPPETI_GRILLI; - GLOBALS._tappeti[28] = TAPPETI_GRILLIVENTO; - GLOBALS._tappeti[31] = TAPPETI_GRILLI; - GLOBALS._tappeti[33] = TAPPETI_MARE; - GLOBALS._tappeti[35] = TAPPETI_MARE; - GLOBALS._tappeti[36] = TAPPETI_GRILLI; - GLOBALS._tappeti[37] = TAPPETI_GRILLI; - GLOBALS._tappeti[40] = TAPPETI_GRILLI; - GLOBALS._tappeti[41] = TAPPETI_GRILLI; - GLOBALS._tappeti[42] = TAPPETI_GRILLI; - GLOBALS._tappeti[45] = TAPPETI_GRILLI; - GLOBALS._tappeti[51] = TAPPETI_GRILLI; - GLOBALS._tappeti[52] = TAPPETI_GRILLIVENTO1; - GLOBALS._tappeti[53] = TAPPETI_GRILLI; - GLOBALS._tappeti[54] = TAPPETI_GRILLI; - GLOBALS._tappeti[57] = TAPPETI_VENTO; - GLOBALS._tappeti[58] = TAPPETI_VENTO; - GLOBALS._tappeti[60] = TAPPETI_VENTO; + GLOBALS._ambiance[i] = 0; + + GLOBALS._ambiance[6] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[7] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[8] = AMBIANCE_CRICKETSMUFFLED; + GLOBALS._ambiance[10] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[12] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[13] = AMBIANCE_CRICKETSMUFFLED; + GLOBALS._ambiance[15] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[16] = AMBIANCE_CRICKETSWIND; + GLOBALS._ambiance[18] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[19] = AMBIANCE_CRICKETSWIND; + GLOBALS._ambiance[20] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[23] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[26] = AMBIANCE_SEAHALFVOLUME; + GLOBALS._ambiance[27] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[28] = AMBIANCE_CRICKETSWIND; + GLOBALS._ambiance[31] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[33] = AMBIANCE_SEA; + GLOBALS._ambiance[35] = AMBIANCE_SEA; + GLOBALS._ambiance[36] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[37] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[40] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[41] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[42] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[45] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[51] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[52] = AMBIANCE_CRICKETSWIND1; + GLOBALS._ambiance[53] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[54] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[57] = AMBIANCE_WIND; + GLOBALS._ambiance[58] = AMBIANCE_WIND; + GLOBALS._ambiance[60] = AMBIANCE_WIND; diff --git a/engines/tony/game.h b/engines/tony/game.h index e231287c0f..d8aceefc12 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -72,11 +72,11 @@ private: public: enum PointerType { PTR_NONE = 0, - PTR_FRECCIASU, - PTR_FRECCIAGIU, - PTR_FRECCIASINISTRA, - PTR_FRECCIADESTRA, - PTR_FRECCIAMAPPA, + PTR_ARROWUP, + PTR_ARROWDOWN, + PTR_ARROWLEFT, + PTR_ARROWRIGHT, + PTR_ARROWMAP, PTR_CUSTOM }; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index f28a22e4a5..ba2698a50b 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -72,7 +72,7 @@ Globals::Globals() { _hSkipIdle = 0; _lastMusic = 0; _lastTappeto = 0; - Common::fill(&_tappeti[0], &_tappeti[200], 0); + Common::fill(&_ambiance[0], &_ambiance[200], 0); _fullScreenMessageLoc = 0; // MPAL global variables diff --git a/engines/tony/globals.h b/engines/tony/globals.h index b63dce7c45..02bd79eee7 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -35,13 +35,13 @@ namespace Tony { -#define TAPPETI_GRILLI 1 -#define TAPPETI_GRILLIOV 2 -#define TAPPETI_GRILLIVENTO 3 -#define TAPPETI_GRILLIVENTO1 4 -#define TAPPETI_VENTO 5 -#define TAPPETI_MARE 6 -#define TAPPETI_MAREMETA 7 +#define AMBIANCE_CRICKETS 1 +#define AMBIANCE_CRICKETSMUFFLED 2 +#define AMBIANCE_CRICKETSWIND 3 +#define AMBIANCE_CRICKETSWIND1 4 +#define AMBIANCE_WIND 5 +#define AMBIANCE_SEA 6 +#define AMBIANCE_SEAHALFVOLUME 7 struct CharacterStruct { uint32 _code; @@ -243,7 +243,7 @@ public: int _lastMusic, _lastTappeto; - int _tappeti[200]; + int _ambiance[200]; RMPoint _fullScreenMessagePt; int _fullScreenMessageLoc; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index cd5bbdad8b..74d9f20181 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -648,39 +648,39 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_FIANCHI: + case TALK_HIPS: _bBodyFront = false; switch (_talkDirection) { case UP: _nBodyOffset.set(2, 42); headStartPat = PAT_HEAD_UP; - bodyStartPat = BPAT_FIANCHIUP_START; + bodyStartPat = BPAT_HIPSUP_START; headLoopPat = PAT_TALK_UP; - bodyLoopPat = BPAT_FIANCHIUP_LOOP; + bodyLoopPat = BPAT_HIPSUP_LOOP; break; case DOWN: _nBodyOffset.set(2, 48); headStartPat = PAT_HEAD_DOWN; - bodyStartPat = BPAT_FIANCHIDOWN_START; + bodyStartPat = BPAT_HIPSDOWN_START; headLoopPat = PAT_TALK_DOWN; - bodyLoopPat = BPAT_FIANCHIDOWN_LOOP; + bodyLoopPat = BPAT_HIPSDOWN_LOOP; break; case LEFT: _nBodyOffset.set(-3, 53); headStartPat = PAT_HEAD_LEFT; - bodyStartPat = BPAT_FIANCHILEFT_START; + bodyStartPat = BPAT_HIPSLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_FIANCHILEFT_LOOP; + bodyLoopPat = BPAT_HIPSLEFT_LOOP; break; case RIGHT: _nBodyOffset.set(2, 53); headStartPat = PAT_HEAD_RIGHT; - bodyStartPat = BPAT_FIANCHIRIGHT_START; + bodyStartPat = BPAT_HIPSRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_FIANCHIRIGHT_LOOP; + bodyLoopPat = BPAT_HIPSRIGHT_LOOP; break; } break; @@ -693,47 +693,47 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, bodyLoopPat = BPAT_SINGLEFT_LOOP; break; - case TALK_RIDE: + case TALK_LAUGH: _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: case LEFT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDELEFT_START; + headStartPat = PAT_LAUGHLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_RIDELEFT_LOOP; - bodyLoopPat = BPAT_RIDELEFT; + headLoopPat = PAT_LAUGHLEFT_LOOP; + bodyLoopPat = BPAT_LAUGHLEFT; break; case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDERIGHT_START; + headStartPat = PAT_LAUGHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_RIDERIGHT_LOOP; - bodyLoopPat = BPAT_RIDERIGHT; + headLoopPat = PAT_LAUGHRIGHT_LOOP; + bodyLoopPat = BPAT_LAUGHRIGHT; break; } break; - case TALK_RIDE2: + case TALK_LAUGH2: _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: case LEFT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDELEFT_START; + headStartPat = PAT_LAUGHLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_RIDELEFT_LOOP; + headLoopPat = PAT_LAUGHLEFT_LOOP; break; case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDERIGHT_START; + headStartPat = PAT_LAUGHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_RIDERIGHT_LOOP; - bodyLoopPat = BPAT_RIDERIGHT; + headLoopPat = PAT_LAUGHRIGHT_LOOP; + bodyLoopPat = BPAT_LAUGHRIGHT; break; } break; @@ -997,22 +997,22 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_NAAH: + case TALK_SARCASTIC: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); - headStartPat = PAT_NAAHLEFT_START; + headStartPat = PAT_SARCASTICLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_NAAHLEFT_LOOP; + headLoopPat = PAT_SARCASTICLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_NAAHRIGHT_START; + headStartPat = PAT_SARCASTICRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_NAAHRIGHT_LOOP; + headLoopPat = PAT_SARCASTICRIGHT_LOOP; break; } break; @@ -1180,22 +1180,22 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_FIANCHI: + case TALK_HIPS: switch (_talkDirection) { case UP: - bodyEndPat = BPAT_FIANCHIUP_END; + bodyEndPat = BPAT_HIPSUP_END; break; case DOWN: - bodyEndPat = BPAT_FIANCHIDOWN_END; + bodyEndPat = BPAT_HIPSDOWN_END; break; case LEFT: - bodyEndPat = BPAT_FIANCHILEFT_END; + bodyEndPat = BPAT_HIPSLEFT_END; break; case RIGHT: - bodyEndPat = BPAT_FIANCHIRIGHT_END; + bodyEndPat = BPAT_HIPSRIGHT_END; break; } break; @@ -1204,12 +1204,12 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = BPAT_SINGLEFT_END; break; - case TALK_RIDE: - case TALK_RIDE2: + case TALK_LAUGH: + case TALK_LAUGH2: if (_talkDirection == LEFT) - headEndPat = PAT_RIDELEFT_END; + headEndPat = PAT_LAUGHLEFT_END; else if (_talkDirection == RIGHT) - headEndPat = PAT_RIDERIGHT_END; + headEndPat = PAT_LAUGHRIGHT_END; bodyEndPat = 0; break; @@ -1230,16 +1230,16 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_NAAH: + case TALK_SARCASTIC: switch (_talkDirection) { case UP: case LEFT: - headEndPat = PAT_NAAHLEFT_END; + headEndPat = PAT_SARCASTICLEFT_END; break; case DOWN: case RIGHT: - headEndPat = PAT_NAAHRIGHT_END; + headEndPat = PAT_SARCASTICRIGHT_END; break; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a50641bf25..775c27a4e0 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -43,9 +43,9 @@ private: public: enum CharacterTalkType { TALK_NORMAL, - TALK_FIANCHI, + TALK_HIPS, TALK_SING, - TALK_RIDE, + TALK_LAUGH, TALK_INDICATE, TALK_SCARED, TALK_SCARED2, @@ -64,9 +64,9 @@ public: TALK_WITH_NOTEBOOK, TALK_WITHMEGAPHONESTATIC, TALK_WITHBEARDSTATIC, - TALK_RIDE2, + TALK_LAUGH2, TALK_DISGUSTED, - TALK_NAAH, + TALK_SARCASTIC, TALK_MACBETH1, TALK_MACBETH2, TALK_MACBETH3, @@ -169,12 +169,12 @@ public: PAT_HEAD_RIGHT, // Laugh - PAT_RIDELEFT_START, - PAT_RIDELEFT_LOOP, - PAT_RIDELEFT_END, - PAT_RIDERIGHT_START, - PAT_RIDERIGHT_LOOP, - PAT_RIDERIGHT_END, + PAT_LAUGHLEFT_START, + PAT_LAUGHLEFT_LOOP, + PAT_LAUGHLEFT_END, + PAT_LAUGHRIGHT_START, + PAT_LAUGHRIGHT_LOOP, + PAT_LAUGHRIGHT_END, // Speaking as a shepherdess PAT_PAST_TALKUP, @@ -217,12 +217,12 @@ public: PAT_DISGUSTEDRIGHT_START, PAT_DISGUSTEDRIGHT_LOOP, PAT_DISGUSTEDRIGHT_END, - PAT_NAAHLEFT_START, - PAT_NAAHLEFT_LOOP, - PAT_NAAHLEFT_END, - PAT_NAAHRIGHT_START, - PAT_NAAHRIGHT_LOOP, - PAT_NAAHRIGHT_END, + PAT_SARCASTICLEFT_START, + PAT_SARCASTICLEFT_LOOP, + PAT_SARCASTICLEFT_END, + PAT_SARCASTICRIGHT_START, + PAT_SARCASTICRIGHT_LOOP, + PAT_SARCASTICRIGHT_END, // Stand scared PAT_SCAREDLEFT_STAND, @@ -266,21 +266,21 @@ public: BPAT_SINGLEFT_LOOP, BPAT_SINGLEFT_END, - BPAT_FIANCHILEFT_START, - BPAT_FIANCHILEFT_LOOP, - BPAT_FIANCHILEFT_END, - BPAT_FIANCHIRIGHT_START, - BPAT_FIANCHIRIGHT_LOOP, - BPAT_FIANCHIRIGHT_END, - BPAT_FIANCHIUP_START, - BPAT_FIANCHIUP_LOOP, - BPAT_FIANCHIUP_END, - BPAT_FIANCHIDOWN_START, - BPAT_FIANCHIDOWN_LOOP, - BPAT_FIANCHIDOWN_END, - - BPAT_RIDELEFT, - BPAT_RIDERIGHT, + BPAT_HIPSLEFT_START, + BPAT_HIPSLEFT_LOOP, + BPAT_HIPSLEFT_END, + BPAT_HIPSRIGHT_START, + BPAT_HIPSRIGHT_LOOP, + BPAT_HIPSRIGHT_END, + BPAT_HIPSUP_START, + BPAT_HIPSUP_LOOP, + BPAT_HIPSUP_END, + BPAT_HIPSDOWN_START, + BPAT_HIPSDOWN_LOOP, + BPAT_HIPSDOWN_END, + + BPAT_LAUGHLEFT, + BPAT_LAUGHRIGHT, BPAT_INDICATELEFT, BPAT_INDICATERIGHT, -- cgit v1.2.3 From fdc619191b4778608263e57a815bd99b3823c11d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Jun 2012 07:31:38 +0200 Subject: TONY: Translate two comments --- engines/tony/custom.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 78b8f4e798..3a0792252b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1413,10 +1413,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, CORO_END_CODE; } - - /* - * Personaggi + * Characters */ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { @@ -1778,7 +1776,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } /* - * Dialoghi + * Dialogs */ int curDialog; -- cgit v1.2.3 From 17289089e6232d464d9eef15f510d66542fbbec5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Jun 2012 22:58:58 +1000 Subject: TONY: Fix for adding dirty rects for 8-bit RLE images --- engines/tony/gfxcore.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index d34923e455..751802bb29 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -900,6 +900,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri u = _dimx - (width + u); x1 = (prim->getDst()._x1 + _dimx - 1) - u; + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + for (y = 0; y < height; y++) { // Decompression RLEDecompressLineFlipped(buf + x1, src + 2, u, width); @@ -911,6 +914,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri buf += bigBuf.getDimx(); } } else { + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); + for (y = 0; y < height; y++) { // Decompression RLEDecompressLine(buf + x1, src + 2, u, width); @@ -922,9 +928,6 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri buf += bigBuf.getDimx(); } } - - // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } -- cgit v1.2.3 From 8c463aa58c6b61c4336a0ff45a02578fad804c05 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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 2990482406710c77280c67f3b7672a569b9d5a92 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Thu, 21 Jun 2012 21:30:09 +0200 Subject: TONY: Fix Valgrind warning The loop uses _ctx->msg, so don't delete it until the loop is done. --- engines/tony/custom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3a0792252b..35ae8849f1 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1761,9 +1761,9 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS._curBackText = NULL; delete _ctx->text; - delete _ctx->msg; } + delete _ctx->msg; // Try to run the custom function to close the speech if (GLOBALS._mCharacter[nChar]._item) { -- cgit v1.2.3 From 93f7bcdf287765107a6d4f5d57fc79ca0c3b8cbb Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 eef6b444df766b90d1323941c7ff9bd8355c111b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Jun 2012 23:47:39 +1000 Subject: TONY: Created a debugger command 'dirty_rects' to show dirty rect areas on-screen --- engines/tony/debugger.cpp | 14 ++++++++++++++ engines/tony/debugger.h | 1 + engines/tony/window.cpp | 16 ++++++++++++++++ engines/tony/window.h | 5 ++--- 4 files changed, 33 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 8beb7285a4..75e58d68d4 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -30,6 +30,7 @@ namespace Tony { Debugger::Debugger() : GUI::Debugger() { DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); + DCmd_Register("dirty_rects", WRAP_METHOD(Debugger, Cmd_DirtyRects)); } static int strToInt(const char *s) { @@ -113,4 +114,17 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { return false; } +/** + * Turns showing dirty rects on or off + */ +bool Debugger::Cmd_DirtyRects(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage; %s [on | off]\n", argv[0]); + return true; + } else { + _vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); + return false; + } +} + } // End of namespace Tony diff --git a/engines/tony/debugger.h b/engines/tony/debugger.h index c5ed5e417e..85ba9d75b6 100644 --- a/engines/tony/debugger.h +++ b/engines/tony/debugger.h @@ -35,6 +35,7 @@ public: protected: bool Cmd_Scene(int argc, const char **argv); + bool Cmd_DirtyRects(int argc, const char **argv); }; } // End of namespace Tony diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index bf0094ff2a..a35e765b6c 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -27,6 +27,7 @@ */ #include "common/scummsys.h" +#include "graphics/surface.h" #include "util.h" #include "tony/window.h" #include "tony/game.h" @@ -40,6 +41,7 @@ namespace Tony { \****************************************************************************/ RMWindow::RMWindow() { + _showDirtyRects = false; } RMWindow::~RMWindow() { @@ -126,11 +128,25 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip Common::List dirtyRects = bigBuf.getDirtyRects(); Common::List::iterator i; + // If showing dirty rects, copy the entire screen background and set up a surface pointer + Graphics::Surface *s = NULL; + if (_showDirtyRects) { + g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + s = g_system->lockScreen(); + } + for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { Common::Rect &r = *i; const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + + if (_showDirtyRects) + // Frame the copied area with a rectangle + s->frameRect(r, 0xffffff); } + + if (_showDirtyRects) + g_system->unlockScreen(); } if (_bGrabThumbnail) { diff --git a/engines/tony/window.h b/engines/tony/window.h index 6189dd391f..562e5fe062 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -57,14 +57,12 @@ private: void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: -// void * /*LPDIRECTDRAWCLIPPER*/ _MainClipper; -// void * /*LPDIRECTDRAWCLIPPER*/ _BackClipper; - int fps, fcount; int lastsecond, lastfcount; int mskRed, mskGreen, mskBlue; bool _wiping; + bool _showDirtyRects; bool _bGrabScreenshot; bool _bGrabThumbnail; @@ -99,6 +97,7 @@ public: int getFps() const { return fps; } + void showDirtyRects(bool v) { _showDirtyRects = v; } }; } // End of namespace Tony -- cgit v1.2.3 From 2e34a25040c4f95e62ce899be5521d7e5e76d095 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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 46d87ef76a7e2b7b8c53c4dee2d043192accf159 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Jun 2012 15:25:03 +1000 Subject: TONY: Bugfix for loading ambient music when restoring a savegame --- engines/tony/sound.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index b0a2c69fd6..31e008eb62 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -486,8 +486,11 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB _dwCodec = dwCodType; // Open the file stream for reading - if (!_file.open(fileName)) - return false; + if (!_file.open(fileName)) { + // Fallback: try with an extra '0' prefix + if (!_file.open("0" + fileName)) + return false; + } // Save the size of the stream _dwSize = _file.size(); -- cgit v1.2.3 From 69ce6e35f48491a87886751e9d8cc2d004cf8f7a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Jun 2012 16:28:03 +1000 Subject: TONY: Bugfix for crash when changing scene whilst music is playing --- engines/tony/sound.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 31e008eb62..7380b3a93a 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -536,6 +536,8 @@ bool FPStream::unloadFile() { /* Closes the file handle stream */ delete _loopStream; delete _rewindableStream; + _loopStream = NULL; + _rewindableStream = NULL; _file.close(); // Flag that the file is no longer in memory -- cgit v1.2.3 From 65a8799f9653956cfced0b77e8c638be7c805824 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sun, 24 Jun 2012 11:09:08 +0200 Subject: TONY: Added "sepia mode". This works by adding a wrapper function for copyRectToScreen(). As far as the engine is concerned, it still draws everything in color. The mouse cursors are still in color, but that can be fixed later. --- engines/tony/window.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++----- engines/tony/window.h | 2 ++ 2 files changed, 57 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index b8cd34d049..5c08ab1eec 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -63,12 +63,61 @@ void RMWindow::init() { _bGrabThumbnail = false; _bGrabMovie = false; _wiping = false; + + _precalcTable = 0; +} + +void RMWindow::createBWPrecalcTable() { + _precalcTable = new uint16[0x8000]; + + for (int i = 0; i < 0x8000; i++) { + int r = (i >> 10) & 0x1F; + int g = (i >> 5) & 0x1F; + int b = i & 0x1F; + + int min = MIN(r, MIN(g, b)); + int max = MAX(r, MAX(g, b)); + + min = (min + max) / 2; + + r = CLIP(min + 8 - 8, 0, 31); + g = CLIP(min + 5 - 8, 0, 31); + b = CLIP(min + 0 - 8, 0, 31); + + _precalcTable[i] = (r << 10) | (g << 5) | b; + } } +void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { + if (GLOBALS._bCfgAnni30) { + if (!_precalcTable) { + createBWPrecalcTable(); + } + Graphics::Surface *screen = g_system->lockScreen(); + const uint16 *src = (const uint16 *)buf; + for (int i = 0; i < h; i++) { + uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i); + for (int j = 0; j < w; j++) { + dst[j] = _precalcTable[src[j] & 0x7FFF]; + } + src += (pitch / 2); + } + g_system->unlockScreen(); + } else { + if (_precalcTable) { + delete[] _precalcTable; + _precalcTable = 0; + } + g_system->copyRectToScreen(buf, pitch, x, y, w, h); + } + } + /** * Close the window */ void RMWindow::close() { + delete[] _precalcTable; + _precalcTable = 0; } void RMWindow::grabThumbnail(uint16 *thumbmem) { @@ -105,7 +154,7 @@ void RMWindow::wipeEffect(Common::Rect &rcBoundEllipse) { // Loop through each line for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { - g_system->copyRectToScreen((const byte *)&line[0], RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + copyRectToScreen((const byte *)&line[0], RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } } @@ -120,7 +169,7 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip _wiping = true; } else if (_wiping) { // Just finished a wiping effect, so copy the full screen - g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); _wiping = false; } else { @@ -131,14 +180,14 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // If showing dirty rects, copy the entire screen background and set up a surface pointer Graphics::Surface *s = NULL; if (_showDirtyRects) { - g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); s = g_system->lockScreen(); } for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { Common::Rect &r = *i; const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); - g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); if (_showDirtyRects) // Frame the copied area with a rectangle @@ -227,13 +276,13 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, if ((center.y - y) >= 0) { // Draw line in top half of circle pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + xs * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y - y, width, 1); + copyRectToScreen(pSrc, RM_SX * 2, xs, center.y - y, width, 1); } if ((center.y + y) < RM_SY) { // Draw line in bottom half of circle pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + xs * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y + y, width, 1); + copyRectToScreen(pSrc, RM_SX * 2, xs, center.y + y, width, 1); } } diff --git a/engines/tony/window.h b/engines/tony/window.h index 571a02829a..c72a3afd8e 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -70,8 +70,10 @@ protected: bool _bGrabThumbnail; bool _bGrabMovie; uint16 *_wThumbBuf; + uint16 *_precalcTable; void createBWPrecalcTable(); + void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); void wipeEffect(Common::Rect &rcBoundEllipse); void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); -- cgit v1.2.3 From e68ab9b5721caaafd99d9936dd372fa266069957 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 58b03ec446737164782867aedc324cce3b491218 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 2 Jul 2012 20:53:31 +1000 Subject: TONY: Refactored the Sepia (B & W) mode so the cursor is converted as well --- engines/tony/game.cpp | 16 +++++++++++++++- engines/tony/game.h | 7 +++++-- engines/tony/gfxcore.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/tony/gfxcore.h | 5 +++++ engines/tony/gfxengine.h | 3 +++ engines/tony/window.cpp | 39 ++++++++------------------------------- engines/tony/window.h | 2 -- 7 files changed, 71 insertions(+), 36 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4e9e2abc38..abc7f1a2e0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1596,8 +1596,22 @@ void RMPointer::updateCursor() { draw(Common::nullContext, buf, &prim); + // Get a pointer to the cursor data + byte *cursorData = buf; + + // If in black & white mode, convert the cursor + if (GLOBALS._bCfgAnni30) { + uint16 *src = (uint16 *)cursorData; + for (int i = 0; i < 64; i++) { + uint16 *lineP = src; + for (int j = 0; j < 64; j++, lineP) { + lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF]; + } + src += 64; + } + } + // Get the raw pixel data and set the cursor to it - const byte *cursorData = buf; Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } diff --git a/engines/tony/game.h b/engines/tony/game.h index d8aceefc12..9804ac87fe 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -67,8 +67,6 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; - void updateCursor(); - public: enum PointerType { PTR_NONE = 0, @@ -147,6 +145,11 @@ public: */ int curAction(); + /** + * Update the cursor + */ + void updateCursor(); + /** * Show the cursor */ diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index d91f5bab4e..119b730303 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -433,6 +433,41 @@ void RMGfxTargetBuffer::mergeDirtyRects() { } } +uint16 *RMGfxTargetBuffer::_precalcTable = NULL; + +/** + * Set up the black & white precalculated mapping table. This is only + * called if the user selects the black & white option. + */ +void RMGfxTargetBuffer::createBWPrecalcTable() { + _precalcTable = new uint16[0x8000]; + + for (int i = 0; i < 0x8000; i++) { + int r = (i >> 10) & 0x1F; + int g = (i >> 5) & 0x1F; + int b = i & 0x1F; + + int min = MIN(r, MIN(g, b)); + int max = MAX(r, MAX(g, b)); + + min = (min + max) / 2; + + r = CLIP(min + 8 - 8, 0, 31); + g = CLIP(min + 5 - 8, 0, 31); + b = CLIP(min + 0 - 8, 0, 31); + + _precalcTable[i] = (r << 10) | (g << 5) | b; + } +} + +/** + * Frees the black & white precalculated mapping table. + */ +void RMGfxTargetBuffer::freeBWPrecalcTable() { + delete[] _precalcTable; + _precalcTable = NULL; +} + /****************************************************************************\ * RMGfxSourceBufferPal Methods \****************************************************************************/ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 32e3c96881..78c4c9bc70 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -562,6 +562,7 @@ private: Common::List _currentDirtyRects, _previousDirtyRects, _dirtyRects; void mergeDirtyRects(); + private: // OSystem::MutexRef csModifyingOT; @@ -573,6 +574,10 @@ public: RMGfxTargetBuffer(); virtual ~RMGfxTargetBuffer(); + static uint16 *_precalcTable; + static void createBWPrecalcTable(); + static void freeBWPrecalcTable(); + // management of the OT list void clearOT(); void drawOT(CORO_PARAM); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2c48612c4d..a69182d032 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -115,6 +115,9 @@ public: RMInput &getInput() { return _input; } + RMPointer &getPointer() { + return _point; + } // Link to the custom function list void initCustomDll(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 5c08ab1eec..c509a12f9e 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -47,6 +47,7 @@ RMWindow::RMWindow() { RMWindow::~RMWindow() { close(); RMText::unload(); + RMGfxTargetBuffer::freeBWPrecalcTable(); } /** @@ -63,50 +64,28 @@ void RMWindow::init() { _bGrabThumbnail = false; _bGrabMovie = false; _wiping = false; - - _precalcTable = 0; -} - -void RMWindow::createBWPrecalcTable() { - _precalcTable = new uint16[0x8000]; - - for (int i = 0; i < 0x8000; i++) { - int r = (i >> 10) & 0x1F; - int g = (i >> 5) & 0x1F; - int b = i & 0x1F; - - int min = MIN(r, MIN(g, b)); - int max = MAX(r, MAX(g, b)); - - min = (min + max) / 2; - - r = CLIP(min + 8 - 8, 0, 31); - g = CLIP(min + 5 - 8, 0, 31); - b = CLIP(min + 0 - 8, 0, 31); - - _precalcTable[i] = (r << 10) | (g << 5) | b; - } } void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { if (GLOBALS._bCfgAnni30) { - if (!_precalcTable) { - createBWPrecalcTable(); + if (!RMGfxTargetBuffer::_precalcTable) { + RMGfxTargetBuffer::createBWPrecalcTable(); + _vm->getEngine()->getPointer().updateCursor(); } Graphics::Surface *screen = g_system->lockScreen(); const uint16 *src = (const uint16 *)buf; for (int i = 0; i < h; i++) { uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i); for (int j = 0; j < w; j++) { - dst[j] = _precalcTable[src[j] & 0x7FFF]; + dst[j] = RMGfxTargetBuffer::_precalcTable[src[j] & 0x7FFF]; } src += (pitch / 2); } g_system->unlockScreen(); } else { - if (_precalcTable) { - delete[] _precalcTable; - _precalcTable = 0; + if (RMGfxTargetBuffer::_precalcTable) { + RMGfxTargetBuffer::freeBWPrecalcTable(); + _vm->getEngine()->getPointer().updateCursor(); } g_system->copyRectToScreen(buf, pitch, x, y, w, h); } @@ -116,8 +95,6 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, * Close the window */ void RMWindow::close() { - delete[] _precalcTable; - _precalcTable = 0; } void RMWindow::grabThumbnail(uint16 *thumbmem) { diff --git a/engines/tony/window.h b/engines/tony/window.h index c72a3afd8e..6528060f17 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -70,9 +70,7 @@ protected: bool _bGrabThumbnail; bool _bGrabMovie; uint16 *_wThumbBuf; - uint16 *_precalcTable; - void createBWPrecalcTable(); void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); void wipeEffect(Common::Rect &rcBoundEllipse); void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); -- cgit v1.2.3 From 924aac4389abaf7bd3ce266fbd53c0bcdf474ba9 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Mon, 2 Jul 2012 20:48:57 +0200 Subject: TONY: Fix warning about statement without effect. --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index abc7f1a2e0..5b9502468a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1604,7 +1604,7 @@ void RMPointer::updateCursor() { uint16 *src = (uint16 *)cursorData; for (int i = 0; i < 64; i++) { uint16 *lineP = src; - for (int j = 0; j < 64; j++, lineP) { + for (int j = 0; j < 64; j++) { lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF]; } src += 64; -- cgit v1.2.3 From 9cc7d6c6c5fc260fd88135db3d14fa61841370eb Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Mon, 2 Jul 2012 20:51:14 +0200 Subject: TONY: Fix crash when entering "sepia" mode by loading a savegame. Apparently, in this case the cursor is updated before _precalcTable has been created. Added safeguard against that. --- engines/tony/game.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 5b9502468a..f1e8f0e614 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1601,6 +1601,9 @@ void RMPointer::updateCursor() { // If in black & white mode, convert the cursor if (GLOBALS._bCfgAnni30) { + if (!RMGfxTargetBuffer::_precalcTable) { + RMGfxTargetBuffer::createBWPrecalcTable(); + } uint16 *src = (uint16 *)cursorData; for (int i = 0; i < 64; i++) { uint16 *lineP = src; -- cgit v1.2.3 From 17b9732a59ea512be368d045104fba6b219ed55e Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 09d9b0d8c989eb57c9e2254ecf9074cdc1963636 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sun, 15 Jul 2012 20:48:43 +0200 Subject: TONY: Change platform from DOS to Windows This is cosmetic, just to keep the detector from saying that Tony Tough is a DOS game. --- engines/tony/detection_tables.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index e37ba11dbf..f9881c29f2 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -37,7 +37,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -54,7 +54,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_DEMO, GUIO1(GUIO_NONE) }, @@ -70,7 +70,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_DEMO | GF_COMPRESSED, GUIO1(GUIO_NONE) }, @@ -86,7 +86,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::FR_FRA, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -102,7 +102,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::DE_DEU, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -118,7 +118,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::IT_ITA, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -134,7 +134,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::PL_POL, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, -- cgit v1.2.3 From e8d3f0b020718ce37be7f8dbe38f1702228a2c7f Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 a5bfbeed32c175119db2eb2510a7afd3626fae47 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Thu, 26 Jul 2012 20:15:32 +0200 Subject: TONY: Don't pass uninitialised rect to addDirtyRect() Wait until after we have the destination rect. Unfortunately, this does not fix any of the graphical glitches during the intro. --- engines/tony/gfxcore.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 119b730303..ca6dd45c14 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -2018,9 +2018,6 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) uint16 *buf = bigBuf; RMRect rcDst; - // Specify the drawn area - bigBuf.addDirtyRect(rcDst); - // It takes the destination rectangle rcDst = prim->getDst(); buf += rcDst._y1 * bigBuf.getDimx() + rcDst._x1; @@ -2032,6 +2029,9 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) buf += bigBuf.getDimx() - rcDst.width(); } + + // Specify the drawn area + bigBuf.addDirtyRect(rcDst); } -- cgit v1.2.3 From 2c530bc6edc9ffd95fa86488a663e67d2735041f Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 3b40d141529160d48da954397fa7b58659b46da5 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Tue, 31 Jul 2012 20:36:48 +0200 Subject: TONY: Whitespace changes. --- engines/tony/mpal/expr.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index c2fadd63df..7cf2cb3fc8 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -141,41 +141,41 @@ static int Compute(int a, int b, byte symbol) { switch (symbol) { case OP_MUL: return a * b; - case OP_DIV: + case OP_DIV: return a / b; - case OP_MODULE: + case OP_MODULE: return a % b; - case OP_ADD: + case OP_ADD: return a + b; - case OP_SUB: + case OP_SUB: return a - b; - case OP_SHL: + case OP_SHL: return a << b; - case OP_SHR: + case OP_SHR: return a >> b; - case OP_MINOR: + case OP_MINOR: return a < b; - case OP_MAJOR: + case OP_MAJOR: return a > b; - case OP_MINEQ: + case OP_MINEQ: return a <= b; - case OP_MAJEQ: + case OP_MAJEQ: return a >= b; - case OP_EQUAL: + case OP_EQUAL: return a == b; - case OP_NOEQUAL: + case OP_NOEQUAL: return a != b; - case OP_BITAND: + case OP_BITAND: return a & b; - case OP_BITXOR: + case OP_BITXOR: return a ^ b; - case OP_BITOR: + case OP_BITOR: return a | b; - case OP_AND: + case OP_AND: return a && b; - case OP_OR: + case OP_OR: return a || b; - default: + default: GLOBALS._mpalError = 1; break; } -- cgit v1.2.3 From fab814b7747be31278fbbfa1d46e28115cd6624e Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Tue, 31 Jul 2012 21:29:25 +0200 Subject: TONY: Remove unused variable. It wasn't used in the original engine either. --- engines/tony/mpal/loadmpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 1ec921dbd4..371a94e24a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -529,7 +529,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) bool ParseMpc(const byte *lpBuf) { uint16 i, j; uint16 wLen; - byte *lpTemp, *lpTemp2; + byte *lpTemp; /* 1. Variables */ if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') @@ -587,7 +587,7 @@ bool ParseMpc(const byte *lpBuf) { j += lpBuf[j] + 1; GLOBALS._lpmmMsgs->_hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); + lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); for (j = 0; lpBuf[j] != 0;) { copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); -- cgit v1.2.3 From 846f9644ddd471b6e6c7b147e971382dddda14fb Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Wed, 1 Aug 2012 22:34:00 +0200 Subject: TONY: Clip width to avoid crash when drawing flipped sprite This fixes - or at least work around - a failed assertion when Pantagruel leaves the office at the beginning of the game. --- engines/tony/gfxcore.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index ca6dd45c14..0c331cc0e9 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -927,6 +927,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri u = _dimx - (width + u); x1 = (prim->getDst()._x1 + _dimx - 1) - u; + if (width > x1) + width = x1; + // Specify the drawn area bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); -- cgit v1.2.3 From e32b79bff1260f8d2853404f750acc22209a323b Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 dfb0e4f7001347aa50ee9707229647783f8f88c0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Aug 2012 19:47:48 +1000 Subject: TONY: Fix dirty rect refresh glitch in the introduction sequence --- engines/tony/gfxengine.h | 1 + engines/tony/window.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index a69182d032..8be09ddd8b 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -130,6 +130,7 @@ public: // Manage a location uint32 loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); + int getCurrentLocation() const { return _nCurLoc; } // Freeze and unfreeze void freeze(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c509a12f9e..2d5954a74c 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -140,11 +140,16 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // Get a pointer to the bytes of the source buffer byte *lpBuf = bigBuf; + // FIXME: The current dirty rect handling code has a minor issue with screen refresh in one + // scene in the introduction sequence as the scene changes. For now, we're working around the + // problem by explicitly having full screen refreshes on that scene + bool fullRefresh = _vm->getEngine()->getCurrentLocation() == 98; + if (rcBoundEllipse != NULL) { // Circular wipe effect getNewFrameWipe(lpBuf, *rcBoundEllipse); _wiping = true; - } else if (_wiping) { + } else if (_wiping || fullRefresh) { // Just finished a wiping effect, so copy the full screen copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); _wiping = false; -- cgit v1.2.3 From 2c44f3f5fac5f5bbe5628cf3de61782f975174fd Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 482c1a71b04bf1b5d0f18847ce445c45085e77fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Aug 2012 22:28:08 +1000 Subject: TONY: Removed some TODO warnings that aren't needed any longer --- engines/tony/tony.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 30ab716c20..a44d9410f3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -355,15 +355,15 @@ FPSfx *TonyEngine::createSFX(Common::SeekableReadStream *stream) { } void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { - warning("TonyEngine::preloadUtilSFX"); + // No preloading is needed in ScummVM } void TonyEngine::unloadAllSFX() { - warning("TonyEngine::unloadAllSFX"); + // No preloading is needed in ScummVM } void TonyEngine::unloadAllUtilSFX() { - warning("TonyEngine::unloadAllUtilSFX"); + // No preloading is needed in ScummVM } void TonyEngine::initMusic() { -- cgit v1.2.3 From c3407390013b1e1826bdb31979a50f5e8a957f04 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 14:00:46 +0200 Subject: TONY: Replace _vm with g_vm. --- engines/tony/custom.cpp | 110 ++++++++++++++++++++-------------------- engines/tony/debugger.cpp | 6 +-- engines/tony/font.cpp | 58 ++++++++++----------- engines/tony/game.cpp | 66 ++++++++++++------------ engines/tony/gfxengine.cpp | 24 ++++----- engines/tony/input.cpp | 6 +-- engines/tony/inventory.cpp | 32 ++++++------ engines/tony/loc.cpp | 10 ++-- engines/tony/mpal/mpal.cpp | 22 ++++---- engines/tony/mpal/mpalutils.cpp | 2 +- engines/tony/sound.cpp | 6 +-- engines/tony/tony.cpp | 36 ++++++------- engines/tony/tony.h | 4 +- engines/tony/tonychar.cpp | 4 +- engines/tony/window.cpp | 6 +-- 15 files changed, 196 insertions(+), 196 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 35ae8849f1..6853cf51a0 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -234,12 +234,12 @@ DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32 VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { int code = (codehi << 16) | codelo; - if (_vm->_voices.size() == 0) + if (g_vm->_voices.size() == 0) return NULL; - for (uint i = 0; i < _vm->_voices.size(); i++) - if (_vm->_voices[i]._code == code) - return &_vm->_voices[i]; + for (uint i = 0; i < g_vm->_voices.size(); i++) + if (g_vm->_voices[i]._code == code) + return &g_vm->_voices[i]; return NULL; } @@ -273,11 +273,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _ctx->curVoc->_offset; // First time allocation - _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.createSfx(&_ctx->voice); + g_vm->_vdbFP.seek(_ctx->curOffset); + g_vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); + _ctx->curOffset = g_vm->_vdbFP.pos(); _ctx->voice->setLoop(false); } @@ -331,11 +331,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } else { - _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_vdbFP.seek(_ctx->curOffset); + g_vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->curOffset = g_vm->_vdbFP.pos(); _ctx->voice->setLoop(false); _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); @@ -512,7 +512,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - _vm->stopMusic(4); + g_vm->stopMusic(4); // On exit, unload and unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); @@ -535,7 +535,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { - _vm->stopMusic(4); + g_vm->stopMusic(4); } // On exit, unfreeze @@ -550,7 +550,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { GLOBALS._lastTappeto = GLOBALS._ambiance[nLoc]; if (GLOBALS._lastTappeto != 0) - _vm->playMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true, 2000); + g_vm->playMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true, 2000); } if (!GLOBALS._bNoBullsEye) { @@ -1286,7 +1286,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->startpt = GLOBALS._loc->scrollPosition(); - _ctx->dwStartTime = _vm->getTime(); + _ctx->dwStartTime = g_vm->getTime(); if (sX) _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; @@ -1294,7 +1294,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { - _ctx->dwCurTime = _vm->getTime() - _ctx->dwStartTime; + _ctx->dwCurTime = g_vm->getTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1368,11 +1368,11 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->autoSave(coroParam); + g_vm->autoSave(coroParam); } DECLARE_CUSTOM_FUNCTION(AbortGame)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->abortGame(); + g_vm->abortGame(); } DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { @@ -1384,12 +1384,12 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); _ctx->dirx = 1; _ctx->diry = 1; - while (_vm->getTime() < _ctx->curTime + nScosse) { + while (g_vm->getTime() < _ctx->curTime + nScosse) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); @@ -1397,7 +1397,7 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS.Unfreeze(); - _ctx->i = _vm->_randomSource.getRandomNumber(2); + _ctx->i = g_vm->_randomSource.getRandomNumber(2); if (_ctx->i == 0 || _ctx->i == 2) _ctx->dirx = -_ctx->dirx; @@ -1486,7 +1486,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->_offset); + g_vm->_vdbFP.seek(_ctx->curVoc->_offset); _ctx->curOffset = _ctx->curVoc->_offset; } @@ -1525,14 +1525,14 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.createSfx(&_ctx->voice); - _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_theSound.createSfx(&_ctx->voice); + g_vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->curOffset = g_vm->_vdbFP.pos(); } // Wait for the end of display @@ -1682,7 +1682,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->pt = RMPoint(GLOBALS._mCharacter[nChar]._x, GLOBALS._mCharacter[nChar]._y); // Parameter for special actions: random between the spoken - _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + g_vm->_randomSource.getRandomNumber( GLOBALS._mCharacter[nChar]._numTalks[GLOBALS._mCharacter[nChar]._curGroup] - 1) + 1; // Try to run the custom function to initialize the speech @@ -1697,8 +1697,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(_ctx->curVoc->_offset); + // fseek(g_vm->m_vdbFP, curVoc->offset, SEEK_SET); + g_vm->_vdbFP.seek(_ctx->curVoc->_offset); _ctx->curOffset = _ctx->curVoc->_offset; } @@ -1738,15 +1738,15 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.createSfx(&_ctx->voice); - _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_theSound.createSfx(&_ctx->voice); + g_vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->curOffset = g_vm->_vdbFP.pos(); } // Wait for the end of display @@ -1806,9 +1806,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->_offset); - _vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_vdbFP.seek(_ctx->curVoc->_offset); + g_vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); if (_ctx->bIsBack) _ctx->voice->setVolume(55); @@ -1863,7 +1863,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->pt = RMPoint(GLOBALS._mCharacter[nPers]._x, GLOBALS._mCharacter[nPers]._y); // Parameter for special actions. Random between the spoken. - _ctx->parm = (GLOBALS._mCharacter[nPers]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (GLOBALS._mCharacter[nPers]._curGroup * 10) + g_vm->_randomSource.getRandomNumber( GLOBALS._mCharacter[nPers]._numTalks[GLOBALS._mCharacter[nPers]._curGroup] - 1) + 1; if (GLOBALS._mCharacter[nPers]._numTexts != 0 && GLOBALS._mCharacter[nPers]._bInTexts) { @@ -2097,11 +2097,11 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeIn Music"); for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { - _vm->setMusicVolume(nChannel, _ctx->i * 4); + g_vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - _vm->setMusicVolume(nChannel, 64); + g_vm->setMusicVolume(nChannel, 64); debug("End FadeIn Music"); @@ -2120,23 +2120,23 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CODE(_ctx); - _ctx->startVolume = _vm->getMusicVolume(nChannel); + _ctx->startVolume = g_vm->getMusicVolume(nChannel); debug("Start FadeOut Music"); for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS._bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) - _vm->setMusicVolume(nChannel, _ctx->i * 4); + g_vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } if (!GLOBALS._bFadeOutStop) - _vm->setMusicVolume(nChannel, 0); + g_vm->setMusicVolume(nChannel, 0); // If a jingle is played, stop it if (nChannel == 2) - _vm->stopMusic(2); + g_vm->stopMusic(2); debug("End FadeOut Music"); @@ -2166,28 +2166,28 @@ DECLARE_CUSTOM_FUNCTION(FadeInJingle)(CORO_PARAM, uint32, uint32, uint32, uint32 } DECLARE_CUSTOM_FUNCTION(StopSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(GLOBALS._curSoundEffect); + g_vm->stopMusic(GLOBALS._curSoundEffect); } DECLARE_CUSTOM_FUNCTION(StopJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(2); + g_vm->stopMusic(2); } DECLARE_CUSTOM_FUNCTION(MuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(GLOBALS._curSoundEffect, 0); + g_vm->setMusicVolume(GLOBALS._curSoundEffect, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = true; - _vm->setMusicVolume(GLOBALS._curSoundEffect, 64); + g_vm->setMusicVolume(GLOBALS._curSoundEffect, 64); } DECLARE_CUSTOM_FUNCTION(MuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(2, 0); + g_vm->setMusicVolume(2, 0); } DECLARE_CUSTOM_FUNCTION(DemuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(2, 64); + g_vm->setMusicVolume(2, 64); } void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { @@ -2298,7 +2298,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->openInitLoadMenu); + CORO_INVOKE_0(g_vm->openInitLoadMenu); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2311,7 +2311,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->openInitOptions); + CORO_INVOKE_0(g_vm->openInitOptions); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2367,13 +2367,13 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } - _ctx->startTime = _vm->getTime(); + _ctx->startTime = g_vm->getTime(); - while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { + while (_ctx->startTime + dwTime * 1000 > g_vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); if (GLOBALS._input->mouseLeftClicked() || GLOBALS._input->mouseRightClicked()) break; - if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 75e58d68d4..6355284ece 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -88,7 +88,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } int sceneNumber = strToInt(argv[1]); - if (sceneNumber >= _vm->_theBoxes.getLocBoxesCount()) { + if (sceneNumber >= g_vm->_theBoxes.getLocBoxesCount()) { DebugPrintf("Invalid scene\n"); return true; } @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas - RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); + RMBoxLoc *box = g_vm->_theBoxes.getBoxes(sceneNumber); scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty); } @@ -122,7 +122,7 @@ bool Debugger::Cmd_DirtyRects(int argc, const char **argv) { DebugPrintf("Usage; %s [on | off]\n", argv[0]); return true; } else { - _vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); + g_vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); return false; } } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index efce8dbe6e..2d334434d4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -322,7 +322,7 @@ void RMFontDialog::init() { _lTable['E'] = 10; _lTable['F'] = 11; - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -365,7 +365,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 14; _lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, @@ -508,7 +508,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 15; _lTable[(byte)''] = 14; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // Czech _cTable[(byte)''] = 196; _cTable[(byte)''] = 197; @@ -574,7 +574,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 13; _lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French _cTable[(byte)''] = 226; @@ -595,7 +595,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { _cTable[(byte)''] = 234; // 'SS' = 235 _cTable[(byte)''] = 236; @@ -686,7 +686,7 @@ void RMFontMacc::init() { //_cTable[(byte)''] = 100; // u with ball _cTable[(byte)''] = 101; - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -729,7 +729,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 14; _lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, @@ -870,7 +870,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // Czech _cTable[(byte)''] = 186; @@ -937,7 +937,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French _cTable[(byte)''] = 226; @@ -958,7 +958,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 10; _lTable[(byte)''] = 10; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { // German _cTable[(byte)''] = 234; @@ -1136,7 +1136,7 @@ void RMFontCredits::init() { _lTable[':'] = 5; _lTable['\''] = 5; - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -1179,7 +1179,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 15; _lTable[(byte)''] = 10; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, @@ -1320,7 +1320,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 13; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // CZECH Language _cTable[(byte)''] = 196; @@ -1387,7 +1387,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 10; _lTable[(byte)''] = 10; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French _cTable[(byte)''] = 226; @@ -1408,7 +1408,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { // German _cTable[(byte)''] = 234; @@ -1580,7 +1580,7 @@ void RMFontObj::init() { setBothCase('R', 'R', 1); setBothCase('R', 'U', 3); - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz @@ -1611,7 +1611,7 @@ void RMFontObj::init() { _cTable[(byte)''] = _cTable[(byte)''] = 93; _lTable[(byte)''] = _lTable[(byte)''] = 21; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, @@ -1689,7 +1689,7 @@ void RMFontObj::init() { _lTable[(byte)''] = _lTable[(byte)''] = 18; _lTable[(byte)''] = _lTable[(byte)''] = 18; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // Czech _cTable[(byte)''] = _cTable[(byte)''] = 127; @@ -1724,7 +1724,7 @@ void RMFontObj::init() { _lTable[(byte)''] = _lTable[(byte)''] = 16; _lTable[(byte)''] = _lTable[(byte)''] = 16; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters @@ -1744,7 +1744,7 @@ void RMFontObj::init() { _cTable[(byte)''] = _cTable[(byte)''] = 20; // u _lTable[(byte)''] = _lTable[(byte)''] = 15; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { // German _cTable[''] = 142; @@ -2074,14 +2074,14 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS._bCfgTimerizedText) { if (!_bForceNoTime) { - if (_vm->getTime() > (uint32)_time + _startTime) + if (g_vm->getTime() > (uint32)_time + _startTime) return; } } } if (!_bNoTab) { - if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } @@ -2095,14 +2095,14 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { // Erase the background else if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!_bForceNoTime) { - if (_vm->getTime() > (uint32)_time + _startTime) + if (g_vm->getTime() > (uint32)_time + _startTime) return; } } // If time is forced if (_bForceTime) { - if (_vm->getTime() > (uint32)_time + _startTime) + if (g_vm->getTime() > (uint32)_time + _startTime) return; } @@ -2138,7 +2138,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_BEGIN_CODE(_ctx); if (_startTime == 0) - _startTime = _vm->getTime(); + _startTime = g_vm->getTime(); if (_bShowed) { if (GLOBALS._bShowSubtitles || _bAlwaysDisplay) { @@ -2481,7 +2481,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { if (0) { _bShow = true; } else { - _ctx->starttime = _vm->getTime(); + _ctx->starttime = g_vm->getTime(); _ctx->deltay = 480 - _ptDrawPos._y; _ctx->destpt = _ptDrawPos; _ptDrawPos.set(0, 480); @@ -2494,7 +2494,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); - _ctx->elaps = _vm->getTime() - _ctx->starttime; + _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; mainUnfreeze(); } @@ -2531,14 +2531,14 @@ void RMDialogChoice::hide(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (1) { - _ctx->starttime = _vm->getTime(); + _ctx->starttime = g_vm->getTime(); _ctx->deltay = 480 - _ptDrawPos._y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); - _ctx->elaps = _vm->getTime() - _ctx->starttime; + _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; mainUnfreeze(); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index f1e8f0e614..d50f480625 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -48,75 +48,75 @@ using namespace MPAL; /****************************************/ uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->getEngine()->loadLocation(nLoc, pt, start); + return g_vm->getEngine()->loadLocation(nLoc, pt, start); } void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - _vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); + g_vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); } void mainLinkGraphicTask(RMGfxTask *task) { - _vm->getEngine()->linkGraphicTask(task); + g_vm->getEngine()->linkGraphicTask(task); } void mainFreeze() { - _vm->getEngine()->freeze(); + g_vm->getEngine()->freeze(); } void mainUnfreeze() { - _vm->getEngine()->unfreeze(); + g_vm->getEngine()->unfreeze(); } void mainWaitFrame(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); + CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE); } void mainShowMouse() { - _vm->getEngine()->enableMouse(); + g_vm->getEngine()->enableMouse(); } void mainHideMouse() { - _vm->getEngine()->disableMouse(); + g_vm->getEngine()->disableMouse(); } void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { - _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); + g_vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } void mainDisableInput() { - _vm->getEngine()->disableInput(); + g_vm->getEngine()->disableInput(); } void mainEnableInput() { - _vm->getEngine()->enableInput(); + g_vm->getEngine()->enableInput(); } void mainInitWipe(int type) { - _vm->getEngine()->initWipe(type); + g_vm->getEngine()->initWipe(type); } void mainCloseWipe() { - _vm->getEngine()->closeWipe(); + g_vm->getEngine()->closeWipe(); } void mainWaitWipeEnd(CORO_PARAM) { - _vm->getEngine()->waitWipeEnd(coroParam); + g_vm->getEngine()->waitWipeEnd(coroParam); } void mainEnableGUI() { - _vm->getEngine()->_bGUIInterface = true; - _vm->getEngine()->_bGUIInventory = true; - _vm->getEngine()->_bGUIOption = true; + g_vm->getEngine()->_bGUIInterface = true; + g_vm->getEngine()->_bGUIInventory = true; + g_vm->getEngine()->_bGUIOption = true; } void mainDisableGUI() { - _vm->getEngine()->_bGUIInterface = false; - _vm->getEngine()->_bGUIInventory = false; - _vm->getEngine()->_bGUIOption = false; + g_vm->getEngine()->_bGUIInterface = false; + g_vm->getEngine()->_bGUIInventory = false; + g_vm->getEngine()->_bGUIOption = false; } void mainSetPerorate(bool bPerorate) { - _vm->getEngine()->setPerorate(bPerorate); + g_vm->getEngine()->setPerorate(bPerorate); } /****************************************************************************\ @@ -489,7 +489,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { if (_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; - _ctx->thumb->init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); + _ctx->thumb->init((byte *)g_vm->getThumbnail(), 640 / 4, 480 / 4); if (_nEditPos == 0) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); @@ -856,7 +856,7 @@ void RMOptionScreen::closeState() { } // Save the new settings to ScummVM - _vm->saveSoundSettings(); + g_vm->saveSoundSettings(); } _nState = MENUNONE; @@ -989,7 +989,7 @@ bool RMOptionScreen::close() { // Start fade out _fadeStep++; - _fadeTime = _vm->getTime(); + _fadeTime = g_vm->getTime(); return true; } @@ -1053,7 +1053,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // Buttons with graphics if (!_bNoLoadSave) { - if (!_vm->getIsDemo()) { + if (!g_vm->getIsDemo()) { _ctx->bRefresh |= _buttonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); _ctx->bRefresh |= _buttonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } @@ -1096,7 +1096,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) +#define KEYPRESS(c) (g_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } @@ -1153,7 +1153,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { _bEditSaveName = false; - _vm->saveState(_statePos + _nEditPos, _editName); + g_vm->saveState(_statePos + _nEditPos, _editName); close(); } @@ -1191,7 +1191,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // There by saving or loading!!! if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { // Loading - CORO_INVOKE_1(_vm->loadState, _statePos + _ctx->i); + CORO_INVOKE_1(g_vm->loadState, _statePos + _ctx->i); close(); } else if (_nState == MENUSAVE && (_statePos != 0 || _ctx->i != 0)) { // Turn on edit mode @@ -1215,7 +1215,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { _bQuitConfirm = false; _ctx->bRefresh = true; - _vm->quitGame(); + g_vm->quitGame(); } } else { if (_buttonQuit->isActive()) { @@ -1281,7 +1281,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); #define FADE_SPEED 20 #define SYNC (_ctx->curTime - _fadeTime) / 25 @@ -1337,7 +1337,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (_fadeY > 480) { _fadeY = 480; _fadeStep++; - _vm->hideLocation(); + g_vm->hideLocation(); } prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); @@ -1347,7 +1347,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } else if (_fadeStep == 7) { // Menu OFF - _vm->showLocation(); + g_vm->showLocation(); _fadeStep++; } else if (_fadeStep == 8) { @@ -1399,7 +1399,7 @@ bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS diff = 10; // Get the savegame filename for the given slot - buf = _vm->getSaveStateFileName(nState); + buf = g_vm->getSaveStateFileName(nState); // Try and open the savegame f = g_system->getSavefileManager()->openForLoading(buf); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 726ee07e28..183e68c8c6 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -110,7 +110,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { CORO_INVOKE_3(_opt.initSaveMenuOnly, _bigBuf, false, _ctx->bRes); if (_ctx->bRes) { - _vm->pauseSound(true); + g_vm->pauseSound(true); disableInput(); _inv.endCombine(); @@ -120,7 +120,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _point.setSpecialPointer(RMPointer::PTR_NONE); _point.setCustomPointer(NULL); enableMouse(); - _vm->grabThumbnail(); + g_vm->grabThumbnail(); // Exists the IDLE to avoid premature death in loading _bMustEnterMenu = true; @@ -162,7 +162,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { disableMouse(); enableInput(); mpalStartIdlePoll(_nCurLoc); - _vm->pauseSound(false); + g_vm->pauseSound(false); } } @@ -214,7 +214,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { goto SKIPCLICKSINISTRO; } else if (_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(openOptionScreen, 0); - else if (!_vm->getIsDemo()) { + else if (!g_vm->getIsDemo()) { if (_input.getAsyncKeyState(Common::KEYCODE_F3) || _input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen CORO_INVOKE_1(openOptionScreen, 4); @@ -355,7 +355,7 @@ SKIPCLICKSINISTRO: } void RMGfxEngine::initCustomDll() { - setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); + setupGlobalVars(&_tony, &_point, &g_vm->_theBoxes, &_loc, &_inv, &_input); } void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { @@ -475,8 +475,8 @@ void RMGfxEngine::init() { // Display 'Loading' screen _bigBuf.addDirtyRect(Common::Rect(0, 0, RM_SX, RM_SY)); - _vm->_window.getNewFrame(*this, NULL); - _vm->_window.repaint(); + g_vm->_window.getNewFrame(*this, NULL); + g_vm->_window.repaint(); GLOBALS._bPatIrqFreeze = true; @@ -507,7 +507,7 @@ void RMGfxEngine::init() { // Initialize Tony _tony.init(); - _tony.linkToBoxes(&_vm->_theBoxes); + _tony.linkToBoxes(&g_vm->_theBoxes); // Initialize the inventory and the interface _inv.init(); @@ -631,9 +631,9 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // boxes - size = _vm->_theBoxes.getSaveStateSize(); + size = g_vm->_theBoxes.getSaveStateSize(); state = new byte[size]; - _vm->_theBoxes.saveState(state); + g_vm->_theBoxes.saveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -769,7 +769,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - _vm->_theBoxes.loadState(_ctx->state); + g_vm->_theBoxes.loadState(_ctx->state); delete[] _ctx->state; } @@ -865,7 +865,7 @@ void RMGfxEngine::waitWipeEnd(CORO_PARAM) { } bool RMGfxEngine::canLoadSave() { - return _bInput && !_tony.inAction() && !_vm->getIsDemo(); + return _bInput && !_tony.inAction() && !g_vm->getIsDemo(); } } // End of namespace Tony diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 7d663c1465..1e79032af2 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,7 +52,7 @@ void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events - while (g_system->getEventManager()->pollEvent(_event) && !_vm->shouldQuit()) { + while (g_system->getEventManager()->pollEvent(_event) && !g_vm->shouldQuit()) { switch (_event.type) { case Common::EVENT_MOUSEMOVE: case Common::EVENT_LBUTTONDOWN: @@ -83,8 +83,8 @@ void RMInput::poll() { // Check for debugger if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) { // Attach to the debugger - _vm->_debugger->attach(); - _vm->_debugger->onFrame(); + g_vm->_debugger->attach(); + g_vm->_debugger->onFrame(); } else { // Flag the given key as being down _keyDown[(int)_event.kbd.keycode] = true; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 0438d7252b..175d9fc6a9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -339,7 +339,7 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { _nCombine = _inv[n - 1 + _curPos]; nCombineObj = _nCombine + 10000; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); return true; } } @@ -402,7 +402,7 @@ void RMInventory::rightClick(const RMPoint &mpos) { _miniAction = 0; _nSelectObj = n - 1; - _vm->playUtilSFX(0); + g_vm->playUtilSFX(0); } } @@ -524,7 +524,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(_csModifyInterface); } - if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { + if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS._bCfgInvLocked = !GLOBALS._bCfgInvLocked; } @@ -538,7 +538,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = RM_SY - 1; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = OPENED; _curPutY = RM_SY - 68; @@ -548,13 +548,13 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = RM_SY - 68; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = CLOSED; } } } else if (_state == OPENING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY -= 3; _curPutTime += INVSPEED; } @@ -565,7 +565,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } else if (_state == CLOSING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY += 3; _curPutTime += INVSPEED; } @@ -578,7 +578,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = - 68; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = OPENED; _curPutY = 0; @@ -588,13 +588,13 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = -2; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = CLOSED; } } } else if (_state == OPENING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY += 3; _curPutTime += INVSPEED; } @@ -604,7 +604,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = 0; } } else if (_state == CLOSING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY -= 3; _curPutTime += INVSPEED; } @@ -629,19 +629,19 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (_miniAction != 1) { _miniInterface.setPattern(2); _miniAction = 1; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } } else if (mpos._x >= startx + 40 && mpos._x < startx + 80) { if (_miniAction != 2) { _miniInterface.setPattern(3); _miniAction = 2; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } } else if (mpos._x >= startx + 80 && mpos._x < startx + 108) { if (_miniAction != 3) { _miniInterface.setPattern(4); _miniAction = 3; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } } else { _miniInterface.setPattern(1); @@ -792,7 +792,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_lastHotZone != _ctx->h) { _lastHotZone = _ctx->h; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } if (GLOBALS._bCfgInterTips) { @@ -832,7 +832,7 @@ void RMInterface::clicked(const RMPoint &mousepos) { _openStart._y = RM_SY - _dimy; // Play the sound effect - _vm->playUtilSFX(0); + g_vm->playUtilSFX(0); } bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d02bd9640f..eaed3b49e2 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -157,7 +157,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; // Read the current time - _nStartTime = _vm->getTime(); + _nStartTime = g_vm->getTime(); _nCurSlot = 0; // Find the first frame of the pattern @@ -210,7 +210,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { } int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { - int CurTime = _vm->getTime(); + int CurTime = g_vm->getTime(); // If the speed is 0, then the pattern never advances if (_speed == 0) { @@ -408,7 +408,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { Common::SeekableReadStream *stream = new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); // Create the sound effect - _fx = _vm->createSFX(stream); + _fx = g_vm->createSFX(stream); _fx->setLoop(false); } @@ -2083,10 +2083,10 @@ bool RMLocation::load(RMDataStream &ds) { _items = new RMItem[_nItems]; - _vm->freezeTime(); + g_vm->freezeTime(); for (i = 0; i < _nItems && !ds.isError(); i++) ds >> _items[i]; - _vm->unfreezeTime(); + g_vm->unfreezeTime(); return ds.isError(); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 7385e60b66..20c28c5c93 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -607,7 +607,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - _ctx->dwStartTime = _vm->getTime(); + _ctx->dwStartTime = g_vm->getTime(); _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); @@ -615,9 +615,9 @@ void ScriptThread(CORO_PARAM, const void *param) { // Sleep for the required time if (s->Moment[_ctx->i].dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); - _ctx->dwStartTime = _vm->getTime(); + _ctx->dwStartTime = g_vm->getTime(); } else { - _ctx->dwCurTime = _vm->getTime(); + _ctx->dwCurTime = g_vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); @@ -761,11 +761,11 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { GLOBALS._bExecutingAction = false; - if (_vm->_initialLoadSlotNumber != -1) { - _ctx->slotNumber = _vm->_initialLoadSlotNumber; - _vm->_initialLoadSlotNumber = -1; + if (g_vm->_initialLoadSlotNumber != -1) { + _ctx->slotNumber = g_vm->_initialLoadSlotNumber; + g_vm->_initialLoadSlotNumber = -1; - CORO_INVOKE_1(_vm->loadState, _ctx->slotNumber); + CORO_INVOKE_1(g_vm->loadState, _ctx->slotNumber); } @@ -909,7 +909,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { copyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); + _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); _ctx->k++; } } @@ -925,7 +925,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) @@ -951,7 +951,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = 0; } - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); /* Loop through all the necessary idle actions */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) @@ -959,7 +959,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; /* It's time to check to see if fortune is on the side of the idle action */ - byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); + byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Check if there is an action running on the item */ if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index aba92a86cd..aa22456a4b 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -37,7 +37,7 @@ namespace MPAL { * @param resId MPAL resource to open */ RMRes::RMRes(uint32 resID) { - _h = _vm->_resUpdate.queryResource(resID); + _h = g_vm->_resUpdate.queryResource(resID); if (_h == NULL) _h = mpalQueryResource(resID); if (_h != NULL) diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 7380b3a93a..781172df52 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -138,7 +138,7 @@ FPSfx::FPSfx(bool bSoundOn) { _rewindableStream = 0; _bPaused = false; - _vm->_activeSfx.push_back(this); + g_vm->_activeSfx.push_back(this); } /** @@ -154,7 +154,7 @@ FPSfx::~FPSfx() { return; g_system->getMixer()->stopHandle(_handle); - _vm->_activeSfx.remove(this); + g_vm->_activeSfx.remove(this); if (_loopStream) delete _loopStream; // _rewindableStream is deleted by deleting _loopStream @@ -403,7 +403,7 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { for (;;) { // Check each active sound - for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { + for (_ctx->i = g_vm->_activeSfx.begin(); _ctx->i != g_vm->_activeSfx.end(); ++_ctx->i) { FPSfx *sfx = *_ctx->i; if (sfx->endOfBuffer()) CoroScheduler.setEvent(sfx->_hEndOfBuffer); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a44d9410f3..6100596b0e 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -35,11 +35,11 @@ namespace Tony { -TonyEngine *_vm; +TonyEngine *g_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { - _vm = this; + g_vm = this; _loadSlotNumber = -1; // Set the up the debugger @@ -229,7 +229,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b if (!getIsDemo()) { if (!_stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) - _vm->abortGame(); + g_vm->abortGame(); } else { _stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } @@ -241,7 +241,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b } else { if (!getIsDemo()) { if (!_stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) - _vm->abortGame(); + g_vm->abortGame(); } else { _stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } @@ -256,13 +256,13 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { Common::String fn; CORO_END_CONTEXT(_ctx); - FPStream **streams = _vm->_stream; + FPStream **streams = g_vm->_stream; CORO_BEGIN_CODE(_ctx); - if (!_vm->getIsDemo()) { + if (!g_vm->getIsDemo()) { if (!streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync)) - _vm->abortGame(); + g_vm->abortGame(); } else { streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync); } @@ -532,34 +532,34 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // and kill the scheudler and all the processes, including this one for (;;) { // If a savegame needs to be loaded, then do so - if (_vm->_loadSlotNumber != -1 && GLOBALS._gfxEngine != NULL) { - _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); + if (g_vm->_loadSlotNumber != -1 && GLOBALS._gfxEngine != NULL) { + _ctx->fn = getSaveStateFileName(g_vm->_loadSlotNumber); CORO_INVOKE_1(GLOBALS._gfxEngine->loadState, _ctx->fn); - _vm->_loadSlotNumber = -1; + g_vm->_loadSlotNumber = -1; } // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - CORO_INVOKE_1(_vm->_theEngine.doFrame, _vm->_bDrawLocation); + CORO_INVOKE_1(g_vm->_theEngine.doFrame, g_vm->_bDrawLocation); // Warns that a frame is finished - CoroScheduler.pulseEvent(_vm->_hEndOfFrame); + CoroScheduler.pulseEvent(g_vm->_hEndOfFrame); // Handle drawing the frame - if (!_vm->_bPaused) { - if (!_vm->_theEngine._bWiping) - _vm->_window.getNewFrame(_vm->_theEngine, NULL); + if (!g_vm->_bPaused) { + if (!g_vm->_theEngine._bWiping) + g_vm->_window.getNewFrame(g_vm->_theEngine, NULL); else - _vm->_window.getNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); + g_vm->_window.getNewFrame(g_vm->_theEngine, &g_vm->_theEngine._rcWipeEllipse); } // Paint the frame onto the screen - _vm->_window.repaint(); + g_vm->_window.repaint(); // Signal the ScummVM debugger - _vm->_debugger->onFrame(); + g_vm->_debugger->onFrame(); } CORO_END_CODE; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 94dc3de92d..18cddf3f2a 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -238,9 +238,9 @@ public: }; // Global reference to the TonyEngine object -extern TonyEngine *_vm; +extern TonyEngine *g_vm; -#define GLOBALS _vm->_globals +#define GLOBALS g_vm->_globals } // End of namespace Tony diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 74d9f20181..8593ece480 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -115,7 +115,7 @@ void RMTony::init() { ds.close(); _body.setPattern(0); - _nTimeLastStep = _vm->getTime(); + _nTimeLastStep = g_vm->getTime(); } @@ -137,7 +137,7 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { setSpeed(GLOBALS._nCfgTonySpeed); // Runs the normal character movement - _ctx->time = _vm->getTime(); + _ctx->time = g_vm->getTime(); do { _nTimeLastStep += (1000 / 40); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 2d5954a74c..3806aa67c8 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -70,7 +70,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, if (GLOBALS._bCfgAnni30) { if (!RMGfxTargetBuffer::_precalcTable) { RMGfxTargetBuffer::createBWPrecalcTable(); - _vm->getEngine()->getPointer().updateCursor(); + g_vm->getEngine()->getPointer().updateCursor(); } Graphics::Surface *screen = g_system->lockScreen(); const uint16 *src = (const uint16 *)buf; @@ -85,7 +85,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, } else { if (RMGfxTargetBuffer::_precalcTable) { RMGfxTargetBuffer::freeBWPrecalcTable(); - _vm->getEngine()->getPointer().updateCursor(); + g_vm->getEngine()->getPointer().updateCursor(); } g_system->copyRectToScreen(buf, pitch, x, y, w, h); } @@ -143,7 +143,7 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // FIXME: The current dirty rect handling code has a minor issue with screen refresh in one // scene in the introduction sequence as the scene changes. For now, we're working around the // problem by explicitly having full screen refreshes on that scene - bool fullRefresh = _vm->getEngine()->getCurrentLocation() == 98; + bool fullRefresh = g_vm->getEngine()->getCurrentLocation() == 98; if (rcBoundEllipse != NULL) { // Circular wipe effect -- cgit v1.2.3 From 93f145773e316a5ec9e37f02e1c2f803e89ccf66 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 21:52:22 +0200 Subject: TONY: Fix saveSoundSettings to use setInt for talkspeed. --- engines/tony/tony.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 6100596b0e..081556572a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -667,7 +667,7 @@ void TonyEngine::saveSoundSettings() { ConfMan.setInt("music_volume", GLOBALS._nCfgMusicVolume * 256 / 10); ConfMan.setBool("subtitles", GLOBALS._bShowSubtitles); - ConfMan.setBool("talkspeed", GLOBALS._nCfgTextSpeed); + ConfMan.setInt("talkspeed", GLOBALS._nCfgTextSpeed * 256 / 10); } } // End of namespace Tony -- cgit v1.2.3 From b1486aa5feb3fa074e91cb8436054608119062ed Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 21:56:12 +0200 Subject: TONY: Fix spelling of setStretch. --- engines/tony/gfxcore.h | 2 +- engines/tony/loc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 78c4c9bc70..2402b1e029 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -189,7 +189,7 @@ public: void setDst(const RMPoint &dst) { _dst.topLeft() = dst; } - void setStrecth(bool bStretch) { + void setStretch(bool bStretch) { _bStretch = bStretch; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index eaed3b49e2..a2dd7e097d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -690,7 +690,7 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->getDst().offset(calculatePos()); // No stretching, please - prim->setStrecth(false); + prim->setStretch(false); // Now we turn to the generic surface drawing routines CORO_INVOKE_2(_sprites[_nCurSprite].draw, bigBuf, prim); -- cgit v1.2.3 From 93e10b52108e84e4db0e05a10d274a90e6cc50ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Aug 2012 22:35:42 +1000 Subject: TONY: Removed some debug warnings which aren't needed any longer --- engines/tony/custom.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6853cf51a0..e082e5fcde 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2122,8 +2122,6 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { _ctx->startVolume = g_vm->getMusicVolume(nChannel); - debug("Start FadeOut Music"); - for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS._bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) g_vm->setMusicVolume(nChannel, _ctx->i * 4); @@ -2138,8 +2136,6 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (nChannel == 2) g_vm->stopMusic(2); - debug("End FadeOut Music"); - CORO_KILL_SELF(); CORO_END_CODE; -- cgit v1.2.3 From bad6ec838876bd88e3638bd07ad6e7d12c9af727 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 23 Aug 2012 22:01:52 +1000 Subject: TONY: Fixed problem with spoken voices being clipped when timed text mode is on. --- engines/tony/sound.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 781172df52..87e142df48 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -132,7 +132,7 @@ FPSfx::FPSfx(bool bSoundOn) { _bSoundSupported = bSoundOn; _bFileLoaded = false; _lastVolume = 63; - _hEndOfBuffer = CORO_INVALID_PID_VALUE; + _hEndOfBuffer = CoroScheduler.createEvent(true, false); _bIsVoice = false; _loopStream = 0; _rewindableStream = 0; @@ -161,9 +161,8 @@ FPSfx::~FPSfx() { else delete _rewindableStream; - // FIXME - //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - // CloseHandle(hEndOfBuffer); + // Free the buffer end event + CoroScheduler.closeEvent(_hEndOfBuffer); } /** -- cgit v1.2.3 From 61b11037c3d05e527932b37b556b655531836373 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 22:59:19 +0200 Subject: TONY: Ignore draw attempts with non-positive width/height. This avoids an invalid dirty rect (width -1) during the introduction scene inside Halloween Park. --- engines/tony/gfxcore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 0c331cc0e9..0241d96af1 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -198,7 +198,7 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int if (y1 + height - 1 > desth - 1) height = desth - y1; - return true; + return (width > 1 && height > 1); } -- cgit v1.2.3 From 0163bd38e8ba45635237340a69894c3678ed5f50 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 23:16:52 +0200 Subject: TONY: Fix background dirty rect handling. Reset the scrolling state on load, so that when a new scene is loaded, the background is redrawn. Also, revert the workaround in d0d15af9, since this (hopefully) fixes the underlying problem. --- engines/tony/loc.cpp | 7 ++++--- engines/tony/window.cpp | 7 +------ 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a2dd7e097d..dedac199fa 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1945,9 +1945,6 @@ RMLocation::RMLocation() { _buf = NULL; TEMPNumLoc = 0; _cmode = CM_256; - - _prevScroll.set(-1, -1); - _prevFixedScroll.set(-1, -1); } @@ -2020,6 +2017,10 @@ bool RMLocation::load(RMDataStream &ds) { byte cm; int i; + // Reset dirty rectangling + _prevScroll.set(-1, -1); + _prevFixedScroll.set(-1, -1); + // Check the ID ds >> id[0] >> id[1] >> id[2]; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 3806aa67c8..b603fa39f3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -140,16 +140,11 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // Get a pointer to the bytes of the source buffer byte *lpBuf = bigBuf; - // FIXME: The current dirty rect handling code has a minor issue with screen refresh in one - // scene in the introduction sequence as the scene changes. For now, we're working around the - // problem by explicitly having full screen refreshes on that scene - bool fullRefresh = g_vm->getEngine()->getCurrentLocation() == 98; - if (rcBoundEllipse != NULL) { // Circular wipe effect getNewFrameWipe(lpBuf, *rcBoundEllipse); _wiping = true; - } else if (_wiping || fullRefresh) { + } else if (_wiping) { // Just finished a wiping effect, so copy the full screen copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); _wiping = false; -- cgit v1.2.3 From 68c6109e7645c46be7c4bbd20fc0f3d68897ccc5 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 23:20:32 +0200 Subject: TONY: Draw the dirty rectangle debugging last. Otherwise the rects are overwritten by the actual drawing. --- engines/tony/window.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index b603fa39f3..1e60e636f3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -165,14 +165,16 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip Common::Rect &r = *i; const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + } - if (_showDirtyRects) + if (_showDirtyRects) { + for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { // Frame the copied area with a rectangle - s->frameRect(r, 0xffffff); - } + s->frameRect(*i, 0xffffff); + } - if (_showDirtyRects) g_system->unlockScreen(); + } } if (_bGrabThumbnail) { -- cgit v1.2.3 From 7815c0522094b058409974618867d683b86564d1 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 23:21:08 +0200 Subject: TONY: Use the right dirty rects for drawAA. This makes it match the relevant non-AA code, and fixes problems due to the invalid rects. (Perhaps we don't need dirty rects here at all though, since all the callers seem to call the non-AA code first with the same parameters?) --- engines/tony/gfxcore.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 0241d96af1..06c74dd231 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1720,7 +1720,17 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (prim->isFlipped()) { u = _dimx - (width + u); x1 = (prim->getDst()._x1 + _dimx - 1) - u; + + if (width > x1) + width = x1; + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + } else { + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } + // width = _dimx; // x1 = prim->Dst().x1; @@ -1807,9 +1817,6 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Skip to the next line buf += bigBuf.getDimx(); } - - // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } -- cgit v1.2.3 From aa603bc208c6b26e78e66d66a120a24ba80c28c4 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 24 Aug 2012 19:15:58 +0200 Subject: TONY: Mark screen dirty in RMGfxClearTask. This fixes the "A LONG TIME AFTER..." screen when talking to the old woman in the booth. Thanks to eriktorbjorn for noticing it. --- engines/tony/gfxcore.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 06c74dd231..27b90b7d48 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -2057,6 +2057,7 @@ int RMGfxClearTask::priority() { void RMGfxClearTask::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Clean the target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.getDimx() * bigBuf.getDimy() * 2), 0x0); + bigBuf.addDirtyRect(Common::Rect(bigBuf.getDimx(), bigBuf.getDimy())); } void RMGfxClearTask::removeThis(CORO_PARAM, bool &result) { -- cgit v1.2.3 From af134e02448c7e4d5d17711c0cb7f53ddc0674f6 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 24 Aug 2012 19:43:22 +0200 Subject: TONY: Animate mouse cursors. This restores the forgotten doFrame code for RMPointer, which fixes the bird mouse cursor. Thanks to eriktorbjorn for noticing it. --- engines/tony/game.cpp | 11 ++++++++++- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d50f480625..a27b8ea544 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1587,13 +1587,22 @@ void RMPointer::hideCursor() { } } +void RMPointer::doFrame() { + // Update the cursor animation if needed. + if (_nCurSpecialPointer == 0 || _nCurSpecialPointer == PTR_CUSTOM) + return; + + RMGfxTargetBuffer buf; + if (_specialPointer[_nCurSpecialPointer - 1]->doFrame(&buf, false)) + updateCursor(); +} void RMPointer::updateCursor() { // Create an intermediate buffer and draw the cursor onto it RMGfxTargetBuffer buf; buf.create(64, 64, 16); RMGfxPrimitive prim; - + draw(Common::nullContext, buf, &prim); // Get a pointer to the cursor data diff --git a/engines/tony/game.h b/engines/tony/game.h index 9804ac87fe..1a758dc8ca 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -98,7 +98,7 @@ public: /** * Process a frame */ - void doFrame(RMGfxTargetBuffer *bigBuf); + void doFrame(); /** * Overloading of priorities diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 183e68c8c6..5431a0ca7d 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -310,6 +310,7 @@ SKIPCLICKSINISTRO: } else { _point.hideCursor(); } + _point.doFrame(); // ********************** // Draw the list in the OT -- cgit v1.2.3 From f917a4beabff01e85159de6a34fd705470ba993c Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 24 Aug 2012 22:35:22 +0200 Subject: TONY: Use Common::String in writeText. This uses an array of lines rather than trying to stick nulls into the string, and so fixes wrapping on hyphens (which overwrote the character before the hyphen). Thanks to eriktorbjorn for both finding the bug and working out what was going wrong. --- engines/tony/font.cpp | 77 +++++++++++++++++++++++++++------------------------ engines/tony/font.h | 4 +-- engines/tony/game.cpp | 8 +++--- 3 files changed, 47 insertions(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 2d334434d4..7e65369bfc 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1801,7 +1801,7 @@ void RMText::removeThis(CORO_PARAM, bool &result) { result = true; } -void RMText::writeText(const RMString &text, int nFont, int *time) { +void RMText::writeText(const Common::String &text, int nFont, int *time) { // Initializes the font (only once) if (_fonts[0] == NULL) { _fonts[0] = new RMFontDialog; @@ -1817,15 +1817,13 @@ void RMText::writeText(const RMString &text, int nFont, int *time) { writeText(text, _fonts[nFont], time); } -void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { +void RMText::writeText(Common::String text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; - char *p, *old_p; - int i, j, x, y; + uint p, old_p; + int j, x, y; int len; int numchar; int width, height; - char *string; - int numlines; // Set the base color font->setBaseColor(_textR, _textG, _textB); @@ -1834,17 +1832,18 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { destroy(); // If the string is empty, do nothing - if (text == NULL || text[0] == '\0') + if (text.empty()) return; // Divide the words into lines. In this cycle, X contains the maximum length reached by a line, // and the number of lines - string = p = text; - i = j = x = 0; - while (*p != '\0') { - j += font->stringLen(*p); - if (j > (((_aHorType == HLEFTPAR) && (i > 0)) ? _maxLineLength - 25 : _maxLineLength)) { - j -= font->stringLen(*p, p[1]); + Common::Array lines; + p = 0; + j = x = 0; + while (p < text.size()) { + j += font->stringLen(text[p]); + if (j > (((_aHorType == HLEFTPAR) && (lines.size() > 0)) ? _maxLineLength - 25 : _maxLineLength)) { + j -= font->stringLen(text[p], (p + 1 == text.size()) ? '\0' : text[p + 1]); if (j > x) x = j; @@ -1855,21 +1854,24 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { // This workaround has the partial word broken up so it will still display // old_p = p; - while (*p != ' ' && *p != '-' && p > string) + while (text[p] != ' ' && text[p] != '-' && p > 0) p--; - if (p == string) + if (p == 0) p = old_p; // Check if there are any blanks to end - while (*p == ' ' && *p != '\0') + while ((text[p] == ' ' || text[p] == '-') && p + 1 < text.size()) p++; - if (*p == '\0') + if (p == text.size()) break; - p--; - i++; - *p = '\0'; + lines.push_back(Common::String(text.c_str(), p)); + if (text[p] == ' ') + p++; + text = text.c_str() + p; + p = 0; j = 0; + continue; } p++; } @@ -1877,27 +1879,29 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { if (j > x) x = j; - i++; - numlines = i; + // Add the last line of text. + lines.push_back(text); x += 8; // Starting position for the surface: X1, Y width = x; - height = (numlines - 1) * font->letterHeight() + font->_fontDimy; + height = (lines.size() - 1) * font->letterHeight() + font->_fontDimy; // Create the surface create(width, height); Common::fill(_buf, _buf + width * height * 2, 0); - p = string; + p = 0; y = 0; numchar = 0; - for (; i > 0; i--) { + for (uint i = 0; i < lines.size(); ++i) { + const Common::String &line = lines[i]; + // Measure the length of the line x = 0; - j = font->stringLen(RMString(p)); + j = font->stringLen(RMString(line.c_str())); switch (_aHorType) { case HLEFT: @@ -1905,7 +1909,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { break; case HLEFTPAR: - if (i == numlines) + if (i == 0) x = 0; else x = 25; @@ -1920,21 +1924,22 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { break; } - while (*p != '\0') { - if (*p == ' ') { - x += font->stringLen(*p); + p = 0; + while (p < line.size()) { + if (line[p] == ' ') { + x += font->stringLen(line[p]); p++; continue; } - prim = font->makeLetterPrimitive(*p, len); + prim = font->makeLetterPrimitive(line[p], len); prim->getDst()._x1 = x; prim->getDst()._y1 = y; addPrim(prim); numchar++; - x += font->stringLen(*p, p[1]); + x += font->stringLen(line[p], (p + 1 == line.size()) ? '\0' : line[p + 1]); p++; } p++; @@ -2021,14 +2026,14 @@ void RMTextDialog::hide(CORO_PARAM) { } void RMTextDialog::writeText(const RMString &text, int font, int *time) { - RMText::writeText(text, font, &_time); + RMText::writeText(Common::String(text), font, &_time); if (time != NULL) *time = _time; } void RMTextDialog::writeText(const RMString &text, RMFontColor *font, int *time) { - RMText::writeText(text, font, &_time); + RMText::writeText(Common::String(text), font, &_time); if (time != NULL) *time = _time; @@ -2251,7 +2256,7 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _item->getName(itemName); // Write it - writeText(itemName, 1); + writeText(Common::String(itemName), 1); // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != _item) { @@ -2389,7 +2394,7 @@ void RMDialogChoice::setNumChoices(int num) { void RMDialogChoice::addChoice(const RMString &string) { // Draw the string assert(_curAdded < _numChoices); - _drawedStrings[_curAdded++].writeText(string, 0); + _drawedStrings[_curAdded++].writeText(Common::String(string), 0); } void RMDialogChoice::prepare(CORO_PARAM) { diff --git a/engines/tony/font.h b/engines/tony/font.h index 9971e536ed..1e84ecb527 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -215,8 +215,8 @@ public: void setMaxLineLength(int max); // Write the text - void writeText(const RMString &text, int font, int *time = NULL); - void writeText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const Common::String &text, int font, int *time = NULL); + void writeText(Common::String text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index a27b8ea544..b3b6fe2347 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -506,15 +506,15 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { - RMString s; + Common::String s; if (_bEditSaveName && _nEditPos == _ctx->i) - s.format("%02d)%s*", _statePos + _ctx->i, _editName); + s = Common::String::format("%02d)%s*", _statePos + _ctx->i, _editName); else { if (_statePos == 0 && _ctx->i == 0) - s.format("Autosave"); + s = "Autosave"; else - s.format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); + s = Common::String::format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); } _ctx->num[_ctx->i] = new RMText; -- cgit v1.2.3 From ba20f1d90dd21986f8eb250e93d794db87b9a51c Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:07:49 +0200 Subject: TONY: Remove unused members of RMTextItemName. --- engines/tony/font.cpp | 4 ---- engines/tony/font.h | 2 -- 2 files changed, 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 7e65369bfc..f83677373f 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2308,10 +2308,6 @@ bool RMTextItemName::isItemSelected() { return _item != NULL; } -bool RMTextItemName::isNormalItemSelected() { - return _item != NULL && _itemName.length() > 0; -} - /****************************************************************************\ * RMDialogChoice Methods diff --git a/engines/tony/font.h b/engines/tony/font.h index 1e84ecb527..e6543ef5d7 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -315,7 +315,6 @@ protected: RMPoint _mpos; RMPoint _curscroll; RMItem *_item; - RMString _itemName; public: RMTextItemName(); @@ -331,7 +330,6 @@ public: RMPoint getHotspot(); RMItem *getSelectedItem(); bool isItemSelected(); - bool isNormalItemSelected(); virtual void removeThis(CORO_PARAM, bool &result) { result = true; -- cgit v1.2.3 From ff9569572a3587b96b849fe4ef572ed91c7e6f5d Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:08:13 +0200 Subject: TONY: Store savegame names with Common::String. --- engines/tony/detection.cpp | 8 ++++---- engines/tony/game.cpp | 8 ++++---- engines/tony/game.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index c408da3f24..8e6d5a64c3 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -128,12 +128,12 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { if (slotNum >= 0 && slotNum <= 999) { byte thumbnailData[160 * 120 * 2]; - Tony::RMString saveName; + Common::String saveName; byte difficulty; if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { // Add the save name to the savegame list - saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); + saveList.push_back(SaveStateDescriptor(slotNum, saveName)); } } } @@ -152,7 +152,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { } SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - Tony::RMString saveName; + Common::String saveName; byte difficulty; byte thumbData[160 * 120 * 2]; @@ -175,7 +175,7 @@ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int s } // Create the return descriptor - SaveStateDescriptor desc(slot, (const char *)saveName); + SaveStateDescriptor desc(slot, saveName); desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); desc.setThumbnail(to); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index b3b6fe2347..9b1d85f827 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -514,7 +514,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { if (_statePos == 0 && _ctx->i == 0) s = "Autosave"; else - s = Common::String::format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); + s = Common::String::format("%02d)%s", _statePos + _ctx->i, _curThumbName[_ctx->i].c_str()); } _ctx->num[_ctx->i] = new RMText; @@ -558,7 +558,7 @@ void RMOptionScreen::refreshThumbnails() { if (!loadThumbnailFromSaveState(_statePos + i, *_curThumb[i], _curThumbName[i], _curThumbDiff[i])) { delete _curThumb[i]; _curThumb[i] = NULL; - _curThumbName[i] = ""; + _curThumbName[i].clear(); _curThumbDiff[i] = 11; } } @@ -1197,7 +1197,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // Turn on edit mode _bEditSaveName = true; _nEditPos = _ctx->i; - strcpy(_editName, _curThumbName[_ctx->i]); + strcpy(_editName, _curThumbName[_ctx->i].c_str()); _ctx->bRefresh = true; } @@ -1386,7 +1386,7 @@ void RMOptionScreen::removeThis(CORO_PARAM, bool &result) { } -bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { +bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, Common::String &name, byte &diff) { Common::String buf; char namebuf[256]; int i; diff --git a/engines/tony/game.h b/engines/tony/game.h index 1a758dc8ca..aa7d45bce6 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -229,7 +229,7 @@ private: RMGfxSourceBuffer8 *_saveEasy; RMGfxSourceBuffer8 *_saveHard; RMGfxSourceBuffer16 *_curThumb[6]; - RMString _curThumbName[6]; + Common::String _curThumbName[6]; byte _curThumbDiff[6]; RMOptionButton *_buttonSave_States[6]; RMOptionButton *_buttonSave_ArrowLeft; @@ -315,7 +315,7 @@ public: /** * Retrieves a savegame's thumbnail, description, and difficulty level */ - static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, Common::String &name, byte &diff); protected: -- cgit v1.2.3 From b77306bfcc26d17b1fca71360d1fcbd2ebdbe0ee Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:21:58 +0200 Subject: TONY: Convert more strings to Common::String. --- engines/tony/font.cpp | 26 ++++++++++++-------------- engines/tony/font.h | 8 ++++---- engines/tony/loc.cpp | 3 +-- engines/tony/loc.h | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index f83677373f..a3d253a52c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -134,11 +134,11 @@ void RMFont::close() { unload(); } -int RMFont::stringLen(const RMString &text) { - int len, i; +int RMFont::stringLen(const Common::String &text) { + uint len, i; len = 0; - for (i = 0; i < text.length() - 1; i++) + for (i = 0; i < text.size() - 1; i++) len += letterLength(text[i], text[i + 1]); len += letterLength(text[i]); @@ -1901,7 +1901,7 @@ void RMText::writeText(Common::String text, RMFontColor *font, int *time) { // Measure the length of the line x = 0; - j = font->stringLen(RMString(line.c_str())); + j = font->stringLen(line); switch (_aHorType) { case HLEFT: @@ -2025,15 +2025,15 @@ void RMTextDialog::hide(CORO_PARAM) { _bShowed = false; } -void RMTextDialog::writeText(const RMString &text, int font, int *time) { - RMText::writeText(Common::String(text), font, &_time); +void RMTextDialog::writeText(const Common::String &text, int font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) *time = _time; } -void RMTextDialog::writeText(const RMString &text, RMFontColor *font, int *time) { - RMText::writeText(Common::String(text), font, &_time); +void RMTextDialog::writeText(const Common::String &text, RMFontColor *font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) *time = _time; @@ -2230,7 +2230,7 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & uint32 hThread; CORO_END_CONTEXT(_ctx); - RMString itemName; + Common::String itemName; CORO_BEGIN_CODE(_ctx); @@ -2249,14 +2249,12 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & else _item = loc.whichItemIsIn(_mpos); - itemName = ""; - // If there an item, get its name if (_item != NULL) _item->getName(itemName); // Write it - writeText(Common::String(itemName), 1); + writeText(itemName, 1); // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != _item) { @@ -2387,10 +2385,10 @@ void RMDialogChoice::setNumChoices(int num) { } } -void RMDialogChoice::addChoice(const RMString &string) { +void RMDialogChoice::addChoice(const Common::String &string) { // Draw the string assert(_curAdded < _numChoices); - _drawedStrings[_curAdded++].writeText(Common::String(string), 0); + _drawedStrings[_curAdded++].writeText(string, 0); } void RMDialogChoice::prepare(CORO_PARAM) { diff --git a/engines/tony/font.h b/engines/tony/font.h index e6543ef5d7..97434b9770 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -100,7 +100,7 @@ public: RMGfxPrimitive *makeLetterPrimitive(byte bChar, int &nLength); // Length in pixels of a string with the current font - int stringLen(const RMString &text); + int stringLen(const Common::String &text); int stringLen(char bChar, char bNext = 0); }; @@ -256,8 +256,8 @@ public: virtual ~RMTextDialog(); // Write the text - void writeText(const RMString &text, int font, int *time = NULL); - void writeText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const Common::String &text, int font, int *time = NULL); + void writeText(const Common::String &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); @@ -376,7 +376,7 @@ public: void setNumChoices(int num); // Adds a string with the choice - void addChoice(const RMString &string); + void addChoice(const Common::String &string); // Show and hide the selection, with possible animations. // NOTE: If no parameter is passed to Show(), it is the obligation of diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index dedac199fa..9fba2dd51a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -736,7 +736,7 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { } } -bool RMItem::getName(RMString &name) { +bool RMItem::getName(Common::String &name) { char buf[256]; mpalQueryItemName(_mpalCode, buf); @@ -1818,7 +1818,6 @@ RMGameBoxes::~RMGameBoxes() { void RMGameBoxes::init() { int i; - RMString fn; RMDataStream ds; // Load boxes from disk diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 35f07fe637..f8a795cc42 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -276,7 +276,7 @@ public: RMPoint hotspot() { return _hot; } - bool getName(RMString &name); + bool getName(Common::String &name); int mpalCode() { return _mpalCode; } -- cgit v1.2.3 From b14a616f3f7f667946f617facd301369a0996582 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:31:00 +0200 Subject: TONY: Get rid of RMString. --- engines/tony/loc.cpp | 12 +- engines/tony/loc.h | 10 +- engines/tony/utils.cpp | 342 +------------------------------------------------ engines/tony/utils.h | 60 +-------- 4 files changed, 18 insertions(+), 406 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 9fba2dd51a..e767584e9b 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -145,7 +145,7 @@ void RMPattern::updateCoord() { void RMPattern::stopSfx(RMSfx *sfx) { for (int i = 0; i < _nSlots; i++) { if (_slots[i]._type == SOUND) { - if (sfx[_slots[i]._data]._name[0] == '_') + if (!sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') sfx[_slots[i]._data].stop(); else if (GLOBALS._bSkipSfxNoLoop) sfx[_slots[i]._data].stop(); @@ -182,7 +182,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { for (i = 0; i < _nSlots; i++) { if (_slots[i]._type == SOUND) { if (i == 0) { - if (sfx[_slots[i]._data]._name[0] == '_') { + if (!sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } else { @@ -193,12 +193,12 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { if (bPlayP0) { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(); - } else if (sfx[_slots[i]._data]._name[0] == '_') { + } else if (!sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } } else { - if (_bLoop && sfx[_slots[i]._data]._name[0] == '_') { + if (_bLoop && !sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } @@ -253,7 +253,7 @@ int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (sfx != NULL) { sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos()._x); - if (sfx[_slots[_nCurSlot]._data]._name[0] != '_') + if (sfx[_slots[_nCurSlot]._data]._name.empty() || sfx[_slots[_nCurSlot]._data]._name[0] != '_') sfx[_slots[_nCurSlot]._data].play(false); else sfx[_slots[_nCurSlot]._data].play(true); @@ -729,7 +729,7 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { // Look for the sound effect for pattern 0 if (bPlayP0) { for (int i = 0; i < _nSfx; i++) { - if (strcmp(_sfx[i]._name, "p0") == 0) + if (_sfx[i]._name == "p0") _sfx[i].play(); } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index f8a795cc42..acfbd45cdb 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -71,7 +71,7 @@ public: */ class RMSfx { public: - RMString _name; + Common::String _name; FPSfx *_fx; bool _bPlayingLoop; @@ -126,7 +126,7 @@ public: }; public: - RMString _name; + Common::String _name; private: int _speed; @@ -174,7 +174,7 @@ private: */ class RMSprite : public RMGfxTask { public: - RMString _name; + Common::String _name; RMRect _rcBox; protected: @@ -200,7 +200,7 @@ public: */ class RMItem : public RMGfxTask { public: - RMString _name; + Common::String _name; protected: int _z; @@ -527,7 +527,7 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString _name; // Name + Common::String _name; // Name private: RMColorMode _cmode; // Color mode diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 54a2209659..8dc1f5d615 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -32,356 +32,26 @@ namespace Tony { -/****************************************************************************\ -* RMString methods -\****************************************************************************/ - -/** - * Constructor - */ -RMString::RMString() { - _string = NULL; - _length = 0; - _realLength = 0; -} - -/** - * Destructor - */ -RMString::~RMString() { - if (_string != NULL) - delete[] _string; -} - -/** - * Copy constructor - */ -RMString::RMString(const RMString &str) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = str; -} - -/** - * Constructor from a char * - */ -RMString::RMString(const char *str) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = str; -} - -/** - * Constructor with a single passed character - */ -RMString::RMString(const int ch) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = ch; -} - -/** - * Returns the length of the string - * @returns Length - */ -int RMString::length() const { - return _length; -} - -/** - * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character - */ -char RMString::getAt(int nIndex) { - assert(nIndex < _length); - return _string[nIndex]; -} - -/** - * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character - */ -void RMString::setAt(int nIndex, char c) { - assert(nIndex < _length); - _string[nIndex] = c; -} - -/** - * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character - */ -char &RMString::operator[](int nIndex) { - assert(nIndex < _length); - return _string[nIndex]; -} - -/** - * Copies a string - * @param str String to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const RMString &str) { - // Set the new length - _length = str._length; - - // If the source is empty, then destroy the current string buffer - if (_length == 0) { - if (_realLength > 0) { - delete[] _string; - _string = NULL; - _realLength = 0; - } - } else { - // Resize if necessary - resize(_length + 1); - - // Copy the string - Common::copy(str._string, str._string + _length + 1, _string); - } - - return *this; -} - -/** - * Copies a char * string - * @param str String to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const char *str) { - // If the source is empty, then destroy the current string buffer - if (str == NULL) { - if (_realLength > 0) { - delete[] _string; - _string = NULL; - _realLength = _length = 0; - } - } else { - // Calculate the new length - _length = strlen(str); - - // Resize if necessary - resize(_length + 1); - - // Copy the string - Common::copy(str, str + _length + 1, _string); - } - - return *this; -} - -/** - * Forms a string from a passed character - * @param ch Character to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const int ch) { - if (ch == '\0') { - // Destroy the current string - if (_realLength > 0) { - delete [] _string; - _string = NULL; - _length = _realLength = 0; - } - } else { - // Resize if necessary - resize(2); - - _string[0] = ch; - _string[1] = '\0'; - _length = 1; - } - - return *this; -} - -/** - * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string - */ -void RMString::connect(const char *str, int size) { - if (size > 0) { - // Calculate the new lenght - int nlen = _length + size; - - // Resize - resize(nlen + 1, true); - - // Linkage with '\0' - Common::copy(str, str + size + 1, _string + _length); - - // Save the new length - _length = nlen; - } -} - -/** - * Concatenate a string - * @param str String to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(RMString &str) { - connect(str, str.length()); - return *this; -} - -/** - * Concatenate a string - * @param str String to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(const char *str) { - connect(str, strlen(str)); - return *this; -} - -/** - * Concatenate a character - * @param ch Character to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(const int ch) { - char str[2]; - - // Create a simple string buffer to hold the single character - str[0] = ch; - str[1] = '\0'; - - connect(str, 1); - return *this; -} - -/** - * Casts a string as char * - * @returns char * reference to string - */ -RMString::operator char *() const { - return _string; -} - -/** - * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. - */ -void RMString::resize(int size, bool bMantain) { - if (_realLength == 0) { - _string = new char[size]; - _realLength = size; - } else if (size > _realLength) { - if (bMantain) { - char *app; - - app = new char[size]; - Common::copy(_string, _string + _length + 1, app); - delete[] _string; - _string = app; - } else { - delete[] _string; - _string = new char[size]; - } - } -} - -/** - * Compacts the string to occupy less memory if possible. - */ -void RMString::compact() { - if (_realLength + 1 > _length) { - char *app; - - app = new char[_length + 1]; - Common::copy(_string, _string + _length + 1, app); - - delete[] _string; - _string = app; - } -} - -/** - * Operator to concatenate two strings - */ -RMString operator+(const RMString &str1, const RMString &str2) { - RMString ret(str1); - - return (ret += str2); -} - -/** - * Operator to concatenate a character to a string - */ -RMString operator+(RMString &str, const int ch) { - RMString ret(str); - - return (ret += ch); -} - -RMString operator+(const int ch, RMString &str) { - RMString ret(ch); - - return (ret += str); -} - -/** - * Operator to concatenate a char * string to an RMString - */ -RMString operator+(RMString &str, const char *s) { - RMString ret(str); - - return (ret += s); -} - -RMString operator+(const char *s, RMString &str) { - RMString ret(s); - - return (ret += str); -} - /** * Extracts a string from a data stream * @param df data stream * @param var String */ -RMDataStream &operator>>(RMDataStream &df, RMString &var) { +RMDataStream &operator>>(RMDataStream &df, Common::String &var) { uint8 len; int i; df >> len; - var.resize(len + 1); - var._length = len + 1; - for (i = 0; i < len; i++) - df >> var[i]; - - var[i] = '\0'; - var._length = len; + for (i = 0; i < len; i++) { + char c; + df >> c; + var += c; + } return df; } -/** - * Formats a string - */ -void RMString::format(const char *str, ...) { - static char buf[2048]; - va_list argList; - - va_start(argList, str); - vsprintf(buf, str, argList); - va_end(argList); - *this = buf; -} - /****************************************************************************\ * RMFileStreamSlow Methods \****************************************************************************/ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index f755a57c39..50b18d8aa7 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -145,65 +145,7 @@ public: friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); }; -/** - * String class - */ -class RMString { -private: - char *_string; - int _length; - int _realLength; - -public: - RMString(); - ~RMString(); - - // Assignment constructors - RMString(const RMString &str); - RMString(const char *str); - RMString(const int ch); - - // General methods - int length() const; - void compact(); - - // Access characters within string - char getAt(int nIndex); - void setAt(int nIndex, char c); - char &operator[](int nIndex); - - // String cast - operator char *() const; - - // String assignments - const RMString &operator=(const RMString &str); - const RMString &operator=(const char *str); - const RMString &operator=(const int ch); - - // String concatenation - const RMString &operator+=(RMString &str); - const RMString &operator+=(const char *str); - const RMString &operator+=(const int ch); - - // Concatentation of string or character - friend RMString operator+(const RMString &str1, const RMString &str2); - - friend RMString operator+(RMString &str, const int ch); - friend RMString operator+(const int ch, RMString &str); - - friend RMString operator+(RMString &str, const char *s); - friend RMString operator+(const char *s, RMString &str); - - // Extraction from data streams - friend RMDataStream &operator>>(RMDataStream &df, RMString &var); - - // String formatting - void format(const char *str, ...); - -private: - void resize(int size, bool bMantain = false); - void connect(const char *str, int size); -}; +RMDataStream &operator>>(RMDataStream &df, Common::String &var); /** * Point class -- cgit v1.2.3 From a9828c88184a4c1a9161ca1fe80f5e6fff9c4f4e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 10:06:10 +0200 Subject: TONY: Replace copyMemory with memcpy. --- engines/tony/gfxcore.cpp | 12 ++++++------ engines/tony/mpal/expr.cpp | 8 ++++---- engines/tony/mpal/loadmpc.cpp | 10 +++++----- engines/tony/mpal/memory.cpp | 9 --------- engines/tony/mpal/memory.h | 3 --- engines/tony/mpal/mpal.cpp | 24 ++++++++++++------------ 6 files changed, 27 insertions(+), 39 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 27b90b7d48..806f4d07bb 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -135,7 +135,7 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, getBpp()); - copyMemory(_buf, buf, dimx * dimy * getBpp() / 8); + memcpy(_buf, buf, dimx * dimy * getBpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); @@ -484,7 +484,7 @@ int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { _pal[i * 3 + 2] = buf[i * 3 + 0]; } } else { - copyMemory(_pal, buf, (1 << getBpp()) * 3); + memcpy(_pal, buf, (1 << getBpp()) * 3); } preparePalette(); @@ -496,7 +496,7 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) { int i; for (i = 0; i < 256; i++) - copyMemory(_pal + i * 3, buf + i * 4, 3); + memcpy(_pal + i * 3, buf + i * 4, 3); preparePalette(); @@ -984,7 +984,7 @@ void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { *cur ++ = rep; if (rep > 0) { - copyMemory(cur, src, rep); + memcpy(cur, src, rep); cur += rep; src += rep; } @@ -1232,7 +1232,7 @@ void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { cur += 2; if (rep > 0) { - copyMemory(cur, src, rep); + memcpy(cur, src, rep); cur += rep; src += rep; } @@ -1683,7 +1683,7 @@ void RMGfxSourceBuffer8AA::calculateAA() { delete[] _aabuf; _aabuf = new byte[_dimx * _dimy]; - copyMemory(_aabuf, _megaAABuf, _dimx * _dimy); + memcpy(_aabuf, _megaAABuf, _dimx * _dimy); } RMGfxSourceBuffer8AA::RMGfxSourceBuffer8AA() : RMGfxSourceBuffer8() { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 7cf2cb3fc8..eb6b485ef6 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -121,7 +121,7 @@ static byte *duplicateExpression(HGLOBAL h) { clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); two = (LPEXPRESSION)(clone + 1); - copyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); + memcpy(clone, orig, sizeof(EXPRESSION) * num + 1); for (i = 0; i < num; i++) { if (one->type == ELT_PARENTH) { @@ -191,7 +191,7 @@ static void solve(LPEXPRESSION one, int num) { two = one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { two->val.num = Compute(one->val.num, two->val.num, one->symbol); - copyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); + memcpy(one, two, (num - 1) * sizeof(EXPRESSION)); --num; } else { j = 1; @@ -203,7 +203,7 @@ static void solve(LPEXPRESSION one, int num) { } three->val.num = Compute(two->val.num, three->val.num, two->symbol); - copyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); + memcpy(two, three, (num - j - 1) * sizeof(EXPRESSION)); --num; } } @@ -291,7 +291,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { cur->val.name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); if (cur->val.name == NULL) return NULL; - copyMemory(cur->val.name, lpBuf + 1, *lpBuf); + memcpy(cur->val.name, lpBuf + 1, *lpBuf); lpBuf += *lpBuf + 1; break; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 371a94e24a..a0dff2927a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -102,7 +102,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->_command[curCmd].lpszVarName == NULL) return NULL; - copyMemory(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); @@ -346,7 +346,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { len = *lpBuf; lpBuf++; - copyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) @@ -416,7 +416,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmiItem->_command[curCmd].lpszVarName == NULL) return NULL; - copyMemory(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); @@ -548,7 +548,7 @@ bool ParseMpc(const byte *lpBuf) { for (i = 0; i < GLOBALS._nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - copyMemory(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; @@ -590,7 +590,7 @@ bool ParseMpc(const byte *lpBuf) { lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); for (j = 0; lpBuf[j] != 0;) { - copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); + memcpy(lpTemp, &lpBuf[j + 1], lpBuf[j]); lpTemp += lpBuf[j]; *lpTemp ++= '\0'; j += lpBuf[j] + 1; diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index c5e752d390..3a68ecb559 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -124,15 +124,6 @@ void MemoryManager::unlockItem(HANDLE handle) { } -/****************************************************************************\ -* Stand-alone methods -\****************************************************************************/ - -void copyMemory(void *dst, const void *first, int size) { - Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); -} - - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 52d527544a..c7e4896cf9 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -70,9 +70,6 @@ public: #define GMEM_MOVEABLE 2 #define GMEM_ZEROINIT 4 -// Stand-alone methods -extern void copyMemory(void *dst, const void *first, int size); - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 20c28c5c93..76ca8a5db3 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -313,7 +313,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (clonemsg == NULL) return NULL; - copyMemory(clonemsg, origmsg, j); + memcpy(clonemsg, origmsg, j); globalUnlock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); return clonemsg; @@ -346,7 +346,7 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { if (clonemsg == NULL) return NULL; - copyMemory(clonemsg, origmsg, i); + memcpy(clonemsg, origmsg, i); globalUnlock(dialog->_periods[j]); @@ -546,7 +546,7 @@ static LPITEM getItemData(uint32 nOrdItem) { if (ret->_frames[i] == NULL) return NULL; - copyMemory(ret->_frames[i], dat, dim); + memcpy(ret->_frames[i], dat, dim); dat += dim; } @@ -906,7 +906,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - copyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + memcpy(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); @@ -995,12 +995,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - copyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); unlockItems(); /* We copy the action in #0 */ // _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; -// copyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); +// memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; /* We will create an action, and will provide the necessary details */ @@ -1298,7 +1298,7 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; - copyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ newitem->dwRes = i; @@ -1679,7 +1679,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1857,7 +1857,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1986,7 +1986,7 @@ bool mpalExecuteScript(int nScript) { if (s == NULL) return false; - copyMemory(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); + memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); unlockScripts(); // !!! New process management @@ -2095,7 +2095,7 @@ int mpalGetSaveStateSize() { void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); - copyMemory(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); } @@ -2114,7 +2114,7 @@ int mpalLoadState(byte *buf) { GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); lockVar(); - copyMemory((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); return GLOBALS._nVars * sizeof(MPALVAR) + 4; -- cgit v1.2.3 From 659436739f1e32297bdd8faac83b71e51d4a4937 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sat, 25 Aug 2012 12:56:02 +0200 Subject: TONY: Make the verb menu sound effects play At least for now, preloading utility sound effects *is* needed in ScummVM. And since we now have preloading of both normal and utility sound effects, I've unstubbed the unloading functions as well. --- engines/tony/tony.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 081556572a..ec2ee49ba2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -54,6 +54,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng SearchMan.addSubDirectoryMatching(gameDataDir, "Voices"); SearchMan.addSubDirectoryMatching(gameDataDir, "Roasted"); SearchMan.addSubDirectoryMatching(gameDataDir, "Music"); + SearchMan.addSubDirectoryMatching(gameDataDir, "Music/utilsfx"); // Set up load slot number _initialLoadSlotNumber = -1; @@ -355,15 +356,36 @@ FPSfx *TonyEngine::createSFX(Common::SeekableReadStream *stream) { } void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { - // No preloading is needed in ScummVM + if (_utilSfx[nChannel] != NULL) { + _utilSfx[nChannel]->stop(); + _utilSfx[nChannel]->release(); + _utilSfx[nChannel] = NULL; + } + + _theSound.createSfx(&_utilSfx[nChannel]); + + _utilSfx[nChannel]->loadFile(fn, FPCODEC_ADPCM); + _utilSfx[nChannel]->setVolume(63); } void TonyEngine::unloadAllSFX() { - // No preloading is needed in ScummVM + for (int i = 0; i < MAX_SFX_CHANNELS; i++) { + if (_sfx[i] != NULL) { + _sfx[i]->stop(); + _sfx[i]->release(); + _sfx[i] = NULL; + } + } } void TonyEngine::unloadAllUtilSFX() { - // No preloading is needed in ScummVM + for (int i = 0; i < MAX_SFX_CHANNELS; i++) { + if (_utilSfx[i] != NULL) { + _utilSfx[i]->stop(); + _utilSfx[i]->release(); + _utilSfx[i] = NULL; + } + } } void TonyEngine::initMusic() { -- cgit v1.2.3 From 8b0dca3862da10e87fe0fec237c694c48e12f83c Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 13:15:28 +0200 Subject: TONY: Fix Take/ReleaseOwnership. --- engines/tony/custom.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e082e5fcde..fcb304c623 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2052,25 +2052,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CORO_BEGIN_CONTEXT; - bool expired; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - // The event is operating as a mutex, so if the event is already set, wait until it's reset - do { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._mut[num], 0, &_ctx->expired); - } while (!_ctx->expired); - - // Set the event to flag ownership - CoroScheduler.setEvent(GLOBALS._mut[num]); - - CORO_END_CODE; + CoroScheduler.waitForSingleObject(coroParam, GLOBALS._mut[num], CORO_INFINITE); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.resetEvent(GLOBALS._mut[num]); + CoroScheduler.setEvent(GLOBALS._mut[num]); } /* @@ -2563,7 +2550,7 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation int i; for (i = 0; i < 10; i++) - GLOBALS._mut[i] = CoroScheduler.createEvent(false, false); + GLOBALS._mut[i] = CoroScheduler.createEvent(false, true); for (i = 0; i < 200; i++) GLOBALS._ambiance[i] = 0; -- cgit v1.2.3 From ca82454d74c27f496666a76ef2c96528375d8b92 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 14:08:35 +0200 Subject: TONY: Reset _hEndOfBuffer when restarting sounds. --- engines/tony/sound.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 87e142df48..8ea7aa03c3 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -261,9 +261,7 @@ bool FPSfx::play() { stop(); // sanity check if (_bFileLoaded) { - // FIXME - //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - // ResetEvent(hEndOfBuffer); + CoroScheduler.resetEvent(_hEndOfBuffer); _rewindableStream->rewind(); -- cgit v1.2.3 From 5cc63df5134834a49a44a929dd549dc924040793 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 14:42:14 +0200 Subject: TONY: Fix exiting from the save menu. We have to copy _nState before it gets reset in closeState. --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 9b1d85f827..321a4fa88d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1008,8 +1008,8 @@ void RMOptionScreen::changeState(CORO_PARAM, OptionScreenState newState) { CORO_BEGIN_CODE(_ctx); - closeState(); _nLastState = _nState; + closeState(); _nState = newState; CORO_INVOKE_0(initState); -- cgit v1.2.3 From 7cb29f1522095484e44d0529e73d3712f33fca92 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Aug 2012 23:33:46 +0200 Subject: TONY: Move font related arrays to a DAT file --- engines/tony/font.cpp | 1426 +------------------------------------------------ engines/tony/tony.cpp | 92 ++++ engines/tony/tony.h | 12 + 3 files changed, 113 insertions(+), 1417 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a3d253a52c..55e3b7627a 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -222,387 +222,10 @@ void RMFontDialog::init() { _lDefault = 13; _hDefault = 18; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - for (i = 0; i < 26; i++) - _cTable['A' + i] = i + 0; - - for (i = 0; i < 26; i++) - _cTable['a' + i] = i + 26; - - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 52; - - _cTable[';'] = 62; - _cTable[','] = 63; - _cTable['.'] = 64; - _cTable[':'] = 65; - _cTable['-'] = 66; - _cTable['_'] = 67; - _cTable['+'] = 68; - _cTable['<'] = 69; - _cTable['>'] = 70; - _cTable['!'] = 71; - //_cTable['!'] = 72; Exclamation countdown - _cTable['?'] = 73; - //_cTable['?'] = 74; Question down - _cTable['('] = 75; - _cTable[')'] = 76; - _cTable['\"'] = 77; - _cTable['^'] = 77; - _cTable['/'] = 78; - _cTable[(byte)''] = 79; - _cTable['$'] = 80; - _cTable['%'] = 81; - _cTable['&'] = 82; - _cTable['='] = 83; - _cTable[(byte)''] = 84; - _cTable[(byte)''] = 85; - _cTable[(byte)''] = 86; - _cTable[(byte)''] = 87; - _cTable[(byte)''] = 88; - _cTable[(byte)''] = 89; - _cTable[(byte)''] = 89; - _cTable[(byte)''] = 90; - _cTable[(byte)''] = 91; - _cTable[(byte)''] = 92; - _cTable[(byte)''] = 93; - _cTable[(byte)''] = 94; - _cTable[(byte)''] = 95; - _cTable[(byte)''] = 96; - _cTable[(byte)''] = 97; - _cTable[(byte)''] = 98; - _cTable[(byte)''] = 99; - //_cTable[' '] = 100; e circlet - //_cTable[' '] = 101; i circlet - //_cTable[' '] = 102; o circlet - //_cTable[' '] = 103; u circlet - _cTable[(byte)''] = 104; - _cTable[(byte)''] = 105; - _cTable[(byte)''] = 106; - _cTable[(byte)''] = 107; - _cTable[(byte)''] = 108; - _cTable[(byte)''] = 109; - //_cTable[''] = 110; integral - _cTable['\''] = 111; - - // Little lengths - _lTable[' '] = 9; - _lTable['\''] = 5; - _lTable['.'] = 5; - _lTable[','] = 5; - _lTable[':'] = 5; - _lTable[';'] = 5; - _lTable['!'] = 5; - _lTable['?'] = 10; - _lTable['\"'] = 5; - _lTable['^'] = 5; - _lTable['('] = 7; - _lTable[')'] = 7; - - _lTable['4'] = 10; - - _lTable['a'] = 14; - _lTable['b'] = 15; - _lTable['c'] = 12; - _lTable['e'] = 12; - _lTable['i'] = 6; - _lTable[''] = 6; - _lTable['l'] = 5; - _lTable['m'] = 16; - _lTable['n'] = 12; - _lTable['o'] = 11; - _lTable['p'] = 11; - _lTable['s'] = 12; - _lTable['u'] = 12; - - _lTable['E'] = 10; - _lTable['F'] = 11; - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - _cTable[(byte)''] = 112; - _cTable[(byte)''] = 113; - _cTable[(byte)''] = 114; - _cTable[(byte)''] = 115; - _cTable[(byte)''] = 116; - _cTable[(byte)''] = 117; - _cTable[(byte)''] = 118; - _cTable[(byte)''] = 119; - _cTable[(byte)''] = 120; - _cTable[(byte)''] = 121; - _cTable[(byte)''] = 122; - _cTable[(byte)''] = 123; - _cTable[(byte)''] = 124; - _cTable[(byte)''] = 125; - _cTable[(byte)''] = 126; - _cTable[(byte)''] = 127; - _cTable[(byte)''] = 128; - _cTable[(byte)''] = 129; - - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - - _cTable[(byte)''] = 130; - _cTable[(byte)''] = 131; - _cTable[(byte)''] = 132; - _cTable[(byte)''] = 133; - _cTable[(byte)''] = 134; - _cTable[(byte)''] = 135; - _cTable[(byte)''] = 136; - _cTable[(byte)''] = 137; - _cTable[(byte)''] = 138; - _cTable[(byte)''] = 139; - _cTable[(byte)''] = 140; - _cTable[(byte)''] = 141; - _cTable[(byte)''] = 142; - _cTable[(byte)''] = 143; - _cTable[(byte)''] = 144; - _cTable[(byte)''] = 145; - _cTable[(byte)''] = 146; - _cTable[(byte)''] = 147; - _cTable[(byte)''] = 148; - _cTable[(byte)''] = 149; - _cTable[(byte)''] = 150; - _cTable[(byte)''] = 151; - _cTable[(byte)''] = 152; - _cTable[(byte)''] = 153; - _cTable[(byte)''] = 154; - _cTable[(byte)''] = 155; - _cTable[(byte)''] = 156; - _cTable[(byte)''] = 157; - _cTable[(byte)''] = 158; - _cTable[(byte)''] = 159; - _cTable[(byte)''] = 160; - _cTable[(byte)''] = 161; - _cTable[(byte)''] = 162; - - _cTable[(byte)''] = 163; - _cTable[(byte)''] = 164; - _cTable[(byte)''] = 165; - _cTable[(byte)''] = 166; - _cTable[(byte)''] = 167; - _cTable[(byte)''] = 168; - _cTable[(byte)''] = 169; - _cTable[(byte)''] = 170; - _cTable[(byte)''] = 171; - _cTable[(byte)''] = 172; - _cTable[(byte)''] = 173; - _cTable[(byte)''] = 174; - _cTable[(byte)''] = 175; - _cTable[(byte)''] = 176; - _cTable[(byte)''] = 177; - _cTable[(byte)''] = 178; - _cTable[(byte)''] = 179; - _cTable[(byte)''] = 180; - _cTable[(byte)''] = 181; - _cTable[(byte)''] = 182; - _cTable[(byte)''] = 183; - _cTable[(byte)''] = 184; - _cTable[(byte)''] = 185; - _cTable[(byte)''] = 186; - _cTable[(byte)''] = 187; - _cTable[(byte)''] = 188; - _cTable[(byte)''] = 189; - _cTable[(byte)''] = 190; - _cTable[(byte)''] = 191; - _cTable[(byte)''] = 192; - _cTable[(byte)''] = 193; - _cTable[(byte)''] = 194; - _cTable[(byte)''] = 195; - - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 17; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 19; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 8; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 14; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // Czech - _cTable[(byte)''] = 196; - _cTable[(byte)''] = 197; - _cTable[(byte)''] = 198; - _cTable[(byte)''] = 199; - _cTable[(byte)''] = 200; - _cTable[(byte)''] = 201; - _cTable[(byte)''] = 202; - _cTable[(byte)''] = 203; - _cTable[(byte)''] = 204; - _cTable[(byte)''] = 205; - _cTable[(byte)''] = 206; - _cTable[(byte)''] = 207; - _cTable[(byte)''] = 208; - _cTable[(byte)''] = 209; - _cTable[(byte)''] = 210; - - _cTable[(byte)''] = 211; - _cTable[(byte)''] = 212; - _cTable[(byte)''] = 213; - _cTable[(byte)''] = 214; - _cTable[(byte)''] = 215; - _cTable[(byte)''] = 216; - _cTable[(byte)''] = 217; - _cTable[(byte)''] = 218; - _cTable[(byte)''] = 219; - _cTable[(byte)''] = 220; - _cTable[(byte)''] = 221; - _cTable[(byte)''] = 222; - _cTable[(byte)''] = 223; - _cTable[(byte)''] = 224; - _cTable[(byte)''] = 225; - - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 19; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 7; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 17; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - _cTable[(byte)''] = 226; - _cTable[(byte)''] = 227; - _cTable[(byte)''] = 228; - _cTable[(byte)''] = 229; - _cTable[(byte)''] = 230; - _cTable[(byte)''] = 231; - _cTable[(byte)''] = 232; - _cTable[(byte)''] = 233; - - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - _cTable[(byte)''] = 234; - // 'SS' = 235 - _cTable[(byte)''] = 236; - _cTable[(byte)''] = 237; - _cTable[(byte)''] = 238; - - _lTable[(byte)''] = 15; + for (i = 0; i < 256; i++) { + _cTable[i] = g_vm->_cTableDialog[i]; + _lTable[i] = g_vm->_lTableDialog[i]; } } @@ -632,342 +255,8 @@ void RMFontMacc::init() { Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - - for (i = 0; i < 26; i++) - _cTable['A' + i] = i + 0; - - for (i = 0; i < 26; i++) - _cTable['a' + i] = i + 26; - - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 52; - - _cTable['!'] = 62; - //_cTable['!'] = 63; // ! rovescia - _cTable['\"'] = 64; - _cTable['$'] = 65; - _cTable['%'] = 66; - _cTable['&'] = 67; - _cTable['/'] = 68; - _cTable['('] = 69; - _cTable[')'] = 70; - _cTable['='] = 71; - _cTable['?'] = 72; - //_cTable['?'] = 73; // ? rovescia - _cTable['*'] = 74; - _cTable['+'] = 75; - _cTable[(byte)''] = 76; - _cTable[';'] = 77; - _cTable[','] = 78; - _cTable['.'] = 79; - _cTable[':'] = 80; - _cTable['-'] = 81; - _cTable['<'] = 82; - _cTable['>'] = 83; - _cTable['/'] = 84; - _cTable[(byte)''] = 85; - _cTable[(byte)''] = 86; - _cTable[(byte)''] = 87; - _cTable[(byte)''] = 88; - _cTable[(byte)''] = 89; - _cTable[(byte)''] = 90; - //_cTable[(byte)''] = 91; // e with ball - _cTable[(byte)''] = 92; - _cTable[(byte)''] = 93; - //_cTable[(byte)''] = 94; // i with ball - _cTable[(byte)''] = 95; - _cTable[(byte)''] = 96; - //_cTable[(byte)''] = 97; // o with ball - _cTable[(byte)''] = 98; - _cTable[(byte)''] = 99; - //_cTable[(byte)''] = 100; // u with ball - _cTable[(byte)''] = 101; - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - _cTable[(byte)''] = 102; - _cTable[(byte)''] = 103; - _cTable[(byte)''] = 104; - _cTable[(byte)''] = 105; - _cTable[(byte)''] = 106; - _cTable[(byte)''] = 107; - _cTable[(byte)''] = 108; - _cTable[(byte)''] = 109; - _cTable[(byte)''] = 110; - _cTable[(byte)''] = 111; - _cTable[(byte)''] = 112; - _cTable[(byte)''] = 113; - _cTable[(byte)''] = 114; - _cTable[(byte)''] = 115; - _cTable[(byte)''] = 116; - _cTable[(byte)''] = 117; - _cTable[(byte)''] = 118; - _cTable[(byte)''] = 119; - - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - _cTable[(byte)''] = 120; - _cTable[(byte)''] = 121; - _cTable[(byte)''] = 122; - _cTable[(byte)''] = 123; - _cTable[(byte)''] = 124; - _cTable[(byte)''] = 125; - _cTable[(byte)''] = 126; - _cTable[(byte)''] = 127; - _cTable[(byte)''] = 128; - _cTable[(byte)''] = 129; - _cTable[(byte)''] = 130; - _cTable[(byte)''] = 131; - _cTable[(byte)''] = 132; - _cTable[(byte)''] = 133; - _cTable[(byte)''] = 134; - _cTable[(byte)''] = 135; - _cTable[(byte)''] = 136; - _cTable[(byte)''] = 137; - _cTable[(byte)''] = 138; - _cTable[(byte)''] = 139; - _cTable[(byte)''] = 140; - _cTable[(byte)''] = 141; - _cTable[(byte)''] = 142; - _cTable[(byte)''] = 143; - _cTable[(byte)''] = 144; - _cTable[(byte)''] = 145; - _cTable[(byte)''] = 146; - _cTable[(byte)''] = 147; - _cTable[(byte)''] = 148; - _cTable[(byte)''] = 149; - _cTable[(byte)''] = 150; - _cTable[(byte)''] = 151; - _cTable[(byte)''] = 152; - - _cTable[(byte)''] = 153; - _cTable[(byte)''] = 154; - _cTable[(byte)''] = 155; - _cTable[(byte)''] = 156; - _cTable[(byte)''] = 157; - _cTable[(byte)''] = 158; - _cTable[(byte)''] = 159; - _cTable[(byte)''] = 160; - _cTable[(byte)''] = 161; - _cTable[(byte)''] = 162; - _cTable[(byte)''] = 163; - _cTable[(byte)''] = 164; - _cTable[(byte)''] = 165; - _cTable[(byte)''] = 166; - _cTable[(byte)''] = 167; - _cTable[(byte)''] = 168; - _cTable[(byte)''] = 169; - _cTable[(byte)''] = 170; - _cTable[(byte)''] = 171; - _cTable[(byte)''] = 172; - _cTable[(byte)''] = 173; - _cTable[(byte)''] = 174; - _cTable[(byte)''] = 175; - _cTable[(byte)''] = 176; - _cTable[(byte)''] = 177; - _cTable[(byte)''] = 178; - _cTable[(byte)''] = 179; - _cTable[(byte)''] = 180; - _cTable[(byte)''] = 181; - _cTable[(byte)''] = 182; - _cTable[(byte)''] = 183; - _cTable[(byte)''] = 184; - _cTable[(byte)''] = 185; - - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 8; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // Czech - - _cTable[(byte)''] = 186; - _cTable[(byte)''] = 187; - _cTable[(byte)''] = 188; - _cTable[(byte)''] = 189; - _cTable[(byte)''] = 190; - _cTable[(byte)''] = 191; - _cTable[(byte)''] = 192; - _cTable[(byte)''] = 193; - _cTable[(byte)''] = 194; - _cTable[(byte)''] = 195; - _cTable[(byte)''] = 196; - _cTable[(byte)''] = 197; - _cTable[(byte)''] = 198; - _cTable[(byte)''] = 199; - _cTable[(byte)''] = 200; - - _cTable[(byte)''] = 201; - _cTable[(byte)''] = 202; - _cTable[(byte)''] = 203; - _cTable[(byte)''] = 204; - _cTable[(byte)''] = 205; - _cTable[(byte)''] = 206; - _cTable[(byte)''] = 207; - _cTable[(byte)''] = 208; - _cTable[(byte)''] = 209; - _cTable[(byte)''] = 210; - _cTable[(byte)''] = 211; - _cTable[(byte)''] = 212; - _cTable[(byte)''] = 213; - _cTable[(byte)''] = 214; - _cTable[(byte)''] = 215; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - _cTable[(byte)''] = 226; - _cTable[(byte)''] = 227; - _cTable[(byte)''] = 228; - _cTable[(byte)''] = 229; - _cTable[(byte)''] = 230; - _cTable[(byte)''] = 231; - _cTable[(byte)''] = 232; - _cTable[(byte)''] = 233; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 8; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - // German - - _cTable[(byte)''] = 234; - // 'SS' = 235 - _cTable[(byte)''] = 236; - _cTable[(byte)''] = 237; - _cTable[(byte)''] = 238; - - _lTable[(byte)''] = 11; + _cTable[i] = g_vm->_cTableMacc[i]; + _lTable[i] = g_vm->_lTableMacc[i]; } } @@ -996,430 +285,8 @@ void RMFontCredits::init() { Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - - for (i = 0; i < 26; i++) - _cTable['A' + i] = i + 0; - - for (i = 0; i < 26; i++) - _cTable['a' + i] = i + 26; - - - - _cTable[(byte)''] = 52; - _cTable[(byte)''] = 53; -// _cTable[''] = 54; // a ^ -// _cTable[''] = 55; // a pallini - _cTable[(byte)''] = 56; - _cTable[(byte)''] = 57; -// _cTable[''] = 58; // e ^ -// _cTable[''] = 59; // e pallini - _cTable[(byte)''] = 60; - _cTable[(byte)''] = 61; -// _cTable[''] = 62; // i ^ -// _cTable[''] = 63; // i pallini - _cTable[(byte)''] = 64; - _cTable[(byte)''] = 65; -// _cTable[''] = 66; // o ^ -// _cTable[''] = 67; // o pallini - _cTable[(byte)''] = 68; - _cTable[(byte)''] = 69; -// _cTable[''] = 70; // u ^ -// _cTable[''] = 71; // u pallini -// _cTable[''] = 72; // y pallini - _cTable[(byte)''] = 73; - _cTable[(byte)''] = 74; -// _cTable[''] = 75; // o barrato -// _cTable[''] = 76; // ac - _cTable[(byte)''] = 77; -// _cTable[''] = 78; // ? rovesciato - _cTable['?'] = 79; -// _cTable[''] = 80; // ! rovesciato - _cTable['!'] = 81; -// _cTable[''] = 82; // 1/2 -// _cTable[''] = 83; // 1/4 - _cTable['('] = 84; - _cTable[')'] = 85; - _cTable[(byte)''] = 86; - _cTable[(byte)''] = 87; -// _cTable[''] = 88; // AE - _cTable[':'] = 89; - _cTable['%'] = 90; - _cTable['&'] = 91; - _cTable['/'] = 92; - _cTable['+'] = 93; - _cTable[';'] = 94; - _cTable[','] = 95; - _cTable['^'] = 96; - _cTable['='] = 97; - _cTable['_'] = 98; - _cTable['*'] = 99; - _cTable['.'] = 100; - - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 101; - _cTable['\''] = 111; - - _lTable[' '] = 11; - _lTable[(byte)''] = _lTable['A'] = 19; - _lTable['B'] = 15; - _lTable['C'] = 14; - _lTable['D'] = 13; - _lTable['E'] = 14; - _lTable['F'] = 13; - _lTable['G'] = 16; - _lTable['H'] = 15; - _lTable['I'] = 5; - _lTable['J'] = 8; - _lTable['K'] = 15; - _lTable['L'] = 13; - _lTable['M'] = 17; - _lTable['N'] = 15; - _lTable[''] = _lTable['O'] = 14; - _lTable['P'] = 12; - _lTable['Q'] = 14; - _lTable['R'] = 14; - _lTable['S'] = 15; - _lTable['T'] = 11; - _lTable[''] = _lTable['U'] = 12; - _lTable['V'] = 12; - _lTable['W'] = 16; - _lTable['X'] = 12; - _lTable['Y'] = 13; - _lTable['Z'] = 14; - - _lTable['a'] = 11; - _lTable['b'] = 9; - _lTable['c'] = 9; - _lTable['d'] = 10; - _lTable['e'] = 9; - _lTable['f'] = 8; - _lTable['g'] = 9; - _lTable['h'] = 10; - _lTable['i'] = 5; - _lTable['j'] = 6; - _lTable['k'] = 12; - _lTable['l'] = 6; - _lTable['m'] = 14; - _lTable['n'] = 10; - _lTable['o'] = 11; - _lTable['p'] = 11; - _lTable['q'] = 9; - _lTable['r'] = 9; - _lTable['s'] = 9; - _lTable['t'] = 6; - _lTable['u'] = 9; - _lTable['v'] = 10; - _lTable['w'] = 14; - _lTable['x'] = 9; - _lTable['y'] = 10; - _lTable['z'] = 9; - - _lTable['0'] = 12; - _lTable['1'] = 8; - _lTable['2'] = 10; - _lTable['3'] = 11; - _lTable['4'] = 12; - _lTable['5'] = 11; - _lTable['6'] = 12; - _lTable['7'] = 10; - _lTable['8'] = 11; - _lTable['9'] = 10; - - _lTable['/'] = 10; - _lTable['^'] = 9; - _lTable[','] = 5; - _lTable['.'] = 5; - _lTable[';'] = 5; - _lTable[':'] = 5; - _lTable['\''] = 5; - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - _cTable[(byte)''] = 112; - _cTable[(byte)''] = 113; - _cTable[(byte)''] = 114; - _cTable[(byte)''] = 115; - _cTable[(byte)''] = 116; - _cTable[(byte)''] = 117; - _cTable[(byte)''] = 118; - _cTable[(byte)''] = 119; - _cTable[(byte)''] = 120; - _cTable[(byte)''] = 121; - _cTable[(byte)''] = 122; - _cTable[(byte)''] = 123; - _cTable[(byte)''] = 124; - _cTable[(byte)''] = 125; - _cTable[(byte)''] = 126; - _cTable[(byte)''] = 127; - _cTable[(byte)''] = 128; - _cTable[(byte)''] = 129; - - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - _cTable[(byte)''] = 130; - _cTable[(byte)''] = 131; - _cTable[(byte)''] = 132; - _cTable[(byte)''] = 133; - _cTable[(byte)''] = 134; - _cTable[(byte)''] = 135; - _cTable[(byte)''] = 136; - _cTable[(byte)''] = 137; - _cTable[(byte)''] = 138; - _cTable[(byte)''] = 139; - _cTable[(byte)''] = 140; - _cTable[(byte)''] = 141; - _cTable[(byte)''] = 142; - _cTable[(byte)''] = 143; - _cTable[(byte)''] = 144; - _cTable[(byte)''] = 145; - _cTable[(byte)''] = 146; - _cTable[(byte)''] = 147; - _cTable[(byte)''] = 148; - _cTable[(byte)''] = 149; - _cTable[(byte)''] = 150; - _cTable[(byte)''] = 151; - _cTable[(byte)''] = 152; - _cTable[(byte)''] = 153; - _cTable[(byte)''] = 154; - _cTable[(byte)''] = 155; - _cTable[(byte)''] = 156; - _cTable[(byte)''] = 157; - _cTable[(byte)''] = 158; - _cTable[(byte)''] = 159; - _cTable[(byte)''] = 160; - _cTable[(byte)''] = 161; - _cTable[(byte)''] = 162; - - _cTable[(byte)''] = 163; - _cTable[(byte)''] = 164; - _cTable[(byte)''] = 165; - _cTable[(byte)''] = 166; - _cTable[(byte)''] = 167; - _cTable[(byte)''] = 168; - _cTable[(byte)''] = 169; - _cTable[(byte)''] = 170; - _cTable[(byte)''] = 171; - _cTable[(byte)''] = 172; - _cTable[(byte)''] = 173; - _cTable[(byte)''] = 174; - _cTable[(byte)''] = 175; - _cTable[(byte)''] = 176; - _cTable[(byte)''] = 177; - _cTable[(byte)''] = 178; - _cTable[(byte)''] = 179; - _cTable[(byte)''] = 180; - _cTable[(byte)''] = 181; - _cTable[(byte)''] = 182; - _cTable[(byte)''] = 183; - _cTable[(byte)''] = 184; - _cTable[(byte)''] = 185; - _cTable[(byte)''] = 186; - _cTable[(byte)''] = 187; - _cTable[(byte)''] = 188; - _cTable[(byte)''] = 189; - _cTable[(byte)''] = 190; - _cTable[(byte)''] = 191; - _cTable[(byte)''] = 192; - _cTable[(byte)''] = 193; - _cTable[(byte)''] = 194; - _cTable[(byte)''] = 195; - - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 22; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 22; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 23; - _lTable[(byte)''] = 23; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 15; - - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // CZECH Language - - _cTable[(byte)''] = 196; - _cTable[(byte)''] = 197; - _cTable[(byte)''] = 198; - _cTable[(byte)''] = 199; - _cTable[(byte)''] = 200; - _cTable[(byte)''] = 201; - _cTable[(byte)''] = 202; - _cTable[(byte)''] = 203; - _cTable[(byte)''] = 204; - _cTable[(byte)''] = 205; - _cTable[(byte)''] = 206; - _cTable[(byte)''] = 207; - _cTable[(byte)''] = 208; - _cTable[(byte)''] = 209; - _cTable[(byte)''] = 210; - - _cTable[(byte)''] = 211; - _cTable[(byte)''] = 212; - _cTable[(byte)''] = 213; - _cTable[(byte)''] = 214; - _cTable[(byte)''] = 215; - _cTable[(byte)''] = 216; - _cTable[(byte)''] = 217; - _cTable[(byte)''] = 218; - _cTable[(byte)''] = 219; - _cTable[(byte)''] = 220; - _cTable[(byte)''] = 221; - _cTable[(byte)''] = 222; - _cTable[(byte)''] = 223; - _cTable[(byte)''] = 224; - _cTable[(byte)''] = 225; - - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 7; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 19; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 6; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - _cTable[(byte)''] = 226; - _cTable[(byte)''] = 227; - _cTable[(byte)''] = 228; - _cTable[(byte)''] = 229; - _cTable[(byte)''] = 230; - _cTable[(byte)''] = 231; - _cTable[(byte)''] = 232; - _cTable[(byte)''] = 233; - - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 6; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - // German - - _cTable[(byte)''] = 234; - // 'SS' = 235 - - // old chars overrides - _cTable[(byte)''] = _cTable[(byte)''] = 55; - _cTable[(byte)''] = _cTable[(byte)''] = 67; - _cTable[(byte)''] = _cTable[(byte)''] = 71; - - _lTable[(byte)''] = 11; + _cTable[i] = g_vm->_cTableCred[i]; + _lTable[i] = g_vm->_lTableCred[i]; } } @@ -1461,112 +328,10 @@ void RMFontObj::init() { Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - - for (i = 0; i < 26; i++) { - _cTable['A' + i] = i + 0; - _cTable['a' + i] = i + 0; + _cTable[i] = g_vm->_cTableObj[i]; + _lTable[i] = g_vm->_lTableObj[i]; } - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 26; - - _cTable[','] = 36; - _cTable[';'] = 37; - _cTable['.'] = 38; - _cTable[':'] = 39; - _cTable['-'] = 40; - _cTable['+'] = 41; - _cTable['!'] = 42; - // _cTable['!'] = 43; Exclamation countdown - _cTable['?'] = 44; - // _cTable['?'] = 45; Interrogativo alla rovescia - _cTable['/'] = 46; - _cTable['('] = 47; - _cTable[')'] = 48; - _cTable['='] = 49; - _cTable['\''] = 50; - _cTable['\"'] = 51; - _cTable[(byte)''] = 52; - _cTable[(byte)'$'] = 53; - _cTable[(byte)'%'] = 54; - _cTable[(byte)'&'] = 55; - _cTable[(byte)'^'] = 56; - _cTable[(byte)'*'] = 57; - _cTable[(byte)'<'] = 58; - _cTable[(byte)'>'] = 59; - _cTable[(byte)''] = 60; - _cTable[(byte)''] = 61; - _cTable[(byte)''] = 62; - _cTable[(byte)''] = 63; - //_cTable[(byte)''] = 64; integral - _cTable[(byte)''] = 65; - _cTable[(byte)''] = 66; - _cTable[(byte)''] = 67; - _cTable[(byte)''] = 68; - _cTable[(byte)''] = 69; - _cTable[(byte)''] = _cTable[(byte)''] = 70; - _cTable[(byte)''] = 71; - _cTable[(byte)''] = 72; - _cTable[(byte)''] = 73; - //_cTable[(byte)' '] = 74; e circlet - _cTable[(byte)''] = 75; - _cTable[(byte)''] = 76; - //_cTable[(byte)' '] = 77; i circlet - _cTable[(byte)''] = 78; - _cTable[(byte)''] = _cTable[(byte)''] = 79; - //_cTable[(byte)' '] = 80; o circlet - _cTable[(byte)''] = 81; - _cTable[(byte)''] = _cTable[(byte)''] = 82; - //_cTable[' '] = 83; u circlet - //_cTable[' '] = 84; y dieresi - - /* Little lengths */ - _lTable[' '] = 11; - _lTable['.'] = 8; - _lTable['-'] = 12; - _lTable['\''] = 8; - _lTable['0'] = 20; - _lTable['1'] = 20; - _lTable['2'] = 15; - _lTable['3'] = 20; - _lTable['4'] = 20; - _lTable['5'] = 20; - _lTable['6'] = 20; - _lTable['7'] = 20; - _lTable['8'] = 20; - _lTable['9'] = 20; - - - _lTable['a'] = _lTable['A'] = _lTable[''] = _lTable[''] = 17; - _lTable['b'] = _lTable['B'] = 17; - _lTable['c'] = _lTable['C'] = 19; - _lTable['d'] = _lTable['D'] = 17; - _lTable['e'] = _lTable['E'] = 15; - _lTable['f'] = _lTable['F'] = 17; - _lTable['g'] = _lTable['G'] = 19; - _lTable['i'] = _lTable['I'] = 16; - _lTable['h'] = _lTable['H'] = 17; - _lTable['k'] = _lTable['K'] = 17; - _lTable['l'] = _lTable['L'] = 14; - _lTable['m'] = _lTable['M'] = 19; - _lTable['n'] = _lTable['N'] = 17; - _lTable['o'] = _lTable['O'] = _lTable[''] = _lTable[''] = 19; - _lTable['p'] = _lTable['P'] = 17; - _lTable['q'] = _lTable['Q'] = 19; - _lTable['r'] = _lTable['R'] = 14; - _lTable['s'] = _lTable['S'] = 13; - _lTable['t'] = _lTable['T'] = 15; - _lTable['u'] = _lTable['U'] = _lTable[''] = _lTable[''] = 15; - _lTable['v'] = _lTable['V'] = 13; - _lTable['x'] = _lTable['X'] = 15; - _lTable['y'] = _lTable['Y'] = 13; - _lTable['w'] = _lTable['W'] = 19; - _lTable['z'] = _lTable['Z'] = 20; - _lTable[(byte)''] = 17; - /* Casi particolari */ setBothCase('C', 'C', 2); setBothCase('A', 'T', -2); @@ -1579,179 +344,6 @@ void RMFontObj::init() { setBothCase('Z', 'A', -1); setBothCase('R', 'R', 1); setBothCase('R', 'U', 3); - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //ス謎戊3剔囀 - //AaCcEeLlNnOoSsZzZz - _cTable[(byte)''] = _cTable[(byte)''] = 85; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - - _cTable[(byte)''] = _cTable[(byte)''] = 86; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - - _cTable[(byte)''] = _cTable[(byte)''] = 87; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - - _cTable[(byte)''] = _cTable[(byte)''] = 88; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - - _cTable[(byte)''] = _cTable[(byte)''] = 89; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - - _cTable[(byte)''] = _cTable[(byte)''] = 90; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - - _cTable[(byte)''] = _cTable[(byte)''] = 91; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - - _cTable[(byte)''] = _cTable[(byte)''] = 92; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - - _cTable[(byte)''] = _cTable[(byte)''] = 93; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - - _cTable[(byte)''] = _cTable[(byte)''] = 85; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - - _cTable[(byte)''] = _cTable[(byte)''] = 94; - _cTable[(byte)''] = _cTable[(byte)''] = 95; - _cTable[(byte)''] = _cTable[(byte)''] = 96; - _cTable[(byte)''] = _cTable[(byte)''] = 97; - _cTable[(byte)''] = _cTable[(byte)''] = 98; - _cTable[(byte)''] = _cTable[(byte)''] = 99; - _cTable[(byte)''] = _cTable[(byte)''] = 100; - _cTable[(byte)''] = _cTable[(byte)''] = 101; - _cTable[(byte)''] = _cTable[(byte)''] = 102; - _cTable[(byte)''] = _cTable[(byte)''] = 103; - _cTable[(byte)''] = _cTable[(byte)''] = 104; - _cTable[(byte)''] = _cTable[(byte)''] = 105; - _cTable[(byte)''] = _cTable[(byte)''] = 106; - _cTable[(byte)''] = _cTable[(byte)''] = 107; - _cTable[(byte)''] = _cTable[(byte)''] = 108; - _cTable[(byte)''] = _cTable[(byte)''] = 109; - _cTable[(byte)''] = _cTable[(byte)''] = 110; - _cTable[(byte)''] = _cTable[(byte)''] = 111; - _cTable[(byte)''] = _cTable[(byte)''] = 112; - _cTable[(byte)''] = _cTable[(byte)''] = 113; - _cTable[(byte)''] = _cTable[(byte)''] = 114; - _cTable[(byte)''] = _cTable[(byte)''] = 115; - _cTable[(byte)''] = _cTable[(byte)''] = 116; - _cTable[(byte)''] = _cTable[(byte)''] = 117; - _cTable[(byte)''] = _cTable[(byte)''] = 118; - _cTable[(byte)''] = _cTable[(byte)''] = 119; - _cTable[(byte)''] = _cTable[(byte)''] = 120; - _cTable[(byte)''] = _cTable[(byte)''] = 121; - _cTable[(byte)''] = _cTable[(byte)''] = 122; - _cTable[(byte)''] = _cTable[(byte)''] = 123; - _cTable[(byte)''] = _cTable[(byte)''] = 124; - _cTable[(byte)''] = _cTable[(byte)''] = 125; - _cTable[(byte)''] = _cTable[(byte)''] = 126; - - - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // Czech - - _cTable[(byte)''] = _cTable[(byte)''] = 127; - _cTable[(byte)''] = _cTable[(byte)''] = 128; - _cTable[(byte)''] = _cTable[(byte)''] = 129; - _cTable[(byte)''] = _cTable[(byte)''] = 130; - _cTable[(byte)''] = _cTable[(byte)''] = 131; - _cTable[(byte)''] = _cTable[(byte)''] = 132; - _cTable[(byte)''] = _cTable[(byte)''] = 133; - _cTable[(byte)''] = _cTable[(byte)''] = 134; - _cTable[(byte)''] = _cTable[(byte)''] = 135; - _cTable[(byte)''] = _cTable[(byte)''] = 136; - _cTable[(byte)''] = _cTable[(byte)''] = 137; - _cTable[(byte)''] = _cTable[(byte)''] = 138; - _cTable[(byte)''] = _cTable[(byte)''] = 139; - _cTable[(byte)''] = _cTable[(byte)''] = 140; - _cTable[(byte)''] = _cTable[(byte)''] = 141; - - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 23; - _lTable[(byte)''] = _lTable[(byte)''] = 24; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - // Translate accented characters as normal letters - - _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 0; // a - _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 17; - - _cTable[(byte)''] = _cTable[(byte)''] = 4; // e - _lTable[(byte)''] = _lTable[(byte)''] = 15; - - _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 8; // i - _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 16; - - _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 14; // o - _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 19; - - _cTable[(byte)''] = _cTable[(byte)''] = 20; // u - _lTable[(byte)''] = _lTable[(byte)''] = 15; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - // German - - _cTable[''] = 142; - // SS = 143 - - _lTable[''] = 24; - } } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ec2ee49ba2..9124bed50d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -111,6 +111,10 @@ Common::Error TonyEngine::run() { * Initialize the game */ Common::ErrorCode TonyEngine::init() { + // Load DAT file (used by font manager) + if (!loadTonyDat()) + return Common::kUnknownError; + if (isCompressed()) { Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab"); if (!stream) @@ -177,6 +181,94 @@ Common::ErrorCode TonyEngine::init() { return Common::kNoError; } +bool TonyEngine::loadTonyDat() { + Common::String msg; + Common::File in; + + in.open("tony.dat"); + + if (!in.isOpen()) { + msg = "You're missing the 'tony.dat' file. Get it from the ScummVM website"; + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + return false; + } + + // Read header + char buf[4+1]; + in.read(buf, 4); + buf[4] = '\0'; + + if (strcmp(buf, "TONY")) { + msg = "File 'tony.dat' is corrupt. Get it from the ScummVM website"; + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + return false; + } + + int majVer = in.readByte(); + int minVer = in.readByte(); + + if ((majVer != TONY_DAT_VER_MAJ) || (minVer != TONY_DAT_VER_MIN)) { + msg = Common::String::format("File 'tony.dat' is wrong version. Expected %d.%d but got %d.%d. Get it from the ScummVM website", TONY_DAT_VER_MAJ, TONY_DAT_VER_MIN, majVer, minVer); + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + + return false; + } + + int expectedLangVariant = -1; + switch (g_vm->getLanguage()) { + case Common::IT_ITA: + expectedLangVariant = 0; + break; + case Common::PL_POL: + expectedLangVariant = 1; + break; + case Common::RU_RUS: + expectedLangVariant = 2; + break; + case Common::CZ_CZE: + expectedLangVariant = 3; + break; + case Common::FR_FRA: + expectedLangVariant = 4; + break; + case Common::DE_DEU: + expectedLangVariant = 5; + break; + default: + msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + + return false; + } + + int numVariant = in.readUint16BE(); + if (expectedLangVariant > numVariant) { + msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + + return false; + } + + in.seek(in.pos() + (2 * 256 * 8 * expectedLangVariant)); + for (int i = 0; i < 256; i++) { + _cTableDialog[i] = in.readSint16BE(); + _lTableDialog[i] = in.readSint16BE(); + _cTableMacc[i] = in.readSint16BE(); + _lTableMacc[i] = in.readSint16BE(); + _cTableCred[i] = in.readSint16BE(); + _lTableCred[i] = in.readSint16BE(); + _cTableObj[i] = in.readSint16BE(); + _lTableObj[i] = in.readSint16BE(); + } + + return true; +} + void TonyEngine::initCustomFunctionMap() { INIT_CUSTOM_FUNCTION(_funcList, _funcListStrings); } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 18cddf3f2a..f8358b15a7 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -70,6 +70,8 @@ enum { struct TonyGameDescription; #define MAX_SFX_CHANNELS 32 +#define TONY_DAT_VER_MAJ 0 +#define TONY_DAT_VER_MIN 1 struct VoiceHeader { int _offset; @@ -81,6 +83,7 @@ struct VoiceHeader { class TonyEngine : public Engine { private: Common::ErrorCode init(); + bool loadTonyDat(); void initMusic(); void closeMusic(); bool openVoiceDatabase(); @@ -106,6 +109,15 @@ public: Globals _globals; Debugger *_debugger; + int16 _cTableDialog[256]; + int16 _lTableDialog[256]; + int16 _cTableMacc[256]; + int16 _lTableMacc[256]; + int16 _cTableCred[256]; + int16 _lTableCred[256]; + int16 _cTableObj[256]; + int16 _lTableObj[256]; + enum DataDir { DD_BASE = 1, DD_SAVE, -- cgit v1.2.3 From 2ce6576515dee78a4377352130f407c199e4dc05 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Aug 2012 23:58:06 +0200 Subject: TONY: Add English in loadTonyDat --- engines/tony/tony.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9124bed50d..3a89caf055 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -220,6 +220,7 @@ bool TonyEngine::loadTonyDat() { int expectedLangVariant = -1; switch (g_vm->getLanguage()) { case Common::IT_ITA: + case Common::EN_ANY: expectedLangVariant = 0; break; case Common::PL_POL: -- cgit v1.2.3 From 72604fa3a67938d0126cf7c7331363ae29018222 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Aug 2012 00:17:28 +0200 Subject: TONY: USe default fonts (Italian/English) when the language is unhandled instead of erroring out --- engines/tony/tony.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 3a89caf055..bb174dfbb1 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -239,11 +239,9 @@ bool TonyEngine::loadTonyDat() { expectedLangVariant = 5; break; default: - msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); - GUIErrorMessage(msg); - warning("%s", msg.c_str()); - - return false; + warning("Unhandled language, falling back to English/Italian fonts."); + expectedLangVariant = 0; + break; } int numVariant = in.readUint16BE(); -- cgit v1.2.3 From addca5d8567717bec3015f7fd0d99a707f96288a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Aug 2012 06:51:29 +0200 Subject: TONY: _rgb buffer is no longer static --- engines/tony/window.cpp | 14 ++++++-------- engines/tony/window.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 1e60e636f3..9cf8167030 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -269,8 +269,6 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; - void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; @@ -284,7 +282,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src += (RM_SY - 1) * RM_BBX; if (dezoom == 1 && 0) { - byte *curOut = rgb; + byte *curOut = _rgb; for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { @@ -322,13 +320,13 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } - rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); + _rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); + _rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); + _rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); if (lpDestBuf != NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + lpDestBuf[k / 3] = ((int)_rgb[k + 0] >> 3) | (((int)_rgb[k + 1] >> 3) << 5) | + (((int)_rgb[k + 2] >> 3) << 10); k += 3; } diff --git a/engines/tony/window.h b/engines/tony/window.h index 6528060f17..25ec349196 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -42,7 +42,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer used to convert to RGB - static byte rgb[RM_SX *RM_SY * 3]; + byte _rgb[RM_SX *RM_SY * 3]; public: /** * Take a screenshot -- cgit v1.2.3 From 037920bf76bbf9320b5a96d8f98720e253a0956e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 12:30:02 +0200 Subject: TONY: Fix width of flipped dirty rects. --- engines/tony/gfxcore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 806f4d07bb..406ed8043b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -931,7 +931,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri width = x1; // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1 + 1, y1 + height)); for (y = 0; y < height; y++) { // Decompression @@ -1725,7 +1725,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri width = x1; // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1 + 1, y1 + height)); } else { // Specify the drawn area bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); -- cgit v1.2.3 From 7b4dd0a682bf79cc86024d77d16411a6e2681f47 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 12:39:58 +0200 Subject: TONY: Remove various bits of unused code. --- engines/tony/font.cpp | 19 ++--------- engines/tony/game.cpp | 6 ---- engines/tony/game.h | 5 --- engines/tony/gfxcore.cpp | 85 +++++++++++++--------------------------------- engines/tony/gfxcore.h | 23 +++++-------- engines/tony/gfxengine.cpp | 10 ------ engines/tony/gfxengine.h | 6 ---- engines/tony/input.cpp | 6 ---- engines/tony/input.h | 15 -------- engines/tony/tony.cpp | 12 ------- engines/tony/tony.h | 8 ----- engines/tony/window.cpp | 7 ---- engines/tony/window.h | 8 ----- 13 files changed, 35 insertions(+), 175 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 55e3b7627a..91dd8c0c39 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -49,21 +49,6 @@ RMFont::~RMFont() { unload(); } - -/** - * Dumps a font to a buffer - * @param buf Buffer for font contents - * @param nChars Number of characters (max 256) - * @param dimx X dimension in pixels - * @param dimy Y dimension in pixels -* -\****************************************************************************/ - -void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, int charY, byte *pal) { - error("DumpFontBMP not supported in ScummVM"); -} - - void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { _letter = new RMGfxSourceBuffer8RLEByte[nChars]; @@ -150,7 +135,7 @@ int RMFont::stringLen(char bChar, char bNext) { } /****************************************************************************\ -* Metodi di RMFontColor +* RMFontColor Methods \****************************************************************************/ RMFontColor::RMFontColor() : RMFont() { @@ -180,7 +165,7 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { _fontG = g1; _fontB = b1; - // Constructs a new paletter for the font + // Constructs a new palette for the font for (i = 1; i < 16; i++) { pal[i * 3 + 0] = r >> 16; pal[i * 3 + 1] = g >> 16; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 321a4fa88d..4699a9b9aa 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1527,12 +1527,6 @@ void RMPointer::close() { } } - -int RMPointer::priority() { - // Pointer has minimum priority so it will be drawn last - return 200; -} - void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int n; diff --git a/engines/tony/game.h b/engines/tony/game.h index aa7d45bce6..9c58f28714 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -100,11 +100,6 @@ public: */ void doFrame(); - /** - * Overloading of priorities - */ - int priority(); - /** * draw method */ diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 406ed8043b..f9f7cb02ec 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -65,7 +65,6 @@ void RMGfxTaskSetPrior::setPriority(int nPrior) { RMGfxBuffer::RMGfxBuffer() { _dimx = _dimy = 0; - _bUseDDraw = false; _origBuf = _buf = NULL; } @@ -73,7 +72,7 @@ RMGfxBuffer::~RMGfxBuffer() { destroy(); } -void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { +void RMGfxBuffer::create(int dimx, int dimy, int nBpp) { // Destroy the buffer it is already exists if (_buf != NULL) destroy(); @@ -81,34 +80,17 @@ void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { // Copy the parameters in the private members _dimx = dimx; _dimy = dimy; - _bUseDDraw = bUseDDraw; - if (!_bUseDDraw) { - // Allocate a buffer - _origBuf = _buf = new byte[_dimx * _dimy * nBpp / 8]; - assert(_buf != NULL); - Common::fill(_origBuf, _origBuf + _dimx * _dimy * nBpp / 8, 0); - } + // Allocate a buffer + _origBuf = _buf = new byte[_dimx * _dimy * nBpp / 8]; + assert(_buf != NULL); + Common::fill(_origBuf, _origBuf + _dimx * _dimy * nBpp / 8, 0); } void RMGfxBuffer::destroy() { - if (!_bUseDDraw) { - if (_origBuf != NULL && _origBuf == _buf) { - delete[] _origBuf; - _origBuf = _buf = NULL; - } - } -} - -void RMGfxBuffer::lock() { - if (_bUseDDraw) { - // Manages acceleration - } -} - -void RMGfxBuffer::unlock() { - if (_bUseDDraw) { - // Manages acceleration + if (_origBuf != NULL && _origBuf == _buf) { + delete[] _origBuf; + _origBuf = _buf = NULL; } } @@ -125,8 +107,8 @@ RMGfxBuffer::operator void *() { return (void *)_buf; } -RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { - create(dimx, dimy, nBpp, bUseDDraw); +RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp) { + create(dimx, dimy, nBpp); } /****************************************************************************\ @@ -240,8 +222,8 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer() { } -RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { +RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 16) { } /****************************************************************************\ @@ -252,19 +234,15 @@ RMGfxTargetBuffer::RMGfxTargetBuffer() { _otlist = NULL; _otSize = 0; _trackDirtyRects = false; -// csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { clearOT(); -// g_system->deleteMutex(csModifyingOT); } void RMGfxTargetBuffer::clearOT() { OTList *cur, *n; -// g_system->lockMutex(csModifyingOT); - cur = _otlist; while (cur != NULL) { @@ -276,8 +254,6 @@ void RMGfxTargetBuffer::clearOT() { } _otlist = NULL; - -// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::drawOT(CORO_PARAM) { @@ -294,10 +270,6 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { _ctx->prev = NULL; _ctx->cur = _otlist; - // Lock the buffer to access it - lock(); -// g_system->lockMutex(csModifyingOT); - while (_ctx->cur != NULL) { // Call the task Draw method, passing it a copy of the original _ctx->myprim = _ctx->cur->_prim->duplicate(); @@ -330,11 +302,6 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { } } -// g_system->unlockMutex(csModifyingOT); - - //Unlock after writing - unlock(); - CORO_END_CODE; } @@ -342,8 +309,6 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { int nPrior; OTList *cur, *n; -// g_system->lockMutex(csModifyingOT); - // Warn of the OT listing prim->_task->Register(); @@ -368,8 +333,6 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { n->_next = cur->_next; cur->_next = n; } - -// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::addDirtyRect(const Common::Rect &r) { @@ -554,8 +517,8 @@ int RMGfxSourceBufferPal::loadPaletteWA(uint32 resID, bool bSwapped) { void RMGfxSourceBuffer4::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 4, bUseDDraw) { +RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 4) { setPriority(0); } @@ -569,8 +532,8 @@ int RMGfxSourceBuffer4::getBpp() { return 4; } -void RMGfxSourceBuffer4::create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::create(dimx, dimy, 4, bUseDDraw); +void RMGfxSourceBuffer4::create(int dimx, int dimy) { + RMGfxBuffer::create(dimx, dimy, 4); } /****************************************************************************\ @@ -641,8 +604,8 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit bigBuf.addDirtyRect(Common::Rect(dst._x1, dst._y1, dst._x1 + width, dst._y1 + height)); } -RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { +RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 8) { setPriority(0); _bTrasp0 = false; } @@ -661,8 +624,8 @@ int RMGfxSourceBuffer8::getBpp() { return 8; } -void RMGfxSourceBuffer8::create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::create(dimx, dimy, 8, bUseDDraw); +void RMGfxSourceBuffer8::create(int dimx, int dimy) { + RMGfxBuffer::create(dimx, dimy, 8); } #define GETRED(x) (((x) >> 10) & 0x1F) @@ -1989,8 +1952,8 @@ void RMGfxSourceBuffer16::prepareImage() { WRITE_LE_UINT16(&buf[i], FROM_LE_16(buf[i]) & 0x7FFF); } -RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { +RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 16) { setPriority(0); _bTrasp0 = false; } @@ -2004,8 +1967,8 @@ int RMGfxSourceBuffer16::getBpp() { return 16; } -void RMGfxSourceBuffer16::create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::create(dimx, dimy, 16, bUseDDraw); +void RMGfxSourceBuffer16::create(int dimx, int dimy) { + RMGfxBuffer::create(dimx, dimy, 16); } /****************************************************************************\ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 2402b1e029..cd7830be24 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -61,11 +61,10 @@ protected: int _dimx, _dimy; byte *_buf; byte *_origBuf; - bool _bUseDDraw; public: RMGfxBuffer(); - RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + RMGfxBuffer(int dimx, int dimy, int nBpp); virtual ~RMGfxBuffer(); // Attributes @@ -77,13 +76,9 @@ public: } // Creation - virtual void create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void create(int dimx, int dimy, int nBpp); virtual void destroy(); - // Buffer access - void lock(); - void unlock(); - // These are valid only if the buffer is locked operator byte *(); operator void *(); @@ -321,11 +316,11 @@ protected: public: RMGfxSourceBuffer16(bool bUseTrasp = false); - RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer16(int dimx, int dimy); virtual ~RMGfxSourceBuffer16(); // Initialization - void create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy); int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -366,11 +361,11 @@ protected: public: RMGfxSourceBuffer8(bool bTrasp0 = true); - RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer8(int dimx, int dimy); virtual ~RMGfxSourceBuffer8(); // Initialization - void create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy); int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -533,10 +528,10 @@ public: class RMGfxSourceBuffer4 : public RMGfxSourceBufferPal { public: RMGfxSourceBuffer4(); - RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer4(int dimx, int dimy); // Initialization - void create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy); int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -618,7 +613,7 @@ public: class RMGfxWoodyBuffer: public RMGfxSourceBuffer16, public RMGfxTargetBuffer { public: RMGfxWoodyBuffer(); - RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); + RMGfxWoodyBuffer(int dimx, int dimy); virtual ~RMGfxWoodyBuffer(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 5431a0ca7d..25aaa625f4 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -500,9 +500,6 @@ void RMGfxEngine::init() { GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); - // Initialize the input - _input.init(); - // Initialize the mouse pointer _point.init(); @@ -530,13 +527,6 @@ void RMGfxEngine::close() { _inv.close(); _tony.close(); _point.close(); - _input.close(); -} - -void RMGfxEngine::switchFullscreen(bool bFull) { -} - -void RMGfxEngine::GDIControl(bool bCon) { } void RMGfxEngine::enableInput() { diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 8be09ddd8b..7206496aaa 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -92,12 +92,6 @@ public: // Closes the graphics engine void close(); - // Warns when changing - void switchFullscreen(bool bFull); - - // Warn that we are guided by the GDI - void GDIControl(bool bCon); - // Warns when entering or exits the options menu void openOptionScreen(CORO_PARAM, int type); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 1e79032af2..88bc3f4092 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -101,12 +101,6 @@ void RMInput::poll() { } } -void RMInput::init() { -} - -void RMInput::close() { -} - bool RMInput::mouseLeft() { return _leftButton; } diff --git a/engines/tony/input.h b/engines/tony/input.h index d9b6dc7e89..55b067ec43 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -46,26 +46,11 @@ private: // Keyboard related fields bool _keyDown[350]; -private: - /** - * Deinitialize DirectInput - */ - void DIClose(); public: RMInput(); ~RMInput(); - /** - * Class initialization - */ - void init(/*uint32 hInst*/); - - /** - * Closes the class - */ - void close(); - /** * Polling (must be performed once per frame) */ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index bb174dfbb1..b0ca074c16 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -610,9 +610,6 @@ void TonyEngine::grabThumbnail() { _window.grabThumbnail(_curThumbnail); } -void TonyEngine::optionScreen() { -} - void TonyEngine::openInitLoadMenu(CORO_PARAM) { _theEngine.openOptionScreen(coroParam, 1); } @@ -706,15 +703,6 @@ void TonyEngine::close() { delete[] _curThumbnail; } -void TonyEngine::switchFullscreen(bool bFull) { - _window.switchFullscreen(bFull); - _theEngine.switchFullscreen(bFull); -} - -void TonyEngine::GDIControl(bool bCon) { - _theEngine.GDIControl(bCon); -} - void TonyEngine::freezeTime() { _bTimeFreezed = true; _nTimeFreezed = getTime() - _startTime; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f8358b15a7..9a25f2ce35 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -167,20 +167,12 @@ public: Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); - /** - * Warn when are being controlled by the GDI - */ - void GDIControl(bool bCon); - void play(); void close(); void abortGame(); void getDataDirectory(DataDir dir, char *path); - void switchFullscreen(bool bFull); - void optionScreen(); - void showLocation() { _bDrawLocation = true; } diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 9cf8167030..c412a53655 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -109,13 +109,6 @@ void RMWindow::repaint() { g_system->updateScreen(); } -bool RMWindow::lock() { - return true; -} - -void RMWindow::unlock() { -} - /** * Wipes an area of the screen */ diff --git a/engines/tony/window.h b/engines/tony/window.h index 25ec349196..4dfd63a3d8 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -53,8 +53,6 @@ public: class RMWindow { private: - bool lock(); - void unlock(); void plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y); void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); @@ -83,7 +81,6 @@ public: * Initialization */ void init(/*HINSTANCE hInst*/); - void initDirectDraw(); void close(); /** @@ -91,11 +88,6 @@ public: */ void repaint(); - /** - * Switch between windowed and fullscreen - */ - void switchFullscreen(bool bFull) {} - /** * Reads the next frame */ -- cgit v1.2.3 From 6805c2cec20cb41f20abdbd4ecb8b2dfa52f2143 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 27 Aug 2012 13:07:34 +0200 Subject: TONY: Translate some minor Italian comments --- engines/tony/mpal/loadmpc.cpp | 2 +- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/mpaldll.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a0dff2927a..ed4ad9d228 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -39,7 +39,7 @@ namespace Tony { namespace MPAL { /****************************************************************************\ -* Funzioni statiche +* Static functions \****************************************************************************/ static bool compareCommands(struct command *cmd1, struct command *cmd2) { diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 83463f0092..b805b1e7a1 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -34,7 +34,7 @@ namespace Tony { namespace MPAL { /****************************************************************************\ -* Prototipi di funzione +* Function prototypes \****************************************************************************/ /** diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index fe1eb2b34a..e637362bdf 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -69,7 +69,7 @@ namespace MPAL { /****************************************************************************\ -* Strutture +* Structures \****************************************************************************/ #include "common/pack-start.h" -- cgit v1.2.3 From 28681a32eeaeba6029d6040da89bd810a0dd2b35 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 23:41:23 +0200 Subject: TONY: Remove more unused bits. --- engines/tony/window.cpp | 3 --- engines/tony/window.h | 11 ----------- 2 files changed, 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c412a53655..9385db27c7 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -57,9 +57,6 @@ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); - // Initialize FPS counters - fps = lastfcount = fcount = lastsecond = 0; - _bGrabScreenshot = false; _bGrabThumbnail = false; _bGrabMovie = false; diff --git a/engines/tony/window.h b/engines/tony/window.h index 4dfd63a3d8..9aaca16d3e 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -35,10 +35,6 @@ namespace Tony { -typedef uint32 HWND; -struct DDSURFACEDESC { -}; - class RMSnapshot { private: // Buffer used to convert to RGB @@ -57,10 +53,6 @@ private: void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: - int fps, fcount; - int lastsecond, lastfcount; - - int mskRed, mskGreen, mskBlue; bool _wiping; bool _showDirtyRects; @@ -98,9 +90,6 @@ public: */ void grabThumbnail(uint16 *buf); - int getFps() const { - return fps; - } void showDirtyRects(bool v) { _showDirtyRects = v; } }; -- cgit v1.2.3 From 3570a0153dfa1034fc8acece5f755038487a5886 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 09:19:10 +0200 Subject: TONY: Improve Take/ReleaseOwnership. This releases all held 'mutexes' when processes die, and keeps track of the lock count too, just in case. --- engines/tony/custom.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++---- engines/tony/globals.cpp | 1 - engines/tony/globals.h | 10 +++++++++- engines/tony/tony.cpp | 1 + 4 files changed, 55 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index fcb304c623..3031fc342b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2052,12 +2052,39 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - // The event is operating as a mutex, so if the event is already set, wait until it's reset - CoroScheduler.waitForSingleObject(coroParam, GLOBALS._mut[num], CORO_INFINITE); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (GLOBALS._mut[num]._ownerPid != (uint32)CoroScheduler.getCurrentPID()) { + // The mutex is currently owned by a different process. + // Wait for the event to be signalled, which means the mutex is free. + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._mut[num]._eventId, CORO_INFINITE); + GLOBALS._mut[num]._ownerPid = (uint32)CoroScheduler.getCurrentPID(); + } + + GLOBALS._mut[num]._lockCount++; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.setEvent(GLOBALS._mut[num]); + if (!GLOBALS._mut[num]._lockCount) { + warning("ReleaseOwnership tried to release mutex %d, which isn't held", num); + return; + } + + if (GLOBALS._mut[num]._ownerPid != (uint32)CoroScheduler.getCurrentPID()) + error("ReleaseOwnership tried to release mutex %d, which is held by a different process", num); + + GLOBALS._mut[num]._lockCount--; + if (!GLOBALS._mut[num]._lockCount) { + GLOBALS._mut[num]._ownerPid = 0; + + // Signal the event, to wake up processes waiting for the lock. + CoroScheduler.setEvent(GLOBALS._mut[num]._eventId); + } } /* @@ -2524,6 +2551,19 @@ ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() +void processKilledCallback(Common::PROCESS *p) { + for (uint i = 0; i < 10; i++) + if (GLOBALS._mut[i]._ownerPid == p->pid) { + // Handle scripts which don't call ReleaseOwnership, such as + // the one in loc37's vEnter when Tony is chasing the mouse. + debug(DEBUG_BASIC, "Force-releasing mutex %d after process died", i); + + GLOBALS._mut[i]._ownerPid = 0; + GLOBALS._mut[i]._lockCount = 0; + CoroScheduler.setEvent(GLOBALS._mut[i]._eventId); + } +} + void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { GLOBALS._tony = tony; GLOBALS._pointer = ptr; @@ -2549,8 +2589,9 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS._bAlwaysDisplay = false; int i; + CoroScheduler.setResourceCallback(processKilledCallback); for (i = 0; i < 10; i++) - GLOBALS._mut[i] = CoroScheduler.createEvent(false, true); + GLOBALS._mut[i]._eventId = CoroScheduler.createEvent(false, true); for (i = 0; i < 200; i++) GLOBALS._ambiance[i] = 0; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index ba2698a50b..dd35d8c5ec 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -67,7 +67,6 @@ Globals::Globals() { _curSoundEffect = 0; _bFadeOutStop = false; - Common::fill(&_mut[0], &_mut[10], 0); _bSkipIdle = false; _hSkipIdle = 0; _lastMusic = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 02bd79eee7..483ced1817 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -155,6 +155,14 @@ typedef CFCALL *LPCFCALL; typedef LPCFCALL *LPLPCFCALL; +struct CoroutineMutex { + CoroutineMutex() : _eventId(0), _ownerPid(0), _lockCount(0) { } + + uint32 _eventId; + uint32 _ownerPid; + uint32 _lockCount; +}; + /****************************************************************************\ * Global variables \****************************************************************************/ @@ -236,7 +244,7 @@ public: RMTony::CharacterTalkType _nTonyNextTalkType; RMPoint _startLocPos[256]; - uint32 _mut[10]; + CoroutineMutex _mut[10]; bool _bSkipIdle; uint32 _hSkipIdle; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b0ca074c16..b9d12beb11 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -89,6 +89,7 @@ TonyEngine::~TonyEngine() { // Reset the coroutine scheduler CoroScheduler.reset(); + CoroScheduler.setResourceCallback(NULL); delete _debugger; } -- cgit v1.2.3 From e6bd426398c75fb6e268e58508b19307ab0c53eb Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 09:47:21 +0200 Subject: TONY: Rename curDialog to g_curDialog. --- engines/tony/custom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3031fc342b..c73c7dec36 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1779,7 +1779,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes * Dialogs */ -int curDialog; +int g_curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { CORO_BEGIN_CONTEXT; @@ -1801,7 +1801,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers != 0 && GLOBALS._isMChar[nPers] && GLOBALS._mCharacter[nPers]._bAlwaysBack) _ctx->bIsBack = true; - _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); + _ctx->curVoc = SearchVoiceHeader(g_curDialog, nMsg); _ctx->voice = NULL; if (_ctx->curVoc) { @@ -1978,7 +1978,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_BEGIN_CODE(_ctx); - curDialog = nDialog; + g_curDialog = nDialog; // Call MPAL to start the dialog mpalQueryDoDialog(nDialog, nStartGroup); -- cgit v1.2.3 From fbf771ea55b321e5f7914eb989d82bdd2a579f98 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 10:08:37 +0200 Subject: TONY: Fix stringLen for empty strings. --- engines/tony/font.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 91dd8c0c39..41dfa1f7bf 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -122,6 +122,9 @@ void RMFont::close() { int RMFont::stringLen(const Common::String &text) { uint len, i; + if (text.empty()) + return letterLength('\0'); + len = 0; for (i = 0; i < text.size() - 1; i++) len += letterLength(text[i], text[i + 1]); -- cgit v1.2.3 From 18b1f6d7c6e5a70d2073178cffbde53236225b4b Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 13:33:24 +0200 Subject: TONY: Remove unused data dumping code. --- engines/tony/mpal/mpal.cpp | 785 --------------------------------------------- 1 file changed, 785 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 76ca8a5db3..16d8a3213b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -2120,791 +2120,6 @@ int mpalLoadState(byte *buf) { return GLOBALS._nVars * sizeof(MPALVAR) + 4; } -bool bDontOutput; - -struct MsgCommentsStruct { - uint16 wStart; - uint16 wEnd; - const char *pComment; -}; -const MsgCommentsStruct MsgComments[] = { - { 10, 16, "###" }, - { 560, 563, "@@@ BUTCH & DUDLEY:" }, - { 551, 553, "@@@ JACK'S LETTER (JACK'S VOICE):" }, - { 679, 679, "@@@ OFF-SCREEN VOICE:" }, - { 799, 799, "###" }, - { 830, 838, "RE-HASHING (FROM MACBETH):" }, - { 890, 894, "@@@ BEARDED LADY FROM WITHIN HER ROOM:" }, - { 1175, 1175, "###" }, - { 1210, 1210, "###" }, - { 1347, 1349, "###" }, - { 1175, 1175, "###" }, - { 1342, 1343, "###" }, - { 1742, 1742, "@@@ OFF-SCREEN VOICE:" }, - { 1749, 1749, "###" }, - { 1759, 1759, "###" }, - { 2165, 2166, "@@@ MORTIMER:" }, - { 2370, 2372, "@@@ ELECTRONIC VOICE FROM AN AUTOMATIC PICTURE MACHINE:" }, - { 2580, 2589, "@@@ BIFF:" }, - { 2590, 2593, "@@@ BARTENDER:" }, - { 2596, 2596, "@@@ SAD PIRATE:" }, - { 2760, 2767, "@@@ EGGHEAD:" }, - { 2959, 2959, "@@@ MONSTROUS VOICE FROM BEHIND A LOCKED DOOR:" }, - { 3352, 3352, "@@@ POLLY:" }, - { 3378, 3379, "@@@ POLLY:" }, - { 3461, 3469, "@@@ RANDALL:" }, - { 3571, 3574, "@@@ CAPTAIN'S JOURNAL (CAPTAIN'S VOICE):" }, - { 3646, 3646, "NOTE: THIS SENTENCE ENDS THE STORY TOLD IN SENTENCES 03640 - 03643:" }, - { 3647, 3648, "TONY SPEAKS TRYING TO IMITATE CAPTAIN CORNELIUS' VOICE:" }, - { 3670, 3671, "###" }, - { 3652, 3652, "###" }, - { 3656, 3657, "@@@ GATEKEEPER:" }, - { 3658, 3659, "@@@ GATEKEEPER (FAR AWAY):" }, - { 3790, 3795, "@@@ GATEKEEPER:" }, - { 3798, 3799, "@@@ OFF-SCREEN VOICE:" }, - { 4384, 4384, "###" }, - { 4394, 4395, "###" }, - { 4780, 4780, "###" }, - { 5089, 5089, "TONY PLAYING SOMEONE ELSE, WITH A DEEPER TONE:" }, - { 5090, 5090, "NORMAL TONY:" }, - { 5091, 5091, "TONY PLAYING SOMEONE ELSE, WITH A DEEPER TONE:" }, - { 5262, 5262, "@@@ OFF-SCREEN VOICE" }, - { 5276, 5277, "###" }, - { 5326, 5326, "###" }, - { 5472, 5472, "LYRICS FROM THE SONG \"I AM ONE\", BY SMASHING PUMPKINS:" }, - { 5488, 5488, "LYRICS FROM THE SONG \"I AM ONE\", BY SMASHING PUMPKINS:" }, - { 5652, 5653, "###" }, -//bernie { 11000, 15000, "###" }, - { 11000, 11111, "###" }, - - - { 0, 0, NULL } -}; - -void outputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wStart != 0; i++) - if (MsgComments[i].wStart == wNum) { - debugC(DEBUG_BASIC, kTonyDebugMPAL, "Start: %d\n", wNum); - - f->writeString("
%s %s %s
\n

\n

\n"); - - if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { - f->writeString(Common::String::format("%s\n", MsgComments[i].pComment)); - f->writeString("

\n

\n\n"); - } else - bDontOutput = true; - return; - } -} - -void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wEnd != 0; i++) - if (MsgComments[i].wEnd == wNum) { - debugC(DEBUG_BASIC, kTonyDebugMPAL, "End: %d\n", wNum); - - if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { - f->writeString("
\n

\n"); - } else - bDontOutput = false; - - f->writeString("

\n

\n\n"); - return; - } -} - - -int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wStart != 0; i++) - if (MsgComments[i].wStart <= wNum && MsgComments[i].wEnd >= wNum) { - if (strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { - if (MsgComments[i].wStart == wNum) { - f->writeString(Common::String::format("%s\n", MsgComments[i].pComment + 4)); - f->writeString("

\n

\n

\n"); - } - - return 1; - } - } - - return 0; -} - -void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wStart != 0; i++) - if (MsgComments[i].wEnd == wNum && strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { - f->writeString("
\n

\n"); - break; - } -} - -void mpalDumpMessages() { - int i, j; - char *lpMessage; - char *p; - char *lpPeriods[30]; - char fname[64]; - char frase[2048]; - int nPeriods; - Common::OutSaveFile *f, *v1; - - v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); - - LockMsg(); - - bDontOutput = false; - - debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping MESSAGES.HTM...\n"); - - f = g_system->getSavefileManager()->openForSaving("Messages.htm"); - f->writeString("\n\n\n"); - - for (i = 0; i < GLOBALS._nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); - if (*lpMessage != '\0') { - // bernie: debug - /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { - int a = 1; - }*/ - - nPeriods = 1; - p = lpPeriods[0] = lpMessage; - - outputStartMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); - - while (1) { - // Find the end of the current period - while (*p != '\0') - p++; - - // If there is another '\0' at the end of the message, then finish - p++; - if (*p == '\0') - break; - - // Otherwise there is another line, so remember the next one's start - lpPeriods[nPeriods++] = p; - } - - // Now make a loop over all the periods - for (j = 0; j < nPeriods; j++) { - if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); - else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); - - strcpy(frase, lpPeriods[j]); - - while ((p = strchr(frase,'^')) != NULL) - *p = '\"'; - - p = frase; - while (*p == ' ') - p++; - if (*p == '\0') - continue; - - if (!bDontOutput) { - v1->writeString(Common::String::format("%s\n", fname)); - f->writeString("\t\n"); - f->writeString(Common::String::format("\t\t\n", fname)); - f->writeString(Common::String::format("\t\t\n", frase)); - f->writeString("\t\n"); - } - } - - OutputEndMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); - - globalUnlock(GLOBALS._lpmmMsgs[i]._hText); - } - } - - f->writeString("
%s %s
\n\n\n"); - - f->finalize(); - v1->finalize(); - delete f; - delete v1; - - UnlockMsg(); -} - -void mpalDumpOthers() { - int i,j; - char *lpMessage; - char *p; - char *lpPeriods[30]; - char fname[64]; - char frase[2048]; - int nPeriods; - - Common::OutSaveFile *f, *v1; - - v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); - f = g_system->getSavefileManager()->openForSaving("Others.htm"); - LockMsg(); - - bDontOutput = false; - - debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping OTHERS.HTM...\n"); - - f->writeString("\n\n"); - - for (i = 0; i < GLOBALS._nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); - if (*lpMessage != '\0') { - nPeriods = 1; - p = lpPeriods[0] = lpMessage; - - if (OutputStartOther(GLOBALS._lpmmMsgs[i]._wNum, f)) { - while (1) { - // Find the end of the current period - while (*p != '\0') - p++; - - // If there is another '0' at the end, then the message is finished - p++; - if (*p == '\0') - break; - - // Remember the start of the next line - lpPeriods[nPeriods++] = p; - } - - // Now loop over all the periods - for (j = 0; j < nPeriods; j++) { - if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); - else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); - - strcpy(frase,lpPeriods[j]); - - while ((p = strchr(frase, '^')) != NULL) - *p = '\"'; - - p = frase; - while (*p == ' ') - p++; - if (*p == '\0') - continue; - - if (!bDontOutput) { - v1->writeString(Common::String::format("%s\n", fname)); - f->writeString("\t\n"); - f->writeString(Common::String::format("\t\t %s \n", fname)); - f->writeString(Common::String::format("\t\t %s \n", frase)); - f->writeString("\t\n"); - } - } - } - - outputEndOther(GLOBALS._lpmmMsgs[i]._wNum, f); - - globalUnlock(GLOBALS._lpmmMsgs[i]._hText); - } - } - - f->writeString("\n\n"); - - f->finalize(); - v1->finalize(); - - delete f; - delete v1; - UnlockMsg(); -} - - -#if 0 // English names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Old lady 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; -const char *DLG90[] = { "Tony", "Bearded lady", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Piranha", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG160[] = { "Tony", "Shmiley", NULL }; -const char *DLG161[] = { "Tony", "Shmiley", NULL }; -const char *DLG162[] = { "Tony", "Shmiley", NULL }; -const char *DLG163[] = { "Tony", "Shmiley", NULL }; -const char *DLG180[] = { "Tony", "Beast", NULL }; -const char *DLG190[] = { "Tony", "Beast", NULL }; -const char *DLG191[] = { "Tony", "Beast", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer", NULL }; -const char *DLG211[] = { "Tony", "Mortimer", NULL }; -const char *DLG212[] = { "Tony", "Mortimer", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; -const char *DLG270[] = { "Tony", "Egghead", NULL }; -const char *DLG271[] = { "Tony", "Egghead", NULL }; -const char *DLG272[] = { "Tony", "Egghead", NULL }; -const char *DLG290[] = { "Tony", "Old lady 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG371[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG372[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG373[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; -const char *DLG560[] = { "Tony", "Superintendent", NULL }; -const char *DLG590[] = { "Tony", "Pantagruel", NULL }; -const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; -#endif - -#if 0 // Polish names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Staruszka 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; -const char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Pirania", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG160[] = { "Tony", "miechozol", NULL }; -const char *DLG161[] = { "Tony", "miechozol", NULL }; -const char *DLG162[] = { "Tony", "miechozol", NULL }; -const char *DLG163[] = { "Tony", "miechozol", NULL }; -const char *DLG180[] = { "Tony", "Wycz", NULL }; -const char *DLG190[] = { "Tony", "Wycz", NULL }; -const char *DLG191[] = { "Tony", "Wycz", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; -const char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; -const char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; -const char *DLG270[] = { "Tony", "Jajogowy", NULL }; -const char *DLG271[] = { "Tony", "Jajogowy", NULL }; -const char *DLG272[] = { "Tony", "Jajogowy", NULL }; -const char *DLG290[] = { "Tony", "Staruszka 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Stranik", NULL }; -const char *DLG371[] = { "Tony", "Stranik", NULL }; -const char *DLG372[] = { "Tony", "Stranik", NULL }; -const char *DLG373[] = { "Tony", "Stranik", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; -const char *DLG560[] = { "Tony", "Inspektor", NULL }; -const char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; -const char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; -#endif // Polish - - -#if 0 // Russian -const char *DLG10[] = { "呷辷", NULL }; -const char *DLG51[] = { "呷辷", "蒼", "釣粳" }; -const char *DLG52[] = { "呷辷", NULL }; -const char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; -const char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; -const char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; -const char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; -const char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; -const char *DLG130[] = { "呷辷", "蒡琿", NULL }; -const char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG160[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG161[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG162[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG163[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG180[] = { "呷辷", "恣粮礦", NULL }; -const char *DLG190[] = { "呷辷", "恣粮礦", NULL }; -const char *DLG191[] = { "呷辷", "恣粮礦", NULL }; -const char *DLG201[] = { "呷辷", NULL }; -const char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; -const char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; -const char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; -const char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; -const char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -const char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -const char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; -const char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; -const char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; -const char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; -const char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; -const char *DLG310[] = { "呷辷", "嚴諡", NULL }; -const char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; -const char *DLG340[] = { "呷辷", "傴辟琺", NULL }; -const char *DLG360[] = { "呷辷", NULL }; -const char *DLG361[] = { "呷辷", NULL }; -const char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG380[] = { "呷辷", NULL }; -const char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; -const char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "呷辷", NULL }; -const char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "呷辷", "Pin-up", NULL }; -const char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; -const char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; -const char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; -const char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; -const char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; -const char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; -#endif // Russian - - -#if 0 // Czech names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Star pan 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; -const char *DLG90[] = { "Tony", "Vousat ena", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Piraa", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG160[] = { "Tony", "Shmiley", NULL }; -const char *DLG161[] = { "Tony", "Shmiley", NULL }; -const char *DLG162[] = { "Tony", "Shmiley", NULL }; -const char *DLG163[] = { "Tony", "Shmiley", NULL }; -const char *DLG180[] = { "Tony", "Zv逖e", NULL }; -const char *DLG190[] = { "Tony", "Zv逖e", NULL }; -const char *DLG191[] = { "Tony", "Zv逖e", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer", NULL }; -const char *DLG211[] = { "Tony", "Mortimer", NULL }; -const char *DLG212[] = { "Tony", "Mortimer", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; -const char *DLG270[] = { "Tony", "Intelektul", NULL }; -const char *DLG271[] = { "Tony", "Intelektul", NULL }; -const char *DLG272[] = { "Tony", "Intelektul", NULL }; -const char *DLG290[] = { "Tony", "Star pan 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Strn", NULL }; -const char *DLG371[] = { "Tony", "Strn", NULL }; -const char *DLG372[] = { "Tony", "Strn", NULL }; -const char *DLG373[] = { "Tony", "Strn", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; -const char *DLG560[] = { "Tony", "Sprvce", NULL }; -const char *DLG590[] = { "Tony", "Pantagruel", NULL }; -const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; -#endif // Czech names - -#if 1 // Deutsch names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; -const char *DLG90[] = { "Tony", "Brtige Dame", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Piranha", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG160[] = { "Tony", "Shmiley", NULL }; -const char *DLG161[] = { "Tony", "Shmiley", NULL }; -const char *DLG162[] = { "Tony", "Shmiley", NULL }; -const char *DLG163[] = { "Tony", "Shmiley", NULL }; -const char *DLG180[] = { "Tony", "Biest", NULL }; -const char *DLG190[] = { "Tony", "Biest", NULL }; -const char *DLG191[] = { "Tony", "Biest", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer", NULL }; -const char *DLG211[] = { "Tony", "Mortimer", NULL }; -const char *DLG212[] = { "Tony", "Mortimer", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; -const char *DLG270[] = { "Tony", "Eierkopf", NULL }; -const char *DLG271[] = { "Tony", "Eierkopf", NULL }; -const char *DLG272[] = { "Tony", "Eierkopf", NULL }; -const char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Pfrtner", NULL }; -const char *DLG371[] = { "Tony", "Pfrtner", NULL }; -const char *DLG372[] = { "Tony", "Pfrtner", NULL }; -const char *DLG373[] = { "Tony", "Pfrtner", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; -const char *DLG560[] = { "Tony", "Verwalter", NULL }; -const char *DLG590[] = { "Tony", "Pantagruel", NULL }; -const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; -#endif - - -#define HANDLE_DIALOG(num) \ -case num: \ - if (nPers >= (int)(sizeof(DLG##num) / sizeof(const char *)) || DLG##num[nPers] == NULL) \ - { \ - warning("ERROR: The character #%d does not exist in dialog %d!\n", nPers, nDlg); \ - return "ERROR"; \ - } \ - else \ - return DLG##num[nPers]; - - -const char *getPersonName(uint16 nDlg, int nPers) { - switch (nDlg) { - HANDLE_DIALOG(10); - HANDLE_DIALOG(51); - HANDLE_DIALOG(52); - HANDLE_DIALOG(61); - HANDLE_DIALOG(71); - HANDLE_DIALOG(90); - HANDLE_DIALOG(110); - HANDLE_DIALOG(111); - HANDLE_DIALOG(130); - HANDLE_DIALOG(150); - HANDLE_DIALOG(151); - HANDLE_DIALOG(152); - HANDLE_DIALOG(153); - HANDLE_DIALOG(154); - HANDLE_DIALOG(160); - HANDLE_DIALOG(161); - HANDLE_DIALOG(162); - HANDLE_DIALOG(163); - HANDLE_DIALOG(180); - HANDLE_DIALOG(190); - HANDLE_DIALOG(191); - HANDLE_DIALOG(201); - HANDLE_DIALOG(210); - HANDLE_DIALOG(211); - HANDLE_DIALOG(212); - HANDLE_DIALOG(240); - HANDLE_DIALOG(250); - HANDLE_DIALOG(251); - HANDLE_DIALOG(260); - HANDLE_DIALOG(270); - HANDLE_DIALOG(271); - HANDLE_DIALOG(272); - HANDLE_DIALOG(290); - HANDLE_DIALOG(310); - HANDLE_DIALOG(330); - HANDLE_DIALOG(340); - HANDLE_DIALOG(360); - HANDLE_DIALOG(361); - HANDLE_DIALOG(370); - HANDLE_DIALOG(371); - HANDLE_DIALOG(372); - HANDLE_DIALOG(373); - HANDLE_DIALOG(380); - HANDLE_DIALOG(410); - HANDLE_DIALOG(430); - HANDLE_DIALOG(460); - HANDLE_DIALOG(470); - HANDLE_DIALOG(471); - HANDLE_DIALOG(472); - HANDLE_DIALOG(473); - HANDLE_DIALOG(474); - HANDLE_DIALOG(480); - HANDLE_DIALOG(490); - HANDLE_DIALOG(530); - HANDLE_DIALOG(550); - HANDLE_DIALOG(560); - HANDLE_DIALOG(590); - HANDLE_DIALOG(600); - - default: - warning("ERROR: Dialog %d does not exist!", (int)nDlg); - return "ERROR"; - } -} - -void mpalDumpDialog(LPMPALDIALOG dlg) { - char dfn[64]; - char fname[64]; - int g,c,j; - struct command* curCmd; - char *frase; char *p; - char copia[2048]; - bool bAtLeastOne; - Common::OutSaveFile *f, *v1; - - v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); - - sprintf(dfn,"DIALOG%03d.HTM", dlg->nObj); - warning("Dumping %s...\n", dfn); - - f = g_system->getSavefileManager()->openForSaving(dfn); - - f->writeString("\n\n"); - - for (g = 0; dlg->_group[g].num != 0; g++) { - bAtLeastOne = false; - - for (c = 0; c_group[g].nCmds; c++) { - curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; - if (curCmd->type == 1 && curCmd->_nCf == 71) { - bAtLeastOne = true; - break; - } - } - - if (!bAtLeastOne) - continue; - - f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); - f->writeString("\n"); - - for (c = 0; c < dlg->_group[g].nCmds; c++) { - curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; - - // If it's a custom function, call SendDialogMessage(nPers, nMsg) - if (curCmd->type == 1 && curCmd->_nCf == 71) { - sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->_arg2); - - for (j = 0; dlg->_periods[j] != NULL; j++) - if (dlg->_periodNums[j] == curCmd->_arg2) - break; - - if (dlg->_periods[j] == NULL) - warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->_arg2); - else { - frase = (char *)globalLock(dlg->_periods[j]); - strcpy(copia, frase); - globalUnlock(dlg->_periods[j]); - - while ((p = strchr(copia,'^')) != NULL) - *p = '\"'; - - p = frase; - while (*p == ' ') - p++; - if (*p == '\0') - continue; - - v1->writeString(Common::String::format("%s\n", fname)); - f->writeString("\t\n"); - f->writeString(Common::String::format("\t\t\n", fname)); - f->writeString(Common::String::format("\t\t\n", - getPersonName(dlg->nObj, curCmd->_arg1))); - f->writeString(Common::String::format("\t\t\n",copia)); - f->writeString("\t\n"); - //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); - } - } - } - - f->writeString("
%s %s %s

\n"); - //fprintf(f,"\n\n\n\n"); - } - - f->finalize(); - v1->finalize(); - delete f; - delete v1; -} - -void mpalDumpDialogs() { - int i; - - lockDialogs(); - - for (i = 0; i < GLOBALS._nDialogs; i++) - mpalDumpDialog(&GLOBALS._lpmdDialogs[i]); - - unlockDialogs(); -} - } // end of namespace MPAL } // end of namespace Tony -- cgit v1.2.3 From 35fd91793b34b72624a89f2a76f45bc8e59020d2 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 14:26:00 +0200 Subject: TONY: Get rid of RMDataStream. --- engines/tony/game.cpp | 7 +- engines/tony/gfxcore.cpp | 12 +- engines/tony/gfxcore.h | 10 +- engines/tony/gfxengine.cpp | 5 +- engines/tony/inventory.cpp | 15 +- engines/tony/loc.cpp | 358 ++++++++++++--------------------------- engines/tony/loc.h | 42 ++--- engines/tony/mpal/mpalutils.cpp | 5 + engines/tony/mpal/mpalutils.h | 6 + engines/tony/tonychar.cpp | 13 +- engines/tony/utils.cpp | 363 ++-------------------------------------- engines/tony/utils.h | 112 +------------ 12 files changed, 180 insertions(+), 768 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4699a9b9aa..1ba8094ac4 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1492,11 +1492,10 @@ void RMPointer::init() { for (i = 0; i < 5; i++) { RMRes res(RES_P_PAP1 + i); - RMDataStream ds; - - ds.openBuffer(res); + Common::SeekableReadStream *ds = res.getReadStream(); _specialPointer[i] = new RMItem; - ds >> *_specialPointer[i]; + _specialPointer[i]->readFromStream(*ds); + delete ds; } //m_hotspot[0].set(19,5); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index f9f7cb02ec..44befa3755 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -125,7 +125,7 @@ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalet return dimx * dimy * getBpp() / 8; } -void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, getBpp()); ds.read(_buf, dimx * dimy * getBpp() / 8); @@ -489,7 +489,7 @@ int RMGfxSourceBufferPal::init(const byte *buf, int dimx, int dimy, bool bLoadPa return read; } -void RMGfxSourceBufferPal::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBufferPal::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { // Load the RAW image RMGfxSourceBuffer::init(ds, dimx, dimy); @@ -749,13 +749,13 @@ int RMGfxSourceBuffer8RLE::init(const byte *buf, int dimx, int dimy, bool bLoadP return RMGfxSourceBufferPal::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLE::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { if (_bNeedRLECompress) { RMGfxSourceBufferPal::init(ds, dimx, dimy, bLoadPalette); } else { int size; - ds >> size; + size = ds.readSint32LE(); _buf = new byte[size]; ds.read(_buf, size); @@ -1826,7 +1826,7 @@ int RMGfxSourceBuffer8RLEByteAA::init(const byte *buf, int dimx, int dimy, bool return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLEByteAA::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!_bNeedRLECompress) { @@ -1862,7 +1862,7 @@ int RMGfxSourceBuffer8RLEWordAA::init(byte *buf, int dimx, int dimy, bool bLoadP return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLEWordAA::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!_bNeedRLECompress) { diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index cd7830be24..472a4ad13a 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -290,7 +290,7 @@ public: // Load the data for the surface virtual int init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); @@ -343,7 +343,7 @@ public: virtual ~RMGfxSourceBufferPal(); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); int loadPaletteWA(uint32 resID, bool bSwapped = false); int loadPaletteWA(const byte *buf, bool bSwapped = false); @@ -418,7 +418,7 @@ public: virtual ~RMGfxSourceBuffer8RLE(); // Overload of the initialization method - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression @@ -501,7 +501,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialization methods - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); @@ -515,7 +515,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialization methods - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEWordAA(); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 25aaa625f4..e8a5df29e9 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -416,7 +416,10 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (!res.isValid()) continue; - _loc.load(res); + Common::SeekableReadStream *ds = res.getReadStream(); + _loc.load(*ds); + delete ds; + initForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 175d9fc6a9..dbd3ad6840 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -95,15 +95,13 @@ void RMInventory::init() { for (i = 0; i <= _nItems; i++) { // Load the items from the resource RMRes res(curres); - RMDataStream ds; - assert(res.isValid()); + Common::SeekableReadStream *ds = res.getReadStream(); // Initialize the MPAL inventory item by reading it in. _items[i]._icon.setInitCurPattern(false); - ds.openBuffer(res); - ds >> _items[i]._icon; - ds.close(); + _items[i]._icon.readFromStream(*ds); + delete ds; // Puts in the default pattern 1 _items[i]._pointer = NULL; @@ -131,13 +129,12 @@ void RMInventory::init() { _items[29]._icon.setPattern(1); // Download interface - RMDataStream ds; RMRes res(RES_I_MINIINTER); assert(res.isValid()); - ds.openBuffer(res); - ds >> _miniInterface; + Common::SeekableReadStream *ds = res.getReadStream(); + _miniInterface.readFromStream(*ds); _miniInterface.setPattern(1); - ds.close(); + delete ds; // Create the text for hints on the mini interface _hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e767584e9b..32c857ceaa 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -42,52 +42,29 @@ using namespace ::Tony::MPAL; * RMPalette Methods \****************************************************************************/ -/** - * Operator for reading palette information from a data stream. - * - * @param ds Data stream - * @param pal Destination palette - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.read(pal._data, 1024); - return ds; +void RMPalette::readFromStream(Common::ReadStream &ds) { + ds.read(_data, 1024); } /****************************************************************************\ * RMSlot Methods \****************************************************************************/ -/** - * Operator for reading slot information from a data stream. - * - * @param ds Data stream - * @param slot Destination slot - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { - slot.readFromStream(ds); - return ds; -} - - -void RMPattern::RMSlot::readFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::RMSlot::readFromStream(Common::ReadStream &ds, bool bLOX) { byte type; // Type - ds >> type; + type = ds.readByte(); _type = (RMPattern::RMSlotType)type; // Dati - ds >> _data; + _data = ds.readSint32LE(); // Posizione - ds >> _pos; + _pos.readFromStream(ds); // Flag generica - ds >> _flag; + _flag = ds.readByte(); } @@ -95,42 +72,29 @@ void RMPattern::RMSlot::readFromStream(RMDataStream &ds, bool bLOX) { * Metodi di RMPattern \****************************************************************************/ -/** - * Operator for reading pattern information from a data stream - * - * @param ds Data stream - * @param pat Destination pattern - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { - pat.readFromStream(ds); - return ds; -} - -void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::readFromStream(Common::ReadStream &ds, bool bLOX) { int i; // Pattern name if (!bLOX) - ds >> _name; + _name = readString(ds); // Velocity - ds >> _speed; + _speed = ds.readSint32LE(); // Position - ds >> _pos; + _pos.readFromStream(ds); // Flag for pattern looping - ds >> _bLoop; + _bLoop = ds.readSint32LE(); // Number of slots - ds >> _nSlots; + _nSlots = ds.readSint32LE(); // Create and read the slots _slots = new RMSlot[_nSlots]; - for (i = 0; i < _nSlots && !ds.isError(); i++) { + for (i = 0; i < _nSlots && !ds.err(); i++) { if (bLOX) _slots[i].readFromStream(ds, true); else @@ -302,56 +266,46 @@ RMPattern::~RMPattern() { * RMSprite Methods \****************************************************************************/ -/** - * Operator for reading sprite information from a data stream. - * - * @param ds Data stream - * @param sprite Destination slot - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { - sprite.readFromStream(ds); - return ds; -} - void RMSprite::init(RMGfxSourceBuffer *buf) { _buf = buf; } -void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.pos(); +void RMSprite::LOXGetSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy) { + uint32 pos = ds.pos(); - ds >> *dimx >> *dimy; + *dimx = ds.readSint32LE(); + *dimy = ds.readSint32LE(); - ds.seek(pos, ds.START); + ds.seek(pos); } -void RMSprite::getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.pos(); +void RMSprite::getSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy) { + uint32 pos = ds.pos(); - ds >> _name; - ds >> *dimx >> *dimy; + _name = readString(ds); + *dimx = ds.readSint32LE(); + *dimy = ds.readSint32LE(); - ds.seek(pos, ds.START); + ds.seek(pos); } -void RMSprite::readFromStream(RMDataStream &ds, bool bLOX) { +void RMSprite::readFromStream(Common::SeekableReadStream &ds, bool bLOX) { int dimx, dimy; // Sprite name if (!bLOX) - ds >> _name; + _name = readString(ds); // Dimensions - ds >> dimx >> dimy; + dimx = ds.readSint32LE(); + dimy = ds.readSint32LE(); // Bounding box - ds >> _rcBox; + _rcBox.readFromStream(ds); // Unused space if (!bLOX) - ds += 32; + ds.skip(32); // Create buffer and read _buf->init(ds, dimx, dimy); @@ -381,26 +335,13 @@ RMSprite::~RMSprite() { * RMSfx Methods \****************************************************************************/ -/** - * Operator for reading SFX information from a data stream. - * - * @param ds Data stream - * @param sfx Destination SFX - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { - sfx.readFromStream(ds); - return ds; -} - -void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { +void RMSfx::readFromStream(Common::ReadStream &ds, bool bLOX) { int size; // sfx name - ds >> _name; + _name = readString(ds); - ds >> size; + size = ds.readSint32LE(); // Read the entire buffer into a MemoryReadStream byte *buffer = (byte *)malloc(size); @@ -459,20 +400,6 @@ void RMSfx::stop() { * RMItem Methods \****************************************************************************/ -/** - * Operator for reading item information from a data stream. - * - * @param ds Data stream - * @param tem Destination item - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { - item.readFromStream(ds); - return ds; -} - - RMGfxSourceBuffer *RMItem::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; @@ -524,53 +451,55 @@ bool RMItem::isIn(const RMPoint &pt, int *size) { return rc.ptInRect(pt + _curScroll); } -void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { +void RMItem::readFromStream(Common::SeekableReadStream &ds, bool bLOX) { int i, dimx, dimy; byte cm; // MPAL code - ds >> _mpalCode; + _mpalCode = ds.readSint32LE(); // Object name - ds >> _name; + _name = readString(ds); // Z (signed) - ds >> _z; + _z = ds.readSint32LE(); // Parent position - ds >> _pos; + _pos.readFromStream(ds); // Hotspot - ds >> _hot; + _hot.readFromStream(ds); // Bounding box - ds >> _rcBox; + _rcBox.readFromStream(ds); // Number of sprites, sound effects, and patterns - ds >> _nSprites >> _nSfx >> _nPatterns; + _nSprites = ds.readSint32LE(); + _nSfx = ds.readSint32LE(); + _nPatterns = ds.readSint32LE(); // Color mode - ds >> cm; + cm = ds.readByte(); _cm = (RMColorMode)cm; // Flag for the presence of custom palette differences - ds >> _bPal; + _bPal = ds.readByte(); if (_cm == CM_256) { // If there is a palette, read it in if (_bPal) - ds >> _pal; + _pal.readFromStream(ds); } // MPAL data if (!bLOX) - ds += 20; + ds.skip(20); - ds >> _FX; - ds >> _FXparm; + _FX = ds.readByte(); + _FXparm = ds.readByte(); if (!bLOX) - ds += 106; + ds.skip(106); // Create sub-classes if (_nSprites > 0) @@ -580,8 +509,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _patterns = new RMPattern[_nPatterns + 1]; // Read in class data - if (!ds.isError()) - for (i = 0; i < _nSprites && !ds.isError(); i++) { + if (!ds.err()) + for (i = 0; i < _nSprites && !ds.err(); i++) { // Download the sprites if (bLOX) { _sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); @@ -597,8 +526,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _sprites[i].setPalette(_pal._data); } - if (!ds.isError()) - for (i = 0; i < _nSfx && !ds.isError(); i++) { + if (!ds.err()) + for (i = 0; i < _nSfx && !ds.err(); i++) { if (bLOX) _sfx[i].readFromStream(ds, true); else @@ -606,8 +535,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { } // Read the pattern from pattern 1 - if (!ds.isError()) - for (i = 1; i <= _nPatterns && !ds.isError(); i++) { + if (!ds.err()) + for (i = 1; i <= _nPatterns && !ds.err(); i++) { if (bLOX) _patterns[i].readFromStream(ds, true); else @@ -899,11 +828,9 @@ void RMWipe::initFade(int type) { _bMustRegister = true; RMRes res(RES_W_CIRCLE); - RMDataStream ds; - - ds.openBuffer(res); - ds >> _wip0r; - ds.close(); + Common::SeekableReadStream *ds = res.getReadStream(); + _wip0r.readFromStream(*ds); + delete ds; _wip0r.setPattern(1); @@ -1706,50 +1633,45 @@ void RMCharacter::linkToBoxes(RMGameBoxes *boxes) { * RMBox Methods \****************************************************************************/ -void RMBox::readFromStream(RMDataStream &ds) { +void RMBox::readFromStream(Common::ReadStream &ds) { uint16 w; int i; byte b; // Bbox - ds >> _left; - ds >> _top; - ds >> _right; - ds >> _bottom; + _left = ds.readSint32LE(); + _top = ds.readSint32LE(); + _right = ds.readSint32LE(); + _bottom = ds.readSint32LE(); // Adjacency for (i = 0; i < MAXBOXES; i++) { - ds >> _adj[i]; + _adj[i] = ds.readSint32LE(); } // Misc - ds >> _numHotspot; - ds >> _destZ; - ds >> b; + _numHotspot = ds.readSint32LE(); + _destZ = ds.readByte(); + b = ds.readByte(); _bActive = b; - ds >> b; + b = ds.readByte(); _bReversed = b; // Reversed expansion space - ds += 30; + for (i = 0; i < 30; i++) + ds.readByte(); // Hotspots for (i = 0; i < _numHotspot; i++) { - ds >> w; + w = ds.readUint16LE(); _hotspot[i]._hotx = w; - ds >> w; + w = ds.readUint16LE(); _hotspot[i]._hoty = w; - ds >> w; + w = ds.readUint16LE(); _hotspot[i]._destination = w; } } -RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { - box.readFromStream(ds); - - return ds; -} - /****************************************************************************\ * RMBoxLoc Methods \****************************************************************************/ @@ -1763,25 +1685,27 @@ RMBoxLoc::~RMBoxLoc() { delete[] _boxes; } -void RMBoxLoc::readFromStream(RMDataStream &ds) { +void RMBoxLoc::readFromStream(Common::ReadStream &ds) { int i; char buf[2]; byte ver; // ID and version - ds >> buf[0] >> buf[1] >> ver; + buf[0] = ds.readByte(); + buf[1] = ds.readByte(); + ver = ds.readByte(); assert(buf[0] == 'B' && buf[1] == 'X'); assert(ver == 3); // Number of boxes - ds >> _numbBox; + _numbBox = ds.readSint32LE(); // Allocate memory for the boxes _boxes = new RMBox[_numbBox]; // Read in boxes for (i = 0; i < _numbBox; i++) - ds >> _boxes[i]; + _boxes[i].readFromStream(ds); } void RMBoxLoc::recalcAllAdj() { @@ -1796,12 +1720,6 @@ void RMBoxLoc::recalcAllAdj() { } } -RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { - bl.readFromStream(ds); - - return ds; -} - /****************************************************************************\ * RMGameBoxes methods \****************************************************************************/ @@ -1818,21 +1736,20 @@ RMGameBoxes::~RMGameBoxes() { void RMGameBoxes::init() { int i; - RMDataStream ds; // Load boxes from disk _nLocBoxes = 130; for (i = 1; i <= _nLocBoxes; i++) { RMRes res(10000 + i); - ds.openBuffer(res); + Common::SeekableReadStream *ds = res.getReadStream(); _allBoxes[i] = new RMBoxLoc(); - ds >> *_allBoxes[i]; + _allBoxes[i]->readFromStream(*ds); _allBoxes[i]->recalcAllAdj(); - ds.close(); + delete ds; } } @@ -1946,70 +1863,13 @@ RMLocation::RMLocation() { _cmode = CM_256; } - -/** - * Load a location (.LOC) from a file that is provided. - * - * @param lpszFileName Name of the file - */ -bool RMLocation::load(const char *lpszFileName) { - Common::File f; - bool bRet; - - // Open the file for reading - if (!f.open(lpszFileName)) - return false; - - // Passes to the method variation for loading from the opened file - bRet = load(f); - - // Close the file - f.close(); - - return bRet; -} - - -/** - * Load a location (.LOC) from a given open file - * - * @param hFile File reference - * - * @returns True if succeeded OK, false in case of error. - */ -bool RMLocation::load(Common::File &file) { - bool bRet; - - file.seek(0); - - RMFileStreamSlow fs; - - fs.openFile(file); - bRet = load(fs); - fs.close(); - - return bRet; -} - - -bool RMLocation::load(const byte *buf) { - RMDataStream ds; - bool bRet; - - ds.openBuffer(buf); - bRet = load(ds); - ds.close(); - return bRet; -} - - /** * Load a location (.LOC) from a given data stream * * @param ds Data stream * @returns True if succeeded OK, false in case of error. */ -bool RMLocation::load(RMDataStream &ds) { +bool RMLocation::load(Common::SeekableReadStream &ds) { char id[3]; int dimx, dimy; byte ver; @@ -2021,7 +1881,7 @@ bool RMLocation::load(RMDataStream &ds) { _prevFixedScroll.set(-1, -1); // Check the ID - ds >> id[0] >> id[1] >> id[2]; + ds.read(id, 3); // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') @@ -2032,26 +1892,28 @@ bool RMLocation::load(RMDataStream &ds) { return false; // Version - ds >> ver; + ver = ds.readByte(); assert(ver == 6); // Location name - ds >> _name; + _name = readString(ds); // Skip the MPAL bailouts (64 bytes) - ds >> TEMPNumLoc; - ds >> TEMPTonyStart._x >> TEMPTonyStart._y; - ds += 64 - 4 * 3; + TEMPNumLoc = ds.readSint32LE(); + TEMPTonyStart._x = ds.readSint32LE(); + TEMPTonyStart._y = ds.readSint32LE(); + ds.skip(64 - 4 * 3); // Skip flag associated with the background (?) - ds += 1; + ds.skip(1); // Location dimensions - ds >> dimx >> dimy; + dimx = ds.readSint32LE(); + dimy = ds.readSint32LE(); _curScroll.set(0, 0); // Read the color mode - ds >> cm; + cm = ds.readByte(); _cmode = (RMColorMode)cm; // Initialize the source buffer and read the location @@ -2076,7 +1938,7 @@ bool RMLocation::load(RMDataStream &ds) { // assert(dimy!=512); // Number of objects - ds >> _nItems; + _nItems = ds.readSint32LE(); // Create and read in the objects if (_nItems > 0) @@ -2084,32 +1946,34 @@ bool RMLocation::load(RMDataStream &ds) { g_vm->freezeTime(); - for (i = 0; i < _nItems && !ds.isError(); i++) - ds >> _items[i]; + for (i = 0; i < _nItems && !ds.err(); i++) + _items[i].readFromStream(ds); g_vm->unfreezeTime(); - return ds.isError(); + return ds.err(); } -bool RMLocation::loadLOX(RMDataStream &ds) { +bool RMLocation::loadLOX(Common::SeekableReadStream &ds) { int dimx, dimy; byte ver; int i; // Version - ds >> ver; + ver = ds.readByte(); assert(ver == 1); // Location name - ds >> _name; + _name = readString(ds); // Location number - ds >> TEMPNumLoc; - ds >> TEMPTonyStart._x >> TEMPTonyStart._y; + TEMPNumLoc = ds.readSint32LE(); + TEMPTonyStart._x = ds.readSint32LE(); + TEMPTonyStart._y = ds.readSint32LE(); // Dimensions - ds >> dimx >> dimy; + dimx = ds.readSint32LE(); + dimy = ds.readSint32LE(); _curScroll.set(0, 0); // It's always 65K (16-bit) mode @@ -2120,16 +1984,16 @@ bool RMLocation::loadLOX(RMDataStream &ds) { _buf->init(ds, dimx, dimy, true); // Number of items - ds >> _nItems; + _nItems = ds.readSint32LE(); // Create and read objects if (_nItems > 0) _items = new RMItem[_nItems]; - for (i = 0; i < _nItems && !ds.isError(); i++) + for (i = 0; i < _nItems && !ds.err(); i++) _items[i].readFromStream(ds, true); - return ds.isError(); + return ds.err(); } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index acfbd45cdb..7b0a2ddd6b 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -62,7 +62,7 @@ public: byte _data[1024]; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); + void readFromStream(Common::ReadStream &ds); }; @@ -79,14 +79,12 @@ public: RMSfx(); virtual ~RMSfx(); - friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); - void play(bool bLoop = false); void setVolume(int vol); void pause(bool bPause); void stop(); - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::ReadStream &ds, bool bLOX = false); }; @@ -116,13 +114,11 @@ public: byte _flag; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint pos() { return _pos; } - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::ReadStream &ds, bool bLOX = false); }; public: @@ -145,8 +141,6 @@ public: RMPattern(); virtual ~RMPattern(); - friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); - // A warning that the pattern now and the current int init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); @@ -162,7 +156,7 @@ public: return _curPos; } - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::ReadStream &ds, bool bLOX = false); private: void updateCoord(); @@ -185,13 +179,12 @@ public: virtual ~RMSprite(); void init(RMGfxSourceBuffer *buf); - friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void setPalette(byte *lpBuf); - void getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void getSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy); + void LOXGetSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy); - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::SeekableReadStream &ds, bool bLOX = false); }; @@ -241,8 +234,6 @@ public: RMItem(); virtual ~RMItem(); - friend RMDataStream &operator>>(RMDataStream &ds, RMItem &item); - // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame bool doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); @@ -296,7 +287,7 @@ public: void playSfx(int nSfx); - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::SeekableReadStream &ds, bool bLOX = false); void pauseSound(bool bPause); @@ -329,11 +320,7 @@ public: bool _bActive; bool _bReversed; -private: - void readFromStream(RMDataStream &ds); - -public: - friend RMDataStream &operator>>(RMDataStream &ds, RMBox &box); + void readFromStream(Common::ReadStream &ds); }; @@ -342,14 +329,12 @@ public: int _numbBox; RMBox *_boxes; -private: - void readFromStream(RMDataStream &ds); + void readFromStream(Common::ReadStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); - friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); void recalcAllAdj(); }; @@ -559,11 +544,8 @@ public: virtual ~RMLocation(); // Load variations - bool load(const char *lpszFileName); - bool load(Common::File &file); - bool load(const byte *buf); - bool load(RMDataStream &ds); - bool loadLOX(RMDataStream &ds); + bool load(Common::SeekableReadStream &ds); + bool loadLOX(Common::SeekableReadStream &ds); // Unload void unload(); diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index aa22456a4b..bfc97a5f3d 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -23,6 +23,7 @@ #include "tony/mpal/mpalutils.h" #include "tony/tony.h" +#include "common/memstream.h" namespace Tony { @@ -75,6 +76,10 @@ unsigned int RMRes::size() { return globalSize(_h); } +Common::SeekableReadStream *RMRes::getReadStream() { + return new Common::MemoryReadStream(_buf, size()); +} + /****************************************************************************\ * RMResRaw methods \****************************************************************************/ diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index 19810cf3a1..19e4fa7778 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -27,6 +27,10 @@ #include "common/scummsys.h" #include "tony/mpal/memory.h" +namespace Common { + class SeekableReadStream; +} + namespace Tony { namespace MPAL { @@ -47,6 +51,8 @@ public: // Casting for access to data operator const byte*(); + + Common::SeekableReadStream *getReadStream(); }; class RMResRaw : public RMRes { diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 8593ece480..9caa10bd46 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -87,7 +87,6 @@ RMGfxSourceBuffer *RMTony::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) void RMTony::init() { RMRes tony(0); RMRes body(9999); - RMDataStream ds; // Tony is shown by default _bShow = _bShowShadow = true; @@ -101,18 +100,18 @@ void RMTony::init() { _bIsStaticTalk = false; // Opens the buffer - ds.openBuffer(tony); + Common::SeekableReadStream *ds = tony.getReadStream(); // Reads his details from the stream - readFromStream(ds, true); + readFromStream(*ds, true); // Closes the buffer - ds.close(); + delete ds; // Reads Tony's body - ds.openBuffer(body); - _body.readFromStream(ds, true); - ds.close(); + ds = body.getReadStream(); + _body.readFromStream(*ds, true); + delete ds; _body.setPattern(0); _nTimeLastStep = g_vm->getTime(); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8dc1f5d615..a3f79decaf 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -35,360 +35,21 @@ namespace Tony { /** * Extracts a string from a data stream * @param df data stream - * @param var String */ -RMDataStream &operator>>(RMDataStream &df, Common::String &var) { +Common::String readString(Common::ReadStream &df) { + Common::String var; uint8 len; int i; - df >> len; + len = df.readByte(); for (i = 0; i < len; i++) { char c; - df >> c; + c = df.readByte(); var += c; } - return df; -} - -/****************************************************************************\ -* RMFileStreamSlow Methods -\****************************************************************************/ - -RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { - _stream = NULL; -} - -RMFileStreamSlow::~RMFileStreamSlow() { - close(); -} - -void RMFileStreamSlow::close() { - delete _stream; -} - -bool RMFileStreamSlow::openFile(Common::File &file) { - _stream = file.readStream(file.size()); - - _length = _stream->pos(); - - return true; -} - -bool RMFileStreamSlow::openFile(const char *lpFN) { - // Open file for reading - Common::File f; - if (!f.open(lpFN)) - return false; - - _length = f.size(); - _stream = f.readStream(f.size()); - - return true; -} - -RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { - seek(nBytes); - return *this; -} - -int RMFileStreamSlow::pos() { - return _stream->pos(); -} - -bool RMFileStreamSlow::isEOF() { - return (pos() >= _length); -} - -int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { - switch (where) { - case START: - return _stream->seek(nBytes); - - case END: - return _stream->seek(nBytes, SEEK_END); - - case CUR: - return _stream->seek(nBytes, SEEK_CUR); - - default: - return 0; - } -} - -bool RMFileStreamSlow::read(void *buf, int size) { - uint32 dwRead; - - dwRead = _stream->read(buf, size); - return ((int)dwRead == size); -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { - df.read(&var, 1); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.read(&var, 1); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { - uint16 v; - df.read(&v, 2); - v = FROM_LE_16(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { - uint16 v; - df.read(&v, 2); - var = (int16)FROM_LE_16(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { - int v; - df.read(&v, 4); - var = FROM_LE_32(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { - uint32 v; - df.read(&v, 4); - var = FROM_LE_32(v); - return df; -} - -/****************************************************************************\ -* RMDataStream methods -\****************************************************************************/ - -/** - * Constructor - */ -RMDataStream::RMDataStream() { - _length = 0; - _pos = 0; - _bError = false; - - _buf = NULL; - _ecode = 0; -} - -/** - * Destructor - */ -RMDataStream::~RMDataStream() { - close(); -} - -/** - * Close a stream - */ -void RMDataStream::close() { - _length = 0; - _pos = 0; -} - -/** - * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. - */ -void RMDataStream::openBuffer(const byte *lpBuf, int size) { - _length = size; - _buf = lpBuf; - _bError = false; - _pos = 0; -} - -/** - * Returns the length of the stream - * @returns Stream length - */ -int RMDataStream::length() { - return _length; -} - -/** - * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not - */ -bool RMDataStream::isEOF() { - return (_pos >= _length); -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, char &var) { - df.read(&var, 1); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint8 &var) { - df.read(&var, 1); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint16 &var) { - uint16 v; - df.read(&v, 2); - - var = FROM_LE_16(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, int16 &var) { - uint16 v; - df.read(&v, 2); - - var = (int16)FROM_LE_16(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, int &var) { - uint32 v; - df.read(&v, 4); - - var = (int)FROM_LE_32(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint32 &var) { - uint32 v; - df.read(&v, 4); - - var = FROM_LE_32(v); - return df; -} - -/** - * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not - */ -bool RMDataStream::read(void *lpBuf, int size) { - byte *dest = (byte *)lpBuf; - - if ((_pos + size) > _length) { - Common::copy(_buf + _pos, _buf + _pos + (_length - _pos), dest); - - return true; - } else { - Common::copy(_buf + _pos, _buf + _pos + size, dest); - - _pos += size; - return false; - } -} - -/** - * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream - */ -RMDataStream &RMDataStream::operator+=(int nBytes) { - _pos += nBytes; - return *this; -} - -/** - * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes - */ -int RMDataStream::seek(int nBytes, RMDSPos origin) { - switch (origin) { - case CUR: - break; - - case START: - _pos = 0; - break; - - case END: - if (_length == SIZENOTKNOWN) - return _pos; - _pos = _length; - break; - } - - _pos += nBytes; - return _pos; -} - -/** - * Returns the current position of the stream - * @returns The current position - */ -int RMDataStream::pos() { - return _pos; -} - -/** - * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise - */ -bool RMDataStream::isError() { - return _bError; -} - -/** - * Sets an error code for the stream - * @param code Error code - */ -void RMDataStream::setError(int code) { - _bError = true; - _ecode = code; -} - -/** - * Returns the error code for the stream - * @returns Error code - */ -int RMDataStream::getError() { - return _ecode; + return var; } /****************************************************************************\ @@ -507,9 +168,9 @@ bool RMPoint::operator!=(RMPoint p) { /** * Reads a point from a stream */ -RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { - ds >> p._x >> p._y; - return ds; +void RMPoint::readFromStream(Common::ReadStream &ds) { + _x = ds.readSint32LE(); + _y = ds.readSint32LE(); } /****************************************************************************\ @@ -663,9 +324,11 @@ void RMRect::normalizeRect() { setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } -RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { - ds >> rc._x1 >> rc._y1 >> rc._x2 >> rc._y2; - return ds; +void RMRect::readFromStream(Common::ReadStream &ds) { + _x1 = ds.readSint32LE(); + _y1 = ds.readSint32LE(); + _x2 = ds.readSint32LE(); + _y2 = ds.readSint32LE(); } /****************************************************************************\ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 50b18d8aa7..d3f93e06ef 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -39,113 +39,7 @@ namespace Tony { using namespace ::Tony::MPAL; -/** - * Data stream for reading data - */ -class RMDataStream { -protected: - const byte *_buf; - int _length; - int _pos; - bool _bError; - int _ecode; - -public: - enum RMDSPos { - CUR, - START, - END - }; - -private: - enum { - SIZENOTKNOWN = 0x7FFFFFFF - }; - -public: - // Constructor and destructor - RMDataStream(); - virtual ~RMDataStream(); - - // Loading buffer - void openBuffer(const byte *buf, int size = SIZENOTKNOWN); - void close(); - - // Attributei - int length(); - virtual int pos(); - - // EOF - virtual bool isEOF(); - - // Read methods - friend RMDataStream &operator>>(RMDataStream &df, char &var); - friend RMDataStream &operator>>(RMDataStream &df, byte &var); - friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int &var); - friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - - // General read - virtual bool read(void *buf, int size); - - // Skipping & Seeking - virtual RMDataStream &operator+=(int nBytes); - virtual int seek(int nBytes, RMDSPos origin = CUR); - - // Error handling - void setError(int ecode); - int getError(); - bool isError(); -}; - -/** - * Data stream per lettura di dati aperto da file - */ -class RMFileStream : public RMDataStream { -private: - byte *_buf; - -public: - RMFileStream(); - virtual ~RMFileStream(); - - // Methods for opening file - bool openFile(const char *lpFN); - bool openFile(Common::File &file); - - void close(); -}; - -class RMFileStreamSlow : public RMDataStream { -private: - Common::SeekableReadStream *_stream; -public: - RMFileStreamSlow(); - virtual ~RMFileStreamSlow(); - - bool openFile(const char *lpFN); - bool openFile(Common::File &file); - - void close(); - - RMDataStream &operator+=(int nBytes); - int seek(int nBytes, RMDSPos where = CUR); - - int pos(); - virtual bool isEOF(); - - bool read(void *buf, int size); - - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); -}; - -RMDataStream &operator>>(RMDataStream &df, Common::String &var); +Common::String readString(Common::ReadStream &ds); /** * Point class @@ -186,7 +80,7 @@ public: operator Common::Point() const; // Extraction from data streams - friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); + void readFromStream(Common::ReadStream &ds); }; class RMPointReference { @@ -256,7 +150,7 @@ public: } // Extract from data stream - friend RMDataStream &operator>>(RMDataStream &ds, RMRect &rc); + void readFromStream(Common::ReadStream &ds); }; /** -- cgit v1.2.3 From 23638a07d34c9d4c30e0b4e65b419c7862853e24 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 17:19:00 +0200 Subject: TONY: Fix crash with TA_PERORATE. --- engines/tony/game.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1ba8094ac4..e832b9687e 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1537,6 +1537,11 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; + // WORKAROUND: updateCursor gets called too early sometimes (for example, when + // the cursor is released over the TA_PERORATE option), via setAction. + if (_ctx->n > 4) + _ctx->n = 0; + _cursorHotspot = _hotspot[_ctx->n]; // Call the Draw method of the pointer -- cgit v1.2.3 From 9ebbeda949c0a4da2c5a3ecb588a718bb867c0d4 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 20:25:48 +0200 Subject: TONY: Implement some forgotten sound/music functions. --- engines/tony/tony.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b9d12beb11..05c195f8ba 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -518,13 +518,28 @@ void TonyEngine::closeMusic() { } void TonyEngine::pauseSound(bool bPause) { + _theEngine.pauseSound(bPause); + + for (uint i = 0; i < 6; i++) + if (_stream[i]) + _stream[i]->pause(bPause); + + for (uint i = 0; i < MAX_SFX_CHANNELS; i++) { + if (_sfx[i]) + _sfx[i]->pause(bPause); + if (_utilSfx[i]) + _utilSfx[i]->pause(bPause); + } } void TonyEngine::setMusicVolume(int nChannel, int volume) { + _stream[nChannel + GLOBALS._flipflop]->setVolume(volume); } int TonyEngine::getMusicVolume(int nChannel) { - return 255; + int volume; + _stream[nChannel + GLOBALS._flipflop]->getVolume(&volume); + return volume; } Common::String TonyEngine::getSaveStateFileName(int n) { -- cgit v1.2.3 From 3c986af9ce531f4d9cab889b196991be14cb88f6 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 22:10:10 +0200 Subject: TONY: Remove unnecessary mainloop mutex. Also, all the related freeze functions/members. --- engines/tony/adv.h | 2 -- engines/tony/custom.cpp | 56 ++-------------------------------------------- engines/tony/font.cpp | 4 ---- engines/tony/game.cpp | 8 ------- engines/tony/gfxengine.cpp | 26 --------------------- engines/tony/gfxengine.h | 5 ----- engines/tony/globals.cpp | 3 --- engines/tony/globals.h | 3 --- engines/tony/tony.cpp | 2 -- engines/tony/tonychar.cpp | 34 ---------------------------- 10 files changed, 2 insertions(+), 141 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index fe1dd32eae..8e497bc1f2 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -67,8 +67,6 @@ enum RMTonyAction { uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void mainLinkGraphicTask(RMGfxTask *task); -void mainFreeze(); -void mainUnfreeze(); void mainWaitFrame(CORO_PARAM); void mainShowMouse(); void mainHideMouse(); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index c73c7dec36..593d27655d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -374,15 +374,12 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); - GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? @@ -413,7 +410,6 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); GLOBALS._tony->hide(); - GLOBALS.Unfreeze(); for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS._input); @@ -474,11 +470,9 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { - GLOBALS.Freeze(); GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); - GLOBALS.Unfreeze(); MCharResetCodes(); ReapplyChangedHotspot(); @@ -514,9 +508,8 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 g_vm->stopMusic(4); - // On exit, unload and unfreeze + // On exit, unload CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -557,9 +550,6 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint GLOBALS.InitWipe(2); } - GLOBALS.Unfreeze(); - - _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!GLOBALS._bNoBullsEye) { @@ -626,9 +616,7 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->take(nDirection, 0); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -642,16 +630,12 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->take(nDirection, 1); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); - GLOBALS.Freeze(); GLOBALS._tony->take(nDirection, 2); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -662,9 +646,7 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->put(nDirection, 0); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -678,16 +660,12 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->put(nDirection, 1); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); - GLOBALS.Freeze(); GLOBALS._tony->put(nDirection, 2); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1250,10 +1228,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); - GLOBALS.Unfreeze(); } CORO_END_CODE; @@ -1315,10 +1291,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); - GLOBALS.Unfreeze(); } @@ -1336,10 +1310,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt._y = _ctx->startpt._y - _ctx->dimy; } - GLOBALS.Freeze(); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1392,10 +1364,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, while (g_vm->getTime() < _ctx->curTime + nScosse) { CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - GLOBALS.Unfreeze(); _ctx->i = g_vm->_randomSource.getRandomNumber(2); @@ -1405,10 +1375,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, _ctx->diry = -_ctx->diry; } - GLOBALS.Freeze(); GLOBALS._loc->setFixedScroll(RMPoint(0, 0)); GLOBALS._tony->setFixedScroll(RMPoint(0, 0)); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1471,16 +1439,12 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nChar]._startTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._startTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._talkPattern); - GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; @@ -1551,15 +1515,11 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } if (GLOBALS._character[nChar]._endTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._endTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._standPattern); - GLOBALS.Unfreeze(); delete _ctx->msg; CORO_END_CODE; @@ -1845,9 +1805,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nPers]._startTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._startTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } @@ -1925,9 +1883,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers != 0) { if (!GLOBALS._isMChar[nPers]) { if (GLOBALS._character[nPers]._endTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._endTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } @@ -2023,9 +1979,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos()); - GLOBALS.Unfreeze(); } // Hide the pointer @@ -2298,7 +2252,7 @@ DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uin } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS._bPatIrqFreeze = bStatus; + // Unused in ScummVM. } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2307,9 +2261,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); CORO_INVOKE_0(g_vm->openInitLoadMenu); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2320,9 +2272,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); CORO_INVOKE_0(g_vm->openInitOptions); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2575,8 +2525,6 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.LoadLocation = mainLoadLocation; GLOBALS.UnloadLocation = mainUnloadLocation; GLOBALS.LinkGraphicTask = mainLinkGraphicTask; - GLOBALS.Freeze = mainFreeze; - GLOBALS.Unfreeze = mainUnfreeze; GLOBALS.WaitFrame = mainWaitFrame; GLOBALS.PlayMusic = mainPlayMusic; GLOBALS.InitWipe = mainInitWipe; diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 41dfa1f7bf..ece418d9a8 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1072,10 +1072,8 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); - mainFreeze(); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; - mainUnfreeze(); } _ptDrawPos._y = _ctx->destpt._y; @@ -1116,10 +1114,8 @@ void RMDialogChoice::hide(CORO_PARAM) { _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); - mainFreeze(); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; - mainUnfreeze(); } } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index e832b9687e..1958adfaa0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -59,14 +59,6 @@ void mainLinkGraphicTask(RMGfxTask *task) { g_vm->getEngine()->linkGraphicTask(task); } -void mainFreeze() { - g_vm->getEngine()->freeze(); -} - -void mainUnfreeze() { - g_vm->getEngine()->unfreeze(); -} - void mainWaitFrame(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE); } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e8a5df29e9..da8218fa99 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -65,7 +65,6 @@ RMGfxEngine::RMGfxEngine() { _bigBuf.offsetY(RM_SKIPY); _bigBuf.setTrackDirtyRects(true); - _csMainLoop = NULL; _nCurLoc = 0; _curAction = TA_GOTO; _curActionObj = 0; @@ -86,7 +85,6 @@ RMGfxEngine::RMGfxEngine() { RMGfxEngine::~RMGfxEngine() { // Close the buffer _bigBuf.destroy(); - g_system->deleteMutex(_csMainLoop); } void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { @@ -144,8 +142,6 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_BEGIN_CODE(_ctx); - g_system->lockMutex(_csMainLoop); - // Poll of input devices _input.poll(); @@ -350,8 +346,6 @@ SKIPCLICKSINISTRO: } } - g_system->unlockMutex(_csMainLoop); - CORO_END_CODE; } @@ -367,11 +361,7 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { item = GLOBALS._gfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { - if (GLOBALS._bPatIrqFreeze) - mainFreeze(); item->setPattern(nPattern, true); - if (GLOBALS._bPatIrqFreeze) - mainUnfreeze(); } if (nStatus != -1) item->setStatus(nStatus); @@ -454,8 +444,6 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } - mainFreeze(); - _bLocationLoaded = false; _bigBuf.clearOT(); @@ -482,8 +470,6 @@ void RMGfxEngine::init() { g_vm->_window.getNewFrame(*this, NULL); g_vm->_window.repaint(); - GLOBALS._bPatIrqFreeze = true; - // Activate GUI _bGUIOption = true; _bGUIInterface = true; @@ -496,9 +482,6 @@ void RMGfxEngine::init() { _bWiping = false; _hWipeEvent = CoroScheduler.createEvent(false, false); - // Create the freeze event - _csMainLoop = g_system->createMutex(); - // Initialize the IRQ function for items for MPAL GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); @@ -549,14 +532,6 @@ void RMGfxEngine::disableMouse() { _bAlwaysDrawMouse = false; } -void RMGfxEngine::freeze() { - g_system->lockMutex(_csMainLoop); -} - -void RMGfxEngine::unfreeze() { - g_system->unlockMutex(_csMainLoop); -} - void CharsSaveAll(Common::OutSaveFile *f); void CharsLoadAll(Common::InSaveFile *f); void MCharResetCodes(); @@ -812,7 +787,6 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_2(unloadLocation, false, NULL); loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); _tony.setPattern(RMTony::PAT_STANDRIGHT); - mainUnfreeze(); // On older versions, need to an enter action if (_ctx->ver < 5) diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 7206496aaa..2e22e1ca62 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -63,7 +63,6 @@ private: int _nCurLoc; RMTonyAction _curAction; int _curActionObj; - OSystem::MutexRef _csMainLoop; int _nWipeType; uint32 _hWipeEvent; @@ -126,10 +125,6 @@ public: void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); int getCurrentLocation() const { return _nCurLoc; } - // Freeze and unfreeze - void freeze(); - void unfreeze(); - // State management void saveState(const Common::String &fn, byte *curThumb, const Common::String &name); void loadState(CORO_PARAM, const Common::String &fn); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index dd35d8c5ec..50ae2e529a 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -44,8 +44,6 @@ Globals::Globals() { LoadLocation = NULL; UnloadLocation = NULL; LinkGraphicTask = NULL; - Freeze = NULL; - Unfreeze = NULL; WaitFrame = NULL; PlayMusic = NULL; WaitWipeEnd = NULL; @@ -58,7 +56,6 @@ Globals::Globals() { _dwTonyNumTexts = 0; _bTonyInTexts = false; _bStaticTalk = false; - _bPatIrqFreeze = false; _bAlwaysDisplay = false; _bIdleExited = false; _bSkipSfxNoLoop = false; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 483ced1817..19276237c2 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -191,7 +191,6 @@ public: RMTextDialog *_curBackText; bool _bTonyIsSpeaking; int _curChangedHotspot; - bool _bPatIrqFreeze; bool _bCfgInvLocked; bool _bCfgInvNoScroll; bool _bCfgTimerizedText; @@ -227,8 +226,6 @@ public: uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); - void (*Freeze)(); - void (*Unfreeze)(); void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); void (*WaitWipeEnd)(CORO_PARAM); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 05c195f8ba..18eccf4615 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -556,10 +556,8 @@ void TonyEngine::autoSave(CORO_PARAM) { grabThumbnail(); CORO_INVOKE_0(mainWaitFrame); CORO_INVOKE_0(mainWaitFrame); - mainFreeze(); _ctx->buf = getSaveStateFileName(0); _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); - mainUnfreeze(); CORO_END_CODE; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 9caa10bd46..c80203fae2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -589,7 +589,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, if (_bShepherdess) { // Talking whilst a shepherdess - mainFreeze(); switch (_talkDirection) { case UP: setPattern(PAT_PAST_TALKUP); @@ -607,7 +606,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, setPattern(PAT_PAST_TALKRIGHT); break; } - mainUnfreeze(); return false; } @@ -1118,10 +1116,8 @@ void RMTony::startTalk(CORO_PARAM, CharacterTalkType nTalkType) { // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { - mainFreeze(); setPattern(_ctx->headStartPat); _body.setPattern(_ctx->bodyStartPat); - mainUnfreeze(); if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(_body.waitForEndPattern); @@ -1129,11 +1125,9 @@ void RMTony::startTalk(CORO_PARAM, CharacterTalkType nTalkType) { CORO_INVOKE_0(waitForEndPattern); } - mainFreeze(); setPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) _body.setPattern(_ctx->bodyLoopPat); - mainUnfreeze(); CORO_END_CODE; } @@ -1166,9 +1160,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa } if (_bShepherdess) { - mainFreeze(); setPattern(finalPat); - mainUnfreeze(); _bIsTalking = false; return false; } @@ -1437,7 +1429,6 @@ void RMTony::endTalk(CORO_PARAM) { // Handles the end of an animated and static, leaving everything unchanged if (_bIsStaticTalk) { if (_nTalkType == TALK_WITHBEARDSTATIC) { - mainFreeze(); setPattern(0); if (_talkDirection == UP || _talkDirection == LEFT) { _body.setPattern(BPAT_WITHBEARDLEFT_STATIC); @@ -1446,11 +1437,8 @@ void RMTony::endTalk(CORO_PARAM) { _body.setPattern(BPAT_WITHBEARDRIGHT_STATIC); _nBodyOffset.set(-26, -14); } - mainUnfreeze(); } else { - mainFreeze(); setPattern(_ctx->headStandPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); } @@ -1461,36 +1449,26 @@ void RMTony::endTalk(CORO_PARAM) { // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { - mainFreeze(); setPattern(_ctx->headEndPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); - mainFreeze(); _body.setPattern(_ctx->bodyEndPat); - mainUnfreeze(); CORO_INVOKE_0(waitForEndPattern); CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->bodyEndPat != 0) { - mainFreeze(); setPattern(_ctx->headStandPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); - mainFreeze(); _body.setPattern(_ctx->bodyEndPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(_body.waitForEndPattern); - mainFreeze(); setPattern(_ctx->headEndPat); - mainUnfreeze(); CORO_INVOKE_0(waitForEndPattern); } else { @@ -1498,10 +1476,8 @@ void RMTony::endTalk(CORO_PARAM) { } if (_ctx->finalPat != 0) { - mainFreeze(); _body.setPattern(0); setPattern(_ctx->finalPat); - mainUnfreeze(); } _bIsTalking = false; @@ -1733,19 +1709,15 @@ void RMTony::startStatic(CORO_PARAM, CharacterTalkType nTalk) { // e vai con i pattern _bIsStaticTalk = true; - mainFreeze(); setPattern(_ctx->headPat); _body.setPattern(_ctx->bodyStartPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); CORO_INVOKE_0(waitForEndPattern); - mainFreeze(); if (_ctx->headLoopPat != -1) setPattern(_ctx->headLoopPat); _body.setPattern(_ctx->bodyLoopPat); - mainUnfreeze(); CORO_END_CODE; } @@ -1902,24 +1874,18 @@ void RMTony::endStatic(CORO_PARAM, CharacterTalkType nTalk) { endStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); if (_ctx->headEndPat != 0) { - mainFreeze(); setPattern(_ctx->headEndPat); - mainUnfreeze(); CORO_INVOKE_0(waitForEndPattern); } else { // Play please - mainFreeze(); _body.setPattern(_ctx->bodyEndPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); } - mainFreeze(); setPattern(_ctx->finalPat); _body.setPattern(0); - mainUnfreeze(); _bIsStaticTalk = false; -- cgit v1.2.3 From 142ac7600f61e193612ec81c7fd7070ec2ca5c0e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 22:28:44 +0200 Subject: TONY: Remove most of the remaining global functions. --- engines/tony/adv.h | 13 ------- engines/tony/custom.cpp | 87 +++++++++++++++++++++-------------------------- engines/tony/debugger.cpp | 4 +-- engines/tony/font.cpp | 4 +-- engines/tony/game.cpp | 52 ---------------------------- engines/tony/globals.cpp | 9 ----- engines/tony/globals.h | 9 ----- engines/tony/loc.cpp | 4 +-- engines/tony/tony.cpp | 4 +-- 9 files changed, 47 insertions(+), 139 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 8e497bc1f2..e3171aa3ee 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -64,21 +64,8 @@ enum RMTonyAction { }; // Global Functions -uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); -void mainLinkGraphicTask(RMGfxTask *task); -void mainWaitFrame(CORO_PARAM); -void mainShowMouse(); -void mainHideMouse(); -void mainEnableInput(); -void mainDisableInput(); -void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); -void mainInitWipe(int type); -void mainCloseWipe(); -void mainWaitWipeEnd(CORO_PARAM); void mainEnableGUI(); void mainDisableGUI(); -void mainSetPerorate(bool bPerorate); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 593d27655d..27de5cf717 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -186,7 +186,7 @@ DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(TonySetPerorate)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.SetPerorate(bStatus); + g_vm->getEngine()->setPerorate(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { @@ -324,7 +324,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } // Record the text - GLOBALS.LinkGraphicTask(&_ctx->text); + g_vm->getEngine()->linkGraphicTask(&_ctx->text); if (_ctx->curVoc) { if (_ctx->i == 0) { @@ -376,9 +376,9 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); _ctx->h = mpalQueryDoAction(0, nLoc, 0); @@ -408,7 +408,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 if (GLOBALS._bSkipIdle) return; - CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, false, NULL); GLOBALS._tony->hide(); for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { @@ -436,8 +436,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->text.forceTime(); // Record the text - GLOBALS.LinkGraphicTask(&_ctx->clear); - GLOBALS.LinkGraphicTask(&_ctx->text); + g_vm->getEngine()->linkGraphicTask(&_ctx->clear); + g_vm->getEngine()->linkGraphicTask(&_ctx->text); // Wait for the end of display _ctx->text.setCustomSkipHandle(GLOBALS._hSkipIdle); @@ -457,20 +457,20 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) CORO_BEGIN_CODE(_ctx); - GLOBALS.LinkGraphicTask(&_ctx->clear); + g_vm->getEngine()->linkGraphicTask(&_ctx->clear); - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); // WORKAROUND: This fixes a bug in the original source where the linked clear task // didn't have time to be drawn and removed from the draw list before the method // ended, thus remaining in the draw list and causing a later crash - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { - GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); @@ -502,14 +502,14 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); if (!GLOBALS._bNoBullsEye) { - GLOBALS.InitWipe(1); - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + g_vm->getEngine()->initWipe(1); + CORO_INVOKE_0(g_vm->getEngine()->waitWipeEnd); } g_vm->stopMusic(4); // On exit, unload - CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, true, NULL); CORO_END_CODE; } @@ -523,8 +523,8 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); if (!GLOBALS._bNoBullsEye) { - GLOBALS.InitWipe(1); - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + g_vm->getEngine()->initWipe(1); + CORO_INVOKE_0(g_vm->getEngine()->waitWipeEnd); } if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { @@ -532,13 +532,13 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } // On exit, unfreeze - CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, true, NULL); GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { GLOBALS._lastTappeto = GLOBALS._ambiance[nLoc]; @@ -547,14 +547,14 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (!GLOBALS._bNoBullsEye) { - GLOBALS.InitWipe(2); + g_vm->getEngine()->initWipe(2); } _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!GLOBALS._bNoBullsEye) { - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); - GLOBALS.CloseWipe(); + CORO_INVOKE_0(g_vm->getEngine()->waitWipeEnd); + g_vm->getEngine()->closeWipe(); } GLOBALS._bNoBullsEye = false; @@ -589,11 +589,11 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, } DECLARE_CUSTOM_FUNCTION(DisableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - mainDisableInput(); + g_vm->getEngine()->disableInput(); } DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - mainEnableInput(); + g_vm->getEngine()->enableInput(); } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1226,7 +1226,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->pt.offset(0, -(int32)sY); } - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); @@ -1289,7 +1289,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); @@ -1362,7 +1362,7 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, _ctx->diry = 1; while (g_vm->getTime() < _ctx->curTime + nScosse) { - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); @@ -1486,7 +1486,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } // Record the text - GLOBALS.LinkGraphicTask(_ctx->text); + g_vm->getEngine()->linkGraphicTask(_ctx->text); if (_ctx->curVoc) { g_vm->_theSound.createSfx(&_ctx->voice); @@ -1695,7 +1695,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } // Record the text - GLOBALS.LinkGraphicTask(_ctx->text); + g_vm->getEngine()->linkGraphicTask(_ctx->text); if (_ctx->curVoc) { g_vm->_theSound.createSfx(&_ctx->voice); @@ -1862,7 +1862,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->forceTime(); } _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); - GLOBALS.LinkGraphicTask(_ctx->text); + g_vm->getEngine()->linkGraphicTask(_ctx->text); if (_ctx->curVoc) { _ctx->voice->play(); @@ -1970,20 +1970,20 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Activate the object - GLOBALS.LinkGraphicTask(&_ctx->dc); + g_vm->getEngine()->linkGraphicTask(&_ctx->dc); CORO_INVOKE_0(_ctx->dc.show); // Draw the pointer GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_NONE); - mainShowMouse(); + g_vm->getEngine()->enableMouse(); while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos()); } // Hide the pointer - mainHideMouse(); + g_vm->getEngine()->disableMouse(); CORO_INVOKE_0(_ctx->dc.hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); @@ -2158,7 +2158,7 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int if (nSync == 0) nSync = 2000; debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "Start CustPlayMusic"); - GLOBALS.PlayMusic(nChannel, mFN, nFX, bLoop, nSync); + g_vm->playMusic(nChannel, mFN, nFX, bLoop, nSync); debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "End CustPlayMusic"); } @@ -2324,13 +2324,13 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text[_ctx->i].setCustomSkipHandle(_ctx->hDisable); // Record the text - GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); + g_vm->getEngine()->linkGraphicTask(&_ctx->text[_ctx->i]); } _ctx->startTime = g_vm->getTime(); while (_ctx->startTime + dwTime * 1000 > g_vm->getTime()) { - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); if (GLOBALS._input->mouseLeftClicked() || GLOBALS._input->mouseRightClicked()) break; if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) @@ -2339,8 +2339,8 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CoroScheduler.setEvent(_ctx->hDisable); - CORO_INVOKE_0(GLOBALS.WaitFrame); - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); delete[] _ctx->text; delete _ctx->msg; @@ -2522,17 +2522,8 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS._inventory = inv; GLOBALS._input = input; - GLOBALS.LoadLocation = mainLoadLocation; - GLOBALS.UnloadLocation = mainUnloadLocation; - GLOBALS.LinkGraphicTask = mainLinkGraphicTask; - GLOBALS.WaitFrame = mainWaitFrame; - GLOBALS.PlayMusic = mainPlayMusic; - GLOBALS.InitWipe = mainInitWipe; - GLOBALS.CloseWipe = mainCloseWipe; - GLOBALS.WaitWipeEnd = mainWaitWipeEnd; GLOBALS.DisableGUI = mainDisableGUI; GLOBALS.EnableGUI = mainEnableGUI; - GLOBALS.SetPerorate = mainSetPerorate; GLOBALS._bAlwaysDisplay = false; int i; diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 6355284ece..85d9469519 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -68,9 +68,9 @@ void DebugChangeScene(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, false, &result); - GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); mainEnableGUI(); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index ece418d9a8..89cf2ffa1b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1071,7 +1071,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; } @@ -1113,7 +1113,7 @@ void RMDialogChoice::hide(CORO_PARAM) { _ctx->deltay = 480 - _ptDrawPos._y; _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1958adfaa0..00c0a1ad7a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,54 +47,6 @@ using namespace MPAL; /* Global functions */ /****************************************/ -uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return g_vm->getEngine()->loadLocation(nLoc, pt, start); -} - -void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - g_vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); -} - -void mainLinkGraphicTask(RMGfxTask *task) { - g_vm->getEngine()->linkGraphicTask(task); -} - -void mainWaitFrame(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE); -} - -void mainShowMouse() { - g_vm->getEngine()->enableMouse(); -} - -void mainHideMouse() { - g_vm->getEngine()->disableMouse(); -} - -void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { - g_vm->playMusic(nChannel, filename, nFX, bLoop, nSync); -} - -void mainDisableInput() { - g_vm->getEngine()->disableInput(); -} - -void mainEnableInput() { - g_vm->getEngine()->enableInput(); -} - -void mainInitWipe(int type) { - g_vm->getEngine()->initWipe(type); -} - -void mainCloseWipe() { - g_vm->getEngine()->closeWipe(); -} - -void mainWaitWipeEnd(CORO_PARAM) { - g_vm->getEngine()->waitWipeEnd(coroParam); -} - void mainEnableGUI() { g_vm->getEngine()->_bGUIInterface = true; g_vm->getEngine()->_bGUIInventory = true; @@ -107,10 +59,6 @@ void mainDisableGUI() { g_vm->getEngine()->_bGUIOption = false; } -void mainSetPerorate(bool bPerorate) { - g_vm->getEngine()->setPerorate(bPerorate); -} - /****************************************************************************\ * RMOptionButton Methods \****************************************************************************/ diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 50ae2e529a..8e4ae240a0 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -41,17 +41,8 @@ Globals::Globals() { _inventory = NULL; _input = NULL; _gfxEngine = NULL; - LoadLocation = NULL; - UnloadLocation = NULL; - LinkGraphicTask = NULL; - WaitFrame = NULL; - PlayMusic = NULL; - WaitWipeEnd = NULL; - CloseWipe = NULL; - InitWipe = NULL; EnableGUI = NULL; DisableGUI = NULL; - SetPerorate = NULL; _dwTonyNumTexts = 0; _bTonyInTexts = false; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 19276237c2..e353d40f3b 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -223,17 +223,8 @@ public: RMInput *_input; RMGfxEngine *_gfxEngine; - uint32(*LoadLocation)(int, RMPoint, RMPoint start); - void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); - void (*LinkGraphicTask)(RMGfxTask *task); - void (*WaitFrame)(CORO_PARAM); - void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); - void (*WaitWipeEnd)(CORO_PARAM); - void (*CloseWipe)(); - void (*InitWipe)(int type); void (*EnableGUI)(); void (*DisableGUI)(); - void (*SetPerorate)(bool bpal); uint32 _dwTonyNumTexts; bool _bTonyInTexts; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 32c857ceaa..d8548cc570 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -808,8 +808,8 @@ void RMWipe::waitForFadeEnd(CORO_PARAM) { _bEndFade = true; _bFading = false; - CORO_INVOKE_0(mainWaitFrame); - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); CORO_END_CODE; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 18eccf4615..bb28848362 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -554,8 +554,8 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); grabThumbnail(); - CORO_INVOKE_0(mainWaitFrame); - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); _ctx->buf = getSaveStateFileName(0); _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); -- cgit v1.2.3 From cdeecf1521e95a8ad250bc18a398b32fd2886c36 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 28 Aug 2012 22:47:10 +0200 Subject: TONY: Replace overlapping memcpy with memmove --- engines/tony/mpal/expr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index eb6b485ef6..772d3da075 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -191,7 +191,7 @@ static void solve(LPEXPRESSION one, int num) { two = one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { two->val.num = Compute(one->val.num, two->val.num, one->symbol); - memcpy(one, two, (num - 1) * sizeof(EXPRESSION)); + memmove(one, two, (num - 1) * sizeof(EXPRESSION)); --num; } else { j = 1; @@ -203,7 +203,7 @@ static void solve(LPEXPRESSION one, int num) { } three->val.num = Compute(two->val.num, three->val.num, two->symbol); - memcpy(two, three, (num - j - 1) * sizeof(EXPRESSION)); + memmove(two, three, (num - j - 1) * sizeof(EXPRESSION)); --num; } } -- cgit v1.2.3 From 56f4bc0225653be13813c662115b67152e78cf1a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 28 Aug 2012 23:05:48 +0200 Subject: TONY: Fix some for and if statements with bad coding style --- engines/tony/custom.cpp | 18 +++++++---- engines/tony/game.cpp | 22 +++++++++----- engines/tony/gfxcore.cpp | 17 +++++++---- engines/tony/inventory.cpp | 3 +- engines/tony/loc.cpp | 24 ++++++++++----- engines/tony/mpal/loadmpc.cpp | 3 +- engines/tony/mpal/mpal.cpp | 70 ++++++++++++++++++++++++++++--------------- engines/tony/sound.cpp | 17 +++++++---- engines/tony/tony.cpp | 3 +- 9 files changed, 119 insertions(+), 58 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 27de5cf717..9aef809826 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -237,9 +237,10 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { if (g_vm->_voices.size() == 0) return NULL; - for (uint i = 0; i < g_vm->_voices.size(); i++) + for (uint i = 0; i < g_vm->_voices.size(); i++) { if (g_vm->_voices[i]._code == code) return &g_vm->_voices[i]; + } return NULL; } @@ -1208,21 +1209,25 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; - if (_ctx->lx < 0) _ctx->lx = 0; + if (_ctx->lx < 0) + _ctx->lx = 0; _ctx->pt.offset((int32)sX, 0); } else if (_ctx->lx < 0) { _ctx->lx += (int32)sX; - if (_ctx->lx > 0) _ctx->lx = 0; + if (_ctx->lx > 0) + _ctx->lx = 0; _ctx->pt.offset(-(int32)sX, 0); } if (_ctx->ly > 0) { _ctx->ly -= sY; - if (_ctx->ly < 0) _ctx->ly = 0; + if (_ctx->ly < 0) + _ctx->ly = 0; _ctx->pt.offset(0, sY); } else if (_ctx->ly < 0) { _ctx->ly += sY; - if (_ctx->ly > 0) _ctx->ly = 0; + if (_ctx->ly > 0) + _ctx->ly = 0; _ctx->pt.offset(0, -(int32)sY); } @@ -1493,7 +1498,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess g_vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); - if (bIsBack) _ctx->voice->setVolume(55); + if (bIsBack) + _ctx->voice->setVolume(55); _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); _ctx->curOffset = g_vm->_vdbFP.pos(); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00c0a1ad7a..c17b611b0c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -476,11 +476,16 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { CORO_INVOKE_0(drawOT); if (_nState == MENULOAD || _nState == MENUSAVE) { - if (_ctx->thumb) delete _ctx->thumb; - if (_ctx->title) delete _ctx->title; + if (_ctx->thumb) + delete _ctx->thumb; - for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (_ctx->num[_ctx->i]) delete _ctx->num[_ctx->i]; + if (_ctx->title) + delete _ctx->title; + + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { + if (_ctx->num[_ctx->i]) + delete _ctx->num[_ctx->i]; + } } CORO_END_CODE; @@ -1049,13 +1054,14 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } } - for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) { if (KEYPRESS(Common::KEYCODE_LSHIFT) || KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } + } for (_ctx->i = 0; _ctx->i < 10 && strlen(_editName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); @@ -1203,9 +1209,10 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } } - if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { if (!_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) close(); + } if (_ctx->bRefresh) CORO_INVOKE_0(refreshAll); @@ -1475,7 +1482,8 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim // Check the pointer _ctx->n = _nCurPointer; - if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; + if (_ctx->n == TA_COMBINE) + _ctx->n = TA_USE; // WORKAROUND: updateCursor gets called too early sometimes (for example, when // the cursor is released over the TA_PERORATE option), via setAction. diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 44befa3755..2e368bbc64 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -648,9 +648,14 @@ int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) { g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1); b = (GETBLUE(fore) >> 2) + (GETBLUE(back) >> 1); - if (r > 0x1F) r = 0x1F; - if (g > 0x1F) g = 0x1F; - if (b > 0x1F) b = 0x1F; + if (r > 0x1F) + r = 0x1F; + + if (g > 0x1F) + g = 0x1F; + + if (b > 0x1F) + b = 0x1F; return (r << 10) | (g << 5) | b; } @@ -1717,7 +1722,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri */ mybuf = &buf[x1]; - for (x = 0; x < width; x++, mybuf += step) + for (x = 0; x < width; x++, mybuf += step) { if (_aabuf[(y + v) * _dimx + x + u] == 2 && x != 0 && x != width - 1) { r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); @@ -1737,6 +1742,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } + } // Skip to the next line buf += bigBuf.getDimx(); @@ -1756,7 +1762,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri */ mybuf = &buf[x1]; - for (x = 0; x < width; x++, mybuf += step) + for (x = 0; x < width; x++, mybuf += step) { if (_aabuf[(y + v) * _dimx + x + u] == 1 && x != 0 && x != width - 1) { r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); @@ -1776,6 +1782,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } + } // Skip to the next line buf += bigBuf.getDimx(); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index dbd3ad6840..647e4264c7 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -763,9 +763,10 @@ int RMInterface::onWhichBox(RMPoint pt) { max = 5; // Find the verb - for (i = 0; i < max; i++) + for (i = 0; i < max; i++) { if (_hotbbox[i].ptInRect(pt)) return i; + } // Found no verb return -1; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d8548cc570..6401e1337f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -141,7 +141,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { // Check for sound: // If the slot is 0, play - // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter + // If speed == 0, must play unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop for (i = 0; i < _nSlots; i++) { if (_slots[i]._type == SOUND) { @@ -1108,7 +1108,9 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin } } - if (minimo == 32000) trovato = punto; + if (minimo == 32000) + trovato = punto; + return trovato; } @@ -1137,11 +1139,13 @@ short RMCharacter::scanLine(const RMPoint &punto) { if (Ldx > Ldy) { Lslope = Lfy / Lfx; - if (Lend._x < Lstart._x) Lspeed = -Lspeed; + if (Lend._x < Lstart._x) + Lspeed = -Lspeed; Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend._y < Lstart._y) Lspeed = - Lspeed; + if (Lend._y < Lstart._y) + Lspeed = - Lspeed; Lstatus = 0; } @@ -1777,11 +1781,13 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { if (!cur) return -1; - for (i = 0; i < cur->_numbBox; i++) - if (cur->_boxes[i]._bActive) + for (i = 0; i < cur->_numbBox; i++) { + if (cur->_boxes[i]._bActive) { if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) return i; + } + } return -1; } @@ -2053,9 +2059,10 @@ void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) { RMItem *RMLocation::getItemFromCode(uint32 dwCode) { int i; - for (i = 0; i < _nItems; i++) + for (i = 0; i < _nItems; i++) { if (_items[i].mpalCode() == (int)dwCode) return &_items[i]; + } return NULL; } @@ -2133,9 +2140,10 @@ void RMLocation::updateScrolling(const RMPoint &ptShowThis) { if (_curScroll._y + RM_SY > _buf->getDimy()) _curScroll._y = _buf->getDimy() - RM_SY; - if (oldScroll != _curScroll) + if (oldScroll != _curScroll) { for (int i = 0; i < _nItems; i++) _items[i].setScrollPosition(_curScroll); + } } void RMLocation::setFixedScroll(const RMPoint &scroll) { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index ed4ad9d228..2d2f8ecd00 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -628,9 +628,10 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0;i < GLOBALS._nDialogs; i++) + for (i = 0;i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) return false; + } globalUnlock(GLOBALS._hDialogs); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 16d8a3213b..721552b80c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -224,9 +224,10 @@ static int msgGetOrderFromNum(uint32 nMsg) { int i; LPMPALMSG msg = GLOBALS._lpmmMsgs; - for (i = 0; i < GLOBALS._nMsgs; i++, msg++) + for (i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) return i; + } return -1; } @@ -242,9 +243,10 @@ static int itemGetOrderFromNum(uint32 nItem) { int i; LPMPALITEM item = GLOBALS._lpmiItems; - for (i = 0; i < GLOBALS._nItems; i++, item++) + for (i = 0; i < GLOBALS._nItems; i++, item++) { if (item->nObj == nItem) return i; + } return -1; } @@ -261,9 +263,10 @@ static int scriptGetOrderFromNum(uint32 nScript) { int i; LPMPALSCRIPT script = GLOBALS._lpmsScripts; - for (i = 0; i < GLOBALS._nScripts; i++, script++) + for (i = 0; i < GLOBALS._nScripts; i++, script++) { if (script->nObj == nScript) return i; + } return -1; } @@ -280,9 +283,10 @@ static int dialogGetOrderFromNum(uint32 nDialog) { int i; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; - for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) + for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) { if (dialog->nObj == nDialog) return i; + } return -1; } @@ -333,14 +337,15 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int i, j; - for (j = 0; dialog->_periods[j] != NULL; j++) + for (j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { /* Found the phrase, it should be duplicated */ origmsg = (const char *)globalLock(dialog->_periods[j]); /* Calculate the length and allocate memory */ i = 0; - while (origmsg[i] != '\0') i++; + while (origmsg[i] != '\0') + i++; clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); if (clonemsg == NULL) @@ -352,7 +357,8 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { return clonemsg; } - + } + return NULL; } @@ -415,9 +421,10 @@ static uint32 *getSelectList(uint32 i) { /* Count how many are active selects */ num = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) num++; + } /* If there are 0, it's a mistake */ if (num == 0) @@ -429,9 +436,10 @@ static uint32 *getSelectList(uint32 i) { /* Copy all the data inside the active select list */ k = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) sl[k++] = dialog->_choice[i]._select[j].dwData; + } sl[k] = (uint32)NULL; return sl; @@ -690,7 +698,8 @@ void ActionThread(CORO_PARAM, const void *param) { LPMPALITEM item; ~CoroContextTag() { - if (item) globalDestroy(item); + if (item) + globalDestroy(item); } CORO_END_CONTEXT(_ctx); @@ -844,14 +853,16 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { _ctx->ord = itemGetOrderFromNum(_ctx->il[_ctx->i]); - if (_ctx->ord == -1) continue; + if (_ctx->ord == -1) + continue; _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { if (_ctx->curItem->Action[_ctx->j].num == 0xFF) _ctx->k++; + } _ctx->nIdleActions += _ctx->k; @@ -928,12 +939,13 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curTime = g_vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; - for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) + for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) { if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->dwSleepTime = 0; break; - } else + } else _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); + } /* We fall alseep, but always checking that the event is set when prompted for closure */ CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); @@ -942,7 +954,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (!_ctx->expired) break; - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); @@ -950,11 +962,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (!_ctx->delayExpired) _ctx->MyThreads[_ctx->i].nItem = 0; } + } _ctx->curTime = g_vm->getTime(); /* Loop through all the necessary idle actions */ - for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) + for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; @@ -966,9 +979,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { continue; /* Check to see if there already another idle funning running on the item */ - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; + } if (_ctx->i < _ctx->nRealItems) continue; @@ -979,11 +993,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; - if (_ctx->curItem->Action[_ctx->j].when != NULL) + if (_ctx->curItem->Action[_ctx->j].when != NULL) { if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { unlockItems(); continue; } + } /* Ok, we can perform the action. For convenience, we do it in a new process */ _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); @@ -1004,9 +1019,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->newItem->dwRes=_ctx->j; /* We will create an action, and will provide the necessary details */ - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == 0) break; + } _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; @@ -1024,13 +1040,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Skip all idle actions of the same item */ } } + } } // Set idle skip on CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); @@ -1041,6 +1058,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { */ CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } + } // Set idle skip off CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); @@ -1178,9 +1196,10 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Search the choice between those required in the dialog */ - for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) break; + } /* If nothing has been found, exit with an error */ if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { @@ -1200,7 +1219,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; /* Calculate the expression of each selection, to see if they're active or inactive */ - for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; _ctx->k++; @@ -1209,6 +1228,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k++; } else _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; + } /* If there are no choices activated, then the dialog is finished. */ if (_ctx->k == 0) { @@ -1373,9 +1393,10 @@ bool doSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) break; + } if (dialog->_choice[i]._select[j].dwData == 0) return false; @@ -2020,9 +2041,10 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { bool mpalStartIdlePoll(int nLoc) { uint32 i; - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) + for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == (uint32)nLoc) return false; + } for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == 0) { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 8ea7aa03c3..3a1c6746c8 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -339,6 +339,7 @@ void FPSfx::pause(bool bPause) { void FPSfx::setVolume(int dwVolume) { if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; @@ -349,7 +350,8 @@ void FPSfx::setVolume(int dwVolume) { dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) + dwVolume = 0; } } else { if (!GLOBALS._bCfgSFX) @@ -655,15 +657,20 @@ void FPStream::pause(bool bPause) { */ void FPStream::setVolume(int dwVolume) { - if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume > 63) + dwVolume = 63; + + if (dwVolume < 0) + dwVolume = 0; _lastVolume = dwVolume; - if (!GLOBALS._bCfgMusic) dwVolume = 0; + if (!GLOBALS._bCfgMusic) + dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgMusicVolume) * 2; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) + dwVolume = 0; } if (g_system->getMixer()->isSoundHandleActive(_handle)) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index bb28848362..79300ca1ee 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -281,9 +281,10 @@ void TonyEngine::GUIError(const Common::String &msg) { } void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, bool bLoop, int nSync) { - if (nChannel < 4) + if (nChannel < 4) { if (GLOBALS._flipflop) nChannel = nChannel + 1; + } switch (nFX) { case 0: -- cgit v1.2.3 From d2b33ca4cce2794e7b4fcf3ccb3f00dc74fff68d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 28 Aug 2012 23:25:50 +0200 Subject: TONY: Janitorial - remove trailing spaces --- engines/tony/game.cpp | 8 ++--- engines/tony/mpal/expr.cpp | 16 +++++----- engines/tony/mpal/expr.h | 2 +- engines/tony/mpal/loadmpc.cpp | 8 ++--- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/mpal.cpp | 70 +++++++++++++++++++++---------------------- engines/tony/mpal/mpal.h | 44 +++++++++++++-------------- engines/tony/mpal/mpaldll.h | 2 +- engines/tony/sound.cpp | 14 ++++----- engines/tony/sound.h | 16 +++++----- engines/tony/utils.cpp | 6 ++-- 11 files changed, 94 insertions(+), 94 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c17b611b0c..0793d97215 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1513,8 +1513,8 @@ int RMPointer::curAction() { return _nCurPointer; } -/** - * Show the cursor +/** + * Show the cursor */ void RMPointer::showCursor() { if (!CursorMan.isVisible()) { @@ -1524,8 +1524,8 @@ void RMPointer::showCursor() { } } -/** - * Hide the cursor +/** + * Hide the cursor */ void RMPointer::hideCursor() { if (CursorMan.isVisible()) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 772d3da075..ef58208d3f 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -88,7 +88,7 @@ typedef struct { byte type; // Tipo di oggetto (vedi enum ExprListTypes) byte unary; // Unary operatore (NON SUPPORTATO) - union { + union { int num; // Numero (se type==ELT_NUMBER) char *name; // Nome variabile (se type==ELT_VAR) HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) @@ -179,7 +179,7 @@ static int Compute(int a, int b, byte symbol) { GLOBALS._mpalError = 1; break; } - + return 0; } @@ -211,7 +211,7 @@ static void solve(LPEXPRESSION one, int num) { /** - * Calculates the result of a mathematical expression, replacing the current + * Calculates the result of a mathematical expression, replacing the current * value of any variable. * * @param expr Pointer to an expression duplicated by DuplicateExpression @@ -253,7 +253,7 @@ static int evaluateAndFreeExpression(byte *expr) { * Parses a mathematical expression from the MPC file * * @param buf Buffer containing the expression to evaluate - * @param h Pointer to a handle that, at the end of execution, + * @param h Pointer to a handle that, at the end of execution, * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ @@ -377,7 +377,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } break; - + case ELT_VAR: if (strcmp(one->val.name, two->val.name) != 0) { globalUnlock(h1); @@ -385,7 +385,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } break; - + case ELT_PARENTH: if (!compareExpressions(one->val.son, two->val.son)) { globalUnlock(h1); @@ -395,13 +395,13 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; } - ++one; + ++one; ++two; } globalUnlock(h1); globalUnlock(h2); - + return true; } diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 3130539000..f9c8a7c48f 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -43,7 +43,7 @@ namespace MPAL { * Parses a mathematical expression from the MPC file * * @param buf Buffer containing the expression to evaluate - * @param h Pointer to a handle that, at the end of execution, + * @param h Pointer to a handle that, at the end of execution, * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 2d2f8ecd00..9da2cc121e 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -157,7 +157,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; - + if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); @@ -252,7 +252,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } } - if (kk == curCmd) { + if (kk == curCmd) { lpmdDialog->_group[i].CmdNum[j] = curCmd; curCmd++; } @@ -445,7 +445,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - if (kk == curCmd) { + if (kk == curCmd) { lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; @@ -520,7 +520,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) //@{ /** - * Reads and interprets the MPC file, and create structures for various directives + * Reads and interprets the MPC file, and create structures for various directives * in the global variables * * @param lpBuf Buffer containing the MPC file data, excluding the header. diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index b805b1e7a1..c0e2ca7fb5 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -38,7 +38,7 @@ namespace MPAL { \****************************************************************************/ /** - * Reads and interprets the MPC file, and create structures for various directives + * Reads and interprets the MPC file, and create structures for various directives * in the global variables * * @param lpBuf Buffer containing the MPC file data, excluding the header. diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 721552b80c..be2f6db43f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -31,7 +31,7 @@ #include "common/savefile.h" #include "common/system.h" #include "tony/tony.h" -#include "tony/mpal/lzo.h" +#include "tony/mpal/lzo.h" #include "tony/mpal/mpal.h" #include "tony/mpal/mpaldll.h" @@ -358,7 +358,7 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { return clonemsg; } } - + return NULL; } @@ -551,7 +551,7 @@ static LPITEM getItemData(uint32 nOrdItem) { dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); - + if (ret->_frames[i] == NULL) return NULL; memcpy(ret->_frames[i], dat, dim); @@ -570,7 +570,7 @@ static LPITEM getItemData(uint32 nOrdItem) { } -/** +/** * Thread that calls a custom function. It is used in scripts, so that each script * function is executed without delaying the others. * @@ -685,7 +685,7 @@ void ScriptThread(CORO_PARAM, const void *param) { /** - * Thread that performs an action on an item. the thread always executes the action, + * Thread that performs an action on an item. the thread always executes the action, * so it should create a new item in which the action is the one required. * Furthermore, the expression is not checked, but it is always performed the action. * @@ -745,7 +745,7 @@ void ActionThread(CORO_PARAM, const void *param) { globalDestroy(_ctx->item); _ctx->item = NULL; - + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); CORO_END_CODE; @@ -855,7 +855,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->ord == -1) continue; - + _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; @@ -1005,7 +1005,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->newItem == false) { globalDestroy(_ctx->MyThreads); globalDestroy(_ctx->MyActions); - + CORO_KILL_SELF(); return; } @@ -1032,7 +1032,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { globalDestroy(_ctx->newItem); globalDestroy(_ctx->MyThreads); globalDestroy(_ctx->MyActions); - + CORO_KILL_SELF(); return; } @@ -1068,10 +1068,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { /** - * Wait for the end of the dialog execution thread, and then restore global + * Wait for the end of the dialog execution thread, and then restore global * variables indicating that the dialogue has finished. * - * @param param Pointer to a handle to the dialog + * @param param Pointer to a handle to the dialog * @remarks This additional process is used, instead of clearing variables * within the same dialog thread, because due to the recursive nature of a dialog, * it would be difficult to know within it when the dialog is actually ending. @@ -1132,9 +1132,9 @@ void GroupThread(CORO_PARAM, const void *param) { if (_ctx->type == 1) { // Call custom function CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], - _ctx->dialog->_command[_ctx->k]._arg1, + _ctx->dialog->_command[_ctx->k]._arg1, _ctx->dialog->_command[_ctx->k]._arg2, - _ctx->dialog->_command[_ctx->k]._arg3, + _ctx->dialog->_command[_ctx->k]._arg3, _ctx->dialog->_command[_ctx->k]._arg4 ); @@ -1143,22 +1143,22 @@ void GroupThread(CORO_PARAM, const void *param) { lockVar(); varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); unlockVar(); - + } else if (_ctx->type == 3) { // DoChoice: call the chosen function CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); - + } else { GLOBALS._mpalError = 1; unlockDialogs(); - + CORO_KILL_SELF(); return; } } /* The gruop is finished, so we can return to the calling function. - * If the group was the first called, then the process will automatically + * If the group was the first called, then the process will automatically * end. Otherwise it returns to the caller method */ return; @@ -1168,7 +1168,7 @@ void GroupThread(CORO_PARAM, const void *param) { /* If we are here, it means that we have not found the requested group */ GLOBALS._mpalError = 1; unlockDialogs(); - + CORO_KILL_SELF(); CORO_END_CODE; @@ -1259,7 +1259,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { /* Bit 1 set: the end of the dialog */ unlockDialogs(); - + CORO_KILL_SELF(); return; } @@ -1348,8 +1348,8 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * @param nGroup Number of the group to perform * @returns The process Id of the process running the dialog * or CORO_INVALID_PID_VALUE on error - * @remarks The dialogue runs in a thread created on purpose, - * so that must inform through an event and when 'necessary to you make a choice. + * @remarks The dialogue runs in a thread created on purpose, + * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. */ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { @@ -1382,7 +1382,7 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { /** - * Takes note of the selection chosen by the user, and warns the process that was running + * Takes note of the selection chosen by the user, and warns the process that was running * the box that it can continue. * * @param nChoice Number of choice that was in progress @@ -1420,7 +1420,7 @@ bool doSelection(uint32 i, uint32 dwData) { * @param lplpcfArray Array of pointers to custom functions. * @returns True if everything is OK, false on failure */ -bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, +bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) { Common::File hMpc; byte buf[5]; @@ -1620,7 +1620,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { */ error("mpalQuery(MPQ_MESSAGE, uint32 nMsg) used incorrect method variant"); - + } else if (wQueryType == MPQ_ITEM_PATTERN) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); @@ -1629,7 +1629,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { buf = Common::String::format("Pattern.%u", GETARG(uint32)); dwRet = (uint32)varGetValue(buf.c_str()); unlockVar(); - + } else if (wQueryType == MPQ_LOCATION_SIZE) { /* * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); @@ -1648,7 +1648,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { GLOBALS._mpalError = 1; unlockLocations(); - + } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); @@ -1815,19 +1815,19 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { LockMsg(); hRet = DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); UnlockMsg(); - + } else if (wQueryType == MPQ_ITEM_PATTERN) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); */ error("mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem) used incorrect variant"); - + } else if (wQueryType == MPQ_LOCATION_SIZE) { /* * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ error("mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord) used incorrect variant"); - + } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); @@ -1961,9 +1961,9 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { */ CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hAskChoice, CORO_INFINITE); - // WORKAROUND: Introduce a single frame delay so that if there are multiple actions running, + // WORKAROUND: Introduce a single frame delay so that if there are multiple actions running, // they all have time to be signalled before resetting the event. This fixes a problem where - // if you try to use the 'shrimp' on the parrot a second time after trying to first use it + // if you try to use the 'shrimp' on the parrot a second time after trying to first use it // whilst the parrot was talking, the cursor wouldn't be re-enabled afterwards CORO_SLEEP(1); @@ -2019,7 +2019,7 @@ bool mpalExecuteScript(int nScript) { /** - * Install a custom routine That will be called by MPAL every time the pattern + * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. * * @param lpiifCustom Custom function to install @@ -2032,7 +2032,7 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { /** * Process the idle actions of the items on one location. * - * @param nLoc Number of the location whose items must be processed + * @param nLoc Number of the location whose items must be processed * for idle actions. * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. * @remarks The maximum number of locations that can be polled @@ -2118,7 +2118,7 @@ void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); - unlockVar(); + unlockVar(); } @@ -2133,7 +2133,7 @@ int mpalLoadState(byte *buf) { globalFree(GLOBALS._hVars); GLOBALS._nVars = READ_LE_UINT32(buf); - + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); lockVar(); memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 251e78afdf..20f2b0b170 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -34,9 +34,9 @@ /* * MPAL (MultiPurpose Adventure Language) is a high level language * for the definition of adventure. Through the use of MPAL you can describe - * storyboard the adventure, and then use it with any user interface. - * In fact, unlike many other similar products, MPAL is not programmed through - * the whole adventure, but are defined only the locations, objects, as they may + * storyboard the adventure, and then use it with any user interface. + * In fact, unlike many other similar products, MPAL is not programmed through + * the whole adventure, but are defined only the locations, objects, as they may * interact with each other, etc.. thus making MPAL useful for any type of adventure. */ @@ -64,16 +64,16 @@ /* * A custom function and a function specified by the program that uses the * library, to perform the particular code. The custom functions are - * retrieved from the library as specified in the source MPAL, and in particular + * retrieved from the library as specified in the source MPAL, and in particular * in defining the behavior of an item with some action. * * To use the custom functions, you need to prepare an array of - * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, + * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, * (defined below), and pass it as second parameter to mpalInit (). Note you - * must specify the size of the array, as elements of pointers and which do not - * contain the same: the library will call it only those functions specified in - * the source MPAL. It can be useful, for debugging reasons, do not bet - * the shares of arrays used to debugging function, to avoid unpleasant crash, + * must specify the size of the array, as elements of pointers and which do not + * contain the same: the library will call it only those functions specified in + * the source MPAL. It can be useful, for debugging reasons, do not bet + * the shares of arrays used to debugging function, to avoid unpleasant crash, * if it has been made an error in source and / or some oversight in the code. * */ @@ -115,7 +115,7 @@ enum QueryCoordinates { /** - * Query can be used with mpalQuery methods. In practice corresponds all claims + * Query can be used with mpalQuery methods. In practice corresponds all claims * that can do at the library */ enum QueryTypes { @@ -176,7 +176,7 @@ typedef void (*LPCUSTOMFUNCTION)(CORO_PARAM, uint32, uint32, uint32, uint32); typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; /** - * + * * Define an IRQ of an item that is called when the pattern changes or the status of an item */ typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); @@ -202,8 +202,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * * @param lpszVarName Nome della variabile (ASCIIZ) * @returns Global variable value - * @remarks This query was implemented for debugging. The program, - * if well designed, should not need to access variables from + * @remarks This query was implemented for debugging. The program, + * if well designed, should not need to access variables from * within the library. */ #define mpalQueryGlobalVar(lpszVarName) \ @@ -313,7 +313,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @param nPeriod Number of words * @returns A pointer to the string of words, or NULL on failure. * @remarks The string must be freed after use using the memory manager. - * Unlike normal messages, the sentences of dialogue are formed by a single + * Unlike normal messages, the sentences of dialogue are formed by a single * string terminated with 0. */ #define mpalQueryDialogPeriod(nPeriod) \ @@ -340,14 +340,14 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) /** - * Warns the library that the user has selected, in a certain choice of the current dialog, + * Warns the library that the user has selected, in a certain choice of the current dialog, * corresponding option at a certain given. * * @param nChoice Choice number of the choice that was in progress * @param dwData Option that was selected by the user. * @returns TRUE if all OK, FALSE on failure. - * @remarks After execution of this query, MPAL continue - * Groups according to the execution of the dialogue. And necessary so the game + * @remarks After execution of this query, MPAL continue + * Groups according to the execution of the dialogue. And necessary so the game * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). */ #define mpalQueryDialogSelection(nChoice, dwData) \ @@ -357,15 +357,15 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) /** - * Warns the library an action was performed on a Object. + * Warns the library an action was performed on a Object. * The library will call custom functions, if necessary. * * @param nAction Action number * @param nItem Item number * @param dwParam Action parameter - * @returns Handle to the thread that is performing the action, or CORO_INVALID_PID_VALUE + * @returns Handle to the thread that is performing the action, or CORO_INVALID_PID_VALUE * if the action is not defined for the item, or the item is inactive. - * @remarks The parameter is used primarily to implement actions + * @remarks The parameter is used primarily to implement actions * as "U.S." involving two objects together. The action will be executed only * if the item is active, ie if its status is a positive number greater than 0. */ @@ -452,7 +452,7 @@ bool mpalExecuteScript(int nScript); uint32 mpalGetError(); /** - * Install a custom routine That will be called by MPAL every time the pattern + * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. * * @param lpiifCustom Custom function to install @@ -462,7 +462,7 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); /** * Process the idle actions of the items on one location. * - * @param nLoc Number of the location whose items must be processed + * @param nLoc Number of the location whose items must be processed * for idle actions. * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. * @remarks The maximum number of locations that can be polled diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index e637362bdf..a95003ef97 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -230,7 +230,7 @@ struct MPALSCRIPT { byte nCmds; uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; - + } Moment[MAX_MOMENTS_PER_SCRIPT]; } PACKED_STRUCT; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 3a1c6746c8..0f9f1c2bbe 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -416,7 +416,7 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { } /** - * Default constructor. + * Default constructor. * * @remarks Do *NOT* declare an object directly, but rather * create it using FPSound::CreateStream() @@ -436,7 +436,7 @@ FPStream::FPStream(bool bSoundOn) { } /** - * Default destructor. + * Default destructor. * * @remarks It calls CloseFile() if needed. */ @@ -455,9 +455,9 @@ FPStream::~FPStream() { } /** - * Releases the memory object. + * Releases the memory object. * - * @remarks Must be called when the object is no longer used + * @remarks Must be called when the object is no longer used * and **ONLY** if the object was created by * FPSound::CreateStream(). * Object pointers are no longer valid after this call. @@ -522,8 +522,8 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB * * @returns For safety, the destructor calls unloadFile() if it has not * been mentioned explicitly. - * - * @remarks It is necessary to call this function to free the + * + * @remarks It is necessary to call this function to free the * memory used by the stream. */ bool FPStream::unloadFile() { @@ -580,7 +580,7 @@ bool FPStream::play() { * Closes the stream. * * @returns True is everything is OK, False otherwise - * + * */ bool FPStream::stop(bool bSync) { diff --git a/engines/tony/sound.h b/engines/tony/sound.h index ca71652f20..bd858e5bca 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -36,7 +36,7 @@ #include "tony/utils.h" namespace Audio { -class RewindableAudioStream; +class RewindableAudioStream; } namespace Tony { @@ -253,7 +253,7 @@ private: Common::File _file; // File handle used for the stream bool _bSoundSupported; // True if the sound is active - bool _bFileLoaded; // True if the file is open + bool _bFileLoaded; // True if the file is open bool _bLoop; // True if the stream should loop bool _bDoFadeOut; // True if fade out is required bool _bSyncExit; @@ -268,7 +268,7 @@ private: public: /** - * Default constructor. + * Default constructor. * * @remarks Do *NOT* declare an object directly, but rather * create it using FPSound::CreateStream() @@ -277,7 +277,7 @@ public: FPStream(bool bSoundOn); /** - * Default destructor. + * Default destructor. * * @remarks It calls CloseFile() if needed. */ @@ -285,9 +285,9 @@ public: ~FPStream(); /** - * Releases the memory object. + * Releases the memory object. * - * @remarks Must be called when the object is no longer used + * @remarks Must be called when the object is no longer used * and **ONLY** if the object was created by * FPSound::CreateStream(). * Object pointers are no longer valid after this call. @@ -311,8 +311,8 @@ public: * * @returns For safety, the destructor calls unloadFile() if it has not * been mentioned explicitly. - * - * @remarks It is necessary to call this function to free the + * + * @remarks It is necessary to call this function to free the * memory used by the stream. */ diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index a3f79decaf..70c33e71ee 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -177,13 +177,13 @@ void RMPoint::readFromStream(Common::ReadStream &ds) { * RMPointReference methods \****************************************************************************/ -RMPointReference &RMPointReference::operator=(const RMPoint &p) { - _x = p._x; _y = p._y; +RMPointReference &RMPointReference::operator=(const RMPoint &p) { + _x = p._x; _y = p._y; return *this; } RMPointReference &RMPointReference::operator-=(const RMPoint &p) { - _x -= p._x; _y -= p._y; + _x -= p._x; _y -= p._y; return *this; } -- cgit v1.2.3 From b12ccad9943c99ecfc4edc6f4a46e4d88db609cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 00:30:07 +0200 Subject: TONY: Reduce scope of some variables --- engines/tony/mpal/expr.cpp | 30 +++++------ engines/tony/mpal/loadmpc.cpp | 88 +++++++++++++----------------- engines/tony/mpal/mpal.cpp | 121 +++++++++++++++++------------------------- engines/tony/utils.cpp | 13 ++--- engines/tony/window.cpp | 2 +- 5 files changed, 107 insertions(+), 147 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index ef58208d3f..2b2dbf2529 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -109,13 +109,12 @@ typedef EXPRESSION *LPEXPRESSION; * @retruns Pointer to the cloned expression */ static byte *duplicateExpression(HGLOBAL h) { - int i, num; byte *orig, *clone; LPEXPRESSION one, two; orig = (byte *)globalLock(h); - num = *(byte *)orig; + int num = *(byte *)orig; one = (LPEXPRESSION)(orig+1); clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); @@ -123,7 +122,7 @@ static byte *duplicateExpression(HGLOBAL h) { memcpy(clone, orig, sizeof(EXPRESSION) * num + 1); - for (i = 0; i < num; i++) { + for (int i = 0; i < num; i++) { if (one->type == ELT_PARENTH) { two->type = ELT_PARENTH2; two->val.pson = duplicateExpression(two->val.son); @@ -218,14 +217,14 @@ static void solve(LPEXPRESSION one, int num) { * @returns Value */ static int evaluateAndFreeExpression(byte *expr) { - int i,num,val; - LPEXPRESSION one,cur; + LPEXPRESSION one, cur; - num = *expr; + int num = *expr; one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i = 0, cur = one; i < num; i++, cur++) { + cur = one; + for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_VAR) { cur->type = ELT_NUMBER; cur->val.num = varGetValue(cur->val.name); @@ -233,7 +232,8 @@ static int evaluateAndFreeExpression(byte *expr) { } // 2) Sostituzioni delle parentesi (tramite ricorsione) - for (i = 0, cur = one; i < num; i++, cur++) { + cur = one; + for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_PARENTH2) { cur->type = ELT_NUMBER; cur->val.num = evaluateAndFreeExpression(cur->val.pson); @@ -242,7 +242,7 @@ static int evaluateAndFreeExpression(byte *expr) { // 3) Risoluzione algebrica solve(one, num); - val = one->val.num; + int val = one->val.num; globalDestroy(expr); return val; @@ -260,9 +260,8 @@ static int evaluateAndFreeExpression(byte *expr) { const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; - uint32 num, i; - num = *lpBuf; + uint32 num = *lpBuf; lpBuf++; if (num == 0) @@ -277,7 +276,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { cur = (LPEXPRESSION)(start + 1); - for (i = 0;i < num; i++) { + for (uint32 i = 0;i < num; i++) { cur->type = *(lpBuf); cur->unary = *(lpBuf + 1); lpBuf += 2; @@ -343,15 +342,14 @@ int evaluateExpression(HGLOBAL h) { * @param h2 Expression to be compared */ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { - int i, num1, num2; byte *e1, *e2; LPEXPRESSION one, two; e1 = (byte *)globalLock(h1); e2 = (byte *)globalLock(h2); - num1 = *(byte *)e1; - num2 = *(byte *)e2; + int num1 = *(byte *)e1; + int num2 = *(byte *)e2; if (num1 != num2) { globalUnlock(h1); @@ -362,7 +360,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { one = (LPEXPRESSION)(e1 + 1); two = (LPEXPRESSION)(e2 + 1); - for (i = 0; i < num1; i++) { + for (int i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { globalUnlock(h1); globalUnlock(h2); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9da2cc121e..790d8d4903 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -62,24 +62,21 @@ static bool compareCommands(struct command *cmd1, struct command *cmd2) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - int curCmd, j, len; - uint i; - lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; lpmsScript->nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; - curCmd = 0; + int curCmd = 0; - for (i = 0; i < lpmsScript->nMoments; i++) { + for (uint i = 0; i < lpmsScript->nMoments; i++) { lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; - for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { + for (int j = 0; j < lpmsScript->Moment[i].nCmds; j++) { lpmsScript->_command[curCmd].type = *lpBuf; lpBuf++; switch (lpmsScript->_command[curCmd].type) { @@ -96,8 +93,8 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpBuf += 4; break; - case 2: // Variable assign - len = *lpBuf; + case 2: { // Variable assign + int len = *lpBuf; lpBuf++; lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->_command[curCmd].lpszVarName == NULL) @@ -109,7 +106,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { if (lpBuf == NULL) return NULL; break; - + } default: return NULL; } @@ -145,22 +142,20 @@ static void FreeScript(LPMPALSCRIPT lpmsScript) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { - uint32 i, j, z, kk; - uint32 num, num2, num3; + uint32 num2, num3; byte *lpLock; - uint32 curCmd; - uint32 len; lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; /* Periodi */ - num = READ_LE_UINT16(lpBuf); + uint32 num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); + uint32 i; for (i = 0; i < num; i++) { lpmdDialog->_periodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -177,7 +172,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /* Gruppi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; - curCmd = 0; + uint32 curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) error("Too much groups in dialog #%d", lpmdDialog->nObj); @@ -190,7 +185,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); - for (j = 0; j < lpmdDialog->_group[i].nCmds; j++) { + for (uint32 j = 0; j < lpmdDialog->_group[i].nCmds; j++) { lpmdDialog->_command[curCmd].type = *lpBuf; lpBuf++; @@ -210,8 +205,8 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { break; // Variable assign - case 2: - len = *lpBuf; + case 2: { + uint32 len = *lpBuf; lpBuf++; lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmdDialog->_command[curCmd].lpszVarName == NULL) @@ -224,7 +219,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (lpBuf == NULL) return NULL; break; - + } // Do Choice case 3: lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); @@ -235,6 +230,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { return NULL; } + uint32 kk; for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { lpmdDialog->_group[i].CmdNum[j] = kk; @@ -278,7 +274,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (num2 >= MAX_SELECTS_PER_CHOICE) error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); - for (j = 0; j < num2; j++) { + for (uint32 j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: @@ -308,7 +304,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); - for (z = 0; z < num3; z++) { + for (uint32 z = 0; z < num3; z++) { lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } @@ -337,14 +333,10 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * completely initialized to 0 beforehand. */ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { - byte len; - uint32 i, j, kk; - uint32 curCmd; - lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - len = *lpBuf; + byte len = *lpBuf; lpBuf++; memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; @@ -359,9 +351,9 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { if (lpmiItem->nActions > 0) lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); - curCmd = 0; + uint32 curCmd = 0; - for (i = 0; i < lpmiItem->nActions; i++) { + for (uint32 i = 0; i < lpmiItem->nActions; i++) { lpmiItem->Action[i].num = *lpBuf; lpBuf++; @@ -393,7 +385,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); - for (j = 0; j < lpmiItem->Action[i].nCmds; j++) { + for (uint32 j = 0; j < lpmiItem->Action[i].nCmds; j++) { lpmiItem->_command[curCmd].type = *lpBuf; lpBuf++; switch (lpmiItem->_command[curCmd].type) { @@ -428,6 +420,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { return NULL; } + uint32 kk; for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; @@ -527,8 +520,6 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) * @returns True if succeeded OK, false if failure. */ bool ParseMpc(const byte *lpBuf) { - uint16 i, j; - uint16 wLen; byte *lpTemp; /* 1. Variables */ @@ -545,8 +536,8 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); - for (i = 0; i < GLOBALS._nVars; i++) { - wLen = *(const byte *)lpBuf; + for (uint16 i = 0; i < GLOBALS._nVars; i++) { + uint16 wLen = *(const byte *)lpBuf; lpBuf++; memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; @@ -579,10 +570,11 @@ bool ParseMpc(const byte *lpBuf) { return false; #endif - for (i = 0; i < GLOBALS._nMsgs; i++) { + for (uint16 i = 0; i < GLOBALS._nMsgs; i++) { GLOBALS._lpmmMsgs->_wNum = READ_LE_UINT16(lpBuf); lpBuf += 2; + uint16 j; for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; @@ -628,7 +620,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0;i < GLOBALS._nDialogs; i++) { + for (uint16 i = 0; i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) return false; } @@ -650,7 +642,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS._nItems; i++) { + for (uint16 i = 0; i < GLOBALS._nItems; i++) { if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) return false; } @@ -672,7 +664,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); - for (i = 0; i < GLOBALS._nLocations; i++) { + for (uint16 i = 0; i < GLOBALS._nLocations; i++) { if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) return false; } @@ -694,7 +686,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS._nScripts; i++) { + for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) return false; @@ -721,12 +713,10 @@ bool ParseMpc(const byte *lpBuf) { */ static void freeDialog(LPMPALDIALOG lpmdDialog) { // Free the periods - int i, j; - - for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) + for (int i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { + for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { if (lpmdDialog->_command[i].type == 2) { // Variable assign globalDestroy(lpmdDialog->_command[i].lpszVarName); @@ -735,8 +725,8 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { } // Free the choices - for (i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { - for (j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { + for (int i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { + for (int j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { if (lpmdDialog->_choice[i]._select[j].when) freeExpression(lpmdDialog->_choice[i]._select[j].when); } @@ -747,14 +737,12 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { * Frees any data allocated from the parsing of the MPC file */ void FreeMpc() { - int i; - // Free variables globalFree(GLOBALS._hVars); // Free messages LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); - for (i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) + for (int i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) globalFree(lpmmMsgs->_hText); globalUnlock(GLOBALS._hMsgs); @@ -764,7 +752,7 @@ void FreeMpc() { if (GLOBALS._hDialogs) { LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) + for (int i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); globalFree(GLOBALS._hDialogs); @@ -774,7 +762,7 @@ void FreeMpc() { if (GLOBALS._hItems) { LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) + for (int i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); globalUnlock(GLOBALS._hItems); @@ -790,7 +778,7 @@ void FreeMpc() { if (GLOBALS._hScripts) { LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { + for (int i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index be2f6db43f..540dee664f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -154,10 +154,9 @@ static void unlockScripts() { * need to remember to call UnlockVar() */ int32 varGetValue(const char *lpszVarName) { - int i; LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS._nVars; v++, i++) + for (int i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; @@ -171,10 +170,9 @@ int32 varGetValue(const char *lpszVarName) { * @param val Value to set */ void varSetValue(const char *lpszVarName, int32 val) { - uint i; LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS._nVars; v++, i++) + for (uint i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) { v->dwVal = val; if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { @@ -202,10 +200,9 @@ void varSetValue(const char *lpszVarName, int32 val) { * first been locked with a call to LockLoc(). */ static int locGetOrderFromNum(uint32 nLoc) { - int i; LPMPALLOCATION loc = GLOBALS._lpmlLocations; - for (i = 0; i < GLOBALS._nLocations; i++, loc++) + for (int i = 0; i < GLOBALS._nLocations; i++, loc++) if (loc->nObj == nLoc) return i; @@ -221,10 +218,9 @@ static int locGetOrderFromNum(uint32 nLoc) { * first been locked with a call to LockMsg() */ static int msgGetOrderFromNum(uint32 nMsg) { - int i; LPMPALMSG msg = GLOBALS._lpmmMsgs; - for (i = 0; i < GLOBALS._nMsgs; i++, msg++) { + for (int i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) return i; } @@ -240,10 +236,9 @@ static int msgGetOrderFromNum(uint32 nMsg) { * first been locked with a call to LockItems() */ static int itemGetOrderFromNum(uint32 nItem) { - int i; LPMPALITEM item = GLOBALS._lpmiItems; - for (i = 0; i < GLOBALS._nItems; i++, item++) { + for (int i = 0; i < GLOBALS._nItems; i++, item++) { if (item->nObj == nItem) return i; } @@ -260,10 +255,9 @@ static int itemGetOrderFromNum(uint32 nItem) { * first been locked with a call to LockScripts() */ static int scriptGetOrderFromNum(uint32 nScript) { - int i; LPMPALSCRIPT script = GLOBALS._lpmsScripts; - for (i = 0; i < GLOBALS._nScripts; i++, script++) { + for (int i = 0; i < GLOBALS._nScripts; i++, script++) { if (script->nObj == nScript) return i; } @@ -280,10 +274,9 @@ static int scriptGetOrderFromNum(uint32 nScript) { * first been locked with a call to LockDialogs() */ static int dialogGetOrderFromNum(uint32 nDialog) { - int i; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; - for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) { + for (int i = 0; i < GLOBALS._nDialogs; i++, dialog++) { if (dialog->nObj == nDialog) return i; } @@ -301,14 +294,13 @@ static int dialogGetOrderFromNum(uint32 nDialog) { static char *DuplicateMessage(uint32 nMsgOrd) { const char *origmsg; char *clonemsg; - int j; if (nMsgOrd == (uint32)-1) return NULL; origmsg = (const char *)globalLock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); - j = 0; + int j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') j++; j += 2; @@ -335,15 +327,14 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; - int i, j; - for (j = 0; dialog->_periods[j] != NULL; j++) { + for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { /* Found the phrase, it should be duplicated */ origmsg = (const char *)globalLock(dialog->_periods[j]); /* Calculate the length and allocate memory */ - i = 0; + int i = 0; while (origmsg[i] != '\0') i++; @@ -370,14 +361,13 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { * @returns Handle to the loaded resource */ HGLOBAL resLoad(uint32 dwId) { - int i; HGLOBAL h; char head[4]; uint32 nBytesRead; uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i = 0; i < GLOBALS._nResources; i++) + for (int i = 0; i < GLOBALS._nResources; i++) if (GLOBALS._lpResources[i * 2] == dwId) { GLOBALS._hMpr.seek(GLOBALS._lpResources[i * 2 + 1]); nBytesRead = GLOBALS._hMpr.read(head, 4); @@ -416,12 +406,11 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; - int j, k, num; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Count how many are active selects */ - num = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { + int num = 0; + for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) num++; } @@ -430,13 +419,13 @@ static uint32 *getSelectList(uint32 i) { if (num == 0) return NULL; - sl= (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + sl = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (sl == NULL) return NULL; /* Copy all the data inside the active select list */ - k = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { + int k = 0; + for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) sl[k++] = dialog->_choice[i]._select[j].dwData; } @@ -447,11 +436,10 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; - uint32 num,i,j; LPMPALVAR v = GLOBALS._lpmvVars; - num = 0; - for (i = 0; i < GLOBALS._nVars; i++, v++) { + uint32 num = 0; + for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -461,8 +449,8 @@ static uint32 *GetItemList(uint32 nLoc) { return NULL; v = GLOBALS._lpmvVars; - j = 0; - for (i = 0; i < GLOBALS._nVars; i++, v++) { + uint32 j = 0; + for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; @@ -478,9 +466,7 @@ static LPITEM getItemData(uint32 nOrdItem) { LPITEM ret; HGLOBAL hDat; char *dat; - int i, j; char *patlength; - uint32 dim; // Zeroing out the allocated memory is required!!! ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); @@ -492,7 +478,7 @@ static LPITEM getItemData(uint32 nOrdItem) { dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { - i = dat[3]; // For version 1.0!! + int i = dat[3]; // For version 1.0!! dat += 4; if (i >= 0x10) { // From 1.0, there's a destination point for each object @@ -513,21 +499,21 @@ static LPITEM getItemData(uint32 nOrdItem) { ret->_destZ = *dat++; // Upload the left & top co-ordinates of each frame - for (i = 0; i < ret->_numframe; i++) { + for (int i = 0; i < ret->_numframe; i++) { ret->_frameslocations[i].left = (int16)READ_LE_UINT16(dat); ret->_frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); dat += 4; } // Upload the size of each frame and calculate the right & bottom - for (i = 0; i < ret->_numframe; i++) { + for (int i = 0; i < ret->_numframe; i++) { ret->_frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->_frameslocations[i].left; ret->_frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->_frameslocations[i].top; dat += 4; } // Upload the bounding boxes of each frame - for (i = 0; i < ret->_numframe; i++) { + for (int i = 0; i < ret->_numframe; i++) { ret->_bbox[i].left = (int16)READ_LE_UINT16(dat); ret->_bbox[i].top = (int16)READ_LE_UINT16(dat + 2); ret->_bbox[i].right = (int16)READ_LE_UINT16(dat + 4); @@ -539,16 +525,16 @@ static LPITEM getItemData(uint32 nOrdItem) { patlength = dat; dat += ret->_numpattern; - for (i = 1; i < ret->_numpattern; i++) { - for (j = 0; j < patlength[i]; j++) + for (int i = 1; i < ret->_numpattern; i++) { + for (int j = 0; j < patlength[i]; j++) ret->_pattern[i][j] = dat[j]; ret->_pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } // Upload the individual frames of animations - for (i = 1; i < ret->_numframe; i++) { - dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * + for (int i = 1; i < ret->_numframe; i++) { + uint32 dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); @@ -559,7 +545,7 @@ static LPITEM getItemData(uint32 nOrdItem) { } // Check if we've got to the end of the file - i = READ_LE_UINT16(dat); + int i = READ_LE_UINT16(dat); if (i != 0xABCD) return NULL; @@ -1288,16 +1274,14 @@ void doChoice(CORO_PARAM, uint32 nChoice) { */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = GLOBALS._lpmiItems; - int i; LPMPALITEM newitem; - uint32 h; item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); if (varGetValue(buf.c_str()) <= 0) return CORO_INVALID_PID_VALUE; - for (i = 0; i < item->nActions; i++) { + for (int i = 0; i < item->nActions; i++) { if (item->Action[i].num != nAction) continue; @@ -1326,6 +1310,7 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // and a second process to free up the memory when the action is finished. // !!! New process management + uint32 h; if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; @@ -1353,8 +1338,6 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * The data on the choices may be obtained through various queries. */ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { - uint32 h; - // Store the running dialog in a global variable GLOBALS._nExecutingDialog = nDlgOrd; @@ -1367,6 +1350,7 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { // Create a thread that performs the dialogue group // Create the process + uint32 h; if ((h = CoroScheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; @@ -1589,7 +1573,6 @@ void mpalFree() { * method that returns numeric results. */ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { - int x, y; Common::String buf; uint32 dwRet = 0; char *n; @@ -1635,8 +1618,8 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ lockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); + int x = locGetOrderFromNum(GETARG(uint32)); + int y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) dwRet = GLOBALS._lpmlLocations[x].dwXlen; @@ -1678,7 +1661,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); */ lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) dwRet = (uint32)false; @@ -1692,14 +1675,14 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); */ lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0]='\0'; else { lockItems(); - y = itemGetOrderFromNum(x); + int y = itemGetOrderFromNum(x); memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1729,8 +1712,8 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); */ lockDialogs(); - x = GETARG(uint32); - y = GETARG(uint32); + int x = GETARG(uint32); + int y = GETARG(uint32); dwRet = (uint32)doSelection(x, y); unlockDialogs(); @@ -1741,9 +1724,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { */ lockItems(); lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); int z = GETARG(uint32); - y = itemGetOrderFromNum(z); + int y = itemGetOrderFromNum(z); if (y != -1) { dwRet = doAction(x, y, GETARG(uint32)); } else { @@ -1761,8 +1744,8 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { if (!GLOBALS._bExecutingDialog) { lockDialogs(); - x = dialogGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); + int x = dialogGetOrderFromNum(GETARG(uint32)); + int y = GETARG(uint32); dwRet = doDialog(x, y); unlockDialogs(); } @@ -1787,7 +1770,6 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * method that returns a pointer or handle. */ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { - int x, y; char *n; Common::String buf; va_list v; @@ -1833,7 +1815,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); */ lockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); + int x = locGetOrderFromNum(GETARG(uint32)); hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); unlockLocations(); @@ -1870,14 +1852,14 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName); */ lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0] = '\0'; else { lockItems(); - y = itemGetOrderFromNum(x); + int y = itemGetOrderFromNum(x); memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1889,7 +1871,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); */ lockDialogs(); - y = GETARG(uint32); + int y = GETARG(uint32); hRet = duplicateDialogPeriod(y); unlockDialogs(); @@ -1998,11 +1980,10 @@ uint32 mpalGetError() { * @returns TRUE if the script 'was launched, FALSE on failure */ bool mpalExecuteScript(int nScript) { - int n; LPMPALSCRIPT s; LockScripts(); - n = scriptGetOrderFromNum(nScript); + int n = scriptGetOrderFromNum(nScript); s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); if (s == NULL) return false; @@ -2039,14 +2020,12 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { * simultaneously is defined defined by MAXPOLLINGFUNCIONS */ bool mpalStartIdlePoll(int nLoc) { - uint32 i; - - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { + for (uint32 i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == (uint32)nLoc) return false; } - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { + for (uint32 i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == 0) { GLOBALS._nPollingLocations[i] = nLoc; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 70c33e71ee..db83c2910b 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -38,12 +38,9 @@ namespace Tony { */ Common::String readString(Common::ReadStream &df) { Common::String var; - uint8 len; - int i; + uint8 len = df.readByte(); - len = df.readByte(); - - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { char c; c = df.readByte(); var += c; @@ -356,16 +353,14 @@ void RMResUpdate::init(const Common::String &fileName) { // It doesn't exist, so exit immediately return; - uint8 version; - uint32 i; + uint8 version = _hFile.readByte(); - version = _hFile.readByte(); _numUpd = _hFile.readUint32LE(); _infos = new ResUpdInfo[_numUpd]; // Load the index of the resources in the file - for (i = 0; i < _numUpd; ++i) { + for (uint32 i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; info._dwRes = _hFile.readUint32LE(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 9385db27c7..0746b267bd 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -265,7 +265,6 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; - uint32 k = 0; uint16 *cursrc; if (lpDestBuf == NULL) @@ -292,6 +291,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src += RM_BBX; } } else { + uint32 k = 0; for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; -- cgit v1.2.3 From 92a9820f3371037fa9009e4b2c9831f169cd8809 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 08:11:52 +0200 Subject: TONY: Translate some remaining italian comments --- engines/tony/mpal/expr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 2b2dbf2529..5f3026144c 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -222,7 +222,7 @@ static int evaluateAndFreeExpression(byte *expr) { int num = *expr; one = (LPEXPRESSION)(expr + 1); - // 1) Sostituzioni delle variabili + // 1) Substitutions of variables cur = one; for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_VAR) { @@ -231,7 +231,7 @@ static int evaluateAndFreeExpression(byte *expr) { } } - // 2) Sostituzioni delle parentesi (tramite ricorsione) + // 2) Replacement of brackets (using recursive calls) cur = one; for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_PARENTH2) { @@ -240,7 +240,7 @@ static int evaluateAndFreeExpression(byte *expr) { } } - // 3) Risoluzione algebrica + // 3) algebraic resolution solve(one, num); int val = one->val.num; globalDestroy(expr); -- cgit v1.2.3 From a29f1fb04ca4ee84986c359f1a1743d16c675487 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 08:14:41 +0200 Subject: TONY: Remove some dead code --- engines/tony/mpal/mpal.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 540dee664f..862ea53824 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -637,7 +637,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->_arg3 = s->_command[_ctx->k]._arg3; _ctx->p->_arg4 = s->_command[_ctx->k]._arg4; - // !!! New process management + // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { GLOBALS._mpalError = 1; @@ -1413,10 +1413,6 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, uint32 dwSizeDecomp, dwSizeComp; byte *cmpbuf; - //printf("Item: %lu\n", sizeof(MPALITEM)); - //printf("Script: %lu\n", sizeof(MPALSCRIPT)); - //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); - /* Save the array of custom functions */ GLOBALS._lplpFunctions = lplpcfArray; GLOBALS._lplpFunctionStrings = lpcfStrings; @@ -1480,21 +1476,6 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, globalDestroy(lpMpcImage); - /* Calculate memory usage */ - /* - { - char errbuf[256]; - wsprintf(errbuf,"Utilizzo in RAM: VAR %lu, MSG %lu, DLG %lu, ITM %lu, LOC %lu, SCR %lu", - GLOBALS.nVars*sizeof(MPALVAR), - GLOBALS.nMsgs*sizeof(MPALMSG), - GLOBALS.nDialogs*sizeof(MPALDIALOG), - GLOBALS.nItems*sizeof(MPALITEM), - GLOBALS.nLocations*sizeof(MPALLOCATION), - GLOBALS.nScripts*sizeof(MPALSCRIPT)); - MessageBox(NULL,errbuf,"Dump",MB_OK); - } -*/ - /* Open the MPR file */ if (!GLOBALS._hMpr.open(lpszMprFileName)) return false; -- cgit v1.2.3 From a6673aaf906505341d8ef259db69efc0f4c540fe Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 29 Aug 2012 09:12:53 +0200 Subject: TONY: Remove useless/commented music code. --- engines/tony/globals.h | 1 - engines/tony/sound.cpp | 12 +++--------- engines/tony/sound.h | 2 +- engines/tony/tony.cpp | 12 +----------- 4 files changed, 5 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.h b/engines/tony/globals.h index e353d40f3b..0911782eac 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -180,7 +180,6 @@ public: int _nextSync; int _curChannel; int _flipflop; - // OSystem::MutexRef csMusic; CharacterStruct _character[16]; MCharacterStruct _mCharacter[10]; ChangedHotspotStruct _changedHotspot[256]; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 0f9f1c2bbe..e8b9dfc42a 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -583,7 +583,7 @@ bool FPStream::play() { * */ -bool FPStream::stop(bool bSync) { +bool FPStream::stop() { if (!_bSoundSupported) return true; @@ -593,15 +593,9 @@ bool FPStream::stop(bool bSync) { if (!g_system->getMixer()->isSoundHandleActive(_handle)) return false; - if (bSync) { - // The caller intends to call waitForSync. - // FIXME: Why call this in that case?! Looks like old code. Remove that parameter. - return true; - } else { - g_system->getMixer()->stopHandle(_handle); + g_system->getMixer()->stopHandle(_handle); - _bPaused = false; - } + _bPaused = false; return true; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index bd858e5bca..73938ecd8c 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -333,7 +333,7 @@ public: * @returns True is everything is OK, False otherwise */ - bool stop(bool bSync = false); + bool stop(); void waitForSync(FPStream *toplay); /** diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 79300ca1ee..d135f66fde 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -364,7 +364,6 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { streams[GLOBALS._nextChannel]->setLoop(GLOBALS._nextLoop); //streams[GLOBALS._nextChannel]->prefetch(); - streams[GLOBALS._curChannel]->stop(true); streams[GLOBALS._curChannel]->waitForSync(streams[GLOBALS._nextChannel]); streams[GLOBALS._curChannel]->unloadFile(); @@ -392,14 +391,10 @@ void TonyEngine::playSFX(int nChannel, int nFX) { } void TonyEngine::stopMusic(int nChannel) { -// g_system->lockMutex(csMusic); - if (nChannel < 4) _stream[nChannel + GLOBALS._flipflop]->stop(); else _stream[nChannel]->stop(); - -// g_system->unlockMutex(csMusic); } void TonyEngine::stopSFX(int nChannel) { @@ -484,7 +479,7 @@ void TonyEngine::unloadAllUtilSFX() { void TonyEngine::initMusic() { int i; - _theSound.init(/*_window*/); + _theSound.init(); _theSound.setMasterVolume(63); for (i = 0; i < 6; i++) @@ -494,9 +489,6 @@ void TonyEngine::initMusic() { _sfx[i] = _utilSfx[i] = NULL; } - // Create the mutex for controlling music access -// csMusic = g_system->createMutex(); - // Preload sound effects preloadUtilSFX(0, "U01.ADP"); // Reversed!! preloadUtilSFX(1, "U02.ADP"); @@ -512,8 +504,6 @@ void TonyEngine::closeMusic() { _stream[i]->release(); } -// g_system->deleteMutex(csMusic); - unloadAllSFX(); unloadAllUtilSFX(); } -- cgit v1.2.3 From 985151fe13d878739287be7827e9b6168010e3ea Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 29 Aug 2012 09:13:37 +0200 Subject: TONY: Limit effect of cursor workaround. This avoids incorrect hotspot offsets. --- engines/tony/game.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 0793d97215..00aa9c1109 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1485,15 +1485,15 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // WORKAROUND: updateCursor gets called too early sometimes (for example, when - // the cursor is released over the TA_PERORATE option), via setAction. - if (_ctx->n > 4) - _ctx->n = 0; - _cursorHotspot = _hotspot[_ctx->n]; // Call the Draw method of the pointer if (_nCurSpecialPointer == 0) { + // WORKAROUND: updateCursor gets called too early sometimes (for example, when + // the cursor is released over the TA_PERORATE option), via setAction. + if (_ctx->n > 4) + _ctx->n = 0; + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); } else { if (_nCurSpecialPointer == PTR_CUSTOM) -- cgit v1.2.3 From 766eadeef98e6adcd52e5fb5325a1f7586572402 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 22:47:33 +0200 Subject: TONY: Translate some remaining Italian comments --- engines/tony/loc.cpp | 12 ++++++------ engines/tony/mpal/loadmpc.cpp | 13 +++++-------- engines/tony/mpal/mpal.cpp | 3 +-- engines/tony/mpal/mpal.h | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 6401e1337f..5d11672e34 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -57,19 +57,19 @@ void RMPattern::RMSlot::readFromStream(Common::ReadStream &ds, bool bLOX) { type = ds.readByte(); _type = (RMPattern::RMSlotType)type; - // Dati + // Data _data = ds.readSint32LE(); - // Posizione + // Position _pos.readFromStream(ds); - // Flag generica + // Generic flag _flag = ds.readByte(); } /****************************************************************************\ -* Metodi di RMPattern +* RMPattern Methods \****************************************************************************/ void RMPattern::readFromStream(Common::ReadStream &ds, bool bLOX) { @@ -547,7 +547,7 @@ void RMItem::readFromStream(Common::SeekableReadStream &ds, bool bLOX) { if (_bInitCurPattern) setPattern(mpalQueryItemPattern(_mpalCode)); - // Initailise the current activation state + // Initialize the current activation state _bIsActive = mpalQueryItemIsActive(_mpalCode); } @@ -883,7 +883,7 @@ short RMCharacter::findPath(short source, short destination) { static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated - static short NEXT[MAXBOXES]; // Prossimo Nodo + static short NEXT[MAXBOXES]; // Next node short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 790d8d4903..e23197144b 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -26,9 +26,6 @@ * Copyright (c) 1997-2003 Nayma Software */ -/* -#include "lzo1x.h" -*/ #include "mpal.h" #include "mpaldll.h" #include "memory.h" @@ -148,7 +145,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; - /* Periodi */ + /* Periods */ uint32 num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -169,7 +166,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->_periodNums[i] = 0; lpmdDialog->_periods[i] = NULL; - /* Gruppi */ + /* Groups */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; uint32 curCmd = 0; @@ -347,7 +344,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->nActions=*lpBuf; lpBuf++; - /* Alloca le azioni */ + /* Allocation action */ if (lpmiItem->nActions > 0) lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); @@ -544,7 +541,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpBuf++; // Salta 'ext' + lpBuf++; // Skip 'ext' GLOBALS._lpmvVars++; } @@ -688,7 +685,7 @@ bool ParseMpc(const byte *lpBuf) { for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) - return false; + return false; // Sort the various moments of the script //qsort( diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 862ea53824..b4b18749ef 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -920,8 +920,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Here's the main loop */ while (1) { - /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per - l'esecuzione */ + // Searching for idle actions requiring time to execute _ctx->curTime = g_vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 20f2b0b170..4c8ca481b0 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -200,7 +200,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; /** * Gets the numerical value of a global variable * - * @param lpszVarName Nome della variabile (ASCIIZ) + * @param lpszVarName Variable name (ASCIIZ) * @returns Global variable value * @remarks This query was implemented for debugging. The program, * if well designed, should not need to access variables from -- cgit v1.2.3 From 825e0896dc52c26e7e31447a434619e190e5c183 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 23:25:14 +0200 Subject: TONY: Replace C-style comments by C++-style ones. Also translate some more Italian comments --- engines/tony/custom.h | 5 -- engines/tony/font.cpp | 8 +-- engines/tony/game.cpp | 7 +-- engines/tony/gfxcore.cpp | 20 +++--- engines/tony/mpal/expr.cpp | 4 -- engines/tony/mpal/loadmpc.cpp | 14 ++--- engines/tony/mpal/mpal.cpp | 141 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 12 ++-- engines/tony/sound.cpp | 2 +- engines/tony/window.h | 2 +- 10 files changed, 99 insertions(+), 116 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 514af1223c..9e18ae2090 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -18,7 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * */ /* @@ -37,10 +36,6 @@ namespace Tony { using namespace MPAL; -/* - * Defines - */ - typedef uint32 HWND; #define INIT_CUSTOM_FUNCTION MapCustomFunctions diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 89cf2ffa1b..901a41b7c4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -206,7 +206,7 @@ void RMFontDialog::init() { load(RES_F_PARL, nchars, 20, 20); - // Initialize the f**king table + // Initialize the font table _lDefault = 13; _hDefault = 18; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -281,7 +281,7 @@ void RMFontCredits::init() { /***************************************************************************\ -* Metodi di RMFontObj +* RMFontObj Methods \****************************************************************************/ #define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) @@ -310,7 +310,7 @@ void RMFontObj::init() { load(RES_F_OBJ, nchars, 25, 30); - // Initialize the f**king table + // Initialize the font table _lDefault = 26; _hDefault = 30; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -320,7 +320,7 @@ void RMFontObj::init() { _lTable[i] = g_vm->_lTableObj[i]; } - /* Casi particolari */ + // Special case setBothCase('C', 'C', 2); setBothCase('A', 'T', -2); setBothCase('R', 'S', 2); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00aa9c1109..224427d10f 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,10 +43,7 @@ namespace Tony { using namespace MPAL; -/****************************************/ -/* Global functions */ -/****************************************/ - +// Global functions void mainEnableGUI() { g_vm->getEngine()->_bGUIInterface = true; g_vm->getEngine()->_bGUIInventory = true; @@ -1045,7 +1042,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } - /**************** State Buttons **************/ + // State Buttons if (_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { if (_editName[0] != '\0') { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 2e368bbc64..53f64aad12 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1610,7 +1610,7 @@ void RMGfxSourceBuffer8AA::calculateAA() { int x, y; byte *src, *srcaa; - /* First pass: fill the edges */ + // First pass: fill the edges Common::fill(_megaAABuf, _megaAABuf + _dimx * _dimy, 0); src = _buf; @@ -1715,11 +1715,9 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Loop buf += bigBuf.getDimx(); // Skip the first line for (y = 1; y < height - 1; y++) { - /* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else - */ + // if (prim->IsFlipped()) + // mybuf=&buf[x1+m_dimx-1]; + // else mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) { @@ -1748,18 +1746,16 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri buf += bigBuf.getDimx(); } -// Position into the destination buffer + // Position into the destination buffer buf = bigBuf; buf += y1 * bigBuf.getDimx(); // Looppone buf += bigBuf.getDimx(); for (y = 1; y < height - 1; y++) { - /* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else - */ + // if (prim->IsFlipped()) + // mybuf=&buf[x1+m_dimx-1]; + // else mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 5f3026144c..31abeb0810 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -31,10 +31,6 @@ #include "tony/mpal/mpaldll.h" #include "tony/tony.h" -/* -#include "lzo1x.h" -*/ - namespace Tony { namespace MPAL { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index e23197144b..9927f9fe8e 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -145,7 +145,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; - /* Periods */ + // Periods uint32 num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -166,7 +166,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->_periodNums[i] = 0; lpmdDialog->_periods[i] = NULL; - /* Groups */ + // Groups num = READ_LE_UINT16(lpBuf); lpBuf += 2; uint32 curCmd = 0; @@ -255,7 +255,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (curCmd >= MAX_COMMANDS_PER_DIALOG) error("Too much commands in dialog #%d",lpmdDialog->nObj); - /* Choices */ + // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -344,7 +344,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->nActions=*lpBuf; lpBuf++; - /* Allocation action */ + // Allocation action if (lpmiItem->nActions > 0) lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); @@ -519,7 +519,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) bool ParseMpc(const byte *lpBuf) { byte *lpTemp; - /* 1. Variables */ + // 1. Variables if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') return false; @@ -547,7 +547,7 @@ bool ParseMpc(const byte *lpBuf) { globalUnlock(GLOBALS._hVars); - /* 2. Messages */ + // 2. Messages if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; @@ -596,7 +596,7 @@ bool ParseMpc(const byte *lpBuf) { globalUnlock(GLOBALS._hMsgs); #endif - /* 3. Objects */ + // 3. Objects if (lpBuf[0] != 'O' || lpBuf[1] != 'B' || lpBuf[2] != 'J' || lpBuf[3] != 'S') return false; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index b4b18749ef..514001eda7 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -330,10 +330,10 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { - /* Found the phrase, it should be duplicated */ + // Found the phrase, it should be duplicated origmsg = (const char *)globalLock(dialog->_periods[j]); - /* Calculate the length and allocate memory */ + // Calculate the length and allocate memory int i = 0; while (origmsg[i] != '\0') i++; @@ -408,14 +408,14 @@ static uint32 *getSelectList(uint32 i) { uint32 *sl; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; - /* Count how many are active selects */ + // Count how many are active selects int num = 0; for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) num++; } - /* If there are 0, it's a mistake */ + // If there are 0, it's a mistake if (num == 0) return NULL; @@ -423,7 +423,7 @@ static uint32 *getSelectList(uint32 i) { if (sl == NULL) return NULL; - /* Copy all the data inside the active select list */ + // Copy all the data inside the active select list int k = 0; for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) @@ -821,18 +821,18 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - /* Initialize data pointers */ + // Initialize data pointers _ctx->MyActions = NULL; _ctx->MyThreads = NULL; - /* To begin with, we need to request the item list from the location */ + // To begin with, we need to request the item list from the location _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); - /* Count the items */ + // Count the items for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) ; - /* We look for items without idle actions, and eliminate them from the list */ + // We look for items without idle actions, and eliminate them from the list lockItems(); _ctx->nIdleActions = 0; _ctx->nRealItems = 0; @@ -853,14 +853,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->nIdleActions += _ctx->k; if (_ctx->k == 0) - /* We can remove this item from the list */ + // We can remove this item from the list _ctx->il[_ctx->i] = (uint32)NULL; else _ctx->nRealItems++; } unlockItems(); - /* If there is nothing left, we can exit */ + // If there is nothing left, we can exit if (_ctx->nRealItems == 0) { globalDestroy(_ctx->il); CORO_KILL_SELF(); @@ -875,8 +875,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { } - /* We have established that there is at least one item that contains idle actions. - Now we created the mirrored copies of the idle actions. */ + // We have established that there is at least one item that contains idle actions. + // Now we created the mirrored copies of the idle actions. _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { globalDestroy(_ctx->MyThreads); @@ -914,11 +914,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { unlockItems(); - /* We don't need the item list anymore */ + // We don't need the item list anymore globalDestroy(_ctx->il); - /* Here's the main loop */ + // Here's the main loop while (1) { // Searching for idle actions requiring time to execute _ctx->curTime = g_vm->getTime(); @@ -932,7 +932,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); } - /* We fall alseep, but always checking that the event is set when prompted for closure */ + // We fall alseep, but always checking that the event is set when prompted for closure CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) @@ -951,19 +951,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curTime = g_vm->getTime(); - /* Loop through all the necessary idle actions */ + // Loop through all the necessary idle actions for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; - /* It's time to check to see if fortune is on the side of the idle action */ + // It's time to check to see if fortune is on the side of the idle action byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { - /* Check if there is an action running on the item */ + // Check if there is an action running on the item if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; - /* Check to see if there already another idle funning running on the item */ + // Check to see if there already another idle funning running on the item for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; @@ -972,11 +972,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->i < _ctx->nRealItems) continue; - /* Ok, we are the only ones :) */ + // Ok, we are the only ones :) lockItems(); _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); - /* Check if there is a WhenExecute expression */ + // Check if there is a WhenExecute expression _ctx->j=_ctx->MyActions[_ctx->k].nAction; if (_ctx->curItem->Action[_ctx->j].when != NULL) { if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { @@ -985,7 +985,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } } - /* Ok, we can perform the action. For convenience, we do it in a new process */ + // Ok, we can perform the action. For convenience, we do it in a new process _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { globalDestroy(_ctx->MyThreads); @@ -998,12 +998,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); unlockItems(); - /* We copy the action in #0 */ -// _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; -// memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); + // We copy the action in #0 + //_ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; + //memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; - /* We will create an action, and will provide the necessary details */ + // We will create an action, and will provide the necessary details for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == 0) break; @@ -1022,7 +1022,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - /* Skip all idle actions of the same item */ + // Skip all idle actions of the same item } } } @@ -1036,11 +1036,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); -/* //if (result != WAIT_OBJECT_0) - if (_ctx->delayExpired) - TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); -*/ + //if (_ctx->delayExpired) + // TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); + CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } } @@ -1142,15 +1141,15 @@ void GroupThread(CORO_PARAM, const void *param) { } } - /* The gruop is finished, so we can return to the calling function. - * If the group was the first called, then the process will automatically - * end. Otherwise it returns to the caller method - */ + // The gruop is finished, so we can return to the calling function. + // If the group was the first called, then the process will automatically + // end. Otherwise it returns to the caller method + return; } } - /* If we are here, it means that we have not found the requested group */ + // If we are here, it means that we have not found the requested group GLOBALS._mpalError = 1; unlockDialogs(); @@ -1174,21 +1173,21 @@ void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CODE(_ctx); - /* Lock the dialogs */ + // Lock the dialogs lockDialogs(); - /* Get a pointer to the current dialog */ + // Get a pointer to the current dialog _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; - /* Search the choice between those required in the dialog */ + // Search the choice between those required in the dialog for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) break; } - /* If nothing has been found, exit with an error */ + // If nothing has been found, exit with an error if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { - /* If we're here, we did not find the required choice */ + // If we're here, we did not find the required choice GLOBALS._mpalError = 1; unlockDialogs(); @@ -1196,14 +1195,14 @@ void doChoice(CORO_PARAM, uint32 nChoice) { return; } - /* We've found the requested choice. Remember what in global variables */ + // We've found the requested choice. Remember what in global variables GLOBALS._nExecutingChoice = _ctx->i; while (1) { GLOBALS._nExecutingChoice = _ctx->i; _ctx->k = 0; - /* Calculate the expression of each selection, to see if they're active or inactive */ + // Calculate the expression of each selection, to see if they're active or inactive for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; @@ -1215,41 +1214,40 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; } - /* If there are no choices activated, then the dialog is finished. */ + // If there are no choices activated, then the dialog is finished. if (_ctx->k == 0) { unlockDialogs(); break; } - /* There are choices available to the user, so wait for them to make one */ + // There are choices available to the user, so wait for them to make one CoroScheduler.resetEvent(GLOBALS._hDoneChoice); CoroScheduler.setEvent(GLOBALS._hAskChoice); CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hDoneChoice, CORO_INFINITE); - /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq - */ + // Now that the choice has been made, we can run the groups associated with the choice tbontbtitq _ctx->j = GLOBALS._nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } - /* Control attribute */ + // Control attribute if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { - /* Bit 0 set: the end of the choice */ + // Bit 0 set: the end of the choice unlockDialogs(); break; } if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { - /* Bit 1 set: the end of the dialog */ + // Bit 1 set: the end of the dialog unlockDialogs(); CORO_KILL_SELF(); return; } - /* End of choic ewithout attributes. We must do it again */ + // End of choic ewithout attributes. We must do it again } // If we're here, we found an end choice. Return to the caller group @@ -1300,9 +1298,10 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); -/* newitem->Action[0].nCmds=item->Action[i].nCmds; - memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); -*/ + + //newitem->Action[0].nCmds=item->Action[i].nCmds; + //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + newitem->dwRes = i; // And finally we can laucnh the process that will execute the action, @@ -1412,15 +1411,15 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, uint32 dwSizeDecomp, dwSizeComp; byte *cmpbuf; - /* Save the array of custom functions */ + // Save the array of custom functions GLOBALS._lplpFunctions = lplpcfArray; GLOBALS._lplpFunctionStrings = lpcfStrings; - /* OPen the MPC file for reading */ + // OPen the MPC file for reading if (!hMpc.open(lpszMpcFileName)) return false; - /* Read and check the header */ + // Read and check the header nBytesRead = hMpc.read(buf, 5); if (nBytesRead != 5) return false; @@ -1430,7 +1429,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, bCompress = buf[4]; - /* Reads the size of the uncompressed file, and allocate memory */ + // Reads the size of the uncompressed file, and allocate memory dwSizeDecomp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1440,7 +1439,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return false; if (bCompress) { - /* Get the compressed size and read the data in */ + // Get the compressed size and read the data in dwSizeComp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1453,33 +1452,33 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeComp) return false; - /* Decompress the data */ + // Decompress the data lzo1x_decompress(cmpbuf, dwSizeComp, lpMpcImage, &nBytesRead); if (nBytesRead != dwSizeDecomp) return false; globalDestroy(cmpbuf); } else { - /* If the file is not compressed, we directly read in the data */ + // If the file is not compressed, we directly read in the data nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); if (nBytesRead != dwSizeDecomp) return false; } - /* Close the file */ + // Close the file hMpc.close(); - /* Process the data */ + // Process the data if (ParseMpc(lpMpcImage) == false) return false; globalDestroy(lpMpcImage); - /* Open the MPR file */ + // Open the MPR file if (!GLOBALS._hMpr.open(lpszMprFileName)) return false; - /* Seek to the end of the file to read overall information */ + // Seek to the end of the file to read overall information GLOBALS._hMpr.seek(-12, SEEK_END); dwSizeComp = GLOBALS._hMpr.readUint32LE(); @@ -1497,7 +1496,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; - /* Move to the start of the resources header */ + // Move to the start of the resources header GLOBALS._hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); GLOBALS._lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS._nResources * 8); @@ -1518,17 +1517,17 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, globalDestroy(cmpbuf); - /* Reset back to the start of the file, leaving it open */ + // Reset back to the start of the file, leaving it open GLOBALS._hMpr.seek(0, SEEK_SET); - /* There is no action or dialog running by default */ + // There is no action or dialog running by default GLOBALS._bExecutingAction = false; GLOBALS._bExecutingDialog = false; - /* There's no polling location */ + // There's no polling location Common::fill(GLOBALS._nPollingLocations, GLOBALS._nPollingLocations + MAXPOLLINGLOCATIONS, 0); - /* Create the event that will be used to co-ordinate making choices and choices finishing */ + // Create the event that will be used to co-ordinate making choices and choices finishing GLOBALS._hAskChoice = CoroScheduler.createEvent(true, false); GLOBALS._hDoneChoice = CoroScheduler.createEvent(true, false); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 4c8ca481b0..492889d88a 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -95,7 +95,7 @@ namespace MPAL { * Macro definitions and structures \****************************************************************************/ -/* OK value for the error codes */ +// OK value for the error codes #define OK 0 #define MAXFRAMES 400 // frame animation of an object @@ -119,31 +119,31 @@ enum QueryCoordinates { * that can do at the library */ enum QueryTypes { - /* General Query */ + // General Query MPQ_VERSION=10, MPQ_GLOBAL_VAR=50, MPQ_RESOURCE, MPQ_MESSAGE, - /* Query on leases */ + // Query on leases MPQ_LOCATION_IMAGE=100, MPQ_LOCATION_SIZE, - /* Queries about items */ + // Queries about items MPQ_ITEM_LIST=200, MPQ_ITEM_DATA, MPQ_ITEM_PATTERN, MPQ_ITEM_NAME, MPQ_ITEM_IS_ACTIVE, - /* Query dialog */ + // Query dialog MPQ_DIALOG_PERIOD=300, MPQ_DIALOG_WAITFORCHOICE, MPQ_DIALOG_SELECTLIST, MPQ_DIALOG_SELECTION, - /* Query execution */ + // Query execution MPQ_DO_ACTION=400, MPQ_DO_DIALOG }; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e8b9dfc42a..2c2c280eb2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -532,7 +532,7 @@ bool FPStream::unloadFile() { assert(!g_system->getMixer()->isSoundHandleActive(_handle)); - /* Closes the file handle stream */ + // Closes the file handle stream delete _loopStream; delete _rewindableStream; _loopStream = NULL; diff --git a/engines/tony/window.h b/engines/tony/window.h index 9aaca16d3e..c4cbcb6643 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -72,7 +72,7 @@ public: /** * Initialization */ - void init(/*HINSTANCE hInst*/); + void init(); void close(); /** -- cgit v1.2.3 From 56c5961fb4790345d71dde1ea286960abfb3c25b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 30 Aug 2012 08:06:10 +0200 Subject: TONY: Translate some variables in findPath, reduce some variable scopes --- engines/tony/loc.cpp | 86 ++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 5d11672e34..a92282cc3f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -880,11 +880,11 @@ void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************/ short RMCharacter::findPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes - static short COSTO[MAXBOXES]; // Cost per node - static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated - static short NEXT[MAXBOXES]; // Next node - short i, j, k, costominimo, fine, errore = 0; + static RMBox box[MAXBOXES]; // Matrix of adjacent boxes + static short nodeCost[MAXBOXES]; // Cost per node + static short valid[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated + static short nextNode[MAXBOXES]; // Next node + short minCost, error = 0; RMBoxLoc *cur; g_system->lockMutex(_csMove); @@ -898,67 +898,67 @@ short RMCharacter::findPath(short source, short destination) { cur = _theBoxes->getBoxes(_curLocation); // Make a backup copy to work on - for (i = 0; i < cur->_numbBox; i++) - memcpy(&BOX[i], &cur->_boxes[i], sizeof(RMBox)); + for (int i = 0; i < cur->_numbBox; i++) + memcpy(&box[i], &cur->_boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->_numbBox; i++) - VALIDO[i] = 0; + for (int i = 0; i < cur->_numbBox; i++) + valid[i] = 0; // Prepare source and variables for the procedure - COSTO[source] = 0; - VALIDO[source] = 1; - fine = 0; + nodeCost[source] = 0; + valid[source] = 1; + bool finish = false; // Find the shortest path - while (!fine) { - costominimo = 32000; // Reset the minimum cost - errore = 1; // Possible error + while (!finish) { + minCost = 32000; // Reset the minimum cost + error = 1; // Possible error // 1st cycle: explore possible new nodes - for (i = 0; i < cur->_numbBox; i++) - if (VALIDO[i] == 1) { - errore = 0; // Failure de-bunked - j = 0; - while (((BOX[i]._adj[j]) != 1) && (j < cur->_numbBox)) + for (int i = 0; i < cur->_numbBox; i++) + if (valid[i] == 1) { + error = 0; // Failure de-bunked + int j = 0; + while (((box[i]._adj[j]) != 1) && (j < cur->_numbBox)) j++; if (j >= cur->_numbBox) - VALIDO[i] = 2; // nodo saturated? + valid[i] = 2; // nodo saturated? else { - NEXT[i] = j; - if (COSTO[i] + 1 < costominimo) - costominimo = COSTO[i] + 1; + nextNode[i] = j; + if (nodeCost[i] + 1 < minCost) + minCost = nodeCost[i] + 1; } } - if (errore) - fine = 1; // All nodes saturated + if (error) + finish = true; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes - for (i = 0; i < cur->_numbBox; i++) - if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { - BOX[i]._adj[NEXT[i]] = 2; - COSTO[NEXT[i]] = costominimo; - VALIDO[NEXT[i]] = 1; - for (j = 0; j < cur->_numbBox; j++) - if (BOX[j]._adj[NEXT[i]] == 1) - BOX[j]._adj[NEXT[i]] = 0; - - if (NEXT[i] == destination) - fine = 1; + for (int i = 0; i < cur->_numbBox; i++) + if ((valid[i] == 1) && ((nodeCost[i] + 1) == minCost)) { + box[i]._adj[nextNode[i]] = 2; + nodeCost[nextNode[i]] = minCost; + valid[nextNode[i]] = 1; + for (int j = 0; j < cur->_numbBox; j++) + if (box[j]._adj[nextNode[i]] == 1) + box[j]._adj[nextNode[i]] = 0; + + if (nextNode[i] == destination) + finish = true; } } // Remove the path from the adjacent modified matrixes - if (!errore) { - _pathLength = COSTO[destination]; - k = _pathLength; + if (!error) { + _pathLength = nodeCost[destination]; + short k = _pathLength; _path[k] = destination; while (_path[k] != source) { - i = 0; - while (BOX[i]._adj[_path[k]] != 2) + int i = 0; + while (box[i]._adj[_path[k]] != 2) i++; k--; _path[k] = i; @@ -969,7 +969,7 @@ short RMCharacter::findPath(short source, short destination) { g_system->unlockMutex(_csMove); - return !errore; + return !error; } -- cgit v1.2.3 From 16b27090b1c7dc11cdc199b1a98c0f2973db5f45 Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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淡maen 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 7fbfbc8e6b57729e1a5008d256b28b0571f1c3b6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 31 Aug 2012 23:08:02 +0200 Subject: TONY: Rename some more variables and structures --- engines/tony/globals.h | 12 +- engines/tony/mpal/loadmpc.cpp | 276 ++++++++++++++++---------------- engines/tony/mpal/loadmpc.h | 4 +- engines/tony/mpal/mpal.cpp | 355 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 13 +- engines/tony/mpal/mpaldll.h | 170 +++++++++----------- engines/tony/tony.cpp | 4 +- 7 files changed, 405 insertions(+), 429 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 0911782eac..6966bd7264 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -252,22 +252,22 @@ public: uint16 _nObjs; uint16 _nVars; HGLOBAL _hVars; - LPMPALVAR _lpmvVars; + LpMpalVar _lpmvVars; uint16 _nMsgs; HGLOBAL _hMsgs; - LPMPALMSG _lpmmMsgs; + LpMpalMsg _lpmmMsgs; uint16 _nDialogs; HGLOBAL _hDialogs; - LPMPALDIALOG _lpmdDialogs; + LpMpalDialog _lpmdDialogs; uint16 _nItems; HGLOBAL _hItems; - LPMPALITEM _lpmiItems; + LpMpalItem _lpmiItems; uint16 _nLocations; HGLOBAL _hLocations; - LPMPALLOCATION _lpmlLocations; + LpMpalLocation _lpmlLocations; uint16 _nScripts; HGLOBAL _hScripts; - LPMPALSCRIPT _lpmsScripts; + LpMpalScript _lpmsScripts; Common::File _hMpr; uint16 _nResources; uint32 *_lpResources; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9927f9fe8e..b3c4193414 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -39,15 +39,15 @@ namespace MPAL { * Static functions \****************************************************************************/ -static bool compareCommands(struct command *cmd1, struct command *cmd2) { - if (cmd1->type == 2 && cmd2->type == 2) { - if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - compareExpressions(cmd1->expr, cmd2->expr)) +static bool compareCommands(struct Command *cmd1, struct Command *cmd2) { + if (cmd1->_type == 2 && cmd2->_type == 2) { + if (strcmp(cmd1->_lpszVarName, cmd2->_lpszVarName) == 0 && + compareExpressions(cmd1->_expr, cmd2->_expr)) return true; else return false; } else - return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); + return (memcmp(cmd1, cmd2, sizeof(struct Command)) == 0); } /** @@ -58,25 +58,25 @@ static bool compareCommands(struct command *cmd1, struct command *cmd2) { * data of the script. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *ParseScript(const byte *lpBuf, LpMpalScript lpmsScript) { + lpmsScript->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->nMoments = READ_LE_UINT16(lpBuf); + lpmsScript->_nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; int curCmd = 0; - for (uint i = 0; i < lpmsScript->nMoments; i++) { - lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); + for (uint i = 0; i < lpmsScript->_nMoments; i++) { + lpmsScript->_moment[i]._dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds = *lpBuf; + lpmsScript->_moment[i]._nCmds = *lpBuf; lpBuf++; - for (int j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->_command[curCmd].type = *lpBuf; + for (int j = 0; j < lpmsScript->_moment[i]._nCmds; j++) { + lpmsScript->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmsScript->_command[curCmd].type) { + switch (lpmsScript->_command[curCmd]._type) { case 1: lpmsScript->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -93,13 +93,13 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { case 2: { // Variable assign int len = *lpBuf; lpBuf++; - lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmsScript->_command[curCmd].lpszVarName == NULL) + lpmsScript->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmsScript->_command[curCmd]._lpszVarName == NULL) return NULL; - memcpy(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmsScript->_command[curCmd]._lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; @@ -108,7 +108,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return NULL; } - lpmsScript->Moment[i].CmdNum[j] = curCmd; + lpmsScript->_moment[i]._cmdNum[j] = curCmd; curCmd++; } } @@ -120,12 +120,12 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { * * @param lpmsScript Pointer to a script structure */ -static void FreeScript(LPMPALSCRIPT lpmsScript) { - for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i].type); ++i, ++lpmsScript) { - if (lpmsScript->_command[i].type == 2) { +static void FreeScript(LpMpalScript lpmsScript) { + for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i]._type); ++i, ++lpmsScript) { + if (lpmsScript->_command[i]._type == 2) { // Variable Assign - globalDestroy(lpmsScript->_command[i].lpszVarName); - freeExpression(lpmsScript->_command[i].expr); + globalDestroy(lpmsScript->_command[i]._lpszVarName); + freeExpression(lpmsScript->_command[i]._expr); } } } @@ -138,11 +138,11 @@ static void FreeScript(LPMPALSCRIPT lpmsScript) { * data of the dialog. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) { uint32 num2, num3; byte *lpLock; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpmdDialog->_nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; // Periods @@ -150,7 +150,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) - error("Too much periods in dialog #%d", lpmdDialog->nObj); + error("Too much periods in dialog #%d", lpmdDialog->_nObj); uint32 i; for (i = 0; i < num; i++) { @@ -172,21 +172,21 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) - error("Too much groups in dialog #%d", lpmdDialog->nObj); + error("Too much groups in dialog #%d", lpmdDialog->_nObj); for (i = 0; i < num; i++) { - lpmdDialog->_group[i].num = READ_LE_UINT16(lpBuf); + lpmdDialog->_group[i]._num = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_group[i].nCmds = *lpBuf; lpBuf++; + lpmdDialog->_group[i]._nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) - error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); + if (lpmdDialog->_group[i]._nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d", lpmdDialog->_group[i]._num, lpmdDialog->_nObj); - for (uint32 j = 0; j < lpmdDialog->_group[i].nCmds; j++) { - lpmdDialog->_command[curCmd].type = *lpBuf; + for (uint32 j = 0; j < lpmdDialog->_group[i]._nCmds; j++) { + lpmdDialog->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmdDialog->_command[curCmd].type) { + switch (lpmdDialog->_command[curCmd]._type) { // Call custom function case 1: lpmdDialog->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); @@ -205,21 +205,21 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { case 2: { uint32 len = *lpBuf; lpBuf++; - lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmdDialog->_command[curCmd].lpszVarName == NULL) + lpmdDialog->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->_command[curCmd]._lpszVarName == NULL) return NULL; - Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd].lpszVarName); + Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd]._lpszVarName); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; } // Do Choice case 3: - lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd]._nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; @@ -230,56 +230,56 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 kk; for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { - lpmdDialog->_group[i].CmdNum[j] = kk; + lpmdDialog->_group[i]._cmdNum[j] = kk; // Free any data allocated for the duplictaed command - if (lpmdDialog->_command[curCmd].type == 2) { - globalDestroy(lpmdDialog->_command[curCmd].lpszVarName); - freeExpression(lpmdDialog->_command[curCmd].expr); + if (lpmdDialog->_command[curCmd]._type == 2) { + globalDestroy(lpmdDialog->_command[curCmd]._lpszVarName); + freeExpression(lpmdDialog->_command[curCmd]._expr); - lpmdDialog->_command[curCmd].lpszVarName = NULL; - lpmdDialog->_command[curCmd].expr = 0; - lpmdDialog->_command[curCmd].type = 0; + lpmdDialog->_command[curCmd]._lpszVarName = NULL; + lpmdDialog->_command[curCmd]._expr = 0; + lpmdDialog->_command[curCmd]._type = 0; } break; } } if (kk == curCmd) { - lpmdDialog->_group[i].CmdNum[j] = curCmd; + lpmdDialog->_group[i]._cmdNum[j] = curCmd; curCmd++; } } } if (curCmd >= MAX_COMMANDS_PER_DIALOG) - error("Too much commands in dialog #%d",lpmdDialog->nObj); + error("Too much commands in dialog #%d",lpmdDialog->_nObj); // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) - error("Too much choices in dialog #%d",lpmdDialog->nObj); + error("Too much choices in dialog #%d",lpmdDialog->_nObj); for (i = 0; i < num; i++) { - lpmdDialog->_choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) - error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); + error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj); for (uint32 j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: - lpmdDialog->_choice[i]._select[j].when = NULL; + lpmdDialog->_choice[i]._select[j]._when = NULL; break; case 1: - lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j].when); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j]._when); if (lpBuf == NULL) return NULL; break; @@ -289,31 +289,31 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->_choice[i]._select[j].attr = *lpBuf++; + lpmdDialog->_choice[i]._select[j]._attr = *lpBuf++; // Data - lpmdDialog->_choice[i]._select[j].dwData = READ_LE_UINT32(lpBuf); + lpmdDialog->_choice[i]._select[j]._dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup num3 = *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) - error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj); for (uint32 z = 0; z < num3; z++) { - lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._select[j]._wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->_choice[i]._select[j].wPlayGroup[num3] = 0; + lpmdDialog->_choice[i]._select[j]._wPlayGroup[num3] = 0; } // Mark the last selection - lpmdDialog->_choice[i]._select[num2].dwData = 0; + lpmdDialog->_choice[i]._select[num2]._dwData = 0; } - lpmdDialog->_choice[num].nChoice = 0; + lpmdDialog->_choice[num]._nChoice = 0; return lpBuf; } @@ -329,63 +329,63 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * @remarks It's necessary that the structure that is passed has been * completely initialized to 0 beforehand. */ -static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { - lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *parseItem(const byte *lpBuf, LpMpalItem lpmiItem) { + lpmiItem->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; byte len = *lpBuf; lpBuf++; - memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + memcpy(lpmiItem->_lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) - error("Describe too long in item #%d", lpmiItem->nObj); + error("Describe too long in item #%d", lpmiItem->_nObj); - lpmiItem->nActions=*lpBuf; + lpmiItem->_nActions=*lpBuf; lpBuf++; // Allocation action - if (lpmiItem->nActions > 0) - lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); + if (lpmiItem->_nActions > 0) + lpmiItem->_action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->_nActions); uint32 curCmd = 0; - for (uint32 i = 0; i < lpmiItem->nActions; i++) { - lpmiItem->Action[i].num = *lpBuf; + for (uint32 i = 0; i < lpmiItem->_nActions; i++) { + lpmiItem->_action[i]._num = *lpBuf; lpBuf++; - lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); + lpmiItem->_action[i]._wParm = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (lpmiItem->Action[i].num == 0xFF) { - lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); + if (lpmiItem->_action[i]._num == 0xFF) { + lpmiItem->_action[i]._wTime = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Action[i].perc = *lpBuf; + lpmiItem->_action[i]._perc = *lpBuf; lpBuf++; } if (*lpBuf == 0) { lpBuf++; - lpmiItem->Action[i].when = NULL; + lpmiItem->_action[i]._when = NULL; } else { lpBuf++; - lpBuf = parseExpression(lpBuf,&lpmiItem->Action[i].when); + lpBuf = parseExpression(lpBuf,&lpmiItem->_action[i]._when); if (lpBuf == NULL) return NULL; } - lpmiItem->Action[i].nCmds=*lpBuf; + lpmiItem->_action[i]._nCmds=*lpBuf; lpBuf++; - if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) - error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); + if (lpmiItem->_action[i]._nCmds >= MAX_COMMANDS_PER_ACTION) + error("Too much commands in action #%d in item #%d",lpmiItem->_action[i]._num, lpmiItem->_nObj); - for (uint32 j = 0; j < lpmiItem->Action[i].nCmds; j++) { - lpmiItem->_command[curCmd].type = *lpBuf; + for (uint32 j = 0; j < lpmiItem->_action[i]._nCmds; j++) { + lpmiItem->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmiItem->_command[curCmd].type) { + switch (lpmiItem->_command[curCmd]._type) { case 1: // Call custom function lpmiItem->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -402,13 +402,13 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmiItem->_command[curCmd].lpszVarName == NULL) + lpmiItem->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->_command[curCmd]._lpszVarName == NULL) return NULL; - memcpy(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmiItem->_command[curCmd]._lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; @@ -420,34 +420,34 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { uint32 kk; for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { - lpmiItem->Action[i].CmdNum[j] = kk; + lpmiItem->_action[i]._cmdNum[j] = kk; // Free any data allocated for the duplictaed command - if (lpmiItem->_command[curCmd].type == 2) { - globalDestroy(lpmiItem->_command[curCmd].lpszVarName); - freeExpression(lpmiItem->_command[curCmd].expr); + if (lpmiItem->_command[curCmd]._type == 2) { + globalDestroy(lpmiItem->_command[curCmd]._lpszVarName); + freeExpression(lpmiItem->_command[curCmd]._expr); - lpmiItem->_command[curCmd].lpszVarName = NULL; - lpmiItem->_command[curCmd].expr = 0; - lpmiItem->_command[curCmd].type = 0; + lpmiItem->_command[curCmd]._lpszVarName = NULL; + lpmiItem->_command[curCmd]._expr = 0; + lpmiItem->_command[curCmd]._type = 0; } break; } } if (kk == curCmd) { - lpmiItem->Action[i].CmdNum[j] = curCmd; + lpmiItem->_action[i]._cmdNum[j] = curCmd; curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { - error("Too much commands in item #%d",lpmiItem->nObj); + error("Too much commands in item #%d", lpmiItem->_nObj); //curCmd=0; } } } } - lpmiItem->dwRes = READ_LE_UINT32(lpBuf); + lpmiItem->_dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -458,23 +458,23 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { * * @param lpmiItem Pointer to an item structure */ -static void freeItem(LPMPALITEM lpmiItem) { +static void freeItem(LpMpalItem lpmiItem) { // Free the actions - if (lpmiItem->Action) { - for (int i = 0; i < lpmiItem->nActions; ++i) { - if (lpmiItem->Action[i].when != 0) - freeExpression(lpmiItem->Action[i].when); + if (lpmiItem->_action) { + for (int i = 0; i < lpmiItem->_nActions; ++i) { + if (lpmiItem->_action[i]._when != 0) + freeExpression(lpmiItem->_action[i]._when); } - globalDestroy(lpmiItem->Action); + globalDestroy(lpmiItem->_action); } // Free the commands - for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i) { - if (lpmiItem->_command[i].type == 2) { + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i]._type); ++i) { + if (lpmiItem->_command[i]._type == 2) { // Variable Assign - globalDestroy(lpmiItem->_command[i].lpszVarName); - freeExpression(lpmiItem->_command[i].expr); + globalDestroy(lpmiItem->_command[i]._lpszVarName); + freeExpression(lpmiItem->_command[i]._expr); } } } @@ -487,14 +487,14 @@ static void freeItem(LPMPALITEM lpmiItem) { * data of the location. * @returns Pointer to the buffer after the location, or NULL on failure. */ -static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { - lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *ParseLocation(const byte *lpBuf, LpMpalLocation lpmlLocation) { + lpmlLocation->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmlLocation->dwXlen = READ_LE_UINT16(lpBuf); + lpmlLocation->_dwXlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); + lpmlLocation->_dwYlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpmlLocation->_dwPicRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -516,7 +516,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) * @param lpBuf Buffer containing the MPC file data, excluding the header. * @returns True if succeeded OK, false if failure. */ -bool ParseMpc(const byte *lpBuf) { +bool parseMpc(const byte *lpBuf) { byte *lpTemp; // 1. Variables @@ -527,18 +527,18 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS._nVars); + GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MpalVar) * (uint32)GLOBALS._nVars); if (GLOBALS._hVars == NULL) return false; - GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); + GLOBALS._lpmvVars = (LpMpalVar)globalLock(GLOBALS._hVars); for (uint16 i = 0; i < GLOBALS._nVars; i++) { uint16 wLen = *(const byte *)lpBuf; lpBuf++; - memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + memcpy(GLOBALS._lpmvVars->_lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS._lpmvVars->_dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Skip 'ext' @@ -556,11 +556,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MpalMsg) * (uint32)GLOBALS._nMsgs); if (GLOBALS._hMsgs == NULL) return false; - GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + GLOBALS._lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); #else GLOBALS._lpmmMsgs=(LPMPALMSG)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); if (GLOBALS._lpmmMsgs==NULL) @@ -611,11 +611,11 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MPALDIALOG)); + GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MpalDialog)); if (GLOBALS._hDialogs == NULL) return false; - GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + GLOBALS._lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); for (uint16 i = 0; i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) @@ -633,11 +633,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MPALITEM)); + GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MpalItem)); if (GLOBALS._hItems == NULL) return false; - GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + GLOBALS._lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); for (uint16 i = 0; i < GLOBALS._nItems; i++) { if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) @@ -655,11 +655,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MPALLOCATION)); + GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MpalLocation)); if (GLOBALS._hLocations == NULL) return false; - GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); + GLOBALS._lpmlLocations = (LpMpalLocation)globalLock(GLOBALS._hLocations); for (uint16 i = 0; i < GLOBALS._nLocations; i++) { if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) @@ -677,11 +677,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MPALSCRIPT)); + GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MpalScript)); if (GLOBALS._hScripts == NULL) return false; - GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + GLOBALS._lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) @@ -708,24 +708,24 @@ bool ParseMpc(const byte *lpBuf) { /** * Free the given dialog */ -static void freeDialog(LPMPALDIALOG lpmdDialog) { +static void freeDialog(LpMpalDialog lpmdDialog) { // Free the periods for (int i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { - if (lpmdDialog->_command[i].type == 2) { + for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i]._type); i++) { + if (lpmdDialog->_command[i]._type == 2) { // Variable assign - globalDestroy(lpmdDialog->_command[i].lpszVarName); - freeExpression(lpmdDialog->_command[i].expr); + globalDestroy(lpmdDialog->_command[i]._lpszVarName); + freeExpression(lpmdDialog->_command[i]._expr); } } // Free the choices for (int i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { for (int j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { - if (lpmdDialog->_choice[i]._select[j].when) - freeExpression(lpmdDialog->_choice[i]._select[j].when); + if (lpmdDialog->_choice[i]._select[j]._when) + freeExpression(lpmdDialog->_choice[i]._select[j]._when); } } } @@ -733,12 +733,12 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { /** * Frees any data allocated from the parsing of the MPC file */ -void FreeMpc() { +void freeMpc() { // Free variables globalFree(GLOBALS._hVars); // Free messages - LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + LpMpalMsg lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); for (int i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) globalFree(lpmmMsgs->_hText); @@ -747,7 +747,7 @@ void FreeMpc() { // Free objects if (GLOBALS._hDialogs) { - LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + LpMpalDialog lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); for (int i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); @@ -757,7 +757,7 @@ void FreeMpc() { // Free items if (GLOBALS._hItems) { - LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + LpMpalItem lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); for (int i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); @@ -773,7 +773,7 @@ void FreeMpc() { // Free the scripts if (GLOBALS._hScripts) { - LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + LpMpalScript lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); for (int i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index c0e2ca7fb5..20956288aa 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -44,12 +44,12 @@ namespace MPAL { * @param lpBuf Buffer containing the MPC file data, excluding the header. * @returns True if succeeded OK, false if failure. */ -bool ParseMpc(const byte *lpBuf); +bool parseMpc(const byte *lpBuf); /** * Frees any data allocated from the parsing of the MPC file */ -void FreeMpc(); +void freeMpc(); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 514001eda7..9a92fd7766 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -60,7 +60,7 @@ const char *mpalCopyright = * Locks the variables for access */ void lockVar() { - GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); + GLOBALS._lpmvVars = (LpMpalVar)globalLock(GLOBALS._hVars); } /** @@ -75,7 +75,7 @@ void unlockVar() { */ static void LockMsg() { #ifdef NEED_LOCK_MSGS - GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + GLOBALS._lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); #endif } @@ -92,7 +92,7 @@ static void UnlockMsg() { * Locks the dialogs for access */ static void lockDialogs() { - GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + GLOBALS._lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); } /** @@ -106,7 +106,7 @@ static void unlockDialogs() { * Locks the location data structures for access */ static void lockLocations() { - GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); + GLOBALS._lpmlLocations = (LpMpalLocation)globalLock(GLOBALS._hLocations); } /** @@ -120,7 +120,7 @@ static void unlockLocations() { * Locks the items structures for use */ static void lockItems() { - GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + GLOBALS._lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); } /** @@ -134,7 +134,7 @@ static void unlockItems() { * Locks the script data structures for use */ static void LockScripts() { - GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + GLOBALS._lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); } /** @@ -154,11 +154,11 @@ static void unlockScripts() { * need to remember to call UnlockVar() */ int32 varGetValue(const char *lpszVarName) { - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; for (int i = 0; i < GLOBALS._nVars; v++, i++) - if (strcmp(lpszVarName, v->lpszVarName) == 0) - return v->dwVal; + if (strcmp(lpszVarName, v->_lpszVarName) == 0) + return v->_dwVal; GLOBALS._mpalError = 1; return 0; @@ -170,18 +170,18 @@ int32 varGetValue(const char *lpszVarName) { * @param val Value to set */ void varSetValue(const char *lpszVarName, int32 val) { - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; for (uint i = 0; i < GLOBALS._nVars; v++, i++) - if (strcmp(lpszVarName, v->lpszVarName) == 0) { - v->dwVal = val; - if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (strcmp(lpszVarName, v->_lpszVarName) == 0) { + v->_dwVal = val; + if (GLOBALS._lpiifCustom != NULL && strncmp(v->_lpszVarName, "Pattern.", 8) == 0) { i = 0; - sscanf(v->lpszVarName, "Pattern.%u", &i); + sscanf(v->_lpszVarName, "Pattern.%u", &i); GLOBALS._lpiifCustom(i, val, -1); - } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->_lpszVarName, "Status.", 7) == 0) { i = 0; - sscanf(v->lpszVarName,"Status.%u", &i); + sscanf(v->_lpszVarName,"Status.%u", &i); GLOBALS._lpiifCustom(i, -1, val); } return; @@ -200,10 +200,10 @@ void varSetValue(const char *lpszVarName, int32 val) { * first been locked with a call to LockLoc(). */ static int locGetOrderFromNum(uint32 nLoc) { - LPMPALLOCATION loc = GLOBALS._lpmlLocations; + LpMpalLocation loc = GLOBALS._lpmlLocations; for (int i = 0; i < GLOBALS._nLocations; i++, loc++) - if (loc->nObj == nLoc) + if (loc->_nObj == nLoc) return i; return -1; @@ -218,7 +218,7 @@ static int locGetOrderFromNum(uint32 nLoc) { * first been locked with a call to LockMsg() */ static int msgGetOrderFromNum(uint32 nMsg) { - LPMPALMSG msg = GLOBALS._lpmmMsgs; + LpMpalMsg msg = GLOBALS._lpmmMsgs; for (int i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) @@ -236,10 +236,10 @@ static int msgGetOrderFromNum(uint32 nMsg) { * first been locked with a call to LockItems() */ static int itemGetOrderFromNum(uint32 nItem) { - LPMPALITEM item = GLOBALS._lpmiItems; + LpMpalItem item = GLOBALS._lpmiItems; for (int i = 0; i < GLOBALS._nItems; i++, item++) { - if (item->nObj == nItem) + if (item->_nObj == nItem) return i; } @@ -255,10 +255,10 @@ static int itemGetOrderFromNum(uint32 nItem) { * first been locked with a call to LockScripts() */ static int scriptGetOrderFromNum(uint32 nScript) { - LPMPALSCRIPT script = GLOBALS._lpmsScripts; + LpMpalScript script = GLOBALS._lpmsScripts; for (int i = 0; i < GLOBALS._nScripts; i++, script++) { - if (script->nObj == nScript) + if (script->_nObj == nScript) return i; } @@ -274,10 +274,10 @@ static int scriptGetOrderFromNum(uint32 nScript) { * first been locked with a call to LockDialogs() */ static int dialogGetOrderFromNum(uint32 nDialog) { - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; + LpMpalDialog dialog = GLOBALS._lpmdDialogs; for (int i = 0; i < GLOBALS._nDialogs; i++, dialog++) { - if (dialog->nObj == nDialog) + if (dialog->_nObj == nDialog) return i; } @@ -326,7 +326,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { @@ -386,7 +386,7 @@ HGLOBAL resLoad(uint32 dwId) { h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); - temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); + temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nSizeComp); nBytesRead = GLOBALS._hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -406,12 +406,12 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Count how many are active selects int num = 0; - for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].curActive) + for (int j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._curActive) num++; } @@ -425,9 +425,9 @@ static uint32 *getSelectList(uint32 i) { // Copy all the data inside the active select list int k = 0; - for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].curActive) - sl[k++] = dialog->_choice[i]._select[j].dwData; + for (int j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._curActive) + sl[k++] = dialog->_choice[i]._select[j]._dwData; } sl[k] = (uint32)NULL; @@ -436,11 +436,11 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; uint32 num = 0; for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { - if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) + if (strncmp(v->_lpszVarName, "Location", 8) == 0 && v->_dwVal == nLoc) num++; } @@ -451,8 +451,8 @@ static uint32 *GetItemList(uint32 nLoc) { v = GLOBALS._lpmvVars; uint32 j = 0; for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { - if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { - sscanf(v->lpszVarName, "Location.%u", &il[j]); + if (strncmp(v->_lpszVarName, "Location", 8) == 0 && v->_dwVal == nLoc) { + sscanf(v->_lpszVarName, "Location.%u", &il[j]); j++; } } @@ -462,7 +462,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM getItemData(uint32 nOrdItem) { - LPMPALITEM curitem = GLOBALS._lpmiItems + nOrdItem; + LpMpalItem curitem = GLOBALS._lpmiItems + nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -474,7 +474,7 @@ static LPITEM getItemData(uint32 nOrdItem) { return NULL; ret->_speed = 150; - hDat = resLoad(curitem->dwRes); + hDat = resLoad(curitem->_dwRes); dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { @@ -597,7 +597,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_END_CONTEXT(_ctx); static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; - LPMPALSCRIPT s = *(const LPMPALSCRIPT *)param; + LpMpalScript s = *(const LpMpalScript *)param; CORO_BEGIN_CODE(_ctx); @@ -605,24 +605,24 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); - for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < s->_nMoments; _ctx->i++) { // Sleep for the required time - if (s->Moment[_ctx->i].dwTime == -1) { + if (s->_moment[_ctx->i]._dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = g_vm->getTime(); } else { _ctx->dwCurTime = g_vm->getTime(); - if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { + if (_ctx->dwCurTime < _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); } } _ctx->numHandles = 0; - for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < s->_moment[_ctx->i]._nCmds; _ctx->j++) { + _ctx->k = s->_moment[_ctx->i]._cmdNum[_ctx->j]; - if (s->_command[_ctx->k].type == 1) { + if (s->_command[_ctx->k]._type == 1) { _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS._mpalError = 1; @@ -644,11 +644,11 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_KILL_SELF(); return; } - } else if (s->_command[_ctx->k].type == 2) { + } else if (s->_command[_ctx->k]._type == 2) { lockVar(); varSetValue( - s->_command[_ctx->k].lpszVarName, - evaluateExpression(s->_command[_ctx->k].expr) + s->_command[_ctx->k]._lpszVarName, + evaluateExpression(s->_command[_ctx->k]._expr) ); unlockVar(); @@ -681,7 +681,7 @@ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; int j, k; - LPMPALITEM item; + LpMpalItem item; ~CoroContextTag() { if (item) @@ -693,13 +693,13 @@ void ActionThread(CORO_PARAM, const void *param) { // The ActionThread owns the data block pointed to, so we need to make sure it's // freed when the process exits - _ctx->item = *(LPMPALITEM *)param; + _ctx->item = *(LpMpalItem *)param; GLOBALS._mpalError = 0; - for (_ctx->j = 0; _ctx->j < _ctx->item->Action[_ctx->item->dwRes].nCmds; _ctx->j++) { - _ctx->k = _ctx->item->Action[_ctx->item->dwRes].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->item->_action[_ctx->item->_dwRes]._nCmds; _ctx->j++) { + _ctx->k = _ctx->item->_action[_ctx->item->_dwRes]._cmdNum[_ctx->j]; - if (_ctx->item->_command[_ctx->k].type == 1) { + if (_ctx->item->_command[_ctx->k]._type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[_ctx->item->_command[_ctx->k]._nCf].c_str(), @@ -714,13 +714,13 @@ void ActionThread(CORO_PARAM, const void *param) { _ctx->item->_command[_ctx->k]._arg4 ); - } else if (_ctx->item->_command[_ctx->k].type == 2) { + } else if (_ctx->item->_command[_ctx->k]._type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k]._lpszVarName); lockVar(); - varSetValue(_ctx->item->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k].expr)); + varSetValue(_ctx->item->_command[_ctx->k]._lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k]._expr)); unlockVar(); } else { @@ -775,20 +775,19 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { - uint32 nItem, nAction; - - uint16 wTime; - byte perc; - HGLOBAL when; - byte nCmds; - uint16 CmdNum[MAX_COMMANDS_PER_ACTION]; - - uint32 dwLastTime; + uint32 _nItem, _nAction; + + uint16 _wTime; + byte _perc; + HGLOBAL _when; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; + uint32 _dwLastTime; } MYACTION; typedef struct { - uint32 nItem; - uint32 hThread; + uint32 _nItem; + uint32 _hThread; } MYTHREAD; CORO_BEGIN_CONTEXT; @@ -796,7 +795,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { int i, j, k; int numitems; int nRealItems; - LPMPALITEM curItem,newItem; + LpMpalItem curItem,newItem; int nIdleActions; uint32 curTime; uint32 dwSleepTime; @@ -805,15 +804,15 @@ void LocationPollThread(CORO_PARAM, const void *param) { bool delayExpired; bool expired; - MYACTION *MyActions; - MYTHREAD *MyThreads; + MYACTION *myActions; + MYTHREAD *myThreads; ~CoroContextTag() { // Free data blocks - if (MyThreads) - globalDestroy(MyThreads); - if (MyActions) - globalDestroy(MyActions); + if (myThreads) + globalDestroy(myThreads); + if (myActions) + globalDestroy(myActions); } CORO_END_CONTEXT(_ctx); @@ -822,8 +821,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Initialize data pointers - _ctx->MyActions = NULL; - _ctx->MyThreads = NULL; + _ctx->myActions = NULL; + _ctx->myThreads = NULL; // To begin with, we need to request the item list from the location _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); @@ -845,8 +844,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { - if (_ctx->curItem->Action[_ctx->j].num == 0xFF) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->_nActions; _ctx->j++) { + if (_ctx->curItem->_action[_ctx->j]._num == 0xFF) _ctx->k++; } @@ -867,8 +866,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); - if (_ctx->MyThreads == NULL) { + _ctx->myThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + if (_ctx->myThreads == NULL) { globalDestroy(_ctx->il); CORO_KILL_SELF(); return; @@ -877,9 +876,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // We have established that there is at least one item that contains idle actions. // Now we created the mirrored copies of the idle actions. - _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); - if (_ctx->MyActions == NULL) { - globalDestroy(_ctx->MyThreads); + _ctx->myActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + if (_ctx->myActions == NULL) { + globalDestroy(_ctx->myThreads); globalDestroy(_ctx->il); CORO_KILL_SELF(); return; @@ -894,19 +893,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { - if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { - _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; - _ctx->MyActions[_ctx->k].nAction = _ctx->j; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->_nActions; _ctx->j++) { + if (_ctx->curItem->_action[_ctx->j]._num == 0xFF) { + _ctx->myActions[_ctx->k]._nItem = _ctx->il[_ctx->i]; + _ctx->myActions[_ctx->k]._nAction = _ctx->j; - _ctx->MyActions[_ctx->k].wTime = _ctx->curItem->Action[_ctx->j].wTime; - _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; - _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; - _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - memcpy(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + _ctx->myActions[_ctx->k]._wTime = _ctx->curItem->_action[_ctx->j]._wTime; + _ctx->myActions[_ctx->k]._perc = _ctx->curItem->_action[_ctx->j]._perc; + _ctx->myActions[_ctx->k]._when = _ctx->curItem->_action[_ctx->j]._when; + _ctx->myActions[_ctx->k]._nCmds = _ctx->curItem->_action[_ctx->j]._nCmds; + memcpy(_ctx->myActions[_ctx->k]._cmdNum, _ctx->curItem->_action[_ctx->j]._cmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); + _ctx->myActions[_ctx->k]._dwLastTime = g_vm->getTime(); _ctx->k++; } } @@ -925,11 +924,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) { - if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { _ctx->dwSleepTime = 0; break; } else - _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); + _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime - _ctx->curTime); } // We fall alseep, but always checking that the event is set when prompted for closure @@ -940,12 +939,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { break; for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + if (_ctx->myThreads[_ctx->i]._nItem != 0) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->myThreads[_ctx->i]._hThread, 0, &_ctx->delayExpired); // if result == WAIT_OBJECT_0) if (!_ctx->delayExpired) - _ctx->MyThreads[_ctx->i].nItem = 0; + _ctx->myThreads[_ctx->i]._nItem = 0; } } @@ -953,19 +952,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Loop through all the necessary idle actions for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { - if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { - _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; + if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { + _ctx->myActions[_ctx->k]._dwLastTime += _ctx->myActions[_ctx->k]._wTime; // It's time to check to see if fortune is on the side of the idle action byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); - if (randomVal < _ctx->MyActions[_ctx->k].perc) { + if (randomVal < _ctx->myActions[_ctx->k]._perc) { // Check if there is an action running on the item - if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->myActions[_ctx->k]._nItem)) continue; // Check to see if there already another idle funning running on the item for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) + if (_ctx->myThreads[_ctx->i]._nItem == _ctx->myActions[_ctx->k]._nItem) break; } @@ -974,49 +973,49 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Ok, we are the only ones :) lockItems(); - _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->myActions[_ctx->k]._nItem); // Check if there is a WhenExecute expression - _ctx->j=_ctx->MyActions[_ctx->k].nAction; - if (_ctx->curItem->Action[_ctx->j].when != NULL) { - if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { + _ctx->j=_ctx->myActions[_ctx->k]._nAction; + if (_ctx->curItem->_action[_ctx->j]._when != NULL) { + if (!evaluateExpression(_ctx->curItem->_action[_ctx->j]._when)) { unlockItems(); continue; } } // Ok, we can perform the action. For convenience, we do it in a new process - _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + _ctx->newItem = (LpMpalItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalItem)); if (_ctx->newItem == false) { - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); + globalDestroy(_ctx->myThreads); + globalDestroy(_ctx->myActions); CORO_KILL_SELF(); return; } - memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + memcpy(_ctx->newItem,_ctx->curItem, sizeof(MpalItem)); unlockItems(); // We copy the action in #0 //_ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; //memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); - _ctx->newItem->dwRes=_ctx->j; + _ctx->newItem->_dwRes = _ctx->j; // We will create an action, and will provide the necessary details for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem == 0) + if (_ctx->myThreads[_ctx->i]._nItem == 0) break; } - _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; + _ctx->myThreads[_ctx->i]._nItem = _ctx->myActions[_ctx->k]._nItem; // Create the process - if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) + if ((_ctx->myThreads[_ctx->i]._hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) { + //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem)) == (void*)-1) globalDestroy(_ctx->newItem); - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); + globalDestroy(_ctx->myThreads); + globalDestroy(_ctx->myActions); CORO_KILL_SELF(); return; @@ -1033,14 +1032,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + if (_ctx->myThreads[_ctx->i]._nItem != 0) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->myThreads[_ctx->i]._hThread, 5000, &_ctx->delayExpired); //if (result != WAIT_OBJECT_0) //if (_ctx->delayExpired) // TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); - CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + CoroScheduler.killMatchingProcess(_ctx->myThreads[_ctx->i]._hThread); } } @@ -1090,7 +1089,7 @@ void doChoice(CORO_PARAM, uint32 nChoice); */ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - LPMPALDIALOG dialog; + LpMpalDialog dialog; int i, j, k; int type; CORO_END_CONTEXT(_ctx); @@ -1106,13 +1105,13 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search inside the group requesting the _ctx->dialog - for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { - if (_ctx->dialog->_group[_ctx->i].num == nGroup) { + for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i]._num != 0; _ctx->i++) { + if (_ctx->dialog->_group[_ctx->i]._num == nGroup) { // Cycle through executing the commands of the group - for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = _ctx->dialog->_group[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i]._nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->_group[_ctx->i]._cmdNum[_ctx->j]; - _ctx->type = _ctx->dialog->_command[_ctx->k].type; + _ctx->type = _ctx->dialog->_command[_ctx->k]._type; if (_ctx->type == 1) { // Call custom function CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], @@ -1125,12 +1124,12 @@ void GroupThread(CORO_PARAM, const void *param) { } else if (_ctx->type == 2) { // Set a variable lockVar(); - varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); + varSetValue(_ctx->dialog->_command[_ctx->k]._lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k]._expr)); unlockVar(); } else if (_ctx->type == 3) { // DoChoice: call the chosen function - CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); + CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k]._nChoice); } else { GLOBALS._mpalError = 1; @@ -1166,7 +1165,7 @@ void GroupThread(CORO_PARAM, const void *param) { */ void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; - LPMPALDIALOG dialog; + LpMpalDialog dialog; int i, j, k; uint32 nGroup; CORO_END_CONTEXT(_ctx); @@ -1180,13 +1179,13 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search the choice between those required in the dialog - for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { - if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i]._nChoice != 0; _ctx->i++) { + if (_ctx->dialog->_choice[_ctx->i]._nChoice == nChoice) break; } // If nothing has been found, exit with an error - if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { + if (_ctx->dialog->_choice[_ctx->i]._nChoice == 0) { // If we're here, we did not find the required choice GLOBALS._mpalError = 1; unlockDialogs(); @@ -1203,15 +1202,15 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; // Calculate the expression of each selection, to see if they're active or inactive - for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._dwData != 0; _ctx->j++) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._when == NULL) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 1; _ctx->k++; - } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when)) { - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; + } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._when)) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 1; _ctx->k++; } else - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 0; } // If there are no choices activated, then the dialog is finished. @@ -1227,19 +1226,19 @@ void doChoice(CORO_PARAM, uint32 nChoice) { // Now that the choice has been made, we can run the groups associated with the choice tbontbtitq _ctx->j = GLOBALS._nSelectedChoice; - for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { - _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; + for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } // Control attribute - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._attr & (1 << 0)) { // Bit 0 set: the end of the choice unlockDialogs(); break; } - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._attr & (1 << 1)) { // Bit 1 set: the end of the dialog unlockDialogs(); @@ -1270,52 +1269,52 @@ void doChoice(CORO_PARAM, uint32 nChoice) { * by calling LockItem(). */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = GLOBALS._lpmiItems; - LPMPALITEM newitem; + LpMpalItem item = GLOBALS._lpmiItems; + LpMpalItem newitem; item+=ordItem; - Common::String buf = Common::String::format("Status.%u", item->nObj); + Common::String buf = Common::String::format("Status.%u", item->_nObj); if (varGetValue(buf.c_str()) <= 0) return CORO_INVALID_PID_VALUE; - for (int i = 0; i < item->nActions; i++) { - if (item->Action[i].num != nAction) + for (int i = 0; i < item->_nActions; i++) { + if (item->_action[i]._num != nAction) continue; - if (item->Action[i].wParm != dwParam) + if (item->_action[i]._wParm != dwParam) continue; - if (item->Action[i].when != NULL) { - if (!evaluateExpression(item->Action[i].when)) + if (item->_action[i]._when != NULL) { + if (!evaluateExpression(item->_action[i]._when)) continue; } // Now we find the right action to be performed // Duplicate the item and copy the current action in #i into #0 - newitem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LpMpalItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalItem)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; // In the new version number of the action in writing dwRes - Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); + Common::copy((byte *)item, (byte *)item + sizeof(MpalItem), (byte *)newitem); //newitem->Action[0].nCmds=item->Action[i].nCmds; //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); - newitem->dwRes = i; + newitem->_dwRes = i; // And finally we can laucnh the process that will execute the action, // and a second process to free up the memory when the action is finished. // !!! New process management uint32 h; - if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - GLOBALS._nExecutingAction = item->nObj; + GLOBALS._nExecutingAction = item->_nObj; GLOBALS._bExecutingAction = true; return h; @@ -1372,15 +1371,15 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool doSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) + for (j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._dwData == dwData && dialog->_choice[i]._select[j]._curActive != 0) break; } - if (dialog->_choice[i]._select[j].dwData == 0) + if (dialog->_choice[i]._select[j]._dwData == 0) return false; GLOBALS._nSelectedChoice = j; @@ -1469,7 +1468,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, hMpc.close(); // Process the data - if (ParseMpc(lpMpcImage) == false) + if (parseMpc(lpMpcImage) == false) return false; globalDestroy(lpMpcImage); @@ -1601,9 +1600,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { int y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = GLOBALS._lpmlLocations[x].dwXlen; + dwRet = GLOBALS._lpmlLocations[x]._dwXlen; else if (y == MPQ_Y) - dwRet = GLOBALS._lpmlLocations[x].dwYlen; + dwRet = GLOBALS._lpmlLocations[x]._dwYlen; else GLOBALS._mpalError = 1; } else @@ -1662,7 +1661,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); int y = itemGetOrderFromNum(x); - memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->_lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1795,7 +1794,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ lockLocations(); int x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS._lpmlLocations[x]._dwPicRes); unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -1839,7 +1838,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); int y = itemGetOrderFromNum(x); - memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->_lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1959,25 +1958,24 @@ uint32 mpalGetError() { * @returns TRUE if the script 'was launched, FALSE on failure */ bool mpalExecuteScript(int nScript) { - LPMPALSCRIPT s; + LpMpalScript s; LockScripts(); int n = scriptGetOrderFromNum(nScript); - s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + s = (LpMpalScript)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalScript)); if (s == NULL) return false; - memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); + memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MpalScript)); unlockScripts(); // !!! New process management - if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) + if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LpMpalScript)) == CORO_INVALID_PID_VALUE) return false; return true; } - /** * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. @@ -1988,7 +1986,6 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { GLOBALS._lpiifCustom = lpiifCus; } - /** * Process the idle actions of the items on one location. * @@ -2063,7 +2060,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { * @returns Length in bytes */ int mpalGetSaveStateSize() { - return GLOBALS._nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MpalVar) + 4; } /** @@ -2075,7 +2072,7 @@ int mpalGetSaveStateSize() { void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); - memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MpalVar)); unlockVar(); } @@ -2092,12 +2089,12 @@ int mpalLoadState(byte *buf) { GLOBALS._nVars = READ_LE_UINT32(buf); - GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MpalVar)); lockVar(); - memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MpalVar)); unlockVar(); - return GLOBALS._nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MpalVar) + 4; } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 492889d88a..1af0f2c9e9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -120,31 +120,31 @@ enum QueryCoordinates { */ enum QueryTypes { // General Query - MPQ_VERSION=10, + MPQ_VERSION = 10, - MPQ_GLOBAL_VAR=50, + MPQ_GLOBAL_VAR = 50, MPQ_RESOURCE, MPQ_MESSAGE, // Query on leases - MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_IMAGE = 100, MPQ_LOCATION_SIZE, // Queries about items - MPQ_ITEM_LIST=200, + MPQ_ITEM_LIST = 200, MPQ_ITEM_DATA, MPQ_ITEM_PATTERN, MPQ_ITEM_NAME, MPQ_ITEM_IS_ACTIVE, // Query dialog - MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_PERIOD = 300, MPQ_DIALOG_WAITFORCHOICE, MPQ_DIALOG_SELECTLIST, MPQ_DIALOG_SELECTION, // Query execution - MPQ_DO_ACTION=400, + MPQ_DO_ACTION = 400, MPQ_DO_DIALOG }; @@ -164,7 +164,6 @@ typedef struct { short _destX, _destY; signed char _destZ; short _objectID; -// char TAG; } ITEM; typedef ITEM *LPITEM; diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index a95003ef97..853b5b2dac 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -42,32 +42,27 @@ namespace MPAL { * Defines \****************************************************************************/ -#define HEX_VERSION 0x0170 - - -#define MAX_ACTIONS_PER_ITEM 40 -#define MAX_COMMANDS_PER_ITEM 128 -#define MAX_COMMANDS_PER_ACTION 128 -#define MAX_DESCRIBE_SIZE 64 - - -#define MAX_MOMENTS_PER_SCRIPT 256 -#define MAX_COMMANDS_PER_SCRIPT 256 -#define MAX_COMMANDS_PER_MOMENT 32 - - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 480 -#define MAX_COMMANDS_PER_GROUP 64 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 64 +#define HEX_VERSION 0x0170 + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 128 +#define MAX_COMMANDS_PER_ACTION 128 +#define MAX_DESCRIBE_SIZE 64 + +#define MAX_MOMENTS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_MOMENT 32 + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 480 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 64 #define MAX_PLAYGROUPS_PER_SELECT 9 -#define MAX_PERIODS_PER_DIALOG 400 - +#define MAX_PERIODS_PER_DIALOG 400 #define NEED_LOCK_MSGS - /****************************************************************************\ * Structures \****************************************************************************/ @@ -77,42 +72,36 @@ namespace MPAL { /** * MPAL global variables */ -struct MPALVAR { - uint32 dwVal; // Variable value - char lpszVarName[33]; // Variable name +struct MpalVar { + uint32 _dwVal; // Variable value + char _lpszVarName[33]; // Variable name } PACKED_STRUCT; -typedef MPALVAR *LPMPALVAR; -typedef LPMPALVAR *LPLPMPALVAR; - +typedef MpalVar *LpMpalVar; /** * MPAL Messages */ -struct MPALMSG { - HGLOBAL _hText; // Handle to the message text - uint16 _wNum; // Message number +struct MpalMsg { + HGLOBAL _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; -typedef MPALMSG *LPMPALMSG; -typedef LPMPALMSG *LPLPMPALMSG; - +typedef MpalMsg *LpMpalMsg; /** * MPAL Locations */ -struct MPALLOCATION { - uint32 nObj; // Location number - uint32 dwXlen, dwYlen; // Dimensions - uint32 dwPicRes; // Resource that contains the image +struct MpalLocation { + uint32 _nObj; // Location number + uint32 _dwXlen, _dwYlen; // Dimensions + uint32 _dwPicRes; // Resource that contains the image } PACKED_STRUCT; -typedef MPALLOCATION *LPMPALLOCATION; -typedef LPMPALLOCATION *LPLPMPALLOCATION; - +typedef MpalLocation *LpMpalLocation; /** * All the data for a command, ie. tags used by OnAction in the item, the time * in the script, and in the group dialog. */ -struct command { +struct Command { /* * Types of commands that are recognized * @@ -121,55 +110,54 @@ struct command { * #3 -> Making a choice (DIALOG) * */ - byte type; // Type of control + byte _type; // Type of control union { - int32 _nCf; // Custom function call [#1] - char *lpszVarName; // Variable name [#2] - int32 nChoice; // Number of choice you make [#3] + int32 _nCf; // Custom function call [#1] + char *_lpszVarName; // Variable name [#2] + int32 _nChoice; // Number of choice you make [#3] }; union { - int32 _arg1; // Argument for custom function [#1] - HGLOBAL expr; // Expression to assign to a variable [#2] + int32 _arg1; // Argument for custom function [#1] + HGLOBAL _expr; // Expression to assign to a variable [#2] }; - int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; /** * MPAL dialog */ -struct MPALDIALOG { - uint32 nObj; // Dialog number +struct MpalDialog { + uint32 _nObj; // Dialog number - struct command _command[MAX_COMMANDS_PER_DIALOG]; + struct Command _command[MAX_COMMANDS_PER_DIALOG]; struct { - uint16 num; - - byte nCmds; - uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; + uint16 _num; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_GROUP]; } _group[MAX_GROUPS_PER_DIALOG]; struct { // The last choice has nChoice == 0 - uint16 nChoice; + uint16 _nChoice; // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { - HGLOBAL when; - uint32 dwData; - uint16 wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; + HGLOBAL _when; + uint32 _dwData; + uint16 _wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; // Bit 0=endchoice Bit 1=enddialog - byte attr; + byte _attr; // Modified at run-time: 0 if the select is currently disabled, // and 1 if currently active - byte curActive; + byte _curActive; } _select[MAX_SELECTS_PER_CHOICE]; } _choice[MAX_CHOICES_PER_DIALOG]; @@ -178,68 +166,60 @@ struct MPALDIALOG { HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; -typedef MPALDIALOG *LPMPALDIALOG; -typedef LPMPALDIALOG *LPLPMPALDIALOG; - +typedef MpalDialog *LpMpalDialog; /** * MPAL Item */ struct ItemAction { - byte num; // Action number - uint16 wTime; // If idle, the time which must pass - byte perc; // Percentage of the idle run - HGLOBAL when; // Expression to compute. If != 0, then + byte _num; // Action number + uint16 _wTime; // If idle, the time which must pass + byte _perc; // Percentage of the idle run + HGLOBAL _when; // Expression to compute. If != 0, then // action can be done - uint16 wParm; // Parameter for action + uint16 _wParm; // Parameter for action - byte nCmds; // Number of commands to be executed - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute + byte _nCmds; // Number of commands to be executed + uint32 _cmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; -struct MPALITEM { - uint32 nObj; // Item number +struct MpalItem { + uint32 _nObj; // Item number - byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Name - byte nActions; // Number of managed actions - uint32 dwRes; // Resource that contains frames and patterns + byte _lpszDescribe[MAX_DESCRIBE_SIZE]; // Name + byte _nActions; // Number of managed actions + uint32 _dwRes; // Resource that contains frames and patterns - struct command _command[MAX_COMMANDS_PER_ITEM]; + struct Command _command[MAX_COMMANDS_PER_ITEM]; // Pointer to array of structures containing various managed activities. In practice, of // every action we know what commands to run, including those defined in structures above - struct ItemAction *Action; + struct ItemAction *_action; } PACKED_STRUCT; -typedef MPALITEM *LPMPALITEM; -typedef LPMPALITEM *LPLPMPALITEM; - +typedef MpalItem *LpMpalItem; /** * MPAL Script */ -struct MPALSCRIPT { - uint32 nObj; - - uint32 nMoments; +struct MpalScript { + uint32 _nObj; + uint32 _nMoments; - struct command _command[MAX_COMMANDS_PER_SCRIPT]; + struct Command _command[MAX_COMMANDS_PER_SCRIPT]; struct { - int32 dwTime; + int32 _dwTime; + byte _nCmds; + uint32 _cmdNum[MAX_COMMANDS_PER_MOMENT]; - byte nCmds; - uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; - - } Moment[MAX_MOMENTS_PER_SCRIPT]; + } _moment[MAX_MOMENTS_PER_SCRIPT]; } PACKED_STRUCT; -typedef MPALSCRIPT *LPMPALSCRIPT; -typedef LPMPALSCRIPT *LPLPMPALSCRIPT; +typedef MpalScript *LpMpalScript; #include "common/pack-end.h" - /****************************************************************************\ * Function prototypes \****************************************************************************/ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d135f66fde..9426a37a8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -312,7 +312,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b uint32 hThread = CoroScheduler.createProcess(doNextMusic, NULL, 0); assert(hThread != CORO_INVALID_PID_VALUE); - } else if (nFX == 44) { // Cambia canale e lascia finire il primo + } else if (nFX == 44) { // Change the channel and let the first finish if (GLOBALS._flipflop) GLOBALS._nextChannel = nChannel - 1; else @@ -704,7 +704,7 @@ void TonyEngine::close() { _theEngine.close(); _window.close(); mpalFree(); - FreeMpc(); + freeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3 From f2df769aab10e719cc4fba6cb71e1500eb3acae4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 00:25:35 +0200 Subject: TONY: More renaming --- engines/tony/custom.cpp | 2 +- engines/tony/custom.h | 3 - engines/tony/game.cpp | 2 +- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 2 +- engines/tony/globals.h | 34 +++++------ engines/tony/mpal/expr.cpp | 128 +++++++++++++++++++++--------------------- engines/tony/mpal/expr.h | 8 +-- engines/tony/mpal/loadmpc.cpp | 6 +- engines/tony/mpal/lzo.cpp | 32 +++++------ engines/tony/mpal/memory.cpp | 16 +++--- engines/tony/mpal/memory.h | 17 +++--- engines/tony/mpal/mpal.cpp | 62 ++++++++++---------- engines/tony/mpal/mpal.h | 24 ++++---- engines/tony/mpal/mpaldll.h | 26 ++++----- engines/tony/mpal/mpalutils.h | 2 +- engines/tony/utils.cpp | 4 +- engines/tony/utils.h | 2 +- 18 files changed, 182 insertions(+), 190 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 9aef809826..4171691e87 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1749,7 +1749,7 @@ int g_curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { CORO_BEGIN_CONTEXT; - LPSTR string; + char *string; RMTextDialog *text; int parm; uint32 h; diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 9e18ae2090..524ab14aab 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -36,10 +36,7 @@ namespace Tony { using namespace MPAL; -typedef uint32 HWND; - #define INIT_CUSTOM_FUNCTION MapCustomFunctions -#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" #define DECLARE_CUSTOM_FUNCTION(x) void x diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 224427d10f..3031dabf3c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1039,7 +1039,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } #define KEYPRESS(c) (g_vm->getEngine()->getInput().getAsyncKeyState(c)) -#define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ +#define PROCESS_CHAR(cod, c) if (KEYPRESS(cod)) { \ _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } // State Buttons diff --git a/engines/tony/game.h b/engines/tony/game.h index 9c58f28714..626ec73afb 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -42,7 +42,7 @@ namespace Tony { assert(raw->isValid()); \ assert((buf16) == NULL); \ (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->init(*raw,raw->width(),raw->height()); \ + (buf16)->init(*raw, raw->width(), raw->height()); \ delete raw; #define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index da8218fa99..6f976ef37c 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -424,7 +424,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { _bLocationLoaded = true; // On entering the location - return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); + return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0, m_nCurLoc, 0); } void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 6966bd7264..eda99eeee2 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -150,9 +150,9 @@ typedef struct { int _nCf; int _arg1, _arg2, _arg3, _arg4; -} CFCALL; -typedef CFCALL *LPCFCALL; -typedef LPCFCALL *LPLPCFCALL; +} CfCall; +typedef CfCall *LpCfCall; +typedef LpCfCall *LPLPCFCALL; struct CoroutineMutex { @@ -176,20 +176,20 @@ public: Common::String _nextMusic; bool _nextLoop; - int _nextChannel; - int _nextSync; - int _curChannel; - int _flipflop; + int _nextChannel; + int _nextSync; + int _curChannel; + int _flipflop; CharacterStruct _character[16]; MCharacterStruct _mCharacter[10]; ChangedHotspotStruct _changedHotspot[256]; bool _isMChar[16]; bool _bAlwaysDisplay; RMPoint _saveTonyPos; - int _saveTonyLoc; + int _saveTonyLoc; RMTextDialog *_curBackText; bool _bTonyIsSpeaking; - int _curChangedHotspot; + int _curChangedHotspot; bool _bCfgInvLocked; bool _bCfgInvNoScroll; bool _bCfgTimerizedText; @@ -210,8 +210,8 @@ public: bool _bSkipSfxNoLoop; bool _bIdleExited; bool _bNoBullsEye; - int _curDialog; - int _curSoundEffect; + int _curDialog; + int _curSoundEffect; bool _bFadeOutStop; RMTony *_tony; @@ -251,22 +251,22 @@ public: Common::String *_lplpFunctionStrings; uint16 _nObjs; uint16 _nVars; - HGLOBAL _hVars; + MpalHandle _hVars; LpMpalVar _lpmvVars; uint16 _nMsgs; - HGLOBAL _hMsgs; + MpalHandle _hMsgs; LpMpalMsg _lpmmMsgs; uint16 _nDialogs; - HGLOBAL _hDialogs; + MpalHandle _hDialogs; LpMpalDialog _lpmdDialogs; uint16 _nItems; - HGLOBAL _hItems; + MpalHandle _hItems; LpMpalItem _lpmiItems; uint16 _nLocations; - HGLOBAL _hLocations; + MpalHandle _hLocations; LpMpalLocation _lpmlLocations; uint16 _nScripts; - HGLOBAL _hScripts; + MpalHandle _hScripts; LpMpalScript _lpmsScripts; Common::File _hMpr; uint16 _nResources; diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 31abeb0810..7923d263c0 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -81,20 +81,20 @@ enum ExprListTypes { * Mathamatical framework to manage operations */ typedef struct { - byte type; // Tipo di oggetto (vedi enum ExprListTypes) - byte unary; // Unary operatore (NON SUPPORTATO) + byte _type; // Tipo di oggetto (vedi enum ExprListTypes) + byte _unary; // Unary operatore (NON SUPPORTATO) union { - int num; // Numero (se type==ELT_NUMBER) - char *name; // Nome variabile (se type==ELT_VAR) - HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) - byte *pson; // Handle lockato (type==ELT_PARENTH2) - } val; + int _num; // Numero (se type==ELT_NUMBER) + char *_name; // Nome variabile (se type==ELT_VAR) + MpalHandle _son; // Handle a espressione (type==ELT_PARENTH) + byte *_pson; // Handle lockato (type==ELT_PARENTH2) + } _val; - byte symbol; // Simbolo matematico (vedi #define OP_*) + byte _symbol; // Simbolo matematico (vedi #define OP_*) -} EXPRESSION; -typedef EXPRESSION *LPEXPRESSION; +} Expression; +typedef Expression *LpExpression; //@} @@ -104,24 +104,24 @@ typedef EXPRESSION *LPEXPRESSION; * @param h Handle to the original expression * @retruns Pointer to the cloned expression */ -static byte *duplicateExpression(HGLOBAL h) { +static byte *duplicateExpression(MpalHandle h) { byte *orig, *clone; - LPEXPRESSION one, two; + LpExpression one, two; orig = (byte *)globalLock(h); int num = *(byte *)orig; - one = (LPEXPRESSION)(orig+1); + one = (LpExpression)(orig+1); - clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); - two = (LPEXPRESSION)(clone + 1); + clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(Expression) * num + 1); + two = (LpExpression)(clone + 1); - memcpy(clone, orig, sizeof(EXPRESSION) * num + 1); + memcpy(clone, orig, sizeof(Expression) * num + 1); for (int i = 0; i < num; i++) { - if (one->type == ELT_PARENTH) { - two->type = ELT_PARENTH2; - two->val.pson = duplicateExpression(two->val.son); + if (one->_type == ELT_PARENTH) { + two->_type = ELT_PARENTH2; + two->_val._pson = duplicateExpression(two->_val._son); } ++one; @@ -178,27 +178,27 @@ static int Compute(int a, int b, byte symbol) { return 0; } -static void solve(LPEXPRESSION one, int num) { - LPEXPRESSION two, three; +static void solve(LpExpression one, int num) { + LpExpression two, three; int j; while (num > 1) { two = one + 1; - if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num = Compute(one->val.num, two->val.num, one->symbol); - memmove(one, two, (num - 1) * sizeof(EXPRESSION)); + if ((two->_symbol == 0) || (one->_symbol & 0xF0) <= (two->_symbol & 0xF0)) { + two->_val._num = Compute(one->_val._num, two->_val._num, one->_symbol); + memmove(one, two, (num - 1) * sizeof(Expression)); --num; } else { j = 1; three = two + 1; - while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { + while ((three->_symbol != 0) && (two->_symbol & 0xF0) > (three->_symbol & 0xF0)) { ++two; ++three; ++j; } - three->val.num = Compute(two->val.num, three->val.num, two->symbol); - memmove(two, three, (num - j - 1) * sizeof(EXPRESSION)); + three->_val._num = Compute(two->_val._num, three->_val._num, two->_symbol); + memmove(two, three, (num - j - 1) * sizeof(Expression)); --num; } } @@ -213,32 +213,32 @@ static void solve(LPEXPRESSION one, int num) { * @returns Value */ static int evaluateAndFreeExpression(byte *expr) { - LPEXPRESSION one, cur; + LpExpression one, cur; int num = *expr; - one = (LPEXPRESSION)(expr + 1); + one = (LpExpression)(expr + 1); // 1) Substitutions of variables cur = one; for (int i = 0; i < num; i++, cur++) { - if (cur->type == ELT_VAR) { - cur->type = ELT_NUMBER; - cur->val.num = varGetValue(cur->val.name); + if (cur->_type == ELT_VAR) { + cur->_type = ELT_NUMBER; + cur->_val._num = varGetValue(cur->_val._name); } } // 2) Replacement of brackets (using recursive calls) cur = one; for (int i = 0; i < num; i++, cur++) { - if (cur->type == ELT_PARENTH2) { - cur->type = ELT_NUMBER; - cur->val.num = evaluateAndFreeExpression(cur->val.pson); + if (cur->_type == ELT_PARENTH2) { + cur->_type = ELT_NUMBER; + cur->_val._num = evaluateAndFreeExpression(cur->_val._pson); } } // 3) algebraic resolution solve(one, num); - int val = one->val.num; + int val = one->_val._num; globalDestroy(expr); return val; @@ -253,8 +253,8 @@ static int evaluateAndFreeExpression(byte *expr) { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { - LPEXPRESSION cur; +const byte *parseExpression(const byte *lpBuf, MpalHandle *h) { + LpExpression cur; byte *start; uint32 num = *lpBuf; @@ -263,35 +263,35 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(Expression) + 1); if (*h == NULL) return NULL; start = (byte *)globalLock(*h); *start = (byte)num; - cur = (LPEXPRESSION)(start + 1); + cur = (LpExpression)(start + 1); for (uint32 i = 0;i < num; i++) { - cur->type = *(lpBuf); - cur->unary = *(lpBuf + 1); + cur->_type = *(lpBuf); + cur->_unary = *(lpBuf + 1); lpBuf += 2; - switch (cur->type) { + switch (cur->_type) { case ELT_NUMBER: - cur->val.num = (int32)READ_LE_UINT32(lpBuf); + cur->_val._num = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case ELT_VAR: - cur->val.name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); - if (cur->val.name == NULL) + cur->_val._name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); + if (cur->_val._name == NULL) return NULL; - memcpy(cur->val.name, lpBuf + 1, *lpBuf); + memcpy(cur->_val._name, lpBuf + 1, *lpBuf); lpBuf += *lpBuf + 1; break; case ELT_PARENTH: - lpBuf = parseExpression(lpBuf, &cur->val.son); + lpBuf = parseExpression(lpBuf, &cur->_val._son); if (lpBuf == NULL) return NULL; break; @@ -300,7 +300,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; } - cur->symbol = *lpBuf; + cur->_symbol = *lpBuf; lpBuf++; cur++; @@ -321,7 +321,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { * @param h Handle to the expression * @returns Numeric value */ -int evaluateExpression(HGLOBAL h) { +int evaluateExpression(MpalHandle h) { int ret; lockVar(); @@ -337,9 +337,9 @@ int evaluateExpression(HGLOBAL h) { * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { +bool compareExpressions(MpalHandle h1, MpalHandle h2) { byte *e1, *e2; - LPEXPRESSION one, two; + LpExpression one, two; e1 = (byte *)globalLock(h1); e2 = (byte *)globalLock(h2); @@ -353,19 +353,19 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one = (LPEXPRESSION)(e1 + 1); - two = (LPEXPRESSION)(e2 + 1); + one = (LpExpression)(e1 + 1); + two = (LpExpression)(e2 + 1); for (int i = 0; i < num1; i++) { - if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { + if (one->_type != two->_type || (i != num1 - 1 && one->_symbol != two->_symbol)) { globalUnlock(h1); globalUnlock(h2); return false; } - switch (one->type) { + switch (one->_type) { case ELT_NUMBER: - if (one->val.num != two->val.num) { + if (one->_val._num != two->_val._num) { globalUnlock(h1); globalUnlock(h2); return false; @@ -373,7 +373,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_VAR: - if (strcmp(one->val.name, two->val.name) != 0) { + if (strcmp(one->_val._name, two->_val._name) != 0) { globalUnlock(h1); globalUnlock(h2); return false; @@ -381,7 +381,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_PARENTH: - if (!compareExpressions(one->val.son, two->val.son)) { + if (!compareExpressions(one->_val._son, two->_val._son)) { globalUnlock(h1); globalUnlock(h2); return false; @@ -404,19 +404,19 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { * * @param h Handle for the expression */ -void freeExpression(HGLOBAL h) { +void freeExpression(MpalHandle h) { byte *data = (byte *)globalLock(h); int num = *data; - LPEXPRESSION cur = (LPEXPRESSION)(data + 1); + LpExpression cur = (LpExpression)(data + 1); for (int i = 0; i < num; ++i, ++cur) { - switch (cur->type) { + switch (cur->_type) { case ELT_VAR: - globalDestroy(cur->val.name); + globalDestroy(cur->_val._name); break; case ELT_PARENTH: - freeExpression(cur->val.son); + freeExpression(cur->_val._son); break; default: diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index f9c8a7c48f..9036099993 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -47,7 +47,7 @@ namespace MPAL { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *parseExpression(const byte *lpBuf, HGLOBAL *h); +const byte *parseExpression(const byte *lpBuf, MpalHandle *h); /** * Calculate the value of a mathamatical expression @@ -55,7 +55,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h); * @param h Handle to the expression * @returns Numeric value */ -int evaluateExpression(HGLOBAL h); +int evaluateExpression(MpalHandle h); /** * Compare two mathematical expressions together @@ -63,14 +63,14 @@ int evaluateExpression(HGLOBAL h); * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool compareExpressions(HGLOBAL h1, HGLOBAL h2); +bool compareExpressions(MpalHandle h1, MpalHandle h2); /** * Frees an expression that was previously parsed * * @param h Handle for the expression */ -void freeExpression(HGLOBAL h); +void freeExpression(MpalHandle h); } // end of namespace MPAL diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index b3c4193414..953820be74 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -253,14 +253,14 @@ static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) { } if (curCmd >= MAX_COMMANDS_PER_DIALOG) - error("Too much commands in dialog #%d",lpmdDialog->_nObj); + error("Too much commands in dialog #%d", lpmdDialog->_nObj); // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) - error("Too much choices in dialog #%d",lpmdDialog->_nObj); + error("Too much choices in dialog #%d", lpmdDialog->_nObj); for (i = 0; i < num; i++) { lpmdDialog->_choice[i]._nChoice = READ_LE_UINT16(lpBuf); @@ -380,7 +380,7 @@ static const byte *parseItem(const byte *lpBuf, LpMpalItem lpmiItem) { lpBuf++; if (lpmiItem->_action[i]._nCmds >= MAX_COMMANDS_PER_ACTION) - error("Too much commands in action #%d in item #%d",lpmiItem->_action[i]._num, lpmiItem->_nObj); + error("Too much commands in action #%d in item #%d", lpmiItem->_action[i]._num, lpmiItem->_nObj); for (uint32 j = 0; j < lpmiItem->_action[i]._nCmds; j++) { lpmiItem->_command[curCmd]._type = *lpBuf; diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 48a0d8ea87..3d0751a5ca 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -69,10 +69,10 @@ namespace Tony { namespace MPAL { -#define pd(a,b) ((uint32) ((a)-(b))) +#define pd(a, b) ((uint32) ((a) - (b))) #define TEST_IP (ip < ip_end) -#define TEST_OP 1 +#define TEST_OP 1 #define NEED_IP(x) ((void) 0) #define NEED_OP(x) ((void) 0) #define TEST_LB(m_pos) ((void) 0) @@ -83,7 +83,7 @@ namespace MPAL { /** * Decompresses an LZO compressed resource */ -int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) { +int lzo1x_decompress(const byte *in, uint32 in_len, byte *out, uint32 *out_len) { register byte *op; register const byte *ip; register uint32 t = 0; @@ -155,12 +155,12 @@ int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) t += 3; if (t >= 8) do { - UA_COPY64(op,ip); + UA_COPY64(op, ip); op += 8; ip += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,ip); + UA_COPY32(op, ip); op += 4; ip += 4; t -= 4; } if (t > 0) @@ -170,17 +170,17 @@ int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) } #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) - if (PTR_ALIGNED2_4(op,ip)) + if (PTR_ALIGNED2_4(op, ip)) { #endif - UA_COPY32(op,ip); + UA_COPY32(op, ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { - UA_COPY32(op,ip); + UA_COPY32(op, ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); @@ -213,7 +213,7 @@ first_literal_run: m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); #endif NEED_OP(3); - t = 3; COPY_DICT(t,m_off) + t = 3; COPY_DICT(t, m_off) #else #if defined(LZO1Z) t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); @@ -382,7 +382,7 @@ match: m_off = 1 + (t >> 2) + (*ip++ << 2); #endif NEED_OP(2); - t = 2; COPY_DICT(t,m_off) + t = 2; COPY_DICT(t, m_off) #else #if defined(LZO1Z) t = 1 + (t << 6) + (*ip++ >> 2); @@ -402,7 +402,7 @@ match: #if defined(COPY_DICT) NEED_OP(t+3-1); - t += 3-1; COPY_DICT(t,m_off) + t += 3-1; COPY_DICT(t, m_off) #else @@ -413,12 +413,12 @@ match: t += (3 - 1); if (t >= 8) do { - UA_COPY64(op,m_pos); + UA_COPY64(op, m_pos); op += 8; m_pos += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,m_pos); + UA_COPY32(op, m_pos); op += 4; m_pos += 4; t -= 4; } if (t > 0) @@ -430,17 +430,17 @@ match: else #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op, m_pos)) { assert((op - m_pos) >= 4); #else if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif - UA_COPY32(op,m_pos); + UA_COPY32(op, m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { - UA_COPY32(op,m_pos); + UA_COPY32(op, m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 3a68ecb559..428c07b3b7 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -39,7 +39,7 @@ const uint32 BLOCK_ID = 0x12345678; * Allocates a new memory block * @return Returns a MemoryItem instance for the new block */ -HANDLE MemoryManager::allocate(uint32 size, uint flags) { +MpalHandle MemoryManager::allocate(uint32 size, uint flags) { MemoryItem *newItem = (MemoryItem *)malloc(sizeof(MemoryItem) + size); newItem->_id = BLOCK_ID; newItem->_size = size; @@ -51,7 +51,7 @@ HANDLE MemoryManager::allocate(uint32 size, uint flags) { Common::fill(dataP, dataP + size, 0); } - return (HANDLE)newItem; + return (MpalHandle)newItem; } /** @@ -70,7 +70,7 @@ void *MemoryManager::alloc(uint32 size, uint flags) { * Returns a reference to the MemoryItem for a gien byte pointer * @param block Byte pointer */ -MemoryItem *MemoryManager::getItem(HGLOBAL handle) { +MemoryItem *MemoryManager::getItem(MpalHandle handle) { MemoryItem *rec = (MemoryItem *)((byte *)handle - OFFSETOF(MemoryItem, _data)); assert(rec->_id == BLOCK_ID); return rec; @@ -79,7 +79,7 @@ MemoryItem *MemoryManager::getItem(HGLOBAL handle) { /** * Returns a size of a memory block given its pointer */ -uint32 MemoryManager::getSize(HANDLE handle) { +uint32 MemoryManager::getSize(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); return item->_size; @@ -88,7 +88,7 @@ uint32 MemoryManager::getSize(HANDLE handle) { /** * Erases a given item */ -void MemoryManager::freeBlock(HANDLE handle) { +void MemoryManager::freeBlock(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); free(item); @@ -97,7 +97,7 @@ void MemoryManager::freeBlock(HANDLE handle) { /** * Erases a given item */ -void MemoryManager::destroyItem(HANDLE handle) { +void MemoryManager::destroyItem(MpalHandle handle) { MemoryItem *item = getItem(handle); assert(item->_id == BLOCK_ID); free(item); @@ -106,7 +106,7 @@ void MemoryManager::destroyItem(HANDLE handle) { /** * Locks an item for access */ -byte *MemoryManager::lockItem(HANDLE handle) { +byte *MemoryManager::lockItem(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); ++item->_lockCount; @@ -116,7 +116,7 @@ byte *MemoryManager::lockItem(HANDLE handle) { /** * Unlocks a locked item */ -void MemoryManager::unlockItem(HANDLE handle) { +void MemoryManager::unlockItem(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); assert(item->_lockCount > 0); diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index c7e4896cf9..b557743512 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -31,8 +31,7 @@ namespace Tony { namespace MPAL { -typedef void *HANDLE; -typedef HANDLE HGLOBAL; +typedef void *MpalHandle; struct MemoryItem { uint32 _id; @@ -46,15 +45,15 @@ struct MemoryItem { class MemoryManager { private: - static MemoryItem *getItem(HGLOBAL handle); + static MemoryItem *getItem(MpalHandle handle); public: - static HANDLE allocate(uint32 size, uint flags); + static MpalHandle allocate(uint32 size, uint flags); static void *alloc(uint32 size, uint flags); - static void freeBlock(HANDLE handle); - static void destroyItem(HANDLE handle); - static uint32 getSize(HANDLE handle); - static byte *lockItem(HANDLE handle); - static void unlockItem(HANDLE handle); + static void freeBlock(MpalHandle handle); + static void destroyItem(MpalHandle handle); + static uint32 getSize(MpalHandle handle); + static byte *lockItem(MpalHandle handle); + static void unlockItem(MpalHandle handle); }; // defines diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 9a92fd7766..533a4d22b9 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -360,8 +360,8 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { * @param dwId ID of the resource to load * @returns Handle to the loaded resource */ -HGLOBAL resLoad(uint32 dwId) { - HGLOBAL h; +MpalHandle resLoad(uint32 dwId) { + MpalHandle h; char head[4]; uint32 nBytesRead; uint32 nSizeComp, nSizeDecomp; @@ -461,15 +461,15 @@ static uint32 *GetItemList(uint32 nLoc) { return il; } -static LPITEM getItemData(uint32 nOrdItem) { +static LpItem getItemData(uint32 nOrdItem) { LpMpalItem curitem = GLOBALS._lpmiItems + nOrdItem; - LPITEM ret; - HGLOBAL hDat; + LpItem ret; + MpalHandle hDat; char *dat; char *patlength; // Zeroing out the allocated memory is required!!! - ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); + ret = (LpItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(Item)); if (ret == NULL) return NULL; ret->_speed = 150; @@ -536,7 +536,7 @@ static LPITEM getItemData(uint32 nOrdItem) { for (int i = 1; i < ret->_numframe; i++) { uint32 dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); - ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); + ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED, dim); if (ret->_frames[i] == NULL) return NULL; @@ -565,12 +565,12 @@ static LPITEM getItemData(uint32 nOrdItem) { */ void CustomThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - LPCFCALL p; + LpCfCall p; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - _ctx->p = *(LPCFCALL *)param; + _ctx->p = *(LpCfCall *)param; CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->p->_nCf], _ctx->p->_arg1, _ctx->p->_arg2, _ctx->p->_arg3, _ctx->p->_arg4); @@ -593,7 +593,7 @@ void ScriptThread(CORO_PARAM, const void *param) { uint32 dwCurTime; uint32 dwId; int numHandles; - LPCFCALL p; + LpCfCall p; CORO_END_CONTEXT(_ctx); static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; @@ -604,7 +604,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->dwStartTime = g_vm->getTime(); _ctx->numHandles = 0; -// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); +// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n", s->_nMoments); for (_ctx->i = 0; _ctx->i < s->_nMoments; _ctx->i++) { // Sleep for the required time if (s->_moment[_ctx->i]._dwTime == -1) { @@ -613,8 +613,8 @@ void ScriptThread(CORO_PARAM, const void *param) { } else { _ctx->dwCurTime = g_vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100)) { - // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); + // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime*100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); } } @@ -623,7 +623,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->k = s->_moment[_ctx->i]._cmdNum[_ctx->j]; if (s->_command[_ctx->k]._type == 1) { - _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); + _ctx->p = (LpCfCall)globalAlloc(GMEM_FIXED, sizeof(CfCall)); if (_ctx->p == NULL) { GLOBALS._mpalError = 1; @@ -638,7 +638,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->_arg4 = s->_command[_ctx->k]._arg4; // !!! New process management - if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { + if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LpCfCall))) == 0) { GLOBALS._mpalError = 1; CORO_KILL_SELF(); @@ -775,14 +775,14 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { - uint32 _nItem, _nAction; - - uint16 _wTime; - byte _perc; - HGLOBAL _when; - byte _nCmds; - uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; - uint32 _dwLastTime; + uint32 _nItem, _nAction; + + uint16 _wTime; + byte _perc; + MpalHandle _when; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; + uint32 _dwLastTime; } MYACTION; typedef struct { @@ -795,7 +795,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { int i, j, k; int numitems; int nRealItems; - LpMpalItem curItem,newItem; + LpMpalItem curItem, newItem; int nIdleActions; uint32 curTime; uint32 dwSleepTime; @@ -1012,7 +1012,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->myThreads[_ctx->i]._hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem)) == (void*)-1) + //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240, (void *)_ctx->newItem)) == (void*)-1) globalDestroy(_ctx->newItem); globalDestroy(_ctx->myThreads); globalDestroy(_ctx->myActions); @@ -1298,8 +1298,8 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MpalItem), (byte *)newitem); - //newitem->Action[0].nCmds=item->Action[i].nCmds; - //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + //newitem->_action[0]._nCmds=item->_action[i]._nCmds; + //memcpy(newitem->_action[0]._cmdNum, item->_action[i]._cmdNum, newitem->Action[0].nCmds * sizeof(newitem->_action[0]._cmdNum[0])); newitem->_dwRes = i; @@ -1630,7 +1630,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { } else if (wQueryType == MPQ_ITEM_DATA) { /* - * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + * LpItem mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ error("mpalQuery(MPQ_ITEM_DATA, uint32 nItem) used incorrect variant"); @@ -1747,7 +1747,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * @remarks This is the specialised version of the original single mpalQuery * method that returns a pointer or handle. */ -HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { +MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) { char *n; Common::String buf; va_list v; @@ -1813,7 +1813,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { } else if (wQueryType == MPQ_ITEM_DATA) { /* - * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + * LpItem mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ lockItems(); hRet = getItemData(itemGetOrderFromNum(GETARG(uint32))); @@ -2008,7 +2008,7 @@ bool mpalStartIdlePoll(int nLoc) { GLOBALS._hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! New process management if ((GLOBALS._pollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) -// if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240,(void *)i))= = (void*)-1) +// if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240, (void *)i))= = (void*)-1) return false; return true; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1af0f2c9e9..c5f505063f 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -100,11 +100,8 @@ namespace MPAL { #define MAXFRAMES 400 // frame animation of an object #define MAXPATTERN 40 // pattern of animation of an object - #define MAXPOLLINGLOCATIONS 64 -#define LPSTR char * - /** * Macro for use with queries that may refer to X and Y co-ordinates */ @@ -113,7 +110,6 @@ enum QueryCoordinates { MPQ_Y }; - /** * Query can be used with mpalQuery methods. In practice corresponds all claims * that can do at the library @@ -164,8 +160,8 @@ typedef struct { short _destX, _destY; signed char _destZ; short _objectID; -} ITEM; -typedef ITEM *LPITEM; +} Item; +typedef Item *LpItem; /** @@ -228,7 +224,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * after use. The message will be in ASCIIZ format. */ #define mpalQueryMessage(nMsg) \ - (LPSTR)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) + (char *)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) /** @@ -246,7 +242,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @param dwCoord MPQ_X or MPQ_Y coordinate to retrieve * @returns Size */ -#define mpalQueryLocationSize(nLoc,dwCoord) \ +#define mpalQueryLocationSize(nLoc, dwCoord) \ mpalQueryDWORD(MPQ_LOCATION_SIZE, (uint32)(nLoc), (uint32)(dwCoord)) @@ -268,7 +264,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Structure filled with requested information */ #define mpalQueryItemData(nItem) \ - (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) + (LpItem)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) /** @@ -302,7 +298,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * is less than or equal to 0), the string will be empty. */ #define mpalQueryItemName(nItem, lpszName) \ - mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (LPSTR)(lpszName)) + mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (char *)(lpszName)) /** @@ -316,7 +312,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * string terminated with 0. */ #define mpalQueryDialogPeriod(nPeriod) \ - (LPSTR)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) + (char *)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) /** @@ -379,8 +375,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Handle to the thread that is running the box, or * CORO_INVALID_PID_VALUE if the dialogue does not exist. */ -#define mpalQueryDoDialog(nDialog,nGroup) \ - mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) +#define mpalQueryDoDialog(nDialog, nGroup) \ + mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog), (uint32)(nGroup)) /** * @defgroup Functions exported to the main game @@ -422,7 +418,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...); * @remarks This is the specialised version of the original single mpalQuery * method that returns a pointer or handle. */ -HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); +MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...); /** * This is a general function to communicate with the library, to request information diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 853b5b2dac..8897096f51 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -82,8 +82,8 @@ typedef MpalVar *LpMpalVar; * MPAL Messages */ struct MpalMsg { - HGLOBAL _hText; // Handle to the message text - uint16 _wNum; // Message number + MpalHandle _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; typedef MpalMsg *LpMpalMsg; @@ -110,7 +110,7 @@ struct Command { * #3 -> Making a choice (DIALOG) * */ - byte _type; // Type of control + byte _type; // Type of control union { int32 _nCf; // Custom function call [#1] @@ -120,10 +120,10 @@ struct Command { union { int32 _arg1; // Argument for custom function [#1] - HGLOBAL _expr; // Expression to assign to a variable [#2] + MpalHandle _expr; // Expression to assign to a variable [#2] }; - int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; @@ -148,7 +148,7 @@ struct MpalDialog { // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { - HGLOBAL _when; + MpalHandle _when; uint32 _dwData; uint16 _wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; @@ -163,7 +163,7 @@ struct MpalDialog { } _choice[MAX_CHOICES_PER_DIALOG]; uint16 _periodNums[MAX_PERIODS_PER_DIALOG]; - HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; + MpalHandle _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; typedef MpalDialog *LpMpalDialog; @@ -175,20 +175,20 @@ struct ItemAction { byte _num; // Action number uint16 _wTime; // If idle, the time which must pass byte _perc; // Percentage of the idle run - HGLOBAL _when; // Expression to compute. If != 0, then - // action can be done + MpalHandle _when; // Expression to compute. If != 0, then + // action can be done uint16 _wParm; // Parameter for action - byte _nCmds; // Number of commands to be executed + byte _nCmds; // Number of commands to be executed uint32 _cmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; struct MpalItem { - uint32 _nObj; // Item number + uint32 _nObj; // Item number byte _lpszDescribe[MAX_DESCRIBE_SIZE]; // Name - byte _nActions; // Number of managed actions - uint32 _dwRes; // Resource that contains frames and patterns + byte _nActions; // Number of managed actions + uint32 _dwRes; // Resource that contains frames and patterns struct Command _command[MAX_COMMANDS_PER_ITEM]; diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index 19e4fa7778..8bc3e1d7c6 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -37,7 +37,7 @@ namespace MPAL { class RMRes { protected: - HGLOBAL _h; + MpalHandle _h; byte *_buf; public: diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index db83c2910b..99ba84ab19 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -370,7 +370,7 @@ void RMResUpdate::init(const Common::String &fileName) { } } -HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { +MpalHandle RMResUpdate::queryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; @@ -400,7 +400,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(0, info._size); + MpalHandle destBuf = globalAllocate(0, info._size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index d3f93e06ef..a24e11f2b6 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -173,7 +173,7 @@ public: ~RMResUpdate(); void init(const Common::String &fileName); - HGLOBAL queryResource(uint32 dwRes); + MpalHandle queryResource(uint32 dwRes); }; } // End of namespace Tony -- cgit v1.2.3 From 8c753c96a097c3b6e67b061470606278a0d8f102 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 01:05:22 +0200 Subject: TONY: Move some functions from .h to .cpp files --- engines/tony/game.cpp | 31 ++++++++++++++++++++++++++++ engines/tony/game.h | 44 ++++++++++++++-------------------------- engines/tony/gfxengine.cpp | 23 +++++++++++++++++++++ engines/tony/gfxengine.h | 21 ++++++------------- engines/tony/loc.h | 1 + engines/tony/sound.h | 8 +++----- engines/tony/tony.cpp | 16 +++++++++++++++ engines/tony/tony.h | 16 ++++----------- engines/tony/tonychar.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/tonychar.h | 33 +++++++++--------------------- 10 files changed, 158 insertions(+), 85 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 3031dabf3c..3abc7a20f8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1571,4 +1571,35 @@ void RMPointer::updateCursor() { CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } +/** + * Sets a new action as current + */ +void RMPointer::setAction(RMTonyAction action) { + _nCurPointer = action; + updateCursor(); +} + +/** + * Sets a new pointer + */ +void RMPointer::setSpecialPointer(PointerType ptr) { + _nCurSpecialPointer = ptr; + if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) + _specialPointer[ptr - 1]->setPattern(1); + + updateCursor(); +} + +RMPointer::PointerType RMPointer::getSpecialPointer() { + return (PointerType)_nCurSpecialPointer; +} + +/** + * Set the new custom pointer + */ +void RMPointer::setCustomPointer(RMGfxSourceBuffer8 *ptr) { + _nCurCustomPointer = ptr; + updateCursor(); +} + } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index 626ec73afb..bb6a356f0a 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -53,8 +53,18 @@ namespace Tony { (buf8)->init(*raw, raw->width(), raw->height(), true); \ delete raw; - class RMPointer { +public: + enum PointerType { + PTR_NONE = 0, + PTR_ARROWUP, + PTR_ARROWDOWN, + PTR_ARROWLEFT, + PTR_ARROWRIGHT, + PTR_ARROWMAP, + PTR_CUSTOM + }; + private: RMGfxSourceBuffer8 *_pointer[16]; RMPoint _hotspot[16]; @@ -67,17 +77,6 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; -public: - enum PointerType { - PTR_NONE = 0, - PTR_ARROWUP, - PTR_ARROWDOWN, - PTR_ARROWLEFT, - PTR_ARROWRIGHT, - PTR_ARROWMAP, - PTR_CUSTOM - }; - public: /** * Constructor & destructor @@ -108,32 +107,19 @@ public: /** * Sets a new action as current */ - void setAction(RMTonyAction action) { - _nCurPointer = action; - updateCursor(); - } + void setAction(RMTonyAction action); /** * Sets a new pointer */ - void setSpecialPointer(PointerType ptr) { - _nCurSpecialPointer = ptr; - if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[ptr - 1]->setPattern(1); + void setSpecialPointer(PointerType ptr); - updateCursor(); - } - PointerType getSpecialPointer() { - return (PointerType)_nCurSpecialPointer; - } + PointerType getSpecialPointer(); /** * Set the new custom pointer */ - void setCustomPointer(RMGfxSourceBuffer8 *ptr) { - _nCurCustomPointer = ptr; - updateCursor(); - } + void setCustomPointer(RMGfxSourceBuffer8 *ptr); /** * Return the current action to be applied according to the pointer diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 6f976ef37c..5c038e154d 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -836,4 +836,27 @@ bool RMGfxEngine::canLoadSave() { return _bInput && !_tony.inAction() && !g_vm->getIsDemo(); } +RMGfxEngine::operator RMGfxTargetBuffer &() { + return _bigBuf; +} + +RMInput &RMGfxEngine::getInput() { + return _input; +} + +RMPointer &RMGfxEngine::getPointer() { + return _point; +} + +/** + * Link to graphic task + */ +void RMGfxEngine::linkGraphicTask(RMGfxTask *task) { + _bigBuf.addPrim(new RMGfxPrimitive(task)); +} + +void RMGfxEngine::setPerorate(bool bpal) { + _inter.setPerorate(bpal); +} + } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2e22e1ca62..ab32a01972 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -102,23 +102,15 @@ public: void enableMouse(); void disableMouse(); - operator RMGfxTargetBuffer &() { - return _bigBuf; - } - RMInput &getInput() { - return _input; - } - RMPointer &getPointer() { - return _point; - } + operator RMGfxTargetBuffer &(); + RMInput &getInput(); + RMPointer &getPointer(); // Link to the custom function list void initCustomDll(); // Link to graphic task - void linkGraphicTask(RMGfxTask *task) { - _bigBuf.addPrim(new RMGfxPrimitive(task)); - }; + void linkGraphicTask(RMGfxTask *task); // Manage a location uint32 loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); @@ -137,9 +129,8 @@ public: void closeWipe(); void waitWipeEnd(CORO_PARAM); - void setPerorate(bool bpal) { - _inter.setPerorate(bpal); - } + void setPerorate(bool bpal); + bool canLoadSave(); }; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7b0a2ddd6b..6c28a66f65 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -529,6 +529,7 @@ private: public: // @@@@@@@@@@@@@@@@@@@@@@@ + RMPoint TEMPTonyStart; RMPoint TEMPGetTonyStart() { return TEMPTonyStart; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 73938ecd8c..c859f781f4 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -49,11 +49,9 @@ enum SoundCodecs { FPCODEC_ADPCM }; -//**************************************************************************** -//* class FPSound -//* ------------- -//* Description: Sound driver For Tony Tough -//**************************************************************************** +/** + * Sound driver For Tony Tough + */ class FPSound { private: diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9426a37a8b..4ffb84ced8 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -615,6 +615,14 @@ void TonyEngine::grabThumbnail() { _window.grabThumbnail(_curThumbnail); } +uint16 *TonyEngine::getThumbnail() { + return _curThumbnail; +} + +void TonyEngine::quitGame() { + _bQuitNow = true; +} + void TonyEngine::openInitLoadMenu(CORO_PARAM) { _theEngine.openOptionScreen(coroParam, 1); } @@ -776,4 +784,12 @@ void TonyEngine::saveSoundSettings() { ConfMan.setInt("talkspeed", GLOBALS._nCfgTextSpeed * 256 / 10); } +void TonyEngine::showLocation() { + _bDrawLocation = true; +} + +void TonyEngine::hideLocation() { + _bDrawLocation = false; +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 9a25f2ce35..22090dfe51 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -173,12 +173,8 @@ public: void getDataDirectory(DataDir dir, char *path); - void showLocation() { - _bDrawLocation = true; - } - void hideLocation() { - _bDrawLocation = false; - } + void showLocation(); + void hideLocation(); /** * Reads the time @@ -226,13 +222,9 @@ public: * Get a thumbnail */ void grabThumbnail(); - uint16 *getThumbnail() { - return _curThumbnail; - } + uint16 *getThumbnail(); - void quitGame() { - _bQuitNow = true; - } + void quitGame(); void openInitLoadMenu(CORO_PARAM); void openInitOptions(CORO_PARAM); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index c80203fae2..c7fa1e4a7b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -1892,4 +1892,54 @@ void RMTony::endStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_END_CODE; } +/** + * Waits until the end of a pattern + */ +void RMTony::waitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { + RMCharacter::waitForEndPattern(coroParam, hCustomSkip); +} + +/** + * Check if currently in an action + */ +bool RMTony::inAction() { + return (_bActionPending && _action != 0) | _bAction; +} + +/** + * Check if there needs to be an update for scrolling movement + */ +bool RMTony::mustUpdateScrolling() { + return ((!inAction()) || (isMoving())); +} + +/** + * Returns Tony's position + */ +RMPoint RMTony::position() { + return _pos; +} + +/** + * Set the scrolling position + */ +void RMTony::setScrollPosition(const RMPoint &pt) { + RMCharacter::setScrollPosition(pt); +} + +/** + * Tony disguises himself! + */ +void RMTony::setShepherdess(bool bIsPast) { + _bShepherdess = bIsPast; +} + +int RMTony::getShepherdess() { + return _bShepherdess; +} + +void RMTony::playSfx(int nSfx) { + RMItem::playSfx(nSfx); +} + } // End of namespace Tony diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 775c27a4e0..d9f18f61ec 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -416,37 +416,27 @@ public: /** * Waits until the end of a pattern */ - void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { - RMCharacter::waitForEndPattern(coroParam, hCustomSkip); - } + void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); /** * Check if currently in an action */ - bool inAction() { - return (_bActionPending && _action != 0) | _bAction; - } + bool inAction(); /** * Check if there needs to be an update for scrolling movement */ - bool mustUpdateScrolling() { - return ((!inAction()) || (isMoving())); - } + bool mustUpdateScrolling(); /** * Returns Tony's position */ - RMPoint position() { - return _pos; - } + RMPoint position(); /** * Set the scrolling position */ - void setScrollPosition(const RMPoint &pt) { - RMCharacter::setScrollPosition(pt); - } + void setScrollPosition(const RMPoint &pt); /** * Set the take animation @@ -475,21 +465,16 @@ public: /** * Tony disguises himself! */ - void setShepherdess(bool bIsPast) { - _bShepherdess = bIsPast; - } - int getShepherdess() { - return _bShepherdess; - } + void setShepherdess(bool bIsPast); + + int getShepherdess(); /** * Perform an action */ void executeAction(int nAction, int nActionItem, int nParm); - void playSfx(int nSfx) { - RMItem::playSfx(nSfx); - } + void playSfx(int nSfx); }; } // End of namespace Tony -- cgit v1.2.3 From 3ab8ebc4f72e54a5ffcabaa22d3cf8e250062457 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 02:27:31 +0200 Subject: TONY: Move some more code from .h to .cpp files --- engines/tony/gfxcore.cpp | 136 ++++++++++++++++++++++++++++++++++++++++ engines/tony/gfxcore.h | 136 +++++++--------------------------------- engines/tony/globals.h | 4 +- engines/tony/input.cpp | 34 ++++++++++ engines/tony/input.h | 28 +++------ engines/tony/mpal/memory.h | 14 ++--- engines/tony/mpal/mpalutils.cpp | 4 ++ engines/tony/mpal/mpalutils.h | 6 +- engines/tony/window.cpp | 4 ++ engines/tony/window.h | 2 +- 10 files changed, 221 insertions(+), 147 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 53f64aad12..38d8d0046d 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -111,6 +111,15 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp) { create(dimx, dimy, nBpp); } +int RMGfxBuffer::getDimx() { + return _dimx; +} + +int RMGfxBuffer::getDimy() { + return _dimy; +} + + /****************************************************************************\ * RMGfxSourceBuffer Methods \****************************************************************************/ @@ -2031,4 +2040,131 @@ void RMGfxClearTask::removeThis(CORO_PARAM, bool &result) { result = true; } +/****************************************************************************\ +* RMGfxPrimitive Methods +\****************************************************************************/ + +RMGfxPrimitive::RMGfxPrimitive() { + _bFlag = 0; + _task = NULL; + _src.setEmpty(); + _dst.setEmpty(); + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task) { + _task = task; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { + _task = task; + _src = src; + _dst = dst; + _bFlag = 0; + _bStretch = (src.width() != dst.width() || src.height() != dst.height()); +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { + _task = task; + _src.topLeft() = src; + _dst = dst; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { + _task = task; + _src.topLeft() = src; + _dst.topLeft() = dst; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { + _task = task; + _src = src; + _dst.topLeft() = dst; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { + _task = task; + _dst = dst; + _src.setEmpty(); + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { + _task = task; + _dst.topLeft() = dst; + _src.setEmpty(); + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::~RMGfxPrimitive() { +} + +void RMGfxPrimitive::setFlag(byte bFlag) { + _bFlag = bFlag; +} + +void RMGfxPrimitive::setTask(RMGfxTask *task) { + _task = task; +} + +void RMGfxPrimitive::setSrc(const RMRect &src) { + _src = src; +} + +void RMGfxPrimitive::setSrc(const RMPoint &src) { + _src.topLeft() = src; +} + +void RMGfxPrimitive::setDst(const RMRect &dst) { + _dst = dst; +} + +void RMGfxPrimitive::setDst(const RMPoint &dst) { + _dst.topLeft() = dst; +} + +void RMGfxPrimitive::setStretch(bool bStretch) { + _bStretch = bStretch; +} + +bool RMGfxPrimitive::haveDst() { + return !_dst.isEmpty(); +} + +RMRect &RMGfxPrimitive::getDst() { + return _dst; +} + +bool RMGfxPrimitive::haveSrc() { + return !_src.isEmpty(); +} + +RMRect &RMGfxPrimitive::getSrc() { + return _src; +} + +/** + * Flags + */ +bool RMGfxPrimitive::isFlipped() { + return _bFlag & 1; +} + +/** + * Duplicate + */ +RMGfxPrimitive *RMGfxPrimitive::duplicate() { + return new RMGfxPrimitive(*this); +} + } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 472a4ad13a..4750e42d00 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -68,12 +68,8 @@ public: virtual ~RMGfxBuffer(); // Attributes - int getDimx() { - return _dimx; - } - int getDimy() { - return _dimy; - } + int getDimx(); + int getDimy(); // Creation virtual void create(int dimx, int dimy, int nBpp); @@ -102,116 +98,32 @@ protected: byte _bFlag; public: - RMGfxPrimitive() { - _bFlag = 0; - _task = NULL; - _src.setEmpty(); - _dst.setEmpty(); - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task) { - _task = task; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { - _task = task; - _src = src; - _dst = dst; - _bFlag = 0; - _bStretch = (src.width() != dst.width() || src.height() != dst.height()); - } - - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { - _task = task; - _src.topLeft() = src; - _dst = dst; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { - _task = task; - _src.topLeft() = src; - _dst.topLeft() = dst; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { - _task = task; - _src = src; - _dst.topLeft() = dst; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { - _task = task; - _dst = dst; - _src.setEmpty(); - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { - _task = task; - _dst.topLeft() = dst; - _src.setEmpty(); - _bFlag = 0; - _bStretch = false; - } - - virtual ~RMGfxPrimitive() { } - - void setFlag(byte bFlag) { - _bFlag = bFlag; - } - void setTask(RMGfxTask *task) { - _task = task; - } - void setSrc(const RMRect &src) { - _src = src; - } - void setSrc(const RMPoint &src) { - _src.topLeft() = src; - } - void setDst(const RMRect &dst) { - _dst = dst; - } - void setDst(const RMPoint &dst) { - _dst.topLeft() = dst; - } - void setStretch(bool bStretch) { - _bStretch = bStretch; - } - - bool haveDst() { - return !_dst.isEmpty(); - } - - RMRect &getDst() { - return _dst; - } - - bool haveSrc() { - return !_src.isEmpty(); - } - RMRect &getSrc() { - return _src; - } + RMGfxPrimitive(); + RMGfxPrimitive(RMGfxTask *task); + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst); + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst); + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst); + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst); + RMGfxPrimitive(RMGfxTask *task, const RMRect &dst); + RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst); + virtual ~RMGfxPrimitive(); + void setFlag(byte bFlag); + void setTask(RMGfxTask *task); + void setSrc(const RMRect &src); + void setSrc(const RMPoint &src); + void setDst(const RMRect &dst); + void setDst(const RMPoint &dst); + void setStretch(bool bStretch); + bool haveDst(); + RMRect &getDst(); + bool haveSrc(); + RMRect &getSrc(); // Flags - bool isFlipped() { - return _bFlag & 1; - } + bool isFlipped(); // Duplicate - virtual RMGfxPrimitive *duplicate() { - return new RMGfxPrimitive(*this); - } + virtual RMGfxPrimitive *duplicate(); }; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index eda99eeee2..75f7f8d1dd 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -148,12 +148,10 @@ struct ChangedHotspotStruct { */ typedef struct { int _nCf; - int _arg1, _arg2, _arg3, _arg4; } CfCall; -typedef CfCall *LpCfCall; -typedef LpCfCall *LPLPCFCALL; +typedef CfCall *LpCfCall; struct CoroutineMutex { CoroutineMutex() : _eventId(0), _ownerPid(0), _lockCount(0) { } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 88bc3f4092..b96ccaf842 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -120,4 +120,38 @@ bool RMInput::getAsyncKeyState(Common::KeyCode kc) { return result; } +/** + * Reading of the mouse + */ +RMPoint RMInput::mousePos() { + return _mousePos; +} + +/** + * Events of mouse clicks + */ +bool RMInput::mouseLeftClicked() { + return _leftClickMouse; +} + +bool RMInput::mouseRightClicked() { + return _rightClickMouse; +} + +bool RMInput::mouseBothClicked() { + return _leftClickMouse && _rightClickMouse; +} + +bool RMInput::mouseLeftReleased() { + return _leftReleaseMouse; +} + +bool RMInput::mouseRightReleased() { + return _rightReleaseMouse; +} + +bool RMInput::mouseBothReleased() { + return _leftReleaseMouse && _rightReleaseMouse; +} + } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index 55b067ec43..d07eaefe34 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -59,9 +59,7 @@ public: /** * Reading of the mouse */ - RMPoint mousePos() { - return _mousePos; - } + RMPoint mousePos(); /** * Current status of the mouse buttons @@ -72,24 +70,12 @@ public: /** * Events of mouse clicks */ - bool mouseLeftClicked() { - return _leftClickMouse; - } - bool mouseRightClicked() { - return _rightClickMouse; - } - bool mouseBothClicked() { - return _leftClickMouse && _rightClickMouse; - } - bool mouseLeftReleased() { - return _leftReleaseMouse; - } - bool mouseRightReleased() { - return _rightReleaseMouse; - } - bool mouseBothReleased() { - return _leftReleaseMouse && _rightReleaseMouse; - } + bool mouseLeftClicked(); + bool mouseRightClicked(); + bool mouseBothClicked(); + bool mouseLeftReleased(); + bool mouseRightReleased(); + bool mouseBothReleased(); /** * Returns true if the given key is pressed diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index b557743512..ba7865938f 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -57,13 +57,13 @@ public: }; // defines -#define globalAlloc(flags, size) MemoryManager::alloc(size, flags) -#define globalAllocate(flags, size) MemoryManager::allocate(size, flags) -#define globalFree(handle) MemoryManager::freeBlock(handle) -#define globalDestroy(handle) MemoryManager::destroyItem(handle) -#define globalLock(handle) MemoryManager::lockItem(handle) -#define globalUnlock(handle) MemoryManager::unlockItem(handle) -#define globalSize(handle) MemoryManager::getSize(handle) +#define globalAlloc(flags, size) MemoryManager::alloc(size, flags) +#define globalAllocate(flags, size) MemoryManager::allocate(size, flags) +#define globalFree(handle) MemoryManager::freeBlock(handle) +#define globalDestroy(handle) MemoryManager::destroyItem(handle) +#define globalLock(handle) MemoryManager::lockItem(handle) +#define globalUnlock(handle) MemoryManager::unlockItem(handle) +#define globalSize(handle) MemoryManager::getSize(handle) #define GMEM_FIXED 1 #define GMEM_MOVEABLE 2 diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index bfc97a5f3d..92d4af37fc 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -80,6 +80,10 @@ Common::SeekableReadStream *RMRes::getReadStream() { return new Common::MemoryReadStream(_buf, size()); } +bool RMRes::isValid() { + return _h != NULL; +} + /****************************************************************************\ * RMResRaw methods \****************************************************************************/ diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index 8bc3e1d7c6..629e157e29 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -47,7 +47,7 @@ public: // Attributes unsigned int size(); const byte *dataPointer(); - bool isValid() { return _h != NULL; } + bool isValid(); // Casting for access to data operator const byte*(); @@ -63,8 +63,8 @@ public: const byte *dataPointer(); operator const byte*(); - int width(); - int height(); + int width(); + int height(); }; } // end of namespace MPAL diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 0746b267bd..013be84b4b 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -255,6 +255,10 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, } } +void RMWindow::showDirtyRects(bool v) { + _showDirtyRects = v; +} + /****************************************************************************\ * RMSnapshot Methods \****************************************************************************/ diff --git a/engines/tony/window.h b/engines/tony/window.h index c4cbcb6643..b2732a3f0c 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -90,7 +90,7 @@ public: */ void grabThumbnail(uint16 *buf); - void showDirtyRects(bool v) { _showDirtyRects = v; } + void showDirtyRects(bool v); }; } // End of namespace Tony -- cgit v1.2.3 From 1f41e5573175fb712e829a9c72b3e4f75afa8fdf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 02:36:54 +0200 Subject: TONY: Remove adv.h --- engines/tony/adv.h | 72 ------------------------------------------------- engines/tony/custom.cpp | 1 - engines/tony/game.h | 33 ++++++++++++++++++++++- engines/tony/globals.h | 1 - engines/tony/loc.cpp | 2 +- engines/tony/window.h | 2 +- 6 files changed, 34 insertions(+), 77 deletions(-) delete mode 100644 engines/tony/adv.h (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h deleted file mode 100644 index e3171aa3ee..0000000000 --- a/engines/tony/adv.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 code is based on original Tony Tough source code - * - * Copyright (c) 1997-2003 Nayma Software - */ - -#ifndef TONY_ADV_H -#define TONY_ADV_H - -#include "common/coroutines.h" -#include "tony/mpal/memory.h" -#include "tony/gfxcore.h" - - -namespace Tony { - -// X & Y dimensions of the adventure -#define RM_SX 640 -#define RM_SY 480 - -// X & Y dimensions of bigbuf -#define RM_BBX (RM_SX) -#define RM_BBY (RM_SY) - -// Skipping X & Y -#define RM_SKIPY ((RM_BBY - RM_SY) / 2) -#define RM_SKIPX 0 - -// Tony's actions -enum RMTonyAction { - TA_GOTO = 0, - TA_TAKE, - TA_USE, - TA_EXAMINE, - TA_TALK, - TA_PERORATE, - - TA_COMBINE = 10, - TA_RECEIVECOMBINE, - TA_COMBINEGIVE, - TA_RECEIVECOMBINEGIVE -}; - -// Global Functions -void mainEnableGUI(); -void mainDisableGUI(); - -} // End of namespace Tony - -#endif diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 4171691e87..f0a9197c6d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -31,7 +31,6 @@ #include "common/savefile.h" #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" -#include "tony/adv.h" #include "tony/custom.h" #include "tony/font.h" #include "tony/game.h" diff --git a/engines/tony/game.h b/engines/tony/game.h index bb6a356f0a..1c955176bf 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -29,7 +29,6 @@ #ifndef TONY_GAME_H #define TONY_GAME_H -#include "tony/adv.h" #include "tony/gfxcore.h" #include "tony/input.h" #include "tony/loc.h" @@ -53,6 +52,38 @@ namespace Tony { (buf8)->init(*raw, raw->width(), raw->height(), true); \ delete raw; +// X & Y dimensions of the adventure +#define RM_SX 640 +#define RM_SY 480 + +// X & Y dimensions of bigbuf +#define RM_BBX (RM_SX) +#define RM_BBY (RM_SY) + +// Skipping X & Y +#define RM_SKIPY ((RM_BBY - RM_SY) / 2) +#define RM_SKIPX 0 + +// Tony's actions +enum RMTonyAction { + TA_GOTO = 0, + TA_TAKE, + TA_USE, + TA_EXAMINE, + TA_TALK, + TA_PERORATE, + + TA_COMBINE = 10, + TA_RECEIVECOMBINE, + TA_COMBINEGIVE, + TA_RECEIVECOMBINEGIVE +}; + +// Global Functions +void mainEnableGUI(); +void mainDisableGUI(); + +// Classes class RMPointer { public: enum PointerType { diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 75f7f8d1dd..d8d8d3eba5 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -24,7 +24,6 @@ #define TONY_GLOBALS #include "common/savefile.h" -#include "tony/adv.h" #include "tony/gfxengine.h" #include "tony/input.h" #include "tony/inventory.h" diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a92282cc3f..7a151ac292 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -29,7 +29,7 @@ #include "common/memstream.h" #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" -#include "tony/adv.h" +#include "tony/game.h" #include "tony/loc.h" #include "tony/tony.h" diff --git a/engines/tony/window.h b/engines/tony/window.h index b2732a3f0c..2e8769707f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -31,7 +31,7 @@ #include "common/scummsys.h" #include "common/rect.h" -#include "tony/adv.h" +#include "tony/game.h" namespace Tony { -- cgit v1.2.3 From 7b17d8060d5600fe736d0b3af4e24da4e1776ddb Mon Sep 17 00:00:00 2001 From: Einar Johan Tr淡an S淡maen 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 09f193352ae519e69bf704620a7351830e3495d6 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 1 Sep 2012 14:14:23 +0200 Subject: SCUMM: PCESetCostumeData should have static linking --- engines/scumm/costume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 6e7e9ff688..3f89bc9611 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -592,7 +592,7 @@ void ClassicCostumeRenderer::proc3_ami(Codec1 &v1) { } while (1); } -void PCESetCostumeData(byte block[16][16], int index, byte value) { +static void PCESetCostumeData(byte block[16][16], int index, byte value) { int row = (index % 16); int plane = (index / 16) % 4; int colOffset = (index < 64) ? 8 : 0; -- cgit v1.2.3 From 60c2061710838c494fddb3e73f16b583a555b448 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 1 Sep 2012 17:59:52 +0300 Subject: SCI: Allow the Fun Seeker's Guide demo to run This demo doesn't have any music, and the original doesn't work with any sound driver, so don't error out when the sound driver can't be initialized properly --- engines/sci/sound/music.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index 918b045cb9..ffd51da673 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -125,7 +125,10 @@ void SciMusic::init() { _pMidiDrv->setTimerCallback(this, &miditimerCallback); _dwTempo = _pMidiDrv->getBaseTempo(); } else { - error("Failed to initialize sound driver"); + // Happens in the Fun Seeker's Guide demo, which doesn't have any sound + // anyway (nor works if anything other than PC Spearker is set), so this + // shouldn't be fatal + warning("Failed to initialize sound driver"); } // Find out what the first possible channel is (used, when doing channel -- cgit v1.2.3 From 7824d0e8e9116e2610072a92c99c6d80ae9db19f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 1 Sep 2012 20:15:12 +0300 Subject: SCI: Limit the hack used for sound initialization to the Fun Seeker's demo only --- engines/sci/sound/drivers/adlib.cpp | 3 +++ engines/sci/sound/music.cpp | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/sci/sound/drivers/adlib.cpp b/engines/sci/sound/drivers/adlib.cpp index db9317e071..191e13db0a 100644 --- a/engines/sci/sound/drivers/adlib.cpp +++ b/engines/sci/sound/drivers/adlib.cpp @@ -807,6 +807,9 @@ int MidiPlayer_AdLib::open(ResourceManager *resMan) { int size = f.size(); const uint patchSize = 1344; + // Note: Funseeker's Guide also has another version of adl.drv, 8803 bytes. + // This isn't supported, but it's not really used anywhere, as that demo + // doesn't have sound anyway. if ((size == 5684) || (size == 5720) || (size == 5727)) { byte *buf = new byte[patchSize]; diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index ffd51da673..a8a65d2aa4 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -125,10 +125,13 @@ void SciMusic::init() { _pMidiDrv->setTimerCallback(this, &miditimerCallback); _dwTempo = _pMidiDrv->getBaseTempo(); } else { - // Happens in the Fun Seeker's Guide demo, which doesn't have any sound - // anyway (nor works if anything other than PC Spearker is set), so this - // shouldn't be fatal - warning("Failed to initialize sound driver"); + if (g_sci->getGameId() == GID_FUNSEEKER) { + // HACK: The Fun Seeker's Guide demo doesn't have patch 3 and the version + // of the Adlib driver (adl.drv) that it includes is unsupported. That demo + // doesn't have any sound anyway, so this shouldn't be fatal. + } else { + error("Failed to initialize sound driver"); + } } // Find out what the first possible channel is (used, when doing channel -- cgit v1.2.3 From c737e6429866f18638a6b61103e4e1c7095407e6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Sep 2012 10:34:11 +0200 Subject: TONY: Move code from .h to .cpp files --- engines/tony/font.cpp | 44 +++++++++++++++++++++-- engines/tony/font.h | 31 ++++------------ engines/tony/game.cpp | 12 +++++++ engines/tony/game.h | 12 ++----- engines/tony/gfxcore.cpp | 44 ++++++++++++++++++++++- engines/tony/gfxcore.h | 38 +++++--------------- engines/tony/inventory.cpp | 15 ++++++++ engines/tony/inventory.h | 15 ++------ engines/tony/loc.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/loc.h | 77 +++++++++++---------------------------- engines/tony/utils.cpp | 30 ++++++++++++++++ engines/tony/utils.h | 17 ++++----- 12 files changed, 279 insertions(+), 145 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 901a41b7c4..927adf9006 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -188,6 +188,17 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { _letter[i].loadPaletteWA(pal); } +/***************************************************************************\ +* RMFontWithTables Methods +\****************************************************************************/ +int RMFontWithTables::convertToLetter(byte nChar) { + return _cTable[nChar]; +} + +int RMFontWithTables::letterLength(int nChar, int nNext) { + return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault); +} + /***************************************************************************\ * RMFontDialog Methods \****************************************************************************/ @@ -359,7 +370,6 @@ RMText::RMText() { } RMText::~RMText() { - } void RMText::unload() { @@ -571,6 +581,23 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CODE; } +/** + * Set the alignment type + */ +void RMText::setAlignType(HorAlign aHor, VerAlign aVer) { + _aHorType = aHor; + _aVerType = aVer; +} + +/** + * Set the base color + */ +void RMText::setColor(byte r, byte g, byte b) { + _textR = r; + _textG = g; + _textB = b; +} + /****************************************************************************\ * RMTextDialog Methods \****************************************************************************/ @@ -751,6 +778,13 @@ void RMTextDialog::setInput(RMInput *input) { _input = input; } +/** + * Set the position + */ +void RMTextDialog::setPosition(const RMPoint &pt) { + _dst = pt; +} + /****************************************************************************\ * RMTextDialogScrolling Methods \****************************************************************************/ @@ -801,7 +835,6 @@ RMTextItemName::RMTextItemName() : RMText() { } RMTextItemName::~RMTextItemName() { - } void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { @@ -886,6 +919,13 @@ bool RMTextItemName::isItemSelected() { return _item != NULL; } +void RMTextItemName::setMouseCoord(const RMPoint &m) { + _mpos = m; +} + +void RMTextItemName::removeThis(CORO_PARAM, bool &result) { + result = true; +} /****************************************************************************\ * RMDialogChoice Methods diff --git a/engines/tony/font.h b/engines/tony/font.h index 97434b9770..99b20571b1 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -126,12 +126,8 @@ protected: protected: // Overloaded methods - int convertToLetter(byte nChar) { - return _cTable[nChar]; - } - int letterLength(int nChar, int nNext = 0) { - return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault); - } + int convertToLetter(byte nChar); + int letterLength(int nChar, int nNext = 0); public: int letterHeight() { @@ -206,10 +202,7 @@ public: static void unload(); // Set the alignment type - void setAlignType(HorAlign aHor, VerAlign aVer) { - _aHorType = aHor; - _aVerType = aVer; - } + void setAlignType(HorAlign aHor, VerAlign aVer); // Sets the maximum length of a line in pixels (used to format the text) void setMaxLineLength(int max); @@ -225,11 +218,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the base color - void setColor(byte r, byte g, byte b) { - _textR = r; - _textG = g; - _textB = b; - } + void setColor(byte r, byte g, byte b); }; /** @@ -269,9 +258,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the position - void setPosition(const RMPoint &pt) { - _dst = pt; - } + void setPosition(const RMPoint &pt); // Waiting void waitForEndDisplay(CORO_PARAM); @@ -320,9 +307,7 @@ public: RMTextItemName(); virtual ~RMTextItemName(); - void setMouseCoord(const RMPoint &m) { - _mpos = m; - } + void setMouseCoord(const RMPoint &m); void doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -331,9 +316,7 @@ public: RMItem *getSelectedItem(); bool isItemSelected(); - virtual void removeThis(CORO_PARAM, bool &result) { - result = true; - } + virtual void removeThis(CORO_PARAM, bool &result); }; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 3abc7a20f8..2bcfdc7fc2 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -128,6 +128,14 @@ void RMOptionButton::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this, _rect)); } +bool RMOptionButton::isActive() { + return _bActive; +} + +void RMOptionButton::setActiveState(bool bState) { + _bActive = bState; +} + /****************************************************************************\ * RMOptionSlide Methods \****************************************************************************/ @@ -253,6 +261,10 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } +int RMOptionSlide::getValue() { + return _nValue; +} + /****************************************************************************\ * RMOptionScreen Methods \****************************************************************************/ diff --git a/engines/tony/game.h b/engines/tony/game.h index 1c955176bf..83a1ddaea1 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -189,12 +189,8 @@ public: bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void addToList(RMGfxTargetBuffer &bigBuf); - bool isActive() { - return _bActive; - } - void setActiveState(bool bState) { - _bActive = bState; - } + bool isActive(); + void setActiveState(bool bState); }; class RMOptionSlide : public RMGfxTaskSetPrior { @@ -219,9 +215,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void addToList(RMGfxTargetBuffer &bigBuf); - int getValue() { - return _nValue; - } + int getValue(); }; class RMOptionScreen : public RMGfxWoodyBuffer { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 38d8d0046d..71bf31396c 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -49,6 +49,17 @@ void RMGfxTask::removeThis(CORO_PARAM, bool &result) { result = true; } +/** + * Registration + */ +void RMGfxTask::Register() { + _nInList++; +} + +void RMGfxTask::Unregister() { + _nInList--; + assert(_nInList >= 0); +} /****************************************************************************\ * RMGfxTaskSetPrior Methods @@ -192,7 +203,6 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int return (width > 1 && height > 1); } - /** * Initializes a surface by resource Id * @@ -204,6 +214,10 @@ int RMGfxSourceBuffer::init(uint32 resID, int dimx, int dimy, bool bLoadPalette) return init(RMRes(resID), dimx, dimy, bLoadPalette); } +void RMGfxSourceBuffer::offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, getBpp()); +} + /****************************************************************************\ * RMGfxWoodyBuffer Methods \****************************************************************************/ @@ -440,6 +454,34 @@ void RMGfxTargetBuffer::freeBWPrecalcTable() { _precalcTable = NULL; } +RMGfxTargetBuffer::operator byte *() { + return _buf; +} + +RMGfxTargetBuffer::operator void *() { + return (void *)_buf; +} + +RMGfxTargetBuffer::operator uint16 *() { + // FIXME: This may not be endian safe + return (uint16 *)_buf; +} + +/** + * Offseting buffer + */ +void RMGfxTargetBuffer::offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, 16); +} + +void RMGfxTargetBuffer::setTrackDirtyRects(bool v) { + _trackDirtyRects = v; +} + +bool RMGfxTargetBuffer::getTrackDirtyRects() const { + return _trackDirtyRects; +} + /****************************************************************************\ * RMGfxSourceBufferPal Methods \****************************************************************************/ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 4750e42d00..ac4eee05e4 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -145,13 +145,8 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Registration - virtual void Register() { - _nInList++; - } - virtual void Unregister() { - _nInList--; - assert(_nInList >= 0); - } + virtual void Register(); + virtual void Unregister(); }; @@ -209,9 +204,7 @@ public: protected: virtual void prepareImage(); bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); - void offsetY(int nLines) { - RMGfxBuffer::offsetY(nLines, getBpp()); - } + void offsetY(int nLines); public: virtual int getBpp() = 0; @@ -490,32 +483,19 @@ public: void drawOT(CORO_PARAM); void addPrim(RMGfxPrimitive *prim); // The pointer must be delted - operator byte *() { - return _buf; - } - operator void *() { - return (void *)_buf; - } - operator uint16 *() { - // FIXME: This may not be endian safe - return (uint16 *)_buf; - } + operator byte *(); + operator void *(); + operator uint16 *(); // Offseting buffer - void offsetY(int nLines) { - RMGfxBuffer::offsetY(nLines, 16); - } + void offsetY(int nLines); // Dirty rect methods void addDirtyRect(const Common::Rect &r); Common::List &getDirtyRects(); void clearDirtyRects(); - void setTrackDirtyRects(bool v) { - _trackDirtyRects = v; - } - bool getTrackDirtyRects() const { - return _trackDirtyRects; - } + void setTrackDirtyRects(bool v); + bool getTrackDirtyRects() const; }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 647e4264c7..81d62a035c 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -736,6 +736,21 @@ int RMInventory::loadState(byte *state) { return getSaveStateSize(); } +RMInventory &RMInventory::operator+=(RMItem *item) { + addItem(item->mpalCode()); + return *this; +} + +RMInventory &RMInventory::operator+=(RMItem &item) { + addItem(item.mpalCode()); + return *this; +} + +RMInventory &RMInventory::operator+=(int code) { + addItem(code); + return *this; +} + /****************************************************************************\ * RMInterface methods \****************************************************************************/ diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index a5b37748c3..ce94c86c1b 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -146,18 +146,9 @@ public: * Add an item to the inventory */ void addItem(int code); - RMInventory &operator+=(RMItem *item) { - addItem(item->mpalCode()); - return *this; - } - RMInventory &operator+=(RMItem &item) { - addItem(item.mpalCode()); - return *this; - } - RMInventory &operator+=(int code) { - addItem(code); - return *this; - } + RMInventory &operator+=(RMItem *item); + RMInventory &operator+=(RMItem &item); + RMInventory &operator+=(int code); /** * Removes an item diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 7a151ac292..4fe19594f9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -255,6 +255,13 @@ RMPattern::RMPattern() { _slots = NULL; } +/** + * Reads the position of the pattern + */ +RMPoint RMPattern::pos() { + return _curPos; +} + RMPattern::~RMPattern() { if (_slots != NULL) { delete[] _slots; @@ -400,6 +407,10 @@ void RMSfx::stop() { * RMItem Methods \****************************************************************************/ +int RMItem::getCurPattern() { + return _nCurPattern; +} + RMGfxSourceBuffer *RMItem::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; @@ -627,6 +638,19 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CODE; } +/** + * Overloaded priority: it's based on Z ordering + */ +int RMItem::priority() { + return _z; +} + +/** + * Pattern number + */ +int RMItem::numPattern() { + return _nPatterns; +} void RMItem::removeThis(CORO_PARAM, bool &result) { // Remove from the OT list if the current frame is -1 (pattern over) @@ -638,6 +662,14 @@ void RMItem::setStatus(int nStatus) { _bIsActive = (nStatus > 0); } +RMPoint RMItem::hotspot() { + return _hot; +} + +int RMItem::mpalCode() { + return _mpalCode; +} + void RMItem::setPattern(int nPattern, bool bPlayP0) { assert(nPattern >= 0 && nPattern <= _nPatterns); @@ -747,6 +779,10 @@ void RMItem::changeHotspot(const RMPoint &pt) { _hot = pt; } +void RMItem::setInitCurPattern(bool status) { + _bInitCurPattern = status; +} + void RMItem::playSfx(int nSfx) { if (nSfx < _nSfx) _sfx[nSfx].play(); @@ -1429,6 +1465,10 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_END_CODE; } +bool RMCharacter::endOfPath() { + return _bEndOfPath; +} + void RMCharacter::stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1471,6 +1511,13 @@ void RMCharacter::stop(CORO_PARAM) { CORO_END_CODE; } +/** + * Check if the character is moving + */ +bool RMCharacter::isMoving() { + return _bMoving; +} + inline int RMCharacter::inWhichBox(const RMPoint &pt) { return _theBoxes->whichBox(_curLocation, pt); } @@ -1582,6 +1629,14 @@ void RMCharacter::waitForEndMovement(CORO_PARAM) { CORO_END_CODE; } +void RMCharacter::setFixedScroll(const RMPoint &fix) { + _fixedScroll = fix; +} + +void RMCharacter::setSpeed(int speed) { + _curSpeed = speed; +} + void RMCharacter::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1764,6 +1819,10 @@ RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { return _allBoxes[nLoc]; } +int RMGameBoxes::getLocBoxesCount() const { + return _nLocBoxes; +} + bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = getBoxes(nLoc); @@ -1869,6 +1928,14 @@ RMLocation::RMLocation() { _cmode = CM_256; } +RMPoint RMLocation::TEMPGetTonyStart() { + return TEMPTonyStart; +} + +int RMLocation::TEMPGetNumLoc() { + return TEMPNumLoc; +} + /** * Load a location (.LOC) from a given data stream * @@ -2178,6 +2245,12 @@ void RMLocation::pauseSound(bool bPause) { _items[i].pauseSound(bPause); } +/** + * Read the current scroll position + */ +RMPoint RMLocation::scrollPosition() { + return _curScroll; +} /****************************************************************************\ * RMMessage Methods @@ -2230,4 +2303,20 @@ void RMMessage::parseMessage() { } } +bool RMMessage::isValid() { + return _lpMessage != NULL; +} + +int RMMessage::numPeriods() { + return _nPeriods; +} + +char *RMMessage::period(int num) { + return _lpPeriods[num]; +} + +char *RMMessage::operator[](int num) { + return _lpPeriods[num]; +} + } // End of namespace Tony diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 6c28a66f65..61eece2440 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -152,9 +152,7 @@ public: void stopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint pos() { - return _curPos; - } + RMPoint pos(); void readFromStream(Common::ReadStream &ds, bool bLOX = false); @@ -197,16 +195,14 @@ public: protected: int _z; - RMPoint _pos; // Coordinate nonno + RMPoint _pos; // Coordinate ancestor RMColorMode _cm; RMPoint _curScroll; byte _FX; byte _FXparm; - virtual int getCurPattern() { - return _nCurPattern; - } + virtual int getCurPattern(); private: int _nCurPattern; @@ -248,14 +244,10 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int priority() { - return _z; - } + virtual int priority(); // Pattern number - int numPattern() { - return _nPatterns; - } + int numPattern(); // Set anew animation pattern, changing abruptly from the current virtual void setPattern(int nPattern, bool bPlayP0 = false); @@ -264,13 +256,9 @@ public: void setStatus(int nStatus); bool isIn(const RMPoint &pt, int *size = NULL); - RMPoint hotspot() { - return _hot; - } + RMPoint hotspot(); bool getName(Common::String &name); - int mpalCode() { - return _mpalCode; - } + int mpalCode(); // Unload void unload(); @@ -281,9 +269,7 @@ public: // Sets a new hotspot fro the object void changeHotspot(const RMPoint &pt); - void setInitCurPattern(bool status) { - _bInitCurPattern = status; - } + void setInitCurPattern(bool status); void playSfx(int nSfx); @@ -354,7 +340,7 @@ public: // Get binding boxes for a given location RMBoxLoc *getBoxes(int nLoc); - int getLocBoxesCount() const { return _nLocBoxes; } + int getLocBoxesCount() const; // Return the box which contains a given point int whichBox(int nLoc, const RMPoint &pt); @@ -431,7 +417,6 @@ protected: bool _bMoving; bool _bDrawNow; bool _bNeedToStop; -// virtual RMGfxPrimitive *NewItemPrimitive(); public: RMCharacter(); @@ -448,17 +433,13 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool endOfPath() { - return _bEndOfPath; - } + bool endOfPath(); // Change the pattern of a character to STOP virtual void stop(CORO_PARAM); // Check if the character is moving - bool isMoving() { - return _bMoving; - } + bool isMoving(); // Move the character to a certain position void move(CORO_PARAM, RMPoint pt, bool *result = NULL); @@ -469,12 +450,8 @@ public: // Wait for the end of movement void waitForEndMovement(CORO_PARAM); - void setFixedScroll(const RMPoint &fix) { - _fixedScroll = fix; - } - void setSpeed(int speed) { - _curSpeed = speed; - } + void setFixedScroll(const RMPoint &fix); + void setSpeed(int speed); }; @@ -531,14 +508,10 @@ public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; - RMPoint TEMPGetTonyStart() { - return TEMPTonyStart; - } + RMPoint TEMPGetTonyStart(); int TEMPNumLoc; - int TEMPGetNumLoc() { - return TEMPNumLoc; - } + int TEMPGetNumLoc(); public: RMLocation(); @@ -573,9 +546,7 @@ public: void updateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint scrollPosition() { - return _curScroll; - } + RMPoint scrollPosition(); // Pause sound void pauseSound(bool bPause); @@ -600,18 +571,10 @@ public: virtual ~RMMessage(); void load(uint32 dwId); - bool isValid() { - return _lpMessage != NULL; - } - int numPeriods() { - return _nPeriods; - } - char *period(int num) { - return _lpPeriods[num]; - } - char *operator[](int num) { - return _lpPeriods[num]; - } + bool isValid(); + int numPeriods(); + char *period(int num); + char *operator[](int num); }; } // End of namespace Tony diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 99ba84ab19..3cc09a1454 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -86,6 +86,14 @@ RMPoint &RMPoint::operator=(RMPoint p) { return *this; } +/** + * Set a point + */ +void RMPoint::set(int x1, int y1) { + _x = x1; + _y = y1; +} + /** * Offsets the point by another point */ @@ -174,6 +182,9 @@ void RMPoint::readFromStream(Common::ReadStream &ds) { * RMPointReference methods \****************************************************************************/ +RMPointReference::RMPointReference(int &x, int &y): _x(x), _y(y) { +} + RMPointReference &RMPointReference::operator=(const RMPoint &p) { _x = p._x; _y = p._y; return *this; @@ -184,6 +195,10 @@ RMPointReference &RMPointReference::operator-=(const RMPoint &p) { return *this; } +RMPointReference::operator RMPoint() const { + return RMPoint(_x, _y); +} + /****************************************************************************\ * RMRect methods \****************************************************************************/ @@ -233,6 +248,14 @@ void RMRect::copyRect(const RMRect &rc) { _y2 = rc._y2; } +RMPointReference &RMRect::topLeft() { + return _topLeft; +} + +RMPointReference &RMRect::bottomRight() { + return _bottomRight; +} + RMPoint RMRect::center() { return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } @@ -328,6 +351,13 @@ void RMRect::readFromStream(Common::ReadStream &ds) { _y2 = ds.readSint32LE(); } +/** + * Check if RMPoint is in RMRect + */ +bool RMRect::ptInRect(const RMPoint &pt) { + return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); +} + /****************************************************************************\ * Resource Update \****************************************************************************/ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index a24e11f2b6..9f13e5f19b 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -58,10 +58,7 @@ public: RMPoint &operator=(RMPoint p); // Set - void set(int x1, int y1) { - _x = x1; - _y = y1; - } + void set(int x1, int y1); // Offset void offset(int xOff, int yOff); @@ -88,10 +85,10 @@ public: int &_x; int &_y; - RMPointReference(int &x, int &y): _x(x), _y(y) {} + RMPointReference(int &x, int &y); RMPointReference &operator=(const RMPoint &p); RMPointReference &operator-=(const RMPoint &p); - operator RMPoint() const { return RMPoint(_x, _y); } + operator RMPoint() const; }; class RMRect { @@ -108,8 +105,8 @@ public: RMRect(const RMRect &rc); // Attributes - RMPointReference &topLeft() { return _topLeft; } - RMPointReference &bottomRight() { return _bottomRight; } + RMPointReference &topLeft(); + RMPointReference &bottomRight(); RMPoint center(); int width() const; int height() const; @@ -145,9 +142,7 @@ public: void normalizeRect(); // Point in rect - bool ptInRect(const RMPoint &pt) { - return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); - } + bool ptInRect(const RMPoint &pt); // Extract from data stream void readFromStream(Common::ReadStream &ds); -- cgit v1.2.3 From e9730ca5978e3fb0b6285ef785149f049f22e824 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Sep 2012 04:31:56 +0300 Subject: TINSEL: Fix bug #3541542 - "DW: PSX version dies when pressing ESC in intro" DW1 PSX seems to have its own scene skipping code for scenes 2 and 3, thus injecting our own causes it to hang. Scenes 2 and 3 can be skipped separately. --- engines/tinsel/scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp index 79bb30f7a3..c5444517f1 100644 --- a/engines/tinsel/scene.cpp +++ b/engines/tinsel/scene.cpp @@ -158,7 +158,8 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) { // The following myEscape value setting is used for enabling title screen skipping in DW1 if (TinselV1 && (g_sceneCtr == 1)) g_initialMyEscape = GetEscEvents(); - _ctx->myEscape = (TinselV1 && (g_sceneCtr < 4)) ? g_initialMyEscape : 0; + // DW1 PSX has its own scene skipping script code for scenes 2 and 3 (bug #3541542). + _ctx->myEscape = (TinselV1 && (g_sceneCtr < (TinselV1PSX ? 2 : 4))) ? g_initialMyEscape : 0; // get the stuff copied to process when it was created _ctx->pInit = (const TP_INIT *)param; -- cgit v1.2.3 From 978f74817a299263d088799ef32b238a2a3abeda Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 3 Sep 2012 07:58:35 +0200 Subject: TSAGE: Apply naming conventions to some sound variables and functions --- engines/tsage/sound.cpp | 266 ++++++++++++++++++++++++------------------------ engines/tsage/sound.h | 102 +++++++++---------- 2 files changed, 184 insertions(+), 184 deletions(-) (limited to 'engines') diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 9df5a6666b..69a9975ef4 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -66,7 +66,7 @@ SoundManager::~SoundManager() { ++i; delete driver; } - _sfTerminate(); + sfTerminate(); // g_system->getTimerManager()->removeTimerProc(_sfUpdateCallback); } @@ -132,7 +132,7 @@ void SoundManager::syncSounds() { } void SoundManager::update() { - _sfSoundServer(); + sfSoundServer(); } Common::List &SoundManager::buildDriverList(bool detectFlag) { @@ -144,22 +144,22 @@ Common::List &SoundManager::buildDriverList(bool detectFlag) { // Adlib driver SoundDriverEntry sd; - sd.driverNum = ADLIB_DRIVER_NUM; - sd.status = detectFlag ? SNDSTATUS_DETECTED : SNDSTATUS_SKIPPED; - sd.field2 = 0; - sd.field6 = 15000; - sd.shortDescription = "Adlib or SoundBlaster"; - sd.longDescription = "3812fm"; + sd._driverNum = ADLIB_DRIVER_NUM; + sd._status = detectFlag ? SNDSTATUS_DETECTED : SNDSTATUS_SKIPPED; + sd._field2 = 0; + sd._field6 = 15000; + sd._shortDescription = "Adlib or SoundBlaster"; + sd._longDescription = "3812fm"; _availableDrivers.push_back(sd); // SoundBlaster entry SoundDriverEntry sdFx; - sdFx.driverNum = SBLASTER_DRIVER_NUM; - sdFx.status = detectFlag ? SNDSTATUS_DETECTED : SNDSTATUS_SKIPPED; - sdFx.field2 = 0; - sdFx.field6 = 15000; - sdFx.shortDescription = "SndBlast"; - sdFx.longDescription = "SoundBlaster"; + sdFx._driverNum = SBLASTER_DRIVER_NUM; + sdFx._status = detectFlag ? SNDSTATUS_DETECTED : SNDSTATUS_SKIPPED; + sdFx._field2 = 0; + sdFx._field6 = 15000; + sdFx._shortDescription = "SndBlast"; + sdFx._longDescription = "SoundBlaster"; _availableDrivers.push_back(sdFx); _driversDetected = true; @@ -204,7 +204,7 @@ void SoundManager::installDriver(int driverNum) { (*i)->mute(true); // Install the driver - if (!_sfInstallDriver(driver)) + if (!sfInstallDriver(driver)) error("Sound driver initialization failed"); switch (driverNum) { @@ -214,11 +214,11 @@ void SoundManager::installDriver(int driverNum) { byte *bankData = g_resourceManager->getResource(RES_BANK, driverNum, 0, true); if (bankData) { // Install the patch bank data - _sfInstallPatchBank(driver, bankData); + sfInstallPatchBank(driver, bankData); DEALLOCATE(bankData); } else { // Could not locate patch bank data, so unload the driver - _sfUnInstallDriver(driver); + sfUnInstallDriver(driver); // Unmute currently active sounds for (Common::List::iterator i = _playList.begin(); i != _playList.end(); ++i) @@ -260,7 +260,7 @@ void SoundManager::unInstallDriver(int driverNum) { (*j)->mute(true); // Uninstall the driver - _sfUnInstallDriver(*i); + sfUnInstallDriver(*i); // Re-orient all the loaded sounds for (j = _soundList.begin(); j != _soundList.end(); ++j) @@ -303,7 +303,7 @@ void SoundManager::unloadSound(int soundNum) { } int SoundManager::determineGroup(const byte *soundData) { - return _sfDetermineGroup(soundData); + return sfDetermineGroup(soundData); } void SoundManager::checkResVersion(const byte *soundData) { @@ -325,7 +325,7 @@ int SoundManager::extractLoop(const byte *soundData) { } void SoundManager::extractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum) { - _sfExtractTrackInfo(trackInfo, soundData, groupNum); + sfExtractTrackInfo(trackInfo, soundData, groupNum); } void SoundManager::addToSoundList(Sound *sound) { @@ -338,46 +338,46 @@ void SoundManager::removeFromSoundList(Sound *sound) { } void SoundManager::addToPlayList(Sound *sound) { - _sfAddToPlayList(sound); + sfAddToPlayList(sound); } void SoundManager::removeFromPlayList(Sound *sound) { if (_soundManager) - _sfRemoveFromPlayList(sound); + sfRemoveFromPlayList(sound); } bool SoundManager::isOnPlayList(Sound *sound) { - return _sfIsOnPlayList(sound); + return sfIsOnPlayList(sound); } void SoundManager::updateSoundVol(Sound *sound) { - _sfUpdateVolume(sound); + sfUpdateVolume(sound); } void SoundManager::updateSoundPri(Sound *sound) { - _sfUpdatePriority(sound); + sfUpdatePriority(sound); } void SoundManager::updateSoundLoop(Sound *sound) { - _sfUpdateLoop(sound); + sfUpdateLoop(sound); } void SoundManager::rethinkVoiceTypes() { Common::StackLock slock(sfManager()._serverSuspendedMutex); - _sfRethinkVoiceTypes(); + sfRethinkVoiceTypes(); } -void SoundManager::_sfSoundServer() { +void SoundManager::sfSoundServer() { if (sfManager()._needToRethink) { - _sfRethinkVoiceTypes(); + sfRethinkVoiceTypes(); sfManager()._needToRethink = false; } else { - _sfDereferenceAll(); + sfDereferenceAll(); } // If the master volume has changed, update it if (sfManager()._newVolume != sfManager()._masterVol) - _sfSetMasterVol(sfManager()._newVolume); + sfSetMasterVol(sfManager()._newVolume); // If a time index has been set for any sound, fast forward to it SynchronizedList::iterator i; @@ -385,14 +385,14 @@ void SoundManager::_sfSoundServer() { Sound *s = *i; if (s->_newTimeIndex != 0) { s->mute(true); - s->_soSetTimeIndex(s->_newTimeIndex); + s->soSetTimeIndex(s->_newTimeIndex); s->mute(false); s->_newTimeIndex = 0; } } // Handle any fading if necessary - _sfProcessFading(); + sfProcessFading(); // Poll all sound drivers in case they need it for (Common::List::iterator j = sfManager()._installedDrivers.begin(); @@ -401,7 +401,7 @@ void SoundManager::_sfSoundServer() { } } -void SoundManager::_sfProcessFading() { +void SoundManager::sfProcessFading() { // Loop through processing active sounds bool removeFlag = false; Common::List::iterator i = sfManager()._playList.begin(); @@ -410,9 +410,9 @@ void SoundManager::_sfProcessFading() { ++i; if (!s->_pausedCount) - removeFlag = s->_soServiceTracks(); + removeFlag = s->soServiceTracks(); if (removeFlag) { - _sfDoRemoveFromPlayList(s); + sfDoRemoveFromPlayList(s); s->_stoppedAsynchronously = true; sfManager()._needToRethink = true; } @@ -429,13 +429,13 @@ void SoundManager::_sfProcessFading() { s->_volume + s->_fadeSteps : s->_fadeDest; } - _sfDoUpdateVolume(s); + sfDoUpdateVolume(s); if (s->_volume != s->_fadeDest) s->_fadeCounter = s->_fadeTicks; else { s->_fadeDest = -1; if (s->_stopAfterFadeFlag) { - _sfDoRemoveFromPlayList(s); + sfDoRemoveFromPlayList(s); s->_stoppedAsynchronously = true; sfManager()._needToRethink = true; } @@ -475,7 +475,7 @@ bool SoundManager::isFading() { return false; } -void SoundManager::_sfUpdateVoiceStructs() { +void SoundManager::sfUpdateVoiceStructs() { for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { VoiceTypeStruct *vs = sfManager()._voiceTypeStructPtrs[voiceIndex]; if (!vs) @@ -504,7 +504,7 @@ void SoundManager::_sfUpdateVoiceStructs() { } } -void SoundManager::_sfUpdateVoiceStructs2() { +void SoundManager::sfUpdateVoiceStructs2() { for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { VoiceTypeStruct *vtStruct = sfManager()._voiceTypeStructPtrs[voiceIndex]; if (!vtStruct) @@ -528,7 +528,7 @@ void SoundManager::_sfUpdateVoiceStructs2() { } } -void SoundManager::_sfUpdateCallback(void *ref) { +void SoundManager::sfUpdateCallback(void *ref) { ((SoundManager *)ref)->update(); } @@ -587,7 +587,7 @@ SoundManager &SoundManager::sfManager() { return *_soundManager; } -int SoundManager::_sfDetermineGroup(const byte *soundData) { +int SoundManager::sfDetermineGroup(const byte *soundData) { const byte *p = soundData + READ_LE_UINT16(soundData + 8); uint32 v; while ((v = READ_LE_UINT32(p)) != 0) { @@ -600,22 +600,22 @@ int SoundManager::_sfDetermineGroup(const byte *soundData) { return 0; } -void SoundManager::_sfAddToPlayList(Sound *sound) { +void SoundManager::sfAddToPlayList(Sound *sound) { Common::StackLock slock(sfManager()._serverSuspendedMutex); - _sfDoAddToPlayList(sound); + sfDoAddToPlayList(sound); sound->_stoppedAsynchronously = false; - _sfRethinkVoiceTypes(); + sfRethinkVoiceTypes(); } -void SoundManager::_sfRemoveFromPlayList(Sound *sound) { +void SoundManager::sfRemoveFromPlayList(Sound *sound) { Common::StackLock slock(sfManager()._serverSuspendedMutex); - if (_sfDoRemoveFromPlayList(sound)) - _sfRethinkVoiceTypes(); + if (sfDoRemoveFromPlayList(sound)) + sfRethinkVoiceTypes(); } -bool SoundManager::_sfIsOnPlayList(Sound *sound) { +bool SoundManager::sfIsOnPlayList(Sound *sound) { Common::StackLock slock(sfManager()._serverSuspendedMutex); bool result = contains(_soundManager->_playList, sound); @@ -623,7 +623,7 @@ bool SoundManager::_sfIsOnPlayList(Sound *sound) { return result; } -void SoundManager::_sfRethinkSoundDrivers() { +void SoundManager::sfRethinkSoundDrivers() { // Free any existing entries int idx; @@ -643,7 +643,7 @@ void SoundManager::_sfRethinkSoundDrivers() { i != sfManager()._installedDrivers.end(); ++i) { // Process the group data for each sound driver SoundDriver *driver = *i; - const byte *groupData = driver->_groupOffset->pData; + const byte *groupData = driver->_groupOffset->_pData; while (*groupData != 0xff) { byte byteVal = *groupData++; @@ -690,7 +690,7 @@ void SoundManager::_sfRethinkSoundDrivers() { i != sfManager()._installedDrivers.end(); ++i) { // Process the group data for each sound driver SoundDriver *driver = *i; - const byte *groupData = driver->_groupOffset->pData; + const byte *groupData = driver->_groupOffset->_pData; while (*groupData != 0xff) { byte byteVal = *groupData++; @@ -746,8 +746,8 @@ void SoundManager::_sfRethinkSoundDrivers() { } } -void SoundManager::_sfRethinkVoiceTypes() { - _sfDereferenceAll(); +void SoundManager::sfRethinkVoiceTypes() { + sfDereferenceAll(); // Pre-processing for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { @@ -797,7 +797,7 @@ void SoundManager::_sfRethinkVoiceTypes() { if ((sound->_mutedCount != 0) || (sound->_pausedCount != 0)) continue; - _sfUpdateVoiceStructs(); + sfUpdateVoiceStructs(); Common::fill(sound->_chWork, sound->_chWork + SOUND_ARR_SIZE, false); for (;;) { @@ -831,7 +831,7 @@ void SoundManager::_sfRethinkVoiceTypes() { if (foundPriority) continue; - _sfUpdateVoiceStructs2(); + sfUpdateVoiceStructs2(); break; } @@ -860,7 +860,7 @@ void SoundManager::_sfRethinkVoiceTypes() { maxPriority = MAX(maxPriority, vtStruct->_entries[idx]._type1._priority2); if (!maxPriority) { - _sfUpdateVoiceStructs2(); + sfUpdateVoiceStructs2(); break; } @@ -944,7 +944,7 @@ void SoundManager::_sfRethinkVoiceTypes() { continue; } - _sfUpdateVoiceStructs2(); + sfUpdateVoiceStructs2(); break; } else { // Channel mode 1 handling (loc_23FAC) @@ -973,7 +973,7 @@ void SoundManager::_sfRethinkVoiceTypes() { if (foundPriority) continue; if (entryIndex == -1) { - _sfUpdateVoiceStructs2(); + sfUpdateVoiceStructs2(); break; } } @@ -1008,7 +1008,7 @@ void SoundManager::_sfRethinkVoiceTypes() { continue; } - _sfUpdateVoiceStructs2(); + sfUpdateVoiceStructs2(); break; } @@ -1051,7 +1051,7 @@ void SoundManager::_sfRethinkVoiceTypes() { if (!foundPriority) continue; if (priorityIndex == -1) { - _sfUpdateVoiceStructs2(); + sfUpdateVoiceStructs2(); break; } @@ -1271,38 +1271,38 @@ void SoundManager::_sfRethinkVoiceTypes() { } } -void SoundManager::_sfUpdateVolume(Sound *sound) { - _sfDereferenceAll(); - _sfDoUpdateVolume(sound); +void SoundManager::sfUpdateVolume(Sound *sound) { + sfDereferenceAll(); + sfDoUpdateVolume(sound); } -void SoundManager::_sfDereferenceAll() { +void SoundManager::sfDereferenceAll() { // Orignal used handles for both the driver list and voiceTypeStructPtrs list. This method then refreshed // pointer lists based on the handles. Since in ScummVM we're just using pointers directly, this // method doesn't need any implementation } -void SoundManager::_sfUpdatePriority(Sound *sound) { +void SoundManager::sfUpdatePriority(Sound *sound) { Common::StackLock slock(sfManager()._serverSuspendedMutex); int tempPriority = (sound->_fixedPriority == 255) ? sound->_sndResPriority : sound->_priority; if (sound->_priority != tempPriority) { sound->_priority = tempPriority; - if (_sfDoRemoveFromPlayList(sound)) { - _sfDoAddToPlayList(sound); - _sfRethinkVoiceTypes(); + if (sfDoRemoveFromPlayList(sound)) { + sfDoAddToPlayList(sound); + sfRethinkVoiceTypes(); } } } -void SoundManager::_sfUpdateLoop(Sound *sound) { +void SoundManager::sfUpdateLoop(Sound *sound) { if (sound->_fixedLoop) sound->_loop = sound->_sndResLoop; else sound->_loop = sound->_fixedLoop; } -void SoundManager::_sfSetMasterVol(int volume) { +void SoundManager::sfSetMasterVol(int volume) { if (volume > 127) volume = 127; @@ -1316,7 +1316,7 @@ void SoundManager::_sfSetMasterVol(int volume) { } } -void SoundManager::_sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum) { +void SoundManager::sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum) { trackInfo->_numTracks = 0; const byte *p = soundData + READ_LE_UINT16(soundData + 8); @@ -1345,11 +1345,11 @@ void SoundManager::_sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *s } } -void SoundManager::_sfTerminate() { +void SoundManager::sfTerminate() { } -void SoundManager::_sfExtractGroupMask() { +void SoundManager::sfExtractGroupMask() { uint32 mask = 0; for (Common::List::iterator i = sfManager()._installedDrivers.begin(); @@ -1359,37 +1359,37 @@ void SoundManager::_sfExtractGroupMask() { _soundManager->_groupsAvail = mask; } -bool SoundManager::_sfInstallDriver(SoundDriver *driver) { +bool SoundManager::sfInstallDriver(SoundDriver *driver) { if (!driver->open()) return false; sfManager()._installedDrivers.push_back(driver); driver->_groupOffset = driver->getGroupData(); - driver->_groupMask = driver->_groupOffset->groupMask; + driver->_groupMask = driver->_groupOffset->_groupMask; - _sfExtractGroupMask(); - _sfRethinkSoundDrivers(); + sfExtractGroupMask(); + sfRethinkSoundDrivers(); driver->setMasterVolume(sfManager()._masterVol); return true; } -void SoundManager::_sfUnInstallDriver(SoundDriver *driver) { +void SoundManager::sfUnInstallDriver(SoundDriver *driver) { sfManager()._installedDrivers.remove(driver); delete driver; - _sfExtractGroupMask(); - _sfRethinkSoundDrivers(); + sfExtractGroupMask(); + sfRethinkSoundDrivers(); } -void SoundManager::_sfInstallPatchBank(SoundDriver *driver, const byte *bankData) { +void SoundManager::sfInstallPatchBank(SoundDriver *driver, const byte *bankData) { driver->installPatch(bankData, g_vm->_memoryManager.getSize(bankData)); } /** * Adds the specified sound in the playing sound list, inserting in order of priority */ -void SoundManager::_sfDoAddToPlayList(Sound *sound) { +void SoundManager::sfDoAddToPlayList(Sound *sound) { Common::StackLock slock2(sfManager()._serverSuspendedMutex); Common::List::iterator i = sfManager()._playList.begin(); @@ -1402,7 +1402,7 @@ void SoundManager::_sfDoAddToPlayList(Sound *sound) { /** * Removes the specified sound from the play list */ -bool SoundManager::_sfDoRemoveFromPlayList(Sound *sound) { +bool SoundManager::sfDoRemoveFromPlayList(Sound *sound) { Common::StackLock slock(sfManager()._serverSuspendedMutex); bool result = false; @@ -1417,7 +1417,7 @@ bool SoundManager::_sfDoRemoveFromPlayList(Sound *sound) { return result; } -void SoundManager::_sfDoUpdateVolume(Sound *sound) { +void SoundManager::sfDoUpdateVolume(Sound *sound) { Common::StackLock slock(sfManager()._serverSuspendedMutex); for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { @@ -1583,7 +1583,7 @@ void Sound::_prime(int soundResID, bool dontQueue) { _remoteReceiver = ALLOCATE(200); } - _soPrimeSound(dontQueue); + soPrimeSound(dontQueue); if (!dontQueue) _soundManager->addToSoundList(this); @@ -1767,7 +1767,7 @@ void Sound::release() { _hold = -1; } -void Sound::_soPrimeSound(bool dontQueue) { +void Sound::soPrimeSound(bool dontQueue) { if (!dontQueue) { _priority = (_fixedPriority != -1) ? _fixedPriority : _sndResPriority; _loop = !_fixedLoop ? _fixedLoop : _sndResLoop; @@ -1785,21 +1785,21 @@ void Sound::_soPrimeSound(bool dontQueue) { _timer = 0; _newTimeIndex = 0; _loopTimer = 0; - _soPrimeChannelData(); + soPrimeChannelData(); } -void Sound::_soSetTimeIndex(uint timeIndex) { +void Sound::soSetTimeIndex(uint timeIndex) { Common::StackLock slock(g_globals->_soundManager._serverSuspendedMutex); if (timeIndex != _timer) { _soundManager->_soTimeIndexFlag = true; _timer = 0; _loopTimer = 0; - _soPrimeChannelData(); + soPrimeChannelData(); while (timeIndex > 0) { - if (_soServiceTracks()) { - SoundManager::_sfDoRemoveFromPlayList(this); + if (soServiceTracks()) { + SoundManager::sfDoRemoveFromPlayList(this); _stoppedAsynchronously = true; _soundManager->_needToRethink = true; break; @@ -1812,9 +1812,9 @@ void Sound::_soSetTimeIndex(uint timeIndex) { } } -bool Sound::_soServiceTracks() { +bool Sound::soServiceTracks() { if (_isEmpty) { - _soRemoteReceive(); + soRemoteReceive(); return false; } @@ -1823,9 +1823,9 @@ bool Sound::_soServiceTracks() { int mode = *_channelData[trackCtr]; if (mode == 0) { - _soServiceTrackType0(trackCtr, _channelData[trackCtr]); + soServiceTrackType0(trackCtr, _channelData[trackCtr]); } else if (mode == 1) { - _soServiceTrackType1(trackCtr, _channelData[trackCtr]); + soServiceTrackType1(trackCtr, _channelData[trackCtr]); } else { error("Unknown sound mode encountered"); } @@ -1851,7 +1851,7 @@ bool Sound::_soServiceTracks() { } } -void Sound::_soPrimeChannelData() { +void Sound::soPrimeChannelData() { if (_isEmpty) { for (int idx = 0; idx < 16; ++idx) { _chProgram[idx] = 0; @@ -1917,11 +1917,11 @@ void Sound::_soPrimeChannelData() { } } -void Sound::_soRemoteReceive() { - error("_soRemoteReceive not implemented"); +void Sound::soRemoteReceive() { + error("soRemoteReceive not implemented"); } -void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { +void Sound::soServiceTrackType0(int trackIndex, const byte *channelData) { if (_trkRest[trackIndex]) { --_trkRest[trackIndex]; return; @@ -1970,7 +1970,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { // Only do processing if fast forwarding to a given time index if (channelNum != -1) { if (voiceType == VOICETYPE_1) { - _soUpdateDamper(vtStruct, channelNum, chVoiceType, v); + soUpdateDamper(vtStruct, channelNum, chVoiceType, v); } else if (voiceNum != -1) { assert(driver); driver->proc18(voiceNum, chVoiceType); @@ -1991,9 +1991,9 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { if (channelNum != -1) { if (voiceType != VOICETYPE_0) { if (chFlags & 0x10) - _soPlaySound2(vtStruct, channelData, channelNum, chVoiceType, v); + soPlaySound2(vtStruct, channelData, channelNum, chVoiceType, v); else - _soPlaySound(vtStruct, channelData, channelNum, chVoiceType, v, b); + soPlaySound(vtStruct, channelData, channelNum, chVoiceType, v, b); } else if (voiceNum != -1) { assert(driver); driver->proc20(voiceNum, chVoiceType); @@ -2030,17 +2030,17 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { int cmdVal = cmdList[v]; if (channelNum == -1) { - if (_soDoUpdateTracks(cmdVal, b)) + if (soDoUpdateTracks(cmdVal, b)) return; } else { - _soDoTrackCommand(_trkChannel[trackIndex], cmdVal, b); + soDoTrackCommand(_trkChannel[trackIndex], cmdVal, b); if (!_soundManager->_soTimeIndexFlag) { if (cmdVal == 7) b = static_cast(_volume * (int)b / 127); if (voiceType != VOICETYPE_0) { - _soProc38(vtStruct, channelNum, chVoiceType, cmdVal, b); + soProc38(vtStruct, channelNum, chVoiceType, cmdVal, b); } else if (voiceNum != -1) { assert(driver); driver->proc24(voiceNum, chVoiceType, this, cmdVal, b); @@ -2067,17 +2067,17 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { int value = *pData++; if (channelNum != -1) { - _soDoTrackCommand(_trkChannel[trackIndex], cmd, value); + soDoTrackCommand(_trkChannel[trackIndex], cmd, value); if (!_soundManager->_soTimeIndexFlag) { if (voiceType != VOICETYPE_0) { - _soProc38(vtStruct, channelNum, chVoiceType, cmd, value); + soProc38(vtStruct, channelNum, chVoiceType, cmd, value); } else if (voiceNum != -1) { assert(driver); driver->proc24(voiceNum, chVoiceType, this, cmd, value); } } - } else if (_soDoUpdateTracks(cmd, value)) { + } else if (soDoUpdateTracks(cmd, value)) { return; } } else if (!(v & 0x2)) { @@ -2091,7 +2091,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { _chPitchBlend[channel] = pitchBlend; if (voiceType != VOICETYPE_0) { - _soProc40(vtStruct, channelNum, pitchBlend); + soProc40(vtStruct, channelNum, pitchBlend); } else if (voiceNum != -1) { assert(driver); driver->setPitchBlend(channel, pitchBlend); @@ -2115,7 +2115,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { } } } else { - _soSetTrackPos(trackIndex, pData - channelData, program); + soSetTrackPos(trackIndex, pData - channelData, program); } } else { @@ -2139,7 +2139,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) { } } -void Sound::_soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0) { +void Sound::soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0) { bool hasDamper = _chDamper[channelNum] != 0; for (uint idx = 0; idx < voiceType->_entries.size(); ++idx) { @@ -2161,8 +2161,8 @@ void Sound::_soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceTyp } } -void Sound::_soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1) { - int entryIndex = _soFindSound(vtStruct, channelNum); +void Sound::soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1) { + int entryIndex = soFindSound(vtStruct, channelNum); if (entryIndex != -1) { SoundDriver *driver = vtStruct->_entries[entryIndex]._driver; assert(driver); @@ -2175,11 +2175,11 @@ void Sound::_soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int } } -void Sound::_soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0) { +void Sound::soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0) { for (int trackCtr = 0; trackCtr < _trackInfo._numTracks; ++trackCtr) { const byte *instrument = _channelData[trackCtr]; if ((*(instrument + 13) == v0) && (*instrument == 1)) { - int entryIndex = _soFindSound(vtStruct, channelNum); + int entryIndex = soFindSound(vtStruct, channelNum); if (entryIndex != -1) { SoundDriver *driver = vtStruct->_entries[entryIndex]._driver; @@ -2199,7 +2199,7 @@ void Sound::_soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, in } } -void Sound::_soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value) { +void Sound::soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value) { if (cmd == 64) { if (value == 0) { for (uint entryIndex = 0; entryIndex < vtStruct->_entries.size(); ++entryIndex) { @@ -2231,7 +2231,7 @@ void Sound::_soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voice } } -void Sound::_soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend) { +void Sound::soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend) { for (uint entryIndex = 0; entryIndex < vtStruct->_entries.size(); ++entryIndex) { VoiceStructEntryType1 &vte = vtStruct->_entries[entryIndex]._type1; @@ -2244,7 +2244,7 @@ void Sound::_soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend) } } -void Sound::_soDoTrackCommand(int channelNum, int command, int value) { +void Sound::soDoTrackCommand(int channelNum, int command, int value) { switch (command) { case 1: _chModulation[channelNum] = value; @@ -2264,7 +2264,7 @@ void Sound::_soDoTrackCommand(int channelNum, int command, int value) { } } -bool Sound::_soDoUpdateTracks(int command, int value) { +bool Sound::soDoUpdateTracks(int command, int value) { if ((command == 76) || (_hold != value)) return false; @@ -2278,7 +2278,7 @@ bool Sound::_soDoUpdateTracks(int command, int value) { return true; } -void Sound::_soSetTrackPos(int trackIndex, int trackPos, int cueValue) { +void Sound::soSetTrackPos(int trackIndex, int trackPos, int cueValue) { _trkIndex[trackIndex] = trackPos; if (cueValue == 127) { if (!_soundManager->_soTimeIndexFlag) @@ -2294,7 +2294,7 @@ void Sound::_soSetTrackPos(int trackIndex, int trackPos, int cueValue) { } } -void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) { +void Sound::soServiceTrackType1(int trackIndex, const byte *channelData) { if (_soundManager->_soTimeIndexFlag || !_trkState[trackIndex]) return; @@ -2310,7 +2310,7 @@ void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) { else { if (vtStruct->_voiceType != VOICETYPE_0) { if (_trkState[trackIndex] == 1) { - int entryIndex = _soFindSound(vtStruct, *(channelData + 1)); + int entryIndex = soFindSound(vtStruct, *(channelData + 1)); if (entryIndex != -1) { SoundDriver *driver = vtStruct->_entries[entryIndex]._driver; assert(driver); @@ -2352,7 +2352,7 @@ void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) { } } -int Sound::_soFindSound(VoiceTypeStruct *vtStruct, int channelNum) { +int Sound::soFindSound(VoiceTypeStruct *vtStruct, int channelNum) { int entryIndex = -1, entry2Index = -1; int v6 = 0, v8 = 0; @@ -2539,10 +2539,10 @@ AdlibSoundDriver::AdlibSoundDriver(): SoundDriver() { _maxVersion = 0x10A; _masterVolume = 0; - _groupData.groupMask = 9; - _groupData.v1 = 0x46; - _groupData.v2 = 0; - _groupData.pData = &adlib_group_data[0]; + _groupData._groupMask = 9; + _groupData._v1 = 0x46; + _groupData._v2 = 0; + _groupData._pData = &adlib_group_data[0]; _mixer = g_vm->_mixer; _sampleRate = _mixer->getOutputRate(); @@ -2823,7 +2823,7 @@ int AdlibSoundDriver::readBuffer(int16 *buffer, const int numSamples) { memset(buffer, 0, sizeof(int16) * numSamples); while (samplesLeft) { if (!_samplesTillCallback) { - SoundManager::_sfUpdateCallback(NULL); + SoundManager::sfUpdateCallback(NULL); flush(); _samplesTillCallback = _samplesPerCallback; @@ -2852,11 +2852,11 @@ SoundBlasterDriver::SoundBlasterDriver(): SoundDriver() { _maxVersion = 0x10A; _masterVolume = 0; - _groupData.groupMask = 1; - _groupData.v1 = 0x3E; - _groupData.v2 = 0; + _groupData._groupMask = 1; + _groupData._v1 = 0x3E; + _groupData._v2 = 0; static byte const group_data[] = { 3, 1, 1, 0, 0xff }; - _groupData.pData = group_data; + _groupData._pData = group_data; _mixer = g_vm->_mixer; _sampleRate = _mixer->getOutputRate(); diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index 77d1f3d3ac..2f59afb49b 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -54,18 +54,18 @@ enum VoiceType {VOICETYPE_0 = 0, VOICETYPE_1 = 1}; class SoundDriverEntry { public: - int driverNum; - SoundDriverStatus status; - int field2, field6; - Common::String shortDescription; - Common::String longDescription; + int _driverNum; + SoundDriverStatus _status; + int _field2, _field6; + Common::String _shortDescription; + Common::String _longDescription; }; struct GroupData { - uint32 groupMask; - byte v1; - byte v2; - const byte *pData; + uint32 _groupMask; + byte _v1; + byte _v2; + const byte *_pData; }; struct RegisterValue { @@ -229,31 +229,31 @@ public: // _sf methods static SoundManager &sfManager(); - static void _sfTerminate(); - static int _sfDetermineGroup(const byte *soundData); - static void _sfAddToPlayList(Sound *sound); - static void _sfRemoveFromPlayList(Sound *sound); - static bool _sfIsOnPlayList(Sound *sound); - static void _sfRethinkSoundDrivers(); - static void _sfRethinkVoiceTypes(); - static void _sfUpdateVolume(Sound *sound); - static void _sfDereferenceAll(); - static void _sfUpdatePriority(Sound *sound); - static void _sfUpdateLoop(Sound *sound); - static void _sfSetMasterVol(int volume); - static void _sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum); - static void _sfExtractGroupMask(); - static bool _sfInstallDriver(SoundDriver *driver); - static void _sfUnInstallDriver(SoundDriver *driver); - static void _sfInstallPatchBank(SoundDriver *driver, const byte *bankData); - static void _sfDoAddToPlayList(Sound *sound); - static bool _sfDoRemoveFromPlayList(Sound *sound); - static void _sfDoUpdateVolume(Sound *sound); - static void _sfSoundServer(); - static void _sfProcessFading(); - static void _sfUpdateVoiceStructs(); - static void _sfUpdateVoiceStructs2(); - static void _sfUpdateCallback(void *ref); + static void sfTerminate(); + static int sfDetermineGroup(const byte *soundData); + static void sfAddToPlayList(Sound *sound); + static void sfRemoveFromPlayList(Sound *sound); + static bool sfIsOnPlayList(Sound *sound); + static void sfRethinkSoundDrivers(); + static void sfRethinkVoiceTypes(); + static void sfUpdateVolume(Sound *sound); + static void sfDereferenceAll(); + static void sfUpdatePriority(Sound *sound); + static void sfUpdateLoop(Sound *sound); + static void sfSetMasterVol(int volume); + static void sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum); + static void sfExtractGroupMask(); + static bool sfInstallDriver(SoundDriver *driver); + static void sfUnInstallDriver(SoundDriver *driver); + static void sfInstallPatchBank(SoundDriver *driver, const byte *bankData); + static void sfDoAddToPlayList(Sound *sound); + static bool sfDoRemoveFromPlayList(Sound *sound); + static void sfDoUpdateVolume(Sound *sound); + static void sfSoundServer(); + static void sfProcessFading(); + static void sfUpdateVoiceStructs(); + static void sfUpdateVoiceStructs2(); + static void sfUpdateCallback(void *ref); }; class Sound: public EventHandler { @@ -343,23 +343,23 @@ public: void orientAfterDriverChange(); // _so methods - void _soPrimeSound(bool dontQueue); - void _soSetTimeIndex(uint timeIndex); - bool _soServiceTracks(); - void _soPrimeChannelData(); - void _soRemoteReceive(); - void _soServiceTrackType0(int trackIndex, const byte *channelData); - void _soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0); - void _soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1); - void _soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0); - void _soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value); - void _soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend); - void _soDoTrackCommand(int channelNum, int command, int value); - bool _soDoUpdateTracks(int command, int value); - void _soSetTrackPos(int trackIndex, int trackPos, int cueValue); - - void _soServiceTrackType1(int trackIndex, const byte *channelData); - int _soFindSound(VoiceTypeStruct *vtStruct, int channelNum); + void soPrimeSound(bool dontQueue); + void soSetTimeIndex(uint timeIndex); + bool soServiceTracks(); + void soPrimeChannelData(); + void soRemoteReceive(); + void soServiceTrackType0(int trackIndex, const byte *channelData); + void soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0); + void soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1); + void soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0); + void soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value); + void soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend); + void soDoTrackCommand(int channelNum, int command, int value); + bool soDoUpdateTracks(int command, int value); + void soSetTrackPos(int trackIndex, int trackPos, int cueValue); + + void soServiceTrackType1(int trackIndex, const byte *channelData); + int soFindSound(VoiceTypeStruct *vtStruct, int channelNum); }; class ASound: public EventHandler { -- 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 From 00ad58c29b7ead1f9d18b99d374b3e8e1e62f3d3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Sep 2012 20:10:30 +0300 Subject: WINTERMUTE: Fix a warning with MSVC --- engines/wintermute/base/scriptables/script.cpp | 4 ++-- engines/wintermute/base/scriptables/script.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index beef4ee9d2..269ea1ea03 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; @@ -48,7 +48,7 @@ ScScript::ScScript(BaseGame *inGame, ScEngine *Engine) : BaseClass(inGame) { _symbols = NULL; _numSymbols = 0; - _engine = Engine; + _engine = engine; _globals = NULL; diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 132f1ce6c5..4daeacd026 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -138,7 +138,7 @@ private: byte *_buffer; public: Common::SeekableReadStream *_scriptStream; - ScScript(BaseGame *inGame, ScEngine *Engine); + ScScript(BaseGame *inGame, ScEngine *engine); virtual ~ScScript(); char *_filename; bool _thread; -- cgit v1.2.3 From 4cfd906cec08fec8c27f33c1a54651271a4fb104 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Sep 2012 20:27:19 +0300 Subject: WINTERMUTE: Fix compilation when vorbis isn't available --- engines/wintermute/base/sound/base_sound_buffer.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index e2d9c8c13f..24414e33a7 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -104,7 +104,9 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel Common::String strFilename(filename); strFilename.toLowercase(); if (strFilename.hasSuffix(".ogg")) { +#ifdef USE_VORBIS _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); +#endif } else if (strFilename.hasSuffix(".wav")) { int waveSize, waveRate; byte waveFlags; -- cgit v1.2.3 From 9989a4f3daba891326810d7ae620cd75d97521f1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 19:41:58 +0200 Subject: WINTERMUTE: Remove extra semicolon. --- engines/wintermute/base/base_keyboard_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 63c0a873ce..c8dc02c49a 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -277,7 +277,7 @@ enum VKeyCodes { VK_UP = 38, VK_RIGHT = 39, VK_DOWN = 40 -}; +} ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { -- cgit v1.2.3 From e8f2742cc789b54d22ed5d47e45938474ea608e9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 19:43:15 +0200 Subject: WINTERMUTE: Replace VKeyCodes constant names. This is a purely cosmetical change, which should help compilation on systems, which use VK_* for internal constants. This should help compilation for WinCE. --- engines/wintermute/base/base_keyboard_state.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index c8dc02c49a..c8a6ccd391 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -272,30 +272,30 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { } enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 + kVkSpace = 32, + kVkLeft = 37, + kVkUp = 38, + kVkRight = 39, + kVkDown = 40 } ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { - case VK_SPACE: + case kVkSpace: return Common::KEYCODE_SPACE; break; - case VK_LEFT: + case kVkLeft: return Common::KEYCODE_LEFT; break; - case VK_RIGHT: + case kVkRight: return Common::KEYCODE_RIGHT; break; - case VK_UP: + case kVkUp: return Common::KEYCODE_UP; break; - case VK_DOWN: + case kVkDown: return Common::KEYCODE_DOWN; break; default: -- cgit v1.2.3 From a8518eebe6632d7632ee204799bd8ff76eb01384 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 19:51:33 +0200 Subject: Revert "WINTERMUTE: Remove extra semicolon." This reverts commit 9989a4f3daba891326810d7ae620cd75d97521f1. Note: Don't blind fix warnings of broken builds. Conflicts: engines/wintermute/base/base_keyboard_state.cpp --- engines/wintermute/base/base_keyboard_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index c8a6ccd391..d5c2027a0d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -277,7 +277,7 @@ enum VKeyCodes { kVkUp = 38, kVkRight = 39, kVkDown = 40 -} +}; ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { -- cgit v1.2.3 From 8208d725e3f06899b2685719d3ae628007616091 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Sep 2012 21:06:00 +0300 Subject: CONFIGURE: Add zlib and libpng to the library dependencies of wintermute --- 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 052fb8f099..26fd2dd16b 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" no +add_engine wintermute "Wintermute" no "" "png zlib" -- cgit v1.2.3 From 0612aac72b160ef5db15c1ae004536155f8b3826 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 20:27:56 +0200 Subject: CONFIGURE: Make Wintermute dependent on vorbis. This is done as discussed with somaen. --- 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 26fd2dd16b..b8b1677e2a 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" no "" "png zlib" +add_engine wintermute "Wintermute" no "" "png zlib vorbis" -- cgit v1.2.3 From df80820184c90a87511f0cabdca4addb9fa13a66 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 20:29:14 +0200 Subject: Revert "WINTERMUTE: Fix compilation when vorbis isn't available" This reverts commit 4cfd906cec08fec8c27f33c1a54651271a4fb104. We now have vorbis as a hard requirement for Wintermute. Also somaen said this commit causes issues, so we agreed on reverting this hack. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 2 -- 1 file changed, 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 24414e33a7..e2d9c8c13f 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -104,9 +104,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel Common::String strFilename(filename); strFilename.toLowercase(); if (strFilename.hasSuffix(".ogg")) { -#ifdef USE_VORBIS _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); -#endif } else if (strFilename.hasSuffix(".wav")) { int waveSize, waveRate; byte waveFlags; -- cgit v1.2.3 From b4090ead4d4334e08725323ff72fd355c93b63d5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 4 Sep 2012 22:17:23 +0200 Subject: WINTERMUTE: Convert CRLF to LF --- engines/wintermute/ad/ad_actor.cpp | 2920 +++---- engines/wintermute/ad/ad_actor.h | 216 +- engines/wintermute/ad/ad_entity.cpp | 2242 ++--- engines/wintermute/ad/ad_entity.h | 136 +- engines/wintermute/ad/ad_game.cpp | 4560 +++++----- engines/wintermute/ad/ad_game.h | 326 +- engines/wintermute/ad/ad_inventory.cpp | 272 +- engines/wintermute/ad/ad_inventory.h | 104 +- engines/wintermute/ad/ad_inventory_box.cpp | 776 +- engines/wintermute/ad/ad_inventory_box.h | 130 +- engines/wintermute/ad/ad_item.cpp | 1626 ++-- engines/wintermute/ad/ad_item.h | 138 +- engines/wintermute/ad/ad_layer.cpp | 1128 +-- engines/wintermute/ad/ad_layer.h | 116 +- engines/wintermute/ad/ad_node_state.cpp | 392 +- engines/wintermute/ad/ad_node_state.h | 120 +- engines/wintermute/ad/ad_object.cpp | 2598 +++--- engines/wintermute/ad/ad_object.h | 248 +- engines/wintermute/ad/ad_path.cpp | 240 +- engines/wintermute/ad/ad_path.h | 112 +- engines/wintermute/ad/ad_path_point.cpp | 150 +- engines/wintermute/ad/ad_path_point.h | 100 +- engines/wintermute/ad/ad_region.cpp | 794 +- engines/wintermute/ad/ad_region.h | 116 +- engines/wintermute/ad/ad_response.cpp | 292 +- engines/wintermute/ad/ad_response.h | 122 +- engines/wintermute/ad/ad_response_box.cpp | 1424 ++-- engines/wintermute/ad/ad_response_box.h | 174 +- engines/wintermute/ad/ad_response_context.cpp | 142 +- engines/wintermute/ad/ad_response_context.h | 100 +- engines/wintermute/ad/ad_rot_level.cpp | 322 +- engines/wintermute/ad/ad_rot_level.h | 98 +- engines/wintermute/ad/ad_scale_level.cpp | 318 +- engines/wintermute/ad/ad_scale_level.h | 100 +- engines/wintermute/ad/ad_scene.cpp | 5972 ++++++------- engines/wintermute/ad/ad_scene.h | 362 +- engines/wintermute/ad/ad_scene_node.cpp | 164 +- engines/wintermute/ad/ad_scene_node.h | 108 +- engines/wintermute/ad/ad_scene_state.cpp | 190 +- engines/wintermute/ad/ad_scene_state.h | 102 +- engines/wintermute/ad/ad_sentence.cpp | 720 +- engines/wintermute/ad/ad_sentence.h | 170 +- engines/wintermute/ad/ad_sprite_set.cpp | 712 +- engines/wintermute/ad/ad_sprite_set.h | 106 +- engines/wintermute/ad/ad_talk_def.cpp | 570 +- engines/wintermute/ad/ad_talk_def.h | 116 +- engines/wintermute/ad/ad_talk_holder.cpp | 804 +- engines/wintermute/ad/ad_talk_holder.h | 114 +- engines/wintermute/ad/ad_talk_node.cpp | 590 +- engines/wintermute/ad/ad_talk_node.h | 126 +- engines/wintermute/ad/ad_types.h | 214 +- engines/wintermute/ad/ad_waypoint_group.cpp | 540 +- engines/wintermute/ad/ad_waypoint_group.h | 116 +- engines/wintermute/base/base.cpp | 370 +- engines/wintermute/base/base.h | 124 +- engines/wintermute/base/base_active_rect.cpp | 220 +- engines/wintermute/base/base_active_rect.h | 120 +- engines/wintermute/base/base_dynamic_buffer.cpp | 408 +- engines/wintermute/base/base_dynamic_buffer.h | 132 +- engines/wintermute/base/base_fader.cpp | 388 +- engines/wintermute/base/base_fader.h | 126 +- engines/wintermute/base/base_file_manager.cpp | 680 +- engines/wintermute/base/base_file_manager.h | 152 +- engines/wintermute/base/base_frame.cpp | 1520 ++-- engines/wintermute/base/base_frame.h | 146 +- engines/wintermute/base/base_game.cpp | 8966 ++++++++++---------- engines/wintermute/base/base_game.h | 724 +- engines/wintermute/base/base_keyboard_state.cpp | 618 +- engines/wintermute/base/base_keyboard_state.h | 150 +- engines/wintermute/base/base_named_object.cpp | 142 +- engines/wintermute/base/base_named_object.h | 102 +- engines/wintermute/base/base_object.cpp | 2492 +++--- engines/wintermute/base/base_object.h | 294 +- engines/wintermute/base/base_parser.cpp | 934 +- engines/wintermute/base/base_parser.h | 176 +- .../wintermute/base/base_persistence_manager.cpp | 1656 ++-- engines/wintermute/base/base_persistence_manager.h | 236 +- engines/wintermute/base/base_point.cpp | 126 +- engines/wintermute/base/base_point.h | 100 +- engines/wintermute/base/base_quick_msg.cpp | 114 +- engines/wintermute/base/base_quick_msg.h | 96 +- engines/wintermute/base/base_region.cpp | 1070 +-- engines/wintermute/base/base_region.h | 138 +- engines/wintermute/base/base_save_thumb_helper.cpp | 160 +- engines/wintermute/base/base_save_thumb_helper.h | 102 +- engines/wintermute/base/base_script_holder.cpp | 1004 +-- engines/wintermute/base/base_script_holder.h | 152 +- engines/wintermute/base/base_scriptable.cpp | 382 +- engines/wintermute/base/base_scriptable.h | 166 +- engines/wintermute/base/base_sprite.cpp | 1628 ++-- engines/wintermute/base/base_sprite.h | 180 +- engines/wintermute/base/base_string_table.cpp | 510 +- engines/wintermute/base/base_string_table.h | 110 +- engines/wintermute/base/base_sub_frame.cpp | 1310 +-- engines/wintermute/base/base_sub_frame.h | 184 +- engines/wintermute/base/base_surface_storage.cpp | 414 +- engines/wintermute/base/base_surface_storage.h | 114 +- .../wintermute/base/base_transition_manager.cpp | 272 +- engines/wintermute/base/base_transition_manager.h | 108 +- engines/wintermute/base/base_viewport.cpp | 196 +- engines/wintermute/base/base_viewport.h | 110 +- engines/wintermute/base/file/base_disk_file.cpp | 392 +- engines/wintermute/base/file/base_disk_file.h | 82 +- engines/wintermute/base/file/base_file.cpp | 136 +- engines/wintermute/base/file/base_file.h | 134 +- engines/wintermute/base/file/base_file_entry.cpp | 146 +- engines/wintermute/base/file/base_file_entry.h | 120 +- engines/wintermute/base/file/base_package.cpp | 552 +- engines/wintermute/base/file/base_package.h | 180 +- engines/wintermute/base/file/base_resources.cpp | 5660 ++++++------ engines/wintermute/base/file/base_resources.h | 90 +- .../wintermute/base/file/base_save_thumb_file.cpp | 308 +- .../wintermute/base/file/base_save_thumb_file.h | 104 +- engines/wintermute/base/file/dcpackage.h | 160 +- engines/wintermute/base/font/base_font.cpp | 280 +- engines/wintermute/base/font/base_font.h | 122 +- engines/wintermute/base/font/base_font_bitmap.cpp | 1178 +-- engines/wintermute/base/font/base_font_bitmap.h | 142 +- engines/wintermute/base/font/base_font_storage.cpp | 284 +- engines/wintermute/base/font/base_font_storage.h | 110 +- .../wintermute/base/font/base_font_truetype.cpp | 1210 +-- engines/wintermute/base/font/base_font_truetype.h | 304 +- engines/wintermute/base/gfx/base_image.cpp | 462 +- engines/wintermute/base/gfx/base_image.h | 144 +- engines/wintermute/base/gfx/base_renderer.cpp | 762 +- engines/wintermute/base/gfx/base_renderer.h | 442 +- engines/wintermute/base/gfx/base_surface.cpp | 298 +- engines/wintermute/base/gfx/base_surface.h | 198 +- .../base/gfx/osystem/base_render_osystem.cpp | 1208 +-- .../base/gfx/osystem/base_render_osystem.h | 262 +- .../base/gfx/osystem/base_surface_osystem.cpp | 858 +- .../base/gfx/osystem/base_surface_osystem.h | 198 +- engines/wintermute/base/particles/part_emitter.cpp | 2512 +++--- engines/wintermute/base/particles/part_emitter.h | 280 +- engines/wintermute/base/particles/part_force.cpp | 130 +- engines/wintermute/base/particles/part_force.h | 114 +- .../wintermute/base/particles/part_particle.cpp | 538 +- engines/wintermute/base/particles/part_particle.h | 180 +- engines/wintermute/base/scriptables/dcscript.h | 282 +- engines/wintermute/base/scriptables/script.cpp | 2934 +++---- engines/wintermute/base/scriptables/script.h | 348 +- .../wintermute/base/scriptables/script_engine.cpp | 1220 +-- .../wintermute/base/scriptables/script_engine.h | 270 +- .../base/scriptables/script_ext_array.cpp | 504 +- .../wintermute/base/scriptables/script_ext_array.h | 112 +- .../base/scriptables/script_ext_date.cpp | 586 +- .../wintermute/base/scriptables/script_ext_date.h | 108 +- .../base/scriptables/script_ext_file.cpp | 1658 ++-- .../wintermute/base/scriptables/script_ext_file.h | 132 +- .../base/scriptables/script_ext_math.cpp | 590 +- .../wintermute/base/scriptables/script_ext_math.h | 106 +- .../base/scriptables/script_ext_mem_buffer.cpp | 1058 +-- .../base/scriptables/script_ext_mem_buffer.h | 120 +- .../base/scriptables/script_ext_object.cpp | 134 +- .../base/scriptables/script_ext_object.h | 92 +- .../base/scriptables/script_ext_string.cpp | 872 +- .../base/scriptables/script_ext_string.h | 116 +- .../wintermute/base/scriptables/script_stack.cpp | 464 +- engines/wintermute/base/scriptables/script_stack.h | 132 +- .../wintermute/base/scriptables/script_value.cpp | 1990 ++--- engines/wintermute/base/scriptables/script_value.h | 226 +- engines/wintermute/base/sound/base_sound.cpp | 584 +- engines/wintermute/base/sound/base_sound.h | 174 +- .../wintermute/base/sound/base_sound_buffer.cpp | 594 +- engines/wintermute/base/sound/base_sound_buffer.h | 200 +- .../wintermute/base/sound/base_sound_manager.cpp | 564 +- engines/wintermute/base/sound/base_sound_manager.h | 136 +- engines/wintermute/coll_templ.h | 172 +- engines/wintermute/dcgf.h | 102 +- engines/wintermute/dctypes.h | 450 +- engines/wintermute/math/math_util.cpp | 104 +- engines/wintermute/math/math_util.h | 84 +- engines/wintermute/math/matrix4.cpp | 172 +- engines/wintermute/math/matrix4.h | 100 +- engines/wintermute/math/vector2.cpp | 110 +- engines/wintermute/math/vector2.h | 150 +- engines/wintermute/platform_osystem.cpp | 524 +- engines/wintermute/platform_osystem.h | 146 +- engines/wintermute/system/sys_class.cpp | 440 +- engines/wintermute/system/sys_class.h | 260 +- engines/wintermute/system/sys_class_registry.cpp | 670 +- engines/wintermute/system/sys_class_registry.h | 212 +- engines/wintermute/system/sys_instance.cpp | 98 +- engines/wintermute/system/sys_instance.h | 136 +- engines/wintermute/ui/ui_button.cpp | 2416 +++--- engines/wintermute/ui/ui_button.h | 160 +- engines/wintermute/ui/ui_edit.cpp | 1902 ++--- engines/wintermute/ui/ui_edit.h | 144 +- engines/wintermute/ui/ui_entity.cpp | 732 +- engines/wintermute/ui/ui_entity.h | 118 +- engines/wintermute/ui/ui_object.cpp | 1300 +-- engines/wintermute/ui/ui_object.h | 170 +- engines/wintermute/ui/ui_text.cpp | 1044 +-- engines/wintermute/ui/ui_text.h | 120 +- engines/wintermute/ui/ui_tiled_image.cpp | 786 +- engines/wintermute/ui/ui_tiled_image.h | 126 +- engines/wintermute/ui/ui_window.cpp | 2888 +++---- engines/wintermute/ui/ui_window.h | 188 +- engines/wintermute/utils/crc.cpp | 474 +- engines/wintermute/utils/crc.h | 170 +- engines/wintermute/utils/path_util.cpp | 202 +- engines/wintermute/utils/path_util.h | 98 +- engines/wintermute/utils/string_util.cpp | 464 +- engines/wintermute/utils/string_util.h | 112 +- engines/wintermute/utils/utils.cpp | 522 +- engines/wintermute/utils/utils.h | 128 +- engines/wintermute/wintypes.h | 106 +- 207 files changed, 59478 insertions(+), 59478 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 63b1532416..9087d66844 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -1,1460 +1,1460 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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_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/base/particles/part_emitter.h" -#include "engines/wintermute/base/base_engine.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdActor, false) - - -////////////////////////////////////////////////////////////////////////// -AdActor::AdActor(BaseGame *inGame) : AdTalkHolder(inGame) { - _path = new AdPath(_gameRef); - - _type = OBJECT_ACTOR; - _dir = DI_LEFT; - - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _targetPoint = new BasePoint; - _afterWalkDir = DI_NONE; - - _animSprite2 = NULL; - - setDefaultAnimNames(); -} - -////////////////////////////////////////////////////////////////////////// -bool AdActor::setDefaultAnimNames() { - _talkAnimName = "talk"; - _idleAnimName = "idle"; - _walkAnimName = "walk"; - _turnLeftAnimName = "turnleft"; - _turnRightAnimName = "turnright"; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -AdActor::~AdActor() { - 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 (uint32 i = 0; i < _talkSprites.size(); i++) { - delete _talkSprites[i]; - } - _talkSprites.clear(); - - for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - delete _talkSpritesEx[i]; - } - _talkSpritesEx.clear(); - - for (uint32 i = 0; i < _anims.size(); i++) { - delete _anims[i]; - _anims[i] = NULL; - } - _anims.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool AdActor::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdActor::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; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { - _gameRef->LOG(0, "'ACTOR' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - 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) { - 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 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 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 AdSpriteSet(_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 AdSpriteSet(_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 AdSpriteSet(_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 AdSpriteSet(_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 BaseSprite(_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; - BaseRegion *rgn = new BaseRegion(_gameRef); - BaseRegion *crgn = new BaseRegion(_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; - AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); - AdWaypointGroup *cwpt = new AdWaypointGroup(_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: { - AdSpriteSet *anim = new AdSpriteSet(_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 AdActor::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 AdActor::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; - - ((AdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); - - _state = STATE_SEARCHING_PATH; - -} - - -////////////////////////////////////////////////////////////////////////// -bool AdActor::display() { - if (_active) { - updateSounds(); - } - - uint32 alpha; - if (_alphaColor != 0) { - alpha = _alphaColor; - } else { - alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; - } - - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - - float rotate; - if (_rotatable) { - if (_rotateValid) { - rotate = _rotate; - } 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 && ((AdGame *)_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 AdActor::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 { - AdSpriteSet *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 { - AdSpriteSet *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 { - AdSpriteSet *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 (((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(); - } - 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; - ((AdGame *)_gameRef)->addSentence(_sentence); - } - } - } else { - _currentSprite = _tempSprite2; - ((AdGame *)_gameRef)->addSentence(_sentence); - } - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite && !_animSprite2) { - if (_sprite) { - _currentSprite = _sprite; - } else { - if (_standSprite) { - _currentSprite = _standSprite->getSprite(_dir); - } else { - AdSpriteSet *anim = getAnimByName(_idleAnimName); - if (anim) { - _currentSprite = anim->getSprite(_dir); - } - } - } - } - break; - default: - error("AdActor::Update - Unhandled enum"); - } - - - if (_currentSprite && !already_moved) { - _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; - afterMove(); - } - } - - //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); - - updateBlockRegion(); - _ready = (_state == STATE_READY); - - updatePartEmitter(); - updateSpriteAttachments(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void AdActor::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(BasePoint(_posX, _posY), *_path->getCurrent()); - } else { - if (_afterWalkDir != DI_NONE) { - turnTo(_afterWalkDir); - } else { - _state = STATE_READY; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdActor::getNextStep() { - if (_walkSprite) { - _currentSprite = _walkSprite->getSprite(_dir); - } else { - AdSpriteSet *anim = getAnimByName(_walkAnimName); - if (anim) { - _currentSprite = anim->getSprite(_dir); - } - } - - 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; - } - - - 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 (((AdGame *)_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(BasePoint(_posX, _posY), *_path->getCurrent()); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -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; - _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 AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); - 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) { - 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); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnTo / TurnToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { - stack->correctParams(1); - int dir; - ScValue *val = stack->pop(); - - // turn to object? - 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); - } - // 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 (uint32 i = 0; i < _anims.size(); 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; - } - - delete _anims[i]; - _anims[i] = NULL; - _anims.remove_at(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 AdTalkHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdActor::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 AdTalkHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdActor::scSetProperty(const char *name, ScValue *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 AdTalkHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdActor::scToString() { - return "[actor object]"; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSprite *AdActor::getTalkStance(const char *stance) { - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new BaseSprite(_gameRef, this); - if (_animSprite) { - bool res = _animSprite->loadFile(_forcedTalkAnimName); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else { - return _animSprite; - } - } - } - - // old way - if (_talkSprites.size() > 0 || _talkSpritesEx.size() > 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); - } - - // not - get a random talk - if (!ret) { - BaseArray talkAnims; - for (uint32 i = 0; i < _anims.size(); i++) { - if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) { - talkAnims.add(_anims[i]); - } - } - - if (talkAnims.size() > 0) { - int rnd = BaseEngine::instance().randInt(0, talkAnims.size() - 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; -} - -////////////////////////////////////////////////////////////////////////// -BaseSprite *AdActor::getTalkStanceOld(const char *stance) { - BaseSprite *ret = NULL; - - if (stance != NULL) { - // search special stances - for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { - ret = _talkSpritesEx[i]->getSprite(_dir); - break; - } - } - if (ret == NULL) { - // search generic stances - for (uint32 i = 0; i < _talkSprites.size(); i++) { - if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { - ret = _talkSprites[i]->getSprite(_dir); - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.size() < 1) { - ret = _standSprite->getSprite(_dir); - } else { - // TODO: remember last - int rnd = BaseEngine::instance().randInt(0, _talkSprites.size() - 1); - ret = _talkSprites[rnd]->getSprite(_dir); - } - } - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool AdActor::persist(BasePersistenceManager *persistMgr) { - AdTalkHolder::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 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; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -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); - } - } - } - // and get height - return AdTalkHolder::getHeight(); -} - - -////////////////////////////////////////////////////////////////////////// -AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { - for (uint32 i = 0; i < _anims.size(); i++) { - if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) { - return _anims[i]; - } - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool AdActor::mergeAnims(const char *animsFilename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - - byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename); - if (fileBuffer == NULL) { - _gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename); - return STATUS_FAILED; - } - - byte *buffer = fileBuffer; - byte *params; - int cmd; - BaseParser parser; - - bool ret = STATUS_OK; - - 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))) { - cmd = PARSERR_GENERIC; - ret = STATUS_FAILED; - } else { - _anims.add(anim); - } - } - break; - } - } - delete[] fileBuffer; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -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); - if (_animSprite2) { - _animSprite2->reset(); - _state = STATE_PLAYING_ANIM_SET; - return STATUS_OK; - } - } - // otherwise call the standard handler - return AdTalkHolder::playAnim(filename); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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_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/base/particles/part_emitter.h" +#include "engines/wintermute/base/base_engine.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdActor, false) + + +////////////////////////////////////////////////////////////////////////// +AdActor::AdActor(BaseGame *inGame) : AdTalkHolder(inGame) { + _path = new AdPath(_gameRef); + + _type = OBJECT_ACTOR; + _dir = DI_LEFT; + + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _targetPoint = new BasePoint; + _afterWalkDir = DI_NONE; + + _animSprite2 = NULL; + + setDefaultAnimNames(); +} + +////////////////////////////////////////////////////////////////////////// +bool AdActor::setDefaultAnimNames() { + _talkAnimName = "talk"; + _idleAnimName = "idle"; + _walkAnimName = "walk"; + _turnLeftAnimName = "turnleft"; + _turnRightAnimName = "turnright"; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +AdActor::~AdActor() { + 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 (uint32 i = 0; i < _talkSprites.size(); i++) { + delete _talkSprites[i]; + } + _talkSprites.clear(); + + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + delete _talkSpritesEx[i]; + } + _talkSpritesEx.clear(); + + for (uint32 i = 0; i < _anims.size(); i++) { + delete _anims[i]; + _anims[i] = NULL; + } + _anims.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool AdActor::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdActor::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; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + _gameRef->LOG(0, "'ACTOR' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + 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) { + 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 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 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 AdSpriteSet(_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 AdSpriteSet(_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 AdSpriteSet(_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 AdSpriteSet(_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 BaseSprite(_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; + BaseRegion *rgn = new BaseRegion(_gameRef); + BaseRegion *crgn = new BaseRegion(_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; + AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); + AdWaypointGroup *cwpt = new AdWaypointGroup(_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: { + AdSpriteSet *anim = new AdSpriteSet(_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 AdActor::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 AdActor::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; + + ((AdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + + _state = STATE_SEARCHING_PATH; + +} + + +////////////////////////////////////////////////////////////////////////// +bool AdActor::display() { + if (_active) { + updateSounds(); + } + + uint32 alpha; + if (_alphaColor != 0) { + alpha = _alphaColor; + } else { + alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + } + + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + + float rotate; + if (_rotatable) { + if (_rotateValid) { + rotate = _rotate; + } 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 && ((AdGame *)_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 AdActor::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 { + AdSpriteSet *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 { + AdSpriteSet *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 { + AdSpriteSet *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 (((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(); + } + 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; + ((AdGame *)_gameRef)->addSentence(_sentence); + } + } + } else { + _currentSprite = _tempSprite2; + ((AdGame *)_gameRef)->addSentence(_sentence); + } + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite && !_animSprite2) { + if (_sprite) { + _currentSprite = _sprite; + } else { + if (_standSprite) { + _currentSprite = _standSprite->getSprite(_dir); + } else { + AdSpriteSet *anim = getAnimByName(_idleAnimName); + if (anim) { + _currentSprite = anim->getSprite(_dir); + } + } + } + } + break; + default: + error("AdActor::Update - Unhandled enum"); + } + + + if (_currentSprite && !already_moved) { + _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; + afterMove(); + } + } + + //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); + + updateBlockRegion(); + _ready = (_state == STATE_READY); + + updatePartEmitter(); + updateSpriteAttachments(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void AdActor::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(BasePoint(_posX, _posY), *_path->getCurrent()); + } else { + if (_afterWalkDir != DI_NONE) { + turnTo(_afterWalkDir); + } else { + _state = STATE_READY; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdActor::getNextStep() { + if (_walkSprite) { + _currentSprite = _walkSprite->getSprite(_dir); + } else { + AdSpriteSet *anim = getAnimByName(_walkAnimName); + if (anim) { + _currentSprite = anim->getSprite(_dir); + } + } + + 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; + } + + + 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 (((AdGame *)_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(BasePoint(_posX, _posY), *_path->getCurrent()); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +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; + _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 AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); + 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) { + 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); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnTo / TurnToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { + stack->correctParams(1); + int dir; + ScValue *val = stack->pop(); + + // turn to object? + 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); + } + // 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 (uint32 i = 0; i < _anims.size(); 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; + } + + delete _anims[i]; + _anims[i] = NULL; + _anims.remove_at(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 AdTalkHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdActor::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 AdTalkHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdActor::scSetProperty(const char *name, ScValue *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 AdTalkHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdActor::scToString() { + return "[actor object]"; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSprite *AdActor::getTalkStance(const char *stance) { + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new BaseSprite(_gameRef, this); + if (_animSprite) { + bool res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else { + return _animSprite; + } + } + } + + // old way + if (_talkSprites.size() > 0 || _talkSpritesEx.size() > 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); + } + + // not - get a random talk + if (!ret) { + BaseArray talkAnims; + for (uint32 i = 0; i < _anims.size(); i++) { + if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) { + talkAnims.add(_anims[i]); + } + } + + if (talkAnims.size() > 0) { + int rnd = BaseEngine::instance().randInt(0, talkAnims.size() - 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; +} + +////////////////////////////////////////////////////////////////////////// +BaseSprite *AdActor::getTalkStanceOld(const char *stance) { + BaseSprite *ret = NULL; + + if (stance != NULL) { + // search special stances + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { + ret = _talkSpritesEx[i]->getSprite(_dir); + break; + } + } + if (ret == NULL) { + // search generic stances + for (uint32 i = 0; i < _talkSprites.size(); i++) { + if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { + ret = _talkSprites[i]->getSprite(_dir); + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.size() < 1) { + ret = _standSprite->getSprite(_dir); + } else { + // TODO: remember last + int rnd = BaseEngine::instance().randInt(0, _talkSprites.size() - 1); + ret = _talkSprites[rnd]->getSprite(_dir); + } + } + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool AdActor::persist(BasePersistenceManager *persistMgr) { + AdTalkHolder::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 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; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +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); + } + } + } + // and get height + return AdTalkHolder::getHeight(); +} + + +////////////////////////////////////////////////////////////////////////// +AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { + for (uint32 i = 0; i < _anims.size(); i++) { + if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) { + return _anims[i]; + } + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool AdActor::mergeAnims(const char *animsFilename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + + byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename); + if (fileBuffer == NULL) { + _gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename); + return STATUS_FAILED; + } + + byte *buffer = fileBuffer; + byte *params; + int cmd; + BaseParser parser; + + bool ret = STATUS_OK; + + 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))) { + cmd = PARSERR_GENERIC; + ret = STATUS_FAILED; + } else { + _anims.add(anim); + } + } + break; + } + } + delete[] fileBuffer; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +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); + if (_animSprite2) { + _animSprite2->reset(); + _state = STATE_PLAYING_ANIM_SET; + return STATUS_OK; + } + } + // otherwise call the standard handler + 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 370a91cc22..271e57cb85 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -1,108 +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 - */ - -#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/coll_templ.h" -#include "engines/wintermute/base/base_point.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "common/str.h" - -namespace Wintermute { - -class AdSpriteSet; -class AdPath; -class BaseSprite; -class AdActor : public AdTalkHolder { -public: - TDirection angleToDirection(int angle); - DECLARE_PERSISTENT(AdActor, AdTalkHolder) - virtual int getHeight(); - BaseSprite *getTalkStance(const char *stance); - virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); - 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; - - AdPath *_path; - AdSpriteSet *_walkSprite; - AdSpriteSet *_standSprite; - AdSpriteSet *_turnLeftSprite; - AdSpriteSet *_turnRightSprite; - BaseArray _talkSprites; - BaseArray _talkSpritesEx; - TDirection _dir; - // new anim system - Common::String _talkAnimName; - Common::String _idleAnimName; - Common::String _walkAnimName; - Common::String _turnLeftAnimName; - Common::String _turnRightAnimName; - BaseArray _anims; - virtual bool playAnim(const char *filename); - AdSpriteSet *getAnimByName(const Common::String &animName); - - // 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(); - - bool setDefaultAnimNames(); - BaseSprite *getTalkStanceOld(const char *stance); - bool mergeAnims(const char *animsFilename); - BaseSprite *_animSprite2; - - void initLine(BasePoint startPt, BasePoint endPt); - void getNextStep(); - void followPath(); - double _pFStepX; - double _pFStepY; - double _pFX; - double _pFY; - int _pFCount; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/coll_templ.h" +#include "engines/wintermute/base/base_point.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "common/str.h" + +namespace Wintermute { + +class AdSpriteSet; +class AdPath; +class BaseSprite; +class AdActor : public AdTalkHolder { +public: + TDirection angleToDirection(int angle); + DECLARE_PERSISTENT(AdActor, AdTalkHolder) + virtual int getHeight(); + BaseSprite *getTalkStance(const char *stance); + virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); + 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; + + AdPath *_path; + AdSpriteSet *_walkSprite; + AdSpriteSet *_standSprite; + AdSpriteSet *_turnLeftSprite; + AdSpriteSet *_turnRightSprite; + BaseArray _talkSprites; + BaseArray _talkSpritesEx; + TDirection _dir; + // new anim system + Common::String _talkAnimName; + Common::String _idleAnimName; + Common::String _walkAnimName; + Common::String _turnLeftAnimName; + Common::String _turnRightAnimName; + BaseArray _anims; + virtual bool playAnim(const char *filename); + AdSpriteSet *getAnimByName(const Common::String &animName); + + // 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(); + + bool setDefaultAnimNames(); + BaseSprite *getTalkStanceOld(const char *stance); + bool mergeAnims(const char *animsFilename); + BaseSprite *_animSprite2; + + void initLine(BasePoint startPt, BasePoint endPt); + void getNextStep(); + void followPath(); + double _pFStepX; + double _pFStepY; + double _pFX; + double _pFY; + int _pFCount; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 67a919dd6b..234af1fffa 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -1,1121 +1,1121 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 "engines/wintermute/base/particles/part_emitter.h" -#include "common/str.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdEntity, false) - -////////////////////////////////////////////////////////////////////////// -AdEntity::AdEntity(BaseGame *inGame) : AdTalkHolder(inGame) { - _type = OBJECT_ENTITY; - _subtype = ENTITY_NORMAL; - _region = NULL; - _item = NULL; - - _walkToX = _walkToY = 0; - _walkToDir = DI_NONE; - - _theora = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdEntity::~AdEntity() { - _gameRef->unregisterObject(_region); - - delete _theora; - _theora = NULL; - - delete[] _item; - _item = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdEntity::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdEntity::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; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { - _gameRef->LOG(0, "'ENTITY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - 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) { - 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 BaseSprite(_gameRef, this); - 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); - } - } - 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); - } - } - 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 BaseSprite(_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; - BaseRegion *rgn = new BaseRegion(_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; - BaseRegion *rgn = new BaseRegion(_gameRef); - BaseRegion *crgn = new BaseRegion(_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; - AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); - AdWaypointGroup *cwpt = new AdWaypointGroup(_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 BaseSprite(_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.", getName()); - } - - 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 && ((AdGame *)_gameRef)->isItemTaken(_item)) { - _active = false; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdEntity::display() { - if (_active) { - updateSounds(); - - uint32 alpha; - if (_alphaColor != 0) { - alpha = _alphaColor; - } else { - alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; - } - - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - float rotate; - if (_rotatable) { - 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; - } - - 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); - } 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 AdEntity::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; - } - ((AdGame *)_gameRef)->addSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((AdGame *)_gameRef)->addSentence(_sentence); - } - } - break; - default: // Silence unhandled enum-warning - break; - } - - - if (_currentSprite) { - _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_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 AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); - ScValue *valAlpha = stack->pop(); - int startTime = stack->pop()->getInt(); - - delete _theora; - _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); - //if (_scale>=0) _theora->_playZoom = _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 BaseRegion(_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 AdTalkHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdEntity::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 AdTalkHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdEntity::scSetProperty(const char *name, ScValue *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 AdTalkHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdEntity::scToString() { - return "[entity object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ENTITY {\n"); - 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()); - 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); - } - - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_subtype == ENTITY_NORMAL && _sprite && _sprite->getFilename()) { - buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->getFilename()); - } - - 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); - } - - - 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->getFilename()) { - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->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 (_scProp) { - _scProp->saveAsText(buffer, indent + 2); - } - - AdObject::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int AdEntity::getHeight() { - if (_region && !_sprite) { - return _region->_rect.bottom - _region->_rect.top; - } else { - if (_currentSprite == NULL) { - _currentSprite = _sprite; - } - return AdObject::getHeight(); - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdEntity::updatePosition() { - if (_region && !_sprite) { - _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; - _posY = _region->_rect.bottom; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdEntity::persist(BasePersistenceManager *persistMgr) { - AdTalkHolder::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 AdEntity::setItem(const char *itemName) { - BaseUtils::setString(&_item, itemName); -} - -////////////////////////////////////////////////////////////////////////// -bool AdEntity::setSprite(const char *filename) { - if (_currentSprite == _sprite) { - _currentSprite = NULL; - } - - delete _sprite; - _sprite = NULL; - BaseSprite *spr = new BaseSprite(_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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 "engines/wintermute/base/particles/part_emitter.h" +#include "common/str.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdEntity, false) + +////////////////////////////////////////////////////////////////////////// +AdEntity::AdEntity(BaseGame *inGame) : AdTalkHolder(inGame) { + _type = OBJECT_ENTITY; + _subtype = ENTITY_NORMAL; + _region = NULL; + _item = NULL; + + _walkToX = _walkToY = 0; + _walkToDir = DI_NONE; + + _theora = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdEntity::~AdEntity() { + _gameRef->unregisterObject(_region); + + delete _theora; + _theora = NULL; + + delete[] _item; + _item = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdEntity::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdEntity::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; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + _gameRef->LOG(0, "'ENTITY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + 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) { + 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 BaseSprite(_gameRef, this); + 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); + } + } + 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); + } + } + 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 BaseSprite(_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; + BaseRegion *rgn = new BaseRegion(_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; + BaseRegion *rgn = new BaseRegion(_gameRef); + BaseRegion *crgn = new BaseRegion(_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; + AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); + AdWaypointGroup *cwpt = new AdWaypointGroup(_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 BaseSprite(_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.", getName()); + } + + 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 && ((AdGame *)_gameRef)->isItemTaken(_item)) { + _active = false; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdEntity::display() { + if (_active) { + updateSounds(); + + uint32 alpha; + if (_alphaColor != 0) { + alpha = _alphaColor; + } else { + alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + } + + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + float rotate; + if (_rotatable) { + 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; + } + + 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); + } 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 AdEntity::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; + } + ((AdGame *)_gameRef)->addSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((AdGame *)_gameRef)->addSentence(_sentence); + } + } + break; + default: // Silence unhandled enum-warning + break; + } + + + if (_currentSprite) { + _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_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 AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); + ScValue *valAlpha = stack->pop(); + int startTime = stack->pop()->getInt(); + + delete _theora; + _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); + //if (_scale>=0) _theora->_playZoom = _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 BaseRegion(_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 AdTalkHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdEntity::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 AdTalkHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdEntity::scSetProperty(const char *name, ScValue *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 AdTalkHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdEntity::scToString() { + return "[entity object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY {\n"); + 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()); + 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); + } + + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->getFilename()) { + buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->getFilename()); + } + + 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); + } + + + 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->getFilename()) { + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->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 (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } + + AdObject::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int AdEntity::getHeight() { + if (_region && !_sprite) { + return _region->_rect.bottom - _region->_rect.top; + } else { + if (_currentSprite == NULL) { + _currentSprite = _sprite; + } + return AdObject::getHeight(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdEntity::updatePosition() { + if (_region && !_sprite) { + _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; + _posY = _region->_rect.bottom; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdEntity::persist(BasePersistenceManager *persistMgr) { + AdTalkHolder::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 AdEntity::setItem(const char *itemName) { + BaseUtils::setString(&_item, itemName); +} + +////////////////////////////////////////////////////////////////////////// +bool AdEntity::setSprite(const char *filename) { + if (_currentSprite == _sprite) { + _currentSprite = NULL; + } + + delete _sprite; + _sprite = NULL; + BaseSprite *spr = new BaseSprite(_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 index 2178563534..39dc133eef 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -1,68 +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 VideoTheoraPlayer; -class AdEntity : public AdTalkHolder { -public: - VideoTheoraPlayer *_theora; - bool setSprite(const char *filename); - int _walkToX; - int _walkToY; - TDirection _walkToDir; - void setItem(const char *itemName); - char *_item; - DECLARE_PERSISTENT(AdEntity, AdTalkHolder) - void updatePosition(); - virtual int getHeight(); - BaseRegion *_region; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - virtual bool update(); - virtual bool display(); - AdEntity(BaseGame *inGame); - virtual ~AdEntity(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - TEntityType _subtype; - - // 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(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 VideoTheoraPlayer; +class AdEntity : public AdTalkHolder { +public: + VideoTheoraPlayer *_theora; + bool setSprite(const char *filename); + int _walkToX; + int _walkToY; + TDirection _walkToDir; + void setItem(const char *itemName); + char *_item; + DECLARE_PERSISTENT(AdEntity, AdTalkHolder) + void updatePosition(); + virtual int getHeight(); + BaseRegion *_region; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool update(); + virtual bool display(); + AdEntity(BaseGame *inGame); + virtual ~AdEntity(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + TEntityType _subtype; + + // 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(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index f5d865d9f8..fe8a5991e2 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -1,2280 +1,2280 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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/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" -#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 "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdGame, true) - -////////////////////////////////////////////////////////////////////////// -AdGame::AdGame(const Common::String &gameId) : BaseGame(gameId) { - _responseBox = NULL; - _inventoryBox = NULL; - - _scene = new AdScene(_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 AdObject(this); - _inventoryOwner = _invObject; - - _tempDisableSaveState = false; - _itemsFile = NULL; - - _smartItemCursor = false; - - addSpeechDir("speech"); -} - - -////////////////////////////////////////////////////////////////////////// -AdGame::~AdGame() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::cleanup() { - for (uint32 i = 0; i < _objects.size(); i++) { - unregisterObject(_objects[i]); - _objects[i] = NULL; - } - _objects.clear(); - - - for (uint32 i = 0; i < _dlgPendingBranches.size(); i++) { - delete[] _dlgPendingBranches[i]; - } - _dlgPendingBranches.clear(); - - for (uint32 i = 0; i < _speechDirs.size(); i++) { - delete[] _speechDirs[i]; - } - _speechDirs.clear(); - - - unregisterObject(_scene); - _scene = NULL; - - // remove items - for (uint32 i = 0; i < _items.size(); i++) { - _gameRef->unregisterObject(_items[i]); - } - _items.clear(); - - - // clear remaining inventories - delete _invObject; - _invObject = NULL; - - for (uint32 i = 0; i < _inventories.size(); i++) { - delete _inventories[i]; - } - _inventories.clear(); - - - 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 (uint32 i = 0; i < _sceneStates.size(); i++) { - delete _sceneStates[i]; - } - _sceneStates.clear(); - - for (uint32 i = 0; i < _responsesBranch.size(); i++) { - delete _responsesBranch[i]; - } - _responsesBranch.clear(); - - for (uint32 i = 0; i < _responsesGame.size(); i++) { - delete _responsesGame[i]; - } - _responsesGame.clear(); - - return BaseGame::cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::initLoop() { - if (_scheduledScene && _transMgr->isReady()) { - changeScene(_scheduledScene, _scheduledFadeIn); - delete[] _scheduledScene; - _scheduledScene = NULL; - - _gameRef->_activeObject = NULL; - } - - - bool res; - res = BaseGame::initLoop(); - if (DID_FAIL(res)) { - return res; - } - - if (_scene) { - res = _scene->initLoop(); - } - - _sentences.clear(); - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::addObject(AdObject *object) { - _objects.add(object); - return registerObject(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; - } - } - - for (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i] == object) { - _objects.remove_at(i); - break; - } - } - return unregisterObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::changeScene(const char *filename, bool fadeIn) { - if (_scene == NULL) { - _scene = new AdScene(_gameRef); - registerObject(_scene); - } else { - _scene->applyEvent("SceneShutdown", true); - - setPrevSceneName(_scene->getName()); - setPrevSceneFilename(_scene->getFilename()); - - if (!_tempDisableSaveState) { - _scene->saveState(); - } - _tempDisableSaveState = false; - } - - if (_scene) { - // reset objects - for (uint32 i = 0; i < _objects.size(); 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 (uint32 i = 0; i < _objects.size(); 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 AdGame::addSentence(AdSentence *sentence) { - _sentences.add(sentence); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::displaySentences(bool frozen) { - for (uint32 i = 0; i < _sentences.size(); i++) { - if (frozen && _sentences[i]->_freezable) { - continue; - } else { - _sentences[i]->display(); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void AdGame::finishSentences() { - for (uint32 i = 0; i < _sentences.size(); i++) { - if (_sentences[i]->canSkip()) { - _sentences[i]->_duration = 0; - if (_sentences[i]->_sound) { - _sentences[i]->_sound->stop(); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -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(); - ScValue *valFadeOut = stack->pop(); - ScValue *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); - AdActor *act = new AdActor(_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); - AdEntity *ent = new AdEntity(_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); - ScValue *val = stack->pop(); - AdObject *obj = (AdObject *)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); - ScValue *val = stack->pop(); - - AdEntity *ent = new AdEntity(_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); - ScValue *val = stack->pop(); - - AdItem *item = new AdItem(_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); - ScValue *val = stack->pop(); - - AdItem *item = NULL; - if (val->isNative()) { - item = (AdItem *)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); - ScValue *val = stack->pop(); - - AdItem *item = NULL; - if (val->isInt()) { - int index = val->getInt(); - if (index >= 0 && index < (int32)_items.size()) { - 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(); - ScValue *val1 = stack->pop(); - ScValue *val2 = stack->pop(); - ScValue *val3 = stack->pop(); - ScValue *val4 = stack->pop(); - - if (_responseBox) { - AdResponse *res = new AdResponse(_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.size() == 0) { - stack->pushNULL(); - return STATUS_OK; - } - - - if (_responseBox->_responses.size() == 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.size()); - } 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); - ScValue *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; - ScValue *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.size() > 0) { - stack->pushString(_dlgPendingBranches[_dlgPendingBranches.size() - 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); - - ScValue *val = stack->pop(); - if (!val->isNULL()) { - for (uint32 i = 0; i < _inventories.size(); i++) { - AdInventory *inv = _inventories[i]; - - for (uint32 j = 0; j < inv->_takenItems.size(); j++) { - if (val->getNative() == inv->_takenItems[j]) { - stack->pushBool(true); - return STATUS_OK; - } else if (scumm_stricmp(val->getString(), inv->_takenItems[j]->getName()) == 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 AdResponseBox(_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 AdInventoryBox(_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 BaseViewport(_gameRef); - } - if (_sceneViewport) { - _sceneViewport->setRect(x, y, x + width, y + height); - } - - stack->pushBool(true); - - return STATUS_OK; - } - - - else { - return BaseGame::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdGame::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.size()); - 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 BaseGame::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::scSetProperty(const char *name, ScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SelectedItem") == 0) { - if (value->isNULL()) { - _selectedItem = NULL; - } else { - if (value->isNative()) { - _selectedItem = NULL; - for (uint32 i = 0; i < _items.size(); i++) { - if (_items[i] == value->getNative()) { - _selectedItem = (AdItem *)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 { - 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; - } - - 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 { - BaseUtils::setString(&_startupScene, value->getString()); - } - - return STATUS_OK; - } - - else { - return BaseGame::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { - ScValue *thisObj; - - ////////////////////////////////////////////////////////////////////////// - // Actor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Actor") == 0) { - stack->correctParams(0); - thisObj = thisStack->getTop(); - - thisObj->setNative(new AdActor(_gameRef)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Entity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Entity") == 0) { - stack->correctParams(0); - thisObj = thisStack->getTop(); - - thisObj->setNative(new AdEntity(_gameRef)); - stack->pushNULL(); - } - - - ////////////////////////////////////////////////////////////////////////// - // call parent - else { - return BaseGame::externalCall(script, stack, thisStack, name); - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::showCursor() { - if (_cursorHidden) { - return STATUS_OK; - } - - if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { - if (_selectedItem->_cursorCombined) { - BaseSprite *origLastCursor = _lastCursor; - BaseGame::showCursor(); - _lastCursor = origLastCursor; - } - if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->getName())) { - return drawCursor(_selectedItem->_cursorHover); - } else { - return drawCursor(_selectedItem->_cursorNormal); - } - } else { - return drawCursor(_selectedItem->_cursorNormal); - } - } else { - return BaseGame::showCursor(); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdGame::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; - BaseParser parser; - - 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(BaseGame::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 AdResponseBox(_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 AdInventoryBox(_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; - BaseUtils::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 BaseViewport(_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: - BaseUtils::setString(&_startupScene, (char *)params2); - break; - - case TOKEN_DEBUG_STARTUP_SCENE: - BaseUtils::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 AdGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) { - cleanup(); - } - BaseGame::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->getIsSaving()) { - _initialScene = false; - } - - persistMgr->transfer(TMEMBER(_startupScene)); - - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void AdGame::setPrevSceneName(const char *name) { - delete[] _prevSceneName; - _prevSceneName = NULL; - if (name) { - _prevSceneName = new char[strlen(name) + 1]; - if (_prevSceneName) { - strcpy(_prevSceneName, name); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdGame::setPrevSceneFilename(const char *name) { - delete[] _prevSceneFilename; - _prevSceneFilename = NULL; - if (name) { - _prevSceneFilename = new char[strlen(name) + 1]; - if (_prevSceneFilename) { - strcpy(_prevSceneFilename, name); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::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 AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - BaseGame::getVersion(verMajor, verMinor, NULL, NULL); - - if (extMajor) { - *extMajor = 0; - } - if (extMinor) { - *extMinor = 0; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::loadItemsFile(const char *filename, bool merge) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdGame::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 AdGame::loadItemsBuffer(byte *buffer, bool merge) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE_END - - byte *params; - int cmd; - BaseParser parser; - - if (!merge) { - while (_items.size() > 0) { - deleteItem(_items[0]); - } - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ITEM: { - AdItem *item = new AdItem(_gameRef); - 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); - } - } - 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; -} - - -////////////////////////////////////////////////////////////////////////// -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] = '\\'; - } - } - - for (uint32 i = 0; i < _sceneStates.size(); i++) { - if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { - delete[] filenameCor; - return _sceneStates[i]; - } - } - - if (saving) { - AdSceneState *ret = new AdSceneState(_gameRef); - ret->setFilename(filenameCor); - - _sceneStates.add(ret); - - delete[] filenameCor; - return ret; - } else { - delete[] filenameCor; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE_END - - int cmd = PARSERR_GENERIC; - BaseParser parser; - - cmd = parser.getCommand(buffer, commands, params); - switch (cmd) { - case TOKEN_ENTITY_CONTAINER: { - UIEntity *ent = new UIEntity(_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 AdGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { - if (strcmp(name, "CreateEntityContainer") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - UIEntity *ent = new UIEntity(_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 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); - _dlgPendingBranches.add(name); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { - char *name = NULL; - bool deleteName = false; - 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]; - 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.size() - 1; i >= 0; i--) { - if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { - startIndex = i; - break; - } - } - if (startIndex >= 0) { - for (uint32 i = startIndex; i < _dlgPendingBranches.size(); i++) { - //ClearBranchResponses(_dlgPendingBranches[i]); - delete[] _dlgPendingBranches[i]; - _dlgPendingBranches[i] = NULL; - } - _dlgPendingBranches.remove_at(startIndex, _dlgPendingBranches.size() - startIndex); - } - - // dialogue is over, forget selected responses - if (_dlgPendingBranches.size() == 0) { - for (uint32 i = 0; i < _responsesBranch.size(); i++) { - delete _responsesBranch[i]; - } - _responsesBranch.clear(); - } - - if (deleteName) { - delete[] name; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::clearBranchResponses(char *name) { - for (uint32 i = 0; i < _responsesBranch.size(); i++) { - if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.remove_at(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::addBranchResponse(int id) { - if (branchResponseUsed(id)) { - return STATUS_OK; - } - AdResponseContext *r = new AdResponseContext(_gameRef); - r->_id = id; - r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); - _responsesBranch.add(r); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::branchResponseUsed(int id) { - 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; - } - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::addGameResponse(int id) { - if (gameResponseUsed(id)) { - return STATUS_OK; - } - AdResponseContext *r = new AdResponseContext(_gameRef); - r->_id = id; - r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); - _responsesGame.add(r); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::gameResponseUsed(int id) { - 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)) { - return true; - } - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::resetResponse(int id) { - char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; - - 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]; - _responsesGame.remove_at(i); - break; - } - } - } - - 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]; - _responsesBranch.remove_at(i); - break; - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::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(); - } - _renderer->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 AdGame::registerInventory(AdInventory *inv) { - for (uint32 i = 0; i < _inventories.size(); i++) { - if (_inventories[i] == inv) { - return STATUS_OK; - } - } - registerObject(inv); - _inventories.add(inv); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdGame::unregisterInventory(AdInventory *inv) { - for (uint32 i = 0; i < _inventories.size(); i++) { - if (_inventories[i] == inv) { - unregisterObject(_inventories[i]); - _inventories.remove_at(i); - return STATUS_OK; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdGame::isItemTaken(char *itemName) { - for (uint32 i = 0; i < _inventories.size(); i++) { - AdInventory *inv = _inventories[i]; - - for (uint32 j = 0; j < inv->_takenItems.size(); j++) { - if (scumm_stricmp(itemName, inv->_takenItems[j]->getName()) == 0) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -AdItem *AdGame::getItemByName(const char *name) { - for (uint32 i = 0; i < _items.size(); i++) { - if (scumm_stricmp(_items[i]->getName(), name) == 0) { - return _items[i]; - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::addItem(AdItem *item) { - _items.add(item); - return _gameRef->registerObject(item); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::resetContent() { - // clear pending dialogs - for (uint32 i = 0; i < _dlgPendingBranches.size(); i++) { - delete[] _dlgPendingBranches[i]; - } - _dlgPendingBranches.clear(); - - - // clear inventories - for (uint32 i = 0; i < _inventories.size(); i++) { - _inventories[i]->_takenItems.clear(); - } - - // clear scene states - for (uint32 i = 0; i < _sceneStates.size(); i++) { - delete _sceneStates[i]; - } - _sceneStates.clear(); - - // clear once responses - for (uint32 i = 0; i < _responsesBranch.size(); i++) { - delete _responsesBranch[i]; - } - _responsesBranch.clear(); - - // clear once game responses - for (uint32 i = 0; i < _responsesGame.size(); i++) { - delete _responsesGame[i]; - } - _responsesGame.clear(); - - // reload inventory items - if (_itemsFile) { - loadItemsFile(_itemsFile); - } - - _tempDisableSaveState = true; - - return BaseGame::resetContent(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::deleteItem(AdItem *item) { - if (!item) { - return STATUS_FAILED; - } - - if (_selectedItem == item) { - _selectedItem = NULL; - } - _scene->handleItemAssociations(item->getName(), false); - - // remove from all inventories - for (uint32 i = 0; i < _inventories.size(); i++) { - _inventories[i]->removeItem(item); - } - - // remove object - for (uint32 i = 0; i < _items.size(); i++) { - if (_items[i] == item) { - unregisterObject(_items[i]); - _items.remove_at(i); - break; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::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 (uint32 i = 0; i < _speechDirs.size(); i++) { - if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete[] temp; - return STATUS_OK; - } - } - _speechDirs.add(temp); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::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 (uint32 i = 0; i < _speechDirs.size(); i++) { - if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete[] _speechDirs[i]; - _speechDirs.remove_at(i); - found = true; - break; - } - } - delete[] temp; - - return found; -} - - -////////////////////////////////////////////////////////////////////////// -char *AdGame::findSpeechFile(char *stringID) { - char *ret = new char[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _speechDirs.size(); i++) { - sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); - if (BaseFileManager::getEngineInstance()->hasFile(ret)) { - return ret; - } - - sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); - if (BaseFileManager::getEngineInstance()->hasFile(ret)) { - return ret; - } - } - delete[] ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::validMouse() { - Point32 pos; - BasePlatform::getCursorPos(&pos); - - return _renderer->pointInViewport(&pos); -} - -////////////////////////////////////////////////////////////////////////// -bool AdGame::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; - BasePlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdGame::onMouseLeftUp() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - } - - BasePlatform::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 AdGame::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 AdGame::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 AdGame::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 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()); - _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); - - 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(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdGame::onScriptShutdown(ScScript *script) { - if (_responseBox && _responseBox->_waitingScript == script) { - _responseBox->_waitingScript = NULL; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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/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" +#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 "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdGame, true) + +////////////////////////////////////////////////////////////////////////// +AdGame::AdGame(const Common::String &gameId) : BaseGame(gameId) { + _responseBox = NULL; + _inventoryBox = NULL; + + _scene = new AdScene(_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 AdObject(this); + _inventoryOwner = _invObject; + + _tempDisableSaveState = false; + _itemsFile = NULL; + + _smartItemCursor = false; + + addSpeechDir("speech"); +} + + +////////////////////////////////////////////////////////////////////////// +AdGame::~AdGame() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::cleanup() { + for (uint32 i = 0; i < _objects.size(); i++) { + unregisterObject(_objects[i]); + _objects[i] = NULL; + } + _objects.clear(); + + + for (uint32 i = 0; i < _dlgPendingBranches.size(); i++) { + delete[] _dlgPendingBranches[i]; + } + _dlgPendingBranches.clear(); + + for (uint32 i = 0; i < _speechDirs.size(); i++) { + delete[] _speechDirs[i]; + } + _speechDirs.clear(); + + + unregisterObject(_scene); + _scene = NULL; + + // remove items + for (uint32 i = 0; i < _items.size(); i++) { + _gameRef->unregisterObject(_items[i]); + } + _items.clear(); + + + // clear remaining inventories + delete _invObject; + _invObject = NULL; + + for (uint32 i = 0; i < _inventories.size(); i++) { + delete _inventories[i]; + } + _inventories.clear(); + + + 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 (uint32 i = 0; i < _sceneStates.size(); i++) { + delete _sceneStates[i]; + } + _sceneStates.clear(); + + for (uint32 i = 0; i < _responsesBranch.size(); i++) { + delete _responsesBranch[i]; + } + _responsesBranch.clear(); + + for (uint32 i = 0; i < _responsesGame.size(); i++) { + delete _responsesGame[i]; + } + _responsesGame.clear(); + + return BaseGame::cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::initLoop() { + if (_scheduledScene && _transMgr->isReady()) { + changeScene(_scheduledScene, _scheduledFadeIn); + delete[] _scheduledScene; + _scheduledScene = NULL; + + _gameRef->_activeObject = NULL; + } + + + bool res; + res = BaseGame::initLoop(); + if (DID_FAIL(res)) { + return res; + } + + if (_scene) { + res = _scene->initLoop(); + } + + _sentences.clear(); + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::addObject(AdObject *object) { + _objects.add(object); + return registerObject(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; + } + } + + for (uint32 i = 0; i < _objects.size(); i++) { + if (_objects[i] == object) { + _objects.remove_at(i); + break; + } + } + return unregisterObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::changeScene(const char *filename, bool fadeIn) { + if (_scene == NULL) { + _scene = new AdScene(_gameRef); + registerObject(_scene); + } else { + _scene->applyEvent("SceneShutdown", true); + + setPrevSceneName(_scene->getName()); + setPrevSceneFilename(_scene->getFilename()); + + if (!_tempDisableSaveState) { + _scene->saveState(); + } + _tempDisableSaveState = false; + } + + if (_scene) { + // reset objects + for (uint32 i = 0; i < _objects.size(); 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 (uint32 i = 0; i < _objects.size(); 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 AdGame::addSentence(AdSentence *sentence) { + _sentences.add(sentence); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::displaySentences(bool frozen) { + for (uint32 i = 0; i < _sentences.size(); i++) { + if (frozen && _sentences[i]->_freezable) { + continue; + } else { + _sentences[i]->display(); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void AdGame::finishSentences() { + for (uint32 i = 0; i < _sentences.size(); i++) { + if (_sentences[i]->canSkip()) { + _sentences[i]->_duration = 0; + if (_sentences[i]->_sound) { + _sentences[i]->_sound->stop(); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +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(); + ScValue *valFadeOut = stack->pop(); + ScValue *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); + AdActor *act = new AdActor(_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); + AdEntity *ent = new AdEntity(_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); + ScValue *val = stack->pop(); + AdObject *obj = (AdObject *)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); + ScValue *val = stack->pop(); + + AdEntity *ent = new AdEntity(_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); + ScValue *val = stack->pop(); + + AdItem *item = new AdItem(_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); + ScValue *val = stack->pop(); + + AdItem *item = NULL; + if (val->isNative()) { + item = (AdItem *)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); + ScValue *val = stack->pop(); + + AdItem *item = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < (int32)_items.size()) { + 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(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + ScValue *val3 = stack->pop(); + ScValue *val4 = stack->pop(); + + if (_responseBox) { + AdResponse *res = new AdResponse(_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.size() == 0) { + stack->pushNULL(); + return STATUS_OK; + } + + + if (_responseBox->_responses.size() == 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.size()); + } 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); + ScValue *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; + ScValue *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.size() > 0) { + stack->pushString(_dlgPendingBranches[_dlgPendingBranches.size() - 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); + + ScValue *val = stack->pop(); + if (!val->isNULL()) { + for (uint32 i = 0; i < _inventories.size(); i++) { + AdInventory *inv = _inventories[i]; + + for (uint32 j = 0; j < inv->_takenItems.size(); j++) { + if (val->getNative() == inv->_takenItems[j]) { + stack->pushBool(true); + return STATUS_OK; + } else if (scumm_stricmp(val->getString(), inv->_takenItems[j]->getName()) == 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 AdResponseBox(_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 AdInventoryBox(_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 BaseViewport(_gameRef); + } + if (_sceneViewport) { + _sceneViewport->setRect(x, y, x + width, y + height); + } + + stack->pushBool(true); + + return STATUS_OK; + } + + + else { + return BaseGame::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdGame::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.size()); + 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 BaseGame::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::scSetProperty(const char *name, ScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SelectedItem") == 0) { + if (value->isNULL()) { + _selectedItem = NULL; + } else { + if (value->isNative()) { + _selectedItem = NULL; + for (uint32 i = 0; i < _items.size(); i++) { + if (_items[i] == value->getNative()) { + _selectedItem = (AdItem *)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 { + 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; + } + + 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 { + BaseUtils::setString(&_startupScene, value->getString()); + } + + return STATUS_OK; + } + + else { + return BaseGame::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { + ScValue *thisObj; + + ////////////////////////////////////////////////////////////////////////// + // Actor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Actor") == 0) { + stack->correctParams(0); + thisObj = thisStack->getTop(); + + thisObj->setNative(new AdActor(_gameRef)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Entity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Entity") == 0) { + stack->correctParams(0); + thisObj = thisStack->getTop(); + + thisObj->setNative(new AdEntity(_gameRef)); + stack->pushNULL(); + } + + + ////////////////////////////////////////////////////////////////////////// + // call parent + else { + return BaseGame::externalCall(script, stack, thisStack, name); + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::showCursor() { + if (_cursorHidden) { + return STATUS_OK; + } + + if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { + if (_selectedItem->_cursorCombined) { + BaseSprite *origLastCursor = _lastCursor; + BaseGame::showCursor(); + _lastCursor = origLastCursor; + } + if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { + if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->getName())) { + return drawCursor(_selectedItem->_cursorHover); + } else { + return drawCursor(_selectedItem->_cursorNormal); + } + } else { + return drawCursor(_selectedItem->_cursorNormal); + } + } else { + return BaseGame::showCursor(); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdGame::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; + BaseParser parser; + + 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(BaseGame::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 AdResponseBox(_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 AdInventoryBox(_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; + BaseUtils::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 BaseViewport(_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: + BaseUtils::setString(&_startupScene, (char *)params2); + break; + + case TOKEN_DEBUG_STARTUP_SCENE: + BaseUtils::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 AdGame::persist(BasePersistenceManager *persistMgr) { + if (!persistMgr->getIsSaving()) { + cleanup(); + } + BaseGame::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->getIsSaving()) { + _initialScene = false; + } + + persistMgr->transfer(TMEMBER(_startupScene)); + + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void AdGame::setPrevSceneName(const char *name) { + delete[] _prevSceneName; + _prevSceneName = NULL; + if (name) { + _prevSceneName = new char[strlen(name) + 1]; + if (_prevSceneName) { + strcpy(_prevSceneName, name); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdGame::setPrevSceneFilename(const char *name) { + delete[] _prevSceneFilename; + _prevSceneFilename = NULL; + if (name) { + _prevSceneFilename = new char[strlen(name) + 1]; + if (_prevSceneFilename) { + strcpy(_prevSceneFilename, name); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::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 AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + BaseGame::getVersion(verMajor, verMinor, NULL, NULL); + + if (extMajor) { + *extMajor = 0; + } + if (extMinor) { + *extMinor = 0; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::loadItemsFile(const char *filename, bool merge) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdGame::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 AdGame::loadItemsBuffer(byte *buffer, bool merge) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE_END + + byte *params; + int cmd; + BaseParser parser; + + if (!merge) { + while (_items.size() > 0) { + deleteItem(_items[0]); + } + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ITEM: { + AdItem *item = new AdItem(_gameRef); + 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); + } + } + 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; +} + + +////////////////////////////////////////////////////////////////////////// +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] = '\\'; + } + } + + for (uint32 i = 0; i < _sceneStates.size(); i++) { + if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { + delete[] filenameCor; + return _sceneStates[i]; + } + } + + if (saving) { + AdSceneState *ret = new AdSceneState(_gameRef); + ret->setFilename(filenameCor); + + _sceneStates.add(ret); + + delete[] filenameCor; + return ret; + } else { + delete[] filenameCor; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE_END + + int cmd = PARSERR_GENERIC; + BaseParser parser; + + cmd = parser.getCommand(buffer, commands, params); + switch (cmd) { + case TOKEN_ENTITY_CONTAINER: { + UIEntity *ent = new UIEntity(_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 AdGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { + if (strcmp(name, "CreateEntityContainer") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + UIEntity *ent = new UIEntity(_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 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); + _dlgPendingBranches.add(name); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { + char *name = NULL; + bool deleteName = false; + 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]; + 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.size() - 1; i >= 0; i--) { + if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { + startIndex = i; + break; + } + } + if (startIndex >= 0) { + for (uint32 i = startIndex; i < _dlgPendingBranches.size(); i++) { + //ClearBranchResponses(_dlgPendingBranches[i]); + delete[] _dlgPendingBranches[i]; + _dlgPendingBranches[i] = NULL; + } + _dlgPendingBranches.remove_at(startIndex, _dlgPendingBranches.size() - startIndex); + } + + // dialogue is over, forget selected responses + if (_dlgPendingBranches.size() == 0) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { + delete _responsesBranch[i]; + } + _responsesBranch.clear(); + } + + if (deleteName) { + delete[] name; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::clearBranchResponses(char *name) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { + if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.remove_at(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::addBranchResponse(int id) { + if (branchResponseUsed(id)) { + return STATUS_OK; + } + AdResponseContext *r = new AdResponseContext(_gameRef); + r->_id = id; + r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); + _responsesBranch.add(r); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::branchResponseUsed(int id) { + 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; + } + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::addGameResponse(int id) { + if (gameResponseUsed(id)) { + return STATUS_OK; + } + AdResponseContext *r = new AdResponseContext(_gameRef); + r->_id = id; + r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); + _responsesGame.add(r); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::gameResponseUsed(int id) { + 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)) { + return true; + } + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::resetResponse(int id) { + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; + + 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]; + _responsesGame.remove_at(i); + break; + } + } + } + + 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]; + _responsesBranch.remove_at(i); + break; + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::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(); + } + _renderer->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 AdGame::registerInventory(AdInventory *inv) { + for (uint32 i = 0; i < _inventories.size(); i++) { + if (_inventories[i] == inv) { + return STATUS_OK; + } + } + registerObject(inv); + _inventories.add(inv); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdGame::unregisterInventory(AdInventory *inv) { + for (uint32 i = 0; i < _inventories.size(); i++) { + if (_inventories[i] == inv) { + unregisterObject(_inventories[i]); + _inventories.remove_at(i); + return STATUS_OK; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdGame::isItemTaken(char *itemName) { + for (uint32 i = 0; i < _inventories.size(); i++) { + AdInventory *inv = _inventories[i]; + + for (uint32 j = 0; j < inv->_takenItems.size(); j++) { + if (scumm_stricmp(itemName, inv->_takenItems[j]->getName()) == 0) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +AdItem *AdGame::getItemByName(const char *name) { + for (uint32 i = 0; i < _items.size(); i++) { + if (scumm_stricmp(_items[i]->getName(), name) == 0) { + return _items[i]; + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::addItem(AdItem *item) { + _items.add(item); + return _gameRef->registerObject(item); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::resetContent() { + // clear pending dialogs + for (uint32 i = 0; i < _dlgPendingBranches.size(); i++) { + delete[] _dlgPendingBranches[i]; + } + _dlgPendingBranches.clear(); + + + // clear inventories + for (uint32 i = 0; i < _inventories.size(); i++) { + _inventories[i]->_takenItems.clear(); + } + + // clear scene states + for (uint32 i = 0; i < _sceneStates.size(); i++) { + delete _sceneStates[i]; + } + _sceneStates.clear(); + + // clear once responses + for (uint32 i = 0; i < _responsesBranch.size(); i++) { + delete _responsesBranch[i]; + } + _responsesBranch.clear(); + + // clear once game responses + for (uint32 i = 0; i < _responsesGame.size(); i++) { + delete _responsesGame[i]; + } + _responsesGame.clear(); + + // reload inventory items + if (_itemsFile) { + loadItemsFile(_itemsFile); + } + + _tempDisableSaveState = true; + + return BaseGame::resetContent(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::deleteItem(AdItem *item) { + if (!item) { + return STATUS_FAILED; + } + + if (_selectedItem == item) { + _selectedItem = NULL; + } + _scene->handleItemAssociations(item->getName(), false); + + // remove from all inventories + for (uint32 i = 0; i < _inventories.size(); i++) { + _inventories[i]->removeItem(item); + } + + // remove object + for (uint32 i = 0; i < _items.size(); i++) { + if (_items[i] == item) { + unregisterObject(_items[i]); + _items.remove_at(i); + break; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::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 (uint32 i = 0; i < _speechDirs.size(); i++) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete[] temp; + return STATUS_OK; + } + } + _speechDirs.add(temp); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::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 (uint32 i = 0; i < _speechDirs.size(); i++) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete[] _speechDirs[i]; + _speechDirs.remove_at(i); + found = true; + break; + } + } + delete[] temp; + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +char *AdGame::findSpeechFile(char *stringID) { + char *ret = new char[MAX_PATH_LENGTH]; + + for (uint32 i = 0; i < _speechDirs.size(); i++) { + sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); + if (BaseFileManager::getEngineInstance()->hasFile(ret)) { + return ret; + } + + sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); + if (BaseFileManager::getEngineInstance()->hasFile(ret)) { + return ret; + } + } + delete[] ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::validMouse() { + Point32 pos; + BasePlatform::getCursorPos(&pos); + + return _renderer->pointInViewport(&pos); +} + +////////////////////////////////////////////////////////////////////////// +bool AdGame::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; + BasePlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdGame::onMouseLeftUp() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + } + + BasePlatform::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 AdGame::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 AdGame::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 AdGame::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 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()); + _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); + + 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(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdGame::onScriptShutdown(ScScript *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 index 5707ec48fd..46427331bf 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -1,163 +1,163 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 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(ScScript *script); - - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - - virtual bool displayDebugInfo(); - - bool addSpeechDir(const char *dir); - bool removeSpeechDir(const char *dir); - char *findSpeechFile(char *StringID); - - bool deleteItem(AdItem *Item); - char *_itemsFile; - bool _tempDisableSaveState; - virtual bool resetContent(); - bool addItem(AdItem *item); - AdItem *getItemByName(const char *name); - - AdObject *_inventoryOwner; - bool isItemTaken(char *itemName); - bool registerInventory(AdInventory *inv); - bool unregisterInventory(AdInventory *inv); - virtual bool displayContent(bool update = true, bool displayAll = false); - - 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(UIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); - - AdSceneState *getSceneState(const char *filename, bool saving); - BaseViewport *_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); - void setPrevSceneName(const char *name); - void setPrevSceneFilename(const char *name); - - AdItem *_selectedItem; - bool cleanup(); - DECLARE_PERSISTENT(AdGame, BaseGame) - - void finishSentences(); - bool showCursor(); - - TGameStateEx _stateEx; - - bool displaySentences(bool frozen); - void addSentence(AdSentence *sentence); - bool changeScene(const char *filename, bool fadeIn); - bool removeObject(AdObject *object); - bool addObject(AdObject *object); - AdScene *_scene; - bool initLoop(); - AdGame(const Common::String &gameId); - virtual ~AdGame(); - - BaseArray _objects; - - 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); - - // 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 - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 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(ScScript *script); + + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + + virtual bool displayDebugInfo(); + + bool addSpeechDir(const char *dir); + bool removeSpeechDir(const char *dir); + char *findSpeechFile(char *StringID); + + bool deleteItem(AdItem *Item); + char *_itemsFile; + bool _tempDisableSaveState; + virtual bool resetContent(); + bool addItem(AdItem *item); + AdItem *getItemByName(const char *name); + + AdObject *_inventoryOwner; + bool isItemTaken(char *itemName); + bool registerInventory(AdInventory *inv); + bool unregisterInventory(AdInventory *inv); + virtual bool displayContent(bool update = true, bool displayAll = false); + + 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(UIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); + + AdSceneState *getSceneState(const char *filename, bool saving); + BaseViewport *_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); + void setPrevSceneName(const char *name); + void setPrevSceneFilename(const char *name); + + AdItem *_selectedItem; + bool cleanup(); + DECLARE_PERSISTENT(AdGame, BaseGame) + + void finishSentences(); + bool showCursor(); + + TGameStateEx _stateEx; + + bool displaySentences(bool frozen); + void addSentence(AdSentence *sentence); + bool changeScene(const char *filename, bool fadeIn); + bool removeObject(AdObject *object); + bool addObject(AdObject *object); + AdScene *_scene; + bool initLoop(); + AdGame(const Common::String &gameId); + virtual ~AdGame(); + + BaseArray _objects; + + 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); + + // 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 + +#endif diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index 44b2dc0508..72f8fa0fb4 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -1,136 +1,136 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(AdInventory, false) - -////////////////////////////////////////////////////////////////////////// -AdInventory::AdInventory(BaseGame *inGame) : BaseObject(inGame) { - _scrollOffset = 0; -} - - -////////////////////////////////////////////////////////////////////////// -AdInventory::~AdInventory() { - _takenItems.clear(); // ref only -} - - -////////////////////////////////////////////////////////////////////////// -bool AdInventory::insertItem(const char *name, const char *insertAfter) { - if (name == NULL) { - return STATUS_FAILED; - } - - AdItem *item = ((AdGame *)_gameRef)->getItemByName(name); - if (item == NULL) { - return STATUS_FAILED; - } - - int insertIndex = -1; - for (uint32 i = 0; i < _takenItems.size(); i++) { - if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { - _takenItems.remove_at(i); - i--; - continue; - } - if (insertAfter && scumm_stricmp(_takenItems[i]->getName(), insertAfter) == 0) { - insertIndex = i + 1; - } - } - - - if (insertIndex == -1) { - _takenItems.add(item); - } else { - _takenItems.insert_at(insertIndex, item); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdInventory::removeItem(const char *name) { - if (name == NULL) { - return STATUS_FAILED; - } - - 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; - } - _takenItems.remove_at(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool AdInventory::removeItem(AdItem *item) { - if (item == NULL) { - return STATUS_FAILED; - } - - for (uint32 i = 0; i < _takenItems.size(); i++) { - if (_takenItems[i] == item) { - if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { - ((AdGame *)_gameRef)->_selectedItem = NULL; - } - _takenItems.remove_at(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool AdInventory::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - - _takenItems.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(AdInventory, false) + +////////////////////////////////////////////////////////////////////////// +AdInventory::AdInventory(BaseGame *inGame) : BaseObject(inGame) { + _scrollOffset = 0; +} + + +////////////////////////////////////////////////////////////////////////// +AdInventory::~AdInventory() { + _takenItems.clear(); // ref only +} + + +////////////////////////////////////////////////////////////////////////// +bool AdInventory::insertItem(const char *name, const char *insertAfter) { + if (name == NULL) { + return STATUS_FAILED; + } + + AdItem *item = ((AdGame *)_gameRef)->getItemByName(name); + if (item == NULL) { + return STATUS_FAILED; + } + + int insertIndex = -1; + for (uint32 i = 0; i < _takenItems.size(); i++) { + if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { + _takenItems.remove_at(i); + i--; + continue; + } + if (insertAfter && scumm_stricmp(_takenItems[i]->getName(), insertAfter) == 0) { + insertIndex = i + 1; + } + } + + + if (insertIndex == -1) { + _takenItems.add(item); + } else { + _takenItems.insert_at(insertIndex, item); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdInventory::removeItem(const char *name) { + if (name == NULL) { + return STATUS_FAILED; + } + + 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; + } + _takenItems.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool AdInventory::removeItem(AdItem *item) { + if (item == NULL) { + return STATUS_FAILED; + } + + for (uint32 i = 0; i < _takenItems.size(); i++) { + if (_takenItems[i] == item) { + if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { + ((AdGame *)_gameRef)->_selectedItem = NULL; + } + _takenItems.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool AdInventory::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 index 9a12eb1abe..4017d914bc 100644 --- a/engines/wintermute/ad/ad_inventory.h +++ b/engines/wintermute/ad/ad_inventory.h @@ -1,52 +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 AdItem; - -class AdInventory : public BaseObject { -public: - DECLARE_PERSISTENT(AdInventory, BaseObject) - bool removeItem(const char *name); - bool removeItem(AdItem *Item); - bool insertItem(const char *name, const char *insertAfter = NULL); - AdInventory(BaseGame *inGame); - virtual ~AdInventory(); - BaseArray _takenItems; - int _scrollOffset; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdItem; + +class AdInventory : public BaseObject { +public: + DECLARE_PERSISTENT(AdInventory, BaseObject) + bool removeItem(const char *name); + bool removeItem(AdItem *Item); + bool insertItem(const char *name, const char *insertAfter = NULL); + AdInventory(BaseGame *inGame); + virtual ~AdInventory(); + BaseArray _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 index ad679007df..16b8e01ff3 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -1,388 +1,388 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdInventoryBox, false) - -////////////////////////////////////////////////////////////////////////// -AdInventoryBox::AdInventoryBox(BaseGame *inGame) : BaseObject(inGame) { - _itemsArea.setEmpty(); - _scrollOffset = 0; - _spacing = 0; - _itemWidth = _itemHeight = 50; - _scrollBy = 1; - - _window = NULL; - _closeButton = NULL; - - _hideSelected = false; - - _visible = false; - _exclusive = false; -} - - -////////////////////////////////////////////////////////////////////////// -AdInventoryBox::~AdInventoryBox() { - _gameRef->unregisterObject(_window); - _window = NULL; - - delete _closeButton; - _closeButton = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { - UIObject *obj = (UIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->getName(), "close") == 0) { - _visible = false; - } else if (scumm_stricmp(obj->getName(), "prev") == 0) { - _scrollOffset -= _scrollBy; - _scrollOffset = MAX(_scrollOffset, 0); - } else if (scumm_stricmp(obj->getName(), "next") == 0) { - _scrollOffset += _scrollBy; - } else { - return BaseObject::listen(param1, param2); - } - break; - default: - error("AdInventoryBox::Listen - Unhandled enum"); - break; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdInventoryBox::display() { - AdGame *adGame = (AdGame *)_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 < (int32)adGame->_inventoryOwner->getInventory()->_takenItems.size()); - } - - - 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 < (int32)adGame->_inventoryOwner->getInventory()->_takenItems.size()) { - AdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; - if (item != ((AdGame *)_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 AdInventoryBox::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdInventoryBox::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; - BaseParser parser; - bool alwaysVisible = 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 UIWindow(_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", &alwaysVisible); - 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 UIButton(_gameRef); - if (_closeButton) { - _closeButton->setName("close"); - _closeButton->setListener(this, _closeButton, 0); - _closeButton->_parent = _window; - } - } - - _visible = alwaysVisible; - - if (_window) { - for (uint32 i = 0; i < _window->_widgets.size(); i++) { - if (!_window->_widgets[i]->_listenerObject) { - _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); - } - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "INVENTORY_BOX\n"); - buffer->putTextIndent(indent, "{\n"); - - 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); - - 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 - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { - BaseObject::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdInventoryBox, false) + +////////////////////////////////////////////////////////////////////////// +AdInventoryBox::AdInventoryBox(BaseGame *inGame) : BaseObject(inGame) { + _itemsArea.setEmpty(); + _scrollOffset = 0; + _spacing = 0; + _itemWidth = _itemHeight = 50; + _scrollBy = 1; + + _window = NULL; + _closeButton = NULL; + + _hideSelected = false; + + _visible = false; + _exclusive = false; +} + + +////////////////////////////////////////////////////////////////////////// +AdInventoryBox::~AdInventoryBox() { + _gameRef->unregisterObject(_window); + _window = NULL; + + delete _closeButton; + _closeButton = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { + UIObject *obj = (UIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->getName(), "close") == 0) { + _visible = false; + } else if (scumm_stricmp(obj->getName(), "prev") == 0) { + _scrollOffset -= _scrollBy; + _scrollOffset = MAX(_scrollOffset, 0); + } else if (scumm_stricmp(obj->getName(), "next") == 0) { + _scrollOffset += _scrollBy; + } else { + return BaseObject::listen(param1, param2); + } + break; + default: + error("AdInventoryBox::Listen - Unhandled enum"); + break; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdInventoryBox::display() { + AdGame *adGame = (AdGame *)_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 < (int32)adGame->_inventoryOwner->getInventory()->_takenItems.size()); + } + + + 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 < (int32)adGame->_inventoryOwner->getInventory()->_takenItems.size()) { + AdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; + if (item != ((AdGame *)_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 AdInventoryBox::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdInventoryBox::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; + BaseParser parser; + bool alwaysVisible = 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 UIWindow(_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", &alwaysVisible); + 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 UIButton(_gameRef); + if (_closeButton) { + _closeButton->setName("close"); + _closeButton->setListener(this, _closeButton, 0); + _closeButton->_parent = _window; + } + } + + _visible = alwaysVisible; + + if (_window) { + for (uint32 i = 0; i < _window->_widgets.size(); i++) { + if (!_window->_widgets[i]->_listenerObject) { + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "INVENTORY_BOX\n"); + buffer->putTextIndent(indent, "{\n"); + + 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); + + 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 + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { + BaseObject::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 index 451ebf9635..cb6d084562 100644 --- a/engines/wintermute/ad/ad_inventory_box.h +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -1,65 +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_ADINVENTORYBOX_H -#define WINTERMUTE_ADINVENTORYBOX_H - -#include "engines/wintermute/base/base_object.h" -#include "common/rect.h" - -namespace Wintermute { -class UIButton; -class UIWindow; - -class AdInventoryBox : public BaseObject { -public: - bool _hideSelected; - DECLARE_PERSISTENT(AdInventoryBox, BaseObject) - bool _visible; - virtual bool display(); - UIButton *_closeButton; - int _spacing; - int _scrollOffset; - Rect32 _itemsArea; - 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(BaseDynamicBuffer *buffer, int indent); -private: - bool _exclusive; - int _scrollBy; - int _itemHeight; - int _itemWidth; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIButton; +class UIWindow; + +class AdInventoryBox : public BaseObject { +public: + bool _hideSelected; + DECLARE_PERSISTENT(AdInventoryBox, BaseObject) + bool _visible; + virtual bool display(); + UIButton *_closeButton; + int _spacing; + int _scrollOffset; + Rect32 _itemsArea; + 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(BaseDynamicBuffer *buffer, int indent); +private: + bool _exclusive; + int _scrollBy; + int _itemHeight; + int _itemWidth; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index f5c8b16308..afd813933b 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -1,813 +1,813 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdItem, false) - -////////////////////////////////////////////////////////////////////////// -AdItem::AdItem(BaseGame *inGame) : AdTalkHolder(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; -} - - -////////////////////////////////////////////////////////////////////////// -AdItem::~AdItem() { - delete _spriteHover; - delete _cursorNormal; - delete _cursorHover; - _spriteHover = NULL; - _cursorNormal = NULL; - _cursorHover = NULL; - - delete[] _amountString; - _amountString = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdItem::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdItem::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; - BaseParser parser; - - 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 BaseSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { - delete _sprite; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - case TOKEN_SPRITE_HOVER: - delete _spriteHover; - _spriteHover = new BaseSprite(_gameRef, this); - if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((AdGame *)_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: - BaseUtils::setString(&_amountString, (char *)params); - break; - - 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); - } - } - 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); - } - } - break; - - case TOKEN_CURSOR: - delete _cursorNormal; - _cursorNormal = new BaseSprite(_gameRef); - if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { - delete _cursorNormal; - _cursorNormal = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_HOVER: - delete _cursorHover; - _cursorHover = new BaseSprite(_gameRef); - if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((AdGame *)_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 AdItem::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; - } - ((AdGame *)_gameRef)->addSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((AdGame *)_gameRef)->addSentence(_sentence); - } - } - default: - break; - } - _ready = (_state == STATE_READY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdItem::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; - - BaseFont *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 AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *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; - 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); - } 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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_spriteHover->getFilename()); - } - 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; - BaseSprite *spr = new BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_cursorNormal->getFilename()); - } - 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; - BaseSprite *spr = new BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_cursorHover->getFilename()); - } - 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 AdTalkHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdItem::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(getName()); - 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 AdTalkHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdItem::scSetProperty(const char *name, ScValue *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 { - BaseUtils::setString(&_amountString, value->getString()); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorCombined") == 0) { - _cursorCombined = value->getBool(); - return STATUS_OK; - } else { - return AdTalkHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdItem::scToString() { - return "[item]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdItem::persist(BasePersistenceManager *persistMgr) { - - AdTalkHolder::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 AdItem::getExtendedFlag(const char *flagName) { - if (!flagName) { - return false; - } else if (strcmp(flagName, "usable") == 0) { - return true; - } else { - return AdObject::getExtendedFlag(flagName); - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdItem, false) + +////////////////////////////////////////////////////////////////////////// +AdItem::AdItem(BaseGame *inGame) : AdTalkHolder(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; +} + + +////////////////////////////////////////////////////////////////////////// +AdItem::~AdItem() { + delete _spriteHover; + delete _cursorNormal; + delete _cursorHover; + _spriteHover = NULL; + _cursorNormal = NULL; + _cursorHover = NULL; + + delete[] _amountString; + _amountString = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdItem::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdItem::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; + BaseParser parser; + + 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 BaseSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { + delete _sprite; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + case TOKEN_SPRITE_HOVER: + delete _spriteHover; + _spriteHover = new BaseSprite(_gameRef, this); + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((AdGame *)_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: + BaseUtils::setString(&_amountString, (char *)params); + break; + + 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); + } + } + 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); + } + } + break; + + case TOKEN_CURSOR: + delete _cursorNormal; + _cursorNormal = new BaseSprite(_gameRef); + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { + delete _cursorNormal; + _cursorNormal = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_HOVER: + delete _cursorHover; + _cursorHover = new BaseSprite(_gameRef); + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((AdGame *)_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 AdItem::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; + } + ((AdGame *)_gameRef)->addSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((AdGame *)_gameRef)->addSentence(_sentence); + } + } + default: + break; + } + _ready = (_state == STATE_READY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdItem::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; + + BaseFont *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 AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *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; + 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); + } 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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_spriteHover->getFilename()); + } + 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; + BaseSprite *spr = new BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorNormal->getFilename()); + } + 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; + BaseSprite *spr = new BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorHover->getFilename()); + } + 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 AdTalkHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdItem::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(getName()); + 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 AdTalkHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdItem::scSetProperty(const char *name, ScValue *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 { + BaseUtils::setString(&_amountString, value->getString()); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorCombined") == 0) { + _cursorCombined = value->getBool(); + return STATUS_OK; + } else { + return AdTalkHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdItem::scToString() { + return "[item]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdItem::persist(BasePersistenceManager *persistMgr) { + + AdTalkHolder::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 AdItem::getExtendedFlag(const char *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_item.h b/engines/wintermute/ad/ad_item.h index e06266f8b7..6047c542c1 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -1,69 +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_ADITEM_H -#define WINTERMUTE_ADITEM_H - - -#include "engines/wintermute/ad/ad_talk_holder.h" - -namespace Wintermute { - -class AdItem : public AdTalkHolder { -public: - bool update(); - DECLARE_PERSISTENT(AdItem, AdTalkHolder) - bool display(int x, int y); - bool getExtendedFlag(const char *flagName); - bool _inInventory; - bool _cursorCombined; - 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 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 _displayAmount; - int _amount; - int _amountOffsetX; - int _amountOffsetY; - TTextAlign _amountAlign; - char *_amountString; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdItem : public AdTalkHolder { +public: + bool update(); + DECLARE_PERSISTENT(AdItem, AdTalkHolder) + bool display(int x, int y); + bool getExtendedFlag(const char *flagName); + bool _inInventory; + bool _cursorCombined; + 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 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 _displayAmount; + int _amount; + int _amountOffsetX; + int _amountOffsetY; + TTextAlign _amountAlign; + char *_amountString; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 709ab50b58..46b75b8b21 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -1,564 +1,564 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(AdLayer, false) - -////////////////////////////////////////////////////////////////////////// -AdLayer::AdLayer(BaseGame *inGame) : BaseObject(inGame) { - _main = false; - _width = _height = 0; - _active = true; - _closeUp = false; -} - - -////////////////////////////////////////////////////////////////////////// -AdLayer::~AdLayer() { - for (uint32 i = 0; i < _nodes.size(); i++) { - delete _nodes[i]; - } - _nodes.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdLayer::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdLayer::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; - BaseParser parser; - - 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: { - AdRegion *region = new AdRegion(_gameRef); - AdSceneNode *node = new AdSceneNode(_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: { - 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; - 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 AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetNode") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - int node = -1; - - if (val->_type == VAL_INT) { - node = val->getInt(); - } else { // get by name - 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; - break; - } - } - } - - if (node < 0 || node >= (int32)_nodes.size()) { - 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); - ScValue *val = stack->pop(); - - AdSceneNode *node = new AdSceneNode(_gameRef); - if (strcmp(name, "AddRegion") == 0) { - AdRegion *region = new AdRegion(_gameRef); - 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()); - } - 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(); - ScValue *val = stack->pop(); - - AdSceneNode *node = new AdSceneNode(_gameRef); - if (strcmp(name, "InsertRegion") == 0) { - AdRegion *region = new AdRegion(_gameRef); - 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()); - } - node->setEntity(entity); - stack->pushNative(entity, true); - } - if (index < 0) { - index = 0; - } - if (index <= (int32)_nodes.size() - 1) { - _nodes.insert_at(index, node); - } else { - _nodes.add(node); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteNode") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - AdSceneNode *toDelete = NULL; - if (val->isNative()) { - BaseScriptable *temp = val->getNative(); - for (uint32 i = 0; i < _nodes.size(); i++) { - if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { - toDelete = _nodes[i]; - break; - } - } - } else { - int index = val->getInt(); - if (index >= 0 && index < (int32)_nodes.size()) { - toDelete = _nodes[index]; - } - } - if (toDelete == NULL) { - stack->pushBool(false); - return STATUS_OK; - } - - for (uint32 i = 0; i < _nodes.size(); i++) { - if (_nodes[i] == toDelete) { - delete _nodes[i]; - _nodes[i] = NULL; - _nodes.remove_at(i); - break; - } - } - stack->pushBool(true); - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdLayer::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.size()); - 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 BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdLayer::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdLayer::scToString() { - return "[layer]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "LAYER {\n"); - 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); - 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"); - } - - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) { - _scProp->saveAsText(buffer, indent + 2); - } - - for (uint32 i = 0; i < _nodes.size(); 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("AdLayer::SaveAsText - Unhandled enum"); - break; - } - } - - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdLayer::persist(BasePersistenceManager *persistMgr) { - - BaseObject::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(AdLayer, false) + +////////////////////////////////////////////////////////////////////////// +AdLayer::AdLayer(BaseGame *inGame) : BaseObject(inGame) { + _main = false; + _width = _height = 0; + _active = true; + _closeUp = false; +} + + +////////////////////////////////////////////////////////////////////////// +AdLayer::~AdLayer() { + for (uint32 i = 0; i < _nodes.size(); i++) { + delete _nodes[i]; + } + _nodes.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdLayer::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdLayer::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; + BaseParser parser; + + 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: { + AdRegion *region = new AdRegion(_gameRef); + AdSceneNode *node = new AdSceneNode(_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: { + 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; + 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 AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetNode") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + int node = -1; + + if (val->_type == VAL_INT) { + node = val->getInt(); + } else { // get by name + 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; + break; + } + } + } + + if (node < 0 || node >= (int32)_nodes.size()) { + 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); + ScValue *val = stack->pop(); + + AdSceneNode *node = new AdSceneNode(_gameRef); + if (strcmp(name, "AddRegion") == 0) { + AdRegion *region = new AdRegion(_gameRef); + 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()); + } + 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(); + ScValue *val = stack->pop(); + + AdSceneNode *node = new AdSceneNode(_gameRef); + if (strcmp(name, "InsertRegion") == 0) { + AdRegion *region = new AdRegion(_gameRef); + 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()); + } + node->setEntity(entity); + stack->pushNative(entity, true); + } + if (index < 0) { + index = 0; + } + if (index <= (int32)_nodes.size() - 1) { + _nodes.insert_at(index, node); + } else { + _nodes.add(node); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteNode") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + AdSceneNode *toDelete = NULL; + if (val->isNative()) { + BaseScriptable *temp = val->getNative(); + for (uint32 i = 0; i < _nodes.size(); i++) { + if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { + toDelete = _nodes[i]; + break; + } + } + } else { + int index = val->getInt(); + if (index >= 0 && index < (int32)_nodes.size()) { + toDelete = _nodes[index]; + } + } + if (toDelete == NULL) { + stack->pushBool(false); + return STATUS_OK; + } + + for (uint32 i = 0; i < _nodes.size(); i++) { + if (_nodes[i] == toDelete) { + delete _nodes[i]; + _nodes[i] = NULL; + _nodes.remove_at(i); + break; + } + } + stack->pushBool(true); + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdLayer::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.size()); + 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 BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdLayer::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdLayer::scToString() { + return "[layer]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "LAYER {\n"); + 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); + 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"); + } + + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } + + for (uint32 i = 0; i < _nodes.size(); 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("AdLayer::SaveAsText - Unhandled enum"); + break; + } + } + + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdLayer::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 index b01079c091..bb5f73b13a 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -1,58 +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 AdSceneNode; -class AdLayer : public BaseObject { -public: - bool _closeUp; - DECLARE_PERSISTENT(AdLayer, BaseObject) - bool _active; - int _height; - int _width; - bool _main; - AdLayer(BaseGame *inGame); - virtual ~AdLayer(); - BaseArray _nodes; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdSceneNode; +class AdLayer : public BaseObject { +public: + bool _closeUp; + DECLARE_PERSISTENT(AdLayer, BaseObject) + bool _active; + int _height; + int _width; + bool _main; + AdLayer(BaseGame *inGame); + virtual ~AdLayer(); + BaseArray _nodes; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index fb2dfed0f5..493156c750 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -1,196 +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/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(AdNodeState, false) - - -////////////////////////////////////////////////////////////////////////// -AdNodeState::AdNodeState(BaseGame *inGame) : BaseClass(inGame) { - _name = NULL; - _active = false; - for (int i = 0; i < 7; i++) { - _caption[i] = NULL; - } - _alphaColor = 0; - _filename = NULL; - _cursor = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdNodeState::~AdNodeState() { - 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 AdNodeState::setName(const char *name) { - delete[] _name; - _name = NULL; - BaseUtils::setString(&_name, name); -} - - -////////////////////////////////////////////////////////////////////////// -void AdNodeState::setFilename(const char *filename) { - delete[] _filename; - _filename = NULL; - BaseUtils::setString(&_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -void AdNodeState::setCursor(const char *filename) { - delete[] _cursor; - _cursor = NULL; - BaseUtils::setString(&_cursor, filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdNodeState::persist(BasePersistenceManager *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 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]); - } -} - - -////////////////////////////////////////////////////////////////////////// -const 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]; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdNodeState::transferEntity(AdEntity *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->getFilename()) { - if (includingSprites) { - setFilename(entity->_sprite->getFilename()); - } else { - setFilename(""); - } - } - 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 (_filename && !entity->_region && includingSprites && strcmp(_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) { - entity->setCursor(_cursor); - } - } - - entity->_active = _active; - entity->_alphaColor = _alphaColor; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(AdNodeState, false) + + +////////////////////////////////////////////////////////////////////////// +AdNodeState::AdNodeState(BaseGame *inGame) : BaseClass(inGame) { + _name = NULL; + _active = false; + for (int i = 0; i < 7; i++) { + _caption[i] = NULL; + } + _alphaColor = 0; + _filename = NULL; + _cursor = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdNodeState::~AdNodeState() { + 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 AdNodeState::setName(const char *name) { + delete[] _name; + _name = NULL; + BaseUtils::setString(&_name, name); +} + + +////////////////////////////////////////////////////////////////////////// +void AdNodeState::setFilename(const char *filename) { + delete[] _filename; + _filename = NULL; + BaseUtils::setString(&_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +void AdNodeState::setCursor(const char *filename) { + delete[] _cursor; + _cursor = NULL; + BaseUtils::setString(&_cursor, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdNodeState::persist(BasePersistenceManager *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 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]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const 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]; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdNodeState::transferEntity(AdEntity *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->getFilename()) { + if (includingSprites) { + setFilename(entity->_sprite->getFilename()); + } else { + setFilename(""); + } + } + 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 (_filename && !entity->_region && includingSprites && strcmp(_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) { + 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 index 0008d4b3ee..e2050815a7 100644 --- a/engines/wintermute/ad/ad_node_state.h +++ b/engines/wintermute/ad/ad_node_state.h @@ -1,60 +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_ADNODESTATE_H -#define WINTERMUTE_ADNODESTATE_H - -namespace Wintermute { - -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); - void setCursor(const char *filename); - DECLARE_PERSISTENT(AdNodeState, BaseClass) - AdNodeState(BaseGame *inGame); - virtual ~AdNodeState(); - const char *getName() const { return _name; } -private: - char *_name; - char *_caption[7]; - void setCaption(const char *caption, int caseVal); - const char *getCaption(int caseVal); - uint32 _alphaColor; - char *_filename; - char *_cursor; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 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); + void setCursor(const char *filename); + DECLARE_PERSISTENT(AdNodeState, BaseClass) + AdNodeState(BaseGame *inGame); + virtual ~AdNodeState(); + const char *getName() const { return _name; } +private: + char *_name; + char *_caption[7]; + void setCaption(const char *caption, int caseVal); + const 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 index a02decebdb..6c77917979 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -1,1299 +1,1299 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 "engines/wintermute/base/particles/part_emitter.h" -#include "common/str.h" -#include "common/util.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdObject, false) - -////////////////////////////////////////////////////////////////////////// -AdObject::AdObject(BaseGame *inGame) : BaseObject(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; -} - - -////////////////////////////////////////////////////////////////////////// -AdObject::~AdObject() { - _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) { - ((AdGame *)_gameRef)->unregisterInventory(_inventory); - _inventory = NULL; - } - - if (_partEmitter) { - _gameRef->unregisterObject(_partEmitter); - } - - - for (uint32 i = 0; i < _attachmentsPre.size(); i++) { - _gameRef->unregisterObject(_attachmentsPre[i]); - } - _attachmentsPre.clear(); - - for (uint32 i = 0; i < _attachmentsPost.size(); i++) { - _gameRef->unregisterObject(_attachmentsPost[i]); - } - _attachmentsPost.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::playAnim(const char *filename) { - delete _animSprite; - _animSprite = NULL; - _animSprite = new BaseSprite(_gameRef, this); - if (!_animSprite) { - _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\")", getName(), filename); - delete _animSprite; - _animSprite = NULL; - return res; - } - _state = STATE_PLAYING_ANIM; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::display() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::update() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *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(); - ScValue *soundVal = stack->pop(); - int duration = stack->pop()->getInt(); - ScValue *valStances = stack->pop(); - - const char *stances = valStances->isNULL() ? NULL : valStances->getString(); - - int align = 0; - ScValue *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); - - AdLayer *main = ((AdGame *)_gameRef)->_scene->_mainLayer; - bool regFound = false; - - 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.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; - break; - } - } - } else if (val->isNative()) { - BaseScriptable *obj = val->getNative(); - - 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; - break; - } - } - - } - - if (!regFound) { - _stickRegion = NULL; - } - stack->pushBool(regFound); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFont") == 0) { - stack->correctParams(1); - ScValue *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->getFilename()) { - stack->pushString(_font->getFilename()); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TakeItem") == 0) { - stack->correctParams(2); - - if (!_inventory) { - _inventory = new AdInventory(_gameRef); - ((AdGame *)_gameRef)->registerInventory(_inventory); - } - - ScValue *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 - ((AdGame *)_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 AdInventory(_gameRef); - ((AdGame *)_gameRef)->registerInventory(_inventory); - } - - 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 - ((AdGame *)_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 AdInventory(_gameRef); - ((AdGame *)_gameRef)->registerInventory(_inventory); - } - - 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() >= (int32)_inventory->_takenItems.size()) { - 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 AdInventory(_gameRef); - ((AdGame *)_gameRef)->registerInventory(_inventory); - } - - ScValue *val = stack->pop(); - if (!val->isNULL()) { - for (uint32 i = 0; i < _inventory->_takenItems.size(); i++) { - if (val->getNative() == _inventory->_takenItems[i]) { - stack->pushBool(true); - return STATUS_OK; - } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->getName()) == 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(); - - PartEmitter *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; - AdEntity *ent = new AdEntity(_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); - ScValue *val = stack->pop(); - bool found = false; - if (val->isNative()) { - BaseScriptable *obj = val->getNative(); - for (uint32 i = 0; i < _attachmentsPre.size(); i++) { - if (_attachmentsPre[i] == obj) { - found = true; - _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.remove_at(i); - i--; - } - } - for (uint32 i = 0; i < _attachmentsPost.size(); i++) { - if (_attachmentsPost[i] == obj) { - found = true; - _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.remove_at(i); - i--; - } - } - } else { - const char *attachmentName = val->getString(); - 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]); - _attachmentsPre.remove_at(i); - 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]); - _attachmentsPost.remove_at(i); - i--; - } - } - } - stack->pushBool(found); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAttachment") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - AdObject *ret = NULL; - if (val->isInt()) { - int index = val->getInt(); - int currIndex = 0; - for (uint32 i = 0; i < _attachmentsPre.size(); i++) { - if (currIndex == index) { - ret = _attachmentsPre[i]; - } - currIndex++; - } - for (uint32 i = 0; i < _attachmentsPost.size(); i++) { - if (currIndex == index) { - ret = _attachmentsPost[i]; - } - currIndex++; - } - } else { - const char *attachmentName = val->getString(); - 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 (uint32 i = 0; i < _attachmentsPost.size(); i++) { - if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { - ret = _attachmentsPre[i]; - break; - } - } - } - } - - if (ret != NULL) { - stack->pushNative(ret, true); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdObject::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.size()); - 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.size() + _attachmentsPost.size()); - return _scValue; - } else { - return BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdObject::scToString() { - return "[ad object]"; -} - - -////////////////////////////////////////////////////////////////////////// -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; - } else { - _font = NULL; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -int AdObject::getHeight() { - if (!_currentSprite) { - return 0; - } else { - BaseFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; - int ret = 0; - for (uint32 i = 0; i < frame->_subframes.size(); i++) { - ret = MAX(ret, frame->_subframes[i]->_hotspotY); - } - - if (_zoomable) { - float zoom = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); - ret = (int)(ret * zoom / 100); - } - return ret; - } -} - - -////////////////////////////////////////////////////////////////////////// -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) { - 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 = ((AdGame *)_gameRef)->findSpeechFile(key); - delete[] key; - - if (sound) { - deleteSound = true; - } - } - } - - // load sound and set duration appropriately - if (sound) { - BaseSound *snd = new BaseSound(_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 -= ((AdGame *)_gameRef)->_scene->getOffsetLeft(); - y -= ((AdGame *)_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 += ((AdGame *)_gameRef)->_scene->getOffsetLeft(); - _sentence->_pos.y += ((AdGame *)_gameRef)->_scene->getOffsetTop(); - } - - _sentence->_fixedPos = !_subtitlesModRelative; - - - _sentence->setupTalkFile(sound); - - _state = STATE_TALKING; - - if (deleteSound) { - delete[] sound; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::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 AdObject::persist(BasePersistenceManager *persistMgr) { - BaseObject::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 AdObject::updateSounds() { - if (_sentence && _sentence->_sound) { - updateOneSound(_sentence->_sound); - } - - return BaseObject::updateSounds(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::resetSoundPan() { - if (_sentence && _sentence->_sound) { - _sentence->_sound->setPan(0.0f); - } - return BaseObject::resetSoundPan(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::getExtendedFlag(const char *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); - } - - BaseClass::saveAsText(buffer, indent + 2); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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); - } - - if (_wptGroup && _currentWptGroup) { - _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -AdInventory *AdObject::getInventory() { - if (!_inventory) { - _inventory = new AdInventory(_gameRef); - ((AdGame *)_gameRef)->registerInventory(_inventory); - } - return _inventory; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdObject::afterMove() { - AdRegion *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; - 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 AdObject::invalidateCurrRegions() { - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - _currentRegions[i] = NULL; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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 = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; - } - } else { - *scaleX = *scaleY = 100; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdObject::updateSpriteAttachments() { - for (uint32 i = 0; i < _attachmentsPre.size(); i++) { - _attachmentsPre[i]->update(); - } - for (uint32 i = 0; i < _attachmentsPost.size(); i++) { - _attachmentsPost[i]->update(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdObject::displaySpriteAttachments(bool preDisplay) { - if (preDisplay) { - for (uint32 i = 0; i < _attachmentsPre.size(); i++) { - displaySpriteAttachment(_attachmentsPre[i]); - } - } else { - for (uint32 i = 0; i < _attachmentsPost.size(); i++) { - displaySpriteAttachment(_attachmentsPost[i]); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdObject::displaySpriteAttachment(AdObject *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; -} - -////////////////////////////////////////////////////////////////////////// -PartEmitter *AdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { - _partFollowParent = followParent; - _partOffsetX = offsetX; - _partOffsetY = offsetY; - - if (!_partEmitter) { - _partEmitter = new PartEmitter(_gameRef, this); - if (_partEmitter) { - _gameRef->registerObject(_partEmitter); - } - } - updatePartEmitter(); - return _partEmitter; -} - -////////////////////////////////////////////////////////////////////////// -bool AdObject::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 "engines/wintermute/base/particles/part_emitter.h" +#include "common/str.h" +#include "common/util.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdObject, false) + +////////////////////////////////////////////////////////////////////////// +AdObject::AdObject(BaseGame *inGame) : BaseObject(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; +} + + +////////////////////////////////////////////////////////////////////////// +AdObject::~AdObject() { + _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) { + ((AdGame *)_gameRef)->unregisterInventory(_inventory); + _inventory = NULL; + } + + if (_partEmitter) { + _gameRef->unregisterObject(_partEmitter); + } + + + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { + _gameRef->unregisterObject(_attachmentsPre[i]); + } + _attachmentsPre.clear(); + + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { + _gameRef->unregisterObject(_attachmentsPost[i]); + } + _attachmentsPost.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::playAnim(const char *filename) { + delete _animSprite; + _animSprite = NULL; + _animSprite = new BaseSprite(_gameRef, this); + if (!_animSprite) { + _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\")", getName(), filename); + delete _animSprite; + _animSprite = NULL; + return res; + } + _state = STATE_PLAYING_ANIM; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::display() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::update() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *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(); + ScValue *soundVal = stack->pop(); + int duration = stack->pop()->getInt(); + ScValue *valStances = stack->pop(); + + const char *stances = valStances->isNULL() ? NULL : valStances->getString(); + + int align = 0; + ScValue *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); + + AdLayer *main = ((AdGame *)_gameRef)->_scene->_mainLayer; + bool regFound = false; + + 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.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; + break; + } + } + } else if (val->isNative()) { + BaseScriptable *obj = val->getNative(); + + 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; + break; + } + } + + } + + if (!regFound) { + _stickRegion = NULL; + } + stack->pushBool(regFound); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFont") == 0) { + stack->correctParams(1); + ScValue *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->getFilename()) { + stack->pushString(_font->getFilename()); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TakeItem") == 0) { + stack->correctParams(2); + + if (!_inventory) { + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); + } + + ScValue *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 + ((AdGame *)_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 AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); + } + + 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 + ((AdGame *)_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 AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); + } + + 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() >= (int32)_inventory->_takenItems.size()) { + 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 AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); + } + + ScValue *val = stack->pop(); + if (!val->isNULL()) { + for (uint32 i = 0; i < _inventory->_takenItems.size(); i++) { + if (val->getNative() == _inventory->_takenItems[i]) { + stack->pushBool(true); + return STATUS_OK; + } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->getName()) == 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(); + + PartEmitter *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; + AdEntity *ent = new AdEntity(_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); + ScValue *val = stack->pop(); + bool found = false; + if (val->isNative()) { + BaseScriptable *obj = val->getNative(); + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { + if (_attachmentsPre[i] == obj) { + found = true; + _gameRef->unregisterObject(_attachmentsPre[i]); + _attachmentsPre.remove_at(i); + i--; + } + } + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { + if (_attachmentsPost[i] == obj) { + found = true; + _gameRef->unregisterObject(_attachmentsPost[i]); + _attachmentsPost.remove_at(i); + i--; + } + } + } else { + const char *attachmentName = val->getString(); + 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]); + _attachmentsPre.remove_at(i); + 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]); + _attachmentsPost.remove_at(i); + i--; + } + } + } + stack->pushBool(found); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAttachment") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + AdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + int currIndex = 0; + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { + if (currIndex == index) { + ret = _attachmentsPre[i]; + } + currIndex++; + } + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { + if (currIndex == index) { + ret = _attachmentsPost[i]; + } + currIndex++; + } + } else { + const char *attachmentName = val->getString(); + 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 (uint32 i = 0; i < _attachmentsPost.size(); i++) { + if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { + ret = _attachmentsPre[i]; + break; + } + } + } + } + + if (ret != NULL) { + stack->pushNative(ret, true); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdObject::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.size()); + 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.size() + _attachmentsPost.size()); + return _scValue; + } else { + return BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdObject::scToString() { + return "[ad object]"; +} + + +////////////////////////////////////////////////////////////////////////// +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; + } else { + _font = NULL; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int AdObject::getHeight() { + if (!_currentSprite) { + return 0; + } else { + BaseFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; + int ret = 0; + for (uint32 i = 0; i < frame->_subframes.size(); i++) { + ret = MAX(ret, frame->_subframes[i]->_hotspotY); + } + + if (_zoomable) { + float zoom = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); + ret = (int)(ret * zoom / 100); + } + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +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) { + 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 = ((AdGame *)_gameRef)->findSpeechFile(key); + delete[] key; + + if (sound) { + deleteSound = true; + } + } + } + + // load sound and set duration appropriately + if (sound) { + BaseSound *snd = new BaseSound(_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 -= ((AdGame *)_gameRef)->_scene->getOffsetLeft(); + y -= ((AdGame *)_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 += ((AdGame *)_gameRef)->_scene->getOffsetLeft(); + _sentence->_pos.y += ((AdGame *)_gameRef)->_scene->getOffsetTop(); + } + + _sentence->_fixedPos = !_subtitlesModRelative; + + + _sentence->setupTalkFile(sound); + + _state = STATE_TALKING; + + if (deleteSound) { + delete[] sound; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::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 AdObject::persist(BasePersistenceManager *persistMgr) { + BaseObject::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 AdObject::updateSounds() { + if (_sentence && _sentence->_sound) { + updateOneSound(_sentence->_sound); + } + + return BaseObject::updateSounds(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::resetSoundPan() { + if (_sentence && _sentence->_sound) { + _sentence->_sound->setPan(0.0f); + } + return BaseObject::resetSoundPan(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::getExtendedFlag(const char *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); + } + + BaseClass::saveAsText(buffer, indent + 2); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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); + } + + if (_wptGroup && _currentWptGroup) { + _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +AdInventory *AdObject::getInventory() { + if (!_inventory) { + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); + } + return _inventory; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdObject::afterMove() { + AdRegion *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; + 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 AdObject::invalidateCurrRegions() { + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + _currentRegions[i] = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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 = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + } + } else { + *scaleX = *scaleY = 100; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdObject::updateSpriteAttachments() { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { + _attachmentsPre[i]->update(); + } + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { + _attachmentsPost[i]->update(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdObject::displaySpriteAttachments(bool preDisplay) { + if (preDisplay) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { + displaySpriteAttachment(_attachmentsPre[i]); + } + } else { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { + displaySpriteAttachment(_attachmentsPost[i]); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdObject::displaySpriteAttachment(AdObject *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; +} + +////////////////////////////////////////////////////////////////////////// +PartEmitter *AdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { + _partFollowParent = followParent; + _partOffsetX = offsetX; + _partOffsetY = offsetY; + + if (!_partEmitter) { + _partEmitter = new PartEmitter(_gameRef, this); + if (_partEmitter) { + _gameRef->registerObject(_partEmitter); + } + } + updatePartEmitter(); + return _partEmitter; +} + +////////////////////////////////////////////////////////////////////////// +bool AdObject::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 index 9451707445..8395f58cff 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -1,124 +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_ADOBJECT_H -#define WINTERMUTE_ADOBJECT_H - -#include "engines/wintermute/ad/ad_types.h" -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class AdWaypointGroup; -class AdRegion; -class AdSentence; -class BaseFont; -class BaseRegion; -class AdInventory; -class PartEmitter; - -#define MAX_NUM_REGIONS 10 - -class AdObject : public BaseObject { -public: - PartEmitter *_partEmitter; - virtual PartEmitter *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; - AdRegion *_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(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(); - AdSentence *_sentence; - bool setFont(const char *filename); - virtual bool update(); - virtual bool display(); - bool _drawn; - bool _active; - virtual bool playAnim(const char *filename); - BaseSprite *_animSprite; - BaseSprite *_currentSprite; - TObjectState _state; - TObjectState _nextState; - TObjectType _type; - 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(); - AdRegion *_currentRegions[MAX_NUM_REGIONS]; - - // 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(); - - BaseArray _attachmentsPre; - BaseArray _attachmentsPost; - - bool updateSpriteAttachments(); - bool displaySpriteAttachments(bool preDisplay); - AdObject *_registerAlias; -private: - bool displaySpriteAttachment(AdObject *attachment); - AdInventory *_inventory; - -protected: - bool getScale(float *scaleX, float *scaleY); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/base_object.h" + +namespace Wintermute { + +class AdWaypointGroup; +class AdRegion; +class AdSentence; +class BaseFont; +class BaseRegion; +class AdInventory; +class PartEmitter; + +#define MAX_NUM_REGIONS 10 + +class AdObject : public BaseObject { +public: + PartEmitter *_partEmitter; + virtual PartEmitter *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; + AdRegion *_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(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(); + AdSentence *_sentence; + bool setFont(const char *filename); + virtual bool update(); + virtual bool display(); + bool _drawn; + bool _active; + virtual bool playAnim(const char *filename); + BaseSprite *_animSprite; + BaseSprite *_currentSprite; + TObjectState _state; + TObjectState _nextState; + TObjectType _type; + 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(); + AdRegion *_currentRegions[MAX_NUM_REGIONS]; + + // 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(); + + BaseArray _attachmentsPre; + BaseArray _attachmentsPost; + + bool updateSpriteAttachments(); + bool displaySpriteAttachments(bool preDisplay); + AdObject *_registerAlias; +private: + bool displaySpriteAttachment(AdObject *attachment); + AdInventory *_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 index 21b68f4d48..c931213456 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -1,120 +1,120 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.h" -#include "engines/wintermute/base/base_point.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdPath, false) - -////////////////////////////////////////////////////////////////////////// -AdPath::AdPath(BaseGame *inGame) : BaseClass(inGame) { - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -AdPath::~AdPath() { - reset(); -} - - -////////////////////////////////////////////////////////////////////////// -void AdPath::reset() { - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - - _points.clear(); - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint *AdPath::getFirst() { - if (_points.size() > 0) { - _currIndex = 0; - return _points[_currIndex]; - } else { - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint *AdPath::getNext() { - _currIndex++; - if (_currIndex < (int32)_points.size()) { - return _points[_currIndex]; - } else { - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint *AdPath::getCurrent() { - if (_currIndex >= 0 && _currIndex < (int32)_points.size()) { - return _points[_currIndex]; - } else { - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdPath::addPoint(BasePoint *point) { - _points.add(point); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdPath::setReady(bool ready) { - bool orig = _ready; - _ready = ready; - - return orig; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdPath::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_currIndex)); - _points.persist(persistMgr); - persistMgr->transfer(TMEMBER(_ready)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.h" +#include "engines/wintermute/base/base_point.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdPath, false) + +////////////////////////////////////////////////////////////////////////// +AdPath::AdPath(BaseGame *inGame) : BaseClass(inGame) { + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +AdPath::~AdPath() { + reset(); +} + + +////////////////////////////////////////////////////////////////////////// +void AdPath::reset() { + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + + _points.clear(); + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint *AdPath::getFirst() { + if (_points.size() > 0) { + _currIndex = 0; + return _points[_currIndex]; + } else { + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint *AdPath::getNext() { + _currIndex++; + if (_currIndex < (int32)_points.size()) { + return _points[_currIndex]; + } else { + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint *AdPath::getCurrent() { + if (_currIndex >= 0 && _currIndex < (int32)_points.size()) { + return _points[_currIndex]; + } else { + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdPath::addPoint(BasePoint *point) { + _points.add(point); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdPath::setReady(bool ready) { + bool orig = _ready; + _ready = ready; + + return orig; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdPath::persist(BasePersistenceManager *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 index de115b261a..6b043197aa 100644 --- a/engines/wintermute/ad/ad_path.h +++ b/engines/wintermute/ad/ad_path.h @@ -1,56 +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 BasePoint; -class AdPath : public BaseClass { -public: - DECLARE_PERSISTENT(AdPath, BaseClass) - BasePoint *getCurrent(); - bool setReady(bool ready = true); - void addPoint(BasePoint *point); - BasePoint *getNext(); - BasePoint *getFirst(); - void reset(); - AdPath(BaseGame *inGame); - virtual ~AdPath(); - BaseArray _points; - int _currIndex; - bool _ready; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 BasePoint; +class AdPath : public BaseClass { +public: + DECLARE_PERSISTENT(AdPath, BaseClass) + BasePoint *getCurrent(); + bool setReady(bool ready = true); + void addPoint(BasePoint *point); + BasePoint *getNext(); + BasePoint *getFirst(); + void reset(); + AdPath(BaseGame *inGame); + virtual ~AdPath(); + BaseArray _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 index 1fb954c668..a36648eb69 100644 --- a/engines/wintermute/ad/ad_path_point.cpp +++ b/engines/wintermute/ad/ad_path_point.cpp @@ -1,75 +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(AdPathPoint, false) - -////////////////////////////////////////////////////////////////////////// -AdPathPoint::AdPathPoint() { - x = y = 0; - _distance = 0; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdPathPoint::AdPathPoint(int initX, int initY, int initDistance) { - x = initX; - y = initY; - _distance = initDistance; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdPathPoint::~AdPathPoint() { - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdPathPoint::persist(BasePersistenceManager *persistMgr) { - - BasePoint::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_distance)); - persistMgr->transfer(TMEMBER(_marked)); - persistMgr->transfer(TMEMBER(_origin)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(AdPathPoint, false) + +////////////////////////////////////////////////////////////////////////// +AdPathPoint::AdPathPoint() { + x = y = 0; + _distance = 0; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdPathPoint::AdPathPoint(int initX, int initY, int initDistance) { + x = initX; + y = initY; + _distance = initDistance; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdPathPoint::~AdPathPoint() { + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdPathPoint::persist(BasePersistenceManager *persistMgr) { + + BasePoint::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 index 8201750cef..58457976c8 100644 --- a/engines/wintermute/ad/ad_path_point.h +++ b/engines/wintermute/ad/ad_path_point.h @@ -1,50 +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 AdPathPoint : public BasePoint { -public: - DECLARE_PERSISTENT(AdPathPoint, BasePoint) - AdPathPoint(int initX, int initY, int initDistance); - AdPathPoint(); - virtual ~AdPathPoint(); - AdPathPoint *_origin; - bool _marked; - int _distance; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdPathPoint : public BasePoint { +public: + DECLARE_PERSISTENT(AdPathPoint, BasePoint) + AdPathPoint(int initX, int initY, int initDistance); + AdPathPoint(); + virtual ~AdPathPoint(); + AdPathPoint *_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 index 3e5f91524d..88bd8201a2 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -1,397 +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/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(AdRegion, false) - -////////////////////////////////////////////////////////////////////////// -AdRegion::AdRegion(BaseGame *inGame) : BaseRegion(inGame) { - _blocked = false; - _decoration = false; - _zoom = 0; - _alpha = 0xFFFFFFFF; -} - - -////////////////////////////////////////////////////////////////////////// -AdRegion::~AdRegion() { -} - - -////////////////////////////////////////////////////////////////////////// -bool AdRegion::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdRegion::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; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - _points.clear(); - - 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 BasePoint(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 AdRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 BaseRegion::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdRegion::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(getName()); - 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 BaseRegion::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdRegion::scSetProperty(const char *name, ScValue *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 BaseRegion::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdRegion::scToString() { - return "[ad region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "REGION {\n"); - 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"); - 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"); - - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) { - _scProp->saveAsText(buffer, indent + 2); - } - - for (uint32 i = 0; i < _points.size(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdRegion::persist(BasePersistenceManager *persistMgr) { - BaseRegion::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdRegion, false) + +////////////////////////////////////////////////////////////////////////// +AdRegion::AdRegion(BaseGame *inGame) : BaseRegion(inGame) { + _blocked = false; + _decoration = false; + _zoom = 0; + _alpha = 0xFFFFFFFF; +} + + +////////////////////////////////////////////////////////////////////////// +AdRegion::~AdRegion() { +} + + +////////////////////////////////////////////////////////////////////////// +bool AdRegion::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdRegion::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; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + _points.clear(); + + 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 BasePoint(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 AdRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 BaseRegion::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdRegion::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(getName()); + 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 BaseRegion::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdRegion::scSetProperty(const char *name, ScValue *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 BaseRegion::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdRegion::scToString() { + return "[ad region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "REGION {\n"); + 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"); + 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"); + + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } + + for (uint32 i = 0; i < _points.size(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdRegion::persist(BasePersistenceManager *persistMgr) { + BaseRegion::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 index 5c33291a88..a60cb9a3f2 100644 --- a/engines/wintermute/ad/ad_region.h +++ b/engines/wintermute/ad/ad_region.h @@ -1,58 +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 AdRegion : public BaseRegion { -public: - DECLARE_PERSISTENT(AdRegion, BaseRegion) - uint32 _alpha; - float _zoom; - bool _blocked; - bool _decoration; - AdRegion(BaseGame *inGame); - virtual ~AdRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdRegion : public BaseRegion { +public: + DECLARE_PERSISTENT(AdRegion, BaseRegion) + uint32 _alpha; + float _zoom; + bool _blocked; + bool _decoration; + AdRegion(BaseGame *inGame); + virtual ~AdRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index f7886bba5a..37f46118bf 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -1,146 +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/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(AdResponse, false) - -////////////////////////////////////////////////////////////////////////// -AdResponse::AdResponse(BaseGame *inGame) : BaseObject(inGame) { - _text = NULL; - _textOrig = NULL; - _icon = _iconHover = _iconPressed = NULL; - _font = NULL; - _iD = 0; - _responseType = RESPONSE_ALWAYS; -} - - -////////////////////////////////////////////////////////////////////////// -AdResponse::~AdResponse() { - 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 AdResponse::setText(const char *text) { - BaseUtils::setString(&_text, text); - BaseUtils::setString(&_textOrig, text); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponse::setIcon(const char *filename) { - delete _icon; - _icon = new BaseSprite(_gameRef); - if (!_icon || DID_FAIL(_icon->loadFile(filename))) { - _gameRef->LOG(0, "AdResponse::setIcon failed for file '%s'", filename); - delete _icon; - _icon = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdResponse::setFont(const char *filename) { - if (_font) { - _gameRef->_fontStorage->removeFont(_font); - } - _font = _gameRef->_fontStorage->addFont(filename); - if (!_font) { - _gameRef->LOG(0, "AdResponse::setFont failed for file '%s'", filename); - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdResponse::setIconHover(const char *filename) { - delete _iconHover; - _iconHover = new BaseSprite(_gameRef); - if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { - _gameRef->LOG(0, "AdResponse::setIconHover failed for file '%s'", filename); - delete _iconHover; - _iconHover = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponse::setIconPressed(const char *filename) { - delete _iconPressed; - _iconPressed = new BaseSprite(_gameRef); - if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { - _gameRef->LOG(0, "AdResponse::setIconPressed failed for file '%s'", filename); - delete _iconPressed; - _iconPressed = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponse::persist(BasePersistenceManager *persistMgr) { - - BaseObject::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdResponse, false) + +////////////////////////////////////////////////////////////////////////// +AdResponse::AdResponse(BaseGame *inGame) : BaseObject(inGame) { + _text = NULL; + _textOrig = NULL; + _icon = _iconHover = _iconPressed = NULL; + _font = NULL; + _iD = 0; + _responseType = RESPONSE_ALWAYS; +} + + +////////////////////////////////////////////////////////////////////////// +AdResponse::~AdResponse() { + 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 AdResponse::setText(const char *text) { + BaseUtils::setString(&_text, text); + BaseUtils::setString(&_textOrig, text); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponse::setIcon(const char *filename) { + delete _icon; + _icon = new BaseSprite(_gameRef); + if (!_icon || DID_FAIL(_icon->loadFile(filename))) { + _gameRef->LOG(0, "AdResponse::setIcon failed for file '%s'", filename); + delete _icon; + _icon = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdResponse::setFont(const char *filename) { + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } + _font = _gameRef->_fontStorage->addFont(filename); + if (!_font) { + _gameRef->LOG(0, "AdResponse::setFont failed for file '%s'", filename); + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdResponse::setIconHover(const char *filename) { + delete _iconHover; + _iconHover = new BaseSprite(_gameRef); + if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { + _gameRef->LOG(0, "AdResponse::setIconHover failed for file '%s'", filename); + delete _iconHover; + _iconHover = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponse::setIconPressed(const char *filename) { + delete _iconPressed; + _iconPressed = new BaseSprite(_gameRef); + if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { + _gameRef->LOG(0, "AdResponse::setIconPressed failed for file '%s'", filename); + delete _iconPressed; + _iconPressed = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponse::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 index 0678ef5a37..0ba88cf2e8 100644 --- a/engines/wintermute/ad/ad_response.h +++ b/engines/wintermute/ad/ad_response.h @@ -1,61 +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 BaseFont; -class AdResponse : public BaseObject { -public: - 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; - BaseSprite *_icon; - BaseSprite *_iconHover; - BaseSprite *_iconPressed; - BaseFont *_font; - char *_text; - char *_textOrig; - AdResponse(BaseGame *inGame); - virtual ~AdResponse(); - TResponseType _responseType; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 BaseFont; +class AdResponse : public BaseObject { +public: + 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; + BaseSprite *_icon; + BaseSprite *_iconHover; + BaseSprite *_iconPressed; + BaseFont *_font; + char *_text; + char *_textOrig; + AdResponse(BaseGame *inGame); + virtual ~AdResponse(); + 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 index 76510e2f3e..a27f1ca54b 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -1,712 +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/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 "engines/wintermute/wintermute.h" -#include "common/str.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdResponseBox, false) - -////////////////////////////////////////////////////////////////////////// -AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { - _font = _fontHover = NULL; - - _window = NULL; - _shieldWindow = new UIWindow(_gameRef); - - _horizontal = false; - BasePlatform::setRectEmpty(&_responseArea); - _scrollOffset = 0; - _spacing = 0; - - _waitingScript = NULL; - _lastResponseText = NULL; - _lastResponseTextOrig = NULL; - - _verticalAlign = VAL_BOTTOM; - _align = TAL_LEFT; -} - - -////////////////////////////////////////////////////////////////////////// -AdResponseBox::~AdResponseBox() { - - 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 AdResponseBox::clearResponses() { - for (uint32 i = 0; i < _responses.size(); i++) { - delete _responses[i]; - } - _responses.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void AdResponseBox::clearButtons() { - for (uint32 i = 0; i < _respButtons.size(); i++) { - delete _respButtons[i]; - } - _respButtons.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::invalidateButtons() { - for (uint32 i = 0; i < _respButtons.size(); 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 AdResponseBox::createButtons() { - clearButtons(); - - _scrollOffset = 0; - for (uint32 i = 0; i < _responses.size(); i++) { - UIButton *btn = new UIButton(_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 AdResponseBox::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdResponseBox::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; - BaseParser parser; - - 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 UIWindow(_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 BaseSprite(_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 (uint32 i = 0; i < _window->_widgets.size(); i++) { - if (!_window->_widgets[i]->_listenerObject) { - _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); - } - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::saveAsText(BaseDynamicBuffer *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->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->getFilename()) { - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); - } - - 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("AdResponseBox::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 - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::display() { - Rect32 rect = _responseArea; - if (_window) { - rect.offsetRect(_window->_posX, _window->_posY); - //_window->display(); - } - - int xxx, yyy; - uint32 i; - - xxx = rect.left; - yyy = rect.top; - - // shift down if needed - if (!_horizontal) { - int totalHeight = 0; - for (i = 0; i < _respButtons.size(); i++) { - totalHeight += (_respButtons[i]->_height + _spacing); - } - totalHeight -= _spacing; - - switch (_verticalAlign) { - case VAL_BOTTOM: - if (yyy + totalHeight < rect.bottom) { - yyy = rect.bottom - totalHeight; - } - break; - - case VAL_CENTER: - if (yyy + totalHeight < rect.bottom) { - yyy += ((rect.bottom - rect.top) - totalHeight) / 2; - } - break; - - case VAL_TOP: - // do nothing - break; - } - } - - // prepare response buttons - bool scrollNeeded = false; - for (i = _scrollOffset; i < _respButtons.size(); 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.size(); i++) { - _respButtons[i]->display(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { - UIObject *obj = (UIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->getName(), "prev") == 0) { - _scrollOffset--; - } 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); - } - handleResponse(_responses[param2]); - _waitingScript = NULL; - _gameRef->_state = GAME_RUNNING; - ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL; - _ready = true; - invalidateButtons(); - clearResponses(); - } else { - return BaseObject::listen(param1, param2); - } - break; - default: - error("AdResponseBox::Listen - Unhandled enum"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { - BaseObject::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 AdResponseBox::weedResponses() { - AdGame *adGame = (AdGame *)_gameRef; - - for (uint32 i = 0; i < _responses.size(); i++) { - switch (_responses[i]->_responseType) { - case RESPONSE_ONCE: - if (adGame->branchResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.remove_at(i); - i--; - } - break; - - case RESPONSE_ONCE_GAME: - if (adGame->gameResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.remove_at(i); - i--; - } - break; - default: - debugC(kWintermuteDebugGeneral, "AdResponseBox::WeedResponses - Unhandled enum"); - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void AdResponseBox::setLastResponseText(const char *text, const char *textOrig) { - BaseUtils::setString(&_lastResponseText, text); - BaseUtils::setString(&_lastResponseTextOrig, textOrig); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::handleResponse(AdResponse *response) { - setLastResponseText(response->_text, response->_textOrig); - - AdGame *adGame = (AdGame *)_gameRef; - - switch (response->_responseType) { - case RESPONSE_ONCE: - adGame->addBranchResponse(response->_iD); - break; - - case RESPONSE_ONCE_GAME: - adGame->addGameResponse(response->_iD); - break; - default: - debugC(kWintermuteDebugGeneral, "AdResponseBox::HandleResponse - Unhandled enum"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { - BaseArray objects; - getObjects(objects, true); - - if (objects.size() == 0) { - return NULL; - } else { - if (currObject != NULL) { - for (uint32 i = 0; i < objects.size(); i++) { - if (objects[i] == currObject) { - if (i < objects.size() - 1) { - return objects[i + 1]; - } else { - break; - } - } - } - } - return objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { - BaseArray objects; - getObjects(objects, true); - - if (objects.size() == 0) { - return NULL; - } else { - if (currObject != NULL) { - for (int i = objects.size() - 1; i >= 0; i--) { - if (objects[i] == currObject) { - if (i > 0) { - return objects[i - 1]; - } else { - break; - } - } - } - } - return objects[objects.size() - 1]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveOnly) { - for (uint32 i = 0; i < _respButtons.size(); i++) { - objects.add(_respButtons[i]); - } - if (_window) { - _window->getWindowObjects(objects, interactiveOnly); - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 "engines/wintermute/wintermute.h" +#include "common/str.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdResponseBox, false) + +////////////////////////////////////////////////////////////////////////// +AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { + _font = _fontHover = NULL; + + _window = NULL; + _shieldWindow = new UIWindow(_gameRef); + + _horizontal = false; + BasePlatform::setRectEmpty(&_responseArea); + _scrollOffset = 0; + _spacing = 0; + + _waitingScript = NULL; + _lastResponseText = NULL; + _lastResponseTextOrig = NULL; + + _verticalAlign = VAL_BOTTOM; + _align = TAL_LEFT; +} + + +////////////////////////////////////////////////////////////////////////// +AdResponseBox::~AdResponseBox() { + + 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 AdResponseBox::clearResponses() { + for (uint32 i = 0; i < _responses.size(); i++) { + delete _responses[i]; + } + _responses.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void AdResponseBox::clearButtons() { + for (uint32 i = 0; i < _respButtons.size(); i++) { + delete _respButtons[i]; + } + _respButtons.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::invalidateButtons() { + for (uint32 i = 0; i < _respButtons.size(); 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 AdResponseBox::createButtons() { + clearButtons(); + + _scrollOffset = 0; + for (uint32 i = 0; i < _responses.size(); i++) { + UIButton *btn = new UIButton(_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 AdResponseBox::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdResponseBox::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; + BaseParser parser; + + 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 UIWindow(_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 BaseSprite(_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 (uint32 i = 0; i < _window->_widgets.size(); i++) { + if (!_window->_widgets[i]->_listenerObject) { + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::saveAsText(BaseDynamicBuffer *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->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->getFilename()) { + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } + + 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("AdResponseBox::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 + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::display() { + Rect32 rect = _responseArea; + if (_window) { + rect.offsetRect(_window->_posX, _window->_posY); + //_window->display(); + } + + int xxx, yyy; + uint32 i; + + xxx = rect.left; + yyy = rect.top; + + // shift down if needed + if (!_horizontal) { + int totalHeight = 0; + for (i = 0; i < _respButtons.size(); i++) { + totalHeight += (_respButtons[i]->_height + _spacing); + } + totalHeight -= _spacing; + + switch (_verticalAlign) { + case VAL_BOTTOM: + if (yyy + totalHeight < rect.bottom) { + yyy = rect.bottom - totalHeight; + } + break; + + case VAL_CENTER: + if (yyy + totalHeight < rect.bottom) { + yyy += ((rect.bottom - rect.top) - totalHeight) / 2; + } + break; + + case VAL_TOP: + // do nothing + break; + } + } + + // prepare response buttons + bool scrollNeeded = false; + for (i = _scrollOffset; i < _respButtons.size(); 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.size(); i++) { + _respButtons[i]->display(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { + UIObject *obj = (UIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->getName(), "prev") == 0) { + _scrollOffset--; + } 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); + } + handleResponse(_responses[param2]); + _waitingScript = NULL; + _gameRef->_state = GAME_RUNNING; + ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL; + _ready = true; + invalidateButtons(); + clearResponses(); + } else { + return BaseObject::listen(param1, param2); + } + break; + default: + error("AdResponseBox::Listen - Unhandled enum"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { + BaseObject::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 AdResponseBox::weedResponses() { + AdGame *adGame = (AdGame *)_gameRef; + + for (uint32 i = 0; i < _responses.size(); i++) { + switch (_responses[i]->_responseType) { + case RESPONSE_ONCE: + if (adGame->branchResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.remove_at(i); + i--; + } + break; + + case RESPONSE_ONCE_GAME: + if (adGame->gameResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.remove_at(i); + i--; + } + break; + default: + debugC(kWintermuteDebugGeneral, "AdResponseBox::WeedResponses - Unhandled enum"); + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void AdResponseBox::setLastResponseText(const char *text, const char *textOrig) { + BaseUtils::setString(&_lastResponseText, text); + BaseUtils::setString(&_lastResponseTextOrig, textOrig); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::handleResponse(AdResponse *response) { + setLastResponseText(response->_text, response->_textOrig); + + AdGame *adGame = (AdGame *)_gameRef; + + switch (response->_responseType) { + case RESPONSE_ONCE: + adGame->addBranchResponse(response->_iD); + break; + + case RESPONSE_ONCE_GAME: + adGame->addGameResponse(response->_iD); + break; + default: + debugC(kWintermuteDebugGeneral, "AdResponseBox::HandleResponse - Unhandled enum"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { + BaseArray objects; + getObjects(objects, true); + + if (objects.size() == 0) { + return NULL; + } else { + if (currObject != NULL) { + for (uint32 i = 0; i < objects.size(); i++) { + if (objects[i] == currObject) { + if (i < objects.size() - 1) { + return objects[i + 1]; + } else { + break; + } + } + } + } + return objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { + BaseArray objects; + getObjects(objects, true); + + if (objects.size() == 0) { + return NULL; + } else { + if (currObject != NULL) { + for (int i = objects.size() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) { + return objects[i - 1]; + } else { + break; + } + } + } + } + return objects[objects.size() - 1]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveOnly) { + for (uint32 i = 0; i < _respButtons.size(); 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 index 8c76b561c6..35f8cb6347 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -1,87 +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 UIButton; -class UIWindow; -class UIObject; -class AdResponse; -class AdResponseBox : public BaseObject { -public: - BaseObject *getNextAccessObject(BaseObject *CurrObject); - BaseObject *getPrevAccessObject(BaseObject *CurrObject); - bool getObjects(BaseArray &objects, bool interactiveOnly); - - bool handleResponse(AdResponse *response); - void setLastResponseText(const char *text, const char *textOrig); - char *_lastResponseText; - char *_lastResponseTextOrig; - DECLARE_PERSISTENT(AdResponseBox, BaseObject) - ScScript *_waitingScript; - virtual bool listen(BaseScriptHolder *param1, uint32 param2); - typedef enum { - EVENT_PREV, - EVENT_NEXT, - EVENT_RESPONSE - } TResponseEvent; - - bool weedResponses(); - bool display(); - int _spacing; - int _scrollOffset; - BaseFont *_fontHover; - BaseFont *_font; - bool createButtons(); - bool invalidateButtons(); - void clearButtons(); - void clearResponses(); - 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(BaseDynamicBuffer *buffer, int indent); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIButton; +class UIWindow; +class UIObject; +class AdResponse; +class AdResponseBox : public BaseObject { +public: + BaseObject *getNextAccessObject(BaseObject *CurrObject); + BaseObject *getPrevAccessObject(BaseObject *CurrObject); + bool getObjects(BaseArray &objects, bool interactiveOnly); + + bool handleResponse(AdResponse *response); + void setLastResponseText(const char *text, const char *textOrig); + char *_lastResponseText; + char *_lastResponseTextOrig; + DECLARE_PERSISTENT(AdResponseBox, BaseObject) + ScScript *_waitingScript; + virtual bool listen(BaseScriptHolder *param1, uint32 param2); + typedef enum { + EVENT_PREV, + EVENT_NEXT, + EVENT_RESPONSE + } TResponseEvent; + + bool weedResponses(); + bool display(); + int _spacing; + int _scrollOffset; + BaseFont *_fontHover; + BaseFont *_font; + bool createButtons(); + bool invalidateButtons(); + void clearButtons(); + void clearResponses(); + 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(BaseDynamicBuffer *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 index 0a2eff842d..ebfa03feea 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -1,71 +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 - */ - -#include "engines/wintermute/ad/ad_response_context.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdResponseContext, false) - -////////////////////////////////////////////////////////////////////////// -AdResponseContext::AdResponseContext(BaseGame *inGame) : BaseClass(inGame) { - _id = 0; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdResponseContext::~AdResponseContext() { - delete[] _context; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_context)); - persistMgr->transfer(TMEMBER(_id)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void AdResponseContext::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_response_context.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdResponseContext, false) + +////////////////////////////////////////////////////////////////////////// +AdResponseContext::AdResponseContext(BaseGame *inGame) : BaseClass(inGame) { + _id = 0; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdResponseContext::~AdResponseContext() { + delete[] _context; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_context)); + persistMgr->transfer(TMEMBER(_id)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void AdResponseContext::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 index a630f975e4..14bc1abd93 100644 --- a/engines/wintermute/ad/ad_response_context.h +++ b/engines/wintermute/ad/ad_response_context.h @@ -1,50 +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 AdResponseContext : public BaseClass { -public: - void setContext(const char *context); - int _id; - char *_context; - DECLARE_PERSISTENT(AdResponseContext, BaseClass) - AdResponseContext(BaseGame *inGame); - virtual ~AdResponseContext(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdResponseContext : public BaseClass { +public: + void setContext(const char *context); + int _id; + char *_context; + DECLARE_PERSISTENT(AdResponseContext, BaseClass) + AdResponseContext(BaseGame *inGame); + virtual ~AdResponseContext(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index 487e1f7067..ca7ed693ad 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -1,161 +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/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(AdRotLevel, false) - - -////////////////////////////////////////////////////////////////////////// -AdRotLevel::AdRotLevel(BaseGame *inGame) : BaseObject(inGame) { - _posX = 0; - _rotation = 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -AdRotLevel::~AdRotLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool AdRotLevel::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdRotLevel::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; - BaseParser parser; - - 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 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); - BaseClass::saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdRotLevel::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_rotation)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdRotLevel, false) + + +////////////////////////////////////////////////////////////////////////// +AdRotLevel::AdRotLevel(BaseGame *inGame) : BaseObject(inGame) { + _posX = 0; + _rotation = 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +AdRotLevel::~AdRotLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool AdRotLevel::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdRotLevel::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; + BaseParser parser; + + 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 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); + BaseClass::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdRotLevel::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 index 7951c7562d..d7f5f8edf0 100644 --- a/engines/wintermute/ad/ad_rot_level.h +++ b/engines/wintermute/ad/ad_rot_level.h @@ -1,49 +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 AdRotLevel : public BaseObject { -public: - DECLARE_PERSISTENT(AdRotLevel, BaseObject) - AdRotLevel(BaseGame *inGame); - virtual ~AdRotLevel(); - float _rotation; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdRotLevel : public BaseObject { +public: + DECLARE_PERSISTENT(AdRotLevel, BaseObject) + AdRotLevel(BaseGame *inGame); + virtual ~AdRotLevel(); + float _rotation; + virtual bool saveAsText(BaseDynamicBuffer *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 index f3ec68dd64..8b68cc5d32 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -1,159 +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/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(AdScaleLevel, false) - -////////////////////////////////////////////////////////////////////////// -AdScaleLevel::AdScaleLevel(BaseGame *inGame) : BaseObject(inGame) { - _posY = 0; - _scale = 100; -} - - -////////////////////////////////////////////////////////////////////////// -AdScaleLevel::~AdScaleLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScaleLevel::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdScaleLevel::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; - BaseParser parser; - - 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 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); - BaseClass::saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScaleLevel::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scale)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdScaleLevel, false) + +////////////////////////////////////////////////////////////////////////// +AdScaleLevel::AdScaleLevel(BaseGame *inGame) : BaseObject(inGame) { + _posY = 0; + _scale = 100; +} + + +////////////////////////////////////////////////////////////////////////// +AdScaleLevel::~AdScaleLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScaleLevel::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdScaleLevel::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; + BaseParser parser; + + 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 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); + BaseClass::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScaleLevel::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 index 41a2edf8c5..628a385eb4 100644 --- a/engines/wintermute/ad/ad_scale_level.h +++ b/engines/wintermute/ad/ad_scale_level.h @@ -1,50 +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 AdScaleLevel : public BaseObject { -public: - DECLARE_PERSISTENT(AdScaleLevel, BaseObject) - float _scale; - AdScaleLevel(BaseGame *inGame); - virtual ~AdScaleLevel(); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdScaleLevel : public BaseObject { +public: + DECLARE_PERSISTENT(AdScaleLevel, BaseObject) + float _scale; + AdScaleLevel(BaseGame *inGame); + virtual ~AdScaleLevel(); + virtual bool saveAsText(BaseDynamicBuffer *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 index f67252350e..e47acc63c9 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1,2986 +1,2986 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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 "engines/wintermute/wintermute.h" -#include - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdScene, false) - -////////////////////////////////////////////////////////////////////////// -AdScene::AdScene(BaseGame *inGame) : BaseObject(inGame) { - _pfTarget = new BasePoint; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -AdScene::~AdScene() { - cleanup(); - _gameRef->unregisterObject(_fader); - delete _pfTarget; - _pfTarget = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void AdScene::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 BaseFader(_gameRef); - _gameRef->registerObject(_fader); - - _viewport = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void AdScene::cleanup() { - BaseObject::cleanup(); - - _mainLayer = NULL; // reference only - - delete _shieldWindow; - _shieldWindow = NULL; - - _gameRef->unregisterObject(_fader); - _fader = NULL; - - for (uint32 i = 0; i < _layers.size(); i++) { - _gameRef->unregisterObject(_layers[i]); - } - _layers.clear(); - - - for (uint32 i = 0; i < _waypointGroups.size(); i++) { - _gameRef->unregisterObject(_waypointGroups[i]); - } - _waypointGroups.clear(); - - for (uint32 i = 0; i < _scaleLevels.size(); i++) { - _gameRef->unregisterObject(_scaleLevels[i]); - } - _scaleLevels.clear(); - - for (uint32 i = 0; i < _rotLevels.size(); i++) { - _gameRef->unregisterObject(_rotLevels[i]); - } - _rotLevels.clear(); - - - for (uint32 i = 0; i < _pfPath.size(); i++) { - delete _pfPath[i]; - } - _pfPath.clear(); - _pfPointsNum = 0; - - for (uint32 i = 0; i < _objects.size(); i++) { - _gameRef->unregisterObject(_objects[i]); - } - _objects.clear(); - - delete _viewport; - _viewport = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester) { - if (!_pfReady) { - return false; - } else { - _pfReady = false; - *_pfTarget = target; - _pfTargetPath = path; - _pfRequester = requester; - - _pfTargetPath->reset(); - _pfTargetPath->setReady(false); - - // prepare working path - pfPointsStart(); - - // first point - //_pfPath.add(new AdPathPoint(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 AdPathPoint(target.x, target.y, INT_MAX)); - pfPointsAdd(target.x, target.y, INT_MAX); - - // active waypoints - for (uint32 i = 0; i < _waypointGroups.size(); i++) { - if (_waypointGroups[i]->_active) { - pfAddWaypointGroup(_waypointGroups[i], requester); - } - } - - - // free waypoints - 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 (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); - } - } - - return true; - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdScene::pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester) { - if (!wpt->_active) { - return; - } - - for (uint32 i = 0; i < wpt->_points.size(); i++) { - 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); - } -} - - -////////////////////////////////////////////////////////////////////////// -float AdScene::getZoomAt(int x, int y) { - float ret = 100; - - bool found = false; - if (_mainLayer) { - 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) { - ret = node->_region->_zoom; - found = true; - break; - } - } - } - } - if (!found) { - ret = getScaleAt(y); - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 AdScene::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.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) { - ret = node->_region->_alpha; - } - break; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { - bool ret = true; - - if (checkFreeObjects) { - 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; - } - } - } - AdGame *adGame = (AdGame *)_gameRef; - 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; - } - } - } - } - - - if (_mainLayer) { - 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)) - { - 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 AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { - bool ret = false; - - if (checkFreeObjects) { - 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; - } - } - } - AdGame *adGame = (AdGame *)_gameRef; - 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; - } - } - } - } - - - if (_mainLayer) { - 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) { - ret = false; - break; - } else { - ret = true; - } - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *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) { - BaseUtils::swap(&x1, &x2); - BaseUtils::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) { - BaseUtils::swap(&x1, &x2); - BaseUtils::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 AdScene::pathFinderStep() { - int i; - // get lowest unmarked - int lowestDist = INT_MAX; - AdPathPoint *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.insert_at(0, new BasePoint(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 AdScene::initLoop() { -#ifdef _DEBUGxxxx - int nu_steps = 0; - uint32 start = _gameRef->_currentTime; - 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 && g_system->getMillis() - start <= _pfMaxTime) { - pathFinderStep(); - } -#endif - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) { - _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); - } - - setFilename(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 AdScene::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; - BaseParser parser; - - 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: { - AdLayer *layer = new AdLayer(_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: { - AdWaypointGroup *wpt = new AdWaypointGroup(_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: { - AdScaleLevel *sl = new AdScaleLevel(_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: { - AdRotLevel *rl = new AdRotLevel(_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: { - AdEntity *entity = new AdEntity(_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 BaseSprite(_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 BaseViewport(_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.", getFilename()); - } - - - sortScaleLevels(); - sortRotLevels(); - - _initialized = true; - - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdScene::traverseNodes(bool doUpdate) { - if (!_initialized) { - return STATUS_OK; - } - - AdGame *adGame = (AdGame *)_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 (uint32 j = 0; j < _layers.size(); j++) { - 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->_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 (uint32 k = 0; k < _layers[j]->_nodes.size(); k++) { - AdSceneNode *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 AdScene::display() { - return traverseNodes(false); -} - -////////////////////////////////////////////////////////////////////////// -bool AdScene::updateFreeObjects() { - AdGame *adGame = (AdGame *)_gameRef; - // 3D-code removed - // bool is3DSet; - - // *** update all active objects - // is3DSet = false; - for (uint32 i = 0; i < adGame->_objects.size(); i++) { - if (!adGame->_objects[i]->_active) { - continue; - } - // 3D-code removed - adGame->_objects[i]->update(); - adGame->_objects[i]->_drawn = false; - } - - - for (uint32 i = 0; i < _objects.size(); 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 AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { - AdGame *adGame = (AdGame *)_gameRef; - BaseArray objects; - AdObject *obj; - - // global objects - 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); - } - } - - // scene objects - 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); - } - } - - // sort by _posY - Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); - - // display them - for (uint32 i = 0; i < objects.size(); 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 (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->display(); - _objects[i]->_drawn = true; - } - } - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int AdScene::compareObjs(const void *obj1, const void *obj2) { - const AdObject *object1 = *(const AdObject *const *)obj1; - const AdObject *object2 = *(const AdObject *const *)obj2; - - if (object1->_posY < object2->_posY) { - return -1; - } else if (object1->_posY > object2->_posY) { - return 1; - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool AdScene::displayRegionContentOld(AdRegion *region) { - AdGame *adGame = (AdGame *)_gameRef; - AdObject *obj; - - // display all objects in region sorted by _posY - do { - obj = NULL; - int minY = INT_MAX; - - // global objects - 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; - } - } - - // scene objects - 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; - } - } - - - 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 (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->display(); - _objects[i]->_drawn = true; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::update() { - return traverseNodes(true); -} - -////////////////////////////////////////////////////////////////////////// -void AdScene::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 AdScene::scrollToObject(BaseObject *object) { - 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); - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdScene::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 AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LoadActor") == 0) { - stack->correctParams(1); - AdActor *act = new AdActor(_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); - AdEntity *ent = new AdEntity(_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); - ScValue *val = stack->pop(); - - AdEntity *ent = new AdEntity(_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); - ScValue *val = stack->pop(); - AdObject *obj = (AdObject *)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); - ScValue *val1 = stack->pop(); - ScValue *val2 = stack->pop(); - if (val1->isNative()) { - skipToObject((BaseObject *)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); - ScValue *val1 = stack->pop(); - ScValue *val2 = stack->pop(); - if (val1->isNative()) { - scrollToObject((BaseObject *)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); - ScValue *val = stack->pop(); - if (val->isInt()) { - int layer = val->getInt(); - if (layer < 0 || layer >= (int32)_layers.size()) { - stack->pushNULL(); - } else { - stack->pushNative(_layers[layer], true); - } - } else { - const char *layerName = val->getString(); - bool layerFound = false; - for (uint32 i = 0; i < _layers.size(); i++) { - if (scumm_stricmp(layerName, _layers[i]->getName()) == 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 >= (int32)_waypointGroups.size()) { - 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(); - - BaseObject *node = getNodeByName(nodeName); - if (node) { - stack->pushNative((BaseScriptable *)node, true); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFreeNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFreeNode") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - AdObject *ret = NULL; - if (val->isInt()) { - int index = val->getInt(); - if (index >= 0 && index < (int32)_objects.size()) { - ret = _objects[index]; - } - } else { - const char *nodeName = val->getString(); - 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; - } - } - } - 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(); - ScValue *val = stack->pop(); - - bool includeDecors = false; - if (!val->isNULL()) { - includeDecors = val->getBool(); - } - - if (_mainLayer) { - 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) { - 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 BaseViewport(_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); - ScValue *val = stack->pop(); - - AdLayer *layer = new AdLayer(_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(); - ScValue *val = stack->pop(); - - AdLayer *layer = new AdLayer(_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 <= (int32)_layers.size() - 1) { - _layers.insert_at(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); - ScValue *val = stack->pop(); - - AdLayer *toDelete = NULL; - if (val->isNative()) { - BaseScriptable *temp = val->getNative(); - for (uint32 i = 0; i < _layers.size(); i++) { - if (_layers[i] == temp) { - toDelete = _layers[i]; - break; - } - } - } else { - int index = val->getInt(); - if (index >= 0 && index < (int32)_layers.size()) { - 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 (uint32 i = 0; i < _layers.size(); i++) { - if (_layers[i] == toDelete) { - _layers.remove_at(i); - _gameRef->unregisterObject(toDelete); - break; - } - } - stack->pushBool(true); - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdScene::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.size()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWaypointGroups (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWaypointGroups") == 0) { - _scValue->setInt(_waypointGroups.size()); - 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.size()); - 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 BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdScene::scToString() { - return "[scene object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::addObject(AdObject *object) { - _objects.add(object); - return _gameRef->registerObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::removeObject(AdObject *object) { - for (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i] == object) { - _objects.remove_at(i); - return _gameRef->unregisterObject(object); - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SCENE {\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - 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 (uint32 i = 0; i < _scripts.size(); 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"); - - BaseClass::saveAsText(buffer, indent + 2); - - // waypoints - buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); - for (uint32 i = 0; i < _waypointGroups.size(); i++) { - _waypointGroups[i]->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // layers - buffer->putTextIndent(indent + 2, "; ----- layers\n"); - for (uint32 i = 0; i < _layers.size(); i++) { - _layers[i]->saveAsText(buffer, indent + 2); - } - - // scale levels - buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); - for (uint32 i = 0; i < _scaleLevels.size(); i++) { - _scaleLevels[i]->saveAsText(buffer, indent + 2); - } - - // rotation levels - buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); - for (uint32 i = 0; i < _rotLevels.size(); i++) { - _rotLevels[i]->saveAsText(buffer, indent + 2); - } - - - buffer->putTextIndent(indent + 2, "\n"); - - // free entities - buffer->putTextIndent(indent + 2, "; ----- free entities\n"); - 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; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::sortScaleLevels() { - if (_scaleLevels.size() == 0) { - return STATUS_OK; - } - bool changed; - do { - changed = false; - 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]; - _scaleLevels[i + 1] = sl; - - changed = true; - } - } - - } while (changed); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::sortRotLevels() { - if (_rotLevels.size() == 0) { - return STATUS_OK; - } - bool changed; - do { - changed = false; - 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]; - _rotLevels[i + 1] = rl; - - changed = true; - } - } - - } while (changed); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float AdScene::getScaleAt(int Y) { - AdScaleLevel *prev = NULL; - AdScaleLevel *next = NULL; - - for (uint32 i = 0; i < _scaleLevels.size(); i++) { - /* AdScaleLevel *xxx = _scaleLevels[i];*/ - /* int j = _scaleLevels.size(); */ - 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 AdScene::persist(BasePersistenceManager *persistMgr) { - BaseObject::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 AdScene::afterLoad() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -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; - - x1 = *targetX; - y1 = *targetY; - x2 = startX; - y2 = startY; - - - xLength = abs(x2 - x1); - yLength = abs(y2 - y1); - - if (xLength > yLength) { - - 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 { - - 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 AdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, BaseObject *requester) { - int x = *argX; - int y = *argY; - - if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { - return STATUS_OK; - } - - // 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)) { - foundRight = true; - break; - } - } - - // 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)) { - foundLeft = true; - break; - } - } - - // 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)) { - foundUp = true; - break; - } - } - - // 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)) { - foundDown = true; - break; - } - } - - if (!foundLeft && !foundRight && !foundUp && !foundDown) { - return STATUS_OK; - } - - int offsetX = INT_MAX, offsetY = INT_MAX; - - if (foundLeft && foundRight) { - if (abs(lengthLeft) < abs(lengthRight)) { - offsetX = lengthLeft; - } else { - offsetX = lengthRight; - } - } else if (foundLeft) { - offsetX = lengthLeft; - } else if (foundRight) { - offsetX = lengthRight; - } - - 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 (!isWalkableAt(*argX, *argY)) { - return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdScene::pfPointsStart() { - _pfPointsNum = 0; -} - - -////////////////////////////////////////////////////////////////////////// -void AdScene::pfPointsAdd(int x, int y, int distance) { - if (_pfPointsNum >= (int32)_pfPath.size()) { - _pfPath.add(new AdPathPoint(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 AdScene::getViewportOffset(int *offsetX, int *offsetY) { - AdGame *adGame = (AdGame *)_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 AdScene::getViewportSize(int *width, int *height) { - AdGame *adGame = (AdGame *)_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 AdScene::getOffsetLeft() { - int viewportX; - getViewportOffset(&viewportX); - - return _offsetLeft - viewportX; -} - - -////////////////////////////////////////////////////////////////////////// -int AdScene::getOffsetTop() { - int viewportY; - getViewportOffset(NULL, &viewportY); - - return _offsetTop - viewportY; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::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 AdScene::setOffset(int offsetLeft, int offsetTop) { - _offsetLeft = offsetLeft; - _offsetTop = offsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -BaseObject *AdScene::getNodeByName(const char *name) { - BaseObject *ret = NULL; - - // dependent objects - for (uint32 i = 0; i < _layers.size(); i++) { - AdLayer *layer = _layers[i]; - 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()))) { - 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 (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 (uint32 i = 0; i < _waypointGroups.size(); i++) { - if (!scumm_stricmp(name, _waypointGroups[i]->getName())) { - return _waypointGroups[i]; - } - } - - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::saveState() { - return persistState(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::loadState() { - return persistState(false); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::persistState(bool saving) { - if (!_persistentState) { - return STATUS_OK; - } - - AdGame *adGame = (AdGame *)_gameRef; - AdSceneState *state = adGame->getSceneState(getFilename(), saving); - if (!state) { - return STATUS_OK; - } - - AdNodeState *nodeState; - - // dependent objects - for (uint32 i = 0; i < _layers.size(); i++) { - AdLayer *layer = _layers[i]; - for (uint32 j = 0; j < layer->_nodes.size(); j++) { - AdSceneNode *node = layer->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: - if (!node->_entity->_saveState) { - continue; - } - nodeState = state->getNodeState(node->_entity->getName(), 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->getName(), saving); - if (nodeState) { - if (saving) { - nodeState->_active = node->_region->_active; - } else { - node->_region->_active = nodeState->_active; - } - } - break; - default: - warning("AdScene::PersistState - unhandled enum"); - break; - } - } - } - - // free entities - for (uint32 i = 0; i < _objects.size(); i++) { - if (!_objects[i]->_saveState) { - continue; - } - if (_objects[i]->_type == OBJECT_ENTITY) { - nodeState = state->getNodeState(_objects[i]->getName(), saving); - if (nodeState) { - nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving); - //if (Saving) NodeState->_active = _objects[i]->_active; - //else _objects[i]->_active = NodeState->_active; - } - } - } - - // waypoint groups - for (uint32 i = 0; i < _waypointGroups.size(); i++) { - nodeState = state->getNodeState(_waypointGroups[i]->getName(), saving); - if (nodeState) { - if (saving) { - nodeState->_active = _waypointGroups[i]->_active; - } else { - _waypointGroups[i]->_active = nodeState->_active; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float AdScene::getRotationAt(int x, int y) { - AdRotLevel *prev = NULL; - AdRotLevel *next = NULL; - - for (uint32 i = 0; i < _rotLevels.size(); i++) { - /* AdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.size();*/ - 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 AdScene::handleItemAssociations(const char *itemName, bool show) { - for (uint32 i = 0; i < _layers.size(); i++) { - AdLayer *layer = _layers[i]; - for (uint32 j = 0; j < layer->_nodes.size(); j++) { - if (layer->_nodes[j]->_type == OBJECT_ENTITY) { - AdEntity *ent = layer->_nodes[j]->_entity; - - if (ent->_item && strcmp(ent->_item, itemName) == 0) { - ent->_active = show; - } - } - } - } - - 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) { - ent->_active = show; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::getRegionsAt(int x, int y, AdRegion **regionList, int numRegions) { - int numUsed = 0; - if (_mainLayer) { - 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) { - regionList[numUsed] = node->_region; - numUsed++; - } else { - break; - } - } - } - } - for (int i = numUsed; i < numRegions; i++) { - regionList[i] = NULL; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdScene::restoreDeviceObjects() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { - BaseArray objects; - getSceneObjects(objects, true); - - if (objects.size() == 0) { - return NULL; - } else { - if (currObject != NULL) { - for (uint32 i = 0; i < objects.size(); i++) { - if (objects[i] == currObject) { - if (i < objects.size() - 1) { - return objects[i + 1]; - } else { - break; - } - } - } - } - return objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { - BaseArray objects; - getSceneObjects(objects, true); - - if (objects.size() == 0) { - return NULL; - } else { - if (currObject != NULL) { - for (int i = objects.size() - 1; i >= 0; i--) { - if (objects[i] == currObject) { - if (i > 0) { - return objects[i - 1]; - } else { - break; - } - } - } - } - return objects[objects.size() - 1]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { - for (uint32 i = 0; i < _layers.size(); i++) { - // close-up layer -> remove everything below it - if (interactiveOnly && _layers[i]->_closeUp) { - objects.clear(); - } - - - for (uint32 j = 0; j < _layers[i]->_nodes.size(); j++) { - AdSceneNode *node = _layers[i]->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: { - AdEntity *ent = node->_entity; - if (ent->_active && (ent->_registrable || !interactiveOnly)) { - objects.add(ent); - } - } - break; - - case OBJECT_REGION: { - BaseArray regionObj; - getRegionObjects(node->_region, regionObj, interactiveOnly); - for (uint32 newIndex = 0; newIndex < regionObj.size(); newIndex++) { - bool found = false; - for (uint32 old = 0; old < objects.size(); old++) { - if (objects[old] == regionObj[newIndex]) { - found = true; - break; - } - } - if (!found) { - objects.add(regionObj[newIndex]); - } - } - //if (regionObj.size() > 0) Objects.Append(RegionObj); - } - break; - default: - debugC(kWintermuteDebugGeneral, "AdScene::GetSceneObjects - Unhandled enum"); - break; - } - } - } - - // objects outside any region - BaseArray regionObj; - getRegionObjects(NULL, regionObj, interactiveOnly); - for (uint32 newIndex = 0; newIndex < regionObj.size(); newIndex++) { - bool found = false; - for (uint32 old = 0; old < objects.size(); old++) { - if (objects[old] == regionObj[newIndex]) { - found = true; - break; - } - } - if (!found) { - objects.add(regionObj[newIndex]); - } - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, bool interactiveOnly) { - AdGame *adGame = (AdGame *)_gameRef; - AdObject *obj; - - // global objects - 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) { - continue; - } - - objects.add(obj); - } - } - - // scene objects - 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) { - continue; - } - - objects.add(obj); - } - } - - // sort by _posY - Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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 "engines/wintermute/wintermute.h" +#include + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdScene, false) + +////////////////////////////////////////////////////////////////////////// +AdScene::AdScene(BaseGame *inGame) : BaseObject(inGame) { + _pfTarget = new BasePoint; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +AdScene::~AdScene() { + cleanup(); + _gameRef->unregisterObject(_fader); + delete _pfTarget; + _pfTarget = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void AdScene::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 BaseFader(_gameRef); + _gameRef->registerObject(_fader); + + _viewport = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void AdScene::cleanup() { + BaseObject::cleanup(); + + _mainLayer = NULL; // reference only + + delete _shieldWindow; + _shieldWindow = NULL; + + _gameRef->unregisterObject(_fader); + _fader = NULL; + + for (uint32 i = 0; i < _layers.size(); i++) { + _gameRef->unregisterObject(_layers[i]); + } + _layers.clear(); + + + for (uint32 i = 0; i < _waypointGroups.size(); i++) { + _gameRef->unregisterObject(_waypointGroups[i]); + } + _waypointGroups.clear(); + + for (uint32 i = 0; i < _scaleLevels.size(); i++) { + _gameRef->unregisterObject(_scaleLevels[i]); + } + _scaleLevels.clear(); + + for (uint32 i = 0; i < _rotLevels.size(); i++) { + _gameRef->unregisterObject(_rotLevels[i]); + } + _rotLevels.clear(); + + + for (uint32 i = 0; i < _pfPath.size(); i++) { + delete _pfPath[i]; + } + _pfPath.clear(); + _pfPointsNum = 0; + + for (uint32 i = 0; i < _objects.size(); i++) { + _gameRef->unregisterObject(_objects[i]); + } + _objects.clear(); + + delete _viewport; + _viewport = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester) { + if (!_pfReady) { + return false; + } else { + _pfReady = false; + *_pfTarget = target; + _pfTargetPath = path; + _pfRequester = requester; + + _pfTargetPath->reset(); + _pfTargetPath->setReady(false); + + // prepare working path + pfPointsStart(); + + // first point + //_pfPath.add(new AdPathPoint(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 AdPathPoint(target.x, target.y, INT_MAX)); + pfPointsAdd(target.x, target.y, INT_MAX); + + // active waypoints + for (uint32 i = 0; i < _waypointGroups.size(); i++) { + if (_waypointGroups[i]->_active) { + pfAddWaypointGroup(_waypointGroups[i], requester); + } + } + + + // free waypoints + 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 (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); + } + } + + return true; + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdScene::pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester) { + if (!wpt->_active) { + return; + } + + for (uint32 i = 0; i < wpt->_points.size(); i++) { + 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); + } +} + + +////////////////////////////////////////////////////////////////////////// +float AdScene::getZoomAt(int x, int y) { + float ret = 100; + + bool found = false; + if (_mainLayer) { + 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) { + ret = node->_region->_zoom; + found = true; + break; + } + } + } + } + if (!found) { + ret = getScaleAt(y); + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 AdScene::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.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) { + ret = node->_region->_alpha; + } + break; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { + bool ret = true; + + if (checkFreeObjects) { + 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; + } + } + } + AdGame *adGame = (AdGame *)_gameRef; + 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; + } + } + } + } + + + if (_mainLayer) { + 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)) + { + 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 AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { + bool ret = false; + + if (checkFreeObjects) { + 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; + } + } + } + AdGame *adGame = (AdGame *)_gameRef; + 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; + } + } + } + } + + + if (_mainLayer) { + 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) { + ret = false; + break; + } else { + ret = true; + } + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *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) { + BaseUtils::swap(&x1, &x2); + BaseUtils::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) { + BaseUtils::swap(&x1, &x2); + BaseUtils::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 AdScene::pathFinderStep() { + int i; + // get lowest unmarked + int lowestDist = INT_MAX; + AdPathPoint *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.insert_at(0, new BasePoint(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 AdScene::initLoop() { +#ifdef _DEBUGxxxx + int nu_steps = 0; + uint32 start = _gameRef->_currentTime; + 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 && g_system->getMillis() - start <= _pfMaxTime) { + pathFinderStep(); + } +#endif + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); + } + + setFilename(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 AdScene::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; + BaseParser parser; + + 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: { + AdLayer *layer = new AdLayer(_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: { + AdWaypointGroup *wpt = new AdWaypointGroup(_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: { + AdScaleLevel *sl = new AdScaleLevel(_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: { + AdRotLevel *rl = new AdRotLevel(_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: { + AdEntity *entity = new AdEntity(_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 BaseSprite(_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 BaseViewport(_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.", getFilename()); + } + + + sortScaleLevels(); + sortRotLevels(); + + _initialized = true; + + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdScene::traverseNodes(bool doUpdate) { + if (!_initialized) { + return STATUS_OK; + } + + AdGame *adGame = (AdGame *)_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 (uint32 j = 0; j < _layers.size(); j++) { + 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->_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 (uint32 k = 0; k < _layers[j]->_nodes.size(); k++) { + AdSceneNode *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 AdScene::display() { + return traverseNodes(false); +} + +////////////////////////////////////////////////////////////////////////// +bool AdScene::updateFreeObjects() { + AdGame *adGame = (AdGame *)_gameRef; + // 3D-code removed + // bool is3DSet; + + // *** update all active objects + // is3DSet = false; + for (uint32 i = 0; i < adGame->_objects.size(); i++) { + if (!adGame->_objects[i]->_active) { + continue; + } + // 3D-code removed + adGame->_objects[i]->update(); + adGame->_objects[i]->_drawn = false; + } + + + for (uint32 i = 0; i < _objects.size(); 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 AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { + AdGame *adGame = (AdGame *)_gameRef; + BaseArray objects; + AdObject *obj; + + // global objects + 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); + } + } + + // scene objects + 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); + } + } + + // sort by _posY + Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); + + // display them + for (uint32 i = 0; i < objects.size(); 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 (uint32 i = 0; i < _objects.size(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->display(); + _objects[i]->_drawn = true; + } + } + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int AdScene::compareObjs(const void *obj1, const void *obj2) { + const AdObject *object1 = *(const AdObject *const *)obj1; + const AdObject *object2 = *(const AdObject *const *)obj2; + + if (object1->_posY < object2->_posY) { + return -1; + } else if (object1->_posY > object2->_posY) { + return 1; + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool AdScene::displayRegionContentOld(AdRegion *region) { + AdGame *adGame = (AdGame *)_gameRef; + AdObject *obj; + + // display all objects in region sorted by _posY + do { + obj = NULL; + int minY = INT_MAX; + + // global objects + 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; + } + } + + // scene objects + 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; + } + } + + + 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 (uint32 i = 0; i < _objects.size(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->display(); + _objects[i]->_drawn = true; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::update() { + return traverseNodes(true); +} + +////////////////////////////////////////////////////////////////////////// +void AdScene::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 AdScene::scrollToObject(BaseObject *object) { + 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); + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdScene::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 AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LoadActor") == 0) { + stack->correctParams(1); + AdActor *act = new AdActor(_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); + AdEntity *ent = new AdEntity(_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); + ScValue *val = stack->pop(); + + AdEntity *ent = new AdEntity(_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); + ScValue *val = stack->pop(); + AdObject *obj = (AdObject *)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); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + if (val1->isNative()) { + skipToObject((BaseObject *)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); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + if (val1->isNative()) { + scrollToObject((BaseObject *)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); + ScValue *val = stack->pop(); + if (val->isInt()) { + int layer = val->getInt(); + if (layer < 0 || layer >= (int32)_layers.size()) { + stack->pushNULL(); + } else { + stack->pushNative(_layers[layer], true); + } + } else { + const char *layerName = val->getString(); + bool layerFound = false; + for (uint32 i = 0; i < _layers.size(); i++) { + if (scumm_stricmp(layerName, _layers[i]->getName()) == 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 >= (int32)_waypointGroups.size()) { + 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(); + + BaseObject *node = getNodeByName(nodeName); + if (node) { + stack->pushNative((BaseScriptable *)node, true); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFreeNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFreeNode") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + AdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < (int32)_objects.size()) { + ret = _objects[index]; + } + } else { + const char *nodeName = val->getString(); + 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; + } + } + } + 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(); + ScValue *val = stack->pop(); + + bool includeDecors = false; + if (!val->isNULL()) { + includeDecors = val->getBool(); + } + + if (_mainLayer) { + 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) { + 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 BaseViewport(_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); + ScValue *val = stack->pop(); + + AdLayer *layer = new AdLayer(_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(); + ScValue *val = stack->pop(); + + AdLayer *layer = new AdLayer(_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 <= (int32)_layers.size() - 1) { + _layers.insert_at(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); + ScValue *val = stack->pop(); + + AdLayer *toDelete = NULL; + if (val->isNative()) { + BaseScriptable *temp = val->getNative(); + for (uint32 i = 0; i < _layers.size(); i++) { + if (_layers[i] == temp) { + toDelete = _layers[i]; + break; + } + } + } else { + int index = val->getInt(); + if (index >= 0 && index < (int32)_layers.size()) { + 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 (uint32 i = 0; i < _layers.size(); i++) { + if (_layers[i] == toDelete) { + _layers.remove_at(i); + _gameRef->unregisterObject(toDelete); + break; + } + } + stack->pushBool(true); + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdScene::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.size()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWaypointGroups (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumWaypointGroups") == 0) { + _scValue->setInt(_waypointGroups.size()); + 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.size()); + 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 BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdScene::scToString() { + return "[scene object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::addObject(AdObject *object) { + _objects.add(object); + return _gameRef->registerObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::removeObject(AdObject *object) { + for (uint32 i = 0; i < _objects.size(); i++) { + if (_objects[i] == object) { + _objects.remove_at(i); + return _gameRef->unregisterObject(object); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SCENE {\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + 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 (uint32 i = 0; i < _scripts.size(); 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"); + + BaseClass::saveAsText(buffer, indent + 2); + + // waypoints + buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); + for (uint32 i = 0; i < _waypointGroups.size(); i++) { + _waypointGroups[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // layers + buffer->putTextIndent(indent + 2, "; ----- layers\n"); + for (uint32 i = 0; i < _layers.size(); i++) { + _layers[i]->saveAsText(buffer, indent + 2); + } + + // scale levels + buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); + for (uint32 i = 0; i < _scaleLevels.size(); i++) { + _scaleLevels[i]->saveAsText(buffer, indent + 2); + } + + // rotation levels + buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); + for (uint32 i = 0; i < _rotLevels.size(); i++) { + _rotLevels[i]->saveAsText(buffer, indent + 2); + } + + + buffer->putTextIndent(indent + 2, "\n"); + + // free entities + buffer->putTextIndent(indent + 2, "; ----- free entities\n"); + 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; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::sortScaleLevels() { + if (_scaleLevels.size() == 0) { + return STATUS_OK; + } + bool changed; + do { + changed = false; + 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]; + _scaleLevels[i + 1] = sl; + + changed = true; + } + } + + } while (changed); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::sortRotLevels() { + if (_rotLevels.size() == 0) { + return STATUS_OK; + } + bool changed; + do { + changed = false; + 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]; + _rotLevels[i + 1] = rl; + + changed = true; + } + } + + } while (changed); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float AdScene::getScaleAt(int Y) { + AdScaleLevel *prev = NULL; + AdScaleLevel *next = NULL; + + for (uint32 i = 0; i < _scaleLevels.size(); i++) { + /* AdScaleLevel *xxx = _scaleLevels[i];*/ + /* int j = _scaleLevels.size(); */ + 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 AdScene::persist(BasePersistenceManager *persistMgr) { + BaseObject::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 AdScene::afterLoad() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +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; + + x1 = *targetX; + y1 = *targetY; + x2 = startX; + y2 = startY; + + + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); + + if (xLength > yLength) { + + 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 { + + 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 AdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, BaseObject *requester) { + int x = *argX; + int y = *argY; + + if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { + return STATUS_OK; + } + + // 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)) { + foundRight = true; + break; + } + } + + // 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)) { + foundLeft = true; + break; + } + } + + // 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)) { + foundUp = true; + break; + } + } + + // 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)) { + foundDown = true; + break; + } + } + + if (!foundLeft && !foundRight && !foundUp && !foundDown) { + return STATUS_OK; + } + + int offsetX = INT_MAX, offsetY = INT_MAX; + + if (foundLeft && foundRight) { + if (abs(lengthLeft) < abs(lengthRight)) { + offsetX = lengthLeft; + } else { + offsetX = lengthRight; + } + } else if (foundLeft) { + offsetX = lengthLeft; + } else if (foundRight) { + offsetX = lengthRight; + } + + 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 (!isWalkableAt(*argX, *argY)) { + return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdScene::pfPointsStart() { + _pfPointsNum = 0; +} + + +////////////////////////////////////////////////////////////////////////// +void AdScene::pfPointsAdd(int x, int y, int distance) { + if (_pfPointsNum >= (int32)_pfPath.size()) { + _pfPath.add(new AdPathPoint(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 AdScene::getViewportOffset(int *offsetX, int *offsetY) { + AdGame *adGame = (AdGame *)_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 AdScene::getViewportSize(int *width, int *height) { + AdGame *adGame = (AdGame *)_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 AdScene::getOffsetLeft() { + int viewportX; + getViewportOffset(&viewportX); + + return _offsetLeft - viewportX; +} + + +////////////////////////////////////////////////////////////////////////// +int AdScene::getOffsetTop() { + int viewportY; + getViewportOffset(NULL, &viewportY); + + return _offsetTop - viewportY; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::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 AdScene::setOffset(int offsetLeft, int offsetTop) { + _offsetLeft = offsetLeft; + _offsetTop = offsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +BaseObject *AdScene::getNodeByName(const char *name) { + BaseObject *ret = NULL; + + // dependent objects + for (uint32 i = 0; i < _layers.size(); i++) { + AdLayer *layer = _layers[i]; + 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()))) { + 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 (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 (uint32 i = 0; i < _waypointGroups.size(); i++) { + if (!scumm_stricmp(name, _waypointGroups[i]->getName())) { + return _waypointGroups[i]; + } + } + + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::saveState() { + return persistState(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::loadState() { + return persistState(false); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::persistState(bool saving) { + if (!_persistentState) { + return STATUS_OK; + } + + AdGame *adGame = (AdGame *)_gameRef; + AdSceneState *state = adGame->getSceneState(getFilename(), saving); + if (!state) { + return STATUS_OK; + } + + AdNodeState *nodeState; + + // dependent objects + for (uint32 i = 0; i < _layers.size(); i++) { + AdLayer *layer = _layers[i]; + for (uint32 j = 0; j < layer->_nodes.size(); j++) { + AdSceneNode *node = layer->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: + if (!node->_entity->_saveState) { + continue; + } + nodeState = state->getNodeState(node->_entity->getName(), 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->getName(), saving); + if (nodeState) { + if (saving) { + nodeState->_active = node->_region->_active; + } else { + node->_region->_active = nodeState->_active; + } + } + break; + default: + warning("AdScene::PersistState - unhandled enum"); + break; + } + } + } + + // free entities + for (uint32 i = 0; i < _objects.size(); i++) { + if (!_objects[i]->_saveState) { + continue; + } + if (_objects[i]->_type == OBJECT_ENTITY) { + nodeState = state->getNodeState(_objects[i]->getName(), saving); + if (nodeState) { + nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving); + //if (Saving) NodeState->_active = _objects[i]->_active; + //else _objects[i]->_active = NodeState->_active; + } + } + } + + // waypoint groups + for (uint32 i = 0; i < _waypointGroups.size(); i++) { + nodeState = state->getNodeState(_waypointGroups[i]->getName(), saving); + if (nodeState) { + if (saving) { + nodeState->_active = _waypointGroups[i]->_active; + } else { + _waypointGroups[i]->_active = nodeState->_active; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float AdScene::getRotationAt(int x, int y) { + AdRotLevel *prev = NULL; + AdRotLevel *next = NULL; + + for (uint32 i = 0; i < _rotLevels.size(); i++) { + /* AdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.size();*/ + 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 AdScene::handleItemAssociations(const char *itemName, bool show) { + for (uint32 i = 0; i < _layers.size(); i++) { + AdLayer *layer = _layers[i]; + for (uint32 j = 0; j < layer->_nodes.size(); j++) { + if (layer->_nodes[j]->_type == OBJECT_ENTITY) { + AdEntity *ent = layer->_nodes[j]->_entity; + + if (ent->_item && strcmp(ent->_item, itemName) == 0) { + ent->_active = show; + } + } + } + } + + 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) { + ent->_active = show; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::getRegionsAt(int x, int y, AdRegion **regionList, int numRegions) { + int numUsed = 0; + if (_mainLayer) { + 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) { + regionList[numUsed] = node->_region; + numUsed++; + } else { + break; + } + } + } + } + for (int i = numUsed; i < numRegions; i++) { + regionList[i] = NULL; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdScene::restoreDeviceObjects() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { + BaseArray objects; + getSceneObjects(objects, true); + + if (objects.size() == 0) { + return NULL; + } else { + if (currObject != NULL) { + for (uint32 i = 0; i < objects.size(); i++) { + if (objects[i] == currObject) { + if (i < objects.size() - 1) { + return objects[i + 1]; + } else { + break; + } + } + } + } + return objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { + BaseArray objects; + getSceneObjects(objects, true); + + if (objects.size() == 0) { + return NULL; + } else { + if (currObject != NULL) { + for (int i = objects.size() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) { + return objects[i - 1]; + } else { + break; + } + } + } + } + return objects[objects.size() - 1]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { + for (uint32 i = 0; i < _layers.size(); i++) { + // close-up layer -> remove everything below it + if (interactiveOnly && _layers[i]->_closeUp) { + objects.clear(); + } + + + for (uint32 j = 0; j < _layers[i]->_nodes.size(); j++) { + AdSceneNode *node = _layers[i]->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: { + AdEntity *ent = node->_entity; + if (ent->_active && (ent->_registrable || !interactiveOnly)) { + objects.add(ent); + } + } + break; + + case OBJECT_REGION: { + BaseArray regionObj; + getRegionObjects(node->_region, regionObj, interactiveOnly); + for (uint32 newIndex = 0; newIndex < regionObj.size(); newIndex++) { + bool found = false; + for (uint32 old = 0; old < objects.size(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; + break; + } + } + if (!found) { + objects.add(regionObj[newIndex]); + } + } + //if (regionObj.size() > 0) Objects.Append(RegionObj); + } + break; + default: + debugC(kWintermuteDebugGeneral, "AdScene::GetSceneObjects - Unhandled enum"); + break; + } + } + } + + // objects outside any region + BaseArray regionObj; + getRegionObjects(NULL, regionObj, interactiveOnly); + for (uint32 newIndex = 0; newIndex < regionObj.size(); newIndex++) { + bool found = false; + for (uint32 old = 0; old < objects.size(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; + break; + } + } + if (!found) { + objects.add(regionObj[newIndex]); + } + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, bool interactiveOnly) { + AdGame *adGame = (AdGame *)_gameRef; + AdObject *obj; + + // global objects + 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) { + continue; + } + + objects.add(obj); + } + } + + // scene objects + 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) { + continue; + } + + objects.add(obj); + } + } + + // sort by _posY + Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index 20b3f5026d..c9c0e413bf 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -1,181 +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 UIWindow; -class AdObject; -class AdRegion; -class BaseViewport; -class AdLayer; -class BasePoint; -class AdWaypointGroup; -class AdPath; -class AdScaleLevel; -class AdRotLevel; -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); - - bool afterLoad(); - - 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); - 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); - int getOffsetTop(); - int getOffsetLeft(); - 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 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); - 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(); - 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); - bool _paralaxScrolling; - void skipTo(int offsetX, int offsetY); - void setDefaults(); - void cleanup(); - void skipToObject(BaseObject *object); - void scrollToObject(BaseObject *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, 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(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(AdObject *Object); - bool removeObject(AdObject *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; - BaseArray _scaleLevels; - BaseArray _rotLevels; - - virtual bool restoreDeviceObjects(); - int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); - - // 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: - bool persistState(bool saving = true); - void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *requester = NULL); - bool _pfReady; - BasePoint *_pfTarget; - AdPath *_pfTargetPath; - BaseObject *_pfRequester; - BaseArray _pfPath; - - int _offsetTop; - int _offsetLeft; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIWindow; +class AdObject; +class AdRegion; +class BaseViewport; +class AdLayer; +class BasePoint; +class AdWaypointGroup; +class AdPath; +class AdScaleLevel; +class AdRotLevel; +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); + + bool afterLoad(); + + 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); + 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); + int getOffsetTop(); + int getOffsetLeft(); + 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 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); + 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(); + 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); + bool _paralaxScrolling; + void skipTo(int offsetX, int offsetY); + void setDefaults(); + void cleanup(); + void skipToObject(BaseObject *object); + void scrollToObject(BaseObject *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, 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(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(AdObject *Object); + bool removeObject(AdObject *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; + BaseArray _scaleLevels; + BaseArray _rotLevels; + + virtual bool restoreDeviceObjects(); + int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); + + // 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: + bool persistState(bool saving = true); + void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *requester = NULL); + bool _pfReady; + BasePoint *_pfTarget; + AdPath *_pfTargetPath; + BaseObject *_pfRequester; + BaseArray _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 index 4f6acdbc95..d0202236fd 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -1,82 +1,82 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_node.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdSceneNode, false) - -////////////////////////////////////////////////////////////////////////// -AdSceneNode::AdSceneNode(BaseGame *inGame) : BaseObject(inGame) { - _type = OBJECT_NONE; - _region = NULL; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdSceneNode::~AdSceneNode() { - _gameRef->unregisterObject(_region); - _region = NULL; - - _gameRef->unregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSceneNode::setEntity(AdEntity *entity) { - _type = OBJECT_ENTITY; - _entity = entity; - return _gameRef->registerObject(entity); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSceneNode::setRegion(AdRegion *region) { - _type = OBJECT_REGION; - _region = region; - return _gameRef->registerObject(region); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSceneNode::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_entity)); - persistMgr->transfer(TMEMBER(_region)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_node.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdSceneNode, false) + +////////////////////////////////////////////////////////////////////////// +AdSceneNode::AdSceneNode(BaseGame *inGame) : BaseObject(inGame) { + _type = OBJECT_NONE; + _region = NULL; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdSceneNode::~AdSceneNode() { + _gameRef->unregisterObject(_region); + _region = NULL; + + _gameRef->unregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSceneNode::setEntity(AdEntity *entity) { + _type = OBJECT_ENTITY; + _entity = entity; + return _gameRef->registerObject(entity); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSceneNode::setRegion(AdRegion *region) { + _type = OBJECT_REGION; + _region = region; + return _gameRef->registerObject(region); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSceneNode::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 index 8cc50b86c4..5bb1606d0e 100644 --- a/engines/wintermute/ad/ad_scene_node.h +++ b/engines/wintermute/ad/ad_scene_node.h @@ -1,54 +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 AdSceneNode : public BaseObject { -public: - DECLARE_PERSISTENT(AdSceneNode, BaseObject) - bool setRegion(AdRegion *region); - bool setEntity(AdEntity *entity); - AdEntity *_entity; - AdRegion *_region; - TObjectType _type; - AdSceneNode(BaseGame *inGame); - virtual ~AdSceneNode(); - -}; - -} - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdSceneNode : public BaseObject { +public: + DECLARE_PERSISTENT(AdSceneNode, BaseObject) + bool setRegion(AdRegion *region); + bool setEntity(AdEntity *entity); + AdEntity *_entity; + AdRegion *_region; + TObjectType _type; + AdSceneNode(BaseGame *inGame); + virtual ~AdSceneNode(); + +}; + +} + +#endif diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 04fd52c382..c09e6a259c 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -1,95 +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 - */ - -#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(AdSceneState, false) - -////////////////////////////////////////////////////////////////////////// -AdSceneState::AdSceneState(BaseGame *inGame) : BaseClass(inGame) { - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdSceneState::~AdSceneState() { - delete[] _filename; - _filename = NULL; - - for (uint32 i = 0; i < _nodeStates.size(); i++) { - delete _nodeStates[i]; - } - _nodeStates.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSceneState::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_filename)); - _nodeStates.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void AdSceneState::setFilename(const char *filename) { - delete[] _filename; - _filename = new char [strlen(filename) + 1]; - if (_filename) { - strcpy(_filename, filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { - for (uint32 i = 0; i < _nodeStates.size(); i++) { - if (scumm_stricmp(_nodeStates[i]->getName(), name) == 0) { - return _nodeStates[i]; - } - } - - if (saving) { - AdNodeState *ret = new AdNodeState(_gameRef); - ret->setName(name); - _nodeStates.add(ret); - - return ret; - } else { - return NULL; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(AdSceneState, false) + +////////////////////////////////////////////////////////////////////////// +AdSceneState::AdSceneState(BaseGame *inGame) : BaseClass(inGame) { + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdSceneState::~AdSceneState() { + delete[] _filename; + _filename = NULL; + + for (uint32 i = 0; i < _nodeStates.size(); i++) { + delete _nodeStates[i]; + } + _nodeStates.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSceneState::persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_filename)); + _nodeStates.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void AdSceneState::setFilename(const char *filename) { + delete[] _filename; + _filename = new char [strlen(filename) + 1]; + if (_filename) { + strcpy(_filename, filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { + for (uint32 i = 0; i < _nodeStates.size(); i++) { + if (scumm_stricmp(_nodeStates[i]->getName(), name) == 0) { + return _nodeStates[i]; + } + } + + if (saving) { + AdNodeState *ret = new AdNodeState(_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 index 8298d23d76..2b25393c5a 100644 --- a/engines/wintermute/ad/ad_scene_state.h +++ b/engines/wintermute/ad/ad_scene_state.h @@ -1,51 +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 AdNodeState; -class AdSceneState : public BaseClass { -public: - AdNodeState *getNodeState(const char *name, bool saving); - void setFilename(const char *filename); - DECLARE_PERSISTENT(AdSceneState, BaseClass) - AdSceneState(BaseGame *inGame); - virtual ~AdSceneState(); - char *_filename; - BaseArray _nodeStates; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdNodeState; +class AdSceneState : public BaseClass { +public: + AdNodeState *getNodeState(const char *name, bool saving); + void setFilename(const char *filename); + DECLARE_PERSISTENT(AdSceneState, BaseClass) + AdSceneState(BaseGame *inGame); + virtual ~AdSceneState(); + char *_filename; + BaseArray _nodeStates; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 51765e3fe9..1f09d3ae0f 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -1,360 +1,360 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdSentence, false) - -////////////////////////////////////////////////////////////////////////// -AdSentence::AdSentence(BaseGame *inGame) : BaseClass(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; -} - - -////////////////////////////////////////////////////////////////////////// -AdSentence::~AdSentence() { - 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 AdSentence::setText(const char *text) { - if (_text) { - delete[] _text; - } - _text = new char[strlen(text) + 1]; - if (_text) { - strcpy(_text, text); - } -} - - -////////////////////////////////////////////////////////////////////////// -void AdSentence::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 *AdSentence::getCurrentStance() { - return getStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *AdSentence::getNextStance() { - _currentStance++; - return getStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *AdSentence::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) { - Common::strlcpy(_tempStance, start, curr - start + 1); - } - - return _tempStance; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSentence::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 - ((AdGame *)_gameRef)->_scene->getOffsetLeft(); - y = y - ((AdGame *)_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 AdSentence::setSound(BaseSound *sound) { - if (!sound) { - return; - } - delete _sound; - _sound = sound; - _soundStarted = false; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSentence::finish() { - if (_sound) { - _sound->stop(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSentence::persist(BasePersistenceManager *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 AdSentence::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"); - - if (!BaseFileManager::getEngineInstance()->hasFile(talkDefFileName)) { - return STATUS_OK; // no talk def file found - } - - _talkDef = new AdTalkDef(_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 AdSentence::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 (uint32 i = 0; i < _talkDef->_nodes.size(); i++) { - if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { - talkNodeFound = true; - - BaseSprite *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) { - BaseSprite *newSprite = _talkDef->getDefaultSprite(dir); - if (newSprite) { - if (newSprite != _currentSprite) { - newSprite->reset(); - } - _currentSprite = newSprite; - } else { - _currentSprite = NULL; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdSentence::canSkip() { - // prevent accidental sentence skipping (TODO make configurable) - return (_gameRef->_timer - _startTime) > 300; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdSentence, false) + +////////////////////////////////////////////////////////////////////////// +AdSentence::AdSentence(BaseGame *inGame) : BaseClass(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; +} + + +////////////////////////////////////////////////////////////////////////// +AdSentence::~AdSentence() { + 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 AdSentence::setText(const char *text) { + if (_text) { + delete[] _text; + } + _text = new char[strlen(text) + 1]; + if (_text) { + strcpy(_text, text); + } +} + + +////////////////////////////////////////////////////////////////////////// +void AdSentence::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 *AdSentence::getCurrentStance() { + return getStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *AdSentence::getNextStance() { + _currentStance++; + return getStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *AdSentence::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) { + Common::strlcpy(_tempStance, start, curr - start + 1); + } + + return _tempStance; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSentence::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 - ((AdGame *)_gameRef)->_scene->getOffsetLeft(); + y = y - ((AdGame *)_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 AdSentence::setSound(BaseSound *sound) { + if (!sound) { + return; + } + delete _sound; + _sound = sound; + _soundStarted = false; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSentence::finish() { + if (_sound) { + _sound->stop(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSentence::persist(BasePersistenceManager *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 AdSentence::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"); + + if (!BaseFileManager::getEngineInstance()->hasFile(talkDefFileName)) { + return STATUS_OK; // no talk def file found + } + + _talkDef = new AdTalkDef(_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 AdSentence::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 (uint32 i = 0; i < _talkDef->_nodes.size(); i++) { + if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { + talkNodeFound = true; + + BaseSprite *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) { + BaseSprite *newSprite = _talkDef->getDefaultSprite(dir); + if (newSprite) { + if (newSprite != _currentSprite) { + newSprite->reset(); + } + _currentSprite = newSprite; + } else { + _currentSprite = NULL; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdSentence::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 index 85be09094c..e7c94030b9 100644 --- a/engines/wintermute/ad/ad_sentence.h +++ b/engines/wintermute/ad/ad_sentence.h @@ -1,85 +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 AdTalkDef; -class BaseFont; -class BaseSprite; -class BaseSound; -class AdSentence : public BaseClass { -public: - bool _freezable; - bool _fixedPos; - BaseSprite *_currentSprite; - char *_currentSkelAnim; - bool update(TDirection dir = DI_DOWN); - bool setupTalkFile(const char *soundFilename); - DECLARE_PERSISTENT(AdSentence, BaseClass) - bool finish(); - void setSound(BaseSound *Sound); - bool _soundStarted; - BaseSound *_sound; - TTextAlign _align; - bool display(); - int _width; - Point32 _pos; - BaseFont *_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; - AdSentence(BaseGame *inGame); - virtual ~AdSentence(); - AdTalkDef *_talkDef; - - bool canSkip(); - -private: - char *_tempStance; - char *getStance(int stance); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdTalkDef; +class BaseFont; +class BaseSprite; +class BaseSound; +class AdSentence : public BaseClass { +public: + bool _freezable; + bool _fixedPos; + BaseSprite *_currentSprite; + char *_currentSkelAnim; + bool update(TDirection dir = DI_DOWN); + bool setupTalkFile(const char *soundFilename); + DECLARE_PERSISTENT(AdSentence, BaseClass) + bool finish(); + void setSound(BaseSound *Sound); + bool _soundStarted; + BaseSound *_sound; + TTextAlign _align; + bool display(); + int _width; + Point32 _pos; + BaseFont *_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; + AdSentence(BaseGame *inGame); + virtual ~AdSentence(); + AdTalkDef *_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 index 5b605d6e32..c8cdec03c3 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -1,356 +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 - */ - -#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" -#include "engines/wintermute/base/base_sprite.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdSpriteSet, false) - -////////////////////////////////////////////////////////////////////////// -AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner) : BaseObject(inGame) { - _owner = owner; - - for (int i = 0; i < NUM_DIRECTIONS; i++) { - _sprites[i] = NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -AdSpriteSet::~AdSpriteSet() { - for (int i = 0; i < NUM_DIRECTIONS; i++) { - delete _sprites[i]; - _sprites[i] = NULL; - } - - _owner = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdSpriteSet::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 AdSpriteSet::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; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { - _gameRef->LOG(0, "'SPRITESET' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - BaseSprite *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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 AdSpriteSet::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_owner)); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - persistMgr->transfer("", &_sprites[i]); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSprite *AdSpriteSet::getSprite(TDirection direction) { - int dir = (int)direction; - if (dir < 0) { - dir = 0; - } - if (dir >= NUM_DIRECTIONS) { - dir = NUM_DIRECTIONS - 1; - } - - BaseSprite *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 AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITESET {\n"); - if (getName()) { - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - } - 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]->getFilename()); - break; - case DI_UPRIGHT: - buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->getFilename()); - break; - case DI_RIGHT: - buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->getFilename()); - break; - case DI_DOWNRIGHT: - buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->getFilename()); - break; - case DI_DOWN: - buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->getFilename()); - break; - case DI_DOWNLEFT: - buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->getFilename()); - break; - case DI_LEFT: - buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->getFilename()); - break; - case DI_UPLEFT: - buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->getFilename()); - break; - } - } - } - - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool AdSpriteSet::containsSprite(BaseSprite *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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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" +#include "engines/wintermute/base/base_sprite.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdSpriteSet, false) + +////////////////////////////////////////////////////////////////////////// +AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner) : BaseObject(inGame) { + _owner = owner; + + for (int i = 0; i < NUM_DIRECTIONS; i++) { + _sprites[i] = NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +AdSpriteSet::~AdSpriteSet() { + for (int i = 0; i < NUM_DIRECTIONS; i++) { + delete _sprites[i]; + _sprites[i] = NULL; + } + + _owner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdSpriteSet::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 AdSpriteSet::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; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + _gameRef->LOG(0, "'SPRITESET' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + BaseSprite *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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 AdSpriteSet::persist(BasePersistenceManager *persistMgr) { + + BaseObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_owner)); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + persistMgr->transfer("", &_sprites[i]); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSprite *AdSpriteSet::getSprite(TDirection direction) { + int dir = (int)direction; + if (dir < 0) { + dir = 0; + } + if (dir >= NUM_DIRECTIONS) { + dir = NUM_DIRECTIONS - 1; + } + + BaseSprite *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 AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITESET {\n"); + if (getName()) { + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + } + 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]->getFilename()); + break; + case DI_UPRIGHT: + buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->getFilename()); + break; + case DI_RIGHT: + buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->getFilename()); + break; + case DI_DOWNRIGHT: + buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->getFilename()); + break; + case DI_DOWN: + buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->getFilename()); + break; + case DI_DOWNLEFT: + buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->getFilename()); + break; + case DI_LEFT: + buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->getFilename()); + break; + case DI_UPLEFT: + buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->getFilename()); + break; + } + } + } + + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool AdSpriteSet::containsSprite(BaseSprite *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 index 3855114850..ba5da0ff2e 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -1,53 +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_ADSPRITESET_H -#define WINTERMUTE_ADSPRITESET_H - - -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { -class BaseSprite; -class AdSpriteSet : public BaseObject { -public: - 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); - BaseSprite *_sprites[NUM_DIRECTIONS]; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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" + +namespace Wintermute { +class BaseSprite; +class AdSpriteSet : public BaseObject { +public: + 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); + BaseSprite *_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 index cd96345fc8..8cb489509b 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -1,285 +1,285 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdTalkDef, false) - -////////////////////////////////////////////////////////////////////////// -AdTalkDef::AdTalkDef(BaseGame *inGame) : BaseObject(inGame) { - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdTalkDef::~AdTalkDef() { - for (uint32 i = 0; i < _nodes.size(); i++) { - delete _nodes[i]; - } - _nodes.clear(); - - delete[] _defaultSpriteFilename; - delete _defaultSprite; - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - delete[] _defaultSpriteSetFilename; - delete _defaultSpriteSet; - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkDef::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdTalkDef::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; - BaseParser parser; - - 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: { - AdTalkNode *node = new AdTalkNode(_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: - BaseUtils::setString(&_defaultSpriteFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET_FILE: - BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET: { - delete _defaultSpriteSet; - _defaultSpriteSet = new AdSpriteSet(_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 BaseSprite(_gameRef); - 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; - } - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkDef::persist(BasePersistenceManager *persistMgr) { - - BaseObject::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 AdTalkDef::saveAsText(BaseDynamicBuffer *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 (uint32 i = 0; i < _nodes.size(); i++) { - _nodes[i]->saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "\n"); - } - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkDef::loadDefaultSprite() { - if (_defaultSpriteFilename && !_defaultSprite) { - _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 AdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - return STATUS_FAILED; - } 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; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdTalkDef, false) + +////////////////////////////////////////////////////////////////////////// +AdTalkDef::AdTalkDef(BaseGame *inGame) : BaseObject(inGame) { + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdTalkDef::~AdTalkDef() { + for (uint32 i = 0; i < _nodes.size(); i++) { + delete _nodes[i]; + } + _nodes.clear(); + + delete[] _defaultSpriteFilename; + delete _defaultSprite; + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + delete[] _defaultSpriteSetFilename; + delete _defaultSpriteSet; + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkDef::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdTalkDef::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; + BaseParser parser; + + 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: { + AdTalkNode *node = new AdTalkNode(_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: + BaseUtils::setString(&_defaultSpriteFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET_FILE: + BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET: { + delete _defaultSpriteSet; + _defaultSpriteSet = new AdSpriteSet(_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 BaseSprite(_gameRef); + 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; + } + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkDef::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 AdTalkDef::saveAsText(BaseDynamicBuffer *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 (uint32 i = 0; i < _nodes.size(); i++) { + _nodes[i]->saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "\n"); + } + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkDef::loadDefaultSprite() { + if (_defaultSpriteFilename && !_defaultSprite) { + _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 AdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + return STATUS_FAILED; + } 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; + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h index f748aa4e7a..d147212775 100644 --- a/engines/wintermute/ad/ad_talk_def.h +++ b/engines/wintermute/ad/ad_talk_def.h @@ -1,58 +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 AdTalkNode; -class AdSpriteSet; -class AdTalkDef : public BaseObject { -public: - char *_defaultSpriteSetFilename; - AdSpriteSet *_defaultSpriteSet; - BaseSprite *getDefaultSprite(TDirection Dir); - bool loadDefaultSprite(); - DECLARE_PERSISTENT(AdTalkDef, BaseObject) - - AdTalkDef(BaseGame *inGame); - virtual ~AdTalkDef(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - BaseArray _nodes; - char *_defaultSpriteFilename; - BaseSprite *_defaultSprite; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdTalkNode; +class AdSpriteSet; +class AdTalkDef : public BaseObject { +public: + char *_defaultSpriteSetFilename; + AdSpriteSet *_defaultSpriteSet; + BaseSprite *getDefaultSprite(TDirection Dir); + bool loadDefaultSprite(); + DECLARE_PERSISTENT(AdTalkDef, BaseObject) + + AdTalkDef(BaseGame *inGame); + virtual ~AdTalkDef(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + BaseArray _nodes; + char *_defaultSpriteFilename; + BaseSprite *_defaultSprite; + virtual bool saveAsText(BaseDynamicBuffer *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 index 89d7bd8a46..1e4ec26459 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -1,402 +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 "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/base/base_engine.h" -#include "common/str.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(AdTalkHolder, false) - -////////////////////////////////////////////////////////////////////////// -AdTalkHolder::AdTalkHolder(BaseGame *inGame) : AdObject(inGame) { - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -AdTalkHolder::~AdTalkHolder() { - delete _sprite; - _sprite = NULL; - - for (uint32 i = 0; i < _talkSprites.size(); i++) { - delete _talkSprites[i]; - } - _talkSprites.clear(); - - for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - delete _talkSpritesEx[i]; - } - _talkSpritesEx.clear(); -} - -////////////////////////////////////////////////////////////////////////// -BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { - BaseSprite *ret = NULL; - - - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new BaseSprite(_gameRef, this); - if (_animSprite) { - bool res = _animSprite->loadFile(_forcedTalkAnimName); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else { - return _animSprite; - } - } - } - - - if (stance != NULL) { - // search special talk stances - for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { - ret = _talkSpritesEx[i]; - break; - } - } - if (ret == NULL) { - // serach generic talk stances - for (uint32 i = 0; i < _talkSprites.size(); i++) { - if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { - ret = _talkSprites[i]; - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.size() < 1) { - ret = _sprite; - } else { - // TODO: remember last - int rnd = BaseEngine::instance().randInt(0, _talkSprites.size() - 1); - ret = _talkSprites[rnd]; - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSprite") == 0) { - stack->correctParams(1); - - ScValue *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(); - 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); - } 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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_sprite->getFilename()); - } - 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(); - - 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); - } - 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 (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->getFilename(), filename) == 0) { - if (_currentSprite == _talkSpritesEx[i]) { - setCurrent = true; - } - if (_tempSprite2 == _talkSpritesEx[i]) { - setTemp2 = true; - } - delete _talkSpritesEx[i]; - _talkSpritesEx.remove_at(i); - break; - } - } - } else { - for (uint32 i = 0; i < _talkSprites.size(); i++) { - if (scumm_stricmp(_talkSprites[i]->getFilename(), filename) == 0) { - if (_currentSprite == _talkSprites[i]) { - setCurrent = true; - } - if (_tempSprite2 == _talkSprites[i]) { - setTemp2 = true; - } - delete _talkSprites[i]; - _talkSprites.remove_at(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; - - 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); - } else { - - // delete current - if (ex) { - for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - if (_talkSpritesEx[i] == _currentSprite) { - setCurrent = true; - } - if (_talkSpritesEx[i] == _tempSprite2) { - setTemp2 = true; - } - delete _talkSpritesEx[i]; - } - _talkSpritesEx.clear(); - } else { - for (uint32 i = 0; i < _talkSprites.size(); i++) { - if (_talkSprites[i] == _currentSprite) { - setCurrent = true; - } - if (_talkSprites[i] == _tempSprite2) { - setTemp2 = true; - } - delete _talkSprites[i]; - } - _talkSprites.clear(); - } - - // 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 AdObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdTalkHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("talk-holder"); - return _scValue; - } else { - return AdObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkHolder::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Item")==0){ - SetItem(value->getString()); - return STATUS_OK; - } - - else*/ return AdObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *AdTalkHolder::scToString() { - return "[talk-holder object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { - for (uint32 i = 0; i < _talkSprites.size(); i++) { - if (_talkSprites[i]->getFilename()) { - buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->getFilename()); - } - } - - for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { - if (_talkSpritesEx[i]->getFilename()) { - buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->getFilename()); - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkHolder::persist(BasePersistenceManager *persistMgr) { - AdObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_sprite)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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/base/base_engine.h" +#include "common/str.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(AdTalkHolder, false) + +////////////////////////////////////////////////////////////////////////// +AdTalkHolder::AdTalkHolder(BaseGame *inGame) : AdObject(inGame) { + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +AdTalkHolder::~AdTalkHolder() { + delete _sprite; + _sprite = NULL; + + for (uint32 i = 0; i < _talkSprites.size(); i++) { + delete _talkSprites[i]; + } + _talkSprites.clear(); + + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + delete _talkSpritesEx[i]; + } + _talkSpritesEx.clear(); +} + +////////////////////////////////////////////////////////////////////////// +BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { + BaseSprite *ret = NULL; + + + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new BaseSprite(_gameRef, this); + if (_animSprite) { + bool res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else { + return _animSprite; + } + } + } + + + if (stance != NULL) { + // search special talk stances + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { + ret = _talkSpritesEx[i]; + break; + } + } + if (ret == NULL) { + // serach generic talk stances + for (uint32 i = 0; i < _talkSprites.size(); i++) { + if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { + ret = _talkSprites[i]; + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.size() < 1) { + ret = _sprite; + } else { + // TODO: remember last + int rnd = BaseEngine::instance().randInt(0, _talkSprites.size() - 1); + ret = _talkSprites[rnd]; + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSprite") == 0) { + stack->correctParams(1); + + ScValue *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(); + 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); + } 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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_sprite->getFilename()); + } + 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(); + + 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); + } + 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 (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->getFilename(), filename) == 0) { + if (_currentSprite == _talkSpritesEx[i]) { + setCurrent = true; + } + if (_tempSprite2 == _talkSpritesEx[i]) { + setTemp2 = true; + } + delete _talkSpritesEx[i]; + _talkSpritesEx.remove_at(i); + break; + } + } + } else { + for (uint32 i = 0; i < _talkSprites.size(); i++) { + if (scumm_stricmp(_talkSprites[i]->getFilename(), filename) == 0) { + if (_currentSprite == _talkSprites[i]) { + setCurrent = true; + } + if (_tempSprite2 == _talkSprites[i]) { + setTemp2 = true; + } + delete _talkSprites[i]; + _talkSprites.remove_at(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; + + 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); + } else { + + // delete current + if (ex) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + if (_talkSpritesEx[i] == _currentSprite) { + setCurrent = true; + } + if (_talkSpritesEx[i] == _tempSprite2) { + setTemp2 = true; + } + delete _talkSpritesEx[i]; + } + _talkSpritesEx.clear(); + } else { + for (uint32 i = 0; i < _talkSprites.size(); i++) { + if (_talkSprites[i] == _currentSprite) { + setCurrent = true; + } + if (_talkSprites[i] == _tempSprite2) { + setTemp2 = true; + } + delete _talkSprites[i]; + } + _talkSprites.clear(); + } + + // 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 AdObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdTalkHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("talk-holder"); + return _scValue; + } else { + return AdObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkHolder::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Item")==0){ + SetItem(value->getString()); + return STATUS_OK; + } + + else*/ return AdObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *AdTalkHolder::scToString() { + return "[talk-holder object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { + if (_talkSprites[i]->getFilename()) { + buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->getFilename()); + } + } + + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { + if (_talkSpritesEx[i]->getFilename()) { + buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->getFilename()); + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkHolder::persist(BasePersistenceManager *persistMgr) { + AdObject::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 index 906c469b32..ce10364b3d 100644 --- a/engines/wintermute/ad/ad_talk_holder.h +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -1,57 +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 AdTalkHolder : public AdObject { -public: - 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 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(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdTalkHolder : public AdObject { +public: + 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 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(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index 6d793f483c..b43a2b288e 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -1,295 +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/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(AdTalkNode, false) - -////////////////////////////////////////////////////////////////////////// -AdTalkNode::AdTalkNode(BaseGame *inGame) : BaseClass(inGame) { - _sprite = NULL; - _spriteFilename = NULL; - _spriteSet = NULL; - _spriteSetFilename = NULL; - _comment = NULL; - - _startTime = _endTime = 0; - _playToEnd = false; - _preCache = false; -} - - -////////////////////////////////////////////////////////////////////////// -AdTalkNode::~AdTalkNode() { - 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 AdTalkNode::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; - BaseParser parser; - - 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: - BaseUtils::setString(&_spriteFilename, (char *)params); - break; - - case TOKEN_SPRITESET_FILE: - BaseUtils::setString(&_spriteSetFilename, (char *)params); - break; - - case TOKEN_SPRITESET: { - delete _spriteSet; - _spriteSet = new AdSpriteSet(_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) { - BaseUtils::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 BaseSprite(_gameRef); - 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))) { - return STATUS_FAILED; - } - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkNode::persist(BasePersistenceManager *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 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); - 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); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdTalkNode::loadSprite() { - if (_spriteFilename && !_sprite) { - _sprite = new BaseSprite(_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 AdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { - delete _spriteSet; - _spriteSet = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -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; - } -} - - -////////////////////////////////////////////////////////////////////////// -BaseSprite *AdTalkNode::getSprite(TDirection dir) { - loadSprite(); - if (_sprite) { - return _sprite; - } else if (_spriteSet) { - return _spriteSet->getSprite(dir); - } else { - return NULL; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(AdTalkNode, false) + +////////////////////////////////////////////////////////////////////////// +AdTalkNode::AdTalkNode(BaseGame *inGame) : BaseClass(inGame) { + _sprite = NULL; + _spriteFilename = NULL; + _spriteSet = NULL; + _spriteSetFilename = NULL; + _comment = NULL; + + _startTime = _endTime = 0; + _playToEnd = false; + _preCache = false; +} + + +////////////////////////////////////////////////////////////////////////// +AdTalkNode::~AdTalkNode() { + 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 AdTalkNode::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; + BaseParser parser; + + 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: + BaseUtils::setString(&_spriteFilename, (char *)params); + break; + + case TOKEN_SPRITESET_FILE: + BaseUtils::setString(&_spriteSetFilename, (char *)params); + break; + + case TOKEN_SPRITESET: { + delete _spriteSet; + _spriteSet = new AdSpriteSet(_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) { + BaseUtils::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 BaseSprite(_gameRef); + 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))) { + return STATUS_FAILED; + } + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkNode::persist(BasePersistenceManager *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 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); + 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); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdTalkNode::loadSprite() { + if (_spriteFilename && !_sprite) { + _sprite = new BaseSprite(_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 AdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { + delete _spriteSet; + _spriteSet = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +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; + } +} + + +////////////////////////////////////////////////////////////////////////// +BaseSprite *AdTalkNode::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 index 863f6d0a3b..7dfd861f85 100644 --- a/engines/wintermute/ad/ad_talk_node.h +++ b/engines/wintermute/ad/ad_talk_node.h @@ -1,63 +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 AdSpriteSet; -class BaseSprite; -class AdTalkNode : public BaseClass { -public: - char *_spriteSetFilename; - AdSpriteSet *_spriteSet; - BaseSprite *getSprite(TDirection dir); - bool isInTimeInterval(uint32 time, TDirection dir); - bool loadSprite(); - DECLARE_PERSISTENT(AdTalkNode, BaseClass) - - AdTalkNode(BaseGame *inGame); - virtual ~AdTalkNode(); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); - char *_spriteFilename; - BaseSprite *_sprite; - uint32 _startTime; - uint32 _endTime; - bool _playToEnd; - bool _preCache; - char *_comment; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdSpriteSet; +class BaseSprite; +class AdTalkNode : public BaseClass { +public: + char *_spriteSetFilename; + AdSpriteSet *_spriteSet; + BaseSprite *getSprite(TDirection dir); + bool isInTimeInterval(uint32 time, TDirection dir); + bool loadSprite(); + DECLARE_PERSISTENT(AdTalkNode, BaseClass) + + AdTalkNode(BaseGame *inGame); + virtual ~AdTalkNode(); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + char *_spriteFilename; + BaseSprite *_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 index 8db20bfc02..ae5882f4ee 100644 --- a/engines/wintermute/ad/ad_types.h +++ b/engines/wintermute/ad/ad_types.h @@ -1,107 +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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 8da62c9115..984ed75aeb 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -1,270 +1,270 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(AdWaypointGroup, false) - -////////////////////////////////////////////////////////////////////////// -AdWaypointGroup::AdWaypointGroup(BaseGame *inGame) : BaseObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; -} - - -////////////////////////////////////////////////////////////////////////// -AdWaypointGroup::~AdWaypointGroup() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void AdWaypointGroup::cleanup() { - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - _points.clear(); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdWaypointGroup::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 AdWaypointGroup::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; - BaseParser parser; - - 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 BasePoint(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 AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "WAYPOINTS {\n"); - 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); - - if (_scProp) { - _scProp->saveAsText(buffer, indent + 2); - } - BaseClass::saveAsText(buffer, indent + 2); - - for (uint32 i = 0; i < _points.size(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool AdWaypointGroup::persist(BasePersistenceManager *persistMgr) { - - BaseObject::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; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *AdWaypointGroup::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 BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool AdWaypointGroup::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - 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; - } - - cleanup(); - - 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); - - _points.add(new BasePoint(x + argX, y + argY)); - } - - _lastMimicScale = scale; - _lastMimicX = argX; - _lastMimicY = argY; - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(AdWaypointGroup, false) + +////////////////////////////////////////////////////////////////////////// +AdWaypointGroup::AdWaypointGroup(BaseGame *inGame) : BaseObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; +} + + +////////////////////////////////////////////////////////////////////////// +AdWaypointGroup::~AdWaypointGroup() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void AdWaypointGroup::cleanup() { + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + _points.clear(); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdWaypointGroup::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 AdWaypointGroup::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; + BaseParser parser; + + 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 BasePoint(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 AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WAYPOINTS {\n"); + 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); + + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } + BaseClass::saveAsText(buffer, indent + 2); + + for (uint32 i = 0; i < _points.size(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool AdWaypointGroup::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *AdWaypointGroup::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 BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool AdWaypointGroup::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + 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; + } + + cleanup(); + + 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); + + _points.add(new BasePoint(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 index a83c942652..5cf6da1d1a 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -1,58 +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 BasePoint; -class AdWaypointGroup : public BaseObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - 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; - AdWaypointGroup(BaseGame *inGame); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual ~AdWaypointGroup(); - BaseArray _points; - int _editorSelectedPoint; - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 BasePoint; +class AdWaypointGroup : public BaseObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + 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; + AdWaypointGroup(BaseGame *inGame); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual ~AdWaypointGroup(); + BaseArray _points; + int _editorSelectedPoint; + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 11f308a522..e351792e61 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -1,185 +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 - */ - -#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 { - -////////////////////////////////////////////////////////////////////// -BaseClass::BaseClass(BaseGame *gameOwner) { - _gameRef = gameOwner; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////////// -BaseClass::BaseClass() { - _gameRef = NULL; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////// -BaseClass::~BaseClass() { - _editorProps.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -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(); - } else { - return initVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) { - if (propName.size() == 0) { - return STATUS_FAILED; - } - - if (propValue.size() == 0) { - _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 BaseClass::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; - BaseParser parser; - - 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 BaseClass::saveAsText(BaseDynamicBuffer *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, "}\n\n"); - - _editorPropsIter++; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.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 { + +////////////////////////////////////////////////////////////////////// +BaseClass::BaseClass(BaseGame *gameOwner) { + _gameRef = gameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +BaseClass::BaseClass() { + _gameRef = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +BaseClass::~BaseClass() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +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(); + } else { + return initVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) { + if (propName.size() == 0) { + return STATUS_FAILED; + } + + if (propValue.size() == 0) { + _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 BaseClass::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; + BaseParser parser; + + 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 BaseClass::saveAsText(BaseDynamicBuffer *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, "}\n\n"); + + _editorPropsIter++; + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index f4c1cf0739..24820c748a 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -1,62 +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_BASE_BASE_H -#define WINTERMUTE_BASE_BASE_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 BaseGame; -class BaseDynamicBuffer; - -class BaseClass { -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) {} - bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); - BaseClass(); - BaseClass(BaseGame *GameOwner); - virtual ~BaseClass(); - BaseGame *_gameRef; -protected: - Common::HashMap _editorProps; - Common::HashMap::iterator _editorPropsIter; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_BASE_H +#define WINTERMUTE_BASE_BASE_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 BaseGame; +class BaseDynamicBuffer; + +class BaseClass { +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) {} + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + BaseClass(); + BaseClass(BaseGame *GameOwner); + virtual ~BaseClass(); + BaseGame *_gameRef; +protected: + Common::HashMap _editorProps; + Common::HashMap::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 index 46870a0d29..d754cf0114 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -1,110 +1,110 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 { - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { - BasePlatform::setRectEmpty(&_rect); - _owner = NULL; - _frame = NULL; - _region = NULL; - _zoomX = 100; - _zoomY = 100; - _offsetX = _offsetY = 0; - clipRect(); -} - - -////////////////////////////////////////////////////////////////////// -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); - _zoomX = zoomX; - _zoomY = zoomY; - _precise = precise; - _region = NULL; - _offsetX = _offsetY = 0; - clipRect(); -} - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY) : BaseClass(inGame) { - _owner = owner; - _region = region; - BasePlatform::copyRect(&_rect, ®ion->_rect); - _rect.offsetRect(-offsetX, -offsetY); - _zoomX = 100; - _zoomY = 100; - _precise = true; - _frame = NULL; - clipRect(); - _offsetX = offsetX; - _offsetY = offsetY; -} - - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::~BaseActiveRect() { - _owner = NULL; - _frame = NULL; - _region = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseActiveRect::clipRect() { - Rect32 rc; - bool customViewport; - _gameRef->getCurrentViewportRect(&rc, &customViewport); - BaseRenderer *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; - } - - BasePlatform::intersectRect(&_rect, &_rect, &rc); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 { + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + clipRect(); +} + + +////////////////////////////////////////////////////////////////////// +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); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; + _region = NULL; + _offsetX = _offsetY = 0; + clipRect(); +} + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY) : BaseClass(inGame) { + _owner = owner; + _region = region; + BasePlatform::copyRect(&_rect, ®ion->_rect); + _rect.offsetRect(-offsetX, -offsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + clipRect(); + _offsetX = offsetX; + _offsetY = offsetY; +} + + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::~BaseActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseActiveRect::clipRect() { + Rect32 rc; + bool customViewport; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + BaseRenderer *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; + } + + 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 3c2cccfeed..fcd2619b03 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -1,60 +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_BASE_ACTIVE_RECT_H -#define WINTERMUTE_BASE_ACTIVE_RECT_H - -#include "engines/wintermute/math/rect32.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { -class BaseRegion; -class BaseSubFrame; -class BaseObject; -class BaseActiveRect: BaseClass { -public: - void clipRect(); - bool _precise; - float _zoomX; - float _zoomY; - BaseSubFrame *_frame; - BaseObject *_owner; - BaseRegion *_region; - int _offsetX; - int _offsetY; - Rect32 _rect; - 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(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_ACTIVE_RECT_H +#define WINTERMUTE_BASE_ACTIVE_RECT_H + +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { +class BaseRegion; +class BaseSubFrame; +class BaseObject; +class BaseActiveRect: BaseClass { +public: + void clipRect(); + bool _precise; + float _zoomX; + float _zoomY; + BaseSubFrame *_frame; + BaseObject *_owner; + BaseRegion *_region; + int _offsetX; + int _offsetY; + Rect32 _rect; + 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(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index b49d4ce150..fc48e93c2b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -1,204 +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/base/base_engine.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { - _buffer = NULL; - _size = 0; - _realSize = 0; - - _offset = 0; - _initSize = initSize; - _growBy = growBy; - - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::~BaseDynamicBuffer() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::cleanup() { - if (_buffer) { - free(_buffer); - } - _buffer = NULL; - _size = 0; - _realSize = 0; - _offset = 0; - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseDynamicBuffer::getSize() { - return _size; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::init(uint32 initSize) { - cleanup(); - - if (initSize == 0) { - initSize = _initSize; - } - - _buffer = (byte *)malloc(initSize); - if (!_buffer) { - BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); - return STATUS_FAILED; - } - - _realSize = initSize; - _initialized = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::putBytes(const byte *buffer, uint32 size) { - if (!_initialized) { - init(); - } - - while (_offset + size > _realSize) { - _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); - if (!_buffer) { - BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return STATUS_FAILED; - } - } - - memcpy(_buffer + _offset, buffer, size); - _offset += size; - _size += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) { - init(); - } - - if (_offset + size > _size) { - BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); - return STATUS_FAILED; - } - - memcpy(buffer, _buffer + _offset, size); - _offset += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putDWORD(uint32 val) { - putBytes((byte *)&val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseDynamicBuffer::getDWORD() { - uint32 ret; - getBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putString(const char *val) { - if (!val) { - putString("(null)"); - } else { - putDWORD(strlen(val) + 1); - putBytes((const byte *)val, strlen(val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseDynamicBuffer::getString() { - uint32 len = getDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) { - return NULL; - } else { - return ret; - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putText(const char *fmt, ...) { - va_list va; - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); - -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putTextIndent(int indent, const char *fmt, ...) { - va_list va; - - putText("%*s", indent, ""); - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { - char buff[32768]; - vsprintf(buff, format, argptr); - putBytes((byte *)buff, strlen(buff)); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_engine.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = initSize; + _growBy = growBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseDynamicBuffer::~BaseDynamicBuffer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::cleanup() { + if (_buffer) { + free(_buffer); + } + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseDynamicBuffer::getSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseDynamicBuffer::init(uint32 initSize) { + cleanup(); + + if (initSize == 0) { + initSize = _initSize; + } + + _buffer = (byte *)malloc(initSize); + if (!_buffer) { + BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); + return STATUS_FAILED; + } + + _realSize = initSize; + _initialized = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseDynamicBuffer::putBytes(const byte *buffer, uint32 size) { + if (!_initialized) { + init(); + } + + while (_offset + size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return STATUS_FAILED; + } + } + + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) { + init(); + } + + if (_offset + size > _size) { + BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); + return STATUS_FAILED; + } + + memcpy(buffer, _buffer + _offset, size); + _offset += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseDynamicBuffer::getDWORD() { + uint32 ret; + getBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putString(const char *val) { + if (!val) { + putString("(null)"); + } else { + putDWORD(strlen(val) + 1); + putBytes((const byte *)val, strlen(val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *BaseDynamicBuffer::getString() { + uint32 len = getDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) { + return NULL; + } else { + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putText(const char *fmt, ...) { + va_list va; + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putTextIndent(int indent, const char *fmt, ...) { + va_list va; + + putText("%*s", indent, ""); + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::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 index df35ad817d..b6f3e12b9c 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -1,66 +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_BASE_DYNAMIC_BUFFER_H -#define WINTERMUTE_BASE_DYNAMIC_BUFFER_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseDynamicBuffer { -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(const byte *buffer, uint32 size); - uint32 getSize(); - bool init(uint32 initSize = 0); - void cleanup(); - uint32 _size; - byte *_buffer; - BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~BaseDynamicBuffer(); - -private: - uint32 _realSize; - uint32 _growBy; - uint32 _initSize; - uint32 _offset; - void putTextForm(const char *format, va_list argptr); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H +#define WINTERMUTE_BASE_DYNAMIC_BUFFER_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseDynamicBuffer { +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(const byte *buffer, uint32 size); + uint32 getSize(); + bool init(uint32 initSize = 0); + void cleanup(); + uint32 _size; + byte *_buffer; + BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~BaseDynamicBuffer(); + +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 index 580a7afeb4..08e6f689ba 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -1,194 +1,194 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_fader.h" -#include "engines/wintermute/base/base_game.h" -#include "common/util.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseFader, false) - -////////////////////////////////////////////////////////////////////////// -BaseFader::BaseFader(BaseGame *inGame) : BaseObject(inGame) { - _active = false; - _red = _green = _blue = 0; - _currentAlpha = 0x00; - _sourceAlpha = 0; - _targetAlpha = 0; - _duration = 1000; - _startTime = 0; - _system = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFader::~BaseFader() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::update() { - if (!_active) { - return STATUS_OK; - } - - int alphaDelta = _targetAlpha - _sourceAlpha; - - uint32 time; - - if (_system) { - time = g_system->getMillis() - _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 BaseFader::display() { - if (!_active) { - return STATUS_OK; - } - - if (_currentAlpha > 0x00) { - _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::deactivate() { - _active = false; - _ready = true; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::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 = g_system->getMillis(); - } else { - _startTime = _gameRef->_timer; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::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 = g_system->getMillis(); - } else { - _startTime = _gameRef->_timer; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseFader::getCurrentColor() { - return BYTETORGBA(_red, _green, _blue, _currentAlpha); -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::persist(BasePersistenceManager *persistMgr) { - BaseObject::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->getIsSaving()) { - _startTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_fader.h" +#include "engines/wintermute/base/base_game.h" +#include "common/util.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseFader, false) + +////////////////////////////////////////////////////////////////////////// +BaseFader::BaseFader(BaseGame *inGame) : BaseObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFader::~BaseFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::update() { + if (!_active) { + return STATUS_OK; + } + + int alphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) { + time = g_system->getMillis() - _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 BaseFader::display() { + if (!_active) { + return STATUS_OK; + } + + if (_currentAlpha > 0x00) { + _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::deactivate() { + _active = false; + _ready = true; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::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 = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::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 = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseFader::getCurrentColor() { + return BYTETORGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::persist(BasePersistenceManager *persistMgr) { + BaseObject::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->getIsSaving()) { + _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 index 30072babfa..d3ced4aacc 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -1,63 +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_BASE_FADER_H -#define WINTERMUTE_BASE_FADER_H - - -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class BaseFader : public BaseObject { -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(BaseFader, BaseObject) - BaseFader(BaseGame *inGame); - virtual ~BaseFader(); -private: - bool _active; - byte _red; - byte _green; - byte _blue; - byte _currentAlpha; - byte _targetAlpha; - byte _sourceAlpha; - uint32 _duration; - uint32 _startTime; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FADER_H +#define WINTERMUTE_BASE_FADER_H + + +#include "engines/wintermute/base/base_object.h" + +namespace Wintermute { + +class BaseFader : public BaseObject { +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(BaseFader, BaseObject) + BaseFader(BaseGame *inGame); + virtual ~BaseFader(); +private: + 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 index f139d99146..b726c0c66f 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -1,340 +1,340 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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_engine.h" -#include "engines/wintermute/wintermute.h" -#include "common/debug.h" -#include "common/str.h" -#include "common/tokenizer.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" -#include "common/fs.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(Common::Language lang) { - _language = lang; - initPaths(); - registerPackages(); -} - -////////////////////////////////////////////////////////////////////// -BaseFileManager::~BaseFileManager() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::cleanup() { - // delete registered paths - _packagePaths.clear(); - - // close open files - for (uint32 i = 0; i < _openFiles.size(); i++) { - delete _openFiles[i]; - } - _openFiles.clear(); - - // delete packages - _packages.clear(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { - byte *buffer = NULL; - - Common::SeekableReadStream *file = openFile(filename); - if (!file) { - if (mustExist) { - 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); - closeFile(file); - return NULL; - } - - if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "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; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { - if (!path.exists()) { - return STATUS_FAILED; - } - - switch (type) { - case PATH_SINGLE: - // _singlePaths.push_back(path); - error("TODO: Allow adding single-paths"); - break; - case PATH_PACKAGE: - _packagePaths.push_back(path); - break; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::reloadPaths() { - // delete registered paths - //_singlePaths.clear(); - _packagePaths.clear(); - - return initPaths(); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::initPaths() { - // Removed: Config-based file-path choice. - - // package files paths - const Common::FSNode gameData(ConfMan.get("path")); - addPath(PATH_PACKAGE, gameData); - - Common::FSNode dataSubFolder = gameData.getChild("data"); - if (dataSubFolder.exists()) { - addPath(PATH_PACKAGE, dataSubFolder); - } - Common::FSNode languageSubFolder = gameData.getChild("language"); - if (languageSubFolder.exists()) { - addPath(PATH_PACKAGE, languageSubFolder); - } - return STATUS_OK; -} - -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))) { - addPath(PATH_PACKAGE, (*it)); - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::registerPackages() { - 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()); - (*it).getChildren(files, Common::FSNode::kListFilesOnly); - for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { - if (!fileIt->getName().hasSuffix(".dcp")) { - continue; - } - // Avoid registering all the language files - // TODO: Select based on the gameDesc. - if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") { - Common::String parentName = fileIt->getParent().getName(); - Common::String dcpName = fileIt->getName(); - 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; - } - } - 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()); - - return STATUS_OK; -} - -bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { - PackageSet *pack = new PackageSet(file, filename, searchSignature); - _packages.add(file.getName(), pack, pack->getPriority() , true); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -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 (uint32 i = 0; i < upcName.size(); i++) { - if (upcName[(int32)i] == '/') { - upcName.setChar('\\', (uint32)i); - } - } - Common::ArchiveMemberPtr entry = _packages.getMember(upcName); - if (!entry) { - return NULL; - } - file = entry->createReadStream(); - return file; -} - -bool BaseFileManager::hasFile(const Common::String &filename) { - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(BaseEngine::instance().getGameId()); - if (filename.size() <= 9) { - return false; - } - int slot = atoi(filename.c_str() + 9); - return pm.getSaveExists(slot); - } - 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)) { - return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - 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); - } - return file; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::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 *BaseFileManager::openFileRaw(const Common::String &filename) { - Common::SeekableReadStream *ret = NULL; - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!BaseEngine::instance().getGameRef()) { - error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); - } - BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); - if (DID_SUCCEED(saveThumbFile->open(filename))) { - ret = saveThumbFile->getMemStream(); - } - delete saveThumbFile; - return ret; - } - - ret = openDiskFile(filename); - if (ret) { - return ret; - } - - ret = openPkgFile(filename); - if (ret) { - return ret; - } - - ret = BaseResources::getFile(filename); - if (ret) { - return ret; - } - - debugC(kWintermuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); - return NULL; -} - -BaseFileManager *BaseFileManager::getEngineInstance() { - if (BaseEngine::instance().getFileManager()) { - return BaseEngine::instance().getFileManager(); - } - return NULL; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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_engine.h" +#include "engines/wintermute/wintermute.h" +#include "common/debug.h" +#include "common/str.h" +#include "common/tokenizer.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" +#include "common/fs.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +BaseFileManager::BaseFileManager(Common::Language lang) { + _language = lang; + initPaths(); + registerPackages(); +} + +////////////////////////////////////////////////////////////////////// +BaseFileManager::~BaseFileManager() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::cleanup() { + // delete registered paths + _packagePaths.clear(); + + // close open files + for (uint32 i = 0; i < _openFiles.size(); i++) { + delete _openFiles[i]; + } + _openFiles.clear(); + + // delete packages + _packages.clear(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { + byte *buffer = NULL; + + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) { + 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); + closeFile(file); + return NULL; + } + + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "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; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { + if (!path.exists()) { + return STATUS_FAILED; + } + + switch (type) { + case PATH_SINGLE: + // _singlePaths.push_back(path); + error("TODO: Allow adding single-paths"); + break; + case PATH_PACKAGE: + _packagePaths.push_back(path); + break; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::reloadPaths() { + // delete registered paths + //_singlePaths.clear(); + _packagePaths.clear(); + + return initPaths(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::initPaths() { + // Removed: Config-based file-path choice. + + // package files paths + const Common::FSNode gameData(ConfMan.get("path")); + addPath(PATH_PACKAGE, gameData); + + Common::FSNode dataSubFolder = gameData.getChild("data"); + if (dataSubFolder.exists()) { + addPath(PATH_PACKAGE, dataSubFolder); + } + Common::FSNode languageSubFolder = gameData.getChild("language"); + if (languageSubFolder.exists()) { + addPath(PATH_PACKAGE, languageSubFolder); + } + return STATUS_OK; +} + +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))) { + addPath(PATH_PACKAGE, (*it)); + } + } + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::registerPackages() { + 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()); + (*it).getChildren(files, Common::FSNode::kListFilesOnly); + for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { + if (!fileIt->getName().hasSuffix(".dcp")) { + continue; + } + // Avoid registering all the language files + // TODO: Select based on the gameDesc. + if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") { + Common::String parentName = fileIt->getParent().getName(); + Common::String dcpName = fileIt->getName(); + 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; + } + } + 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()); + + return STATUS_OK; +} + +bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { + PackageSet *pack = new PackageSet(file, filename, searchSignature); + _packages.add(file.getName(), pack, pack->getPriority() , true); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +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 (uint32 i = 0; i < upcName.size(); i++) { + if (upcName[(int32)i] == '/') { + upcName.setChar('\\', (uint32)i); + } + } + Common::ArchiveMemberPtr entry = _packages.getMember(upcName); + if (!entry) { + return NULL; + } + file = entry->createReadStream(); + return file; +} + +bool BaseFileManager::hasFile(const Common::String &filename) { + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + BasePersistenceManager pm(BaseEngine::instance().getGameId()); + if (filename.size() <= 9) { + return false; + } + int slot = atoi(filename.c_str() + 9); + return pm.getSaveExists(slot); + } + 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)) { + return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { + 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); + } + return file; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::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 *BaseFileManager::openFileRaw(const Common::String &filename) { + Common::SeekableReadStream *ret = NULL; + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + if (!BaseEngine::instance().getGameRef()) { + error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); + } + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); + if (DID_SUCCEED(saveThumbFile->open(filename))) { + ret = saveThumbFile->getMemStream(); + } + delete saveThumbFile; + return ret; + } + + ret = openDiskFile(filename); + if (ret) { + return ret; + } + + ret = openPkgFile(filename); + if (ret) { + return ret; + } + + ret = BaseResources::getFile(filename); + if (ret) { + return ret; + } + + debugC(kWintermuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + return NULL; +} + +BaseFileManager *BaseFileManager::getEngineInstance() { + if (BaseEngine::instance().getFileManager()) { + return BaseEngine::instance().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 3fb4434e9c..70aff49bbb 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -1,76 +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_BASE_FILE_MANAGER_H -#define WINTERMUTE_BASE_FILE_MANAGER_H - -#include "common/archive.h" -#include "common/str.h" -#include "common/fs.h" -#include "common/file.h" -#include "common/language.h" - -namespace Wintermute { -class BaseFileManager { -public: - bool cleanup(); - - bool closeFile(Common::SeekableReadStream *File); - bool hasFile(const Common::String &filename); - 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(Common::Language lang); - virtual ~BaseFileManager(); - // Used only for detection - bool registerPackages(const Common::FSList &fslist); - static BaseFileManager *getEngineInstance(); -private: - typedef enum { - PATH_PACKAGE, - PATH_SINGLE - } TPathType; - bool reloadPaths(); - bool initPaths(); - 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::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: -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FILE_MANAGER_H +#define WINTERMUTE_BASE_FILE_MANAGER_H + +#include "common/archive.h" +#include "common/str.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/language.h" + +namespace Wintermute { +class BaseFileManager { +public: + bool cleanup(); + + bool closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); + 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(Common::Language lang); + virtual ~BaseFileManager(); + // Used only for detection + bool registerPackages(const Common::FSList &fslist); + static BaseFileManager *getEngineInstance(); +private: + typedef enum { + PATH_PACKAGE, + PATH_SINGLE + } TPathType; + bool reloadPaths(); + bool initPaths(); + 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::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: +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index ed2c7acaca..e1b29a3a5c 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -1,760 +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/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(BaseFrame, false) - -////////////////////////////////////////////////////////////////////// -BaseFrame::BaseFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { - _delay = 0; - _moveX = _moveY = 0; - - _sound = NULL; - _killSound = false; - - _editorExpanded = false; - _keyframe = false; -} - - -////////////////////////////////////////////////////////////////////// -BaseFrame::~BaseFrame() { - delete _sound; - _sound = NULL; - - for (uint32 i = 0; i < _subframes.size(); i++) { - delete _subframes[i]; - } - _subframes.clear(); - - for (uint32 i = 0; i < _applyEvent.size(); i++) { - delete[] _applyEvent[i]; - _applyEvent[i] = NULL; - } - _applyEvent.clear(); -} - - -////////////////////////////////////////////////////////////////////// -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 (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; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { - if (_sound && !muted) { - if (owner) { - owner->updateOneSound(_sound); - } - _sound->play(); - /* - if (_gameRef->_state == GAME_FROZEN) { - _sound->Pause(true); - } - */ - } - if (owner) { - for (uint32 i = 0; i < _applyEvent.size(); 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 BaseFrame::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; - BaseParser parser; - 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; - BasePlatform::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: { - BaseSubFrame *subframe = new BaseSubFrame(_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 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; - _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; - } - - - 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 (!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 (BasePlatform::isRectEmpty(&rect)) { - sub->setDefaultRect(); - } else { - sub->setRect(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.insert_at(0, sub); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) { - return false; - } - BasePlatform::setRectEmpty(rect); - - Rect32 subRect; - - for (uint32 i = 0; i < _subframes.size(); i++) { - _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - BasePlatform::unionRect(rect, rect, &subRect); - } - return true; -} - - - -////////////////////////////////////////////////////////////////////////// -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) { - buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - } - - if (_sound && _sound->getFilename()) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename()); - } - - 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.size() > 0) { - _subframes[0]->saveAsText(buffer, indent, false); - } - - for (uint32 i = 1; i < _subframes.size(); i++) { - _subframes[i]->saveAsText(buffer, indent + 2); - } - - for (uint32 i = 0; i < _applyEvent.size(); i++) { - buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); - } - - BaseClass::saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::persist(BasePersistenceManager *persistMgr) { - BaseScriptable::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 BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSound") == 0) { - stack->correctParams(0); - - if (_sound && _sound->getFilename()) { - stack->pushString(_sound->getFilename()); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSound") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - delete _sound; - _sound = NULL; - - if (!val->isNULL()) { - _sound = new BaseSound(_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 >= (int32)_subframes.size()) { - 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); - ScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - if (index < 0 || index >= (int32)_subframes.size()) { - script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); - } - } else { - BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); - for (uint32 i = 0; i < _subframes.size(); i++) { - if (_subframes[i] == sub) { - delete _subframes[i]; - _subframes.remove_at(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSubframe") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) { - filename = val->getString(); - } - - BaseSubFrame *sub = new BaseSubFrame(_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; - } - - ScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) { - filename = val->getString(); - } - - BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - } - - if (index >= (int32)_subframes.size()) { - _subframes.add(sub); - } else { - _subframes.insert_at(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 >= (int32)_applyEvent.size()) { - 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 (uint32 i = 0; i < _applyEvent.size(); 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 (uint32 i = 0; i < _applyEvent.size(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete[] _applyEvent[i]; - _applyEvent.remove_at(i); - break; - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.size() == 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); - } - _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.size()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumEvents (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.size()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.size() == 1) { - return _subframes[0]->scGetProperty(name); - } else { - return BaseScriptable::scGetProperty(name); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::scSetProperty(const char *name, ScValue *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.size() == 1) { - return _subframes[0]->scSetProperty(name, value); - } else { - return BaseScriptable::scSetProperty(name, value); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseFrame::scToString() { - return "[frame]"; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseFrame, false) + +////////////////////////////////////////////////////////////////////// +BaseFrame::BaseFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +BaseFrame::~BaseFrame() { + delete _sound; + _sound = NULL; + + for (uint32 i = 0; i < _subframes.size(); i++) { + delete _subframes[i]; + } + _subframes.clear(); + + for (uint32 i = 0; i < _applyEvent.size(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.clear(); +} + + +////////////////////////////////////////////////////////////////////// +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 (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; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) { + owner->updateOneSound(_sound); + } + _sound->play(); + /* + if (_gameRef->_state == GAME_FROZEN) { + _sound->Pause(true); + } + */ + } + if (owner) { + for (uint32 i = 0; i < _applyEvent.size(); 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 BaseFrame::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; + BaseParser parser; + 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; + BasePlatform::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: { + BaseSubFrame *subframe = new BaseSubFrame(_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 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; + _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; + } + + + 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 (!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 (BasePlatform::isRectEmpty(&rect)) { + sub->setDefaultRect(); + } else { + sub->setRect(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.insert_at(0, sub); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) { + return false; + } + BasePlatform::setRectEmpty(rect); + + Rect32 subRect; + + for (uint32 i = 0; i < _subframes.size(); i++) { + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + BasePlatform::unionRect(rect, rect, &subRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +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) { + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + } + + if (_sound && _sound->getFilename()) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename()); + } + + 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.size() > 0) { + _subframes[0]->saveAsText(buffer, indent, false); + } + + for (uint32 i = 1; i < _subframes.size(); i++) { + _subframes[i]->saveAsText(buffer, indent + 2); + } + + for (uint32 i = 0; i < _applyEvent.size(); i++) { + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + BaseClass::saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::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 BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSound") == 0) { + stack->correctParams(0); + + if (_sound && _sound->getFilename()) { + stack->pushString(_sound->getFilename()); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSound") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + delete _sound; + _sound = NULL; + + if (!val->isNULL()) { + _sound = new BaseSound(_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 >= (int32)_subframes.size()) { + 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); + ScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= (int32)_subframes.size()) { + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + } + } else { + BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); + for (uint32 i = 0; i < _subframes.size(); i++) { + if (_subframes[i] == sub) { + delete _subframes[i]; + _subframes.remove_at(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSubframe") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) { + filename = val->getString(); + } + + BaseSubFrame *sub = new BaseSubFrame(_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; + } + + ScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) { + filename = val->getString(); + } + + BaseSubFrame *sub = new BaseSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + } + + if (index >= (int32)_subframes.size()) { + _subframes.add(sub); + } else { + _subframes.insert_at(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 >= (int32)_applyEvent.size()) { + 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 (uint32 i = 0; i < _applyEvent.size(); 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 (uint32 i = 0; i < _applyEvent.size(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + delete[] _applyEvent[i]; + _applyEvent.remove_at(i); + break; + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.size() == 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); + } + _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.size()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumEvents") == 0) { + _scValue->setInt(_applyEvent.size()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.size() == 1) { + return _subframes[0]->scGetProperty(name); + } else { + return BaseScriptable::scGetProperty(name); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::scSetProperty(const char *name, ScValue *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.size() == 1) { + return _subframes[0]->scSetProperty(name, value); + } else { + return BaseScriptable::scSetProperty(name, value); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseFrame::scToString() { + return "[frame]"; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index c89fb49e61..ea5467b6fe 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -1,73 +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_BASE_FRAME_H -#define WINTERMUTE_BASE_FRAME_H - -#include "engines/wintermute/base/base_scriptable.h" -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { -class BaseSound; -class BaseSubFrame; -class BaseObject; -class ScScript; -class ScStack; -class BaseFrame: public BaseScriptable { -public: - bool _killSound; - bool _keyframe; - 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(BaseDynamicBuffer *buffer, int indent); - int _moveY; - 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 loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - - BaseFrame(BaseGame *inGame); - virtual ~BaseFrame(); - - BaseArray _applyEvent; - - // 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(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FRAME_H +#define WINTERMUTE_BASE_FRAME_H + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { +class BaseSound; +class BaseSubFrame; +class BaseObject; +class ScScript; +class ScStack; +class BaseFrame: public BaseScriptable { +public: + bool _killSound; + bool _keyframe; + 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(BaseDynamicBuffer *buffer, int indent); + int _moveY; + 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 loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + + BaseFrame(BaseGame *inGame); + virtual ~BaseFrame(); + + BaseArray _applyEvent; + + // 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(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index e8aaac6c40..622e85cc11 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1,4483 +1,4483 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based 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_engine.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/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/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" -#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/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" -#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(BaseGame, true) - - -////////////////////////////////////////////////////////////////////// -BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { - _shuttingDown = false; - - _state = GAME_RUNNING; - _origState = GAME_RUNNING; - _freezeLevel = 0; - - _interactive = true; - _origInteractive = false; - - _surfaceStorage = NULL; - _fontStorage = NULL; - _renderer = NULL; - _soundMgr = NULL; - _transMgr = NULL; - _scEngine = NULL; - _keyboardState = NULL; - - _mathClass = NULL; - - _debugLogFile = NULL; - _debugDebugMode = false; - _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; - - _stringTable = new BaseStringTable(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; - - _richSavedGames = false; - _savedGameExt = NULL; - BaseUtils::setString(&_savedGameExt, "dsv"); - - _musicCrossfadeRunning = false; - _musicCrossfadeStartTime = 0; - _musicCrossfadeLength = 0; - _musicCrossfadeChannel1 = -1; - _musicCrossfadeChannel2 = -1; - _musicCrossfadeSwap = false; - - _localSaveDir = NULL; - BaseUtils::setString(&_localSaveDir, "saves"); - _saveDirChecked = false; - - _loadingIcon = NULL; - _loadingIconX = _loadingIconY = 0; - _loadingIconPersistent = false; - - _textEncoding = TEXT_ANSI; - _textRTL = false; - - _soundBufferSizeSec = 3; - _suspendedRendering = false; - - _lastCursor = NULL; - - - BasePlatform::setRectEmpty(&_mouseLockRect); - - _suppressScriptErrors = false; - _lastMiniUpdate = 0; - _miniUpdateEnabled = false; - - _cachedThumbnail = NULL; - - _autorunDisabled = false; - - // compatibility bits - _compatKillMethodThreads = false; - - _usedMem = 0; - - - _autoSaveOnExit = true; - _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 - #else*/ - _touchInterface = false; - _constrainedMemory = false; -//#endif - -} - - -////////////////////////////////////////////////////////////////////// -BaseGame::~BaseGame() { - _shuttingDown = true; - - LOG(0, ""); - LOG(0, "Shutting down..."); - - ConfMan.setBool("last_run", true); - - cleanup(); - - delete[] _localSaveDir; - delete[] _settingsGameFile; - delete[] _savedGameExt; - - delete _cachedThumbnail; - - delete _mathClass; - - delete _transMgr; - delete _scEngine; - delete _fontStorage; - delete _surfaceStorage; - delete _videoPlayer; - delete _theoraPlayer; - delete _soundMgr; - //SAFE_DELETE(_keyboardState); - - delete _renderer; - delete _stringTable; - - _localSaveDir = NULL; - _settingsGameFile = NULL; - _savedGameExt = NULL; - - _cachedThumbnail = NULL; - - _mathClass = NULL; - - _transMgr = NULL; - _scEngine = NULL; - _fontStorage = NULL; - _surfaceStorage = NULL; - _videoPlayer = NULL; - _theoraPlayer = NULL; - _soundMgr = NULL; - - _renderer = NULL; - _stringTable = NULL; - - DEBUG_DebugDisable(); - debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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 (uint32 i = 0; i < _regObjects.size(); i++) { - delete _regObjects[i]; - _regObjects[i] = NULL; - } - _regObjects.clear(); - - _windows.clear(); // refs only - _focusedWindow = NULL; // ref only - - delete _cursorNoninteractive; - delete _cursor; - delete _activeCursor; - _cursorNoninteractive = NULL; - _cursor = NULL; - _activeCursor = NULL; - - delete _scValue; - delete _sFX; - _scValue = NULL; - _sFX = NULL; - - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->_owner = NULL; - _scripts[i]->finish(); - } - _scripts.clear(); - - _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - for (uint32 i = 0; i < _quickMessages.size(); i++) { - delete _quickMessages[i]; - } - _quickMessages.clear(); - - _viewportStack.clear(); - _viewportSP = -1; - - setName(NULL); - setFilename(NULL); - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _lastCursor = NULL; - - delete _keyboardState; - _keyboardState = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initialize1() { - bool loaded = false; // Not really a loop, but a goto-replacement. - while (!loaded) { - _surfaceStorage = new BaseSurfaceStorage(this); - if (_surfaceStorage == NULL) { - break; - } - - _fontStorage = new BaseFontStorage(this); - if (_fontStorage == NULL) { - break; - } - - _soundMgr = new BaseSoundMgr(this); - if (_soundMgr == NULL) { - break; - } - - _mathClass = new SXMath(this); - if (_mathClass == NULL) { - break; - } - - _scEngine = new ScEngine(this); - if (_scEngine == NULL) { - break; - } - - _videoPlayer = new VideoPlayer(this); - if (_videoPlayer == NULL) { - break; - } - - _transMgr = new BaseTransitionMgr(this); - if (_transMgr == NULL) { - break; - } - - _keyboardState = new BaseKeyboardState(this); - if (_keyboardState == NULL) { - break; - } - - _fader = new BaseFader(this); - if (_fader == NULL) { - break; - } - registerObject(_fader); - - loaded = true; - } - if (loaded == true) { - return STATUS_OK; - } else { - delete _mathClass; - delete _keyboardState; - delete _transMgr; - delete _surfaceStorage; - delete _fontStorage; - delete _soundMgr; - delete _scEngine; - delete _videoPlayer; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initialize2() { // we know whether we are going to be accelerated - _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) { - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initialize3() { // renderer is initialized - _posX = _renderer->_width / 2; - _posY = _renderer->_height / 2; - _renderer->initIndicator(); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void BaseGame::DEBUG_DebugEnable(const char *filename) { - _debugDebugMode = true; - - 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); - - AnsiString platform = BasePlatform::getPlatformName(); - LOG(0, "Platform: %s", platform.c_str()); - LOG(0, ""); -} - - -////////////////////////////////////////////////////////////////////// -void BaseGame::DEBUG_DebugDisable() { - if (_debugLogFile != NULL) { - LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - //fclose((FILE *)_debugLogFile); - _debugLogFile = NULL; - } - _debugDebugMode = false; -} - - -////////////////////////////////////////////////////////////////////// -void BaseGame::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); - } - - 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 BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { - _engineLogCallback = callback; - _engineLogCallbackData = data; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initLoop() { - _viewportSP = -1; - - _currentTime = g_system->getMillis(); - - _renderer->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.size() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { - _focusedWindow = _windows[i]; - break; - } - } - - updateSounds(); - - if (_fader) { - _fader->update(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initInput() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseGame::getSequence() { - return ++_sequence; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::setOffset(int offsetX, int offsetY) { - _offsetX = offsetX; - _offsetY = offsetY; -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) { - *offsetX = _offsetX; - } - if (offsetY != NULL) { - *offsetY = _offsetY; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 BaseGame::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 - - // 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; - BaseParser parser; - - 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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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: - 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: - 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: - BaseUtils::setString(&_localSaveDir, (char *)params); - break; - - case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); - break; - } - } - - _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"); - } - - - 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 BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 = BaseObject::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(); - ScValue *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); - BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *) 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); - ScValue *val = stack->pop(); - BaseObject *obj = (BaseObject *)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); - UIWindow *win = new UIWindow(_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); - ScValue *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(); - ScValue *valLooping = stack->pop(); - bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - - ScValue *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]->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_music[channel]->getFilename()); - } - } - 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(); - - BaseSound *sound = new BaseSound(_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; - - BasePlatform::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) { - BaseUtils::swap(&left, &right); - } - if (bottom < top) { - BaseUtils::swap(&top, &bottom); - } - - BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayVideo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayVideo") == 0) { - _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); - ScValue *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); - - 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 (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(7); - const char *filename = stack->pop()->getString(); - ScValue *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); - - 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 VideoTheoraPlayer(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(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - ConfMan.setInt(privKey, 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(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - int result = initVal; - if (ConfMan.hasKey(privKey)) { - result = ConfMan.getInt(privKey); - } - stack->pushInt(result); - 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(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - Common::String privVal = StringUtil::encodeSetting(val); - ConfMan.set(privKey, privVal); - 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(); - 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; - } - - ////////////////////////////////////////////////////////////////////////// - // 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(SaveLoad::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'; - SaveLoad::getSaveSlotDescription(slot, desc); - stack->pushString(desc); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmptySaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmptySaveSlot") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - SaveLoad::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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_activeCursor->getFilename()); - } - - 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(); - - bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false - stack->pushBool(exists); - 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]; - - 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)) { - break; - } - fileNum++; - } - - bool ret = false; - BaseImage *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; - BaseImage *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); - ScValue *val = stack->pop(); - - UIWindow *win = new UIWindow(_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); - BaseObject *obj = (BaseObject *)stack->pop()->getNative(); - for (uint32 i = 0; i < _windows.size(); 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); - ScValue *val = stack->pop(); - int loadImageX = stack->pop()->getInt(); - int loadImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - _renderer->setLoadingScreen(NULL, loadImageX, loadImageY); - } else { - _renderer->setLoadingScreen(val->getString(), loadImageX, loadImageY); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSavingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSavingScreen") == 0) { - stack->correctParams(3); - ScValue *val = stack->pop(); - int saveImageX = stack->pop()->getInt(); - int saveImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - _renderer->setSaveImage(NULL, saveImageX, saveImageY); - } else { - _renderer->setSaveImage(NULL, saveImageX, saveImageY); - } - 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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_cursorNoninteractive->getFilename()); - } - - 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 BaseSprite(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 BaseSaveThumbHelper(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 = BaseFileManager::getEngineInstance()->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); - } - - BaseFileManager::getEngineInstance()->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); - // Block kept to show intention of opcode. - /*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); - #endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideStatusLine") == 0) { - stack->correctParams(0); - // Block kept to show intention of opcode. - /*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); - #endif*/ - stack->pushNULL(); - - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseGame::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(getName()); - 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)g_system->getMillis()); - 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 = "saves/"; // TODO: This is just to avoid telling the engine actual paths. - _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(BasePlatform::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) { - if (!ConfMan.hasKey("most_recent_saveslot")) { - _scValue->setInt(-1); - } else { - _scValue->setInt(ConfMan.getInt("most_recent_saveslot")); - } - 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 BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::scSetProperty(const char *name, ScValue *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 = BaseObject::scSetProperty(name, value); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - BaseScriptable *obj = value->getNative(); - if (obj == NULL || validObject((BaseObject *)obj)) { - _mainObject = (BaseObject *)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 BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseGame::scToString() { - return "[game object]"; -} - - - -#define QUICK_MSG_DURATION 3000 -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayQuickMsg() { - if (_quickMessages.size() == 0 || !_systemFont) { - return STATUS_OK; - } - - // update - for (uint32 i = 0; i < _quickMessages.size(); i++) { - if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { - delete _quickMessages[i]; - _quickMessages.remove_at(i); - i--; - } - } - - int posY = 20; - - // display - 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); - } - return STATUS_OK; -} - - -#define MAX_QUICK_MSG 5 -////////////////////////////////////////////////////////////////////////// -void BaseGame::quickMessage(const char *text) { - if (_quickMessages.size() >= MAX_QUICK_MSG) { - delete _quickMessages[0]; - _quickMessages.remove_at(0); - } - _quickMessages.add(new BaseQuickMsg(_gameRef, text)); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::quickMessageForm(char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - quickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::registerObject(BaseObject *object) { - _regObjects.add(object); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::unregisterObject(BaseObject *object) { - if (!object) { - return STATUS_OK; - } - - // is it a window? - for (uint32 i = 0; i < _windows.size(); i++) { - if ((BaseObject *)_windows[i] == object) { - _windows.remove_at(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 (uint32 i = 0; i < _regObjects.size(); i++) { - if (_regObjects[i] == object) { - _regObjects.remove_at(i); - if (!_loadInProgress) { - SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); - } - delete object; - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::invalidateValues(void *value, void *data) { - ScValue *val = (ScValue *)value; - if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((BaseScriptable *)data)->_refCount == 1) { - ((BaseScriptable *)data)->_refCount++; - } - val->setNative(NULL); - val->setNULL(); - } -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::validObject(BaseObject *object) { - if (!object) { - return false; - } - if (object == this) { - return true; - } - - for (uint32 i = 0; i < _regObjects.size(); i++) { - if (_regObjects[i] == object) { - return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { - ScValue *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); - - BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *)obj)) { - script->waitForExclusive((BaseObject *)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(BaseUtils::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; - ScValue *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(BaseUtils::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; - BaseUtils::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; - BaseUtils::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; - BaseUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(L); - } - - ////////////////////////////////////////////////////////////////////////// - // Debug - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Debug") == 0) { - stack->correctParams(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 BaseGame::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 BaseGame::saveGame(int slot, const char *desc, bool quickSave) { - return SaveLoad::saveGame(slot, desc, quickSave, _gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", BaseUtils::GetUsedMemMB()); - - _loading = false; - _scheduledLoadSlot = -1; - - Common::String filename = SaveLoad::getSaveSlotFilename(slot); - - return loadGame(filename.c_str()); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadGame(const char *filename) { - return SaveLoad::loadGame(filename, _gameRef); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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.size() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { - _focusedWindow = _windows[i]; - break; - } - } - } - - // display all windows - for (uint32 i = 0; i < _windows.size(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { - - res = _windows[i]->display(); - if (DID_FAIL(res)) { - return res; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - delete _music[channel]; - _music[channel] = NULL; - - _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]); - _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 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; - } - - if (_music[channel]) { - _music[channel]->stop(); - delete _music[channel]; - _music[channel] = NULL; - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - if (_music[channel]) { - return _music[channel]->pause(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - if (_music[channel]) { - return _music[channel]->resume(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) { - return _music[channel]->setPositionTime(time); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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 = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (origBuffer == NULL) { - _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret = STATUS_OK; - - byte *buffer = origBuffer; - byte *params; - int cmd; - BaseParser parser; - - 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: - //BaseEngine::instance().getRegistry()->setBasePath((char *)params); - break; - - case TOKEN_RICH_SAVED_GAMES: - parser.scanStr((char *)params, "%b", &_richSavedGames); - break; - - case TOKEN_SAVED_GAME_EXT: - BaseUtils::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 = true; // TODO: These two settings should probably be cleaned out altogether. - _compressedSavegames = true; - - delete[] origBuffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) { - cleanup(); - } - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_activeObject)); - persistMgr->transfer(TMEMBER(_capturedObject)); - persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - 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)); - - _renderer->persistSaveLoadImages(persistMgr); - - 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->getIsSaving()) { - _quitting = false; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::focusWindow(UIWindow *window) { - UIWindow *prev = _focusedWindow; - - for (uint32 i = 0; i < _windows.size(); i++) { - if (_windows[i] == window) { - if (i < _windows.size() - 1) { - _windows.remove_at(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 BaseGame::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 BaseGame::unfreeze() { - if (_freezeLevel == 0) { - return STATUS_OK; - } - - _freezeLevel--; - if (_freezeLevel == 0) { - _state = _origState; - _interactive = _origInteractive; - _scEngine->resumeAll(); - _soundMgr->resumeAll(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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; - } - - _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; - } - - return false; -} - -void BaseGame::handleKeyRelease(Common::Event *event) { - _keyboardState->handleKeyRelease(event); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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 BaseGame::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 BaseGame::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("BaseGame::SetWindowTitle - Ignoring textencoding"); - utf8Title = Utf8String(title); - /* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ - } - warning("BaseGame::SetWindowTitle: Ignoring value: %s", utf8Title.c_str()); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::setActiveObject(BaseObject *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 BaseGame::pushViewport(BaseViewport *viewport) { - _viewportSP++; - if (_viewportSP >= (int32)_viewportStack.size()) { - _viewportStack.add(viewport); - } else { - _viewportStack[_viewportSP] = viewport; - } - - _renderer->setViewport(viewport->getRect()); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::popViewport() { - _viewportSP--; - if (_viewportSP < -1) { - _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); - } - - if (_viewportSP >= 0 && _viewportSP < (int32)_viewportStack.size()) { - _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - } else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) { - return STATUS_FAILED; - } else { - if (_viewportSP >= 0) { - BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) { - *custom = true; - } - } else { - BasePlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - if (custom) { - *custom = false; - } - } - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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 BaseGame::windowLoadHook(UIWindow *win, char **buf, char **params) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::setInteractive(bool state) { - _interactive = state; - if (_transMgr) { - _transMgr->_origInteractive = state; - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::resetMousePos() { - Common::Point p; - p.x = _mousePos.x + _renderer->_drawOffsetX; - p.y = _mousePos.y + _renderer->_drawOffsetY; - - BasePlatform::setCursorPos(p.x, p.y); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayContent(bool doUpdate, bool displayAll) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayContentSimple() { - // fill black - _renderer->fill(0, 0, 0); - _renderer->displayIndicator(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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 - BaseSound *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 BaseGame::resetContent() { - _scEngine->clearGlobals(); - //_timer = 0; - //_liveTimer = 0; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::DEBUG_DumpClassRegistry() { - warning("DEBUG_DumpClassRegistry - untested"); - Common::DumpFile *f = new Common::DumpFile; - f->open("zz_class_reg_dump.log"); - - SystemClassRegistry::getInstance()->dumpClasses(f); - - f->close(); - delete f; - _gameRef->quickMessage("Classes dump completed."); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::invalidateDeviceObjects() { - for (uint32 i = 0; i < _regObjects.size(); i++) { - _regObjects[i]->invalidateDeviceObjects(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::restoreDeviceObjects() { - for (uint32 i = 0; i < _regObjects.size(); i++) { - _regObjects[i]->restoreDeviceObjects(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::setWaitCursor(const char *filename) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - _cursorNoninteractive = new BaseSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) { - return true; - } - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::stopVideo() { - if (_videoPlayer->isPlaying()) { - _videoPlayer->stop(); - } - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - _theoraPlayer->stop(); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::drawCursor(BaseSprite *cursor) { - if (!cursor) { - return STATUS_FAILED; - } - if (cursor != _lastCursor) { - cursor->reset(); - _lastCursor = cursor; - } - return cursor->draw(_mousePos.x, _mousePos.y); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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 BaseGame::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; - BasePlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseLeftUp() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - } - - BasePlatform::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::onPaint() { - if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->initLoop(); - displayContent(false, true); - displayDebugInfo(); - _renderer->windowedBlt(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onWindowClose() { - if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) { - _gameRef->applyEvent("QuitGame"); - } - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::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().c_str()); - 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((const 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); - - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::getMousePos(Point32 *pos) { - BasePlatform::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 (!BasePlatform::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; - - BasePlatform::setCursorPos(newPos.x, newPos.y); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::miniUpdate() { // TODO: Is this really necessary, it used to update sound, but the mixer does that now. - if (!_miniUpdateEnabled) { - return; - } - - if (g_system->getMillis() - _lastMiniUpdate > 200) { - _lastMiniUpdate = g_system->getMillis(); - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onScriptShutdown(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isLeftDoubleClick() { - return isDoubleClick(0); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isRightDoubleClick() { - return isDoubleClick(1); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isDoubleClick(int buttonIndex) { - uint32 maxDoubleCLickTime = 500; - int maxMoveX = 4; - int maxMoveY = 4; - - Point32 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 || 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; - } else { - _lastClick[buttonIndex].time = 0; - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::autoSaveOnExit() { - _soundMgr->saveSettings(); - ConfMan.flushToDisk(); - - if (!_autoSaveOnExit) { - return; - } - if (_state == GAME_FROZEN) { - return; - } - - saveGame(_autoSaveSlot, "autosave", true); -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::addMem(int bytes) { - _usedMem += bytes; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString BaseGame::getDeviceType() const { - return "computer"; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based 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_engine.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/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/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" +#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/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" +#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(BaseGame, true) + + +////////////////////////////////////////////////////////////////////// +BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _transMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _debugLogFile = NULL; + _debugDebugMode = false; + _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; + + _stringTable = new BaseStringTable(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; + + _richSavedGames = false; + _savedGameExt = NULL; + BaseUtils::setString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _localSaveDir = NULL; + BaseUtils::setString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + BasePlatform::setRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _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 + #else*/ + _touchInterface = false; + _constrainedMemory = false; +//#endif + +} + + +////////////////////////////////////////////////////////////////////// +BaseGame::~BaseGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + ConfMan.setBool("last_run", true); + + cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; + delete _soundMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _soundMgr = NULL; + + _renderer = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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 (uint32 i = 0; i < _regObjects.size(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.clear(); + + _windows.clear(); // refs only + _focusedWindow = NULL; // ref only + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->finish(); + } + _scripts.clear(); + + _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + for (uint32 i = 0; i < _quickMessages.size(); i++) { + delete _quickMessages[i]; + } + _quickMessages.clear(); + + _viewportStack.clear(); + _viewportSP = -1; + + setName(NULL); + setFilename(NULL); + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initialize1() { + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new BaseSurfaceStorage(this); + if (_surfaceStorage == NULL) { + break; + } + + _fontStorage = new BaseFontStorage(this); + if (_fontStorage == NULL) { + break; + } + + _soundMgr = new BaseSoundMgr(this); + if (_soundMgr == NULL) { + break; + } + + _mathClass = new SXMath(this); + if (_mathClass == NULL) { + break; + } + + _scEngine = new ScEngine(this); + if (_scEngine == NULL) { + break; + } + + _videoPlayer = new VideoPlayer(this); + if (_videoPlayer == NULL) { + break; + } + + _transMgr = new BaseTransitionMgr(this); + if (_transMgr == NULL) { + break; + } + + _keyboardState = new BaseKeyboardState(this); + if (_keyboardState == NULL) { + break; + } + + _fader = new BaseFader(this); + if (_fader == NULL) { + break; + } + registerObject(_fader); + + loaded = true; + } + if (loaded == true) { + return STATUS_OK; + } else { + delete _mathClass; + delete _keyboardState; + delete _transMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _scEngine; + delete _videoPlayer; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initialize2() { // we know whether we are going to be accelerated + _renderer = makeOSystemRenderer(this); + if (_renderer == NULL) { + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + _renderer->initIndicator(); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void BaseGame::DEBUG_DebugEnable(const char *filename) { + _debugDebugMode = true; + + 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); + + AnsiString platform = BasePlatform::getPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void BaseGame::DEBUG_DebugDisable() { + if (_debugLogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; + } + _debugDebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void BaseGame::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); + } + + 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 BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initLoop() { + _viewportSP = -1; + + _currentTime = g_system->getMillis(); + + _renderer->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.size() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + updateSounds(); + + if (_fader) { + _fader->update(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initInput() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseGame::getSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::setOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::getOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) { + *offsetX = _offsetX; + } + if (offsetY != NULL) { + *offsetY = _offsetY; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 BaseGame::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 + + // 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; + BaseParser parser; + + 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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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: + 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: + 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: + BaseUtils::setString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + _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"); + } + + + 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 BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 = BaseObject::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(); + ScValue *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); + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *) 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); + ScValue *val = stack->pop(); + BaseObject *obj = (BaseObject *)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); + UIWindow *win = new UIWindow(_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); + ScValue *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(); + ScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); + + ScValue *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]->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_music[channel]->getFilename()); + } + } + 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(); + + BaseSound *sound = new BaseSound(_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; + + BasePlatform::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) { + BaseUtils::swap(&left, &right); + } + if (bottom < top) { + BaseUtils::swap(&top, &bottom); + } + + BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayVideo") == 0) { + _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); + ScValue *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); + + 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 (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(7); + const char *filename = stack->pop()->getString(); + ScValue *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); + + 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 VideoTheoraPlayer(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(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + ConfMan.setInt(privKey, 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(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + int result = initVal; + if (ConfMan.hasKey(privKey)) { + result = ConfMan.getInt(privKey); + } + stack->pushInt(result); + 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(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String privVal = StringUtil::encodeSetting(val); + ConfMan.set(privKey, privVal); + 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(); + 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; + } + + ////////////////////////////////////////////////////////////////////////// + // 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(SaveLoad::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'; + SaveLoad::getSaveSlotDescription(slot, desc); + stack->pushString(desc); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + SaveLoad::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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_activeCursor->getFilename()); + } + + 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(); + + bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false + stack->pushBool(exists); + 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]; + + 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)) { + break; + } + fileNum++; + } + + bool ret = false; + BaseImage *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; + BaseImage *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); + ScValue *val = stack->pop(); + + UIWindow *win = new UIWindow(_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); + BaseObject *obj = (BaseObject *)stack->pop()->getNative(); + for (uint32 i = 0; i < _windows.size(); 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); + ScValue *val = stack->pop(); + int loadImageX = stack->pop()->getInt(); + int loadImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + _renderer->setLoadingScreen(NULL, loadImageX, loadImageY); + } else { + _renderer->setLoadingScreen(val->getString(), loadImageX, loadImageY); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->correctParams(3); + ScValue *val = stack->pop(); + int saveImageX = stack->pop()->getInt(); + int saveImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + _renderer->setSaveImage(NULL, saveImageX, saveImageY); + } else { + _renderer->setSaveImage(NULL, saveImageX, saveImageY); + } + 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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorNoninteractive->getFilename()); + } + + 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 BaseSprite(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 BaseSaveThumbHelper(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 = BaseFileManager::getEngineInstance()->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); + } + + BaseFileManager::getEngineInstance()->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); + // Block kept to show intention of opcode. + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); + #endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideStatusLine") == 0) { + stack->correctParams(0); + // Block kept to show intention of opcode. + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); + #endif*/ + stack->pushNULL(); + + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseGame::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(getName()); + 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)g_system->getMillis()); + 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 = "saves/"; // TODO: This is just to avoid telling the engine actual paths. + _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(BasePlatform::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) { + if (!ConfMan.hasKey("most_recent_saveslot")) { + _scValue->setInt(-1); + } else { + _scValue->setInt(ConfMan.getInt("most_recent_saveslot")); + } + 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 BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::scSetProperty(const char *name, ScValue *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 = BaseObject::scSetProperty(name, value); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + BaseScriptable *obj = value->getNative(); + if (obj == NULL || validObject((BaseObject *)obj)) { + _mainObject = (BaseObject *)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 BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseGame::scToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayQuickMsg() { + if (_quickMessages.size() == 0 || !_systemFont) { + return STATUS_OK; + } + + // update + for (uint32 i = 0; i < _quickMessages.size(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.remove_at(i); + i--; + } + } + + int posY = 20; + + // display + 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); + } + return STATUS_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void BaseGame::quickMessage(const char *text) { + if (_quickMessages.size() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.remove_at(0); + } + _quickMessages.add(new BaseQuickMsg(_gameRef, text)); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::quickMessageForm(char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + quickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::registerObject(BaseObject *object) { + _regObjects.add(object); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::unregisterObject(BaseObject *object) { + if (!object) { + return STATUS_OK; + } + + // is it a window? + for (uint32 i = 0; i < _windows.size(); i++) { + if ((BaseObject *)_windows[i] == object) { + _windows.remove_at(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 (uint32 i = 0; i < _regObjects.size(); i++) { + if (_regObjects[i] == object) { + _regObjects.remove_at(i); + if (!_loadInProgress) { + SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); + } + delete object; + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::invalidateValues(void *value, void *data) { + ScValue *val = (ScValue *)value; + if (val->isNative() && val->getNative() == data) { + if (!val->_persistent && ((BaseScriptable *)data)->_refCount == 1) { + ((BaseScriptable *)data)->_refCount++; + } + val->setNative(NULL); + val->setNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::validObject(BaseObject *object) { + if (!object) { + return false; + } + if (object == this) { + return true; + } + + for (uint32 i = 0; i < _regObjects.size(); i++) { + if (_regObjects[i] == object) { + return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { + ScValue *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); + + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *)obj)) { + script->waitForExclusive((BaseObject *)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(BaseUtils::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; + ScValue *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(BaseUtils::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; + BaseUtils::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; + BaseUtils::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; + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Debug") == 0) { + stack->correctParams(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 BaseGame::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 BaseGame::saveGame(int slot, const char *desc, bool quickSave) { + return SaveLoad::saveGame(slot, desc, quickSave, _gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", BaseUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + Common::String filename = SaveLoad::getSaveSlotFilename(slot); + + return loadGame(filename.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadGame(const char *filename) { + return SaveLoad::loadGame(filename, _gameRef); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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.size() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (uint32 i = 0; i < _windows.size(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + + res = _windows[i]->display(); + if (DID_FAIL(res)) { + return res; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + delete _music[channel]; + _music[channel] = NULL; + + _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]); + _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 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; + } + + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + if (_music[channel]) { + return _music[channel]->pause(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + if (_music[channel]) { + return _music[channel]->resume(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) { + return _music[channel]->setPositionTime(time); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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 = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (origBuffer == NULL) { + _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret = STATUS_OK; + + byte *buffer = origBuffer; + byte *params; + int cmd; + BaseParser parser; + + 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: + //BaseEngine::instance().getRegistry()->setBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.scanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + BaseUtils::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 = true; // TODO: These two settings should probably be cleaned out altogether. + _compressedSavegames = true; + + delete[] origBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::persist(BasePersistenceManager *persistMgr) { + if (!persistMgr->getIsSaving()) { + cleanup(); + } + + BaseObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + 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)); + + _renderer->persistSaveLoadImages(persistMgr); + + 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->getIsSaving()) { + _quitting = false; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::focusWindow(UIWindow *window) { + UIWindow *prev = _focusedWindow; + + for (uint32 i = 0; i < _windows.size(); i++) { + if (_windows[i] == window) { + if (i < _windows.size() - 1) { + _windows.remove_at(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 BaseGame::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 BaseGame::unfreeze() { + if (_freezeLevel == 0) { + return STATUS_OK; + } + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->resumeAll(); + _soundMgr->resumeAll(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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; + } + + _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; + } + + return false; +} + +void BaseGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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 BaseGame::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 BaseGame::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("BaseGame::SetWindowTitle - Ignoring textencoding"); + utf8Title = Utf8String(title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } + warning("BaseGame::SetWindowTitle: Ignoring value: %s", utf8Title.c_str()); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::setActiveObject(BaseObject *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 BaseGame::pushViewport(BaseViewport *viewport) { + _viewportSP++; + if (_viewportSP >= (int32)_viewportStack.size()) { + _viewportStack.add(viewport); + } else { + _viewportStack[_viewportSP] = viewport; + } + + _renderer->setViewport(viewport->getRect()); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::popViewport() { + _viewportSP--; + if (_viewportSP < -1) { + _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + } + + if (_viewportSP >= 0 && _viewportSP < (int32)_viewportStack.size()) { + _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + } else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { + if (rect == NULL) { + return STATUS_FAILED; + } else { + if (_viewportSP >= 0) { + BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) { + *custom = true; + } + } else { + BasePlatform::setRect(rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (custom) { + *custom = false; + } + } + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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 BaseGame::windowLoadHook(UIWindow *win, char **buf, char **params) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::setInteractive(bool state) { + _interactive = state; + if (_transMgr) { + _transMgr->_origInteractive = state; + } +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::resetMousePos() { + Common::Point p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + BasePlatform::setCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayContentSimple() { + // fill black + _renderer->fill(0, 0, 0); + _renderer->displayIndicator(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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 + BaseSound *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 BaseGame::resetContent() { + _scEngine->clearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::DEBUG_DumpClassRegistry() { + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); + + SystemClassRegistry::getInstance()->dumpClasses(f); + + f->close(); + delete f; + _gameRef->quickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::invalidateDeviceObjects() { + for (uint32 i = 0; i < _regObjects.size(); i++) { + _regObjects[i]->invalidateDeviceObjects(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::restoreDeviceObjects() { + for (uint32 i = 0; i < _regObjects.size(); i++) { + _regObjects[i]->restoreDeviceObjects(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::setWaitCursor(const char *filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new BaseSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isVideoPlaying() { + if (_videoPlayer->isPlaying()) { + return true; + } + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::stopVideo() { + if (_videoPlayer->isPlaying()) { + _videoPlayer->stop(); + } + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::drawCursor(BaseSprite *cursor) { + if (!cursor) { + return STATUS_FAILED; + } + if (cursor != _lastCursor) { + cursor->reset(); + _lastCursor = cursor; + } + return cursor->draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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 BaseGame::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; + BasePlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseLeftUp() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + } + + BasePlatform::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::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 BaseGame::onPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->initLoop(); + displayContent(false, true); + displayDebugInfo(); + _renderer->windowedBlt(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onWindowClose() { + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) { + _gameRef->applyEvent("QuitGame"); + } + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::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().c_str()); + 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((const 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); + + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::getMousePos(Point32 *pos) { + BasePlatform::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 (!BasePlatform::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; + + BasePlatform::setCursorPos(newPos.x, newPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::miniUpdate() { // TODO: Is this really necessary, it used to update sound, but the mixer does that now. + if (!_miniUpdateEnabled) { + return; + } + + if (g_system->getMillis() - _lastMiniUpdate > 200) { + _lastMiniUpdate = g_system->getMillis(); + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onScriptShutdown(ScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isLeftDoubleClick() { + return isDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isRightDoubleClick() { + return isDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + + Point32 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 || 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; + } else { + _lastClick[buttonIndex].time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::autoSaveOnExit() { + _soundMgr->saveSettings(); + ConfMan.flushToDisk(); + + if (!_autoSaveOnExit) { + return; + } + if (_state == GAME_FROZEN) { + return; + } + + saveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::addMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString BaseGame::getDeviceType() const { + return "computer"; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index aecbe31722..93cbc4536b 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -1,362 +1,362 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#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" -#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 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 BaseGame: public BaseObject { -public: - DECLARE_PERSISTENT(BaseGame, BaseObject) - - virtual bool onScriptShutdown(ScScript *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 void miniUpdate(); - - void getMousePos(Point32 *Pos); - Rect32 _mouseLockRect; - - bool _shuttingDown; - - virtual bool displayDebugInfo(); - bool _debugShowFPS; - - bool _suspendedRendering; - int _soundBufferSizeSec; - - TTextEncoding _textEncoding; - bool _textRTL; - - virtual bool resetContent(); - - void DEBUG_DumpClassRegistry(); - bool setWaitCursor(const char *filename); - - int _thumbnailWidth; - int _thumbnailHeight; - - bool _editorMode; - void getOffset(int *offsetX, int *offsetY); - void setOffset(int offsetX, int offsetY); - int getSequence(); - - int _offsetY; - int _offsetX; - float _offsetPercentX; - float _offsetPercentY; - BaseObject *_mainObject; - - bool initInput(); - bool initLoop(); - uint32 _currentTime; - uint32 _deltaTime; - BaseFont *_systemFont; - BaseFont *_videoFont; - bool initialize1(); - bool initialize2(); - bool initialize3(); - BaseTransitionMgr *_transMgr; - - void LOG(bool res, const char *fmt, ...); - - BaseRenderer *_renderer; - BaseSoundMgr *_soundMgr; - ScEngine *_scEngine; - SXMath *_mathClass; - BaseSurfaceStorage *_surfaceStorage; - BaseFontStorage *_fontStorage; - BaseGame(const Common::String &gameId); - virtual ~BaseGame(); - - void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *filename = NULL); - bool _debugDebugMode; - - void *_debugLogFile; - int _sequence; - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - - int _viewportSP; - - BaseStringTable *_stringTable; - int _settingsResWidth; - int _settingsResHeight; - char *_settingsGameFile; - bool _suppressScriptErrors; - bool _mouseLeftDown; // TODO: Hide - - 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); - virtual const char *scToString(); - // compatibility bits - bool _compatKillMethodThreads; - - const char* getGameId() { return _gameId.c_str(); } - void setGameId(const Common::String& gameId) { _gameId = gameId; } - uint32 _surfaceGCCycleTime; - bool _smartCache; // RO - bool _subtitles; // RO - - int _scheduledLoadSlot; - bool _loading; - - 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); - - bool unfreeze(); - bool freeze(bool includingMusic = true); - bool focusWindow(UIWindow *window); - bool _loadInProgress; - UIWindow *_focusedWindow; - bool _editorForceScripts; - - static void invalidateValues(void *value, void *data); - - bool loadSettings(const char *filename); - - bool displayWindows(bool inGame = false); - bool _useD3D; - virtual bool cleanup(); - bool loadGame(int slot); - bool loadGame(const char *filename); - bool saveGame(int slot, const char *desc, bool quickSave = false); - virtual bool showCursor(); - - BaseObject *_activeObject; - - bool _interactive; - TGameState _state; - TGameState _origState; - bool _origInteractive; - uint32 _timer; - uint32 _timerDelta; - uint32 _timerLast; - - uint32 _liveTimer; - uint32 _liveTimerDelta; - uint32 _liveTimerLast; - - BaseObject *_capturedObject; - Point32 _mousePos; - bool validObject(BaseObject *object); - bool unregisterObject(BaseObject *object); - bool registerObject(BaseObject *object); - void quickMessage(const char *text); - void quickMessageForm(char *fmt, ...); - bool displayQuickMsg(); - - 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(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(BaseViewport *Viewport); - bool setActiveObject(BaseObject *Obj); - BaseSprite *_lastCursor; - bool drawCursor(BaseSprite *Cursor); - - BaseSaveThumbHelper *_cachedThumbnail; - void addMem(int bytes); - bool _touchInterface; - bool _constrainedMemory; -protected: - BaseSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - - BaseFader *_fader; - - int _freezeLevel; - VideoPlayer *_videoPlayer; - VideoTheoraPlayer *_theoraPlayer; -private: - 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(); - - char *_localSaveDir; - bool _saveDirChecked; - bool _richSavedGames; - char *_savedGameExt; - - 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; - - 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(); - - BaseArray _quickMessages; - BaseArray _windows; - BaseArray _viewportStack; - BaseArray _regObjects; - - AnsiString getDeviceType() const; - - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#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" +#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 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 BaseGame: public BaseObject { +public: + DECLARE_PERSISTENT(BaseGame, BaseObject) + + virtual bool onScriptShutdown(ScScript *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 void miniUpdate(); + + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; + + bool _shuttingDown; + + virtual bool displayDebugInfo(); + bool _debugShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + virtual bool resetContent(); + + void DEBUG_DumpClassRegistry(); + bool setWaitCursor(const char *filename); + + int _thumbnailWidth; + int _thumbnailHeight; + + bool _editorMode; + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); + + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + BaseObject *_mainObject; + + bool initInput(); + bool initLoop(); + uint32 _currentTime; + uint32 _deltaTime; + BaseFont *_systemFont; + BaseFont *_videoFont; + bool initialize1(); + bool initialize2(); + bool initialize3(); + BaseTransitionMgr *_transMgr; + + void LOG(bool res, const char *fmt, ...); + + BaseRenderer *_renderer; + BaseSoundMgr *_soundMgr; + ScEngine *_scEngine; + SXMath *_mathClass; + BaseSurfaceStorage *_surfaceStorage; + BaseFontStorage *_fontStorage; + BaseGame(const Common::String &gameId); + virtual ~BaseGame(); + + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *filename = NULL); + bool _debugDebugMode; + + void *_debugLogFile; + int _sequence; + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + + int _viewportSP; + + BaseStringTable *_stringTable; + int _settingsResWidth; + int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; // TODO: Hide + + 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); + virtual const char *scToString(); + // compatibility bits + bool _compatKillMethodThreads; + + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } + uint32 _surfaceGCCycleTime; + bool _smartCache; // RO + bool _subtitles; // RO + + int _scheduledLoadSlot; + bool _loading; + + 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); + + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(UIWindow *window); + bool _loadInProgress; + UIWindow *_focusedWindow; + bool _editorForceScripts; + + static void invalidateValues(void *value, void *data); + + bool loadSettings(const char *filename); + + bool displayWindows(bool inGame = false); + bool _useD3D; + virtual bool cleanup(); + bool loadGame(int slot); + bool loadGame(const char *filename); + bool saveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); + + BaseObject *_activeObject; + + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + BaseObject *_capturedObject; + Point32 _mousePos; + bool validObject(BaseObject *object); + bool unregisterObject(BaseObject *object); + bool registerObject(BaseObject *object); + void quickMessage(const char *text); + void quickMessageForm(char *fmt, ...); + bool displayQuickMsg(); + + 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(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(BaseViewport *Viewport); + bool setActiveObject(BaseObject *Obj); + BaseSprite *_lastCursor; + bool drawCursor(BaseSprite *Cursor); + + BaseSaveThumbHelper *_cachedThumbnail; + void addMem(int bytes); + bool _touchInterface; + bool _constrainedMemory; +protected: + BaseSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + BaseFader *_fader; + + int _freezeLevel; + VideoPlayer *_videoPlayer; + VideoTheoraPlayer *_theoraPlayer; +private: + 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(); + + char *_localSaveDir; + bool _saveDirChecked; + bool _richSavedGames; + char *_savedGameExt; + + 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; + + 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(); + + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; + BaseArray _regObjects; + + AnsiString getDeviceType() const; + + 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 index d5c2027a0d..fd5f2b0e1d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -1,309 +1,309 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseKeyboardState, false) - -////////////////////////////////////////////////////////////////////////// -BaseKeyboardState::BaseKeyboardState(BaseGame *inGame) : BaseScriptable(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; - } -} - -////////////////////////////////////////////////////////////////////////// -BaseKeyboardState::~BaseKeyboardState() { - delete[] _keyStates; -} - -void BaseKeyboardState::handleKeyPress(Common::Event *event) { - if (event->type == Common::EVENT_KEYDOWN) { - _keyStates[event->kbd.keycode] = true; - } -} - -void BaseKeyboardState::handleKeyRelease(Common::Event *event) { - if (event->type == Common::EVENT_KEYUP) { - _keyStates[event->kbd.keycode] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // IsKeyDown - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "IsKeyDown") == 0) { - stack->correctParams(1); - ScValue *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(); - } - - bool isDown = _keyStates[vKeyToKeyCode(vKey)]; - - stack->pushBool(isDown); - return STATUS_OK; - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseKeyboardState::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 BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - if (_renderer) SetWindowText(_renderer->_window, _name); - return STATUS_OK; - } - - else*/ return BaseScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseKeyboardState::scToString() { - return "[keyboard state]"; -} - - -////////////////////////////////////////////////////////////////////////// -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_SPACE)) { - _currentPrintable = true; - } else { - _currentPrintable = false; - } - //_currentKeyData = KeyData; - - _currentControl = isControlDown(); - _currentAlt = isAltDown(); - _currentShift = isShiftDown(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { - //if (!persistMgr->getIsSaving()) cleanup(); - BaseScriptable::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->getIsSaving()) { - _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 BaseKeyboardState::isShiftDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_SHIFT); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::isControlDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_CTRL); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::isAltDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_ALT); -} - -////////////////////////////////////////////////////////////////////////// -uint32 BaseKeyboardState::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 { - kVkSpace = 32, - kVkLeft = 37, - kVkUp = 38, - kVkRight = 39, - kVkDown = 40 -}; - -////////////////////////////////////////////////////////////////////////// -Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { - // todo - switch (vkey) { - case kVkSpace: - return Common::KEYCODE_SPACE; - break; - case kVkLeft: - return Common::KEYCODE_LEFT; - break; - case kVkRight: - return Common::KEYCODE_RIGHT; - break; - case kVkUp: - return Common::KEYCODE_UP; - break; - case kVkDown: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; - } - -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +BaseKeyboardState::BaseKeyboardState(BaseGame *inGame) : BaseScriptable(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; + } +} + +////////////////////////////////////////////////////////////////////////// +BaseKeyboardState::~BaseKeyboardState() { + delete[] _keyStates; +} + +void BaseKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } +} + +void BaseKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "IsKeyDown") == 0) { + stack->correctParams(1); + ScValue *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(); + } + + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; + + stack->pushBool(isDown); + return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseKeyboardState::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 BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + if (_renderer) SetWindowText(_renderer->_window, _name); + return STATUS_OK; + } + + else*/ return BaseScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseKeyboardState::scToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +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_SPACE)) { + _currentPrintable = true; + } else { + _currentPrintable = false; + } + //_currentKeyData = KeyData; + + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { + //if (!persistMgr->getIsSaving()) cleanup(); + BaseScriptable::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->getIsSaving()) { + _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 BaseKeyboardState::isShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::isControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::isAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 BaseKeyboardState::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 { + kVkSpace = 32, + kVkLeft = 37, + kVkUp = 38, + kVkRight = 39, + kVkDown = 40 +}; + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { + // todo + switch (vkey) { + case kVkSpace: + return Common::KEYCODE_SPACE; + break; + case kVkLeft: + return Common::KEYCODE_LEFT; + break; + case kVkRight: + return Common::KEYCODE_RIGHT; + break; + case kVkUp: + return Common::KEYCODE_UP; + break; + case kVkDown: + 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 index 4b1826d483..ebc0c83ee1 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -1,75 +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_BASE_KEYBOARD_STATE_H -#define WINTERMUTE_BASE_KEYBOARD_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 BaseKeyboardState : public BaseScriptable { -public: - uint32 _currentKeyData; - uint32 _currentCharCode; - bool _currentPrintable; - - bool _currentShift; - bool _currentAlt; - bool _currentControl; - - DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) - BaseKeyboardState(BaseGame *inGame); - virtual ~BaseKeyboardState(); - 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 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: - uint8 *_keyStates; - uint32 keyCodeToVKey(Common::Event *event); - Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_KEYBOARD_STATE_H +#define WINTERMUTE_BASE_KEYBOARD_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 BaseKeyboardState : public BaseScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) + BaseKeyboardState(BaseGame *inGame); + virtual ~BaseKeyboardState(); + 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 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: + 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 index d95dd3e25b..915bf24d7f 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -1,71 +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 - */ - -#include "engines/wintermute/base/base_named_object.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::BaseNamedObject() : BaseClass() { - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::BaseNamedObject(TDynamicConstructor, TDynamicConstructor) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::~BaseNamedObject(void) { - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////// -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); - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_named_object.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::BaseNamedObject() : BaseClass() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::BaseNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::~BaseNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +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); + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index 9818708605..77a00cee45 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -1,51 +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_BASE_NAMED_OBJECT_H -#define WINTERMUTE_BASE_NAMED_OBJECT_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseNamedObject : public BaseClass { - char *_name; -public: - BaseNamedObject(BaseGame *inGame); - BaseNamedObject(); - virtual ~BaseNamedObject(void); - BaseNamedObject(TDynamicConstructor, TDynamicConstructor); - - const char *getName() { return _name; } - void setName(const char *name); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_NAMED_OBJECT_H +#define WINTERMUTE_BASE_NAMED_OBJECT_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseNamedObject : public BaseClass { + char *_name; +public: + BaseNamedObject(BaseGame *inGame); + BaseNamedObject(); + virtual ~BaseNamedObject(void); + BaseNamedObject(TDynamicConstructor, TDynamicConstructor); + + const char *getName() { return _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 index ff8fcd0bf2..b6a6887624 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -1,1246 +1,1246 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseObject, false) - -////////////////////////////////////////////////////////////////////// -BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(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(); - - BasePlatform::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; -} - - -////////////////////////////////////////////////////////////////////// -BaseObject::~BaseObject() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) { - _gameRef->_activeObject = NULL; - } - - BaseScriptHolder::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 BaseObject::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]); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseObject::getCaption(int caseVal) { - if (caseVal == 0) { - caseVal = 1; - } - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { - return ""; - } else { - return _caption[caseVal - 1]; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::listen(BaseScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_cursor->getFilename()); - } - - 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; - - ScValue *val1 = stack->pop(); - ScValue *val2 = stack->pop(); - ScValue *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; - - ScValue *val1 = stack->pop(); - ScValue *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 BaseScriptHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseObject::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 BaseScriptHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::scSetProperty(const char *name, ScValue *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 BaseScriptHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseObject::scToString() { - return "[object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::showCursor() { - if (_cursor) { - return _gameRef->drawCursor(_cursor); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::persist(BasePersistenceManager *persistMgr) { - BaseScriptHolder::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 BaseObject::setCursor(const char *filename) { - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } - - _sharedCursors = false; - _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { - delete _cursor; - _cursor = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::setActiveCursor(const char *filename) { - delete _activeCursor; - _activeCursor = new BaseSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { - delete _activeCursor; - _activeCursor = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -int BaseObject::getHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::handleMouse(TMouseEvent event, TMouseButton button) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::handleKeypress(Common::Event *event, bool printable) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::handleMouseWheel(int delta) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -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) { - _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 BaseSound(_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 BaseObject::stopSFX(bool deleteSound) { - if (_sFX) { - _sFX->stop(); - if (deleteSound) { - delete _sFX; - _sFX = NULL; - } - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::pauseSFX() { - if (_sFX) { - return _sFX->pause(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::resumeSFX() { - 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; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::setSFXVolume(int volume) { - _sFXVolume = volume; - if (_sFX) { - return _sFX->setVolumePercent(volume); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::updateSounds() { - if (_soundEvent) { - if (_sFX && !_sFX->isPlaying()) { - applyEvent(_soundEvent); - setSoundEvent(NULL); - } - } - - if (_sFX) { - updateOneSound(_sFX); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::updateOneSound(BaseSound *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 BaseObject::resetSoundPan() { - if (!_sFX) { - return STATUS_OK; - } else { - return _sFX->setPan(0.0f); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::getExtendedFlag(const char *flagName) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::isReady() { - return _ready; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseObject::setSoundEvent(const char *eventName) { - delete[] _soundEvent; - _soundEvent = NULL; - if (eventName) { - _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) { - strcpy(_soundEvent, eventName); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::afterMove() { - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseObject, false) + +////////////////////////////////////////////////////////////////////// +BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(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(); + + BasePlatform::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; +} + + +////////////////////////////////////////////////////////////////////// +BaseObject::~BaseObject() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::cleanup() { + if (_gameRef && _gameRef->_activeObject == this) { + _gameRef->_activeObject = NULL; + } + + BaseScriptHolder::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 BaseObject::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]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseObject::getCaption(int caseVal) { + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { + return ""; + } else { + return _caption[caseVal - 1]; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::listen(BaseScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursor->getFilename()); + } + + 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; + + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + ScValue *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; + + ScValue *val1 = stack->pop(); + ScValue *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 BaseScriptHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseObject::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 BaseScriptHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::scSetProperty(const char *name, ScValue *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 BaseScriptHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseObject::scToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::showCursor() { + if (_cursor) { + return _gameRef->drawCursor(_cursor); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::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 BaseObject::setCursor(const char *filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new BaseSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { + delete _cursor; + _cursor = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::setActiveCursor(const char *filename) { + delete _activeCursor; + _activeCursor = new BaseSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { + delete _activeCursor; + _activeCursor = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int BaseObject::getHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::handleKeypress(Common::Event *event, bool printable) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::handleMouseWheel(int delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +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) { + _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 BaseSound(_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 BaseObject::stopSFX(bool deleteSound) { + if (_sFX) { + _sFX->stop(); + if (deleteSound) { + delete _sFX; + _sFX = NULL; + } + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::pauseSFX() { + if (_sFX) { + return _sFX->pause(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::resumeSFX() { + 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; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) { + return _sFX->setVolumePercent(volume); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::updateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->isPlaying()) { + applyEvent(_soundEvent); + setSoundEvent(NULL); + } + } + + if (_sFX) { + updateOneSound(_sFX); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::updateOneSound(BaseSound *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 BaseObject::resetSoundPan() { + if (!_sFX) { + return STATUS_OK; + } else { + return _sFX->setPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::getExtendedFlag(const char *flagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::isReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseObject::setSoundEvent(const char *eventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) { + strcpy(_soundEvent, eventName); + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::afterMove() { + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index e1a21e91ba..34adbdb585 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -1,147 +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_BASE_OBJECT_H -#define WINTERMUTE_BASE_OBJECT_H - - -#include "engines/wintermute/base/base_script_holder.h" -#include "engines/wintermute/persistent.h" -#include "common/events.h" - -namespace Wintermute { - -class BaseSprite; -class BaseSound; -class BaseSurface; -class BaseScriptHolder; -class ScValue; -class ScStack; -class ScScript; -class BaseObject : public BaseScriptHolder { -protected: - bool _autoSoundPanning; - uint32 _sFXStart; - 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); - 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); - 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 _editorOnly; - bool _is3D; - - DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) - virtual bool showCursor(); - BaseSprite *_cursor; - bool _sharedCursors; - BaseSprite *_activeCursor; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - virtual bool listen(BaseScriptHolder *param1, uint32 param2); - - bool _movable; - bool _zoomable; - bool _shadowable; - int _posY; - int _posX; - bool _registrable; - char *_caption[7]; - bool _saveState; - - BaseObject(BaseGame *inGame); - virtual ~BaseObject(); - // 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 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_OBJECT_H +#define WINTERMUTE_BASE_OBJECT_H + + +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/persistent.h" +#include "common/events.h" + +namespace Wintermute { + +class BaseSprite; +class BaseSound; +class BaseSurface; +class BaseScriptHolder; +class ScValue; +class ScStack; +class ScScript; +class BaseObject : public BaseScriptHolder { +protected: + bool _autoSoundPanning; + uint32 _sFXStart; + 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); + 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); + 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 _editorOnly; + bool _is3D; + + DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) + virtual bool showCursor(); + BaseSprite *_cursor; + bool _sharedCursors; + BaseSprite *_activeCursor; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); + + bool _movable; + bool _zoomable; + bool _shadowable; + int _posY; + int _posX; + bool _registrable; + char *_caption[7]; + bool _saveState; + + BaseObject(BaseGame *inGame); + virtual ~BaseObject(); + // 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 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 007f93e443..9a0e9e3ad9 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -1,467 +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 "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" - -#define WHITESPACE " \t\n\r" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -BaseParser::BaseParser() { - _whiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(_whiteSpace, WHITESPACE); -} - - -////////////////////////////////////////////////////////////////////// -BaseParser::~BaseParser() { - if (_whiteSpace != NULL) { - delete[] _whiteSpace; - } -} - - -////////////////////////////////////////////////////////////////////// -char *BaseParser::getLastOffender() { - return _lastOffender; -} - - -////////////////////////////////////////////////////////////////////// -int32 BaseParser::getObject(char **buf, const 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. - // 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 - // 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 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { - if (!*buf) { - return PARSERR_TOKENNOTFOUND; - } - BaseEngine::instance().getGameRef()->miniUpdate(); - char *name; - return getObject(buf, tokens, &name, params); -} - - -////////////////////////////////////////////////////////////////////// -void BaseParser::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 *BaseParser::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 *BaseParser::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; -} - -////////////////////////////////////////////////////////////////////// -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++; - } - 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 BaseParser::getTokenFloat(char **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.; - } - float rc = (float)atof(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -int BaseParser::getTokenInt(char **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; - } - int rc = atoi(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { - Common::String token = getToken(buf); - const char *t = token.c_str(); - if (strcmp(t, tok)) { - return; // Error - } -} - - -////////////////////////////////////////////////////////////////////// -int BaseParser::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) { - Common::strlcpy(a, in, (int)(in2 - in) + 1); - in = in2 + 1; - } else { - strcpy(a, in); - in = strchr(in, 0); - } - } else { - const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - Common::strlcpy(a, in, (int)(in2 - in) + 1); - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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" + +#define WHITESPACE " \t\n\r" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +BaseParser::BaseParser() { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +BaseParser::~BaseParser() { + if (_whiteSpace != NULL) { + delete[] _whiteSpace; + } +} + + +////////////////////////////////////////////////////////////////////// +char *BaseParser::getLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +int32 BaseParser::getObject(char **buf, const 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. + // 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 + // 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 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { + if (!*buf) { + return PARSERR_TOKENNOTFOUND; + } + BaseEngine::instance().getGameRef()->miniUpdate(); + char *name; + return getObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void BaseParser::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 *BaseParser::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 *BaseParser::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; +} + +////////////////////////////////////////////////////////////////////// +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++; + } + 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 BaseParser::getTokenFloat(char **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.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int BaseParser::getTokenInt(char **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; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { + Common::String token = getToken(buf); + const char *t = token.c_str(); + if (strcmp(t, tok)) { + return; // Error + } +} + + +////////////////////////////////////////////////////////////////////// +int BaseParser::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) { + Common::strlcpy(a, in, (int)(in2 - in) + 1); + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + Common::strlcpy(a, in, (int)(in2 - in) + 1); + 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 index 6b4f733d74..76ca8ea856 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -1,88 +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_BASE_PARSER_H -#define WINTERMUTE_BASE_PARSER_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 const BaseParser::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/coll_templ.h" - -namespace Wintermute { - -class BaseParser { -public: - struct TokenDesc { - int32 id; - const char *token; - }; - -public: - int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, const TokenDesc *tokens, char **params); - BaseParser(); - virtual ~BaseParser(); -private: - char *getLastOffender(); - void skipToken(char **buf, char *tok, char *msg = NULL); - int getTokenInt(char **buf); - float getTokenFloat(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, const TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; - char *_whiteSpace; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_PARSER_H +#define WINTERMUTE_BASE_PARSER_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 const BaseParser::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/coll_templ.h" + +namespace Wintermute { + +class BaseParser { +public: + struct TokenDesc { + int32 id; + const char *token; + }; + +public: + int scanStr(const char *in, const char *format, ...); + int32 getCommand(char **buf, const TokenDesc *tokens, char **params); + BaseParser(); + virtual ~BaseParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(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, const 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 index 94588eff32..4cb67b87e1 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -1,828 +1,828 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based 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_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" -#include "engines/wintermute/math/vector2.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" -#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 - -////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool deleteSingleton) { - _saving = false; -// _buffer = NULL; -// _bufferSize = 0; - _offset = 0; - _saveStream = NULL; - _loadStream = NULL; - _deleteSingleton = deleteSingleton; - if (BaseEngine::instance().getGameRef()) { - _gameRef = BaseEngine::instance().getGameRef(); - } else { - _gameRef = 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"; - } -} - - -////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::~BasePersistenceManager() { - cleanup(); - if (_deleteSingleton && BaseEngine::instance().getGameRef() == NULL) - BaseEngine::destroy(); -} - - -////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::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 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 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); - 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 BasePersistenceManager::deleteSaveSlot(int slot) { - Common::String filename = getFilenameForSlot(slot); - g_system->getSavefileManager()->removeSavefile(filename); -} - -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(); - 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 BasePersistenceManager::getSaveExists(int slot) { - Common::String filename = getFilenameForSlot(slot); - if (DID_FAIL(readHeader(filename))) { - return false; - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::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 BaseSaveThumbHelper(_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->getName()); - - // 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 BasePersistenceManager::readHeader(const Common::String &filename) { - cleanup(); - - _saving = false; - - _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = BaseFileManager::getEngineInstance()->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 BasePersistenceManager::initLoad(const Common::String &filename) { - if (DID_FAIL(readHeader(filename))) { - cleanup(); - return STATUS_FAILED; - } - _saving = false; - - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { - debugC(kWintermuteDebugSaveGame, "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) - ) { - - 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; - } - - // 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) - ) { - 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; - - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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 = ((WintermuteEngine *)g_engine)->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; -} - - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { - _saveStream->write(buffer, size); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { - _loadStream->read(buffer, size); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::putDWORD(uint32 val) { - _saveStream->writeUint32LE(val); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BasePersistenceManager::getDWORD() { - uint32 ret = _loadStream->readUint32LE(); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::putString(const Common::String &val) { - if (!val.size()) { - putString("(null)"); - } else { - _saveStream->writeUint32LE(val.size()); - _saveStream->writeString(val); - } -} - -Common::String BasePersistenceManager::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 *BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::putFloat(float val) { - Common::String str = Common::String::format("F%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -float BasePersistenceManager::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 BasePersistenceManager::putDouble(double val) { - Common::String str = Common::String::format("D%f", val); - str.format("D%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -double BasePersistenceManager::getDouble() { - char *str = getString(); - 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 double", str); - } - delete[] str; - return value; -} - -////////////////////////////////////////////////////////////////////////// -// bool -bool BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::transfer(const char *name, void *val) { - int classID = -1, instanceID = -1; - - if (_saving) { - SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); - if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - debugC(kWintermuteDebugSaveGame, "Warning: invalid instance '%s'", name); - } - - _saveStream->writeUint32LE(classID); - _saveStream->writeUint32LE(instanceID); - } else { - classID = _loadStream->readUint32LE(); - instanceID = _loadStream->readUint32LE(); - - *(void **)val = SystemClassRegistry::getInstance()->idToPointer(classID, instanceID); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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 - if (verMajor > _savedVerMajor || - (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || - (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) { - return false; - } - - return true; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based 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_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" +#include "engines/wintermute/math/vector2.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" +#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 + +////////////////////////////////////////////////////////////////////////// +BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool deleteSingleton) { + _saving = false; +// _buffer = NULL; +// _bufferSize = 0; + _offset = 0; + _saveStream = NULL; + _loadStream = NULL; + _deleteSingleton = deleteSingleton; + if (BaseEngine::instance().getGameRef()) { + _gameRef = BaseEngine::instance().getGameRef(); + } else { + _gameRef = 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"; + } +} + + +////////////////////////////////////////////////////////////////////////// +BasePersistenceManager::~BasePersistenceManager() { + cleanup(); + if (_deleteSingleton && BaseEngine::instance().getGameRef() == NULL) + BaseEngine::destroy(); +} + + +////////////////////////////////////////////////////////////////////////// +void BasePersistenceManager::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 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 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); + 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 BasePersistenceManager::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +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(); + 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 BasePersistenceManager::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + if (DID_FAIL(readHeader(filename))) { + return false; + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::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 BaseSaveThumbHelper(_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->getName()); + + // 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 BasePersistenceManager::readHeader(const Common::String &filename) { + cleanup(); + + _saving = false; + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); + //_buffer = BaseFileManager::getEngineInstance()->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 BasePersistenceManager::initLoad(const Common::String &filename) { + if (DID_FAIL(readHeader(filename))) { + cleanup(); + return STATUS_FAILED; + } + _saving = false; + + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { + debugC(kWintermuteDebugSaveGame, "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) + ) { + + 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; + } + + // 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) + ) { + 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; + + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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 = ((WintermuteEngine *)g_engine)->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; +} + + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BasePersistenceManager::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BasePersistenceManager::getDWORD() { + uint32 ret = _loadStream->readUint32LE(); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void BasePersistenceManager::putString(const Common::String &val) { + if (!val.size()) { + putString("(null)"); + } else { + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); + } +} + +Common::String BasePersistenceManager::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 *BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float BasePersistenceManager::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 BasePersistenceManager::putDouble(double val) { + Common::String str = Common::String::format("D%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double BasePersistenceManager::getDouble() { + char *str = getString(); + 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 double", str); + } + delete[] str; + return value; +} + +////////////////////////////////////////////////////////////////////////// +// bool +bool BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::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 BasePersistenceManager::transfer(const char *name, void *val) { + int classID = -1, instanceID = -1; + + if (_saving) { + SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { + debugC(kWintermuteDebugSaveGame, "Warning: invalid instance '%s'", name); + } + + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); + } else { + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); + + *(void **)val = SystemClassRegistry::getInstance()->idToPointer(classID, instanceID); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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 + 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 index fb5a73d0d3..a262c92a0b 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -1,118 +1,118 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H -#define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H - - -#include "engines/wintermute/dctypes.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 BaseGame; -class BasePersistenceManager { -public: - char *_savedDescription; - Common::String _savePrefix; - Common::String _savedName; - bool saveFile(const Common::String &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 Common::String &filename); - bool initSave(const char *desc); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 _offset; - - bool getIsSaving() { return _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); - BasePersistenceManager(const char *savePrefix = NULL, bool deleteSingleton = false); - virtual ~BasePersistenceManager(); - bool checkVersion(byte verMajor, byte verMinor, byte verBuild); - - uint32 _thumbnailDataSize; - byte *_thumbnailData; - Common::String getFilenameForSlot(int slot) const; -private: - bool _deleteSingleton; - bool readHeader(const Common::String &filename); - TimeDate getTimeDate(); - 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 - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H +#define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H + + +#include "engines/wintermute/dctypes.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 BaseGame; +class BasePersistenceManager { +public: + char *_savedDescription; + Common::String _savePrefix; + Common::String _savedName; + bool saveFile(const Common::String &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 Common::String &filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 _offset; + + bool getIsSaving() { return _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); + BasePersistenceManager(const char *savePrefix = NULL, bool deleteSingleton = false); + virtual ~BasePersistenceManager(); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; +private: + bool _deleteSingleton; + bool readHeader(const Common::String &filename); + TimeDate getTimeDate(); + 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 + +#endif diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 73e7e4690a..fbd8960894 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -1,63 +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 "engines/wintermute/base/base_point.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BasePoint, false) - -////////////////////////////////////////////////////////////////////////// -BasePoint::BasePoint() { - x = y = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint::~BasePoint() { - -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint::BasePoint(int initX, int initY) { - x = initX; - y = initY; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePoint::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(x)); - persistMgr->transfer(TMEMBER(y)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_point.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BasePoint, false) + +////////////////////////////////////////////////////////////////////////// +BasePoint::BasePoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint::~BasePoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint::BasePoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePoint::persist(BasePersistenceManager *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 index 43f8f960f1..c0bbd3102e 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -1,50 +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_BASE_POINT_H -#define WINTERMUTE_BASE_POINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BasePoint: public BaseClass { -public: - DECLARE_PERSISTENT(BasePoint, BaseClass) - BasePoint(); - BasePoint(int initX, int initY); - int y; - int x; - virtual ~BasePoint(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_POINT_H +#define WINTERMUTE_BASE_POINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BasePoint: public BaseClass { +public: + DECLARE_PERSISTENT(BasePoint, BaseClass) + BasePoint(); + BasePoint(int initX, int initY); + int y; + int x; + virtual ~BasePoint(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index dfe25b474b..0a9907ac6b 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -1,57 +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 - */ - -#include "engines/wintermute/base/base_quick_msg.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { - _text = new char [strlen(text) + 1]; - if (_text) { - strcpy(_text, text); - } - _startTime = _gameRef->_currentTime; -} - - -////////////////////////////////////////////////////////////////////////// -BaseQuickMsg::~BaseQuickMsg() { - if (_text) { - delete[] _text; - } -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseQuickMsg::getText() { - return _text; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_quick_msg.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) { + strcpy(_text, text); + } + _startTime = _gameRef->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +BaseQuickMsg::~BaseQuickMsg() { + if (_text) { + delete[] _text; + } +} + + +////////////////////////////////////////////////////////////////////////// +char *BaseQuickMsg::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 index d00b302baf..4fed5ffc2e 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -1,48 +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_BASE_QUICKMSG_H -#define WINTERMUTE_BASE_QUICKMSG_H - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseQuickMsg : public BaseClass { -public: - char *getText(); - uint32 _startTime; - char *_text; - BaseQuickMsg(BaseGame *inGame, const char *Text); - virtual ~BaseQuickMsg(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_QUICKMSG_H +#define WINTERMUTE_BASE_QUICKMSG_H + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseQuickMsg : public BaseClass { +public: + char *getText(); + uint32 _startTime; + char *_text; + BaseQuickMsg(BaseGame *inGame, const char *Text); + virtual ~BaseQuickMsg(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 4d7f3487f0..e332ffe9ff 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -1,535 +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 "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(BaseRegion, false) - -////////////////////////////////////////////////////////////////////////// -BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; - - BasePlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -BaseRegion::~BaseRegion() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRegion::cleanup() { - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - _points.clear(); - - BasePlatform::setRectEmpty(&_rect); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::createRegion() { - return DID_SUCCEED(getBoundingRect(&_rect)); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::pointInRegion(int x, int y) { - if (_points.size() < 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 (BasePlatform::ptInRect(&_rect, pt)) { - return ptInPolygon(x, y); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 BaseRegion::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; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - _points.clear(); - - 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 BasePoint(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 BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 BasePoint(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 < (int32)_points.size()) { - _points.insert_at(index, new BasePoint(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 < (int32)_points.size()) { - _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 < (int32)_points.size()) { - delete _points[index]; - _points[index] = NULL; - - _points.remove_at(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 < (int32)_points.size()) { - ScValue *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 BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseRegion::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(getName()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumPoints - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.size()); - return _scValue; - } else { - return BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseRegion::scToString() { - return "[region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::saveAsText(BaseDynamicBuffer *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", 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); - - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (uint32 i = 0; i < _points.size(); 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 BaseRegion::persist(BasePersistenceManager *persistMgr) { - - BaseObject::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 BaseRegion::ptInPolygon(int x, int y) { - if (_points.size() < 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 (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)) { - 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 BaseRegion::getBoundingRect(Rect32 *rect) { - if (_points.size() == 0) { - BasePlatform::setRectEmpty(rect); - } else { - int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; - - for (uint32 i = 0; i < _points.size(); 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); - } - BasePlatform::setRect(rect, minX, minY, maxX, maxY); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) { - return STATUS_OK; - } - - cleanup(); - - for (uint32 i = 0; i < region->_points.size(); 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 BasePoint(xVal + x, yVal + y)); - } - - _lastMimicScale = scale; - _lastMimicX = x; - _lastMimicY = y; - - return createRegion() ? STATUS_OK : STATUS_FAILED; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseRegion, false) + +////////////////////////////////////////////////////////////////////////// +BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + BasePlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +BaseRegion::~BaseRegion() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseRegion::cleanup() { + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + _points.clear(); + + BasePlatform::setRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::createRegion() { + return DID_SUCCEED(getBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::pointInRegion(int x, int y) { + if (_points.size() < 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 (BasePlatform::ptInRect(&_rect, pt)) { + return ptInPolygon(x, y); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 BaseRegion::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; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + _points.clear(); + + 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 BasePoint(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 BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 BasePoint(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 < (int32)_points.size()) { + _points.insert_at(index, new BasePoint(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 < (int32)_points.size()) { + _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 < (int32)_points.size()) { + delete _points[index]; + _points[index] = NULL; + + _points.remove_at(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 < (int32)_points.size()) { + ScValue *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 BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseRegion::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(getName()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumPoints") == 0) { + _scValue->setInt(_points.size()); + return _scValue; + } else { + return BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseRegion::scToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::saveAsText(BaseDynamicBuffer *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", 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); + + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (uint32 i = 0; i < _points.size(); 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 BaseRegion::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 BaseRegion::ptInPolygon(int x, int y) { + if (_points.size() < 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 (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)) { + 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 BaseRegion::getBoundingRect(Rect32 *rect) { + if (_points.size() == 0) { + BasePlatform::setRectEmpty(rect); + } else { + int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; + + for (uint32 i = 0; i < _points.size(); 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); + } + BasePlatform::setRect(rect, minX, minY, maxX, maxY); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) { + return STATUS_OK; + } + + cleanup(); + + for (uint32 i = 0; i < region->_points.size(); 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 BasePoint(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 index e7ae9bda13..8dd02fe928 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -1,69 +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_BASE_REGION_H -#define WINTERMUTE_BASE_REGION_H - -#include "engines/wintermute/base/base_point.h" -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class BaseRegion : public BaseObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - 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(BaseRegion, BaseObject) - bool _active; - int _editorSelectedPoint; - 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; - BaseArray _points; - 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); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_REGION_H +#define WINTERMUTE_BASE_REGION_H + +#include "engines/wintermute/base/base_point.h" +#include "engines/wintermute/base/base_object.h" + +namespace Wintermute { + +class BaseRegion : public BaseObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + 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(BaseRegion, BaseObject) + bool _active; + int _editorSelectedPoint; + 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; + BaseArray _points; + 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); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // 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 8cd15ccf1d..186e1234a8 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -1,80 +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 - */ - -#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 { - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbHelper::~BaseSaveThumbHelper(void) { - delete _thumbnail; - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbHelper::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(); - } - - BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) { - return STATUS_FAILED; - } - - // normal thumbnail - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new BaseImage(); - _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); - } - - - delete screenshot; - screenshot = NULL; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_save_thumb_helper.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbHelper::~BaseSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbHelper::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(); + } + + BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); + if (!screenshot) { + return STATUS_FAILED; + } + + // normal thumbnail + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new BaseImage(); + _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 index 0af3103f71..8863508ac9 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -1,51 +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_BASE_SAVE_THUMB_HELPER_H -#define WINTERMUTE_BASE_SAVE_THUMB_HELPER_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseImage; - -class BaseSaveThumbHelper : public BaseClass { -public: - BaseSaveThumbHelper(BaseGame *inGame); - virtual ~BaseSaveThumbHelper(void); - bool storeThumbnail(bool doFlip = false); - - BaseImage *_thumbnail; -private: - BaseImage *_richThumbnail; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BASE_SAVE_THUMB_HELPER_H +#define WINTERMUTE_BASE_SAVE_THUMB_HELPER_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseImage; + +class BaseSaveThumbHelper : public BaseClass { +public: + BaseSaveThumbHelper(BaseGame *inGame); + virtual ~BaseSaveThumbHelper(void); + bool storeThumbnail(bool doFlip = false); + + BaseImage *_thumbnail; +private: + BaseImage *_richThumbnail; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index e4132351e0..d3e6078d43 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -1,502 +1,502 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseScriptHolder, false) - -////////////////////////////////////////////////////////////////////// -BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { - setName(""); - - _freezable = true; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////// -BaseScriptHolder::~BaseScriptHolder() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::cleanup() { - delete[] _filename; - _filename = NULL; - - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->finish(true); - _scripts[i]->_owner = NULL; - } - _scripts.clear(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -void BaseScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) { - delete[] _filename; - _filename = NULL; - } - if (filename == NULL) { - return; - } - _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) { - strcpy(_filename, filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { - int numHandlers = 0; - - bool ret = STATUS_FAILED; - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread) { - ScScript *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 BaseScriptHolder::listen(BaseScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); - ScValue *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 (uint32 i = 0; i < _scripts.size(); 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 (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; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptHolder::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(getName()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } else { - return BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } else { - return BaseScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseScriptHolder::scToString() { - return "[script_holder]"; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { - return BaseClass::saveAsText(buffer, indent); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - if (persistMgr->getIsSaving()) { - const char *name = getName(); - persistMgr->transfer(TMEMBER(name)); - } else { - char *name; - persistMgr->transfer(TMEMBER(name)); - setName(name); - delete[] name; - } - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::addScript(const char *filename) { - 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()); - return STATUS_OK; - } - } - } - - ScScript *scr = _gameRef->_scEngine->runScript(filename, this); - if (!scr) { - if (_gameRef->_editorForceScripts) { - // editor hack - scr = new ScScript(_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); - - return STATUS_OK; - } - return STATUS_FAILED; - } else { - scr->_freezable = _freezable; - _scripts.add(scr); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::removeScript(ScScript *script) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i] == script) { - _scripts.remove_at(i); - break; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::canHandleEvent(const char *EventName) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { - return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::canHandleMethod(const char *MethodName) { - for (uint32 i = 0; i < _scripts.size(); 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 BaseScriptHolder::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; - BaseParser parser; - - 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; - } - - - ScValue *val = new ScValue(_gameRef); - val->setString(propValue); - scSetProperty(propName, val); - - delete val; - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptHolder::makeFreezable(bool freezable) { - _freezable = freezable; - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->_freezable = freezable; - } - -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.size() - 1; i >= 0; i--) { - if (_scripts[i]->canHandleMethod(methodName)) { - - ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); - if (thread) { - bool ret = thread->createMethodThread(_scripts[i], methodName); - if (DID_SUCCEED(ret)) { - _scripts[i]->_engine->_scripts.add(thread); - return thread; - } else { - delete thread; - } - } - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); - if (getName() && strcmp(getName(), "") != 0) { - strcat(buf, " Name: "); - strcat(buf, getName()); - } - if (_filename) { - strcat(buf, " File: "); - strcat(buf, _filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeObject -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::sendEvent(const char *eventName) { - return DID_SUCCEED(applyEvent(eventName)); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { + setName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +BaseScriptHolder::~BaseScriptHolder() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::cleanup() { + delete[] _filename; + _filename = NULL; + + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.clear(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +void BaseScriptHolder::setFilename(const char *filename) { + if (_filename != NULL) { + delete[] _filename; + _filename = NULL; + } + if (filename == NULL) { + return; + } + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) { + strcpy(_filename, filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; + + bool ret = STATUS_FAILED; + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread) { + ScScript *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 BaseScriptHolder::listen(BaseScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); + ScValue *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 (uint32 i = 0; i < _scripts.size(); 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 (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; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseScriptHolder::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(getName()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } else { + return BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } else { + return BaseScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseScriptHolder::scToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { + return BaseClass::saveAsText(buffer, indent); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + if (persistMgr->getIsSaving()) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + delete[] name; + } + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::addScript(const char *filename) { + 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()); + return STATUS_OK; + } + } + } + + ScScript *scr = _gameRef->_scEngine->runScript(filename, this); + if (!scr) { + if (_gameRef->_editorForceScripts) { + // editor hack + scr = new ScScript(_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); + + return STATUS_OK; + } + return STATUS_FAILED; + } else { + scr->_freezable = _freezable; + _scripts.add(scr); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::removeScript(ScScript *script) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i] == script) { + _scripts.remove_at(i); + break; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::canHandleEvent(const char *EventName) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { + return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::canHandleMethod(const char *MethodName) { + for (uint32 i = 0; i < _scripts.size(); 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 BaseScriptHolder::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; + BaseParser parser; + + 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; + } + + + ScValue *val = new ScValue(_gameRef); + val->setString(propValue); + scSetProperty(propName, val); + + delete val; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->_freezable = freezable; + } + +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { + for (int i = _scripts.size() - 1; i >= 0; i--) { + if (_scripts[i]->canHandleMethod(methodName)) { + + ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); + if (thread) { + bool ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { + _scripts[i]->_engine->_scripts.add(thread); + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); + if (getName() && strcmp(getName(), "") != 0) { + strcat(buf, " Name: "); + strcat(buf, getName()); + } + if (_filename) { + strcat(buf, " File: "); + strcat(buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::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 index cab0d4f693..0c3d7a1a70 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -1,76 +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_BASE_SCRIPTHOLDER_H -#define WINTERMUTE_BASE_SCRIPTHOLDER_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class BaseScriptHolder : public BaseScriptable { -public: - DECLARE_PERSISTENT(BaseScriptHolder, BaseScriptable) - - 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(ScScript *script); - bool addScript(const char *filename); - 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); - const char *getFilename() { return _filename; } - bool parseProperty(byte *buffer, bool complete = true); - bool _freezable; - bool _ready; - - BaseArray _scripts; - // 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(); - virtual void scDebuggerDesc(char *buf, int bufSize); - // IWmeObject -private: - char *_filename; -public: - virtual bool sendEvent(const char *eventName); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SCRIPTHOLDER_H +#define WINTERMUTE_BASE_SCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class BaseScriptHolder : public BaseScriptable { +public: + DECLARE_PERSISTENT(BaseScriptHolder, BaseScriptable) + + 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(ScScript *script); + bool addScript(const char *filename); + 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); + const char *getFilename() { return _filename; } + bool parseProperty(byte *buffer, bool complete = true); + bool _freezable; + bool _ready; + + BaseArray _scripts; + // 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(); + virtual void scDebuggerDesc(char *buf, int bufSize); + // IWmeObject +private: + char *_filename; +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 index 6e5b30f7b6..143934402b 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -1,191 +1,191 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_value.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -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); - } - - _persistable = persistable; - - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseScriptable::~BaseScriptable() { - //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 BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - /* - stack->correctParams(0); - stack->pushNULL(); - script->runtimeError("Call to undefined method '%s'.", name); - - return STATUS_OK; - */ - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptable::scGetProperty(const char *name) { - 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; - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseScriptable::scToString() { - return "[native object]"; -} - -////////////////////////////////////////////////////////////////////////// -void *BaseScriptable::scToMemBuffer() { - return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseScriptable::scToInt() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -double BaseScriptable::scToFloat() { - return 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::scToBool() { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetString(const char *val) { -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetInt(int val) { -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetFloat(double val) { -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetBool(bool val) { -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_refCount)); - persistMgr->transfer(TMEMBER(_scProp)); - persistMgr->transfer(TMEMBER(_scValue)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseScriptable::scCompare(BaseScriptable *val) { - if (this < val) { - return -1; - } else if (this > val) { - return 1; - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::canHandleMethod(const char *eventMethod) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { - return NULL; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_value.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +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); + } + + _persistable = persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +BaseScriptable::~BaseScriptable() { + //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 BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + /* + stack->correctParams(0); + stack->pushNULL(); + script->runtimeError("Call to undefined method '%s'.", name); + + return STATUS_OK; + */ + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseScriptable::scGetProperty(const char *name) { + 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; + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseScriptable::scToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *BaseScriptable::scToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseScriptable::scToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double BaseScriptable::scToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::scToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetString(const char *val) { +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetInt(int val) { +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetFloat(double val) { +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetBool(bool val) { +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseScriptable::scCompare(BaseScriptable *val) { + if (this < val) { + return -1; + } else if (this > val) { + return 1; + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::canHandleMethod(const char *eventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { + return NULL; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 11cb0bcf9f..b006e6e07c 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -1,83 +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_BASE_SCRIPTABLE_H -#define WINTERMUTE_BASE_SCRIPTABLE_H - - -#include "engines/wintermute/base/base_named_object.h" -#include "engines/wintermute/persistent.h" - -namespace Wintermute { - -class ScValue; -class ScStack; -class ScScript; - -class BaseScriptable : public BaseNamedObject { -public: - virtual ScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) - - 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, 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(); - 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(BaseScriptable *val); - virtual void scDebuggerDesc(char *buf, int bufSize); - int _refCount; - ScValue *_scValue; - ScValue *_scProp; -}; - -// Implemented in their respective .cpp-files -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 - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SCRIPTABLE_H +#define WINTERMUTE_BASE_SCRIPTABLE_H + + +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/persistent.h" + +namespace Wintermute { + +class ScValue; +class ScStack; +class ScScript; + +class BaseScriptable : public BaseNamedObject { +public: + virtual ScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) + + 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, 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(); + 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(BaseScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); + int _refCount; + ScValue *_scValue; + ScValue *_scProp; +}; + +// Implemented in their respective .cpp-files +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 + +#endif diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index ae0e844cb5..e2dd8bbd39 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -1,814 +1,814 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_sprite.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(BaseSprite, false) - -////////////////////////////////////////////////////////////////////// -BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner) : BaseScriptHolder(inGame) { - _editorAllFrames = false; - _owner = Owner; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////// -BaseSprite::~BaseSprite() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSprite::setDefaults() { - _currentFrame = -1; - _looping = false; - _lastFrameTime = 0; - setFilename(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 BaseSprite::cleanup() { - BaseScriptHolder::cleanup(); - - for (uint32 i = 0; i < _frames.size(); i++) { - delete _frames[i]; - } - _frames.clear(); - - delete[] _editorBgFile; - _editorBgFile = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - getCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - 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 BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); - if (!file) { - _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); - if (_gameRef->_debugDebugMode) { - return loadFile("invalid_debug.bmp", lifeTime, cacheType); - } else { - return loadFile("invalid.bmp", lifeTime, cacheType); - } - } else { - BaseFileManager::getEngineInstance()->closeFile(file); - file = NULL; - } - - bool ret = STATUS_FAILED; - - AnsiString filePrefix = filename; - AnsiString ext = PathUtil::getExtension(filename); - 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); - if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); - ret = STATUS_FAILED; - delete frame; - delete subframe; - } else { - subframe->setDefaultRect(); - frame->_subframes.add(subframe); - _frames.add(frame); - _currentFrame = 0; - ret = STATUS_OK; - } - } else { - 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()); - } else { - ret = STATUS_OK; - } - delete[] buffer; - } - } - - setFilename(filename.c_str()); - - 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 BaseSprite::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; - BaseParser parser; - - 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; - BaseFrame *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 BaseFrame(_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 BaseSprite::reset() { - if (_frames.size() > 0) { - _currentFrame = 0; - } else { - _currentFrame = -1; - } - - killAllSounds(); - - _lastFrameTime = 0; - _finished = false; - _moveX = _moveY = 0; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSprite::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 < (int32)_frames.size() - 1) { - _currentFrame++; - if (_continuous) { - _canBreak = (_currentFrame == (int32)_frames.size() - 1); - } - } else { - if (_looping) { - _currentFrame = 0; - _canBreak = true; - } else { - _finished = true; - _canBreak = true; - } - } - - _lastFrameTime = timer; - } - - _changed = (lastFrame != _currentFrame || (_looping && (int32)_frames.size() == 1)); - - if (_lastFrameTime == 0) { - _lastFrameTime = timer; - _changed = true; - if (_continuous) { - _canBreak = (_currentFrame == (int32)_frames.size() - 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 BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - 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, registerVal, zoomX, zoomY, _precise, alpha, _editorAllFrames, rotate, blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -BaseSurface *BaseSprite::getSurface() { - // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - return NULL; - } - BaseFrame *frame = _frames[_currentFrame]; - if (frame && frame->_subframes.size() > 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; - } - - BasePlatform::setRectEmpty(rect); - for (uint32 i = 0; i < _frames.size(); i++) { - Rect32 frame; - Rect32 temp; - BasePlatform::copyRect(&temp, rect); - _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - BasePlatform::unionRect(rect, &temp, &frame); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITE {\n"); - 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"); - 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); - } - - BaseScriptHolder::saveAsText(buffer, indent + 2); - - // scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (uint32 i = 0; i < _frames.size(); i++) { - _frames[i]->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::persist(BasePersistenceManager *persistMgr) { - BaseScriptHolder::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 BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetFrame") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= (int32)_frames.size()) { - 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); - ScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - 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 (uint32 i = 0; i < _frames.size(); i++) { - if (_frames[i] == frame) { - if (i == (uint32)_currentFrame) { - _lastFrameTime = 0; - } - delete _frames[i]; - _frames.remove_at(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); - ScValue *val = stack->pop(); - const char *filename = NULL; - 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))) { - 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; - } - - ScValue *val = stack->pop(); - const char *filename = NULL; - 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 (index >= (int32)_frames.size()) { - _frames.add(frame); - } else { - _frames.insert_at(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 BaseScriptHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseSprite::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.size()); - 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 BaseScriptHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = value->getInt(0); - if (_currentFrame >= (int32)_frames.size() || _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 BaseScriptHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseSprite::scToString() { - return "[sprite]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::killAllSounds() { - for (uint32 i = 0; i < _frames.size(); i++) { - if (_frames[i]->_sound) { - _frames[i]->_sound->stop(); - } - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_sprite.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(BaseSprite, false) + +////////////////////////////////////////////////////////////////////// +BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner) : BaseScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +BaseSprite::~BaseSprite() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSprite::setDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + setFilename(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 BaseSprite::cleanup() { + BaseScriptHolder::cleanup(); + + for (uint32 i = 0; i < _frames.size(); i++) { + delete _frames[i]; + } + _frames.clear(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + getCurrentFrame(zoomX, zoomY); + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { + 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 BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); + if (!file) { + _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); + if (_gameRef->_debugDebugMode) { + return loadFile("invalid_debug.bmp", lifeTime, cacheType); + } else { + return loadFile("invalid.bmp", lifeTime, cacheType); + } + } else { + BaseFileManager::getEngineInstance()->closeFile(file); + file = NULL; + } + + bool ret = STATUS_FAILED; + + AnsiString filePrefix = filename; + AnsiString ext = PathUtil::getExtension(filename); + 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); + if (subframe->_surface == NULL) { + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); + ret = STATUS_FAILED; + delete frame; + delete subframe; + } else { + subframe->setDefaultRect(); + frame->_subframes.add(subframe); + _frames.add(frame); + _currentFrame = 0; + ret = STATUS_OK; + } + } else { + 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()); + } else { + ret = STATUS_OK; + } + delete[] buffer; + } + } + + setFilename(filename.c_str()); + + 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 BaseSprite::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; + BaseParser parser; + + 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; + BaseFrame *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 BaseFrame(_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 BaseSprite::reset() { + if (_frames.size() > 0) { + _currentFrame = 0; + } else { + _currentFrame = -1; + } + + killAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSprite::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 < (int32)_frames.size() - 1) { + _currentFrame++; + if (_continuous) { + _canBreak = (_currentFrame == (int32)_frames.size() - 1); + } + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (lastFrame != _currentFrame || (_looping && (int32)_frames.size() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) { + _canBreak = (_currentFrame == (int32)_frames.size() - 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 BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { + 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, registerVal, zoomX, zoomY, _precise, alpha, _editorAllFrames, rotate, blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +BaseSurface *BaseSprite::getSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { + return NULL; + } + BaseFrame *frame = _frames[_currentFrame]; + if (frame && frame->_subframes.size() > 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; + } + + BasePlatform::setRectEmpty(rect); + for (uint32 i = 0; i < _frames.size(); i++) { + Rect32 frame; + Rect32 temp; + BasePlatform::copyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + BasePlatform::unionRect(rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + 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"); + 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); + } + + BaseScriptHolder::saveAsText(buffer, indent + 2); + + // scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (uint32 i = 0; i < _frames.size(); i++) { + _frames[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::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 BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetFrame") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= (int32)_frames.size()) { + 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); + ScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + 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 (uint32 i = 0; i < _frames.size(); i++) { + if (_frames[i] == frame) { + if (i == (uint32)_currentFrame) { + _lastFrameTime = 0; + } + delete _frames[i]; + _frames.remove_at(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); + ScValue *val = stack->pop(); + const char *filename = NULL; + 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))) { + 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; + } + + ScValue *val = stack->pop(); + const char *filename = NULL; + 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 (index >= (int32)_frames.size()) { + _frames.add(frame); + } else { + _frames.insert_at(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 BaseScriptHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseSprite::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.size()); + 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 BaseScriptHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "CurrentFrame") == 0) { + _currentFrame = value->getInt(0); + if (_currentFrame >= (int32)_frames.size() || _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 BaseScriptHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseSprite::scToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::killAllSounds() { + for (uint32 i = 0; i < _frames.size(); 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 index db9931c6f3..c861ca9930 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -1,90 +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_BASE_SPRITE_H -#define WINTERMUTE_BASE_SPRITE_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/base_script_holder.h" - -namespace Wintermute { -class BaseFrame; -class BaseSurface; -class BaseObject; -class BaseSprite: public BaseScriptHolder { -public: - bool killAllSounds(); - BaseSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; - void cleanup(); - void setDefaults(); - bool _precise; - 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, 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(); - 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 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; - int _currentFrame; - 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; - bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SPRITE_H +#define WINTERMUTE_BASE_SPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base_script_holder.h" + +namespace Wintermute { +class BaseFrame; +class BaseSurface; +class BaseObject; +class BaseSprite: public BaseScriptHolder { +public: + bool killAllSounds(); + BaseSurface *getSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void cleanup(); + void setDefaults(); + bool _precise; + 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, 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(); + 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 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; + int _currentFrame; + 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; + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 3b5e5e3774..2f890beea1 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -1,255 +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/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 "common/str.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -BaseStringTable::~BaseStringTable() { - // delete strings - _strings.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -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) { - _gameRef->_textRTL = true; - return STATUS_OK; - } - - Common::String finalKey = key; - finalKey.toLowercase(); - - 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; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -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; - } - - char *key = new char[value - str]; - Common::strlcpy(key, str + 1, (size_t)(value - str)); - - BasePlatform::strlwr(key); - - 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[] newStr; - return key; - } - } else { - return key; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseStringTable::expand(char **str) const { - if (str == NULL || *str == NULL || *str[0] != '/') { - return; - } - - char *value = strchr(*str + 1, '/'); - if (value == NULL) { - return; - } - - char *key = new char[value - *str]; - Common::strlcpy(key, *str + 1, (size_t)(value - *str)); - - BasePlatform::strlwr(key); - - value++; - - char *newStr; - - StringsIter it = _strings.find(key); - if (it != _strings.end()) { - newStr = new char[it->_value.size() + 1]; - strcpy(newStr, it->_value.c_str()); - } else { - newStr = new char[strlen(value) + 1]; - strcpy(newStr, value); - } - - delete[] key; - delete[] *str; - *str = newStr; - - if (strlen(*str) > 0 && *str[0] == '/') { - expand(str); - } -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - char *key = new char[value - string]; - Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); - BasePlatform::strlwr(key); - - value++; - - const char *newStr; - - StringsIter it = _strings.find(key); - if (it != _strings.end()) { - newStr = it->_value.c_str(); - } else { - newStr = value; - } - - delete[] key; - - if (strlen(newStr) > 0 && newStr[0] == '/') { - return expandStatic(newStr); - } else { - return newStr; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseStringTable::loadFile(const char *filename, bool clearOld) { - _gameRef->LOG(0, "Loading string table..."); - - if (clearOld) { - _strings.clear(); - } - - uint32 size; - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseStringTable::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]; - Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 "common/str.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +BaseStringTable::~BaseStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +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) { + _gameRef->_textRTL = true; + return STATUS_OK; + } + + Common::String finalKey = key; + finalKey.toLowercase(); + + 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; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +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; + } + + char *key = new char[value - str]; + Common::strlcpy(key, str + 1, (size_t)(value - str)); + + BasePlatform::strlwr(key); + + 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[] newStr; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseStringTable::expand(char **str) const { + if (str == NULL || *str == NULL || *str[0] != '/') { + return; + } + + char *value = strchr(*str + 1, '/'); + if (value == NULL) { + return; + } + + char *key = new char[value - *str]; + Common::strlcpy(key, *str + 1, (size_t)(value - *str)); + + BasePlatform::strlwr(key); + + value++; + + char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); + } else { + newStr = new char[strlen(value) + 1]; + strcpy(newStr, value); + } + + delete[] key; + delete[] *str; + *str = newStr; + + if (strlen(*str) > 0 && *str[0] == '/') { + expand(str); + } +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + char *key = new char[value - string]; + Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); + BasePlatform::strlwr(key); + + value++; + + const char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = it->_value.c_str(); + } else { + newStr = value; + } + + delete[] key; + + if (strlen(newStr) > 0 && newStr[0] == '/') { + return expandStatic(newStr); + } else { + return newStr; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseStringTable::loadFile(const char *filename, bool clearOld) { + _gameRef->LOG(0, "Loading string table..."); + + if (clearOld) { + _strings.clear(); + } + + uint32 size; + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseStringTable::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]; + Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); + 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 index 09d8aecce4..128807bd1a 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -1,55 +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_BASE_STRING_TABLE_H -#define WINTERMUTE_BASE_STRING_TABLE_H - - -#include "common/hashmap.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseStringTable : public BaseClass { -public: - bool loadFile(const char *filename, bool deleteAll = true); - 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(); - char *getKey(const char *str) const; -private: - Common::HashMap _strings; - typedef Common::HashMap::const_iterator StringsIter; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_STRING_TABLE_H +#define WINTERMUTE_BASE_STRING_TABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseStringTable : public BaseClass { +public: + bool loadFile(const char *filename, bool deleteAll = true); + 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(); + char *getKey(const char *str) const; +private: + Common::HashMap _strings; + typedef Common::HashMap::const_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 index 3ddfd1bb14..6a9246efd4 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -1,655 +1,655 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseSubFrame, false) - -////////////////////////////////////////////////////////////////////////// -BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { - _surface = NULL; - _hotspotX = _hotspotY = 0; - _alpha = 0xFFFFFFFF; - _transparent = 0xFFFF00FF; - - _wantsDefaultRect = false; - BasePlatform::setRectEmpty(&_rect); - - _editorSelected = false; - - _surfaceFilename = NULL; - _cKDefault = true; - _cKRed = _cKBlue = _cKGreen = 0; - _lifeTime = -1; - _keepLoaded = false; - - _2DOnly = _3DOnly = false; - _decoration = false; - - _mirrorX = _mirrorY = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSubFrame::~BaseSubFrame() { - 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 BaseSubFrame::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; - BaseParser parser; - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custoTrans = false; - BasePlatform::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 (BasePlatform::isRectEmpty(&rect)) { - setDefaultRect(); - } else { - 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) { - if (!_surface) { - return STATUS_OK; - } - - if (registerOwner != NULL && !_decoration) { - if (zoomX == 100 && zoomY == 100) { - _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 + 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) { - 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, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); - } else { - if (zoomX == 100 && zoomY == 100) { - 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)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); - } - } - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -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; - - BasePlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), - (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::saveAsText(BaseDynamicBuffer *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; - BasePlatform::setRectEmpty(&rect); - if (_surface) { - BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } - 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) { - 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"); - } - - BaseClass::saveAsText(buffer, indent + 2); - - - if (complete) { - buffer->putTextIndent(indent, "}\n\n"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSubFrame::setDefaultRect() { - if (_surface) { - _wantsDefaultRect = true; - } else { - _wantsDefaultRect = false; - BasePlatform::setRectEmpty(&_rect); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::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(_wantsDefaultRect)); - - 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 BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); - ScValue *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 BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseSubFrame::scGetProperty(const char *name) { - if (!_scValue) { - _scValue = new ScValue(_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 BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::scSetProperty(const char *name, ScValue *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 BaseScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseSubFrame::scToString() { - return "[subframe]"; -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - delete[] _surfaceFilename; - _surfaceFilename = NULL; - - _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - if (_surface) { - _surfaceFilename = new char[filename.size() + 1]; - strcpy(_surfaceFilename, filename.c_str()); - - _cKDefault = defaultCK; - _cKRed = ckRed; - _cKGreen = ckGreen; - _cKBlue = ckBlue; - _lifeTime = lifeTime; - _keepLoaded = keepLoaded; - - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + _wantsDefaultRect = false; + BasePlatform::setRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSubFrame::~BaseSubFrame() { + 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 BaseSubFrame::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; + BaseParser parser; + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custoTrans = false; + BasePlatform::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 (BasePlatform::isRectEmpty(&rect)) { + setDefaultRect(); + } else { + 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) { + if (!_surface) { + return STATUS_OK; + } + + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + _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 + 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) { + 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, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + } else { + if (zoomX == 100 && zoomY == 100) { + 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)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +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; + + BasePlatform::setRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), + (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::saveAsText(BaseDynamicBuffer *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; + BasePlatform::setRectEmpty(&rect); + if (_surface) { + BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } + 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) { + 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"); + } + + BaseClass::saveAsText(buffer, indent + 2); + + + if (complete) { + buffer->putTextIndent(indent, "}\n\n"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSubFrame::setDefaultRect() { + if (_surface) { + _wantsDefaultRect = true; + } else { + _wantsDefaultRect = false; + BasePlatform::setRectEmpty(&_rect); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::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(_wantsDefaultRect)); + + 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 BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); + ScValue *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 BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseSubFrame::scGetProperty(const char *name) { + if (!_scValue) { + _scValue = new ScValue(_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 BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::scSetProperty(const char *name, ScValue *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 BaseScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseSubFrame::scToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + if (_surface) { + _surfaceFilename = new char[filename.size() + 1]; + strcpy(_surfaceFilename, filename.c_str()); + + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; + + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::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 index e89a189e2d..b174c6e5f0 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -1,92 +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_BASE_SUBFRAME_H -#define WINTERMUTE_BASE_SUBFRAME_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { -class BaseObject; -class BaseSurface; -class BaseSubFrame : public BaseScriptable { -public: - bool _mirrorX; - bool _mirrorY; - bool _decoration; - 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(); - uint32 _transparent; - bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete); - bool _editorSelected; - BaseSubFrame(BaseGame *inGame); - virtual ~BaseSubFrame(); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - 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; - 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; - byte _cKBlue; - int _lifeTime; - bool _keepLoaded; - char *_surfaceFilename; - - bool _2DOnly; - bool _3DOnly; - - BaseSurface *_surface; - - // 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(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SUBFRAME_H +#define WINTERMUTE_BASE_SUBFRAME_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { +class BaseObject; +class BaseSurface; +class BaseSubFrame : public BaseScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + 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(); + uint32 _transparent; + bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete); + bool _editorSelected; + BaseSubFrame(BaseGame *inGame); + virtual ~BaseSubFrame(); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + 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; + 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; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + BaseSurface *_surface; + + // 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(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index c87da898db..1dcebb0595 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -1,207 +1,207 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseSurfaceStorage, true); - -////////////////////////////////////////////////////////////////////// -BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame) : BaseClass(inGame) { - _lastCleanupTime = 0; -} - - -////////////////////////////////////////////////////////////////////// -BaseSurfaceStorage::~BaseSurfaceStorage() { - cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -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); - } - delete _surfaces[i]; - } - _surfaces.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::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 && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { - //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->invalidate(); - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::removeSurface(BaseSurface *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; -} - - -////////////////////////////////////////////////////////////////////// -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.c_str()) == 0) { - _surfaces[i]->_referenceCount++; - return _surfaces[i]; - } - } - - if (!BaseFileManager::getEngineInstance()->hasFile(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); - } else { - return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - } - } - - BaseSurface *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 BaseSurfaceStorage::restoreAll() { - bool ret; - for (uint32 i = 0; i < _surfaces.size(); i++) { - ret = _surfaces[i]->restore(); - if (ret != STATUS_OK) { - _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); - return ret; - } - } - return STATUS_OK; -} - - -/* -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) -{ - - if (!persistMgr->getIsSaving()) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - - //_surfaces.persist(persistMgr); - - return STATUS_OK; -} -*/ - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::sortSurfaces() { - Common::sort(_surfaces.begin(), _surfaces.end(), surfaceSortCB); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *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) { - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame) : BaseClass(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +BaseSurfaceStorage::~BaseSurfaceStorage() { + cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +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); + } + delete _surfaces[i]; + } + _surfaces.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::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 && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->invalidate(); + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::removeSurface(BaseSurface *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; +} + + +////////////////////////////////////////////////////////////////////// +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.c_str()) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + if (!BaseFileManager::getEngineInstance()->hasFile(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); + } else { + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } + } + + BaseSurface *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 BaseSurfaceStorage::restoreAll() { + bool ret; + for (uint32 i = 0; i < _surfaces.size(); i++) { + ret = _surfaces[i]->restore(); + if (ret != STATUS_OK) { + _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return STATUS_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) +{ + + if (!persistMgr->getIsSaving()) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + + //_surfaces.persist(persistMgr); + + return STATUS_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::sortSurfaces() { + Common::sort(_surfaces.begin(), _surfaces.end(), surfaceSortCB); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *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) { + 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 index 28c36bebca..aef8ad23f9 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -1,57 +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_BASE_SURFACE_STORAGE_H -#define WINTERMUTE_BASE_SURFACE_STORAGE_H - -#include "engines/wintermute/base/base.h" -#include "common/array.h" - -namespace Wintermute { -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(BaseSurfaceStorage, BaseClass); - - bool restoreAll(); - 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(); - - Common::Array _surfaces; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SURFACE_STORAGE_H +#define WINTERMUTE_BASE_SURFACE_STORAGE_H + +#include "engines/wintermute/base/base.h" +#include "common/array.h" + +namespace Wintermute { +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(BaseSurfaceStorage, BaseClass); + + bool restoreAll(); + 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(); + + 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 index d71bce1084..5c28f36d30 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -1,136 +1,136 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_transition_manager.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { - _state = TRANS_MGR_READY; - _type = TRANSITION_NONE; - _origInteractive = false; - _preserveInteractive = false; - _lastTime = 0; - _started = false; -} - - - -////////////////////////////////////////////////////////////////////////// -BaseTransitionMgr::~BaseTransitionMgr() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseTransitionMgr::isReady() { - return (_state == TRANS_MGR_READY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseTransitionMgr::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 BaseTransitionMgr::update() { - if (isReady()) { - return STATUS_OK; - } - - if (!_started) { - _started = true; - _lastTime = g_system->getMillis(); - } - - switch (_type) { - case TRANSITION_NONE: - _state = TRANS_MGR_READY; - break; - - case TRANSITION_FADE_OUT: { - 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); - - if (time > FADE_DURATION) { - _state = TRANS_MGR_READY; - } - } - break; - - case TRANSITION_FADE_IN: { - 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); - - if (time > FADE_DURATION) { - _state = TRANS_MGR_READY; - } - } - break; - default: - error("BaseTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); - } - - if (isReady()) { - if (_preserveInteractive) { - _gameRef->_interactive = _origInteractive; - } - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_transition_manager.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +BaseTransitionMgr::~BaseTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseTransitionMgr::isReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseTransitionMgr::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 BaseTransitionMgr::update() { + if (isReady()) { + return STATUS_OK; + } + + if (!_started) { + _started = true; + _lastTime = g_system->getMillis(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + 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); + + if (time > FADE_DURATION) { + _state = TRANS_MGR_READY; + } + } + break; + + case TRANSITION_FADE_IN: { + 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); + + if (time > FADE_DURATION) { + _state = TRANS_MGR_READY; + } + } + break; + default: + error("BaseTransitionMgr::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 index 1a989fbcfd..d16a44c88e 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -1,54 +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_BASE_TRANSITION_MANAGER_H -#define WINTERMUTE_BASE_TRANSITION_MANAGER_H - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseTransitionMgr : public BaseClass { -public: - bool _started; - uint32 _lastTime; - bool _origInteractive; - bool _preserveInteractive; - bool update(); - bool start(TTransitionType type, bool nonInteractive = false); - bool isReady(); - TTransMgrState _state; - BaseTransitionMgr(BaseGame *inGame); - virtual ~BaseTransitionMgr(); - TTransitionType _type; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_TRANSITION_MANAGER_H +#define WINTERMUTE_BASE_TRANSITION_MANAGER_H + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseTransitionMgr : public BaseClass { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); + bool isReady(); + TTransMgrState _state; + BaseTransitionMgr(BaseGame *inGame); + virtual ~BaseTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index af36a4fdd7..3b003e1c49 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -1,98 +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(BaseViewport, false) - -////////////////////////////////////////////////////////////////////////// -BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { - BasePlatform::setRectEmpty(&_rect); - _mainObject = NULL; - _offsetX = _offsetY = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BaseViewport::~BaseViewport() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseViewport::persist(BasePersistenceManager *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 BaseViewport::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); - } - - BasePlatform::setRect(&_rect, left, top, right, bottom); - _offsetX = left; - _offsetY = top; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -Rect32 *BaseViewport::getRect() { - return &_rect; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseViewport::getWidth() { - return _rect.right - _rect.left; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseViewport::getHeight() { - return _rect.bottom - _rect.top; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(BaseViewport, false) + +////////////////////////////////////////////////////////////////////////// +BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BaseViewport::~BaseViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseViewport::persist(BasePersistenceManager *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 BaseViewport::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); + } + + BasePlatform::setRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +Rect32 *BaseViewport::getRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseViewport::getWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseViewport::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 index c94beeb2b1..98ad1c1e14 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -1,55 +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_BASE_VIEWPORT_H -#define WINTERMUTE_BASE_VIEWPORT_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { -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(BaseViewport, BaseClass) - int _offsetY; - int _offsetX; - BaseObject *_mainObject; - BaseViewport(BaseGame *inGame = NULL); - virtual ~BaseViewport(); -private: - Rect32 _rect; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_VIEWPORT_H +#define WINTERMUTE_BASE_VIEWPORT_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { +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(BaseViewport, BaseClass) + int _offsetY; + int _offsetX; + BaseObject *_mainObject; + BaseViewport(BaseGame *inGame = NULL); + virtual ~BaseViewport(); +private: + Rect32 _rect; +}; + +} // 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 8fff78a32a..2d3951b026 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -1,196 +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 "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" -#include "common/archive.h" -#include "common/tokenizer.h" -#include "common/config-manager.h" - -namespace Wintermute { - -void correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') { - fileName[i] = '/'; - } - } -} - -// 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: These should have been handled in openDiskFile. - if (filename.contains(':')) { - // So just return an invalid node. - return Common::FSNode(); - } - - // 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. - curNode = curNode.getChild(pathPart); - if (!curNode.isReadable()) { - // Return an invalid FSNode. - return Common::FSNode(); - } - // Following the comments in common/fs.h, anything not a directory is a file. - if (!curNode.isDirectory()) { - if (!path.empty()) { - error("Relative path %s reached a file before the end of the path", filename.c_str()); - } - return curNode; - } - } - } - // 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) { - 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, fixedFilename); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { - if ((*it)->getName() == filename) { - file = (*it)->createReadStream(); - break; - } - } - // File wasn't found in SearchMan, try to parse the path as a relative path. - if (!file) { - Common::FSNode searchNode = getNodeForRelativePath(filename); - if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { - file = searchNode.createReadStream(); - } - } - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based 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_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" +#include "common/archive.h" +#include "common/tokenizer.h" +#include "common/config-manager.h" + +namespace Wintermute { + +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') { + fileName[i] = '/'; + } + } +} + +// 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: These should have been handled in openDiskFile. + if (filename.contains(':')) { + // So just return an invalid node. + return Common::FSNode(); + } + + // 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. + curNode = curNode.getChild(pathPart); + if (!curNode.isReadable()) { + // Return an invalid FSNode. + return Common::FSNode(); + } + // Following the comments in common/fs.h, anything not a directory is a file. + if (!curNode.isDirectory()) { + if (!path.empty()) { + error("Relative path %s reached a file before the end of the path", filename.c_str()); + } + return curNode; + } + } + } + // 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) { + 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, fixedFilename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { + if ((*it)->getName() == filename) { + file = (*it)->createReadStream(); + break; + } + } + // File wasn't found in SearchMan, try to parse the path as a relative path. + if (!file) { + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + file = searchNode.createReadStream(); + } + } + 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 index 69644408d0..c9f93b80d9 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -1,41 +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_BASE_DISKFILE_H -#define WINTERMUTE_BASE_DISKFILE_H - -#include "common/stream.h" - -namespace Wintermute { - -Common::SeekableReadStream *openDiskFile(const Common::String &filename); -bool diskFileExists(const Common::String &filename); - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_DISKFILE_H +#define WINTERMUTE_BASE_DISKFILE_H + +#include "common/stream.h" + +namespace Wintermute { + +Common::SeekableReadStream *openDiskFile(const Common::String &filename); +bool diskFileExists(const Common::String &filename); + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index f2a347ee0f..f52a13211e 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -1,68 +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 - */ - -#include "engines/wintermute/base/file/base_file.h" -#include "common/memstream.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -BaseFile::BaseFile() { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFile::~BaseFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFile::isEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *BaseFile::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_file.h" +#include "common/memstream.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +BaseFile::BaseFile() { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFile::~BaseFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFile::isEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *BaseFile::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 index 7ae36d5ad1..82f6ce3554 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -1,67 +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_BASE_FILE_H -#define WINTERMUTE_BASE_FILE_H - - -#include "engines/wintermute/base/base.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Wintermute { - -class BaseFile { -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(); - BaseFile(); - virtual ~BaseFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FILE_H +#define WINTERMUTE_BASE_FILE_H + + +#include "engines/wintermute/base/base.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Common { +class SeekableReadStream; +} + +namespace Wintermute { + +class BaseFile { +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(); + BaseFile(); + virtual ~BaseFile(); + // 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 index 82ddf7c90e..b9805d78dd 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -1,73 +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 - */ - -#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 { - -Common::SeekableReadStream *BaseFileEntry::createReadStream() const { - Common::SeekableReadStream *file = _package->getFilePointer(); - if (!file) { - return NULL; - } - - bool compressed = (_compressedLength != 0); - - if (compressed) { - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // - } else { - file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); - } - - file->seek(0); - - return file; -} - -////////////////////////////////////////////////////////////////////////// -BaseFileEntry::BaseFileEntry() { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFileEntry::~BaseFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 { + +Common::SeekableReadStream *BaseFileEntry::createReadStream() const { + Common::SeekableReadStream *file = _package->getFilePointer(); + if (!file) { + return NULL; + } + + bool compressed = (_compressedLength != 0); + + if (compressed) { + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // + } else { + file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); + } + + file->seek(0); + + return file; +} + +////////////////////////////////////////////////////////////////////////// +BaseFileEntry::BaseFileEntry() { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFileEntry::~BaseFileEntry() { + _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 index 6dd4bc08a4..6e4823d994 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -1,60 +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_BASE_FILEENTRY_H -#define WINTERMUTE_BASE_FILEENTRY_H - -#include "common/archive.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Wintermute { - -class BasePackage; - -class BaseFileEntry : public Common::ArchiveMember { -public: - virtual Common::SeekableReadStream *createReadStream() const; - virtual Common::String getName() const { return _filename; } - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - BasePackage *_package; - BaseFileEntry(); - virtual ~BaseFileEntry(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FILEENTRY_H +#define WINTERMUTE_BASE_FILEENTRY_H + +#include "common/archive.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Wintermute { + +class BasePackage; + +class BaseFileEntry : public Common::ArchiveMember { +public: + virtual Common::SeekableReadStream *createReadStream() const; + virtual Common::String getName() const { return _filename; } + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + BasePackage *_package; + BaseFileEntry(); + virtual ~BaseFileEntry(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index c5a62299e2..9780992652 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -1,276 +1,276 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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 { - -BasePackage::BasePackage() { - _name = ""; - _cd = 0; - _priority = 0; - _boundToExe = false; -} - -Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::SeekableReadStream *stream = _fsnode.createReadStream(); - - return stream; -} - -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; - -} - -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; - 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); - - 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); - 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] = 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; -} - -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()); -} - -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; -} - -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); -} - -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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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 { + +BasePackage::BasePackage() { + _name = ""; + _cd = 0; + _priority = 0; + _boundToExe = false; +} + +Common::SeekableReadStream *BasePackage::getFilePointer() { + Common::SeekableReadStream *stream = _fsnode.createReadStream(); + + return stream; +} + +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; + +} + +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; + 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); + + 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); + 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] = 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; +} + +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()); +} + +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; +} + +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); +} + +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 23d7d7690f..2882eb03b7 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -1,90 +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_BASE_PACKAGE_H -#define WINTERMUTE_BASE_PACKAGE_H - -#include "common/archive.h" -#include "common/stream.h" -#include "common/fs.h" - -namespace Wintermute { -class BasePackage { -public: - Common::SeekableReadStream *getFilePointer(); - Common::FSNode _fsnode; - bool _boundToExe; - byte _priority; - Common::String _name; - int _cd; - 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 - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_PACKAGE_H +#define WINTERMUTE_BASE_PACKAGE_H + +#include "common/archive.h" +#include "common/stream.h" +#include "common/fs.h" + +namespace Wintermute { +class BasePackage { +public: + Common::SeekableReadStream *getFilePointer(); + Common::FSNode _fsnode; + bool _boundToExe; + byte _priority; + Common::String _name; + int _cd; + 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 + +#endif diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index a8bda164dc..0b32cb0c4f 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -1,2830 +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/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 *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) { - 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; -} - -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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 *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) { + 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; +} + +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 48a0f534d0..91c30bcfa7 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -1,45 +1,45 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_RESOURCES_H -#define WINTERMUTE_BASE_RESOURCES_H - -#include "common/stream.h" -#include "common/str.h" - -namespace Wintermute { - -class BaseResources { -public: - static Common::SeekableReadStream *getFile(const Common::String &filename); - static bool hasFile(const Common::String &filename); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_RESOURCES_H +#define WINTERMUTE_BASE_RESOURCES_H + +#include "common/stream.h" +#include "common/str.h" + +namespace Wintermute { + +class BaseResources { +public: + static Common::SeekableReadStream *getFile(const Common::String &filename); + static bool hasFile(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 index 515d8870d7..5bdab0853e 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -1,154 +1,154 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/base/file/base_save_thumb_file.h" -#include "engines/wintermute/platform_osystem.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::BaseSaveThumbFile() { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::~BaseSaveThumbFile() { - close(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbFile::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; - - BasePersistenceManager *pm = new BasePersistenceManager(); - Common::String slotFilename = pm->getFilenameForSlot(slot); - if (!pm) { - return STATUS_FAILED; - } - - if (DID_FAIL(pm->initLoad(slotFilename))) { - delete pm; - return STATUS_FAILED; - } - - 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 BaseSaveThumbFile::close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbFile::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 BaseSaveThumbFile::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/base/file/base_save_thumb_file.h" +#include "engines/wintermute/platform_osystem.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbFile::BaseSaveThumbFile() { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbFile::~BaseSaveThumbFile() { + close(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbFile::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; + + BasePersistenceManager *pm = new BasePersistenceManager(); + Common::String slotFilename = pm->getFilenameForSlot(slot); + if (!pm) { + return STATUS_FAILED; + } + + if (DID_FAIL(pm->initLoad(slotFilename))) { + delete pm; + return STATUS_FAILED; + } + + 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 BaseSaveThumbFile::close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbFile::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 BaseSaveThumbFile::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 index 377e06f02c..3b217525fd 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -1,52 +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_BASE_SAVETHUMBFILE_H -#define WINTERMUTE_BASE_SAVETHUMBFILE_H - - -#include "engines/wintermute/base/file/base_file.h" - -namespace Wintermute { - -//TODO: Get rid of this -class BaseSaveThumbFile : public BaseFile { -public: - BaseSaveThumbFile(); - virtual ~BaseSaveThumbFile(); - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SAVETHUMBFILE_H +#define WINTERMUTE_BASE_SAVETHUMBFILE_H + + +#include "engines/wintermute/base/file/base_file.h" + +namespace Wintermute { + +//TODO: Get rid of this +class BaseSaveThumbFile : public BaseFile { +public: + BaseSaveThumbFile(); + virtual ~BaseSaveThumbFile(); + 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/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 82f1998527..2234139408 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -1,80 +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 _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; - // base_package.cpp: - void readFromStream(Common::ReadStream *stream); -}; - -/* -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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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; + // base_package.cpp: + void readFromStream(Common::ReadStream *stream); +}; + +/* +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 diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index cb70c4add8..87dd3da5a3 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -1,140 +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 - */ - -#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" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseFont, false) - -////////////////////////////////////////////////////////////////////// -BaseFont::BaseFont(BaseGame *inGame) : BaseObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -BaseFont::~BaseFont() { -} - - -////////////////////////////////////////////////////////////////////// -void BaseFont::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { -} - - -////////////////////////////////////////////////////////////////////// -int BaseFont::getTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int BaseFont::getTextWidth(byte *text, int maxLength) { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseFont::getLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFont::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) { - if (isTrueType(gameRef, filename)) { - BaseFontTT *font = new BaseFontTT(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } else { - BaseFontBitmap *font = new BaseFontBitmap(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 BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - return false; - } - - byte *workBuffer = buffer; - - char *params; - BaseParser parser; - - bool ret = false; - if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { - ret = true; - } - - delete[] buffer; - return ret; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseFont, false) + +////////////////////////////////////////////////////////////////////// +BaseFont::BaseFont(BaseGame *inGame) : BaseObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +BaseFont::~BaseFont() { +} + + +////////////////////////////////////////////////////////////////////// +void BaseFont::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int BaseFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int BaseFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFont::persist(BasePersistenceManager *persistMgr) { + + BaseObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) { + if (isTrueType(gameRef, filename)) { + BaseFontTT *font = new BaseFontTT(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + BaseFontBitmap *font = new BaseFontBitmap(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 BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + return false; + } + + byte *workBuffer = buffer; + + char *params; + BaseParser parser; + + 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 index acd424ac06..0abe62ab98 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -1,61 +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_BASE_FONT_H -#define WINTERMUTE_BASE_FONT_H - -#include "engines/wintermute/base/base_object.h" - -#define NUM_CHARACTERS 256 - -namespace Wintermute { - -class BaseFont: public BaseObject { -public: - DECLARE_PERSISTENT(BaseFont, BaseObject) - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - 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() {} - BaseFont(BaseGame *inGame); - virtual ~BaseFont(); - - 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 Common::String &filename); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONT_H +#define WINTERMUTE_BASE_FONT_H + +#include "engines/wintermute/base/base_object.h" + +#define NUM_CHARACTERS 256 + +namespace Wintermute { + +class BaseFont: public BaseObject { +public: + DECLARE_PERSISTENT(BaseFont, BaseObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + 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() {} + BaseFont(BaseGame *inGame); + virtual ~BaseFont(); + + 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 Common::String &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 index 062f4801cf..fced08c7e2 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -1,589 +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/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(BaseFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -BaseFontBitmap::BaseFontBitmap(BaseGame *inGame) : BaseFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -BaseFontBitmap::~BaseFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -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); -} - - -////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::getTextHeight(byte *text, int width) { - return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::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; (uint32)i < str.size(); i++) { - textWidth += getCharWidth((byte)str[i]); - } - - return textWidth; -} - - -////////////////////////////////////////////////////////////////////// -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; - } - - if (text == NULL || text[0] == '\0') { - return _tileHeight; - } - - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((const 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 newLine = false; - bool longLine = 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; - newLine = true; - } - - if (lineLength + getCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - realLength = lineLength; - newLine = true; - longLine = true; - } - - if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { - done = true; - if (!newLine) { - end = index; - lineLength += getCharWidth(str[index]); - realLength = lineLength; - } - } else { - lineLength += getCharWidth(str[index]); - } - - if ((lineLength > width) || done || newLine) { - 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("BaseFontBitmap::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 (longLine) { - end--; - } - start = end + 2; - index = end + 1; - lineLength = 0; - newLine = false; - longLine = false; - numLines++; - } - } - - if (draw) { - _gameRef->_renderer->endSpriteBatch(); - } - - return numLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::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]; - } - - BasePlatform::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 < (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; - } - } - if (!handled && _subframe) { - _subframe->_surface->displayTrans(x, y, rect); - } -} - - -////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::loadFile(const Common::String &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; - } - - bool ret; - - setFilename(filename.c_str()); - - if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str()); - } - - 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 BaseFontBitmap::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; - BaseParser parser; - - 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, defaultWidth = 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", &defaultWidth); - 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 BaseSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surfaceFile != NULL && !_sprite) { - _subframe = new BaseSubFrame(_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] = defaultWidth; - } - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { - - BaseFont::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->getIsSaving()) { - persistMgr->putBytes(_widths, sizeof(_widths)); - } else { - persistMgr->getBytes(_widths, sizeof(_widths)); - } - - - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::getCharWidth(byte index) { - if (_fontextFix) { - index--; - } - return _widths[index]; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::getWidths() { - BaseSurface *surf = NULL; - - if (_sprite) { - 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; - } - } - } - 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 BaseFontBitmap::getLetterHeight() { - return _tileHeight; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(BaseFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +BaseFontBitmap::BaseFontBitmap(BaseGame *inGame) : BaseFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +BaseFontBitmap::~BaseFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +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); +} + + +////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::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; (uint32)i < str.size(); i++) { + textWidth += getCharWidth((byte)str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +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; + } + + if (text == NULL || text[0] == '\0') { + return _tileHeight; + } + + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((const 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 newLine = false; + bool longLine = 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; + newLine = true; + } + + if (lineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + realLength = lineLength; + newLine = true; + longLine = true; + } + + if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!newLine) { + end = index; + lineLength += getCharWidth(str[index]); + realLength = lineLength; + } + } else { + lineLength += getCharWidth(str[index]); + } + + if ((lineLength > width) || done || newLine) { + 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("BaseFontBitmap::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 (longLine) { + end--; + } + start = end + 2; + index = end + 1; + lineLength = 0; + newLine = false; + longLine = false; + numLines++; + } + } + + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } + + return numLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void BaseFontBitmap::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]; + } + + BasePlatform::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 < (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; + } + } + if (!handled && _subframe) { + _subframe->_surface->displayTrans(x, y, rect); + } +} + + +////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::loadFile(const Common::String &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; + } + + bool ret; + + setFilename(filename.c_str()); + + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str()); + } + + 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 BaseFontBitmap::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; + BaseParser parser; + + 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, defaultWidth = 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", &defaultWidth); + 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 BaseSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new BaseSubFrame(_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] = defaultWidth; + } + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { + + BaseFont::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->getIsSaving()) { + persistMgr->putBytes(_widths, sizeof(_widths)); + } else { + persistMgr->getBytes(_widths, sizeof(_widths)); + } + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::getCharWidth(byte index) { + if (_fontextFix) { + index--; + } + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::getWidths() { + BaseSurface *surf = NULL; + + if (_sprite) { + 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; + } + } + } + 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 BaseFontBitmap::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 index 14a6e1cc87..2f3a69d097 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -1,71 +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_BASE_FONTBITMAP_H -#define WINTERMUTE_BASE_FONTBITMAP_H - - -#include "engines/wintermute/base/font/base_font.h" - -namespace Wintermute { -class BaseSubFrame; -class BaseFontBitmap : public BaseFont { -public: - DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) - bool loadBuffer(byte *Buffer); - bool loadFile(const Common::String &filename); - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - 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); - virtual ~BaseFontBitmap(); - -private: - bool getWidths(); - BaseSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - BaseSubFrame *_subframe; - bool _wholeCell; - - int getCharWidth(byte index); - void drawChar(byte c, int x, int y); - - int textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONTBITMAP_H +#define WINTERMUTE_BASE_FONTBITMAP_H + + +#include "engines/wintermute/base/font/base_font.h" + +namespace Wintermute { +class BaseSubFrame; +class BaseFontBitmap : public BaseFont { +public: + DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) + bool loadBuffer(byte *Buffer); + bool loadFile(const Common::String &filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + 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); + virtual ~BaseFontBitmap(); + +private: + bool getWidths(); + BaseSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + BaseSubFrame *_subframe; + bool _wholeCell; + + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(const 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 index 298417ec32..d26fa1d593 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -1,142 +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 - */ - -#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(BaseFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -BaseFontStorage::BaseFontStorage(BaseGame *inGame) : BaseClass(inGame) { -} - -////////////////////////////////////////////////////////////////////////// -BaseFontStorage::~BaseFontStorage() { - cleanup(true); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::cleanup(bool warn) { - for (uint32 i = 0; i < _fonts.size(); i++) { - if (warn) { - _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); - } - delete _fonts[i]; - } - _fonts.clear(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::initLoop() { - for (uint32 i = 0; i < _fonts.size(); i++) { - _fonts[i]->initLoop(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFontStorage::addFont(const Common::String &filename) { - if (!filename.size()) { - return NULL; - } - - for (uint32 i = 0; i < _fonts.size(); i++) { - if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - BaseFont* font = new BaseFont(_gameRef); - if (!font) return NULL; - - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.add(font); - return font; - } - */ - BaseFont *font = BaseFont::createFromFile(_gameRef, filename); - if (font) { - font->_refCount = 1; - _fonts.add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::removeFont(BaseFont *font) { - if (!font) { - return STATUS_FAILED; - } - - for (uint32 i = 0; i < _fonts.size(); i++) { - if (_fonts[i] == font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.remove_at(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { - - if (!persistMgr->getIsSaving()) { - cleanup(false); - } - - persistMgr->transfer(TMEMBER(_gameRef)); - _fonts.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(BaseFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +BaseFontStorage::BaseFontStorage(BaseGame *inGame) : BaseClass(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +BaseFontStorage::~BaseFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::cleanup(bool warn) { + for (uint32 i = 0; i < _fonts.size(); i++) { + if (warn) { + _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); + } + delete _fonts[i]; + } + _fonts.clear(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::initLoop() { + for (uint32 i = 0; i < _fonts.size(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +BaseFont *BaseFontStorage::addFont(const Common::String &filename) { + if (!filename.size()) { + return NULL; + } + + for (uint32 i = 0; i < _fonts.size(); i++) { + if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + BaseFont* font = new BaseFont(_gameRef); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + BaseFont *font = BaseFont::createFromFile(_gameRef, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::removeFont(BaseFont *font) { + if (!font) { + return STATUS_FAILED; + } + + for (uint32 i = 0; i < _fonts.size(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { + + if (!persistMgr->getIsSaving()) { + 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 index 733e1c5da3..60874167e7 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -1,55 +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_BASE_FONTSTORAGE_H -#define WINTERMUTE_BASE_FONTSTORAGE_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { - -class BaseFont; - -class BaseFontStorage : public BaseClass { -public: - DECLARE_PERSISTENT(BaseFontStorage, BaseClass) - bool cleanup(bool warn = false); - bool removeFont(BaseFont *font); - BaseFont *addFont(const Common::String &filename); - BaseFontStorage(BaseGame *inGame); - virtual ~BaseFontStorage(); - BaseArray _fonts; - bool initLoop(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONTSTORAGE_H +#define WINTERMUTE_BASE_FONTSTORAGE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { + +class BaseFont; + +class BaseFontStorage : public BaseClass { +public: + DECLARE_PERSISTENT(BaseFontStorage, BaseClass) + bool cleanup(bool warn = false); + bool removeFont(BaseFont *font); + BaseFont *addFont(const Common::String &filename); + BaseFontStorage(BaseGame *inGame); + virtual ~BaseFontStorage(); + BaseArray _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 index 171f33d8ab..599010bbd5 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -1,605 +1,605 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseFontTT, false) - -////////////////////////////////////////////////////////////////////////// -BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(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; - } - - _lineHeight = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -BaseFontTT::~BaseFontTT(void) { - clearCache(); - - for (uint32 i = 0; i < _layers.size(); i++) { - delete _layers[i]; - } - _layers.clear(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _deletableFont; - _font = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::clearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) { - delete _cachedTexts[i]; - } - _cachedTexts[i] = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -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 - 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 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 (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 BaseFontTT::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 BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((const char *)text, "") == 0) { - return; - } - - WideString textStr = (const 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 - - BaseRenderer *renderer = _gameRef->_renderer; - - // find cached surface, if exists - int minPriority = INT_MAX; - int minIndex = -1; - BaseSurface *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 BaseCachedTTFontText; - - _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; - BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (uint32 i = 0; i < _layers.size(); 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; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - //TextLineList lines; - // TODO: Use WideString-conversion here. - //WrapText(text, width, maxHeight, lines); - 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; - } else if (align == TAL_CENTER) { - alignment = Graphics::kTextAlignCenter; - } else if (align == TAL_RIGHT) { - 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)); -// 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, 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)); - } - 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; - } - - BaseSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); - retSurface->putSurface(*convertedSurface, true); - convertedSurface->free(); - surface->free(); - delete surface; - delete convertedSurface; - return retSurface; - // TODO: _isUnderline, _isBold, _isItalic, _isStriked -} - - -////////////////////////////////////////////////////////////////////////// -int BaseFontTT::getLetterHeight() { - return (int)getLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -bool BaseFontTT::loadFile(const Common::String &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; - } - - bool ret; - - setFilename(filename.c_str()); - - if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str()); - } - - 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 BaseFontTT::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; - BaseParser parser; - - 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: - BaseUtils::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: { - BaseTTFontLayer *layer = new BaseTTFontLayer; - 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.size() == 0) { - BaseTTFontLayer *layer = new BaseTTFontLayer; - layer->_color = baseColor; - _layers.add(layer); - } - - if (!_fontFile) { - BaseUtils::setString(&_fontFile, "arial.ttf"); - } - - return initFont(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontTT::parseLayer(BaseTTFontLayer *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; - BaseParser parser; - - 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 BaseFontTT::persist(BasePersistenceManager *persistMgr) { - BaseFont::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->getIsSaving()) { - numLayers = _layers.size(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - _layers[i]->persist(persistMgr); - } - } else { - numLayers = _layers.size(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - BaseTTFontLayer *layer = new BaseTTFontLayer; - layer->persist(persistMgr); - _layers.add(layer); - } - } - - if (!persistMgr->getIsSaving()) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - _cachedTexts[i] = NULL; - } - _fallbackFont = _font = _deletableFont = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::afterLoad() { - initFont(); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFontTT::initFont() { - if (!_fontFile) { - return STATUS_FAILED; - } - - 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 = BaseFileManager::getEngineInstance()->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, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). - _font = _deletableFont; -#endif - } - if (!_font) { - _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BaseFontTT::InitFont - Couldn't load font: %s", _fontFile); - } - _lineHeight = _font->getFontHeight(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - //TextLineList lines; - - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(BaseFontTT, false) + +////////////////////////////////////////////////////////////////////////// +BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(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; + } + + _lineHeight = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +BaseFontTT::~BaseFontTT(void) { + clearCache(); + + for (uint32 i = 0; i < _layers.size(); i++) { + delete _layers[i]; + } + _layers.clear(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) { + delete _cachedTexts[i]; + } + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +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 + 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 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 (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 BaseFontTT::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 BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((const char *)text, "") == 0) { + return; + } + + WideString textStr = (const 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 + + BaseRenderer *renderer = _gameRef->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + BaseSurface *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 BaseCachedTTFontText; + + _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; + BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (uint32 i = 0; i < _layers.size(); 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; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO: Use WideString-conversion here. + //WrapText(text, width, maxHeight, lines); + 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; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + 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)); +// 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, 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)); + } + 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; + } + + BaseSurface *retSurface = _gameRef->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; + // TODO: _isUnderline, _isBold, _isItalic, _isStriked +} + + +////////////////////////////////////////////////////////////////////////// +int BaseFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +bool BaseFontTT::loadFile(const Common::String &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; + } + + bool ret; + + setFilename(filename.c_str()); + + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str()); + } + + 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 BaseFontTT::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; + BaseParser parser; + + 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: + BaseUtils::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: { + BaseTTFontLayer *layer = new BaseTTFontLayer; + 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.size() == 0) { + BaseTTFontLayer *layer = new BaseTTFontLayer; + layer->_color = baseColor; + _layers.add(layer); + } + + if (!_fontFile) { + BaseUtils::setString(&_fontFile, "arial.ttf"); + } + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontTT::parseLayer(BaseTTFontLayer *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; + BaseParser parser; + + 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 BaseFontTT::persist(BasePersistenceManager *persistMgr) { + BaseFont::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->getIsSaving()) { + numLayers = _layers.size(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + _layers[i]->persist(persistMgr); + } + } else { + numLayers = _layers.size(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + BaseTTFontLayer *layer = new BaseTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->getIsSaving()) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFontTT::initFont() { + if (!_fontFile) { + return STATUS_FAILED; + } + + 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 = BaseFileManager::getEngineInstance()->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, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BaseFontTT::InitFont - Couldn't load font: %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + + 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 index a93e4efacb..02dca7439f 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -1,152 +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 - */ - -#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" -#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 BaseFontTT : public BaseFont { -private: - ////////////////////////////////////////////////////////////////////////// - class BaseCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - BaseSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - BaseCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~BaseCachedTTFontText() { - if (_surface) { - delete _surface; - } - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class BaseTTFontLayer { - public: - BaseTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - bool persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); - return STATUS_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - -public: - 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); - 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); - bool loadFile(const Common::String &filename); - - float getLineHeight() const { - return _lineHeight; - } - - void afterLoad(); - void initLoop(); - -private: - bool parseLayer(BaseTTFontLayer *layer, byte *buffer); - - 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); - - BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - bool initFont(); - - Graphics::Font *_deletableFont; - const Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - - float _lineHeight; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - BaseArray _layers; - void clearCache(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#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" +#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 BaseFontTT : public BaseFont { +private: + ////////////////////////////////////////////////////////////////////////// + class BaseCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + BaseSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + BaseCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~BaseCachedTTFontText() { + if (_surface) { + delete _surface; + } + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class BaseTTFontLayer { + public: + BaseTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + bool persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + +public: + 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); + 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); + bool loadFile(const Common::String &filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + bool parseLayer(BaseTTFontLayer *layer, byte *buffer); + + 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); + + BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + bool initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _lineHeight; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + BaseArray _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 bf11e15307..4b15d563ed 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -1,231 +1,231 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/gfx/base_image.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/graphics/transparent_surface.h" -#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 "common/textconsole.h" -#include "common/stream.h" -#include "common/system.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseImage::BaseImage() { - _fileManager = BaseFileManager::getEngineInstance(); - _palette = NULL; - _surface = NULL; - _decoder = NULL; - _deletableSurface = NULL; -} - - -////////////////////////////////////////////////////////////////////// -BaseImage::~BaseImage() { - delete _decoder; - if (_deletableSurface) { - _deletableSurface->free(); - } - delete _deletableSurface; -} - -bool BaseImage::loadFile(const Common::String &filename) { - _filename = filename; - _filename.toLowercase(); - if (filename.hasPrefix("savegame:")) { - _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 Graphics::TGADecoder(); - } else if (_filename.hasSuffix(".jpg")) { - _decoder = new Graphics::JPEGDecoder(); - } else { - error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); - } - _filename = filename; - Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); - if (!file) { - return false; - } - - _decoder->loadStream(*file); - _surface = _decoder->getSurface(); - _palette = _decoder->getPalette(); - _fileManager->closeFile(file); - - return true; -} - -byte BaseImage::getAlphaAt(int x, int y) const { - if (!_surface) { - return 0xFF; - } - uint32 color = *(const uint32 *)_surface->getBasePtr(x, y); - byte r, g, b, a; - _surface->format.colorToARGB(color, a, r, g, b); - return a; -} - -void BaseImage::copyFrom(const Graphics::Surface *surface) { - _surface = _deletableSurface = new Graphics::Surface(); - _deletableSurface->copyFrom(*surface); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::saveBMPFile(const char *filename) const { - warning("BaseImage::saveBMPFile - stubbed"); // TODO - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::resize(int newWidth, int newHeight) { - // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - TransparentSurface temp(*_surface, true); - if (_deletableSurface) { - _deletableSurface->free(); - delete _deletableSurface; - _deletableSurface = NULL; - } - _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); - temp.free(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -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 */ - 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; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { - // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - - TransparentSurface temp(*origImage->_surface, false); - if (_deletableSurface) { - _deletableSurface->free(); - delete _deletableSurface; - _deletableSurface = NULL; - } - _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); - return true; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/gfx/base_image.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/graphics/transparent_surface.h" +#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 "common/textconsole.h" +#include "common/stream.h" +#include "common/system.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseImage::BaseImage() { + _fileManager = BaseFileManager::getEngineInstance(); + _palette = NULL; + _surface = NULL; + _decoder = NULL; + _deletableSurface = NULL; +} + + +////////////////////////////////////////////////////////////////////// +BaseImage::~BaseImage() { + delete _decoder; + if (_deletableSurface) { + _deletableSurface->free(); + } + delete _deletableSurface; +} + +bool BaseImage::loadFile(const Common::String &filename) { + _filename = filename; + _filename.toLowercase(); + if (filename.hasPrefix("savegame:")) { + _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 Graphics::TGADecoder(); + } else if (_filename.hasSuffix(".jpg")) { + _decoder = new Graphics::JPEGDecoder(); + } else { + error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); + } + _filename = filename; + Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); + if (!file) { + return false; + } + + _decoder->loadStream(*file); + _surface = _decoder->getSurface(); + _palette = _decoder->getPalette(); + _fileManager->closeFile(file); + + return true; +} + +byte BaseImage::getAlphaAt(int x, int y) const { + if (!_surface) { + return 0xFF; + } + uint32 color = *(const uint32 *)_surface->getBasePtr(x, y); + byte r, g, b, a; + _surface->format.colorToARGB(color, a, r, g, b); + return a; +} + +void BaseImage::copyFrom(const Graphics::Surface *surface) { + _surface = _deletableSurface = new Graphics::Surface(); + _deletableSurface->copyFrom(*surface); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::saveBMPFile(const char *filename) const { + warning("BaseImage::saveBMPFile - stubbed"); // TODO + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::resize(int newWidth, int newHeight) { + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. + TransparentSurface temp(*_surface, true); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); + temp.free(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +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 */ + 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; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. + + TransparentSurface temp(*origImage->_surface, false); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); + return true; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 560a5f0d74..6d01b84184 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -1,72 +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_BASE_IMAGE_H -#define WINTERMUTE_BASE_IMAGE_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" - -namespace Wintermute { -class BaseSurface; -class BaseFileManager; -class BaseImage { - -public: - BaseImage(); - ~BaseImage(); - - 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) const; - bool writeBMPToStream(Common::WriteStream *stream) const; - bool resize(int newWidth, int newHeight); - bool saveBMPFile(const char *filename) const; - bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); - void copyFrom(const Graphics::Surface *surface); -private: - Common::String _filename; - Graphics::ImageDecoder *_decoder; - const Graphics::Surface *_surface; - Graphics::Surface *_deletableSurface; - const byte *_palette; - BaseFileManager *_fileManager; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_IMAGE_H +#define WINTERMUTE_BASE_IMAGE_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" + +namespace Wintermute { +class BaseSurface; +class BaseFileManager; +class BaseImage { + +public: + BaseImage(); + ~BaseImage(); + + 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) const; + bool writeBMPToStream(Common::WriteStream *stream) const; + bool resize(int newWidth, int newHeight); + bool saveBMPFile(const char *filename) const; + bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); + void copyFrom(const Graphics::Surface *surface); +private: + Common::String _filename; + Graphics::ImageDecoder *_decoder; + const Graphics::Surface *_surface; + Graphics::Surface *_deletableSurface; + const byte *_palette; + BaseFileManager *_fileManager; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 202c864683..9205438a5b 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -1,381 +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/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/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 { - -////////////////////////////////////////////////////////////////////// -BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { - _window = 0; - _clipperWindow = 0; - _active = false; - _ready = false; - _windowed = true; - _forceAlphaColor = 0x00; - - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; - _indicatorWidthDrawn = 0; - - _loadImageName = ""; - _saveImageName = ""; - _saveLoadImage = NULL; - _loadInProgress = false; - _hasDrawnSaveLoadImage = false; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - - _width = _height = _bPP = 0; - BasePlatform::setRectEmpty(&_monitorRect); - - _realWidth = _realHeight = 0; - _drawOffsetX = _drawOffsetY = 0; -} - - -////////////////////////////////////////////////////////////////////// -BaseRenderer::~BaseRenderer() { - deleteRectList(); - unclipCursor(); - delete _saveLoadImage; -} - - -////////////////////////////////////////////////////////////////////// -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) { - bool redisplay = (_indicatorProgress != value); - _indicatorProgress = value; - if (redisplay) - displayIndicator(); -} - -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; - _hasDrawnSaveLoadImage = false; - - 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; - _indicatorWidthDrawn = 0; - - 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) { - Point32 point; - point.x = x; - point.y = y; - - for (int i = _rectList.size() - 1; i >= 0; i--) { - if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { - if (_rectList[i]->_precise) { - // frame - if (_rectList[i]->_frame) { - 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->getRect().right - _rectList[i]->_frame->getRect().left; - xx = width - xx; - } - - if (_rectList[i]->_frame->_mirrorY) { - int height = _rectList[i]->_frame->getRect().bottom - _rectList[i]->_frame->getRect().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 (BaseObject *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRenderer::deleteRectList() { - for (uint32 i = 0; i < _rectList.size(); i++) { - delete _rectList[i]; - } - _rectList.clear(); -} - -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::initRenderer(int width, int height, bool windowed) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -void BaseRenderer::onWindowChange() { -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::windowedBlt() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setup2D(bool Force) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setupLines() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -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 - - 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 BaseRenderer::setViewport(int left, int top, int right, int bottom) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setScreenViewport() { - return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setViewport(Rect32 *rect) { - return setViewport(rect->left + _drawOffsetX, - rect->top + _drawOffsetY, - rect->right + _drawOffsetX, - rect->bottom + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::clipCursor() { - // TODO: Reimplement this. (Currently aspect-indpendence isn't quite finished) - /* - 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 BaseRenderer::unclipCursor() { - /* - if (!_windowed) ::ClipCursor(NULL); - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -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; - } - - return true; -} - -void BaseRenderer::addRectToList(BaseActiveRect *rect) { - _rectList.push_back(rect); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::displayIndicator() { - if (!_indicatorDisplay || !_indicatorProgress) { - return STATUS_OK; - } - if (_saveLoadImage && !_hasDrawnSaveLoadImage) { - Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) { - _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - } else { - _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - flip(); - _hasDrawnSaveLoadImage = true; - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { - 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 + curWidth, _indicatorY + i, _indicatorColor); - } - - setup2D(); - _indicatorWidthDrawn = curWidth; - if (_indicatorWidthDrawn) { - indicatorFlip(); - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_active_rect.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#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 { + +////////////////////////////////////////////////////////////////////// +BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { + _window = 0; + _clipperWindow = 0; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _indicatorWidthDrawn = 0; + + _loadImageName = ""; + _saveImageName = ""; + _saveLoadImage = NULL; + _loadInProgress = false; + _hasDrawnSaveLoadImage = false; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _width = _height = _bPP = 0; + BasePlatform::setRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +BaseRenderer::~BaseRenderer() { + deleteRectList(); + unclipCursor(); + delete _saveLoadImage; +} + + +////////////////////////////////////////////////////////////////////// +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) { + bool redisplay = (_indicatorProgress != value); + _indicatorProgress = value; + if (redisplay) + displayIndicator(); +} + +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; + _hasDrawnSaveLoadImage = false; + + 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; + _indicatorWidthDrawn = 0; + + 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) { + Point32 point; + point.x = x; + point.y = y; + + for (int i = _rectList.size() - 1; i >= 0; i--) { + if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { + // frame + if (_rectList[i]->_frame) { + 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->getRect().right - _rectList[i]->_frame->getRect().left; + xx = width - xx; + } + + if (_rectList[i]->_frame->_mirrorY) { + int height = _rectList[i]->_frame->getRect().bottom - _rectList[i]->_frame->getRect().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 (BaseObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseRenderer::deleteRectList() { + for (uint32 i = 0; i < _rectList.size(); i++) { + delete _rectList[i]; + } + _rectList.clear(); +} + +////////////////////////////////////////////////////////////////////// +bool BaseRenderer::initRenderer(int width, int height, bool windowed) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +void BaseRenderer::onWindowChange() { +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::windowedBlt() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setup2D(bool Force) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setupLines() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +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 + + 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 BaseRenderer::setViewport(int left, int top, int right, int bottom) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setScreenViewport() { + return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setViewport(Rect32 *rect) { + return setViewport(rect->left + _drawOffsetX, + rect->top + _drawOffsetY, + rect->right + _drawOffsetX, + rect->bottom + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::clipCursor() { + // TODO: Reimplement this. (Currently aspect-indpendence isn't quite finished) + /* + 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 BaseRenderer::unclipCursor() { + /* + if (!_windowed) ::ClipCursor(NULL); + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +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; + } + + return true; +} + +void BaseRenderer::addRectToList(BaseActiveRect *rect) { + _rectList.push_back(rect); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::displayIndicator() { + if (!_indicatorDisplay || !_indicatorProgress) { + return STATUS_OK; + } + if (_saveLoadImage && !_hasDrawnSaveLoadImage) { + Rect32 rc; + BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) { + _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + } else { + _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + flip(); + _hasDrawnSaveLoadImage = true; + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { + 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 + curWidth, _indicatorY + i, _indicatorColor); + } + + setup2D(); + _indicatorWidthDrawn = curWidth; + if (_indicatorWidthDrawn) { + indicatorFlip(); + } + 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 0ff4e6a3be..0475824464 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -1,221 +1,221 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_RENDERER_H -#define WINTERMUTE_BASE_RENDERER_H - -#include "engines/wintermute/math/rect32.h" -#include "engines/wintermute/base/base.h" -#include "common/rect.h" -#include "common/array.h" - -namespace Wintermute { - -class BaseImage; -class BaseActiveRect; -class BaseObject; -class BaseSurface; -class BasePersistenceManager; - -/** - * @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; - int _realHeight; - int _drawOffsetX; - int _drawOffsetY; - - virtual void dumpData(const char *filename) {} - /** - * 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 Rect32 getViewPort() = 0; - virtual bool setScreenViewport(); - - 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); - virtual ~BaseRenderer(); - virtual bool setProjection() { - return STATUS_OK; - }; - - 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. - */ - 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); - /** - * 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; - /** - * 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(); - - /** - * 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; - }; - virtual bool drawShaderQuad() { - return STATUS_FAILED; - } - - virtual float getScaleRatioX() const { - return 1.0f; - } - virtual float getScaleRatioY() const { - 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(); - bool unclipCursor(); - - BaseObject *getObjectAt(int x, int y); - void deleteRectList(); - - virtual bool startSpriteBatch() { - return STATUS_OK; - }; - virtual bool endSpriteBatch() { - return STATUS_OK; - }; - bool pointInViewport(Point32 *P); - bool _active; - bool _ready; - bool _windowed; - int _bPP; - int _height; - int _width; - uint32 _window; - 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(); -protected: - Common::String _loadImageName; - Common::String _saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - BaseSurface *_saveLoadImage; - bool _hasDrawnSaveLoadImage; - - int _indicatorWidthDrawn; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - bool _loadInProgress; - bool _indicatorDisplay; - int _indicatorProgress; -protected: - uint32 _clipperWindow; - - Rect32 _windowRect; - Rect32 _viewportRect; - Rect32 _screenRect; - Rect32 _monitorRect; -private: - Common::Array _rectList; -}; - -BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_RENDERER_H +#define WINTERMUTE_BASE_RENDERER_H + +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/base/base.h" +#include "common/rect.h" +#include "common/array.h" + +namespace Wintermute { + +class BaseImage; +class BaseActiveRect; +class BaseObject; +class BaseSurface; +class BasePersistenceManager; + +/** + * @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; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; + + virtual void dumpData(const char *filename) {} + /** + * 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 Rect32 getViewPort() = 0; + virtual bool setScreenViewport(); + + 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); + virtual ~BaseRenderer(); + virtual bool setProjection() { + return STATUS_OK; + }; + + 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. + */ + 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); + /** + * 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; + /** + * 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(); + + /** + * 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; + }; + virtual bool drawShaderQuad() { + return STATUS_FAILED; + } + + virtual float getScaleRatioX() const { + return 1.0f; + } + virtual float getScaleRatioY() const { + 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(); + bool unclipCursor(); + + BaseObject *getObjectAt(int x, int y); + void deleteRectList(); + + virtual bool startSpriteBatch() { + return STATUS_OK; + }; + virtual bool endSpriteBatch() { + return STATUS_OK; + }; + bool pointInViewport(Point32 *P); + bool _active; + bool _ready; + bool _windowed; + int _bPP; + int _height; + int _width; + uint32 _window; + 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(); +protected: + Common::String _loadImageName; + Common::String _saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + BaseSurface *_saveLoadImage; + bool _hasDrawnSaveLoadImage; + + int _indicatorWidthDrawn; + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + bool _loadInProgress; + bool _indicatorDisplay; + int _indicatorProgress; +protected: + uint32 _clipperWindow; + + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; +private: + Common::Array _rectList; +}; + +BaseRenderer *makeOSystemRenderer(BaseGame *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 index cbd665591a..d882adf5ad 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -1,149 +1,149 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/base_game.h" -#include "engines/wintermute/base/gfx/base_surface.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { - _referenceCount = 0; - - _width = _height = 0; - - _filename = ""; - - _pixelOpReady = false; - - _ckDefault = true; - _ckRed = _ckGreen = _ckBlue = 0; - _lifeTime = 0; - _keepLoaded = false; - - _lastUsedTime = 0; - _valid = false; -} - - -////////////////////////////////////////////////////////////////////// -BaseSurface::~BaseSurface() { - if (_pixelOpReady) { - endPixelOp(); - } -} - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::restore() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::isTransparentAt(int x, int y) { - return false; -} - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -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 BaseSurface::create(int width, int height) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::startPixelOp() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::endPixelOp() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { - return false; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::isTransparentAtLite(int x, int y) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::invalidate() { - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::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 BaseSurface::setSize(int width, int height) { - _width = width; - _height = height; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/base_game.h" +#include "engines/wintermute/base/gfx/base_surface.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { + _referenceCount = 0; + + _width = _height = 0; + + _filename = ""; + + _pixelOpReady = false; + + _ckDefault = true; + _ckRed = _ckGreen = _ckBlue = 0; + _lifeTime = 0; + _keepLoaded = false; + + _lastUsedTime = 0; + _valid = false; +} + + +////////////////////////////////////////////////////////////////////// +BaseSurface::~BaseSurface() { + if (_pixelOpReady) { + endPixelOp(); + } +} + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::restore() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::isTransparentAt(int x, int y) { + return false; +} + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +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 BaseSurface::create(int width, int height) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::startPixelOp() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::endPixelOp() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::isTransparentAtLite(int x, int y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::invalidate() { + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::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 BaseSurface::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 index f45856f652..ee53c03e77 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -1,99 +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_BASE_SURFACE_H -#define WINTERMUTE_BASE_SURFACE_H - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/math/rect32.h" -#include "graphics/surface.h" - -namespace Wintermute { - -class BaseSurface: public BaseClass { -public: - virtual bool invalidate(); - virtual bool prepareToDraw(); - uint32 _lastUsedTime; - bool _valid; - int _lifeTime; - - bool _pixelOpReady; - BaseSurface(BaseGame *inGame); - virtual ~BaseSurface(); - - 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 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; - } - 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: - bool _ckDefault; - byte _ckRed; - byte _ckGreen; - byte _ckBlue; - - bool _keepLoaded; - Common::String _filename; - int _height; - int _width; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SURFACE_H +#define WINTERMUTE_BASE_SURFACE_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "graphics/surface.h" + +namespace Wintermute { + +class BaseSurface: public BaseClass { +public: + virtual bool invalidate(); + virtual bool prepareToDraw(); + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + + bool _pixelOpReady; + BaseSurface(BaseGame *inGame); + virtual ~BaseSurface(); + + 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 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; + } + 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: + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + bool _keepLoaded; + 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 index 7a862e4441..6d67253038 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -1,604 +1,604 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/gfx/osystem/base_render_osystem.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" -#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/transparent_surface.h" -#include "common/queue.h" -#include "common/config-manager.h" - -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) { - _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; -} - -BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { - return new BaseRenderOSystem(inGame); -} - -////////////////////////////////////////////////////////////////////////// -BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { - _renderSurface = new Graphics::Surface(); - _blankSurface = new Graphics::Surface(); - _drawNum = 1; - _needsFlip = true; - - _borderLeft = _borderRight = _borderTop = _borderBottom = 0; - _ratioX = _ratioY = 1.0f; - setAlphaMod(255); - setColorMod(255, 255, 255); - _dirtyRect = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseRenderOSystem::~BaseRenderOSystem() { - _renderSurface->free(); - delete _renderSurface; - _blankSurface->free(); - delete _blankSurface; - TransparentSurface::destroyLookup(); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { - _width = width; - _height = height; - _renderRect.setWidth(_width); - _renderRect.setHeight(_height); - - _realWidth = width; - _realHeight = height; - - //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); - - 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; - - _windowed = !ConfMan.getBool("fullscreen"); - - 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(); - - if (gfxError != OSystem::kTransactionSuccess) { - warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); - return STATUS_FAILED; - } - - 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, _blankSurface->h, _blankSurface->w), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); - _active = true; - - _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); - - return STATUS_OK; -} - -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 BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { - byte alpha = RGBCOLGetA(_colorMod); - _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(); - } 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; - it = _renderQueue.erase(it); - delete ticket; - } else { - (*it)->_wantsDraw = false; - ++it; - } - } - } - 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 BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { - _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects) { - return STATUS_OK; - } - if (!rect) { -// 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 - _renderSurface->fillRect(*rect, _clearColor); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::fade(uint16 alpha) { - byte dwAlpha = (byte)(255 - alpha); - return fadeToColor(0, 0, 0, dwAlpha); -} - - -////////////////////////////////////////////////////////////////////////// -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. - - // TODO: Add fading with dirty rects. - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - } - - 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); - - //TODO: This is only here until I'm sure about the final pixelformat - uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - - 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); -} - -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, bool disableAlpha) { - // Skip rects that are completely outside the screen: - if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { - return; - } - - if (owner) { // Fade-tickets are owner-less - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); - compare._colorMod = _colorMod; - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { - if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { - (*it)->_colorMod = _colorMod; - if (_disableDirtyRects) { - drawFromSurface(*it, NULL); - } else { - drawFromTicket(*it); - } - return; - } - } - } - RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); - ticket->_colorMod = _colorMod; - if (!_disableDirtyRects) { - drawFromTicket(ticket); - } else { - ticket->_wantsDraw = true; - _renderQueue.push_back(ticket); - drawFromSurface(ticket, NULL); - } -} - -void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { - addDirtyRect(renderTicket->_dstRect); - renderTicket->_isValid = false; -// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. -} - -void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { - if ((*it)->_owner == surf) { - invalidateTicket(*it); - } - } -} - -void BaseRenderOSystem::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; - } - } - 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); - } - } -} - -void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { - if (!_dirtyRect) { - _dirtyRect = new Common::Rect(rect); - } else { - _dirtyRect->extend(rect); - } - _dirtyRect->clip(_renderRect); -} - -void BaseRenderOSystem::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); - 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; - - // 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); - // 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->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) - 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 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; - 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 BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); - } - - 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; -} - -////////////////////////////////////////////////////////////////////////// -BaseImage *BaseRenderOSystem::takeScreenshot() { -// TODO: Clip by viewport. - BaseImage *screenshot = new BaseImage(); - screenshot->copyFrom(_renderSurface); - return screenshot; -} - -////////////////////////////////////////////////////////////////////////// -Common::String BaseRenderOSystem::getName() const { - return "ScummVM-OSystem-renderer"; -} - -////////////////////////////////////////////////////////////////////////// -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); - rect.top = (int16)(top + _borderTop); - 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) { - 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 = (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 = (int16)MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; - point->y = (int16)MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::dumpData(const char *filename) { - warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO -} - -BaseSurface *BaseRenderOSystem::createSurface() { - return new BaseSurfaceOSystem(_gameRef); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/gfx/osystem/base_render_osystem.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" +#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/transparent_surface.h" +#include "common/queue.h" +#include "common/config-manager.h" + +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) { + _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; +} + +BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { + return new BaseRenderOSystem(inGame); +} + +////////////////////////////////////////////////////////////////////////// +BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { + _renderSurface = new Graphics::Surface(); + _blankSurface = new Graphics::Surface(); + _drawNum = 1; + _needsFlip = true; + + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; + setAlphaMod(255); + setColorMod(255, 255, 255); + _dirtyRect = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseRenderOSystem::~BaseRenderOSystem() { + _renderSurface->free(); + delete _renderSurface; + _blankSurface->free(); + delete _blankSurface; + TransparentSurface::destroyLookup(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { + _width = width; + _height = height; + _renderRect.setWidth(_width); + _renderRect.setHeight(_height); + + _realWidth = width; + _realHeight = height; + + //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); + + 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; + + _windowed = !ConfMan.getBool("fullscreen"); + + 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(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return STATUS_FAILED; + } + + 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, _blankSurface->h, _blankSurface->w), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); + _active = true; + + _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); + + return STATUS_OK; +} + +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 BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { + byte alpha = RGBCOLGetA(_colorMod); + _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(); + } 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; + it = _renderQueue.erase(it); + delete ticket; + } else { + (*it)->_wantsDraw = false; + ++it; + } + } + } + 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 BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { + _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!_disableDirtyRects) { + return STATUS_OK; + } + if (!rect) { +// 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 + _renderSurface->fillRect(*rect, _clearColor); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::fade(uint16 alpha) { + byte dwAlpha = (byte)(255 - alpha); + return fadeToColor(0, 0, 0, dwAlpha); +} + + +////////////////////////////////////////////////////////////////////////// +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. + + // TODO: Add fading with dirty rects. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); + } + + 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); + + //TODO: This is only here until I'm sure about the final pixelformat + uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); + + 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); +} + +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, bool disableAlpha) { + // Skip rects that are completely outside the screen: + if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { + return; + } + + if (owner) { // Fade-tickets are owner-less + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + if (_disableDirtyRects) { + drawFromSurface(*it, NULL); + } else { + drawFromTicket(*it); + } + return; + } + } + } + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); + ticket->_colorMod = _colorMod; + if (!_disableDirtyRects) { + drawFromTicket(ticket); + } else { + ticket->_wantsDraw = true; + _renderQueue.push_back(ticket); + drawFromSurface(ticket, NULL); + } +} + +void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { + addDirtyRect(renderTicket->_dstRect); + renderTicket->_isValid = false; +// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. +} + +void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { + if ((*it)->_owner == surf) { + invalidateTicket(*it); + } + } +} + +void BaseRenderOSystem::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; + } + } + 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); + } + } +} + +void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { + if (!_dirtyRect) { + _dirtyRect = new Common::Rect(rect); + } else { + _dirtyRect->extend(rect); + } + _dirtyRect->clip(_renderRect); +} + +void BaseRenderOSystem::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); + 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; + + // 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); + // 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->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) + 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 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; + 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 BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); + } + + 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; +} + +////////////////////////////////////////////////////////////////////////// +BaseImage *BaseRenderOSystem::takeScreenshot() { +// TODO: Clip by viewport. + BaseImage *screenshot = new BaseImage(); + screenshot->copyFrom(_renderSurface); + return screenshot; +} + +////////////////////////////////////////////////////////////////////////// +Common::String BaseRenderOSystem::getName() const { + return "ScummVM-OSystem-renderer"; +} + +////////////////////////////////////////////////////////////////////////// +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); + rect.top = (int16)(top + _borderTop); + 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) { + 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 = (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 = (int16)MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; + point->y = (int16)MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; +} + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::dumpData(const char *filename) { + warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO +} + +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 aebb4cf888..1e72508cd0 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -1,131 +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 - */ - -#ifndef WINTERMUTE_BASE_RENDERER_SDL_H -#define WINTERMUTE_BASE_RENDERER_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 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, bool disableAlpha = false); - RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} - ~RenderTicket(); - const Graphics::Surface *getSurface() { return _surface; } - Common::Rect _srcRect; - Common::Rect _dstRect; - uint32 _mirror; - bool _hasAlpha; - - bool _isValid; - bool _wantsDraw; - uint32 _drawNum; - uint32 _colorMod; - - BaseSurfaceOSystem *_owner; - bool operator==(RenderTicket &a); -}; - -class BaseRenderOSystem : public BaseRenderer { -public: - BaseRenderOSystem(BaseGame *inGame); - ~BaseRenderOSystem(); - - Common::String getName() const; - - 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); - 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); - - BaseImage *takeScreenshot(); - - void setAlphaMod(byte alpha); - void setColorMod(byte r, byte g, byte b); - void invalidateTicket(RenderTicket *renderTicket); - void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); - 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); - void pointToScreen(Point32 *point); - - void dumpData(const char *filename); - - float getScaleRatioX() const { - return _ratioX; - } - float getScaleRatioY() const { - return _ratioY; - } - - 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; - Common::List _renderQueue; - bool _needsFlip; - uint32 _drawNum; - Common::Rect _renderRect; - Graphics::Surface *_renderSurface; - Graphics::Surface *_blankSurface; - - int _borderLeft; - int _borderTop; - int _borderRight; - int _borderBottom; - - static const bool _disableDirtyRects = true; - float _ratioX; - float _ratioY; - uint32 _colorMod; - uint32 _clearColor; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_RENDERER_SDL_H +#define WINTERMUTE_BASE_RENDERER_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 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, bool disableAlpha = false); + RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} + ~RenderTicket(); + const Graphics::Surface *getSurface() { return _surface; } + Common::Rect _srcRect; + Common::Rect _dstRect; + uint32 _mirror; + bool _hasAlpha; + + bool _isValid; + bool _wantsDraw; + uint32 _drawNum; + uint32 _colorMod; + + BaseSurfaceOSystem *_owner; + bool operator==(RenderTicket &a); +}; + +class BaseRenderOSystem : public BaseRenderer { +public: + BaseRenderOSystem(BaseGame *inGame); + ~BaseRenderOSystem(); + + Common::String getName() const; + + 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); + 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); + + BaseImage *takeScreenshot(); + + void setAlphaMod(byte alpha); + void setColorMod(byte r, byte g, byte b); + void invalidateTicket(RenderTicket *renderTicket); + void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); + 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); + void pointToScreen(Point32 *point); + + void dumpData(const char *filename); + + float getScaleRatioX() const { + return _ratioX; + } + float getScaleRatioY() const { + return _ratioY; + } + + 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; + Common::List _renderQueue; + bool _needsFlip; + uint32 _drawNum; + Common::Rect _renderRect; + Graphics::Surface *_renderSurface; + Graphics::Surface *_blankSurface; + + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; + + static const bool _disableDirtyRects = true; + float _ratioX; + float _ratioY; + uint32 _colorMod; + uint32 _clearColor; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 7724a93481..d5464782a3 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -1,429 +1,429 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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" -#include "engines/wintermute/platform_osystem.h" -#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 "graphics/pixelformat.h" -#include "graphics/surface.h" -#include "common/stream.h" -#include "common/system.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { - _surface = new Graphics::Surface(); - _alphaMask = NULL; - _hasAlpha = true; - _lockPixels = NULL; - _lockPitch = 0; - _loaded = false; -} - -////////////////////////////////////////////////////////////////////////// -BaseSurfaceOSystem::~BaseSurfaceOSystem() { - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - - delete[] _alphaMask; - _alphaMask = NULL; - - _gameRef->addMem(-_width * _height * 4); - BaseRenderOSystem *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 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(); - - 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; -} - -bool BaseSurfaceOSystem::finishLoad() { - BaseImage *image = new BaseImage(); - if (!image->loadFile(_filename)) { - return false; - } - - _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); TODO - } - - // 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. - _surface->free(); - 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 >= 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()); - } - - _hasAlpha = hasTransparency(_surface); - _valid = true; - - _gameRef->addMem(_width * _height * 4); - - delete image; - - _loaded = true; - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { - warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); - return; - // TODO: Reimplement this - delete[] _alphaMask; - _alphaMask = NULL; - if (!surface) { - return; - } - - 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; - */ - _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 = getPixelAt(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 (!hasTransparency) { - delete[] _alphaMask; - _alphaMask = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -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 */ - 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 BaseSurfaceOSystem::create(int width, int height) { - _width = width; - _height = height; - - _gameRef->addMem(_width * _height * 4); - - _valid = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { - return isTransparentAtLite(x, y); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { - 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; - _surface->format.colorToARGB(pixel, a, r, g, b); - if (a <= 128) { - return true; - } else { - return false; - } - } - - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::startPixelOp() { - //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); - // Any pixel-op makes the caching useless: - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::endPixelOp() { - //SDL_UnlockTexture(_texture); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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 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 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 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 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::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 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(); - } - - if (renderer->_forceAlphaColor != 0) { - alpha = renderer->_forceAlphaColor; - } - - 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 // These are kept for reference if BlendMode is reimplemented at some point. - 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; - - // Crop off-by-ones: - 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. - - // 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"); - } - - renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); - - return STATUS_OK; -} - -bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { - _loaded = true; - _surface->free(); - _surface->copyFrom(surface); - _hasAlpha = hasAlpha; - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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" +#include "engines/wintermute/platform_osystem.h" +#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 "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "common/stream.h" +#include "common/system.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { + _surface = new Graphics::Surface(); + _alphaMask = NULL; + _hasAlpha = true; + _lockPixels = NULL; + _lockPitch = 0; + _loaded = false; +} + +////////////////////////////////////////////////////////////////////////// +BaseSurfaceOSystem::~BaseSurfaceOSystem() { + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + + delete[] _alphaMask; + _alphaMask = NULL; + + _gameRef->addMem(-_width * _height * 4); + BaseRenderOSystem *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 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(); + + 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; +} + +bool BaseSurfaceOSystem::finishLoad() { + BaseImage *image = new BaseImage(); + if (!image->loadFile(_filename)) { + return false; + } + + _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); TODO + } + + // 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. + _surface->free(); + 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 >= 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()); + } + + _hasAlpha = hasTransparency(_surface); + _valid = true; + + _gameRef->addMem(_width * _height * 4); + + delete image; + + _loaded = true; + + return true; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); + return; + // TODO: Reimplement this + delete[] _alphaMask; + _alphaMask = NULL; + if (!surface) { + return; + } + + 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; + */ + _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 = getPixelAt(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 (!hasTransparency) { + delete[] _alphaMask; + _alphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +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 */ + 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 BaseSurfaceOSystem::create(int width, int height) { + _width = width; + _height = height; + + _gameRef->addMem(_width * _height * 4); + + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { + return isTransparentAtLite(x, y); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { + 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; + _surface->format.colorToARGB(pixel, a, r, g, b); + if (a <= 128) { + return true; + } else { + return false; + } + } + + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::startPixelOp() { + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + // Any pixel-op makes the caching useless: + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::endPixelOp() { + //SDL_UnlockTexture(_texture); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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 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 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 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 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::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 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(); + } + + if (renderer->_forceAlphaColor != 0) { + alpha = renderer->_forceAlphaColor; + } + + 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 // These are kept for reference if BlendMode is reimplemented at some point. + 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; + + // Crop off-by-ones: + 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. + + // 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"); + } + + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); + + return STATUS_OK; +} + +bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { + _loaded = true; + _surface->free(); + _surface->copyFrom(surface); + _hasAlpha = hasAlpha; + BaseRenderOSystem *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 index b68fac4e3b..43422ef4e7 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -1,99 +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_BASE_SURFACESDL_H -#define WINTERMUTE_BASE_SURFACESDL_H - -#include "graphics/surface.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "common/list.h" - -namespace Wintermute { -struct TransparentSurface; -class BaseImage; -class BaseSurfaceOSystem : public BaseSurface { -public: - BaseSurfaceOSystem(BaseGame *inGame); - ~BaseSurfaceOSystem(); - - 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); - 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; - 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 getPixelAt(Graphics::Surface *surface, int x, int y); - - bool _hasAlpha; - void *_lockPixels; - int _lockPitch; - byte *_alphaMask; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SURFACESDL_H +#define WINTERMUTE_BASE_SURFACESDL_H + +#include "graphics/surface.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/list.h" + +namespace Wintermute { +struct TransparentSurface; +class BaseImage; +class BaseSurfaceOSystem : public BaseSurface { +public: + BaseSurfaceOSystem(BaseGame *inGame); + ~BaseSurfaceOSystem(); + + 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); + 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; + 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 getPixelAt(Graphics::Surface *surface, int x, int y); + + bool _hasAlpha; + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 7012bef86f..3655b89131 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -1,1256 +1,1256 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(PartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { - _width = _height = 0; - - BasePlatform::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; -} - - -////////////////////////////////////////////////////////////////////////// -PartEmitter::~PartEmitter(void) { - for (uint32 i = 0; i < _particles.size(); i++) { - delete _particles[i]; - } - _particles.clear(); - - for (uint32 i = 0; i < _forces.size(); i++) { - delete _forces[i]; - } - _forces.clear(); - - - for (uint32 i = 0; i < _sprites.size(); i++) { - delete[] _sprites[i]; - } - _sprites.clear(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::addSprite(const char *filename) { - if (!filename) { - return STATUS_FAILED; - } - - // do we already have the file? - for (uint32 i = 0; i < _sprites.size(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - return STATUS_OK; - } - } - - // check if file exists - Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename); - if (!File) { - _gameRef->LOG(0, "Sprite '%s' not found", filename); - return STATUS_FAILED; - } else { - BaseFileManager::getEngineInstance()->closeFile(File); - } - - char *str = new char[strlen(filename) + 1]; - strcpy(str, filename); - _sprites.add(str); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::removeSprite(const char *filename) { - for (uint32 i = 0; i < _sprites.size(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete[] _sprites[i]; - _sprites.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) { - return STATUS_FAILED; - } - if (_sprites.size() == 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); - } - - float scale; - 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); - } - - float angle = BaseUtils::randomAngle(_angle1, _angle2); - int spriteIndex = BaseUtils::randomInt(0, _sprites.size() - 1); - - float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); - - 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); - 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(BaseUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(vecVel); - - if (_alphaTimeBased) { - particle->_alpha1 = _alpha1; - particle->_alpha2 = _alpha2; - } else { - int alpha = BaseUtils::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 PartEmitter::update() { - if (!_running) { - return STATUS_OK; - } else { - return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); - } -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { - int numLive = 0; - - for (uint32 i = 0; i < _particles.size(); 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 (uint32 i = 0; i < _particles.size(); i++) { - if (_particles[i]->_isDead) { - firstDeadIndex = i; - break; - } - } - - PartParticle *particle; - if (firstDeadIndex >= 0) { - particle = _particles[firstDeadIndex]; - } else { - particle = new PartParticle(_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 PartEmitter::display(BaseRegion *region) { - if (_sprites.size() <= 1) { - _gameRef->_renderer->startSpriteBatch(); - } - - 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; - } - } - - _particles[i]->display(this); - } - - if (_sprites.size() <= 1) { - _gameRef->_renderer->endSpriteBatch(); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::start() { - for (uint32 i = 0; i < _particles.size(); 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 PartEmitter::sortParticlesByZ() { - // sort particles by _posY - Common::sort(_particles.begin(), _particles.end(), PartEmitter::compareZ); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int PartEmitter::compareZ(const void *obj1, const void *obj2) { - const PartParticle *p1 = *(const PartParticle *const *)obj1; - const PartParticle *p2 = *(const PartParticle *const *)obj2; - - if (p1->_posZ < p2->_posZ) { - return -1; - } else if (p1->_posZ > p2->_posZ) { - return 1; - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::setBorder(int x, int y, int width, int height) { - BasePlatform::setRect(&_border, x, y, x + width, y + height); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { - _borderThicknessLeft = thicknessLeft; - _borderThicknessRight = thicknessRight; - _borderThicknessTop = thicknessTop; - _borderThicknessBottom = thicknessBottom; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -PartForce *PartEmitter::addForceByName(const Common::String &name) { - PartForce *force = NULL; - - for (uint32 i = 0; i < _forces.size(); i++) { - if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { - force = _forces[i]; - break; - } - } - if (!force) { - force = new PartForce(_gameRef); - if (force) { - force->setName(name.c_str()); - _forces.add(force); - } - } - return force; -} - - -////////////////////////////////////////////////////////////////////////// -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; - } - - force->_type = type; - force->_pos = Vector2(posX, posY); - - force->_direction = Vector2(0, strength); - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(force->_direction); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::removeForce(const Common::String &name) { - 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); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 (uint32 i = 0; i < _particles.size(); i++) { - delete _particles[i]; - } - _particles.clear(); - - _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, PartForce::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, PartForce::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 BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - -////////////////////////////////////////////////////////////////////////// -ScValue *PartEmitter::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 (uint32 i = 0; i < _particles.size(); 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 BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::scSetProperty(const char *name, ScValue *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()) { - BaseUtils::setString(&_emitEvent, value->getString()); - } - return STATUS_OK; - } else { - return BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *PartEmitter::scToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::persist(BasePersistenceManager *persistMgr) { - BaseObject::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); - - uint32 numForces; - if (persistMgr->getIsSaving()) { - numForces = _forces.size(); - persistMgr->transfer(TMEMBER(numForces)); - for (uint32 i = 0; i < _forces.size(); i++) { - _forces[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numForces)); - for (uint32 i = 0; i < numForces; i++) { - PartForce *force = new PartForce(_gameRef); - force->persist(persistMgr); - _forces.add(force); - } - } - - uint32 numParticles; - if (persistMgr->getIsSaving()) { - numParticles = _particles.size(); - persistMgr->transfer(TMEMBER(numParticles)); - for (uint32 i = 0; i < _particles.size(); i++) { - _particles[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numParticles)); - for (uint32 i = 0; i < numParticles; i++) { - PartParticle *particle = new PartParticle(_gameRef); - particle->persist(persistMgr); - _particles.add(particle); - } - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(PartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { + _width = _height = 0; + + BasePlatform::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; +} + + +////////////////////////////////////////////////////////////////////////// +PartEmitter::~PartEmitter(void) { + for (uint32 i = 0; i < _particles.size(); i++) { + delete _particles[i]; + } + _particles.clear(); + + for (uint32 i = 0; i < _forces.size(); i++) { + delete _forces[i]; + } + _forces.clear(); + + + for (uint32 i = 0; i < _sprites.size(); i++) { + delete[] _sprites[i]; + } + _sprites.clear(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::addSprite(const char *filename) { + if (!filename) { + return STATUS_FAILED; + } + + // do we already have the file? + for (uint32 i = 0; i < _sprites.size(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + return STATUS_OK; + } + } + + // check if file exists + Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename); + if (!File) { + _gameRef->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else { + BaseFileManager::getEngineInstance()->closeFile(File); + } + + char *str = new char[strlen(filename) + 1]; + strcpy(str, filename); + _sprites.add(str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::removeSprite(const char *filename) { + for (uint32 i = 0; i < _sprites.size(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete[] _sprites[i]; + _sprites.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) { + return STATUS_FAILED; + } + if (_sprites.size() == 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); + } + + float scale; + 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); + } + + float angle = BaseUtils::randomAngle(_angle1, _angle2); + int spriteIndex = BaseUtils::randomInt(0, _sprites.size() - 1); + + float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); + + 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); + 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(BaseUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = BaseUtils::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 PartEmitter::update() { + if (!_running) { + return STATUS_OK; + } else { + return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); + } +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (uint32 i = 0; i < _particles.size(); 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 (uint32 i = 0; i < _particles.size(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + PartParticle *particle; + if (firstDeadIndex >= 0) { + particle = _particles[firstDeadIndex]; + } else { + particle = new PartParticle(_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 PartEmitter::display(BaseRegion *region) { + if (_sprites.size() <= 1) { + _gameRef->_renderer->startSpriteBatch(); + } + + 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; + } + } + + _particles[i]->display(this); + } + + if (_sprites.size() <= 1) { + _gameRef->_renderer->endSpriteBatch(); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::start() { + for (uint32 i = 0; i < _particles.size(); 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 PartEmitter::sortParticlesByZ() { + // sort particles by _posY + Common::sort(_particles.begin(), _particles.end(), PartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int PartEmitter::compareZ(const void *obj1, const void *obj2) { + const PartParticle *p1 = *(const PartParticle *const *)obj1; + const PartParticle *p2 = *(const PartParticle *const *)obj2; + + if (p1->_posZ < p2->_posZ) { + return -1; + } else if (p1->_posZ > p2->_posZ) { + return 1; + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::setBorder(int x, int y, int width, int height) { + BasePlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +PartForce *PartEmitter::addForceByName(const Common::String &name) { + PartForce *force = NULL; + + for (uint32 i = 0; i < _forces.size(); i++) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new PartForce(_gameRef); + if (force) { + force->setName(name.c_str()); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +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; + } + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::removeForce(const Common::String &name) { + 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); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 (uint32 i = 0; i < _particles.size(); i++) { + delete _particles[i]; + } + _particles.clear(); + + _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, PartForce::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, PartForce::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 BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + +////////////////////////////////////////////////////////////////////////// +ScValue *PartEmitter::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 (uint32 i = 0; i < _particles.size(); 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 BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::scSetProperty(const char *name, ScValue *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()) { + BaseUtils::setString(&_emitEvent, value->getString()); + } + return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *PartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::persist(BasePersistenceManager *persistMgr) { + BaseObject::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); + + uint32 numForces; + if (persistMgr->getIsSaving()) { + numForces = _forces.size(); + persistMgr->transfer(TMEMBER(numForces)); + for (uint32 i = 0; i < _forces.size(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (uint32 i = 0; i < numForces; i++) { + PartForce *force = new PartForce(_gameRef); + force->persist(persistMgr); + _forces.add(force); + } + } + + uint32 numParticles; + if (persistMgr->getIsSaving()) { + numParticles = _particles.size(); + persistMgr->transfer(TMEMBER(numParticles)); + for (uint32 i = 0; i < _particles.size(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (uint32 i = 0; i < numParticles; i++) { + PartParticle *particle = new PartParticle(_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 index dd02cf7f17..9a35cd9bbc 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -1,140 +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_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "engines/wintermute/base/base_object.h" -#include "engines/wintermute/base/particles/part_force.h" - -namespace Wintermute { -class BaseRegion; -class PartParticle; -class PartEmitter : public BaseObject { -public: - DECLARE_PERSISTENT(PartEmitter, BaseObject) - - 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 Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const Common::String &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 _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - BaseScriptHolder *_owner; - - 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); - uint32 _lastGenTime; - BaseArray _particles; - BaseArray _sprites; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 BaseRegion; +class PartParticle; +class PartEmitter : public BaseObject { +public: + DECLARE_PERSISTENT(PartEmitter, BaseObject) + + 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 Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const Common::String &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 _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + BaseScriptHolder *_owner; + + 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); + uint32 _lastGenTime; + BaseArray _particles; + BaseArray _sprites; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index abbaa2819d..df84162504 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -1,65 +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/persistent.h" -#include "engines/wintermute/base/particles/part_force.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -PartForce::~PartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool PartForce::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->getIsSaving()) { - 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)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/particles/part_force.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +PartForce::~PartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool PartForce::persist(BasePersistenceManager *persistMgr) { + if (persistMgr->getIsSaving()) { + 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)); + + 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 index 6903a919e9..27f4cb7d90 100644 --- a/engines/wintermute/base/particles/part_force.h +++ b/engines/wintermute/base/particles/part_force.h @@ -1,57 +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 PartForce : public BaseNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - PartForce(BaseGame *inGame); - virtual ~PartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - bool persist(BasePersistenceManager *PersistMgr); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 PartForce : public BaseNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + PartForce(BaseGame *inGame); + virtual ~PartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + bool persist(BasePersistenceManager *PersistMgr); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 5f523612b8..0b850d9618 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -1,269 +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/base/particles/part_particle.h" -#include "engines/wintermute/base/particles/part_emitter.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 { - -////////////////////////////////////////////////////////////////////////// -PartParticle::PartParticle(BaseGame *inGame) : BaseClass(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; - BasePlatform::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; -} - - -////////////////////////////////////////////////////////////////////////// -PartParticle::~PartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::setSprite(const Common::String &filename) { - if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) { - _sprite->reset(); - return STATUS_OK; - } - - delete _sprite; - _sprite = NULL; - - SystemClassRegistry::getInstance()->_disabled = true; - _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef); - if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - SystemClassRegistry::getInstance()->_disabled = false; - return STATUS_OK; - } else { - delete _sprite; - _sprite = NULL; - SystemClassRegistry::getInstance()->_disabled = false; - return STATUS_FAILED; - } - -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::update(PartEmitter *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 && !BasePlatform::isRectEmpty(&_border)) { - Point32 p; - p.x = (int32)_pos.x; - p.y = (int32)_pos.y; - if (!BasePlatform::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 (uint32 i = 0; i < emitter->_forces.size(); i++) { - PartForce *force = emitter->_forces[i]; - switch (force->_type) { - case PartForce::FORCE_GLOBAL: - _velocity += force->_direction * elapsedTime; - break; - - case PartForce::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 = BaseUtils::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 PartParticle::display(PartEmitter *emitter) { - if (!_sprite) { - return STATUS_FAILED; - } - if (_isDead) { - return STATUS_OK; - } - - _sprite->getCurrentFrame(); - return _sprite->display((int)_pos.x, (int)_pos.y, - NULL, - _scale, _scale, - BYTETORGBA(255, 255, 255, _currentAlpha), - _rotation, - emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::fadeIn(uint32 currentTime, int fadeTime) { - _currentAlpha = 0; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEIN; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEOUT; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::persist(BasePersistenceManager *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->getIsSaving()) { - const char *filename = _sprite->getFilename(); - persistMgr->transfer(TMEMBER(filename)); - } else { - char *filename; - persistMgr->transfer(TMEMBER(filename)); - SystemClassRegistry::getInstance()->_disabled = true; - setSprite(filename); - SystemClassRegistry::getInstance()->_disabled = false; - delete[] filename; - filename = NULL; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/particles/part_particle.h" +#include "engines/wintermute/base/particles/part_emitter.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 { + +////////////////////////////////////////////////////////////////////////// +PartParticle::PartParticle(BaseGame *inGame) : BaseClass(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; + BasePlatform::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; +} + + +////////////////////////////////////////////////////////////////////////// +PartParticle::~PartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::setSprite(const Common::String &filename) { + if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + SystemClassRegistry::getInstance()->_disabled = true; + _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + SystemClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + SystemClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::update(PartEmitter *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 && !BasePlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!BasePlatform::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 (uint32 i = 0; i < emitter->_forces.size(); i++) { + PartForce *force = emitter->_forces[i]; + switch (force->_type) { + case PartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case PartForce::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 = BaseUtils::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 PartParticle::display(PartEmitter *emitter) { + if (!_sprite) { + return STATUS_FAILED; + } + if (_isDead) { + return STATUS_OK; + } + + _sprite->getCurrentFrame(); + return _sprite->display((int)_pos.x, (int)_pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::persist(BasePersistenceManager *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->getIsSaving()) { + const char *filename = _sprite->getFilename(); + persistMgr->transfer(TMEMBER(filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + SystemClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + SystemClassRegistry::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 index 3c8fc2c68b..4b8c2f131e 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -1,90 +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 PartEmitter; -class BaseSprite; -class BasePersistenceManager; - -class PartParticle : public BaseClass { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - PartParticle(BaseGame *inGame); - virtual ~PartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - Rect32 _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - BaseSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(PartEmitter *emitter); - - bool setSprite(const Common::String &filename); - - bool fadeIn(uint32 currentTime, int fadeTime); - bool fadeOut(uint32 currentTime, int fadeTime); - - bool persist(BasePersistenceManager *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 PartEmitter; +class BaseSprite; +class BasePersistenceManager; + +class PartParticle : public BaseClass { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + PartParticle(BaseGame *inGame); + virtual ~PartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + BaseSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(PartEmitter *emitter); + + bool setSprite(const Common::String &filename); + + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); + + bool persist(BasePersistenceManager *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h index 6810fdf665..4aae897dc2 100644 --- a/engines/wintermute/base/scriptables/dcscript.h +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -1,141 +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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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.cpp b/engines/wintermute/base/scriptables/script.cpp index 269ea1ea03..9469bd46a7 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1,1467 +1,1467 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(ScScript, false) - -////////////////////////////////////////////////////////////////////////// -ScScript::ScScript(BaseGame *inGame, ScEngine *engine) : BaseClass(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; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript::~ScScript() { - cleanup(); -} - -void ScScript::readHeader() { - uint32 oldPos = _scriptStream->pos(); - _scriptStream->seek(0); - _header.magic = _scriptStream->readUint32LE(); - _header.version = _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); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::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 ScStack(_gameRef); - _callStack = new ScStack(_gameRef); - _thisStack = new ScStack(_gameRef); - _stack = new ScStack(_gameRef); - - _operand = new ScValue(_gameRef); - _reg1 = new ScValue(_gameRef); - - - // skip to the beginning - _iP = _header.codeStart; - _scriptStream->seek(_iP); - _currentLine = 0; - - // ready to rumble... - _state = SCRIPT_RUNNING; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::initTables() { - uint32 origIP = _iP; - - readHeader(); - // load symbol table - _iP = _header.symbolTable; - - _numSymbols = getDWORD(); - _symbols = new char*[_numSymbols]; - for (uint32 i = 0; i < _numSymbols; i++) { - uint32 index = getDWORD(); - _symbols[index] = getString(); - } - - // load functions table - _iP = _header.funcTable; - - _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.eventTable; - - _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.externalsTable; - - _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.methodTable; - - _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 ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *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 ScValue(_gameRef); - - _owner = owner; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) { - cleanup(); - - _thread = true; - _methodThread = false; - _threadEvent = new char[eventName.size() + 1]; - if (_threadEvent) { - strcpy(_threadEvent, eventName.c_str()); - } - - // 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 ScScript::createMethodThread(ScScript *original, const Common::String &methodName) { - uint32 ip = original->getMethodPos(methodName); - if (ip == 0) { - return STATUS_FAILED; - } - - cleanup(); - - _thread = true; - _methodThread = true; - _threadEvent = new char[methodName.size() + 1]; - if (_threadEvent) { - strcpy(_threadEvent, methodName.c_str()); - } - - // 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 ScScript::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 ScScript::getDWORD() { - _scriptStream->seek((int32)_iP); - uint32 ret = _scriptStream->readUint32LE(); - _iP += sizeof(uint32); -// assert(oldRet == ret); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -double ScScript::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 *ScScript::getString() { - char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') { - _iP++; - } - _iP++; // string terminator - _scriptStream->seek(_iP); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::executeInstruction() { - bool ret = STATUS_OK; - - uint32 dw; - const char *str = NULL; - - //ScValue* op = new ScValue(_gameRef); - _operand->cleanup(); - - ScValue *op1; - ScValue *op2; - - uint32 inst = getDWORD(); - switch (inst) { - - case II_DEF_VAR: - _operand->setNULL(); - dw = getDWORD(); - if (_scopeStack->_sP < 0) { - _globals->setProp(_symbols[dw], _operand); - } else { - _scopeStack->getTop()->setProp(_symbols[dw], _operand); - } - - 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); - } - break; - } - - case II_RET: - if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _scopeStack->pop(); - _iP = (uint32)_callStack->pop()->getInt(); - } 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); - - ScValue *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; - } - /* - ScValue* 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); - 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: { - ScValue *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: { - ScValue *var = getVar(_symbols[getDWORD()]); - _operand->setReference(var); - _stack->push(_operand); - break; - } - - case II_POP_VAR: { - char *varName = _symbols[getDWORD()]; - ScValue *var = getVar(varName); - if (var) { - ScValue *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); - } - } - } - - 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(); - ScValue *val = _stack->pop()->getProp(str); - if (val) { - _stack->push(val); - } else { - _stack->pushNULL(); - } - - break; - } - - case II_POP_BY_EXP: { - str = _stack->pop()->getString(); - 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."); - var->setNULL(); - } else { - var->setProp(str, val); - } - - 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; - ScValue *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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::compareStrict(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_DBG_LINE: { - int newLine = getDWORD(); - if (newLine != _currentLine) { - _currentLine = newLine; - } - 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 ScScript::getFuncPos(const Common::String &name) { - for (uint32 i = 0; i < _numFunctions; i++) { - if (name == _functions[i].name) { - return _functions[i].pos; - } - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getMethodPos(const Common::String &name) { - for (uint32 i = 0; i < _numMethods; i++) { - if (name == _methods[i].name) { - return _methods[i].pos; - } - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScScript::getVar(char *name) { - ScValue *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); - ScValue *val = new ScValue(_gameRef); - ScValue *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 ScScript::waitFor(BaseObject *object) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_WAITING; - _waitObject = object; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::waitForExclusive(BaseObject *object) { - _engine->resetObject(object); - return waitFor(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::sleep(uint32 duration) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_SLEEPING; - if (_gameRef->_state == GAME_FROZEN) { - _waitTime = g_system->getMillis() + duration; - _waitFrozen = true; - } else { - _waitTime = _gameRef->_timer + duration; - _waitFrozen = false; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::finish(bool includingThreads) { - if (_state != SCRIPT_FINISHED && includingThreads) { - _state = SCRIPT_FINISHED; - finishThreads(); - } else { - _state = SCRIPT_FINISHED; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::run() { - _state = SCRIPT_RUNNING; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void ScScript::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 ScScript::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - // buffer - if (persistMgr->getIsSaving()) { - 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->getIsSaving()) { - _tracingMode = false; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) { - //if (_state!=SCRIPT_PERSISTENT) return NULL; - - uint32 pos = getEventPos(eventName); - if (!pos) { - return NULL; - } - - ScScript *thread = new ScScript(_gameRef, _engine); - if (thread) { - bool ret = thread->createThread(this, pos, eventName); - if (DID_SUCCEED(ret)) { - thread->_unbreakable = unbreakable; - _engine->_scripts.add(thread); - return thread; - } else { - delete thread; - return NULL; - } - } else { - return NULL; - } - -} - - -////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getEventPos(const Common::String &name) { - for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name.c_str(), _events[i].name) == 0) { - return _events[i].pos; - } - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleEvent(const Common::String &eventName) { - return getEventPos(eventName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleMethod(const Common::String &methodName) { - return getMethodPos(methodName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::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 ScScript::resume() { - if (_state != SCRIPT_PAUSED) { - return STATUS_OK; - } - - _state = _origState; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript::TExternalFunction *ScScript::getExternal(char *name) { - for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) { - return &_externals[i]; - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) { - - _gameRef->LOG(0, "External functions are not supported on this platform."); - stack->correctParams(0); - stack->pushNULL(); - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::copyParameters(ScStack *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 ScScript::finishThreads() { - 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); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugScript interface implementation -int ScScript::dbgGetLine() { - return _currentLine; -} - -////////////////////////////////////////////////////////////////////////// -const char *ScScript::dbgGetFilename() { - return _filename; -} - -////////////////////////////////////////////////////////////////////////// -void ScScript::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(ScScript, false) + +////////////////////////////////////////////////////////////////////////// +ScScript::ScScript(BaseGame *inGame, ScEngine *engine) : BaseClass(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; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript::~ScScript() { + cleanup(); +} + +void ScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); + _header.magic = _scriptStream->readUint32LE(); + _header.version = _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); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::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 ScStack(_gameRef); + _callStack = new ScStack(_gameRef); + _thisStack = new ScStack(_gameRef); + _stack = new ScStack(_gameRef); + + _operand = new ScValue(_gameRef); + _reg1 = new ScValue(_gameRef); + + + // skip to the beginning + _iP = _header.codeStart; + _scriptStream->seek(_iP); + _currentLine = 0; + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::initTables() { + uint32 origIP = _iP; + + readHeader(); + // load symbol table + _iP = _header.symbolTable; + + _numSymbols = getDWORD(); + _symbols = new char*[_numSymbols]; + for (uint32 i = 0; i < _numSymbols; i++) { + uint32 index = getDWORD(); + _symbols[index] = getString(); + } + + // load functions table + _iP = _header.funcTable; + + _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.eventTable; + + _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.externalsTable; + + _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.methodTable; + + _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 ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *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 ScValue(_gameRef); + + _owner = owner; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) { + cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[eventName.size() + 1]; + if (_threadEvent) { + strcpy(_threadEvent, eventName.c_str()); + } + + // 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 ScScript::createMethodThread(ScScript *original, const Common::String &methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) { + return STATUS_FAILED; + } + + cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[methodName.size() + 1]; + if (_threadEvent) { + strcpy(_threadEvent, methodName.c_str()); + } + + // 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 ScScript::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 ScScript::getDWORD() { + _scriptStream->seek((int32)_iP); + uint32 ret = _scriptStream->readUint32LE(); + _iP += sizeof(uint32); +// assert(oldRet == ret); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +double ScScript::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 *ScScript::getString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') { + _iP++; + } + _iP++; // string terminator + _scriptStream->seek(_iP); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::executeInstruction() { + bool ret = STATUS_OK; + + uint32 dw; + const char *str = NULL; + + //ScValue* op = new ScValue(_gameRef); + _operand->cleanup(); + + ScValue *op1; + ScValue *op2; + + uint32 inst = getDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->setNULL(); + dw = getDWORD(); + if (_scopeStack->_sP < 0) { + _globals->setProp(_symbols[dw], _operand); + } else { + _scopeStack->getTop()->setProp(_symbols[dw], _operand); + } + + 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); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->getInt(); + } 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); + + ScValue *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; + } + /* + ScValue* 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); + 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: { + ScValue *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: { + ScValue *var = getVar(_symbols[getDWORD()]); + _operand->setReference(var); + _stack->push(_operand); + break; + } + + case II_POP_VAR: { + char *varName = _symbols[getDWORD()]; + ScValue *var = getVar(varName); + if (var) { + ScValue *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); + } + } + } + + 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(); + ScValue *val = _stack->pop()->getProp(str); + if (val) { + _stack->push(val); + } else { + _stack->pushNULL(); + } + + break; + } + + case II_POP_BY_EXP: { + str = _stack->pop()->getString(); + 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."); + var->setNULL(); + } else { + var->setProp(str, val); + } + + 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; + ScValue *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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::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(ScValue::compareStrict(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_DBG_LINE: { + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; + } + 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 ScScript::getFuncPos(const Common::String &name) { + for (uint32 i = 0; i < _numFunctions; i++) { + if (name == _functions[i].name) { + return _functions[i].pos; + } + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 ScScript::getMethodPos(const Common::String &name) { + for (uint32 i = 0; i < _numMethods; i++) { + if (name == _methods[i].name) { + return _methods[i].pos; + } + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScScript::getVar(char *name) { + ScValue *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); + ScValue *val = new ScValue(_gameRef); + ScValue *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 ScScript::waitFor(BaseObject *object) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = object; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::waitForExclusive(BaseObject *object) { + _engine->resetObject(object); + return waitFor(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::sleep(uint32 duration) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_SLEEPING; + if (_gameRef->_state == GAME_FROZEN) { + _waitTime = g_system->getMillis() + duration; + _waitFrozen = true; + } else { + _waitTime = _gameRef->_timer + duration; + _waitFrozen = false; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { + _state = SCRIPT_FINISHED; + finishThreads(); + } else { + _state = SCRIPT_FINISHED; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::run() { + _state = SCRIPT_RUNNING; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void ScScript::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 ScScript::persist(BasePersistenceManager *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + // buffer + if (persistMgr->getIsSaving()) { + 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->getIsSaving()) { + _tracingMode = false; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) { + //if (_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = getEventPos(eventName); + if (!pos) { + return NULL; + } + + ScScript *thread = new ScScript(_gameRef, _engine); + if (thread) { + bool ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { + thread->_unbreakable = unbreakable; + _engine->_scripts.add(thread); + return thread; + } else { + delete thread; + return NULL; + } + } else { + return NULL; + } + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 ScScript::getEventPos(const Common::String &name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(name.c_str(), _events[i].name) == 0) { + return _events[i].pos; + } + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::canHandleEvent(const Common::String &eventName) { + return getEventPos(eventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::canHandleMethod(const Common::String &methodName) { + return getMethodPos(methodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::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 ScScript::resume() { + if (_state != SCRIPT_PAUSED) { + return STATUS_OK; + } + + _state = _origState; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript::TExternalFunction *ScScript::getExternal(char *name) { + for (uint32 i = 0; i < _numExternals; i++) { + if (strcmp(name, _externals[i].name) == 0) { + return &_externals[i]; + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) { + + _gameRef->LOG(0, "External functions are not supported on this platform."); + stack->correctParams(0); + stack->pushNULL(); + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::copyParameters(ScStack *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 ScScript::finishThreads() { + 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); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int ScScript::dbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *ScScript::dbgGetFilename() { + return _filename; +} + +////////////////////////////////////////////////////////////////////////// +void ScScript::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 index 4daeacd026..0616bce58a 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -1,174 +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_SCSCRIPT_H -#define WINTERMUTE_SCSCRIPT_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { -class BaseScriptHolder; -class BaseObject; -class ScEngine; -class ScStack; -class ScScript : public BaseClass { -public: - BaseArray _breakpoints; - bool _tracingMode; - - ScScript *_parentScript; - bool _unbreakable; - bool finishThreads(); - bool copyParameters(ScStack *stack); - - void afterLoad(); -private: - ScValue *_operand; - ScValue *_reg1; -public: - bool _freezable; - bool resume(); - bool pause(); - 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, ...); - bool run(); - bool finish(bool includingThreads = false); - bool sleep(uint32 duration); - bool waitForExclusive(BaseObject *object); - bool waitFor(BaseObject *object); - uint32 _waitTime; - bool _waitFrozen; - BaseObject *_waitObject; - ScScript *_waitScript; - TScriptState _state; - TScriptState _origState; - ScValue *getVar(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; - uint32 codeStart; - uint32 funcTable; - uint32 symbolTable; - uint32 eventTable; - uint32 externalsTable; - uint32 methodTable; - } 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; - - - 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, BaseScriptHolder *owner); - uint32 _iP; -private: - void readHeader(); - uint32 _bufferSize; - byte *_buffer; -public: - Common::SeekableReadStream *_scriptStream; - 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; - TMethodPos *_methods; - TEventPos *_events; - uint32 _numExternals; - TExternalFunction *_externals; - uint32 _numFunctions; - uint32 _numMethods; - uint32 _numEvents; - - bool initScript(); - bool initTables(); - - -// IWmeDebugScript interface implementation -public: - virtual int dbgGetLine(); - virtual const char *dbgGetFilename(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/base/scriptables/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { +class BaseScriptHolder; +class BaseObject; +class ScEngine; +class ScStack; +class ScScript : public BaseClass { +public: + BaseArray _breakpoints; + bool _tracingMode; + + ScScript *_parentScript; + bool _unbreakable; + bool finishThreads(); + bool copyParameters(ScStack *stack); + + void afterLoad(); +private: + ScValue *_operand; + ScValue *_reg1; +public: + bool _freezable; + bool resume(); + bool pause(); + 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, ...); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(BaseObject *object); + bool waitFor(BaseObject *object); + uint32 _waitTime; + bool _waitFrozen; + BaseObject *_waitObject; + ScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + ScValue *getVar(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; + uint32 codeStart; + uint32 funcTable; + uint32 symbolTable; + uint32 eventTable; + uint32 externalsTable; + uint32 methodTable; + } 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; + + + 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, BaseScriptHolder *owner); + uint32 _iP; +private: + void readHeader(); + uint32 _bufferSize; + byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; + 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; + TMethodPos *_methods; + TEventPos *_events; + uint32 _numExternals; + TExternalFunction *_externals; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; + + bool initScript(); + bool initTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 02f6080958..20e2ccadd1 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -1,610 +1,610 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_engine.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_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" -#include "engines/wintermute/utils/utils.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(ScEngine, true) - -#define COMPILER_DLL "dcscomp.dll" -////////////////////////////////////////////////////////////////////////// -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 ScValue(_gameRef); - - - // register 'Game' as global variable - if (!_globals->propExists("Game")) { - ScValue val(_gameRef); - val.setNative(_gameRef, true); - _globals->setProp("Game", &val); - } - - // register 'Math' as global variable - if (!_globals->propExists("Math")) { - ScValue 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(); -} - - -////////////////////////////////////////////////////////////////////////// -ScEngine::~ScEngine() { - _gameRef->LOG(0, "Shutting down scripting engine"); - - disableProfiling(); - - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::cleanup() { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) { - _scripts[i]->_owner->removeScript(_scripts[i]); - } - delete _scripts[i]; - _scripts.remove_at(i); - i--; - } - - _scripts.clear(); - - delete _globals; - _globals = NULL; - - emptyScriptCache(); - - _currentScript = NULL; // ref only - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { - return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::closeFile(void *data, byte *buffer) { - delete[] buffer; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::parseElement(void *data, int line, int type, void *elementData) { -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { - byte *compBuffer; - uint32 compSize; - - // get script from cache - compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) { - return NULL; - } - - // add new script - 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); - delete script; - return NULL; - } else { - // publish the "self" pseudo-variable - ScValue val(_gameRef); - if (owner) { - val.setNative(owner, true); - } else { - val.setNULL(); - } - - script->_globals->setProp("self", &val); - script->_globals->setProp("this", &val); - - _scripts.add(script); - - return script; - } -} - - -////////////////////////////////////////////////////////////////////////// -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 = g_system->getMillis(); - *outSize = _cachedScripts[i]->_size; - return _cachedScripts[i]->_buffer; - } - } - } - - // nope, load it - byte *compBuffer; - uint32 compSize; - - uint32 size; - - byte *buffer = BaseEngine::instance().getFileManager()->readWholeFile(filename, &size); - if (!buffer) { - _gameRef->LOG(0, "ScEngine::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, "ScEngine::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 = 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; - index = i; - } - } - - if (_cachedScripts[index] != NULL) { - delete _cachedScripts[index]; - } - _cachedScripts[index] = cachedScript; - - ret = cachedScript->_buffer; - *outSize = cachedScript->_size; - } - - - // cleanup - delete[] buffer; - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::tick() { - if (_scripts.size() == 0) { - return STATUS_OK; - } - - - // resolve waiting scripts - 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.size(); 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 <= g_system->getMillis()) { - _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: - break; - } // switch - } // for each script - - - // execute scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - - // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) { - continue; - } - - // 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) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - 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(); - } - - 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); - } - } - _currentScript = NULL; - } - - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::tickUnbreakable() { - // execute unbreakable scripts - for (uint32 i = 0; i < _scripts.size(); 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 ScEngine::removeFinishedScripts() { - // remove finished scripts - 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]); - } - - delete _scripts[i]; - _scripts.remove_at(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { - int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - - for (uint32 i = 0; i < _scripts.size(); 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("ScEngine::GetNumScripts - unhandled enum"); - break; - } - numTotal++; - } - if (running) { - *running = numRunning; - } - if (waiting) { - *waiting = numWaiting; - } - if (persistent) { - *persistent = numPersistent; - } - - return numTotal; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::emptyScriptCache() { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i]) { - delete _cachedScripts[i]; - _cachedScripts[i] = NULL; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::resetObject(BaseObject *Object) { - // terminate all scripts waiting for this object - for (uint32 i = 0; i < _scripts.size(); 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 ScEngine::resetScript(ScScript *script) { - // terminate all scripts waiting for this script - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { - _scripts[i]->finish(); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) { - cleanup(); - } - - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_currentScript)); - persistMgr->transfer(TMEMBER(_globals)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::editorCleanup() { - 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); - i--; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::pauseAll() { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i] != _currentScript) { - _scripts[i]->pause(); - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::resumeAll() { - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->resume(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::isValidScript(ScScript *script) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i] == script) { - return true; - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::clearGlobals(bool includingNatives) { - _globals->CleanProps(includingNatives); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void ScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) { - return; - } - - AnsiString fileName = filename; - fileName.toLowercase(); - _scriptTimes[fileName] += time; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::enableProfiling() { - if (_isProfiling) { - return; - } - - // destroy old data, if any - _scriptTimes.clear(); - - _profilingStartTime = g_system->getMillis(); - _isProfiling = true; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::disableProfiling() { - if (!_isProfiling) { - return; - } - - dumpStats(); - _isProfiling = false; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::dumpStats() { - error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = g_system->getMillis() - _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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_engine.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_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" +#include "engines/wintermute/utils/utils.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(ScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +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 ScValue(_gameRef); + + + // register 'Game' as global variable + if (!_globals->propExists("Game")) { + ScValue val(_gameRef); + val.setNative(_gameRef, true); + _globals->setProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->propExists("Math")) { + ScValue 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(); +} + + +////////////////////////////////////////////////////////////////////////// +ScEngine::~ScEngine() { + _gameRef->LOG(0, "Shutting down scripting engine"); + + disableProfiling(); + + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::cleanup() { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } + delete _scripts[i]; + _scripts.remove_at(i); + i--; + } + + _scripts.clear(); + + delete _globals; + _globals = NULL; + + emptyScriptCache(); + + _currentScript = NULL; // ref only + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { + return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::closeFile(void *data, byte *buffer) { + delete[] buffer; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::parseElement(void *data, int line, int type, void *elementData) { +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; + + // get script from cache + compBuffer = getCompiledScript(filename, &compSize); + if (!compBuffer) { + return NULL; + } + + // add new script + 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); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + ScValue val(_gameRef); + if (owner) { + val.setNative(owner, true); + } else { + val.setNULL(); + } + + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); + + _scripts.add(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +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 = g_system->getMillis(); + *outSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *compBuffer; + uint32 compSize; + + uint32 size; + + byte *buffer = BaseEngine::instance().getFileManager()->readWholeFile(filename, &size); + if (!buffer) { + _gameRef->LOG(0, "ScEngine::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, "ScEngine::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 = 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; + index = i; + } + } + + if (_cachedScripts[index] != NULL) { + delete _cachedScripts[index]; + } + _cachedScripts[index] = cachedScript; + + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; + } + + + // cleanup + delete[] buffer; + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::tick() { + if (_scripts.size() == 0) { + return STATUS_OK; + } + + + // resolve waiting scripts + 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.size(); 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 <= g_system->getMillis()) { + _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: + break; + } // switch + } // for each script + + + // execute scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) { + continue; + } + + // 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) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + 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(); + } + + 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); + } + } + _currentScript = NULL; + } + + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::tickUnbreakable() { + // execute unbreakable scripts + for (uint32 i = 0; i < _scripts.size(); 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 ScEngine::removeFinishedScripts() { + // remove finished scripts + 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]); + } + + delete _scripts[i]; + _scripts.remove_at(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; + + for (uint32 i = 0; i < _scripts.size(); 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("ScEngine::GetNumScripts - unhandled enum"); + break; + } + numTotal++; + } + if (running) { + *running = numRunning; + } + if (waiting) { + *waiting = numWaiting; + } + if (persistent) { + *persistent = numPersistent; + } + + return numTotal; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::emptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::resetObject(BaseObject *Object) { + // terminate all scripts waiting for this object + for (uint32 i = 0; i < _scripts.size(); 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 ScEngine::resetScript(ScScript *script) { + // terminate all scripts waiting for this script + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { + _scripts[i]->finish(); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::persist(BasePersistenceManager *persistMgr) { + if (!persistMgr->getIsSaving()) { + cleanup(); + } + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::editorCleanup() { + 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); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::pauseAll() { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i] != _currentScript) { + _scripts[i]->pause(); + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::resumeAll() { + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->resume(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::isValidScript(ScScript *script) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i] == script) { + return true; + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void ScEngine::addScriptTime(const char *filename, uint32 time) { + if (!_isProfiling) { + return; + } + + AnsiString fileName = filename; + fileName.toLowercase(); + _scriptTimes[fileName] += time; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::enableProfiling() { + if (_isProfiling) { + return; + } + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = g_system->getMillis(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::disableProfiling() { + if (!_isProfiling) { + return; + } + + dumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::dumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = g_system->getMillis() - _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 index f526353368..1a023326eb 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -1,135 +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 - */ - -#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" - -namespace Wintermute { - -#define MAX_CACHED_SCRIPTS 20 -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 = g_system->getMillis(); - _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.clear(); - } - - Common::String _filename; - BaseArray _lines; - }; - -public: - bool clearGlobals(bool includingNatives = false); - bool tickUnbreakable(); - bool removeFinishedScripts(); - bool isValidScript(ScScript *script); - - ScScript *_currentScript; - bool resumeAll(); - bool pauseAll(); - void editorCleanup(); - bool resetObject(BaseObject *Object); - bool resetScript(ScScript *script); - bool emptyScriptCache(); - byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(ScEngine, BaseClass) - bool cleanup(); - int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - bool tick(); - ScValue *_globals; - ScScript *runScript(const char *filename, BaseScriptHolder *owner = NULL); - static const bool _compilerAvailable = false; - - 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); - - BaseArray _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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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" + +namespace Wintermute { + +#define MAX_CACHED_SCRIPTS 20 +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 = g_system->getMillis(); + _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.clear(); + } + + Common::String _filename; + BaseArray _lines; + }; + +public: + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); + bool isValidScript(ScScript *script); + + ScScript *_currentScript; + bool resumeAll(); + bool pauseAll(); + void editorCleanup(); + bool resetObject(BaseObject *Object); + bool resetScript(ScScript *script); + bool emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); + DECLARE_PERSISTENT(ScEngine, BaseClass) + bool cleanup(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + bool tick(); + ScValue *_globals; + ScScript *runScript(const char *filename, BaseScriptHolder *owner = NULL); + static const bool _compilerAvailable = false; + + 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); + + BaseArray _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 index c8d4f64ae9..5ed07f0da6 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -1,252 +1,252 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXArray, false) - -BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { - return new SXArray(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - _length = 0; - _values = new ScValue(_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()); - } - } -} - -////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame) : BaseScriptable(inGame) { - _length = 0; - _values = new ScValue(_gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -SXArray::~SXArray() { - delete _values; - _values = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *SXArray::scToString() { - char dummy[32768]; - strcpy(dummy, ""); - char propName[20]; - for (int i = 0; i < _length; i++) { - sprintf(propName, "%d", i); - ScValue *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, ","); - } - } - _strRep = dummy; - return _strRep.c_str(); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *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; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXArray::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 SXArray::scSetProperty(const char *name, ScValue *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 SXArray::persist(BasePersistenceManager *persistMgr) { - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_length)); - persistMgr->transfer(TMEMBER(_values)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -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')) { - isNumber = false; - break; - } - } - - if (isNumber) { - int index = atoi(origStr); - sprintf(outStr, "%d", index); - return true; - } else { - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool SXArray::push(ScValue *val) { - char paramName[20]; - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, val, true); - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXArray, false) + +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { + return new SXArray(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXArray::SXArray(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + _length = 0; + _values = new ScValue(_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()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +SXArray::SXArray(BaseGame *inGame) : BaseScriptable(inGame) { + _length = 0; + _values = new ScValue(_gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +SXArray::~SXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *SXArray::scToString() { + char dummy[32768]; + strcpy(dummy, ""); + char propName[20]; + for (int i = 0; i < _length; i++) { + sprintf(propName, "%d", i); + ScValue *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, ","); + } + } + _strRep = dummy; + return _strRep.c_str(); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *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; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXArray::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 SXArray::scSetProperty(const char *name, ScValue *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 SXArray::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +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')) { + isNumber = false; + break; + } + } + + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); + return true; + } else { + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool SXArray::push(ScValue *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 index 614f829950..d9805ef94f 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -1,56 +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_SXARRAY_H -#define WINTERMUTE_SXARRAY_H - -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXArray : public BaseScriptable { -public: - bool push(ScValue *val); - bool validNumber(const char *origStr, char *outStr); - 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(); -private: - int _length; - ScValue *_values; - Common::String _strRep; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SXArray : public BaseScriptable { +public: + bool push(ScValue *val); + bool validNumber(const char *origStr, char *outStr); + 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(); +private: + int _length; + ScValue *_values; + Common::String _strRep; +}; + +} // 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 7726015081..11eead3b9c 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -1,293 +1,293 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXDate, false) - -BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { - return new SXDate(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXDate::SXDate(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - stack->correctParams(6); - - memset(&_tm, 0, sizeof(_tm)); - - ScValue *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); - } -} - - -////////////////////////////////////////////////////////////////////////// -SXDate::~SXDate() { - -} - -////////////////////////////////////////////////////////////////////////// -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(); - //return asctime(&_tm); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); - stack->pushInt(_tm.tm_wday); - 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; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXDate::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("date"); - return _scValue; - } else { - return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXDate::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name")==0){ - setName(value->getString()); - return STATUS_OK; - } - - else*/ return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool SXDate::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::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 SXDate::scCompare(BaseScriptable *Value) { - TimeDate time1 = _tm; - TimeDate time2 = ((SXDate *)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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXDate, false) + +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { + return new SXDate(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXDate::SXDate(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + stack->correctParams(6); + + memset(&_tm, 0, sizeof(_tm)); + + ScValue *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); + } +} + + +////////////////////////////////////////////////////////////////////////// +SXDate::~SXDate() { + +} + +////////////////////////////////////////////////////////////////////////// +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(); + //return asctime(&_tm); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *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); + stack->pushInt(_tm.tm_wday); + 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; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXDate::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("date"); + return _scValue; + } else { + return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXDate::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name")==0){ + setName(value->getString()); + return STATUS_OK; + } + + else*/ return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool SXDate::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::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 SXDate::scCompare(BaseScriptable *Value) { + TimeDate time1 = _tm; + TimeDate time2 = ((SXDate *)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 index 7cdf57e689..f6f04dd7e6 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -1,54 +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_SXDATE_H -#define WINTERMUTE_SXDATE_H - -#include "common/system.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXDate : public BaseScriptable { -public: - 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(); -private: - TimeDate _tm; - Common::String _strRep; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SXDate : public BaseScriptable { +public: + 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(); +private: + TimeDate _tm; + 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 index 53d551119d..ab574d464b 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -1,829 +1,829 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXFile, false) - -BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { - return new SXFile(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXFile::SXFile(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - _filename = NULL; - if (!val->isNULL()) { - BaseUtils::setString(&_filename, val->getString()); - } - - _readFile = NULL; - _writeFile = NULL; - - _mode = 0; - _textMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -SXFile::~SXFile() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void SXFile::cleanup() { - delete[] _filename; - _filename = NULL; - close(); -} - - -////////////////////////////////////////////////////////////////////////// -void SXFile::close() { - if (_readFile) { - BaseFileManager::getEngineInstance()->closeFile(_readFile); - _readFile = NULL; - } - if (_writeFile) { - _writeFile->finalize(); - delete _writeFile; - _writeFile = NULL; - } - _mode = 0; - _textMode = false; -} - -////////////////////////////////////////////////////////////////////////// -const char *SXFile::scToString() { - if (_filename) { - return _filename; - } else { - return "[file object]"; - } -} - -#define FILE_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFilename - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFilename") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - cleanup(); - BaseUtils::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 = BaseFileManager::getEngineInstance()->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(); - error("SXFile-Method: \"Delete\" not supported"); - //stack->pushBool(BasePlatform::deleteFile(_filename) != false); - stack->pushBool(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(); - error("SXFile-Method: Copy not supported"); - //stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); - stack->pushBool(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 BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXFile::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 BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXFile::scSetProperty(const char *name, ScValue *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 BaseScriptable::scSetProperty(name, value); -} - -////////////////////////////////////////////////////////////////////////// -uint32 SXFile::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 SXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) { - return _readFile->seek(pos, whence); - } 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; - } -} - -////////////////////////////////////////////////////////////////////////// -uint32 SXFile::getLength() { - if (_mode == 1 && _readFile) { - return _readFile->size(); - } 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; - } -} - -////////////////////////////////////////////////////////////////////////// -bool SXFile::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_mode)); - persistMgr->transfer(TMEMBER(_textMode)); - - uint32 pos = 0; - if (persistMgr->getIsSaving()) { - 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 = BaseFileManager::getEngineInstance()->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 *SXFile::openForWrite(const Common::String &filename, bool binary) { - error("SXFile::openForWrite - WriteFiles not supported"); -} - -// Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXFile, false) + +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { + return new SXFile(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXFile::SXFile(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + _filename = NULL; + if (!val->isNULL()) { + BaseUtils::setString(&_filename, val->getString()); + } + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +SXFile::~SXFile() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void SXFile::cleanup() { + delete[] _filename; + _filename = NULL; + close(); +} + + +////////////////////////////////////////////////////////////////////////// +void SXFile::close() { + if (_readFile) { + BaseFileManager::getEngineInstance()->closeFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *SXFile::scToString() { + if (_filename) { + return _filename; + } else { + return "[file object]"; + } +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFilename") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + cleanup(); + BaseUtils::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 = BaseFileManager::getEngineInstance()->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(); + error("SXFile-Method: \"Delete\" not supported"); + //stack->pushBool(BasePlatform::deleteFile(_filename) != false); + stack->pushBool(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(); + error("SXFile-Method: Copy not supported"); + //stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(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 BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXFile::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 BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXFile::scSetProperty(const char *name, ScValue *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 BaseScriptable::scSetProperty(name, value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 SXFile::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 SXFile::setPos(uint32 pos, int whence) { + if (_mode == 1 && _readFile) { + return _readFile->seek(pos, whence); + } 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; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 SXFile::getLength() { + if (_mode == 1 && _readFile) { + return _readFile->size(); + } 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; + } +} + +////////////////////////////////////////////////////////////////////////// +bool SXFile::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); + + uint32 pos = 0; + if (persistMgr->getIsSaving()) { + 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 = BaseFileManager::getEngineInstance()->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 *SXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *SXFile::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 index 389974a48e..b91a53e695 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -1,66 +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 BaseFile; - -class SXFile : public BaseScriptable { -public: - 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(); - SXFile(BaseGame *inGame, ScStack *Stack); - virtual ~SXFile(); -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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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 BaseFile; + +class SXFile : public BaseScriptable { +public: + 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(); + SXFile(BaseGame *inGame, ScStack *Stack); + virtual ~SXFile(); +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 index f7d0ba20b9..598b80cff3 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -1,295 +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(SXMath, true) - -BaseScriptable *makeSXMath(BaseGame *inGame) { - return new SXMath(inGame); -} - -////////////////////////////////////////////////////////////////////////// -SXMath::SXMath(BaseGame *inGame) : BaseScriptable(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -SXMath::~SXMath() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *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; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXMath::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 SXMath::degreeToRadian(double value) { - return value * (M_PI / 180.0f); -} - - -////////////////////////////////////////////////////////////////////////// -double SXMath::radianToDegree(double value) { - return value * (180.0f / M_PI); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMath::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXMath, true) + +BaseScriptable *makeSXMath(BaseGame *inGame) { + return new SXMath(inGame); +} + +////////////////////////////////////////////////////////////////////////// +SXMath::SXMath(BaseGame *inGame) : BaseScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +SXMath::~SXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *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; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXMath::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 SXMath::degreeToRadian(double value) { + return value * (M_PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double SXMath::radianToDegree(double value) { + return value * (180.0f / M_PI); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMath::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::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 index b195c0785d..f86d59fe7b 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -1,53 +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 SXMath : public BaseScriptable { -public: - 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); - double radianToDegree(double value); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SXMath : public BaseScriptable { +public: + 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); + 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 index eef1931d8b..5ed9bd5313 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -1,529 +1,529 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXMemBuffer, false) - -BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { - return new SXMemBuffer(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - stack->correctParams(1); - _buffer = NULL; - _size = 0; - - int newSize = stack->pop()->getInt(); - resize(MAX(0, newSize)); -} - -////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer) : BaseScriptable(inGame) { - _size = 0; - _buffer = buffer; -} - - -////////////////////////////////////////////////////////////////////////// -SXMemBuffer::~SXMemBuffer() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void *SXMemBuffer::scToMemBuffer() { - return _buffer; -} - -////////////////////////////////////////////////////////////////////////// -void SXMemBuffer::cleanup() { - if (_size) { - free(_buffer); - } - _buffer = NULL; - _size = 0; -} - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::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 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; - } - 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 *SXMemBuffer::scToString() { - return "[membuffer object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *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]; - Common::strlcpy(str, (const char *)_buffer + start, length + 1); - 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); - SXMemBuffer *buf = new SXMemBuffer(_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(); - /* ScValue *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; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXMemBuffer::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 BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::scSetProperty(const char *name, ScValue *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 BaseScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_size)); - - if (persistMgr->getIsSaving()) { - 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 SXMemBuffer::scCompare(BaseScriptable *val) { - if (_buffer == val->scToMemBuffer()) { - return 0; - } else { - return 1; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXMemBuffer, false) + +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { + return new SXMemBuffer(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + stack->correctParams(1); + _buffer = NULL; + _size = 0; + + int newSize = stack->pop()->getInt(); + resize(MAX(0, newSize)); +} + +////////////////////////////////////////////////////////////////////////// +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer) : BaseScriptable(inGame) { + _size = 0; + _buffer = buffer; +} + + +////////////////////////////////////////////////////////////////////////// +SXMemBuffer::~SXMemBuffer() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *SXMemBuffer::scToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void SXMemBuffer::cleanup() { + if (_size) { + free(_buffer); + } + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::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 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; + } + 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 *SXMemBuffer::scToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *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]; + Common::strlcpy(str, (const char *)_buffer + start, length + 1); + 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); + SXMemBuffer *buf = new SXMemBuffer(_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(); + /* ScValue *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; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXMemBuffer::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 BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::scSetProperty(const char *name, ScValue *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 BaseScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_size)); + + if (persistMgr->getIsSaving()) { + 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 SXMemBuffer::scCompare(BaseScriptable *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 index 0a16167b58..d2662b3036 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -1,60 +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_SXMEMBUFFER_H -#define WINTERMUTE_SXMEMBUFFER_H - - -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXMemBuffer : public BaseScriptable { -public: - 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(); - SXMemBuffer(BaseGame *inGame, ScStack *stack); - SXMemBuffer(BaseGame *inGame, void *buffer); - virtual ~SXMemBuffer(); - virtual void *scToMemBuffer(); -private: - int _size; - - bool resize(int newSize); - void *_buffer; - void cleanup(); - bool checkBounds(ScScript *script, int start, int length); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SXMemBuffer : public BaseScriptable { +public: + 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(); + SXMemBuffer(BaseGame *inGame, ScStack *stack); + SXMemBuffer(BaseGame *inGame, void *buffer); + virtual ~SXMemBuffer(); + virtual void *scToMemBuffer(); +private: + int _size; + + bool resize(int newSize); + void *_buffer; + void cleanup(); + bool checkBounds(ScScript *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 index 40c9b885cd..b87aac81f9 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -1,67 +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(SXObject, false) - -BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { - return new SXObject(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -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()); - } -} - - -////////////////////////////////////////////////////////////////////////// -SXObject::~SXObject() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool SXObject::persist(BasePersistenceManager *persistMgr) { - BaseObject::persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXObject, false) + +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { + return new SXObject(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +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()); + } +} + + +////////////////////////////////////////////////////////////////////////// +SXObject::~SXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool SXObject::persist(BasePersistenceManager *persistMgr) { + BaseObject::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 index 32aa00776e..c85d16d44e 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -1,46 +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_SXOBJECT_H -#define WINTERMUTE_SXOBJECT_H - - -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class SXObject : public BaseObject { -public: - DECLARE_PERSISTENT(SXObject, BaseObject) - SXObject(BaseGame *inGame, ScStack *Stack); - virtual ~SXObject(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SXObject : public BaseObject { +public: + DECLARE_PERSISTENT(SXObject, BaseObject) + SXObject(BaseGame *inGame, ScStack *Stack); + virtual ~SXObject(); +}; + +} // 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 9bcfe28bbf..8d87a92dc1 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -1,436 +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/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(SXString, false) - -BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { - return new SXString(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - _string = NULL; - _capacity = 0; - - stack->correctParams(1); - ScValue *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(""); - } -} - - -////////////////////////////////////////////////////////////////////////// -SXString::~SXString() { - if (_string) { - delete[] _string; - } -} - - -////////////////////////////////////////////////////////////////////////// -void SXString::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 *SXString::scToString() { - if (_string) { - return _string; - } else { - return "[null string]"; - } -} - - -////////////////////////////////////////////////////////////////////////// -void SXString::scSetString(const char *val) { - setStringVal(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *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) { - BaseUtils::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(); - - ScValue *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); - ScValue *val = stack->pop(); - char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) { - strcpy(separators, val->getString()); - } - - SXArray *array = new SXArray(_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 ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - } else { - val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); - } - - array->push(val); - delete val; - val = NULL; - } - - stack->pushNative(array, false); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXString::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 SXString::scSetProperty(const char *name, ScValue *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 SXString::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_capacity)); - - if (persistMgr->getIsSaving()) { - 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 SXString::scCompare(BaseScriptable *val) { - return strcmp(_string, ((SXString *)val)->_string); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(SXString, false) + +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { + return new SXString(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + _string = NULL; + _capacity = 0; + + stack->correctParams(1); + ScValue *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(""); + } +} + + +////////////////////////////////////////////////////////////////////////// +SXString::~SXString() { + if (_string) { + delete[] _string; + } +} + + +////////////////////////////////////////////////////////////////////////// +void SXString::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 *SXString::scToString() { + if (_string) { + return _string; + } else { + return "[null string]"; + } +} + + +////////////////////////////////////////////////////////////////////////// +void SXString::scSetString(const char *val) { + setStringVal(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *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) { + BaseUtils::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(); + + ScValue *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); + ScValue *val = stack->pop(); + char separators[MAX_PATH_LENGTH] = ","; + if (!val->isNULL()) { + strcpy(separators, val->getString()); + } + + SXArray *array = new SXArray(_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 ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + } else { + val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + } + + array->push(val); + delete val; + val = NULL; + } + + stack->pushNative(array, false); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXString::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 SXString::scSetProperty(const char *name, ScValue *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 SXString::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_capacity)); + + if (persistMgr->getIsSaving()) { + 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 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 c2de3860ed..255b9c57eb 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -1,58 +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 SXString : public BaseScriptable { -public: - 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); - - SXString(BaseGame *inGame, ScStack *Stack); - virtual ~SXString(); - -private: - char *_string; - int _capacity; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SXString : public BaseScriptable { +public: + 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); + + SXString(BaseGame *inGame, ScStack *Stack); + virtual ~SXString(); + +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 index d27748abe6..77367045c2 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -1,232 +1,232 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(ScStack, false) - -////////////////////////////////////////////////////////////////////////// -ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { - _sP = -1; -} - - -////////////////////////////////////////////////////////////////////////// -ScStack::~ScStack() { - -#if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.size(), _sP); -#endif - - for (uint32 i = 0; i < _values.size(); i++) { - delete _values[i]; - } - _values.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::pop() { - if (_sP < 0) { - _gameRef->LOG(0, "Fatal: Stack underflow"); - return NULL; - } - - return _values[_sP--]; -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::push(ScValue *val) { - _sP++; - - if (_sP < (int32)_values.size()) { - _values[_sP]->cleanup(); - _values[_sP]->copy(val); - } else { - ScValue *copyVal = new ScValue(_gameRef); - copyVal->copy(val); - _values.add(copyVal); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::getPushValue() { - _sP++; - - if (_sP >= (int32)_values.size()) { - ScValue *val = new ScValue(_gameRef); - _values.add(val); - } - _values[_sP]->cleanup(); - return _values[_sP]; -} - - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::getTop() { - if (_sP < 0 || _sP >= (int32)_values.size()) { - return NULL; - } else { - return _values[_sP]; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::getAt(int index) { - index = _sP - index; - if (index < 0 || index >= (int32)_values.size()) { - return NULL; - } else { - return _values[index]; - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::correctParams(uint32 expectedParams) { - uint32 nuParams = (uint32)pop()->getInt(); - - if (expectedParams < nuParams) { // too many params - while (expectedParams < nuParams) { - //Pop(); - delete _values[_sP - expectedParams]; - _values.remove_at(_sP - expectedParams); - nuParams--; - _sP--; - } - } else if (expectedParams > nuParams) { // need more params - while (expectedParams > nuParams) { - //Push(null_val); - ScValue *nullVal = new ScValue(_gameRef); - nullVal->setNULL(); - _values.insert_at(_sP - nuParams + 1, nullVal); - nuParams++; - _sP++; - - if ((int32)_values.size() > _sP + 1) { - delete _values[_values.size() - 1]; - _values.remove_at(_values.size() - 1); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushNULL() { - /* - ScValue* val = new ScValue(_gameRef); - val->setNULL(); - Push(val); - delete val; - */ - getPushValue()->setNULL(); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushInt(int val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setInt(Val); - Push(val); - delete val; - */ - getPushValue()->setInt(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushFloat(double val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setFloat(Val); - Push(val); - delete val; - */ - getPushValue()->setFloat(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushBool(bool val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setBool(Val); - Push(val); - delete val; - */ - getPushValue()->setBool(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushString(const char *val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setString(Val); - Push(val); - delete val; - */ - getPushValue()->setString(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushNative(BaseScriptable *val, bool persistent) { - /* - ScValue* val = new ScValue(_gameRef); - val->setNative(Val, Persistent); - Push(val); - delete val; - */ - - getPushValue()->setNative(val, persistent); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScStack::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_sP)); - _values.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(ScStack, false) + +////////////////////////////////////////////////////////////////////////// +ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +ScStack::~ScStack() { + +#if _DEBUG + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.size(), _sP); +#endif + + for (uint32 i = 0; i < _values.size(); i++) { + delete _values[i]; + } + _values.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::pop() { + if (_sP < 0) { + _gameRef->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::push(ScValue *val) { + _sP++; + + if (_sP < (int32)_values.size()) { + _values[_sP]->cleanup(); + _values[_sP]->copy(val); + } else { + ScValue *copyVal = new ScValue(_gameRef); + copyVal->copy(val); + _values.add(copyVal); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::getPushValue() { + _sP++; + + if (_sP >= (int32)_values.size()) { + ScValue *val = new ScValue(_gameRef); + _values.add(val); + } + _values[_sP]->cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::getTop() { + if (_sP < 0 || _sP >= (int32)_values.size()) { + return NULL; + } else { + return _values[_sP]; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::getAt(int index) { + index = _sP - index; + if (index < 0 || index >= (int32)_values.size()) { + return NULL; + } else { + return _values[index]; + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::correctParams(uint32 expectedParams) { + uint32 nuParams = (uint32)pop()->getInt(); + + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { + //Pop(); + delete _values[_sP - expectedParams]; + _values.remove_at(_sP - expectedParams); + nuParams--; + _sP--; + } + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { + //Push(null_val); + ScValue *nullVal = new ScValue(_gameRef); + nullVal->setNULL(); + _values.insert_at(_sP - nuParams + 1, nullVal); + nuParams++; + _sP++; + + if ((int32)_values.size() > _sP + 1) { + delete _values[_values.size() - 1]; + _values.remove_at(_values.size() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushNULL() { + /* + ScValue* val = new ScValue(_gameRef); + val->setNULL(); + Push(val); + delete val; + */ + getPushValue()->setNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushInt(int val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setInt(Val); + Push(val); + delete val; + */ + getPushValue()->setInt(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushFloat(double val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setFloat(Val); + Push(val); + delete val; + */ + getPushValue()->setFloat(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushBool(bool val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setBool(Val); + Push(val); + delete val; + */ + getPushValue()->setBool(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushString(const char *val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setString(Val); + Push(val); + delete val; + */ + getPushValue()->setString(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushNative(BaseScriptable *val, bool persistent) { + /* + ScValue* val = new ScValue(_gameRef); + val->setNative(Val, Persistent); + Push(val); + delete val; + */ + + getPushValue()->setNative(val, persistent); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScStack::persist(BasePersistenceManager *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 index 0e2adae518..86d246cf34 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -1,66 +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 ScValue; -class BaseScriptable; - -class ScStack : public BaseClass { -public: - 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); - ScValue *getTop(); - void push(ScValue *val); - ScValue *pop(); - ScStack(BaseGame *inGame); - virtual ~ScStack(); - BaseArray _values; - int _sP; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 ScValue; +class BaseScriptable; + +class ScStack : public BaseClass { +public: + 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); + ScValue *getTop(); + void push(ScValue *val); + ScValue *pop(); + ScStack(BaseGame *inGame); + virtual ~ScStack(); + BaseArray _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 index 03ca69ac7e..0bc7ab5807 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -1,995 +1,995 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(ScValue, false) - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame) : BaseClass(inGame) { - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, bool val) : BaseClass(inGame) { - _type = VAL_BOOL; - _valBool = val; - - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, int val) : BaseClass(inGame) { - _type = VAL_INT; - _valInt = val; - - _valFloat = 0.0f; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, double val) : BaseClass(inGame) { - _type = VAL_FLOAT; - _valFloat = val; - - _valInt = 0; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, const char *val) : BaseClass(inGame) { - _type = VAL_STRING; - _valString = NULL; - setStringVal(val); - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::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; -} - - - -////////////////////////////////////////////////////////////////////////// -ScValue::~ScValue() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScValue::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 (_gameRef->_textEncoding == TEXT_ANSI) { - _gameRef->_scValue->setInt(strlen(_valString)); - } else { - WideString wstr = StringUtil::utf8ToWide(_valString); - _gameRef->_scValue->setInt(wstr.size()); - } - - return _gameRef->_scValue; - } - - ScValue *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 ScValue::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 ScValue::setProp(const char *name, ScValue *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)) { - ScValue *newVal = NULL; - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - newVal = _valIter->_value; - } - if (!newVal) { - newVal = new ScValue(_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; - } - ScValue* val = new ScValue(_gameRef); - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if (_type!=VAL_NATIVE) _type = VAL_OBJECT; - */ - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->propExists(name); - } - _valIter = _valObject.find(name); - - return (_valIter != _valObject.end()); -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::deleteProps() { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - delete(ScValue *)_valIter->_value; - _valIter++; - } - _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::CleanProps(bool includingNatives) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) { - _valIter->_value->setNULL(); - } - _valIter++; - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isNULL(); - } - - return (_type == VAL_NULL); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isNative() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isNative(); - } - - return (_type == VAL_NATIVE); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isString() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isString(); - } - - return (_type == VAL_STRING); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isFloat(); - } - - return (_type == VAL_FLOAT); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isInt() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isInt(); - } - - return (_type == VAL_INT); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isBool() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isBool(); - } - - return (_type == VAL_BOOL); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isObject() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isObject(); - } - - return (_type == VAL_OBJECT); -} - - -////////////////////////////////////////////////////////////////////////// -TValType ScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getType(); - } - - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::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 ScValue::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 ScValue::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 ScValue::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 ScValue::setString(const Common::String &val) { - setString(val.c_str()); -} - -////////////////////////////////////////////////////////////////////////// -void ScValue::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 ScValue::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 ScValue::setNative(BaseScriptable *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 ScValue::setObject() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setObject(); - return; - } - - deleteProps(); - _type = VAL_OBJECT; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setReference(ScValue *val) { - _valRef = val; - _type = VAL_VARIABLE_REF; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::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 ScValue::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 ScValue::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 *ScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getMemBuffer(); - } - - if (_type == VAL_NATIVE) { - return _valNative->scToMemBuffer(); - } else { - return (void *)NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *ScValue::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; -} - - -////////////////////////////////////////////////////////////////////////// -BaseScriptable *ScValue::getNative() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getNative(); - } - - if (_type == VAL_NATIVE) { - return _valNative; - } else { - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -TValType ScValue::getType() { - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::copy(ScValue *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 ScValue(_gameRef); - _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); - orig->_valIter++; - } - } else { - _valObject.clear(); - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setValue(ScValue *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("ScValue::setValue - unhandled enum"); - break; - } - } - // otherwise just copy everything - else { - copy(val); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::persist(BasePersistenceManager *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->getIsSaving()) { - 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 { - ScValue *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 ScValue::saveAsText(BaseDynamicBuffer *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 ScValue::compare(ScValue *val1, ScValue *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 ScValue::compareStrict(ScValue *val1, ScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) { - return -1; - } else { - return ScValue::compare(val1, val2); - } -} - -////////////////////////////////////////////////////////////////////////// -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 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 ScValue::setProperty(const char *propName, double value) { - ScValue *val = new ScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -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; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProperty(const char *propName) { - ScValue *val = new ScValue(_gameRef); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(ScValue, false) + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame) : BaseClass(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, bool val) : BaseClass(inGame) { + _type = VAL_BOOL; + _valBool = val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, int val) : BaseClass(inGame) { + _type = VAL_INT; + _valInt = val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, double val) : BaseClass(inGame) { + _type = VAL_FLOAT; + _valFloat = val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, const char *val) : BaseClass(inGame) { + _type = VAL_STRING; + _valString = NULL; + setStringVal(val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::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; +} + + + +////////////////////////////////////////////////////////////////////////// +ScValue::~ScValue() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScValue::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 (_gameRef->_textEncoding == TEXT_ANSI) { + _gameRef->_scValue->setInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::utf8ToWide(_valString); + _gameRef->_scValue->setInt(wstr.size()); + } + + return _gameRef->_scValue; + } + + ScValue *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 ScValue::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 ScValue::setProp(const char *name, ScValue *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)) { + ScValue *newVal = NULL; + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + newVal = _valIter->_value; + } + if (!newVal) { + newVal = new ScValue(_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; + } + ScValue* val = new ScValue(_gameRef); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if (_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->propExists(name); + } + _valIter = _valObject.find(name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::deleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(ScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::CleanProps(bool includingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) { + _valIter->_value->setNULL(); + } + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isNULL(); + } + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isNative() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isNative(); + } + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isString() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isString(); + } + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isFloat(); + } + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isInt() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isInt(); + } + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isBool() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isBool(); + } + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isObject() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isObject(); + } + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType ScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getType(); + } + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::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 ScValue::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 ScValue::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 ScValue::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 ScValue::setString(const Common::String &val) { + setString(val.c_str()); +} + +////////////////////////////////////////////////////////////////////////// +void ScValue::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 ScValue::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 ScValue::setNative(BaseScriptable *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 ScValue::setObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setObject(); + return; + } + + deleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setReference(ScValue *val) { + _valRef = val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::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 ScValue::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 ScValue::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 *ScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getMemBuffer(); + } + + if (_type == VAL_NATIVE) { + return _valNative->scToMemBuffer(); + } else { + return (void *)NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *ScValue::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; +} + + +////////////////////////////////////////////////////////////////////////// +BaseScriptable *ScValue::getNative() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getNative(); + } + + if (_type == VAL_NATIVE) { + return _valNative; + } else { + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +TValType ScValue::getType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::copy(ScValue *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 ScValue(_gameRef); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); + orig->_valIter++; + } + } else { + _valObject.clear(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setValue(ScValue *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("ScValue::setValue - unhandled enum"); + break; + } + } + // otherwise just copy everything + else { + copy(val); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::persist(BasePersistenceManager *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->getIsSaving()) { + 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 { + ScValue *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 ScValue::saveAsText(BaseDynamicBuffer *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 ScValue::compare(ScValue *val1, ScValue *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 ScValue::compareStrict(ScValue *val1, ScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) { + return -1; + } else { + return ScValue::compare(val1, val2); + } +} + +////////////////////////////////////////////////////////////////////////// +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 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 ScValue::setProperty(const char *propName, double value) { + ScValue *val = new ScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +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; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProperty(const char *propName) { + ScValue *val = new ScValue(_gameRef); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index af31014bac..bf7d9cd8a1 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -1,113 +1,113 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/base/scriptables/dcscript.h" // Added by ClassView -#include "common/str.h" - -namespace Wintermute { - -class ScScript; -class BaseScriptable; - -class ScValue : public BaseClass { -public: - static int compare(ScValue *val1, ScValue *val2); - static int compareStrict(ScValue *val1, ScValue *val2); - TValType getTypeTolerant(); - void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(ScValue, BaseClass) - - bool _isConstVar; - bool saveAsText(BaseDynamicBuffer *buffer, int indent); - void setValue(ScValue *val); - bool _persistent; - bool propExists(const char *name); - void copy(ScValue *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(); - BaseScriptable *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(BaseScriptable *val, bool persistent = false); - void setObject(); - void setReference(ScValue *val); - bool isNULL(); - bool isNative(); - bool isString(); - bool isBool(); - bool isFloat(); - bool isInt(); - bool isObject(); - bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false); - ScValue *getProp(const char *name); - BaseScriptable *_valNative; - ScValue *_valRef; -private: - bool _valBool; - int _valInt; - double _valFloat; - char *_valString; -public: - TValType _type; - 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); - bool setProperty(const char *propName, double value); - bool setProperty(const char *propName, bool value); - bool setProperty(const char *propName); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/base/scriptables/dcscript.h" // Added by ClassView +#include "common/str.h" + +namespace Wintermute { + +class ScScript; +class BaseScriptable; + +class ScValue : public BaseClass { +public: + static int compare(ScValue *val1, ScValue *val2); + static int compareStrict(ScValue *val1, ScValue *val2); + TValType getTypeTolerant(); + void cleanup(bool ignoreNatives = false); + DECLARE_PERSISTENT(ScValue, BaseClass) + + bool _isConstVar; + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + void setValue(ScValue *val); + bool _persistent; + bool propExists(const char *name); + void copy(ScValue *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(); + BaseScriptable *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(BaseScriptable *val, bool persistent = false); + void setObject(); + void setReference(ScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false); + ScValue *getProp(const char *name); + BaseScriptable *_valNative; + ScValue *_valRef; +private: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + 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); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index aac68baccd..00d07cd3c2 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -1,292 +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/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(BaseSound, false) - -BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { - _sound = NULL; - _soundFilename = ""; - - _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; -} - -BaseSound::~BaseSound() { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - } - _sound = NULL; -} - -bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - } - _soundFilename = Common::String(); // Set empty - - _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); - if (_sound) { - _soundFilename = filename; - - _soundType = type; - _soundStreamed = streamed; - - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::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 BaseSound::getLength() { - if (_sound) { - return _sound->getLength(); - } else { - return 0; - } -} - -bool BaseSound::play(bool looping) { - if (_sound) { - _soundPaused = false; - return _sound->play(looping, _soundPosition); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::stop() { - if (_sound) { - _soundPaused = false; - return _sound->stop(); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::pause(bool freezePaused) { - if (_sound) { - _soundPaused = true; - if (freezePaused) { - _sound->_freezePaused = true; - } - return _sound->pause(); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::resume() { - if (_sound && _soundPaused) { - _soundPaused = false; - return _sound->resume(); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->getIsSaving() && _sound) { - _soundPlaying = _sound->isPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) { - _soundPosition = _sound->getPosition(); - } - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; - } - - if (persistMgr->getIsSaving()) { - _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 BaseSound::isPlaying() { - return _sound && _sound->isPlaying(); -} - -bool BaseSound::isPaused() { - return _sound && _soundPaused; -} - -bool BaseSound::setPositionTime(uint32 time) { - if (!_sound) { - return STATUS_FAILED; - } - _soundPosition = time; - bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) { - _soundPosition = 0; - } - return ret; -} - -uint32 BaseSound::getPositionTime() { - if (!_sound) { - return 0; - } - - if (!_sound->isPlaying()) { - return 0; - } else { - return _sound->getPosition(); - } -} - -bool BaseSound::setVolumePercent(int percent) { - if (!_sound) { - return STATUS_FAILED; - } else { - return _sound->setPrivateVolume(percent * 255 / 100); - } -} - -bool BaseSound::setVolume(int volume) { - if (!_sound) { - return STATUS_FAILED; - } else { - return _sound->setPrivateVolume(volume); - } -} - -bool BaseSound::setPrivateVolume(int volume) { - if (!_sound) { - return STATUS_FAILED; - } else { - _sound->_privateVolume = volume; - return STATUS_OK; - } -} - -int BaseSound::getVolumePercent() { - if (!_sound) { - return 0; - } else { - return _sound->_privateVolume * 100 / 255; - } -} - -int BaseSound::getVolume() { - if (!_sound) { - return 0; - } else { - return _sound->_privateVolume; - } -} - -bool BaseSound::setLoopStart(uint32 pos) { - if (!_sound) { - return STATUS_FAILED; - } else { - _sound->setLoopStart(pos); - return STATUS_OK; - } -} - -bool BaseSound::setPan(float pan) { - if (_sound) { - return _sound->setPan(pan); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(BaseSound, false) + +BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { + _sound = NULL; + _soundFilename = ""; + + _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; +} + +BaseSound::~BaseSound() { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + } + _sound = NULL; +} + +bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + } + _soundFilename = Common::String(); // Set empty + + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); + if (_sound) { + _soundFilename = filename; + + _soundType = type; + _soundStreamed = streamed; + + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::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 BaseSound::getLength() { + if (_sound) { + return _sound->getLength(); + } else { + return 0; + } +} + +bool BaseSound::play(bool looping) { + if (_sound) { + _soundPaused = false; + return _sound->play(looping, _soundPosition); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::stop() { + if (_sound) { + _soundPaused = false; + return _sound->stop(); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::pause(bool freezePaused) { + if (_sound) { + _soundPaused = true; + if (freezePaused) { + _sound->_freezePaused = true; + } + return _sound->pause(); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->resume(); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::persist(BasePersistenceManager *persistMgr) { + if (persistMgr->getIsSaving() && _sound) { + _soundPlaying = _sound->isPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) { + _soundPosition = _sound->getPosition(); + } + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (persistMgr->getIsSaving()) { + _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 BaseSound::isPlaying() { + return _sound && _sound->isPlaying(); +} + +bool BaseSound::isPaused() { + return _sound && _soundPaused; +} + +bool BaseSound::setPositionTime(uint32 time) { + if (!_sound) { + return STATUS_FAILED; + } + _soundPosition = time; + bool ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) { + _soundPosition = 0; + } + return ret; +} + +uint32 BaseSound::getPositionTime() { + if (!_sound) { + return 0; + } + + if (!_sound->isPlaying()) { + return 0; + } else { + return _sound->getPosition(); + } +} + +bool BaseSound::setVolumePercent(int percent) { + if (!_sound) { + return STATUS_FAILED; + } else { + return _sound->setPrivateVolume(percent * 255 / 100); + } +} + +bool BaseSound::setVolume(int volume) { + if (!_sound) { + return STATUS_FAILED; + } else { + return _sound->setPrivateVolume(volume); + } +} + +bool BaseSound::setPrivateVolume(int volume) { + if (!_sound) { + return STATUS_FAILED; + } else { + _sound->_privateVolume = volume; + return STATUS_OK; + } +} + +int BaseSound::getVolumePercent() { + if (!_sound) { + return 0; + } else { + return _sound->_privateVolume * 100 / 255; + } +} + +int BaseSound::getVolume() { + if (!_sound) { + return 0; + } else { + return _sound->_privateVolume; + } +} + +bool BaseSound::setLoopStart(uint32 pos) { + if (!_sound) { + return STATUS_FAILED; + } else { + _sound->setLoopStart(pos); + return STATUS_OK; + } +} + +bool BaseSound::setPan(float pan) { + if (_sound) { + return _sound->setPan(pan); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::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 index d65757474a..637061b7cc 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -1,87 +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_BASE_SOUND_H -#define WINTERMUTE_BASE_SOUND_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 BaseSoundBuffer; -class BaseSound : public BaseClass { -public: - bool setPan(float pan); - 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 isPlaying(); - bool isPaused(); - DECLARE_PERSISTENT(BaseSound, BaseClass) - bool resume(); - bool pause(bool freezePaused = false); - bool stop(); - bool play(bool looping = false); - uint32 getLength(); - const char *getFilename() { return _soundFilename.c_str(); } - bool setSoundSimple(); - 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; - float _sFXParam3; - float _sFXParam4; - BaseSoundBuffer *_sound; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SOUND_H +#define WINTERMUTE_BASE_SOUND_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 BaseSoundBuffer; +class BaseSound : public BaseClass { +public: + bool setPan(float pan); + 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 isPlaying(); + bool isPaused(); + DECLARE_PERSISTENT(BaseSound, BaseClass) + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); + uint32 getLength(); + const char *getFilename() { return _soundFilename.c_str(); } + bool setSoundSimple(); + 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; + float _sFXParam3; + float _sFXParam4; + BaseSoundBuffer *_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 index e2d9c8c13f..3fd6c4d5f2 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -1,297 +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/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 "engines/wintermute/wintermute.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 - -////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { - _stream = NULL; - _handle = NULL; -// _sync = NULL; - - _streamed = false; - _filename = ""; - _file = NULL; - _privateVolume = 255; - _volume = 255; - - _looping = false; - _loopStart = 0; - _startPos = 0; - - _type = Audio::Mixer::kSFXSoundType; - - _freezePaused = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer::~BaseSoundBuffer() { - stop(); - - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - delete _stream; - _stream = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 blockSize) { - _streamed = streamed; -} - - -////////////////////////////////////////////////////////////////////////// -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 = BaseFileManager::getEngineInstance()->openFile(filename, true, false); - if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); - return STATUS_FAILED; - } - Common::String strFilename(filename); - strFilename.toLowercase(); - 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 { - 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.c_str()); - } - if (!_stream) { - return STATUS_FAILED; - } - _filename = filename; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::play(bool looping, uint32 startSample) { - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - // Store the loop-value for save-games. - setLooping(looping); - 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 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; -} - -////////////////////////////////////////////////////////////////////////// -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; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::stop() { - if (_stream && _handle) { - g_system->getMixer()->stopHandle(*_handle); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::pause() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, true); - } - return STATUS_OK; - -} - -////////////////////////////////////////////////////////////////////////// -uint32 BaseSoundBuffer::getLength() { - if (_stream) { - uint32 len = _stream->getLength().msecs(); - return len * 1000; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) { - _type = type; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::updateVolume() { - setVolume(_privateVolume); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::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 BaseSoundBuffer::setPrivateVolume(int volume) { - _privateVolume = volume; - return setVolume(_privateVolume); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::isPlaying() { - if (_stream && _handle) { - return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseSoundBuffer::getPosition() { - if (_stream && _handle) { - uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); - return pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setPosition(uint32 pos) { - if (isPlaying()) { - warning("BaseSoundBuffer::SetPosition - not implemented for playing sounds yet."); - } - _startPos = pos; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setLoopStart(uint32 pos) { - _loopStart = pos; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setPan(float pan) { - if (_handle) { - g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - // 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: - break; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 "engines/wintermute/wintermute.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 + +////////////////////////////////////////////////////////////////////////// +BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { + _stream = NULL; + _handle = NULL; +// _sync = NULL; + + _streamed = false; + _filename = ""; + _file = NULL; + _privateVolume = 255; + _volume = 255; + + _looping = false; + _loopStart = 0; + _startPos = 0; + + _type = Audio::Mixer::kSFXSoundType; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSoundBuffer::~BaseSoundBuffer() { + stop(); + + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + delete _stream; + _stream = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 blockSize) { + _streamed = streamed; +} + + +////////////////////////////////////////////////////////////////////////// +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 = BaseFileManager::getEngineInstance()->openFile(filename, true, false); + if (!_file) { + _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); + return STATUS_FAILED; + } + Common::String strFilename(filename); + strFilename.toLowercase(); + 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 { + 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.c_str()); + } + if (!_stream) { + return STATUS_FAILED; + } + _filename = filename; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::play(bool looping, uint32 startSample) { + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + // Store the loop-value for save-games. + setLooping(looping); + 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 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; +} + +////////////////////////////////////////////////////////////////////////// +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; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::stop() { + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::pause() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); + } + return STATUS_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 BaseSoundBuffer::getLength() { + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) { + _type = type; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::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 BaseSoundBuffer::setPrivateVolume(int volume) { + _privateVolume = volume; + return setVolume(_privateVolume); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::isPlaying() { + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseSoundBuffer::getPosition() { + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setPosition(uint32 pos) { + if (isPlaying()) { + warning("BaseSoundBuffer::SetPosition - not implemented for playing sounds yet."); + } + _startPos = pos; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setPan(float pan) { + if (_handle) { + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + // 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: + 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 index 29402ee76e..9c39f4c34b 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -1,100 +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_BASE_SOUNDBUFFER_H -#define WINTERMUTE_BASE_SOUNDBUFFER_H - - -#include "engines/wintermute/base/base.h" -#include "audio/mixer.h" -#include "common/stream.h" - -namespace Audio { -class SeekableAudioStream; -class SoundHandle; -} - -namespace Wintermute { - -class BaseFile; -class BaseSoundBuffer : public BaseClass { -public: - - BaseSoundBuffer(BaseGame *inGame); - virtual ~BaseSoundBuffer(); - - 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 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); - - //HSTREAM _stream; - //HSYNC _sync; - Audio::SeekableAudioStream *_stream; - Audio::SoundHandle *_handle; - - bool _freezePaused; - uint32 _loopStart; - Audio::Mixer::SoundType _type; - bool _looping; - - int _privateVolume; -private: - uint32 _startPos; - Common::String _filename; - bool _streamed; - Common::SeekableReadStream *_file; - int _volume; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SOUNDBUFFER_H +#define WINTERMUTE_BASE_SOUNDBUFFER_H + + +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/stream.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace Wintermute { + +class BaseFile; +class BaseSoundBuffer : public BaseClass { +public: + + BaseSoundBuffer(BaseGame *inGame); + virtual ~BaseSoundBuffer(); + + 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 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); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + Audio::Mixer::SoundType _type; + bool _looping; + + int _privateVolume; +private: + uint32 _startPos; + Common::String _filename; + bool _streamed; + Common::SeekableReadStream *_file; + 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 index 2bfe0499f9..f7788cd255 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -1,282 +1,282 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_manager.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" -#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(BaseSoundMgr, true); - -////////////////////////////////////////////////////////////////////////// -BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) { - _soundAvailable = false; - _volumeMaster = 255; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSoundMgr::~BaseSoundMgr() { - saveSettings(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::cleanup() { - for (uint32 i = 0; i < _sounds.size(); i++) { - delete _sounds[i]; - } - _sounds.clear(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSoundMgr::saveSettings() { - if (_soundAvailable) { - ConfMan.setInt("master_volume", _volumeMaster); - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::initialize() { - _soundAvailable = false; - - if (!g_system->getMixer()->isReady()) { - return STATUS_FAILED; - } - _volumeMaster = (ConfMan.hasKey("master_volume") ? ConfMan.getInt("master_volume") : 255); - _soundAvailable = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -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")) { - AnsiString path = PathUtil::getDirectoryName(filename); - AnsiString name = PathUtil::getFileNameWithoutExtension(filename); - - AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (BaseFileManager::getEngineInstance()->hasFile(newFile)) { - useFilename = newFile; - } - } - - sound = new BaseSoundBuffer(_gameRef); - if (!sound) { - return NULL; - } - - sound->setStreaming(streamed); - sound->setType(type); - - - bool res = sound->loadFromFile(useFilename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str()); - 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 BaseSoundMgr::addSound(BaseSoundBuffer *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 BaseSoundMgr::removeSound(BaseSoundBuffer *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 BaseSoundMgr::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_engine->syncSoundSettings(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { - return setVolume(type, percent * 255 / 100); -} - - -////////////////////////////////////////////////////////////////////////// -byte BaseSoundMgr::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 BaseSoundMgr::setMasterVolume(byte value) { - _volumeMaster = value; - for (uint32 i = 0; i < _sounds.size(); i++) { - _sounds[i]->updateVolume(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::setMasterVolumePercent(byte percent) { - setMasterVolume(percent * 255 / 100); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte BaseSoundMgr::getMasterVolumePercent() { - return getMasterVolume() * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -byte BaseSoundMgr::getMasterVolume() { - return (byte)_volumeMaster; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::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 BaseSoundMgr::resumeAll() { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->_freezePaused) { - _sounds[i]->resume(); - _sounds[i]->_freezePaused = false; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float BaseSoundMgr::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_manager.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" +#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(BaseSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) { + _soundAvailable = false; + _volumeMaster = 255; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSoundMgr::~BaseSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::cleanup() { + for (uint32 i = 0; i < _sounds.size(); i++) { + delete _sounds[i]; + } + _sounds.clear(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSoundMgr::saveSettings() { + if (_soundAvailable) { + ConfMan.setInt("master_volume", _volumeMaster); + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::initialize() { + _soundAvailable = false; + + if (!g_system->getMixer()->isReady()) { + return STATUS_FAILED; + } + _volumeMaster = (ConfMan.hasKey("master_volume") ? ConfMan.getInt("master_volume") : 255); + _soundAvailable = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +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")) { + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); + + AnsiString newFile = PathUtil::combine(path, name + "ogg"); + if (BaseFileManager::getEngineInstance()->hasFile(newFile)) { + useFilename = newFile; + } + } + + sound = new BaseSoundBuffer(_gameRef); + if (!sound) { + return NULL; + } + + sound->setStreaming(streamed); + sound->setType(type); + + + bool res = sound->loadFromFile(useFilename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str()); + 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 BaseSoundMgr::addSound(BaseSoundBuffer *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 BaseSoundMgr::removeSound(BaseSoundBuffer *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 BaseSoundMgr::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_engine->syncSoundSettings(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); +} + + +////////////////////////////////////////////////////////////////////////// +byte BaseSoundMgr::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 BaseSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (uint32 i = 0; i < _sounds.size(); i++) { + _sounds[i]->updateVolume(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::setMasterVolumePercent(byte percent) { + setMasterVolume(percent * 255 / 100); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte BaseSoundMgr::getMasterVolumePercent() { + return getMasterVolume() * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +byte BaseSoundMgr::getMasterVolume() { + return (byte)_volumeMaster; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::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 BaseSoundMgr::resumeAll() { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->resume(); + _sounds[i]->_freezePaused = false; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float BaseSoundMgr::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 index d0b782b2b7..36a729b5ae 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -1,68 +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_BASE_SOUNDMGR_H -#define WINTERMUTE_BASE_SOUNDMGR_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/base.h" -#include "audio/mixer.h" -#include "common/array.h" - -namespace Wintermute { -class BaseSoundBuffer; -class BaseSoundMgr : public BaseClass { -public: - float posToPan(int x, int y); - bool resumeAll(); - bool pauseAll(bool includingMusic = true); - bool cleanup(); - //DECLARE_PERSISTENT(BaseSoundMgr, BaseClass); - 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(BaseSoundBuffer *sound); - 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; - BaseSoundMgr(BaseGame *inGame); - virtual ~BaseSoundMgr(); - Common::Array _sounds; - void saveSettings(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SOUNDMGR_H +#define WINTERMUTE_BASE_SOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/array.h" + +namespace Wintermute { +class BaseSoundBuffer; +class BaseSoundMgr : public BaseClass { +public: + float posToPan(int x, int y); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); + //DECLARE_PERSISTENT(BaseSoundMgr, BaseClass); + 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(BaseSoundBuffer *sound); + 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; + BaseSoundMgr(BaseGame *inGame); + virtual ~BaseSoundMgr(); + 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 389636cfe6..493ea07015 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -1,86 +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_COLL_TEMPL_H -#define WINTERMUTE_COLL_TEMPL_H - -#include "common/array.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -// Basically Common::Array with peristence-support. -template -class BaseArray : public Common::Array { -public: -// 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); - } - } - return true; - } - int add(TYPE newElement) { - Common::Array::push_back(newElement); - return Common::Array::size() - 1; - } - void remove_at(uint32 idx) { - Common::Array::remove_at(idx); - } - void remove_at(uint32 idx, uint32 num) { - while (num) { - if (idx >= Common::Array::size()) { - break; - } - Common::Array::remove_at(idx); - } - } - template - void copy(const BaseArray &src) { - Common::Array::insert_at(0, src); - } -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 "common/array.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +// Basically Common::Array with peristence-support. +template +class BaseArray : public Common::Array { +public: +// 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); + } + } + return true; + } + int add(TYPE newElement) { + Common::Array::push_back(newElement); + return Common::Array::size() - 1; + } + void remove_at(uint32 idx) { + Common::Array::remove_at(idx); + } + void remove_at(uint32 idx, uint32 num) { + while (num) { + if (idx >= Common::Array::size()) { + break; + } + Common::Array::remove_at(idx); + } + } + template + void copy(const BaseArray &src) { + Common::Array::insert_at(0, src); + } +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 867300e2d3..fc4174094b 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -1,51 +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_DCGF_H -#define WINTERMUTE_DCGF_H - - -////////////////////////////////////////////////////////////////////////// -#define DCGF_VER_MAJOR 1 -#define DCGF_VER_MINOR 1 -#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 1 -#define SAVEGAME_VER_BUILD 1 -////////////////////////////////////////////////////////////////////////// - -#define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 1 +#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 1 +#define SAVEGAME_VER_BUILD 1 +////////////////////////////////////////////////////////////////////////// + +#define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP + +#endif diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index cab54fd144..bd4966eb6b 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -1,225 +1,225 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 "common/str.h" -#include "common/list.h" -#include "common/array.h" - -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 Common::List WideStringList; -typedef Common::List AnsiStringList; - -typedef Common::Array WideStringArray; -typedef Common::Array 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 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 "common/str.h" +#include "common/list.h" +#include "common/array.h" + +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 Common::List WideStringList; +typedef Common::List AnsiStringList; + +typedef Common::Array WideStringArray; +typedef Common::Array 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 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 diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp index 434e0e016b..31af77538a 100644 --- a/engines/wintermute/math/math_util.cpp +++ b/engines/wintermute/math/math_util.cpp @@ -1,52 +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/math/math_util.h" -#include - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -float MathUtil::round(float val) { - float result = floor(val); - if (val - result >= 0.5f) { - 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.5f) { + 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 index 5f13c416d7..38b6d9abf9 100644 --- a/engines/wintermute/math/math_util.h +++ b/engines/wintermute/math/math_util.h @@ -1,42 +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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 diff --git a/engines/wintermute/math/matrix4.cpp b/engines/wintermute/math/matrix4.cpp index e38833d094..ca1eae8813 100644 --- a/engines/wintermute/math/matrix4.cpp +++ b/engines/wintermute/math/matrix4.cpp @@ -1,86 +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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 index c95bd364ff..273633f723 100644 --- a/engines/wintermute/math/matrix4.h +++ b/engines/wintermute/math/matrix4.h @@ -1,50 +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_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); - - float m[4][4]; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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); + + float m[4][4]; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/math/vector2.cpp b/engines/wintermute/math/vector2.cpp index 40c2b346d7..74c5586d62 100644 --- a/engines/wintermute/math/vector2.cpp +++ b/engines/wintermute/math/vector2.cpp @@ -1,55 +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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 index dfed1824f0..31f31daaa0 100644 --- a/engines/wintermute/math/vector2.h +++ b/engines/wintermute/math/vector2.h @@ -1,75 +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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index c50645df95..0bd99b11cd 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -1,262 +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/base/base_game.h" -#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/textconsole.h" -#include "common/system.h" - -namespace Wintermute { - -BaseGame *BasePlatform::_gameRef = NULL; - -#define CLASS_NAME "GF_FRAME" -int BasePlatform::initialize(BaseGame *inGame, int argc, char *argv[]) { - _gameRef = inGame; - return true; -} - -////////////////////////////////////////////////////////////////////////// -void BasePlatform::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; -// 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. -// Originally this was the behaviour for WME Lite on iOS: -// if (_gameRef) { -// _gameRef->AutoSaveOnExit(); -// _gameRef->_quitting = true; -// } - if (_gameRef) { - _gameRef->onWindowClose(); - } - break; - default: - // TODO: Do we care about any other events? - break; - - } -} - - -////////////////////////////////////////////////////////////////////////// -// Win32 API bindings -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::getCursorPos(Point32 *lpPoint) { - BaseRenderOSystem *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 BasePlatform::setCursorPos(int x, int y) { - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - - Point32 p; - p.x = x; - p.y = y; - renderer->pointToScreen(&p); - - g_system->warpMouse(x, y); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::showWindow(int nCmdShow) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -void BasePlatform::setCapture() { - return; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::releaseCapture() { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::setRectEmpty(Rect32 *lprc) { - lprc->left = lprc->right = lprc->top = lprc->bottom = 0; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::isRectEmpty(const Rect32 *lprc) { - return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); -} - -////////////////////////////////////////////////////////////////////////// -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 BasePlatform::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 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) { - 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 BasePlatform::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 BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { - if (lprcDst == NULL || lprcSrc == NULL) { - return false; - } - - *lprcDst = *lprcSrc; - return true; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString BasePlatform::getPlatformName() { - // TODO: Should conform to the WME-spec. - //return AnsiString(SDL_GetPlatform()); - return AnsiString("ScummVM"); -} - -////////////////////////////////////////////////////////////////////////// -char *BasePlatform::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/system.h" + +namespace Wintermute { + +BaseGame *BasePlatform::_gameRef = NULL; + +#define CLASS_NAME "GF_FRAME" +int BasePlatform::initialize(BaseGame *inGame, int argc, char *argv[]) { + _gameRef = inGame; + return true; +} + +////////////////////////////////////////////////////////////////////////// +void BasePlatform::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; +// 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. +// Originally this was the behaviour for WME Lite on iOS: +// if (_gameRef) { +// _gameRef->AutoSaveOnExit(); +// _gameRef->_quitting = true; +// } + if (_gameRef) { + _gameRef->onWindowClose(); + } + break; + default: + // TODO: Do we care about any other events? + break; + + } +} + + +////////////////////////////////////////////////////////////////////////// +// Win32 API bindings +////////////////////////////////////////////////////////////////////////// +bool BasePlatform::getCursorPos(Point32 *lpPoint) { + BaseRenderOSystem *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 BasePlatform::setCursorPos(int x, int y) { + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + Point32 p; + p.x = x; + p.y = y; + renderer->pointToScreen(&p); + + g_system->warpMouse(x, y); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePlatform::showWindow(int nCmdShow) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +void BasePlatform::setCapture() { + return; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePlatform::releaseCapture() { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePlatform::setRectEmpty(Rect32 *lprc) { + lprc->left = lprc->right = lprc->top = lprc->bottom = 0; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePlatform::isRectEmpty(const Rect32 *lprc) { + return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); +} + +////////////////////////////////////////////////////////////////////////// +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 BasePlatform::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 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) { + 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 BasePlatform::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 BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { + if (lprcDst == NULL || lprcSrc == NULL) { + return false; + } + + *lprcDst = *lprcSrc; + return true; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString BasePlatform::getPlatformName() { + // TODO: Should conform to the WME-spec. + //return AnsiString(SDL_GetPlatform()); + return AnsiString("ScummVM"); +} + +////////////////////////////////////////////////////////////////////////// +char *BasePlatform::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 index 9f281c89cd..21a77e0a0e 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -1,73 +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_PLATFORMSDL_H -#define WINTERMUTE_PLATFORMSDL_H - -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/math/rect32.h" -#include "common/events.h" - -namespace Wintermute { - -class BaseGame; - -////////////////////////////////////////////////////////////////////////// -class BasePlatform { -public: - static int initialize(BaseGame *inGame, int argc, char *argv[]); - static void handleEvent(Common::Event *event); - static AnsiString getPlatformName(); - - // Win32 API bindings - static bool getCursorPos(Point32 *lpPoint); - static bool setCursorPos(int x, int y); - static bool showWindow(int nCmdShow); - - static void setCapture(); - static bool releaseCapture(); - - 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); - - // string functions - 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; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 "common/events.h" + +namespace Wintermute { + +class BaseGame; + +////////////////////////////////////////////////////////////////////////// +class BasePlatform { +public: + static int initialize(BaseGame *inGame, int argc, char *argv[]); + static void handleEvent(Common::Event *event); + static AnsiString getPlatformName(); + + // Win32 API bindings + static bool getCursorPos(Point32 *lpPoint); + static bool setCursorPos(int x, int y); + static bool showWindow(int nCmdShow); + + static void setCapture(); + static bool releaseCapture(); + + 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); + + // string functions + 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; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/system/sys_class.cpp b/engines/wintermute/system/sys_class.cpp index bce9a04aec..06b36b84de 100644 --- a/engines/wintermute/system/sys_class.cpp +++ b/engines/wintermute/system/sys_class.cpp @@ -1,220 +1,220 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 { - -////////////////////////////////////////////////////////////////////////// -SystemClass::SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass) { - _name = name; - - _build = build; - _load = load; - _next = NULL; - _savedID = -1; - _persistent = persistentClass; - _numInst = 0; - - SystemClassRegistry::getInstance()->registerClass(this); -} - - -////////////////////////////////////////////////////////////////////////// -SystemClass::~SystemClass() { - SystemClassRegistry::getInstance()->unregisterClass(this); - removeAllInstances(); -} - -////////////////////////////////////////////////////////////////////////// -bool SystemClass::removeAllInstances() { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - delete(it->_value); - } - _instances.clear(); - _instanceMap.clear(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -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; - - SystemClassRegistry::getInstance()->addInstanceToTable(inst, instance); - - return inst; -} - - -////////////////////////////////////////////////////////////////////////// -bool SystemClass::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 SystemClass::getInstanceID(void *pointer) { - InstanceMap::iterator mapIt = _instanceMap.find(pointer); - if (mapIt == _instanceMap.end()) { - return -1; - } else { - return (mapIt->_value)->getID(); - } -} - -////////////////////////////////////////////////////////////////////////// -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(); - } - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -int SystemClass::getNumInstances() { - return _instances.size(); -} - -////////////////////////////////////////////////////////////////////////// -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 SystemClass::saveTable(BaseGame *gameRef, BasePersistenceManager *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 SystemClass::loadTable(BaseGame *gameRef, BasePersistenceManager *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); - 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 - else { - void *emptyObject = _build(); - if (!emptyObject) { - warning("HALT"); - } - - addInstance(emptyObject, SystemClassRegistry::getInstance()->getNextID(), instID); - } - - } -} - -////////////////////////////////////////////////////////////////////////// -void SystemClass::saveInstances(BaseGame *Game, BasePersistenceManager *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 SystemClass::loadInstance(void *instance, BasePersistenceManager *persistMgr) { - _load(instance, persistMgr); -} - - -////////////////////////////////////////////////////////////////////////// -void SystemClass::resetSavedIDs() { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - (it->_value)->setSavedID(-1); - } -} - -////////////////////////////////////////////////////////////////////////// -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); - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 { + +////////////////////////////////////////////////////////////////////////// +SystemClass::SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass) { + _name = name; + + _build = build; + _load = load; + _next = NULL; + _savedID = -1; + _persistent = persistentClass; + _numInst = 0; + + SystemClassRegistry::getInstance()->registerClass(this); +} + + +////////////////////////////////////////////////////////////////////////// +SystemClass::~SystemClass() { + SystemClassRegistry::getInstance()->unregisterClass(this); + removeAllInstances(); +} + +////////////////////////////////////////////////////////////////////////// +bool SystemClass::removeAllInstances() { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + delete(it->_value); + } + _instances.clear(); + _instanceMap.clear(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +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; + + SystemClassRegistry::getInstance()->addInstanceToTable(inst, instance); + + return inst; +} + + +////////////////////////////////////////////////////////////////////////// +bool SystemClass::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 SystemClass::getInstanceID(void *pointer) { + InstanceMap::iterator mapIt = _instanceMap.find(pointer); + if (mapIt == _instanceMap.end()) { + return -1; + } else { + return (mapIt->_value)->getID(); + } +} + +////////////////////////////////////////////////////////////////////////// +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(); + } + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int SystemClass::getNumInstances() { + return _instances.size(); +} + +////////////////////////////////////////////////////////////////////////// +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 SystemClass::saveTable(BaseGame *gameRef, BasePersistenceManager *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 SystemClass::loadTable(BaseGame *gameRef, BasePersistenceManager *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); + 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 + else { + void *emptyObject = _build(); + if (!emptyObject) { + warning("HALT"); + } + + addInstance(emptyObject, SystemClassRegistry::getInstance()->getNextID(), instID); + } + + } +} + +////////////////////////////////////////////////////////////////////////// +void SystemClass::saveInstances(BaseGame *Game, BasePersistenceManager *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 SystemClass::loadInstance(void *instance, BasePersistenceManager *persistMgr) { + _load(instance, persistMgr); +} + + +////////////////////////////////////////////////////////////////////////// +void SystemClass::resetSavedIDs() { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + (it->_value)->setSavedID(-1); + } +} + +////////////////////////////////////////////////////////////////////////// +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); + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/system/sys_class.h b/engines/wintermute/system/sys_class.h index 28d718bb47..3f91723ed8 100644 --- a/engines/wintermute/system/sys_class.h +++ b/engines/wintermute/system/sys_class.h @@ -1,130 +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 SystemInstance; -class BaseGame; -class BasePersistenceManager; -class SystemClass; - -} - -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::SystemInstance *val) const { - return (uint)((size_t)val); - } -}; - - -} - -namespace Wintermute { - -class SystemClass { -public: - SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass); - ~SystemClass(); - - int getNumInstances(); - bool removeInstance(void *instance); - SystemInstance *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(BaseGame *Game, BasePersistenceManager *PersistMgr); - void loadTable(BaseGame *Game, BasePersistenceManager *PersistMgr); - - void saveInstances(BaseGame *Game, BasePersistenceManager *PersistMgr); - void loadInstance(void *instance, BasePersistenceManager *PersistMgr); - - void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); - - void resetSavedIDs(); - - void dump(Common::WriteStream *stream); - -private: - int _numInst; - bool _persistent; - SystemClass *_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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SystemInstance; +class BaseGame; +class BasePersistenceManager; +class SystemClass; + +} + +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::SystemInstance *val) const { + return (uint)((size_t)val); + } +}; + + +} + +namespace Wintermute { + +class SystemClass { +public: + SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass); + ~SystemClass(); + + int getNumInstances(); + bool removeInstance(void *instance); + SystemInstance *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(BaseGame *Game, BasePersistenceManager *PersistMgr); + void loadTable(BaseGame *Game, BasePersistenceManager *PersistMgr); + + void saveInstances(BaseGame *Game, BasePersistenceManager *PersistMgr); + void loadInstance(void *instance, BasePersistenceManager *PersistMgr); + + void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); + + void resetSavedIDs(); + + void dump(Common::WriteStream *stream); + +private: + int _numInst; + bool _persistent; + SystemClass *_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 index d836b32635..5e3b968c5c 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -1,335 +1,335 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 { - -////////////////////////////////////////////////////////////////////////// -SystemClassRegistry::SystemClassRegistry() { - _count = 0; - _disabled = false; -} - - -////////////////////////////////////////////////////////////////////////// -SystemClassRegistry::~SystemClassRegistry() { - unregisterClasses(); -} - -////////////////////////////////////////////////////////////////////////// -SystemClassRegistry *SystemClassRegistry::getInstance() { - return BaseEngine::instance().getClassRegistry(); -} - -void SystemClassRegistry::unregisterClasses() { - // SystemClass calls UnregisterClass upon destruction. - while (_classes.size() > 0) { - delete _classes.begin()->_value; - } -} - -////////////////////////////////////////////////////////////////////////// -bool SystemClassRegistry::registerClass(SystemClass *classObj) { - classObj->setID(_count++); - //_classes.insert(classObj); - _classes[classObj] = classObj; - - _nameMap[classObj->getName()] = classObj; - _idMap[classObj->getID()] = classObj; - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { - - Classes::iterator it = _classes.find(classObj); - if (it == _classes.end()) { - return false; - } - - if (classObj->getNumInstances() != 0) { - debugC(Wintermute::kWintermuteDebugSaveGame, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); - } - _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 SystemClassRegistry::registerInstance(const char *className, void *instance) { - if (_disabled) { - return true; - } - - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) { - return false; - } - - SystemInstance *inst = (*mapIt)._value->addInstance(instance, _count++); - return (inst != NULL); -} - -////////////////////////////////////////////////////////////////////////// -void SystemClassRegistry::addInstanceToTable(SystemInstance *instance, void *pointer) { - _instanceMap[pointer] = instance; - - if (instance->getSavedID() >= 0) { - _savedInstanceMap[instance->getSavedID()] = instance; - } -} - -////////////////////////////////////////////////////////////////////////// -int SystemClassRegistry::getNextID() { - return _count++; -} - -////////////////////////////////////////////////////////////////////////// -bool SystemClassRegistry::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 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; - } - - - SystemInstance *inst = (*it)._value; - *instanceID = inst->getID(); - *classID = inst->getClass()->getID(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -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, BasePersistenceManager *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 SystemClassRegistry::saveTable(BaseGame *gameRef, BasePersistenceManager *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->_renderer->setIndicatorVal((int)(50.0f / (float)((float)_classes.size() / (float)counter))); - } - - (it->_value)->saveTable(gameRef, persistMgr); - } - persistMgr->putString(""); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *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->_renderer->setIndicatorVal((int)(50.0f / (float)((float)numClasses / (float)i))); - - 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 SystemClassRegistry::saveInstances(BaseGame *gameRef, BasePersistenceManager *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->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter))); - } - } - gameRef->miniUpdate(); - - (it->_value)->saveInstances(gameRef, persistMgr); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool SystemClassRegistry::loadInstances(BaseGame *gameRef, BasePersistenceManager *persistMgr) { - // get total instances - int numInstances = persistMgr->getDWORD(); - - for (int i = 0; i < numInstances; i++) { - if (i % 20 == 0) { - gameRef->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)numInstances / (float)i))); - } - - 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 SystemClassRegistry::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 SystemClassRegistry::dumpClasses(Common::WriteStream *stream) { - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - (it->_value)->dump(stream); - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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 { + +////////////////////////////////////////////////////////////////////////// +SystemClassRegistry::SystemClassRegistry() { + _count = 0; + _disabled = false; +} + + +////////////////////////////////////////////////////////////////////////// +SystemClassRegistry::~SystemClassRegistry() { + unregisterClasses(); +} + +////////////////////////////////////////////////////////////////////////// +SystemClassRegistry *SystemClassRegistry::getInstance() { + return BaseEngine::instance().getClassRegistry(); +} + +void SystemClassRegistry::unregisterClasses() { + // SystemClass calls UnregisterClass upon destruction. + while (_classes.size() > 0) { + delete _classes.begin()->_value; + } +} + +////////////////////////////////////////////////////////////////////////// +bool SystemClassRegistry::registerClass(SystemClass *classObj) { + classObj->setID(_count++); + //_classes.insert(classObj); + _classes[classObj] = classObj; + + _nameMap[classObj->getName()] = classObj; + _idMap[classObj->getID()] = classObj; + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { + + Classes::iterator it = _classes.find(classObj); + if (it == _classes.end()) { + return false; + } + + if (classObj->getNumInstances() != 0) { + debugC(Wintermute::kWintermuteDebugSaveGame, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); + } + _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 SystemClassRegistry::registerInstance(const char *className, void *instance) { + if (_disabled) { + return true; + } + + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) { + return false; + } + + SystemInstance *inst = (*mapIt)._value->addInstance(instance, _count++); + return (inst != NULL); +} + +////////////////////////////////////////////////////////////////////////// +void SystemClassRegistry::addInstanceToTable(SystemInstance *instance, void *pointer) { + _instanceMap[pointer] = instance; + + if (instance->getSavedID() >= 0) { + _savedInstanceMap[instance->getSavedID()] = instance; + } +} + +////////////////////////////////////////////////////////////////////////// +int SystemClassRegistry::getNextID() { + return _count++; +} + +////////////////////////////////////////////////////////////////////////// +bool SystemClassRegistry::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 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; + } + + + SystemInstance *inst = (*it)._value; + *instanceID = inst->getID(); + *classID = inst->getClass()->getID(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +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, BasePersistenceManager *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 SystemClassRegistry::saveTable(BaseGame *gameRef, BasePersistenceManager *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->_renderer->setIndicatorVal((int)(50.0f / (float)((float)_classes.size() / (float)counter))); + } + + (it->_value)->saveTable(gameRef, persistMgr); + } + persistMgr->putString(""); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *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->_renderer->setIndicatorVal((int)(50.0f / (float)((float)numClasses / (float)i))); + + 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 SystemClassRegistry::saveInstances(BaseGame *gameRef, BasePersistenceManager *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->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter))); + } + } + gameRef->miniUpdate(); + + (it->_value)->saveInstances(gameRef, persistMgr); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool SystemClassRegistry::loadInstances(BaseGame *gameRef, BasePersistenceManager *persistMgr) { + // get total instances + int numInstances = persistMgr->getDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (i % 20 == 0) { + gameRef->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)numInstances / (float)i))); + } + + 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 SystemClassRegistry::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 SystemClassRegistry::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 index e612ab3e82..ef7218c7c1 100644 --- a/engines/wintermute/system/sys_class_registry.h +++ b/engines/wintermute/system/sys_class_registry.h @@ -1,106 +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/system/sys_class.h" -#include "common/hashmap.h" -#include "common/hash-str.h" -#include "common/func.h" -#include "common/stream.h" - -namespace Wintermute { -class SystemClass; -} - -namespace Common { -template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(Wintermute::SystemClass *val) const { - return (uint)((size_t)val); - } -}; - -} - -namespace Wintermute { - -class BaseGame; -class BasePersistenceManager; -class SystemInstance; - -class SystemClassRegistry { - void unregisterClasses(); -public: - void registerClasses(); // persistent.cpp - static SystemClassRegistry *getInstance(); - - SystemClassRegistry(); - virtual ~SystemClassRegistry(); - - bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - bool loadTable(BaseGame *Game, BasePersistenceManager *PersistMgr); - bool saveTable(BaseGame *Game, BasePersistenceManager *PersistMgr, bool quickSave); - bool loadInstances(BaseGame *Game, BasePersistenceManager *PersistMgr); - bool saveInstances(BaseGame *Game, BasePersistenceManager *PersistMgr, bool quickSave); - void *idToPointer(int classID, int instanceID); - bool getPointerID(void *pointer, int *classID, int *instanceID); - bool registerClass(SystemClass *classObj); - bool unregisterClass(SystemClass *classObj); - bool registerInstance(const char *className, void *instance); - bool unregisterInstance(const char *className, void *instance); - void dumpClasses(Common::WriteStream *stream); - int getNextID(); - void addInstanceToTable(SystemInstance *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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/system/sys_class.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/func.h" +#include "common/stream.h" + +namespace Wintermute { +class SystemClass; +} + +namespace Common { +template struct Hash; +template<> struct Hash : public UnaryFunction { + uint operator()(Wintermute::SystemClass *val) const { + return (uint)((size_t)val); + } +}; + +} + +namespace Wintermute { + +class BaseGame; +class BasePersistenceManager; +class SystemInstance; + +class SystemClassRegistry { + void unregisterClasses(); +public: + void registerClasses(); // persistent.cpp + static SystemClassRegistry *getInstance(); + + SystemClassRegistry(); + virtual ~SystemClassRegistry(); + + bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + bool loadTable(BaseGame *Game, BasePersistenceManager *PersistMgr); + bool saveTable(BaseGame *Game, BasePersistenceManager *PersistMgr, bool quickSave); + bool loadInstances(BaseGame *Game, BasePersistenceManager *PersistMgr); + bool saveInstances(BaseGame *Game, BasePersistenceManager *PersistMgr, bool quickSave); + void *idToPointer(int classID, int instanceID); + bool getPointerID(void *pointer, int *classID, int *instanceID); + bool registerClass(SystemClass *classObj); + bool unregisterClass(SystemClass *classObj); + bool registerInstance(const char *className, void *instance); + bool unregisterInstance(const char *className, void *instance); + void dumpClasses(Common::WriteStream *stream); + int getNextID(); + void addInstanceToTable(SystemInstance *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 index 1323382152..d106119dba 100644 --- a/engines/wintermute/system/sys_instance.cpp +++ b/engines/wintermute/system/sys_instance.cpp @@ -1,49 +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 { - -////////////////////////////////////////////////////////////////////////// -SystemInstance::SystemInstance(void *instance, int id, SystemClass *sysClass) { - _instance = instance; - _id = id; - _savedID = -1; - _class = sysClass; - - _used = false; -} - -////////////////////////////////////////////////////////////////////////// -SystemInstance::~SystemInstance() { -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 { + +////////////////////////////////////////////////////////////////////////// +SystemInstance::SystemInstance(void *instance, int id, SystemClass *sysClass) { + _instance = instance; + _id = id; + _savedID = -1; + _class = sysClass; + + _used = false; +} + +////////////////////////////////////////////////////////////////////////// +SystemInstance::~SystemInstance() { +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/system/sys_instance.h b/engines/wintermute/system/sys_instance.h index 78eb27c122..215a6d1437 100644 --- a/engines/wintermute/system/sys_instance.h +++ b/engines/wintermute/system/sys_instance.h @@ -1,68 +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 SystemClass; - -class SystemInstance { -public: - SystemInstance(void *instance, int id, SystemClass *sysClass); - virtual ~SystemInstance(); - - int getID() const { - return _id; - } - int getSavedID() const { - return _savedID; - } - void *getInstance() const { - return _instance; - } - SystemClass *getClass() const { - return _class; - } - - void setSavedID(int id) { - _savedID = id; - } - -private: - bool _used; - int _id; - int _savedID; - void *_instance; - SystemClass *_class; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 SystemClass; + +class SystemInstance { +public: + SystemInstance(void *instance, int id, SystemClass *sysClass); + virtual ~SystemInstance(); + + int getID() const { + return _id; + } + int getSavedID() const { + return _savedID; + } + void *getInstance() const { + return _instance; + } + SystemClass *getClass() const { + return _class; + } + + void setSavedID(int id) { + _savedID = id; + } + +private: + bool _used; + int _id; + int _savedID; + void *_instance; + SystemClass *_class; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index c5ca63081c..f2ac5b2fdd 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1,1208 +1,1208 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_stack.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(UIButton, false) - -////////////////////////////////////////////////////////////////////////// -UIButton::UIButton(BaseGame *inGame) : UIObject(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; -} - - -////////////////////////////////////////////////////////////////////////// -UIButton::~UIButton() { - 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 UIButton::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 UIButton::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; - BaseParser parser; - - 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 UITiledImage(_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 UITiledImage(_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 UITiledImage(_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 UITiledImage(_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 UITiledImage(_gameRef); - if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { - delete _backFocus; - _backFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "BUTTON\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - 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"); - - 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("UIButton::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 (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -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 (_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 UIButton::display(int offsetX, int offsetY) { - if (!_visible) { - return STATUS_OK; - } - - UITiledImage *back = NULL; - BaseSprite *image = NULL; - BaseFont *font = 0; - - //RECT rect; - //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 && g_system->getMillis() - _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->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(); - } - - _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void UIButton::press() { - applyEvent("Press"); - if (_listenerObject) { - _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); - } - if (_parentNotify && _parent) { - _parent->applyEvent(getName()); - } - - _oneTimePress = false; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetDisabledFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetDisabledFont") == 0) { - stack->correctParams(1); - ScValue *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); - ScValue *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); - ScValue *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); - ScValue *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 BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_imageDisable->getFilename()); - } - - 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 BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_imageHover->getFilename()); - } - - 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 BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_imagePress->getFilename()); - } - - 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 BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_imageFocus->getFilename()); - } - - 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 = g_system->getMillis(); - } - stack->pushNULL(); - - return STATUS_OK; - } else { - return UIObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *UIButton::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 UIObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIButton::scSetProperty(const char *name, ScValue *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 UIObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *UIButton::scToString() { - return "[button]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIButton::persist(BasePersistenceManager *persistMgr) { - - UIObject::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->getIsSaving()) { - _oneTimePress = false; - _oneTimePressTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(UIButton, false) + +////////////////////////////////////////////////////////////////////////// +UIButton::UIButton(BaseGame *inGame) : UIObject(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; +} + + +////////////////////////////////////////////////////////////////////////// +UIButton::~UIButton() { + 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 UIButton::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 UIButton::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; + BaseParser parser; + + 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 UITiledImage(_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 UITiledImage(_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 UITiledImage(_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 UITiledImage(_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 UITiledImage(_gameRef); + if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { + delete _backFocus; + _backFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 BaseSprite(_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 UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "BUTTON\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + 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"); + + 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("UIButton::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 (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +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 (_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 UIButton::display(int offsetX, int offsetY) { + if (!_visible) { + return STATUS_OK; + } + + UITiledImage *back = NULL; + BaseSprite *image = NULL; + BaseFont *font = 0; + + //RECT rect; + //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 && g_system->getMillis() - _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->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(); + } + + _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void UIButton::press() { + applyEvent("Press"); + if (_listenerObject) { + _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); + } + if (_parentNotify && _parent) { + _parent->applyEvent(getName()); + } + + _oneTimePress = false; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetDisabledFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetDisabledFont") == 0) { + stack->correctParams(1); + ScValue *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); + ScValue *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); + ScValue *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); + ScValue *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 BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageDisable->getFilename()); + } + + 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 BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageHover->getFilename()); + } + + 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 BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imagePress->getFilename()); + } + + 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 BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageFocus->getFilename()); + } + + 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 = g_system->getMillis(); + } + stack->pushNULL(); + + return STATUS_OK; + } else { + return UIObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *UIButton::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 UIObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIButton::scSetProperty(const char *name, ScValue *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 UIObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *UIButton::scToString() { + return "[button]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIButton::persist(BasePersistenceManager *persistMgr) { + + UIObject::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->getIsSaving()) { + _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 index 88ba8dafc7..9342f766cc 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -1,80 +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_UIBUTTON_H -#define WINTERMUTE_UIBUTTON_H - - -#include "engines/wintermute/ui/ui_object.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace Wintermute { - -class UIButton : public UIObject { -public: - bool _pixelPerfect; - bool _stayPressed; - bool _centerImage; - bool _oneTimePress; - uint32 _oneTimePressTime; - DECLARE_PERSISTENT(UIButton, UIObject) - void press(); - virtual bool display() { return display(0, 0); } - virtual bool display(int offsetX, int offsetY); - bool _press; - bool _hover; - void correctSize(); - TTextAlign _align; - 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(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIButton : public UIObject { +public: + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + uint32 _oneTimePressTime; + DECLARE_PERSISTENT(UIButton, UIObject) + void press(); + virtual bool display() { return display(0, 0); } + virtual bool display(int offsetX, int offsetY); + bool _press; + bool _hover; + void correctSize(); + TTextAlign _align; + 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(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 2ea44cd64c..94d11255ce 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -1,951 +1,951 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(UIEdit, false) - -////////////////////////////////////////////////////////////////////////// -UIEdit::UIEdit(BaseGame *inGame) : UIObject(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; -} - - -////////////////////////////////////////////////////////////////////////// -UIEdit::~UIEdit() { - if (!_sharedFonts) { - if (_fontSelected) { - _gameRef->_fontStorage->removeFont(_fontSelected); - } - } - - delete[] _cursorChar; - _cursorChar = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIEdit::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 UIEdit::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; - BaseParser parser; - - 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 UITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new BaseSprite(_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 BaseSprite(_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 UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "EDIT\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->getFilename()) { - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); - } - - if (_image && _image->getFilename()) { - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); - } - - 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->getFilename()) { - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); - } - - 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 (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool UIEdit::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 UIObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *UIEdit::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 UIObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIEdit::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SelStart") == 0) { - _selStart = value->getInt(); - _selStart = MAX(_selStart, 0); - _selStart = (int)MIN((size_t)_selStart, strlen(_text)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelEnd") == 0) { - _selEnd = value->getInt(); - _selEnd = MAX(_selEnd, 0); - _selEnd = (int)MIN((size_t)_selEnd, strlen(_text)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = (uint32)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 UIObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *UIEdit::scToString() { - return "[edit]"; -} - - -////////////////////////////////////////////////////////////////////////// -void UIEdit::setCursorChar(const char *character) { - if (!character) { - return; - } - delete[] _cursorChar; - _cursorChar = new char [strlen(character) + 1]; - if (_cursorChar) { - strcpy(_cursorChar, character); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIEdit::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 - BaseFont *font; - BaseFont *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 = (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); - - 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 (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = g_system->getMillis(); - _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 (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = g_system->getMillis(); - _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->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); - - - _gameRef->_textEncoding = OrigEncoding; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIEdit::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 (BaseKeyboardState::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 (!BaseKeyboardState::isShiftDown()) { - _selStart = _selEnd; - } - handled = true; - break; - - case Common::KEYCODE_RIGHT: - case Common::KEYCODE_DOWN: - _selEnd++; - if (!BaseKeyboardState::isShiftDown()) { - _selStart = _selEnd; - } - handled = true; - break; - - case Common::KEYCODE_HOME: - if (_gameRef->_textRTL) { - _selEnd = strlen(_text); - if (!BaseKeyboardState::isShiftDown()) { - _selStart = _selEnd; - } - } else { - _selEnd = 0; - if (!BaseKeyboardState::isShiftDown()) { - _selStart = _selEnd; - } - } - handled = true; - break; - - case Common::KEYCODE_END: - if (_gameRef->_textRTL) { - _selEnd = 0; - if (!BaseKeyboardState::isShiftDown()) { - _selStart = _selEnd; - } - } else { - _selEnd = strlen(_text); - if (!BaseKeyboardState::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, (const byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); - - if (_gameRef->_textRTL) { - _selEnd = _selStart; - } else { - _selStart = _selEnd; - } - - return true; - } - - return false; -} - - - -////////////////////////////////////////////////////////////////////////// -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)); - - 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(getName()); - } - - return end - start; -} - - -////////////////////////////////////////////////////////////////////////// -int UIEdit::insertChars(int pos, const 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(getName()); - } - - return num; -} - - - -////////////////////////////////////////////////////////////////////////// -bool UIEdit::persist(BasePersistenceManager *persistMgr) { - - UIObject::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->getIsSaving()) { - _cursorVisible = false; - _lastBlinkTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/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(UIEdit, false) + +////////////////////////////////////////////////////////////////////////// +UIEdit::UIEdit(BaseGame *inGame) : UIObject(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; +} + + +////////////////////////////////////////////////////////////////////////// +UIEdit::~UIEdit() { + if (!_sharedFonts) { + if (_fontSelected) { + _gameRef->_fontStorage->removeFont(_fontSelected); + } + } + + delete[] _cursorChar; + _cursorChar = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIEdit::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 UIEdit::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; + BaseParser parser; + + 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 UITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new BaseSprite(_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 BaseSprite(_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 UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "EDIT\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->getFilename()) { + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); + } + + if (_image && _image->getFilename()) { + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); + } + + 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->getFilename()) { + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } + + 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 (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool UIEdit::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 UIObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *UIEdit::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 UIObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIEdit::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SelStart") == 0) { + _selStart = value->getInt(); + _selStart = MAX(_selStart, 0); + _selStart = (int)MIN((size_t)_selStart, strlen(_text)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelEnd") == 0) { + _selEnd = value->getInt(); + _selEnd = MAX(_selEnd, 0); + _selEnd = (int)MIN((size_t)_selEnd, strlen(_text)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorBlinkRate") == 0) { + _cursorBlinkRate = (uint32)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 UIObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *UIEdit::scToString() { + return "[edit]"; +} + + +////////////////////////////////////////////////////////////////////////// +void UIEdit::setCursorChar(const char *character) { + if (!character) { + return; + } + delete[] _cursorChar; + _cursorChar = new char [strlen(character) + 1]; + if (_cursorChar) { + strcpy(_cursorChar, character); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIEdit::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 + BaseFont *font; + BaseFont *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 = (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); + + 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 (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = g_system->getMillis(); + _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 (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = g_system->getMillis(); + _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->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + + + _gameRef->_textEncoding = OrigEncoding; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIEdit::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 (BaseKeyboardState::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 (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } + handled = true; + break; + + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_DOWN: + _selEnd++; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } + handled = true; + break; + + case Common::KEYCODE_HOME: + if (_gameRef->_textRTL) { + _selEnd = strlen(_text); + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } + } else { + _selEnd = 0; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } + } + handled = true; + break; + + case Common::KEYCODE_END: + if (_gameRef->_textRTL) { + _selEnd = 0; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } + } else { + _selEnd = strlen(_text); + if (!BaseKeyboardState::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, (const byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); + + if (_gameRef->_textRTL) { + _selEnd = _selStart; + } else { + _selStart = _selEnd; + } + + return true; + } + + return false; +} + + + +////////////////////////////////////////////////////////////////////////// +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)); + + 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(getName()); + } + + return end - start; +} + + +////////////////////////////////////////////////////////////////////////// +int UIEdit::insertChars(int pos, const 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(getName()); + } + + return num; +} + + + +////////////////////////////////////////////////////////////////////////// +bool UIEdit::persist(BasePersistenceManager *persistMgr) { + + UIObject::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->getIsSaving()) { + _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 index fa760951b0..610629afb3 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -1,72 +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 BaseFont; -class UIEdit : public UIObject { -public: - DECLARE_PERSISTENT(UIEdit, UIObject) - int _maxLength; - int insertChars(int pos, const 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; - BaseFont *_fontSelected; - UIEdit(BaseGame *inGame); - virtual ~UIEdit(); - - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 BaseFont; +class UIEdit : public UIObject { +public: + DECLARE_PERSISTENT(UIEdit, UIObject) + int _maxLength; + int insertChars(int pos, const 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; + BaseFont *_fontSelected; + UIEdit(BaseGame *inGame); + virtual ~UIEdit(); + + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 18a4db124a..c49cb5a240 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -1,366 +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/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(UIEntity, false) - -////////////////////////////////////////////////////////////////////////// -UIEntity::UIEntity(BaseGame *inGame) : UIObject(inGame) { - _type = UI_CUSTOM; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -UIEntity::~UIEntity() { - if (_entity) { - _gameRef->unregisterObject(_entity); - } - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIEntity::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 UIEntity::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; - BaseParser parser; - - 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 UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - - 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->getFilename()) { - buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->getFilename()); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool UIEntity::setEntity(const char *filename) { - if (_entity) { - _gameRef->unregisterObject(_entity); - } - _entity = new AdEntity(_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 UIEntity::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 UIEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 UIObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *UIEntity::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 UIObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -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 UIObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *UIEntity::scToString() { - return "[entity container]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIEntity::persist(BasePersistenceManager *persistMgr) { - - UIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_entity)); - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(UIEntity, false) + +////////////////////////////////////////////////////////////////////////// +UIEntity::UIEntity(BaseGame *inGame) : UIObject(inGame) { + _type = UI_CUSTOM; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +UIEntity::~UIEntity() { + if (_entity) { + _gameRef->unregisterObject(_entity); + } + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIEntity::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 UIEntity::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; + BaseParser parser; + + 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 UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + + 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->getFilename()) { + buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->getFilename()); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool UIEntity::setEntity(const char *filename) { + if (_entity) { + _gameRef->unregisterObject(_entity); + } + _entity = new AdEntity(_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 UIEntity::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 UIEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 UIObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *UIEntity::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 UIObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +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 UIObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *UIEntity::scToString() { + return "[entity container]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIEntity::persist(BasePersistenceManager *persistMgr) { + + UIObject::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 index aeb32a6ffb..3bf8068fd5 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -1,59 +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_UIENTITY_H -#define WINTERMUTE_UIENTITY_H - -#include "engines/wintermute/ui/ui_object.h" - -namespace Wintermute { -class AdEntity; -class UIEntity : public UIObject { -public: - DECLARE_PERSISTENT(UIEntity, UIObject) - UIEntity(BaseGame *inGame); - virtual ~UIEntity(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - virtual bool display() { return display(0, 0); } - virtual bool display(int offsetX, int offsetY); - AdEntity *_entity; - bool setEntity(const char *filename); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 AdEntity; +class UIEntity : public UIObject { +public: + DECLARE_PERSISTENT(UIEntity, UIObject) + UIEntity(BaseGame *inGame); + virtual ~UIEntity(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + virtual bool display() { return display(0, 0); } + virtual bool display(int offsetX, int offsetY); + AdEntity *_entity; + bool setEntity(const char *filename); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 716570fd67..85e381c55b 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -1,650 +1,650 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(UIObject, false) - -////////////////////////////////////////////////////////////////////////// -UIObject::UIObject(BaseGame *inGame) : BaseObject(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; -} - - -////////////////////////////////////////////////////////////////////////// -UIObject::~UIObject() { - if (!_gameRef->_loadInProgress) { - SystemClassRegistry::getInstance()->enumInstances(BaseGame::invalidateValues, "ScValue", (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 UIObject::setText(const char *text) { - if (_text) { - delete[] _text; - } - _text = new char [strlen(text) + 1]; - if (_text) { - strcpy(_text, text); - for (uint32 i = 0; i < strlen(_text); i++) { - if (_text[i] == '|') { - _text[i] = '\n'; - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIObject::display(int offsetX, int offsetY) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void UIObject::setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam) { - _listenerObject = object; - _listenerParamObject = listenerObject; - _listenerParamDWORD = listenerParam; -} - - -////////////////////////////////////////////////////////////////////////// -void UIObject::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 UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFont") == 0) { - stack->correctParams(1); - ScValue *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); - ScValue *val = stack->pop(); - - /* const char *filename = */ val->getString(); - - delete _image; - _image = NULL; - if (val->isNULL()) { - stack->pushBool(true); - return STATUS_OK; - } - - _image = new BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_image->getFilename()); - } - - 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) { - UIWindow *win = (UIWindow *)_parent; - - 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.size(); i++) { - if (win->_widgets[i] == widget) { - found = true; - break; - } - } - } - // find by name - else { - const char *findName = val->getString(); - for (i = 0; i < win->_widgets.size(); i++) { - if (scumm_stricmp(win->_widgets[i]->getName(), findName) == 0) { - found = true; - break; - } - } - } - - if (found) { - bool done = false; - for (uint32 j = 0; j < win->_widgets.size(); j++) { - if (win->_widgets[j] == this) { - if (strcmp(name, "MoveAfter") == 0) { - i++; - } - if (j >= i) { - j++; - } - - win->_widgets.insert_at(i, this); - win->_widgets.remove_at(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) { - UIWindow *win = (UIWindow *)_parent; - 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); - 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) { - UIWindow *win = (UIWindow *)_parent; - for (uint32 i = 0; i < win->_widgets.size(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.remove_at(i); - win->_widgets.add(this); - break; - } - } - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *UIObject::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(getName()); - 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) { - UIWindow *win = (UIWindow *)_parent; - for (uint32 i = 0; i < win->_widgets.size(); i++) { - if (win->_widgets[i] == this) { - if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.size() - 1) { - _scValue->setNative(win->_widgets[i + 1], true); - } - } else { - if (i > 0) { - _scValue->setNative(win->_widgets[i - 1], true); - } - } - break; - } - } - } - return _scValue; - } else { - return BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIObject::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *UIObject::scToString() { - return "[ui_object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIObject::isFocused() { - 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; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIObject::handleMouse(TMouseEvent event, TMouseButton button) { - // handle focus change - if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - focus(); - } - return BaseObject::handleMouse(event, button); -} - - -////////////////////////////////////////////////////////////////////////// -bool UIObject::focus() { - UIObject *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((UIWindow *)obj); - } - } - - obj = obj->_parent; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIObject::getTotalOffset(int *offsetX, int *offsetY) { - int offX = 0, offY = 0; - - UIObject *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 UIObject::persist(BasePersistenceManager *persistMgr) { - - BaseObject::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 UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { - return STATUS_FAILED; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(UIObject, false) + +////////////////////////////////////////////////////////////////////////// +UIObject::UIObject(BaseGame *inGame) : BaseObject(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; +} + + +////////////////////////////////////////////////////////////////////////// +UIObject::~UIObject() { + if (!_gameRef->_loadInProgress) { + SystemClassRegistry::getInstance()->enumInstances(BaseGame::invalidateValues, "ScValue", (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 UIObject::setText(const char *text) { + if (_text) { + delete[] _text; + } + _text = new char [strlen(text) + 1]; + if (_text) { + strcpy(_text, text); + for (uint32 i = 0; i < strlen(_text); i++) { + if (_text[i] == '|') { + _text[i] = '\n'; + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIObject::display(int offsetX, int offsetY) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void UIObject::setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam) { + _listenerObject = object; + _listenerParamObject = listenerObject; + _listenerParamDWORD = listenerParam; +} + + +////////////////////////////////////////////////////////////////////////// +void UIObject::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 UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFont") == 0) { + stack->correctParams(1); + ScValue *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); + ScValue *val = stack->pop(); + + /* const char *filename = */ val->getString(); + + delete _image; + _image = NULL; + if (val->isNULL()) { + stack->pushBool(true); + return STATUS_OK; + } + + _image = new BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_image->getFilename()); + } + + 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) { + UIWindow *win = (UIWindow *)_parent; + + 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.size(); i++) { + if (win->_widgets[i] == widget) { + found = true; + break; + } + } + } + // find by name + else { + const char *findName = val->getString(); + for (i = 0; i < win->_widgets.size(); i++) { + if (scumm_stricmp(win->_widgets[i]->getName(), findName) == 0) { + found = true; + break; + } + } + } + + if (found) { + bool done = false; + for (uint32 j = 0; j < win->_widgets.size(); j++) { + if (win->_widgets[j] == this) { + if (strcmp(name, "MoveAfter") == 0) { + i++; + } + if (j >= i) { + j++; + } + + win->_widgets.insert_at(i, this); + win->_widgets.remove_at(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) { + UIWindow *win = (UIWindow *)_parent; + 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); + 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) { + UIWindow *win = (UIWindow *)_parent; + for (uint32 i = 0; i < win->_widgets.size(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.remove_at(i); + win->_widgets.add(this); + break; + } + } + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *UIObject::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(getName()); + 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) { + UIWindow *win = (UIWindow *)_parent; + for (uint32 i = 0; i < win->_widgets.size(); i++) { + if (win->_widgets[i] == this) { + if (strcmp(name, "NextSibling") == 0) { + if (i < win->_widgets.size() - 1) { + _scValue->setNative(win->_widgets[i + 1], true); + } + } else { + if (i > 0) { + _scValue->setNative(win->_widgets[i - 1], true); + } + } + break; + } + } + } + return _scValue; + } else { + return BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIObject::scSetProperty(const char *name, ScValue *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 BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *UIObject::scToString() { + return "[ui_object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIObject::isFocused() { + 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; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIObject::handleMouse(TMouseEvent event, TMouseButton button) { + // handle focus change + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + focus(); + } + return BaseObject::handleMouse(event, button); +} + + +////////////////////////////////////////////////////////////////////////// +bool UIObject::focus() { + UIObject *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((UIWindow *)obj); + } + } + + obj = obj->_parent; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIObject::getTotalOffset(int *offsetX, int *offsetY) { + int offX = 0, offY = 0; + + UIObject *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 UIObject::persist(BasePersistenceManager *persistMgr) { + + BaseObject::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 UIObject::saveAsText(BaseDynamicBuffer *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 index b0a34fe61e..81c025d33b 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -1,85 +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_UIOBJECT_H -#define WINTERMUTE_UIOBJECT_H - - -#include "engines/wintermute/base/base_object.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace Wintermute { - -class UITiledImage; -class BaseFont; -class UIObject : public BaseObject { -public: - - bool getTotalOffset(int *offsetX, int *offsetY); - bool _canFocus; - bool focus(); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - bool isFocused(); - bool _parentNotify; - DECLARE_PERSISTENT(UIObject, BaseObject) - UIObject *_parent; - virtual bool display() { return display(0, 0); } - virtual bool display(int offsetX) { return display(offsetX, 0); } - virtual bool display(int offsetX, int offsetY); - virtual void correctSize(); - bool _sharedFonts; - bool _sharedImages; - void setText(const char *text); - char *_text; - BaseFont *_font; - bool _visible; - UITiledImage *_back; - bool _disable; - UIObject(BaseGame *inGame = NULL); - virtual ~UIObject(); - int _width; - int _height; - TUIObjectType _type; - BaseSprite *_image; - void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); - BaseScriptHolder *_listenerParamObject; - uint32 _listenerParamDWORD; - BaseScriptHolder *_listenerObject; - UIObject *_focusedWidget; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UITiledImage; +class BaseFont; +class UIObject : public BaseObject { +public: + + bool getTotalOffset(int *offsetX, int *offsetY); + bool _canFocus; + bool focus(); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + bool isFocused(); + bool _parentNotify; + DECLARE_PERSISTENT(UIObject, BaseObject) + UIObject *_parent; + virtual bool display() { return display(0, 0); } + virtual bool display(int offsetX) { return display(offsetX, 0); } + virtual bool display(int offsetX, int offsetY); + virtual void correctSize(); + bool _sharedFonts; + bool _sharedImages; + void setText(const char *text); + char *_text; + BaseFont *_font; + bool _visible; + UITiledImage *_back; + bool _disable; + UIObject(BaseGame *inGame = NULL); + virtual ~UIObject(); + int _width; + int _height; + TUIObjectType _type; + BaseSprite *_image; + void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); + BaseScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + BaseScriptHolder *_listenerObject; + UIObject *_focusedWidget; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 86d5c754f1..1844b640d0 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -1,522 +1,522 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(UIText, false) - -////////////////////////////////////////////////////////////////////////// -UIText::UIText(BaseGame *inGame) : UIObject(inGame) { - _textAlign = TAL_LEFT; - _verticalAlign = VAL_CENTER; - _type = UI_STATIC; - _canFocus = false; -} - - -////////////////////////////////////////////////////////////////////////// -UIText::~UIText() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool UIText::display(int offsetX, int offsetY) { - if (!_visible) { - return STATUS_OK; - } - - - BaseFont *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 BaseActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool UIText::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 UIText::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; - BaseParser parser; - - 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 UITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new BaseSprite(_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 BaseSprite(_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 UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "STATIC\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->getFilename()) { - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); - } - - if (_image && _image->getFilename()) { - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); - } - - if (_font && _font->getFilename()) { - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - } - - if (_cursor && _cursor->getFilename()) { - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); - } - - 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("UIText::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 (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool UIText::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 UIObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *UIText::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 UIObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIText::scSetProperty(const char *name, ScValue *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 UIObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *UIText::scToString() { - return "[static]"; -} - - - -////////////////////////////////////////////////////////////////////////// -bool UIText::persist(BasePersistenceManager *persistMgr) { - - UIObject::persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_textAlign)); - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIText::sizeToFit() { - if (_font && _text) { - _width = _font->getTextWidth((byte *)_text); - _height = _font->getTextHeight((byte *)_text, _width); - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(UIText, false) + +////////////////////////////////////////////////////////////////////////// +UIText::UIText(BaseGame *inGame) : UIObject(inGame) { + _textAlign = TAL_LEFT; + _verticalAlign = VAL_CENTER; + _type = UI_STATIC; + _canFocus = false; +} + + +////////////////////////////////////////////////////////////////////////// +UIText::~UIText() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool UIText::display(int offsetX, int offsetY) { + if (!_visible) { + return STATUS_OK; + } + + + BaseFont *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 BaseActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool UIText::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 UIText::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; + BaseParser parser; + + 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 UITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new BaseSprite(_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 BaseSprite(_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 UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "STATIC\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->getFilename()) { + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); + } + + if (_image && _image->getFilename()) { + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); + } + + if (_font && _font->getFilename()) { + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + } + + if (_cursor && _cursor->getFilename()) { + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } + + 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("UIText::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 (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool UIText::scCallMethod(ScScript *script, ScStack *stack, ScStack *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 UIObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *UIText::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 UIObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIText::scSetProperty(const char *name, ScValue *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 UIObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *UIText::scToString() { + return "[static]"; +} + + + +////////////////////////////////////////////////////////////////////////// +bool UIText::persist(BasePersistenceManager *persistMgr) { + + UIObject::persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_textAlign)); + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIText::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 index 54817ccf52..d2f116b44b 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -1,60 +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 UIText : public UIObject { -private: - bool sizeToFit(); -public: - virtual bool display(int offsetX, int offsetY); - 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(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIText : public UIObject { +private: + bool sizeToFit(); +public: + virtual bool display(int offsetX, int offsetY); + 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(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 0cf28b81f5..cec23cf67e 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -1,393 +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/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(UITiledImage, false) - -////////////////////////////////////////////////////////////////////////// -UITiledImage::UITiledImage(BaseGame *inGame) : BaseObject(inGame) { - _image = NULL; - - 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); -} - - -////////////////////////////////////////////////////////////////////////// -UITiledImage::~UITiledImage() { - delete _image; - _image = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool UITiledImage::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 UITiledImage::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 UITiledImage::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; - BaseParser parser; - 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 BaseSubFrame(_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 - 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 - 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 - 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 - if (_image && _image->_surface) { - 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(&_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); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool UITiledImage::saveAsText(BaseDynamicBuffer *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 - BaseClass::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void UITiledImage::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 UITiledImage::persist(BasePersistenceManager *persistMgr) { - BaseObject::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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(UITiledImage, false) + +////////////////////////////////////////////////////////////////////////// +UITiledImage::UITiledImage(BaseGame *inGame) : BaseObject(inGame) { + _image = NULL; + + 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); +} + + +////////////////////////////////////////////////////////////////////////// +UITiledImage::~UITiledImage() { + delete _image; + _image = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool UITiledImage::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 UITiledImage::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 UITiledImage::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; + BaseParser parser; + 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 BaseSubFrame(_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 + 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 + 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 + 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 + if (_image && _image->_surface) { + 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(&_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); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool UITiledImage::saveAsText(BaseDynamicBuffer *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 + BaseClass::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void UITiledImage::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 UITiledImage::persist(BasePersistenceManager *persistMgr) { + BaseObject::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 index 863bf7d1ea..c413e7f129 100644 --- a/engines/wintermute/ui/ui_tiled_image.h +++ b/engines/wintermute/ui/ui_tiled_image.h @@ -1,63 +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 BaseSubFrame; -class UITiledImage : public BaseObject { -public: - 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(BaseDynamicBuffer *buffer, int indent); - - bool display(int x, int y, int width, int height); - UITiledImage(BaseGame *inGame = NULL); - virtual ~UITiledImage(); - BaseSubFrame *_image; - Rect32 _upLeft; - Rect32 _upMiddle; - Rect32 _upRight; - Rect32 _middleLeft; - Rect32 _middleMiddle; - Rect32 _middleRight; - Rect32 _downLeft; - Rect32 _downMiddle; - Rect32 _downRight; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 BaseSubFrame; +class UITiledImage : public BaseObject { +public: + 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(BaseDynamicBuffer *buffer, int indent); + + bool display(int x, int y, int width, int height); + UITiledImage(BaseGame *inGame = NULL); + virtual ~UITiledImage(); + BaseSubFrame *_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 index ffb7e4dbf8..65af62141d 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -1,1444 +1,1444 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(UIWindow, false) - -////////////////////////////////////////////////////////////////////////// -UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { - BasePlatform::setRectEmpty(&_titleRect); - BasePlatform::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; -} - - -////////////////////////////////////////////////////////////////////////// -UIWindow::~UIWindow() { - close(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void UIWindow::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 (uint32 i = 0; i < _widgets.size(); i++) { - delete _widgets[i]; - } - _widgets.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -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->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - - _shieldWindow->display(); - } - } else if (_isMenu) { - if (!_shieldButton) { - _shieldButton = new UIButton(_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) { - 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); - _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 BaseViewport(_gameRef); - } - if (_viewport) { - _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); - _gameRef->pushViewport(_viewport); - popViewport = true; - } - } - - - UITiledImage *back = _back; - BaseSprite *image = _image; - BaseFont *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 (!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->addRectToList(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); - } - - for (uint32 i = 0; i < _widgets.size(); i++) { - _widgets[i]->display(_posX + offsetX, _posY + offsetY); - } - - if (_alphaColor != 0) { - _gameRef->_renderer->_forceAlphaColor = 0; - } - - if (popViewport) { - _gameRef->popViewport(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(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 UIWindow::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; - BaseParser parser; - - 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 UITiledImage(_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 UITiledImage(_gameRef); - if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { - delete _backInactive; - _backInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new BaseSprite(_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 BaseSprite(_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 BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BUTTON: { - UIButton *btn = new UIButton(_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: { - UIText *text = new UIText(_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: { - UIEdit *edit = new UIEdit(_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: { - UIWindow *win = new UIWindow(_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 UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "WINDOW\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - 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->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->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->getFilename()) { - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); - } - - 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 (!BasePlatform::isRectEmpty(&_titleRect)) { - buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); - } - - if (!BasePlatform::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 (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - BaseClass::saveAsText(buffer, indent + 2); - - // controls - for (uint32 i = 0; i < _widgets.size(); i++) { - _widgets[i]->saveAsText(buffer, indent + 2); - } - - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::enableWidget(const char *name, bool enable) { - for (uint32 i = 0; i < _widgets.size(); i++) { - if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { - _widgets[i]->_disable = !enable; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::showWidget(const char *name, bool visible) { - for (uint32 i = 0; i < _widgets.size(); i++) { - if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { - _widgets[i]->_visible = visible; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -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); - ScValue *val = stack->pop(); - if (val->getType() == VAL_INT) { - int widget = val->getInt(); - if (widget < 0 || widget >= (int32)_widgets.size()) { - stack->pushNULL(); - } else { - stack->pushNative(_widgets[widget], true); - } - } else { - 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; - } - } - 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 BaseSprite(_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->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_imageInactive->getFilename()); - } - - 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); - - ScValue *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); - ScValue *val = stack->pop(); - - UIButton *btn = new UIButton(_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); - ScValue *val = stack->pop(); - - UIText *sta = new UIText(_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); - ScValue *val = stack->pop(); - - UIEdit *edi = new UIEdit(_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); - ScValue *val = stack->pop(); - - UIWindow *win = new UIWindow(_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); - ScValue *val = stack->pop(); - UIObject *obj = (UIObject *)val->getNative(); - - for (uint32 i = 0; i < _widgets.size(); i++) { - if (_widgets[i] == obj) { - delete _widgets[i]; - _widgets.remove_at(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 UIObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *UIWindow::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.size()); - 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 UIObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::scSetProperty(const char *name, ScValue *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 UIObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *UIWindow::scToString() { - return "[window]"; -} - - -////////////////////////////////////////////////////////////////////////// -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(!BaseKeyboardState::isShiftDown())); - } else { - if (_focusedWidget) { - return _focusedWidget->handleKeypress(event, printable); - } else { - return false; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::handleMouseWheel(int Delta) { - if (_focusedWidget) { - return _focusedWidget->handleMouseWheel(Delta); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::handleMouse(TMouseEvent event, TMouseButton button) { - bool res = UIObject::handleMouse(event, button); - - // handle window dragging - if (!BasePlatform::isRectEmpty(&_dragRect)) { - // start drag - if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - Rect32 dragRect = _dragRect; - int offsetX, offsetY; - getTotalOffset(&offsetX, &offsetY); - dragRect.offsetRect(_posX + offsetX, _posY + offsetY); - - if (BasePlatform::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 UIWindow::persist(BasePersistenceManager *persistMgr) { - - UIObject::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 UIWindow::moveFocus(bool forward) { - int i; - bool found = false; - for (i = 0; i < (int32)_widgets.size(); i++) { - if (_widgets[i] == _focusedWidget) { - found = true; - break; - } - } - if (!found) { - _focusedWidget = NULL; - } - - if (!_focusedWidget) { - if (_widgets.size() > 0) { - i = 0; - } else { - return STATUS_OK; - } - } - - int numTries = 0; - bool done = false; - - while (numTries <= (int32)_widgets.size()) { - if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { - _focusedWidget = _widgets[i]; - done = true; - break; - } - - if (forward) { - i++; - if (i >= (int32)_widgets.size()) { - i = 0; - } - } else { - i--; - if (i < 0) { - i = _widgets.size() - 1; - } - } - numTries++; - } - - return done ? STATUS_OK : STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::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 UIWindow::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 UIWindow::close() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { - _gameRef->unfreeze(); - } - - _mode = WINDOW_NORMAL; - _visible = false; - _ready = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { - UIObject *obj = (UIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->getName(), "close") == 0) { - close(); - } else { - return BaseObject::listen(param1, param2); - } - break; - default: - return BaseObject::listen(param1, param2); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void UIWindow::makeFreezable(bool freezable) { - for (uint32 i = 0; i < _widgets.size(); i++) { - _widgets[i]->makeFreezable(freezable); - } - - BaseObject::makeFreezable(freezable); -} - - -////////////////////////////////////////////////////////////////////////// -bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { - for (uint32 i = 0; i < _widgets.size(); i++) { - UIObject *control = _widgets[i]; - if (control->_disable && interactiveOnly) { - continue; - } - - switch (control->_type) { - case UI_WINDOW: - ((UIWindow *)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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_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(UIWindow, false) + +////////////////////////////////////////////////////////////////////////// +UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { + BasePlatform::setRectEmpty(&_titleRect); + BasePlatform::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; +} + + +////////////////////////////////////////////////////////////////////////// +UIWindow::~UIWindow() { + close(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void UIWindow::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 (uint32 i = 0; i < _widgets.size(); i++) { + delete _widgets[i]; + } + _widgets.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +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->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + + _shieldWindow->display(); + } + } else if (_isMenu) { + if (!_shieldButton) { + _shieldButton = new UIButton(_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) { + 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); + _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 BaseViewport(_gameRef); + } + if (_viewport) { + _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); + _gameRef->pushViewport(_viewport); + popViewport = true; + } + } + + + UITiledImage *back = _back; + BaseSprite *image = _image; + BaseFont *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 (!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->addRectToList(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + } + + for (uint32 i = 0; i < _widgets.size(); i++) { + _widgets[i]->display(_posX + offsetX, _posY + offsetY); + } + + if (_alphaColor != 0) { + _gameRef->_renderer->_forceAlphaColor = 0; + } + + if (popViewport) { + _gameRef->popViewport(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(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 UIWindow::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; + BaseParser parser; + + 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 UITiledImage(_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 UITiledImage(_gameRef); + if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { + delete _backInactive; + _backInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new BaseSprite(_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 BaseSprite(_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 BaseSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BUTTON: { + UIButton *btn = new UIButton(_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: { + UIText *text = new UIText(_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: { + UIEdit *edit = new UIEdit(_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: { + UIWindow *win = new UIWindow(_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 UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WINDOW\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + 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->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->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->getFilename()) { + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } + + 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 (!BasePlatform::isRectEmpty(&_titleRect)) { + buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); + } + + if (!BasePlatform::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 (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + BaseClass::saveAsText(buffer, indent + 2); + + // controls + for (uint32 i = 0; i < _widgets.size(); i++) { + _widgets[i]->saveAsText(buffer, indent + 2); + } + + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::enableWidget(const char *name, bool enable) { + for (uint32 i = 0; i < _widgets.size(); i++) { + if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { + _widgets[i]->_disable = !enable; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::showWidget(const char *name, bool visible) { + for (uint32 i = 0; i < _widgets.size(); i++) { + if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { + _widgets[i]->_visible = visible; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +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); + ScValue *val = stack->pop(); + if (val->getType() == VAL_INT) { + int widget = val->getInt(); + if (widget < 0 || widget >= (int32)_widgets.size()) { + stack->pushNULL(); + } else { + stack->pushNative(_widgets[widget], true); + } + } else { + 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; + } + } + 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 BaseSprite(_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->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageInactive->getFilename()); + } + + 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); + + ScValue *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); + ScValue *val = stack->pop(); + + UIButton *btn = new UIButton(_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); + ScValue *val = stack->pop(); + + UIText *sta = new UIText(_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); + ScValue *val = stack->pop(); + + UIEdit *edi = new UIEdit(_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); + ScValue *val = stack->pop(); + + UIWindow *win = new UIWindow(_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); + ScValue *val = stack->pop(); + UIObject *obj = (UIObject *)val->getNative(); + + for (uint32 i = 0; i < _widgets.size(); i++) { + if (_widgets[i] == obj) { + delete _widgets[i]; + _widgets.remove_at(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 UIObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *UIWindow::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.size()); + 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 UIObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::scSetProperty(const char *name, ScValue *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 UIObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *UIWindow::scToString() { + return "[window]"; +} + + +////////////////////////////////////////////////////////////////////////// +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(!BaseKeyboardState::isShiftDown())); + } else { + if (_focusedWidget) { + return _focusedWidget->handleKeypress(event, printable); + } else { + return false; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::handleMouseWheel(int Delta) { + if (_focusedWidget) { + return _focusedWidget->handleMouseWheel(Delta); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + bool res = UIObject::handleMouse(event, button); + + // handle window dragging + if (!BasePlatform::isRectEmpty(&_dragRect)) { + // start drag + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + Rect32 dragRect = _dragRect; + int offsetX, offsetY; + getTotalOffset(&offsetX, &offsetY); + dragRect.offsetRect(_posX + offsetX, _posY + offsetY); + + if (BasePlatform::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 UIWindow::persist(BasePersistenceManager *persistMgr) { + + UIObject::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 UIWindow::moveFocus(bool forward) { + int i; + bool found = false; + for (i = 0; i < (int32)_widgets.size(); i++) { + if (_widgets[i] == _focusedWidget) { + found = true; + break; + } + } + if (!found) { + _focusedWidget = NULL; + } + + if (!_focusedWidget) { + if (_widgets.size() > 0) { + i = 0; + } else { + return STATUS_OK; + } + } + + int numTries = 0; + bool done = false; + + while (numTries <= (int32)_widgets.size()) { + if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { + _focusedWidget = _widgets[i]; + done = true; + break; + } + + if (forward) { + i++; + if (i >= (int32)_widgets.size()) { + i = 0; + } + } else { + i--; + if (i < 0) { + i = _widgets.size() - 1; + } + } + numTries++; + } + + return done ? STATUS_OK : STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::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 UIWindow::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 UIWindow::close() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { + _gameRef->unfreeze(); + } + + _mode = WINDOW_NORMAL; + _visible = false; + _ready = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { + UIObject *obj = (UIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->getName(), "close") == 0) { + close(); + } else { + return BaseObject::listen(param1, param2); + } + break; + default: + return BaseObject::listen(param1, param2); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void UIWindow::makeFreezable(bool freezable) { + for (uint32 i = 0; i < _widgets.size(); i++) { + _widgets[i]->makeFreezable(freezable); + } + + BaseObject::makeFreezable(freezable); +} + + +////////////////////////////////////////////////////////////////////////// +bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { + for (uint32 i = 0; i < _widgets.size(); i++) { + UIObject *control = _widgets[i]; + if (control->_disable && interactiveOnly) { + continue; + } + + switch (control->_type) { + case UI_WINDOW: + ((UIWindow *)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 index 8093e2b8f4..cbd417a7d9 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -1,94 +1,94 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIButton; -class BaseViewport; -class UIWindow : public UIObject { - uint32 _fadeColor; -public: - bool getWindowObjects(BaseArray &Objects, bool InteractiveOnly); - - bool _pauseMusic; - void cleanup(); - virtual void makeFreezable(bool freezable); - BaseViewport *_viewport; - bool _clipContents; - bool _inGame; - bool _isMenu; - bool _fadeBackground; - - virtual bool handleMouseWheel(int delta); - UIWindow *_shieldWindow; - UIButton *_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(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); - UIWindow(BaseGame *inGame); - virtual ~UIWindow(); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - BaseArray _widgets; - TTextAlign _titleAlign; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - UITiledImage *_backInactive; - BaseFont *_fontInactive; - BaseSprite *_imageInactive; - virtual bool listen(BaseScriptHolder *param1, uint32 param2); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // 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(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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 UIButton; +class BaseViewport; +class UIWindow : public UIObject { + uint32 _fadeColor; +public: + bool getWindowObjects(BaseArray &Objects, bool InteractiveOnly); + + bool _pauseMusic; + void cleanup(); + virtual void makeFreezable(bool freezable); + BaseViewport *_viewport; + bool _clipContents; + bool _inGame; + bool _isMenu; + bool _fadeBackground; + + virtual bool handleMouseWheel(int delta); + UIWindow *_shieldWindow; + UIButton *_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(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); + UIWindow(BaseGame *inGame); + virtual ~UIWindow(); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + BaseArray _widgets; + TTextAlign _titleAlign; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + UITiledImage *_backInactive; + BaseFont *_fontInactive; + BaseSprite *_imageInactive; + virtual bool listen(BaseScriptHolder *param1, uint32 param2); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // 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(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/utils/crc.cpp b/engines/wintermute/utils/crc.cpp index 8f608600f3..e7ec45511b 100644 --- a/engines/wintermute/utils/crc.cpp +++ b/engines/wintermute/utils/crc.cpp @@ -1,237 +1,237 @@ -/********************************************************************** - * - * 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 "engines/wintermute/utils/crc.h" - -namespace Wintermute { - -/* - * 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 byteVal, crc remainder) { - unsigned char data; - data = (unsigned char)(REFLECT_DATA(byteVal) ^ (remainder >> (WIDTH - 8))); - remainder = crcTable[data] ^ (remainder << 8); - return remainder; -} - -crc crc_finalize(crc remainder) { - return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); -} - -} // end of namespace Wintermute +/********************************************************************** + * + * 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 "engines/wintermute/utils/crc.h" + +namespace Wintermute { + +/* + * 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 byteVal, crc remainder) { + unsigned char data; + data = (unsigned char)(REFLECT_DATA(byteVal) ^ (remainder >> (WIDTH - 8))); + remainder = crcTable[data] ^ (remainder << 8); + return 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 9b9446ce57..77c2ea267f 100644 --- a/engines/wintermute/utils/crc.h +++ b/engines/wintermute/utils/crc.h @@ -1,85 +1,85 @@ -/********************************************************************** - * - * 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 - -#include "common/system.h" // For types. - -namespace Wintermute { - -#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 uint16 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 uint16 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 uint32 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 byteVal, crc remainder); -extern "C" crc crc_finalize(crc remainder); - -} // End of namespace Wintermute - -#endif /* _crc_h */ +/********************************************************************** + * + * 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 + +#include "common/system.h" // For types. + +namespace Wintermute { + +#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 uint16 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 uint16 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 uint32 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 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 55bf776848..298f0c268f 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -1,101 +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 - */ - -#include "common/file.h" -#include "engines/wintermute/utils/path_util.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::unifySeparators(const AnsiString &path) { - AnsiString newPath = path; - - for (uint32 i = 0; i < newPath.size(); i++) { - if (newPath[i] == '\\') { - newPath.setChar('/', i); - } - } - - 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 (!newPath1.hasSuffix("/") && !newPath2.hasPrefix("/")) { - newPath1 += "/"; - } - - return newPath1 + newPath2; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getDirectoryName(const AnsiString &path) { - AnsiString newPath = unifySeparators(path); - Common::String filename = getFileName(path); - return Common::String(path.c_str(), path.size() - filename.size()); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getFileName(const AnsiString &path) { - AnsiString newPath = unifySeparators(path); - Common::String lastPart = Common::lastPathComponent(newPath, '/'); - if (lastPart[lastPart.size() - 1 ] != '/') { - return lastPart; - } else { - return path; - } -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { - AnsiString fileName = getFileName(path); - // TODO: Prettify this. - AnsiString extension = Common::lastPathComponent(fileName, '.'); - for (uint32 i = 0; i < extension.size() + 1; i++) { - fileName.deleteLastChar(); - } - return fileName; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getExtension(const AnsiString &path) { - AnsiString fileName = getFileName(path); - return Common::lastPathComponent(path, '.'); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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/file.h" +#include "engines/wintermute/utils/path_util.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::unifySeparators(const AnsiString &path) { + AnsiString newPath = path; + + for (uint32 i = 0; i < newPath.size(); i++) { + if (newPath[i] == '\\') { + newPath.setChar('/', i); + } + } + + 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 (!newPath1.hasSuffix("/") && !newPath2.hasPrefix("/")) { + newPath1 += "/"; + } + + return newPath1 + newPath2; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getDirectoryName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); + Common::String filename = getFileName(path); + return Common::String(path.c_str(), path.size() - filename.size()); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getFileName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); + Common::String lastPart = Common::lastPathComponent(newPath, '/'); + if (lastPart[lastPart.size() - 1 ] != '/') { + return lastPart; + } else { + return path; + } +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { + AnsiString fileName = getFileName(path); + // TODO: Prettify this. + AnsiString extension = Common::lastPathComponent(fileName, '.'); + for (uint32 i = 0; i < extension.size() + 1; i++) { + fileName.deleteLastChar(); + } + return fileName; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getExtension(const AnsiString &path) { + AnsiString fileName = getFileName(path); + return Common::lastPathComponent(path, '.'); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h index 92adfd91b8..7358c2aba0 100644 --- a/engines/wintermute/utils/path_util.h +++ b/engines/wintermute/utils/path_util.h @@ -1,49 +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_PATHUTILS_H -#define WINTERMUTE_PATHUTILS_H - -#include "engines/wintermute/dctypes.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); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/dctypes.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); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index 63793f7d0b..2c3be8c2f5 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -1,232 +1,232 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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/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 - /*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 - /* 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::isUtf8BOM(const byte *buffer, uint32 bufferSize) { - if (bufferSize > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - return true; - } else { - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - const char *index = strstr(str.c_str(), toFind.c_str()); - if (index == NULL) { - return -1; - } else { - return index - str.c_str(); - } -} - -Common::String StringUtil::encodeSetting(const Common::String &str) { - if (str.contains('=')) { - error("Setting contains '='"); - } - return str; -} - -Common::String StringUtil::decodeSetting(const Common::String &str) { - return str; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(int val) { - return Common::String::format("%d", val); -} - - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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/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 + /*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 + /* 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::isUtf8BOM(const byte *buffer, uint32 bufferSize) { + if (bufferSize > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + return true; + } else { + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + const char *index = strstr(str.c_str(), toFind.c_str()); + if (index == NULL) { + return -1; + } else { + return index - str.c_str(); + } +} + +Common::String StringUtil::encodeSetting(const Common::String &str) { + if (str.contains('=')) { + error("Setting contains '='"); + } + return str; +} + +Common::String StringUtil::decodeSetting(const Common::String &str) { + return str; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::toString(int val) { + return Common::String::format("%d", val); +} + + +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/string_util.h b/engines/wintermute/utils/string_util.h index 87760971a8..e419e2bca8 100644 --- a/engines/wintermute/utils/string_util.h +++ b/engines/wintermute/utils/string_util.h @@ -1,56 +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_STRINGUTIL_H -#define WINTERMUTE_STRINGUTIL_H - -#include "engines/wintermute/dctypes.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 isUtf8BOM(const byte *buffer, uint32 bufferSize); - static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); - - static Common::String encodeSetting(const Common::String &str); - static Common::String decodeSetting(const Common::String &str); - - static AnsiString toString(int val); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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/dctypes.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 isUtf8BOM(const byte *buffer, uint32 bufferSize); + static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); + + static Common::String encodeSetting(const Common::String &str); + static Common::String decodeSetting(const Common::String &str); + + static AnsiString toString(int val); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index f26d60b7cf..824b16ccdb 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -1,261 +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/utils/utils.h" -#include "engines/wintermute/wintermute.h" -#include "engines/wintermute/base/base_engine.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -static inline unsigned Sqr(int x) { - return (x * x); -} - -////////////////////////////////////////////////////////////////////////////////// -// Swap - swaps two integers -////////////////////////////////////////////////////////////////////////////////// -void BaseUtils::swap(int *a, int *b) { - int temp = *a; - *a = *b; - *b = temp; -} - - -////////////////////////////////////////////////////////////////////////// -float BaseUtils::normalizeAngle(float angle) { - while (angle > 360) { - angle -= 360; - } - while (angle < 0) { - angle += 360; - } - - return angle; -} - - -//////////////////////////////////////////////////////////////////////////////// -void BaseUtils::createPath(const char *path, bool pathOnly) { - /* AnsiString pathStr; - - if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); - else pathStr = path; - */ -// try { - warning("BaseUtils::CreatePath - not implemented: %s", path); -// boost::filesystem::create_directories(path); -// } catch (...) { - return; -// } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseUtils::debugMessage(const char *text) { - //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseUtils::setString(char **string, const char *value) { - delete[] *string; - *string = new char[strlen(value) + 1]; - if (*string) { - strcpy(*string, value); - } - return *string; -} - -////////////////////////////////////////////////////////////////////////// -char *BaseUtils::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); - Common::strlcpy(ret, start, len + 1); - return ret; - } - } - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -int BaseUtils::randomInt(int from, int to) { - if (to < from) { - int i = to; - to = from; - from = i; - } - 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)BaseEngine::instance().randInt(0, randMax) / (float)randMax; - return from + (to - from) * randNum; -} - -////////////////////////////////////////////////////////////////////////// -float BaseUtils::randomAngle(float from, float to) { - while (to < from) { - to += 360; - } - return normalizeAngle(randomFloat(from, to)); -} - -////////////////////////////////////////////////////////////////////////// -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); - varMin = MIN(varMin, varB); - - //Max. value of RGB - float varMax = MAX(varR, varG); - varMax = MAX(varMax, varB); - - //Delta RGB value - float delMax = varMax - varMin; - - float H = 0.0f, S = 0.0f, L = 0.0f; - - L = (varMax + varMin) / 2.0f; - - //This is a gray, no chroma... - if (delMax == 0) { - H = 0; - S = 0; - } - //Chromatic data... - else { - 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 (H < 0) { - H += 1; - } - if (H > 1) { - H -= 1; - } - } - - *outH = (byte)(H * 255); - *outS = (byte)(S * 255); - *outL = (byte)(L * 255); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseUtils::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 var1, var2; - - if (L < 0.5) { - var2 = L * (1.0 + S); - } else { - var2 = (L + S) - (S * L); - } - - var1 = 2.0f * L - var2; - - 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); -} - - -////////////////////////////////////////////////////////////////////////// -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); - } - return (v1); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/base_engine.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +static inline unsigned Sqr(int x) { + return (x * x); +} + +////////////////////////////////////////////////////////////////////////////////// +// Swap - swaps two integers +////////////////////////////////////////////////////////////////////////////////// +void BaseUtils::swap(int *a, int *b) { + int temp = *a; + *a = *b; + *b = temp; +} + + +////////////////////////////////////////////////////////////////////////// +float BaseUtils::normalizeAngle(float angle) { + while (angle > 360) { + angle -= 360; + } + while (angle < 0) { + angle += 360; + } + + return angle; +} + + +//////////////////////////////////////////////////////////////////////////////// +void BaseUtils::createPath(const char *path, bool pathOnly) { + /* AnsiString pathStr; + + if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); + else pathStr = path; + */ +// try { + warning("BaseUtils::CreatePath - not implemented: %s", path); +// boost::filesystem::create_directories(path); +// } catch (...) { + return; +// } +} + + +////////////////////////////////////////////////////////////////////////// +void BaseUtils::debugMessage(const char *text) { + //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); +} + + +////////////////////////////////////////////////////////////////////////// +char *BaseUtils::setString(char **string, const char *value) { + delete[] *string; + *string = new char[strlen(value) + 1]; + if (*string) { + strcpy(*string, value); + } + return *string; +} + +////////////////////////////////////////////////////////////////////////// +char *BaseUtils::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); + Common::strlcpy(ret, start, len + 1); + return ret; + } + } + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int BaseUtils::randomInt(int from, int to) { + if (to < from) { + int i = to; + to = from; + from = i; + } + 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)BaseEngine::instance().randInt(0, randMax) / (float)randMax; + return from + (to - from) * randNum; +} + +////////////////////////////////////////////////////////////////////////// +float BaseUtils::randomAngle(float from, float to) { + while (to < from) { + to += 360; + } + return normalizeAngle(randomFloat(from, to)); +} + +////////////////////////////////////////////////////////////////////////// +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); + varMin = MIN(varMin, varB); + + //Max. value of RGB + float varMax = MAX(varR, varG); + varMax = MAX(varMax, varB); + + //Delta RGB value + float delMax = varMax - varMin; + + float H = 0.0f, S = 0.0f, L = 0.0f; + + L = (varMax + varMin) / 2.0f; + + //This is a gray, no chroma... + if (delMax == 0) { + H = 0; + S = 0; + } + //Chromatic data... + else { + 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 (H < 0) { + H += 1; + } + if (H > 1) { + H -= 1; + } + } + + *outH = (byte)(H * 255); + *outS = (byte)(S * 255); + *outL = (byte)(L * 255); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseUtils::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 var1, var2; + + if (L < 0.5) { + var2 = L * (1.0 + S); + } else { + var2 = (L + S) - (S * L); + } + + var1 = 2.0f * L - var2; + + 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); +} + + +////////////////////////////////////////////////////////////////////////// +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); + } + return (v1); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index af69bd4523..d6a603ec72 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -1,64 +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_UTILS_H -#define WINTERMUTE_UTILS_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/math/rect32.h" - -namespace Wintermute { - -class BaseGame; - -class BaseUtils { -public: - static void swap(int *a, int *b); - static float normalizeAngle(float angle); - - static void createPath(const char *path, bool pathOnly = false); - - static void debugMessage(const char *text); - static char *setString(char **string, const char *value); - - 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 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 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-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" +#include "engines/wintermute/math/rect32.h" + +namespace Wintermute { + +class BaseGame; + +class BaseUtils { +public: + static void swap(int *a, int *b); + static float normalizeAngle(float angle); + + static void createPath(const char *path, bool pathOnly = false); + + static void debugMessage(const char *text); + static char *setString(char **string, const char *value); + + 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 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 a83a31f2ea..c7723808ea 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -1,53 +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_WINTYPES_H -#define WINTERMUTE_WINTYPES_H - -#include "common/scummsys.h" - -namespace Wintermute { - -#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)) - -#define DID_SUCCEED(hr) ((bool)(hr)) -#define DID_FAIL(hr) (!((bool)(hr))) - -#define STATUS_OK (true) -#define STATUS_FAILED (false) - -#define MAX_PATH_LENGTH 512 - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_WINTYPES_H +#define WINTERMUTE_WINTYPES_H + +#include "common/scummsys.h" + +namespace Wintermute { + +#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)) + +#define DID_SUCCEED(hr) ((bool)(hr)) +#define DID_FAIL(hr) (!((bool)(hr))) + +#define STATUS_OK (true) +#define STATUS_FAILED (false) + +#define MAX_PATH_LENGTH 512 + +} // end of namespace Wintermute + +#endif -- cgit v1.2.3 From 6472ef86bbee92bc02a67d87677dc6b0925a0362 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 5 Sep 2012 08:12:14 +0200 Subject: CGE: Fix bug #3557904 - Shadow at wrong position --- engines/cge/cge_main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 3ba5f7fed9..ecbfba2502 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -207,7 +207,7 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) { readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES); } else { - // Open up the savgame file + // Open up the savegame file Common::String slotName = generateSaveName(slotNumber); Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(slotName); @@ -316,8 +316,8 @@ Common::Error CGEEngine::saveGameState(int slot, const Common::String &desc) { // Reload the scene sceneUp(); - _hero->_x = x; - _hero->_y = y; + // Restore player position + _hero->gotoxy(x, y); _hero->_z = z; return Common::kNoError; -- cgit v1.2.3 From 35a7e79614673509870ad9421020e34fccbede71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Sep 2012 20:47:32 +1000 Subject: TONY: Change to hopefully fix Mingw 64 compilation errors --- engines/tony/mpal/mpal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 533a4d22b9..10f5753540 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -570,7 +570,7 @@ void CustomThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - _ctx->p = *(LpCfCall *)param; + _ctx->p = *(const LpCfCall *)param; CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->p->_nCf], _ctx->p->_arg1, _ctx->p->_arg2, _ctx->p->_arg3, _ctx->p->_arg4); @@ -693,7 +693,7 @@ void ActionThread(CORO_PARAM, const void *param) { // The ActionThread owns the data block pointed to, so we need to make sure it's // freed when the process exits - _ctx->item = *(LpMpalItem *)param; + _ctx->item = *(const LpMpalItem *)param; GLOBALS._mpalError = 0; for (_ctx->j = 0; _ctx->j < _ctx->item->_action[_ctx->item->_dwRes]._nCmds; _ctx->j++) { -- cgit v1.2.3 From 220e945d6746ce22c655b2893f7ce0c001d811a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Sep 2012 22:32:02 +1000 Subject: TONY: Bugfix for OFFSETOF macro on 64-bit systems --- engines/tony/mpal/memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 428c07b3b7..78b036e657 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -64,7 +64,7 @@ void *MemoryManager::alloc(uint32 size, uint flags) { return &item->_data[0]; } -#define OFFSETOF(type, field) ((unsigned long) &(((type *) 0)->field)) +#define OFFSETOF(type, field) ((size_t) &(((type *) 0)->field)) /** * Returns a reference to the MemoryItem for a gien byte pointer -- cgit v1.2.3