From d5608e82edb4a73f6ab30a8db9a79dc16ed2ed9f Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Fri, 3 Nov 2006 22:36:05 +0000 Subject: cleanup (got rid of the custom Language enum, re-used the one in the Common namespace) svn-id: r24595 --- engines/queen/command.cpp | 2 +- engines/queen/defs.h | 18 ------------------ engines/queen/display.cpp | 4 ++-- engines/queen/graphics.cpp | 2 +- engines/queen/input.cpp | 20 ++++++++++---------- engines/queen/input.h | 10 +++------- engines/queen/journal.cpp | 2 +- engines/queen/logic.cpp | 6 +++--- engines/queen/queen.cpp | 19 ++++++++++--------- engines/queen/queen.h | 4 ---- engines/queen/resource.cpp | 22 +++++++++++----------- engines/queen/resource.h | 2 +- engines/queen/talk.cpp | 22 +++++++++++----------- 13 files changed, 54 insertions(+), 79 deletions(-) diff --git a/engines/queen/command.cpp b/engines/queen/command.cpp index ff34238db5..5767223301 100644 --- a/engines/queen/command.cpp +++ b/engines/queen/command.cpp @@ -124,7 +124,7 @@ void CmdState::init() { Command::Command(QueenEngine *vm) : _cmdList(NULL), _cmdArea(NULL), _cmdObject(NULL), _cmdInventory(NULL), _cmdGameState(NULL), - _cmdText((vm->resource()->getLanguage() == HEBREW), CmdText::COMMAND_Y_POS, vm), _vm(vm) { + _cmdText((vm->resource()->getLanguage() == Common::HB_ISR), CmdText::COMMAND_Y_POS, vm), _vm(vm) { } Command::~Command() { diff --git a/engines/queen/defs.h b/engines/queen/defs.h index fecbf6b674..f3b98e3fe2 100644 --- a/engines/queen/defs.h +++ b/engines/queen/defs.h @@ -41,13 +41,11 @@ enum { PANEL_ZONE_HEIGHT = 50 }; - enum { FRAMES_JOE = 38, FRAMES_JOURNAL = 40 }; - enum Direction { DIR_LEFT = 1, DIR_RIGHT = 2, @@ -55,7 +53,6 @@ enum Direction { DIR_BACK = 4 }; - enum { INK_BG_PANEL = 226, INK_JOURNAL = 248, @@ -68,7 +65,6 @@ enum { INK_OUTLINED_TEXT = 16 }; - enum { ITEM_NONE = 0, ITEM_BAT, @@ -252,7 +248,6 @@ enum { ROOM_JOURNAL = 200 // dummy value to keep Display methods happy }; - //! GameState vars enum { VAR_HOTEL_ITEMS_REMOVED = 3, @@ -265,18 +260,6 @@ enum { VAR_AZURA_IN_LOVE = 167 }; - -enum Language { - ENGLISH = 'E', - FRENCH = 'F', - GERMAN = 'G', - HEBREW = 'H', - ITALIAN = 'I', - SPANISH = 'S', - RUSSIAN = 'R' -}; - - enum Verb { VERB_NONE = 0, @@ -317,7 +300,6 @@ enum Verb { VERB_PREP_TO = 12 }; - } // End of namespace Queen #endif diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp index 5f57922817..7f5e26102d 100644 --- a/engines/queen/display.cpp +++ b/engines/queen/display.cpp @@ -45,9 +45,9 @@ Display::Display(QueenEngine *vm, OSystem *system) : _fullscreen(true), _horizontalScroll(0), _bdWidth(0), _bdHeight(0), _system(system), _vm(vm) { - if (vm->resource()->getLanguage() == HEBREW) + if (vm->resource()->getLanguage() == Common::HB_ISR) _font = _fontHebrew; - else if (vm->resource()->getLanguage() == RUSSIAN) + else if (vm->resource()->getLanguage() == Common::RU_RUS) _font = _fontRussian; else _font = _fontRegular; diff --git a/engines/queen/graphics.cpp b/engines/queen/graphics.cpp index c2e34ee215..11ae2d1e27 100644 --- a/engines/queen/graphics.cpp +++ b/engines/queen/graphics.cpp @@ -469,7 +469,7 @@ void Graphics::setBobText(const BobSlot *pbs, const char *text, int textX, int t // Hebrew strings are written from right to left and should be cut // to lines in reverse - if (_vm->resource()->getLanguage() == HEBREW) { + if (_vm->resource()->getLanguage() == Common::HB_ISR) { for (i = length - 1; i >= 0; i--) { lineLength++; diff --git a/engines/queen/input.cpp b/engines/queen/input.cpp index 84e91f7a1c..82bcc9d8da 100644 --- a/engines/queen/input.cpp +++ b/engines/queen/input.cpp @@ -27,7 +27,7 @@ namespace Queen { -const char *Input::_commandKeys[LANGUAGE_COUNT] = { +const char *Input::_commandKeys[] = { "ocmglptu", // English "osbgpnre", // German "ofdnepau", // French @@ -36,7 +36,7 @@ const char *Input::_commandKeys[LANGUAGE_COUNT] = { "acodmthu" // Spanish }; -const Verb Input::_verbKeys[8] = { +const Verb Input::_verbKeys[] = { VERB_OPEN, VERB_CLOSE, VERB_MOVE, @@ -47,7 +47,7 @@ const Verb Input::_verbKeys[8] = { VERB_USE }; -Input::Input(Language language, OSystem *system) : +Input::Input(Common::Language language, OSystem *system) : _system(system), _fastMode(false), _keyVerb(VERB_NONE), _cutawayRunning(false), _canQuit(false), _cutawayQuit(false), _dialogueRunning(false), _talkQuit(false), _quickSave(false), @@ -55,23 +55,23 @@ Input::Input(Language language, OSystem *system) : _mouse_y(0), _mouseButton(0), _idleTime(0) { switch (language) { - case ENGLISH: - case RUSSIAN: + case Common::EN_ANY: + case Common::RU_RUS: _currentCommandKeys = _commandKeys[0]; break; - case GERMAN: + case Common::DE_DEU: _currentCommandKeys = _commandKeys[1]; break; - case FRENCH: + case Common::FR_FRA: _currentCommandKeys = _commandKeys[2]; break; - case ITALIAN: + case Common::IT_ITA: _currentCommandKeys = _commandKeys[3]; break; - case HEBREW: + case Common::HB_ISR: _currentCommandKeys = _commandKeys[4]; break; - case SPANISH: + case Common::ES_ESP: _currentCommandKeys = _commandKeys[5]; break; default: diff --git a/engines/queen/input.h b/engines/queen/input.h index d1e86016c9..3a36fe64ee 100644 --- a/engines/queen/input.h +++ b/engines/queen/input.h @@ -44,7 +44,7 @@ public: MOUSE_RBUTTON = 2 }; - Input(Language language, OSystem *system); + Input(Common::Language language, OSystem *system); //! calls the other delay() with a value adjusted depending on _fastMode void delay(); @@ -114,10 +114,6 @@ private: KEY_F12 }; - enum { - LANGUAGE_COUNT = 6 - }; - //! used to get keyboard and mouse events OSystem *_system; @@ -167,10 +163,10 @@ private: const char *_currentCommandKeys; //! command keys for all languages - static const char *_commandKeys[LANGUAGE_COUNT]; + static const char *_commandKeys[]; //! verbs matching the command keys - static const Verb _verbKeys[8]; + static const Verb _verbKeys[]; }; } // End of namespace Queen diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp index 1a0c511b6d..d763ae486f 100644 --- a/engines/queen/journal.cpp +++ b/engines/queen/journal.cpp @@ -387,7 +387,7 @@ void Journal::drawPanelText(int y, const char *text) { _panelTextY[_panelTextCount++] = y; } else { *p++ = '\0'; - if (_vm->resource()->getLanguage() == HEBREW) { + if (_vm->resource()->getLanguage() == Common::HB_ISR) { drawPanelText(y - 5, p); drawPanelText(y + 5, s); } else { diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp index 43a19c639d..b1675f38b3 100644 --- a/engines/queen/logic.cpp +++ b/engines/queen/logic.cpp @@ -206,7 +206,7 @@ void Logic::initialise() { } // Patch for German text bug - if (_vm->resource()->getLanguage() == GERMAN) { + if (_vm->resource()->getLanguage() == Common::DE_DEU) { _objDescription[296] = "Es bringt nicht viel, das festzubinden."; } @@ -233,7 +233,7 @@ void Logic::initialise() { // Spanish version adds some space characters (0x20) at the beginning // and the end of the journal button captions. As the engine computes // the text width to center it, we need to trim those strings. - if (_vm->resource()->getLanguage() == SPANISH) { + if (_vm->resource()->getLanguage() == Common::ES_ESP) { for (i = 30; i <= 35; i++) { _joeResponse[i] = trim(_joeResponse[i]); } @@ -1232,7 +1232,7 @@ void Logic::handlePinnacleRoom() { _entryObj = 0; uint16 prevObj = 0; - CmdText cmdText((_vm->resource()->getLanguage() == HEBREW), 5, _vm); + CmdText cmdText((_vm->resource()->getLanguage() == Common::HB_ISR), 5, _vm); cmdText.setVerb(VERB_WALK_TO); while (_vm->input()->mouseButton() == 0 || _entryObj == 0) { diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index c19945d332..df7a3ef472 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -68,8 +68,9 @@ GameDescriptor Engine_QUEEN_findGameID(const char *gameid) { return GameDescriptor(); } - -GameDescriptor determineTarget(uint32 size) { +// FIXME/TODO: it would be nice to re-use the existing code of the +// Resource class to detect the FOTAQ version. +static GameDescriptor determineTarget(uint32 size) { switch (size) { case 3724538: //regular demo case 3732177: @@ -260,14 +261,14 @@ void QueenEngine::saveGameState(uint16 slot, const char *desc) { assert(dataSize < SAVESTATE_MAX_SIZE); // write header - GameStateHeader header; - memset(&header, 0, sizeof(header)); file->writeUint32BE('SCVM'); - header.version = TO_BE_32(SAVESTATE_CUR_VER); - header.flags = TO_BE_32(0); - header.dataSize = TO_BE_32(dataSize); - strncpy(header.description, desc, sizeof(header.description) - 1); - file->write(&header, sizeof(header)); + file->writeUint32BE(SAVESTATE_CUR_VER); + file->writeUint32BE(0); + file->writeUint32BE(dataSize); + char description[32]; + memset(description, 0, 32); + strncpy(description, desc, 31); + file->write(description, 32); // write save data file->write(saveData, dataSize); diff --git a/engines/queen/queen.h b/engines/queen/queen.h index 5cefd35cd3..d51ad97abc 100644 --- a/engines/queen/queen.h +++ b/engines/queen/queen.h @@ -49,8 +49,6 @@ FORCEINLINE int16 READ_BE_INT16(const void *ptr) { namespace Queen { -#include "common/pack-start.h" // START STRUCT PACKING - struct GameStateHeader { uint32 version; uint32 flags; @@ -58,8 +56,6 @@ struct GameStateHeader { char description[32]; }; -#include "common/pack-end.h" // END STRUCT PACKING - class BamScene; class BankManager; class Command; diff --git a/engines/queen/resource.cpp b/engines/queen/resource.cpp index 2545dd6127..eee279fae5 100644 --- a/engines/queen/resource.cpp +++ b/engines/queen/resource.cpp @@ -172,24 +172,25 @@ void Resource::checkJASVersion() { error("Verifying game version failed! (expected: '%s', found: '%s')", _versionString, versionStr); } -Language Resource::getLanguage() const { +Common::Language Resource::getLanguage() const { switch (_versionString[1]) { case 'E': if (Common::parseLanguage(ConfMan.get("language")) == Common::RU_RUS) - return RUSSIAN; - return ENGLISH; + return Common::RU_RUS; + return Common::EN_ANY; case 'G': - return GERMAN; + return Common::DE_DEU; case 'F': - return FRENCH; + return Common::FR_FRA; case 'I': - return ITALIAN; + return Common::IT_ITA; case 'S': - return SPANISH; + return Common::ES_ESP; case 'H': - return HEBREW; + return Common::HB_ISR; default: - return ENGLISH; + warning("Unknown language id '%c', defaulting to English", _versionString[1]); + return Common::EN_ANY; } } @@ -211,8 +212,7 @@ void Resource::readTableCompResource() { error("Invalid table header"); _resourceFile->read(_versionString, 6); - _resourceFile->readByte(); // obsolete - _resourceFile->readByte(); // obsolete + _resourceFile->skip(2); // obsolete _compression = _resourceFile->readByte(); readTableEntries(_resourceFile); diff --git a/engines/queen/resource.h b/engines/queen/resource.h index e205490eca..cb2851d27e 100644 --- a/engines/queen/resource.h +++ b/engines/queen/resource.h @@ -83,7 +83,7 @@ public: const char *JASVersion() const { return _versionString; } //! returns language of the game - Language getLanguage() const; + Common::Language getLanguage() const; enum Version { VER_ENG_FLOPPY = 0, diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp index 2b8d3c9508..bf025523fb 100644 --- a/engines/queen/talk.cpp +++ b/engines/queen/talk.cpp @@ -348,15 +348,15 @@ void Talk::findDialogueString(uint16 offset, int16 id, int16 max, char *str) { byte *Talk::loadDialogFile(const char *filename) { static const struct { const char *filename; - Language lang; + Common::Language language; } dogFiles[] = { - { "chief1.dog", FRENCH }, - { "chief2.dog", FRENCH }, - { "bud1.dog", ITALIAN } + { "chief1.dog", Common::FR_FRA }, + { "chief2.dog", Common::FR_FRA }, + { "bud1.dog", Common::IT_ITA } }; for (int i = 0; i < ARRAYSIZE(dogFiles); ++i) { if (!scumm_stricmp(filename, dogFiles[i].filename) && - _vm->resource()->getLanguage() == dogFiles[i].lang) { + _vm->resource()->getLanguage() == dogFiles[i].language) { Common::File fdog; fdog.open(filename); if (fdog.isOpen()) { @@ -798,7 +798,7 @@ void Talk::speakSegment( // French talkie version has a useless voice file ; c30e_102 file is the same as c30e_101, // so there is no need to play it. This voice was used in room 30 (N8) when talking to Klunk. - if (!(_vm->resource()->getLanguage() == FRENCH && !strcmp(voiceFileName, "c30e_102")) + if (!(_vm->resource()->getLanguage() == Common::FR_FRA && !strcmp(voiceFileName, "c30e_102")) && _vm->sound()->speechOn()) _vm->sound()->playSfx(voiceFileName, true); @@ -1076,10 +1076,10 @@ int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) { } int lines; memset(optionText, 0, 5 * MAX_STRING_SIZE); - if (_vm->resource()->getLanguage() == ENGLISH || _vm->display()->textWidth(option) <= MAX_TEXT_WIDTH) { + if (_vm->resource()->getLanguage() == Common::EN_ANY || _vm->display()->textWidth(option) <= MAX_TEXT_WIDTH) { strcpy(optionText[0], option); lines = 1; - } else if (_vm->resource()->getLanguage() == HEBREW) { + } else if (_vm->resource()->getLanguage() == Common::HB_ISR) { lines = splitOptionHebrew(option, optionText); } else { lines = splitOptionDefault(option, optionText); @@ -1196,7 +1196,7 @@ int16 Talk::selectSentence() { _vm->grid()->clear(GS_PANEL); - if (_vm->resource()->getLanguage() != ENGLISH) { + if (_vm->resource()->getLanguage() != Common::EN_ANY) { _vm->grid()->setZone(GS_PANEL, ARROW_ZONE_UP, MAX_TEXT_WIDTH + 1, 0, 319, 24); _vm->grid()->setZone(GS_PANEL, ARROW_ZONE_DOWN, MAX_TEXT_WIDTH + 1, 25, 319, 49); } @@ -1219,7 +1219,7 @@ int16 Talk::selectSentence() { i, 0, yOffset * LINE_HEIGHT - PUSHUP, - (_vm->resource()->getLanguage() == ENGLISH) ? 319 : MAX_TEXT_WIDTH, + (_vm->resource()->getLanguage() == Common::EN_ANY) ? 319 : MAX_TEXT_WIDTH, (yOffset + optionLines) * LINE_HEIGHT - PUSHUP); } @@ -1242,7 +1242,7 @@ int16 Talk::selectSentence() { // Up and down dialogue arrows - if (_vm->resource()->getLanguage() != ENGLISH) { + if (_vm->resource()->getLanguage() != Common::EN_ANY) { arrowBobUp->active = (startOption > 1); arrowBobDown->active = (yOffset > 4); } -- cgit v1.2.3