ViterboKnight
King
- Joined
- Feb 6, 2006
- Messages
- 796
The function CvPlayer::isValidTriggerCorporation could have a bug.
When PickCity, CorporationsRequired, NumCorporations and PickCorporation are all set, this functions does these steps:
- checks if the given corporation is listed among the CorporationsRequired.
- if a city has already be picked (and THAT's the case, look at the caller function, CvPlayer::initTriggeredData), the code enters that IF section, and the function will NEVER return TRUE.
Maybe, the last line of that function (the default value, the 'return false') should be instead a 'return true'.
bool CvPlayer::isValidTriggerCorporation(const CvEventTriggerInfo& kTrigger, CvCity* pCity, CorporationTypes eCorporation) const
{
if (kTrigger.getNumCorporationsRequired() > 0)
{
bool bFound = false;
for (int i = 0; i < kTrigger.getNumCorporationsRequired(); ++i)
{
if (eCorporation == kTrigger.getCorporationRequired(i))
{
bFound = true;
break;
}
}
if (!bFound)
{
return false;
}
}
if (NULL != pCity)
{
if (!pCity->isHasCorporation(eCorporation))
{
return false;
}
if (kTrigger.isHeadquarters())
{
if (!pCity->isHeadquarters(eCorporation))
{
return false;
}
}
}
else
{
if (getHasCorporationCount(eCorporation) > 0)
{
return true;
}
if (kTrigger.isHeadquarters())
{
CvCity* pHeadquarters = GC.getGameINLINE().getHeadquarters(eCorporation);
if (NULL == pHeadquarters || pHeadquarters->getOwnerINLINE() != getID())
{
return false;
}
}
}
return false;
}
When PickCity, CorporationsRequired, NumCorporations and PickCorporation are all set, this functions does these steps:
- checks if the given corporation is listed among the CorporationsRequired.
- if a city has already be picked (and THAT's the case, look at the caller function, CvPlayer::initTriggeredData), the code enters that IF section, and the function will NEVER return TRUE.
Maybe, the last line of that function (the default value, the 'return false') should be instead a 'return true'.
Spoiler :
bool CvPlayer::isValidTriggerCorporation(const CvEventTriggerInfo& kTrigger, CvCity* pCity, CorporationTypes eCorporation) const
{
if (kTrigger.getNumCorporationsRequired() > 0)
{
bool bFound = false;
for (int i = 0; i < kTrigger.getNumCorporationsRequired(); ++i)
{
if (eCorporation == kTrigger.getCorporationRequired(i))
{
bFound = true;
break;
if (!bFound)
{
return false;
if (NULL != pCity)
{
if (!pCity->isHasCorporation(eCorporation))
{
return false;
if (kTrigger.isHeadquarters())
{
if (!pCity->isHeadquarters(eCorporation))
{
return false;
else
{
if (getHasCorporationCount(eCorporation) > 0)
{
return true;
if (kTrigger.isHeadquarters())
{
CvCity* pHeadquarters = GC.getGameINLINE().getHeadquarters(eCorporation);
if (NULL == pHeadquarters || pHeadquarters->getOwnerINLINE() != getID())
{
return false;
return false;