diff options
-rw-r--r-- | engines/xeen/dialogs/dialogs_spells.cpp | 8 | ||||
-rw-r--r-- | engines/xeen/map.cpp | 35 | ||||
-rw-r--r-- | engines/xeen/map.h | 7 |
3 files changed, 30 insertions, 20 deletions
diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp index a14d4babaa..21bd7e2776 100644 --- a/engines/xeen/dialogs/dialogs_spells.cpp +++ b/engines/xeen/dialogs/dialogs_spells.cpp @@ -742,12 +742,8 @@ bool LloydsBeacon::execute() { } } - // Open up the text file for the destination map and read in it's name - Common::String txtName = Common::String::format("%s%c%03d.txt", - c._lloydSide ? "dark" : "xeen", c._lloydMap >= 100 ? 'x' : '0', c._lloydMap); - File textFile(txtName, 1); - Common::String mapName = textFile.readString(); - textFile.close(); + // Get the destination map name + Common::String mapName = Map::getMazeName(c._lloydMap, c._lloydSide); // Display the dialog w.open(); diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 06c1592ed3..ce14553ce7 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -747,20 +747,7 @@ void Map::load(int mapId) { // Handle loading text data if (!textLoaded) { textLoaded = true; - - if (g_vm->getGameID() == GType_Clouds) { - _mazeName = Res._cloudsMapNames[mapId]; - } else { - Common::String txtName = Common::String::format("%s%c%03d.txt", - ccNum ? "dark" : "xeen", mapId >= 100 ? 'x' : '0', mapId); - File fText(txtName, 1); - char mazeName[33]; - fText.read(mazeName, 33); - mazeName[32] = '\0'; - - _mazeName = Common::String(mazeName); - fText.close(); - } + _mazeName = getMazeName(mapId, ccNum); // Load the monster/object data Common::String mobName = Common::String::format("maze%c%03d.mob", @@ -1404,4 +1391,24 @@ void Map::getNewMaze() { load(mapId); } +Common::String Map::getMazeName(int mapId, int ccNum) { + if (ccNum == -1) + ccNum = g_vm->_files->_ccNum; + + if (g_vm->getGameID() == GType_Clouds) { + return Res._cloudsMapNames[mapId]; + } else { + Common::String txtName = Common::String::format("%s%c%03d.txt", + ccNum ? "dark" : "xeen", mapId >= 100 ? 'x' : '0', mapId); + File fText(txtName, 1); + char mazeName[33]; + fText.read(mazeName, 33); + mazeName[32] = '\0'; + + Common::String name = Common::String(mazeName); + fText.close(); + return name; + } +} + } // End of namespace Xeen diff --git a/engines/xeen/map.h b/engines/xeen/map.h index fc591fc208..c34ef9e76e 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -516,6 +516,13 @@ public: * position to the relative position on the new map */ void getNewMaze(); + + /** + * Return the name of a specified maze + * @param mapId Map Id + * @param ccNum Cc file number. If -1, uses the current C + */ + static Common::String getMazeName(int mapId, int ccNum = -1); }; } // End of namespace Xeen |