CvPlayer::GetBorrowedCityName(CivilizationTypes) const
- Defined in
- CvPlayer.cpp, line 3257
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetBorrowedCityName
Hooks
static bool BeforeCvPlayer_GetBorrowedCityName(const CvPlayer* self, CivilizationTypes eCivToBorrowFrom, CvString& result);static void AfterCvPlayer_GetBorrowedCityName(const CvPlayer* self, CivilizationTypes eCivToBorrowFrom, CvString& result);static CvString ReplaceCvPlayer_GetBorrowedCityName(CvString (*original)(const CvPlayer*, CivilizationTypes), const CvPlayer* self, CivilizationTypes eCivToBorrowFrom);CivRegisterBefore<CivHooks::CvPlayer_GetBorrowedCityName>(host, &BeforeCvPlayer_GetBorrowedCityName);CivRegisterAfter<CivHooks::CvPlayer_GetBorrowedCityName>(host, &AfterCvPlayer_GetBorrowedCityName);CivRegisterReplace<CivHooks::CvPlayer_GetBorrowedCityName>(host, &ReplaceCvPlayer_GetBorrowedCityName);
Code
3257CvString CvPlayer::GetBorrowedCityName(CivilizationTypes eCivToBorrowFrom) const3258{3259 CvString szRtnValue;3260 CvCivilizationInfo *pCivInfo = GC.getCivilizationInfo(eCivToBorrowFrom);32613262 if (pCivInfo)3263 {3264 int iRange = pCivInfo->getNumCityNames() - RESERVE_TOP_X_NAMES;3265 int iRandOffset = GC.getGame().getJonRandNum(iRange, "Random City Name To Steal");3266 for(int iI = 0; iI < iRange; iI++) 3267 {3268 CvString strCityName = pCivInfo->getCityNames(RESERVE_TOP_X_NAMES + ((iI + iRandOffset) % iRange));3269 szRtnValue = GetLocalizedText(strCityName.c_str());32703271 if(isCityNameValid(szRtnValue, true))3272 {3273 break;3274 }3275 }3276 }32773278 return szRtnValue;32793280}
Calls
- CvCivilizationInfo::getCityNames(int) const
- CvCivilizationInfo::getNumCityNames() const
- CvGame::getJonRandNum(int, const char *)
- CvGlobals::getCivilizationInfo(CivilizationTypes)
- CvGlobals::getGame()
- CvPlayer::isCityNameValid(CvString &, bool) const
CvString::CvStringCvString::CvStringCvString::CvStringCvString::operator=- GetLocalizedText(const char *)
std::basic_string::c_str