aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/savegame.cpp
diff options
context:
space:
mode:
authorColin Snover2016-06-25 21:19:47 +0200
committerWillem Jan Palenstijn2016-07-01 00:18:32 +0200
commitca279390a36d0f87be134c6788c6420a748b99b8 (patch)
tree2ab248f2a8feedc15709d0611e7d5f691665a403 /engines/sci/engine/savegame.cpp
parent0c799e1bd910231ba05c8ed7f182577314ac967b (diff)
downloadscummvm-rg350-ca279390a36d0f87be134c6788c6420a748b99b8.tar.gz
scummvm-rg350-ca279390a36d0f87be134c6788c6420a748b99b8.tar.bz2
scummvm-rg350-ca279390a36d0f87be134c6788c6420a748b99b8.zip
SCI32: Fix broken Remap implementation
Remap would crash SCI2.1early games with 19 remap slots, and did not actually work in most cases in SCI2.1mid+ games. 1. Avoid accidental corruption of values from the VM that may be valid when signed or larger than 8 bits 2. Fix bad `matchColor` function. 3. Remove unnecessary initialisation of SingleRemaps 4. Update architecture to more closely mirror how SSCI worked 5. Split large `apply` function into smaller units 6. Fix buffer overrun when loading a SCI2.1early game with remap 7. Warn instead of crashing with an error on invalid input (to match SSCI more closely) 8. Add save/load function
Diffstat (limited to 'engines/sci/engine/savegame.cpp')
-rw-r--r--engines/sci/engine/savegame.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 302f046458..0972aec4a4 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -48,8 +48,9 @@
#include "sci/sound/music.h"
#ifdef ENABLE_SCI32
-#include "sci/graphics/palette32.h"
#include "sci/graphics/frameout.h"
+#include "sci/graphics/palette32.h"
+#include "sci/graphics/remap32.h"
#endif
namespace Sci {
@@ -807,6 +808,33 @@ void GfxPalette32::saveLoadWithSerializer(Common::Serializer &s) {
}
}
}
+
+void GfxRemap32::saveLoadWithSerializer(Common::Serializer &s) {
+ if (s.getVersion() < 35) {
+ return;
+ }
+
+ s.syncAsByte(_numActiveRemaps);
+ s.syncAsByte(_blockedRangeStart);
+ s.syncAsSint16LE(_blockedRangeCount);
+
+ for (uint i = 0; i < _remaps.size(); ++i) {
+ SingleRemap &singleRemap = _remaps[i];
+ s.syncAsByte(singleRemap._type);
+ if (s.isLoading() && singleRemap._type != kRemapNone) {
+ singleRemap.reset();
+ }
+ s.syncAsByte(singleRemap._from);
+ s.syncAsByte(singleRemap._to);
+ s.syncAsByte(singleRemap._delta);
+ s.syncAsByte(singleRemap._percent);
+ s.syncAsByte(singleRemap._gray);
+ }
+
+ if (s.isLoading()) {
+ _needsUpdate = true;
+ }
+}
#endif
void GfxPorts::saveLoadWithSerializer(Common::Serializer &s) {