[Scummvm-git-logs] scummvm master -> 98adf0273d65f5a07779bcd7ddae65ad93333b8e

alxpnv a04198622 at gmail.com
Fri Sep 17 10:19:46 UTC 2021


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1dc17b7475 ASYLUM: use const references where possible
3c4159cfe1 ASYLUM: make .movies file target-specific
b49f9e755b ASYLUM: append metadata to the saves made via the game menu
98adf0273d ASYLUM: reset game flags when using 'scene' debug command


Commit: 1dc17b747593a6f5f163362d09862766be4167b0
    https://github.com/scummvm/scummvm/commit/1dc17b747593a6f5f163362d09862766be4167b0
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-17T13:21:43+03:00

Commit Message:
ASYLUM: use const references where possible

Changed paths:
    engines/asylum/respack.cpp
    engines/asylum/respack.h
    engines/asylum/system/savegame.cpp
    engines/asylum/system/savegame.h
    engines/asylum/views/video.cpp
    engines/asylum/views/video.h


diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index e791db6b10..79fce333e0 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -120,7 +120,7 @@ void ResourceManager::unload(ResourcePackId id) {
 //////////////////////////////////////////////////////////////////////////
 // ResourcePack
 //////////////////////////////////////////////////////////////////////////
-ResourcePack::ResourcePack(Common::String filename) {
+ResourcePack::ResourcePack(const Common::String &filename) {
 	init(filename);
 }
 
@@ -132,7 +132,7 @@ ResourcePack::~ResourcePack() {
 	_packFile.close();
 }
 
-void ResourcePack::init(Common::String filename) {
+void ResourcePack::init(const Common::String &filename) {
 	if (!_packFile.open(filename))
 		error("[ResourcePack::init] Could not open resource file: %s", filename.c_str());
 
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 832c7b4e25..5fe4ae856b 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -58,14 +58,14 @@ public:
 	ResourceEntry *get(uint16 index);
 
 protected:
-	ResourcePack(Common::String filename);
+	ResourcePack(const Common::String &filename);
 	~ResourcePack();
 
 private:
 	Common::Array<ResourceEntry> _resources;
 	Common::File _packFile;
 
-	void init(Common::String filename);
+	void init(const Common::String &filename);
 
 	friend class ResourceManager;
 };
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index c0756f680d..9ac330fbeb 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -217,7 +217,7 @@ Common::String Savegame::getFilename(uint32 index) const {
 	return _vm->getSaveStateName(index);
 }
 
-bool Savegame::isSavegamePresent(Common::String filename) const {
+bool Savegame::isSavegamePresent(const Common::String &filename) const {
 	if (g_system->getSavefileManager()->listSavefiles(filename).size() == 0)
 		return false;
 
@@ -259,7 +259,7 @@ void Savegame::writeHeader(Common::OutSaveFile *file) const {
 	write(file, SAVEGAME_BUILD, "Build");
 }
 
-bool Savegame::loadData(Common::String filename) {
+bool Savegame::loadData(const Common::String &filename) {
 	Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(filename);
 	if (!file) {
 		getWorld()->chapter = kChapterInvalid;
@@ -294,7 +294,7 @@ bool Savegame::loadData(Common::String filename) {
 	return true;
 }
 
-bool Savegame::saveData(Common::String filename, Common::String name, ChapterIndex chapter, bool appendExtended) {
+bool Savegame::saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter, bool appendExtended) {
 	Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(filename);
 	if (!file)
 		return false;
@@ -323,7 +323,7 @@ bool Savegame::saveData(Common::String filename, Common::String name, ChapterInd
 	return true;
 }
 
-void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String description) {
+void Savegame::seek(Common::InSaveFile *file, uint32 offset, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Seeking to offset: %s", description.c_str());
 
 	if (offset == 0)
@@ -340,7 +340,7 @@ void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String desc
 	}
 }
 
-uint32 Savegame::read(Common::InSaveFile *file, Common::String description) {
+uint32 Savegame::read(Common::InSaveFile *file, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Reading %s", description.c_str());
 
 	uint32 size = file->readUint32LE();
@@ -352,7 +352,7 @@ uint32 Savegame::read(Common::InSaveFile *file, Common::String description) {
 	return file->readUint32LE();
 }
 
-Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common::String description) {
+Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Reading %s (of length %d)", description.c_str(), strLength);
 
 	/*uint32 size =*/ file->readUint32LE();
@@ -372,7 +372,7 @@ Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common
 	return ret;
 }
 
-void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
+void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Reading %s (%d block(s) of size %d)", description.c_str(), size, count);
 
 	uint32 fileSize = file->readUint32LE();
@@ -390,7 +390,7 @@ void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32
 	data->saveLoadWithSerializer(ser);
 }
 
-void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String description) {
+void Savegame::write(Common::OutSaveFile *file, uint32 val, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Writing %s: %d", description.c_str(), val);
 
 	file->writeUint32LE(4);
@@ -399,7 +399,7 @@ void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String descr
 	file->writeUint32LE(val);
 }
 
-void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLength, Common::String description) {
+void Savegame::write(Common::OutSaveFile *file, const Common::String &val, uint32 strLength, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Writing %s (of length %d): %s", description.c_str(), strLength, val.c_str());
 
 	if (val.size() > strLength)
@@ -417,7 +417,7 @@ void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLe
 	}
 }
 
-void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
+void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description) {
 	debugC(kDebugLevelSavegame, "[Savegame] Writing %s (%d block(s) of size %d)", description.c_str(), size, count);
 
 	file->writeUint32LE(size);
@@ -492,7 +492,7 @@ void Savegame::loadMoviesViewed() {
 //////////////////////////////////////////////////////////////////////////
 // Accessors
 //////////////////////////////////////////////////////////////////////////
-void Savegame::setName(uint32 index, Common::String name) {
+void Savegame::setName(uint32 index, const Common::String &name) {
 	if (index >= ARRAYSIZE(_names))
 		error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
 
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 53314d2ed9..eb98444df0 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -97,7 +97,7 @@ public:
 	 * @param offset 		Offset index of the info into the file
 	 * @param description   The description.
 	 */
-	static void seek(Common::InSaveFile *file, uint32 offset, Common::String description);
+	static void seek(Common::InSaveFile *file, uint32 offset, const Common::String &description);
 
 	/**
 	 * Reads data from a file.
@@ -107,7 +107,7 @@ public:
 	 *
 	 * @return the value
 	 */
-	static uint32 read(Common::InSaveFile *file, Common::String description);
+	static uint32 read(Common::InSaveFile *file, const Common::String &description);
 
 	/**
 	 * Reads data from a file.
@@ -118,7 +118,7 @@ public:
 	 *
 	 * @return the string
 	 */
-	static Common::String read(Common::InSaveFile *file, uint32 strLength, Common::String description);
+	static Common::String read(Common::InSaveFile *file, uint32 strLength, const Common::String &description);
 
 	/**
 	 * Reads data from a file.
@@ -129,7 +129,7 @@ public:
 	 * @param count 		Number of.
 	 * @param description   The description.
 	 */
-	static void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description);
+	static void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description);
 
 	/**
 	 * Writes data to a file.
@@ -138,7 +138,7 @@ public:
 	 * @param val 			The value
 	 * @param description   The description.
 	 */
-	static void write(Common::OutSaveFile *file, uint32 val, Common::String description);
+	static void write(Common::OutSaveFile *file, uint32 val, const Common::String &description);
 
 	/**
 	 * Writes data to a file.
@@ -148,7 +148,7 @@ public:
 	 * @param strLength		The size of the string.
 	 * @param description   The description.
 	 */
-	static void write(Common::OutSaveFile *file, Common::String val, uint32 strLength, Common::String description);
+	static void write(Common::OutSaveFile *file, const Common::String &val, uint32 strLength, const Common::String &description);
 
 	/**
 	 * Writes data to a file.
@@ -159,7 +159,7 @@ public:
 	 * @param count 		Number of.
 	 * @param description   The description.
 	 */
-	static void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description);
+	static void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description);
 
 	//////////////////////////////////////////////////////////////////////////
 	// Movies
@@ -171,7 +171,7 @@ public:
 	//////////////////////////////////////////////////////////////////////////
 	// Accessors
 	//////////////////////////////////////////////////////////////////////////
-	void setName(uint32 index, Common::String name);
+	void setName(uint32 index, const Common::String &name);
 	Common::String getName(uint32 index) const;
 
 	Common::String *getName() { return &_names[_index]; }
@@ -218,7 +218,7 @@ private:
 	 *
 	 * @return true if savegame present, false if not.
 	 */
-	bool isSavegamePresent(Common::String filename) const;
+	bool isSavegamePresent(const Common::String &filename) const;
 
 	//////////////////////////////////////////////////////////////////////////
 	// Reading & writing
@@ -247,7 +247,7 @@ private:
 	 *
 	 * @return true if it succeeds, false if it fails.
 	 */
-	bool loadData(Common::String filename);
+	bool loadData(const Common::String &filename);
 
 	/**
 	 * Save savegame data.
@@ -259,7 +259,7 @@ private:
 	 *
 	 * @return true if it succeeds, false if it fails.
 	 */
-	bool saveData(Common::String filename, Common::String name, ChapterIndex chapter, bool appendExtended = false);
+	bool saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter, bool appendExtended = false);
 };
 
 } // End of namespace Asylum
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 2087db7339..493a659cd2 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -168,7 +168,7 @@ void VideoPlayer::play(uint32 videoNumber, EventHandler *handler) {
 	_vm->switchEventHandler(handler);
 }
 
-void VideoPlayer::play(Common::String filename, bool showSubtitles) {
+void VideoPlayer::play(const Common::String &filename, bool showSubtitles) {
 	if (!_decoder->loadFile(filename))
 		error("[Video::playVideo] Invalid video index (%d)", _currentMovie);
 
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index d933915bc6..1805e0207b 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -93,7 +93,7 @@ private:
 	 * @param filename 		Filename of the file.
 	 * @param showSubtitles true to show, false to hide the subtitles.
 	 */
-	void play(Common::String filename, bool showSubtitles);
+	void play(const Common::String &filename, bool showSubtitles);
 
 	/**
 	 * Sets up the palette.


Commit: 3c4159cfe1cb6bca2f31d75d4230216ae7a0fff2
    https://github.com/scummvm/scummvm/commit/3c4159cfe1cb6bca2f31d75d4230216ae7a0fff2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-17T13:21:43+03:00

Commit Message:
ASYLUM: make .movies file target-specific

Changed paths:
    engines/asylum/asylum.h
    engines/asylum/system/savegame.cpp


diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index aee7742c6e..57b32b449e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -193,6 +193,7 @@ public:
 	bool checkGameVersion(const char *version) { return !strcmp(_gameDescription->extra, version); }
 	bool isAltDemo() { return Common::File::exists("asylum.dat"); }
 	Common::Language getLanguage() { return _gameDescription->language; }
+	Common::String getMoviesFileName() { return Common::String::format("%s.movies", _targetName.c_str()); }
 
 	// Save/Load
 	bool canLoadGameStateCurrently();
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 9ac330fbeb..6d937437e1 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -47,8 +47,6 @@ namespace Asylum {
 
 #define SAVEGAME_QUICKSLOT 24
 
-#define SAVEGAME_MOVIES "asylum.movies"
-
 static const char *savegame_version = "v1.01 FINAL";
 
 Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false) {
@@ -450,7 +448,7 @@ void Savegame::setMovieViewed(uint32 index) {
 		_moviesViewed[index] = 1;
 
 		// Write data to disk
-		Common::OutSaveFile *movies = g_system->getSavefileManager()->openForSaving(SAVEGAME_MOVIES);
+		Common::OutSaveFile *movies = g_system->getSavefileManager()->openForSaving(_vm->getMoviesFileName());
 		if (!movies)
 			error("[Savegame::setMovieViewed] Could not open viewed movie list!");
 
@@ -476,11 +474,11 @@ uint32 Savegame::getMoviesViewed(int32 *movieList) const {
 }
 
 void Savegame::loadMoviesViewed() {
-	if (!isSavegamePresent(SAVEGAME_MOVIES))
+	if (!isSavegamePresent(_vm->getMoviesFileName()))
 		return;
 
 	// Load data from disk
-	Common::InSaveFile *movies = g_system->getSavefileManager()->openForLoading(SAVEGAME_MOVIES);
+	Common::InSaveFile *movies = g_system->getSavefileManager()->openForLoading(_vm->getMoviesFileName());
 	if (!movies)
 		error("[Savegame::setMovieViewed] Could not open viewed movie list!");
 


Commit: b49f9e755b52d21bd98839da2cbaa27d7a418ca3
    https://github.com/scummvm/scummvm/commit/b49f9e755b52d21bd98839da2cbaa27d7a418ca3
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-17T13:21:43+03:00

Commit Message:
ASYLUM: append metadata to the saves made via the game menu

Changed paths:
    engines/asylum/asylum.cpp
    engines/asylum/asylum.h
    engines/asylum/metaengine.cpp
    engines/asylum/puzzles/writings.cpp
    engines/asylum/system/savegame.cpp
    engines/asylum/system/savegame.h
    engines/asylum/system/screen.h
    engines/asylum/views/scene.cpp
    engines/asylum/views/scene.h
    engines/asylum/views/video.cpp


diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4072241fb5..1a22309142 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -660,7 +660,7 @@ Common::Error AsylumEngine::saveGameState(int slot, const Common::String &desc,
 	savegame()->loadList();
 	savegame()->setIndex(slot);
 	savegame()->setName(slot, desc);
-	savegame()->save(true);
+	savegame()->save();
 
 	return Common::kNoError;
 }
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 57b32b449e..dc66677ac5 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -194,6 +194,7 @@ public:
 	bool isAltDemo() { return Common::File::exists("asylum.dat"); }
 	Common::Language getLanguage() { return _gameDescription->language; }
 	Common::String getMoviesFileName() { return Common::String::format("%s.movies", _targetName.c_str()); }
+	bool isMenuVisible() { return _handler == (EventHandler *)_menu; }
 
 	// Save/Load
 	bool canLoadGameStateCurrently();
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index b66cbbbc52..721ebdbc01 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -31,8 +31,12 @@
 
 #include "engines/advancedDetector.h"
 
+#include "graphics/scaler.h"
+
 #include "asylum/system/savegame.h"
 
+#include "asylum/views/scene.h"
+
 #include "asylum/asylum.h"
 #include "asylum/shared.h"
 
@@ -47,7 +51,8 @@ public:
 	}
 
 	int getMaximumSaveSlot() const override { return 25; }
-	SaveStateList listSaves(const char *target) const override;
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
+	void getSavegameThumbnail(Graphics::Surface &thumb) override;
 	Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
 	Common::KeymapArray initKeymaps(const char *target) const override;
 	const Common::AchievementDescriptionList *getAchievementDescriptionList() const override;
@@ -60,36 +65,31 @@ bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
 		(f == kSupportsSavingDuringRuntime);
 }
 
-SaveStateList AsylumMetaEngine::listSaves(const char *target) const {
-	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
-	Common::StringArray filenames;
-	Common::String pattern(getSavegameFilePattern(target));
-
-	filenames = saveFileMan->listSavefiles(pattern);
-
-	SaveStateList saveList;
-	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
-		// Obtain the last 3 digits of the filename, since they correspond to the save slot
-		int slotNum = atoi(file->c_str() + file->size() - 3);
-
-		if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
-			SaveStateDescriptor desc = querySaveMetaInfos(target, slotNum);
-			if (desc.getSaveSlot() == -1) {
-				Common::InSaveFile *in(saveFileMan->openForLoading(*file));
-				if (in && in->size()) {
-					(void)(uint32)Asylum::Savegame::read(in, "Chapter");
-					desc.setSaveSlot(slotNum);
-					desc.setDescription(Asylum::Savegame::read(in, 45, "Game Name"));
-				}
-			}
-
-			saveList.push_back(desc);
+void AsylumMetaEngine::getSavegameThumbnail(Graphics::Surface &thumb) {
+	Asylum::AsylumEngine *engine = (Asylum::AsylumEngine *)g_engine;
+
+	if (engine->isMenuVisible()) {
+		const Graphics::Surface &savedScreen = engine->scene()->getSavedScreen();
+		::createThumbnail(&thumb, (const byte *)savedScreen.getPixels(), savedScreen.w, savedScreen.h, engine->scene()->getSavedPalette());
+	} else {
+		::createThumbnailFromScreen(&thumb);
+	}
+}
+
+SaveStateDescriptor AsylumMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	SaveStateDescriptor desc = MetaEngine::querySaveMetaInfos(target, slot);
+
+	if (desc.getSaveSlot() == -1) {
+		Common::InSaveFile *in(g_system->getSavefileManager()->openForLoading(getSavegameFile(slot, target)));
+
+		if (in && in->size()) {
+			(void)(uint32)Asylum::Savegame::read(in, "Chapter");
+			desc.setSaveSlot(slot);
+			desc.setDescription(Asylum::Savegame::read(in, 45, "Game Name"));
 		}
 	}
 
-	// Sort saves based on slot number.
-	Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
-	return saveList;
+	return desc;
 }
 
 Common::Error AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index e735586214..53791f1c1f 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -96,7 +96,7 @@ bool PuzzleWritings::init(const AsylumEvent &)  {
 	getText()->drawCentered(Common::Point(10, 375), 590, getText()->get(MAKE_RESOURCE(kResourcePackText, textId++)));
 	getText()->drawCentered(Common::Point(10, 405), 590, getText()->get(MAKE_RESOURCE(kResourcePackText, textId)));
 
-	_textSurface.copyFrom(*getScreen()->getSurface());
+	_textSurface.copyFrom(getScreen()->getSurface());
 
 	return false;
 }
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 6d937437e1..e56c9ebe6b 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -130,11 +130,11 @@ bool Savegame::quickLoad() {
 	return true;
 }
 
-void Savegame::save(bool appendExtended) {
+void Savegame::save() {
 	// Original creates a folder to hold saved games and checks for disk space, we can skip that
 	getCursor()->hide();
 
-	if (saveData(getFilename(_index), _names[_index], getWorld()->chapter, appendExtended)) {
+	if (saveData(getFilename(_index), _names[_index], getWorld()->chapter)) {
 		_savegames[_index] = true;
 
 		getMenu()->setDword455C78(true);
@@ -292,7 +292,7 @@ bool Savegame::loadData(const Common::String &filename) {
 	return true;
 }
 
-bool Savegame::saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter, bool appendExtended) {
+bool Savegame::saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter) {
 	Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(filename);
 	if (!file)
 		return false;
@@ -311,10 +311,7 @@ bool Savegame::saveData(const Common::String &filename, const Common::String &na
 
 	write(file, _vm->getTick(), "Time");
 
-	if (appendExtended)
-		_vm->getMetaEngine()->appendExtendedSaveToStream(file, _vm->getTotalPlayTime() / 1000, name, false);
-	else
-		file->writeUint32LE(0);
+	_vm->getMetaEngine()->appendExtendedSaveToStream(file, _vm->getTotalPlayTime() / 1000, name, false);
 
 	delete file;
 
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index eb98444df0..6ec51b9440 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -69,11 +69,9 @@ public:
 	/**
 	 * Saves a game
 	 *
-	 * @param  appendExtended Append the extended savegame header to the stream.
-	 *
 	 * @return true if it succeeds, false if it fails.
 	 */
-	void save(bool appendExtended = false);
+	void save();
 
 	/**
 	 * Quick saves a game
@@ -255,11 +253,10 @@ private:
 	 * @param filename       Filename of the file.
 	 * @param name 	         The name.
 	 * @param chapter        The chapter.
-	 * @param appendExtended Append the extended savegame header to the stream.
 	 *
 	 * @return true if it succeeds, false if it fails.
 	 */
-	bool saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter, bool appendExtended = false);
+	bool saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter);
 };
 
 } // End of namespace Asylum
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index cdc5752393..a150d17d1b 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -33,7 +33,7 @@
 
 namespace Asylum {
 
-#define PALETTE_SIZE 256 * 3
+#define PALETTE_SIZE (256 * 3)
 
 class AsylumEngine;
 class GraphicResource;
@@ -95,6 +95,7 @@ public:
 
 	// Palette
 	void setPalette(ResourceId id);
+	const byte *getPalette() { return _mainPalette; }
 	void setMainPalette(const byte *data);
 	void loadGrayPalette();
 	void updatePalette();
@@ -135,7 +136,7 @@ public:
 	void copyToBackBufferClipped(Graphics::Surface *surface, int16 x, int16 y);
 
 	// Used by Writings puzzle
-	const Graphics::Surface *getSurface() const { return &_backBuffer; };
+	const Graphics::Surface &getSurface() const { return _backBuffer; };
 
 protected:
 	// Palette fading Timer
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 3a76a24ed1..6cd159fc50 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -69,6 +69,8 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
 	_musicVolume = 0;
 	_frameCounter = 0;
 
+	_savedScreen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+
 	g_debugActors = 0;
 	g_debugObjects  = 0;
 	g_debugPolygons  = 0;
@@ -83,6 +85,8 @@ Scene::~Scene() {
 	// Clear script queue
 	getScript()->reset();
 
+	_savedScreen.free();
+
 	delete _polygons;
 	delete _ws;
 }
@@ -472,8 +476,11 @@ bool Scene::key(const AsylumEvent &evt) {
 			if (getCursor()->isHidden())
 				break;
 
-			if (!_vm->checkGameVersion("Demo"))
+			if (!_vm->checkGameVersion("Demo")) {
+				_savedScreen.copyFrom(getScreen()->getSurface());
+				memcpy(_savedPalette, getScreen()->getPalette(), sizeof(_savedPalette));
 				_vm->switchEventHandler(_vm->menu());
+			}
 		}
 		break;
 
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index a9e92dc7a0..704e0359b3 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -29,6 +29,8 @@
 
 #include "graphics/surface.h"
 
+#include "asylum/system/screen.h"
+
 #include "asylum/eventhandler.h"
 #include "asylum/shared.h"
 
@@ -196,6 +198,9 @@ public:
 	WorldStats  *worldstats() { return _ws; }
 	uint32 getFrameCounter() { return _frameCounter; }
 
+	const byte *getSavedPalette() { return _savedPalette; }
+	const Graphics::Surface &getSavedScreen() { return _savedScreen; }
+
 private:
 	AsylumEngine  *_vm;
 
@@ -215,6 +220,9 @@ private:
 	Common::Array<UpdateItem> _updateList;
 	uint32 _frameCounter;
 
+	Graphics::Surface _savedScreen;
+	byte _savedPalette[PALETTE_SIZE];
+
 	//////////////////////////////////////////////////////////////////////////
 	// Message handling
 	void activate();
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 493a659cd2..6d96c13b57 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -111,7 +111,7 @@ bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
 				getText()->draw(0, 99, kTextCenter, Common::Point(10, y), 20, 620, text);
 
 				if (_vm->checkGameVersion("Steam")) {
-					Graphics::Surface *st = getScreen()->getSurface()->convertTo(g_system->getScreenFormat(), _subtitlePalette);
+					Graphics::Surface *st = getScreen()->getSurface().convertTo(g_system->getScreenFormat(), _subtitlePalette);
 					g_system->copyRectToScreen((const byte *)st->getBasePtr(0, 400), st->pitch, 0, 400, 640, 80);
 					st->free();
 					delete st;


Commit: 98adf0273d65f5a07779bcd7ddae65ad93333b8e
    https://github.com/scummvm/scummvm/commit/98adf0273d65f5a07779bcd7ddae65ad93333b8e
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-17T13:21:43+03:00

Commit Message:
ASYLUM: reset game flags when using 'scene' debug command

Changed paths:
    engines/asylum/asylum.cpp
    engines/asylum/asylum.h
    engines/asylum/console.cpp


diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1a22309142..f8c96c4b54 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -58,7 +58,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
 	_video(NULL), _handler(NULL), _puzzles(NULL) {
 
 	// Init data
-	memset(&_gameFlags, 0, sizeof(_gameFlags));
+	resetFlags();
 	_introPlayed = false;
 	_tickOffset = 0;
 
@@ -263,7 +263,7 @@ void AsylumEngine::restart() {
 	_cursor->hide();
 
 	// Cleanup
-	memset(&_gameFlags, 0, sizeof(_gameFlags));
+	resetFlags();
 	delete _scene;
 	_scene = NULL;
 	delete _encounter;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index dc66677ac5..92da3a1822 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -156,7 +156,7 @@ public:
 	bool isGameFlagSet(GameFlag flag) const;
 	bool isGameFlagNotSet(GameFlag flag) const;
 	bool areGameFlagsSet(uint from, uint to) const;
-	void resetFlags();
+	void resetFlags() { memset(_gameFlags, 0, sizeof(_gameFlags)); }
 
 	// Misc
 	uint getRandom(uint max) { return max ? _rnd->getRandomNumber(max - 1) : 0; }
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index b2d99fd2d8..72277bd627 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -687,6 +687,7 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
 
 	_vm->_delayedSceneIndex = index;
 	_vm->_puzzles->reset();
+	_vm->resetFlags();
 
 	return false;
 }




More information about the Scummvm-git-logs mailing list