[Scummvm-git-logs] scummvm master -> 119e09e56e02b424c6f24ffee7293353e7459775

criezy noreply at scummvm.org
Fri Jun 24 19:56:11 UTC 2022


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

Summary:
4f90db8fb4 AGS: Small correction to the hung script loop check
e9c84767f7 AGS: Merged BitmapFlip with engine's GlobalFlipType (same values)
f52c6a25ab AGS: Fixed forgot to save SetMultitasking in usetup.multitasking
b042a703d2 AGS: Hotfixed potential buffer overflow in check_for_messages_...
119e09e56e AGS: Removed a too early call to pl_stop_plugins() and fixed another


Commit: 4f90db8fb47a306e739c4f61783251304ebc3ea7
    https://github.com/scummvm/scummvm/commit/4f90db8fb47a306e739c4f61783251304ebc3ea7
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-24T20:54:42+01:00

Commit Message:
AGS: Small correction to the hung script loop check

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


diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index 4f7f7df6844..4e4beb20150 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -437,7 +437,7 @@ int ccInstance::Run(int32_t curpc) {
 	int32_t thisbase[MAXNEST], funcstart[MAXNEST];
 	int was_just_callas = -1;
 	int curnest = 0;
-	int loopIterations = 0;
+	unsigned loopIterations = 0;
 	int num_args_to_func = -1;
 	int next_call_needs_object = 0;
 	int loopIterationCheckDisabled = 0;
@@ -794,12 +794,12 @@ int ccInstance::Run(int32_t curpc) {
 					_lastAliveTs = now;
 					timeout_warn = false;
 					loopIterations = 0;
-				} else if ((loopIterationCheckDisabled == 0) && (++loopIterations > (int)_G(maxWhileLoops))) {
-					cc_error("!Script appears to be hung (a while loop ran %d times). The problem may be in a calling function; check the call stack.", loopIterations);
+				} else if ((loopIterationCheckDisabled == 0) && (_G(maxWhileLoops) > 0) && (++loopIterations > _G(maxWhileLoops))) {
+					cc_error("!Script appears to be hung (a while loop ran %d times). The problem may be in a calling function; check the call stack.", (int)loopIterations);
 					return -1;
 				} else if (test_dur > timeout) {
 					// minimal timeout occured
-					if (test_dur.count() > timeout_abort.count()) {
+					if ((timeout_abort.count() > 0) && (test_dur.count() > timeout_abort.count())) {
 						// critical timeout occured
 						/* CHECKME: disabled, because not working well
 						if (loopIterationCheckDisabled == 0) {
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index ae63f666452..b3d6bbb5391 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -1284,10 +1284,10 @@ public:
 	unsigned _timeoutCheckMs = 60u;
 	// Critical timeout: how much time may pass without any engine update
 	// before we abort or post a warning
-	unsigned _timeoutAbortMs = 60u * 10;
+	unsigned _timeoutAbortMs = 0u;
 	// Maximal while loops without any engine update in between,
 	// after which the interpreter will abort
-	unsigned _maxWhileLoops = 150000u;
+	unsigned _maxWhileLoops = 0u;
 	ccInstance *_loadedInstances[MAX_LOADED_INSTANCES];
 
 	/**@}*/


Commit: e9c84767f735314ea675a42989e16e6758470cfd
    https://github.com/scummvm/scummvm/commit/e9c84767f735314ea675a42989e16e6758470cfd
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-24T20:54:47+01:00

Commit Message:
AGS: Merged BitmapFlip with engine's GlobalFlipType (same values)

>From upstream a747deafe67d536b6bcaf408077ca83f6e61a33d

Changed paths:
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/ac/draw.h
    engines/ags/engine/ac/dynamic_sprite.cpp
    engines/ags/engine/ac/inv_window.cpp
    engines/ags/engine/ac/view_frame.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.h
    engines/ags/engine/gfx/gfx_defines.h
    engines/ags/engine/gfx/gfx_driver_base.cpp
    engines/ags/engine/gfx/gfx_driver_base.h
    engines/ags/engine/gfx/graphics_driver.h
    engines/ags/shared/gfx/allegro_bitmap.cpp
    engines/ags/shared/gfx/allegro_bitmap.h
    engines/ags/shared/gfx/bitmap.h
    engines/ags/shared/gfx/gfx_def.h


diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 455bbad155b..c1525ae1ace 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -685,7 +685,7 @@ void render_black_borders() {
 void render_to_screen() {
 	// Stage: final plugin callback (still drawn on game screen
 	if (pl_any_want_hook(AGSE_FINALSCREENDRAW)) {
-		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetMainViewport(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GlobalFlipType)_GP(play).screen_flipped);
+		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetMainViewport(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GraphicFlip)_GP(play).screen_flipped);
 		_G(gfxDriver)->DrawSprite(AGSE_FINALSCREENDRAW, 0, nullptr);
 		_G(gfxDriver)->EndSpriteBatch();
 	}
@@ -703,7 +703,7 @@ void render_to_screen() {
 		const Rect &viewport = _GP(play).GetMainViewport();
 		if (_GP(play).shake_screen_yoff > 0 && !_G(gfxDriver)->RequiresFullRedrawEachFrame())
 			_G(gfxDriver)->ClearRectangle(viewport.Left, viewport.Top, viewport.GetWidth() - 1, _GP(play).shake_screen_yoff, nullptr);
-		_G(gfxDriver)->Render(0, _GP(play).shake_screen_yoff, (GlobalFlipType)_GP(play).screen_flipped);
+		_G(gfxDriver)->Render(0, _GP(play).shake_screen_yoff, (GraphicFlip)_GP(play).screen_flipped);
 
 #if AGS_PLATFORM_OS_ANDROID
 		if (_GP(game).color_depth == 1)
@@ -1090,8 +1090,8 @@ void apply_tint_or_light(int actspsindex, int light_level,
 	}
 }
 
-Bitmap *transform_sprite(Bitmap *src, bool src_has_alpha, std::unique_ptr<Bitmap> &dst, const Size dst_sz, BitmapFlip flip) {
-	if ((src->GetSize() == dst_sz) && (flip == kBitmap_NoFlip))
+Bitmap *transform_sprite(Bitmap *src, bool src_has_alpha, std::unique_ptr<Bitmap> &dst, const Size dst_sz, GraphicFlip flip) {
+	if ((src->GetSize() == dst_sz) && (flip == kFlip_None))
 		return src; // No transform: return source image
 
 	recycle_bitmap(dst, src->GetColorDepth(), dst_sz.Width, dst_sz.Height, true);
@@ -1105,14 +1105,14 @@ Bitmap *transform_sprite(Bitmap *src, bool src_has_alpha, std::unique_ptr<Bitmap
 		if (_G(in_new_room) > 0)
 			select_palette(_G(palette));
 
-		if (flip != kBitmap_NoFlip) {
+		if (flip != kFlip_None) {
 			Bitmap tempbmp;
 			tempbmp.CreateTransparent(dst_sz.Width, dst_sz.Height, src->GetColorDepth());
 			if ((IS_ANTIALIAS_SPRITES) && !src_has_alpha)
 				tempbmp.AAStretchBlt(src, RectWH(dst_sz), kBitmap_Transparency);
 			else
 				tempbmp.StretchBlt(src, RectWH(dst_sz), kBitmap_Transparency);
-			dst->FlipBlt(&tempbmp, 0, 0, kBitmap_HFlip);
+			dst->FlipBlt(&tempbmp, 0, 0, kFlip_Horizontal);
 		} else {
 			if ((IS_ANTIALIAS_SPRITES) && !src_has_alpha)
 				dst->AAStretchBlt(src, RectWH(dst_sz), kBitmap_Transparency);
@@ -1124,7 +1124,7 @@ Bitmap *transform_sprite(Bitmap *src, bool src_has_alpha, std::unique_ptr<Bitmap
 			unselect_palette();
 	} else {
 		// If not scaled, then simply blit mirrored
-		dst->FlipBlt(src, 0, 0, kBitmap_HFlip);
+		dst->FlipBlt(src, 0, 0, kFlip_Horizontal);
 	}
 	return dst.get(); // return transformed result
 }
@@ -1136,7 +1136,7 @@ Bitmap *transform_sprite(Bitmap *src, bool src_has_alpha, std::unique_ptr<Bitmap
 static bool scale_and_flip_sprite(int useindx, int sppic, int newwidth, int newheight, bool hmirror) {
 	Bitmap *src = _GP(spriteset)[sppic];
 	Bitmap *result = transform_sprite(src, (_GP(game).SpriteInfos[sppic].Flags & SPF_ALPHACHANNEL) != 0,
-		_GP(actsps)[useindx].Bmp, Size(newwidth, newheight), hmirror ? kBitmap_HFlip : kBitmap_NoFlip);
+		_GP(actsps)[useindx].Bmp, Size(newwidth, newheight), hmirror ? kFlip_Horizontal : kFlip_None);
 	return result != src;
 }
 
@@ -2066,7 +2066,7 @@ static void construct_room_view() {
 		                           0.f);
 		if (_G(gfxDriver)->RequiresFullRedrawEachFrame()) {
 			// we draw everything as a sprite stack
-			_G(gfxDriver)->BeginSpriteBatch(view_rc, room_trans, Point(0, _GP(play).shake_screen_yoff), (GlobalFlipType)_GP(play).screen_flipped);
+			_G(gfxDriver)->BeginSpriteBatch(view_rc, room_trans, Point(0, _GP(play).shake_screen_yoff), (GraphicFlip)_GP(play).screen_flipped);
 		} else {
 			if (_GP(CameraDrawData)[viewport->GetID()].Frame == nullptr && _GP(CameraDrawData)[viewport->GetID()].IsOverlap) {
 				// room background is prepended to the sprite stack
@@ -2095,7 +2095,7 @@ static void construct_room_view() {
 
 // Schedule ui rendering
 static void construct_ui_view() {
-	_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetUIViewportAbs(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GlobalFlipType)_GP(play).screen_flipped);
+	_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetUIViewportAbs(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GraphicFlip)_GP(play).screen_flipped);
 	draw_gui_and_overlays();
 	_G(gfxDriver)->EndSpriteBatch();
 	clear_draw_list();
@@ -2198,7 +2198,7 @@ void construct_game_screen_overlay(bool draw_mouse) {
 	if (pl_any_want_hook(AGSE_POSTSCREENDRAW)) {
 		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetMainViewport(),
 			SpriteTransform(), Point(0, _GP(play).shake_screen_yoff),
-			(GlobalFlipType)_GP(play).screen_flipped);
+			(GraphicFlip)_GP(play).screen_flipped);
 		_G(gfxDriver)->DrawSprite(AGSE_POSTSCREENDRAW, 0, nullptr);
 		_G(gfxDriver)->EndSpriteBatch();
 	}
@@ -2237,7 +2237,7 @@ void construct_game_screen_overlay(bool draw_mouse) {
 
 	if (_GP(play).screen_is_faded_out == 0) {
 		// Stage: mouse cursor
-		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetMainViewport(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GlobalFlipType)_GP(play).screen_flipped);
+		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetMainViewport(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GraphicFlip)_GP(play).screen_flipped);
 		if (draw_mouse && !_GP(play).mouse_cursor_hidden) {
 			_G(gfxDriver)->DrawSprite(_G(mousex) - _G(hotx), _G(mousey) - _G(hoty), _G(mouseCursor));
 			invalidate_sprite(_G(mousex) - _G(hotx), _G(mousey) - _G(hoty), _G(mouseCursor), false);
@@ -2400,7 +2400,7 @@ void render_graphics(IDriverDependantBitmap *extraBitmap, int extraX, int extraY
 	// TODO: extraBitmap is a hack, used to place an additional gui element
 	// on top of the screen. Normally this should be a part of the game UI stage.
 	if (extraBitmap != nullptr) {
-		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetUIViewportAbs(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GlobalFlipType)_GP(play).screen_flipped);
+		_G(gfxDriver)->BeginSpriteBatch(_GP(play).GetUIViewportAbs(), SpriteTransform(), Point(0, _GP(play).shake_screen_yoff), (GraphicFlip)_GP(play).screen_flipped);
 		invalidate_sprite(extraX, extraY, extraBitmap, false);
 		_G(gfxDriver)->DrawSprite(extraX, extraY, extraBitmap);
 		_G(gfxDriver)->EndSpriteBatch();
diff --git a/engines/ags/engine/ac/draw.h b/engines/ags/engine/ac/draw.h
index 30e7ea78dc0..e6f1b9a7cfe 100644
--- a/engines/ags/engine/ac/draw.h
+++ b/engines/ags/engine/ac/draw.h
@@ -184,7 +184,7 @@ void draw_gui_sprite(Shared::Bitmap *ds, bool use_alpha, int xpos, int ypos,
 // * if transformation is necessary - writes into dst and returns dst;
 // * if no transformation is necessary - simply returns src;
 Shared::Bitmap *transform_sprite(Shared::Bitmap *src, bool src_has_alpha, std::unique_ptr<Shared::Bitmap> &dst,
-	const Size dst_sz, Shared::BitmapFlip flip = Shared::kBitmap_NoFlip);
+	const Size dst_sz, Shared::GraphicFlip flip = Shared::kFlip_None);
 // Render game on screen
 void render_to_screen();
 // Callbacks for the graphics driver
diff --git a/engines/ags/engine/ac/dynamic_sprite.cpp b/engines/ags/engine/ac/dynamic_sprite.cpp
index e6b3532bf17..8992b0fe7b6 100644
--- a/engines/ags/engine/ac/dynamic_sprite.cpp
+++ b/engines/ags/engine/ac/dynamic_sprite.cpp
@@ -125,8 +125,8 @@ void DynamicSprite_Flip(ScriptDynamicSprite *sds, int direction) {
 	// resize the sprite to the requested size
 	Bitmap *newPic = BitmapHelper::CreateTransparentBitmap(_GP(game).SpriteInfos[sds->slot].Width, _GP(game).SpriteInfos[sds->slot].Height, _GP(spriteset)[sds->slot]->GetColorDepth());
 
-	// AGS script FlipDirection corresponds to internal BitmapFlip
-	newPic->FlipBlt(_GP(spriteset)[sds->slot], 0, 0, static_cast<BitmapFlip>(direction));
+	// AGS script FlipDirection corresponds to internal GraphicFlip
+	newPic->FlipBlt(_GP(spriteset)[sds->slot], 0, 0, static_cast<GraphicFlip>(direction));
 	delete _GP(spriteset)[sds->slot];
 
 	// replace the bitmap in the sprite set
diff --git a/engines/ags/engine/ac/inv_window.cpp b/engines/ags/engine/ac/inv_window.cpp
index d7fd0ea1a12..442faf5ca0f 100644
--- a/engines/ags/engine/ac/inv_window.cpp
+++ b/engines/ags/engine/ac/inv_window.cpp
@@ -323,7 +323,7 @@ void InventoryScreen::Draw(Bitmap *ds) {
 	if (top_item > 0)
 		wputblock(ds, windowwid - ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(2), arrowblock, 1);
 	if (top_item + num_visible_items < numitems)
-		arrowblock->FlipBlt(arrowblock, windowwid - ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(4) + ARROWBUTTONWID, Shared::kBitmap_VFlip);
+		arrowblock->FlipBlt(arrowblock, windowwid - ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(4) + ARROWBUTTONWID, Shared::kFlip_Vertical);
 	delete arrowblock;
 }
 
diff --git a/engines/ags/engine/ac/view_frame.cpp b/engines/ags/engine/ac/view_frame.cpp
index 6cd0333a1c9..07301a5579c 100644
--- a/engines/ags/engine/ac/view_frame.cpp
+++ b/engines/ags/engine/ac/view_frame.cpp
@@ -156,14 +156,14 @@ void DrawViewFrame(Bitmap *ds, const ViewFrame *vframe, int x, int y, bool alpha
 		Bitmap *src = vf_bmp;
 		if (vframe->flags & VFLG_FLIPSPRITE) {
 			src = new Bitmap(vf_bmp->GetWidth(), vf_bmp->GetHeight(), vf_bmp->GetColorDepth());
-			src->FlipBlt(vf_bmp, 0, 0, Shared::kBitmap_HFlip);
+			src->FlipBlt(vf_bmp, 0, 0, Shared::kFlip_Horizontal);
 		}
 		draw_sprite_support_alpha(ds, true, x, y, src, (_GP(game).SpriteInfos[vframe->pic].Flags & SPF_ALPHACHANNEL) != 0);
 		if (src != vf_bmp)
 			delete src;
 	} else {
 		if (vframe->flags & VFLG_FLIPSPRITE)
-			ds->FlipBlt(_GP(spriteset)[vframe->pic], x, y, Shared::kBitmap_HFlip);
+			ds->FlipBlt(_GP(spriteset)[vframe->pic], x, y, Shared::kFlip_Horizontal);
 		else
 			ds->Blit(_GP(spriteset)[vframe->pic], x, y, Shared::kBitmap_Transparency);
 	}
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.cpp b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
index a97e275d628..2ed1ec6cab3 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.cpp
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
@@ -495,7 +495,7 @@ void ScummVMRendererGraphicsDriver::BlitToScreen() {
 		_screen->update();
 }
 
-void ScummVMRendererGraphicsDriver::Render(int /*xoff*/, int /*yoff*/, GlobalFlipType flip) {
+void ScummVMRendererGraphicsDriver::Render(int /*xoff*/, int /*yoff*/, GraphicFlip flip) {
 	switch (flip) {
 	case kFlip_Both:
 		_renderFlip = (RendererFlip)(FLIP_HORIZONTAL | FLIP_VERTICAL);
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.h b/engines/ags/engine/gfx/ali_3d_scummvm.h
index 7f440aeec92..f8f43f2b090 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.h
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.h
@@ -198,7 +198,7 @@ public:
 
 	void RenderToBackBuffer() override;
 	void Render() override;
-	void Render(int xoff, int yoff, GlobalFlipType flip) override;
+	void Render(int xoff, int yoff, Shared::GraphicFlip flip) override;
 	bool GetCopyOfScreenIntoBitmap(Bitmap *destination, bool at_native_res, GraphicResolution *want_fmt) override;
 	void FadeOut(int speed, int targetColourRed, int targetColourGreen, int targetColourBlue) override;
 	void FadeIn(int speed, PALETTE pal, int targetColourRed, int targetColourGreen, int targetColourBlue) override;
diff --git a/engines/ags/engine/gfx/gfx_defines.h b/engines/ags/engine/gfx/gfx_defines.h
index bfc88ab94c3..69835bf1c32 100644
--- a/engines/ags/engine/gfx/gfx_defines.h
+++ b/engines/ags/engine/gfx/gfx_defines.h
@@ -29,14 +29,6 @@ namespace AGS3 {
 namespace AGS {
 namespace Engine {
 
-// TODO: find the way to merge this with sprite batch transform
-enum GlobalFlipType {
-	kFlip_None,
-	kFlip_Horizontal, // this means - mirror over horizontal middle line
-	kFlip_Vertical,   // this means - mirror over vertical middle line
-	kFlip_Both
-};
-
 // GraphicResolution struct determines image size and color depth
 struct GraphicResolution : Size {
 	int32_t ColorDepth; // color depth in bits per pixel
diff --git a/engines/ags/engine/gfx/gfx_driver_base.cpp b/engines/ags/engine/gfx/gfx_driver_base.cpp
index 6efab7c00ae..deefc5e10d0 100644
--- a/engines/ags/engine/gfx/gfx_driver_base.cpp
+++ b/engines/ags/engine/gfx/gfx_driver_base.cpp
@@ -66,7 +66,7 @@ Rect GraphicsDriverBase::GetRenderDestination() const {
 }
 
 void GraphicsDriverBase::BeginSpriteBatch(const Rect &viewport, const SpriteTransform &transform,
-	const Point offset, GlobalFlipType flip, PBitmap surface) {
+	const Point offset, GraphicFlip flip, PBitmap surface) {
 	_spriteBatchDesc.push_back(SpriteBatchDesc(_actSpriteBatch, viewport, transform, offset, flip, surface));
 	_actSpriteBatch = _spriteBatchDesc.size() - 1;
 	InitSpriteBatch(_actSpriteBatch, _spriteBatchDesc[_actSpriteBatch]);
diff --git a/engines/ags/engine/gfx/gfx_driver_base.h b/engines/ags/engine/gfx/gfx_driver_base.h
index e178ddcf1bf..e7003528725 100644
--- a/engines/ags/engine/gfx/gfx_driver_base.h
+++ b/engines/ags/engine/gfx/gfx_driver_base.h
@@ -32,6 +32,7 @@
 #include "engines/ags/lib/std/map.h"
 #include "ags/lib/std/vector.h"
 #include "ags/engine/gfx/ddb.h"
+#include "ags/shared/gfx/gfx_def.h"
 #include "ags/engine/gfx/graphics_driver.h"
 #include "ags/shared/util/scaling.h"
 
@@ -53,13 +54,13 @@ struct SpriteBatchDesc {
 	// Global node offset applied to the whole batch as the last transform
 	Point                    Offset;
 	// Global node flip applied to the whole batch as the last transform
-	GlobalFlipType           Flip = kFlip_None;
+	Shared::GraphicFlip      Flip = Shared::kFlip_None;
 	// Optional bitmap to draw sprites upon. Used exclusively by the software rendering mode.
 	PBitmap                  Surface;
 
 	SpriteBatchDesc() = default;
 	SpriteBatchDesc(uint32_t parent, const Rect viewport, const SpriteTransform & transform, const Point offset = Point(),
-		GlobalFlipType flip = kFlip_None, PBitmap surface = nullptr)
+		Shared::GraphicFlip flip = Shared::kFlip_None, PBitmap surface = nullptr)
 		: Parent(parent)
 		, Viewport(viewport)
 		, Transform(transform)
@@ -104,7 +105,7 @@ public:
 	Rect        GetRenderDestination() const override;
 
 	void        BeginSpriteBatch(const Rect &viewport, const SpriteTransform &transform,
-	                             const Point offset = Point(), GlobalFlipType flip = kFlip_None, PBitmap surface = nullptr) override;
+	                             const Point offset = Point(), Shared::GraphicFlip flip = Shared::kFlip_None, PBitmap surface = nullptr) override;
 	void        EndSpriteBatch() override;
 	void        ClearDrawLists() override;
 
diff --git a/engines/ags/engine/gfx/graphics_driver.h b/engines/ags/engine/gfx/graphics_driver.h
index 365b684db92..92012fdf12a 100644
--- a/engines/ags/engine/gfx/graphics_driver.h
+++ b/engines/ags/engine/gfx/graphics_driver.h
@@ -31,6 +31,7 @@
 //#include "math/matrix.h"
 #include "ags/lib/std/memory.h"
 #include "ags/lib/allegro.h" // RGB, PALETTE
+#include "ags/shared/gfx/gfx_def.h"
 #include "ags/engine/gfx/gfx_defines.h"
 #include "ags/engine/gfx/gfx_mode_list.h"
 #include "ags/shared/util/geometry.h"
@@ -152,7 +153,7 @@ public:
 	// Beginning a batch while the previous was not ended will create a sub-batch
 	// (think of it as of a child scene node).
 	virtual void BeginSpriteBatch(const Rect &viewport, const SpriteTransform &transform,
-		const Point offset = Point(), GlobalFlipType flip = kFlip_None, PBitmap surface = nullptr) = 0;
+		const Point offset = Point(), Shared::GraphicFlip flip = Shared::kFlip_None, PBitmap surface = nullptr) = 0;
 	// Ends current sprite batch
 	virtual void EndSpriteBatch() = 0;
 	// Adds sprite to the active batch
@@ -169,7 +170,7 @@ public:
 	// Renders with additional final offset and flip
 	// TODO: leftover from old code, solely for software renderer; remove when
 	// software mode either discarded or scene node graph properly implemented.
-	virtual void Render(int xoff, int yoff, GlobalFlipType flip) = 0;
+	virtual void Render(int xoff, int yoff, Shared::GraphicFlip flip) = 0;
 	// Copies contents of the game screen into bitmap using simple blit or pixel copy.
 	// 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.
diff --git a/engines/ags/shared/gfx/allegro_bitmap.cpp b/engines/ags/shared/gfx/allegro_bitmap.cpp
index ee43959f64b..ac5f16d98c5 100644
--- a/engines/ags/shared/gfx/allegro_bitmap.cpp
+++ b/engines/ags/shared/gfx/allegro_bitmap.cpp
@@ -282,16 +282,16 @@ void Bitmap::LitBlendBlt(Bitmap *src, int dst_x, int dst_y, int light_amount) {
 	draw_lit_sprite(_alBitmap, al_src_bmp, dst_x, dst_y, light_amount);
 }
 
-void Bitmap::FlipBlt(Bitmap *src, int dst_x, int dst_y, BitmapFlip flip) {
+void Bitmap::FlipBlt(Bitmap *src, int dst_x, int dst_y, GraphicFlip flip) {
 	BITMAP *al_src_bmp = src->_alBitmap;
 	switch (flip) {
-	case kBitmap_HFlip:
+	case kFlip_Horizontal:
 		draw_sprite_h_flip(_alBitmap, al_src_bmp, dst_x, dst_y);
 		break;
-	case kBitmap_VFlip:
+	case kFlip_Vertical:
 		draw_sprite_v_flip(_alBitmap, al_src_bmp, dst_x, dst_y);
 		break;
-	case kBitmap_HVFlip:
+	case kFlip_Both:
 		draw_sprite_vh_flip(_alBitmap, al_src_bmp, dst_x, dst_y);
 		break;
 	default: // blit with no transform
diff --git a/engines/ags/shared/gfx/allegro_bitmap.h b/engines/ags/shared/gfx/allegro_bitmap.h
index cd97d5859ad..d57fab036c9 100644
--- a/engines/ags/shared/gfx/allegro_bitmap.h
+++ b/engines/ags/shared/gfx/allegro_bitmap.h
@@ -194,7 +194,7 @@ public:
 	// Draw bitmap using lighting preset
 	void    LitBlendBlt(Bitmap *src, int dst_x, int dst_y, int light_amount);
 	// TODO: generic "draw transformed" function? What about mask option?
-	void    FlipBlt(Bitmap *src, int dst_x, int dst_y, BitmapFlip flip);
+	void    FlipBlt(Bitmap *src, int dst_x, int dst_y, GraphicFlip flip);
 	void    RotateBlt(Bitmap *src, int dst_x, int dst_y, fixed_t angle);
 	void    RotateBlt(Bitmap *src, int dst_x, int dst_y, int pivot_x, int pivot_y, fixed_t angle);
 
diff --git a/engines/ags/shared/gfx/bitmap.h b/engines/ags/shared/gfx/bitmap.h
index 4f1147ca6b2..cae8ac39449 100644
--- a/engines/ags/shared/gfx/bitmap.h
+++ b/engines/ags/shared/gfx/bitmap.h
@@ -28,6 +28,7 @@
 #ifndef AGS_SHARED_GFX_BITMAP_H
 #define AGS_SHARED_GFX_BITMAP_H
 
+#include "ags/shared/gfx/gfx_def.h"
 #include "ags/shared/util/geometry.h"
 #include "ags/shared/util/string.h"
 
@@ -43,13 +44,6 @@ enum BitmapMaskOption {
 	kBitmap_Transparency
 };
 
-enum BitmapFlip {
-	kBitmap_NoFlip,
-	kBitmap_HFlip,
-	kBitmap_VFlip,
-	kBitmap_HVFlip
-};
-
 } // namespace Shared
 } // namespace AGS
 } // namespace AGS3
diff --git a/engines/ags/shared/gfx/gfx_def.h b/engines/ags/shared/gfx/gfx_def.h
index 8b89917558e..38bda137ad2 100644
--- a/engines/ags/shared/gfx/gfx_def.h
+++ b/engines/ags/shared/gfx/gfx_def.h
@@ -32,6 +32,13 @@ namespace AGS3 {
 namespace AGS {
 namespace Shared {
 
+enum GraphicFlip {
+	kFlip_None,
+	kFlip_Horizontal, // this means - mirror over horizontal middle line
+	kFlip_Vertical,   // this means - mirror over vertical middle line
+	kFlip_Both        // mirror over diagonal (horizontal and vertical)
+};
+
 enum BlendMode {
 	// free blending (ARGB -> ARGB) modes
 	kBlendMode_NoAlpha = 0, // ignore alpha channel


Commit: f52c6a25ab174a53b8c4d2c302b8897672ce3b06
    https://github.com/scummvm/scummvm/commit/f52c6a25ab174a53b8c4d2c302b8897672ce3b06
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-24T20:54:47+01:00

Commit Message:
AGS: Fixed forgot to save SetMultitasking in usetup.multitasking

Complements 3a4d94bf0

>From upstream dd76b001a64105d1d7ad5b4878bbd646e19c6391

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 c557edf4ab7..bb931e3b935 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -642,6 +642,8 @@ int SaveScreenShot(const char *namm) {
 void SetMultitasking(int mode) {
 	if ((mode < 0) | (mode > 1))
 		quit("!SetMultitasking: invalid mode parameter");
+	// Save requested setting
+	_GP(usetup).multitasking = mode;
 
 	// Account for the override config option (must be checked first!)
 	if ((_GP(usetup).override_multitasking >= 0) && (mode != _GP(usetup).override_multitasking)) {


Commit: b042a703d2d78083312619a9bb821a156b936005
    https://github.com/scummvm/scummvm/commit/b042a703d2d78083312619a9bb821a156b936005
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-24T20:54:47+01:00

Commit Message:
AGS: Hotfixed potential buffer overflow in check_for_messages_...

>From upstream 22b7fe46365ba03863dc149248b7bbd6a3fbbc45

Changed paths:
    engines/ags/engine/debugging/debug.cpp


diff --git a/engines/ags/engine/debugging/debug.cpp b/engines/ags/engine/debugging/debug.cpp
index 11a0237df43..b299871dab4 100644
--- a/engines/ags/engine/debugging/debug.cpp
+++ b/engines/ags/engine/debugging/debug.cpp
@@ -309,8 +309,8 @@ void debug_script_log(const char *msg, ...) {
 }
 
 struct Breakpoint {
-	char scriptName[80];
-	int lineNumber;
+	char scriptName[80]{};
+	int lineNumber = 0;
 };
 
 bool send_message_to_editor(const char *msg, const char *errorMsg) {
@@ -397,14 +397,14 @@ int check_for_messages_from_editor() {
 			bool isDelete = (msgPtr[0] == 'D');
 			// Format:  SETBREAK $scriptname$lineNumber$
 			msgPtr += 10;
-			char scriptNameBuf[80];
-			int i = 0;
+			char scriptNameBuf[sizeof(Breakpoint::scriptName)]{};
+			size_t i = 0;
 			while (msgPtr[0] != '$') {
-				scriptNameBuf[i] = msgPtr[0];
+				if (i < sizeof(scriptNameBuf) - 1)
+					scriptNameBuf[i] = msgPtr[0];
 				msgPtr++;
 				i++;
 			}
-			scriptNameBuf[i] = 0;
 			msgPtr++;
 
 			int lineNumber = atoi(msgPtr);


Commit: 119e09e56e02b424c6f24ffee7293353e7459775
    https://github.com/scummvm/scummvm/commit/119e09e56e02b424c6f24ffee7293353e7459775
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-24T20:54:47+01:00

Commit Message:
AGS: Removed a too early call to pl_stop_plugins() and fixed another

There's one call in unload_game_file(), which should be called after
all objects that may have been provided by plugins are disposed
(fonts, managed objects).

>From upstream 462cabe7353fc75f3cf70222a97028066f12f030

Changed paths:
    engines/ags/engine/ac/game.cpp
    engines/ags/engine/main/quit.cpp


diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index d175a1b5a69..2ff30a57090 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -431,9 +431,9 @@ void unload_game_file() {
 
 	free_all_fonts();
 
-	pl_stop_plugins();
 	ccRemoveAllSymbols();
 	ccUnregisterAllObjects();
+	pl_stop_plugins();
 
 	free_do_once_tokens();
 	_GP(play).gui_draw_order.clear();
diff --git a/engines/ags/engine/main/quit.cpp b/engines/ags/engine/main/quit.cpp
index 7603274a49f..8a3bb503ae8 100644
--- a/engines/ags/engine/main/quit.cpp
+++ b/engines/ags/engine/main/quit.cpp
@@ -208,8 +208,6 @@ void quit_free() {
 
 	_G(our_eip) = 9016;
 
-	pl_stop_plugins();
-
 	quit_check_dynamic_sprites(qreason);
 
 	if (_G(use_cdplayer))




More information about the Scummvm-git-logs mailing list