CvPlayerTrade::GetTradeConnectionTheirBuildingValueTimes100(const TradeConnection &, YieldTypes, bool)
- Defined in
- CvTradeClasses.cpp, line 2225
- Class
- CvPlayerTrade
- Hook name
CivHooks::CvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100
Hooks
static bool BeforeCvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100(CvPlayerTrade* self, const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer, int& result);static void AfterCvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100(CvPlayerTrade* self, const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer, int& result);static int ReplaceCvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100(int (*original)(CvPlayerTrade*, const TradeConnection&, YieldTypes, bool), CvPlayerTrade* self, const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer);CivRegisterBefore<CivHooks::CvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100>(host, &BeforeCvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100);CivRegisterAfter<CivHooks::CvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100>(host, &AfterCvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100);CivRegisterReplace<CivHooks::CvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100>(host, &ReplaceCvPlayerTrade_GetTradeConnectionTheirBuildingValueTimes100);
Code
2225int CvPlayerTrade::GetTradeConnectionTheirBuildingValueTimes100(const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer)2226{2227 // this only applies to international trade routes, so otherwise, buzz off!2228 if (!GC.getGame().GetGameTrade()->IsConnectionInternational(kTradeConnection))2229 {2230 return 0;2231 }22322233 if (eYield != YIELD_GOLD)2234 {2235 return 0;2236 }22372238 CvPlot* pOriginPlot = GC.getMap().plot(kTradeConnection.m_iOriginX, kTradeConnection.m_iOriginY);2239 CvPlot* pDestPlot = GC.getMap().plot(kTradeConnection.m_iDestX, kTradeConnection.m_iDestY);22402241 CvAssertMsg(pOriginPlot && pDestPlot, "pOriginPlot or pDestPlot are null");2242 if (!pOriginPlot || !pDestPlot)2243 {2244 return 0;2245 }22462247 CvCity* pDestCity = pDestPlot->getPlotCity();2248 if (!pDestCity)2249 {2250 return 0;2251 }22522253 int iBonus = 0;22542255 // minor civs should not get bonuses for others trading with them2256 if (!GET_PLAYER(kTradeConnection.m_eDestOwner).isMinorCiv() && !GET_PLAYER(kTradeConnection.m_eOriginOwner).isMinorCiv())2257 {2258 if (kTradeConnection.m_eOriginOwner == m_pPlayer->GetID())2259 {2260 iBonus += pDestCity->GetTradeRouteTargetBonus() * 100;2261 }22622263 if (kTradeConnection.m_eDestOwner == m_pPlayer->GetID())2264 {2265 iBonus += pDestCity->GetTradeRouteRecipientBonus() * 100;2266 }2267 }22682269 if (bAsOriginPlayer)2270 {2271 iBonus *= (100 + GET_PLAYER(kTradeConnection.m_eOriginOwner).GetPlayerTraits()->GetTradeBuildingModifier());2272 iBonus /= 100;2273 }2274 else2275 {2276 iBonus *= (100 + GET_PLAYER(kTradeConnection.m_eDestOwner).GetPlayerTraits()->GetTradeBuildingModifier());2277 iBonus /= 100;2278 } 22792280 return iBonus;2281}
Calls
- CvCity::GetTradeRouteRecipientBonus() const
- CvCity::GetTradeRouteTargetBonus() const
- CvGame::GetGameTrade()
- CvGameTrade::IsConnectionInternational(const TradeConnection &)
- CvGlobals::getGame()
- CvGlobals::getMap()
- CvMap::plot(int, int) const
- CvPlayer::GetID() const
- CvPlayer::GetPlayerTraits() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerTraits::GetTradeBuildingModifier() const
- CvPlot::getPlotCity() const