[Scummvm-git-logs] scummvm master -> 5f3004b94e8bc66a8c4007d18efa64bd8f5e77fe
dreammaster
dreammaster at scummvm.org
Fri Sep 10 03:14:45 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5f3004b94e AGS: Fix loading standalone AGS Maniac Mansion Deluxe saves
Commit: 5f3004b94e8bc66a8c4007d18efa64bd8f5e77fe
https://github.com/scummvm/scummvm/commit/5f3004b94e8bc66a8c4007d18efa64bd8f5e77fe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-09T20:14:27-07:00
Commit Message:
AGS: Fix loading standalone AGS Maniac Mansion Deluxe saves
It seems the older version of AGSFlashlight didn't persist
it's fields in the savegame like the latest version does.
I decided against trying to explicitly figure out which
version of AGSFlashlight different games used, and instead
simply have fallback handling if the savegame doesn't
have the data.
The only minor disadvantage is that this means that whilst
savegames are portable from standalone AGS to ScummVM for
the game, it won't in the other direction. But I don't
think that's too major an issue, since it's only for the
few games that do use the old AGSFlashlight
Changed paths:
engines/ags/plugins/ags_flashlight/ags_flashlight.cpp
engines/ags/plugins/ags_plugin.cpp
engines/ags/plugins/ags_plugin.h
engines/ags/plugins/serializer.h
diff --git a/engines/ags/plugins/ags_flashlight/ags_flashlight.cpp b/engines/ags/plugins/ags_flashlight/ags_flashlight.cpp
index 19a49c0d82..62285988fe 100644
--- a/engines/ags/plugins/ags_flashlight/ags_flashlight.cpp
+++ b/engines/ags/plugins/ags_flashlight/ags_flashlight.cpp
@@ -107,35 +107,39 @@ void AGSFlashlight::syncGame(Serializer &s) {
uint32 SaveVersion = SaveMagic;
s.syncAsInt(SaveVersion);
- if (s.isLoading() && SaveVersion != SaveMagic)
- _engine->AbortGame("agsflashlight: bad save.");
-
- s.syncAsInt(g_RedTint);
- s.syncAsInt(g_GreenTint);
- s.syncAsInt(g_BlueTint);
-
- s.syncAsInt(g_DarknessLightLevel);
- s.syncAsInt(g_BrightnessLightLevel);
- s.syncAsInt(g_DarknessSize);
- s.syncAsInt(g_DarknessDiameter);
- s.syncAsInt(g_BrightnessSize);
-
- s.syncAsInt(g_FlashlightX);
- s.syncAsInt(g_FlashlightY);
-
- s.syncAsInt(g_FlashlightFollowMouse);
-
- s.syncAsInt(g_FollowCharacterId);
- s.syncAsInt(g_FollowCharacterDx);
- s.syncAsInt(g_FollowCharacterDy);
- s.syncAsInt(g_FollowCharacterHorz);
- s.syncAsInt(g_FollowCharacterVert);
-
- if (s.isLoading()) {
- if (g_FollowCharacterId != 0)
- g_FollowCharacter = _engine->GetCharacter(g_FollowCharacterId);
-
- g_BitmapMustBeUpdated = true;
+ if (s.isLoading() && SaveVersion != SaveMagic) {
+ // Older versions of AGSFlashlight didn't persist their data.
+ // So in such a case, revert the 4 bytes and skip everything else
+ s.unreadInt();
+
+ } else {
+ s.syncAsInt(g_RedTint);
+ s.syncAsInt(g_GreenTint);
+ s.syncAsInt(g_BlueTint);
+
+ s.syncAsInt(g_DarknessLightLevel);
+ s.syncAsInt(g_BrightnessLightLevel);
+ s.syncAsInt(g_DarknessSize);
+ s.syncAsInt(g_DarknessDiameter);
+ s.syncAsInt(g_BrightnessSize);
+
+ s.syncAsInt(g_FlashlightX);
+ s.syncAsInt(g_FlashlightY);
+
+ s.syncAsInt(g_FlashlightFollowMouse);
+
+ s.syncAsInt(g_FollowCharacterId);
+ s.syncAsInt(g_FollowCharacterDx);
+ s.syncAsInt(g_FollowCharacterDy);
+ s.syncAsInt(g_FollowCharacterHorz);
+ s.syncAsInt(g_FollowCharacterVert);
+
+ if (s.isLoading()) {
+ if (g_FollowCharacterId != 0)
+ g_FollowCharacter = _engine->GetCharacter(g_FollowCharacterId);
+
+ g_BitmapMustBeUpdated = true;
+ }
}
}
diff --git a/engines/ags/plugins/ags_plugin.cpp b/engines/ags/plugins/ags_plugin.cpp
index 02d5a0fb8b..64159d1e0b 100644
--- a/engines/ags/plugins/ags_plugin.cpp
+++ b/engines/ags/plugins/ags_plugin.cpp
@@ -268,6 +268,16 @@ int IAGSEngine::FWrite(void *buffer, int32 len, int32 handle) {
return _G(pl_file_stream)->Write(buffer, len);
}
+bool IAGSEngine::FSeek(soff_t offset, int origin, int32 handle) {
+ if (handle != _G(pl_file_handle)) {
+ quitprintf("IAGSEngine::FWrite: invalid file handle: %d", handle);
+ }
+ if (!_G(pl_file_stream)) {
+ quit("IAGSEngine::FWrite: file stream not set");
+ }
+ return _G(pl_file_stream)->Seek(offset, (AGS::Shared::StreamSeek)origin);
+}
+
void IAGSEngine::DrawTextWrapped(int32 xx, int32 yy, int32 wid, int32 font, int32 color, const char *text) {
// TODO: use generic function from the engine instead of having copy&pasted code here
int linespacing = getfontspacing_outlined(font);
diff --git a/engines/ags/plugins/ags_plugin.h b/engines/ags/plugins/ags_plugin.h
index ac4f87209b..7a0453b261 100644
--- a/engines/ags/plugins/ags_plugin.h
+++ b/engines/ags/plugins/ags_plugin.h
@@ -378,6 +378,8 @@ public:
AGSIFUNC(int) FWrite(void *, int32, int32);
// similar to fread - buffer, size, filehandle
AGSIFUNC(int) FRead(void *, int32, int32);
+ // similar to fseek
+ AGSIFUNC(bool)FSeek(soff_t offset, int origin, int32 handle);
// print text, wrapping as usual
AGSIFUNC(void) DrawTextWrapped(int32 x, int32 y, int32 width, int32 font, int32 color, const char *text);
// set the current active 'screen'
diff --git a/engines/ags/plugins/serializer.h b/engines/ags/plugins/serializer.h
index 14345a04ec..85c6cb2c16 100644
--- a/engines/ags/plugins/serializer.h
+++ b/engines/ags/plugins/serializer.h
@@ -23,6 +23,7 @@
#ifndef AGS_PLUGINS_SERIALIZER_H
#define AGS_PLUGINS_SERIALIZER_H
+#include "ags/shared/api/stream_api.h"
#include "ags/plugins/ags_plugin.h"
#include "common/serializer.h"
@@ -91,6 +92,10 @@ private:
else
_engine->FWrite(&value, sizeof(double), _file);
}
+
+ void unreadInt() {
+ _engine->FSeek(-4, AGS::Shared::kSeekCurrent, _file);
+ }
};
} // namespace Plugins
More information about the Scummvm-git-logs
mailing list