CvPlayer::getAdvancedStartVisibilityCost(bool, CvPlot *)
- Defined in
- CvPlayer.cpp, line 23519
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_getAdvancedStartVisibilityCost
Hooks
static bool BeforeCvPlayer_getAdvancedStartVisibilityCost(CvPlayer* self, bool bAdd, CvPlot* pPlot, int& result);static void AfterCvPlayer_getAdvancedStartVisibilityCost(CvPlayer* self, bool bAdd, CvPlot* pPlot, int& result);static int ReplaceCvPlayer_getAdvancedStartVisibilityCost(int (*original)(CvPlayer*, bool, CvPlot*), CvPlayer* self, bool bAdd, CvPlot* pPlot);CivRegisterBefore<CivHooks::CvPlayer_getAdvancedStartVisibilityCost>(host, &BeforeCvPlayer_getAdvancedStartVisibilityCost);CivRegisterAfter<CivHooks::CvPlayer_getAdvancedStartVisibilityCost>(host, &AfterCvPlayer_getAdvancedStartVisibilityCost);CivRegisterReplace<CivHooks::CvPlayer_getAdvancedStartVisibilityCost>(host, &ReplaceCvPlayer_getAdvancedStartVisibilityCost);
Code
23519int CvPlayer::getAdvancedStartVisibilityCost(bool bAdd, CvPlot* pPlot)23520{23521 if(0 == getNumCities())23522 {23523 return -1;23524 }2352523526 int iNumVisiblePlots = 0;23527 int iCost = GC.getADVANCED_START_VISIBILITY_COST();2352823529 // This denotes Visibility may not be purchased through Advanced Start23530 if(iCost == -1)23531 {23532 return -1;23533 }2353423535 // Valid Plot?23536 if(pPlot != NULL)23537 {23538 if(bAdd)23539 {23540 if(pPlot->isRevealed(getTeam()))23541 {23542 return -1;23543 }23544 if(!pPlot->isAdjacentRevealed(getTeam()))23545 {23546 return -1;23547 }23548 }23549 else23550 {23551 if(!pPlot->isRevealed(getTeam()))23552 {23553 return -1;23554 }23555 }23556 }2355723558 // Increase cost if the XML defines that additional units will cost more23559 if(0 != GC.getADVANCED_START_VISIBILITY_COST_INCREASE())23560 {23561 const int nPlots = GC.getMap().numPlots();23562 for(int iPlotLoop = 0; iPlotLoop < nPlots; iPlotLoop++)23563 {23564 CvPlot* pMapPlot = GC.getMap().plotByIndexUnchecked(iPlotLoop);2356523566 if(pMapPlot->isRevealed(getTeam()))23567 {23568 ++iNumVisiblePlots;23569 }23570 }2357123572 if(!bAdd)23573 {23574 --iNumVisiblePlots;23575 }2357623577 if(iNumVisiblePlots > 0)23578 {23579 iCost *= 100 + GC.getADVANCED_START_VISIBILITY_COST_INCREASE() * iNumVisiblePlots;23580 iCost /= 100;23581 }23582 }2358323584 return iCost;23585}
Calls
- CvGlobals::getADVANCED_START_VISIBILITY_COST()
- CvGlobals::getADVANCED_START_VISIBILITY_COST_INCREASE()
- CvGlobals::getMap()
- CvMap::numPlots() const
- CvMap::plotByIndexUnchecked(int) const
- CvPlayer::getNumCities() const
- CvPlayer::getTeam() const
- CvPlot::isAdjacentRevealed(TeamTypes) const
- CvPlot::isRevealed(TeamTypes) const