From 961af31675977c9f1c0ef984a93f5c0eeab7c972 Mon Sep 17 00:00:00 2001 From: azum4roll Date: Thu, 20 Feb 2025 00:54:51 +0800 Subject: [PATCH] 4.19.1 fixes (#11661) * fix CP concert tour not working since 2.7 and an assert that's probably never going to be hit anyway also fixed concert tour mission tooltip - CP has changed the tourism amount to be static, but the Lua function is still using the dynamic number removed redundant tourism reduction against players with the NoOpenTrade trait - it's already included in tourism modifiers * fix great merchant trade tooltip - currently the gold amount is dynamic - this affects VP too --- CvGameCoreDLL_Expansion2/CvCultureClasses.cpp | 38 ++++++------- CvGameCoreDLL_Expansion2/CvUnit.cpp | 8 +-- CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp | 57 +++++-------------- 3 files changed, 33 insertions(+), 70 deletions(-) diff --git a/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp b/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp index 366e5e71d5..4b99776902 100644 --- a/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp @@ -3866,28 +3866,24 @@ void CvPlayerCulture::ChangeInfluenceOn(PlayerTypes ePlayer, int iValue) int CvPlayerCulture::ChangeInfluenceOn(PlayerTypes eOtherPlayer, int iBaseInfluence, bool bApplyModifiers /* = false */, bool bModifyForGameSpeed /* = true */) { - int iInfluence = iBaseInfluence; - - if (bModifyForGameSpeed) { - iInfluence = iInfluence * GC.getGame().getGameSpeedInfo().getCulturePercent() / 100; - } - - if (bApplyModifiers && m_pPlayer->getCapitalCity()) { - int iModifier = m_pPlayer->getCapitalCity()->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false); - if (iModifier != 0) { - iInfluence = iInfluence * (100 + iModifier) / 100; - } - } - - if (eOtherPlayer != m_pPlayer->GetID() && GET_PLAYER(eOtherPlayer).isMajorCiv() && GET_PLAYER(eOtherPlayer).GetPlayerTraits()->IsNoOpenTrade()) - { - if (!GC.getGame().GetGameTrade()->IsPlayerConnectedToPlayer(eOtherPlayer, m_pPlayer->GetID(), true)) - iInfluence /= 2; - } - - if (iInfluence != 0) { + int iInfluence = iBaseInfluence; + + if (bModifyForGameSpeed) + { + iInfluence = iInfluence * GC.getGame().getGameSpeedInfo().getCulturePercent() / 100; + } + + CvCity* pCapital = m_pPlayer->getCapitalCity(); + if (bApplyModifiers && pCapital) + { + int iModifier = pCapital->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false); + iInfluence = iInfluence * (100 + iModifier) / 100; + } + + if (iInfluence != 0) + { ChangeInfluenceOn(eOtherPlayer, iInfluence); - } + } return iInfluence; } diff --git a/CvGameCoreDLL_Expansion2/CvUnit.cpp b/CvGameCoreDLL_Expansion2/CvUnit.cpp index ee9b997860..ae3eeb9b50 100644 --- a/CvGameCoreDLL_Expansion2/CvUnit.cpp +++ b/CvGameCoreDLL_Expansion2/CvUnit.cpp @@ -13103,14 +13103,10 @@ bool CvUnit::canBlastTourism(const CvPlot* pPlot, bool bTestVisible) const // -------------------------------------------------------------------------------- int CvUnit::getBlastTourism() { - CvPlayer* pPlayer = &GET_PLAYER(getOwner()); - if (!pPlayer) + if (getOwner() == NO_PLAYER) return 0; - if (!canBlastTourism(plot())) - { - return 0; - } + CvPlayer* pPlayer = &GET_PLAYER(getOwner()); // Get base multiplier from unit int iMultiplier = getUnitInfo().GetOneShotTourism(); diff --git a/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp b/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp index 40c4af33fb..4f7f99932e 100644 --- a/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp +++ b/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp @@ -2014,11 +2014,7 @@ int CvLuaUnit::lGetHurryProduction(lua_State* L) //int GetTradeGold(); int CvLuaUnit::lGetTradeGold(lua_State* L) { - CvUnit* pkUnit = GetInstance(L); - - const int iResult = pkUnit->getTradeGold(); - lua_pushinteger(L, iResult); - return 1; + return BasicLuaMethod(L, &CvUnit::GetGoldBlastStrength); } //------------------------------------------------------------------------------ //int GetTradeInfluence(CyPlot* pPlot); @@ -2161,49 +2157,24 @@ int CvLuaUnit::lGetGivePoliciesCulture(lua_State* L) //int GetBlastTourism() int CvLuaUnit::lGetBlastTourism(lua_State* L) { - CvUnit* pkUnit = GetInstance(L); - int iResult = 0; - if (pkUnit) - { - iResult = pkUnit->getBlastTourism(); + CvUnit* pUnit = GetInstance(L); + int iResult = pUnit->GetTourismBlastStrength(); -#if defined(MOD_BALANCE_CORE) - if (MOD_BALANCE_CORE_NEW_GP_ATTRIBUTES && pkUnit && pkUnit->getBlastTourism() > 0) + if (MOD_BALANCE_CORE_NEW_GP_ATTRIBUTES && iResult > 0) + { + CvPlot* pPlot = pUnit->plot(); + if (pPlot && pUnit->canBlastTourism(pPlot)) { - CvPlot* pPlot = pkUnit->plot(); - if (pPlot && pkUnit->canBlastTourism(pPlot)) - { - CvPlayer& kUnitOwner = GET_PLAYER(pkUnit->getOwner()); - PlayerTypes eOtherPlayer = pPlot->getOwner(); - + CvCity* pCapital = GET_PLAYER(pUnit->getOwner()).getCapitalCity(); + PlayerTypes eOtherPlayer = pPlot->getOwner(); - // below logic based on CvPlayerCulture::ChangeInfluenceOn() - if (eOtherPlayer != NO_PLAYER) - { - // gamespeed modifier - iResult = iResult * GC.getGame().getGameSpeedInfo().getCulturePercent() / 100; - - // player to player modifier (eg religion, open borders, ideology) - if (kUnitOwner.getCapitalCity()) - { - int iModifier = kUnitOwner.getCapitalCity()->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false); - if (iModifier != 0) - { - iResult = iResult * (100 + iModifier) / 100; - } - } - - // IsNoOpenTrade trait modifier (half tourism if trait owner does not send a trade route to the unit owner) - CvPlayer& kOtherPlayer = GET_PLAYER(eOtherPlayer); - if (eOtherPlayer != pkUnit->getOwner() && kOtherPlayer.isMajorCiv() && kOtherPlayer.GetPlayerTraits()->IsNoOpenTrade()) - { - if (!GC.getGame().GetGameTrade()->IsPlayerConnectedToPlayer(eOtherPlayer, pkUnit->getOwner(), true)) - iResult /= 2; - } - } + // Player to player modifier + if (pCapital) + { + int iModifier = pCapital->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false); + iResult = iResult * (100 + iModifier) / 100; } } -#endif } lua_pushinteger(L, iResult);