diff options
author | Torbjörn Andersson | 2006-07-08 20:20:55 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2006-07-08 20:20:55 +0000 |
commit | 1e0b6995aa2b49b39a6c352b499558d42ca6417c (patch) | |
tree | 890226a88462cdea09328dfbbd5946937461faa0 /engines/sword2 | |
parent | 07ffde92706f3725c44978c477b2b987a4aa2cf0 (diff) | |
download | scummvm-rg350-1e0b6995aa2b49b39a6c352b499558d42ca6417c.tar.gz scummvm-rg350-1e0b6995aa2b49b39a6c352b499558d42ca6417c.tar.bz2 scummvm-rg350-1e0b6995aa2b49b39a6c352b499558d42ca6417c.zip |
More robust handling of the optional startup.inf file.
svn-id: r23436
Diffstat (limited to 'engines/sword2')
-rw-r--r-- | engines/sword2/startup.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/engines/sword2/startup.cpp b/engines/sword2/startup.cpp index 45906dffa3..7ac089e04e 100644 --- a/engines/sword2/startup.cpp +++ b/engines/sword2/startup.cpp @@ -60,8 +60,34 @@ bool Sword2Engine::initStartMenu() { int start_ids[MAX_starts]; char buf[10]; + int lineno = 0; + while (fp.readLine(buf, sizeof(buf))) { - start_ids[_totalScreenManagers] = atoi(buf); + char *errptr; + int id; + + lineno++; + id = strtol(buf, &errptr, 10); + + if (*errptr) { + warning("startup.inf:%d: Invalid string '%s'", lineno, buf); + continue; + } + + if (!_resman->checkValid(id)) { + warning("startup.inf:%d: Invalid resource %d", lineno, id); + continue; + } + + if (_resman->fetchType(id) != SCREEN_MANAGER) { + byte name[NAME_LEN]; + + warning("startup.inf:%d: '%s' (%d) is not a screen manager", lineno, _resman->fetchName(id, name), id); + continue; + } + + start_ids[_totalScreenManagers] = id; + if (++_totalScreenManagers >= MAX_starts) { warning("Too many entries in startup.inf"); break; @@ -86,17 +112,10 @@ bool Sword2Engine::initStartMenu() { debug(2, "Querying screen manager %d", _startRes); // Open each one and run through the interpreter. Script 0 is - // the query request script - - // if the resource number is within range & it's not a null - // resource - // - need to check in case un-built sections included in - // start list + // the query request script. We have already made reasonably + // sure the resource is ok. - if (_resman->checkValid(_startRes)) { - _logic->runResScript(_startRes, 0); - } else - warning("Start menu resource %d invalid", _startRes); + _logic->runResScript(_startRes, 0); } return 1; |