1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

CGameState::updateRumor: fix infinite loop with only one map rumor

This commit is contained in:
Arseniy Shestakov 2016-09-15 23:22:25 +03:00
parent fdca75b4b0
commit c8090c78ec

View File

@ -2139,8 +2139,6 @@ void CGameState::updateRumor()
int rumorId = -1, rumorExtra = -1;
auto & rand = getRandomGenerator();
rumor.type = *RandomGeneratorUtil::nextItem(rumorTypes, rand);
if(!map->rumors.size() && rumor.type == RumorState::TYPE_MAP)
rumor.type = RumorState::TYPE_RAND;
do
{
@ -2181,9 +2179,14 @@ void CGameState::updateRumor()
break;
}
case RumorState::TYPE_MAP:
rumorId = rand.nextInt(map->rumors.size() - 1);
break;
// Makes sure that map rumors only used if there enough rumors too choose from
if(map->rumors.size() && (map->rumors.size() > 1 || !rumor.last.count(RumorState::TYPE_MAP)))
{
rumorId = rand.nextInt(map->rumors.size() - 1);
break;
}
else
rumor.type = RumorState::TYPE_RAND;
case RumorState::TYPE_RAND:
do