diff options
author | Paul Gilbert | 2016-04-14 20:02:52 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:07 -0400 |
commit | f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5 (patch) | |
tree | a6eeca5e8990c29b635e3190dbf416e8ddbaf76e /engines/titanic/core/game_object.cpp | |
parent | 1babcc10cfce1458ac07c8e1027c321962cf8f09 (diff) | |
download | scummvm-rg350-f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5.tar.gz scummvm-rg350-f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5.tar.bz2 scummvm-rg350-f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5.zip |
TITANIC: Implemented CGameObject::find
Diffstat (limited to 'engines/titanic/core/game_object.cpp')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 0a541bfb4d..ba8ab42c68 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -21,7 +21,9 @@ */ #include "titanic/core/game_object.h" +#include "titanic/core/mail_man.h" #include "titanic/core/resource_key.h" +#include "titanic/core/room_item.h" #include "titanic/pet_control/pet_control.h" #include "titanic/support/files_manager.h" #include "titanic/support/screen_manager.h" @@ -568,4 +570,60 @@ void CGameObject::petDisplayMsg(const CString &msg) const { pet->displayMessage(msg); } +CGameObject *CGameObject::getMailManFirstObject() const { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->getFirstObject() : nullptr; +} + +CGameObject *CGameObject::getMailManNextObject(CGameObject *prior) const { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->getNextObject(prior) : nullptr; +} + +CGameObject *CGameObject::findRoomObject(const CString &name) const { + return static_cast<CGameObject *>(findRoom()->findByName(name)); +} + +Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) { + CGameObject *go; + *item = nullptr; + + // Scan under PET if flagged + if (findAreas & FIND_PET) { + for (go = getPetControl()->getFirstObject(); go; go = getPetControl()->getNextObject(go)) { + if (go->getName() == name) { + *item = go; + return FOUND_PET; + } + } + } + + if (findAreas & FIND_MAILMAN) { + for (go = getMailManFirstObject(); go; go = getMailManNextObject(go)) { + if (go->getName() == name) { + *item = go; + return FOUND_MAILMAN; + } + } + } + + if (findAreas & FIND_GLOBAL) { + go = static_cast<CGameObject *>(getRoot()->findByName(name)); + if (go) { + *item = go; + return FOUND_GLOBAL; + } + } + + if (findAreas & FIND_ROOM) { + go = findRoomObject(name); + if (go) { + *item = go; + return FOUND_ROOM; + } + } + + return FOUND_NONE; +} + } // End of namespace Titanic |