diff options
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/actor.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/boxes.cpp | 12 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 63 | ||||
-rw-r--r-- | engines/scumm/gfx.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/help.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/imuse/imuse.cpp | 27 | ||||
-rw-r--r-- | engines/scumm/imuse/imuse_internal.h | 10 | ||||
-rw-r--r-- | engines/scumm/imuse/imuse_part.cpp | 3 | ||||
-rw-r--r-- | engines/scumm/imuse/imuse_player.cpp | 47 | ||||
-rw-r--r-- | engines/scumm/imuse/sysex_scumm.cpp | 8 | ||||
-rw-r--r-- | engines/scumm/input.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/object.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/palette.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/player_towns.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/player_v4a.h | 2 | ||||
-rw-r--r-- | engines/scumm/saveload.cpp | 19 | ||||
-rw-r--r-- | engines/scumm/script_v5.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 3 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 12 | ||||
-rw-r--r-- | engines/scumm/scumm_v0.h | 2 | ||||
-rw-r--r-- | engines/scumm/string.cpp | 3 |
21 files changed, 140 insertions, 91 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 25a26f6cf2..e4057d1f13 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -2747,7 +2747,7 @@ void Actor::saveLoadWithSerializer(Serializer *ser) { if (ser->isLoading()) { // Not all actor data is saved; so when loading, we first reset - // the actor, to ensure completely reproducible behaviour (else, + // the actor, to ensure completely reproducible behavior (else, // some not saved value in the actor class can cause odd things) initActor(-1); } diff --git a/engines/scumm/boxes.cpp b/engines/scumm/boxes.cpp index ba4dedfbd3..64d4d7422c 100644 --- a/engines/scumm/boxes.cpp +++ b/engines/scumm/boxes.cpp @@ -726,7 +726,7 @@ int ScummEngine::getNextBox(byte from, byte to) { dest = to; do { dest = itineraryMatrix[numOfBoxes * from + dest]; - } while (dest != Actor::kInvalidBox && !areBoxesNeighbours(from, dest)); + } while (dest != Actor::kInvalidBox && !areBoxesNeighbors(from, dest)); if (dest == Actor::kInvalidBox) dest = -1; @@ -962,7 +962,7 @@ void ScummEngine::calcItineraryMatrix(byte *itineraryMatrix, int num) { // Allocate the adjacent & itinerary matrices adjacentMatrix = (byte *)malloc(boxSize * boxSize); - // Initialise the adjacent matrix: each box has distance 0 to itself, + // Initialize the adjacent matrix: each box has distance 0 to itself, // and distance 1 to its direct neighbors. Initially, it has distance // 255 (= infinity) to all other boxes. for (i = 0; i < num; i++) { @@ -970,7 +970,7 @@ void ScummEngine::calcItineraryMatrix(byte *itineraryMatrix, int num) { if (i == j) { adjacentMatrix[i * boxSize + j] = 0; itineraryMatrix[i * boxSize + j] = j; - } else if (areBoxesNeighbours(i, j)) { + } else if (areBoxesNeighbors(i, j)) { adjacentMatrix[i * boxSize + j] = 1; itineraryMatrix[i * boxSize + j] = j; } else { @@ -1060,8 +1060,8 @@ void ScummEngine::createBoxMatrix() { free(itineraryMatrix); } -/** Check if two boxes are neighbours. */ -bool ScummEngine::areBoxesNeighbours(int box1nr, int box2nr) { +/** Check if two boxes are neighbors. */ +bool ScummEngine::areBoxesNeighbors(int box1nr, int box2nr) { Common::Point tmp; BoxCoords box; BoxCoords box2; @@ -1158,7 +1158,7 @@ bool ScummEngine::areBoxesNeighbours(int box1nr, int box2nr) { return false; } -bool ScummEngine_v0::areBoxesNeighbours(int box1nr, int box2nr) { +bool ScummEngine_v0::areBoxesNeighbors(int box1nr, int box2nr) { int i; const int numOfBoxes = getNumBoxes(); const byte *boxm; diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index bba26961c7..aecd13db5a 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -69,26 +69,26 @@ static const MD5Table *findInMD5Table(const char *md5) { Common::String ScummEngine::generateFilename(const int room) const { const int diskNumber = (room > 0) ? _res->_types[rtRoom][room]._roomno : 0; - char buf[128]; + Common::String result; if (_game.version == 4) { if (room == 0 || room >= 900) { - snprintf(buf, sizeof(buf), "%03d.lfl", room); + result = Common::String::format("%03d.lfl", room); } else { - snprintf(buf, sizeof(buf), "disk%02d.lec", diskNumber); + result = Common::String::format("disk%02d.lec", diskNumber); } } else { switch (_filenamePattern.genMethod) { case kGenDiskNum: - snprintf(buf, sizeof(buf), _filenamePattern.pattern, diskNumber); + result = Common::String::format(_filenamePattern.pattern, diskNumber); break; case kGenRoomNum: - snprintf(buf, sizeof(buf), _filenamePattern.pattern, room); + result = Common::String::format(_filenamePattern.pattern, room); break; case kGenUnchanged: - strncpy(buf, _filenamePattern.pattern, sizeof(buf)); + result = _filenamePattern.pattern; break; default: @@ -96,11 +96,11 @@ Common::String ScummEngine::generateFilename(const int room) const { } } - return buf; + return result; } Common::String ScummEngine_v60he::generateFilename(const int room) const { - char buf[128]; + Common::String result; char id = 0; switch (_filenamePattern.genMethod) { @@ -115,16 +115,16 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const { } if (_filenamePattern.genMethod == kGenHEPC) { - snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id); + result = Common::String::format("%s.he%c", _filenamePattern.pattern, id); } else { if (id == '3') { // special case for cursors // For mac they're stored in game binary - strncpy(buf, _filenamePattern.pattern, sizeof(buf)); + result = _filenamePattern.pattern; } else { if (_filenamePattern.genMethod == kGenHEMac) - snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id); + result = Common::String::format("%s (%c)", _filenamePattern.pattern, id); else - snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id); + result = Common::String::format("%s %c", _filenamePattern.pattern, id); } } @@ -135,11 +135,11 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const { return ScummEngine::generateFilename(room); } - return buf; + return result; } Common::String ScummEngine_v70he::generateFilename(const int room) const { - char buf[128]; + Common::String result; char id = 0; switch (_filenamePattern.genMethod) { @@ -156,19 +156,19 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const { id = 'b'; // Special cases for Blue's games, which share common (b) files if (_game.id == GID_BIRTHDAY && !(_game.features & GF_DEMO)) - strcpy(buf, "Blue'sBirthday.(b)"); + result = "Blue'sBirthday.(b)"; else if (_game.id == GID_TREASUREHUNT) - strcpy(buf, "Blue'sTreasureHunt.(b)"); + result = "Blue'sTreasureHunt.(b)"; else - snprintf(buf, sizeof(buf), "%s.(b)", _filenamePattern.pattern); + result = Common::String::format("%s.(b)", _filenamePattern.pattern); break; case 1: id = 'a'; - snprintf(buf, sizeof(buf), "%s.(a)", _filenamePattern.pattern); + result = Common::String::format("%s.(a)", _filenamePattern.pattern); break; default: id = '0'; - snprintf(buf, sizeof(buf), "%s.he0", _filenamePattern.pattern); + result = Common::String::format("%s.he0", _filenamePattern.pattern); } } else if (room < 0) { id = '0' - room; @@ -179,16 +179,16 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const { if (_filenamePattern.genMethod == kGenHEPC) { // For HE >= 98, we already called snprintf above. if (_game.heversion < 98 || room < 0) - snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id); + result = Common::String::format("%s.he%c", _filenamePattern.pattern, id); } else { if (id == '3') { // special case for cursors // For mac they're stored in game binary - strncpy(buf, _filenamePattern.pattern, sizeof(buf)); + result = _filenamePattern.pattern; } else { if (_filenamePattern.genMethod == kGenHEMac) - snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id); + result = Common::String::format("%s (%c)", _filenamePattern.pattern, id); else - snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id); + result = Common::String::format("%s %c", _filenamePattern.pattern, id); } } @@ -199,40 +199,39 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const { return ScummEngine_v60he::generateFilename(room); } - return buf; + return result; } static Common::String generateFilenameForDetection(const char *pattern, FilenameGenMethod genMethod) { - char buf[128]; + Common::String result; switch (genMethod) { case kGenDiskNum: case kGenRoomNum: - snprintf(buf, sizeof(buf), pattern, 0); + result = Common::String::format(pattern, 0); break; case kGenHEPC: - snprintf(buf, sizeof(buf), "%s.he0", pattern); + result = Common::String::format("%s.he0", pattern); break; case kGenHEMac: - snprintf(buf, sizeof(buf), "%s (0)", pattern); + result = Common::String::format("%s (0)", pattern); break; case kGenHEMacNoParens: - snprintf(buf, sizeof(buf), "%s 0", pattern); + result = Common::String::format("%s 0", pattern); break; case kGenUnchanged: - strncpy(buf, pattern, sizeof(buf)); + result = pattern; break; default: error("generateFilenameForDetection: Unsupported genMethod"); } - buf[sizeof(buf) - 1] = 0; - return buf; + return result; } struct DetectorDesc { diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 08ae9fdd96..1b913e16b4 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -583,7 +583,7 @@ void ScummEngine::updateDirtyScreen(VirtScreenNumber slot) { vs->tdirty[i] = vs->h; vs->bdirty[i] = 0; if (i != (_gdi->_numStrips - 1) && vs->bdirty[i + 1] == bottom && vs->tdirty[i + 1] == top) { - // Simple optimizations: if two or more neighbouring strips + // Simple optimizations: if two or more neighboring strips // form one bigger rectangle, coalesce them. w += 8; continue; diff --git a/engines/scumm/help.cpp b/engines/scumm/help.cpp index 59bf79658e..ae7a1ad3bc 100644 --- a/engines/scumm/help.cpp +++ b/engines/scumm/help.cpp @@ -107,7 +107,7 @@ void ScummHelp::updateStrings(byte gameId, byte version, Common::Platform platfo ADD_TEXT(_("* Note that using ctrl-f and")); ADD_TEXT(_(" ctrl-g are not recommended")); ADD_TEXT(_(" since they may cause crashes")); - ADD_TEXT(_(" or incorrect game behaviour.")); + ADD_TEXT(_(" or incorrect game behavior.")); break; case 3: if (gameId == GID_LOOM) diff --git a/engines/scumm/imuse/imuse.cpp b/engines/scumm/imuse/imuse.cpp index fe23b88e52..7d971f5ca4 100644 --- a/engines/scumm/imuse/imuse.cpp +++ b/engines/scumm/imuse/imuse.cpp @@ -99,8 +99,9 @@ IMuseInternal::~IMuseInternal() { } } -byte *IMuseInternal::findStartOfSound(int sound) { +byte *IMuseInternal::findStartOfSound(int sound, int ct) { int32 size, pos; + static uint32 id[] = { 'MThd', 'FORM', 'MDhd', 'MDpg' }; byte *ptr = g_scumm->_res->_types[rtSound][sound]._address; @@ -110,10 +111,11 @@ byte *IMuseInternal::findStartOfSound(int sound) { } // Check for old-style headers first, like 'RO' + int trFlag = (kMThd | kFORM); if (ptr[0] == 'R' && ptr[1] == 'O'&& ptr[2] != 'L') - return ptr; + return ct == trFlag ? ptr : 0; if (ptr[4] == 'S' && ptr[5] == 'O') - return ptr + 4; + return ct == trFlag ? ptr + 4 : 0; ptr += 4; size = READ_BE_UINT32(ptr); @@ -124,12 +126,16 @@ byte *IMuseInternal::findStartOfSound(int sound) { size = 48; // Arbitrary; we should find our tag within the first 48 bytes of the resource pos = 0; while (pos < size) { - if (!memcmp(ptr + pos, "MThd", 4) || !memcmp(ptr + pos, "FORM", 4)) - return ptr + pos; + for (int i = 0; i < ARRAYSIZE(id); ++i) { + if ((ct & (1 << i)) && (READ_BE_UINT32(ptr + pos) == id[i])) + return ptr + pos; + } ++pos; // We could probably iterate more intelligently } - debug(3, "IMuseInternal::findStartOfSound(): Failed to align on sound %d", sound); + if (ct == (kMThd | kFORM)) + debug(3, "IMuseInternal::findStartOfSound(): Failed to align on sound %d", sound); + return 0; } @@ -556,7 +562,7 @@ bool IMuseInternal::startSound_internal(int sound, int offset) { return false; } - void *ptr = findStartOfSound(sound); + byte *ptr = findStartOfSound(sound); if (!ptr) { debug(2, "IMuseInternal::startSound(): Couldn't find sound %d", sound); return false; @@ -576,8 +582,11 @@ bool IMuseInternal::startSound_internal(int sound, int offset) { // Bug #590511 and Patch #607175 (which was reversed to fix // an FOA regression: Bug #622606). Player *player = findActivePlayer(sound); - if (!player) - player = allocate_player(128); + if (!player) { + ptr = findStartOfSound(sound, IMuseInternal::kMDhd); + player = allocate_player(ptr ? (READ_BE_UINT32(&ptr[4]) && ptr[10] ? ptr[10] : 128) : 128); + } + if (!player) return false; diff --git a/engines/scumm/imuse/imuse_internal.h b/engines/scumm/imuse/imuse_internal.h index ec60b22509..8808a3655a 100644 --- a/engines/scumm/imuse/imuse_internal.h +++ b/engines/scumm/imuse/imuse_internal.h @@ -229,6 +229,7 @@ protected: // Sequencer part int start_seq_sound(int sound, bool reset_vars = true); + void loadStartParameters(int sound); int query_param(int param); public: @@ -445,7 +446,14 @@ protected: static void midiTimerCallback(void *data); void on_timer(MidiDriver *midi); - byte *findStartOfSound(int sound); + enum ChunkType { + kMThd = 1, + kFORM = 2, + kMDhd = 4, // Used in MI2 and INDY4. Contain certain start parameters (priority, volume, etc. ) for the player. + kMDpg = 8 // These chunks exist in DOTT and SAMNMAX. They don't get processed, however. + }; + + byte *findStartOfSound(int sound, int ct = (kMThd | kFORM)); bool isMT32(int sound); bool isMIDI(int sound); int get_queue_sound_status(int sound) const; diff --git a/engines/scumm/imuse/imuse_part.cpp b/engines/scumm/imuse/imuse_part.cpp index 808af23dde..5df8407a96 100644 --- a/engines/scumm/imuse/imuse_part.cpp +++ b/engines/scumm/imuse/imuse_part.cpp @@ -137,7 +137,8 @@ void Part::set_pan(int8 pan) { } void Part::set_transpose(int8 transpose) { - _transpose_eff = transpose_clamp((_transpose = transpose) + _player->getTranspose(), -24, 24); + _transpose = transpose; + _transpose_eff = (_transpose == -128) ? 0 : transpose_clamp(_transpose + _player->getTranspose(), -24, 24); sendPitchBend(); } diff --git a/engines/scumm/imuse/imuse_player.cpp b/engines/scumm/imuse/imuse_player.cpp index e7ee935130..0b084f3116 100644 --- a/engines/scumm/imuse/imuse_player.cpp +++ b/engines/scumm/imuse/imuse_player.cpp @@ -90,7 +90,7 @@ Player::~Player() { } bool Player::startSound(int sound, MidiDriver *midi) { - void *ptr; + byte *ptr; int i; // Not sure what the old code was doing, @@ -108,13 +108,8 @@ bool Player::startSound(int sound, MidiDriver *midi) { _active = true; _midi = midi; _id = sound; - _priority = 0x80; - _volume = 0x7F; - _vol_chan = 0xFFFF; - _vol_eff = (_se->get_channel_volume(0xFFFF) << 7) >> 7; - _pan = 0; - _transpose = 0; - _detune = 0; + + loadStartParameters(sound); for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i) _parameterFaders[i].init(); @@ -125,7 +120,7 @@ bool Player::startSound(int sound, MidiDriver *midi) { _midi = NULL; return false; } - + debugC(DEBUG_IMUSE, "Starting music %d", sound); return true; } @@ -199,11 +194,43 @@ int Player::start_seq_sound(int sound, bool reset_vars) { _parser->property(MidiParser::mpSmartJump, 1); _parser->loadMusic(ptr, 0); _parser->setTrack(_track_index); - setSpeed(reset_vars ? 128 : _speed); + + ptr = _se->findStartOfSound(sound, IMuseInternal::kMDhd); + setSpeed(reset_vars ? (ptr ? (READ_BE_UINT32(&ptr[4]) && ptr[15] ? ptr[15] : 128) : 128) : _speed); return 0; } +void Player::loadStartParameters(int sound) { + _priority = 0x80; + _volume = 0x7F; + _vol_chan = 0xFFFF; + _vol_eff = (_se->get_channel_volume(0xFFFF) << 7) >> 7; + _pan = 0; + _transpose = 0; + _detune = 0; + + byte *ptr = _se->findStartOfSound(sound, IMuseInternal::kMDhd); + uint32 size = 0; + + if (ptr) { + ptr += 4; + size = READ_BE_UINT32(ptr); + ptr += 4; + + // MDhd chunks don't get used in MI1 and contain only zeroes. + // We check for volume, priority and speed settings of zero here. + if (size && (ptr[2] | ptr[3] | ptr[7])) { + _priority = ptr[2]; + _volume = ptr[3]; + _pan = ptr[4]; + _transpose = ptr[5]; + _detune = ptr[6]; + setSpeed(ptr[7]); + } + } +} + void Player::uninit_parts() { assert(!_parts || _parts->_player == this); diff --git a/engines/scumm/imuse/sysex_scumm.cpp b/engines/scumm/imuse/sysex_scumm.cpp index 6ab71c2fa5..4eb3bee93c 100644 --- a/engines/scumm/imuse/sysex_scumm.cpp +++ b/engines/scumm/imuse/sysex_scumm.cpp @@ -64,6 +64,11 @@ void sysexHandler_Scumm(Player *player, const byte *msg, uint16 len) { // BYTE 14: Pitchbend range(lower 4 bits) [bug #1088045] // BYTE 15: Program(upper 4 bits) // BYTE 16: Program(lower 4 bits) + + // athrxx (05-21-2011): + // BYTE 9, 10: Transpose (if set to 0x80, this means that part->_transpose_eff will be 0 (also ignoring player->_transpose) + // BYTE 11, 12: Detune + part = player->getPart(p[0] & 0x0F); if (part) { part->set_onoff(p[2] & 0x01); @@ -71,7 +76,8 @@ void sysexHandler_Scumm(Player *player, const byte *msg, uint16 len) { part->set_pri(p[4]); part->volume((p[5] & 0x0F) << 4 |(p[6] & 0x0F)); part->set_pan((p[7] & 0x0F) << 4 | (p[8] & 0x0F)); - part->_percussion = player->_isMIDI ? ((p[9] & 0x08) > 0) : false; + part->_percussion = player->_isMIDI ? ((p[9] & 0x08) > 0) : false; + part->set_transpose((p[9] & 0x0F) << 4 | (p[10] & 0x0F)); part->set_detune((p[11] & 0x0F) << 4 | (p[12] & 0x0F)); part->pitchBendFactor((p[13] & 0x0F) << 4 | (p[14] & 0x0F)); if (part->_percussion) { diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 1a4ed91f1c..07c52578c3 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -117,7 +117,7 @@ void ScummEngine::parseEvent(Common::Event event) { if (_saveLoadSlot == 0) _saveLoadSlot = 10; - sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot); + _saveLoadDescription = Common::String::format("Quicksave %d", _saveLoadSlot); _saveLoadFlag = (event.kbd.hasFlags(Common::KBD_ALT)) ? 1 : 2; _saveTemporaryState = false; } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) { @@ -303,14 +303,14 @@ void ScummEngine::processInput() { if ((_leftBtnPressed & msClicked) && (_rightBtnPressed & msClicked) && _game.version >= 4) { // Pressing both mouse buttons is treated as if you pressed // the cutscene exit key (ESC) in V4+ games. That mimicks - // the behaviour of the original engine where pressing both + // the behavior of the original engine where pressing both // mouse buttons also skips the current cutscene. _mouseAndKeyboardStat = 0; lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } else if ((_rightBtnPressed & msClicked) && (_game.version <= 3 && _game.id != GID_LOOM)) { // Pressing right mouse button is treated as if you pressed // the cutscene exit key (ESC) in V0-V3 games. That mimicks - // the behaviour of the original engine where pressing right + // the behavior of the original engine where pressing right // mouse button also skips the current cutscene. _mouseAndKeyboardStat = 0; lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index fb99d6ce7d..ae4bbc45a6 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -101,7 +101,7 @@ void ScummEngine::setOwnerOf(int obj, int owner) { // In Sam & Max this is necessary, or you won't get your stuff back // from the Lost and Found tent after riding the Cone of Tragedy. But // it probably applies to all V6+ games. See bugs #493153 and #907113. - // FT disassembly is checked, behaviour is correct. [sev] + // FT disassembly is checked, behavior is correct. [sev] int arg = (_game.version >= 6) ? obj : 0; diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index b85771e897..ba13ff46d9 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -214,7 +214,7 @@ void ScummEngine::resetPalette() { } else { if ((_game.platform == Common::kPlatformAmiga) && _game.version == 4) { // if rendermode is set to EGA we use the full palette from the resources - // else we initialise and then lock down the first 16 colors. + // else we initialize and then lock down the first 16 colors. if (_renderMode != Common::kRenderEGA) setPaletteFromTable(tableAmigaMIPalette, sizeof(tableAmigaMIPalette) / 3); #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE diff --git a/engines/scumm/player_towns.cpp b/engines/scumm/player_towns.cpp index 5d49478cb0..e71a8d0587 100644 --- a/engines/scumm/player_towns.cpp +++ b/engines/scumm/player_towns.cpp @@ -585,7 +585,7 @@ Player_Towns_v2::~Player_Towns_v2() { _intf = 0; if (_imuseDispose) - delete _imuse; + delete _imuse; delete[] _sblData; delete[] _soundOverride; diff --git a/engines/scumm/player_v4a.h b/engines/scumm/player_v4a.h index b51ca2f993..d01c70f295 100644 --- a/engines/scumm/player_v4a.h +++ b/engines/scumm/player_v4a.h @@ -67,7 +67,7 @@ private: // byte type; } _sfxSlots[4]; - int8 _initState; // < 0: failed, 0: uninitialised, > 0: initialised + int8 _initState; // < 0: failed, 0: uninitialized, > 0: initialized int getSfxChan(int id) const { for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i) diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index f5d219c721..19834cb35d 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -103,7 +103,7 @@ bool ScummEngine::canLoadGameStateCurrently() { return (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0); } -Common::Error ScummEngine::saveGameState(int slot, const char *desc) { +Common::Error ScummEngine::saveGameState(int slot, const Common::String &desc) { requestSave(slot, desc); return Common::kNoError; } @@ -135,13 +135,11 @@ bool ScummEngine::canSaveGameStateCurrently() { } -void ScummEngine::requestSave(int slot, const char *name) { +void ScummEngine::requestSave(int slot, const Common::String &name) { _saveLoadSlot = slot; _saveTemporaryState = false; _saveLoadFlag = 1; // 1 for save - assert(name); - strncpy(_saveLoadName, name, sizeof(_saveLoadName)); - _saveLoadName[sizeof(_saveLoadName) - 1] = 0; + _saveLoadDescription = name; } void ScummEngine::requestLoad(int slot) { @@ -166,7 +164,7 @@ bool ScummEngine::saveState(Common::OutSaveFile *out, bool writeHeader) { SaveGameHeader hdr; if (writeHeader) { - memcpy(hdr.name, _saveLoadName, sizeof(hdr.name)); + Common::strlcpy(hdr.name, _saveLoadDescription.c_str(), sizeof(hdr.name)); saveSaveGameHeader(out, hdr); } #if !defined(__DS__) && !defined(__N64__) /* && !defined(__PLAYSTATION2__) */ @@ -387,7 +385,8 @@ bool ScummEngine::loadState(int slot, bool compat) { if (hdr.ver == VER(7)) hdr.ver = VER(8); - memcpy(_saveLoadName, hdr.name, sizeof(hdr.name)); + hdr.name[sizeof(hdr.name)-1] = 0; + _saveLoadDescription = hdr.name; // Unless specifically requested with _saveSound, we do not save the iMUSE // state for temporary state saves - such as certain cutscenes in DOTT, @@ -589,9 +588,9 @@ bool ScummEngine::loadState(int slot, bool compat) { } Common::String ScummEngine::makeSavegameName(const Common::String &target, int slot, bool temporary) { - char extension[6]; - snprintf(extension, sizeof(extension), ".%c%02d", temporary ? 'c' : 's', slot); - return (target + extension); + Common::String extension; + extension = Common::String::format(".%c%02d", temporary ? 'c' : 's', slot); + return target + extension; } void ScummEngine::listSavegames(bool *marks, int num) { diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp index b8f3b4b3b3..2c8f65496f 100644 --- a/engines/scumm/script_v5.cpp +++ b/engines/scumm/script_v5.cpp @@ -2646,7 +2646,7 @@ void ScummEngine_v5::decodeParseString() { // In SCUMM V1-V3, there were no 'default' values for the text slot - // values. Hence to achieve correct behaviour, we have to keep the + // values. Hence to achieve correct behavior, we have to keep the // 'default' values in sync with the active values. // // Note: This is needed for Indy3 (Grail Diary). It's also needed diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index e8dd6cb548..c0c477a597 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -213,7 +213,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _saveLoadSlot = 0; _lastSaveTime = 0; _saveTemporaryState = false; - memset(_saveLoadName, 0, sizeof(_saveLoadName)); memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets)); _scriptPointer = NULL; _scriptOrgPointer = NULL; @@ -2056,7 +2055,7 @@ void ScummEngine::scummLoop(int delta) { // Trigger autosave if necessary. if (!_saveLoadFlag && shouldPerformAutoSave(_lastSaveTime) && canSaveGameStateCurrently()) { _saveLoadSlot = 0; - sprintf(_saveLoadName, "Autosave %d", _saveLoadSlot); + _saveLoadDescription = Common::String::format("Autosave %d", _saveLoadSlot); _saveLoadFlag = 1; _saveTemporaryState = false; } diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 636c909911..6e75f47d77 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -44,7 +44,7 @@ #ifdef __DS__ /* This disables the dual layer mode which is used in FM-Towns versions - * of SCUMM games and which emulates the behaviour of the original code. + * of SCUMM games and which emulates the behavior of the original code. * The only purpose is code size reduction for certain backends. * SCUMM 3 (FM-Towns) games will run in normal (DOS VGA) mode, which should * work just fine in most situations. Some glitches might occur. SCUMM 5 games @@ -228,7 +228,7 @@ enum ScummGameId { GID_TENTACLE, GID_ZAK, - GID_HEGAME, // Generic name for all HE games with default behaviour + GID_HEGAME, // Generic name for all HE games with default behavior GID_PUTTDEMO, GID_FBEAR, GID_PUTTMOON, @@ -401,7 +401,7 @@ public: virtual Common::Error loadGameState(int slot); virtual bool canLoadGameStateCurrently(); - virtual Common::Error saveGameState(int slot, const char *desc); + virtual Common::Error saveGameState(int slot, const Common::String &desc); virtual bool canSaveGameStateCurrently(); virtual void pauseEngineIntern(bool pause); @@ -572,7 +572,7 @@ protected: uint32 _lastSaveTime; bool _saveTemporaryState; Common::String _saveLoadFileName; - char _saveLoadName[32]; + Common::String _saveLoadDescription; bool saveState(Common::OutSaveFile *out, bool writeHeader = true); bool saveState(int slot, bool compat); @@ -594,7 +594,7 @@ public: bool getSavegameName(int slot, Common::String &desc); void listSavegames(bool *marks, int num); - void requestSave(int slot, const char *name); + void requestSave(int slot, const Common::String &name); void requestLoad(int slot); // thumbnail + info stuff @@ -1120,7 +1120,7 @@ protected: void calcItineraryMatrix(byte *itineraryMatrix, int num); void createBoxMatrix(); - virtual bool areBoxesNeighbours(int i, int j); + virtual bool areBoxesNeighbors(int i, int j); /* String class */ public: diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h index 9c492663dc..af481df0e0 100644 --- a/engines/scumm/scumm_v0.h +++ b/engines/scumm/scumm_v0.h @@ -94,7 +94,7 @@ protected: virtual void resetSentence(bool walking); - virtual bool areBoxesNeighbours(int box1nr, int box2nr); + virtual bool areBoxesNeighbors(int box1nr, int box2nr); /* Version C64 script opcodes */ void o_stopCurrentScript(); diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp index c27b6d5e1c..4b3207c6bf 100644 --- a/engines/scumm/string.cpp +++ b/engines/scumm/string.cpp @@ -1210,7 +1210,8 @@ int ScummEngine::convertVerbMessage(byte *dst, int dstSize, int var) { num = readVar(var); if (num) { for (k = 1; k < _numVerbs; k++) { - if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) { + // Fix ZAK FM-TOWNS bug #1013617 by emulating exact (inconsistant?) behavior of the original code + if (num == _verbs[k].verbid && !_verbs[k].type && (!_verbs[k].saveid || (_game.version == 3 && _game.platform == Common::kPlatformFMTowns))) { const byte *ptr = getResourceAddress(rtVerb, k); return convertMessageToString(ptr, dst, dstSize); } |