diff options
author | Colin Snover | 2017-07-27 20:16:44 -0500 |
---|---|---|
committer | Colin Snover | 2017-07-30 19:10:50 -0500 |
commit | ad05bfedd85b4ca560166bf95a0a2ec46df52dc8 (patch) | |
tree | 9483bde45221079257d61fe8ea7d5760da009268 | |
parent | d2b26b2c21d5b644e4b961bddd3d8ed9ec7cfb7b (diff) | |
download | scummvm-rg350-ad05bfedd85b4ca560166bf95a0a2ec46df52dc8.tar.gz scummvm-rg350-ad05bfedd85b4ca560166bf95a0a2ec46df52dc8.tar.bz2 scummvm-rg350-ad05bfedd85b4ca560166bf95a0a2ec46df52dc8.zip |
SCI: Expose API for retrieving multiple objects with the same name
This is needed by Phant2 guest additions to find the correct
slider for the music volume, since the sliders have no unique name.
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 13 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 5 |
2 files changed, 14 insertions, 4 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 3cf9d08ceb..aa70d5f838 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -284,12 +284,11 @@ const char *SegManager::getObjectName(reg_t pos) { return name; } -reg_t SegManager::findObjectByName(const Common::String &name, int index) { +Common::Array<reg_t> SegManager::findObjectsByName(const Common::String &name) { Common::Array<reg_t> result; - uint i; // Now all values are available; iterate over all objects. - for (i = 0; i < _heap.size(); i++) { + for (uint i = 0; i < _heap.size(); i++) { const SegmentObj *mobj = _heap[i]; if (!mobj) @@ -320,12 +319,18 @@ reg_t SegManager::findObjectByName(const Common::String &name, int index) { } } + return result; +} + +reg_t SegManager::findObjectByName(const Common::String &name, int index) { + Common::Array<reg_t> result = findObjectsByName(name); + if (result.empty()) return NULL_REG; if (result.size() > 1 && index < 0) { debug("findObjectByName(%s): multiple matches:", name.c_str()); - for (i = 0; i < result.size(); i++) + for (uint i = 0; i < result.size(); i++) debug(" %3x: [%04x:%04x]", i, PRINT_REG(result[i])); return NULL_REG; // Ambiguous } diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 916b813eb5..d13edf0ef2 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -411,6 +411,11 @@ public: const char *getObjectName(reg_t pos); /** + * Finds the addresses of all objects with the given name. + */ + Common::Array<reg_t> findObjectsByName(const Common::String &name); + + /** * Find the address of an object by its name. In case multiple objects * with the same name occur, the optional index parameter can be used * to distinguish between them. If index is -1, then if there is a |