Hooks
static bool BeforeCvTacticalAnalysisMap_PopulateCell(CvTacticalAnalysisMap* self, int iIndex, CvPlot* pPlot, bool& result);static void AfterCvTacticalAnalysisMap_PopulateCell(CvTacticalAnalysisMap* self, int iIndex, CvPlot* pPlot, bool& result);static bool ReplaceCvTacticalAnalysisMap_PopulateCell(bool (*original)(CvTacticalAnalysisMap*, int, CvPlot*), CvTacticalAnalysisMap* self, int iIndex, CvPlot* pPlot);CivRegisterBefore<CivHooks::CvTacticalAnalysisMap_PopulateCell>(host, &BeforeCvTacticalAnalysisMap_PopulateCell);CivRegisterAfter<CivHooks::CvTacticalAnalysisMap_PopulateCell>(host, &AfterCvTacticalAnalysisMap_PopulateCell);CivRegisterReplace<CivHooks::CvTacticalAnalysisMap_PopulateCell>(host, &ReplaceCvTacticalAnalysisMap_PopulateCell);
Code
501/// Update data for a cell: returns whether or not to add to dominance zones502bool CvTacticalAnalysisMap::PopulateCell(int iIndex, CvPlot* pPlot)503{504 CvUnit* pLoopUnit;505 int iUnitLoop;506 CvTacticalAnalysisCell& cell = m_pPlots[iIndex];507508 cell.Clear();509510 cell.SetRevealed(pPlot->isRevealed(m_pPlayer->getTeam()));511 cell.SetVisible(pPlot->isVisible(m_pPlayer->getTeam()));512 cell.SetImpassableTerrain(pPlot->isImpassable() || pPlot->isMountain());513 cell.SetWater(pPlot->isWater());514 cell.SetOcean(pPlot->isWater() && !pPlot->isShallowWater());515516 bool bImpassableTerritory = false;517 if(pPlot->isOwned())518 {519 TeamTypes eMyTeam = m_pPlayer->getTeam();520 TeamTypes ePlotTeam = pPlot->getTeam();521522 if(eMyTeam != ePlotTeam && !GET_TEAM(eMyTeam).isAtWar(ePlotTeam) && !GET_TEAM(ePlotTeam).IsAllowsOpenBordersToTeam(eMyTeam))523 {524 bImpassableTerritory = true;525 }526 else if(pPlot->isCity())527 {528 if(pPlot->getOwner() == m_pPlayer->GetID())529 {530 cell.SetFriendlyCity(true);531 }532 else if(GET_TEAM(eMyTeam).isAtWar(ePlotTeam))533 {534 cell.SetEnemyCity(true);535 }536 else537 {538 cell.SetNeutralCity(true);539 }540 }541542 if(m_pPlayer->GetID() == pPlot->getOwner())543 {544 cell.SetOwnTerritory(true);545 }546547 if(GET_TEAM(eMyTeam).isFriendlyTerritory(ePlotTeam))548 {549 cell.SetFriendlyTerritory(true);550 }551552 if(GET_TEAM(ePlotTeam).isAtWar(ePlotTeam))553 {554 cell.SetEnemyTerritory(true);555 }556 }557 else558 {559 cell.SetUnclaimedTerritory(true);560 }561562 cell.SetImpassableTerritory(bImpassableTerritory);563 cell.SetDefenseModifier(pPlot->defenseModifier(NO_TEAM, true));564565 if(pPlot->getNumUnits() > 0)566 {567 for(iUnitLoop = 0; iUnitLoop < pPlot->getNumUnits(); iUnitLoop++)568 {569 pLoopUnit = pPlot->getUnitByIndex(iUnitLoop);570 if(!pLoopUnit) continue;571 if(pLoopUnit->getOwner() == m_pPlayer->GetID())572 {573 if(pLoopUnit->IsCombatUnit())574 {575 // CvAssertMsg(!cell.GetFriendlyMilitaryUnit(), "Two friendly military units in a hex, please show Ed and send save.");576 cell.SetFriendlyMilitaryUnit(pLoopUnit);577 }578 else579 {580 // CvAssertMsg(!cell.GetFriendlyCivilianUnit(), "Two friendly civilian units in a hex, please show Ed and send save.");581 cell.SetFriendlyCivilianUnit(pLoopUnit);582 }583 }584 else if(pLoopUnit->isEnemy(m_pPlayer->getTeam()))585 {586 if(pLoopUnit->IsCombatUnit())587 {588 // CvAssertMsg(!cell.GetEnemyMilitaryUnit(), "Two enemy military units in a hex, please show Ed and send save.");589 cell.SetEnemyMilitaryUnit(pLoopUnit);590 }591 else592 {593 // CvAssertMsg(!cell.GetEnemyCivilianUnit(), "Two enemy civilian units in a hex, please show Ed and send save.");594 cell.SetEnemyCivilianUnit(pLoopUnit);595 }596 }597 else598 {599 if(pLoopUnit->IsCombatUnit())600 {601 // CvAssertMsg(!cell.GetNeutralMilitaryUnit(), "Two neutral military units in a hex, please show Ed and send save.");602 cell.SetNeutralMilitaryUnit(pLoopUnit);603 }604 else605 {606 // CvAssertMsg(!cell.GetNeutralCivilianUnit(), "Two neutral civilian units in a hex, please show Ed and send save.");607 cell.SetNeutralCivilianUnit(pLoopUnit);608 }609 }610 }611 }612613 // Figure out whether or not to add this to a dominance zone614 bool bAdd = true;615 if(cell.IsImpassableTerrain() || cell.IsImpassableTerritory() || !cell.IsRevealed())616 {617 bAdd = false;618 }619 return bAdd;620}