From 658b58419b0c30efbb671431f3b4158d225cec7d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 30 Mar 2018 19:06:31 +0200 Subject: BLADERUNNER: Further work on acquireCluesByRelations() --- engines/bladerunner/actor_clues.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/bladerunner/actor_clues.h | 8 ++++++++ 2 files changed, 43 insertions(+) (limited to 'engines/bladerunner') diff --git a/engines/bladerunner/actor_clues.cpp b/engines/bladerunner/actor_clues.cpp index 3665f4de09..16b9002765 100644 --- a/engines/bladerunner/actor_clues.cpp +++ b/engines/bladerunner/actor_clues.cpp @@ -21,6 +21,7 @@ */ #include "bladerunner/actor_clues.h" +#include "bladerunner/actor.h" #include "bladerunner/bladerunner.h" #include "bladerunner/game_info.h" @@ -88,10 +89,40 @@ bool ActorClues::isAcquired(int clueId) const { #endif } +int ActorClues::getWeight(int clueId) const { + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) { + return 0; + } + return _clues[clueIndex].weight; +} + void ActorClues::acquireCluesByRelations(int actorId, int otherActorId) { warning("TODO: acquireCluesByRelations"); } +int ActorClues::findAcquirableCluesFromActor(int actorId, int targetActorId, CluesUS *list, int size) { + Actor *actor = _vm->_actors[actorId]; + Actor *otherActor = _vm->_actors[targetActorId]; + int count = 0; + int cluesCount = actor->_clues->getCount(); + + for (int i = 0; i < cluesCount; i++) { + int clueId = actor->_clues->getClueIdByIndex(i); + + if (actor->_clues->isAcquired(clueId) + && otherActor->_clues->getWeight(clueId) > 0 + && !otherActor->_clues->isAcquired(clueId)) { + list[count].clueId = clueId; + list[count].modifier = 0; + + count++; + } + } + + return count; +} + int ActorClues::getFromActorId(int clueId) const { int clueIndex = findClueIndex(clueId); if (clueIndex == -1) { @@ -171,6 +202,10 @@ int ActorClues::getCount() const { return _count; } +int ActorClues::getClueIdByIndex(int index) const { + return _clues[index].clueId; +} + void ActorClues::removeAll() { _count = 0; for (int i = 0; i < _maxCount; ++i) { diff --git a/engines/bladerunner/actor_clues.h b/engines/bladerunner/actor_clues.h index 8bf9011937..aa8693f71b 100644 --- a/engines/bladerunner/actor_clues.h +++ b/engines/bladerunner/actor_clues.h @@ -45,6 +45,11 @@ class ActorClues { byte flags; }; + struct CluesUS { + int clueId; + int modifier; + }; + BladeRunnerEngine *_vm; int _count; @@ -59,8 +64,10 @@ public: void acquire(int clueId, bool flag2, int fromActorId); void lose(int clueId); bool isAcquired(int clueId) const; + int getWeight(int clueId) const; void acquireCluesByRelations(int actorId, int otherActorId); + int findAcquirableCluesFromActor(int actorId, int targetActorId, CluesUS *list, int size); int getFromActorId(int clueId) const; @@ -75,6 +82,7 @@ public: int getField1(int clueId) const; int getCount() const; + int getClueIdByIndex(int index) const; void removeAll(); -- cgit v1.2.3