[Scummvm-git-logs] scummvm master -> 1f3a3be32346d2fdd4bbf6b983d4f4f12cb0cd48

bluegr noreply at scummvm.org
Sun Sep 18 20:24:03 UTC 2022


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:
1f3a3be323 SCUMM: HE: share condition mask logic


Commit: 1f3a3be32346d2fdd4bbf6b983d4f4f12cb0cd48
    https://github.com/scummvm/scummvm/commit/1f3a3be32346d2fdd4bbf6b983d4f4f12cb0cd48
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2022-09-18T23:23:58+03:00

Commit Message:
SCUMM: HE: share condition mask logic

Changed paths:
    engines/scumm/actor.cpp
    engines/scumm/actor_he.h


diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 2fb0a7212fb..5c54b4c0a05 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -3403,13 +3403,13 @@ void ActorHE::setHEFlag(int bit, int set) {
 	}
 }
 
-void ActorHE::setUserCondition(int slot, int set) {
+void ActorHE::setCondition(int slot, int set) {
 	const int condMaskCode = (_vm->_game.heversion >= 85) ? 0x1FFF : 0x3FF;
-	assertRange(1, slot, 32, "setUserCondition: Condition");
+	assertRange(1, slot, 32, "setCondition: Condition");
 	if (set == 0) {
-		_heCondMask &= ~(1 << (slot + 0xF));
+		_heCondMask &= ~(1 << (slot - 1));
 	} else {
-		_heCondMask |= 1 << (slot + 0xF);
+		_heCondMask |= 1 << (slot - 1);
 	}
 	if (_heCondMask & condMaskCode) {
 		_heCondMask &= ~1;
@@ -3418,28 +3418,33 @@ void ActorHE::setUserCondition(int slot, int set) {
 	}
 }
 
+bool ActorHE::isConditionSet(int slot) const {
+	assertRange(1, slot, 32, "isConditionSet: Condition");
+	return (_heCondMask & (1 << (slot - 1))) != 0;
+}
+
+void ActorHE::setUserCondition(int slot, int set) {
+	assertRange(1, slot, 16, "setUserCondition: Condition");
+	setCondition(slot + 16, set);
+}
+
 bool ActorHE::isUserConditionSet(int slot) const {
-	assertRange(1, slot, 32, "isUserConditionSet: Condition");
-	return (_heCondMask & (1 << (slot + 0xF))) != 0;
+	assertRange(1, slot, 16, "isUserConditionSet: Condition");
+	return isConditionSet(slot + 16);
 }
 
 void ActorHE::setTalkCondition(int slot) {
 	const int condMaskCode = (_vm->_game.heversion >= 85) ? 0x1FFF : 0x3FF;
-	assertRange(1, slot, 32, "setTalkCondition: Condition");
+	assertRange(1, slot, 16, "setTalkCondition: Condition");
 	_heCondMask = (_heCondMask & ~condMaskCode) | 1;
 	if (slot != 1) {
-		_heCondMask |= 1 << (slot - 1);
-		if (_heCondMask & condMaskCode) {
-			_heCondMask &= ~1;
-		} else {
-			_heCondMask |= 1;
-		}
+		setCondition(slot, 1);
 	}
 }
 
 bool ActorHE::isTalkConditionSet(int slot) const {
-	assertRange(1, slot, 32, "isTalkConditionSet: Condition");
-	return (_heCondMask & (1 << (slot - 1))) != 0;
+	assertRange(1, slot, 16, "isTalkConditionSet: Condition");
+	return isConditionSet(slot);
 }
 
 #ifdef ENABLE_HE
diff --git a/engines/scumm/actor_he.h b/engines/scumm/actor_he.h
index d05184c4f87..0f3c5666503 100644
--- a/engines/scumm/actor_he.h
+++ b/engines/scumm/actor_he.h
@@ -61,6 +61,9 @@ public:
 
 	void setHEFlag(int bit, int set);
 
+	void setCondition(int slot, int set);
+	bool isConditionSet(int slot) const;
+
 	void setUserCondition(int slot, int set);
 	bool isUserConditionSet(int slot) const;
 




More information about the Scummvm-git-logs mailing list