[Scummvm-git-logs] scummvm master -> 1d4d6d501e1797b968d1c6a6d45102810f50f2cb

criezy noreply at scummvm.org
Sat Dec 17 21:11:39 UTC 2022


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

Summary:
31c1d49762 AGS: fixed skip_rle_bitmap8() made no sense whatsoever
5772893340 AGS: Engine: fixed CallScriptFunction for the ancient games + added comments
c156608796 AGS: Engine: fixed dangerous use of String::Wrapper in logging
871d4b54e1 AGS: Engine: in DialogOptions exceed all the keypress buffer
3286cf18ec AGS: Engine: in display_main exceed all the keypress buffer
57266951a9 AGS: Engine: fixed built-in textboxes not responding to printed chars
b052270504 AGS: Engine: in built-in dialogs exceed all the keypress buffer at once
ccbe6f5419 AGS: Engine: in video_check_user_input() exceed all the keypress buffer
1d4d6d501e AGS: Engine: corrected some of the key evt queue exceeding loops


Commit: 31c1d49762ee4570888d859b6c3d9e219f883c9d
    https://github.com/scummvm/scummvm/commit/31c1d49762ee4570888d859b6c3d9e219f883c9d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: fixed skip_rle_bitmap8() made no sense whatsoever

This fixes loading pre 2.55 games.

>From upstream 3df6b7185685bcd6a2d6cbdb7b5c3b62ea5dc9b0

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


diff --git a/engines/ags/shared/util/compress.cpp b/engines/ags/shared/util/compress.cpp
index 0c4867dc273..9ab0bf97d73 100644
--- a/engines/ags/shared/util/compress.cpp
+++ b/engines/ags/shared/util/compress.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "ags/shared/util/compress.h"
+#include "ags/lib/std/vector.h"
 #include "ags/shared/ac/common.h"   // quit, update_polled_stuff
 #include "ags/shared/gfx/bitmap.h"
 #include "ags/shared/util/file.h"
@@ -318,8 +319,12 @@ Shared::Bitmap *load_rle_bitmap8(Stream *in, RGB(*pal)[256]) {
 void skip_rle_bitmap8(Stream *in) {
 	int w = in->ReadInt16();
 	int h = in->ReadInt16();
-	// Skip 8-bit pixel data + RGB palette
-	in->Seek((w * h) + (3 * 256));
+	// Unpack the pixels into temp buf
+	std::vector<uint8_t> buf;
+	buf.resize(w * h);
+	cunpackbitl(&buf[0], w * h, in);
+	// Skip RGB palette
+	in->Seek(3 * 256);
 }
 
 //-----------------------------------------------------------------------------


Commit: 57728933409f8c89b33f007119d5ce52df41a111
    https://github.com/scummvm/scummvm/commit/57728933409f8c89b33f007119d5ce52df41a111
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: fixed CallScriptFunction for the ancient games + added comments

Was broken by dec92f05ea9156961d17d9a7f62f11d73b8dba07
(e38df03c5d1658a2c44a26ba4ee6f22663c1e701 in upstream).

Some games do not have function arg count appended to the function names in
the export table; in that case `export_args` remained uninitialized.

>From upstream cdbb7a7367db57e14983015232ecc97f6a3dd212

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


diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index 200972b99bf..beb960a9d81 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -313,31 +313,32 @@ int ccInstance::CallScriptFunction(const char *funcname, int32_t numargs, const
 		return -4;
 	}
 
+	// NOTE: passing more parameters than expected by the function is fine:
+	// the function args are pushed to the stack in REVERSE order, first
+	// parameters are always the last, so function code knows how to find them
+	// using negative offsets, and does not care about any preceding entries.
 	int32_t startat = -1;
-	int k;
 	char mangledName[200];
 	size_t mangled_len = snprintf(mangledName, sizeof(mangledName), "%s$", funcname);
-	int32_t export_args = 0;
+	int export_args = numargs;
 
-	for (k = 0; k < instanceof->numexports; k++) {
+	for (int k = 0; k < instanceof->numexports; k++) {
 		char *thisExportName = instanceof->exports[k];
-		int match = 0;
+		bool match = false;
 
 		// check for a mangled name match
 		if (strncmp(thisExportName, mangledName, mangled_len) == 0) {
 			// found, compare the number of parameters
 			export_args = atoi(thisExportName + mangled_len);
 			if (export_args > numargs) {
-				cc_error("wrong number of parameters to exported function '%s' (expected %d, supplied %d)",
+				cc_error("Not enough parameters to exported function '%s' (expected %d, supplied %d)",
 					funcname, export_args, numargs);
 				return -1;
 			}
-			match = 1;
+			match = true;
 		}
-
-		// check for an exact match (if the script was compiled with
-		// an older version)
-		if ((match == 1) || (strcmp(thisExportName, funcname) == 0)) {
+		// check for an exact match (if the script was compiled with an older version)
+		if (match || (strcmp(thisExportName, funcname) == 0)) {
 			int32_t etype = (instanceof->export_addr[k] >> 24L) & 0x000ff;
 			if (etype != EXPORT_FUNCTION) {
 				cc_error("symbol is not a function");


Commit: c15660879605f066a753fba313c3a830889bb694
    https://github.com/scummvm/scummvm/commit/c15660879605f066a753fba313c3a830889bb694
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: fixed dangerous use of String::Wrapper in logging

>From upstream 588d91ab6a09877eab06bf66073239db0d28271b

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


diff --git a/engines/ags/engine/ac/system.cpp b/engines/ags/engine/ac/system.cpp
index c16de469bab..409dd365125 100644
--- a/engines/ags/engine/ac/system.cpp
+++ b/engines/ags/engine/ac/system.cpp
@@ -342,7 +342,7 @@ RuntimeScriptValue Sc_System_SaveConfigToFile(const RuntimeScriptValue *params,
 
 RuntimeScriptValue Sc_System_Log(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF_PURE(Sc_System_Log, 2);
-	Debug::Printf(kDbgGroup_Script, (MessageType)params[0].IValue, String::Wrapper(scsf_buffer));
+	Debug::Printf(kDbgGroup_Script, (MessageType)params[0].IValue, scsf_buffer);
 	return RuntimeScriptValue((int32_t)0);
 }
 


Commit: 871d4b54e10b5fc87edfac9c101ff59e1f88f480
    https://github.com/scummvm/scummvm/commit/871d4b54e10b5fc87edfac9c101ff59e1f88f480
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: in DialogOptions exceed all the keypress buffer

>From upstream 5488f02bae108c1f191a5b6ca3a46eee6497058a

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


diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp
index c707a908593..ed0c6059f22 100644
--- a/engines/ags/engine/ac/dialog.cpp
+++ b/engines/ags/engine/ac/dialog.cpp
@@ -425,6 +425,7 @@ struct DialogOptions {
 	int parserActivated;
 
 	int curyp;
+	bool needRedraw;
 	bool wantRefresh;
 	bool usingCustomRendering;
 	int orixp;
@@ -444,7 +445,15 @@ struct DialogOptions {
 	void Prepare(int _dlgnum, bool _runGameLoopsInBackground);
 	void Show();
 	void Redraw();
+	// Runs the dialog options update;
+	// returns whether should continue to run options loop, or stop
 	bool Run();
+	// Process all the buffered key events;
+	// returns whether should continue to run options loop, or stop
+	bool RunKeyControls();
+	// Process single key event
+	// returns whether should continue to run options loop, or stop
+	bool RunKey(const KeyInput &ki);
 	void Close();
 };
 
@@ -588,6 +597,7 @@ void DialogOptions::Show() {
 
 	orixp = dlgxp;
 	oriyp = dlgyp;
+	needRedraw = false;
 	wantRefresh = false;
 	mouseison = -10;
 
@@ -732,15 +742,9 @@ void DialogOptions::Redraw() {
 		if (dlgyp < dirtyy)
 			dirtyy = dlgyp;
 
-		//curyp = dlgyp + 1;
 		curyp = dlgyp;
 		curyp = write_dialog_options(ds, options_surface_has_alpha, dlgxp, curyp, numdisp, mouseison, areawid, bullet_wid, usingfont, dtop, disporder, dispyp, linespacing, forecol, padding);
 
-		/*if (curyp > _GP(play).viewport.GetHeight()) {
-		  dlgyp = _GP(play).viewport.GetHeight() - (curyp - dlgyp);
-		  ds->FillRect(Rect(0,dlgyp-1,_GP(play).viewport.GetWidth()-1,_GP(play).viewport.GetHeight()-1);
-		  goto redraw_options;
-		}*/
 		if (parserInput)
 			parserInput->X = dlgxp;
 	}
@@ -802,7 +806,6 @@ bool DialogOptions::Run() {
 	sys_evt_process_pending();
 
 	const bool new_custom_render = usingCustomRendering && _GP(game).options[OPT_DIALOGOPTIONSAPI] >= 0;
-	const bool old_keyhandle = _GP(game).options[OPT_KEYHANDLEAPI] == 0;
 
 	if (runGameLoopsInBackground) {
 		_GP(play).disabled_user_interface++;
@@ -818,62 +821,16 @@ bool DialogOptions::Run() {
 		run_function_on_non_blocking_thread(&_GP(runDialogOptionRepExecFunc));
 	}
 
-	KeyInput ki;
-	if (run_service_key_controls(ki) && !_GP(play).IsIgnoringInput()) {
-		const eAGSKeyCode agskey = ki.Key;
-		if (parserInput) {
-			wantRefresh = true;
-			// type into the parser 
-			// TODO: find out what are these key commands, and are these documented?
-			if ((agskey == eAGSKeyCodeF3) || ((agskey == eAGSKeyCodeSpace) && (parserInput->Text.GetLength() == 0))) {
-				// write previous contents into textbox (F3 or Space when box is empty)
-				size_t last_len = ustrlen(_GP(play).lastParserEntry);
-				size_t cur_len = ustrlen(parserInput->Text.GetCStr());
-				// [ikm] CHECKME: tbh I don't quite get the logic here (it was like this in original code);
-				// but what we do is copying only the last part of the previous string
-				if (cur_len < last_len) {
-					const char *entry = _GP(play).lastParserEntry;
-					// TODO: utility function for advancing N utf-8 chars
-					for (size_t i = 0; i < cur_len; ++i) ugetxc(&entry);
-					parserInput->Text.Append(entry);
-				}
+	needRedraw = false;
 
-				//ags_domouse(DOMOUSE_DISABLE);
-				Redraw();
-				return true; // continue running loop
-			} else if ((agskey >= eAGSKeyCodeSpace) || (agskey == eAGSKeyCodeReturn) || (agskey == eAGSKeyCodeBackspace)) {
-				parserInput->OnKeyPress(ki);
-				if (!parserInput->IsActivated) {
-					//ags_domouse(DOMOUSE_DISABLE);
-					Redraw();
-					return true; // continue running loop
-				}
-			}
-		} else if (new_custom_render) {
-			if (old_keyhandle || (ki.UChar == 0)) {
-				// "dialog_options_key_press"
-				_GP(runDialogOptionKeyPressHandlerFunc).params[0].SetDynamicObject(&_GP(ccDialogOptionsRendering), &_GP(ccDialogOptionsRendering));
-				_GP(runDialogOptionKeyPressHandlerFunc).params[1].SetInt32(AGSKeyToScriptKey(ki.Key));
-				_GP(runDialogOptionKeyPressHandlerFunc).params[2].SetInt32(ki.Mod);
-				run_function_on_non_blocking_thread(&_GP(runDialogOptionKeyPressHandlerFunc));
-			}
-			if (!old_keyhandle && (ki.UChar > 0)) {
-				// "dialog_options_text_input"
-				_GP(runDialogOptionTextInputHandlerFunc).params[0].SetDynamicObject(&_GP(ccDialogOptionsRendering), &_GP(ccDialogOptionsRendering));
-				_GP(runDialogOptionTextInputHandlerFunc).params[1].SetInt32(ki.UChar);
-				run_function_on_non_blocking_thread(&_GP(runDialogOptionKeyPressHandlerFunc));
-			}
-		}
-		// Allow selection of options by keyboard shortcuts
-		else if (_GP(game).options[OPT_DIALOGNUMBERED] >= kDlgOptKeysOnly &&
-			agskey >= '1' && agskey <= '9') {
-			int numkey = agskey - '1';
-			if (numkey < numdisp) {
-				chose = disporder[numkey];
-				return false; // end dialog options running loop
-			}
-		}
-	}
+	// Handle keyboard
+	if (!RunKeyControls())
+		return false; // end loop
+
+	if (needRedraw)
+		Redraw();
+
+	// Handle mouse
 	mousewason = mouseison;
 	mouseison = -1;
 	if (new_custom_render); // do not automatically detect option under mouse
@@ -973,7 +930,6 @@ bool DialogOptions::Run() {
 		}
 	}
 	if (mousewason != mouseison) {
-		//ags_domouse(DOMOUSE_DISABLE);
 		Redraw();
 		return true; // continue running loop
 	}
@@ -998,6 +954,78 @@ bool DialogOptions::Run() {
 	return true; // continue running loop
 }
 
+bool DialogOptions::RunKeyControls() {
+	// Handle all the buffered key events
+	bool do_break = false; // continue the loop or end dialog options
+	while (ags_keyevent_ready()) {
+		KeyInput ki;
+		if (run_service_key_controls(ki) && !_GP(play).IsIgnoringInput()) {
+			if (!do_break && !RunKey(ki)) {
+				ags_clear_input_buffer();
+				do_break = true; // end dialog options
+			}
+		}
+	}
+	return !do_break;
+}
+
+bool DialogOptions::RunKey(const KeyInput &ki) {
+	const bool new_custom_render = usingCustomRendering && _GP(game).options[OPT_DIALOGOPTIONSAPI] >= 0;
+	const bool old_keyhandle = _GP(game).options[OPT_KEYHANDLEAPI] == 0;
+
+	const eAGSKeyCode agskey = ki.Key;
+	if (parserInput) {
+		wantRefresh = true;
+		// type into the parser
+		// TODO: find out what are these key commands, and are these documented?
+		if ((agskey == eAGSKeyCodeF3) || ((agskey == eAGSKeyCodeSpace) && (parserInput->Text.GetLength() == 0))) {
+			// write previous contents into textbox (F3 or Space when box is empty)
+			size_t last_len = ustrlen(_GP(play).lastParserEntry);
+			size_t cur_len = ustrlen(parserInput->Text.GetCStr());
+			// [ikm] CHECKME: tbh I don't quite get the logic here (it was like this in original code);
+			// but what we do is copying only the last part of the previous string
+			if (cur_len < last_len) {
+				const char *entry = _GP(play).lastParserEntry;
+				// TODO: utility function for advancing N utf-8 chars
+				for (size_t i = 0; i < cur_len; ++i) ugetxc(&entry);
+				parserInput->Text.Append(entry);
+			}
+			needRedraw = true;
+			return true; // continue running loop
+		} else if ((agskey >= eAGSKeyCodeSpace) || (agskey == eAGSKeyCodeReturn) || (agskey == eAGSKeyCodeBackspace)) {
+			parserInput->OnKeyPress(ki);
+			if (!parserInput->IsActivated) {
+				needRedraw = true;
+				return true; // continue running loop
+			}
+		}
+	} else if (new_custom_render) {
+		if (old_keyhandle || (ki.UChar == 0)) {
+			// "dialog_options_key_press"
+			_GP(runDialogOptionKeyPressHandlerFunc).params[0].SetDynamicObject(&_GP(ccDialogOptionsRendering), &_GP(ccDialogOptionsRendering));
+			_GP(runDialogOptionKeyPressHandlerFunc).params[1].SetInt32(AGSKeyToScriptKey(ki.Key));
+			_GP(runDialogOptionKeyPressHandlerFunc).params[2].SetInt32(ki.Mod);
+			run_function_on_non_blocking_thread(&_GP(runDialogOptionKeyPressHandlerFunc));
+		}
+		if (!old_keyhandle && (ki.UChar > 0)) {
+			// "dialog_options_text_input"
+			_GP(runDialogOptionTextInputHandlerFunc).params[0].SetDynamicObject(&_GP(ccDialogOptionsRendering), &_GP(ccDialogOptionsRendering));
+			_GP(runDialogOptionTextInputHandlerFunc).params[1].SetInt32(ki.UChar);
+			run_function_on_non_blocking_thread(&_GP(runDialogOptionKeyPressHandlerFunc));
+		}
+	}
+	// Allow selection of options by keyboard shortcuts
+	else if (_GP(game).options[OPT_DIALOGNUMBERED] >= kDlgOptKeysOnly &&
+		agskey >= '1' && agskey <= '9') {
+		int numkey = agskey - '1';
+		if (numkey < numdisp) {
+			chose = disporder[numkey];
+			return false; // end dialog options running loop
+		}
+	}
+	return true; // continue running loop
+}
+
 void DialogOptions::Close() {
 	ags_clear_input_buffer();
 	invalidate_screen();


Commit: 3286cf18eca222b8f8580a71bd98b0cc9ea1de4e
    https://github.com/scummvm/scummvm/commit/3286cf18eca222b8f8580a71bd98b0cc9ea1de4e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: in display_main exceed all the keypress buffer

>From upstream d2100b01ee4a85219b481dcd7593f0e0d419523e

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 3a4e2925535..edec57a5749 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -294,16 +294,19 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 					break;
 				}
 			}
-			KeyInput ki;
-			if (run_service_key_controls(ki)) {
-				check_skip_cutscene_keypress(ki.Key);
-				if (_GP(play).fast_forward)
-					break;
-				if ((skip_setting & SKIP_KEYPRESS) && !_GP(play).IsIgnoringInput()) {
-					_GP(play).SetWaitKeySkip(ki);
-					break;
+			bool do_break = false;
+			while (!_GP(play).fast_forward && !do_break && ags_keyevent_ready()) {
+				KeyInput ki;
+				if (run_service_key_controls(ki)) {
+					check_skip_cutscene_keypress(ki.Key);
+					if ((skip_setting & SKIP_KEYPRESS) && !_GP(play).IsIgnoringInput()) {
+						_GP(play).SetWaitKeySkip(ki);
+						do_break = true;
+					}
 				}
 			}
+			if (do_break)
+				break;
 
 			update_polled_stuff_if_runtime();
 
@@ -352,6 +355,7 @@ ScreenOverlay *_display_main(int xx, int yy, int wii, const char *text, int disp
 		GameLoopUntilNoOverlay();
 	}
 
+	ags_clear_input_buffer();
 	_GP(play).messagetime = -1;
 	return nullptr;
 }


Commit: 57266951a9ac7de80357213ced8c613c5ee681c8
    https://github.com/scummvm/scummvm/commit/57266951a9ac7de80357213ced8c613c5ee681c8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: fixed built-in textboxes not responding to printed chars

>From upstream f1064e91c3b71e2bed4d866bb57b2d32fc1fed25

Changed paths:
    engines/ags/engine/gui/csci_dialog.cpp


diff --git a/engines/ags/engine/gui/csci_dialog.cpp b/engines/ags/engine/gui/csci_dialog.cpp
index 7962e3abebe..b33e47fd93d 100644
--- a/engines/ags/engine/gui/csci_dialog.cpp
+++ b/engines/ags/engine/gui/csci_dialog.cpp
@@ -144,7 +144,7 @@ int CSCIWaitMessage(CSCIMessage *cscim) {
 			} else if (keywas == eAGSKeyCodeEscape) {
 				cscim->id = finddefaultcontrol(CNF_CANCEL);
 				cscim->code = CM_COMMAND;
-			} else if ((keywas < eAGSKeyCodeSpace) && (keywas != eAGSKeyCodeBackspace));
+			} else if ((uchar == 0) && (keywas < eAGSKeyCodeSpace) && (keywas != eAGSKeyCodeBackspace)) ;
 			else if ((keywas >= eAGSKeyCodeUpArrow) & (keywas <= eAGSKeyCodePageDown) & (finddefaultcontrol(CNT_LISTBOX) >= 0))
 				_G(vobjs)[finddefaultcontrol(CNT_LISTBOX)]->processmessage(CTB_KEYPRESS, keywas, 0);
 			else if (finddefaultcontrol(CNT_TEXTBOX) >= 0)


Commit: b0522705040cfb0fc32aea2ebc1e4d1d7b59b4e5
    https://github.com/scummvm/scummvm/commit/b0522705040cfb0fc32aea2ebc1e4d1d7b59b4e5
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: in built-in dialogs exceed all the keypress buffer at once

>From upstream ec194e7fbd964f29e590d3b446db9dd3804e9e02

Changed paths:
    engines/ags/engine/ac/inv_window.cpp
    engines/ags/engine/gui/csci_dialog.cpp


diff --git a/engines/ags/engine/ac/inv_window.cpp b/engines/ags/engine/ac/inv_window.cpp
index 204edfd1d12..05d06c50e45 100644
--- a/engines/ags/engine/ac/inv_window.cpp
+++ b/engines/ags/engine/ac/inv_window.cpp
@@ -346,9 +346,13 @@ bool InventoryScreen::Run() {
 	// Run() can be called in a loop, so keep events going.
 	sys_evt_process_pending();
 
-	KeyInput ki;
-	if (run_service_key_controls(ki) && !_GP(play).IsIgnoringInput()) {
-		return false; // end inventory screen loop
+	// Handle all the buffered key events
+	while (ags_keyevent_ready()) {
+		KeyInput ki;
+		if (run_service_key_controls(ki) && !_GP(play).IsIgnoringInput()) {
+			ags_clear_input_buffer();
+			return false; // end inventory screen loop
+		}
 	}
 
 	update_audio_system_on_game_loop();
diff --git a/engines/ags/engine/gui/csci_dialog.cpp b/engines/ags/engine/gui/csci_dialog.cpp
index b33e47fd93d..61ca3d4c096 100644
--- a/engines/ags/engine/gui/csci_dialog.cpp
+++ b/engines/ags/engine/gui/csci_dialog.cpp
@@ -84,7 +84,6 @@ int CSCIDrawWindow(int xx, int yy, int wid, int hit) {
 		quit("Too many windows created.");
 
 	_G(windowcount)++;
-	//  ags_domouse(DOMOUSE_DISABLE);
 	xx -= 2;
 	yy -= 2;
 	wid += 4;
@@ -93,7 +92,6 @@ int CSCIDrawWindow(int xx, int yy, int wid, int hit) {
 	_G(oswi)[drawit].x = xx;
 	_G(oswi)[drawit].y = yy;
 	__my_wbutt(ds, 0, 0, wid - 1, hit - 1);    // wbutt goes outside its area
-	//  ags_domouse(DOMOUSE_ENABLE);
 	_G(oswi)[drawit].oldtop = _G(topwindowhandle);
 	_G(topwindowhandle) = drawit;
 	_G(oswi)[drawit].handle = _G(topwindowhandle);
@@ -105,11 +103,9 @@ int CSCIDrawWindow(int xx, int yy, int wid, int hit) {
 }
 
 void CSCIEraseWindow(int handl) {
-	//  ags_domouse(DOMOUSE_DISABLE);
 	_G(ignore_bounds)--;
 	_G(topwindowhandle) = _G(oswi)[handl].oldtop;
 	_G(oswi)[handl].handle = -1;
-	//  ags_domouse(DOMOUSE_ENABLE);
 	_G(windowcount)--;
 	clear_gui_screen();
 }
@@ -117,9 +113,7 @@ void CSCIEraseWindow(int handl) {
 int CSCIWaitMessage(CSCIMessage *cscim) {
 	for (int uu = 0; uu < MAXCONTROLS; uu++) {
 		if (_G(vobjs)[uu] != nullptr) {
-			//      ags_domouse(DOMOUSE_DISABLE);
 			_G(vobjs)[uu]->drawifneeded();
-			//      ags_domouse(DOMOUSE_ENABLE);
 		}
 	}
 
@@ -134,6 +128,9 @@ int CSCIWaitMessage(CSCIMessage *cscim) {
 		cscim->id = -1;
 		cscim->code = 0;
 		_G(smcode) = 0;
+		// NOTE: CSCIWaitMessage is supposed to report only single message,
+		// therefore we cannot process all buffered key presses here
+		// (unless the whole dialog system is rewritten).
 		KeyInput ki;
 		if (run_service_key_controls(ki) && !_GP(play).IsIgnoringInput()) {
 			int keywas = ki.Key;
@@ -210,9 +207,7 @@ int CSCICreateControl(int typeandflags, int xx, int yy, int wii, int hii, const
 
 	_G(vobjs)[usec]->typeandflags = typeandflags;
 	_G(vobjs)[usec]->wlevel = _G(topwindowhandle);
-	//  ags_domouse(DOMOUSE_DISABLE);
 	_G(vobjs)[usec]->draw(get_gui_screen());
-	//  ags_domouse(DOMOUSE_ENABLE);
 	return usec;
 }
 


Commit: ccbe6f541962d073209b20d48fbb025e4efcd4d3
    https://github.com/scummvm/scummvm/commit/ccbe6f541962d073209b20d48fbb025e4efcd4d3
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: in video_check_user_input() exceed all the keypress buffer

>From upstream f7b90bbaaa242e4dc79d26fdddaf7e269e7ce600 and part of
upstream 66738a0c4550ec349dcf45ec39030b56332e1ea8

Changed paths:
    engines/ags/engine/media/video/video.cpp


diff --git a/engines/ags/engine/media/video/video.cpp b/engines/ags/engine/media/video/video.cpp
index 8c2e8c70cc4..e4124edd0c1 100644
--- a/engines/ags/engine/media/video/video.cpp
+++ b/engines/ags/engine/media/video/video.cpp
@@ -111,16 +111,20 @@ static bool play_video(Video::VideoDecoder *decoder, const char *name, int flags
 			KeyInput key;
 			eAGSMouseButton mbut;
 			int mwheelz;
-			if (run_service_key_controls(key)) {
-				if (key.Key == 27 && skip >= VideoSkipEscape)
-					return true;
-				if (skip >= VideoSkipAnyKey)
-					return true;  // skip on any key
+			// Handle all the buffered key events
+			bool do_break = false;
+			while (ags_keyevent_ready()) {
+				if (run_service_key_controls(key)) {
+					if ((key.Key == eAGSKeyCodeEscape) && (skip == VideoSkipEscape))
+						do_break = true;
+					if (skip >= VideoSkipAnyKey)
+						do_break = true;  // skip on any key
+				}
 			}
-
-			if (run_service_mb_controls(mbut, mwheelz) && mbut >= kMouseNone && skip == VideoSkipKeyOrMouse) {
+			if (do_break)
+				return true; // skip on key press
+			if (run_service_mb_controls(mbut, mwheelz) && mbut >= kMouseNone && skip == VideoSkipKeyOrMouse)
 				return true; // skip on mouse click
-			}
 		}
 	}
 


Commit: 1d4d6d501e1797b968d1c6a6d45102810f50f2cb
    https://github.com/scummvm/scummvm/commit/1d4d6d501e1797b968d1c6a6d45102810f50f2cb
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-12-17T22:10:55+01:00

Commit Message:
AGS: Engine: corrected some of the key evt queue exceeding loops

Part of upstream 66738a0c4550ec349dcf45ec39030b56332e1ea8

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


diff --git a/engines/ags/engine/ac/inv_window.cpp b/engines/ags/engine/ac/inv_window.cpp
index 05d06c50e45..0faf37eddb1 100644
--- a/engines/ags/engine/ac/inv_window.cpp
+++ b/engines/ags/engine/ac/inv_window.cpp
@@ -347,13 +347,16 @@ bool InventoryScreen::Run() {
 	sys_evt_process_pending();
 
 	// Handle all the buffered key events
+	bool do_break = false;
 	while (ags_keyevent_ready()) {
 		KeyInput ki;
 		if (run_service_key_controls(ki) && !_GP(play).IsIgnoringInput()) {
 			ags_clear_input_buffer();
-			return false; // end inventory screen loop
+			do_break = true; // end inventory screen loop
 		}
 	}
+	if (do_break)
+		return false;
 
 	update_audio_system_on_game_loop();
 	refresh_gui_screen();




More information about the Scummvm-git-logs mailing list