SCUMM: Fix detection of Maniac Mansion from within DoTT

It turns out that in some versions of ScummVM, paths end with a
directory separator, while in others they don't. This should handle
both cases, I hope. (It's a bit tricky for me to test.)
This commit is contained in:
Torbjörn Andersson 2016-03-09 21:23:13 +01:00
parent 0f2e7fcdf0
commit e11a370fe4
2 changed files with 29 additions and 6 deletions

5
NEWS
View file

@ -8,6 +8,11 @@ For a more comprehensive changelog of the latest experimental code, see:
- Added optional "pause, when entering commands" feature, that was only available - Added optional "pause, when entering commands" feature, that was only available
in the original interpreter for Hercules rendering. in the original interpreter for Hercules rendering.
1.8.1 (XXXX-XX-XX)
SCUMM:
- Fixed detection of Maniac Mansion from Day of the Tentacle in the Windows
version of ScummVM.
1.8.0 (2016-03-04) 1.8.0 (2016-03-04)
New Games: New Games:
- Added support for Rex Nebular and the Cosmic Gender Bender. - Added support for Rex Nebular and the Cosmic Gender Bender.

View file

@ -2608,16 +2608,34 @@ bool ScummEngine::startManiac() {
Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains(); Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains();
for (; iter != ConfMan.endGameDomains(); ++iter) { for (; iter != ConfMan.endGameDomains(); ++iter) {
Common::ConfigManager::Domain &dom = iter->_value; Common::ConfigManager::Domain &dom = iter->_value;
Common::String path = dom.getVal("path"); Common::String path1 = dom.getVal("path");
if (path.hasPrefix(currentPath)) { if (path1.hasPrefix(currentPath)) {
path.erase(0, currentPath.size() + 1); // In some ports (e.g. Windows), the "path" will end with a
if (path.equalsIgnoreCase("maniac")) { // path separator. In others (e.g. Linux), it won't. And
// we have no way of knowing exactly what the separator
// is. The technical term for this is "annoying".
path1.erase(0, currentPath.size());
if (!path1.empty()) {
// If we've found the path we're looking for, all that
// remains now is the "maniac" part of it. If paths end
// with a separator, we'll have "maniac" followed by a
// separator. If they don't, we'll have a separator
// followed by "maniac".
Common::String path2 = path1;
path1.erase(0, 1);
path2.deleteLastChar();
if (path1.equalsIgnoreCase("maniac") || path2.equalsIgnoreCase("maniac")) {
maniacTarget = iter->_key; maniacTarget = iter->_key;
break; break;
} }
} }
} }
}
} else { } else {
maniacTarget = ConfMan.get("easter_egg"); maniacTarget = ConfMan.get("easter_egg");
} }