CvPlayer::canSpyBribeUnit(PlayerTypes, CvUnit &) const
- Defined in
- CvPlayer.cpp, line 26140
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_canSpyBribeUnit
Hooks
static bool BeforeCvPlayer_canSpyBribeUnit(const CvPlayer* self, PlayerTypes eTarget, CvUnit& kUnit, bool& result);static void AfterCvPlayer_canSpyBribeUnit(const CvPlayer* self, PlayerTypes eTarget, CvUnit& kUnit, bool& result);static bool ReplaceCvPlayer_canSpyBribeUnit(bool (*original)(const CvPlayer*, PlayerTypes, CvUnit&), const CvPlayer* self, PlayerTypes eTarget, CvUnit& kUnit);CivRegisterBefore<CivHooks::CvPlayer_canSpyBribeUnit>(host, &BeforeCvPlayer_canSpyBribeUnit);CivRegisterAfter<CivHooks::CvPlayer_canSpyBribeUnit>(host, &AfterCvPlayer_canSpyBribeUnit);CivRegisterReplace<CivHooks::CvPlayer_canSpyBribeUnit>(host, &ReplaceCvPlayer_canSpyBribeUnit);
Code
26140bool CvPlayer::canSpyBribeUnit(PlayerTypes eTarget, CvUnit& kUnit) const26141{26142 if(!canSpyDestroyUnit(eTarget, kUnit))26143 {26144 return false;26145 }2614626147 // Can't buy units when at war26148 if(kUnit.isEnemy(getTeam()))26149 {26150 return false;26151 }2615226153 IDInfo* pUnitNode = kUnit.plot()->headUnitNode();2615426155 while(pUnitNode != NULL)26156 {26157 CvUnit* pLoopUnit = ::getUnit(*pUnitNode);26158 pUnitNode = kUnit.plot()->nextUnitNode(pUnitNode);2615926160 if(NULL != pLoopUnit && pLoopUnit != &kUnit)26161 {26162 if(pLoopUnit->isEnemy(getTeam()))26163 {26164 // If we buy the unit, we will be on the same plot as an enemy unit! Not good.26165 return false;26166 }26167 }26168 }2616926170 return true;26171}