Improved version of patch to fix bug #1722153: "FT: Error on loading a game saved during a dialogue"

svn-id: r26987
This commit is contained in:
Eugene Sandulenko 2007-05-28 08:02:10 +00:00
parent 45e8fbe8f5
commit bd67214c96
4 changed files with 27 additions and 5 deletions

View File

@ -1311,6 +1311,20 @@ void CharsetRenderer::translateColor() {
}
}
void CharsetRenderer::saveLoadWithSerializer(Serializer *ser) {
static const SaveLoadEntry charsetRendererEntries[] = {
MKLINE(CharsetRenderer, _curId, sleByte, VER(73)),
MKLINE(CharsetRenderer, _color, sleByte, VER(73)),
MKEND()
};
ser->saveLoadEntries(this, charsetRendererEntries);
if (ser->isLoading()) {
setCurID(_curId);
setColor(_color);
}
}
void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) {
int width, height, origWidth, origHeight;

View File

@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
#include "scumm/gfx.h"
#include "scumm/saveload.h"
namespace Scumm {
@ -84,6 +85,8 @@ public:
virtual int getCharWidth(byte chr) = 0;
virtual void setColor(byte color) { _color = color; translateColor(); }
void saveLoadWithSerializer(Serializer *ser);
};
class CharsetRendererCommon : public CharsetRenderer {

View File

@ -1156,11 +1156,16 @@ void ScummEngine::saveOrLoad(Serializer *s) {
//
// Save/load the charset renderer state
//
if (s->getVersion() >= VER(72)) {
if (s->isSaving()) {
s->saveByte(_charset->getCurID());
} else {
if (s->getVersion() >= VER(73)) {
_charset->saveLoadWithSerializer(s);
} else if (s->isLoading()) {
if (s->getVersion() == VER(72)) {
_charset->setCurID(s->loadByte());
} 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);
}
}
}

View File

@ -47,7 +47,7 @@ namespace Scumm {
* only saves/loads those which are valid for the version of the savegame
* which is being loaded/saved currently.
*/
#define CURRENT_VER 72
#define CURRENT_VER 73
/**
* An auxillary macro, used to specify savegame versions. We use this instead