diff options
Diffstat (limited to 'engines/drascula')
-rw-r--r-- | engines/drascula/detection.cpp | 30 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 8 | ||||
-rw-r--r-- | engines/drascula/interface.cpp | 2 | ||||
-rw-r--r-- | engines/drascula/resource.cpp | 9 | ||||
-rw-r--r-- | engines/drascula/saveload.cpp | 109 | ||||
-rw-r--r-- | engines/drascula/sound.cpp | 1 |
6 files changed, 83 insertions, 76 deletions
diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index 6ba5597e8a..0969ad4131 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -63,8 +63,6 @@ static const PlainGameDescriptor drasculaGames[] = { namespace Drascula { -using Common::GUIO_NONE; - static const DrasculaGameDescription gameDescriptions[] = { { // Drascula English version @@ -75,7 +73,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -95,7 +93,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -112,7 +110,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -129,7 +127,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -142,7 +140,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -155,7 +153,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -168,7 +166,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -181,7 +179,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -194,7 +192,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, { @@ -206,7 +204,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -223,7 +221,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -240,7 +238,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -257,7 +255,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformPC, GF_PACKED, - GUIO_NONE + GUIO1(GUIO_NONE) }, }, @@ -270,7 +268,7 @@ class DrasculaMetaEngine : public AdvancedMetaEngine { public: DrasculaMetaEngine() : AdvancedMetaEngine(Drascula::gameDescriptions, sizeof(Drascula::DrasculaGameDescription), drasculaGames) { _singleid = "drascula"; - _guioptions = Common::GUIO_NOMIDI | Common::GUIO_NOLAUNCHLOAD; + _guioptions = GUIO2(GUIO_NOMIDI, GUIO_NOLAUNCHLOAD); } virtual const char *getName() const { diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 2b6aa0f291..6f98c50fdc 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -30,6 +30,7 @@ #include "common/file.h" #include "common/hash-str.h" #include "common/keyboard.h" +#include "common/ptr.h" #include "common/random.h" #include "common/savefile.h" #include "common/system.h" @@ -264,15 +265,13 @@ private: }; class TextResourceParser { - Common::SeekableReadStream *_stream; - DisposeAfterUse::Flag _dispose; + Common::DisposablePtr<Common::SeekableReadStream> _stream; int _maxLen; void getLine(char *buf); public: TextResourceParser(Common::SeekableReadStream *stream, DisposeAfterUse::Flag dispose); - ~TextResourceParser(); void parseInt(int &result); void parseString(char *result); @@ -496,6 +495,8 @@ public: void updateVolume(Audio::Mixer::SoundType soundType, int prevVolume); void volumeControls(); bool saveLoadScreen(); + void loadSaveNames(); + void saveSaveNames(); void print_abc(const char *, int, int); void delay(int ms); bool confirmExit(); @@ -776,6 +777,7 @@ private: RoomUpdate *_roomPreUpdates, *_roomUpdates; RoomTalkAction *_roomActions; TalkSequenceCommand *_talkSequences; + char _saveNames[10][23]; char **loadTexts(Common::File &in); void freeTexts(char **ptr); diff --git a/engines/drascula/interface.cpp b/engines/drascula/interface.cpp index eb36baed18..e3a97087c0 100644 --- a/engines/drascula/interface.cpp +++ b/engines/drascula/interface.cpp @@ -159,7 +159,7 @@ void DrasculaEngine::enterName() { key = getScan(); if (key != 0) { - if (key >= 0 && key <= 0xFF && isalpha(key)) + if (key >= 0 && key <= 0xFF && isalpha(static_cast<unsigned char>(key))) select2[v] = tolower(key); else if ((key >= Common::KEYCODE_0 && key <= Common::KEYCODE_9) || key == Common::KEYCODE_SPACE) select2[v] = key; diff --git a/engines/drascula/resource.cpp b/engines/drascula/resource.cpp index 6da43e7cba..95a95e3487 100644 --- a/engines/drascula/resource.cpp +++ b/engines/drascula/resource.cpp @@ -42,7 +42,7 @@ Common::SeekableReadStream *ArchiveMan::open(const Common::String &filename) { } TextResourceParser::TextResourceParser(Common::SeekableReadStream *stream, DisposeAfterUse::Flag dispose) : - _stream(stream), _dispose(dispose) { + _stream(stream, dispose) { // NOTE: strangely enough, the code before this refactoring used the size of // the stream as a fixed maximum length for the parser. Using an updated @@ -50,12 +50,6 @@ TextResourceParser::TextResourceParser(Common::SeekableReadStream *stream, Dispo _maxLen = _stream->size(); } -TextResourceParser::~TextResourceParser() { - if (_dispose == DisposeAfterUse::YES) { - delete _stream; - } -} - void TextResourceParser::getLine(char *buf) { byte c; char *b; @@ -101,4 +95,3 @@ void TextResourceParser::parseString(char* result) { } // End of namespace Drascula - diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp index 664a082eb4..c8622f3c92 100644 --- a/engines/drascula/saveload.cpp +++ b/engines/drascula/saveload.cpp @@ -26,20 +26,26 @@ namespace Drascula { -bool DrasculaEngine::saveLoadScreen() { - char names[10][23]; - Common::String file; - int n, n2, num_sav = 0, y = 27; +/** + * Loads the save names from the EPA index file. + * + * TODO: We should move the save names in their respective save files and get + * rid of this completely. A good example is the sword1 engine, which also used + * to have an index file for its saves, that has been removed. + * sword1 contains code that converts the old index-based saves into the new + * format without the index file, so we could apply this idea to drascula as + * well. + */ +void DrasculaEngine::loadSaveNames() { Common::InSaveFile *sav; - - clearRoom(); - Common::String fileEpa = Common::String::format("%s.epa", _targetName.c_str()); + + // Create and initialize the index file, if it doesn't exist if (!(sav = _saveFileMan->openForLoading(fileEpa))) { Common::OutSaveFile *epa; if (!(epa = _saveFileMan->openForSaving(fileEpa))) error("Can't open %s file", fileEpa.c_str()); - for (n = 0; n < NUM_SAVES; n++) + for (int n = 0; n < NUM_SAVES; n++) epa->writeString("*\n"); epa->finalize(); delete epa; @@ -47,11 +53,47 @@ bool DrasculaEngine::saveLoadScreen() { error("Can't open %s file", fileEpa.c_str()); } } - for (n = 0; n < NUM_SAVES; n++) { - strncpy(names[n], sav->readLine().c_str(), 23); - names[n][22] = '\0'; // make sure the savegame name is 0-terminated + + // Load the index file + for (int n = 0; n < NUM_SAVES; n++) { + strncpy(_saveNames[n], sav->readLine().c_str(), 23); + _saveNames[n][22] = '\0'; // make sure the savegame name is 0-terminated } delete sav; +} + +/** + * Saves the save names into the EPA index file. + * + * TODO: We should move the save names in their respective save files and get + * rid of this completely. A good example is the sword1 engine, which also used + * to have an index file for its saves, that has been removed. + * sword1 contains code that converts the old index-based saves into the new + * format without the index file, so we could apply this idea to drascula as + * well. + */ +void DrasculaEngine::saveSaveNames() { + Common::OutSaveFile *tsav; + Common::String fileEpa = Common::String::format("%s.epa", _targetName.c_str()); + + if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { + error("Can't open %s file", fileEpa.c_str()); + } + for (int n = 0; n < NUM_SAVES; n++) { + tsav->writeString(_saveNames[n]); + tsav->writeString("\n"); + } + tsav->finalize(); + delete tsav; +} + +bool DrasculaEngine::saveLoadScreen() { + Common::String file; + int n, n2, num_sav = 0, y = 27; + + clearRoom(); + + loadSaveNames(); loadPic("savescr.alg", bgSurface, HALF_PAL); @@ -66,7 +108,7 @@ bool DrasculaEngine::saveLoadScreen() { y = 27; copyBackground(); for (n = 0; n < NUM_SAVES; n++) { - print_abc(names[n], 116, y); + print_abc(_saveNames[n], 116, y); y = y + 9; } print_abc(select, 117, 15); @@ -79,33 +121,24 @@ bool DrasculaEngine::saveLoadScreen() { delay(50); for (n = 0; n < NUM_SAVES; n++) { if (mouseX > 115 && mouseY > y + (9 * n) && mouseX < 115 + 175 && mouseY < y + 10 + (9 * n)) { - strcpy(select, names[n]); + strcpy(select, _saveNames[n]); if (strcmp(select, "*")) selectionMade = 1; else { enterName(); - strcpy(names[n], select); + strcpy(_saveNames[n], select); if (selectionMade == 1) { file = Common::String::format("%s%02d", _targetName.c_str(), n + 1); saveGame(file.c_str()); - Common::OutSaveFile *tsav; - if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { - error("Can't open %s file", fileEpa.c_str()); - } - for (n = 0; n < NUM_SAVES; n++) { - tsav->writeString(names[n]); - tsav->writeString("\n"); - } - tsav->finalize(); - delete tsav; + saveSaveNames(); } } print_abc(select, 117, 15); y = 27; for (n2 = 0; n2 < NUM_SAVES; n2++) { - print_abc(names[n2], 116, y); + print_abc(_saveNames[n2], 116, y); y = y + 9; } if (selectionMade == 1) { @@ -117,27 +150,18 @@ bool DrasculaEngine::saveLoadScreen() { if (mouseX > 117 && mouseY > 15 && mouseX < 295 && mouseY < 24 && selectionMade == 1) { enterName(); - strcpy(names[num_sav], select); + strcpy(_saveNames[num_sav], select); print_abc(select, 117, 15); y = 27; for (n2 = 0; n2 < NUM_SAVES; n2++) { - print_abc(names[n2], 116, y); + print_abc(_saveNames[n2], 116, y); y = y + 9; } if (selectionMade == 1) { file = Common::String::format("%s%02d", _targetName.c_str(), n + 1); saveGame(file.c_str()); - Common::OutSaveFile *tsav; - if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { - error("Can't open %s file", fileEpa.c_str()); - } - for (n = 0; n < NUM_SAVES; n++) { - tsav->writeString(names[n]); - tsav->writeString("\n"); - } - tsav->finalize(); - delete tsav; + saveSaveNames(); } } @@ -149,16 +173,7 @@ bool DrasculaEngine::saveLoadScreen() { break; } else if (mouseX > 208 && mouseY > 123 && mouseX < 282 && mouseY < 149 && selectionMade == 1) { saveGame(file.c_str()); - Common::OutSaveFile *tsav; - if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { - error("Can't open %s file", fileEpa.c_str()); - } - for (n = 0; n < NUM_SAVES; n++) { - tsav->writeString(names[n]); - tsav->writeString("\n"); - } - tsav->finalize(); - delete tsav; + saveSaveNames(); } else if (mouseX > 168 && mouseY > 154 && mouseX < 242 && mouseY < 180) break; else if (selectionMade == 0) { diff --git a/engines/drascula/sound.cpp b/engines/drascula/sound.cpp index 4721d2d369..413a631118 100644 --- a/engines/drascula/sound.cpp +++ b/engines/drascula/sound.cpp @@ -23,7 +23,6 @@ #include "audio/audiostream.h" #include "audio/mixer.h" #include "audio/decoders/raw.h" -#include "audio/decoders/voc.h" #include "common/config-manager.h" #include "common/textconsole.h" |