[Scummvm-git-logs] scummvm master -> 6be7f86bc6168a0047d93b16f26aecedd0ae24f6

aquadran noreply at scummvm.org
Sat Sep 13 16:33:54 UTC 2025


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

Summary:
6be7f86bc6 WINTERMUTE: Imported few script opcodes from latest wmelite


Commit: 6be7f86bc6168a0047d93b16f26aecedd0ae24f6
    https://github.com/scummvm/scummvm/commit/6be7f86bc6168a0047d93b16f26aecedd0ae24f6
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2025-09-13T18:33:48+02:00

Commit Message:
WINTERMUTE: Imported few script opcodes from latest wmelite

Changed paths:
    engines/wintermute/ad/ad_actor.cpp
    engines/wintermute/ad/ad_actor.h
    engines/wintermute/ad/ad_scene.cpp
    engines/wintermute/ad/ad_scene.h


diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp
index 318ec842862..10d78bb5eae 100644
--- a/engines/wintermute/ad/ad_actor.cpp
+++ b/engines/wintermute/ad/ad_actor.cpp
@@ -69,6 +69,9 @@ AdActor::AdActor(BaseGame *inGame) : AdTalkHolder(inGame) {
 
 	_animSprite2 = nullptr;
 
+	_stopOnBlocked = false;
+	_actorIsBlocked = false;
+
 	setDefaultAnimNames();
 }
 
@@ -187,6 +190,7 @@ TOKEN_DEF(RELATIVE_SCALE)
 TOKEN_DEF(ALPHA)
 TOKEN_DEF(EDITOR_PROPERTY)
 TOKEN_DEF(ANIMATION)
+TOKEN_DEF(STOP_ON_BLOCKED)
 TOKEN_DEF_END
 //////////////////////////////////////////////////////////////////////////
 bool AdActor::loadBuffer(char *buffer, bool complete) {
@@ -227,6 +231,7 @@ bool AdActor::loadBuffer(char *buffer, bool complete) {
 	TOKEN_TABLE(ALPHA)
 	TOKEN_TABLE(EDITOR_PROPERTY)
 	TOKEN_TABLE(ANIMATION)
+	TOKEN_TABLE(STOP_ON_BLOCKED)
 	TOKEN_TABLE_END
 
 	char *params;
@@ -511,6 +516,7 @@ void AdActor::turnTo(TDirection dir) {
 //////////////////////////////////////////////////////////////////////////
 void AdActor::goTo(int x, int y, TDirection afterWalkDir) {
 	_afterWalkDir = afterWalkDir;
+	_actorIsBlocked = false;
 	if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) {
 		return;
 	}
@@ -921,12 +927,26 @@ void AdActor::getNextStep() {
 		maxStepX--;
 	}
 
-	if (((AdGame *)_game)->_scene->isBlockedAt((int)_pFX, (int)_pFY, true, this)) {
+	if (((AdGame *)_game)->_scene->isBlockedAt((int)_pFX, (int)_pFY, true, this, false)) {
+		// is the actor already at its final position? this is not a block
 		if (_pFCount == 0) {
 			_state = _nextState;
 			_nextState = STATE_READY;
 			return;
 		}
+
+		// scripts can be informed if the actor is blocked right now
+		applyEvent("ActorIsBlocked");
+
+		// stop and set the block flag
+		if (_stopOnBlocked == true) {
+			_actorIsBlocked = true;
+			_state = _nextState;
+			_nextState = STATE_READY;
+			return;
+		}
+
+		// try to find a new path to the target
 		goTo(_targetPoint->x, _targetPoint->y);
 		return;
 	}
@@ -1159,6 +1179,25 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
 		const char *animName = stack->pop()->getString();
 		stack->pushBool(getAnimByName(animName) != nullptr);
 		return STATUS_OK;
+	}
+
+	//////////////////////////////////////////////////////////////////////////
+	// SetStopOnBlocked
+	//////////////////////////////////////////////////////////////////////////
+	else if (strcmp(name, "SetStopOnBlocked") == 0) {
+		stack->correctParams(1);
+		_stopOnBlocked = stack->pop()->getBool();
+		stack->pushNULL();
+		return STATUS_OK;
+	}
+
+	//////////////////////////////////////////////////////////////////////////
+	// GetStopOnBlocked
+	//////////////////////////////////////////////////////////////////////////
+	else if (strcmp(name, "GetStopOnBlocked") == 0) {
+		stack->correctParams(0);
+		stack->pushBool(_stopOnBlocked);
+		return STATUS_OK;
 	} else {
 		return AdTalkHolder::scCallMethod(script, stack, thisStack, name);
 	}
@@ -1221,6 +1260,14 @@ ScValue *AdActor::scGetProperty(const char *name) {
 	else if (strcmp(name, "TurnRightAnimName") == 0) {
 		_scValue->setString(_turnRightAnimName);
 		return _scValue;
+	}
+
+	//////////////////////////////////////////////////////////////////////////
+	// ActorIsBlocked
+	//////////////////////////////////////////////////////////////////////////
+	else if (strcmp(name, "ActorIsBlocked") == 0) {
+		_scValue->setBool(_actorIsBlocked);
+		return _scValue;
 	} else {
 		return AdTalkHolder::scGetProperty(name);
 	}
@@ -1433,6 +1480,14 @@ bool AdActor::persist(BasePersistenceManager *persistMgr) {
 	persistMgr->transferCharPtr(TMEMBER(_turnLeftAnimName));
 	persistMgr->transferCharPtr(TMEMBER(_turnRightAnimName));
 
+	// TODO: add at next save game version bump
+	//persistMgr->transferBool(TMEMBER(_stopOnBlocked));
+	//persistMgr->transferBool(TMEMBER(_actorIsBlocked));
+	if (!persistMgr->getIsSaving()) {
+		_stopOnBlocked = false;
+		_actorIsBlocked = false;
+	}
+
 	_anims.persist(persistMgr);
 
 	return STATUS_OK;
diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h
index b7071d37d80..05fa19b03bc 100644
--- a/engines/wintermute/ad/ad_actor.h
+++ b/engines/wintermute/ad/ad_actor.h
@@ -78,6 +78,10 @@ public:
 	bool playAnim(const char *filename) override;
 	AdSpriteSet *getAnimByName(const char *animName);
 
+	// alternative behaviour when actor is blocked
+	bool _stopOnBlocked;
+	bool _actorIsBlocked;
+
 	// scripting interface
 	ScValue *scGetProperty(const char *name) override;
 	bool scSetProperty(const char *name, ScValue *value) override;
diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp
index 2ce47f8d639..66bb68f9439 100644
--- a/engines/wintermute/ad/ad_scene.cpp
+++ b/engines/wintermute/ad/ad_scene.cpp
@@ -371,8 +371,8 @@ uint32 AdScene::getAlphaAt(int x, int y, bool colorCheck) {
 
 
 //////////////////////////////////////////////////////////////////////////
-bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *requester) {
-	bool ret = true;
+bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *requester, bool defaultBlock) {
+	bool ret = defaultBlock;
 
 	if (checkFreeObjects) {
 		for (int32 i = 0; i < _objects.getSize(); i++) {
diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h
index 7dd8d4d0c7e..838376a8b9f 100644
--- a/engines/wintermute/ad/ad_scene.h
+++ b/engines/wintermute/ad/ad_scene.h
@@ -145,7 +145,13 @@ public:
 	uint32 _pfMaxTime;
 	bool initLoop();
 	void pathFinderStep();
-	bool isBlockedAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr);
+	/*
+	 * Added the possibility to configure the default behaviour of this function. If neither free objects nor a main layer
+	 * exist, the function used to return "blocked". This results in all actors being "blocked" shortly after load.
+	 * The default behaviour is unchanged to avoid strange side effects. The actor class is now able to override this default.
+	 *
+	 */
+	bool isBlockedAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr, bool defaultBlock = true);
 	bool isWalkableAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr);
 	AdLayer *_mainLayer;
 	float getZoomAt(int x, int y);




More information about the Scummvm-git-logs mailing list