Code
4407int CvLuaPlayer::lGetTradeRoutes(lua_State* L)4408{4409 CvPlayerAI* pkPlayer = GetInstance(L);44104411 lua_createtable(L, 0, 0);4412 int index = 1;44134414 CvGameTrade* pTrade = GC.getGame().GetGameTrade();4415 for (uint ui = 0; ui < pTrade->m_aTradeConnections.size(); ui++)4416 {4417 if (pTrade->IsTradeRouteIndexEmpty(ui))4418 {4419 continue;4420 }44214422 TradeConnection* pConnection = &(pTrade->m_aTradeConnections[ui]);4423 if (pConnection->m_eOriginOwner != pkPlayer->GetID())4424 {4425 continue;4426 }44274428 CvCity* pFromCity = GC.getMap().plot(pConnection->m_iOriginX, pConnection->m_iOriginY)->getPlotCity();4429 CvCity* pToCity = GC.getMap().plot(pConnection->m_iDestX, pConnection->m_iDestY)->getPlotCity();44304431 CvPlayer* pToPlayer = &GET_PLAYER(pToCity->getOwner());44324433 lua_createtable(L, 0, 0);4434 const int t = lua_gettop(L);44354436#if defined(MOD_API_LUA_EXTENSIONS) && defined(MOD_API_TRADEROUTES)4437 lua_pushinteger(L, pConnection->m_eConnectionType);4438 lua_setfield(L, t, "TradeConnectionType");4439#endif4440 lua_pushinteger(L, pConnection->m_eDomain);4441 lua_setfield(L, t, "Domain");4442 lua_pushinteger(L, pkPlayer->getCivilizationType());4443 lua_setfield(L, t, "FromCivilizationType");4444 lua_pushinteger(L , pkPlayer->GetID());4445 lua_setfield(L, t, "FromID");4446 lua_pushstring(L, pFromCity->getName());4447 lua_setfield(L, t, "FromCityName");4448 CvLuaCity::Push(L, pFromCity);4449 lua_setfield(L, t, "FromCity");4450 lua_pushinteger(L, GET_PLAYER(pConnection->m_eDestOwner).getCivilizationType());4451 lua_setfield(L, t, "ToCivilizationType");4452 lua_pushinteger(L, pToPlayer->GetID());4453 lua_setfield(L, t, "ToID");4454 lua_pushstring(L, pToCity->getName());4455 lua_setfield(L, t, "ToCityName");4456 CvLuaCity::Push(L, pToCity);4457 lua_setfield(L, t, "ToCity");4458 lua_pushinteger(L, pkPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_GOLD, true));4459 lua_setfield(L, t, "FromGPT");4460 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_GOLD, false));4461 lua_setfield(L, t, "ToGPT");4462 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_FOOD, false));4463 lua_setfield(L, t, "ToFood");4464 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_PRODUCTION, false));4465 lua_setfield(L, t, "ToProduction");4466 lua_pushinteger(L, pkPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_SCIENCE, true));4467 lua_setfield(L, t, "FromScience");4468 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_SCIENCE, false));4469 lua_setfield(L, t, "ToScience");447044714472 ReligionTypes eToReligion = NO_RELIGION;4473 int iToPressure = 0;4474 ReligionTypes eFromReligion = NO_RELIGION;4475 int iFromPressure = 0;44764477 pFromCity->GetCityReligions()->WouldExertTradeRoutePressureToward(pToCity, eToReligion, iToPressure);4478 pToCity->GetCityReligions()->WouldExertTradeRoutePressureToward(pFromCity, eFromReligion, iFromPressure);4479 4480 // Internally pressure is now 10 times greater than what is shown to user4481 iToPressure /= GC.getRELIGION_MISSIONARY_PRESSURE_MULTIPLIER();4482 iFromPressure /= GC.getRELIGION_MISSIONARY_PRESSURE_MULTIPLIER();44834484 lua_pushinteger(L, eToReligion);4485 lua_setfield(L, t, "ToReligion");4486 lua_pushinteger(L, iToPressure);4487 lua_setfield(L, t, "ToPressure");4488 lua_pushinteger(L, eFromReligion);4489 lua_setfield(L, t, "FromReligion");4490 lua_pushinteger(L, iFromPressure);4491 lua_setfield(L, t, "FromPressure");44924493 int iToDelta = pFromCity->GetCityCulture()->GetBaseTourism() * pFromCity->GetCityCulture()->GetTourismMultiplier(pToPlayer->GetID(), true, true, false, true, true);4494 int iFromDelta = pToCity->GetCityCulture()->GetBaseTourism() * pToCity->GetCityCulture()->GetTourismMultiplier(pkPlayer->GetID(), true, true, false, true, true);4495 lua_pushinteger(L, iFromDelta);4496 lua_setfield(L, t, "FromTourism");4497 lua_pushinteger(L, iToDelta);4498 lua_setfield(L, t, "ToTourism");44994500 lua_pushinteger(L, pConnection->m_iTurnRouteComplete - GC.getGame().getGameTurn());4501 lua_setfield(L, t, "TurnsLeft");4502#if defined(MOD_API_LUA_EXTENSIONS) && defined(MOD_API_TRADEROUTES)4503 lua_pushinteger(L, pConnection->m_unitID);4504 lua_setfield(L, t, "UnitID");4505 lua_pushboolean(L, pConnection->m_bTradeUnitRecalled);4506 lua_setfield(L, t, "IsRecalled");4507 lua_pushinteger(L, pConnection->m_iCircuitsCompleted);4508 lua_setfield(L, t, "CircuitsCompleted");4509 lua_pushinteger(L, pConnection->m_iCircuitsToComplete);4510 lua_setfield(L, t, "CircuitsToComplete");4511 lua_pushboolean(L, pConnection->m_bTradeUnitMovingForward);4512 lua_setfield(L, t, "MovingForward");4513#endif45144515 lua_rawseti(L, -2, index++);4516 }45174518 return 1;4519}