mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Merge pull request #4762 from IvanSavenko/bugfixing
Fixes for recently reported bugs and regressions
This commit is contained in:
commit
7866179a01
@ -309,7 +309,11 @@ const CHeroClass * CGHeroInstance::getHeroClass() const
|
|||||||
|
|
||||||
HeroClassID CGHeroInstance::getHeroClassID() const
|
HeroClassID CGHeroInstance::getHeroClassID() const
|
||||||
{
|
{
|
||||||
|
auto heroType = getHeroTypeID();
|
||||||
|
if (heroType.hasValue())
|
||||||
return getHeroType()->heroClass->getId();
|
return getHeroType()->heroClass->getId();
|
||||||
|
else
|
||||||
|
return HeroClassID();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CHero * CGHeroInstance::getHeroType() const
|
const CHero * CGHeroInstance::getHeroType() const
|
||||||
|
@ -208,7 +208,7 @@ int CGObjectInstance::getSightRadius() const
|
|||||||
int3 CGObjectInstance::getVisitableOffset() const
|
int3 CGObjectInstance::getVisitableOffset() const
|
||||||
{
|
{
|
||||||
if (!isVisitable())
|
if (!isVisitable())
|
||||||
throw std::runtime_error("Attempt to access visitable offset of a non-visitable object!");
|
logGlobal->debug("Attempt to access visitable offset on a non-visitable object!");
|
||||||
return appearance->getVisitableOffset();
|
return appearance->getVisitableOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ void CGObjectInstance::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
int3 CGObjectInstance::visitablePos() const
|
int3 CGObjectInstance::visitablePos() const
|
||||||
{
|
{
|
||||||
if (!isVisitable())
|
if (!isVisitable())
|
||||||
throw std::runtime_error("Attempt to access visitable position on a non-visitable object!");
|
logGlobal->debug("Attempt to access visitable position on a non-visitable object!");
|
||||||
|
|
||||||
return pos - getVisitableOffset();
|
return pos - getVisitableOffset();
|
||||||
}
|
}
|
||||||
|
@ -95,19 +95,7 @@ void CRewardableObject::blockingDialogAnswered(const CGHeroInstance * hero, int3
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (answer == 0)
|
onBlockingDialogAnswered(hero, answer);
|
||||||
return; //Player refused
|
|
||||||
|
|
||||||
if(answer > 0 && answer - 1 < configuration.info.size())
|
|
||||||
{
|
|
||||||
auto list = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
|
|
||||||
markAsVisited(hero);
|
|
||||||
grantReward(list[answer - 1], hero);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Unhandled choice");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,21 +131,7 @@ void TownRewardableBuildingInstance::heroLevelUpDone(const CGHeroInstance *hero)
|
|||||||
|
|
||||||
void TownRewardableBuildingInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
|
void TownRewardableBuildingInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
|
||||||
{
|
{
|
||||||
if(answer == 0)
|
onBlockingDialogAnswered(hero, answer);
|
||||||
return; // player refused
|
|
||||||
|
|
||||||
if(visitors.find(hero->id) != visitors.end())
|
|
||||||
return; // query not for this building
|
|
||||||
|
|
||||||
if(answer > 0 && answer-1 < configuration.info.size())
|
|
||||||
{
|
|
||||||
auto list = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
|
|
||||||
grantReward(list[answer - 1], hero);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Unhandled choice");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TownRewardableBuildingInstance::grantReward(ui32 rewardID, const CGHeroInstance * hero) const
|
void TownRewardableBuildingInstance::grantReward(ui32 rewardID, const CGHeroInstance * hero) const
|
||||||
|
@ -366,4 +366,21 @@ void Rewardable::Interface::doHeroVisit(const CGHeroInstance *h) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rewardable::Interface::onBlockingDialogAnswered(const CGHeroInstance * hero, int32_t answer) const
|
||||||
|
{
|
||||||
|
if (answer == 0)
|
||||||
|
return; //Player refused
|
||||||
|
|
||||||
|
if(answer > 0 && answer - 1 < configuration.info.size())
|
||||||
|
{
|
||||||
|
auto list = getAvailableRewards(hero, Rewardable::EEventType::EVENT_FIRST_VISIT);
|
||||||
|
markAsVisited(hero);
|
||||||
|
grantReward(list[answer - 1], hero);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unhandled choice");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -48,6 +48,8 @@ protected:
|
|||||||
virtual void markAsVisited(const CGHeroInstance * hero) const = 0;
|
virtual void markAsVisited(const CGHeroInstance * hero) const = 0;
|
||||||
virtual void markAsScouted(const CGHeroInstance * hero) const = 0;
|
virtual void markAsScouted(const CGHeroInstance * hero) const = 0;
|
||||||
virtual void grantReward(ui32 rewardID, const CGHeroInstance * hero) const = 0;
|
virtual void grantReward(ui32 rewardID, const CGHeroInstance * hero) const = 0;
|
||||||
|
|
||||||
|
void onBlockingDialogAnswered(const CGHeroInstance * hero, int32_t answer) const;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// filters list of visit info and returns rewards that can be granted to current hero
|
/// filters list of visit info and returns rewards that can be granted to current hero
|
||||||
|
@ -139,6 +139,18 @@ void Initializer::initialize(CGHeroInstance * o)
|
|||||||
o->tempOwner = PlayerColor::NEUTRAL;
|
o->tempOwner = PlayerColor::NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(o->ID == Obj::HERO)
|
||||||
|
{
|
||||||
|
for(auto const & t : VLC->heroh->objects)
|
||||||
|
{
|
||||||
|
if(t->heroClass->getId() == HeroClassID(o->subID))
|
||||||
|
{
|
||||||
|
o->subID = t->getId();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(o->getHeroTypeID().hasValue())
|
if(o->getHeroTypeID().hasValue())
|
||||||
{
|
{
|
||||||
o->gender = o->getHeroType()->gender;
|
o->gender = o->getHeroType()->gender;
|
||||||
|
@ -116,6 +116,8 @@ void NewTurnProcessor::handleTownEvents(const CGTownInstance * town)
|
|||||||
iw.components.emplace_back(ComponentType::CREATURE, town->creatures.at(i).second.back(), event.creatures.at(i));
|
iw.components.emplace_back(ComponentType::CREATURE, town->creatures.at(i).second.back(), event.creatures.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameHandler->sendAndApply(sac); //show dialog
|
||||||
}
|
}
|
||||||
gameHandler->sendAndApply(iw); //show dialog
|
gameHandler->sendAndApply(iw); //show dialog
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user