Sentry function not working properly when applied over a group of units

Pep

King
Joined
May 28, 2002
Messages
688
Location
Spain
In the attached image, the naval group (on sentry mission) doesn't awake when a barbarian warrior enters the red spot on the following turn. If you disband the galleon and then sentry the privateers, they do awake at the next turn. This is because the privateers have an extended visibility radius (as they start with the sentry promotion while the galleon doesn't). I think the visibility radius of a group when on a sentry mission, should be the highest of the visibility radius of the units that form the group.

You can open the savegame and test it too.
 

Attachments

  • Civ4ScreenShot0001.JPG
    Civ4ScreenShot0001.JPG
    129.8 KB · Views: 101
  • sentryTest.CivBeyondSwordSave
    86.4 KB · Views: 85
To correct this bug, I think the beginning of the function CvSelectionGroup::sentryAlert() could be modified:

Spoiler :

from:
bool CvSelectionGroup::sentryAlert() const
{
int iMaxRange = 0;
CLLNode<IDInfo>* pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);

int iRange = pLoopUnit->visibilityRange() + 1;

if (iRange > iMaxRange)
{
iMaxRange = iRange;
}
}

CvUnit* pHeadUnit = getHeadUnit();

...

to:
bool CvSelectionGroup::sentryAlert() const
{
int iMaxRange = 0;
CLLNode<IDInfo>* pUnitNode = headUnitNode();
int iIndex = -1;
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);

int iRange = pLoopUnit->visibilityRange() + 1;

if (iRange > iMaxRange)
{
iMaxRange = iRange;
iIndex = getUnitIndex(pLoopUnit);
}
}

CvUnit* pHeadUnit = ((iIndex == -1) ? NULL : getUnitAt(iIndex));

...

 
Top Bottom