Skip to content

Commit

Permalink
XEEN: Fix LLoyd's Beacon spell in Clouds of Xeen
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 30, 2018
1 parent 7d2b9df commit 09f67c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
8 changes: 2 additions & 6 deletions engines/xeen/dialogs/dialogs_spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
35 changes: 21 additions & 14 deletions engines/xeen/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
7 changes: 7 additions & 0 deletions engines/xeen/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,13 @@ class Map {
* 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
Expand Down

0 comments on commit 09f67c8

Please sign in to comment.