aliens

Author Topic: curious, SavedBattleGame::getPatrolNode() @ Wb.  (Read 3845 times)

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
curious, SavedBattleGame::getPatrolNode() @ Wb.
« on: October 02, 2013, 06:57:46 am »
- from SavedBattleGame::getPatrolNode()

Code: [Select]
for (int i = 0; i < end; ++i)
{
if (!scout && fromNode->getNodeLinks()->at(i) < 1) continue;
Node *n = getNodes()->at(scout ? i : fromNode->getNodeLinks()->at(i));
if ((n->getFlags() > 0 || n->getRank() > 0 || scout) https:// for non-scouts we find a node with a desirability above 0
    && (!(n->getType() & Node::TYPE_SMALL)
|| unit->getArmor()->getSize() == 1) https:// the small unit bit is not set or the unit is small
&& (!(n->getType() & Node::TYPE_FLYING)
|| unit->getArmor()->getMovementType() == MT_FLY) https:// the flying unit bit is not set or the unit can fly
&& !n->isAllocated() https:// check if not allocated
&& !(n->getType() & Node::TYPE_DANGEROUS) https:// don't go there if an alien got shot there; stupid behavior like that
&& setUnitPosition(unit, n->getPosition(), true) https:// check if not already occupied
&& getTile(n->getPosition()) && !getTile(n->getPosition())->getFire() https:// you are not a firefighter; do not patrol into fire
&& (!scout || n != fromNode) https:// scouts push forward
&& n->getPosition().x > 0 && n->getPosition().y > 0)
{
if (!preferred
|| (preferred->getRank() == Node::nodeRank[unit->getRankInt()][0] && preferred->getFlags() < n->getFlags())
|| preferred->getFlags() < n->getFlags()) preferred = n;
{
compliantNodes.push_back(n);
}
}
}

preferred = n is hiding...

Even more confusing is that, although a change to SavedBattleGame.cpp shows up for me in the commit, "speed up alien turn somewhat" to Sup/master, this file didn't automatically merge to my personal branch, unlike AlienBAIState & CivilianBAIState which merged fine. so, Given the alleged confusion regarding preferred = n I'm wondering which is correct:

Code: [Select]
https:// pre-commit
getPathfinding()->calculate(unit, n->getPosition());
if (getPathfinding()->getStartDirection() != -1)
{
compliantNodes.push_back(n);
}
getPathfinding()->abortPath();

https:// or, simply

https:// post-commit
compliantNodes.push_back(n);


i Assume the latter, but figure a closer look'd be good too, if only for better formatting.
« Last Edit: October 02, 2013, 07:02:16 am by kevL »

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: curious, SavedBattleGame::getPatrolNode() @ Wb.
« Reply #1 on: October 02, 2013, 02:47:26 pm »
i removed the pathfinding to selectable nodes from getPatrolNode and moved it into AlienBAIState and CivilianBAIState as a post-selection check rather than a pre-selection condition. so yes, the latter is correct.

as for the formatting, yes, that needs fixed.

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: curious, SavedBattleGame::getPatrolNode() @ Wb.
« Reply #2 on: October 02, 2013, 03:09:07 pm »
ok, Ty