From ad05bfedd85b4ca560166bf95a0a2ec46df52dc8 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 27 Jul 2017 20:16:44 -0500 Subject: 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. --- engines/sci/engine/seg_manager.cpp | 13 +++++++++---- engines/sci/engine/seg_manager.h | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'engines/sci') 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 SegManager::findObjectsByName(const Common::String &name) { Common::Array 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 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 @@ -410,6 +410,11 @@ public: */ const char *getObjectName(reg_t pos); + /** + * Finds the addresses of all objects with the given name. + */ + Common::Array 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 -- cgit v1.2.3