1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

- fixes crash on giving banned skills to hero (partial #1427)

- fixes hover text for prisons - they should not display name of imprisoned hero
- missing bits for launcher, Linux-specific
This commit is contained in:
Ivan Savenko
2013-09-04 23:00:51 +00:00
parent 6fc87d0df1
commit 0a627698d8
5 changed files with 38 additions and 18 deletions

View File

@@ -23,21 +23,23 @@
SecondarySkill CHeroClass::chooseSecSkill(const std::set<SecondarySkill> & possibles) const //picks secondary skill out from given possibilities
{
if(possibles.size()==1)
return *possibles.begin();
int totalProb = 0;
for(auto & possible : possibles)
{
totalProb += secSkillProbability[possible];
}
int ran = rand()%totalProb;
for(auto & possible : possibles)
if (totalProb != 0) // may trigger if set contains only banned skills (0 probability)
{
ran -= secSkillProbability[possible];
if(ran<0)
return possible;
int ran = rand()%totalProb;
for(auto & possible : possibles)
{
ran -= secSkillProbability[possible];
if(ran<0)
return possible;
}
}
throw std::runtime_error("Cannot pick secondary skill!");
// FIXME: select randomly? How H3 handles such rare situation?
return *possibles.begin();
}
EAlignment::EAlignment CHeroClass::getAlignment() const