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

criezy noreply at scummvm.org
Sat Jun 18 00:12:44 UTC 2022


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

Summary:
73ff6317fd AGS: Add some more std replacements needed for recent AGS code
fad62e8cef AGS: Refactored SpriteCache's MRU list
1414f0ba92 AGS: Slightly more detailed sprcache info on Ctrl+Alt+V
ee23fde329 AGS: Fixed SpriteCache::FreeMem not using an argument
1cd8fa0d30 AGS: Fixed CreateTextCore not passing room layer flag further
282ee9ad97 AGS: Fixing more trivial warnings
babf223ab7 AGS: Add WaitInput to Script API


Commit: 73ff6317fd834ae3452f59b10c347fae833a20bb
    https://github.com/scummvm/scummvm/commit/73ff6317fd834ae3452f59b10c347fae833a20bb
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:03:30+01:00

Commit Message:
AGS: Add some more std replacements needed for recent AGS code

Changed paths:
    engines/ags/lib/std/algorithm.h
    engines/ags/lib/std/list.h


diff --git a/engines/ags/lib/std/algorithm.h b/engines/ags/lib/std/algorithm.h
index f48d03eb24c..ce347caebb3 100644
--- a/engines/ags/lib/std/algorithm.h
+++ b/engines/ags/lib/std/algorithm.h
@@ -125,6 +125,22 @@ ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T &value, Compare c
 	return last;
 }
 
+template<class ForwardIt>
+ForwardIt next(ForwardIt it, int n = 1) {
+	ForwardIt it2 = it;
+	while (n > 0) { ++it2; --n; }
+	while (n < 0) { --it2; ++n; }
+	return it2;
+}
+
+template<class BidirIt>
+BidirIt prev(BidirIt it, int n = 1) {
+	BidirIt it2 = it;
+	while (n > 0) { --it2; --n; }
+	while (n < 0) { ++it2; ++n; }
+	return it2;
+}
+
 } // namespace std
 } // namespace AGS3
 
diff --git a/engines/ags/lib/std/list.h b/engines/ags/lib/std/list.h
index d0e037bdcbb..0b198e5dbea 100644
--- a/engines/ags/lib/std/list.h
+++ b/engines/ags/lib/std/list.h
@@ -68,6 +68,22 @@ public:
 	reverse_iterator rend() {
 		return reverse_iterator(Common::List<T>::end());
 	}
+
+	void splice(typename Common::List<T>::iterator pos, list<T>& /*other*/, typename Common::List<T>::iterator it ) {
+		// We insert it before pos in this list
+		typename Common::List<T>::NodeBase *n = static_cast<typename Common::List<T>::NodeBase *>(it._node);
+		typename Common::List<T>::NodeBase *nPos = static_cast<typename Common::List<T>::NodeBase*>(pos._node);
+		if (n == nPos || n->_next == nPos)
+			return;
+		// Remove from current position
+		n->_prev->_next = n->_next;
+		n->_next->_prev = n->_prev;
+		// Insert in new position
+		n->_next = nPos;
+		n->_prev = nPos->_prev;
+		n->_prev->_next = n;
+		n->_next->_prev = n;
+	}
 };
 
 } // namespace std


Commit: fad62e8cef33f52be6502b7e3499631c0a712348
    https://github.com/scummvm/scummvm/commit/fad62e8cef33f52be6502b7e3499631c0a712348
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:03:30+01:00

Commit Message:
AGS: Refactored SpriteCache's MRU list

Using ideas from Nick Sonneveld (@sonneveld).
>From upstream: 1f57208879ca278e5b3c45d05a8c29f30632a5bd

Changed paths:
    engines/ags/shared/ac/sprite_cache.cpp
    engines/ags/shared/ac/sprite_cache.h


diff --git a/engines/ags/shared/ac/sprite_cache.cpp b/engines/ags/shared/ac/sprite_cache.cpp
index ff375e35731..742f285f8b4 100644
--- a/engines/ags/shared/ac/sprite_cache.cpp
+++ b/engines/ags/shared/ac/sprite_cache.cpp
@@ -29,7 +29,6 @@
 #include "ags/shared/util/stream.h"
 #include "ags/lib/std/algorithm.h"
 #include "ags/shared/ac/sprite_cache.h"
-#include "ags/shared/ac/common.h" // quit
 #include "ags/shared/ac/game_struct_defines.h"
 #include "ags/shared/debugging/out.h"
 #include "ags/shared/gfx/bitmap.h"
@@ -56,20 +55,9 @@ SpriteInfo::SpriteInfo()
 namespace AGS {
 namespace Shared {
 
-SpriteCache::SpriteData::SpriteData()
-	: Size(0)
-	, Flags(0)
-	, Image(nullptr) {
-}
-
-SpriteCache::SpriteData::~SpriteData() {
-	// TODO: investigate, if it's actually safe/preferred to delete bitmap here
-	// (some of these bitmaps may be assigned from outside of the cache)
-}
-
 SpriteCache::SpriteCache(std::vector<SpriteInfo> &sprInfos)
 	: _sprInfos(sprInfos), _maxCacheSize(DEFAULTCACHESIZE_KB * 1024u),
-	_cacheSize(0u), _lockedSize(0u), _liststart(-1), _listend(-1) {
+	_cacheSize(0u), _lockedSize(0u) {
 }
 
 SpriteCache::~SpriteCache() {
@@ -93,6 +81,7 @@ size_t SpriteCache::GetSpriteSlotCount() const {
 }
 
 void SpriteCache::SetMaxCacheSize(size_t size) {
+	FreeMem(size);
 	_maxCacheSize = size;
 }
 
@@ -106,14 +95,9 @@ void SpriteCache::Reset() {
 		}
 	}
 	_spriteData.clear();
-
+	_mru.clear();
 	_cacheSize = 0;
 	_lockedSize = 0;
-	_mrulist.clear();
-	_mrubacklink.clear();
-
-	_liststart = -1;
-	_listend = -1;
 }
 
 void SpriteCache::SetSprite(sprkey_t index, Bitmap *sprite) {
@@ -172,8 +156,6 @@ sprkey_t SpriteCache::EnlargeTo(sprkey_t topmost) {
 	size_t newsize = topmost + 1;
 	_sprInfos.resize(newsize);
 	_spriteData.resize(newsize);
-	_mrulist.resize(newsize);
-	_mrubacklink.resize(newsize);
 	return topmost;
 }
 
@@ -218,97 +200,59 @@ Bitmap *SpriteCache::operator [] (sprkey_t index) {
 	if (index < 0 || (size_t)index >= _spriteData.size())
 		return nullptr;
 
-	// Externally added sprite, don't put it into MRU list
-	if (_spriteData[index].IsExternalSprite())
+	// Externally added sprite or locked sprite, don't put it into MRU list
+	if (_spriteData[index].IsExternalSprite() || _spriteData[index].IsLocked())
 		return _spriteData[index].Image;
 
-	// Sprite exists in file but is not in mem, load it
-	if ((_spriteData[index].Image == nullptr) && _spriteData[index].IsAssetSprite())
+	if (_spriteData[index].Image) {
+		// Move to the beginning of the MRU list
+		_mru.splice(_mru.begin(), _mru, _spriteData[index].MruIt);
+	} else {
+		// Sprite exists in file but is not in mem, load it
 		LoadSprite(index);
+		_spriteData[index].MruIt = _mru.insert(_mru.begin(), index);
+	}
+	return _spriteData[index].Image;
+}
 
-	// Locked sprite that shouldn't be put into MRU list
-	if (_spriteData[index].IsLocked())
-		return _spriteData[index].Image;
-
-	if (_liststart < 0) {
-		_liststart = index;
-		_listend = index;
-		_mrulist[index] = END_OF_LIST;
-		_mrubacklink[index] = START_OF_LIST;
-	} else if (_listend != index) {
-		// this is the oldest element being bumped to newest, so update start link
-		if (index == _liststart) {
-			_liststart = _mrulist[index];
-			_mrubacklink[_liststart] = START_OF_LIST;
-		}
-		// already in list, link previous to next
-		else if (_mrulist[index] > 0) {
-			_mrulist[_mrubacklink[index]] = _mrulist[index];
-			_mrubacklink[_mrulist[index]] = _mrubacklink[index];
+void SpriteCache::FreeMem(size_t threshold) {
+	for (int tries = 0; (_mru.size() > 0) && (_cacheSize >= _maxCacheSize); ++tries) {
+		DisposeOldest();
+		if (tries > 1000) { // ???
+			Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Error, "RUNTIME CACHE ERROR: STUCK IN FREE_UP_MEM; RESETTING CACHE");
+			DisposeAll();
 		}
-
-		// set this as the newest element in the list
-		_mrulist[index] = END_OF_LIST;
-		_mrulist[_listend] = index;
-		_mrubacklink[index] = _listend;
-		_listend = index;
 	}
-
-	return _spriteData[index].Image;
 }
 
 void SpriteCache::DisposeOldest() {
-	if (_liststart < 0)
+	assert(_mru.size() > 0);
+	if (_mru.size() == 0)
 		return;
-
-	sprkey_t sprnum = _liststart;
-
-	if ((_spriteData[sprnum].Image != nullptr) && !_spriteData[sprnum].IsLocked()) {
-		// Free the memory
-		// Sprites that are not from the game resources should not normally be in a MRU list;
-		// if such is met here there's something wrong with the internal cache logic!
-		if (!_spriteData[sprnum].IsAssetSprite()) {
-			quitprintf("SpriteCache::DisposeOldest: attempted to remove sprite %d that was added externally or does not exist", sprnum);
-		}
+	auto it = std::prev(_mru.end());
+	const auto sprnum = *it;
+	// Safety check: must be a sprite from resources
+	assert(_spriteData[sprnum].IsAssetSprite());
+	if (!_spriteData[sprnum].IsAssetSprite()) {
+		Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Error, "SpriteCache::DisposeOldest: in MRU list sprite %d is external or does not exist", sprnum);
+		_mru.erase(it);
+		return;
+	}
+	// Delete the image, unless is locked
+	// NOTE: locked sprites may still occur in MRU list
+	if (!_spriteData[sprnum].IsLocked()) {
 		_cacheSize -= _spriteData[sprnum].Size;
-
-		delete _spriteData[sprnum].Image;
+		delete _spriteData[*it].Image;
 		_spriteData[sprnum].Image = nullptr;
-	}
-
-	if (_liststart == _listend) {
-		// there was one huge sprite, removing it has now emptied the cache completely
-		if (_cacheSize > 0) {
-			Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Error, "SPRITE CACHE ERROR: Sprite cache should be empty, but still has %d bytes", _cacheSize);
-		}
-		_mrulist[_liststart] = 0;
-		_liststart = -1;
-		_listend = -1;
-	} else {
-		sprkey_t oldstart = _liststart;
-		_liststart = _mrulist[_liststart];
-		_mrulist[oldstart] = 0;
-		_mrubacklink[_liststart] = START_OF_LIST;
-		if (oldstart == _liststart) {
-			// Somehow, we have got a recursive link to itself, so we
-			// the game will freeze (since it is not actually freeing any
-			// memory)
-			// There must be a bug somewhere causing this, but for now
-			// let's just reset the cache
-			Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Error, "RUNTIME CACHE ERROR: CACHE INCONSISTENT: RESETTING\n\tAt size %d (of %d), start %d end %d  fwdlink=%d",
-				_cacheSize, _maxCacheSize, oldstart, _listend, _liststart);
-			DisposeAll();
-		}
-	}
-
 #ifdef DEBUG_SPRITECACHE
-	Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Debug, "DisposeOldest: disposed %d, size now %d KB", sprnum, _cacheSize / 1024);
+		Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Debug, "DisposeOldest: disposed %d, size now %d KB", sprnum, _cacheSize / 1024);
 #endif
+	}
+	// Remove from the mru list
+	_mru.erase(it);
 }
 
 void SpriteCache::DisposeAll() {
-	_liststart = -1;
-	_listend = -1;
 	for (size_t i = 0; i < _spriteData.size(); ++i) {
 		if (!_spriteData[i].IsLocked() && // not locked
 			_spriteData[i].IsAssetSprite()) // sprite from game resource
@@ -316,29 +260,31 @@ void SpriteCache::DisposeAll() {
 			delete _spriteData[i].Image;
 			_spriteData[i].Image = nullptr;
 		}
-		_mrulist[i] = 0;
-		_mrubacklink[i] = 0;
 	}
 	_cacheSize = _lockedSize;
+	_mru.clear();
 }
 
 void SpriteCache::Precache(sprkey_t index) {
 	if (index < 0 || (size_t)index >= _spriteData.size())
 		return;
+	if (!_spriteData[index].IsAssetSprite())
+		return; // cannot precache a non-asset sprite
 
 	soff_t sprSize = 0;
 
-	if (_spriteData[index].Image == nullptr)
+	if (_spriteData[index].Image == nullptr) {
 		sprSize = LoadSprite(index);
-	else if (!_spriteData[index].IsLocked())
+	} else if (!_spriteData[index].IsLocked()) {
 		sprSize = _spriteData[index].Size;
+		// Remove locked sprite from the MRU list
+		_mru.erase(_spriteData[index].MruIt);
+	}
 
 	// make sure locked sprites can't fill the cache
 	_maxCacheSize += sprSize;
 	_lockedSize += sprSize;
-
 	_spriteData[index].Flags |= SPRCACHEFLAG_LOCKED;
-
 #ifdef DEBUG_SPRITECACHE
 	Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Debug, "Precached %d", index);
 #endif
@@ -349,19 +295,11 @@ sprkey_t SpriteCache::GetDataIndex(sprkey_t index) {
 }
 
 size_t SpriteCache::LoadSprite(sprkey_t index) {
-	int hh = 0;
-
-	while (_cacheSize > _maxCacheSize) {
-		DisposeOldest();
-		hh++;
-		if (hh > 1000) {
-			Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Error, "RUNTIME CACHE ERROR: STUCK IN FREE_UP_MEM; RESETTING CACHE");
-			DisposeAll();
-		}
-	}
-
+	assert((index >= 0) && ((size_t)index < _spriteData.size()));
 	if (index < 0 || (size_t)index >= _spriteData.size())
-		quit("sprite cache array index out of bounds");
+		return 0;
+
+	FreeMem(_maxCacheSize);
 
 	sprkey_t load_index = GetDataIndex(index);
 	Bitmap *image;
@@ -444,8 +382,7 @@ HError SpriteCache::InitFile(const String &filename, const String &sprindex_file
 	size_t newsize = metrics.size();
 	_sprInfos.resize(newsize);
 	_spriteData.resize(newsize);
-	_mrulist.resize(newsize);
-	_mrubacklink.resize(newsize);
+	_mru.clear();
 	for (size_t i = 0; i < metrics.size(); ++i) {
 		if (!metrics[i].IsNull()) {
 			// Existing sprite
diff --git a/engines/ags/shared/ac/sprite_cache.h b/engines/ags/shared/ac/sprite_cache.h
index d2a1b5b2412..5356675d8e3 100644
--- a/engines/ags/shared/ac/sprite_cache.h
+++ b/engines/ags/shared/ac/sprite_cache.h
@@ -43,6 +43,7 @@
 
 #include "ags/lib/std/memory.h"
 #include "ags/lib/std/vector.h"
+#include "ags/lib/std/list.h"
 #include "ags/shared/ac/sprite_file.h"
 #include "ags/shared/core/platform.h"
 #include "ags/shared/util/error.h"
@@ -151,16 +152,20 @@ private:
 	// Gets the index of a sprite which data is used for the given slot;
 	// in case of remapped sprite this will return the one given sprite is remapped to
 	sprkey_t    GetDataIndex(sprkey_t index);
-	// Delete the oldest image in cache
+	// Delete the oldest (least recently used) image in cache
 	void        DisposeOldest();
+	// Keep disposing oldest elements until cache size is reduced to the given threshold
+	void        FreeMem(size_t threshold);
 
 	// Information required for the sprite streaming
 	struct SpriteData {
-		size_t          Size; // to track cache size
-		uint32_t        Flags;
+		size_t          Size = 0; // to track cache size
+		uint32_t        Flags = 0;
 		// TODO: investigate if we may safely use unique_ptr here
 		// (some of these bitmaps may be assigned from outside of the cache)
-		Shared::Bitmap *Image; // actual bitmap
+		Shared::Bitmap *Image = nullptr; // actual bitmap
+		// MRU list reference
+		std::list<sprkey_t>::iterator MruIt;
 
 		// Tells if there actually is a registered sprite in this slot
 		bool DoesSpriteExist() const;
@@ -170,9 +175,6 @@ private:
 		bool IsExternalSprite() const;
 		// Tells if sprite is locked and should not be disposed by cache logic
 		bool IsLocked() const;
-
-		SpriteData();
-		~SpriteData();
 	};
 
 	// Provided map of sprite infos, to fill in loaded sprite properties
@@ -189,10 +191,7 @@ private:
 	// MRU list: the way to track which sprites were used recently.
 	// When clearing up space for new sprites, cache first deletes the sprites
 	// that were last time used long ago.
-	std::vector<sprkey_t> _mrulist;
-	std::vector<sprkey_t> _mrubacklink;
-	int _liststart;
-	int _listend;
+	std::list<sprkey_t> _mru;
 
 	// Initialize the empty sprite slot
 	void        InitNullSpriteParams(sprkey_t index);


Commit: 1414f0ba92e0b6a9c459471cd236080b2cf2a82e
    https://github.com/scummvm/scummvm/commit/1414f0ba92e0b6a9c459471cd236080b2cf2a82e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:03:30+01:00

Commit Message:
AGS: Slightly more detailed sprcache info on Ctrl+Alt+V

>From upstream: 9f5b5d3afa86c8bf0925a358e3f581fe40f67c1c

Changed paths:
    engines/ags/engine/ac/global_debug.cpp
    engines/ags/shared/ac/sprite_cache.h


diff --git a/engines/ags/engine/ac/global_debug.cpp b/engines/ags/engine/ac/global_debug.cpp
index a0df887f507..ec0ce698653 100644
--- a/engines/ags/engine/ac/global_debug.cpp
+++ b/engines/ags/engine/ac/global_debug.cpp
@@ -55,17 +55,22 @@ String GetRuntimeInfo() {
 	DisplayMode mode = _G(gfxDriver)->GetDisplayMode();
 	Rect render_frame = _G(gfxDriver)->GetRenderDestination();
 	PGfxFilter filter = _G(gfxDriver)->GetGraphicsFilter();
+	const size_t total_spr =  _GP(spriteset).GetCacheSize();
+	const size_t total_lockspr =  _GP(spriteset).GetLockedSize();
+	const size_t total_normspr = total_spr - total_lockspr;
+	const size_t max_normspr =  _GP(spriteset).GetMaxCacheSize() - total_lockspr;
+	const unsigned norm_spr_filled = (uint64_t)total_normspr * 100 / max_normspr;
 	String runtimeInfo = String::FromFormat(
 		"Adventure Game Studio run-time engine[ACI version %s"
 		"[Game resolution %d x %d (%d-bit)"
 		"[Running %d x %d at %d-bit%s[GFX: %s; %s[Draw frame %d x %d["
-		"Sprite cache size: %d KB (limit %d KB; %d KB locked)",
+		"Sprite cache KB: %zu, norm: %zu / %zu (%u%%), locked: %zu",
 		_G(EngineVersion).LongString.GetCStr(), _GP(game).GetGameRes().Width, _GP(game).GetGameRes().Height, _GP(game).GetColorDepth(),
 		mode.Width, mode.Height, mode.ColorDepth,
 		mode.IsWindowed() ? " W" : "",
 		_G(gfxDriver)->GetDriverName(), filter->GetInfo().Name.GetCStr(),
 		render_frame.GetWidth(), render_frame.GetHeight(),
-		_GP(spriteset).GetCacheSize() / 1024, _GP(spriteset).GetMaxCacheSize() / 1024, _GP(spriteset).GetLockedSize() / 1024);
+		total_spr / 1024, total_normspr / 1024, max_normspr / 1024, norm_spr_filled, total_lockspr / 1024);
 	if (_GP(play).separate_music_lib)
 		runtimeInfo.Append("[AUDIO.VOX enabled");
 	if (_GP(play).voice_avail)
diff --git a/engines/ags/shared/ac/sprite_cache.h b/engines/ags/shared/ac/sprite_cache.h
index 5356675d8e3..552f7a7eb3b 100644
--- a/engines/ags/shared/ac/sprite_cache.h
+++ b/engines/ags/shared/ac/sprite_cache.h
@@ -114,11 +114,11 @@ public:
 	sprkey_t    EnlargeTo(sprkey_t topmost);
 	// Finds a free slot index, if all slots are occupied enlarges sprite bank; returns index
 	sprkey_t    GetFreeIndex();
-	// Returns current size of the cache, in bytes
+	// Returns current size of the cache, in bytes; this includes locked size too!
 	size_t      GetCacheSize() const;
 	// Gets the total size of the locked sprites, in bytes
 	size_t      GetLockedSize() const;
-	// Returns maximal size limit of the cache, in bytes
+	// Returns maximal size limit of the cache, in bytes; this includes locked size too!
 	size_t      GetMaxCacheSize() const;
 	// Returns number of sprite slots in the bank (this includes both actual sprites and free slots)
 	size_t      GetSpriteSlotCount() const;


Commit: ee23fde329e0c0784f7414992a66e622c67a6f04
    https://github.com/scummvm/scummvm/commit/ee23fde329e0c0784f7414992a66e622c67a6f04
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:03:30+01:00

Commit Message:
AGS: Fixed SpriteCache::FreeMem not using an argument

>From upstream 0369250309f797eb5035fcdf75cd8ad882fa317e

Changed paths:
    engines/ags/shared/ac/sprite_cache.cpp


diff --git a/engines/ags/shared/ac/sprite_cache.cpp b/engines/ags/shared/ac/sprite_cache.cpp
index 742f285f8b4..101f0455ff1 100644
--- a/engines/ags/shared/ac/sprite_cache.cpp
+++ b/engines/ags/shared/ac/sprite_cache.cpp
@@ -216,7 +216,7 @@ Bitmap *SpriteCache::operator [] (sprkey_t index) {
 }
 
 void SpriteCache::FreeMem(size_t threshold) {
-	for (int tries = 0; (_mru.size() > 0) && (_cacheSize >= _maxCacheSize); ++tries) {
+	for (int tries = 0; (_mru.size() > 0) && (_cacheSize >= threshold); ++tries) {
 		DisposeOldest();
 		if (tries > 1000) { // ???
 			Debug::Printf(kDbgGroup_SprCache, kDbgMsg_Error, "RUNTIME CACHE ERROR: STUCK IN FREE_UP_MEM; RESETTING CACHE");


Commit: 1cd8fa0d3084c8069d9c1905459327f152bd5560
    https://github.com/scummvm/scummvm/commit/1cd8fa0d3084c8069d9c1905459327f152bd5560
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:03:30+01:00

Commit Message:
AGS: Fixed CreateTextCore not passing room layer flag further

>From upstream e5aaa87573c6357edeb50a526892619ff748ea12

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


diff --git a/engines/ags/engine/ac/overlay.cpp b/engines/ags/engine/ac/overlay.cpp
index 770d8a7689a..7716fc504c4 100644
--- a/engines/ags/engine/ac/overlay.cpp
+++ b/engines/ags/engine/ac/overlay.cpp
@@ -213,7 +213,7 @@ ScreenOverlay *Overlay_CreateTextCore(bool room_layer, int x, int y, int width,
 	if (width < 8) width = _GP(play).GetUIViewport().GetWidth() / 2;
 	if (x < 0) x = _GP(play).GetUIViewport().GetWidth() / 2 - width / 2;
 	if (text_color == 0) text_color = 16;
-	return _display_main(x, y, width, text, disp_type, font, -text_color, 0, allow_shrink, false);
+	return _display_main(x, y, width, text, disp_type, font, -text_color, 0, allow_shrink, false, room_layer);
 }
 
 ScriptOverlay *Overlay_CreateGraphicalEx(bool room_layer, int x, int y, int slot, int transparent, bool clone) {


Commit: 282ee9ad97c06a9a7a7811c5cb02ecd7a08d49df
    https://github.com/scummvm/scummvm/commit/282ee9ad97c06a9a7a7811c5cb02ecd7a08d49df
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:08:54+01:00

Commit Message:
AGS: Fixing more trivial warnings

>From upstream 83f7d9857e70f7d1d10fedf61196740d20ba0b0a

Changed paths:
    engines/ags/engine/ac/character_extras.cpp
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/ac/draw.h
    engines/ags/engine/ac/game.cpp
    engines/ags/engine/ac/global_object.cpp
    engines/ags/engine/ac/object.cpp
    engines/ags/engine/ac/room.cpp
    engines/ags/engine/ac/room_status.cpp
    engines/ags/engine/ac/room_status.h
    engines/ags/engine/ac/walk_behind.cpp
    engines/ags/engine/ac/walk_behind.h
    engines/ags/engine/ac/walkable_area.cpp
    engines/ags/engine/gfx/ali_3d_scummvm.h
    engines/ags/engine/gui/animating_gui_button.cpp
    engines/ags/engine/gui/my_textbox.cpp
    engines/ags/engine/main/game_run.cpp
    engines/ags/engine/main/update.cpp
    engines/ags/engine/platform/base/ags_platform_driver.h
    engines/ags/shared/gui/gui_object.h
    engines/ags/shared/gui/gui_slider.cpp


diff --git a/engines/ags/engine/ac/character_extras.cpp b/engines/ags/engine/ac/character_extras.cpp
index 915a0de11d4..ef6b358ee00 100644
--- a/engines/ags/engine/ac/character_extras.cpp
+++ b/engines/ags/engine/ac/character_extras.cpp
@@ -67,8 +67,8 @@ void CharacterExtras::WriteToSavegame(Stream *out) {
 	out->WriteInt8(process_idle_this_time);
 	out->WriteInt8(slow_move_counter);
 	out->WriteInt16(animwait);
-	out->WriteInt8(anim_volume);
-	out->WriteInt8(cur_anim_volume);
+	out->WriteInt8(static_cast<uint8_t>(anim_volume));
+	out->WriteInt8(static_cast<uint8_t>(cur_anim_volume));
 	out->WriteInt8(0); // reserved to fill int32
 	out->WriteInt8(0);
 }
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 48944635191..8222d49531f 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -766,7 +766,7 @@ void draw_sprite_slot_support_alpha(Bitmap *ds, bool ds_has_alpha, int xpos, int
 	                          blend_mode, alpha);
 }
 
-Engine::IDriverDependantBitmap* recycle_ddb_sprite(Engine::IDriverDependantBitmap *ddb, uint32 sprite_id, Shared::Bitmap *source, bool has_alpha, bool opaque) {
+Engine::IDriverDependantBitmap* recycle_ddb_sprite(Engine::IDriverDependantBitmap *ddb, uint32_t sprite_id, Shared::Bitmap *source, bool has_alpha, bool opaque) {
 	// no ddb, - get or create shared object
 	if (!ddb)
 		return _G(gfxDriver)->GetSharedDDB(sprite_id, source, has_alpha, opaque);
@@ -1316,7 +1316,7 @@ int construct_object_gfx(int aa, int *drawnWidth, int *drawnHeight, bool alwaysU
 void prepare_objects_for_drawing() {
 	_G(our_eip) = 32;
 
-	for (int aa = 0; aa < _G(croom)->numobj; aa++) {
+	for (uint32_t aa = 0; aa < _G(croom)->numobj; aa++) {
 		if (_G(objs)[aa].on != 1) continue;
 		// offscreen, don't draw
 		if ((_G(objs)[aa].x >= _GP(thisroom).Width) || (_G(objs)[aa].y < 1))
@@ -1724,7 +1724,7 @@ void prepare_room_sprites() {
 			_G(our_eip) = 34;
 
 			if (_G(walkBehindMethod) == DrawAsSeparateSprite) {
-				for (int wb = 1 /* 0 is "no area" */;
+				for (size_t wb = 1 /* 0 is "no area" */;
 					(wb < MAX_WALK_BEHINDS) && (wb < (int)_GP(walkbehindobj).size()); ++wb) {
 					const auto &wbobj = _GP(walkbehindobj)[wb];
 					if (wbobj.Ddb) {
diff --git a/engines/ags/engine/ac/draw.h b/engines/ags/engine/ac/draw.h
index ef1826f8db5..30e7ea78dc0 100644
--- a/engines/ags/engine/ac/draw.h
+++ b/engines/ags/engine/ac/draw.h
@@ -151,7 +151,7 @@ void mark_current_background_dirty();
 // Avoid freeing and reallocating the memory if possible
 Shared::Bitmap *recycle_bitmap(Shared::Bitmap *bimp, int coldep, int wid, int hit, bool make_transparent = false);
 void recycle_bitmap(std::unique_ptr<Shared::Bitmap> &bimp, int coldep, int wid, int hit, bool make_transparent = false);
-Engine::IDriverDependantBitmap* recycle_ddb_sprite(Engine::IDriverDependantBitmap *ddb, uint32 sprite_id, Shared::Bitmap *source, bool has_alpha = false, bool opaque = false);
+Engine::IDriverDependantBitmap* recycle_ddb_sprite(Engine::IDriverDependantBitmap *ddb, uint32_t sprite_id, Shared::Bitmap *source, bool has_alpha = false, bool opaque = false);
 inline Engine::IDriverDependantBitmap* recycle_ddb_bitmap(Engine::IDriverDependantBitmap *ddb, Shared::Bitmap *source, bool has_alpha = false, bool opaque = false) {
 	return recycle_ddb_sprite(ddb, UINT32_MAX, source, has_alpha, opaque);
 }
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index dbe8c1ceab6..2120a2e093a 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -1348,7 +1348,7 @@ bool unserialize_audio_script_object(int index, const char *objectType, Stream *
 
 void game_sprite_updated(int sprnum) {
 	// update the shared texture (if exists)
-	_G(gfxDriver)->UpdateSharedDDB(sprnum, _GP(spriteset)[sprnum], _GP(game).SpriteInfos[sprnum].Flags & SPF_ALPHACHANNEL, false);
+	_G(gfxDriver)->UpdateSharedDDB(sprnum, _GP(spriteset)[sprnum], (_GP(game).SpriteInfos[sprnum].Flags & SPF_ALPHACHANNEL) != 0, false);
 
 	// character and object draw caches
 	reset_objcache_for_sprite(sprnum);
diff --git a/engines/ags/engine/ac/global_object.cpp b/engines/ags/engine/ac/global_object.cpp
index ae83f7640d0..71b063aef2b 100644
--- a/engines/ags/engine/ac/global_object.cpp
+++ b/engines/ags/engine/ac/global_object.cpp
@@ -61,9 +61,9 @@ int GetObjectIDAtScreen(int scrx, int scry) {
 }
 
 int GetObjectIDAtRoom(int roomx, int roomy) {
-	int aa, bestshotyp = -1, bestshotwas = -1;
+	int bestshotyp = -1, bestshotwas = -1;
 	// Iterate through all objects in the room
-	for (aa = 0; aa < _G(croom)->numobj; aa++) {
+	for (uint32_t aa = 0; aa < _G(croom)->numobj; aa++) {
 		if (_G(objs)[aa].on != 1) continue;
 		if (_G(objs)[aa].flags & OBJF_NOINTERACT)
 			continue;
diff --git a/engines/ags/engine/ac/object.cpp b/engines/ags/engine/ac/object.cpp
index b3b95b2e268..ee8206d063b 100644
--- a/engines/ags/engine/ac/object.cpp
+++ b/engines/ags/engine/ac/object.cpp
@@ -75,7 +75,7 @@ ScriptObject *GetObjectAtRoom(int x, int y) {
 }
 
 AGS_INLINE int is_valid_object(int obtest) {
-	if ((obtest < 0) || (obtest >= _G(croom)->numobj)) return 0;
+	if ((obtest < 0) || (static_cast<uint32_t>(obtest) >= _G(croom)->numobj)) return 0;
 	return 1;
 }
 
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index eb8238912d1..e537f567d19 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -222,8 +222,6 @@ void save_room_data_segment() {
 }
 
 void unload_old_room() {
-	int ff;
-
 	// if switching games on restore, don't do this
 	if (_G(displayed_room) < 0)
 		return;
@@ -234,11 +232,11 @@ void unload_old_room() {
 
 	dispose_room_drawdata();
 
-	for (ff = 0; ff < _G(croom)->numobj; ff++)
+	for (uint32_t ff = 0; ff < _G(croom)->numobj; ff++)
 		_G(objs)[ff].moving = 0;
 
 	if (!_GP(play).ambient_sounds_persist) {
-		for (ff = NUM_SPEECH_CHANS; ff < _GP(game).numGameChannels; ff++)
+		for (int ff = NUM_SPEECH_CHANS; ff < _GP(game).numGameChannels; ff++)
 			StopAmbientSound(ff);
 	}
 
@@ -264,20 +262,20 @@ void unload_old_room() {
 	remove_screen_overlay(-1);
 	delete _G(raw_saved_screen);
 	_G(raw_saved_screen) = nullptr;
-	for (ff = 0; ff < MAX_ROOM_BGFRAMES; ff++)
+	for (int ff = 0; ff < MAX_ROOM_BGFRAMES; ff++)
 		_GP(play).raw_modified[ff] = 0;
 	for (size_t i = 0; i < _GP(thisroom).LocalVariables.size() && i < MAX_GLOBAL_VARIABLES; ++i)
 		_G(croom)->interactionVariableValues[i] = _GP(thisroom).LocalVariables[i].Value;
 
 	// ensure that any half-moves (eg. with scaled movement) are stopped
-	for (ff = 0; ff < _GP(game).numcharacters; ff++) {
+	for (int ff = 0; ff < _GP(game).numcharacters; ff++) {
 		_GP(charextra)[ff].xwas = INVALID_X;
 	}
 
 	_GP(play).swap_portrait_lastchar = -1;
 	_GP(play).swap_portrait_lastlastchar = -1;
 
-	for (ff = 0; ff < _G(croom)->numobj; ff++) {
+	for (uint32_t ff = 0; ff < _G(croom)->numobj; ff++) {
 		// un-export the object's script object
 		if (_GP(thisroom).Objects[ff].ScriptName.IsEmpty())
 			continue;
@@ -285,7 +283,7 @@ void unload_old_room() {
 		ccRemoveExternalSymbol(_GP(thisroom).Objects[ff].ScriptName);
 	}
 
-	for (ff = 0; ff < MAX_ROOM_HOTSPOTS; ff++) {
+	for (int ff = 0; ff < MAX_ROOM_HOTSPOTS; ff++) {
 		if (_GP(thisroom).Hotspots[ff].ScriptName.IsEmpty())
 			continue;
 
@@ -465,7 +463,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 		_GP(play).bg_frame = 0;
 
 	// do the palette
-	for (uint cc = 0; cc < 256; cc++) {
+	for (size_t cc = 0; cc < 256; cc++) {
 		if (_GP(game).paluses[cc] == PAL_BACKGROUND)
 			_G(palette)[cc] = _GP(thisroom).Palette[cc];
 		else {
@@ -532,11 +530,11 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 		if (_GP(thisroom).EventHandlers == nullptr) {
 			// legacy interactions
 			_GP(thisroom).Interaction->CopyTimesRun(_G(croom)->intrRoom);
-			for (uint cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
+			for (int cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
 				_GP(thisroom).Hotspots[cc].Interaction->CopyTimesRun(_G(croom)->intrHotspot[cc]);
-			for (uint cc = 0; cc < _GP(thisroom).Objects.size(); cc++)
+			for (size_t cc = 0; cc < _GP(thisroom).Objects.size(); cc++)
 				_GP(thisroom).Objects[cc].Interaction->CopyTimesRun(_G(croom)->intrObject[cc]);
-			for (uint cc = 0; cc < MAX_ROOM_REGIONS; cc++)
+			for (int cc = 0; cc < MAX_ROOM_REGIONS; cc++)
 				_GP(thisroom).Regions[cc].Interaction->CopyTimesRun(_G(croom)->intrRegion[cc]);
 		}
 		for (size_t i = 0; i < _GP(thisroom).LocalVariables.size() && i < (size_t)MAX_GLOBAL_VARIABLES; ++i)
@@ -544,9 +542,9 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 
 		// Always copy object and hotspot names for < 3.6.0 games, because they were not settable
 		if (_G(loaded_game_file_version) < kGameVersion_360_16) {
-			for (uint cc = 0; cc < _GP(thisroom).Objects.size(); ++cc)
+			for (size_t cc = 0; cc < _GP(thisroom).Objects.size(); ++cc)
 				_G(croom)->obj[cc].name = _GP(thisroom).Objects[cc].Name;
-			for (uint cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
+			for (int cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
 				_G(croom)->hotspot[cc].Name = _GP(thisroom).Hotspots[cc].Name;
 		}
 	} else {
@@ -556,7 +554,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 		_G(croom)->obj.resize(_G(croom)->numobj);
 		_G(croom)->objProps.resize(_G(croom)->numobj);
 		_G(croom)->intrObject.resize(_G(croom)->numobj);
-		for (int cc = 0; cc < _G(croom)->numobj; cc++) {
+		for (size_t cc = 0; cc < _G(croom)->numobj; cc++) {
 			const auto &trobj = _GP(thisroom).Objects[cc];
 			auto &crobj = _G(croom)->obj[cc];
 			crobj.x = trobj.X;
@@ -586,11 +584,11 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 		for (size_t i = 0; i < (size_t)MAX_WALK_BEHINDS; ++i)
 			_G(croom)->walkbehind_base[i] = _GP(thisroom).WalkBehinds[i].Baseline;
 
-		for (uint cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) {
+		for (int cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) {
 			_G(croom)->hotspot[cc].Enabled = true;
 			_G(croom)->hotspot[cc].Name = _GP(thisroom).Hotspots[cc].Name;
 		}
-		for (uint cc = 0; cc < MAX_ROOM_REGIONS; cc++) {
+		for (int cc = 0; cc < MAX_ROOM_REGIONS; cc++) {
 			_G(croom)->region_enabled[cc] = 1;
 		}
 
@@ -614,24 +612,24 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 		// legacy interactions
 		// copy interactions from room file into our temporary struct
 		_G(croom)->intrRoom = *_GP(thisroom).Interaction;
-		for (uint cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
+		for (int cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
 			_G(croom)->intrHotspot[cc] = *_GP(thisroom).Hotspots[cc].Interaction;
-		for (uint cc = 0; cc < _GP(thisroom).Objects.size(); cc++)
+		for (size_t cc = 0; cc < _GP(thisroom).Objects.size(); cc++)
 			_G(croom)->intrObject[cc] = *_GP(thisroom).Objects[cc].Interaction;
-		for (uint cc = 0; cc < MAX_ROOM_REGIONS; cc++)
+		for (int cc = 0; cc < MAX_ROOM_REGIONS; cc++)
 			_G(croom)->intrRegion[cc] = *_GP(thisroom).Regions[cc].Interaction;
 	}
 
 	_G(objs) = _G(croom)->obj.size() > 0 ? &_G(croom)->obj[0] : nullptr;
 
-	for (int cc = 0; cc < _G(croom)->numobj; cc++) {
+	for (size_t cc = 0; cc < _G(croom)->numobj; cc++) {
 		// export the object's script object
 		if (_GP(thisroom).Objects[cc].ScriptName.IsEmpty())
 			continue;
 		ccAddExternalDynamicObject(_GP(thisroom).Objects[cc].ScriptName, &_G(scrObj)[cc], &_GP(ccDynamicObject));
 	}
 
-	for (uint cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) {
+	for (int cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) {
 		if (_GP(thisroom).Hotspots[cc].ScriptName.IsEmpty())
 			continue;
 
@@ -858,7 +856,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
 
 	_G(our_eip) = 212;
 	invalidate_screen();
-	for (int cc = 0; cc < _G(croom)->numobj; cc++) {
+	for (size_t cc = 0; cc < _G(croom)->numobj; cc++) {
 		if (_G(objs)[cc].on == 2)
 			MergeObject(cc);
 	}
diff --git a/engines/ags/engine/ac/room_status.cpp b/engines/ags/engine/ac/room_status.cpp
index 2fdc7b6d976..7ba488389b3 100644
--- a/engines/ags/engine/ac/room_status.cpp
+++ b/engines/ags/engine/ac/room_status.cpp
@@ -130,11 +130,11 @@ void RoomStatus::ReadFromSavegame(Stream *in, int save_ver) {
 	FreeProperties();
 
 	beenhere = in->ReadInt8();
-	numobj = in->ReadInt32();
+	numobj = static_cast<uint32_t>(in->ReadInt32());
 	obj.resize(numobj);
 	objProps.resize(numobj);
 	intrObject.resize(numobj);
-	for (int i = 0; i < numobj; ++i) {
+	for (uint32_t i = 0; i < numobj; ++i) {
 		obj[i].ReadFromSavegame(in, save_ver);
 		Properties::ReadValues(objProps[i], in);
 		if (_G(loaded_game_file_version) <= kGameVersion_272)
@@ -171,7 +171,7 @@ void RoomStatus::ReadFromSavegame(Stream *in, int save_ver) {
 void RoomStatus::WriteToSavegame(Stream *out) const {
 	out->WriteInt8(beenhere);
 	out->WriteInt32(numobj);
-	for (int i = 0; i < numobj; ++i) {
+	for (uint32_t i = 0; i < numobj; ++i) {
 		obj[i].WriteToSavegame(out);
 		Properties::WriteValues(objProps[i], out);
 		if (_G(loaded_game_file_version) <= kGameVersion_272)
diff --git a/engines/ags/engine/ac/room_status.h b/engines/ags/engine/ac/room_status.h
index bf17316e336..2562a267dbf 100644
--- a/engines/ags/engine/ac/room_status.h
+++ b/engines/ags/engine/ac/room_status.h
@@ -51,7 +51,7 @@ struct HotspotState {
 // a room that could change
 struct RoomStatus {
 	int   beenhere = 0;
-	int   numobj = 0;
+	uint32_t numobj = 0;
 	std::vector<RoomObject> obj;
 	int   tsdatasize = 0;
 	char *tsdata = nullptr;
diff --git a/engines/ags/engine/ac/walk_behind.cpp b/engines/ags/engine/ac/walk_behind.cpp
index cb90cb9b8a4..27c41cf8df5 100644
--- a/engines/ags/engine/ac/walk_behind.cpp
+++ b/engines/ags/engine/ac/walk_behind.cpp
@@ -80,7 +80,7 @@ void walkbehinds_generate_sprites() {
 
 // Edits the given game object's sprite, cutting out pixels covered by walk-behinds;
 // returns whether any pixels were updated;
-bool walkbehinds_cropout(Bitmap *sprit, int sprx, int spry, int basel, int zoom) {
+bool walkbehinds_cropout(Bitmap *sprit, int sprx, int spry, int basel) {
 	if (_G(noWalkBehindsAtAll))
 		return false;
 
diff --git a/engines/ags/engine/ac/walk_behind.h b/engines/ags/engine/ac/walk_behind.h
index d1ded1cc642..be18f1e97fe 100644
--- a/engines/ags/engine/ac/walk_behind.h
+++ b/engines/ags/engine/ac/walk_behind.h
@@ -55,7 +55,7 @@ void walkbehinds_recalc();
 void walkbehinds_generate_sprites();
 // Edits the given game object's sprite, cutting out pixels covered by walk-behinds;
 // returns whether any pixels were updated
-bool walkbehinds_cropout(Shared::Bitmap *sprit, int sprx, int spry, int basel, int zoom = 100);
+bool walkbehinds_cropout(Shared::Bitmap *sprit, int sprx, int spry, int basel);
 
 } // namespace AGS3
 
diff --git a/engines/ags/engine/ac/walkable_area.cpp b/engines/ags/engine/ac/walkable_area.cpp
index 8b1aa21b7d0..9fde29c31c0 100644
--- a/engines/ags/engine/ac/walkable_area.cpp
+++ b/engines/ags/engine/ac/walkable_area.cpp
@@ -134,10 +134,9 @@ Bitmap *prepare_walkable_areas(int sourceChar) {
 	else if (_GP(game).chars[sourceChar].flags & CHF_NOBLOCKING)
 		return _G(walkable_areas_temp);
 
-	int ww;
 	// for each character in the current room, make the area under
 	// them unwalkable
-	for (ww = 0; ww < _GP(game).numcharacters; ww++) {
+	for (int ww = 0; ww < _GP(game).numcharacters; ww++) {
 		if (_GP(game).chars[ww].on != 1) continue;
 		if (_GP(game).chars[ww].room != _G(displayed_room)) continue;
 		if (ww == sourceChar) continue;
@@ -159,7 +158,7 @@ Bitmap *prepare_walkable_areas(int sourceChar) {
 
 	// check for any blocking objects in the room, and deal with them
 	// as well
-	for (ww = 0; ww < _G(croom)->numobj; ww++) {
+	for (uint32_t ww = 0; ww < _G(croom)->numobj; ww++) {
 		if (_G(objs)[ww].on != 1) continue;
 		if ((_G(objs)[ww].flags & OBJF_SOLID) == 0)
 			continue;
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.h b/engines/ags/engine/gfx/ali_3d_scummvm.h
index 3a23c37535e..ed55b2fb081 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.h
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.h
@@ -179,7 +179,7 @@ public:
 	void UpdateDDBFromBitmap(IDriverDependantBitmap *ddb, Bitmap *bitmap, bool hasAlpha) override;
 	void DestroyDDB(IDriverDependantBitmap *ddb) override;
 
-	IDriverDependantBitmap *GetSharedDDB(uint32_t sprite_id,
+	IDriverDependantBitmap *GetSharedDDB(uint32_t /*sprite_id*/,
 		Bitmap *bitmap, bool hasAlpha, bool opaque) override {
 		// Software renderer does not require a texture cache, because it uses bitmaps directly
 		return CreateDDBFromBitmap(bitmap, hasAlpha, opaque);
diff --git a/engines/ags/engine/gui/animating_gui_button.cpp b/engines/ags/engine/gui/animating_gui_button.cpp
index dd9e51eb2be..042a4c66368 100644
--- a/engines/ags/engine/gui/animating_gui_button.cpp
+++ b/engines/ags/engine/gui/animating_gui_button.cpp
@@ -66,7 +66,7 @@ void AnimatingGUIButton::WriteToSavegame(Stream *out) {
 	out->WriteInt16(speed);
 	out->WriteInt16(anim_flags); // was repeat (0,1)
 	out->WriteInt16(wait);
-	out->WriteInt8(volume);
+	out->WriteInt8(static_cast<uint8_t>(volume));
 	out->WriteInt8(0); // reserved to fill int32
 	out->WriteInt8(0);
 	out->WriteInt8(0);
diff --git a/engines/ags/engine/gui/my_textbox.cpp b/engines/ags/engine/gui/my_textbox.cpp
index 0737aeb6ff4..fe12753996f 100644
--- a/engines/ags/engine/gui/my_textbox.cpp
+++ b/engines/ags/engine/gui/my_textbox.cpp
@@ -67,10 +67,10 @@ int MyTextBox::processmessage(int mcode, int wParam, NumberPtr lParam) {
 		strcpy((char *)lParam._ptr, text); // FIXME! dangerous
 	else if (mcode == CTB_KEYPRESS) {
 		// NOTE: this deprecated control does not support UTF-8
-		//int key = wParam;
+		int key = wParam;
 		int uchar = lParam;
 		size_t len = strlen(text);
-		if (wParam == eAGSKeyCodeBackspace) {
+		if (key == eAGSKeyCodeBackspace) {
 			if (len > 0)
 				text[len - 1] = 0;
 			drawandmouse();
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 9efef9c60c8..3144d1a5e69 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -341,14 +341,13 @@ bool run_service_key_controls(KeyInput &out_key) {
 	if ((agskey == eAGSKeyCodeCtrlD) && (_GP(play).debug_mode > 0)) {
 		// ctrl+D - show info
 		char infobuf[900];
-		int ff;
 		sprintf(infobuf, "In room %d %s[Player at %d, %d (view %d, loop %d, frame %d)%s%s%s",
 		        _G(displayed_room), (_G(noWalkBehindsAtAll) ? "(has no walk-behinds)" : ""), _G(playerchar)->x, _G(playerchar)->y,
 		        _G(playerchar)->view + 1, _G(playerchar)->loop, _G(playerchar)->frame,
 		        (IsGamePaused() == 0) ? "" : "[Game paused.",
 		        (_GP(play).ground_level_areas_disabled == 0) ? "" : "[Ground areas disabled.",
 		        (IsInterfaceEnabled() == 0) ? "[Game in Wait state" : "");
-		for (ff = 0; ff < _G(croom)->numobj; ff++) {
+		for (uint32_t ff = 0; ff < _G(croom)->numobj; ff++) {
 			if (ff >= 8) break; // buffer not big enough for more than 7
 			sprintf(&infobuf[strlen(infobuf)],
 			        "[Object %d: (%d,%d) size (%d x %d) on:%d moving:%s animating:%d slot:%d trnsp:%d clkble:%d",
@@ -363,7 +362,7 @@ bool run_service_key_controls(KeyInput &out_key) {
 		Display(infobuf);
 		int chd = _GP(game).playercharacter;
 		char bigbuffer[STD_BUFFER_SIZE] = "CHARACTERS IN THIS ROOM:[";
-		for (ff = 0; ff < _GP(game).numcharacters; ff++) {
+		for (int ff = 0; ff < _GP(game).numcharacters; ff++) {
 			if (_GP(game).chars[ff].room != _G(displayed_room)) continue;
 			if (strlen(bigbuffer) > 430) {
 				strcat(bigbuffer, "and more...");
diff --git a/engines/ags/engine/main/update.cpp b/engines/ags/engine/main/update.cpp
index 648021e3dac..b8c74266053 100644
--- a/engines/ags/engine/main/update.cpp
+++ b/engines/ags/engine/main/update.cpp
@@ -179,7 +179,7 @@ void update_script_timers() {
 
 void update_cycling_views() {
 	// update graphics for object if cycling view
-	for (int i = 0; i < _G(croom)->numobj; ++i) {
+	for (uint32_t  i = 0; i < _G(croom)->numobj; ++i) {
 		_G(objs)[i].UpdateCyclingView(i);
 	}
 }
diff --git a/engines/ags/engine/platform/base/ags_platform_driver.h b/engines/ags/engine/platform/base/ags_platform_driver.h
index bee844e3f9a..a86efa7839a 100644
--- a/engines/ags/engine/platform/base/ags_platform_driver.h
+++ b/engines/ags/engine/platform/base/ags_platform_driver.h
@@ -87,7 +87,7 @@ struct AGSPlatformDriver
 	virtual void AttachToParentConsole();
 	virtual int  GetLastSystemError();
 	// Optionally fill in config tree from the platform-specific config source
-	virtual void ReadConfiguration(Shared::ConfigTree &cfg) {}
+	virtual void ReadConfiguration(Shared::ConfigTree & /*cfg*/) {}
 	// Get root directory for storing per-game shared data
 	virtual FSLocation GetAllUsersDataDirectory() {
 		return FSLocation(".");
diff --git a/engines/ags/shared/gui/gui_object.h b/engines/ags/shared/gui/gui_object.h
index 196918d7167..9140538ee36 100644
--- a/engines/ags/shared/gui/gui_object.h
+++ b/engines/ags/shared/gui/gui_object.h
@@ -69,7 +69,7 @@ public:
 	// Operations
 	// Returns the (untransformed!) visual rectangle of this control,
 	// in *relative* coordinates, optionally clipped by the logical size
-	virtual Rect    CalcGraphicRect(bool clipped) {
+	virtual Rect    CalcGraphicRect(bool /*clipped*/) {
 		return RectWH(0, 0, Width, Height);
 	}
 	virtual void    Draw(Bitmap *ds, int x = 0, int y = 0) {
diff --git a/engines/ags/shared/gui/gui_slider.cpp b/engines/ags/shared/gui/gui_slider.cpp
index 4efe00e743c..492d733fc9b 100644
--- a/engines/ags/shared/gui/gui_slider.cpp
+++ b/engines/ags/shared/gui/gui_slider.cpp
@@ -61,7 +61,7 @@ bool GUISlider::IsOverControl(int x, int y, int leeway) const {
 	return _cachedHandle.IsInside(Point(x, y));
 }
 
-Rect GUISlider::CalcGraphicRect(bool clipped) {
+Rect GUISlider::CalcGraphicRect(bool /*clipped*/) {
 	// Sliders are never clipped as of 3.6.0
 	// TODO: precalculate everything on width/height/graphic change!!
 	UpdateMetrics();


Commit: babf223ab7e2197b5c7d1ef159c8d8b094b5545b
    https://github.com/scummvm/scummvm/commit/babf223ab7e2197b5c7d1ef159c8d8b094b5545b
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-18T01:08:58+01:00

Commit Message:
AGS: Add WaitInput to Script API

- modify skip result to use a flag + data bitwise combination
- also include WaitInput in Script API header
- the input flags can only be 8-bit, since wait_skipped_by and
  key_skip_wait are char, and key_skip_wait is serialized in
  gamestate.

>From upstream 9e3d58a83dda00bff9073adb31b2b97adcf8d020

Changed paths:
    engines/ags/engine/ac/game_state.cpp
    engines/ags/engine/ac/global_api.cpp
    engines/ags/engine/ac/global_game.cpp
    engines/ags/engine/ac/global_game.h
    engines/ags/engine/ac/runtime_defines.h
    engines/ags/plugins/core/global_api.cpp
    engines/ags/plugins/core/global_api.h


diff --git a/engines/ags/engine/ac/game_state.cpp b/engines/ags/engine/ac/game_state.cpp
index 25481f57330..812f8973ab8 100644
--- a/engines/ags/engine/ac/game_state.cpp
+++ b/engines/ags/engine/ac/game_state.cpp
@@ -376,11 +376,7 @@ void GameState::SetWaitSkipResult(int how, int data) {
 }
 
 int GameState::GetWaitSkipResult() const {
-	switch (wait_skipped_by) {
-	case SKIP_KEYPRESS: return wait_skipped_by_data;
-	case SKIP_MOUSECLICK: return -(wait_skipped_by_data + 1); // convert to 1-based code and negate
-	default: return 0;
-	}
+	return wait_skipped_by << 16 | (wait_skipped_by_data & 0x0000FFFF);
 }
 
 bool GameState::IsBlockingVoiceSpeech() const {
diff --git a/engines/ags/engine/ac/global_api.cpp b/engines/ags/engine/ac/global_api.cpp
index bf48cd21a51..a816a872d54 100644
--- a/engines/ags/engine/ac/global_api.cpp
+++ b/engines/ags/engine/ac/global_api.cpp
@@ -1881,6 +1881,11 @@ RuntimeScriptValue Sc_WaitMouseKey(const RuntimeScriptValue *params, int32_t par
 	API_SCALL_INT_PINT(WaitMouseKey);
 }
 
+// int (int input_flags, int nloops)
+RuntimeScriptValue Sc_WaitInput(const RuntimeScriptValue *params, int32_t param_count) {
+	API_SCALL_INT_PINT2(WaitInput);
+}
+
 RuntimeScriptValue Sc_SkipWait(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SkipWait);
 }
@@ -2257,6 +2262,7 @@ void RegisterGlobalAPI() {
 	ccAddExternalStaticFunction("WaitKey",                  Sc_WaitKey);
 	ccAddExternalStaticFunction("WaitMouse",                Sc_WaitMouse);
 	ccAddExternalStaticFunction("WaitMouseKey",             Sc_WaitMouseKey);
+	ccAddExternalStaticFunction("WaitInput",                Sc_WaitInput);
 	ccAddExternalStaticFunction("SkipWait",                 Sc_SkipWait);
 }
 
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index 87cd69de640..a36fcec7785 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -807,6 +807,10 @@ int WaitMouseKey(int nloops) {
 	return WaitImpl(SKIP_KEYPRESS | SKIP_MOUSECLICK | SKIP_AUTOTIMER, nloops);
 }
 
+int WaitInput(int input_flags, int nloops) {
+	return WaitImpl(input_flags >> 16 | SKIP_AUTOTIMER, nloops);
+}
+
 void SkipWait() {
 	_GP(play).wait_counter = 0;
 }
diff --git a/engines/ags/engine/ac/global_game.h b/engines/ags/engine/ac/global_game.h
index 213d516a9af..5da6fa48827 100644
--- a/engines/ags/engine/ac/global_game.h
+++ b/engines/ags/engine/ac/global_game.h
@@ -107,6 +107,7 @@ void scrWait(int nloops);
 int WaitKey(int nloops);
 int WaitMouse(int nloops);
 int WaitMouseKey(int nloops);
+int WaitInput(int input_flags, int nloops);
 void SkipWait();
 
 void scStartRecording(int keyToStop);
diff --git a/engines/ags/engine/ac/runtime_defines.h b/engines/ags/engine/ac/runtime_defines.h
index 6bfcf23e9e7..b638ea44cb8 100644
--- a/engines/ags/engine/ac/runtime_defines.h
+++ b/engines/ags/engine/ac/runtime_defines.h
@@ -135,10 +135,10 @@ const int LegacyRoomVolumeFactor = 30;
 #define EVENT_CLAIMED    2
 
 // Internal skip style flags, for speech/display, wait
-#define SKIP_NONE       0
-#define SKIP_AUTOTIMER  1
-#define SKIP_KEYPRESS   2
-#define SKIP_MOUSECLICK 4
+#define SKIP_NONE       0x00
+#define SKIP_AUTOTIMER  0x01
+#define SKIP_KEYPRESS   0x02
+#define SKIP_MOUSECLICK 0x04
 
 #define MANOBJNUM 99
 
diff --git a/engines/ags/plugins/core/global_api.cpp b/engines/ags/plugins/core/global_api.cpp
index cc090842c8f..7a9df9508d7 100644
--- a/engines/ags/plugins/core/global_api.cpp
+++ b/engines/ags/plugins/core/global_api.cpp
@@ -439,6 +439,7 @@ void GlobalAPI::AGS_EngineStartup(IAGSEngine *engine) {
 	SCRIPT_METHOD(Wait, GlobalAPI::scrWait);
 	SCRIPT_METHOD(WaitKey, GlobalAPI::WaitKey);
 	SCRIPT_METHOD(WaitMouseKey, GlobalAPI::WaitMouseKey);
+	SCRIPT_METHOD(WaitInput, GlobalAPI::WaitInput);
 }
 
 void GlobalAPI::ScPl_sc_AbortGame(ScriptMethodParams &params) {
@@ -2216,6 +2217,11 @@ void GlobalAPI::WaitMouseKey(ScriptMethodParams &params) {
 	params._result = AGS3::WaitMouseKey(nloops);
 }
 
+void GlobalAPI::WaitInput(ScriptMethodParams &params) {
+	PARAMS2(int, input_flags, int, nloops);
+	params._result = AGS3::WaitInput(input_flags, nloops);
+}
+
 } // namespace Core
 } // namespace Plugins
 } // namespace AGS3
diff --git a/engines/ags/plugins/core/global_api.h b/engines/ags/plugins/core/global_api.h
index 8b87637fdd1..985a309c302 100644
--- a/engines/ags/plugins/core/global_api.h
+++ b/engines/ags/plugins/core/global_api.h
@@ -394,6 +394,7 @@ public:
 	void scrWait(ScriptMethodParams &params);
 	void WaitKey(ScriptMethodParams &params);
 	void WaitMouseKey(ScriptMethodParams &params);
+	void WaitInput(ScriptMethodParams &params);
 };
 
 } // namespace Core




More information about the Scummvm-git-logs mailing list