aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/saveload.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/saveload.cpp')
-rw-r--r--engines/scumm/saveload.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index f5d219c721..f9a6b211c3 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -103,7 +103,7 @@ bool ScummEngine::canLoadGameStateCurrently() {
return (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0);
}
-Common::Error ScummEngine::saveGameState(int slot, const char *desc) {
+Common::Error ScummEngine::saveGameState(int slot, const Common::String &desc) {
requestSave(slot, desc);
return Common::kNoError;
}
@@ -135,13 +135,11 @@ bool ScummEngine::canSaveGameStateCurrently() {
}
-void ScummEngine::requestSave(int slot, const char *name) {
+void ScummEngine::requestSave(int slot, const Common::String &name) {
_saveLoadSlot = slot;
_saveTemporaryState = false;
_saveLoadFlag = 1; // 1 for save
- assert(name);
- strncpy(_saveLoadName, name, sizeof(_saveLoadName));
- _saveLoadName[sizeof(_saveLoadName) - 1] = 0;
+ _saveLoadDescription = name;
}
void ScummEngine::requestLoad(int slot) {
@@ -166,7 +164,7 @@ bool ScummEngine::saveState(Common::OutSaveFile *out, bool writeHeader) {
SaveGameHeader hdr;
if (writeHeader) {
- memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
+ Common::strlcpy(hdr.name, _saveLoadDescription.c_str(), sizeof(hdr.name));
saveSaveGameHeader(out, hdr);
}
#if !defined(__DS__) && !defined(__N64__) /* && !defined(__PLAYSTATION2__) */
@@ -387,7 +385,8 @@ bool ScummEngine::loadState(int slot, bool compat) {
if (hdr.ver == VER(7))
hdr.ver = VER(8);
- memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));
+ hdr.name[sizeof(hdr.name)-1] = 0;
+ _saveLoadDescription = hdr.name;
// Unless specifically requested with _saveSound, we do not save the iMUSE
// state for temporary state saves - such as certain cutscenes in DOTT,
@@ -589,9 +588,9 @@ bool ScummEngine::loadState(int slot, bool compat) {
}
Common::String ScummEngine::makeSavegameName(const Common::String &target, int slot, bool temporary) {
- char extension[6];
- snprintf(extension, sizeof(extension), ".%c%02d", temporary ? 'c' : 's', slot);
- return (target + extension);
+ Common::String extension;
+ extension = Common::String::format(".%c%02d", temporary ? 'c' : 's', slot);
+ return target + extension;
}
void ScummEngine::listSavegames(bool *marks, int num) {
@@ -1490,7 +1489,7 @@ void ScummEngine_v5::saveOrLoad(Serializer *s) {
// 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.
- if (_game.platform == Common::kPlatformFMTowns && _bytesPerPixelOutput == 2 && s->isLoading() && s->getVersion() < VER(82)) {
+ if (_game.platform == Common::kPlatformFMTowns && _outputPixelFormat.bytesPerPixel == 2 && s->isLoading() && s->getVersion() < VER(82)) {
if (_game.id == GID_LOOM) {
redefineBuiltinCursorFromChar(1, 1);
redefineBuiltinCursorHotspot(1, 0, 0);
@@ -1498,6 +1497,16 @@ void ScummEngine_v5::saveOrLoad(Serializer *s) {
resetCursors();
}
}
+
+ // 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
+ if (_game.platform == Common::kPlatformPCEngine && s->isLoading()) {
+ for (int i = 0; i < 256; ++i)
+ _16BitPalette[i] = get16BitColor(_currentPalette[i * 3 + 0], _currentPalette[i * 3 + 1], _currentPalette[i * 3 + 2]);
+ }
+#endif
}
#ifdef ENABLE_SCUMM_7_8