[Scummvm-git-logs] scummvm master -> 86f3f8933b3db4b4803e68699cbb13a9201f0166

dreammaster noreply at scummvm.org
Thu Mar 24 04:03:32 UTC 2022


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

Summary:
ca4c91031b AGS: Configurable font init mode, for backward compatibility
34c2d428b6 AGS: Simpler method of parsing window modes in user config
8befb47c05 AGS: Some corrections to reading legacy config
52b3d7437c AGS: Updated comment in ccInstance::AddGlobalVar() about glvar fixup
0211fa25e6 AGS: Moved linespacing precalc to post_init_font()
c0c76de84a AGS: An ugly workaround for legacy label linespacing
094879ed48 AGS: Fix some remaining MAXSTRLEN to point to Globals
263ae9d8fd AGS: File.ReadRawLineBack() can read lines longer than 200 chars
de739c1913 AGS: Updated build version (3.6.0.10)
8511f7b36c AGS: Adjusted comment in SetObjectFrame to make it bit more visible
d378ce6d89 AGS: Use formal font height to set default linespacing, for now
86f3f8933b AGS: Use real font height for speech & dialog option bitmap sizes


Commit: ca4c91031beccda26d14e4920fc4dbb3706c02d4
    https://github.com/scummvm/scummvm/commit/ca4c91031beccda26d14e4920fc4dbb3706c02d4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:09:46-07:00

Commit Message:
AGS: Configurable font init mode, for backward compatibility

>From upstream 9a11a1d4334aef99b8b516a13d5a5bcc0284fde7

Changed paths:
    engines/ags/engine/game/game_init.cpp
    engines/ags/plugins/ags_plugin.cpp
    engines/ags/shared/ac/game_struct_defines.h
    engines/ags/shared/font/fonts.cpp
    engines/ags/shared/font/fonts.h


diff --git a/engines/ags/engine/game/game_init.cpp b/engines/ags/engine/game/game_init.cpp
index 25213d4513c..884b4fffb49 100644
--- a/engines/ags/engine/game/game_init.cpp
+++ b/engines/ags/engine/game/game_init.cpp
@@ -258,10 +258,10 @@ HError InitAndRegisterGameEntities() {
 	return HError::None();
 }
 
-void LoadFonts(GameDataVersion data_ver) {
+void LoadFonts(GameSetupStruct &game, GameDataVersion data_ver) {
 	for (int i = 0; i < _GP(game).numfonts; ++i) {
 		FontInfo &finfo = _GP(game).fonts[i];
-		if (!wloadfont_size(i, finfo))
+		if (!load_font_size(i, finfo, game.options[OPT_FONTLOADLOGIC]))
 			quitprintf("Unable to load font %d, no renderer could load a matching file", i);
 
 		const bool is_wfn = is_bitmap_font(i);
@@ -299,14 +299,12 @@ void LoadFonts(GameDataVersion data_ver) {
 		if (finfo.LineSpacing == 0) {
 			set_font_linespacing(i, height + 2 * finfo.AutoOutlineThickness);
 
-			// WORKAROUND: For qfg2vga at least, fInfo.SizePt == 0, which causes below
-			// to screw up line spacing. Since by the current upstream HEAD this has all
-			// been replaced anyway, for now I'm adding an explicit 0 check
-			if (finfo.SizePt != 0) {
-				// Backward compatibility: if the real font's height != formal height
-				// and there's no custom linespacing, then set linespacing = formal height.
+			// Backward compatibility: if the real font's height != formal height
+			// and there's no custom linespacing, then set linespacing = formal height.
+			if ((game.options[OPT_FONTLOADLOGIC] & FONT_LOAD_REPORTREALHEIGHT) == 0) {
 				const int compat_height = finfo.SizePt * finfo.SizeMultiplier;
-				if (height != compat_height) {
+				// WORKAROUND: Don't replace if no height
+				if (compat_height != 0 && height != compat_height) {
 					set_font_linespacing(i, compat_height + 2 * finfo.AutoOutlineThickness);
 				}
 			}
@@ -355,8 +353,9 @@ void AllocScriptModules() {
 }
 
 HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion data_ver) {
-	const ScriptAPIVersion base_api = (ScriptAPIVersion)_GP(game).options[OPT_BASESCRIPTAPI];
-	const ScriptAPIVersion compat_api = (ScriptAPIVersion)_GP(game).options[OPT_SCRIPTCOMPATLEV];
+	GameSetupStruct &game = ents.Game;
+	const ScriptAPIVersion base_api = (ScriptAPIVersion)game.options[OPT_BASESCRIPTAPI];
+	const ScriptAPIVersion compat_api = (ScriptAPIVersion)game.options[OPT_SCRIPTCOMPATLEV];
 	if (data_ver >= kGameVersion_341) {
 		const char *base_api_name = GetScriptAPIName(base_api);
 		const char *compat_api_name = GetScriptAPIName(compat_api);
@@ -366,42 +365,43 @@ HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion dat
 	}
 	// If the game was compiled using unsupported version of the script API,
 	// we warn about potential incompatibilities but proceed further.
-	if (_GP(game).options[OPT_BASESCRIPTAPI] > kScriptAPI_Current)
+	if (game.options[OPT_BASESCRIPTAPI] > kScriptAPI_Current)
 		_G(platform)->DisplayAlert("Warning: this game requests a higher version of AGS script API, it may not run correctly or run at all.");
 
 	//
 	// 1. Check that the loaded data is valid and compatible with the current
 	// engine capabilities.
 	//
-	if (_GP(game).numfonts == 0)
+	if (game.numfonts == 0)
 		return new GameInitError(kGameInitErr_NoFonts);
-	if (_GP(game).audioClipTypes.size() > MAX_AUDIO_TYPES)
+	if (game.audioClipTypes.size() > MAX_AUDIO_TYPES)
 		return new GameInitError(kGameInitErr_TooManyAudioTypes,
-			String::FromFormat("Required: %zu, max: %zu", _GP(game).audioClipTypes.size(), MAX_AUDIO_TYPES));
+			String::FromFormat("Required: %zu, max: %zu", game.audioClipTypes.size(), MAX_AUDIO_TYPES));
 
 	//
 	// 3. Allocate and init game objects
 	//
-	_G(charextra) = (CharacterExtras *)calloc(_GP(game).numcharacters, sizeof(CharacterExtras));
-	_G(charcache) = (CharacterCache *)calloc(1, sizeof(CharacterCache) * _GP(game).numcharacters + 5);
-	_G(mls) = (MoveList *)calloc(_GP(game).numcharacters + MAX_ROOM_OBJECTS + 1, sizeof(MoveList));
+	_G(charextra) = (CharacterExtras *)calloc(game.numcharacters, sizeof(CharacterExtras));
+	_G(charcache) = (CharacterCache *)calloc(1, sizeof(CharacterCache) * game.numcharacters + 5);
+	_G(mls) = (MoveList *)calloc(game.numcharacters + MAX_ROOM_OBJECTS + 1, sizeof(MoveList));
 	init_game_drawdata();
 	_GP(views) = std::move(ents.Views);
 
-	_GP(play).charProps.resize(_GP(game).numcharacters);
+	_GP(play).charProps.resize(game.numcharacters);
 	_G(old_dialog_scripts) = ents.OldDialogScripts;
 	_G(old_speech_lines) = ents.OldSpeechLines;
 
 	// Set number of game channels corresponding to the loaded game version
 	if (_G(loaded_game_file_version) < kGameVersion_360)
-		_GP(game).numGameChannels = MAX_GAME_CHANNELS_v320;
+		game.numGameChannels = MAX_GAME_CHANNELS_v320;
 	else
-		_GP(game).numGameChannels = MAX_GAME_CHANNELS;
+		game.numGameChannels = MAX_GAME_CHANNELS;
 
 	HError err = InitAndRegisterGameEntities();
 	if (!err)
 		return new GameInitError(kGameInitErr_EntityInitFail, err);
-	LoadFonts(data_ver);
+	LoadFonts(game, data_ver);
+	LoadLipsyncData();
 
 	//
 	// 4. Initialize certain runtime variables
@@ -410,12 +410,12 @@ HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion dat
 	_G(ifacepopped) = -1;
 
 	String svg_suffix;
-	if (_GP(game).saveGameFileExtension[0] != 0)
-		svg_suffix.Format(".%s", _GP(game).saveGameFileExtension);
+	if (game.saveGameFileExtension[0] != 0)
+		svg_suffix.Format(".%s", game.saveGameFileExtension);
 	set_save_game_suffix(svg_suffix);
 
-	_GP(play).score_sound = _GP(game).scoreClipID;
-	_GP(play).fade_effect = _GP(game).options[OPT_FADETYPE];
+	_GP(play).score_sound = game.scoreClipID;
+	_GP(play).fade_effect = game.options[OPT_FADETYPE];
 
 	//
 	// 5. Initialize runtime state of certain game objects
@@ -424,7 +424,7 @@ HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion dat
 		// labels are not clickable by default
 		_GP(guilabels)[i].SetClickable(false);
 	}
-	_GP(play).gui_draw_order = (int32_t *)calloc(_GP(game).numgui * sizeof(int), 1);
+	_GP(play).gui_draw_order = (int32_t *)calloc(game.numgui * sizeof(int), 1);
 	update_gui_zorder();
 	calculate_reserved_channel_count();
 
diff --git a/engines/ags/plugins/ags_plugin.cpp b/engines/ags/plugins/ags_plugin.cpp
index 9b497229820..ea5724238ac 100644
--- a/engines/ags/plugins/ags_plugin.cpp
+++ b/engines/ags/plugins/ags_plugin.cpp
@@ -744,7 +744,7 @@ void IAGSEngine::BreakIntoDebugger() {
 }
 
 IAGSFontRenderer *IAGSEngine::ReplaceFontRenderer(int fontNumber, IAGSFontRenderer *newRenderer) {
-	auto *old_render = font_replace_renderer(fontNumber, newRenderer);
+	auto *old_render = font_replace_renderer(fontNumber, newRenderer, _GP(game).options[OPT_FONTLOADLOGIC]);
 	GUI::MarkForFontUpdate(fontNumber);
 	return old_render;
 }
diff --git a/engines/ags/shared/ac/game_struct_defines.h b/engines/ags/shared/ac/game_struct_defines.h
index b0879917887..d26bb704f8c 100644
--- a/engines/ags/shared/ac/game_struct_defines.h
+++ b/engines/ags/shared/ac/game_struct_defines.h
@@ -85,6 +85,7 @@ namespace AGS3 {
 #define OPT_RENDERATSCREENRES 45 // scale sprites at the (final) screen resolution
 #define OPT_RELATIVEASSETRES 46 // relative asset resolution mode (where sprites are resized to match game type)
 #define OPT_WALKSPEEDABSOLUTE 47 // if movement speeds are independent of walkable mask resolution
+#define OPT_FONTLOADLOGIC   48 // fonts load/init logic, see FONT_LOAD_xxx flags
 #define OPT_HIGHESTOPTION   OPT_WALKSPEEDABSOLUTE
 #define OPT_NOMODMUSIC      98
 #define OPT_LIPSYNCTEXT     99
diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index 49caf9686fb..20cfbca577c 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -73,7 +73,7 @@ bool is_font_loaded(size_t fontNumber) {
 }
 
 // Finish font's initialization
-static void post_init_font(size_t fontNumber) {
+static void post_init_font(size_t fontNumber, int load_mode) {
 	Font &font = _GP(fonts)[fontNumber];
 	if (font.Metrics.Height == 0) {
 		// There is no explicit method for getting maximal possible height of any
@@ -85,19 +85,20 @@ static void post_init_font(size_t fontNumber) {
 		font.Metrics.Height = height;
 		font.Metrics.RealHeight = height;
 	}
-	font.Metrics.CompatHeight = font.Metrics.Height;
+	font.Metrics.CompatHeight = (load_mode & FONT_LOAD_REPORTREALHEIGHT) == 0 ?
+		font.Metrics.Height : font.Metrics.RealHeight;
 	if (font.Info.Outline != FONT_OUTLINE_AUTO) {
 		font.Info.AutoOutlineThickness = 0;
 	}
 }
 
-IAGSFontRenderer *font_replace_renderer(size_t fontNumber, IAGSFontRenderer *renderer) {
+IAGSFontRenderer *font_replace_renderer(size_t fontNumber, IAGSFontRenderer *renderer, int load_mode) {
 	if (fontNumber >= _GP(fonts).size())
 		return nullptr;
 	IAGSFontRenderer *oldRender = _GP(fonts)[fontNumber].Renderer;
 	_GP(fonts)[fontNumber].Renderer = renderer;
 	_GP(fonts)[fontNumber].Renderer2 = nullptr;
-	post_init_font(fontNumber);
+	post_init_font(fontNumber, load_mode);
 	return oldRender;
 }
 
@@ -350,7 +351,7 @@ FontInfo get_fontinfo(size_t font_number) {
 }
 
 // Loads a font from disk
-bool wloadfont_size(size_t fontNumber, const FontInfo &font_info) {
+bool load_font_size(size_t fontNumber, const FontInfo &font_info, int load_mode) {
 	if (_GP(fonts).size() <= fontNumber)
 		_GP(fonts).resize(fontNumber + 1);
 	else
@@ -372,7 +373,7 @@ bool wloadfont_size(size_t fontNumber, const FontInfo &font_info) {
 
 	_GP(fonts)[fontNumber].Info = font_info;
 	_GP(fonts)[fontNumber].Metrics = metrics;
-	post_init_font(fontNumber);
+	post_init_font(fontNumber, load_mode);
 	return true;
 }
 
diff --git a/engines/ags/shared/font/fonts.h b/engines/ags/shared/font/fonts.h
index a6f9089f2b9..f899bb0cb5b 100644
--- a/engines/ags/shared/font/fonts.h
+++ b/engines/ags/shared/font/fonts.h
@@ -31,6 +31,11 @@
 
 namespace AGS3 {
 
+// Font load flags, primarily for backward compatibility
+// REPORTREALHEIGHT: get_font_height should return real font's height,
+// otherwise returns formal height, equal to "font size" parameter
+#define FONT_LOAD_REPORTREALHEIGHT 0x01
+
 class IAGSFontRenderer;
 class IAGSFontRenderer2;
 struct FontInfo;
@@ -66,7 +71,7 @@ struct FontRenderParams;
 void init_font_renderer();
 void shutdown_font_renderer();
 void adjust_y_coordinate_for_text(int *ypos, size_t fontnum);
-IAGSFontRenderer *font_replace_renderer(size_t fontNumber, IAGSFontRenderer *renderer);
+IAGSFontRenderer *font_replace_renderer(size_t fontNumber, IAGSFontRenderer *renderer, int load_mode);
 bool font_first_renderer_loaded();
 bool is_font_loaded(size_t fontNumber);
 bool is_bitmap_font(size_t fontNumber);
@@ -115,7 +120,7 @@ void set_fontinfo(size_t fontNumber, const FontInfo &finfo);
 // Gets full information about the font
 FontInfo get_fontinfo(size_t font_number);
 // Loads a font from disk
-bool wloadfont_size(size_t fontNumber, const FontInfo &font_info);
+bool load_font_size(size_t fontNumber, const FontInfo &font_info, int load_mode);
 void wgtprintf(Shared::Bitmap *ds, int xxx, int yyy, size_t fontNumber, color_t text_color, char *fmt, ...);
 // Allocates two outline stencil buffers, or returns previously creates ones;
 // these buffers are owned by the font, they should not be deleted by the caller.


Commit: 34c2d428b61464ed74e85a2258946b11fdbad8e8
    https://github.com/scummvm/scummvm/commit/34c2d428b61464ed74e85a2258946b11fdbad8e8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:09:50-07:00

Commit Message:
AGS: Simpler method of parsing window modes in user config

>From upstream 4010bf5bb315498436199d356e2d2e882442316b

Changed paths:
    engines/ags/engine/main/config.cpp


diff --git a/engines/ags/engine/main/config.cpp b/engines/ags/engine/main/config.cpp
index 3bb52d222a1..08d3f645407 100644
--- a/engines/ags/engine/main/config.cpp
+++ b/engines/ags/engine/main/config.cpp
@@ -94,6 +94,32 @@ void INIwritestring(ConfigTree &cfg, const String &sectn, const String &item, co
 	cfg[sectn][item] = value;
 }
 
+static WindowSetup parse_window_mode(const String &option, bool as_windowed) {
+	// "full_window" option means pseudo fullscreen ("borderless fullscreen window")
+	if (!as_windowed && (option.CompareNoCase("full_window") == 0))
+		return WindowSetup(as_windowed ? kWnd_Windowed : kWnd_FullDesktop);
+	// Check supported options for explicit resolution or scale factor,
+	// in which case we'll use either a resizing window or a REAL fullscreen mode
+	const WindowMode exp_wmode = as_windowed ? kWnd_Windowed : kWnd_Fullscreen;
+	if (option.CompareNoCase("desktop") == 0)
+		return WindowSetup(get_desktop_size(), exp_wmode);
+	if (option.CompareNoCase("native") == 0)
+		return WindowSetup(game.GetGameRes(), exp_wmode);
+	// Try parse an explicit resolution type or game scale factor --
+	size_t at = option.FindChar('x');
+	if (at == 0) { // try parse as a scale (xN)
+		int scale = StrUtil::StringToInt(option.Mid(1));
+		if (scale > 0) return WindowSetup(scale, exp_wmode);
+	} else if (at != -1) { // else try parse as a "width x height"
+		Size sz = Size(StrUtil::StringToInt(option.Mid(0, at)),
+			StrUtil::StringToInt(option.Mid(at + 1)));
+		if (!sz.IsNull()) return WindowSetup(sz, exp_wmode);
+	}
+	// In case of "default" option, or any format mistake, return the default:
+	// currently it is either max resizing window of "fullscreen desktop"
+	return WindowSetup(as_windowed ? kWnd_Windowed : kWnd_FullDesktop);
+}
+
 // Legacy screen size definition
 enum ScreenSizeDefinition {
 	kScreenDef_Undefined = -1,
@@ -332,6 +358,10 @@ void apply_config(const ConfigTree &cfg) {
 		_GP(usetup).Screen.DriverID = INIreadstring(cfg, "graphics", "driver", _GP(usetup).Screen.DriverID);
 
 		_GP(usetup).Screen.Windowed = INIreadint(cfg, "graphics", "windowed") > 0;
+
+		_GP(usetup).Screen.FsSetup = parse_window_mode(INIreadstring(cfg, "graphics", "fullscreen", "default"), false);
+		_GP(usetup).Screen.WinSetup = parse_window_mode(INIreadstring(cfg, "graphics", "window", "default"), true);
+
 		// TODO: move to config overrides (replace values during config load)
 #if AGS_PLATFORM_OS_MACOS
 		_GP(usetup).Screen.Filter.ID = "none";


Commit: 8befb47c057194b949d9d8b6ee0cae47ae94d27d
    https://github.com/scummvm/scummvm/commit/8befb47c057194b949d9d8b6ee0cae47ae94d27d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:09:50-07:00

Commit Message:
AGS: Some corrections to reading legacy config

>From upstream 183e1e2dff4d487eda5ef01ed54867fa5fec7927

Changed paths:
    engines/ags/engine/main/config.cpp
    engines/ags/engine/main/config.h


diff --git a/engines/ags/engine/main/config.cpp b/engines/ags/engine/main/config.cpp
index 08d3f645407..884f37a1e5e 100644
--- a/engines/ags/engine/main/config.cpp
+++ b/engines/ags/engine/main/config.cpp
@@ -94,7 +94,7 @@ void INIwritestring(ConfigTree &cfg, const String &sectn, const String &item, co
 	cfg[sectn][item] = value;
 }
 
-static WindowSetup parse_window_mode(const String &option, bool as_windowed) {
+static WindowSetup parse_window_mode(const String &option, bool as_windowed, WindowSetup def_value = WindowSetup()) {
 	// "full_window" option means pseudo fullscreen ("borderless fullscreen window")
 	if (!as_windowed && (option.CompareNoCase("full_window") == 0))
 		return WindowSetup(as_windowed ? kWnd_Windowed : kWnd_FullDesktop);
@@ -104,7 +104,7 @@ static WindowSetup parse_window_mode(const String &option, bool as_windowed) {
 	if (option.CompareNoCase("desktop") == 0)
 		return WindowSetup(get_desktop_size(), exp_wmode);
 	if (option.CompareNoCase("native") == 0)
-		return WindowSetup(game.GetGameRes(), exp_wmode);
+		return WindowSetup(_GP(game).GetGameRes(), exp_wmode);
 	// Try parse an explicit resolution type or game scale factor --
 	size_t at = option.FindChar('x');
 	if (at == 0) { // try parse as a scale (xN)
@@ -115,9 +115,8 @@ static WindowSetup parse_window_mode(const String &option, bool as_windowed) {
 			StrUtil::StringToInt(option.Mid(at + 1)));
 		if (!sz.IsNull()) return WindowSetup(sz, exp_wmode);
 	}
-	// In case of "default" option, or any format mistake, return the default:
-	// currently it is either max resizing window of "fullscreen desktop"
-	return WindowSetup(as_windowed ? kWnd_Windowed : kWnd_FullDesktop);
+	// In case of "default" option, or any format mistake, return the default
+	return def_value;
 }
 
 // Legacy screen size definition
@@ -129,7 +128,7 @@ enum ScreenSizeDefinition {
 	kNumScreenDef
 };
 
-ScreenSizeDefinition parse_screendef(const String &option) {
+static ScreenSizeDefinition parse_legacy_screendef(const String &option) {
 	const char *screen_sz_def_options[kNumScreenDef] = { "explicit", "scaling", "max" };
 	for (int i = 0; i < kNumScreenDef; ++i) {
 		if (option.CompareNoCase(screen_sz_def_options[i]) == 0) {
@@ -139,18 +138,18 @@ ScreenSizeDefinition parse_screendef(const String &option) {
 	return kScreenDef_Undefined;
 }
 
-FrameScaleDef parse_scaling_option(const String &option) {
+FrameScaleDef parse_scaling_option(const String &option, FrameScaleDef def_value) {
 	if (option.CompareNoCase("round") == 0 || option.CompareNoCase("max_round") == 0)
 		return kFrame_Round;
 	if (option.CompareNoCase("stretch") == 0)
 		return kFrame_Stretch;
 	if (option.CompareNoCase("proportional") == 0)
 		return kFrame_Proportional;
-	return kFrame_Undefined;
+	return def_value;
 }
 
-FrameScaleDef parse_legacy_scaling_option(const String &option, int &scale) {
-	FrameScaleDef frame = parse_scaling_option(option);
+static FrameScaleDef parse_legacy_scaling_option(const String &option, int &scale) {
+	FrameScaleDef frame = parse_scaling_option(option, kFrame_Undefined);
 	if (frame == kFrame_Undefined) {
 		scale = StrUtil::StringToInt(option);
 		return scale > 0 ? kFrame_Round : kFrame_Undefined;
@@ -222,11 +221,14 @@ void config_defaults() {
 #else
 	_GP(usetup).Screen.DriverID = "OGL";
 #endif
+	// Defaults for the window style are max resizing window and "fullscreen desktop"
+	_GP(usetup).Screen.FsSetup = WindowSetup(kWnd_FullDesktop);
+	_GP(usetup).Screen.WinSetup = WindowSetup(kWnd_Windowed);
 	_GP(usetup).audio_backend = 1;
 	_GP(usetup).translation = "";
 }
 
-void read_legacy_graphics_config(const ConfigTree &cfg) {
+static void read_legacy_graphics_config(const ConfigTree &cfg) {
 	// Pre-3.* game resolution setup
 	int default_res = INIreadint(cfg, "misc", "defaultres", 0);
 	int screen_res = INIreadint(cfg, "misc", "screenres", 0);
@@ -238,51 +240,62 @@ void read_legacy_graphics_config(const ConfigTree &cfg) {
 	_GP(usetup).Screen.Windowed = INIreadint(cfg, "misc", "windowed") > 0;
 	_GP(usetup).Screen.DriverID = INIreadstring(cfg, "misc", "gfxdriver", _GP(usetup).Screen.DriverID);
 
+	// Window setup: style and size definition, game frame style
 	{
 		String legacy_filter = INIreadstring(cfg, "misc", "gfxfilter");
 		if (!legacy_filter.IsEmpty()) {
-			// NOTE: legacy scaling config is applied only to windowed setting
-			int scale_factor; // FIXME
+			// Legacy scaling config is applied only to windowed setting
+			int scale_factor = 0;
 			parse_legacy_frame_config(legacy_filter, _GP(usetup).Screen.Filter.ID, _GP(usetup).Screen.WinGameFrame,
 				scale_factor);
+			if (scale_factor > 0)
+				_GP(usetup).Screen.WinSetup = WindowSetup(scale_factor);
 
-			// AGS 3.2.1 and 3.3.0 aspect ratio preferences
+			// AGS 3.2.1 and 3.3.0 aspect ratio preferences for fullscreen
 			if (!_GP(usetup).Screen.Windowed) {
-				/* FIXME --- set FsGameFrame?
-				_GP(usetup).Screen.DisplayMode.ScreenSize.MatchDeviceRatio =
+				bool allow_borders =
 					(INIreadint(cfg, "misc", "sideborders") > 0 || INIreadint(cfg, "misc", "forceletterbox") > 0 ||
-					 INIreadint(cfg, "misc", "prefer_sideborders") > 0 || INIreadint(cfg, "misc", "prefer_letterbox") > 0);
-				*/
+						INIreadint(cfg, "misc", "prefer_sideborders") > 0 || INIreadint(cfg, "misc", "prefer_letterbox") > 0);
+				_GP(usetup).Screen.FsGameFrame = allow_borders ? kFrame_Proportional : kFrame_Stretch;
 			}
 		}
 
 		// AGS 3.4.0 - 3.4.1-rc uniform scaling option
 		String uniform_frame_scale = INIreadstring(cfg, "graphics", "game_scale");
-		int src_scale = 1;
 		if (!uniform_frame_scale.IsEmpty()) {
+			int src_scale = 1;
 			FrameScaleDef frame = parse_legacy_scaling_option(uniform_frame_scale, src_scale);
 			_GP(usetup).Screen.FsGameFrame = frame;
 			_GP(usetup).Screen.WinGameFrame = frame;
 		}
 
 		// AGS 3.5.* gfx mode with screen definition
-		ScreenSizeDefinition scr_def = parse_screendef(INIreadstring(cfg, "graphics", "screen_def"));
+		const bool is_windowed = INIreadint(cfg, "graphics", "windowed") != 0;
+		WindowSetup &ws = is_windowed ? _GP(usetup).Screen.WinSetup : _GP(usetup).Screen.FsSetup;
+		const WindowMode wm = is_windowed ? kWnd_Windowed : kWnd_Fullscreen;
+		ScreenSizeDefinition scr_def = parse_legacy_screendef(INIreadstring(cfg, "graphics", "screen_def"));
 		switch (scr_def) {
 		case kScreenDef_Explicit:
-			_GP(usetup).Screen.FsSetup =
-				_GP(usetup).Screen.WinSetup = WindowSetup(Size(
-					INIreadint(cfg, "graphics", "screen_width"),
-					INIreadint(cfg, "graphics", "screen_height")));
-			break;
+		{
+			Size sz(
+				INIreadint(cfg, "graphics", "screen_width"),
+				INIreadint(cfg, "graphics", "screen_height"));
+			ws = WindowSetup(sz, wm);
+		}
+		break;
 		case kScreenDef_ByGameScaling:
-			INIreadint(cfg, "graphics", "windowed") ?
+		{
+			int src_scale;
+			is_windowed ?
 				parse_legacy_scaling_option(INIreadstring(cfg, "graphics", "game_scale_win"), src_scale) :
 				parse_legacy_scaling_option(INIreadstring(cfg, "graphics", "game_scale_fs"), src_scale);
-			_GP(usetup).Screen.FsSetup =
-				_GP(usetup).Screen.WinSetup = WindowSetup(src_scale);
+			ws = WindowSetup(src_scale, wm);
+		}
+		break;
+		case kScreenDef_MaxDisplay:
+			ws = is_windowed ? WindowSetup() : WindowSetup(kWnd_FullDesktop);
 			break;
 		default:
-			// set nothing
 			break;
 		}
 	}
@@ -290,6 +303,7 @@ void read_legacy_graphics_config(const ConfigTree &cfg) {
 	_GP(usetup).Screen.Params.RefreshRate = INIreadint(cfg, "misc", "refresh");
 }
 
+
 void override_config_ext(ConfigTree &cfg) {
 	// Mobile ports always run in fullscreen mode
 #if AGS_PLATFORM_OS_ANDROID || AGS_PLATFORM_OS_IOS
@@ -356,11 +370,11 @@ void apply_config(const ConfigTree &cfg) {
 
 		// Graphics mode
 		_GP(usetup).Screen.DriverID = INIreadstring(cfg, "graphics", "driver", _GP(usetup).Screen.DriverID);
-
-		_GP(usetup).Screen.Windowed = INIreadint(cfg, "graphics", "windowed") > 0;
-
-		_GP(usetup).Screen.FsSetup = parse_window_mode(INIreadstring(cfg, "graphics", "fullscreen", "default"), false);
-		_GP(usetup).Screen.WinSetup = parse_window_mode(INIreadstring(cfg, "graphics", "window", "default"), true);
+		_GP(usetup).Screen.Windowed = INIreadint(cfg, "graphics", "windowed", _GP(usetup).Screen.Windowed ? 1 : 0) > 0;
+		_GP(usetup).Screen.FsSetup =
+			parse_window_mode(INIreadstring(cfg, "graphics", "fullscreen", "default"), false, _GP(usetup).Screen.FsSetup);
+		_GP(usetup).Screen.WinSetup =
+			parse_window_mode(INIreadstring(cfg, "graphics", "window", "default"), true, _GP(usetup).Screen.WinSetup);
 
 		// TODO: move to config overrides (replace values during config load)
 #if AGS_PLATFORM_OS_MACOS
@@ -368,9 +382,9 @@ void apply_config(const ConfigTree &cfg) {
 #else
 		_GP(usetup).Screen.Filter.ID = INIreadstring(cfg, "graphics", "filter", "StdScale");
 		_GP(usetup).Screen.FsGameFrame =
-			parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_fs", "proportional"));
+			parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_fs", "proportional"), _GP(usetup).Screen.FsGameFrame);
 		_GP(usetup).Screen.WinGameFrame =
-			parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_win", "round"));
+			parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_win", "round"), _GP(usetup).Screen.WinGameFrame);
 #endif
 
 		_GP(usetup).Screen.Params.RefreshRate = INIreadint(cfg, "graphics", "refresh");
diff --git a/engines/ags/engine/main/config.h b/engines/ags/engine/main/config.h
index 15a41d39a13..1df535cfff0 100644
--- a/engines/ags/engine/main/config.h
+++ b/engines/ags/engine/main/config.h
@@ -47,7 +47,7 @@ void post_config();
 
 void save_config_file();
 
-FrameScaleDef parse_scaling_option(const String &option);
+FrameScaleDef parse_scaling_option(const String &option, FrameScaleDef def_value = kFrame_Undefined);
 String make_scaling_option(FrameScaleDef scale_def);
 uint32_t convert_scaling_to_fp(int scale_factor);
 int convert_fp_to_scaling(uint32_t scaling);


Commit: 52b3d7437c43ebc171445ea09742b651a18f6112
    https://github.com/scummvm/scummvm/commit/52b3d7437c43ebc171445ea09742b651a18f6112
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:13:06-07:00

Commit Message:
AGS: Updated comment in ccInstance::AddGlobalVar() about glvar fixup

>From upstream 23c2e0aee21de7960e5660aca6c96bf039ead1db

Changed paths:
    engines/ags/engine/script/cc_instance.cpp


diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index d620deebd76..1901d8658ad 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -1577,16 +1577,15 @@ bool ccInstance::CreateGlobalVars(const ccScript *scri) {
 }
 
 bool ccInstance::AddGlobalVar(const ScriptVariable &glvar) {
-	// [IKM] 2013-02-23:
-	// !!! TODO
-	// "Metal Dead" game (built with AGS 3.21.1115) fails to pass this check,
-	// because one of its fixups in script creates reference beyond global
-	// data buffer. The error will be suppressed until root of the problem is
-	// found, and some proper workaround invented.
+	// NOTE:
+	// We suppress the error here, because unfortunately at least one existing
+	// game ("Metal Dead", built with AGS 3.21.1115) fails to pass this check.
+	// It has been found that this may be caused by a global variable of zero
+	// size (an instance of empty struct) placed in the end of the script.
+	// TODO: invent some workaround?
+	// TODO: enable the error back in AGS 4, as this is not a normal behavior.
 	if (glvar.ScAddress < 0 || glvar.ScAddress >= globaldatasize) {
-		/*
-		return false;
-		*/
+		/* return false; */
 		Debug::Printf(kDbgMsg_Warn, "WARNING: global variable refers to data beyond allocated buffer (%d, %d)", glvar.ScAddress, globaldatasize);
 	}
 	globalvars->insert(std::make_pair(glvar.ScAddress, glvar));


Commit: 0211fa25e6af50bf0e873050044b0de2c1baaf49
    https://github.com/scummvm/scummvm/commit/0211fa25e6af50bf0e873050044b0de2c1baaf49
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:17:33-07:00

Commit Message:
AGS: Moved linespacing precalc to post_init_font()

>From upstream f848107265d2662819636790d24c13292fe2ec82

Changed paths:
    engines/ags/engine/game/game_init.cpp
    engines/ags/shared/font/fonts.cpp
    engines/ags/shared/font/fonts.h


diff --git a/engines/ags/engine/game/game_init.cpp b/engines/ags/engine/game/game_init.cpp
index 884b4fffb49..758e83ad8cc 100644
--- a/engines/ags/engine/game/game_init.cpp
+++ b/engines/ags/engine/game/game_init.cpp
@@ -291,25 +291,6 @@ void LoadFonts(GameSetupStruct &game, GameDataVersion data_ver) {
 				set_font_outline(i, FONT_OUTLINE_AUTO);
 		}
 	}
-
-	// Precalculate and cache any additional parameters; do this after all the fixups
-	for (int i = 0; i < _GP(game).numfonts; ++i) {
-		FontInfo &finfo = _GP(game).fonts[i];
-		const int height = get_font_height(i);
-		if (finfo.LineSpacing == 0) {
-			set_font_linespacing(i, height + 2 * finfo.AutoOutlineThickness);
-
-			// Backward compatibility: if the real font's height != formal height
-			// and there's no custom linespacing, then set linespacing = formal height.
-			if ((game.options[OPT_FONTLOADLOGIC] & FONT_LOAD_REPORTREALHEIGHT) == 0) {
-				const int compat_height = finfo.SizePt * finfo.SizeMultiplier;
-				// WORKAROUND: Don't replace if no height
-				if (compat_height != 0 && height != compat_height) {
-					set_font_linespacing(i, compat_height + 2 * finfo.AutoOutlineThickness);
-				}
-			}
-		}
-	}
 }
 
 void LoadLipsyncData() {
diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index 20cfbca577c..22904819de5 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -87,9 +87,26 @@ static void post_init_font(size_t fontNumber, int load_mode) {
 	}
 	font.Metrics.CompatHeight = (load_mode & FONT_LOAD_REPORTREALHEIGHT) == 0 ?
 		font.Metrics.Height : font.Metrics.RealHeight;
+
 	if (font.Info.Outline != FONT_OUTLINE_AUTO) {
 		font.Info.AutoOutlineThickness = 0;
 	}
+
+	// If there's no explicit linespacing property set, then calculate
+	// default linespacing from the font height + outline thickness.
+	font.LineSpacingCalc = font.Info.LineSpacing;
+	if (font.Info.LineSpacing == 0) {
+		const int height = font.Metrics.Height;
+		font.LineSpacingCalc = height + 2 * font.Info.AutoOutlineThickness;
+		// Backward compatibility: if the real font's height != formal height
+		// then set linespacing from the formal height.
+		if ((load_mode & FONT_LOAD_REPORTREALHEIGHT) == 0) {
+			const int compat_height = font.Metrics.CompatHeight;
+			if (height != compat_height) {
+				font.LineSpacingCalc = compat_height + 2 * font.Info.AutoOutlineThickness;
+			}
+		}
+	}
 }
 
 IAGSFontRenderer *font_replace_renderer(size_t fontNumber, IAGSFontRenderer *renderer, int load_mode) {
@@ -192,12 +209,14 @@ int get_font_surface_height(size_t fontNumber) {
 int get_font_linespacing(size_t fontNumber) {
 	if (fontNumber >= _GP(fonts).size())
 		return 0;
-	return _GP(fonts)[fontNumber].Info.LineSpacing;
+	return _GP(fonts)[fontNumber].LineSpacingCalc;
 }
 
 void set_font_linespacing(size_t fontNumber, int spacing) {
-	if (fontNumber < _GP(fonts).size())
+	if (fontNumber < _GP(fonts).size()) {
 		_GP(fonts)[fontNumber].Info.LineSpacing = spacing;
+		_GP(fonts)[fontNumber].LineSpacingCalc = spacing;
+	}
 }
 
 // Project-dependent implementation
diff --git a/engines/ags/shared/font/fonts.h b/engines/ags/shared/font/fonts.h
index f899bb0cb5b..0b87fa02066 100644
--- a/engines/ags/shared/font/fonts.h
+++ b/engines/ags/shared/font/fonts.h
@@ -50,6 +50,8 @@ struct Font {
 	FontInfo            Info;
 	// Values received from the renderer and saved for the reference
 	FontMetrics       Metrics;
+	// Precalculated linespacing, based on font properties and compat settings
+	int                 LineSpacingCalc = 0;
 
 	// Outline buffers
 	Bitmap TextStencil, TextStencilSub;


Commit: c0c76de84ae46c19e0ae24e374472ee67275099b
    https://github.com/scummvm/scummvm/commit/c0c76de84ae46c19e0ae24e374472ee67275099b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:22:26-07:00

Commit Message:
AGS: An ugly workaround for legacy label linespacing

>From upstream 9847f5b34abd7f3e5d3d1ca496ef2a991087e81e

Changed paths:
    engines/ags/shared/ac/game_struct_defines.h
    engines/ags/shared/font/fonts.cpp
    engines/ags/shared/font/fonts.h
    engines/ags/shared/gui/gui_label.cpp


diff --git a/engines/ags/shared/ac/game_struct_defines.h b/engines/ags/shared/ac/game_struct_defines.h
index d26bb704f8c..a5f569b28f3 100644
--- a/engines/ags/shared/ac/game_struct_defines.h
+++ b/engines/ags/shared/ac/game_struct_defines.h
@@ -106,6 +106,7 @@ namespace AGS3 {
 #define MAX_LEGACY_FONT_SIZE 63
 // Contemporary font flags
 #define FFLG_SIZEMULTIPLIER  0x01  // size data means multiplier
+#define FFLG_DEFLINESPACING  0x02  // linespacing derived from the font height
 // Font outline types
 #define FONT_OUTLINE_NONE -1
 #define FONT_OUTLINE_AUTO -10
diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index 22904819de5..9ba20998105 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -96,6 +96,7 @@ static void post_init_font(size_t fontNumber, int load_mode) {
 	// default linespacing from the font height + outline thickness.
 	font.LineSpacingCalc = font.Info.LineSpacing;
 	if (font.Info.LineSpacing == 0) {
+		font.Info.Flags |= FFLG_DEFLINESPACING;
 		const int height = font.Metrics.Height;
 		font.LineSpacingCalc = height + 2 * font.Info.AutoOutlineThickness;
 		// Backward compatibility: if the real font's height != formal height
@@ -138,6 +139,12 @@ const char *get_font_name(size_t fontNumber) {
 	return name ? name : "";
 }
 
+int get_font_flags(size_t fontNumber) {
+	if (fontNumber >= _GP(fonts).size())
+		return 0;
+	return _GP(fonts)[fontNumber].Info.Flags;
+}
+
 void ensure_text_valid_for_font(char *text, size_t fontnum) {
 	if (fontnum >= _GP(fonts).size() || !_GP(fonts)[fontnum].Renderer)
 		return;
@@ -214,6 +221,7 @@ int get_font_linespacing(size_t fontNumber) {
 
 void set_font_linespacing(size_t fontNumber, int spacing) {
 	if (fontNumber < _GP(fonts).size()) {
+		_GP(fonts)[fontNumber].Info.Flags &= ~FFLG_DEFLINESPACING;
 		_GP(fonts)[fontNumber].Info.LineSpacing = spacing;
 		_GP(fonts)[fontNumber].LineSpacingCalc = spacing;
 	}
diff --git a/engines/ags/shared/font/fonts.h b/engines/ags/shared/font/fonts.h
index 0b87fa02066..900ffc88ac1 100644
--- a/engines/ags/shared/font/fonts.h
+++ b/engines/ags/shared/font/fonts.h
@@ -80,6 +80,8 @@ bool is_bitmap_font(size_t fontNumber);
 bool font_supports_extended_characters(size_t fontNumber);
 // Get font's name, if it's available, otherwise returns empty string
 const char *get_font_name(size_t fontNumber);
+// Get a collection of FFLG_* flags corresponding to this font
+int get_font_flags(size_t fontNumber);
 // TODO: with changes to WFN font renderer that implemented safe rendering of
 // strings containing invalid chars (since 3.3.1) this function is not
 // important, except for (maybe) few particular cases.
diff --git a/engines/ags/shared/gui/gui_label.cpp b/engines/ags/shared/gui/gui_label.cpp
index bf7fa675062..7cb91f27d28 100644
--- a/engines/ags/shared/gui/gui_label.cpp
+++ b/engines/ags/shared/gui/gui_label.cpp
@@ -56,7 +56,10 @@ void GUILabel::Draw(Shared::Bitmap *ds) {
 		return;
 
 	color_t text_color = ds->GetCompatibleColor(TextColor);
-	const int linespacing = get_font_linespacing(Font) + 1;
+	const int linespacing = // Older engine labels used (font height + 1) as linespacing for some reason
+		((_G(loaded_game_file_version) < kGameVersion_360) && (get_font_flags(Font) & FFLG_DEFLINESPACING)) ?
+		(get_font_height(Font) + 1) :
+		get_font_linespacing(Font);
 	// < 2.72 labels did not limit vertical size of text
 	const bool limit_by_label_frame = _G(loaded_game_file_version) >= kGameVersion_272;
 	int at_y = Y;


Commit: 094879ed48cff7754bdd4431a872d49da9ce70a5
    https://github.com/scummvm/scummvm/commit/094879ed48cff7754bdd4431a872d49da9ce70a5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:30:46-07:00

Commit Message:
AGS: Fix some remaining MAXSTRLEN to point to Globals

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


diff --git a/engines/ags/engine/ac/string.cpp b/engines/ags/engine/ac/string.cpp
index 461798c36fa..5e32d87e8bd 100644
--- a/engines/ags/engine/ac/string.cpp
+++ b/engines/ags/engine/ac/string.cpp
@@ -296,13 +296,12 @@ size_t break_up_text_into_lines(const char *todis, SplitLines &lines, int wii, i
 		return lines.Count();
 }
 
-int MAXSTRLEN = MAX_MAXSTRLEN;
 void check_strlen(char *ptt) {
-	MAXSTRLEN = MAX_MAXSTRLEN;
+	_G(MAXSTRLEN) = MAX_MAXSTRLEN;
 	long charstart = (intptr_t)&_GP(game).chars[0];
 	long charend = charstart + sizeof(CharacterInfo) * _GP(game).numcharacters;
 	if (((intptr_t)&ptt[0] >= charstart) && ((intptr_t)&ptt[0] <= charend))
-		MAXSTRLEN = 30;
+		_G(MAXSTRLEN) = 30;
 }
 
 /*void GetLanguageString(int indxx,char*buffr) {


Commit: 263ae9d8fd147d084b80a7ba65e60c25d36c40a5
    https://github.com/scummvm/scummvm/commit/263ae9d8fd147d084b80a7ba65e60c25d36c40a5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:32:53-07:00

Commit Message:
AGS: File.ReadRawLineBack() can read lines longer than 200 chars

>From upstream 4a1e1440d115b2259b9b960e01753a4ddabedd2e

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 31e8188baf8..da20e76f51e 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -114,30 +114,49 @@ void File_WriteRawLine(sc_File *fil, const char *towrite) {
 	FileWriteRawLine(fil->handle, towrite);
 }
 
-void File_ReadRawLine(sc_File *fil, char *buffer) {
+// Reads line of chars until linebreak is met or buffer is filled;
+// returns whether reached the end of line (false in case not enough buffer);
+// guarantees null-terminator in the buffer.
+static bool File_ReadRawLineImpl(sc_File *fil, char *buffer, size_t buf_len) {
+	if (buf_len == 0) return false;
 	Stream *in = get_valid_file_stream_from_handle(fil->handle, "File.ReadRawLine");
-	check_strlen(buffer);
-	int i = 0;
-	while (i < _G(MAXSTRLEN) - 1) {
-		buffer[i] = in->ReadInt8();
-		if (buffer[i] == '\r') {
-			// CR -- skip LF and abort
-			in->ReadInt8();
-			break;
+	for (size_t i = 0; i < buf_len - 1; ++i) {
+		char c = in->ReadByte();
+		if (c < 0 || c == '\n') // EOF or LF
+		{
+			buffer[i] = 0;
+			return true;
 		}
-		if (buffer[i] == '\n')  // LF only -- abort
-			break;
-		if (in->EOS())  // EOF -- abort
-			break;
-		i++;
+		if (c == '\r') // CR or CRLF
+		{
+			c = in->ReadByte();
+			// Look for '\n', but it may be missing, which is also a valid case
+			if (c >= 0 && c != '\n') in->Seek(-1, kSeekCurrent);
+			buffer[i] = 0;
+			return true;
+		}
+		buffer[i] = c;
 	}
-	buffer[i] = 0;
+	buffer[buf_len - 1] = 0;
+	return false; // not enough buffer
+}
+
+void File_ReadRawLine(sc_File *fil, char *buffer) {
+	check_strlen(buffer);
+	File_ReadRawLineImpl(fil, buffer, _G(MAXSTRLEN));
 }
 
 const char *File_ReadRawLineBack(sc_File *fil) {
-	char readbuffer[MAX_MAXSTRLEN + 1];
-	File_ReadRawLine(fil, readbuffer);
-	return CreateNewScriptString(readbuffer);
+	char readbuffer[MAX_MAXSTRLEN];
+	if (File_ReadRawLineImpl(fil, readbuffer, MAX_MAXSTRLEN))
+		return CreateNewScriptString(readbuffer);
+	String sbuf = readbuffer;
+	bool done = false;
+	while (!done) {
+		done = File_ReadRawLineImpl(fil, readbuffer, MAX_MAXSTRLEN);
+		sbuf.Append(readbuffer);
+	};
+	return CreateNewScriptString(sbuf.GetCStr());
 }
 
 void File_ReadString(sc_File *fil, char *toread) {


Commit: de739c19139e483b23be42e4a75f36ffa2f9dffd
    https://github.com/scummvm/scummvm/commit/de739c19139e483b23be42e4a75f36ffa2f9dffd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:35:13-07:00

Commit Message:
AGS: Updated build version (3.6.0.10)

>From upstream a048e17a7a4eaa5377bba95244565ab5f1fb2f76

Changed paths:
    engines/ags/shared/core/def_version.h


diff --git a/engines/ags/shared/core/def_version.h b/engines/ags/shared/core/def_version.h
index 9b55af08c55..99d10a9aefe 100644
--- a/engines/ags/shared/core/def_version.h
+++ b/engines/ags/shared/core/def_version.h
@@ -22,9 +22,9 @@
 #ifndef AGS_SHARED_CORE_DEFVERSION_H
 #define AGS_SHARED_CORE_DEFVERSION_H
 
-#define ACI_VERSION_STR      "3.6.0.12"
+#define ACI_VERSION_STR      "3.6.0.10"
 #if defined (RC_INVOKED) // for MSVC resource compiler
-#define ACI_VERSION_MSRC_DEF  3,6,0,12
+#define ACI_VERSION_MSRC_DEF  3.6.0.10
 #endif
 
 #define SPECIAL_VERSION ""


Commit: 8511f7b36c057e76d80efc7411a61a9129100182
    https://github.com/scummvm/scummvm/commit/8511f7b36c057e76d80efc7411a61a9129100182
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:40:23-07:00

Commit Message:
AGS: Adjusted comment in SetObjectFrame to make it bit more visible

>From upstream 6c6a5ff35a29eedbcd8aa1a33ec99de2f3536b09

Changed paths:
    engines/ags/engine/ac/global_object.cpp
    engines/ags/shared/ac/view.cpp


diff --git a/engines/ags/engine/ac/global_object.cpp b/engines/ags/engine/ac/global_object.cpp
index 3b02edffb0b..44b688c862e 100644
--- a/engines/ags/engine/ac/global_object.cpp
+++ b/engines/ags/engine/ac/global_object.cpp
@@ -156,11 +156,11 @@ void SetObjectFrame(int obn, int viw, int lop, int fra) {
 	if (lop < 0 || lop >= _GP(views)[viw].numLoops) quitprintf("!SetObjectFrame: invalid loop number used (%d, range is 0 - %d)", lop, _GP(views)[viw].numLoops - 1);
 	// historically AGS let user to pass literally any positive invalid frame value by silently reassigning it to zero...
 	if (fra < 0 || fra >= _GP(views)[viw].loops[lop].numFrames) {
-		if (_GP(views)[viw].loops[lop].numFrames == 0) // NOTE: we have a dummy frame allocated for this case
+		if (_GP(views)[viw].loops[lop].numFrames == 0)
 			debug_script_warn("SetObjectFrame: specified loop %d has no frames, will fallback to dummy frame", lop);
 		else
 			debug_script_warn("SetObjectFrame: frame index out of range (%d, must be 0 - %d), set to 0", fra, _GP(views)[viw].loops[lop].numFrames - 1);
-		fra = 0;
+		fra = 0; // NOTE: we have 1 dummy frame allocated for empty loops
 	}
 	if (viw > UINT16_MAX || lop > UINT16_MAX || fra > UINT16_MAX) {
 		debug_script_warn("Warning: object's (id %d) view/loop/frame (%d/%d/%d) is outside of internal range (%d/%d/%d), reset to no view",
diff --git a/engines/ags/shared/ac/view.cpp b/engines/ags/shared/ac/view.cpp
index 1db120a3228..ef362f5f1e9 100644
--- a/engines/ags/shared/ac/view.cpp
+++ b/engines/ags/shared/ac/view.cpp
@@ -73,7 +73,7 @@ bool ViewLoopNew::RunNextLoop() {
 void ViewLoopNew::Initialize(int frameCount) {
 	numFrames = frameCount;
 	flags = 0;
-	// an extra frame is allocated o prevent crashes with empty loops
+	// an extra frame is allocated to prevent crashes with empty loops
 	frames.resize(numFrames > 0 ? numFrames : 1);
 }
 


Commit: d378ce6d89f842fb102b4d35a64603682bec8e31
    https://github.com/scummvm/scummvm/commit/d378ce6d89f842fb102b4d35a64603682bec8e31
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:40:34-07:00

Commit Message:
AGS: Use formal font height to set default linespacing, for now

>From upstream aedbd80b6985981e5310c0928ad651143452ddcc

Changed paths:
    engines/ags/shared/font/fonts.cpp


diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index 9ba20998105..e4817a00961 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -99,14 +99,11 @@ static void post_init_font(size_t fontNumber, int load_mode) {
 		font.Info.Flags |= FFLG_DEFLINESPACING;
 		const int height = font.Metrics.Height;
 		font.LineSpacingCalc = height + 2 * font.Info.AutoOutlineThickness;
-		// Backward compatibility: if the real font's height != formal height
-		// then set linespacing from the formal height.
-		if ((load_mode & FONT_LOAD_REPORTREALHEIGHT) == 0) {
-			const int compat_height = font.Metrics.CompatHeight;
-			if (height != compat_height) {
-				font.LineSpacingCalc = compat_height + 2 * font.Info.AutoOutlineThickness;
-			}
-		}
+		// NOTE: we use formal font height to define default linespacing;
+		// this is compatible with the old games and also seem to give nicer
+		// looks (plus user may always setup custom linespacing).
+		// If real height will be wanted, check for FONT_LOAD_REPORTREALHEIGHT
+		// flag in "load_mode" to know when to apply real or formal height.
 	}
 }
 


Commit: 86f3f8933b3db4b4803e68699cbb13a9201f0166
    https://github.com/scummvm/scummvm/commit/86f3f8933b3db4b4803e68699cbb13a9201f0166
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-03-23T20:50:27-07:00

Commit Message:
AGS: Use real font height for speech & dialog option bitmap sizes

>From upstream 22af623cadce89ac27777cf2178649a71fc2a345

Changed paths:
    engines/ags/engine/ac/dialog.cpp
    engines/ags/engine/ac/display.cpp
    engines/ags/engine/ac/display.h
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/ac/global_gui.cpp
    engines/ags/shared/font/fonts.cpp
    engines/ags/shared/font/fonts.h


diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp
index 65af26940c7..2d5725974d2 100644
--- a/engines/ags/engine/ac/dialog.cpp
+++ b/engines/ags/engine/ac/dialog.cpp
@@ -360,7 +360,7 @@ int write_dialog_options(Bitmap *ds, bool ds_has_alpha, int dlgxp, int curyp, in
 		needheight = 0;\
 		for (int i = 0; i < numdisp; ++i) {\
 			break_up_text_into_lines(get_translation(dtop->optionnames[(int)disporder[i]]), _GP(Lines), areawid-(2*padding+2+bullet_wid), usingfont);\
-			needheight += getheightoflines(usingfont, _GP(Lines).Count()) + data_to_game_coord(_GP(game).options[OPT_DIALOGGAP]);\
+			needheight += get_text_lines_surf_height(usingfont, _GP(Lines).Count()) + data_to_game_coord(_GP(game).options[OPT_DIALOGGAP]);\
 		}\
 		if (parserInput) needheight += parserInput->Height + data_to_game_coord(_GP(game).options[OPT_DIALOGGAP]);\
 	}
diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index 738499f3b0f..f4982318498 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -63,9 +63,8 @@ using namespace AGS::Shared;
 using namespace AGS::Shared::BitmapHelper;
 
 struct DisplayVars {
-	int lineheight;    // font's height of single line
-	int linespacing;   // font's line spacing
-	int fulltxtheight; // total height of all the text
+	int linespacing = 0;   // font's line spacing
+	int fulltxtheight = 0; // total height of all the text
 } disp;
 
 // Pass yy = -1 to find Y co-ord automatically
@@ -100,9 +99,8 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
 
 	ensure_text_valid_for_font(todis, usingfont);
 	break_up_text_into_lines(todis, _GP(Lines), wii - 2 * padding, usingfont);
-	disp.lineheight = get_font_height_outlined(usingfont);
 	disp.linespacing = get_font_linespacing(usingfont);
-	disp.fulltxtheight = getheightoflines(usingfont, _GP(Lines).Count());
+	disp.fulltxtheight = get_text_lines_surf_height(usingfont, _GP(Lines).Count());
 
 	// AGS 2.x: If the screen is faded out, fade in again when displaying a message box.
 	if (!asspch && (_G(loaded_game_file_version) <= kGameVersion_272))
@@ -563,10 +561,6 @@ int get_font_outline_padding(int font) {
 	return 0;
 }
 
-int getheightoflines(int font, int numlines) {
-	return get_font_linespacing(font) * (numlines - 1) + get_font_height_outlined(font);
-}
-
 int get_text_width_outlined(const char *tex, int font) {
 	return get_text_width(tex, font) + 2 * get_font_outline_padding(font);
 }
diff --git a/engines/ags/engine/ac/display.h b/engines/ags/engine/ac/display.h
index 38608bc358c..238bd4ed83f 100644
--- a/engines/ags/engine/ac/display.h
+++ b/engines/ags/engine/ac/display.h
@@ -52,8 +52,6 @@ int GetTextDisplayTime(const char *text, int canberel = 0);
 // Draw an outline if requested, then draw the text on top
 void wouttext_outline(Shared::Bitmap *ds, int xxp, int yyp, int usingfont, color_t text_color, const char *texx);
 void wouttext_aligned(Shared::Bitmap *ds, int usexp, int yy, int oriwid, int usingfont, color_t text_color, const char *text, HorAlignment align);
-// Gets the total maximal height of the given number of lines printed with the given font
-int getheightoflines(int font, int numlines);
 // Get the maximal width of the given font, with corresponding outlining
 int get_text_width_outlined(const char *tex, int font);
 void do_corner(Shared::Bitmap *ds, int sprn, int xx1, int yy1, int typx, int typy);
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 3c5ae00a406..02bb0221e66 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -1924,14 +1924,13 @@ PBitmap draw_room_background(Viewport *view, const SpriteTransform &room_trans)
 	return _GP(CameraDrawData)[view_index].Frame;
 }
 
-
 void draw_fps(const Rect &viewport) {
 	// TODO: make allocated "fps struct" instead of using static vars!!
 	static IDriverDependantBitmap *ddb = nullptr;
 	static Bitmap *fpsDisplay = nullptr;
 	const int font = FONT_NORMAL;
 	if (fpsDisplay == nullptr) {
-		fpsDisplay = CreateCompatBitmap(viewport.GetWidth(), (get_font_height_outlined(font) + get_fixed_pixel_size(5)));
+		fpsDisplay = CreateCompatBitmap(viewport.GetWidth(), (get_font_surface_height(font) + get_fixed_pixel_size(5)));
 	}
 	fpsDisplay->ClearTransparent();
 
@@ -2268,7 +2267,7 @@ void construct_engine_overlay() {
 		const int font = FONT_NORMAL;
 		int ypp = 1;
 		int txtspacing = get_font_linespacing(font);
-		int barheight = getheightoflines(font, DEBUG_CONSOLE_NUMLINES - 1) + 4;
+		int barheight = get_text_lines_surf_height(font, DEBUG_CONSOLE_NUMLINES - 1) + 4;
 
 		if (_G(debugConsoleBuffer) == nullptr) {
 			_G(debugConsoleBuffer) = CreateCompatBitmap(viewport.GetWidth(), barheight);
diff --git a/engines/ags/engine/ac/global_gui.cpp b/engines/ags/engine/ac/global_gui.cpp
index 69a088d4b9b..ef6f5b5099c 100644
--- a/engines/ags/engine/ac/global_gui.cpp
+++ b/engines/ags/engine/ac/global_gui.cpp
@@ -40,9 +40,6 @@ namespace AGS3 {
 
 using namespace AGS::Shared;
 
-
-
-
 int IsGUIOn(int guinum) {
 	if ((guinum < 0) || (guinum >= _GP(game).numgui))
 		quit("!IsGUIOn: invalid GUI number specified");
@@ -187,7 +184,7 @@ int GetTextHeight(const char *text, int fontnum, int width) {
 
 	if (break_up_text_into_lines(text, _GP(Lines), data_to_game_coord(width), fontnum) == 0)
 		return 0;
-	return game_to_data_coord(getheightoflines(fontnum, _GP(Lines).Count()));
+	return game_to_data_coord(get_text_lines_height(fontnum, _GP(Lines).Count()));
 }
 
 int GetFontHeight(int fontnum) {
diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index e4817a00961..b65b7f87eae 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -224,6 +224,22 @@ void set_font_linespacing(size_t fontNumber, int spacing) {
 	}
 }
 
+int get_text_lines_height(size_t fontNumber, size_t numlines) {
+	if (fontNumber >= _GP(fonts).size() || numlines == 0)
+		return 0;
+	return _GP(fonts)[fontNumber].LineSpacingCalc * (numlines - 1) +
+		(_GP(fonts)[fontNumber].Metrics.CompatHeight +
+			2 * _GP(fonts)[fontNumber].Info.AutoOutlineThickness);
+}
+
+int get_text_lines_surf_height(size_t fontNumber, size_t numlines) {
+	if (fontNumber >= _GP(fonts).size() || numlines == 0)
+		return 0;
+	return _GP(fonts)[fontNumber].LineSpacingCalc * (numlines - 1) +
+		(_GP(fonts)[fontNumber].Metrics.RealHeight +
+			2 * _GP(fonts)[fontNumber].Info.AutoOutlineThickness);
+}
+
 // Project-dependent implementation
 extern int get_text_width_outlined(const char *tex, int font);
 
diff --git a/engines/ags/shared/font/fonts.h b/engines/ags/shared/font/fonts.h
index 900ffc88ac1..84cd5ca8dfd 100644
--- a/engines/ags/shared/font/fonts.h
+++ b/engines/ags/shared/font/fonts.h
@@ -97,8 +97,6 @@ int get_text_width(const char *texx, size_t fontNumber);
 // note that this is a "formal" font height, that may have different value
 // depending on compatibility mode (used when running old games);
 int get_font_height(size_t fontNumber);
-// TODO: GUI classes located in Common library do not make use of outlining,
-// need to find a way to make all code use same functions.
 // Get the maximal height of the given font, with corresponding outlining
 int get_font_height_outlined(size_t fontNumber);
 // Get font's surface height: this always returns the height enough to accomodate
@@ -112,6 +110,12 @@ void set_font_linespacing(size_t fontNumber, int spacing);
 int  get_font_outline(size_t font_number);
 // Get font's automatic outline thickness (if set)
 int  get_font_outline_thickness(size_t font_number);
+// Gets the total maximal height of the given number of lines printed with the given font;
+// note that this uses formal font height, for compatibility purposes
+int get_text_lines_height(size_t fontNumber, size_t numlines);
+// Gets the height of a graphic surface enough to accomodate this number of text lines;
+// note this accounts for the real pixel font height
+int get_text_lines_surf_height(size_t fontNumber, size_t numlines);
 // get the source font associated with an outline font
 int get_font_outline_font(size_t font_number);
 // Set font's outline type




More information about the Scummvm-git-logs mailing list