From 29d6fb0f049e66c1c1aa87b6ac42974aff066839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= Date: Fri, 16 Sep 2016 20:59:07 +0200 Subject: [PATCH] Properly check if corpse was visited Fixes two issues: - corpse without loot couldn't be marked as visited - taking loot from once visitable objects marked them as visited for all players --- lib/mapObjects/CRewardableObject.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/mapObjects/CRewardableObject.cpp b/lib/mapObjects/CRewardableObject.cpp index 9f488cda3..df56f7103 100644 --- a/lib/mapObjects/CRewardableObject.cpp +++ b/lib/mapObjects/CRewardableObject.cpp @@ -317,16 +317,11 @@ bool CRewardableObject::wasVisited(PlayerColor player) const case VISIT_UNLIMITED: case VISIT_BONUS: return false; - case VISIT_ONCE: // FIXME: hide this info deeper and return same as player? - for (auto & visit : info) - { - if (visit.numOfGrants != 0) - return true; - } - case VISIT_HERO: - return false; + case VISIT_ONCE: case VISIT_PLAYER: return vstd::contains(cb->getPlayer(player)->visitedObjects, ObjectInstanceID(id)); + case VISIT_HERO: + return false; default: return false; } @@ -826,12 +821,16 @@ void CGOnceVisitable::initObj(CRandomGenerator & rand) onEmpty.addTxt(MetaString::ADVOB_TXT, 38); soundID = soundBase::MYSTERY; blockVisit = true; + info.resize(1); if(rand.nextInt(99) < 20) { - info.resize(1); loadRandomArtifact(rand, info[0], 10, 10, 10, 0); info[0].message.addTxt(MetaString::ADVOB_TXT, 37); } + else + { + info[0].message.addTxt(MetaString::ADVOB_TXT, 38); + } } break; case Obj::LEAN_TO: