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

criezy noreply at scummvm.org
Tue Jun 21 22:29:14 UTC 2022


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

Summary:
db1d5b17cd AGS: Tidy vsync setting methods in renderers
b3aed69af6 AGS: Implement toggling Vsync if the backends supports it
f70d871748 AGS: Prefer to use override specifier where necessary
4e9e0fcf15 AGS: Fixed parsing of legacy "game_scale_win" from 3.5.* config
0c936b888d AGS: Fixed GUI textual controls not redrawn when translation changes
025e89f6e3 AGS: Removed unused global variable
a336b97f4e AGS: Fixed few more warnings
76aebcd336 AGS: Tidy the quit message code and add comments
5089b28645 AGS: Added more logging for multitasking mode, switching in/out
2389e64223 AGS: Fixed character's loop fixup in UpdateMoveAndAnim()
fe8c21366a AGS: Added comments to ScriptSystem


Commit: db1d5b17cd916199fe00b6a99351ac3df9521667
    https://github.com/scummvm/scummvm/commit/db1d5b17cd916199fe00b6a99351ac3df9521667
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Tidy vsync setting methods in renderers

>From upstream 5ff955152c43f6adfe03298a7cac069efffbee4d

Changed paths:
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/ac/event.cpp
    engines/ags/engine/ac/system.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.h
    engines/ags/engine/gfx/graphics_driver.h


diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index d28e20a74e3..6d2754b57bb 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -693,7 +693,7 @@ void render_to_screen() {
 	construct_engine_overlay();
 
 	// only vsync in full screen mode, it makes things worse in a window
-	_G(gfxDriver)->EnableVsyncBeforeRender((_GP(scsystem).vsync > 0) && (!_GP(scsystem).windowed));
+	_G(gfxDriver)->SetVsync((_GP(scsystem).vsync > 0) && (!_GP(scsystem).windowed));
 
 	bool succeeded = false;
 	while (!succeeded) {
diff --git a/engines/ags/engine/ac/event.cpp b/engines/ags/engine/ac/event.cpp
index 56a149355cd..14328123abb 100644
--- a/engines/ags/engine/ac/event.cpp
+++ b/engines/ags/engine/ac/event.cpp
@@ -255,7 +255,6 @@ void process_event(const EventHappened *evp) {
 					boxhit = Math::Clamp(boxhit, 0, viewport.GetHeight());
 					int lxp = viewport.GetWidth() / 2 - boxwid / 2;
 					int lyp = viewport.GetHeight() / 2 - boxhit / 2;
-					_G(gfxDriver)->Vsync();
 					temp_scr->Blit(saved_backbuf, lxp, lyp, lxp, lyp,
 					               boxwid, boxhit);
 					render_to_screen();
diff --git a/engines/ags/engine/ac/system.cpp b/engines/ags/engine/ac/system.cpp
index 7c51648478f..c16de469bab 100644
--- a/engines/ags/engine/ac/system.cpp
+++ b/engines/ags/engine/ac/system.cpp
@@ -127,7 +127,7 @@ int System_GetVsync() {
 }
 
 void System_SetVsync(int newValue) {
-	if (ags_stricmp(_G(gfxDriver)->GetDriverID(), "D3D9") != 0)
+	if (_G(gfxDriver)->DoesSupportVsyncToggle())
 		_GP(scsystem).vsync = newValue;
 }
 
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.cpp b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
index d400241ae3f..fb3751450e7 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.cpp
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
@@ -505,9 +505,6 @@ void ScummVMRendererGraphicsDriver::Render() {
 	Render(0, 0, kFlip_None);
 }
 
-void ScummVMRendererGraphicsDriver::Vsync() {
-}
-
 Bitmap *ScummVMRendererGraphicsDriver::GetMemoryBackBuffer() {
 	return virtualScreen;
 }
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.h b/engines/ags/engine/gfx/ali_3d_scummvm.h
index ed55b2fb081..3b824dcfe3b 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.h
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.h
@@ -206,8 +206,11 @@ public:
 	bool SupportsGammaControl() override;
 	void SetGamma(int newGamma) override;
 	void UseSmoothScaling(bool /*enabled*/) override {}
-	void EnableVsyncBeforeRender(bool /*enabled*/) override {}
-	void Vsync() override;
+	bool DoesSupportVsyncToggle() override { return false; }
+	bool SetVsync(bool /*enabled*/) override {
+		/* TODO: support toggling; See Common::OSystem::kFeatureVSync */
+		return _mode.Vsync;
+	}
 	void RenderSpritesAtScreenResolution(bool /*enabled*/, int /*supersampling*/) override {}
 	bool RequiresFullRedrawEachFrame() override {
 		return false;
diff --git a/engines/ags/engine/gfx/graphics_driver.h b/engines/ags/engine/gfx/graphics_driver.h
index da1371827be..365b684db92 100644
--- a/engines/ags/engine/gfx/graphics_driver.h
+++ b/engines/ags/engine/gfx/graphics_driver.h
@@ -174,8 +174,10 @@ public:
 	// Bitmap must be of supported size and pixel format. If it's not the method will
 	// fail and optionally write wanted destination format into 'want_fmt' pointer.
 	virtual bool GetCopyOfScreenIntoBitmap(Shared::Bitmap *destination, bool at_native_res, GraphicResolution *want_fmt = nullptr) = 0;
-	virtual void EnableVsyncBeforeRender(bool enabled) = 0;
-	virtual void Vsync() = 0;
+	// Tells if the renderer supports toggling vsync after initializing the mode.
+	virtual bool DoesSupportVsyncToggle() = 0;
+	// Toggles vertical sync mode, if renderer supports one; returns the new state.
+	virtual bool SetVsync(bool enabled) = 0;
 	// Enables or disables rendering mode that draws sprite list directly into
 	// the final resolution, as opposed to drawing to native-resolution buffer
 	// and scaling to final frame. The effect may be that sprites that are


Commit: b3aed69af66285d58f9adedbc6ac3bf4a83d986e
    https://github.com/scummvm/scummvm/commit/b3aed69af66285d58f9adedbc6ac3bf4a83d986e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Implement toggling Vsync if the backends supports it

Changed paths:
    engines/ags/engine/gfx/ali_3d_scummvm.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.h


diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.cpp b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
index fb3751450e7..a97e275d628 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.cpp
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
@@ -117,6 +117,8 @@ bool ScummVMRendererGraphicsDriver::SetDisplayMode(const DisplayMode &mode) {
 	const int driver = GFX_SCUMMVM;
 	if (set_gfx_mode(driver, mode.Width, mode.Height, mode.ColorDepth) != 0)
 		return false;
+	if (g_system->hasFeature(OSystem::kFeatureVSync))
+		g_system->setFeatureState(OSystem::kFeatureVSync, mode.Vsync);
 
 	OnInit();
 	OnModeSet(mode);
@@ -208,6 +210,18 @@ void ScummVMRendererGraphicsDriver::SetGamma(int newGamma) {
 #endif
 }
 
+bool ScummVMRendererGraphicsDriver::DoesSupportVsyncToggle() {
+	return g_system->hasFeature(OSystem::kFeatureVSync);
+}
+
+bool ScummVMRendererGraphicsDriver::SetVsync(bool enabled) {
+	if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+		g_system->setFeatureState(OSystem::kFeatureVSync, enabled);
+		_mode.Vsync = g_system->getFeatureState(OSystem::kFeatureVSync);
+	}
+	return _mode.Vsync;
+}
+
 int ScummVMRendererGraphicsDriver::GetCompatibleBitmapFormat(int color_depth) {
 	return color_depth;
 }
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.h b/engines/ags/engine/gfx/ali_3d_scummvm.h
index 3b824dcfe3b..7f440aeec92 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.h
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.h
@@ -206,11 +206,8 @@ public:
 	bool SupportsGammaControl() override;
 	void SetGamma(int newGamma) override;
 	void UseSmoothScaling(bool /*enabled*/) override {}
-	bool DoesSupportVsyncToggle() override { return false; }
-	bool SetVsync(bool /*enabled*/) override {
-		/* TODO: support toggling; See Common::OSystem::kFeatureVSync */
-		return _mode.Vsync;
-	}
+	bool DoesSupportVsyncToggle() override;
+	bool SetVsync(bool enabled) override;
 	void RenderSpritesAtScreenResolution(bool /*enabled*/, int /*supersampling*/) override {}
 	bool RequiresFullRedrawEachFrame() override {
 		return false;


Commit: f70d871748596d01ddaf159b065cdc7fd4e734eb
    https://github.com/scummvm/scummvm/commit/f70d871748596d01ddaf159b065cdc7fd4e734eb
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Prefer to use override specifier where necessary

>From upstream 0d41b5ef0e2dadf24a4618a496b43630981687ff

Changed paths:
    engines/ags/engine/gfx/gfxfilter_scummvm_renderer.h


diff --git a/engines/ags/engine/gfx/gfxfilter_scummvm_renderer.h b/engines/ags/engine/gfx/gfxfilter_scummvm_renderer.h
index 5aaef8b8682..cbb2642fcce 100644
--- a/engines/ags/engine/gfx/gfxfilter_scummvm_renderer.h
+++ b/engines/ags/engine/gfx/gfxfilter_scummvm_renderer.h
@@ -38,9 +38,9 @@ namespace ALSW {
 
 class ScummVMRendererGfxFilter : public ScalingGfxFilter {
 public:
-	virtual ~ScummVMRendererGfxFilter() {}
+	~ScummVMRendererGfxFilter() override {}
 
-	virtual const GfxFilterInfo &GetInfo() const;
+	const GfxFilterInfo &GetInfo() const override;
 };
 
 } // namespace ALSW


Commit: 4e9e0fcf15d2e31bd7833022d3dd4b0e2dcf1df2
    https://github.com/scummvm/scummvm/commit/4e9e0fcf15d2e31bd7833022d3dd4b0e2dcf1df2
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Fixed parsing of legacy "game_scale_win" from 3.5.* config

>From upstream 0e592f18546d3d65e2cf7822a4f7063278beef06

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


diff --git a/engines/ags/engine/main/config.cpp b/engines/ags/engine/main/config.cpp
index e087eceabaa..fb525be80ce 100644
--- a/engines/ags/engine/main/config.cpp
+++ b/engines/ags/engine/main/config.cpp
@@ -244,7 +244,7 @@ static void read_legacy_graphics_config(const ConfigTree &cfg) {
 		break;
 		case kScreenDef_ByGameScaling:
 		{
-			int src_scale;
+			int src_scale = 0;
 			is_windowed ?
 				parse_legacy_scaling_option(CfgReadString(cfg, "graphics", "game_scale_win"), src_scale) :
 				parse_legacy_scaling_option(CfgReadString(cfg, "graphics", "game_scale_fs"), src_scale);


Commit: 0c936b888d7e8f1112b1bbcd829ca12d30516aae
    https://github.com/scummvm/scummvm/commit/0c936b888d7e8f1112b1bbcd829ca12d30516aae
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Fixed GUI textual controls not redrawn when translation changes

>From upstream 618d2e38a118f47389aaf7e57972b2520b81fc1b

Changed paths:
    engines/ags/engine/ac/game.cpp
    engines/ags/shared/gui/gui_main.cpp
    engines/ags/shared/gui/gui_main.h


diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 261b5365e0e..0ea6787f46d 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -665,6 +665,7 @@ int Game_ChangeTranslation(const char *newFilename) {
 	if ((newFilename == nullptr) || (newFilename[0] == 0)) { // switch back to default translation
 		close_translation();
 		_GP(usetup).translation = "";
+		GUI::MarkForTranslationUpdate();
 		return 1;
 	}
 
@@ -673,6 +674,7 @@ int Game_ChangeTranslation(const char *newFilename) {
 		return 0; // failed, kept previous translation
 
 	_GP(usetup).translation = newFilename;
+	GUI::MarkForTranslationUpdate();
 	return 1;
 }
 
diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 96cae7694ce..77c9a17f024 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -689,6 +689,21 @@ void MarkAllGUIForUpdate() {
 	}
 }
 
+void MarkForTranslationUpdate() {
+	for (auto &btn : _GP(guibuts)) {
+		if (btn.IsTranslated())
+			btn.MarkChanged();
+	}
+	for (auto &lbl : _GP(guilabels)) {
+		if (lbl.IsTranslated())
+			lbl.MarkChanged();
+	}
+	for (auto &list : _GP(guilist)) {
+		if (list.IsTranslated())
+			list.MarkChanged();
+	}
+}
+
 void MarkForFontUpdate(int font) {
 	for (auto &btn : _GP(guibuts)) {
 		if (btn.Font == font)
diff --git a/engines/ags/shared/gui/gui_main.h b/engines/ags/shared/gui/gui_main.h
index b5be1f763ff..625f23681c1 100644
--- a/engines/ags/shared/gui/gui_main.h
+++ b/engines/ags/shared/gui/gui_main.h
@@ -229,6 +229,8 @@ void DrawTextAlignedHor(Bitmap *ds, const char *text, int font, color_t text_col
 
 // Mark all existing GUI for redraw
 void MarkAllGUIForUpdate();
+// Mark all translatable GUI controls for redraw
+void MarkForTranslationUpdate();
 // Mark all GUI which use the given font for redraw
 void MarkForFontUpdate(int font);
 // Mark labels that acts as special text placeholders for redraw


Commit: 025e89f6e3b456e627d9421dedac8914bcc1a42f
    https://github.com/scummvm/scummvm/commit/025e89f6e3b456e627d9421dedac8914bcc1a42f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Removed unused global variable

(could be remains of an old audio threading code)

>From upstream a0424b98c6096da653824ec6fc03521f3583558e

Changed paths:
    engines/ags/engine/media/audio/audio.cpp
    engines/ags/globals.h


diff --git a/engines/ags/engine/media/audio/audio.cpp b/engines/ags/engine/media/audio/audio.cpp
index d79e7637e3d..dd6bb1146e5 100644
--- a/engines/ags/engine/media/audio/audio.cpp
+++ b/engines/ags/engine/media/audio/audio.cpp
@@ -765,8 +765,6 @@ void update_audio_system_on_game_loop() {
 
 	process_scheduled_music_update();
 
-	_G(audio_doing_crossfade) = true;
-
 	audio_update_polled_stuff();
 
 	if (_G(crossFading)) {
@@ -799,8 +797,6 @@ void update_audio_system_on_game_loop() {
 		}
 	}
 
-	_G(audio_doing_crossfade) = false;
-
 	if (_G(loopcounter) % 5 == 0) {
 		update_ambient_sound_vol();
 		update_directional_sound_vol();
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index f954f0b8939..15bad25e80b 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -299,7 +299,6 @@ public:
 	std::array<SOUNDCLIP *> *_audioChannels;
 	std::array<AmbientSound> *_ambient;
 
-	volatile bool _audio_doing_crossfade = false;
 	ScriptAudioChannel *_scrAudioChannel;
 	char _acaudio_buffer[256];
 	int _reserved_channel_count = 0;


Commit: a336b97f4e7a9a557fad6c39955cb8963cefc0cf
    https://github.com/scummvm/scummvm/commit/a336b97f4e7a9a557fad6c39955cb8963cefc0cf
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Fixed few more warnings

>From upstream 343dda7e508e5c3b6b50ad13756020e200d513ef

Changed paths:
    engines/ags/plugins/ags_plugin.cpp


diff --git a/engines/ags/plugins/ags_plugin.cpp b/engines/ags/plugins/ags_plugin.cpp
index 53727609a0e..1230daa470d 100644
--- a/engines/ags/plugins/ags_plugin.cpp
+++ b/engines/ags/plugins/ags_plugin.cpp
@@ -393,7 +393,7 @@ int IAGSEngine::GetNumObjects() {
 	return _G(croom)->numobj;
 }
 AGSObject *IAGSEngine::GetObject(int32 num) {
-	if (num >= (int32)_G(croom)->numobj)
+	if (num < 0 || static_cast<uint32_t>(num) >= _G(croom)->numobj)
 		quit("!IAGSEngine::GetObject: invalid object");
 
 	return (AGSObject *)&_G(croom)->obj[num];


Commit: 76aebcd336341995ffa8012493a5ce74c8a29402
    https://github.com/scummvm/scummvm/commit/76aebcd336341995ffa8012493a5ce74c8a29402
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Tidy the quit message code and add comments

>From upstream 3b4d21ab7025d4b66e7351639073f6d62e44f277

Changed paths:
    engines/ags/engine/main/game_run.cpp
    engines/ags/engine/main/quit.cpp
    engines/ags/engine/main/quit.h


diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 3144d1a5e69..2a12ecc0512 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -322,6 +322,7 @@ bool run_service_key_controls(KeyInput &out_key) {
 
 	// Alt+X, abort (but only once game is loaded)
 	if ((_G(displayed_room) >= 0) && (_GP(play).abort_key > 0 && agskey == _GP(play).abort_key)) {
+		Debug::Printf("Abort key pressed");
 		_G(check_dynamic_sprites_at_exit) = 0;
 		quit("!|");
 	}
diff --git a/engines/ags/engine/main/quit.cpp b/engines/ags/engine/main/quit.cpp
index 77a8413ad45..7603274a49f 100644
--- a/engines/ags/engine/main/quit.cpp
+++ b/engines/ags/engine/main/quit.cpp
@@ -94,7 +94,11 @@ void quit_shutdown_audio() {
 	shutdown_sound();
 }
 
-QuitReason quit_check_for_error_state(const char *&qmsg, String &alertis) {
+// Parses the quit message; returns:
+// * QuitReason - which is a code of the reason we're quitting (game error, etc);
+// * errmsg - a pure error message (extracted from the parsed string).
+// * alertis - a complex message to post into the engine output (stdout, log);
+QuitReason quit_check_for_error_state(const char *qmsg, String &errmsg, String &alertis) {
 	if (qmsg[0] == '|') {
 		return kQuit_GameRequest;
 	} else if (qmsg[0] == '!') {
@@ -117,35 +121,26 @@ QuitReason quit_check_for_error_state(const char *&qmsg, String &alertis) {
 
 		alertis.Append(cc_get_error().CallStack);
 
-		if (qreason != kQuit_UserAbort)
-			alertis.Append("\nError: ");
-		else
-			qmsg = "";
+		if (qreason != kQuit_UserAbort) {
+			alertis.AppendFmt("\nError: %s", qmsg);
+			errmsg = qmsg;
+		}
 		return qreason;
 	} else if (qmsg[0] == '%') {
 		qmsg++;
 		alertis.Format("A warning has been generated. This is not normally fatal, but you have selected "
 		               "to treat warnings as errors.\n"
-		               "(ACI version %s)\n\n%s\n", _G(EngineVersion).LongString.GetCStr(), cc_get_error().CallStack.GetCStr());
+		               "(ACI version %s)\n\n%s\n%s", _G(EngineVersion).LongString.GetCStr(), cc_get_error().CallStack.GetCStr(), qmsg);
+		errmsg = qmsg;
 		return kQuit_GameWarning;
 	} else {
 		alertis.Format("An internal error has occurred. Please note down the following information.\n"
 		               "(ACI version %s)\n"
-		               "\nError: ", _G(EngineVersion).LongString.GetCStr());
+		               "\nError: %s", _G(EngineVersion).LongString.GetCStr(), qmsg);
 		return kQuit_FatalError;
 	}
 }
 
-void quit_message_on_exit(const String &qmsg, String &alertis, QuitReason qreason) {
-	// successful exit or user abort displays no messages
-	if ((qreason & (kQuitKind_NormalExit | kQuit_UserAbort)) == 0 && !_G(handledErrorInEditor)) {
-		// Display the message (at this point the window still exists)
-		snprintf(_G(pexbuf), sizeof(_G(pexbuf)), "%s\n", qmsg.GetCStr());
-		alertis.Append(_G(pexbuf));
-		_G(platform)->DisplayAlert("%s", alertis.GetCStr());
-	}
-}
-
 void quit_release_data() {
 	resetRoomStatuses();
 	_GP(thisroom).Free();
@@ -181,19 +176,24 @@ void quit(const char *quitmsg) {
 }
 
 void quit_free() {
-	String alertis;
 	if (strlen(_G(quit_message)) == 0)
 		strcpy(_G(quit_message), "|bye!");
 
 	const char *quitmsg = _G(quit_message);
-	QuitReason qreason = quit_check_for_error_state(quitmsg, alertis);
+
+	Debug::Printf(kDbgMsg_Info, "Quitting the game...");
+
+	// NOTE: we must not use the quitmsg pointer past this step,
+	// as it may be from a plugin and we're about to free plugins
+	String errmsg, fullmsg;
+	QuitReason qreason = quit_check_for_error_state(quitmsg, errmsg, fullmsg);
 
 	if (qreason & kQuitKind_NormalExit)
 		save_config_file();
 
 	_G(handledErrorInEditor) = false;
 
-	quit_tell_editor_debugger(_G(quit_message), qreason);
+	quit_tell_editor_debugger(errmsg, qreason);
 
 	_G(our_eip) = 9900;
 
@@ -231,10 +231,13 @@ void quit_free() {
 
 	engine_shutdown_gfxmode();
 
-	quit_message_on_exit(quitmsg, alertis, qreason);
-
 	_G(platform)->PreBackendExit();
 
+	// On abnormal exit: display the message (at this point the window still exists)
+	if ((qreason & kQuitKind_NormalExit) == 0 && !_G(handledErrorInEditor)) {
+		_G(platform)->DisplayAlert("%s", fullmsg.GetCStr());
+	}
+
 	// release backed library
 	// WARNING: no Allegro objects should remain in memory after this,
 	// if their destruction is called later, program will crash!
diff --git a/engines/ags/engine/main/quit.h b/engines/ags/engine/main/quit.h
index cd12100f3d8..efd00121da3 100644
--- a/engines/ags/engine/main/quit.h
+++ b/engines/ags/engine/main/quit.h
@@ -25,9 +25,15 @@
 namespace AGS3 {
 
 enum QuitReason {
+	// Flags defining the base reason, could be subtyped by summing
+	// with the other flags:
+	// - normal exit means everything is fine
 	kQuitKind_NormalExit = 0x01,
+	// - game was requested to abort
 	kQuitKind_DeliberateAbort = 0x02,
+	// - something was wrong with the game logic (script)
 	kQuitKind_GameException = 0x04,
+	// - something was wrong with the engine, which it could not handle
 	kQuitKind_EngineException = 0x08,
 
 	// user closed the window or script command QuitGame was executed


Commit: 5089b286450089cd6e8cb54de76937d458d14de0
    https://github.com/scummvm/scummvm/commit/5089b286450089cd6e8cb54de76937d458d14de0
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Added more logging for multitasking mode, switching in/out

>From upstream d3925672f5b96fab3308b606eb6f38dc279636d7

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


diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 6d2754b57bb..8caa8119aec 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -715,9 +715,15 @@ void render_to_screen() {
 
 		succeeded = true;
 		/*}
-		catch (Ali3DFullscreenLostException)
-		{
-		    platform->Delay(500);
+		catch (Ali3DFullscreenLostException e) {
+			Debug::Printf("Renderer exception: %s", e._message);
+			platform->Delay(500);
+		}
+		catch (Ali3DException e) {
+			Debug::Printf("Renderer exception: %s", e._message);
+		}
+		catch (...) {
+			Debug::Printf("Unknown renderer exception");
 		}*/
 	}
 }
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 0ea6787f46d..adee37d2a81 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -1191,6 +1191,7 @@ int __GetLocationType(int xxx, int yyy, int allowHotspot0) {
 
 // Called whenever game looses input focus
 void display_switch_out() {
+	Debug::Printf("Switching out from the game");
 	_G(switched_away) = true;
 	ags_clear_input_state();
 	// Always unlock mouse when switching out from the game
@@ -1199,6 +1200,7 @@ void display_switch_out() {
 
 // Called when game looses input focus and must pause until focus is returned
 void display_switch_out_suspend() {
+	Debug::Printf("Suspending the game on switch out");
 	_G(switching_away_from_game)++;
 	_G(game_update_suspend)++;
 	display_switch_out();
@@ -1225,6 +1227,7 @@ void display_switch_out_suspend() {
 
 // Called whenever game gets input focus
 void display_switch_in() {
+	Debug::Printf("Switching back into the game");
 	ags_clear_input_state();
 	// If auto lock option is set, lock mouse to the game window
 	if (_GP(usetup).mouse_auto_lock && _GP(scsystem).windowed)
@@ -1234,6 +1237,7 @@ void display_switch_in() {
 
 // Called when game gets input focus and must resume after pause
 void display_switch_in_resume() {
+	Debug::Printf("Resuming the game on switch in");
 	display_switch_in();
 
 	// Resume all the sounds
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index b9c7ecfcdf4..f75a0651f73 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -639,14 +639,18 @@ void SetMultitasking(int mode) {
 		quit("!SetMultitasking: invalid mode parameter");
 
 	if (_GP(usetup).override_multitasking >= 0) {
+		Debug::Printf("SetMultitasking: overridden by user config: %d -> %d", mode, _GP(usetup).override_multitasking);
 		mode = _GP(usetup).override_multitasking;
 	}
 
 	// Don't allow background running if full screen
-	if ((mode == 1) && (!_GP(scsystem).windowed))
+	if ((mode == 1) && (!_GP(scsystem).windowed)) {
+		Debug::Printf("SetMultitasking: overridden by fullscreen: %d -> %d", mode, 0);
 		mode = 0;
+	}
 
 	// Install engine callbacks for switching in and out the window
+	Debug::Printf("SetMultitasking: mode %d", mode);
 	if (mode == 0) {
 		sys_set_background_mode(false);
 		sys_evt_set_focus_callbacks(display_switch_in_resume, display_switch_out_suspend);


Commit: 2389e64223c66353a568b021eea6458de0c07ac2
    https://github.com/scummvm/scummvm/commit/2389e64223c66353a568b021eea6458de0c07ac2
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Fixed character's loop fixup in UpdateMoveAndAnim()

Was broken by 7a1ee192e2
Fixes bug #13477 AGS: Heroine's Quest intro shows portrait bug

This old commit was trying to fix a problem in old game(s), when
character was set to a loop with no frames. In such case the old
engine would seek for the first loop with frames, starting with 0.
The condition for doing so was made incorrect though: instead of
testing simply for a empty loop, it tested for frame number being
outside of the current loop's frame range.
This broke games where e.g. some walking view's loops were shorter
than the others.

A replacement is a condition that tests exactly for an empty loop
instead. The frame exceeding a loop's frame count is fixed later
along the way, so it's not a problem here.

>From upstream ac73a555d737fb3f759cc7da9eeaf488a3bdcb2f

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


diff --git a/engines/ags/engine/ac/character_info_engine.cpp b/engines/ags/engine/ac/character_info_engine.cpp
index d661f358059..e201c74422b 100644
--- a/engines/ags/engine/ac/character_info_engine.cpp
+++ b/engines/ags/engine/ac/character_info_engine.cpp
@@ -78,7 +78,7 @@ void CharacterInfo::UpdateMoveAndAnim(int &char_index, CharacterExtras *chex, st
 
 	// Fixup character's view when possible
 	if (view >= 0 &&
-		(loop >= _GP(views)[view].numLoops || frame >= _GP(views)[view].loops[loop].numFrames)) {
+		(loop >= _GP(views)[view].numLoops || _GP(views)[view].loops[loop].numFrames == 0)) {
 		for (loop = 0;
 			(loop < _GP(views)[view].numLoops) && (_GP(views)[view].loops[loop].numFrames == 0); ++loop) {
 		}


Commit: fe8c21366a8da263a7ff74c5c1e9cd818636ae1d
    https://github.com/scummvm/scummvm/commit/fe8c21366a8da263a7ff74c5c1e9cd818636ae1d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-21T23:28:01+01:00

Commit Message:
AGS: Added comments to ScriptSystem

>From upstream 9698d329e84ce4450aeb0bd3fbc3b43b8c29a3e2

Changed paths:
    engines/ags/engine/ac/dynobj/script_system.h


diff --git a/engines/ags/engine/ac/dynobj/script_system.h b/engines/ags/engine/ac/dynobj/script_system.h
index 46d44b95454..89bad5b2a2c 100644
--- a/engines/ags/engine/ac/dynobj/script_system.h
+++ b/engines/ags/engine/ac/dynobj/script_system.h
@@ -19,6 +19,13 @@
  *
  */
 
+// ScriptSystem is a readable/writeable struct which has been exposed to
+// script in older versions of API (deprecated).
+// WARNING: it *MUST* keep its size exact to avoid breaking address offsets
+// when running old scripts. In case of emergency you may use its reserved
+// fields, but it's not recommended to do, as this struct is not a part of
+// the modern API anymore.
+
 #ifndef AGS_ENGINE_DYNOBJ_SCRIPT_SYSTEM_H
 #define AGS_ENGINE_DYNOBJ_SCRIPT_SYSTEM_H
 
@@ -26,14 +33,16 @@ namespace AGS3 {
 
 // The text script's "system" struct
 struct ScriptSystem {
-	int width, height;
-	int coldepth;
-	int os;
-	int windowed;
-	int vsync;
-	int viewport_width, viewport_height;
-	char aci_version[10]; // FIXME this when possible, version format is different now
-	int reserved[5];  // so that future scripts don't overwrite data
+	int width = 0; // game screen width
+	int height = 0; // game screen height
+	int coldepth = 0; // game's color depth
+	int os = 0; // operating system's code (see eScriptSystemOSID)
+	int windowed = 0; // windowed/fullscreen flag
+	int vsync = 0; // vertical sync flag
+	int viewport_width = 0; // game viewport width (normal or letterboxed)
+	int viewport_height = 0; // game viewport height (normal or letterboxed)
+	char aci_version[10]{}; // engine version string (informational)
+	int reserved[5]{}; // reserved fields
 };
 
 } // namespace AGS3




More information about the Scummvm-git-logs mailing list