From 332a515d2cb718fdaa46f8c01875f430dbd03036 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 11:47:17 +0200 Subject: DM: Add getIndexInCell function in ChampionMan --- engines/dm/champion.cpp | 7 ++++++- engines/dm/champion.h | 6 +++--- engines/dm/loadsave.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 0e0d5e8eea..0ae05396f7 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -5,7 +5,12 @@ namespace DM { ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {} -ChampionIndex ChampionMan::getIndexInCell(int16 mapX, int16 mapY, ViewCell cell) { +ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { + for (uint16 i = 0; i < _partyChampionCount; ++i) { + if ((_champions[i]._cell == cell) && _champions[i]._currHealth) + return (ChampionIndex)i; + } + return kChampionNone; } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 36f1689b7a..536d3676b2 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -243,14 +243,14 @@ public: class ChampionMan { DMEngine *_vm; - Champion champions[4]; + Champion _champions[4]; public: - uint16 _partChampionCount; + uint16 _partyChampionCount; bool _partyDead; // @ G0303_B_PartyDead Thing _leaderHand; ChampionMan(DMEngine *vm); - ChampionIndex getIndexInCell(int16 mapX, int16 mapY, ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell + ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell }; } diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index cd522fa508..e58b746060 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -15,7 +15,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; - cm._partChampionCount = 0; + cm._partyChampionCount = 0; cm._leaderHand = Thing::thingNone; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { -- cgit v1.2.3