[Scummvm-git-logs] scummvm master -> 6816c628229631cc573a07527945dcf570eae668

criezy criezy at scummvm.org
Sat Mar 13 03:38:13 UTC 2021


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

Summary:
1bad267805 AGS: Map savegame names and other save files to use gameid
8fb9b5f9d5 AGS: Fix FillDirList implementation
346da4bac6 AGS: Fix setting the game palette
d70308096c AGS: Fix savegame screenshots for paletted games
4945526219 GRAPHICS: Fix 24bpp pixel formats handling in ManageSurface blitting
6816c62822 AGS: Fix fully transparent savegame screenshots


Commit: 1bad26780587001dab42af44d8eb0222a518004d
    https://github.com/scummvm/scummvm/commit/1bad26780587001dab42af44d8eb0222a518004d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-13T03:28:22Z

Commit Message:
AGS: Map savegame names and other save files to use gameid

AGS uses agssave.xxx for its savegames, and it was already
changed to use the gameid in ScummVM, except when this is
called from scripts. Some games, such as If On A Winter's
Night Four Travelers, access savegames from scripts and
those are now mapped to ScummVm names. This solves the
missing Continue menu on the start screen for IOAWN4T
when we already saved the game.

Some games also save additional files in the save game
directory, and they can have generic names such as
'playersettings.dat', or 'user.cfg', and since we use
the same savegame path for all games, to avoid any
conflict we now prepend the game target name to all the
files created or read from there.

Changed paths:
    engines/ags/engine/ac/file.cpp


diff --git a/engines/ags/engine/ac/file.cpp b/engines/ags/engine/ac/file.cpp
index 1152e7ca47..aec6b63fed 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -50,6 +50,8 @@
 #include "ags/engine/script/script_runtime.h"
 #include "ags/engine/ac/dynobj/scriptstring.h"
 #include "ags/globals.h"
+#include "ags/ags.h"
+#include "common/config-manager.h"
 
 namespace AGS3 {
 
@@ -306,6 +308,14 @@ bool ResolveScriptPath(const String &orig_sc_path, bool read_only, ResolvedPath
 	} else if (sc_path.CompareLeft(GameSavedgamesDirToken) == 0) {
 		parent_dir = get_save_game_directory();
 		child_path = sc_path.Mid(strlen(GameSavedgamesDirToken));
+#if AGS_PLATFORM_SCUMMVM
+		// Remap "agsgame.*"
+		const char  *agsSavePrefix = "/agssave.";
+		if (child_path.CompareLeft(agsSavePrefix) == 0) {
+			int slotNum = child_path.Mid(strlen(agsSavePrefix)).ToInt();
+			child_path = ::AGS::g_vm->getSaveStateName(slotNum);
+		}
+#endif
 	} else if (sc_path.CompareLeft(GameDataDirToken) == 0) {
 		parent_dir = MakeAppDataPath();
 		child_path = sc_path.Mid(strlen(GameDataDirToken));
@@ -328,6 +338,16 @@ bool ResolveScriptPath(const String &orig_sc_path, bool read_only, ResolvedPath
 	if (child_path[0u] == '\\' || child_path[0u] == '/')
 		child_path.ClipLeft(1);
 
+#if AGS_PLATFORM_SCUMMVM
+	// For files on savepath, always ensure it starts with the game target prefix to avoid
+	// conflicts (as we usually have the same save dir for all games).
+	if (parent_dir == SAVE_FOLDER_PREFIX) {
+		String gameTarget = ConfMan.getActiveDomainName();
+		if (child_path.CompareLeft(gameTarget) != 0)
+			child_path = String::FromFormat("%s-%s", gameTarget.GetCStr(), child_path.GetCStr());
+	}
+#endif
+
 	String full_path = String::FromFormat("%s%s", parent_dir.GetCStr(), child_path.GetCStr());
 	// don't allow write operations for relative paths outside game dir
 	if (!read_only) {


Commit: 8fb9b5f9d5bc905fe1c1450c985047eef73e5bc8
    https://github.com/scummvm/scummvm/commit/8fb9b5f9d5bc905fe1c1450c985047eef73e5bc8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-13T03:28:22Z

Commit Message:
AGS: Fix FillDirList implementation

This function is used to list files that match a given pattern.
For example Kathy Rain uses it to list ./*.tra files. The
original engine uses al_findfirst() and al_findnext().
This fixes listing the available languages in the Kathy
Rain in-game options.

Changed paths:
    engines/ags/engine/ac/file.cpp
    engines/ags/engine/ac/listbox.cpp


diff --git a/engines/ags/engine/ac/file.cpp b/engines/ags/engine/ac/file.cpp
index aec6b63fed..f1c04d2f7e 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -312,8 +312,15 @@ bool ResolveScriptPath(const String &orig_sc_path, bool read_only, ResolvedPath
 		// Remap "agsgame.*"
 		const char  *agsSavePrefix = "/agssave.";
 		if (child_path.CompareLeft(agsSavePrefix) == 0) {
-			int slotNum = child_path.Mid(strlen(agsSavePrefix)).ToInt();
-			child_path = ::AGS::g_vm->getSaveStateName(slotNum);
+			String suffix = child_path.Mid(strlen(agsSavePrefix));
+			if (suffix.CompareLeft("*") == 0) {
+				Common::String file_name = ::AGS::g_vm->getSaveStateName(999);
+				Common::replace(file_name, "999", "*");
+				child_path = file_name;
+			} else {
+				int slotNum = suffix.ToInt();
+				child_path = ::AGS::g_vm->getSaveStateName(slotNum);
+			}
 		}
 #endif
 	} else if (sc_path.CompareLeft(GameDataDirToken) == 0) {
diff --git a/engines/ags/engine/ac/listbox.cpp b/engines/ags/engine/ac/listbox.cpp
index 3ccee016e3..bd49e07ca6 100644
--- a/engines/ags/engine/ac/listbox.cpp
+++ b/engines/ags/engine/ac/listbox.cpp
@@ -33,6 +33,7 @@
 #include "ags/engine/debugging/debug_log.h"
 
 #include "ags/shared/debugging/out.h"
+#include "ags/shared/util/path.h"
 #include "ags/engine/script/script_api.h"
 #include "ags/engine/script/script_runtime.h"
 #include "ags/engine/ac/dynobj/scriptstring.h"
@@ -40,6 +41,7 @@
 #include "ags/ags.h"
 #include "common/fs.h"
 #include "common/savefile.h"
+#include "common/config-manager.h"
 
 namespace AGS3 {
 
@@ -72,12 +74,26 @@ void ListBox_Clear(GUIListBox *listbox) {
 }
 
 void FillDirList(std::set<String> &files, const String &path) {
-	Common::FSNode folder(path);
-	Common::FSList fsList;
-	folder.getChildren(fsList, Common::FSNode::kListAll);
+	String dirName = Path::GetDirectoryPath(path);
+	String filePattern = Path::get_filename(path);
+	if (dirName.CompareLeftNoCase(get_install_dir()) == 0) {
+		String subDir = dirName.Mid(get_install_dir().GetLength());
+		if (!subDir.IsEmpty() && subDir[0u] == '/')
+			subDir.ClipLeft(1);
+		dirName = ConfMan.get("path");
+	} else if (dirName.CompareLeftNoCase(get_save_game_directory()) == 0) {
+		String subDir = dirName.Mid(get_save_game_directory().GetLength());
+		if (!subDir.IsEmpty() && subDir[0u] == '/')
+			subDir.ClipLeft(1);
+		dirName = Path::ConcatPaths(ConfMan.get("savepath"), subDir);
+	}
 
-	for (uint idx = 0; idx < fsList.size(); ++idx)
-		files.insert(fsList[idx].getName());
+	Common::FSDirectory dir(dirName);
+	Common::ArchiveMemberList fileList;
+	dir.listMatchingMembers(fileList, filePattern);
+	for (Common::ArchiveMemberList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) {
+		files.insert((*iter)->getName());
+	}
 }
 
 void ListBox_FillDirList(GUIListBox *listbox, const char *filemask) {
@@ -85,6 +101,7 @@ void ListBox_FillDirList(GUIListBox *listbox, const char *filemask) {
 	guis_need_update = 1;
 
 	ResolvedPath rp;
+	ResolveScriptPath("$SAVEGAMEDIR$/agssave.*", true, rp);
 	if (!ResolveScriptPath(filemask, true, rp))
 		return;
 


Commit: 346da4bac6d20fa47a2059f1dc5d01753a4a1a70
    https://github.com/scummvm/scummvm/commit/346da4bac6d20fa47a2059f1dc5d01753a4a1a70
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-13T03:28:22Z

Commit Message:
AGS: Fix setting the game palette

The allegro set_palette_range includes both the first
and last indexes passed, but we were excluded the last
index, which means we copied one less color than we
should. This was well visible in Trilby's Notes right
from the start of the game.

Changed paths:
    engines/ags/lib/allegro/color.cpp


diff --git a/engines/ags/lib/allegro/color.cpp b/engines/ags/lib/allegro/color.cpp
index 9763bddcda..c674f8ac2b 100644
--- a/engines/ags/lib/allegro/color.cpp
+++ b/engines/ags/lib/allegro/color.cpp
@@ -59,7 +59,7 @@ void set_palette(const PALETTE p) {
 }
 
 void set_palette_range(const PALETTE p, int from, int to, int retracesync) {
-	for (int i = from; i < to; ++i) {
+	for (int i = from; i <= to; ++i) {
 		_G(current_palette)[i] = p[i];
 	}
 }


Commit: d70308096c0ad481f9d82cdffbceb172ac773205
    https://github.com/scummvm/scummvm/commit/d70308096c0ad481f9d82cdffbceb172ac773205
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-13T03:28:22Z

Commit Message:
AGS: Fix savegame screenshots for paletted games

We were passing an empty palette to blit, causing
black screenshots for example in Trilby's Notes.
Screenshots seemed to be working already in some
other games, such as Black Cauldron, and I have
no idea how.

Changed paths:
    engines/ags/shared/gfx/image.cpp


diff --git a/engines/ags/shared/gfx/image.cpp b/engines/ags/shared/gfx/image.cpp
index dac1b15887..30fff283c7 100644
--- a/engines/ags/shared/gfx/image.cpp
+++ b/engines/ags/shared/gfx/image.cpp
@@ -31,6 +31,8 @@
 #include "image/pcx.h"
 #include "image/tga.h"
 
+#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
+
 namespace AGS3 {
 
 template<class DECODER>
@@ -101,7 +103,17 @@ int save_bitmap(Common::WriteStream &out, BITMAP *bmp, const RGB *pal) {
 	const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
 #endif
 
-	const Graphics::ManagedSurface &src = bmp->getSurface();
+	Graphics::ManagedSurface &src = bmp->getSurface();
+	if (bmp->format.bytesPerPixel == 1 && pal != nullptr) {
+		// We don't use the ManagedSurface palette in-game, so it is not defined yet.
+		byte palette[256 * 3];
+		for (int c = 0, i = 0 ; c < 256 ; ++c, i += 3) {
+			palette[i] = VGA_COLOR_TRANS(pal[c].r);
+			palette[i + 1] = VGA_COLOR_TRANS(pal[c].g);
+			palette[i + 2] = VGA_COLOR_TRANS(pal[c].b);
+		}
+		src.setPalette(palette, 0, 256);
+	}
 	Graphics::ManagedSurface surface(bmp->w, bmp->h, requiredFormat_3byte);
 	surface.rawBlitFrom(bmp->getSurface(), Common::Rect(0, 0, src.w, src.h),
 		Common::Point(0, 0), src.getPalette());


Commit: 49455262198130df3bf21c0c114c53c23ba8e661
    https://github.com/scummvm/scummvm/commit/49455262198130df3bf21c0c114c53c23ba8e661
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-13T03:28:22Z

Commit Message:
GRAPHICS: Fix 24bpp pixel formats handling in ManageSurface blitting

The code was only working for one specific case of 24bpp
pixel formats, and it is now generic. This fixes wrong
colors in the AGS savegame screenshots.

Changed paths:
    graphics/managed_surface.cpp


diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 1b14bac22d..2ea7009b97 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -23,6 +23,7 @@
 #include "graphics/managed_surface.h"
 #include "common/algorithm.h"
 #include "common/textconsole.h"
+#include "common/endian.h"
 
 namespace Graphics {
 
@@ -347,11 +348,8 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
 				*(uint16 *)destVal = destPixel;
 			else if (format.bytesPerPixel == 4)
 				*(uint32 *)destVal = destPixel;
-			else {
-				destVal[0] = rDest;
-				destVal[1] = gDest;
-				destVal[2] = bDest;
-			}
+			else
+				WRITE_UINT24(destVal, destPixel);
 		}
 	}
 


Commit: 6816c628229631cc573a07527945dcf570eae668
    https://github.com/scummvm/scummvm/commit/6816c628229631cc573a07527945dcf570eae668
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-13T03:28:22Z

Commit Message:
AGS: Fix fully transparent savegame screenshots

If On A Winter's Night, Four Travelers was such as game that
generated fully transparent screenshots. I am not completely
sure why it happens, and the easiest solution was to reset
the alpha byte to 0xff.

Changed paths:
    engines/ags/engine/ac/game.cpp
    engines/ags/lib/allegro/surface.cpp
    engines/ags/lib/allegro/surface.h


diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 68b9a3a19a..d36b0a1782 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -922,6 +922,7 @@ void create_savegame_screenshot(Bitmap *&screenShot) {
 			quit("!Invalid game.screenshot_width/height, must be from 16x16 to screen res");
 
 		screenShot = CopyScreenIntoBitmap(usewid, usehit);
+		screenShot->GetAllegroBitmap()->makeOpaque();
 
 		// Restore original screen
 		_G(debug_flags) = old_flags;
diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
index 183bc15177..5de65b4177 100644
--- a/engines/ags/lib/allegro/surface.cpp
+++ b/engines/ags/lib/allegro/surface.cpp
@@ -51,6 +51,20 @@ int BITMAP::getpixel(int x, int y) const {
 		return *(const uint32 *)pixel;
 }
 
+void BITMAP::makeOpaque() {
+	if (format.aBits() == 0)
+		return;
+	assert(format.bytesPerPixel == 4);
+	uint32 alphaMask = format.ARGBToColor(0xff, 0, 0, 0);
+
+	unsigned char *pixels = getPixels();
+	for (int y = 0 ; y < h ; ++y, pixels += pitch) {
+		uint32 *data = (uint32*)pixels;
+		for (int x = 0 ; x < w ; ++x, ++data)
+			(*data) |= alphaMask;
+	}
+}
+
 void BITMAP::circlefill(int x, int y, int radius, int color) {
 	int cx = 0;
 	int cy = radius;
diff --git a/engines/ags/lib/allegro/surface.h b/engines/ags/lib/allegro/surface.h
index ba387cf0f7..1a4362f958 100644
--- a/engines/ags/lib/allegro/surface.h
+++ b/engines/ags/lib/allegro/surface.h
@@ -71,6 +71,8 @@ public:
 		_owner->clear();
 	}
 
+	void makeOpaque();
+
 	/**
 	 * Draws a solid filled in circle
 	 */




More information about the Scummvm-git-logs mailing list