aboutsummaryrefslogtreecommitdiff
path: root/engines/supernova/supernova.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/supernova/supernova.cpp')
-rw-r--r--engines/supernova/supernova.cpp80
1 files changed, 14 insertions, 66 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 16569cf83a..10a460a7e7 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -148,7 +148,7 @@ void SupernovaEngine::init() {
if (status.getCode() != Common::kNoError)
error("Failed reading game strings");
- _resMan = new ResourceManager(_MSPart);
+ _resMan = new ResourceManager(this);
_sound = new Sound(_mixer, _resMan);
_screen = new Screen(this, _resMan);
if (_MSPart == 1)
@@ -185,78 +185,26 @@ void SupernovaEngine::pauseEngineIntern(bool pause) {
}
Common::Error SupernovaEngine::loadGameStrings() {
- Common::String cur_lang = ConfMan.get("language");
Common::String string_id("TEXT");
- // Note: we don't print any warning or errors here if we cannot find the file
- // or the format is not as expected. We will get those warning when reading the
- // strings anyway (actually the engine will even refuse to start).
-
+ Common::SeekableReadStream *stream = getBlockFromDatFile(string_id);
- // Validate the data file header
- Common::File f;
- char id[5], lang[5];
- id[4] = lang[4] = '\0';
- if (!f.open(SUPERNOVA_DAT)) {
- GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA_DAT);
- return Common::kReadingFailed;
- }
- f.read(id, 3);
- if (strncmp(id, "MSN", 3) != 0) {
- GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA_DAT);
+ if (stream == nullptr) {
+ Common::Language l = Common::parseLanguage(ConfMan.get("language"));
+ GUIErrorMessageFormat(_("Unable to locate the text for %s language in engine data file."), Common::getLanguageDescription(l));
return Common::kReadingFailed;
}
- int version = f.readByte();
- if (version != SUPERNOVA_DAT_VERSION) {
- GUIErrorMessageFormat(
- _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."),
- SUPERNOVA_DAT, SUPERNOVA_DAT_VERSION, version);
- return Common::kReadingFailed;
+ int size = stream->size();
+ while (size > 0) {
+ Common::String s;
+ char ch;
+ while ((ch = (char)stream->readByte()) != '\0')
+ s += ch;
+ _gameStrings.push_back(s);
+ size -= s.size() + 1;
}
-
- int part;
- uint32 gameBlockSize;
- while (!f.eos()) {
- part = f.readByte();
- gameBlockSize = f.readUint32LE();
- if (f.eos()){
- GUIErrorMessageFormat(_("Unable to find block for part %d"), _MSPart);
- return Common::kReadingFailed;
- }
- if (part == _MSPart) {
- break;
- } else
- f.skip(gameBlockSize);
- }
-
- uint32 readSize = 0;
-
- while (readSize < gameBlockSize) {
- f.read(id, 4);
- f.read(lang, 4);
- uint32 size = f.readUint32LE();
- if (f.eos())
- break;
- if (string_id == id && cur_lang == lang) {
- while (size > 0) {
- Common::String s;
- char ch;
- while ((ch = (char)f.readByte()) != '\0')
- s += ch;
- _gameStrings.push_back(s);
- size -= s.size() + 1;
- }
- return Common::kNoError;
- } else {
- f.skip(size);
- readSize += size;
- }
- }
-
- Common::Language l = Common::parseLanguage(cur_lang);
- GUIErrorMessageFormat(_("Unable to locate the text for %s language in engine data file."), Common::getLanguageDescription(l));
- return Common::kReadingFailed;
+ return Common::kNoError;
}
const Common::String &SupernovaEngine::getGameString(int idx) const {