Code
3002// Most of this came from CvLuaPlayer::lGetTradeRoutes(lua_State* L)3003int CvLuaGame::lGetTradeRoute(lua_State* L)3004{3005 const int iRouteIndex = lua_tointeger(L, 1);30063007 CvGameTrade* pTrade = GC.getGame().GetGameTrade();3008 if (!pTrade->IsTradeRouteIndexEmpty(iRouteIndex)) {3009 TradeConnection* pConnection = &(pTrade->m_aTradeConnections[iRouteIndex]);3010 CvCity* pFromCity = GC.getMap().plot(pConnection->m_iOriginX, pConnection->m_iOriginY)->getPlotCity();3011 CvPlayer* pFromPlayer = &GET_PLAYER(pFromCity->getOwner());3012 CvCity* pToCity = GC.getMap().plot(pConnection->m_iDestX, pConnection->m_iDestY)->getPlotCity();3013 CvPlayer* pToPlayer = &GET_PLAYER(pToCity->getOwner());30143015 lua_createtable(L, 0, 0);3016 const int t = lua_gettop(L);30173018 lua_pushinteger(L, pConnection->m_eConnectionType);3019 lua_setfield(L, t, "TradeConnectionType");3020 lua_pushinteger(L, pConnection->m_eDomain);3021 lua_setfield(L, t, "Domain");3022 lua_pushinteger(L, pFromPlayer->getCivilizationType());3023 lua_setfield(L, t, "FromCivilizationType");3024 lua_pushinteger(L , pFromPlayer->GetID());3025 lua_setfield(L, t, "FromID");3026 lua_pushstring(L, pFromCity->getName());3027 lua_setfield(L, t, "FromCityName");3028 CvLuaCity::Push(L, pFromCity);3029 lua_setfield(L, t, "FromCity");3030 lua_pushinteger(L, GET_PLAYER(pConnection->m_eDestOwner).getCivilizationType());3031 lua_setfield(L, t, "ToCivilizationType");3032 lua_pushinteger(L, pToPlayer->GetID());3033 lua_setfield(L, t, "ToID");3034 lua_pushstring(L, pToCity->getName());3035 lua_setfield(L, t, "ToCityName");3036 CvLuaCity::Push(L, pToCity);3037 lua_setfield(L, t, "ToCity");3038 lua_pushinteger(L, pFromPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_GOLD, true));3039 lua_setfield(L, t, "FromGPT");3040 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_GOLD, false));3041 lua_setfield(L, t, "ToGPT");3042 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_FOOD, false));3043 lua_setfield(L, t, "ToFood");3044 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_PRODUCTION, false));3045 lua_setfield(L, t, "ToProduction");3046 lua_pushinteger(L, pFromPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_SCIENCE, true));3047 lua_setfield(L, t, "FromScience");3048 lua_pushinteger(L, pToPlayer->GetTrade()->GetTradeConnectionValueTimes100(*pConnection, YIELD_SCIENCE, false));3049 lua_setfield(L, t, "ToScience");30503051 ReligionTypes eToReligion = NO_RELIGION;3052 int iToPressure = 0;3053 ReligionTypes eFromReligion = NO_RELIGION;3054 int iFromPressure = 0;30553056 pFromCity->GetCityReligions()->WouldExertTradeRoutePressureToward(pToCity, eToReligion, iToPressure);3057 pToCity->GetCityReligions()->WouldExertTradeRoutePressureToward(pFromCity, eFromReligion, iFromPressure);3058 3059 // Internally pressure is now 10 times greater than what is shown to user3060 iToPressure /= GC.getRELIGION_MISSIONARY_PRESSURE_MULTIPLIER();3061 iFromPressure /= GC.getRELIGION_MISSIONARY_PRESSURE_MULTIPLIER();30623063 lua_pushinteger(L, eToReligion);3064 lua_setfield(L, t, "ToReligion");3065 lua_pushinteger(L, iToPressure);3066 lua_setfield(L, t, "ToPressure");3067 lua_pushinteger(L, eFromReligion);3068 lua_setfield(L, t, "FromReligion");3069 lua_pushinteger(L, iFromPressure);3070 lua_setfield(L, t, "FromPressure");30713072 int iToDelta = pFromCity->GetCityCulture()->GetBaseTourism() * pFromCity->GetCityCulture()->GetTourismMultiplier(pToPlayer->GetID(), true, true, false, true, true);3073 int iFromDelta = pToCity->GetCityCulture()->GetBaseTourism() * pToCity->GetCityCulture()->GetTourismMultiplier(pFromPlayer->GetID(), true, true, false, true, true);3074 lua_pushinteger(L, iFromDelta);3075 lua_setfield(L, t, "FromTourism");3076 lua_pushinteger(L, iToDelta);3077 lua_setfield(L, t, "ToTourism");30783079 lua_pushinteger(L, pConnection->m_iTurnRouteComplete - GC.getGame().getGameTurn());3080 lua_setfield(L, t, "TurnsLeft");3081 lua_pushinteger(L, pConnection->m_unitID);3082 lua_setfield(L, t, "UnitID");3083 lua_pushboolean(L, pConnection->m_bTradeUnitRecalled);3084 lua_setfield(L, t, "IsRecalled");3085 lua_pushinteger(L, pConnection->m_iCircuitsCompleted);3086 lua_setfield(L, t, "CircuitsCompleted");3087 lua_pushinteger(L, pConnection->m_iCircuitsToComplete);3088 lua_setfield(L, t, "CircuitsToComplete");3089 lua_pushboolean(L, pConnection->m_bTradeUnitMovingForward);3090 lua_setfield(L, t, "MovingForward");309130923093 return 1;3094 }30953096 return 0;3097}