2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2001-10-09 14:30:12 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2001-10-09 14:30:12 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2010-11-19 17:03:07 +00:00
|
|
|
#include "common/memstream.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/savefile.h"
|
2017-11-29 00:06:12 -06:00
|
|
|
#include "common/serializer.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2009-03-16 04:45:12 +00:00
|
|
|
#include "common/zlib.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
|
|
|
|
#include "scumm/actor.h"
|
|
|
|
#include "scumm/charset.h"
|
2004-01-06 17:28:29 +00:00
|
|
|
#include "scumm/imuse_digi/dimuse.h"
|
2006-02-20 20:57:26 +00:00
|
|
|
#include "scumm/imuse/imuse.h"
|
2013-11-01 14:53:43 +02:00
|
|
|
#include "scumm/players/player_towns.h"
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/intern_he.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "scumm/object.h"
|
|
|
|
#include "scumm/resource.h"
|
2009-03-20 16:33:58 +00:00
|
|
|
#include "scumm/scumm_v0.h"
|
|
|
|
#include "scumm/scumm_v7.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "scumm/sound.h"
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/sprite_he.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "scumm/verbs.h"
|
|
|
|
|
2010-11-08 23:07:42 +00:00
|
|
|
#include "backends/audiocd/audiocd.h"
|
|
|
|
|
2008-08-20 15:08:00 +00:00
|
|
|
#include "graphics/thumbnail.h"
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
struct SaveGameHeader {
|
|
|
|
uint32 type;
|
|
|
|
uint32 size;
|
|
|
|
uint32 ver;
|
2001-11-09 18:54:15 +00:00
|
|
|
char name[32];
|
2001-10-16 10:01:48 +00:00
|
|
|
};
|
|
|
|
|
2005-10-01 21:13:38 +00:00
|
|
|
struct SaveInfoSection {
|
|
|
|
uint32 type;
|
|
|
|
uint32 version;
|
|
|
|
uint32 size;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
uint32 timeTValue; // Obsolete since version 2, but kept for compatibility
|
2005-10-01 21:13:38 +00:00
|
|
|
uint32 playtime;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
uint32 date;
|
|
|
|
uint16 time;
|
2006-07-21 21:25:17 +00:00
|
|
|
};
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2006-07-22 16:19:00 +00:00
|
|
|
#define SaveInfoSectionSize (4+4+4 + 4+4 + 4+2)
|
|
|
|
|
2019-05-05 22:41:20 +10:00
|
|
|
#define CURRENT_VER 99
|
2005-10-12 17:59:12 +00:00
|
|
|
#define INFOSECTION_VERSION 2
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2008-08-20 15:08:00 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error ScummEngine::loadGameState(int slot) {
|
2008-11-06 15:41:38 +00:00
|
|
|
requestLoad(slot);
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummEngine::canLoadGameStateCurrently() {
|
2008-11-11 10:25:29 +00:00
|
|
|
// FIXME: For now always allow loading in V0-V3 games
|
|
|
|
// FIXME: Actually, we might wish to support loading in more places.
|
|
|
|
// As long as we are sure it won't cause any problems... Are we
|
|
|
|
// aware of *any* spots where loading is not supported?
|
2009-07-23 10:33:13 +00:00
|
|
|
|
|
|
|
// HE games are limited to original load and save interface only,
|
|
|
|
// due to numerous glitches (see bug #1726909) that can occur.
|
2010-04-04 09:36:10 +00:00
|
|
|
//
|
|
|
|
// Except the earliest HE Games (3DO and initial DOS version of
|
|
|
|
// puttputt), which didn't offer scripted load/save screens.
|
|
|
|
if (_game.heversion >= 62)
|
2009-07-23 10:33:13 +00:00
|
|
|
return false;
|
|
|
|
|
2009-07-29 19:39:03 +00:00
|
|
|
// COMI always disables saving/loading (to tell the truth:
|
|
|
|
// the main menu) via its scripts, thus we need to make an
|
|
|
|
// exception here. This the same forced overwriting of the
|
|
|
|
// script decisions as in ScummEngine::processKeyboard.
|
|
|
|
if (_game.id == GID_CMI)
|
|
|
|
return true;
|
|
|
|
|
2008-11-11 10:25:29 +00:00
|
|
|
return (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0);
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
2011-06-02 14:11:38 +02:00
|
|
|
Common::Error ScummEngine::saveGameState(int slot, const Common::String &desc) {
|
2008-11-06 15:41:38 +00:00
|
|
|
requestSave(slot, desc);
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummEngine::canSaveGameStateCurrently() {
|
2014-10-29 11:19:15 +02:00
|
|
|
// Disallow saving in v0-v3 games when a 'prequel' to a cutscene is shown.
|
|
|
|
// This is a blank screen with text, and while this is shown, saving should
|
|
|
|
// be disabled, as no room is set.
|
|
|
|
if (_game.version <= 3 && _currentScript == 0xFF && _roomResource == 0 && _currentRoom == 0)
|
|
|
|
return false;
|
|
|
|
|
2008-11-11 10:25:29 +00:00
|
|
|
// TODO: Should we disallow saving in some more places,
|
|
|
|
// e.g. when a SAN movie is playing? Not sure whether the
|
|
|
|
// original EXE allowed this.
|
2009-07-23 05:48:20 +00:00
|
|
|
|
2009-07-23 10:33:13 +00:00
|
|
|
// HE games are limited to original load and save interface only,
|
|
|
|
// due to numerous glitches (see bug #1726909) that can occur.
|
2010-04-04 09:36:10 +00:00
|
|
|
//
|
|
|
|
// Except the earliest HE Games (3DO and initial DOS version of
|
|
|
|
// puttputt), which didn't offer scripted load/save screens.
|
|
|
|
if (_game.heversion >= 62)
|
2009-07-23 10:33:13 +00:00
|
|
|
return false;
|
|
|
|
|
2009-07-29 19:39:03 +00:00
|
|
|
// COMI always disables saving/loading (to tell the truth:
|
|
|
|
// the main menu) via its scripts, thus we need to make an
|
|
|
|
// exception here. This the same forced overwriting of the
|
|
|
|
// script decisions as in ScummEngine::processKeyboard.
|
|
|
|
if (_game.id == GID_CMI)
|
|
|
|
return true;
|
|
|
|
|
2009-09-11 10:13:54 +00:00
|
|
|
// SCUMM v4+ doesn't allow saving in room 0 or if
|
2009-07-23 05:48:20 +00:00
|
|
|
// VAR(VAR_MAINMENU_KEY) to set to zero.
|
|
|
|
return (VAR_MAINMENU_KEY == 0xFF || (VAR(VAR_MAINMENU_KEY) != 0 && _currentRoom != 0));
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-02 14:11:38 +02:00
|
|
|
void ScummEngine::requestSave(int slot, const Common::String &name) {
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadSlot = slot;
|
2008-11-06 15:41:38 +00:00
|
|
|
_saveTemporaryState = false;
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadFlag = 1; // 1 for save
|
2011-06-02 14:11:38 +02:00
|
|
|
_saveLoadDescription = name;
|
2003-02-08 01:27:21 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine::requestLoad(int slot) {
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadSlot = slot;
|
2014-12-30 03:45:14 +01:00
|
|
|
_saveTemporaryState = (slot == 100);
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadFlag = 2; // 2 for load
|
|
|
|
}
|
|
|
|
|
2013-07-15 22:52:03 -04:00
|
|
|
Common::SeekableReadStream *ScummEngine::openSaveFileForReading(int slot, bool compat, Common::String &fileName) {
|
|
|
|
fileName = makeSavegameName(slot, compat);
|
|
|
|
return _saveFileMan->openForLoading(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::WriteStream *ScummEngine::openSaveFileForWriting(int slot, bool compat, Common::String &fileName) {
|
|
|
|
fileName = makeSavegameName(slot, compat);
|
|
|
|
return _saveFileMan->openForSaving(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool saveSaveGameHeader(Common::WriteStream *out, SaveGameHeader &hdr) {
|
2011-04-12 16:53:15 +02:00
|
|
|
hdr.type = MKTAG('S','C','V','M');
|
2007-11-06 12:22:52 +00:00
|
|
|
hdr.size = 0;
|
|
|
|
hdr.ver = CURRENT_VER;
|
|
|
|
|
|
|
|
out->writeUint32BE(hdr.type);
|
|
|
|
out->writeUint32LE(hdr.size);
|
|
|
|
out->writeUint32LE(hdr.ver);
|
|
|
|
out->write(hdr.name, sizeof(hdr.name));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-15 22:52:03 -04:00
|
|
|
bool ScummEngine::saveState(Common::WriteStream *out, bool writeHeader) {
|
2009-03-16 04:45:12 +00:00
|
|
|
SaveGameHeader hdr;
|
|
|
|
|
|
|
|
if (writeHeader) {
|
2011-06-02 14:11:38 +02:00
|
|
|
Common::strlcpy(hdr.name, _saveLoadDescription.c_str(), sizeof(hdr.name));
|
2009-03-16 04:45:12 +00:00
|
|
|
saveSaveGameHeader(out, hdr);
|
|
|
|
}
|
2009-12-30 21:11:38 +00:00
|
|
|
#if !defined(__DS__) && !defined(__N64__) /* && !defined(__PLAYSTATION2__) */
|
2009-03-16 04:45:12 +00:00
|
|
|
Graphics::saveThumbnail(*out);
|
|
|
|
#endif
|
|
|
|
saveInfos(out);
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
Common::Serializer ser(0, out);
|
|
|
|
ser.setVersion(CURRENT_VER);
|
|
|
|
saveLoadWithSerializer(ser);
|
2009-03-16 04:45:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-15 22:52:03 -04:00
|
|
|
bool ScummEngine::saveState(int slot, bool compat, Common::String &filename) {
|
2014-03-18 22:49:36 +00:00
|
|
|
bool saveFailed = false;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2010-04-11 21:30:57 +00:00
|
|
|
pauseEngine(true);
|
|
|
|
|
2013-07-15 22:52:03 -04:00
|
|
|
Common::WriteStream *out = openSaveFileForWriting(slot, compat, filename);
|
2014-03-18 22:49:36 +00:00
|
|
|
if (!out) {
|
2009-03-16 04:45:12 +00:00
|
|
|
saveFailed = true;
|
2014-03-18 22:49:36 +00:00
|
|
|
} else {
|
|
|
|
if (!saveState(out))
|
|
|
|
saveFailed = true;
|
|
|
|
|
|
|
|
out->finalize();
|
|
|
|
if (out->err())
|
|
|
|
saveFailed = true;
|
|
|
|
delete out;
|
|
|
|
}
|
2009-03-16 04:45:12 +00:00
|
|
|
|
2014-03-18 22:49:36 +00:00
|
|
|
if (saveFailed)
|
2008-09-14 21:34:49 +00:00
|
|
|
debug(1, "State save as '%s' FAILED", filename.c_str());
|
2014-03-18 22:49:36 +00:00
|
|
|
else
|
|
|
|
debug(1, "State saved as '%s'", filename.c_str());
|
2010-04-11 21:30:57 +00:00
|
|
|
|
|
|
|
pauseEngine(false);
|
|
|
|
|
2014-03-18 22:49:36 +00:00
|
|
|
return !saveFailed;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2009-03-16 04:45:12 +00:00
|
|
|
|
2009-04-19 01:01:54 +00:00
|
|
|
void ScummEngine_v4::prepareSavegame() {
|
2009-03-16 04:45:12 +00:00
|
|
|
Common::MemoryWriteStreamDynamic *memStream;
|
|
|
|
Common::WriteStream *writeStream;
|
|
|
|
|
|
|
|
// free memory of the last prepared savegame
|
|
|
|
delete _savePreparedSavegame;
|
|
|
|
_savePreparedSavegame = NULL;
|
|
|
|
|
|
|
|
// store headerless savegame in a compressed memory stream
|
2017-09-20 19:01:51 +02:00
|
|
|
memStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::NO);
|
2009-03-16 04:45:12 +00:00
|
|
|
writeStream = Common::wrapCompressedWriteStream(memStream);
|
|
|
|
if (saveState(writeStream, false)) {
|
|
|
|
// we have to finalize the compression-stream first, otherwise the internal
|
|
|
|
// memory-stream pointer will be zero (Important: flush() does not work here!).
|
|
|
|
writeStream->finalize();
|
|
|
|
if (!writeStream->err()) {
|
|
|
|
// wrap uncompressing MemoryReadStream around the savegame data
|
|
|
|
_savePreparedSavegame = Common::wrapCompressedReadStream(
|
2010-01-08 22:07:35 +00:00
|
|
|
new Common::MemoryReadStream(memStream->getData(), memStream->size(), DisposeAfterUse::YES));
|
2009-03-16 04:45:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// free the CompressedWriteStream and MemoryWriteStreamDynamic
|
|
|
|
// but not the memory stream's internal buffer
|
|
|
|
delete writeStream;
|
|
|
|
}
|
|
|
|
|
2009-04-19 01:01:54 +00:00
|
|
|
bool ScummEngine_v4::savePreparedSavegame(int slot, char *desc) {
|
2009-03-16 04:45:12 +00:00
|
|
|
bool success;
|
|
|
|
Common::String filename;
|
|
|
|
Common::OutSaveFile *out;
|
|
|
|
SaveGameHeader hdr;
|
|
|
|
uint32 nread, nwritten;
|
|
|
|
|
|
|
|
out = 0;
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
// check if savegame was successfully stored in memory
|
|
|
|
if (!_savePreparedSavegame)
|
|
|
|
success = false;
|
|
|
|
|
|
|
|
// open savegame file
|
|
|
|
if (success) {
|
|
|
|
filename = makeSavegameName(slot, false);
|
2009-05-29 14:38:22 +00:00
|
|
|
if (!(out = _saveFileMan->openForSaving(filename))) {
|
2009-03-16 04:45:12 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write header to file
|
|
|
|
if (success) {
|
|
|
|
memset(hdr.name, 0, sizeof(hdr.name));
|
|
|
|
strncpy(hdr.name, desc, sizeof(hdr.name)-1);
|
|
|
|
success = saveSaveGameHeader(out, hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy savegame from memory-stream to file
|
|
|
|
if (success) {
|
|
|
|
_savePreparedSavegame->seek(0, SEEK_SET);
|
|
|
|
byte buffer[1024];
|
|
|
|
while ((nread = _savePreparedSavegame->read(buffer, sizeof(buffer)))) {
|
|
|
|
nwritten = out->write(buffer, nread);
|
|
|
|
if (nwritten < nread) {
|
|
|
|
success = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (out) {
|
|
|
|
out->finalize();
|
|
|
|
if (out->err())
|
|
|
|
success = false;
|
|
|
|
delete out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
debug(1, "State save as '%s' FAILED", filename.c_str());
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
debug(1, "State saved as '%s'", filename.c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-01 23:32:20 +00:00
|
|
|
static bool loadSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &hdr) {
|
2006-02-25 11:12:44 +00:00
|
|
|
hdr.type = in->readUint32BE();
|
|
|
|
hdr.size = in->readUint32LE();
|
|
|
|
hdr.ver = in->readUint32LE();
|
|
|
|
in->read(hdr.name, sizeof(hdr.name));
|
2011-04-12 16:53:15 +02:00
|
|
|
return !in->err() && hdr.type == MKTAG('S','C','V','M');
|
2006-02-25 11:12:44 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 21:48:12 +00:00
|
|
|
bool ScummEngine::loadState(int slot, bool compat) {
|
2013-07-15 22:52:03 -04:00
|
|
|
// Wrapper around the other variant
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String filename;
|
2013-07-15 22:52:03 -04:00
|
|
|
return loadState(slot, compat, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummEngine::loadState(int slot, bool compat, Common::String &filename) {
|
2001-10-16 10:01:48 +00:00
|
|
|
SaveGameHeader hdr;
|
2004-07-18 05:04:30 +00:00
|
|
|
int sb, sh;
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2013-07-15 22:52:03 -04:00
|
|
|
Common::SeekableReadStream *in = openSaveFileForReading(slot, compat, filename);
|
|
|
|
if (!in)
|
2001-10-09 14:30:12 +00:00
|
|
|
return false;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2006-02-25 11:12:44 +00:00
|
|
|
if (!loadSaveGameHeader(in, hdr)) {
|
2008-09-14 21:34:49 +00:00
|
|
|
warning("Invalid savegame '%s'", filename.c_str());
|
2004-01-04 00:44:40 +00:00
|
|
|
delete in;
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-08-26 16:13:38 +00:00
|
|
|
// In older versions of ScummVM, the header version was not endian safe.
|
2006-02-25 11:12:44 +00:00
|
|
|
// We account for that by retrying once with swapped byte order in case
|
|
|
|
// we see a version that is higher than anything we'd expect...
|
|
|
|
if (hdr.ver > 0xFFFFFF)
|
2003-06-14 18:52:30 +00:00
|
|
|
hdr.ver = SWAP_BYTES_32(hdr.ver);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-22 23:49:29 +00:00
|
|
|
// Reject save games which are too old or too new. Note that
|
|
|
|
// We do not really support V7 games, but still accept them here
|
|
|
|
// to work around a bug from the stone age (see below for more
|
|
|
|
// information).
|
|
|
|
if (hdr.ver < VER(7) || hdr.ver > CURRENT_VER) {
|
2008-09-14 21:34:49 +00:00
|
|
|
warning("Invalid version of '%s'", filename.c_str());
|
2004-01-04 00:44:40 +00:00
|
|
|
delete in;
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2003-05-23 02:58:34 +00:00
|
|
|
|
2005-04-26 14:01:38 +00:00
|
|
|
// We (deliberately) broke HE savegame compatibility at some point.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (hdr.ver < VER(50) && _game.heversion >= 71) {
|
2008-09-14 21:34:49 +00:00
|
|
|
warning("Unsupported version of '%s'", filename.c_str());
|
2005-04-26 14:01:38 +00:00
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-10-22 23:47:39 +00:00
|
|
|
// Since version 52 a thumbnail is saved directly after the header.
|
2008-08-20 15:08:00 +00:00
|
|
|
if (hdr.ver >= VER(52)) {
|
|
|
|
// Prior to version 75 we always required an thumbnail to be present
|
|
|
|
if (hdr.ver <= VER(74)) {
|
|
|
|
if (!Graphics::checkThumbnailHeader(*in)) {
|
|
|
|
warning("Can not load thumbnail");
|
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-08-20 15:12:36 +00:00
|
|
|
|
2010-08-02 22:28:30 +00:00
|
|
|
Graphics::skipThumbnail(*in);
|
2008-08-20 15:08:00 +00:00
|
|
|
}
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2005-10-22 23:47:39 +00:00
|
|
|
// Since version 56 we save additional information about the creation of
|
|
|
|
// the save game and the save time.
|
2005-10-01 21:13:38 +00:00
|
|
|
if (hdr.ver >= VER(56)) {
|
2011-04-05 11:39:07 +02:00
|
|
|
SaveStateMetaInfos infos;
|
2005-10-01 21:13:38 +00:00
|
|
|
if (!loadInfos(in, &infos)) {
|
|
|
|
warning("Info section could not be found");
|
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:52:02 +00:00
|
|
|
setTotalPlayTime(infos.playtime * 1000);
|
2005-10-01 21:13:38 +00:00
|
|
|
} else {
|
|
|
|
// start time counting
|
2010-10-27 22:52:02 +00:00
|
|
|
setTotalPlayTime();
|
2005-10-01 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
// Due to a bug in scummvm up to and including 0.3.0, save games could be saved
|
|
|
|
// in the V8/V9 format but were tagged with a V7 mark. Ouch. So we just pretend V7 == V8 here
|
2003-08-29 04:05:23 +00:00
|
|
|
if (hdr.ver == VER(7))
|
|
|
|
hdr.ver = VER(8);
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2011-06-02 14:11:38 +02:00
|
|
|
hdr.name[sizeof(hdr.name)-1] = 0;
|
|
|
|
_saveLoadDescription = hdr.name;
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2004-01-31 16:07:11 +00:00
|
|
|
// Unless specifically requested with _saveSound, we do not save the iMUSE
|
|
|
|
// state for temporary state saves - such as certain cutscenes in DOTT,
|
|
|
|
// FOA, Sam and Max, etc.
|
|
|
|
//
|
2007-06-30 18:09:17 +00:00
|
|
|
// Thus, we should probably not stop music when restoring from one of
|
2004-01-31 16:07:11 +00:00
|
|
|
// these saves. This change stops the Mole Man theme from going quiet in
|
|
|
|
// Sam & Max when Doug tells you about the Ball of Twine, as mentioned in
|
|
|
|
// patch #886058.
|
|
|
|
//
|
|
|
|
// If we don't have iMUSE at all we may as well stop the sounds. The previous
|
|
|
|
// default behavior here was to stopAllSounds on all state restores.
|
|
|
|
|
2004-01-31 22:12:35 +00:00
|
|
|
if (!_imuse || _saveSound || !_saveTemporaryState)
|
2004-01-31 16:07:11 +00:00
|
|
|
_sound->stopAllSounds();
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
2004-03-02 20:35:48 +00:00
|
|
|
if (_imuseDigital) {
|
|
|
|
_imuseDigital->stopAllSounds();
|
|
|
|
_imuseDigital->resetState();
|
|
|
|
}
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
2004-03-02 20:35:48 +00:00
|
|
|
|
2002-12-16 12:09:52 +00:00
|
|
|
_sound->stopCD();
|
2003-11-29 14:37:47 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->pauseSounds(true);
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2002-12-22 21:58:16 +00:00
|
|
|
closeRoom();
|
2004-01-04 00:44:40 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
memset(_inventory, 0, sizeof(_inventory[0]) * _numInventory);
|
2003-12-25 22:05:02 +00:00
|
|
|
memset(_newNames, 0, sizeof(_newNames[0]) * _numNewNames);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
// Because old savegames won't fill the entire gfxUsageBits[] array,
|
|
|
|
// clear it here just to be sure it won't hold any unforseen garbage.
|
|
|
|
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
// Nuke all resources
|
2011-05-13 14:02:53 +02:00
|
|
|
for (ResType type = rtFirst; type <= rtLast; type = ResType(type + 1))
|
|
|
|
if (type != rtTemp && type != rtBuffer && (type != rtSound || _saveSound || !compat))
|
2011-05-13 14:48:01 +02:00
|
|
|
for (ResId idx = 0; idx < _res->_types[type].size(); idx++) {
|
2011-05-13 14:02:53 +02:00
|
|
|
_res->nukeResource(type, idx);
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
resetScummVars();
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.features & GF_OLD_BUNDLE)
|
2003-04-23 09:20:22 +00:00
|
|
|
loadCharset(0); // FIXME - HACK ?
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
//
|
|
|
|
// Now do the actual loading
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
Common::Serializer ser(in, 0);
|
|
|
|
ser.setVersion(hdr.ver);
|
|
|
|
saveLoadWithSerializer(ser);
|
2004-01-04 00:44:40 +00:00
|
|
|
delete in;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-26 13:22:46 +00:00
|
|
|
// Update volume settings
|
2008-06-30 17:44:21 +00:00
|
|
|
syncSoundSettings();
|
2005-04-26 13:22:46 +00:00
|
|
|
|
2010-08-18 21:38:43 +00:00
|
|
|
if (_townsPlayer && (hdr.ver >= VER(81)))
|
|
|
|
_townsPlayer->restoreAfterLoad();
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
// Init NES costume data
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.platform == Common::kPlatformNES) {
|
2005-04-26 13:43:01 +00:00
|
|
|
if (hdr.ver < VER(47))
|
|
|
|
_NESCostumeSet = 0;
|
|
|
|
NES_loadCostumeSet(_NESCostumeSet);
|
|
|
|
}
|
|
|
|
|
2004-01-08 00:48:37 +00:00
|
|
|
// Normally, _vm->_screenTop should always be >= 0, but for some old save games
|
|
|
|
// it is not, hence we check & correct it here.
|
|
|
|
if (_screenTop < 0)
|
|
|
|
_screenTop = 0;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-02-02 23:43:39 +00:00
|
|
|
// WORKAROUND bug #795214: For unknown reasons, object 819 sometimes is in
|
|
|
|
// state 1 in old save games, implying it should be drawn. This in turn
|
|
|
|
// results in a crash when entering the church, as object 819 is part of the
|
2009-09-11 10:13:54 +00:00
|
|
|
// exitof the church and there are no graphics assigned to it.
|
2007-02-02 23:43:39 +00:00
|
|
|
if (_game.id == GID_MONKEY_VGA) {
|
2006-02-15 17:31:26 +00:00
|
|
|
putState(819, 0);
|
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (hdr.ver < VER(33) && _game.version >= 7) {
|
2004-07-16 14:41:05 +00:00
|
|
|
// For a long time, we didn't set these vars to default values.
|
|
|
|
VAR(VAR_DEFAULT_TALK_DELAY) = 60;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 7)
|
2004-07-16 14:41:05 +00:00
|
|
|
VAR(VAR_NUM_GLOBAL_OBJS) = _numGlobalObjects - 1;
|
|
|
|
}
|
|
|
|
|
2004-02-22 16:15:49 +00:00
|
|
|
if (hdr.ver < VER(30)) {
|
|
|
|
// For a long time, we used incorrect location, causing it to default to zero.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8)
|
|
|
|
_scummVars[VAR_CHARINC] = (_game.features & GF_DEMO) ? 3 : 1;
|
2004-02-22 16:15:49 +00:00
|
|
|
// Needed due to subtitle speed changes
|
|
|
|
_defaultTalkDelay /= 20;
|
|
|
|
}
|
2004-02-21 08:21:11 +00:00
|
|
|
|
2004-01-11 19:58:29 +00:00
|
|
|
// For a long time, we used incorrect locations for some camera related
|
|
|
|
// scumm vars. We now know the proper locations. To be able to properly use
|
|
|
|
// old save games, we update the old (bad) variables to the new (correct)
|
|
|
|
// ones.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (hdr.ver < VER(28) && _game.version == 8) {
|
2004-01-11 19:58:29 +00:00
|
|
|
_scummVars[VAR_CAMERA_MIN_X] = _scummVars[101];
|
|
|
|
_scummVars[VAR_CAMERA_MAX_X] = _scummVars[102];
|
|
|
|
_scummVars[VAR_CAMERA_MIN_Y] = _scummVars[103];
|
|
|
|
_scummVars[VAR_CAMERA_MAX_Y] = _scummVars[104];
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_X] = _scummVars[105];
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_Y] = _scummVars[106];
|
|
|
|
_scummVars[VAR_CAMERA_SPEED_X] = _scummVars[107];
|
|
|
|
_scummVars[VAR_CAMERA_SPEED_Y] = _scummVars[108];
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_X] = _scummVars[109];
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_Y] = _scummVars[110];
|
|
|
|
}
|
2003-05-03 20:49:53 +00:00
|
|
|
|
2009-02-11 23:22:52 +00:00
|
|
|
// For a long time, we used incorrect values for some camera related
|
|
|
|
// scumm vars. We now know the proper values. To be able to properly use
|
|
|
|
// old save games, we update the old (bad) values to the new (correct)
|
|
|
|
// ones.
|
|
|
|
if (hdr.ver < VER(77) && _game.version >= 7) {
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_X] = 100;
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_Y] = 70;
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_X] = 100;
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_Y] = 100;
|
|
|
|
}
|
|
|
|
|
2004-07-26 04:03:11 +00:00
|
|
|
// With version 22, we replaced the scale items with scale slots. So when
|
|
|
|
// loading such an old save game, try to upgrade the old to new format.
|
|
|
|
if (hdr.ver < VER(22)) {
|
|
|
|
// Convert all rtScaleTable resources to matching scale items
|
2011-05-13 14:48:01 +02:00
|
|
|
for (ResId idx = 1; idx < _res->_types[rtScaleTable].size(); idx++) {
|
2011-05-13 14:02:53 +02:00
|
|
|
convertScaleTableToScaleSlot(idx);
|
2004-07-26 04:03:11 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-22 03:08:18 +00:00
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
// Reset the palette.
|
|
|
|
resetPalette();
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-05-29 12:45:11 +00:00
|
|
|
if (hdr.ver < VER(35) && _game.id == GID_MANIAC && _game.version <= 1)
|
2006-04-29 16:24:39 +00:00
|
|
|
resetV1ActorTalkColor();
|
2004-07-26 15:14:10 +00:00
|
|
|
|
2005-04-26 14:18:34 +00:00
|
|
|
// Load the static room data
|
2006-04-29 16:24:39 +00:00
|
|
|
setupRoomSubBlocks();
|
2003-06-05 10:27:15 +00:00
|
|
|
|
2007-02-10 02:05:59 +00:00
|
|
|
if (_game.version < 7) {
|
2004-01-04 00:44:40 +00:00
|
|
|
camera._last.x = camera._cur.x;
|
|
|
|
}
|
|
|
|
|
2004-07-18 05:04:30 +00:00
|
|
|
sb = _screenB;
|
|
|
|
sh = _screenH;
|
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
// Restore the virtual screens and force a fade to black.
|
2005-04-26 15:41:15 +00:00
|
|
|
initScreens(0, _screenHeight);
|
2005-03-25 22:11:08 +00:00
|
|
|
|
2007-09-08 11:15:27 +00:00
|
|
|
VirtScreen *vs = &_virtscr[kMainVirtScreen];
|
2004-08-14 19:42:00 +00:00
|
|
|
memset(vs->getPixels(0, 0), 0, vs->pitch * vs->h);
|
|
|
|
vs->setDirtyRange(0, vs->h);
|
2004-01-04 00:44:40 +00:00
|
|
|
updateDirtyScreen(kMainVirtScreen);
|
|
|
|
updatePalette();
|
2004-07-18 05:04:30 +00:00
|
|
|
initScreens(sb, sh);
|
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
_completeScreenRedraw = true;
|
|
|
|
|
|
|
|
// Reset charset mask
|
|
|
|
_charset->_hasMask = false;
|
2007-01-28 20:11:31 +00:00
|
|
|
clearTextSurface();
|
2004-01-04 00:44:40 +00:00
|
|
|
|
|
|
|
_lastCodePtr = NULL;
|
|
|
|
_drawObjectQueNr = 0;
|
|
|
|
_verbMouseOver = 0;
|
|
|
|
|
|
|
|
cameraMoved();
|
|
|
|
|
|
|
|
initBGBuffers(_roomHeight);
|
|
|
|
|
2004-07-26 04:03:11 +00:00
|
|
|
if (VAR_ROOM_FLAG != 0xFF)
|
|
|
|
VAR(VAR_ROOM_FLAG) = 1;
|
|
|
|
|
|
|
|
// Sync with current config setting
|
2005-11-15 22:50:14 +00:00
|
|
|
if (VAR_VOICE_MODE != 0xFF)
|
2004-07-26 04:03:11 +00:00
|
|
|
VAR(VAR_VOICE_MODE) = ConfMan.getBool("subtitles");
|
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
debug(1, "State loaded from '%s'", filename.c_str());
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->pauseSounds(false);
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2008-01-01 16:26:04 +00:00
|
|
|
// WORKAROUND: Original save/load script ran this script
|
|
|
|
// after game load, and o2_loadRoomWithEgo() does as well
|
|
|
|
// this script starts character-dependent music
|
|
|
|
//
|
|
|
|
// Fixes bug #1766072: MANIACNES: Music Doesn't Start On Load Game
|
|
|
|
if (_game.platform == Common::kPlatformNES) {
|
|
|
|
runScript(5, 0, 0, 0);
|
2010-06-15 10:46:04 +00:00
|
|
|
|
|
|
|
if (VAR(224)) {
|
|
|
|
_sound->addSoundToQueue(VAR(224));
|
|
|
|
}
|
2008-01-01 16:26:04 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String ScummEngine::makeSavegameName(const Common::String &target, int slot, bool temporary) {
|
2011-06-02 14:11:38 +02:00
|
|
|
Common::String extension;
|
|
|
|
extension = Common::String::format(".%c%02d", temporary ? 'c' : 's', slot);
|
|
|
|
return target + extension;
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 22:39:21 +00:00
|
|
|
void ScummEngine::listSavegames(bool *marks, int num) {
|
2007-07-12 17:58:15 +00:00
|
|
|
assert(marks);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-12-07 17:59:24 +00:00
|
|
|
char slot[3];
|
2007-07-12 17:58:15 +00:00
|
|
|
int slotNum;
|
2010-03-18 15:54:40 +00:00
|
|
|
Common::StringArray files;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String prefix = makeSavegameName(99, false);
|
2008-09-15 06:51:15 +00:00
|
|
|
prefix.setChar('*', prefix.size()-2);
|
|
|
|
prefix.setChar(0, prefix.size()-1);
|
2007-07-12 17:58:15 +00:00
|
|
|
memset(marks, false, num * sizeof(bool)); //assume no savegames for this title
|
2009-05-29 14:38:22 +00:00
|
|
|
files = _saveFileMan->listSavefiles(prefix);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2010-03-18 15:54:40 +00:00
|
|
|
for (Common::StringArray::const_iterator file = files.begin(); file != files.end(); ++file) {
|
2007-07-12 17:58:15 +00:00
|
|
|
//Obtain the last 2 digits of the filename, since they correspond to the save slot
|
|
|
|
slot[0] = file->c_str()[file->size()-2];
|
|
|
|
slot[1] = file->c_str()[file->size()-1];
|
2007-12-07 17:59:24 +00:00
|
|
|
slot[2] = 0;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-07-12 17:58:15 +00:00
|
|
|
slotNum = atoi(slot);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (slotNum >= 0 && slotNum < num)
|
2007-07-12 17:58:15 +00:00
|
|
|
marks[slotNum] = true; //mark this slot as valid
|
|
|
|
}
|
2002-12-17 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
bool getSavegameName(Common::InSaveFile *in, Common::String &desc, int heversion);
|
|
|
|
|
|
|
|
bool ScummEngine::getSavegameName(int slot, Common::String &desc) {
|
|
|
|
Common::InSaveFile *in = 0;
|
|
|
|
bool result = false;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
desc.clear();
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String filename = makeSavegameName(slot, false);
|
2009-05-29 14:38:22 +00:00
|
|
|
in = _saveFileMan->openForLoading(filename);
|
2008-02-04 10:15:21 +00:00
|
|
|
if (in) {
|
|
|
|
result = Scumm::getSavegameName(in, desc, _game.heversion);
|
|
|
|
delete in;
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
2008-02-04 10:15:21 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-11-27 19:01:30 +01:00
|
|
|
namespace {
|
|
|
|
bool loadAndCheckSaveGameHeader(Common::InSaveFile *in, int heversion, SaveGameHeader &hdr, Common::String *error = nullptr) {
|
2006-02-25 11:12:44 +00:00
|
|
|
if (!loadSaveGameHeader(in, hdr)) {
|
2013-11-27 19:01:30 +01:00
|
|
|
if (error) {
|
|
|
|
*error = "Invalid savegame";
|
|
|
|
}
|
2001-11-09 18:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2013-11-27 19:01:30 +01:00
|
|
|
if (hdr.ver > CURRENT_VER) {
|
2002-07-16 15:25:22 +00:00
|
|
|
hdr.ver = TO_LE_32(hdr.ver);
|
2013-11-27 19:01:30 +01:00
|
|
|
}
|
|
|
|
|
2003-08-29 04:05:23 +00:00
|
|
|
if (hdr.ver < VER(7) || hdr.ver > CURRENT_VER) {
|
2013-11-27 19:01:30 +01:00
|
|
|
if (error) {
|
|
|
|
*error = "Invalid version";
|
|
|
|
}
|
2001-11-09 18:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 14:01:38 +00:00
|
|
|
// We (deliberately) broke HE savegame compatibility at some point.
|
2008-02-04 10:15:21 +00:00
|
|
|
if (hdr.ver < VER(57) && heversion >= 60) {
|
2013-11-27 19:01:30 +01:00
|
|
|
if (error) {
|
|
|
|
*error = "Unsupported version";
|
|
|
|
}
|
2005-04-26 14:01:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
hdr.name[sizeof(hdr.name) - 1] = 0;
|
2013-11-27 19:01:30 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} // End of anonymous namespace
|
|
|
|
|
|
|
|
bool getSavegameName(Common::InSaveFile *in, Common::String &desc, int heversion) {
|
|
|
|
SaveGameHeader hdr;
|
|
|
|
|
|
|
|
if (!loadAndCheckSaveGameHeader(in, heversion, hdr, &desc)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
desc = hdr.name;
|
2001-11-09 18:54:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-27 19:29:21 +01:00
|
|
|
bool ScummEngine::querySaveMetaInfos(const char *target, int slot, int heversion, Common::String &desc, Graphics::Surface *&thumbnail, SaveStateMetaInfos *&timeInfos) {
|
|
|
|
if (slot < 0) {
|
|
|
|
return false;
|
2008-09-14 21:13:40 +00:00
|
|
|
}
|
2005-05-09 00:09:01 +00:00
|
|
|
|
2005-10-01 21:13:38 +00:00
|
|
|
SaveGameHeader hdr;
|
2013-11-27 19:29:21 +01:00
|
|
|
const Common::String filename = ScummEngine::makeSavegameName(target, slot, false);
|
|
|
|
Common::ScopedPtr<Common::SeekableReadStream> in(g_system->getSavefileManager()->openForLoading(filename));
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2013-11-27 19:29:21 +01:00
|
|
|
if (!in) {
|
2005-10-01 21:13:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-27 19:29:21 +01:00
|
|
|
if (!loadAndCheckSaveGameHeader(in.get(), heversion, hdr)) {
|
2005-10-01 21:13:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-27 19:29:21 +01:00
|
|
|
desc = hdr.name;
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2013-11-27 19:29:21 +01:00
|
|
|
if (hdr.ver > VER(52)) {
|
|
|
|
if (Graphics::checkThumbnailHeader(*in)) {
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
if (!Graphics::loadThumbnail(*in, thumbnail)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-27 19:29:21 +01:00
|
|
|
}
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2013-11-27 19:29:21 +01:00
|
|
|
if (hdr.ver > VER(57)) {
|
|
|
|
if (!loadInfos(in.get(), timeInfos)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
timeInfos = nullptr;
|
|
|
|
}
|
2005-10-01 21:13:38 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-01 21:13:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-05 11:39:07 +02:00
|
|
|
bool ScummEngine::loadInfos(Common::SeekableReadStream *file, SaveStateMetaInfos *stuff) {
|
|
|
|
memset(stuff, 0, sizeof(SaveStateMetaInfos));
|
2005-10-01 21:13:38 +00:00
|
|
|
|
|
|
|
SaveInfoSection section;
|
2006-02-25 02:47:22 +00:00
|
|
|
section.type = file->readUint32BE();
|
2011-04-12 16:53:15 +02:00
|
|
|
if (section.type != MKTAG('I','N','F','O')) {
|
2005-10-01 21:13:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
section.version = file->readUint32BE();
|
|
|
|
section.size = file->readUint32BE();
|
|
|
|
|
2007-03-08 21:08:23 +00:00
|
|
|
// If we ever extend this we should add a table containing the sizes corresponding to each
|
|
|
|
// version, so that we are able to properly verify their correctness.
|
2006-07-22 16:19:00 +00:00
|
|
|
if (section.version == INFOSECTION_VERSION && section.size != SaveInfoSectionSize) {
|
2005-10-01 21:13:38 +00:00
|
|
|
warning("Info section is corrupt");
|
|
|
|
file->skip(section.size);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
section.timeTValue = file->readUint32BE();
|
|
|
|
section.playtime = file->readUint32BE();
|
|
|
|
|
2007-03-08 21:08:23 +00:00
|
|
|
// For header version 1, we load the data in with our old method
|
2005-10-12 17:59:12 +00:00
|
|
|
if (section.version == 1) {
|
2007-12-28 07:43:52 +00:00
|
|
|
//time_t tmp = section.timeTValue;
|
|
|
|
//tm *curTime = localtime(&tmp);
|
|
|
|
//stuff->date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF;
|
|
|
|
//stuff->time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF;
|
|
|
|
stuff->date = 0;
|
|
|
|
stuff->time = 0;
|
2005-10-12 17:59:12 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
if (section.version >= 2) {
|
|
|
|
section.date = file->readUint32BE();
|
|
|
|
section.time = file->readUint16BE();
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
stuff->date = section.date;
|
|
|
|
stuff->time = section.time;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
stuff->playtime = section.playtime;
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2007-03-08 21:08:23 +00:00
|
|
|
// Skip over the remaining (unsupported) data
|
2008-09-16 14:56:02 +00:00
|
|
|
if (section.size > SaveInfoSectionSize)
|
2006-07-22 16:19:00 +00:00
|
|
|
file->skip(section.size - SaveInfoSectionSize);
|
2005-10-01 21:13:38 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-27 19:32:08 +01:00
|
|
|
void ScummEngine::saveInfos(Common::WriteStream *file) {
|
2005-10-01 21:13:38 +00:00
|
|
|
SaveInfoSection section;
|
2011-04-12 16:53:15 +02:00
|
|
|
section.type = MKTAG('I','N','F','O');
|
2005-10-01 21:13:38 +00:00
|
|
|
section.version = INFOSECTION_VERSION;
|
2006-07-22 16:19:00 +00:00
|
|
|
section.size = SaveInfoSectionSize;
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
// still save old format for older versions
|
2009-10-08 19:41:38 +00:00
|
|
|
section.timeTValue = 0;
|
2010-10-27 22:37:51 +00:00
|
|
|
section.playtime = getTotalPlayTime() / 1000;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2009-10-08 19:41:38 +00:00
|
|
|
TimeDate curTime;
|
2007-12-28 07:43:52 +00:00
|
|
|
_system->getTimeAndDate(curTime);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-11-29 18:01:16 +00:00
|
|
|
section.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
|
|
|
|
section.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2006-02-25 02:47:22 +00:00
|
|
|
file->writeUint32BE(section.type);
|
2005-10-01 21:13:38 +00:00
|
|
|
file->writeUint32BE(section.version);
|
|
|
|
file->writeUint32BE(section.size);
|
|
|
|
file->writeUint32BE(section.timeTValue);
|
|
|
|
file->writeUint32BE(section.playtime);
|
2005-10-12 17:59:12 +00:00
|
|
|
file->writeUint32BE(section.date);
|
|
|
|
file->writeUint16BE(section.time);
|
2005-10-01 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
static void syncWithSerializer(Common::Serializer &s, ObjectData &od) {
|
|
|
|
s.syncAsUint32LE(od.OBIMoffset, VER(8));
|
|
|
|
s.syncAsUint32LE(od.OBCDoffset, VER(8));
|
|
|
|
s.syncAsUint16LE(od.walk_x, VER(8));
|
|
|
|
s.syncAsUint16LE(od.walk_y, VER(8));
|
|
|
|
s.syncAsUint16LE(od.obj_nr, VER(8));
|
|
|
|
s.syncAsSint16LE(od.x_pos, VER(8));
|
|
|
|
s.syncAsSint16LE(od.y_pos, VER(8));
|
|
|
|
s.syncAsUint16LE(od.width, VER(8));
|
|
|
|
s.syncAsUint16LE(od.height, VER(8));
|
|
|
|
s.syncAsByte(od.actordir, VER(8));
|
|
|
|
s.syncAsByte(od.parentstate, VER(8));
|
|
|
|
s.syncAsByte(od.parent, VER(8));
|
|
|
|
s.syncAsByte(od.state, VER(8));
|
|
|
|
s.syncAsByte(od.fl_object_index, VER(8));
|
|
|
|
s.syncAsByte(od.flags, VER(46));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, VerbSlot &vs) {
|
|
|
|
s.syncAsSint16LE(vs.curRect.left, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.curRect.top, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.curRect.right, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.curRect.bottom, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.oldRect.left, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.oldRect.top, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.oldRect.right, VER(8));
|
|
|
|
s.syncAsSint16LE(vs.oldRect.bottom, VER(8));
|
|
|
|
s.syncAsByte(vs.verbid, VER(8), VER(11));
|
|
|
|
s.syncAsSint16LE(vs.verbid, VER(12));
|
|
|
|
s.syncAsByte(vs.color, VER(8));
|
|
|
|
s.syncAsByte(vs.hicolor, VER(8));
|
|
|
|
s.syncAsByte(vs.dimcolor, VER(8));
|
|
|
|
s.syncAsByte(vs.bkcolor, VER(8));
|
|
|
|
s.syncAsByte(vs.type, VER(8));
|
|
|
|
s.syncAsByte(vs.charset_nr, VER(8));
|
|
|
|
s.syncAsByte(vs.curmode, VER(8));
|
|
|
|
s.syncAsByte(vs.saveid, VER(8));
|
|
|
|
s.syncAsByte(vs.key, VER(8));
|
|
|
|
s.syncAsByte(vs.center, VER(8));
|
|
|
|
s.syncAsByte(vs.prep, VER(8));
|
|
|
|
s.syncAsUint16LE(vs.imgindex, VER(8));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, ScriptSlot &ss) {
|
|
|
|
s.syncAsUint32LE(ss.offs, VER(8));
|
|
|
|
s.syncAsSint32LE(ss.delay, VER(8));
|
|
|
|
s.syncAsUint16LE(ss.number, VER(8));
|
|
|
|
s.syncAsUint16LE(ss.delayFrameCount, VER(8));
|
|
|
|
s.syncAsByte(ss.status, VER(8));
|
|
|
|
s.syncAsByte(ss.where, VER(8));
|
|
|
|
s.syncAsByte(ss.freezeResistant, VER(8));
|
|
|
|
s.syncAsByte(ss.recursive, VER(8));
|
|
|
|
s.syncAsByte(ss.freezeCount, VER(8));
|
|
|
|
s.syncAsByte(ss.didexec, VER(8));
|
|
|
|
s.syncAsByte(ss.cutsceneOverride, VER(8));
|
|
|
|
s.syncAsByte(ss.cycle, VER(46));
|
|
|
|
s.skip(1, VER(8), VER(10)); // unk5
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, NestedScript &ns) {
|
|
|
|
s.syncAsUint16LE(ns.number, VER(8));
|
|
|
|
s.syncAsByte(ns.where, VER(8));
|
|
|
|
s.syncAsByte(ns.slot, VER(8));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, SentenceTab &st) {
|
|
|
|
s.syncAsByte(st.verb, VER(8));
|
|
|
|
s.syncAsByte(st.preposition, VER(8));
|
|
|
|
s.syncAsUint16LE(st.objectA, VER(8));
|
|
|
|
s.syncAsUint16LE(st.objectB, VER(8));
|
|
|
|
s.syncAsByte(st.freezeCount, VER(8));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, StringTab &st) {
|
|
|
|
s.syncAsSint16LE(st.xpos, VER(8));
|
|
|
|
s.syncAsSint16LE(st._default.xpos, VER(8));
|
|
|
|
s.syncAsSint16LE(st.ypos, VER(8));
|
|
|
|
s.syncAsSint16LE(st._default.ypos, VER(8));
|
|
|
|
s.syncAsSint16LE(st.right, VER(8));
|
|
|
|
s.syncAsSint16LE(st._default.right, VER(8));
|
|
|
|
s.syncAsSByte(st.color, VER(8));
|
|
|
|
s.syncAsSByte(st._default.color, VER(8));
|
|
|
|
s.syncAsSByte(st.charset, VER(8));
|
|
|
|
s.syncAsSByte(st._default.charset, VER(8));
|
|
|
|
s.syncAsByte(st.center, VER(8));
|
|
|
|
s.syncAsByte(st._default.center, VER(8));
|
|
|
|
s.syncAsByte(st.overhead, VER(8));
|
|
|
|
s.syncAsByte(st._default.overhead, VER(8));
|
|
|
|
s.syncAsByte(st.no_talk_anim, VER(8));
|
|
|
|
s.syncAsByte(st._default.no_talk_anim, VER(8));
|
|
|
|
s.syncAsByte(st.wrapping, VER(71));
|
|
|
|
s.syncAsByte(st._default.wrapping, VER(71));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, ColorCycle &cc) {
|
|
|
|
s.syncAsUint16LE(cc.delay, VER(8));
|
|
|
|
s.syncAsUint16LE(cc.counter, VER(8));
|
|
|
|
s.syncAsUint16LE(cc.flags, VER(8));
|
|
|
|
s.syncAsByte(cc.start, VER(8));
|
|
|
|
s.syncAsByte(cc.end, VER(8));
|
|
|
|
}
|
|
|
|
|
|
|
|
void syncWithSerializer(Common::Serializer &s, ScummEngine::ScaleSlot &ss) {
|
|
|
|
s.syncAsUint16LE(ss.x1, VER(13));
|
|
|
|
s.syncAsUint16LE(ss.y1, VER(13));
|
|
|
|
s.syncAsUint16LE(ss.scale1, VER(13));
|
|
|
|
s.syncAsUint16LE(ss.x2, VER(13));
|
|
|
|
s.syncAsUint16LE(ss.y2, VER(13));
|
|
|
|
s.syncAsUint16LE(ss.scale2, VER(13));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, AudioCDManager::Status &as) {
|
|
|
|
s.syncAsUint32LE(as.playing, VER(24));
|
|
|
|
s.syncAsSint32LE(as.track, VER(24));
|
|
|
|
s.syncAsUint32LE(as.start, VER(24));
|
|
|
|
s.syncAsUint32LE(as.duration, VER(24));
|
|
|
|
s.syncAsSint32LE(as.numLoops, VER(24));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void syncWithSerializer(Common::Serializer &s, Common::Rect &rect) {
|
|
|
|
s.syncAsSint16LE(rect.left);
|
|
|
|
s.syncAsSint16LE(rect.top);
|
|
|
|
s.syncAsSint16LE(rect.right);
|
|
|
|
s.syncAsSint16LE(rect.bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, size_t N, size_t M>
|
|
|
|
static void sync2DArray(Common::Serializer &s, T (&array)[N][M], const size_t dim1, const size_t dim2, void (*serializer)(Common::Serializer &, T &), Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion) {
|
|
|
|
|
|
|
|
if (s.getVersion() < minVersion || s.getVersion() > maxVersion) {
|
|
|
|
return;
|
|
|
|
}
|
2003-11-29 13:58:17 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
assert(dim1 <= N);
|
|
|
|
assert(dim2 <= M);
|
|
|
|
for (size_t i = 0; i < dim1; ++i) {
|
|
|
|
for (size_t j = 0; j < dim2; ++j) {
|
|
|
|
serializer(s, array[i][j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine::saveLoadWithSerializer(Common::Serializer &s) {
|
2011-05-13 14:02:53 +02:00
|
|
|
int i;
|
2002-03-03 21:33:43 +00:00
|
|
|
int var120Backup;
|
2002-03-03 22:14:47 +00:00
|
|
|
int var98Backup;
|
2004-09-10 12:13:03 +00:00
|
|
|
uint8 md5Backup[16];
|
|
|
|
|
|
|
|
// MD5 Operations: Backup on load, compare, and reset.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading())
|
2004-09-12 12:18:46 +00:00
|
|
|
memcpy(md5Backup, _gameMD5, 16);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load main state (many members of class ScummEngine get saved here)
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_gameMD5, sizeof(_gameMD5), VER(39));
|
|
|
|
s.skip(2, VER(8), VER(50)); // _roomWidth
|
|
|
|
s.skip(2, VER(8), VER(50)); // _roomHeight
|
|
|
|
s.skip(4, VER(8), VER(50)); // _ENCD_offs
|
|
|
|
s.skip(4, VER(8), VER(50)); // _EXCD_offs
|
|
|
|
s.skip(4, VER(8), VER(50)); // _IM00_offs
|
|
|
|
s.skip(4, VER(8), VER(50)); // _CLUT_offs
|
|
|
|
s.skip(4, VER(8), VER(9)); // _EPAL_offs
|
|
|
|
s.skip(4, VER(8), VER(50)); // _PALS_offs
|
|
|
|
s.syncAsByte(_curPalIndex, VER(8));
|
|
|
|
s.syncAsByte(_currentRoom, VER(8));
|
|
|
|
s.syncAsByte(_roomResource, VER(8));
|
|
|
|
s.syncAsByte(_numObjectsInRoom, VER(8));
|
|
|
|
s.syncAsByte(_currentScript, VER(8));
|
|
|
|
s.skip(4 * _numLocalScripts, VER(8), VER(50)); // _localScriptOffsets
|
|
|
|
|
|
|
|
// vm.localvar grew from 25 to 40 script entries and then from
|
|
|
|
// 16 to 32 bit variables (but that wasn't reflect here)... and
|
|
|
|
// THEN from 16 to 25 variables.
|
|
|
|
sync2DArray(s, vm.localvar, 25, 17, Common::Serializer::Uint16LE, VER(8), VER(8));
|
|
|
|
sync2DArray(s, vm.localvar, 40, 17, Common::Serializer::Uint16LE, VER(9), VER(14));
|
|
|
|
|
|
|
|
// We used to save 25 * 40 = 1000 blocks; but actually, each 'row consisted of 26 entry,
|
|
|
|
// i. 26 * 40 = 1040. Thus the last 40 blocks of localvar where not saved at all. To be
|
|
|
|
// able to load this screwed format, we use a trick: We load 26 * 38 = 988 blocks.
|
|
|
|
// Then, we mark the followin 12 blocks (24 bytes) as obsolete.
|
|
|
|
sync2DArray(s, vm.localvar, 38, 26, Common::Serializer::Uint16LE, VER(15), VER(17));
|
|
|
|
s.skip(2 * 12, VER(15), VER(17));
|
|
|
|
|
|
|
|
// This was the first proper multi dimensional version of the localvars, with 32 bit values
|
|
|
|
sync2DArray(s, vm.localvar, 40, 26, Common::Serializer::Uint32LE, VER(18), VER(19));
|
|
|
|
|
|
|
|
// Then we doubled the script slots again, from 40 to 80
|
|
|
|
sync2DArray(s, vm.localvar, NUM_SCRIPT_SLOT, 26, Common::Serializer::Uint32LE, VER(20));
|
|
|
|
|
|
|
|
s.syncBytes(_resourceMapper, 128, VER(8));
|
|
|
|
s.syncBytes(_charsetColorMap, 16, VER(8));
|
|
|
|
|
|
|
|
// _charsetData grew from 10*16, to 15*16, to 23*16 bytes
|
2018-01-31 12:14:56 -06:00
|
|
|
for (i = 0; i < 10; ++i) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_charsetData[i], 16, VER(8));
|
|
|
|
}
|
2018-01-31 12:14:56 -06:00
|
|
|
for (; i < 15; ++i) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_charsetData[i], 16, VER(10));
|
|
|
|
}
|
2018-01-31 12:14:56 -06:00
|
|
|
for (; i < 23; ++i) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_charsetData[i], 16, VER(67));
|
|
|
|
}
|
|
|
|
|
|
|
|
s.skip(2, VER(8), VER(62)); // _curExecScript
|
|
|
|
|
|
|
|
s.syncAsSint16LE(camera._dest.x, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._dest.y, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._cur.x, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._cur.y, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._last.x, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._last.y, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._accel.x, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._accel.y, VER(8));
|
|
|
|
s.syncAsSint16LE(_screenStartStrip, VER(8));
|
|
|
|
s.syncAsSint16LE(_screenEndStrip, VER(8));
|
|
|
|
s.syncAsByte(camera._mode, VER(8));
|
|
|
|
s.syncAsByte(camera._follows, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._leftTrigger, VER(8));
|
|
|
|
s.syncAsSint16LE(camera._rightTrigger, VER(8));
|
|
|
|
s.syncAsUint16LE(camera._movingToActor, VER(8));
|
|
|
|
|
|
|
|
s.syncAsByte(_actorToPrintStrFor, VER(8));
|
|
|
|
s.syncAsByte(_charsetColor, VER(8));
|
|
|
|
|
|
|
|
// _charsetBufPos was changed from byte to int
|
|
|
|
s.syncAsByte(_charsetBufPos, VER(8), VER(9));
|
|
|
|
s.syncAsSint16LE(_charsetBufPos, VER(10));
|
|
|
|
|
|
|
|
s.syncAsByte(_haveMsg, VER(8));
|
|
|
|
s.syncAsByte(_haveActorSpeechMsg, VER(61));
|
|
|
|
s.syncAsByte(_useTalkAnims, VER(8));
|
|
|
|
|
|
|
|
s.syncAsSint16LE(_talkDelay, VER(8));
|
|
|
|
s.syncAsSint16LE(_defaultTalkDelay, VER(8));
|
|
|
|
s.skip(2, VER(8), VER(27)); // _numInMsgStack
|
|
|
|
s.syncAsByte(_sentenceNum, VER(8));
|
|
|
|
|
|
|
|
s.syncAsByte(vm.cutSceneStackPointer, VER(8));
|
|
|
|
s.syncArray(vm.cutScenePtr, 5, Common::Serializer::Uint32LE, VER(8));
|
|
|
|
s.syncBytes(vm.cutSceneScript, 5, VER(8));
|
|
|
|
s.syncArray(vm.cutSceneData, 5, Common::Serializer::Sint16LE, VER(8));
|
|
|
|
s.syncAsSint16LE(vm.cutSceneScriptIndex, VER(8));
|
|
|
|
|
|
|
|
s.syncAsByte(vm.numNestedScripts, VER(8));
|
|
|
|
s.syncAsByte(_userPut, VER(8));
|
|
|
|
s.syncAsUint16LE(_userState, VER(17));
|
|
|
|
s.syncAsByte(_cursor.state, VER(8));
|
|
|
|
s.skip(1, VER(8), VER(20)); // _gdi->_cursorActive
|
|
|
|
s.syncAsByte(_currentCursor, VER(8));
|
|
|
|
// TODO: This seems wrong, _grabbedCursor is >8192 bytes and sometimes holds
|
|
|
|
// 16-bit values
|
|
|
|
s.syncBytes(_grabbedCursor, 8192, VER(20));
|
|
|
|
s.syncAsSint16LE(_cursor.width, VER(20));
|
|
|
|
s.syncAsSint16LE(_cursor.height, VER(20));
|
|
|
|
s.syncAsSint16LE(_cursor.hotspotX, VER(20));
|
|
|
|
s.syncAsSint16LE(_cursor.hotspotY, VER(20));
|
|
|
|
s.syncAsByte(_cursor.animate, VER(20));
|
|
|
|
s.syncAsByte(_cursor.animateIndex, VER(20));
|
|
|
|
s.syncAsSint16LE(_mouse.x, VER(20));
|
|
|
|
s.syncAsSint16LE(_mouse.y, VER(20));
|
|
|
|
|
|
|
|
s.syncBytes(_colorUsedByCycle, 256, VER(60));
|
|
|
|
s.syncAsByte(_doEffect, VER(8));
|
|
|
|
s.syncAsByte(_switchRoomEffect, VER(8));
|
|
|
|
s.syncAsByte(_newEffect, VER(8));
|
|
|
|
s.syncAsByte(_switchRoomEffect2, VER(8));
|
|
|
|
s.syncAsByte(_bgNeedsRedraw, VER(8));
|
|
|
|
|
|
|
|
// The state of palManipulate is stored only since V10
|
|
|
|
s.syncAsByte(_palManipStart, VER(10));
|
|
|
|
s.syncAsByte(_palManipEnd, VER(10));
|
|
|
|
s.syncAsUint16LE(_palManipCounter, VER(10));
|
|
|
|
|
|
|
|
// gfxUsageBits grew from 200 to 410 entries. Then 3 * 410 entries:
|
|
|
|
s.syncArray(gfxUsageBits, 200, Common::Serializer::Uint32LE, VER(8), VER(9));
|
|
|
|
s.syncArray(gfxUsageBits, 410, Common::Serializer::Uint32LE, VER(10), VER(13));
|
|
|
|
s.syncArray(gfxUsageBits, 3 * 410, Common::Serializer::Uint32LE, VER(14));
|
|
|
|
|
|
|
|
s.skip(1, VER(8), VER(50)); // _gdi->_transparentColor
|
|
|
|
s.syncBytes(_currentPalette, 768, VER(8));
|
|
|
|
s.syncBytes(_darkenPalette, 768, VER(53));
|
|
|
|
|
|
|
|
// Sam & Max specific palette replaced by _shadowPalette now.
|
|
|
|
s.skip(256, VER(8), VER(33)); // _proc_special_palette
|
|
|
|
|
|
|
|
s.syncBytes(_charsetBuffer, 256, VER(8));
|
|
|
|
|
|
|
|
s.syncAsByte(_egoPositioned, VER(8));
|
|
|
|
|
|
|
|
// _gdi->_imgBufOffs grew from 4 to 5 entries. Then one day we realized
|
|
|
|
// that we don't have to store it since initBGBuffers() recomputes it.
|
|
|
|
s.skip(2 * 4, VER(8), VER(9)); // _gdi->_imgBufOffs
|
|
|
|
s.skip(2 * 5, VER(10), VER(26)); // _gdi->_imgBufOffs
|
|
|
|
|
|
|
|
// See _imgBufOffs: _numZBuffer is recomputed by initBGBuffers().
|
|
|
|
s.skip(1, VER(8), VER(26)); // _gdi->_numZBuffer
|
|
|
|
|
|
|
|
s.syncAsByte(_screenEffectFlag, VER(8));
|
|
|
|
|
|
|
|
s.skip(4, VER(8), VER(9)); // _randSeed1
|
|
|
|
s.skip(4, VER(8), VER(9)); // _randSeed2
|
|
|
|
|
|
|
|
// Converted _shakeEnabled to boolean and added a _shakeFrame field.
|
|
|
|
s.syncAsSint16LE(_shakeEnabled, VER(8), VER(9));
|
|
|
|
s.syncAsByte(_shakeEnabled, VER(10));
|
|
|
|
s.syncAsUint32LE(_shakeFrame, VER(10));
|
|
|
|
|
|
|
|
s.syncAsByte(_keepText, VER(8));
|
|
|
|
|
|
|
|
s.syncAsUint16LE(_screenB, VER(8));
|
|
|
|
s.syncAsUint16LE(_screenH, VER(8));
|
|
|
|
|
|
|
|
s.syncAsUint16LE(_NESCostumeSet, VER(47));
|
|
|
|
|
|
|
|
s.skip(2, VER(9), VER(9)); // _cd_track
|
|
|
|
s.skip(2, VER(9), VER(9)); // _cd_loops
|
|
|
|
s.skip(2, VER(9), VER(9)); // _cd_frame
|
|
|
|
s.skip(2, VER(9), VER(9)); // _cd_end
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2004-09-10 12:13:03 +00:00
|
|
|
// MD5 Operations: Backup on load, compare, and reset.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading()) {
|
2006-01-14 16:33:24 +00:00
|
|
|
char md5str1[32+1], md5str2[32+1];
|
2011-05-13 14:02:53 +02:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
sprintf(md5str1 + i*2, "%02x", (int)_gameMD5[i]);
|
|
|
|
sprintf(md5str2 + i*2, "%02x", (int)md5Backup[i]);
|
2006-01-14 16:33:24 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
debug(2, "Save version: %d", s.getVersion());
|
|
|
|
debug(2, "Saved game MD5: %s", (s.getVersion() >= 39) ? md5str1 : "unknown");
|
2006-01-14 16:33:24 +00:00
|
|
|
|
2004-09-12 12:15:19 +00:00
|
|
|
if (memcmp(md5Backup, _gameMD5, 16) != 0) {
|
2007-02-04 01:24:43 +00:00
|
|
|
warning("Game was saved with different gamedata - you may encounter problems");
|
2005-10-13 23:20:41 +00:00
|
|
|
debug(1, "You have %s and save is %s.", md5str2, md5str1);
|
2008-01-28 00:14:17 +00:00
|
|
|
memcpy(_gameMD5, md5Backup, 16);
|
2004-09-10 12:13:03 +00:00
|
|
|
}
|
2006-01-14 16:33:24 +00:00
|
|
|
}
|
2004-09-10 12:13:03 +00:00
|
|
|
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
// Starting V14, we extended the usage bits, to be able to cope with games
|
|
|
|
// that have more than 30 actors (up to 94 are supported now, in theory).
|
|
|
|
// Since the format of the usage bits was changed by this, we have to
|
|
|
|
// convert them when loading an older savegame.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && s.getVersion() < VER(14))
|
2003-01-14 10:06:56 +00:00
|
|
|
upgradeGfxUsageBits();
|
|
|
|
|
2016-06-27 21:25:44 +02:00
|
|
|
// When loading, reset the ShakePos. Fixes one part of bug #7141
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && s.getVersion() >= VER(10))
|
2016-06-27 21:25:44 +02:00
|
|
|
_system->setShakePos(0);
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
// When loading, move the mouse to the saved mouse position.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && s.getVersion() >= VER(20)) {
|
2003-05-28 18:13:30 +00:00
|
|
|
updateCursor();
|
2004-03-28 16:30:50 +00:00
|
|
|
_system->warpMouse(_mouse.x, _mouse.y);
|
2003-05-28 18:13:30 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
// Before V61, we re-used the _haveMsg flag to handle "alternative" speech
|
|
|
|
// sound files (see charset code 10).
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && s.getVersion() < VER(61)) {
|
2005-11-04 09:57:13 +00:00
|
|
|
if (_haveMsg == 0xFE) {
|
|
|
|
_haveActorSpeechMsg = false;
|
|
|
|
_haveMsg = 0xFF;
|
|
|
|
} else {
|
|
|
|
_haveActorSpeechMsg = true;
|
|
|
|
}
|
2005-11-02 21:47:44 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-04-26 13:47:47 +00:00
|
|
|
// Save/load actors
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-10-21 23:01:13 +00:00
|
|
|
for (i = 0; i < _numActors; i++)
|
2006-12-25 15:03:36 +00:00
|
|
|
_actors[i]->saveLoadWithSerializer(s);
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-04-26 13:47:47 +00:00
|
|
|
// Save/load sound data
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-10-21 23:04:58 +00:00
|
|
|
_sound->saveLoadWithSerializer(s);
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load script data
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncArray(vm.slot, 25, syncWithSerializer, VER(0), VER(8));
|
|
|
|
s.syncArray(vm.slot, 40, syncWithSerializer, VER(9), VER(19));
|
|
|
|
s.syncArray(vm.slot, NUM_SCRIPT_SLOT, syncWithSerializer, VER(20));
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() < VER(46)) {
|
2005-03-02 07:11:58 +00:00
|
|
|
// When loading an old savegame, make sure that the 'cycle'
|
|
|
|
// field is set to something sensible, otherwise the scripts
|
|
|
|
// that were running probably won't be.
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SCRIPT_SLOT; i++) {
|
|
|
|
vm.slot[i].cycle = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load local objects
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncArray(_objs, _numLocalObjects, syncWithSerializer);
|
|
|
|
if (s.isLoading()) {
|
|
|
|
if (s.getVersion() < VER(13)) {
|
2012-01-16 22:32:46 +01:00
|
|
|
// Since roughly v13 of the save games, the objs storage has changed a bit
|
|
|
|
for (i = _numObjectsInRoom; i < _numLocalObjects; i++)
|
|
|
|
_objs[i].obj_nr = 0;
|
2017-11-29 00:06:12 -06:00
|
|
|
} else if (_game.version == 0 && s.getVersion() < VER(91)) {
|
2012-01-16 22:32:46 +01:00
|
|
|
for (i = 0; i < _numLocalObjects; i++) {
|
2012-02-04 17:35:59 +01:00
|
|
|
// Merge object id and type (previously stored in flags)
|
2012-01-22 00:01:53 +01:00
|
|
|
if (_objs[i].obj_nr != 0 && OBJECT_V0_TYPE(_objs[i].obj_nr) == 0 && _objs[i].flags != 0)
|
2012-01-16 22:32:46 +01:00
|
|
|
_objs[i].obj_nr = OBJECT_V0(_objs[i].obj_nr, _objs[i].flags);
|
2012-02-04 17:35:59 +01:00
|
|
|
_objs[i].flags = 0;
|
2012-01-16 22:32:46 +01:00
|
|
|
}
|
2003-01-14 18:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load misc stuff
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncArray(_verbs, _numVerbs, syncWithSerializer);
|
|
|
|
s.syncArray(vm.nest, 16, syncWithSerializer);
|
|
|
|
s.syncArray(_sentence, 6, syncWithSerializer);
|
|
|
|
s.syncArray(_string, 6, syncWithSerializer);
|
|
|
|
s.syncArray(_colorCycle, 16, syncWithSerializer);
|
|
|
|
s.syncArray(_scaleSlots, 20, syncWithSerializer, VER(13));
|
2003-01-13 01:29:45 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load resources
|
|
|
|
//
|
2011-05-13 14:02:53 +02:00
|
|
|
ResType type;
|
|
|
|
ResId idx;
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() >= VER(26)) {
|
2003-12-27 00:10:20 +00:00
|
|
|
// New, more robust resource save/load system. This stores the type
|
|
|
|
// and index of each resource. Thus if we increase e.g. the maximum
|
|
|
|
// number of script resources, savegames won't break.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isSaving()) {
|
|
|
|
uint16 endMarker = 0xFFFF;
|
2011-05-13 14:02:53 +02:00
|
|
|
for (type = rtFirst; type <= rtLast; type = ResType(type + 1)) {
|
2011-05-11 17:07:31 +02:00
|
|
|
if (_res->_types[type]._mode != kStaticResTypeMode && type != rtTemp && type != rtBuffer) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsUint16LE(type); // Save the res type...
|
2011-05-13 14:48:01 +02:00
|
|
|
for (idx = 0; idx < _res->_types[type].size(); idx++) {
|
2003-12-27 00:10:20 +00:00
|
|
|
// Only save resources which actually exist...
|
2011-05-13 14:48:01 +02:00
|
|
|
if (_res->_types[type][idx]._address) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsUint16LE(idx); // Save the index of the resource
|
2003-12-27 00:10:20 +00:00
|
|
|
saveResource(s, type, idx);
|
|
|
|
}
|
|
|
|
}
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsUint16LE(endMarker);
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsUint16LE(endMarker);
|
2003-12-27 00:10:20 +00:00
|
|
|
} else {
|
2014-03-30 19:48:08 +02:00
|
|
|
uint16 tmp;
|
2017-11-29 00:06:12 -06:00
|
|
|
while (s.syncAsUint16LE(tmp), tmp != 0xFFFF) {
|
2014-03-30 19:48:08 +02:00
|
|
|
type = (ResType)tmp;
|
2017-11-29 00:06:12 -06:00
|
|
|
while (s.syncAsUint16LE(idx), idx != 0xFFFF) {
|
2011-05-13 14:48:01 +02:00
|
|
|
assert(idx < _res->_types[type].size());
|
2003-12-27 00:10:20 +00:00
|
|
|
loadResource(s, type, idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Old, fragile resource save/load system. Doesn't save resources
|
|
|
|
// with index 0, and breaks whenever we change the limit on a given
|
|
|
|
// resource type.
|
2011-05-13 14:02:53 +02:00
|
|
|
for (type = rtFirst; type <= rtLast; type = ResType(type + 1))
|
2011-05-11 17:07:31 +02:00
|
|
|
if (_res->_types[type]._mode != kStaticResTypeMode && type != rtTemp && type != rtBuffer) {
|
2008-01-28 00:14:17 +00:00
|
|
|
// For V1-V5 games, there used to be no object name resources.
|
|
|
|
// At some point this changed. But since old savegames rely on
|
|
|
|
// unchanged resource counts, we have to hard code the following check
|
|
|
|
if (_game.version < 6 && type == rtObjectName)
|
|
|
|
continue;
|
2011-05-13 14:48:01 +02:00
|
|
|
for (idx = 1; idx < _res->_types[type].size(); idx++)
|
2011-05-11 17:10:59 +02:00
|
|
|
loadResourceOLD(s, type, idx);
|
2008-01-28 00:14:17 +00:00
|
|
|
}
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
2005-04-26 16:43:20 +00:00
|
|
|
// Save/load global object state
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_objectOwnerTable, _numGlobalObjects);
|
|
|
|
s.syncBytes(_objectStateTable, _numGlobalObjects);
|
2001-11-26 19:57:57 +00:00
|
|
|
if (_objectRoomTable)
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_objectRoomTable, _numGlobalObjects);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load palette data
|
2011-11-24 21:27:22 +01:00
|
|
|
// Don't save 16 bit palette in FM-Towns and PCE games, since it gets regenerated afterwards anyway.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (_16BitPalette && !(_game.platform == Common::kPlatformFMTowns && s.getVersion() < VER(82)) && !((_game.platform == Common::kPlatformFMTowns || _game.platform == Common::kPlatformPCEngine) && s.getVersion() > VER(87))) {
|
|
|
|
s.syncArray(_16BitPalette, 512, Common::Serializer::Uint16LE);
|
2009-10-27 09:44:13 +00:00
|
|
|
}
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
2012-09-26 04:17:31 +02:00
|
|
|
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
// FM-Towns specific (extra palette data, color cycle data, etc.)
|
2011-11-01 17:36:50 +01:00
|
|
|
// In earlier save game versions (below 87) the FM-Towns specific data would get saved (and loaded) even in non FM-Towns games.
|
|
|
|
// This would cause an unnecessary save file incompatibility between DS (which uses the DISABLE_TOWNS_DUAL_LAYER_MODE setting)
|
|
|
|
// and other ports.
|
2011-11-24 21:27:22 +01:00
|
|
|
// In version 88 and later the save files from FM-Towns targets are compatible between DS and other platforms, too.
|
|
|
|
|
|
|
|
#ifdef DISABLE_TOWNS_DUAL_LAYER_MODE
|
|
|
|
byte hasTownsData = 0;
|
2018-01-31 21:12:22 -06:00
|
|
|
if (_game.platform == Common::kPlatformFMTowns && s.getVersion() > VER(87))
|
|
|
|
s.syncAsByte(hasTownsData);
|
2011-11-24 21:27:22 +01:00
|
|
|
|
|
|
|
if (hasTownsData) {
|
|
|
|
// Skip FM-Towns specific data
|
2018-01-31 21:12:22 -06:00
|
|
|
s.skip(69 + 44 * sizeof(int16));
|
2011-11-24 21:27:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2017-11-29 00:06:12 -06:00
|
|
|
byte hasTownsData = ((_game.platform == Common::kPlatformFMTowns && s.getVersion() >= VER(87)) || (s.getVersion() >= VER(82) && s.getVersion() < VER(87))) ? 1 : 0;
|
|
|
|
if (_game.platform == Common::kPlatformFMTowns && s.getVersion() > VER(87))
|
|
|
|
s.syncAsByte(hasTownsData);
|
2011-11-24 21:27:22 +01:00
|
|
|
|
|
|
|
if (hasTownsData) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_textPalette, 48);
|
|
|
|
// TODO: This seems wrong, there are 16 _cyclRects
|
|
|
|
s.syncArray(_cyclRects, 10, syncWithSerializer, VER(82));
|
|
|
|
if (s.getVersion() >= VER(82))
|
|
|
|
syncWithSerializer(s, _curStringRect);
|
|
|
|
s.syncBytes(_townsCharsetColorMap, 16);
|
|
|
|
s.syncAsByte(_townsOverrideShadowColor, VER(82));
|
|
|
|
s.syncAsByte(_numCyclRects, VER(82));
|
|
|
|
s.syncAsByte(_townsPaletteFlags, VER(82));
|
|
|
|
s.syncAsByte(_townsClearLayerFlag, VER(82));
|
|
|
|
s.syncAsByte(_townsActiveLayerFlags, VER(82));
|
|
|
|
} else if (_game.platform == Common::kPlatformFMTowns && s.getVersion() >= VER(82)) {
|
2011-11-24 21:27:22 +01:00
|
|
|
warning("Save file is missing FM-Towns specific graphic data (game was apparently saved on another platform)");
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
}
|
2010-10-05 19:04:52 +00:00
|
|
|
#endif
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
2003-08-29 03:54:47 +00:00
|
|
|
if (_shadowPaletteSize) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_shadowPalette, _shadowPaletteSize);
|
2003-08-29 03:54:47 +00:00
|
|
|
// _roomPalette didn't show up until V21 save games
|
2011-08-26 18:43:28 +02:00
|
|
|
// Note that we also save the room palette for Indy4 Amiga, since it
|
|
|
|
// is used as palette map there too, but we do so slightly a bit
|
|
|
|
// further down to group it with the other special palettes needed.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() >= VER(21) && _game.version < 5)
|
|
|
|
s.syncBytes(_roomPalette, sizeof(_roomPalette));
|
2003-08-29 03:54:47 +00:00
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
// PalManip data was not saved before V10 save games
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() < VER(10))
|
2002-12-08 16:14:29 +00:00
|
|
|
_palManipCounter = 0;
|
2002-09-24 15:46:09 +00:00
|
|
|
if (_palManipCounter) {
|
|
|
|
if (!_palManipPalette)
|
|
|
|
_palManipPalette = (byte *)calloc(0x300, 1);
|
|
|
|
if (!_palManipIntermediatePal)
|
2004-11-27 18:01:44 +00:00
|
|
|
_palManipIntermediatePal = (byte *)calloc(0x600, 1);
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_palManipPalette, 0x300);
|
|
|
|
s.syncBytes(_palManipIntermediatePal, 0x600);
|
2002-09-24 15:46:09 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-21 15:45:09 +00:00
|
|
|
// darkenPalette was not saved before V53
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && s.getVersion() < VER(53)) {
|
2005-05-21 15:45:09 +00:00
|
|
|
memcpy(_darkenPalette, _currentPalette, 768);
|
|
|
|
}
|
2002-09-24 15:46:09 +00:00
|
|
|
|
2005-11-01 02:43:54 +00:00
|
|
|
// _colorUsedByCycle was not saved before V60
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && s.getVersion() < VER(60)) {
|
2005-11-01 02:43:54 +00:00
|
|
|
memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle));
|
|
|
|
}
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2011-08-26 18:43:28 +02:00
|
|
|
// Indy4 Amiga specific palette tables were not saved before V85
|
|
|
|
if (_game.platform == Common::kPlatformAmiga && _game.id == GID_INDY4) {
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() >= 85) {
|
|
|
|
s.syncBytes(_roomPalette, 256);
|
|
|
|
s.syncBytes(_verbPalette, 256);
|
|
|
|
s.syncBytes(_amigaPalette, 3 * 64);
|
2011-08-27 19:57:45 +02:00
|
|
|
|
|
|
|
// Starting from version 86 we also save the first used color in
|
|
|
|
// the palette beyond the verb palette. For old versions we just
|
|
|
|
// look for it again, which hopefully won't cause any troubles.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() >= VER(86)) {
|
|
|
|
s.syncAsUint16LE(_amigaFirstUsedColor);
|
2011-08-27 19:57:45 +02:00
|
|
|
} else {
|
|
|
|
amigaPaletteFindFirstUsedColor();
|
|
|
|
}
|
2011-08-26 18:43:28 +02:00
|
|
|
} else {
|
|
|
|
warning("Save with old Indiana Jones 4 Amiga palette handling detected");
|
|
|
|
// We need to restore the internal state of the Amiga palette for Indy4
|
|
|
|
// Amiga. This might lead to graphics glitches!
|
|
|
|
setAmigaPaletteFromPtr(_currentPalette);
|
|
|
|
}
|
|
|
|
}
|
2011-08-26 05:51:08 +02:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
//
|
|
|
|
// Save/load more global object state
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncArray(_classData, _numGlobalObjects, Common::Serializer::Uint32LE);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load script variables
|
|
|
|
//
|
2003-05-08 15:48:50 +00:00
|
|
|
var120Backup = _scummVars[120];
|
|
|
|
var98Backup = _scummVars[98];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncArray(_roomVars, _numRoomVariables, Common::Serializer::Sint32LE, VER(38));
|
2004-09-10 01:03:01 +00:00
|
|
|
|
2003-01-15 14:14:00 +00:00
|
|
|
// The variables grew from 16 to 32 bit.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() < VER(15))
|
|
|
|
s.syncArray(_scummVars, _numVariables, Common::Serializer::Sint16LE);
|
2003-01-15 14:14:00 +00:00
|
|
|
else
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncArray(_scummVars, _numVariables, Common::Serializer::Sint32LE);
|
2002-03-03 22:14:47 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_TENTACLE) // Maybe misplaced, but that's the main idea
|
2003-05-08 15:48:50 +00:00
|
|
|
_scummVars[120] = var120Backup;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_INDY4)
|
2004-10-03 10:02:32 +00:00
|
|
|
_scummVars[98] = var98Backup;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_bitVars, _numBitVariables / 8);
|
2001-11-07 18:10:52 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load a list of the locked objects
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isSaving()) {
|
|
|
|
byte endMarker = 0xFF;
|
2011-05-13 14:02:53 +02:00
|
|
|
for (type = rtFirst; type <= rtLast; type = ResType(type + 1))
|
2011-05-13 14:48:01 +02:00
|
|
|
for (idx = 1; idx < _res->_types[type].size(); idx++) {
|
2011-05-13 14:02:53 +02:00
|
|
|
if (_res->isLocked(type, idx)) {
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsByte(type);
|
|
|
|
s.syncAsUint16LE(idx);
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsByte(endMarker);
|
2001-11-07 18:10:52 +00:00
|
|
|
} else {
|
2014-03-30 19:48:08 +02:00
|
|
|
uint8 tmp;
|
2017-11-29 00:06:12 -06:00
|
|
|
while (s.syncAsByte(tmp), tmp != 0xFF) {
|
2014-03-30 19:48:08 +02:00
|
|
|
type = (ResType)tmp;
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsUint16LE(idx);
|
2011-05-13 14:02:53 +02:00
|
|
|
_res->lock(type, idx);
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-09 17:29:22 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load the Audio CD status
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() >= VER(24)) {
|
2010-06-09 20:09:57 +00:00
|
|
|
AudioCDManager::Status info;
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isSaving())
|
2010-06-15 04:13:12 +00:00
|
|
|
info = _system->getAudioCDManager()->getStatus();
|
2017-11-29 00:06:12 -06:00
|
|
|
syncWithSerializer(s, info);
|
2003-11-29 13:58:17 +00:00
|
|
|
// If we are loading, and the music being loaded was supposed to loop
|
2005-04-26 13:43:01 +00:00
|
|
|
// forever, then resume playing it. This helps a lot when the audio CD
|
2003-11-29 13:58:17 +00:00
|
|
|
// is used to provide ambient music (see bug #788195).
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.isLoading() && info.playing && info.numLoops < 0)
|
2014-07-03 00:14:28 +03:00
|
|
|
_sound->playCDTrackInternal(info.track, info.numLoops, info.start, info.duration);
|
2003-11-29 13:58:17 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load the iMuse status
|
|
|
|
//
|
2004-01-31 22:12:35 +00:00
|
|
|
if (_imuse && (_saveSound || !_saveTemporaryState)) {
|
2018-01-31 12:33:13 -06:00
|
|
|
_imuse->saveLoadIMuse(s, this);
|
2002-12-07 20:28:40 +00:00
|
|
|
}
|
2007-05-26 17:39:33 +00:00
|
|
|
|
2010-08-18 21:38:43 +00:00
|
|
|
|
2012-11-15 22:23:44 +01:00
|
|
|
//
|
|
|
|
// Save/load music engine status
|
|
|
|
//
|
|
|
|
if (_musicEngine) {
|
|
|
|
_musicEngine->saveLoadWithSerializer(s);
|
|
|
|
}
|
|
|
|
|
2010-08-18 21:38:43 +00:00
|
|
|
|
2007-05-26 17:39:33 +00:00
|
|
|
//
|
|
|
|
// Save/load the charset renderer state
|
|
|
|
//
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() >= VER(73)) {
|
2007-05-28 08:02:10 +00:00
|
|
|
_charset->saveLoadWithSerializer(s);
|
2017-11-29 00:06:12 -06:00
|
|
|
} else if (s.isLoading()) {
|
|
|
|
if (s.getVersion() == VER(72)) {
|
|
|
|
byte curId;
|
|
|
|
s.syncAsByte(curId);
|
|
|
|
_charset->setCurID(curId);
|
2007-05-28 08:02:10 +00:00
|
|
|
} else {
|
|
|
|
// Before V72, the charset id wasn't saved. This used to cause issues such
|
|
|
|
// as the one described in the bug report #1722153. For these savegames,
|
|
|
|
// we reinitialize the id using a, hopefully, sane value.
|
|
|
|
_charset->setCurID(_string[0]._default.charset);
|
2007-05-26 17:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-26 13:33:17 +00:00
|
|
|
}
|
2004-05-02 10:07:59 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v0::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine_v2::saveLoadWithSerializer(s);
|
|
|
|
|
|
|
|
s.syncAsByte(_currentMode, VER(78));
|
|
|
|
s.syncAsByte(_currentLights, VER(78));
|
|
|
|
s.syncAsByte(_activeVerb, VER(92));
|
|
|
|
s.syncAsUint16LE(_activeObject, VER(92));
|
|
|
|
s.syncAsUint16LE(_activeObject2, VER(92));
|
|
|
|
s.syncAsByte(_cmdVerb, VER(92));
|
|
|
|
s.syncAsUint16LE(_cmdObject, VER(92));
|
|
|
|
s.syncAsUint16LE(_cmdObject2, VER(92));
|
|
|
|
s.syncAsUint16LE(_walkToObject, VER(92));
|
|
|
|
s.syncAsByte(_walkToObjectState, VER(92));
|
2006-03-16 12:04:52 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 23:19:33 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v2::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine::saveLoadWithSerializer(s);
|
2006-03-16 12:04:52 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsUint16LE(_inventoryOffset, VER(79));
|
2009-07-28 23:19:33 +00:00
|
|
|
|
|
|
|
// In old saves we didn't store _inventoryOffset -> reset it to
|
|
|
|
// a sane default when loading one of those.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (s.getVersion() < VER(79) && s.isLoading()) {
|
2009-07-28 23:19:33 +00:00
|
|
|
_inventoryOffset = 0;
|
|
|
|
}
|
2019-05-05 22:41:20 +10:00
|
|
|
|
|
|
|
s.syncAsByte(_flashlight.xStrips, VER(99));
|
|
|
|
s.syncAsByte(_flashlight.yStrips, VER(99));
|
2006-03-16 12:04:52 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v5::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine::saveLoadWithSerializer(s);
|
2004-11-28 21:24:02 +00:00
|
|
|
|
2005-01-06 15:57:12 +00:00
|
|
|
// This is probably only needed for Loom.
|
2017-11-29 00:06:12 -06:00
|
|
|
// TODO: This looks wrong, _cursorImages is [4][17]
|
|
|
|
sync2DArray(s, _cursorImages, 4, 16, Common::Serializer::Uint16LE, VER(44));
|
|
|
|
s.syncBytes(_cursorHotspots, 8, VER(44));
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
|
|
|
// Reset cursors for old FM-Towns savegames saved with 256 color setting.
|
|
|
|
// Otherwise the cursor will be messed up when displayed in the new hi color setting.
|
2017-11-29 00:06:12 -06:00
|
|
|
if (_game.platform == Common::kPlatformFMTowns && _outputPixelFormat.bytesPerPixel == 2 && s.isLoading() && s.getVersion() < VER(82)) {
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
if (_game.id == GID_LOOM) {
|
|
|
|
redefineBuiltinCursorFromChar(1, 1);
|
|
|
|
redefineBuiltinCursorHotspot(1, 0, 0);
|
|
|
|
} else {
|
|
|
|
resetCursors();
|
|
|
|
}
|
|
|
|
}
|
2011-06-18 16:32:59 +02:00
|
|
|
|
|
|
|
// Regenerate 16bit palette after loading.
|
|
|
|
// This avoids color issues when loading savegames that have been saved with a different ScummVM port
|
|
|
|
// that uses a different 16bit color mode than the ScummVM port which is currently used.
|
|
|
|
#ifdef USE_RGB_COLOR
|
2017-11-29 00:06:12 -06:00
|
|
|
if (_game.platform == Common::kPlatformPCEngine && s.isLoading()) {
|
2011-06-18 16:32:59 +02:00
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
_16BitPalette[i] = get16BitColor(_currentPalette[i * 3 + 0], _currentPalette[i * 3 + 1], _currentPalette[i * 3 + 2]);
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-26 13:33:17 +00:00
|
|
|
}
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
2017-11-29 00:06:12 -06:00
|
|
|
void syncWithSerializer(Common::Serializer &s, ScummEngine_v7::SubtitleText &st) {
|
|
|
|
s.syncBytes(st.text, 256, VER(61));
|
|
|
|
s.syncAsByte(st.charset, VER(61));
|
|
|
|
s.syncAsByte(st.color, VER(61));
|
|
|
|
s.syncAsSint16LE(st.xpos, VER(61));
|
|
|
|
s.syncAsSint16LE(st.ypos, VER(61));
|
|
|
|
s.syncAsByte(st.actorSpeechMsg, VER(61));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v7::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine::saveLoadWithSerializer(s);
|
|
|
|
|
|
|
|
_imuseDigital->saveLoadEarly(s);
|
|
|
|
|
|
|
|
s.syncArray(_subtitleQueue, ARRAYSIZE(_subtitleQueue), syncWithSerializer);
|
|
|
|
s.syncAsSint32LE(_subtitleQueuePos, VER(61));
|
|
|
|
s.skip(4, VER(68), VER(68)); // _verbCharset
|
|
|
|
s.syncAsSint32LE(_verbLineSpacing, VER(68));
|
|
|
|
|
|
|
|
if (s.getVersion() <= VER(68) && s.isLoading()) {
|
2007-12-23 17:27:33 +00:00
|
|
|
// WORKAROUND bug #1846049: Reset the default charset color to a sane value.
|
|
|
|
_string[0]._default.charset = 1;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v60he::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine::saveLoadWithSerializer(s);
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_arraySlot, _numArray);
|
2005-10-19 12:15:36 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v70he::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine_v60he::saveLoadWithSerializer(s);
|
2005-10-19 12:15:36 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsSint32LE(_heSndSoundId, VER(51));
|
|
|
|
s.syncAsSint32LE(_heSndOffset, VER(51));
|
|
|
|
s.syncAsSint32LE(_heSndChannel, VER(51));
|
|
|
|
s.syncAsSint32LE(_heSndFlags, VER(51));
|
2005-10-19 12:15:36 +00:00
|
|
|
}
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_HE
|
2017-11-29 00:06:12 -06:00
|
|
|
static void syncWithSerializer(Common::Serializer &s, WizPolygon &wp) {
|
|
|
|
s.syncAsSint16LE(wp.vert[0].x, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[0].y, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[1].x, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[1].y, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[2].x, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[2].y, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[3].x, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[3].y, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[4].x, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.vert[4].y, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.bound.left, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.bound.top, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.bound.right, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.bound.bottom, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.id, VER(40));
|
|
|
|
s.syncAsSint16LE(wp.numVerts, VER(40));
|
|
|
|
s.syncAsByte(wp.flag, VER(40));
|
2005-04-26 14:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v71he::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine_v70he::saveLoadWithSerializer(s);
|
|
|
|
|
|
|
|
s.syncArray(_wiz->_polygons, ARRAYSIZE(_wiz->_polygons), syncWithSerializer);
|
2005-10-19 12:15:36 +00:00
|
|
|
}
|
2005-04-26 15:31:51 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void syncWithSerializer(Common::Serializer &s, FloodFillParameters &ffp) {
|
|
|
|
s.syncAsSint32LE(ffp.box.left, VER(51));
|
|
|
|
s.syncAsSint32LE(ffp.box.top, VER(51));
|
|
|
|
s.syncAsSint32LE(ffp.box.right, VER(51));
|
|
|
|
s.syncAsSint32LE(ffp.box.bottom, VER(51));
|
|
|
|
s.syncAsSint32LE(ffp.x, VER(51));
|
|
|
|
s.syncAsSint32LE(ffp.y, VER(51));
|
|
|
|
s.syncAsSint32LE(ffp.flags, VER(51));
|
|
|
|
s.skip(4, VER(51), VER(62)); // unk1C
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine_v71he::saveLoadWithSerializer(s);
|
|
|
|
|
|
|
|
_sprite->saveLoadWithSerializer(s);
|
|
|
|
|
|
|
|
syncWithSerializer(s, _floodFillParams);
|
2005-10-19 12:15:36 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsSint32LE(_curMaxSpriteId, VER(51));
|
|
|
|
s.syncAsSint32LE(_curSpriteId, VER(51));
|
|
|
|
s.syncAsSint32LE(_curSpriteGroupId, VER(51));
|
|
|
|
s.skip(4, VER(51), VER(63)); // _numSpritesToProcess
|
|
|
|
s.syncAsSint32LE(_heObject, VER(51));
|
|
|
|
s.syncAsSint32LE(_heObjectNum, VER(51));
|
|
|
|
s.syncAsSint32LE(_hePaletteNum, VER(51));
|
2005-04-26 15:13:04 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine_v99he::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine_v90he::saveLoadWithSerializer(s);
|
2005-04-26 15:13:04 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncBytes(_hePalettes, (_numPalettes + 1) * _hePaletteSlot);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v100he::saveLoadWithSerializer(Common::Serializer &s) {
|
|
|
|
ScummEngine_v99he::saveLoadWithSerializer(s);
|
2005-04-26 15:13:04 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
s.syncAsSint32LE(_heResId, VER(51));
|
|
|
|
s.syncAsSint32LE(_heResType, VER(51));
|
2005-04-26 14:01:38 +00:00
|
|
|
}
|
2005-05-14 14:06:37 +00:00
|
|
|
#endif
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine::loadResourceOLD(Common::Serializer &ser, ResType type, ResId idx) {
|
2002-02-24 17:25:03 +00:00
|
|
|
uint32 size;
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
if (type == rtSound && ser.getVersion() >= VER(23)) {
|
2011-05-13 11:39:51 +02:00
|
|
|
// Save/load only a list of resource numbers that need to be reloaded.
|
2017-11-29 00:06:12 -06:00
|
|
|
uint16 tmp;
|
|
|
|
ser.syncAsUint16LE(tmp);
|
|
|
|
if (tmp)
|
2011-05-13 11:39:51 +02:00
|
|
|
ensureResourceLoaded(rtSound, idx);
|
|
|
|
} else if (_res->_types[type]._mode == kDynamicResTypeMode) {
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint32LE(size);
|
2011-05-11 17:10:59 +02:00
|
|
|
if (size) {
|
|
|
|
_res->createResource(type, idx, size);
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncBytes(getResourceAddress(type, idx), size);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (type == rtInventory) {
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint16LE(_inventory[idx]);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
2017-11-29 00:06:12 -06:00
|
|
|
if (type == rtObjectName && ser.getVersion() >= VER(25)) {
|
2011-05-11 17:10:59 +02:00
|
|
|
// Paranoia: We increased the possible number of new names
|
|
|
|
// to fix bugs #933610 and #936323. The savegame format
|
|
|
|
// didn't change, but at least during the transition
|
|
|
|
// period there is a slight chance that we try to load
|
|
|
|
// more names than we have allocated space for. If so,
|
|
|
|
// discard them.
|
|
|
|
if (idx < _numNewNames)
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint16LE(_newNames[idx]);
|
2003-09-14 20:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine::saveResource(Common::Serializer &ser, ResType type, ResId idx) {
|
2011-05-13 14:48:01 +02:00
|
|
|
assert(_res->_types[type][idx]._address);
|
2003-12-27 00:10:20 +00:00
|
|
|
|
2011-05-11 17:07:31 +02:00
|
|
|
if (_res->_types[type]._mode == kDynamicResTypeMode) {
|
2011-05-13 14:48:01 +02:00
|
|
|
byte *ptr = _res->_types[type][idx]._address;
|
|
|
|
uint32 size = _res->_types[type][idx]._size;
|
2003-12-27 00:10:20 +00:00
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint32LE(size);
|
|
|
|
ser.syncBytes(ptr, size);
|
2003-12-27 00:10:20 +00:00
|
|
|
|
|
|
|
if (type == rtInventory) {
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint16LE(_inventory[idx]);
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
|
|
|
if (type == rtObjectName) {
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint16LE(_newNames[idx]);
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 00:06:12 -06:00
|
|
|
void ScummEngine::loadResource(Common::Serializer &ser, ResType type, ResId idx) {
|
|
|
|
if (_game.heversion >= 60 && ser.getVersion() <= VER(65) &&
|
2006-03-26 00:24:00 +00:00
|
|
|
((type == rtSound && idx == 1) || (type == rtSpoolBuffer))) {
|
2017-11-29 00:06:12 -06:00
|
|
|
uint32 size;
|
|
|
|
ser.syncAsUint32LE(size);
|
2006-03-26 00:24:00 +00:00
|
|
|
assert(size);
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(type, idx, size);
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncBytes(getResourceAddress(type, idx), size);
|
2011-05-13 11:39:51 +02:00
|
|
|
} else if (type == rtSound) {
|
|
|
|
// HE Games use sound resource 1 for speech
|
|
|
|
if (_game.heversion >= 60 && idx == 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ensureResourceLoaded(rtSound, idx);
|
2011-05-11 17:07:31 +02:00
|
|
|
} else if (_res->_types[type]._mode == kDynamicResTypeMode) {
|
2017-11-29 00:06:12 -06:00
|
|
|
uint32 size;
|
|
|
|
ser.syncAsUint32LE(size);
|
2003-12-27 00:10:20 +00:00
|
|
|
assert(size);
|
2011-05-13 11:39:51 +02:00
|
|
|
byte *ptr = _res->createResource(type, idx, size);
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncBytes(ptr, size);
|
2003-12-27 00:10:20 +00:00
|
|
|
|
|
|
|
if (type == rtInventory) {
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint16LE(_inventory[idx]);
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
|
|
|
if (type == rtObjectName) {
|
2017-11-29 00:06:12 -06:00
|
|
|
ser.syncAsUint16LE(_newNames[idx]);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-10-03 18:33:57 +00:00
|
|
|
|
|
|
|
} // End of namespace Scumm
|