diff options
author | johndoe123 | 2014-12-12 13:21:21 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | e63eaabbdb5c54df03651edc34a6048946fb2f3f (patch) | |
tree | 5ae947b396a9bca7a1a99c59ec7a9e4b789b85e4 /engines/illusions/bbdou | |
parent | 9d98f92298c7e0c494b0ae6455a5f0183080db70 (diff) | |
download | scummvm-rg350-e63eaabbdb5c54df03651edc34a6048946fb2f3f.tar.gz scummvm-rg350-e63eaabbdb5c54df03651edc34a6048946fb2f3f.tar.bz2 scummvm-rg350-e63eaabbdb5c54df03651edc34a6048946fb2f3f.zip |
ILLUSIONS: Move trigger functions code to seperate file
Diffstat (limited to 'engines/illusions/bbdou')
-rw-r--r-- | engines/illusions/bbdou/bbdou_triggerfunctions.cpp | 82 | ||||
-rw-r--r-- | engines/illusions/bbdou/bbdou_triggerfunctions.h | 60 | ||||
-rw-r--r-- | engines/illusions/bbdou/illusions_bbdou.cpp | 55 | ||||
-rw-r--r-- | engines/illusions/bbdou/illusions_bbdou.h | 28 |
4 files changed, 143 insertions, 82 deletions
diff --git a/engines/illusions/bbdou/bbdou_triggerfunctions.cpp b/engines/illusions/bbdou/bbdou_triggerfunctions.cpp new file mode 100644 index 0000000000..7c1ee4702e --- /dev/null +++ b/engines/illusions/bbdou/bbdou_triggerfunctions.cpp @@ -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. + * + */ + +#include "illusions/bbdou/illusions_bbdou.h" +#include "illusions/bbdou/bbdou_triggerfunctions.h" + +namespace Illusions { + +// TriggerFunction + +TriggerFunction::TriggerFunction(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback) + : _sceneId(sceneId), _verbId(verbId), _objectId2(objectId2), _objectId(objectId), _callback(callback) { +} + +TriggerFunction::~TriggerFunction() { + delete _callback; +} + +void TriggerFunction::run(uint32 callingThreadId) { + (*_callback)(this, callingThreadId); +} + +// TriggerFunctions + +void TriggerFunctions::add(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback) { + ItemsIterator it = findInternal(sceneId, verbId, objectId2, objectId); + if (it != _triggerFunctions.end()) { + delete *it; + _triggerFunctions.erase(it); + } + _triggerFunctions.push_back(new TriggerFunction(sceneId, verbId, objectId2, objectId, callback)); +} + +TriggerFunction *TriggerFunctions::find(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) { + ItemsIterator it = findInternal(sceneId, verbId, objectId2, objectId); + if (it != _triggerFunctions.end()) + return (*it); + return 0; +} + +void TriggerFunctions::removeBySceneId(uint32 sceneId) { + ItemsIterator it = _triggerFunctions.begin(); + while (it != _triggerFunctions.end()) { + if ((*it)->_sceneId == sceneId) { + delete *it; + it = _triggerFunctions.erase(it); + } else + ++it; + } +} + +TriggerFunctions::ItemsIterator TriggerFunctions::findInternal(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) { + ItemsIterator it = _triggerFunctions.begin(); + for (; it != _triggerFunctions.end(); ++it) { + TriggerFunction *triggerFunction = *it; + if (triggerFunction->_sceneId == sceneId && triggerFunction->_verbId == verbId && + triggerFunction->_objectId2 == objectId2 && triggerFunction->_objectId == objectId) + break; + } + return it; +} + +} // End of namespace Illusions diff --git a/engines/illusions/bbdou/bbdou_triggerfunctions.h b/engines/illusions/bbdou/bbdou_triggerfunctions.h new file mode 100644 index 0000000000..a41bfba50b --- /dev/null +++ b/engines/illusions/bbdou/bbdou_triggerfunctions.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. + * + */ + +#ifndef ILLUSIONS_BBDOU_BBDOU_TRIGGERFUNCTIONS_H +#define ILLUSIONS_BBDOU_BBDOU_TRIGGERFUNCTIONS_H + +#include "common/algorithm.h" +#include "common/stack.h" + +namespace Illusions { + +struct TriggerFunction; + +typedef Common::Functor2<TriggerFunction*, uint32, void> TriggerFunctionCallback; + +struct TriggerFunction { + uint32 _sceneId; + uint32 _verbId; + uint32 _objectId2; + uint32 _objectId; + TriggerFunctionCallback *_callback; + TriggerFunction(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback); + ~TriggerFunction(); + void run(uint32 callingThreadId); +}; + +class TriggerFunctions { +public: + void add(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback); + TriggerFunction *find(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId); + void removeBySceneId(uint32 sceneId); +public: + typedef Common::List<TriggerFunction*> Items; + typedef Items::iterator ItemsIterator; + Items _triggerFunctions; + ItemsIterator findInternal(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId); +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_BBDOU_BBDOU_TRIGGERFUNCTIONS_H diff --git a/engines/illusions/bbdou/illusions_bbdou.cpp b/engines/illusions/bbdou/illusions_bbdou.cpp index 9aeb0808cf..b2e5098085 100644 --- a/engines/illusions/bbdou/illusions_bbdou.cpp +++ b/engines/illusions/bbdou/illusions_bbdou.cpp @@ -65,60 +65,6 @@ namespace Illusions { -// TriggerFunction - -TriggerFunction::TriggerFunction(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback) - : _sceneId(sceneId), _verbId(verbId), _objectId2(objectId2), _objectId(objectId), _callback(callback) { -} - -TriggerFunction::~TriggerFunction() { - delete _callback; -} - -void TriggerFunction::run(uint32 callingThreadId) { - (*_callback)(this, callingThreadId); -} - -// TriggerFunctions - -void TriggerFunctions::add(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback) { - ItemsIterator it = findInternal(sceneId, verbId, objectId2, objectId); - if (it != _triggerFunctions.end()) { - delete *it; - _triggerFunctions.erase(it); - } - _triggerFunctions.push_back(new TriggerFunction(sceneId, verbId, objectId2, objectId, callback)); -} - -TriggerFunction *TriggerFunctions::find(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) { - ItemsIterator it = findInternal(sceneId, verbId, objectId2, objectId); - if (it != _triggerFunctions.end()) - return (*it); - return 0; -} - -void TriggerFunctions::removeBySceneId(uint32 sceneId) { - ItemsIterator it = _triggerFunctions.begin(); - while (it != _triggerFunctions.end()) { - if ((*it)->_sceneId == sceneId) { - delete *it; - it = _triggerFunctions.erase(it); - } else - ++it; - } -} - -TriggerFunctions::ItemsIterator TriggerFunctions::findInternal(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) { - ItemsIterator it = _triggerFunctions.begin(); - for (; it != _triggerFunctions.end(); ++it) { - TriggerFunction *triggerFunction = *it; - if (triggerFunction->_sceneId == sceneId && triggerFunction->_verbId == verbId && - triggerFunction->_objectId2 == objectId2 && triggerFunction->_objectId == objectId) - break; - } - return it; -} - // ActiveScenes ActiveScenes::ActiveScenes() { @@ -348,7 +294,6 @@ uint32 IllusionsEngine_BBDOU::causeTrigger(uint32 sceneId, uint32 verbId, uint32 if (triggerFunction) { triggerFunction->run(callingThreadId); } else if (findTriggerCause(sceneId, verbId, objectId2, objectId, codeOffs)) { - //debug("Run cause at %08X", codeOffs); causeThreadId = startTempScriptThread(_scriptResource->getCode(codeOffs), callingThreadId, verbId, objectId2, objectId); } diff --git a/engines/illusions/bbdou/illusions_bbdou.h b/engines/illusions/bbdou/illusions_bbdou.h index 5317809907..f2dbd1aee7 100644 --- a/engines/illusions/bbdou/illusions_bbdou.h +++ b/engines/illusions/bbdou/illusions_bbdou.h @@ -24,6 +24,7 @@ #define ILLUSIONS_ILLUSIONS_BBDOU_H #include "illusions/illusions.h" +#include "illusions/bbdou/bbdou_triggerfunctions.h" #include "common/algorithm.h" #include "common/stack.h" @@ -32,33 +33,6 @@ namespace Illusions { class Dictionary; class ScriptMan; class ScriptStack; -class TriggerFunctions; -class TriggerFunction; - -typedef Common::Functor2<TriggerFunction*, uint32, void> TriggerFunctionCallback; - -struct TriggerFunction { - uint32 _sceneId; - uint32 _verbId; - uint32 _objectId2; - uint32 _objectId; - TriggerFunctionCallback *_callback; - TriggerFunction(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback); - ~TriggerFunction(); - void run(uint32 callingThreadId); -}; - -class TriggerFunctions { -public: - void add(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback); - TriggerFunction *find(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId); - void removeBySceneId(uint32 sceneId); -public: - typedef Common::List<TriggerFunction*> Items; - typedef Items::iterator ItemsIterator; - Items _triggerFunctions; - ItemsIterator findInternal(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId); -}; struct ActiveScene { uint32 _sceneId; |