CvPlayer::doWarnings()
- Defined in
- CvPlayer.cpp, line 23588
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_doWarnings
Hooks
static bool BeforeCvPlayer_doWarnings(CvPlayer* self);static void AfterCvPlayer_doWarnings(CvPlayer* self);static void ReplaceCvPlayer_doWarnings(void (*original)(CvPlayer*), CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_doWarnings>(host, &BeforeCvPlayer_doWarnings);CivRegisterAfter<CivHooks::CvPlayer_doWarnings>(host, &AfterCvPlayer_doWarnings);CivRegisterReplace<CivHooks::CvPlayer_doWarnings>(host, &ReplaceCvPlayer_doWarnings);
Code
23588void CvPlayer::doWarnings()23589{23590 if(m_eID == GC.getGame().getActivePlayer())23591 {23592 //update enemy units close to your territory23593 int iMaxCount = range(((getNumCities() + 4) / 7), 2, 5);23594 for(int iI = 0; iI < GC.getMap().numPlots(); iI++)23595 {23596 if(iMaxCount == 0)23597 {23598 break;23599 }2360023601 CvPlot* pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);2360223603 if(pLoopPlot->isAdjacentPlayer(GetID()))23604 {23605 if(!(pLoopPlot->isCity()))23606 {23607 if(pLoopPlot->isVisible(getTeam()))23608 {23609 CvUnit* pUnit = pLoopPlot->getVisibleEnemyDefender(GetID());23610 if(pUnit != NULL)23611 {23612 CvCity* pNearestCity = GC.getMap().findCity(pLoopPlot->getX(), pLoopPlot->getY(), GetID(), NO_TEAM, !(pLoopPlot->isWater()));2361323614 if(pNearestCity != NULL)23615 {23616 CvString message = GetLocalizedText("TXT_KEY_MISC_ENEMY_TROOPS_SPOTTED", pNearestCity->getNameKey());23617 GC.GetEngineUserInterface()->AddPlotMessage(0, pLoopPlot->GetPlotIndex(), GetID(), true, GC.getEVENT_MESSAGE_TIME(), message);2361823619 iMaxCount--;23620 }23621 }23622 }23623 }23624 }23625 }23626 }23627}
Calls
- CvCity::getNameKey() const
- CvGame::getActivePlayer() const
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getEVENT_MESSAGE_TIME()
- CvGlobals::getGame()
- CvGlobals::getMap()
- CvMap::findCity(int, int, PlayerTypes, TeamTypes, bool, bool, TeamTypes, DirectionTypes, const CvCity *)
- CvMap::numPlots() const
- CvMap::plotByIndexUnchecked(int) const
- CvPlayer::GetID() const
- CvPlayer::getNumCities() const
- CvPlayer::getTeam() const
- CvPlot::GetPlotIndex() const
- CvPlot::getVisibleEnemyDefender(PlayerTypes)
- CvPlot::getX() const
- CvPlot::getY() const
- CvPlot::isAdjacentPlayer(PlayerTypes, bool) const
- CvPlot::isCity() const
- CvPlot::isVisible(TeamTypes) const
- CvPlot::isWater() const
CvString::operator const char *FAutoVariable::operator const PlayerTypes &GetLocalizedTextICvUserInterface1::AddPlotMessage- range(int, int, int)