[Scummvm-git-logs] scummvm master -> 6924e2e92492492d1a2ef144d96b079565428ec2

scemino noreply at scummvm.org
Thu Mar 21 11:52:47 UTC 2024


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

Summary:
f2eea8952e TWP: Fix calling the 'Finalize' virtual function in the destructor in SQVM. PVS-Studio V1053
6924e2e924 TWP: Disallow to exec verb/walk when clicking in HUD


Commit: f2eea8952e7d3affe24435318ae83f7216d3c20c
    https://github.com/scummvm/scummvm/commit/f2eea8952e7d3affe24435318ae83f7216d3c20c
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-21T12:52:26+01:00

Commit Message:
TWP: Fix calling the 'Finalize' virtual function in the destructor in SQVM. PVS-Studio V1053

Changed paths:
    engines/twp/squirrel/sqvm.cpp


diff --git a/engines/twp/squirrel/sqvm.cpp b/engines/twp/squirrel/sqvm.cpp
index 2cb14212847..bf60dd3ac22 100755
--- a/engines/twp/squirrel/sqvm.cpp
+++ b/engines/twp/squirrel/sqvm.cpp
@@ -154,7 +154,7 @@ void SQVM::FinalizeCore()
 
 SQVM::~SQVM()
 {
-    Finalize();
+    FinalizeCore();
     REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain,this);
 }
 


Commit: 6924e2e92492492d1a2ef144d96b079565428ec2
    https://github.com/scummvm/scummvm/commit/6924e2e92492492d1a2ef144d96b079565428ec2
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-21T12:52:26+01:00

Commit Message:
TWP: Disallow to exec verb/walk when clicking in HUD

Changed paths:
    engines/twp/hud.cpp
    engines/twp/hud.h
    engines/twp/scenegraph.h
    engines/twp/twp.cpp


diff --git a/engines/twp/hud.cpp b/engines/twp/hud.cpp
index 8e65ae3540b..4bc557931ae 100644
--- a/engines/twp/hud.cpp
+++ b/engines/twp/hud.cpp
@@ -166,13 +166,12 @@ void Hud::drawCore(Math::Matrix4 trsf) {
 	_shader._highlightColor = slot->verbUiColors.verbHighlightTint;
 
 	bool isOver = false;
-	for (int i = 1; i < 22; i++) {
+	for (int i = 1; i < MAX_VERBS; i++) {
 		const Verb &verb = slot->verbs[i];
 		if (verb.image.size() > 0) {
 			const SpriteSheetFrame &verbFrame = verbSheet->getFrame(Common::String::format("%s%s_%s", verb.image.c_str(), verbSuffix.c_str(), lang.c_str()));
 			bool over = verbFrame.spriteSourceSize.contains(_mousePos.getX(), _mousePos.getY());
-			if (over)
-				isOver = true;
+			isOver |= over;
 			Color color = (over || (verb.id.id == _defaultVerbId)) ? verbHighlight : verbColor;
 			if (_mouseClick && over) {
 				_verb = verb;
@@ -185,9 +184,11 @@ void Hud::drawCore(Math::Matrix4 trsf) {
 }
 
 void Hud::update(float elapsed, Math::Vector2d pos, Common::SharedPtr<Object> hotspot, bool mouseClick) {
-	_mousePos = Math::Vector2d(pos.getX(), SCREEN_HEIGHT - pos.getY());
-	_defaultVerbId = !hotspot ? 0 : hotspot->defaultVerbId();
-	_mouseClick = mouseClick;
+	if(_active) {
+		_mousePos = Math::Vector2d(pos.getX(), SCREEN_HEIGHT - pos.getY());
+		_defaultVerbId = !hotspot ? 0 : hotspot->defaultVerbId();
+		_mouseClick = mouseClick;
+	}
 
 	_fadeTime += elapsed;
 
diff --git a/engines/twp/hud.h b/engines/twp/hud.h
index 10df3b63b08..78508c0d327 100644
--- a/engines/twp/hud.h
+++ b/engines/twp/hud.h
@@ -128,6 +128,7 @@ public:
 	int _defaultVerbId = 0;
 	float _fadeTime = 0.f;
 	bool _fadeIn = false;
+	bool _active = false;
 };
 } // namespace Twp
 
diff --git a/engines/twp/scenegraph.h b/engines/twp/scenegraph.h
index 8486084952b..02e5fad842b 100644
--- a/engines/twp/scenegraph.h
+++ b/engines/twp/scenegraph.h
@@ -308,6 +308,9 @@ private:
 	void drawItems(Math::Matrix4 trsf);
 	void drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf);
 
+public:
+	bool _active;
+
 private:
 	Common::SharedPtr<Object> _actor;
 	Color _backColor, _verbNormal;
diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp
index d536c52beff..e2e14223dd1 100644
--- a/engines/twp/twp.cpp
+++ b/engines/twp/twp.cpp
@@ -232,7 +232,7 @@ void TwpEngine::clickedAt(Math::Vector2d scrPos) {
 		Math::Vector2d roomPos = screenToRoom(scrPos);
 		Common::SharedPtr<Object> obj = objAt(roomPos);
 
-		if (_cursor.doubleClick) {
+		if (!_hud->_active && _cursor.doubleClick) {
 			walkFast(true);
 			_holdToMove = true;
 			return;
@@ -246,7 +246,7 @@ void TwpEngine::clickedAt(Math::Vector2d scrPos) {
 				sqcall("onVerbClick");
 				handled = execSentence(nullptr, vb.id, _noun1, _noun2);
 			}
-			if (!handled) {
+			if (!handled && !_hud->_active) {
 				if (_actor && (scrPos.getY() > 172)) {
 					// Just clicking on the ground
 					cancelSentence(_actor);
@@ -515,7 +515,7 @@ void TwpEngine::update(float elapsed) {
 			_sentence.setText(cursorText());
 
 			// call clickedAt if any button down
-			if ((_inputState.getInputActive() && _dialog->getState() == DialogState::None) && !_hud->isOver()) {
+			if ((_inputState.getInputActive() && _dialog->getState() == DialogState::None)) {
 				if (_cursor.isLeftDown() || _cursor.isRightDown()) {
 					clickedAt(scrPos);
 				} else if (_cursor.leftDown || _cursor.rightDown) {
@@ -617,6 +617,9 @@ void TwpEngine::update(float elapsed) {
 	}
 
 	// update inventory
+	const bool hudActive = (_room->_fullscreen == FULLSCREENROOM && (scrPos.getY() < 204.f));
+	_hud->_active = hudActive;
+	_uiInv._active = hudActive;
 	if (!_actor) {
 		_uiInv.update(elapsed);
 	} else {




More information about the Scummvm-git-logs mailing list