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

bluegr bluegr at gmail.com
Sun May 30 07:57:55 UTC 2021


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

Summary:
faaf6beaaa TRECISION: Group code that clears the inventory item combination state


Commit: faaf6beaaae0182cc9fdbf1a477b090b47118a7d
    https://github.com/scummvm/scummvm/commit/faaf6beaaae0182cc9fdbf1a477b090b47118a7d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-05-30T10:57:42+03:00

Commit Message:
TRECISION: Group code that clears the inventory item combination state

Changed paths:
    engines/trecision/inventory.cpp
    engines/trecision/logic.cpp
    engines/trecision/trecision.h


diff --git a/engines/trecision/inventory.cpp b/engines/trecision/inventory.cpp
index 5eefed6bdb..6842304c7a 100644
--- a/engines/trecision/inventory.cpp
+++ b/engines/trecision/inventory.cpp
@@ -127,18 +127,7 @@ void TrecisionEngine::examineItem() {
 	_actor->actorStop();
 	_pathFind->nextStep();
 	if (_flagUseWithStarted) {
-		_flagInventoryLocked = false;
-		_flagUseWithStarted = false;
-		_useWith[WITH] = _curInventory;
-		_useWithInv[WITH] = true;
-		if (_useWith[USED] != _curInventory) {
-			doUseWith();
-			_lightIcon = 0xFF;
-		} else {
-			_animMgr->smkStop(kSmackerIcon);
-			showInventoryName(_curInventory, true);
-			_lightIcon = _curInventory;
-		}
+		endUseWith();
 	} else
 		doInvExamine();
 }
@@ -149,19 +138,7 @@ void TrecisionEngine::useItem() {
 		return;
 
 	if (_flagUseWithStarted) {
-		_flagInventoryLocked = false;
-		_flagUseWithStarted = false;
-		_useWith[WITH] = _curInventory;
-		_useWithInv[WITH] = true;
-
-		if (_useWith[USED] != _curInventory) {
-			doUseWith();
-			_lightIcon = 0xFF;
-		} else {
-			_animMgr->smkStop(kSmackerIcon);
-			showInventoryName(_curInventory, true);
-			_lightIcon = _curInventory;
-		}
+		endUseWith();
 	} else if (_inventoryObj[_curInventory].isUseWith()) {
 		if ((_curInventory == kItemFlare) && (_curRoom == kRoom29)) {
 			_textMgr->characterSay(1565);
@@ -179,6 +156,38 @@ void TrecisionEngine::useItem() {
 		doInvOperate();
 }
 
+void TrecisionEngine::endUseWith() {
+	_flagInventoryLocked = false;
+	_flagUseWithStarted = false;
+	_useWith[WITH] = _curInventory;
+	_useWithInv[WITH] = true;
+	if (_useWith[USED] != _curInventory) {
+		doUseWith();
+		_lightIcon = 0xFF;
+	} else {
+		_animMgr->smkStop(kSmackerIcon);
+		showInventoryName(_curInventory, true);
+		_lightIcon = _curInventory;
+	}
+}
+
+void TrecisionEngine::clearUseWith() {
+	if (_flagUseWithStarted) {
+		if (_useWithInv[USED]) {
+			_lightIcon = 0xFF;
+			_animMgr->smkStop(kSmackerIcon);
+			setInventoryStart(_inventoryRefreshStartIcon, INVENTORY_HIDE);
+			_flagInventoryLocked = false;
+		}
+		_useWith[USED] = 0;
+		_useWith[WITH] = 0;
+		_useWithInv[USED] = false;
+		_useWithInv[WITH] = false;
+		_flagUseWithStarted = false;
+		_textMgr->clearLastText();
+	}
+}
+
 uint8 TrecisionEngine::whatIcon(Common::Point pos) {
 	if (pos.x < ICONMARGSX || pos.x > MAXX - ICONMARGDX)
 		return 0;
diff --git a/engines/trecision/logic.cpp b/engines/trecision/logic.cpp
index 5b446ff31c..2f496d1f36 100644
--- a/engines/trecision/logic.cpp
+++ b/engines/trecision/logic.cpp
@@ -3742,20 +3742,7 @@ void LogicManager::doMouseLeftRight() {
 				_vm->_textMgr->clearLastText();
 				_vm->_curObj = oDOOR2B;
 				_vm->startCharacterAction(a2B1PROVAAPRIREPORTA, 0, 0, 0);
-				if (_vm->_flagUseWithStarted) {
-					if (_vm->_useWithInv[USED]) {
-						_vm->_lightIcon = 0xFF;
-						_vm->_animMgr->smkStop(kSmackerIcon);
-						_vm->setInventoryStart(_vm->_inventoryRefreshStartIcon, INVENTORY_HIDE);
-						_vm->_flagInventoryLocked = false;
-					}
-					_vm->_useWith[USED] = 0;
-					_vm->_useWith[WITH] = 0;
-					_vm->_useWithInv[USED] = false;
-					_vm->_useWithInv[WITH] = false;
-					_vm->_flagUseWithStarted = false;
-					_vm->_textMgr->clearLastText();
-				}
+				_vm->clearUseWith();
 				return;
 			} else if (_vm->_curRoom == kRoom35 && !_vm->_room[kRoom35].hasExtra()
 					&& ((_vm->_curObj == oFRONTOFFICEC35)
@@ -3763,20 +3750,7 @@ void LogicManager::doMouseLeftRight() {
 			            || (_vm->_curObj == oSEDIA35) || (_vm->_curObj == oRIBELLEA35) || (_vm->_curObj == oCOMPUTER35) || (_vm->_curObj == oGIORNALE35))) {
 				_vm->_curObj = oLASTLEV5;
 				_vm->_scheduler->doEvent(MC_CHARACTER, ME_CHARACTERGOTOEXAMINE, MP_DEFAULT, _vm->_curMessage->_u16Param1, _vm->_curMessage->_u16Param2, 0, _vm->_curObj);
-				if (_vm->_flagUseWithStarted) {
-					if (_vm->_useWithInv[USED]) {
-						_vm->_lightIcon = 0xFF;
-						_vm->_animMgr->smkStop(kSmackerIcon);
-						_vm->setInventoryStart(_vm->_inventoryRefreshStartIcon, INVENTORY_HIDE);
-						_vm->_flagInventoryLocked = false;
-					}
-					_vm->_useWith[USED] = 0;
-					_vm->_useWith[WITH] = 0;
-					_vm->_useWithInv[USED] = false;
-					_vm->_useWithInv[WITH] = false;
-					_vm->_flagUseWithStarted = false;
-					_vm->_textMgr->clearLastText();
-				}
+				_vm->clearUseWith();
 				return;
 			} else if ((_vm->_curMessage->_event == ME_MLEFT) &&
 					   ((!_vm->_room[_vm->_curRoom].hasExtra() && ((_vm->_curObj == oENTRANCE2E) || (_vm->_curObj == od24TO26) || (_vm->_curObj == od21TO23 && !_vm->_obj[_vm->_curObj].isFlagExamine()))) ||
@@ -3872,16 +3846,10 @@ void LogicManager::doSystemChangeRoom(uint16 room) {
 	_vm->_scheduler->resetQueues();
 
 	_vm->closeInventoryImmediately();
+	_vm->clearUseWith();
 
 	_vm->_flagCharacterExists = true;
 	_vm->_flagShowCharacter = true;
-	_vm->_animMgr->smkStop(kSmackerIcon);
-	_vm->_useWith[USED] = 0;
-	_vm->_useWith[WITH] = 0;
-	_vm->_useWithInv[USED] = false;
-	_vm->_useWithInv[WITH] = false;
-	_vm->_flagUseWithStarted = false;
-	_vm->_lightIcon = 0xFF;
 	_vm->_flagCharacterSpeak = false;
 	_vm->_flagSomeoneSpeaks = false;
 	_vm->_actor->actorStop();
diff --git a/engines/trecision/trecision.h b/engines/trecision/trecision.h
index 9ecf3a95a5..008990a965 100644
--- a/engines/trecision/trecision.h
+++ b/engines/trecision/trecision.h
@@ -101,6 +101,7 @@ class TrecisionEngine : public Engine {
 	void doInventoryUseWithScreen();
 	void rollInventory(uint8 status);
 	void doScrollInventory(Common::Point pos);
+	void endUseWith();
 
 	// Script
 	void endScript();
@@ -180,6 +181,7 @@ public:
 	void closeInventoryImmediately();
 	void useItem();
 	void examineItem();
+	void clearUseWith();
 
 	// Script
 	void playScript(uint16 id);




More information about the Scummvm-git-logs mailing list