Hooks
static bool BeforeCvLuaPlayer_lGetTradeToYouRoutesTTString(lua_State* L, int& result);static void AfterCvLuaPlayer_lGetTradeToYouRoutesTTString(lua_State* L, int& result);static int ReplaceCvLuaPlayer_lGetTradeToYouRoutesTTString(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaPlayer_lGetTradeToYouRoutesTTString>(host, &BeforeCvLuaPlayer_lGetTradeToYouRoutesTTString);CivRegisterAfter<CivHooks::CvLuaPlayer_lGetTradeToYouRoutesTTString>(host, &AfterCvLuaPlayer_lGetTradeToYouRoutesTTString);CivRegisterReplace<CivHooks::CvLuaPlayer_lGetTradeToYouRoutesTTString>(host, &ReplaceCvLuaPlayer_lGetTradeToYouRoutesTTString);
Code
4235int CvLuaPlayer::lGetTradeToYouRoutesTTString(lua_State* L)4236{4237 CvPlayerAI* pkPlayer = GetInstance(L);4238 CvGameTrade* pTrade = GC.getGame().GetGameTrade();4239 CvPlayerTrade* pPlayerTrade = pkPlayer->GetTrade();42404241 CvString strResult = ""; 42424243 TradeConnection* pConnection = NULL;4244 for (uint ui = 0; ui < pTrade->m_aTradeConnections.size(); ui++)4245 {4246 if (pTrade->IsTradeRouteIndexEmpty(ui))4247 {4248 continue;4249 }42504251 pConnection = &(pTrade->m_aTradeConnections[ui]);42524253 // don't include internal trade, but does this not count teams sharing stuff between each other4254 if (pConnection->m_eConnectionType != TRADE_CONNECTION_INTERNATIONAL)4255 {4256 continue;4257 }42584259 if (pConnection->m_eDestOwner == pkPlayer->GetID())4260 {4261 CvPlot* pOriginPlot = GC.getMap().plot(pConnection->m_iOriginX, pConnection->m_iOriginY);4262 CvPlot* pDestPlot = GC.getMap().plot(pConnection->m_iDestX, pConnection->m_iDestY);4263 if (pOriginPlot == NULL || pDestPlot == NULL)4264 {4265 continue;4266 }42674268 CvCity* pOriginCity = pOriginPlot->getPlotCity();4269 CvCity* pDestCity = pDestPlot->getPlotCity();42704271 if (pOriginCity == NULL || pDestCity == NULL)4272 {4273 continue;4274 }42754276 CvString strOriginYieldsStr = "";4277 //for (uint uiYield = 0; uiYield < NUM_YIELD_TYPES; uiYield++)4278 //{4279 // YieldTypes eYield = (YieldTypes)uiYield;4280 // int iYieldQuantity = pPlayerTrade->GetTradeConnectionValueTimes100(*pConnection, eYield, false);4281 // if (iYieldQuantity != 0)4282 // {4283 // switch (eYield)4284 // {4285 // case YIELD_FOOD:4286 // strOriginYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_FOOD_YIELD_TT", iYieldQuantity / 100);4287 // break;4288 // case YIELD_PRODUCTION:4289 // strOriginYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_PRODUCTION_YIELD_TT", iYieldQuantity / 100);4290 // break;4291 // case YIELD_GOLD:4292 // strOriginYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_GOLD_YIELD_TT", iYieldQuantity / 100);4293 // break;4294 // case YIELD_SCIENCE:4295 // strOriginYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_SCIENCE_YIELD_TT", iYieldQuantity / 100);4296 // break;4297 // case YIELD_CULTURE:4298 // strOriginYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_CULTURE_YIELD_TT", iYieldQuantity / 100);4299 // break;4300 // case YIELD_FAITH:4301 // strOriginYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_FAITH_YIELD_TT", iYieldQuantity / 100);4302 // break;4303 // }4304 // }4305 //}43064307 CvString strDestYieldsStr = "";4308 for (uint uiYield = 0; uiYield < NUM_YIELD_TYPES; uiYield++)4309 {4310 YieldTypes eYield = (YieldTypes)uiYield;4311 int iYieldQuantity = pPlayerTrade->GetTradeConnectionValueTimes100(*pConnection, eYield, false);4312 if (iYieldQuantity != 0)4313 {4314 if (strDestYieldsStr != "") 4315 {4316 strDestYieldsStr += ", ";4317 }4318 switch (eYield)4319 {4320 case YIELD_FOOD:4321 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_FOOD_YIELD_TT", iYieldQuantity / 100);4322 break;4323 case YIELD_PRODUCTION:4324 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_PRODUCTION_YIELD_TT", iYieldQuantity / 100);4325 break;4326 case YIELD_GOLD:4327 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_GOLD_YIELD_TT", iYieldQuantity / 100);4328 break;4329 case YIELD_SCIENCE:4330 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_SCIENCE_YIELD_TT", iYieldQuantity / 100);4331 break;4332 case YIELD_CULTURE:4333 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_CULTURE_YIELD_TT", iYieldQuantity / 100);4334 break;4335 case YIELD_FAITH:4336 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_FAITH_YIELD_TT", iYieldQuantity / 100);4337 break;4338#if defined(MOD_API_UNIFIED_YIELDS_TOURISM)4339 case YIELD_TOURISM:4340 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_TOURISM_YIELD_TT", iYieldQuantity / 100);4341 break;4342#endif4343#if defined(MOD_API_UNIFIED_YIELDS_GOLDEN_AGE)4344 case YIELD_GOLDEN_AGE_POINTS:4345 strDestYieldsStr += GetLocalizedText("TXT_KEY_TOP_PANEL_ITR_GOLDEN_AGE_POINTS_YIELD_TT", iYieldQuantity / 100);4346 break;4347#endif4348 }4349 }4350 }43514352 //CvUnitEntry* pUnitEntry = GC.getUnitInfo(pPlayerTrade->GetTradeUnit(pConnection->m_eDomain));43534354 Localization::String strBuffer;4355 if (strOriginYieldsStr != "" && strDestYieldsStr != "")4356 {4357 strBuffer = Localization::Lookup("TXT_KEY_TOP_PANEL_ITR_TO_YOU_ROUTE_BOTH_TT");4358 }4359 else if (strOriginYieldsStr != "")4360 {4361 strBuffer = Localization::Lookup("TXT_KEY_TOP_PANEL_ITR_TO_YOU_ROUTE_ONLY_ORIGIN_TT");4362 }4363 else if (strDestYieldsStr != "")4364 {4365 strBuffer = Localization::Lookup("TXT_KEY_TOP_PANEL_ITR_TO_YOU_ROUTE_ONLY_DEST_TT");4366 }43674368 if (pConnection->m_eConnectionType == TRADE_CONNECTION_INTERNATIONAL)4369 {4370 if (GET_PLAYER(pDestCity->getOwner()).isMinorCiv())4371 {4372 strBuffer << "TXT_KEY_TOP_PANEL_ITR_CITY_STATE_TT";4373 }4374 else4375 {4376 strBuffer << GET_PLAYER(pOriginCity->getOwner()).getCivilizationShortDescription();4377 }4378 }43794380 strBuffer << pOriginCity->getNameKey();4381 if (strOriginYieldsStr != "")4382 {4383 strBuffer << strOriginYieldsStr;4384 }43854386 strBuffer << pDestCity->getNameKey();4387 if (strDestYieldsStr != "")4388 {4389 strBuffer << strDestYieldsStr;4390 }43914392 if (strResult != "")4393 {4394 strResult += "[NEWLINE]";4395 }43964397 strResult += strBuffer.toUTF8();4398 }4399 }44004401 lua_pushstring(L, strResult);44024403 return 1;4404}