1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

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

Discussion in 'Civ4 - Bug Reports' started by Pep, Aug 11, 2008.

  1. Pep

    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.
     

    Attached Files:

  2. Pep

    Pep King

    Joined:
    May 28, 2002
    Messages:
    688
    Location:
    Spain
    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));

    ...

     

Share This Page