[Scummvm-git-logs] scummvm master -> 922ba51bf816ea983da9d80d3dc31a6a842aaf65

scemino noreply at scummvm.org
Sun Mar 24 12:18:03 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:
7c4f21d7a8 TWP: When actor turns he should stand
922ba51bf8 TWP: Fix missing animations


Commit: 7c4f21d7a85f22f8c418c966484c5f56fa78949d
    https://github.com/scummvm/scummvm/commit/7c4f21d7a85f22f8c418c966484c5f56fa78949d
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-24T12:09:19+01:00

Commit Message:
TWP: When actor turns he should stand

Changed paths:
    engines/twp/object.cpp


diff --git a/engines/twp/object.cpp b/engines/twp/object.cpp
index fe4fd243348..315d6557fb1 100644
--- a/engines/twp/object.cpp
+++ b/engines/twp/object.cpp
@@ -798,11 +798,13 @@ void Object::walk(Common::SharedPtr<Object> actor, Common::SharedPtr<Object> obj
 }
 
 void Object::turn(Facing facing) {
+	stand();
 	setFacing(facing);
 }
 
 void Object::turn(Common::SharedPtr<Object> actor, Common::SharedPtr<Object> obj) {
 	Facing facing = getFacingToFaceTo(actor, obj);
+	actor->stand();
 	actor->setFacing(facing);
 }
 


Commit: 922ba51bf816ea983da9d80d3dc31a6a842aaf65
    https://github.com/scummvm/scummvm/commit/922ba51bf816ea983da9d80d3dc31a6a842aaf65
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-24T12:09:19+01:00

Commit Message:
TWP: Fix missing animations

Changed paths:
    engines/twp/object.cpp


diff --git a/engines/twp/object.cpp b/engines/twp/object.cpp
index 315d6557fb1..43ba6808756 100644
--- a/engines/twp/object.cpp
+++ b/engines/twp/object.cpp
@@ -189,6 +189,27 @@ bool Object::playCore(const Common::String &state, bool loop, bool instant) {
 	return false;
 }
 
+static Node* getChildByName(Node* node, const Common::String& name) {
+	if(!node)
+		return nullptr;
+	for (auto child : node->getChildren()) {
+		if (child->getName() == name) {
+			return child;
+		}
+	}
+	return nullptr;
+}
+
+static Node* getLayerByName(Node* node, const Common::String& name) {
+	Node* child = getChildByName(node, name);
+	if(child)
+		return child;
+	if(node->getChildren().size()==1) {
+		return getChildByName(node->getChildren()[0], name);
+	}
+	return nullptr;
+}
+
 void Object::showLayer(const Common::String &layer, bool visible) {
 	int index = -1;
 	for (size_t i = 0; i < _hiddenLayers.size(); i++) {
@@ -205,14 +226,9 @@ void Object::showLayer(const Common::String &layer, bool visible) {
 		if (index == -1)
 			_hiddenLayers.push_back(layer);
 	}
-	if (_node != NULL) {
-		for (size_t i = 0; i < _node->getChildren().size(); i++) {
-			Node *node = _node->getChildren()[i];
-			if (node->getName() == layer) {
-				node->setVisible(visible);
-			}
-		}
-	}
+	Node* node = getLayerByName(_node.get(), layer);
+	if(node)
+		node->setVisible(visible);
 }
 
 Facing Object::getFacing() const {
@@ -499,6 +515,9 @@ Common::String Object::getAnimName(const Common::String &key) {
 }
 
 void Object::setHeadIndex(int head) {
+	Node* node = getLayerByName(_node.get(), Common::String::format("%s%d", getAnimName(HEAD_ANIMNAME).c_str(), head));
+	if(!node)
+		return;
 	for (int i = 0; i <= 6; i++) {
 		showLayer(Common::String::format("%s%d", getAnimName(HEAD_ANIMNAME).c_str(), i), i == head);
 	}
@@ -513,20 +532,35 @@ void Object::stopWalking() {
 		_walkTo->disable();
 }
 
-void Object::setAnimationNames(const Common::String &head, const Common::String &stand, const Common::String &walk, const Common::String &reach) {
-	if (!head.empty())
+void Object::setAnimationNames(const Common::String &head, const Common::String &standAnim, const Common::String &walk, const Common::String &reach) {
+	if (!head.empty()) {
 		setHeadIndex(0);
-	_animNames[HEAD_ANIMNAME] = head;
-	showLayer(_animNames[HEAD_ANIMNAME], true);
+		_animNames[HEAD_ANIMNAME] = head;
+	} else {
+		_animNames.erase(HEAD_ANIMNAME);
+	}
+
+	showLayer(getAnimName(HEAD_ANIMNAME), true);
 	setHeadIndex(1);
-	if (!stand.empty())
-		_animNames[STAND_ANIMNAME] = stand;
-	if (!walk.empty())
+	if (!standAnim.empty()) {
+		_animNames[STAND_ANIMNAME] = standAnim;
+	} else {
+		_animNames.erase(STAND_ANIMNAME);
+	}
+	if (!walk.empty()) {
 		_animNames[WALK_ANIMNAME] = walk;
-	if (!reach.empty())
+	} else {
+		_animNames.erase(WALK_ANIMNAME);
+	}
+	if (!reach.empty()) {
 		_animNames[REACH_ANIMNAME] = reach;
+	} else {
+		_animNames.erase(REACH_ANIMNAME);
+	}
 	if (isWalking())
 		play(getAnimName(WALK_ANIMNAME), true);
+	else
+		stand();
 }
 
 void Object::blinkRate(Common::SharedPtr<Object> obj, float min, float max) {
@@ -561,7 +595,7 @@ void Object::setCostume(const Common::String &name, const Common::String &sheet)
 }
 
 void Object::stand() {
-	play(getAnimName(STAND_ANIMNAME));
+	play(getAnimName(STAND_ANIMNAME), true);
 }
 
 #define SET_MOTOR(motorTo)     \




More information about the Scummvm-git-logs mailing list