[Scummvm-git-logs] scummvm master -> 012ca99120c53bd20e96e172cefcf9c8cb2f9c8f

dreammaster noreply at scummvm.org
Sat Apr 23 04:41:46 UTC 2022


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

Summary:
09d4069428 AGS: Share animation cycling algo between Buttons and RoomObjects
f5c7246752 AGS: Use CycleViewAnim() for character's animation
cf397751a1 AGS: Fixed potential crash with less room bg frames... again
809cc413da AGS: Fixed crash in prepare_roomview_frame() on no camera link
229676c239 AGS: Skip WaitMouse/Key* when skipping cutscene
5cc7daedfe AGS: Use outline fonts too when getting outlined text width / height
62574f8eda AGS: Use outlined width/height when arranging text on GUI
f2f80939ad AGS: Don't do text's v-alignment hack in the new games (> 3.6.0)
623e895971 AGS: Changed text alignment switches to use kGameVersion_360_21
7ebdd8f304 AGS: Removed redundant <3 params check from DoRunScriptFuncCantBlock
e95969dc16 AGS: Fixed translation keys ascii->utf8 conversion
f9921b0112 AGS: Fixed negative number save slots are accepted as valid
dec832ad4f AGS: Refactor GUISlider::Draw(), make it easier to understand
7dab6a4964 AGS: Exclude Sliders from clipping GUI controls rule
f5b603f16e AGS: Updated build version (3.6.0.21), set version as Beta
0e283a9a87 AGS: Removed guis list param from ResortGUI (useless)
012ca99120 AGS: In built-in guis renamed local args hiding global variables


Commit: 09d4069428ae889fbf4fe32e338803a72926d10b
    https://github.com/scummvm/scummvm/commit/09d4069428ae889fbf4fe32e338803a72926d10b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:05:04-07:00

Commit Message:
AGS: Share animation cycling algo between Buttons and RoomObjects

>From upstream fd28a2548e39c85478d98e26b51713cd687acada

Changed paths:
    engines/ags/engine/ac/button.cpp
    engines/ags/engine/ac/button.h
    engines/ags/engine/ac/object.cpp
    engines/ags/engine/ac/object.h
    engines/ags/engine/ac/room_object.cpp
    engines/ags/engine/ac/room_object.h
    engines/ags/engine/ac/runtime_defines.h
    engines/ags/engine/gui/animating_gui_button.h
    engines/ags/engine/main/game_run.cpp


diff --git a/engines/ags/engine/ac/button.cpp b/engines/ags/engine/ac/button.cpp
index f8e09f35dbb..6f5fe9feb6d 100644
--- a/engines/ags/engine/ac/button.cpp
+++ b/engines/ags/engine/ac/button.cpp
@@ -25,6 +25,7 @@
 #include "ags/shared/ac/view.h"
 #include "ags/shared/ac/game_setup_struct.h"
 #include "ags/engine/ac/global_translation.h"
+#include "ags/engine/ac/object.h"
 #include "ags/engine/ac/string.h"
 #include "ags/engine/ac/view_frame.h"
 #include "ags/engine/debugging/debug_log.h"
@@ -43,6 +44,15 @@ using namespace AGS::Shared;
 
 // *** BUTTON FUNCTIONS
 
+// Update the actual button's image from the current animation frame
+void UpdateButtonState(const AnimatingGUIButton &abtn) {
+	_GP(guibuts)[abtn.buttonid].Image = _GP(views)[abtn.view].loops[abtn.loop].frames[abtn.frame].pic;
+	_GP(guibuts)[abtn.buttonid].CurrentImage = _GP(guibuts)[abtn.buttonid].Image;
+	_GP(guibuts)[abtn.buttonid].PushedImage = 0;
+	_GP(guibuts)[abtn.buttonid].MouseOverImage = 0;
+	_GP(guibuts)[abtn.buttonid].NotifyParentChanged();
+}
+
 void Button_AnimateEx(GUIButton *butt, int view, int loop, int speed, int repeat, int blocking, int direction, int sframe) {
 	int guin = butt->ParentId;
 	int objn = butt->Id;
@@ -73,24 +83,17 @@ void Button_AnimateEx(GUIButton *butt, int view, int loop, int speed, int repeat
 	// if it's already animating, stop it
 	FindAndRemoveButtonAnimation(guin, objn);
 
-	// Prepare button
-	int buttonId = _GP(guis)[guin].GetControlID(objn);
-	_GP(guibuts)[buttonId].PushedImage = 0;
-	_GP(guibuts)[buttonId].MouseOverImage = 0;
-
 	// reverse animation starts at the *previous frame*
 	if (direction) {
 		if (--sframe < 0)
 			sframe = _GP(views)[view].loops[loop].numFrames - (-sframe);
-		sframe++; // set on next frame, first call to Update will decrement
-	} else {
-		sframe--; // set on prev frame, first call to Update will increment
 	}
 
+	int but_id = _GP(guis)[guin].GetControlID(objn);
 	AnimatingGUIButton abtn;
 	abtn.ongui = guin;
 	abtn.onguibut = objn;
-	abtn.buttonid = buttonId;
+	abtn.buttonid = but_id;
 	abtn.view = view;
 	abtn.loop = loop;
 	abtn.speed = speed;
@@ -98,14 +101,11 @@ void Button_AnimateEx(GUIButton *butt, int view, int loop, int speed, int repeat
 	abtn.blocking = blocking;
 	abtn.direction = direction;
 	abtn.frame = sframe;
-	abtn.wait = 0;
+	abtn.wait = abtn.speed + _GP(views)[abtn.view].loops[abtn.loop].frames[abtn.frame].speed;
 	_GP(animbuts).push_back(abtn);
-	// launch into the first frame
-	if (UpdateAnimatingButton(_GP(animbuts).size() - 1)) {
-		debug_script_warn("AnimateButton: no frames to animate (button: %s, view: %d, loop: %d)",
-			butt->GetScriptName().GetCStr(), view, loop);
-		StopButtonAnimation(_GP(animbuts).size() - 1);
-	}
+	// launch into the first frame, and play the first frame's sound
+	UpdateButtonState(abtn);
+	CheckViewFrame(abtn.view, abtn.loop, abtn.frame);
 
 	// Blocking animate
 	if (blocking)
@@ -243,59 +243,19 @@ void AddButtonAnimation(const AnimatingGUIButton &abtn) {
 }
 
 // returns 1 if animation finished
-int UpdateAnimatingButton(int bu) {
+bool UpdateAnimatingButton(int bu) {
 	AnimatingGUIButton &abtn = _GP(animbuts)[bu];
-
 	if (abtn.wait > 0) {
 		abtn.wait--;
-		return 0;
-	}
-	ViewStruct *tview = &_GP(views)[abtn.view];
-
-	if (abtn.direction) { // backwards
-		abtn.frame--;
-		if (abtn.frame < 0) {
-			if ((abtn.loop > 0) && tview->loops[abtn.loop - 1].RunNextLoop()) {
-				// go to next loop
-				abtn.loop--;
-				abtn.frame = tview->loops[abtn.loop].numFrames - 1;
-			} else if (abtn.repeat) {
-				// multi-loop anim, go back
-				while (tview->loops[abtn.loop].RunNextLoop())
-					abtn.loop++;
-				abtn.frame = tview->loops[abtn.loop].numFrames - 1;
-			} else
-				return 1;
-		}
-	} else { // forwards
-		abtn.frame++;
-		if (abtn.frame >= tview->loops[abtn.loop].numFrames) {
-			if (tview->loops[abtn.loop].RunNextLoop()) {
-				// go to next loop
-				abtn.loop++;
-				abtn.frame = 0;
-			} else if (abtn.repeat) {
-				abtn.frame = 0;
-				// multi-loop anim, go back
-				while ((abtn.loop > 0) &&
-					(tview->loops[abtn.loop - 1].RunNextLoop()))
-					abtn.loop--;
-			} else
-				return 1;
-		}
+		return true;
 	}
-
+	if (!CycleViewAnim(abtn.view, abtn.loop, abtn.frame, !abtn.direction,
+		abtn.repeat != 0 ? ANIM_REPEAT : ANIM_ONCE))
+		return false;
 	CheckViewFrame(abtn.view, abtn.loop, abtn.frame);
-
-	// update the button's image
-	_GP(guibuts)[abtn.buttonid].Image = tview->loops[abtn.loop].frames[abtn.frame].pic;
-	_GP(guibuts)[abtn.buttonid].CurrentImage = _GP(guibuts)[abtn.buttonid].Image;
-	_GP(guibuts)[abtn.buttonid].PushedImage = 0;
-	_GP(guibuts)[abtn.buttonid].MouseOverImage = 0;
-	_GP(guibuts)[abtn.buttonid].NotifyParentChanged();
-
-	abtn.wait = abtn.speed + tview->loops[abtn.loop].frames[abtn.frame].speed;
-	return 0;
+	abtn.wait = abtn.speed + _GP(views)[abtn.view].loops[abtn.loop].frames[abtn.frame].speed;
+	UpdateButtonState(abtn);
+	return true;
 }
 
 void StopButtonAnimation(int idxn) {
diff --git a/engines/ags/engine/ac/button.h b/engines/ags/engine/ac/button.h
index 733d0769f34..43fe8603fcd 100644
--- a/engines/ags/engine/ac/button.h
+++ b/engines/ags/engine/ac/button.h
@@ -48,7 +48,8 @@ void        Button_SetPushedGraphic(GUIButton *guil, int slotn);
 int         Button_GetTextColor(GUIButton *butt);
 void        Button_SetTextColor(GUIButton *butt, int newcol);
 
-int         UpdateAnimatingButton(int bu);
+// Update button's animation, returns whether the animation continues
+bool        UpdateAnimatingButton(int bu);
 size_t      GetAnimatingButtonCount();
 AnimatingGUIButton *GetAnimatingButtonByIndex(int idxn);
 void        AddButtonAnimation(const AnimatingGUIButton &abtn);
diff --git a/engines/ags/engine/ac/object.cpp b/engines/ags/engine/ac/object.cpp
index 15c98dcc5ac..a9a84a12d5c 100644
--- a/engines/ags/engine/ac/object.cpp
+++ b/engines/ags/engine/ac/object.cpp
@@ -40,6 +40,7 @@
 #include "ags/engine/ac/route_finder.h"
 #include "ags/engine/gfx/graphics_driver.h"
 #include "ags/shared/ac/view.h"
+#include "ags/engine/ac/view_frame.h"
 #include "ags/shared/gfx/bitmap.h"
 #include "ags/shared/gfx/gfx_def.h"
 #include "ags/shared/gui/gui_main.h"
@@ -552,6 +553,72 @@ int check_click_on_object(int roomx, int roomy, int mood) {
 	return 1;
 }
 
+// General view animation algorithm: find next loop and frame, depending on anim settings
+bool CycleViewAnim(int view, uint16_t &o_loop, uint16_t &o_frame, bool forwards, int repeat) {
+	// Allow multi-loop repeat: idk why, but original engine behavior
+	// was to only check this for forward animation, not backward
+	const bool multi_loop_repeat = !forwards || (_GP(play).no_multiloop_repeat == 0);
+
+	ViewStruct *aview = &_GP(views)[view];
+	uint16_t loop = o_loop;
+	uint16_t frame = o_frame;
+	bool done = false;
+
+	if (forwards) {
+		if (frame + 1 >= aview->loops[loop].numFrames) { // Reached the last frame in the loop, find out what to do next
+			if (aview->loops[loop].RunNextLoop()) {
+				// go to next loop
+				loop++;
+				frame = 0;
+			} else {
+				// If either ANIM_REPEAT or ANIM_ONCERESET:
+				// reset to the beginning of a multiloop animation
+				if (repeat != ANIM_ONCE) {
+					frame = 0;
+					if (multi_loop_repeat)
+						while ((loop > 0) && (aview->loops[loop - 1].RunNextLoop()))
+							loop--;
+				} else { // if ANIM_ONCE, stop at the last frame
+					frame = aview->loops[loop].numFrames - 1;
+				}
+
+				if (repeat != ANIM_REPEAT) // either ANIM_ONCE or ANIM_ONCERESET
+					done = true; // finished animation
+			}
+		} else
+			frame++;
+	} else // backwards
+	{
+		if (frame == 0) { // Reached the first frame in the loop, find out what to do next
+			if ((loop > 0) && aview->loops[loop - 1].RunNextLoop()) {
+				// go to next loop
+				loop--;
+				frame = aview->loops[loop].numFrames - 1;
+			} else {
+				// If either ANIM_REPEAT or ANIM_ONCERESET:
+				// reset to the beginning of a multiloop animation
+				if (repeat != ANIM_ONCE) {
+					if (multi_loop_repeat)
+						while (aview->loops[loop].RunNextLoop())
+							loop++;
+					frame = aview->loops[loop].numFrames - 1;
+				} else { // if ANIM_ONCE, stop at the first frame
+					frame = 0;
+				}
+
+				if (repeat != ANIM_REPEAT) // either ANIM_ONCE or ANIM_ONCERESET
+					done = true; // finished animation
+			}
+		} else
+			frame--;
+	}
+
+	// Update object values
+	o_loop = loop;
+	o_frame = frame;
+	return !done; // have we finished animating?
+}
+
 //=============================================================================
 //
 // Script API Functions
diff --git a/engines/ags/engine/ac/object.h b/engines/ags/engine/ac/object.h
index b7eb95aafb9..28fe1c010e6 100644
--- a/engines/ags/engine/ac/object.h
+++ b/engines/ags/engine/ac/object.h
@@ -102,6 +102,10 @@ int     is_pos_in_sprite(int xx, int yy, int arx, int ary, Shared::Bitmap *sprit
 // X and Y co-ordinates must be in native format
 // X and Y are ROOM coordinates
 int     check_click_on_object(int roomx, int roomy, int mood);
+// General view animation algorithm: find next loop and frame, depending on anim settings;
+// loop and frame values are passed by reference and will be updated;
+// returns whether the animation should continue.
+bool    CycleViewAnim(int view, uint16_t &loop, uint16_t &frame, bool forwards, int repeat);
 
 } // namespace AGS3
 
diff --git a/engines/ags/engine/ac/room_object.cpp b/engines/ags/engine/ac/room_object.cpp
index 9f95b150aba..89ba5239262 100644
--- a/engines/ags/engine/ac/room_object.cpp
+++ b/engines/ags/engine/ac/room_object.cpp
@@ -24,6 +24,7 @@
 #include "ags/shared/ac/common_defines.h"
 #include "ags/shared/ac/game_setup_struct.h"
 #include "ags/engine/ac/game_state.h"
+#include "ags/engine/ac/object.h"
 #include "ags/engine/ac/runtime_defines.h"
 #include "ags/engine/ac/view_frame.h"
 #include "ags/engine/debugging/debug_log.h"
@@ -79,24 +80,15 @@ void RoomObject::UpdateCyclingView(int ref_id) {
 	if (cycling == 0) return;
 	if (view == (uint16_t)-1) return;
 	if (wait > 0) {
-		wait--;
-		return;
+		wait--; return;
 	}
 
-	if (cycling >= ANIM_BACKWARDS) {
-
-		update_cycle_view_backwards();
-
-	} else {  // Animate forwards
-
-		update_cycle_view_forwards();
-
-	}  // end if forwards
+	cycling = CycleViewAnim(view, loop, frame, cycling < ANIM_BACKWARDS, cycling % ANIM_BACKWARDS);
 
 	ViewFrame *vfptr = &_GP(views)[view].loops[loop].frames[frame];
 	if (vfptr->pic > UINT16_MAX)
 		debug_script_warn("Warning: object's (id %d) sprite %d is outside of internal range (%d), reset to 0",
-		                  ref_id, vfptr->pic, UINT16_MAX);
+			ref_id, vfptr->pic, UINT16_MAX);
 	num = Math::InRangeOrDef<uint16_t>(vfptr->pic, 0);
 
 	if (cycling == 0)
@@ -106,54 +98,6 @@ void RoomObject::UpdateCyclingView(int ref_id) {
 	CheckViewFrame(view, loop, frame);
 }
 
-
-void RoomObject::update_cycle_view_forwards() {
-	frame++;
-	if (frame >= _GP(views)[view].loops[loop].numFrames) {
-		// go to next loop thing
-		if (_GP(views)[view].loops[loop].RunNextLoop()) {
-			if (loop + 1 >= _GP(views)[view].numLoops)
-				quit("!Last loop in a view requested to move to next loop");
-			loop++;
-			frame = 0;
-		} else if (cycling % ANIM_BACKWARDS == ANIM_ONCE) {
-			// leave it on the last frame
-			cycling = 0;
-			frame--;
-		} else {
-			if (_GP(play).no_multiloop_repeat == 0) {
-				// multi-loop anims, go back to start of it
-				while ((loop > 0) &&
-				        (_GP(views)[view].loops[loop - 1].RunNextLoop()))
-					loop--;
-			}
-			if (cycling % ANIM_BACKWARDS == ANIM_ONCERESET)
-				cycling = 0;
-			frame = 0;
-		}
-	}
-}
-
-void RoomObject::update_cycle_view_backwards() {
-	// animate backwards
-	if (frame > 0) {
-		frame--;
-	} else {
-		if ((loop > 0) &&
-		        (_GP(views)[view].loops[loop - 1].RunNextLoop())) {
-			// If it's a Go-to-next-loop on the previous one, then go back
-			loop--;
-			frame = _GP(views)[view].loops[loop].numFrames - 1;
-		} else if (cycling % ANIM_BACKWARDS == ANIM_ONCE) {
-			// leave it on the first frame
-			cycling = 0;
-			frame = 0;
-		} else { // repeating animation
-			frame = _GP(views)[view].loops[loop].numFrames - 1;
-		}
-	}
-}
-
 void RoomObject::ReadFromSavegame(Stream *in, int save_ver) {
 	x = in->ReadInt32();
 	y = in->ReadInt32();
diff --git a/engines/ags/engine/ac/room_object.h b/engines/ags/engine/ac/room_object.h
index 56242364eef..8cd18bf1f72 100644
--- a/engines/ags/engine/ac/room_object.h
+++ b/engines/ags/engine/ac/room_object.h
@@ -79,8 +79,6 @@ struct RoomObject {
 	}
 
 	void UpdateCyclingView(int ref_id);
-	void update_cycle_view_forwards();
-	void update_cycle_view_backwards();
 
 	void ReadFromSavegame(Shared::Stream *in, int save_ver);
 	void WriteToSavegame(Shared::Stream *out) const;
diff --git a/engines/ags/engine/ac/runtime_defines.h b/engines/ags/engine/ac/runtime_defines.h
index cc127f5fed6..dc75ab8e6b8 100644
--- a/engines/ags/engine/ac/runtime_defines.h
+++ b/engines/ags/engine/ac/runtime_defines.h
@@ -90,8 +90,11 @@ const int LegacyRoomVolumeFactor = 30;
 #define CHANIM_REPEAT    2
 #define CHANIM_BACKWARDS 4
 #define ANIM_BACKWARDS 10
+// Animates once and stops at the *last* frame
 #define ANIM_ONCE      1
+// Animates infinitely until stopped by command
 #define ANIM_REPEAT    2
+// Animates once and stops, resetting to the very first frame
 #define ANIM_ONCERESET 3
 #define FONT_STATUSBAR  0
 #define FONT_NORMAL     _GP(play).normal_font
diff --git a/engines/ags/engine/gui/animating_gui_button.h b/engines/ags/engine/gui/animating_gui_button.h
index c6290318a57..00caa64f78d 100644
--- a/engines/ags/engine/gui/animating_gui_button.h
+++ b/engines/ags/engine/gui/animating_gui_button.h
@@ -19,9 +19,13 @@
  *
  */
 
+// Description of a button animation; stored separately from the GUI button.
+//
+
 #ifndef AGS_ENGINE_GUI_ANIMATING_GUI_BUTTON_H
 #define AGS_ENGINE_GUI_ANIMATING_GUI_BUTTON_H
 
+#include "ags/shared/core/types.h"
 #include "ags/engine/ac/runtime_defines.h"
 
 namespace AGS3 {
@@ -38,7 +42,7 @@ struct AnimatingGUIButton {
 	// index into _GP(guibuts) array, GUI, button
 	short buttonid = 0, ongui = 0, onguibut = 0;
 	// current animation status
-	short view = 0, loop = 0, frame = 0;
+	uint16_t view = 0, loop = 0, frame = 0;
 	short speed = 0, repeat = 0, blocking = 0,
 		direction = 0, wait = 0;
 
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index c2d559afae1..ab6f976417f 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -594,7 +594,7 @@ static void game_loop_update_animated_buttons() {
 	// this bit isn't in update_stuff because it always needs to
 	// happen, even when the game is paused
 	for (size_t i = 0; i < GetAnimatingButtonCount(); ++i) {
-		if (UpdateAnimatingButton(i)) {
+		if (!UpdateAnimatingButton(i)) {
 			StopButtonAnimation(i);
 			i--;
 		}


Commit: f5c7246752f875d4a81fff751373a27c03308359
    https://github.com/scummvm/scummvm/commit/f5c7246752f875d4a81fff751373a27c03308359
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:15:47-07:00

Commit Message:
AGS: Use CycleViewAnim() for character's animation

>From upstream 814d489f3a67cac4956b6590618377693571add9

Changed paths:
    engines/ags/engine/ac/character_info_engine.cpp
    engines/ags/shared/ac/character_info.h


diff --git a/engines/ags/engine/ac/character_info_engine.cpp b/engines/ags/engine/ac/character_info_engine.cpp
index 14fdae64f36..5418cac2e28 100644
--- a/engines/ags/engine/ac/character_info_engine.cpp
+++ b/engines/ags/engine/ac/character_info_engine.cpp
@@ -28,6 +28,7 @@
 #include "ags/engine/ac/global_character.h"
 #include "ags/engine/ac/global_game.h"
 #include "ags/engine/ac/math.h"
+#include "ags/engine/ac/object.h"
 #include "ags/engine/ac/view_frame.h"
 #include "ags/engine/debugging/debug_log.h"
 #include "ags/shared/game/room_struct.h"
@@ -290,52 +291,21 @@ int CharacterInfo::update_character_animating(int &aa, int &doing_nothing) {
 			//continue;
 			return RETURN_CONTINUE;
 		} else {
-			int oldframe = frame;
-			if (animating & CHANIM_BACKWARDS) {
-				frame--;
-				if (frame < 0) {
-					// if the previous loop is a Run Next Loop one, go back to it
-					if ((loop > 0) &&
-					        (_GP(views)[view].loops[loop - 1].RunNextLoop())) {
-
-						loop--;
-						frame = _GP(views)[view].loops[loop].numFrames - 1;
-					} else if (animating & CHANIM_REPEAT) {
-
-						frame = _GP(views)[view].loops[loop].numFrames - 1;
-
-						while (_GP(views)[view].loops[loop].RunNextLoop()) {
-							loop++;
-							frame = _GP(views)[view].loops[loop].numFrames - 1;
-						}
-					} else {
-						frame++;
-						animating = 0;
-					}
-				}
-			} else
-				frame++;
+			// Normal view animation
+			const int oldframe = frame;
 
 			if ((aa == _G(char_speaking)) &&
-			        (_GP(play).speech_in_post_state ||
-			         ((!_GP(play).speech_has_voice) &&
-			          (_GP(play).close_mouth_speech_time > 0) &&
-			          (_GP(play).messagetime < _GP(play).close_mouth_speech_time)))) {
+				(_GP(play).speech_in_post_state ||
+				((!_GP(play).speech_has_voice) &&
+					(_GP(play).close_mouth_speech_time > 0) &&
+					(_GP(play).messagetime < _GP(play).close_mouth_speech_time)))) {
 				// finished talking - stop animation
 				animating = 0;
 				frame = 0;
-			}
-
-			if (frame >= _GP(views)[view].loops[loop].numFrames) {
-
-				if (_GP(views)[view].loops[loop].RunNextLoop()) {
-					if (loop + 1 >= _GP(views)[view].numLoops)
-						quit("!Animating character tried to overrun last loop in view");
-					loop++;
-					frame = 0;
-				} else if ((animating & CHANIM_REPEAT) == 0) {
-					animating = 0;
-					frame--;
+			} else {
+				if (!CycleViewAnim(view, loop, frame, (animating & CHANIM_BACKWARDS) == 0,
+					(animating & CHANIM_REPEAT) ? ANIM_REPEAT : ANIM_ONCE)) {
+					animating = 0; // finished animating
 					// end of idle anim
 					if (idleleft < 0) {
 						// constant anim, reset (need this cos animating==0)
@@ -347,18 +317,11 @@ int CharacterInfo::update_character_animating(int &aa, int &doing_nothing) {
 							idleleft = idletime;
 						}
 					}
-				} else {
-					frame = 0;
-					// if it's a multi-loop animation, go back to start
-					if (_GP(play).no_multiloop_repeat == 0) {
-						while ((loop > 0) &&
-						        (_GP(views)[view].loops[loop - 1].RunNextLoop()))
-							loop--;
-					}
 				}
 			}
+
 			wait = _GP(views)[view].loops[loop].frames[frame].speed;
-			// idle anim doesn't have speed stored cos animating==0
+			// idle anim doesn't have speed stored cos animating==0 (TODO: investigate why?)
 			if (idleleft < 0)
 				wait += idle_anim_speed;
 			else
diff --git a/engines/ags/shared/ac/character_info.h b/engines/ags/shared/ac/character_info.h
index 9f856544c22..c2b93b34736 100644
--- a/engines/ags/shared/ac/character_info.h
+++ b/engines/ags/shared/ac/character_info.h
@@ -24,6 +24,7 @@
 
 #include "ags/lib/std/vector.h"
 #include "ags/shared/ac/common_defines.h" // constants
+#include "ags/shared/core/types.h"
 
 namespace AGS3 {
 
@@ -93,7 +94,7 @@ struct CharacterInfo {
 	int   index_id;  // used for object functions to know the id
 	short pic_xoffs; // this is fixed in screen coordinates
 	short walkwaitcounter;
-	short loop, frame;
+	uint16_t loop, frame;
 	short walking, animating;
 	short walkspeed, animspeed;
 	short inv[MAX_INV];


Commit: cf397751a152632c6fee4b11dc622d4842a736b0
    https://github.com/scummvm/scummvm/commit/cf397751a152632c6fee4b11dc622d4842a736b0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:18:45-07:00

Commit Message:
AGS: Fixed potential crash with less room bg frames... again

>From upstream e45f87d1196a1c1a05b3e5cc1966c8633314902f

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


diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index 6a60c83ee5a..c791e1c84f2 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -261,6 +261,8 @@ void unload_old_room() {
 		_G(roominst) = nullptr;
 	} else _G(croom)->tsdatasize = 0;
 	memset(&_GP(play).walkable_areas_on[0], 1, MAX_WALK_AREAS + 1);
+	_GP(play).bg_frame = 0;
+	_GP(play).bg_frame_locked = 0;
 	remove_screen_overlay(-1);
 	delete _G(raw_saved_screen);
 	_G(raw_saved_screen) = nullptr;
@@ -469,6 +471,10 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 	_GP(play).anim_background_speed = _GP(thisroom).BgAnimSpeed;
 	_GP(play).bg_anim_delay = _GP(play).anim_background_speed;
 
+	// Fixup the frame index, in case the new room does not have enough background frames
+	if (_GP(play).bg_frame < 0 || _GP(play).bg_frame >= _GP(thisroom).BgFrameCount)
+		_GP(play).bg_frame = 0;
+
 	// do the palette
 	for (cc = 0; cc < 256; cc++) {
 		if (_GP(game).paluses[cc] == PAL_BACKGROUND)
@@ -927,7 +933,7 @@ void new_room(int newnum, CharacterInfo *forchar) {
 
 	load_new_room(newnum, forchar);
 
-	// Reset background frame state (it's not a part of the RoomStatus currently)
+	// Update background frame state (it's not a part of the RoomStatus currently)
 	_GP(play).bg_frame = 0;
 	_GP(play).bg_frame_locked = (_GP(thisroom).Options.Flags & kRoomFlag_BkgFrameLocked) != 0;
 }


Commit: 809cc413da8c900e396b89aa6d40f0119e356c03
    https://github.com/scummvm/scummvm/commit/809cc413da8c900e396b89aa6d40f0119e356c03
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:21:35-07:00

Commit Message:
AGS: Fixed crash in prepare_roomview_frame() on no camera link

>From upstream 0fc94a038cd794046b594afeb8974064c00bdbbd

Changed paths:
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/ac/room.cpp


diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 18c8c50cc51..d9a364e3429 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -448,6 +448,7 @@ void on_mainviewport_changed() {
 
 // Allocates a bitmap for rendering camera/viewport pair (software render mode)
 void prepare_roomview_frame(Viewport *view) {
+	if (!view->GetCamera()) return; // no camera link
 	const int view_index = view->GetID();
 	const Size view_sz = view->GetRect().GetSize();
 	const Size cam_sz = view->GetCamera()->GetRect().GetSize();
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index c791e1c84f2..41358f576ac 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -472,7 +472,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 	_GP(play).bg_anim_delay = _GP(play).anim_background_speed;
 
 	// Fixup the frame index, in case the new room does not have enough background frames
-	if (_GP(play).bg_frame < 0 || _GP(play).bg_frame >= _GP(thisroom).BgFrameCount)
+	if (_GP(play).bg_frame < 0 || _GP(play).bg_frame >= (int)_GP(thisroom).BgFrameCount)
 		_GP(play).bg_frame = 0;
 
 	// do the palette


Commit: 229676c239403047fa5a474dba85b4af2bad5dbc
    https://github.com/scummvm/scummvm/commit/229676c239403047fa5a474dba85b4af2bad5dbc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:26:39-07:00

Commit Message:
AGS: Skip WaitMouse/Key* when skipping cutscene

>From upstream 587214734100d43348bfe6433e8c88b5df5c4915

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


diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index 36aebd0753d..e61775328fe 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -771,6 +771,10 @@ void SetGraphicalVariable(const char *varName, int p_value) {
 }
 
 int WaitImpl(int skip_type, int nloops) {
+	// if skipping cutscene and expecting user input: don't wait at all
+	if (_GP(play).fast_forward && ((skip_type & ~SKIP_AUTOTIMER) != 0))
+		return 0;
+
 	_GP(play).wait_counter = nloops;
 	_GP(play).wait_skipped_by = SKIP_NONE;
 	_GP(play).wait_skipped_by = SKIP_AUTOTIMER; // we set timer flag by default to simplify that case


Commit: 5cc7daedfe584ae6328eabed18ecd8c0bbc40be5
    https://github.com/scummvm/scummvm/commit/5cc7daedfe584ae6328eabed18ecd8c0bbc40be5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:34:19-07:00

Commit Message:
AGS: Use outline fonts too when getting outlined text width / height

>From upstream 1f3960014a313fc7b47dd26274ffd87b96bbbb87

Changed paths:
    engines/ags/engine/ac/display.cpp
    engines/ags/engine/ac/display.h
    engines/ags/shared/font/fonts.cpp
    engines/ags/shared/font/fonts.h
    engines/ags/shared/gui/gui_main.h


diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index 5b371590c58..c39ffb55db7 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -561,10 +561,6 @@ int get_font_outline_padding(int font) {
 	return 0;
 }
 
-int get_text_width_outlined(const char *tex, int font) {
-	return get_text_width(tex, font) + 2 * get_font_outline_padding(font);
-}
-
 void do_corner(Bitmap *ds, int sprn, int x, int y, int offx, int offy) {
 	if (sprn < 0) return;
 	if (_GP(spriteset)[sprn] == nullptr) {
diff --git a/engines/ags/engine/ac/display.h b/engines/ags/engine/ac/display.h
index 238bd4ed83f..bfba7456311 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);
-// 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);
 // Returns the image of a button control on the GUI under given child index
 int get_but_pic(GUIMain *guo, int indx);
diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index e130a33d04b..096074995d6 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -155,6 +155,18 @@ int get_text_width(const char *texx, size_t fontNumber) {
 	return _GP(fonts)[fontNumber].Renderer->GetTextWidth(texx, fontNumber);
 }
 
+int get_text_width_outlined(const char *text, size_t font_number) {
+	if (font_number >= _GP(fonts).size() || !_GP(fonts)[font_number].Renderer)
+		return 0;
+	int self_width = _GP(fonts)[font_number].Renderer->GetTextWidth(text, font_number);
+	int outline = _GP(fonts)[font_number].Info.Outline;
+	if (outline < 0 || static_cast<size_t>(outline) > _GP(fonts).size()) { // FONT_OUTLINE_AUTO or FONT_OUTLINE_NONE
+		return self_width + 2 * _GP(fonts)[font_number].Info.AutoOutlineThickness;
+	}
+	int outline_width = _GP(fonts)[outline].Renderer->GetTextWidth(text, outline);
+	return std::max(self_width, outline_width);
+}
+
 int get_font_outline(size_t font_number) {
 	if (font_number >= _GP(fonts).size())
 		return FONT_OUTLINE_NONE;
@@ -185,8 +197,13 @@ int get_font_height(size_t fontNumber) {
 int get_font_height_outlined(size_t fontNumber) {
 	if (fontNumber >= _GP(fonts).size() || !_GP(fonts)[fontNumber].Renderer)
 		return 0;
-	return _GP(fonts)[fontNumber].Metrics.CompatHeight
-		+ 2 * _GP(fonts)[fontNumber].Info.AutoOutlineThickness;
+	int self_height = _GP(fonts)[fontNumber].Metrics.CompatHeight;
+	int outline = _GP(fonts)[fontNumber].Info.Outline;
+	if (outline < 0 || static_cast<size_t>(outline) > _GP(fonts).size()) { // FONT_OUTLINE_AUTO or FONT_OUTLINE_NONE
+		return self_height + 2 * _GP(fonts)[fontNumber].Info.AutoOutlineThickness;
+	}
+	int outline_height = _GP(fonts)[outline].Metrics.CompatHeight;
+	return std::max(self_height, outline_height);
 }
 
 int get_font_surface_height(size_t fontNumber) {
@@ -225,9 +242,6 @@ int get_text_lines_surf_height(size_t fontNumber, size_t numlines) {
 			2 * _GP(fonts)[fontNumber].Info.AutoOutlineThickness);
 }
 
-// Project-dependent implementation
-extern int get_text_width_outlined(const char *tex, int font);
-
 namespace AGS {
 namespace Shared {
 SplitLines Lines;
diff --git a/engines/ags/shared/font/fonts.h b/engines/ags/shared/font/fonts.h
index 10322040b48..d5bbbb2f35c 100644
--- a/engines/ags/shared/font/fonts.h
+++ b/engines/ags/shared/font/fonts.h
@@ -88,6 +88,8 @@ void ensure_text_valid_for_font(char *text, size_t fontnum);
 int get_font_scaling_mul(size_t fontNumber);
 // Calculate actual width of a line of text
 int get_text_width(const char *texx, size_t fontNumber);
+// Get the maximal width of the given font, with corresponding outlining
+int get_text_width_outlined(const char *text, size_t font_number);
 // Get font's height; this value is used for logical arrangement of UI elements;
 // note that this is a "formal" font height, that may have different value
 // depending on compatibility mode (used when running old games);
diff --git a/engines/ags/shared/gui/gui_main.h b/engines/ags/shared/gui/gui_main.h
index 5c6739a13df..c05611bbadc 100644
--- a/engines/ags/shared/gui/gui_main.h
+++ b/engines/ags/shared/gui/gui_main.h
@@ -246,9 +246,6 @@ extern int get_adjusted_spritewidth(int spr);
 extern int get_adjusted_spriteheight(int spr);
 extern bool is_sprite_alpha(int spr);
 
-// Those function have distinct implementations in Engine and Editor
-extern int get_text_width_outlined(Shared::Bitmap *ds, const char *tex, int font);
-
 #define SET_EIP(x) set_our_eip(x);
 extern void set_eip_guiobj(int eip);
 extern int get_eip_guiobj();


Commit: 62574f8edab3e421763a3880f82df01ba414b2b0
    https://github.com/scummvm/scummvm/commit/62574f8edab3e421763a3880f82df01ba414b2b0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:54:00-07:00

Commit Message:
AGS: Use outlined width/height when arranging text on GUI

>From upstream 8fd4b1b55dc08949e70d295afb4be91d1a26da5c

Changed paths:
    engines/ags/engine/ac/drawing_surface.cpp
    engines/ags/plugins/ags_plugin.cpp
    engines/ags/shared/gui/gui_listbox.cpp
    engines/ags/shared/gui/gui_main.cpp


diff --git a/engines/ags/engine/ac/drawing_surface.cpp b/engines/ags/engine/ac/drawing_surface.cpp
index 3bd8ed4f52a..edf05cc3c5b 100644
--- a/engines/ags/engine/ac/drawing_surface.cpp
+++ b/engines/ags/engine/ac/drawing_surface.cpp
@@ -344,15 +344,8 @@ void DrawingSurface_DrawStringWrapped(ScriptDrawingSurface *sds, int xx, int yy,
 	color_t text_color = sds->currentColour;
 
 	for (size_t i = 0; i < _GP(Lines).Count(); i++) {
-		int drawAtX = xx;
-
-		if (alignment & kMAlignHCenter) {
-			drawAtX = xx + ((wid / 2) - get_text_width(_GP(Lines)[i].GetCStr(), font) / 2);
-		} else if (alignment & kMAlignRight) {
-			drawAtX = (xx + wid) - get_text_width(_GP(Lines)[i].GetCStr(), font);
-		}
-
-		wouttext_outline(ds, drawAtX, yy + linespacing * i, font, text_color, _GP(Lines)[i].GetCStr());
+		GUI::DrawTextAlignedHor(ds, _GP(Lines)[i].GetCStr(), font, text_color,
+			xx, xx + wid - 1, yy + linespacing * i, (FrameAlignment)alignment);
 	}
 
 	sds->FinishedDrawing();
diff --git a/engines/ags/plugins/ags_plugin.cpp b/engines/ags/plugins/ags_plugin.cpp
index f1d8bced28e..007a96302a1 100644
--- a/engines/ags/plugins/ags_plugin.cpp
+++ b/engines/ags/plugins/ags_plugin.cpp
@@ -484,7 +484,7 @@ void IAGSEngine::GetTextExtent(int32 font, const char *text, int32 *width, int32
 	if (width != nullptr)
 		width[0] = get_text_width_outlined(text, font);
 	if (height != nullptr)
-		height[0] = get_font_height(font);
+		height[0] = get_font_height_outlined(font);
 }
 void IAGSEngine::PrintDebugConsole(const char *text) {
 	debug_script_log("[PLUGIN] %s", text);
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index 1f1cffb5bf3..1187c7066f2 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -19,8 +19,9 @@
  *
  */
 
-#include "ags/shared/font/fonts.h"
 #include "ags/shared/gui/gui_listbox.h"
+#include "ags/shared/ac/game_version.h"
+#include "ags/shared/font/fonts.h"
 #include "ags/shared/gui/gui_main.h"
 #include "ags/shared/util/stream.h"
 #include "ags/shared/util/string_utils.h"
@@ -267,7 +268,9 @@ void GUIListBox::OnResized() {
 }
 
 void GUIListBox::UpdateMetrics() {
-	RowHeight = get_font_height(Font) + get_fixed_pixel_size(2);
+	int font_height = (_G(loaded_game_file_version) < kGameVersion_360) ?
+		get_font_height(Font) : get_font_height_outlined(Font);
+	RowHeight = font_height + get_fixed_pixel_size(2); // +1 top/bottom margin
 	VisibleItemCount = Height / RowHeight;
 	if (ItemCount <= VisibleItemCount)
 		TopItem = 0; // reset scroll if all items are visible
diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 51e7c488f49..3ecb5f9b31d 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -649,15 +649,16 @@ void DrawDisabledEffect(Bitmap *ds, const Rect &rc) {
 }
 
 void DrawTextAligned(Bitmap *ds, const char *text, int font, color_t text_color, const Rect &frame, FrameAlignment align) {
-	int text_height = get_font_height(font);
+	int text_height = (_G(loaded_game_file_version) < kGameVersion_360) ?
+		get_font_height(font) : get_font_height_outlined(font);
 	if (align & kMAlignVCenter)
 		text_height++; // CHECKME
-	Rect item = AlignInRect(frame, RectWH(0, 0, get_text_width(text, font), text_height), align);
+	Rect item = AlignInRect(frame, RectWH(0, 0, get_text_width_outlined(text, font), text_height), align);
 	wouttext_outline(ds, item.Left, item.Top, font, text_color, text);
 }
 
 void DrawTextAlignedHor(Bitmap *ds, const char *text, int font, color_t text_color, int x1, int x2, int y, FrameAlignment align) {
-	int x = AlignInHRange(x1, x2, 0, get_text_width(text, font), align);
+	int x = AlignInHRange(x1, x2, 0, get_text_width_outlined(text, font), align);
 	wouttext_outline(ds, x, y, font, text_color, text);
 }
 


Commit: f2f80939adde5b15c6d2f630ba7f46b90e78ec6d
    https://github.com/scummvm/scummvm/commit/f2f80939adde5b15c6d2f630ba7f46b90e78ec6d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T20:57:16-07:00

Commit Message:
AGS: Don't do text's v-alignment hack in the new games (> 3.6.0)

>From upstream ed971d2c5d289db6df31e2a2214771bcb162e5ca

Changed paths:
    engines/ags/shared/gui/gui_main.cpp


diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 3ecb5f9b31d..61f60abe7a9 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -650,9 +650,8 @@ void DrawDisabledEffect(Bitmap *ds, const Rect &rc) {
 
 void DrawTextAligned(Bitmap *ds, const char *text, int font, color_t text_color, const Rect &frame, FrameAlignment align) {
 	int text_height = (_G(loaded_game_file_version) < kGameVersion_360) ?
-		get_font_height(font) : get_font_height_outlined(font);
-	if (align & kMAlignVCenter)
-		text_height++; // CHECKME
+		get_font_height(font) + ((align & kMAlignVCenter) ? 1 : 0) :
+		get_font_height_outlined(font);
 	Rect item = AlignInRect(frame, RectWH(0, 0, get_text_width_outlined(text, font), text_height), align);
 	wouttext_outline(ds, item.Left, item.Top, font, text_color, text);
 }


Commit: 623e895971aee7d37114f014dc81577e06a7686f
    https://github.com/scummvm/scummvm/commit/623e895971aee7d37114f014dc81577e06a7686f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:01:38-07:00

Commit Message:
AGS: Changed text alignment switches to use kGameVersion_360_21

>From upstream 0948e6be65b46df8bd4b183f77655375d6a06e95

Changed paths:
    engines/ags/shared/ac/game_version.h
    engines/ags/shared/gui/gui_listbox.cpp
    engines/ags/shared/gui/gui_main.cpp


diff --git a/engines/ags/shared/ac/game_version.h b/engines/ags/shared/ac/game_version.h
index 9451c15eb1e..d3263644d71 100644
--- a/engines/ags/shared/ac/game_version.h
+++ b/engines/ags/shared/ac/game_version.h
@@ -118,7 +118,10 @@ Format value is defined as AGS version represented as NN,NN,NN,NN.
 Fonts have adjustable outline
 3.6.0.11:
 New font load flags, control backward compatible font behavior
-
+3.6.0.16:
+Idle animation speed, modifiable hotspot names, fixed video frame
+3.6.0.21:
+Some adjustments to gui text alignment.
 */
 
 enum GameDataVersion {
@@ -154,7 +157,8 @@ enum GameDataVersion {
 	kGameVersion_360 = 3060000,
 	kGameVersion_360_11 = 3060011,
 	kGameVersion_360_16 = 3060016,
-	kGameVersion_Current = kGameVersion_360_16
+	kGameVersion_360_21 = 3060021,
+	kGameVersion_Current = kGameVersion_360_21
 };
 
 } // namespace AGS3
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index 1187c7066f2..97276c8af6c 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -268,7 +268,7 @@ void GUIListBox::OnResized() {
 }
 
 void GUIListBox::UpdateMetrics() {
-	int font_height = (_G(loaded_game_file_version) < kGameVersion_360) ?
+	int font_height = (_G(loaded_game_file_version) < kGameVersion_360_21) ?
 		get_font_height(Font) : get_font_height_outlined(Font);
 	RowHeight = font_height + get_fixed_pixel_size(2); // +1 top/bottom margin
 	VisibleItemCount = Height / RowHeight;
diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 61f60abe7a9..7a69e5d96ab 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -649,7 +649,7 @@ void DrawDisabledEffect(Bitmap *ds, const Rect &rc) {
 }
 
 void DrawTextAligned(Bitmap *ds, const char *text, int font, color_t text_color, const Rect &frame, FrameAlignment align) {
-	int text_height = (_G(loaded_game_file_version) < kGameVersion_360) ?
+	int text_height = (_G(loaded_game_file_version) < kGameVersion_360_21) ?
 		get_font_height(font) + ((align & kMAlignVCenter) ? 1 : 0) :
 		get_font_height_outlined(font);
 	Rect item = AlignInRect(frame, RectWH(0, 0, get_text_width_outlined(text, font), text_height), align);


Commit: 7ebdd8f3041bbd212221bc8d7406d83be8fb5420
    https://github.com/scummvm/scummvm/commit/7ebdd8f3041bbd212221bc8d7406d83be8fb5420
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:04:25-07:00

Commit Message:
AGS: Removed redundant <3 params check from DoRunScriptFuncCantBlock

>From upstream f156586fa9d6b99249eaff54230179f784fdec09

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


diff --git a/engines/ags/engine/script/script.cpp b/engines/ags/engine/script/script.cpp
index e995563ac9f..0523e189682 100644
--- a/engines/ags/engine/script/script.cpp
+++ b/engines/ags/engine/script/script.cpp
@@ -288,13 +288,7 @@ static bool DoRunScriptFuncCantBlock(ccInstance *sci, NonBlockingScriptFunction
 		return (false);
 
 	_G(no_blocking_functions)++;
-	int result = 0;
-
-	if (funcToRun->numParameters < 3) {
-		result = sci->CallScriptFunction((const char *)funcToRun->functionName, funcToRun->numParameters, funcToRun->params);
-	} else {
-		quit("DoRunScriptFuncCantBlock called with too many parameters");
-	}
+	int result = sci->CallScriptFunction(funcToRun->functionName, funcToRun->numParameters, funcToRun->params);
 
 	if (_G(abort_engine))
 		return false;


Commit: e95969dc160c2aaccd7734549d6d9d62657f739b
    https://github.com/scummvm/scummvm/commit/e95969dc160c2aaccd7734549d6d9d62657f739b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:06:24-07:00

Commit Message:
AGS: Fixed translation keys ascii->utf8 conversion

>From upstream 607d68522092f8e4c716552635e4213aaf5b4113

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


diff --git a/engines/ags/engine/ac/translation.cpp b/engines/ags/engine/ac/translation.cpp
index e177d09f378..32993d1be9e 100644
--- a/engines/ags/engine/ac/translation.cpp
+++ b/engines/ags/engine/ac/translation.cpp
@@ -124,7 +124,7 @@ bool init_translation(const String &lang, const String &fallback_lang) {
 			StringMap conv_map;
 			std::vector<char> ascii; // ascii buffer
 			for (const auto &item : _GP(trans).Dict) {
-				ascii.resize(item._key.GetLength()); // ascii len will be <= utf-8 len
+				ascii.resize(item._key.GetLength() + 1); // ascii len will be <= utf-8 len
 				StrUtil::ConvertUtf8ToAscii(item._key.GetCStr(), key_enc.GetCStr(), &ascii[0], ascii.size());
 				conv_map.insert(std::make_pair(String(&ascii[0]), item._value));
 			}


Commit: f9921b0112a9dfa3a7900832c7f776a2d77677bb
    https://github.com/scummvm/scummvm/commit/f9921b0112a9dfa3a7900832c7f776a2d77677bb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:13:38-07:00

Commit Message:
AGS: Fixed negative number save slots are accepted as valid

>From upstream 1accb3e3b1ce4e68b950880ad9c0b3880cf1449e

Changed paths:
    engines/ags/engine/ac/global_game.cpp
    engines/ags/engine/ac/runtime_defines.h


diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index e61775328fe..2dd9be420bc 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -186,8 +186,8 @@ void FillSaveList(std::vector<SaveListItem> &saves, size_t max_count) {
 	for (uint idx = 0; idx < saveList.size(); ++idx) {
 		int saveGameSlot = saveList[idx].getSaveSlot();
 
-		// only list games .000 to .099 (to allow higher slots for other perposes)
-		if (saveGameSlot > 99)
+		// only list games .000 to .xxx (to allow higher slots for other perposes)
+		if (saveGameSlot < 0 || saveGameSlot > TOP_LISTEDSAVESLOT)
 			continue;
 
 		String description;
diff --git a/engines/ags/engine/ac/runtime_defines.h b/engines/ags/engine/ac/runtime_defines.h
index dc75ab8e6b8..3899dfb4881 100644
--- a/engines/ags/engine/ac/runtime_defines.h
+++ b/engines/ags/engine/ac/runtime_defines.h
@@ -47,7 +47,12 @@ namespace AGS3 {
 #define DIALOG_NEWTOPIC  12000
 #define MAX_TIMERS       21
 #define MAX_PARSED_WORDS 15
+// how many saves may be listed at once
 #define MAXSAVEGAMES     50
+// topmost save index to be listed with a FillSaveGameList command
+// NOTE: changing this may theoretically affect older games which
+// use slots > 99 for special purposes!
+#define TOP_LISTEDSAVESLOT 99
 #define MAX_QUEUED_MUSIC 10
 #define GLED_INTERACTION 1
 #define GLED_EFFECTS     2


Commit: dec832ad4f6c70e8d9026c57c3c1bc3caad85b8e
    https://github.com/scummvm/scummvm/commit/dec832ad4f6c70e8d9026c57c3c1bc3caad85b8e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:18:01-07:00

Commit Message:
AGS: Refactor GUISlider::Draw(), make it easier to understand

>From upstream 9394a2df433f63a4753e1dbbaf5a2a6fdff6e69a

Changed paths:
    engines/ags/shared/gui/gui_slider.cpp
    engines/ags/shared/gui/gui_slider.h


diff --git a/engines/ags/shared/gui/gui_slider.cpp b/engines/ags/shared/gui/gui_slider.cpp
index 78e1e7861e2..1951d78b4e0 100644
--- a/engines/ags/shared/gui/gui_slider.cpp
+++ b/engines/ags/shared/gui/gui_slider.cpp
@@ -41,6 +41,7 @@ GUISlider::GUISlider() {
 	_scEventCount = 1;
 	_scEventNames[0] = "Change";
 	_scEventArgs[0] = "GUIControl *control";
+	_handleRange = 0;
 }
 
 bool GUISlider::IsHorizontal() const {
@@ -56,51 +57,61 @@ bool GUISlider::IsOverControl(int x, int y, int leeway) const {
 }
 
 void GUISlider::Draw(Shared::Bitmap *ds) {
-	Rect bar;
-	Rect handle;
-	int  thickness;
-
+	// Clamp Value
+	// TODO: this is necessary here because some Slider fields are still public
 	if (MinValue >= MaxValue)
 		MaxValue = MinValue + 1;
 	Value = Math::Clamp(Value, MinValue, MaxValue);
+	// Test if sprite is available
+	// TODO: react to sprites initialization/deletion instead!
+	if (_GP(spriteset)[HandleImage] == nullptr)
+		HandleImage = 0;
+
+	// Depending on slider's orientation, thickness is either Height or Width
+	const int thickness = IsHorizontal() ? Height : Width;
+	// "thick_f" is the factor for calculating relative element positions
+	const int thick_f = thickness / 3; // one third of the control's thickness
+	// Bar thickness
+	const int bar_thick = thick_f * 2 + 2;
+
+	// Calculate handle size
+	Size handle_sz;
+	if (HandleImage > 0) // handle is a sprite
+	{
+		handle_sz = Size(get_adjusted_spritewidth(HandleImage),
+			get_adjusted_spriteheight(HandleImage));
+	} else // handle is a drawn rectangle
+	{
+		if (IsHorizontal())
+			handle_sz = Size(get_fixed_pixel_size(4) + 1, bar_thick + (thick_f - 1) * 2);
+		else
+			handle_sz = Size(bar_thick + (thick_f - 1) * 2, get_fixed_pixel_size(4) + 1);
+	}
 
-	// it's a horizontal slider
-	if (IsHorizontal()) {
-		thickness = Height / 3;
-		bar.Left = X + 1;
-		bar.Top = Y + Height / 2 - thickness;
-		bar.Right = X + Width - 1;
-		bar.Bottom = Y + Height / 2 + thickness + 1;
-		handle.Left = (int)(((float)(Value - MinValue) / (float)(MaxValue - MinValue)) * (float)(Width - 4) - 2) + bar.Left + 1;
-		handle.Top = bar.Top - (thickness - 1);
-		handle.Right = handle.Left + get_fixed_pixel_size(4);
-		handle.Bottom = bar.Bottom + (thickness - 1);
-		if (HandleImage > 0) {
-			// store the centre of the pic rather than the top
-			handle.Top = bar.Top + (bar.Bottom - bar.Top) / 2 + get_fixed_pixel_size(1);
-			handle.Left += get_fixed_pixel_size(2);
-		}
-		handle.Top += data_to_game_coord(HandleOffset);
-		handle.Bottom += data_to_game_coord(HandleOffset);
+	// Calculate bar and handle positions
+	Rect bar;
+	Rect handle;
+	int handle_range;
+	if (IsHorizontal()) // horizontal slider
+	{
+		// Value pos is a coordinate corresponding to current slider's value
+		bar = RectWH(X + 1, Y + Height / 2 - thick_f, Width - 1, bar_thick);
+		handle_range = Width - 4;
+		int value_pos = (int)(((float)(Value - MinValue) * (float)handle_range) / (float)(MaxValue - MinValue));
+		handle = RectWH((bar.Left + get_fixed_pixel_size(2)) - (handle_sz.Width / 2) + 1 + value_pos - 2,
+			bar.Top + (bar.GetHeight() - handle_sz.Height) / 2,
+			handle_sz.Width, handle_sz.Height);
+		handle.MoveToY(handle.Top + data_to_game_coord(HandleOffset));
 	}
 	// vertical slider
 	else {
-		thickness = Width / 3;
-		bar.Left = X + Width / 2 - thickness;
-		bar.Top = Y + 1;
-		bar.Right = X + Width / 2 + thickness + 1;
-		bar.Bottom = Y + Height - 1;
-		handle.Top = (int)(((float)(MaxValue - Value) / (float)(MaxValue - MinValue)) * (float)(Height - 4) - 2) + bar.Top + 1;
-		handle.Left = bar.Left - (thickness - 1);
-		handle.Bottom = handle.Top + get_fixed_pixel_size(4);
-		handle.Right = bar.Right + (thickness - 1);
-		if (HandleImage > 0) {
-			// store the centre of the pic rather than the left
-			handle.Left = bar.Left + (bar.Right - bar.Left) / 2 + get_fixed_pixel_size(1);
-			handle.Top += get_fixed_pixel_size(2);
-		}
-		handle.Left += data_to_game_coord(HandleOffset);
-		handle.Right += data_to_game_coord(HandleOffset);
+		bar = RectWH(X + Width / 2 - thick_f, Y + 1, bar_thick, Height - 1);
+		handle_range = Height - 4;
+		int value_pos = (int)(((float)(MaxValue - Value) * (float)handle_range) / (float)(MaxValue - MinValue));
+		handle = RectWH(bar.Left + (bar.GetWidth() - handle_sz.Width) / 2,
+			(bar.Top + get_fixed_pixel_size(2)) - (handle_sz.Height / 2) + 1 + value_pos - 2,
+			handle_sz.Width, handle_sz.Height);
+		handle.MoveToX(handle.Left + data_to_game_coord(HandleOffset));
 	}
 
 	color_t draw_color;
@@ -129,7 +140,7 @@ void GUISlider::Draw(Shared::Bitmap *ds) {
 	} else {
 		// normal grey background
 		draw_color = ds->GetCompatibleColor(16);
-		ds->FillRect(Rect(bar.Left + 1, bar.Top + 1, bar.Right - 1, bar.Bottom - 1), draw_color);
+		ds->FillRect(bar, draw_color);
 		draw_color = ds->GetCompatibleColor(8);
 		ds->DrawLine(Line(bar.Left, bar.Top, bar.Left, bar.Bottom), draw_color);
 		ds->DrawLine(Line(bar.Left, bar.Top, bar.Right, bar.Top), draw_color);
@@ -138,21 +149,14 @@ void GUISlider::Draw(Shared::Bitmap *ds) {
 		ds->DrawLine(Line(bar.Left, bar.Bottom, bar.Right, bar.Bottom), draw_color);
 	}
 
-	if (HandleImage > 0) {
-		// an image for the slider handle
-		// TODO: react to sprites initialization/deletion instead!
-		if (_GP(spriteset)[HandleImage] == nullptr)
-			HandleImage = 0;
-
-		handle.Left -= get_adjusted_spritewidth(HandleImage) / 2;
-		handle.Top -= get_adjusted_spriteheight(HandleImage) / 2;
+	if (HandleImage > 0) // handle is a sprite
+	{
 		draw_gui_sprite(ds, HandleImage, handle.Left, handle.Top, true);
-		handle.Right = handle.Left + get_adjusted_spritewidth(HandleImage);
-		handle.Bottom = handle.Top + get_adjusted_spriteheight(HandleImage);
-	} else {
+	} else // handle is a drawn rectangle
+	{
 		// normal grey tracker handle
 		draw_color = ds->GetCompatibleColor(7);
-		ds->FillRect(Rect(handle.Left, handle.Top, handle.Right, handle.Bottom), draw_color);
+		ds->FillRect(handle, draw_color);
 		draw_color = ds->GetCompatibleColor(15);
 		ds->DrawLine(Line(handle.Left, handle.Top, handle.Right, handle.Top), draw_color);
 		ds->DrawLine(Line(handle.Left, handle.Top, handle.Left, handle.Bottom), draw_color);
@@ -162,6 +166,7 @@ void GUISlider::Draw(Shared::Bitmap *ds) {
 	}
 
 	_cachedHandle = handle;
+	_handleRange = handle_range;
 }
 
 bool GUISlider::OnMouseDown() {
@@ -175,9 +180,9 @@ void GUISlider::OnMouseMove(int x, int y) {
 		return;
 
 	if (IsHorizontal())
-		Value = (int)(((float)((x - X) - 2) / (float)(Width - 4)) * (float)(MaxValue - MinValue)) + MinValue;
+		Value = (int)(((float)((x - X) - 2) * (float)(MaxValue - MinValue)) / (float)_handleRange) + MinValue;
 	else
-		Value = (int)(((float)(((Y + Height) - y) - 2) / (float)(Height - 4)) * (float)(MaxValue - MinValue)) + MinValue;
+		Value = (int)(((float)(((Y + Height) - y) - 2) * (float)(MaxValue - MinValue)) / (float)_handleRange) + MinValue;
 
 	Value = Math::Clamp(Value, MinValue, MaxValue);
 	NotifyParentChanged();
diff --git a/engines/ags/shared/gui/gui_slider.h b/engines/ags/shared/gui/gui_slider.h
index 4df5e04fff2..70c296586a8 100644
--- a/engines/ags/shared/gui/gui_slider.h
+++ b/engines/ags/shared/gui/gui_slider.h
@@ -65,6 +65,8 @@ private:
 	// The following variables are not persisted on disk
 	// Cached coordinates of slider handle
 	Rect    _cachedHandle;
+	// The length of the handle movement range, in pixels
+	int     _handleRange;
 };
 
 } // namespace Shared


Commit: 7dab6a49640947e9622a0a6f76efaab75702b351
    https://github.com/scummvm/scummvm/commit/7dab6a49640947e9622a0a6f76efaab75702b351
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:21:46-07:00

Commit Message:
AGS: Exclude Sliders from clipping GUI controls rule

>From upstream fd8976b09e821b015b8d267531c2bce659d95d13

Changed paths:
    engines/ags/shared/gui/gui_main.cpp
    engines/ags/shared/gui/gui_object.h
    engines/ags/shared/gui/gui_slider.h


diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 7a69e5d96ab..893c6538fdb 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -258,8 +258,10 @@ void GUIMain::DrawAt(Bitmap *ds, int x, int y) {
 		if (!objToDraw->IsVisible())
 			continue;
 
-		if (GUI::Options.ClipControls)
+		if (GUI::Options.ClipControls && objToDraw->IsContentClipped())
 			subbmp.SetClip(RectWH(objToDraw->X, objToDraw->Y, objToDraw->Width, objToDraw->Height));
+		else
+			subbmp.ResetClip();
 		objToDraw->Draw(&subbmp);
 
 		int selectedColour = 14;
diff --git a/engines/ags/shared/gui/gui_object.h b/engines/ags/shared/gui/gui_object.h
index 346ba7f7238..5031bba5c6b 100644
--- a/engines/ags/shared/gui/gui_object.h
+++ b/engines/ags/shared/gui/gui_object.h
@@ -60,6 +60,8 @@ public:
 	bool            IsVisible() const;
 	// implemented separately in engine and editor
 	bool            IsClickable() const;
+    // Compatibility: should the control's graphic be clipped to its x,y,w,h
+    virtual bool    IsContentClipped() const { return true; }
 
 	// Operations
 	virtual void    Draw(Bitmap *ds) {
diff --git a/engines/ags/shared/gui/gui_slider.h b/engines/ags/shared/gui/gui_slider.h
index 70c296586a8..8ea4d1dc71b 100644
--- a/engines/ags/shared/gui/gui_slider.h
+++ b/engines/ags/shared/gui/gui_slider.h
@@ -33,6 +33,9 @@ class GUISlider : public GUIObject {
 public:
 	GUISlider();
 
+	// Compatibility: sliders are not clipped as of 3.6.0
+	bool IsContentClipped() const override { return false; }
+
 	// Tells if the slider is horizontal (otherwise - vertical)
 	bool IsHorizontal() const;
 	bool IsOverControl(int x, int y, int leeway) const override;


Commit: f5b603f16e2314c4471aa025356b04fca9bbe7f8
    https://github.com/scummvm/scummvm/commit/f5b603f16e2314c4471aa025356b04fca9bbe7f8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:25:28-07:00

Commit Message:
AGS: Updated build version (3.6.0.21), set version as Beta

>From upstream d1db1fea5139492a949b664b0fbe32b2b9ccc265

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 765bd984d7b..96952c2be58 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.20"
+#define ACI_VERSION_STR      "3.6.0.21"
 #if defined (RC_INVOKED) // for MSVC resource compiler
-#define ACI_VERSION_MSRC_DEF  3.6.020
+#define ACI_VERSION_MSRC_DEF  3.6.0.21
 #endif
 
 #define SPECIAL_VERSION ""


Commit: 0e283a9a87074d33cd3206c4f412aa93324d9589
    https://github.com/scummvm/scummvm/commit/0e283a9a87074d33cd3206c4f412aa93324d9589
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:30:23-07:00

Commit Message:
AGS: Removed guis list param from ResortGUI (useless)

>From upstream fcb6c37e27be324a122be92fc28b8b36ad80bde9

Changed paths:
    engines/ags/shared/gui/gui_main.cpp


diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 893c6538fdb..a9d3508784c 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -738,16 +738,15 @@ GUILabelMacro FindLabelMacros(const String &text) {
 	return (GUILabelMacro)macro_flags;
 }
 
-HError ResortGUI(std::vector<GUIMain> &theGuis, bool bwcompat_ctrl_zorder = false) {
+static HError ResortGUI(bool bwcompat_ctrl_zorder = false) {
 	// set up the reverse-lookup array
-	for (size_t gui_index = 0; gui_index < theGuis.size(); ++gui_index) {
-		GUIMain &gui = theGuis[gui_index];
+	for (auto &gui : _GP(guis)) {
 		HError err = gui.RebuildArray();
 		if (!err)
 			return err;
 		for (int ctrl_index = 0; ctrl_index < gui.GetControlCount(); ++ctrl_index) {
 			GUIObject *gui_ctrl = gui.GetControl(ctrl_index);
-			gui_ctrl->ParentId = gui_index;
+			gui_ctrl->ParentId = gui.ID;
 			gui_ctrl->Id = ctrl_index;
 			if (bwcompat_ctrl_zorder)
 				gui_ctrl->ZOrder = ctrl_index;
@@ -859,7 +858,7 @@ HError ReadGUI(Stream *in, bool is_savegame) {
 			_GP(guilist)[i].ReadFromFile(in, GameGuiVersion);
 		}
 	}
-	return ResortGUI(_GP(guis), GameGuiVersion < kGuiVersion_272e);
+	return ResortGUI(GameGuiVersion < kGuiVersion_272e);
 }
 
 void WriteGUI(Stream *out) {


Commit: 012ca99120c53bd20e96e172cefcf9c8cb2f9c8f
    https://github.com/scummvm/scummvm/commit/012ca99120c53bd20e96e172cefcf9c8cb2f9c8f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-04-22T21:40:27-07:00

Commit Message:
AGS: In built-in guis renamed local args hiding global variables

>From upstream aa2a418b41547cb8e65c60855c74061c9ccae646

Changed paths:
    engines/ags/engine/gui/my_label.h
    engines/ags/engine/gui/my_listbox.cpp
    engines/ags/engine/gui/my_listbox.h
    engines/ags/engine/gui/my_push_button.cpp
    engines/ags/engine/gui/my_push_button.h
    engines/ags/engine/gui/my_textbox.cpp
    engines/ags/engine/gui/my_textbox.h
    engines/ags/engine/gui/new_control.cpp
    engines/ags/engine/gui/new_control.h


diff --git a/engines/ags/engine/gui/my_label.h b/engines/ags/engine/gui/my_label.h
index b9f61675ddd..2e20ec762de 100644
--- a/engines/ags/engine/gui/my_label.h
+++ b/engines/ags/engine/gui/my_label.h
@@ -32,7 +32,7 @@ struct MyLabel : public NewControl {
 
 	void draw(Shared::Bitmap *ds) override;
 
-	int pressedon(int mousex, int mousey) override;
+	int pressedon(int mx, int my) override;
 
 	int processmessage(int mcode, int wParam, NumberPtr lParam) override;
 };
diff --git a/engines/ags/engine/gui/my_listbox.cpp b/engines/ags/engine/gui/my_listbox.cpp
index d71cdbf3b12..cc475e8c47f 100644
--- a/engines/ags/engine/gui/my_listbox.cpp
+++ b/engines/ags/engine/gui/my_listbox.cpp
@@ -106,7 +106,7 @@ int MyListBox::pressedon(int mousex, int mousey) {
 	if (mousex > x + wid - ARROWWIDTH) {
 		if ((mousey - y < hit / 2) & (topitem > 0))
 			topitem--;
-		else if ((mousey - y > hit / 2) & (topitem + numonscreen < items))
+		else if ((mousey - y > hit / 2) &(topitem + numonscreen < items))
 			topitem++;
 
 	} else {
diff --git a/engines/ags/engine/gui/my_listbox.h b/engines/ags/engine/gui/my_listbox.h
index 719bf03abbe..4fbf7cf15ed 100644
--- a/engines/ags/engine/gui/my_listbox.h
+++ b/engines/ags/engine/gui/my_listbox.h
@@ -37,7 +37,7 @@ struct MyListBox : public NewControl {
 	~MyListBox() override;
 
 	void draw(Shared::Bitmap *ds) override;
-	int pressedon(int mousex, int mousey) override;
+	int pressedon(int mx, int my) override;
 	void additem(char *texx);
 	int processmessage(int mcode, int wParam, NumberPtr lParam) override;
 };
diff --git a/engines/ags/engine/gui/my_push_button.cpp b/engines/ags/engine/gui/my_push_button.cpp
index 5779b3c9f93..e27b1c94fe1 100644
--- a/engines/ags/engine/gui/my_push_button.cpp
+++ b/engines/ags/engine/gui/my_push_button.cpp
@@ -70,12 +70,12 @@ void MyPushButton::draw(Bitmap *ds) {
 	ds->DrawRect(Rect(x - 1, y - 1, x + wid + 1, y + hit + 1), draw_color);
 }
 
-int MyPushButton::pressedon(int mousex, int mousey) {
+int MyPushButton::pressedon(int mx, int my) {
 	int wasstat;
 	while (mbutrelease(MouseLeft) == 0) {
 
 		wasstat = state;
-		state = mouseisinarea(mousex, mousey);
+		state = mouseisinarea(mx, my);
 		// stop mp3 skipping if button held down
 		update_polled_stuff_if_runtime();
 		if (wasstat != state) {
diff --git a/engines/ags/engine/gui/my_push_button.h b/engines/ags/engine/gui/my_push_button.h
index f56e2a24c6e..e4f3384ab62 100644
--- a/engines/ags/engine/gui/my_push_button.h
+++ b/engines/ags/engine/gui/my_push_button.h
@@ -30,7 +30,7 @@ struct MyPushButton : public NewControl {
 	char text[50];
 	MyPushButton(int xx, int yy, int wi, int hi, const char *tex);
 	void draw(Shared::Bitmap *ds) override;
-	int pressedon(int mousex, int mousey) override;
+	int pressedon(int mx, int my) override;
 	int processmessage(int mcode, int wParam, NumberPtr lParam) override;
 };
 
diff --git a/engines/ags/engine/gui/my_textbox.cpp b/engines/ags/engine/gui/my_textbox.cpp
index 87a7bfaf9cc..98ba424a20b 100644
--- a/engines/ags/engine/gui/my_textbox.cpp
+++ b/engines/ags/engine/gui/my_textbox.cpp
@@ -54,7 +54,7 @@ void MyTextBox::draw(Bitmap *ds) {
 	wouttextxy(ds, x + 2 + get_text_width(text, _G(cbuttfont)), y + 1, _G(cbuttfont), text_color, tbu);
 }
 
-int MyTextBox::pressedon(int mousex, int mousey) {
+int MyTextBox::pressedon(int /*mx*/, int /*my*/) {
 	return 0;
 }
 
diff --git a/engines/ags/engine/gui/my_textbox.h b/engines/ags/engine/gui/my_textbox.h
index 960451d3d12..40a23099393 100644
--- a/engines/ags/engine/gui/my_textbox.h
+++ b/engines/ags/engine/gui/my_textbox.h
@@ -31,7 +31,7 @@ struct MyTextBox : public NewControl {
 	char text[TEXTBOX_MAXLEN + 1];
 	MyTextBox(int xx, int yy, int wii, const char *tee);
 	void draw(Shared::Bitmap *ds) override;
-	int pressedon(int mousex, int mousey) override;
+	int pressedon(int mx, int my) override;
 	int processmessage(int mcode, int wParam, NumberPtr lParam) override;
 };
 
diff --git a/engines/ags/engine/gui/new_control.cpp b/engines/ags/engine/gui/new_control.cpp
index f142932591b..4aaaf2ee0a0 100644
--- a/engines/ags/engine/gui/new_control.cpp
+++ b/engines/ags/engine/gui/new_control.cpp
@@ -48,15 +48,17 @@ NewControl::NewControl() {
 	enabled = 1;
 	needredraw = 1;
 }
-int NewControl::mouseisinarea(int mousex, int mousey) {
+
+int NewControl::mouseisinarea(int mx, int my) {
 	if (_G(topwindowhandle) != wlevel)
 		return 0;
 
-	if ((mousex > x) & (mousex < x + wid) & (mousey > y) & (mousey < y + hit))
+	if ((mx > x) &(mx < x + wid) &(my > y) &(my < y + hit))
 		return 1;
 
 	return 0;
 }
+
 void NewControl::drawifneeded() {
 	if (_G(topwindowhandle) != wlevel)
 		return;
diff --git a/engines/ags/engine/gui/new_control.h b/engines/ags/engine/gui/new_control.h
index d08e5348043..6bd6f40c964 100644
--- a/engines/ags/engine/gui/new_control.h
+++ b/engines/ags/engine/gui/new_control.h
@@ -33,13 +33,13 @@ struct NewControl {
 	int8 visible, enabled;        // not implemented
 	int8 needredraw;
 	virtual void draw(Shared::Bitmap *ds) = 0;
-	virtual int pressedon(int mousex, int mousey) = 0;
+	virtual int pressedon(int mx, int my) = 0;
 	virtual int processmessage(int, int, NumberPtr) = 0;
 
 	NewControl(int xx, int yy, int wi, int hi);
 	NewControl();
 	virtual ~NewControl() {}
-	int mouseisinarea(int mousex, int mousey);
+	int mouseisinarea(int mx, int my);
 	void drawifneeded();
 	void drawandmouse();
 };




More information about the Scummvm-git-logs mailing list