[Scummvm-git-logs] scummvm master -> f2a41c84769ac2cfb6399999307a91899f618c2b

criezy noreply at scummvm.org
Fri Jan 20 14:15:08 UTC 2023


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

Summary:
2ef1dfd3a6 AGS: Engine: fixed few typos in error messages
5614bc15de AGS: Engine: prevent cursor from leaving game area
dcba4db6f1 AGS: Engine: fixed voice is disabled if tried to enable already enabled vox
b1d4f4ee47 AGS: Engine: print game's guid into log along with the title
5dea74f224 AGS: Engine: also print uid into log along with guid
6f82ba6008 AGS: Engine: fixed ScriptOverlay loosing ID when changing text
862759135e AGS: Engine: split out create_textual_image() out of _display_main()
51e541cfb6 AGS: Remove unneeded La Croix Pan workaround
7e3c3f1f0b AGS: Engine: reimplemented Overlay.SetText without call to _display_main()
300379a2d6 AGS: Engine: ScreenOverlay.SetImage() accepts offset as arguments
da147138d4 AGS: Script API: removed a rule that Viewport and Camera 0 can't be deleted
5ae3427f9d AGS: Common: simplified MFLUtil::ReadEncInt32(), use conditional function
f2a41c8476 AGS: Updated build version (3.6.0.36)


Commit: 2ef1dfd3a6884ba42b6017fc58febebc38c0bd84
    https://github.com/scummvm/scummvm/commit/2ef1dfd3a6884ba42b6017fc58febebc38c0bd84
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: fixed few typos in error messages

>From upstream dd961852cf3e94c202dd0d9a7984f90e48ccd2fa

Changed paths:
    engines/ags/engine/ac/character.cpp
    engines/ags/engine/ac/global_inventory_item.cpp


diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index 10edab3af67..b80fc10b80a 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -83,7 +83,7 @@ void Character_AddInventory(CharacterInfo *chaa, ScriptInvItem *invi, int addInd
 	int ee;
 
 	if (invi == nullptr)
-		quit("!AddInventoryToCharacter: invalid invnetory number");
+		quit("!AddInventoryToCharacter: invalid inventory number");
 
 	int inum = invi->id;
 
@@ -641,7 +641,7 @@ void Character_LockViewOffsetEx(CharacterInfo *chap, int vii, int xoffs, int yof
 void Character_LoseInventory(CharacterInfo *chap, ScriptInvItem *invi) {
 
 	if (invi == nullptr)
-		quit("!LoseInventoryFromCharacter: invalid invnetory number");
+		quit("!LoseInventoryFromCharacter: invalid inventory number");
 
 	int inum = invi->id;
 
diff --git a/engines/ags/engine/ac/global_inventory_item.cpp b/engines/ags/engine/ac/global_inventory_item.cpp
index c9c707606db..3c4ed921009 100644
--- a/engines/ags/engine/ac/global_inventory_item.cpp
+++ b/engines/ags/engine/ac/global_inventory_item.cpp
@@ -108,7 +108,7 @@ void RunInventoryInteraction(int iit, int modd) {
 		run_event_block_inv(iit, 3);
 	} else if (modd == MODE_TALK)
 		run_event_block_inv(iit, 2);
-	else // other click on invnetory
+	else // other click on inventory
 		run_event_block_inv(iit, 4);
 }
 


Commit: 5614bc15de5db7fa762f9d49b541de4bb3366c2f
    https://github.com/scummvm/scummvm/commit/5614bc15de5db7fa762f9d49b541de4bb3366c2f
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: prevent cursor from leaving game area

>From upstream 8cf49996d05a6fb4fd8691fa87fb6a12114e45d7

Changed paths:
    engines/ags/engine/device/mouse_w32.cpp


diff --git a/engines/ags/engine/device/mouse_w32.cpp b/engines/ags/engine/device/mouse_w32.cpp
index 016a00a2cb3..49046b381f6 100644
--- a/engines/ags/engine/device/mouse_w32.cpp
+++ b/engines/ags/engine/device/mouse_w32.cpp
@@ -72,8 +72,8 @@ void mgetgraphpos() {
 		_G(real_mouse_y) = CLIP(_G(real_mouse_y) + rel_y, _GP(mouse).ControlRect.Top, _GP(mouse).ControlRect.Bottom);
 	} else {
 		// Save real cursor coordinates provided by system
-		_G(real_mouse_x) = _G(sys_mouse_x);
-		_G(real_mouse_y) = _G(sys_mouse_y);
+		_G(real_mouse_x) = CLIP((int)_G(sys_mouse_x), _GP(mouse).ControlRect.Left, _GP(mouse).ControlRect.Right);
+		_G(real_mouse_y) = CLIP((int)_G(sys_mouse_y), _GP(mouse).ControlRect.Top, _GP(mouse).ControlRect.Bottom);
 	}
 
 	// Set new in-game cursor position


Commit: dcba4db6f1b70638b85a0406adcec053109b14bd
    https://github.com/scummvm/scummvm/commit/dcba4db6f1b70638b85a0406adcec053109b14bd
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: fixed voice is disabled if tried to enable already enabled vox

>From upstream 24eb9c8f16cfc518ae343f825d49f05cefaee32e

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


diff --git a/engines/ags/engine/ac/speech.cpp b/engines/ags/engine/ac/speech.cpp
index b6f2167b53b..8d95b090025 100644
--- a/engines/ags/engine/ac/speech.cpp
+++ b/engines/ags/engine/ac/speech.cpp
@@ -94,12 +94,12 @@ SkipSpeechStyle internal_skip_speech_to_user(int internal_val) {
 bool init_voicepak(const String &name) {
 	if (_GP(usetup).no_speech_pack) return false; // voice-over disabled
 
-	_GP(play).voice_avail = false;
 	String speech_file = name.IsEmpty() ? "speech.vox" : String::FromFormat("sp_%s.vox", name.GetCStr());
 	if (_GP(ResPaths).SpeechPak.Name.CompareNoCase(speech_file) == 0)
 		return true; // same pak already assigned
 
 	// First remove existing voice packs
+	_GP(play).voice_avail = false;
 	_GP(AssetMgr)->RemoveLibrary(_GP(ResPaths).SpeechPak.Path);
 	_GP(AssetMgr)->RemoveLibrary(_GP(ResPaths).VoiceDirSub);
 


Commit: b1d4f4ee4713171811afa7e7a2de1c6a1037c1f6
    https://github.com/scummvm/scummvm/commit/b1d4f4ee4713171811afa7e7a2de1c6a1037c1f6
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: print game's guid into log along with the title

>From upstream 473604e6dafb647b83f039ea4ca5db97975325d0

Changed paths:
    engines/ags/shared/game/main_game_file.cpp


diff --git a/engines/ags/shared/game/main_game_file.cpp b/engines/ags/shared/game/main_game_file.cpp
index c4db80d06e8..2ae2692bf1b 100644
--- a/engines/ags/shared/game/main_game_file.cpp
+++ b/engines/ags/shared/game/main_game_file.cpp
@@ -756,6 +756,7 @@ HGameFileError ReadGameData(LoadedGameEntities &ents, Stream *in, GameDataVersio
 	}
 
 	Debug::Printf(kDbgMsg_Info, "Game title: '%s'", game.gamename);
+	Debug::Printf(kDbgMsg_Info, "Game guid: '%s'", game.guid);
 
 	if (game.GetGameRes().IsNull())
 		return new MainGameFileError(kMGFErr_InvalidNativeResolution);


Commit: 5dea74f224052b91c34669e582b23c854224bfa2
    https://github.com/scummvm/scummvm/commit/5dea74f224052b91c34669e582b23c854224bfa2
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: also print uid into log along with guid

>From upstream e1d0e9648173629e0345b528b79a490d5e345ee1

Changed paths:
    engines/ags/shared/game/main_game_file.cpp


diff --git a/engines/ags/shared/game/main_game_file.cpp b/engines/ags/shared/game/main_game_file.cpp
index 2ae2692bf1b..41b6255d783 100644
--- a/engines/ags/shared/game/main_game_file.cpp
+++ b/engines/ags/shared/game/main_game_file.cpp
@@ -756,6 +756,7 @@ HGameFileError ReadGameData(LoadedGameEntities &ents, Stream *in, GameDataVersio
 	}
 
 	Debug::Printf(kDbgMsg_Info, "Game title: '%s'", game.gamename);
+	Debug::Printf(kDbgMsg_Info, "Game uid (old format): `%d`", game.uniqueid);
 	Debug::Printf(kDbgMsg_Info, "Game guid: '%s'", game.guid);
 
 	if (game.GetGameRes().IsNull())


Commit: 6f82ba60084535d322457c378cf0649f3d309737
    https://github.com/scummvm/scummvm/commit/6f82ba60084535d322457c378cf0649f3d309737
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: fixed ScriptOverlay loosing ID when changing text

>From upstream acd7ac23d35aafbceb0115b3c3ae1a946e4de20a

Changed paths:
    engines/ags/engine/ac/global_overlay.cpp
    engines/ags/engine/ac/overlay.cpp


diff --git a/engines/ags/engine/ac/global_overlay.cpp b/engines/ags/engine/ac/global_overlay.cpp
index e4150854d3e..d9b93993b0c 100644
--- a/engines/ags/engine/ac/global_overlay.cpp
+++ b/engines/ags/engine/ac/global_overlay.cpp
@@ -57,7 +57,8 @@ int CreateTextOverlay(int xx, int yy, int wii, int fontid, int text_color, const
 void SetTextOverlay(int ovrid, int xx, int yy, int wii, int fontid, int text_color, const char *text) {
 	RemoveOverlay(ovrid);
 	const int disp_type = ovrid;
-	if (CreateTextOverlay(xx, yy, wii, fontid, text_color, text, disp_type) != ovrid)
+	int new_ovrid = CreateTextOverlay(xx, yy, wii, fontid, text_color, text, disp_type);
+	if (new_ovrid != ovrid)
 		quit("SetTextOverlay internal error: inconsistent type ids");
 }
 
diff --git a/engines/ags/engine/ac/overlay.cpp b/engines/ags/engine/ac/overlay.cpp
index 8911b7eca1d..25f77e2e445 100644
--- a/engines/ags/engine/ac/overlay.cpp
+++ b/engines/ags/engine/ac/overlay.cpp
@@ -60,11 +60,18 @@ void Overlay_SetText(ScriptOverlay *scover, int wii, int fontid, int text_color,
 	int xx = game_to_data_coord(_GP(screenover)[ovri].x);
 	int yy = game_to_data_coord(_GP(screenover)[ovri].y);
 
-	RemoveOverlay(scover->overlayId);
+	// FIXME: a refactor needed!
+	// these calls to RemoveOverlay and CreateOverlay below are potentially dangerous,
+	// because they may allocate new script objects too under certain conditions.
+	// This did not happen because users only had access to custom overlay pointers before,
+	// but now they also may access internal overlays (such as Say text and portrait).
 	const int disp_type = scover->overlayId;
+	RemoveOverlay(scover->overlayId);
 
-	if (CreateTextOverlay(xx, yy, wii, fontid, text_color, get_translation(text), disp_type) != scover->overlayId)
+	int new_ovrid = CreateTextOverlay(xx, yy, wii, fontid, text_color, get_translation(text), disp_type);
+	if (new_ovrid != disp_type)
 		quit("SetTextOverlay internal error: inconsistent type ids");
+	scover->overlayId = new_ovrid;
 }
 
 int Overlay_GetX(ScriptOverlay *scover) {


Commit: 862759135eabb3645cccda146b3638ea80417947
    https://github.com/scummvm/scummvm/commit/862759135eabb3645cccda146b3638ea80417947
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: split out create_textual_image() out of _display_main()

This simply makes generation of the textual image a separate function that may be used elsewhere, besides creating a new message overlay.
>From upstream a49550d32e9ea210e2d9b6711157251359d3c4c0

Changed paths:
    engines/ags/engine/ac/display.cpp
    engines/ags/engine/ac/display.h


diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index edec57a5749..57997aba549 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -67,17 +67,17 @@ struct DisplayVars {
 	int fulltxtheight = 0; // total height of all the text
 } disp;
 
-// Pass yy = -1 to find Y co-ord automatically
-// allowShrink = 0 for none, 1 for leftwards, 2 for rightwards
-// pass blocking=2 to create permanent overlay
-ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp_type, int usingfont,
-		int asspch, int isThought, int allowShrink, bool overlayPositionFixed, bool roomlayer) {
+// Generates a textual image and returns a disposable bitmap
+Bitmap *create_textual_image(const char *text, int asspch, int isThought,
+							 int &xx, int &yy, int &adjustedXX, int &adjustedYY, int wii, int usingfont, int allowShrink,
+							 bool &alphaChannel) {
+	//
+	// Configure the textual image
+	//
 	const bool use_speech_textwindow = (asspch < 0) && (_GP(game).options[OPT_SPEECHTYPE] >= 2);
 	const bool use_thought_gui = (isThought) && (_GP(game).options[OPT_THOUGHTGUI] > 0);
 
-	bool alphaChannel = false;
-	char todis[STD_BUFFER_SIZE];
-	snprintf(todis, STD_BUFFER_SIZE - 1, "%s", text);
+	alphaChannel = false;
 	int usingGui = -1;
 	if (use_speech_textwindow)
 		usingGui = _GP(play).speech_textwindow_gui;
@@ -85,8 +85,9 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 		usingGui = _GP(game).options[OPT_THOUGHTGUI];
 
 	int padding = get_textwindow_padding(usingGui);
-	int paddingScaled = get_fixed_pixel_size(padding);
-	int paddingDoubledScaled = get_fixed_pixel_size(padding * 2); // Just in case screen size does is not neatly divisible by 320x200
+	const int paddingScaled = get_fixed_pixel_size(padding);
+ 	// Just in case screen size is not neatly divisible by 320x200
+	const int paddingDoubledScaled = get_fixed_pixel_size(padding * 2);
 
 	// FIXME: Fixes the display of the F1 help dialog in La Croix Pan,
 	// since it was previously incorrectly wrapping on the 's' at the end
@@ -98,41 +99,20 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 	// than can be supported by ScummVM's surface classes
 	wii = MIN(wii, 8000);
 
+	// Make message copy, because ensure_text_valid_for_font() may modify it
+	char todis[STD_BUFFER_SIZE];
+	snprintf(todis, STD_BUFFER_SIZE - 1, "%s", text);
 	ensure_text_valid_for_font(todis, usingfont);
 	break_up_text_into_lines(todis, _GP(Lines), wii - 2 * padding, usingfont);
 	disp.linespacing = get_font_linespacing(usingfont);
 	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))
-		_GP(play).screen_is_faded_out = 0;
-
-	// if it's a normal message box and the game was being skipped,
-	// ensure that the screen is up to date before the message box
-	// is drawn on top of it
-	// TODO: is this really necessary anymore?
-	if ((_GP(play).skip_until_char_stops >= 0) && (disp_type == DISPLAYTEXT_MESSAGEBOX))
-		render_graphics();
-
-	EndSkippingUntilCharStops();
-
 	if (_GP(topBar).wantIt) {
-		// ensure that the window is wide enough to display
-		// any top bar text
+		// ensure that the window is wide enough to display any top bar text
 		int topBarWid = get_text_width_outlined(_GP(topBar).text, _GP(topBar).font);
 		topBarWid += data_to_game_coord(_GP(play).top_bar_borderwidth + 2) * 2;
 		if (_G(longestline) < topBarWid)
 			_G(longestline) = topBarWid;
-		// the top bar should behave like DisplaySpeech wrt blocking
-		disp_type = DISPLAYTEXT_SPEECH;
-	}
-
-	if (asspch > 0) {
-		// update the all_buttons_disabled variable in advance
-		// of the adjust_x/y_for_guis calls
-		_GP(play).disabled_user_interface++;
-		update_gui_disabled_status();
-		_GP(play).disabled_user_interface--;
 	}
 
 	const Rect &ui_view = _GP(play).GetUIViewport();
@@ -170,11 +150,8 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 			xx = (ui_view.GetWidth() - wii) - 5;
 	} else if (xx < 0) xx = ui_view.GetWidth() / 2 - wii / 2;
 
-	int extraHeight = paddingDoubledScaled;
+	const int extraHeight = paddingDoubledScaled;
 	color_t text_color = MakeColor(15);
-	if (disp_type < DISPLAYTEXT_NORMALOVERLAY)
-		remove_screen_overlay(_GP(play).text_overlay_on); // remove any previous blocking texts
-
 	const int bmp_width = MAX(2, wii);
 	const int bmp_height = MAX(2, disp.fulltxtheight + extraHeight);
 	Bitmap *text_window_ds = BitmapHelper::CreateTransparentBitmap(
@@ -184,11 +161,11 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 	const bool wantFreeScreenop = true;
 
 	//
-	// Creating displayed graphic
+	// Create the textual image (may also adjust some params in the process)
 	//
 	// may later change if usingGUI, needed to avoid changing original coordinates
-	int adjustedXX = xx;
-	int adjustedYY = yy;
+	adjustedXX = xx;
+	adjustedYY = yy;
 
 	if ((strlen(todis) < 1) || (strcmp(todis, "  ") == 0) || (wii == 0));
 	// if it's an empty speech line, don't draw anything
@@ -245,6 +222,58 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 			wouttext_aligned(text_window_ds, xoffs, yoffs + ee * disp.linespacing, oriwid, usingfont, text_color, _GP(Lines)[ee].GetCStr(), _GP(play).text_align);
 	}
 
+	return text_window_ds;
+}
+
+// Pass yy = -1 to find Y co-ord automatically
+// allowShrink = 0 for none, 1 for leftwards, 2 for rightwards
+// pass blocking=2 to create permanent overlay
+ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp_type, int usingfont,
+							 int asspch, int isThought, int allowShrink, bool overlayPositionFixed, bool roomlayer) {
+	//
+	// Prepare for the message display
+	//
+
+	// 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))
+		_GP(play).screen_is_faded_out = 0;
+
+	// if it's a normal message box and the game was being skipped,
+	// ensure that the screen is up to date before the message box
+	// is drawn on top of it
+	// TODO: is this really necessary anymore?
+	if ((_GP(play).skip_until_char_stops >= 0) && (disp_type == DISPLAYTEXT_MESSAGEBOX))
+		render_graphics();
+
+	// TODO: should this really be called regardless of message type?
+	// _display_main may be called even for custom textual overlays
+	EndSkippingUntilCharStops();
+
+	if (asspch > 0) {
+		// update the all_buttons_disabled variable in advance
+		// of the adjust_x/y_for_guis calls
+		_GP(play).disabled_user_interface++;
+		update_gui_disabled_status();
+		_GP(play).disabled_user_interface--;
+	}
+
+	if (_GP(topBar).wantIt) {
+		// the top bar should behave like DisplaySpeech wrt blocking
+		disp_type = DISPLAYTEXT_SPEECH;
+	}
+
+	// remove any previous blocking texts if necessary
+	if (disp_type < DISPLAYTEXT_NORMALOVERLAY)
+		remove_screen_overlay(_GP(play).text_overlay_on);
+
+	int adjustedXX, adjustedYY;
+	bool alphaChannel;
+	Bitmap *text_window_ds = create_textual_image(text, asspch, isThought, xx, yy, adjustedXX, adjustedYY, wii, usingfont, allowShrink, alphaChannel);
+
+	//
+	// Configure and create an overlay object
+	//
+
 	int ovrtype;
 	switch (disp_type) {
 	case DISPLAYTEXT_SPEECH: ovrtype = OVER_TEXTSPEECH; break;
@@ -256,6 +285,7 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 	size_t nse = add_screen_overlay(roomlayer, xx, yy, ovrtype, text_window_ds, adjustedXX - xx, adjustedYY - yy, alphaChannel);
 	// we should not delete text_window_ds here, because it is now owned by Overlay
 
+	// If it's a non-blocking overlay type, then we're done here
 	if (disp_type >= DISPLAYTEXT_NORMALOVERLAY) {
 		return &_GP(screenover)[nse];
 	}
@@ -263,6 +293,7 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 	//
 	// Wait for the blocking text to timeout or until skipped by another command
 	//
+
 	if (disp_type == DISPLAYTEXT_MESSAGEBOX) {
 		// If fast-forwarding, then skip immediately
 		if (_GP(play).fast_forward) {
@@ -272,7 +303,7 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 			return nullptr;
 		}
 
-		int countdown = GetTextDisplayTime(todis);
+		int countdown = GetTextDisplayTime(text);
 		int skip_setting = user_to_internal_skip_speech((SkipSpeechStyle)_GP(play).skip_display);
 		// Loop until skipped
 		while (true) {
@@ -355,6 +386,10 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 		GameLoopUntilNoOverlay();
 	}
 
+	//
+	// Post-message cleanup
+	//
+
 	ags_clear_input_buffer();
 	_GP(play).messagetime = -1;
 	return nullptr;
diff --git a/engines/ags/engine/ac/display.h b/engines/ags/engine/ac/display.h
index f929b145af5..b1dca4c19bf 100644
--- a/engines/ags/engine/ac/display.h
+++ b/engines/ags/engine/ac/display.h
@@ -38,6 +38,9 @@ using AGS::Shared::GUIMain;
 // also accepts explicit overlay ID >= OVER_CUSTOM
 
 struct ScreenOverlay;
+Shared::Bitmap *create_textual_image(const char *text, int asspch, int isThought,
+									 int &xx, int &yy, int &adjustedXX, int &adjustedYY, int wii, int usingfont, int allowShrink,
+									 bool &alphaChannel);
 // Creates a textual overlay using the given parameters;
 // Pass yy = -1 to find Y co-ord automatically
 // allowShrink = 0 for none, 1 for leftwards, 2 for rightwards


Commit: 51e541cfb604eae318a51a3ad61de91936cf4869
    https://github.com/scummvm/scummvm/commit/51e541cfb604eae318a51a3ad61de91936cf4869
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Remove unneeded La Croix Pan workaround

The help text now behaves like the original game

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


diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index 57997aba549..299330923c2 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -84,17 +84,11 @@ Bitmap *create_textual_image(const char *text, int asspch, int isThought,
 	else if (use_thought_gui)
 		usingGui = _GP(game).options[OPT_THOUGHTGUI];
 
-	int padding = get_textwindow_padding(usingGui);
+	const int padding = get_textwindow_padding(usingGui);
 	const int paddingScaled = get_fixed_pixel_size(padding);
  	// Just in case screen size is not neatly divisible by 320x200
 	const int paddingDoubledScaled = get_fixed_pixel_size(padding * 2);
 
-	// FIXME: Fixes the display of the F1 help dialog in La Croix Pan,
-	// since it was previously incorrectly wrapping on the 's' at the end
-	// of the 'Cursors' word. May be due to minor differences in width calcs
-	if (padding == 3 && ConfMan.get("gameid") == "lacroixpan")
-		padding = 0;
-
 	// WORKAROUND: Guard Duty specifies a wii of 100,000, which is larger
 	// than can be supported by ScummVM's surface classes
 	wii = MIN(wii, 8000);


Commit: 7e3c3f1f0b4c5eda8432a5e17057a1d3cb037fa7
    https://github.com/scummvm/scummvm/commit/7e3c3f1f0b4c5eda8432a5e17057a1d3cb037fa7
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: reimplemented Overlay.SetText without call to _display_main()

Previously Overlay.SetText was passing into CreateTextOverlay() -> Overlay_CreateTextCore() -> _display_main().
This effectively removed and recreated an overlay with different image but the same ID.

Also, previously, this method could have been only called for custom overlays in practice.
For these the script object was not touched, and kept the correct overlay reference.

The situation has changed when we let user script to access some of the internally created
 overlays, such as Text and Portrait overlays created by a blocking Say command.
When these overlays are recreated, they also must be completely destroyed, invalidating any
existing script references. Hence calling _display_main() from Overlay.SetText() is no longer
acceptable, as it leads to a full overlay recreation, and possible duplication of a script
reference with two (or more) separate managed handles (this is almost like, two shared
pointers owning same object).

To fix this problem, here we replace a call to CreateTextOverlay() with manual recreation of a
textual image, and assigning a new image to the same overlay.
This does not change anything from the script's POV, as SetText method already suggests
that the overlay reference remains valid (previously only the internal object was secretly
replaced).

>From upstream aaf6144e5123d36e4f04fcc6592b02ec18f869e0

Changed paths:
    engines/ags/engine/ac/global_overlay.cpp
    engines/ags/engine/ac/overlay.cpp


diff --git a/engines/ags/engine/ac/global_overlay.cpp b/engines/ags/engine/ac/global_overlay.cpp
index d9b93993b0c..f03f705175d 100644
--- a/engines/ags/engine/ac/global_overlay.cpp
+++ b/engines/ags/engine/ac/global_overlay.cpp
@@ -46,6 +46,7 @@ int CreateTextOverlay(int xx, int yy, int wii, int fontid, int text_color, const
 
 	if (xx != OVR_AUTOPLACE) {
 		data_to_game_coords(&xx, &yy);
+		// NOTE: this is ugly, but OVR_AUTOPLACE here suggests that width is already in game coords
 		wii = data_to_game_coord(wii);
 	} else  // allow DisplaySpeechBackground to be shrunk
 		allowShrink = 1;
diff --git a/engines/ags/engine/ac/overlay.cpp b/engines/ags/engine/ac/overlay.cpp
index 25f77e2e445..c9fed2bd747 100644
--- a/engines/ags/engine/ac/overlay.cpp
+++ b/engines/ags/engine/ac/overlay.cpp
@@ -53,25 +53,41 @@ void Overlay_Remove(ScriptOverlay *sco) {
 	sco->Remove();
 }
 
-void Overlay_SetText(ScriptOverlay *scover, int wii, int fontid, int text_color, const char *text) {
+void Overlay_SetText(ScriptOverlay *scover, int width, int fontid, int text_color, const char *text) {
 	int ovri = find_overlay_of_type(scover->overlayId);
 	if (ovri < 0)
 		quit("!Overlay.SetText: invalid overlay ID specified");
-	int xx = game_to_data_coord(_GP(screenover)[ovri].x);
-	int yy = game_to_data_coord(_GP(screenover)[ovri].y);
-
-	// FIXME: a refactor needed!
-	// these calls to RemoveOverlay and CreateOverlay below are potentially dangerous,
-	// because they may allocate new script objects too under certain conditions.
-	// This did not happen because users only had access to custom overlay pointers before,
-	// but now they also may access internal overlays (such as Say text and portrait).
-	const int disp_type = scover->overlayId;
-	RemoveOverlay(scover->overlayId);
-
-	int new_ovrid = CreateTextOverlay(xx, yy, wii, fontid, text_color, get_translation(text), disp_type);
-	if (new_ovrid != disp_type)
-		quit("SetTextOverlay internal error: inconsistent type ids");
-	scover->overlayId = new_ovrid;
+	auto &over = _GP(screenover)[ovri];
+	const int x = over.x;
+	const int y = over.y;
+
+	// TODO: find a nice way to refactor and share these code pieces
+	// from CreateTextOverlay
+	width = data_to_game_coord(width);
+	// allow DisplaySpeechBackground to be shrunk
+	int allow_shrink = (x == OVR_AUTOPLACE) ? 1 : 0;
+
+	// from Overlay_CreateTextCore
+	if (width < 8) width = _GP(play).GetUIViewport().GetWidth() / 2;
+
+	if (text_color == 0) text_color = 16;
+
+	// Recreate overlay image
+	int dummy_x = x, dummy_y = y, adj_x = x, adj_y = y;
+	bool has_alpha = false;
+	// NOTE: we pass text_color negated to let optionally use textwindow (if applicable)
+	// this is a generic ugliness of _display_main args, need to refactor later.
+	Bitmap *image = create_textual_image(get_translation(text), -text_color, 0, dummy_x, dummy_y, adj_x, adj_y,
+										 width, fontid, allow_shrink, has_alpha);
+
+	// Update overlay properties
+	over.SetImage(image);
+	over.SetAlphaChannel(has_alpha);
+	over.x = x;
+	over.y = y;
+	over.offsetX = adj_x - dummy_x;
+	over.offsetY = adj_y - dummy_y;
+	over.ddb = nullptr; // is generated during first draw pass
 }
 
 int Overlay_GetX(ScriptOverlay *scover) {


Commit: 300379a2d64f00e598648224492554e3fb0def11
    https://github.com/scummvm/scummvm/commit/300379a2d64f00e598648224492554e3fb0def11
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Engine: ScreenOverlay.SetImage() accepts offset as arguments

+ Fixed overlays losing offsets when restoring a save.

>From upstream 2002caf32882ab28accd544369c9991675a0dcb1

Changed paths:
    engines/ags/engine/ac/overlay.cpp
    engines/ags/engine/ac/screen_overlay.cpp
    engines/ags/engine/ac/screen_overlay.h
    engines/ags/engine/game/savegame_components.cpp
    engines/ags/engine/game/savegame_v321.cpp


diff --git a/engines/ags/engine/ac/overlay.cpp b/engines/ags/engine/ac/overlay.cpp
index c9fed2bd747..0f4a76aa4fd 100644
--- a/engines/ags/engine/ac/overlay.cpp
+++ b/engines/ags/engine/ac/overlay.cpp
@@ -81,12 +81,8 @@ void Overlay_SetText(ScriptOverlay *scover, int width, int fontid, int text_colo
 										 width, fontid, allow_shrink, has_alpha);
 
 	// Update overlay properties
-	over.SetImage(image);
+	over.SetImage(image, adj_x - dummy_x, adj_y - dummy_y);
 	over.SetAlphaChannel(has_alpha);
-	over.x = x;
-	over.y = y;
-	over.offsetX = adj_x - dummy_x;
-	over.offsetY = adj_y - dummy_y;
 	over.ddb = nullptr; // is generated during first draw pass
 }
 
@@ -390,17 +386,15 @@ size_t add_screen_overlay_impl(bool roomlayer, int x, int y, int type, int sprnu
 	}
 	ScreenOverlay over;
 	if (piccy) {
-		over.SetImage(piccy);
+		over.SetImage(piccy, pic_offx, pic_offy);
 		over.SetAlphaChannel(has_alpha);
 	} else {
-		over.SetSpriteNum(sprnum);
+		over.SetSpriteNum(sprnum, pic_offx, pic_offy);
 		over.SetAlphaChannel((_GP(game).SpriteInfos[sprnum].Flags & SPF_ALPHACHANNEL) != 0);
 	}
 	over.ddb = nullptr; // is generated during first draw pass
 	over.x = x;
 	over.y = y;
-	over.offsetX = pic_offx;
-	over.offsetY = pic_offy;
 	// by default draw speech and portraits over GUI, and the rest under GUI
 	over.zorder = (roomlayer || type == OVER_TEXTMSG || type == OVER_PICTURE || type == OVER_TEXTSPEECH) ?
 		INT_MAX : INT_MIN;
diff --git a/engines/ags/engine/ac/screen_overlay.cpp b/engines/ags/engine/ac/screen_overlay.cpp
index 8a286b47b0c..37ca7ee4ece 100644
--- a/engines/ags/engine/ac/screen_overlay.cpp
+++ b/engines/ags/engine/ac/screen_overlay.cpp
@@ -35,11 +35,12 @@ Bitmap *ScreenOverlay::GetImage() const {
 		_pic.get();
 }
 
-void ScreenOverlay::SetImage(Shared::Bitmap *pic) {
+void ScreenOverlay::SetImage(Shared::Bitmap *pic, int offx, int offy) {
 	_flags &= ~kOver_SpriteReference;
 	_pic.reset(pic);
 	_sprnum = -1;
-	offsetX = offsetY = 0;
+	offsetX = offx;
+	offsetY = offy;
 	scaleWidth = scaleHeight = 0;
 	const auto *img = GetImage();
 	if (img) {
@@ -49,11 +50,12 @@ void ScreenOverlay::SetImage(Shared::Bitmap *pic) {
 	MarkChanged();
 }
 
-void ScreenOverlay::SetSpriteNum(int sprnum) {
+void ScreenOverlay::SetSpriteNum(int sprnum, int offx, int offy) {
 	_flags |= kOver_SpriteReference;
 	_pic.reset();
 	_sprnum = sprnum;
-	offsetX = offsetY = 0;
+	offsetX = offx;
+	offsetY = offy;
 	scaleWidth = scaleHeight = 0;
 	const auto *img = GetImage();
 	if (img) {
diff --git a/engines/ags/engine/ac/screen_overlay.h b/engines/ags/engine/ac/screen_overlay.h
index f38f730dcd9..9827c696dee 100644
--- a/engines/ags/engine/ac/screen_overlay.h
+++ b/engines/ags/engine/ac/screen_overlay.h
@@ -99,8 +99,8 @@ struct ScreenOverlay {
 	int GetSpriteNum() const {
 		return _sprnum;
 	}
-	void SetImage(Shared::Bitmap *pic);
-	void SetSpriteNum(int sprnum);
+	void SetImage(Shared::Bitmap *pic, int offx = 0, int offy = 0);
+	void SetSpriteNum(int sprnum, int offx = 0, int offy = 0);
 	// Tells if Overlay has graphically changed recently
 	bool HasChanged() const {
 		return _hasChanged;
diff --git a/engines/ags/engine/game/savegame_components.cpp b/engines/ags/engine/game/savegame_components.cpp
index a453950f589..ecda89b5d0c 100644
--- a/engines/ags/engine/game/savegame_components.cpp
+++ b/engines/ags/engine/game/savegame_components.cpp
@@ -773,7 +773,7 @@ HSaveError ReadOverlays(Stream *in, int32_t cmp_ver, const PreservedParams & /*p
 		bool has_bitmap;
 		over.ReadFromFile(in, has_bitmap, cmp_ver);
 		if (has_bitmap)
-			over.SetImage(read_serialized_bitmap(in));
+			over.SetImage(read_serialized_bitmap(in), over.offsetX, over.offsetY);
 		if (over.scaleWidth <= 0 || over.scaleHeight <= 0) {
 			over.scaleWidth = over.GetImage()->GetWidth();
 			over.scaleHeight = over.GetImage()->GetHeight();
diff --git a/engines/ags/engine/game/savegame_v321.cpp b/engines/ags/engine/game/savegame_v321.cpp
index b8b11e6dfd0..efbed45c027 100644
--- a/engines/ags/engine/game/savegame_v321.cpp
+++ b/engines/ags/engine/game/savegame_v321.cpp
@@ -286,7 +286,7 @@ static void restore_game_overlays(Stream *in) {
 	ReadOverlays_Aligned(in, has_bitmap, num_overs);
 	for (size_t i = 0; i < num_overs; ++i) {
 		if (has_bitmap[i])
-			_GP(screenover)[i].SetImage(read_serialized_bitmap(in));
+			_GP(screenover)[i].SetImage(read_serialized_bitmap(in), _GP(screenover)[i].offsetX, _GP(screenover)[i].offsetY);
 	}
 }
 


Commit: da147138d48fb5d10b202b384b5f39bd76f40825
    https://github.com/scummvm/scummvm/commit/da147138d48fb5d10b202b384b5f39bd76f40825
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Script API: removed a rule that Viewport and Camera 0 can't be deleted

This was a silly thing to have, and actually it was not
implemented correctly, as a cam or viewport with 0th index is not
necessarily the "primary" one (set as Game.Camera and
Screen.Viewport). The logic was rather weak there anyway.

>From upstream eb90cfa46251d595f8b8f8c5f29ea720d2833038

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


diff --git a/engines/ags/engine/ac/game_state.cpp b/engines/ags/engine/ac/game_state.cpp
index 9378037f874..58b0fdbac31 100644
--- a/engines/ags/engine/ac/game_state.cpp
+++ b/engines/ags/engine/ac/game_state.cpp
@@ -268,8 +268,7 @@ ScriptViewport *GameState::RegisterRoomViewport(int index, int32_t handle) {
 }
 
 void GameState::DeleteRoomViewport(int index) {
-	// NOTE: viewport 0 can not be deleted
-	if (index <= 0 || (size_t)index >= _roomViewports.size())
+	if (index < 0 || (size_t)index >= _roomViewports.size())
 		return;
 	auto handle = _scViewportHandles[index];
 	auto scobj = const_cast<ScriptViewport*>((const ScriptViewport*)ccGetObjectAddressFromHandle(handle));
@@ -328,8 +327,7 @@ ScriptCamera *GameState::RegisterRoomCamera(int index, int32_t handle) {
 }
 
 void GameState::DeleteRoomCamera(int index) {
-	// NOTE: camera 0 can not be deleted
-	if (index <= 0 || (size_t)index >= _roomCameras.size())
+	if (index < 0 || (size_t)index >= _roomCameras.size())
 		return;
 	auto handle = _scCameraHandles[index];
 	auto scobj = const_cast<ScriptCamera*>((const ScriptCamera*)ccGetObjectAddressFromHandle(handle));


Commit: 5ae3427f9db24fa1a291c5a1ba40385fe635dd5e
    https://github.com/scummvm/scummvm/commit/5ae3427f9db24fa1a291c5a1ba40385fe635dd5e
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Common: simplified MFLUtil::ReadEncInt32(), use conditional function

Apparently, this was already done once in b6b8701, but then broken soon after by a merge 22e3a83 (years ago).
>From upstream 50800e0e2aca0b7678af4a24bd6322d82261760f

Changed paths:
    engines/ags/shared/util/multi_file_lib.cpp


diff --git a/engines/ags/shared/util/multi_file_lib.cpp b/engines/ags/shared/util/multi_file_lib.cpp
index b4c0364ea95..745e921a278 100644
--- a/engines/ags/shared/util/multi_file_lib.cpp
+++ b/engines/ags/shared/util/multi_file_lib.cpp
@@ -401,11 +401,7 @@ int8_t MFLUtil::ReadEncInt8(Stream *in, int &rand_val) {
 int32_t MFLUtil::ReadEncInt32(Stream *in, int &rand_val) {
 	int val;
 	ReadEncArray(&val, sizeof(int32_t), 1, in, rand_val);
-#if AGS_PLATFORM_ENDIAN_BIG
-	return AGS::Shared::BitByteOperations::SwapBytesInt32(val);
-#else
-	return val;
-#endif
+	return BBOp::Int32FromLE(val);
 }
 
 void MFLUtil::ReadEncString(char *buffer, size_t max_len, Stream *in, int &rand_val) {


Commit: f2a41c84769ac2cfb6399999307a91899f618c2b
    https://github.com/scummvm/scummvm/commit/f2a41c84769ac2cfb6399999307a91899f618c2b
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-01-20T14:14:56Z

Commit Message:
AGS: Updated build version (3.6.0.36)

>From upstream 17503d7bd066e8bd4a5af490c9ab053a47e4468f

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 c0253430312..3509f3f5e9f 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.35"
+#define ACI_VERSION_STR      "3.6.0.36"
 #if defined (RC_INVOKED) // for MSVC resource compiler
-#define ACI_VERSION_MSRC_DEF  3.6.0.35
+#define ACI_VERSION_MSRC_DEF  3.6.0.36
 #endif
 
 #define SPECIAL_VERSION ""




More information about the Scummvm-git-logs mailing list