Source beta 3.124 vs beta 3.128

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,728
Location
Near Portsmouth, UK
Game beta has just updated from 3.124 to 3.128 and the SDK has also updated

Differences between 124 and 128 code base in the attached images
 
Sorry for may posting it in the wrong thread.
But a:=)can we change the ammount of reasearch per trade route and
b:=) how ?,
i know teach us newcomers a lession:deadhorse:
 
Sometimes I just want to strangle someone

Code:
if ((isEmbarked() && !pkBuildInfo->IsCanBeEmbarked())  && (strcmp("UNIT_JAPANESE_SAMURAI", getUnitInfo().GetType()) != 0))
 
Sometimes I just want to strangle someone

Code:
if ((isEmbarked() && !pkBuildInfo->IsCanBeEmbarked())  && (strcmp("UNIT_JAPANESE_SAMURAI", getUnitInfo().GetType()) != 0))

Why code something generically if you can do it the hacky and hardcode it for cheaper! Sometimes I wonder what the engine must look like on the inside. :rolleyes:
 
And sometimes you find one to make you laugh :D

CvDiplomacyAI:: DoDugUpMyYardStatement(...)
 
a) Can we change the amount of reasearch per trade route and
b) How?

I know teach us newcomers a lesson

We know the trade route science is displayed when choosing where to send a trade unit ...
So search C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V\ for files matching "trade*.lua"
ChooseInternationalTradeRoutePopup.lua looks like a good place to start
Code:
local g_ItemManagers = {
  InstanceManager:new( "ItemInstance", "Button", Controls.YourCitiesStack ),
  InstanceManager:new( "ItemInstance", "Button", Controls.MajorCivsStack ),
  InstanceManager:new( "ItemInstance", "Button", Controls.CityStatesStack ),
}
means I need to find where "g_ItemManagers[2]" is used - as that's the IM that hands out major city list items.
It's not, but "g_ItemManagers[tradeRoute.Category]" is the only usage of g_ItemManagers, so it's got to be in that loop
"itemInstance.Bonuses:SetText(tradeRoute.Bonuses);" looks promising, so where does tradeRoute.Bonuses come from? ... g_Model
Which itself is populated from "table.insert(g_Model, tradeRoute);", where bonuses comes from "tradeRoute.Bonuses = strOutput;"
strOutput is built from myBonuses and theirBonuses
myBonuses is built from "u.Mine / 100" and u.Mine comes from "for j,u in ipairs(v.Yields) do"
v comes from "for i,v in ipairs(potentialTradeSpots) do" and potentialTradeSpots from pPlayer:GetPotentialInternationalTradeRouteDestinations(pUnit)
So we're looking for CvLuaPlayer::GetPotentialInternationalTradeRouteDestinations()
Which, unlike most Lua API methods doesn't just call a CvPlayer method, but contains a lot of code itself
Code:
int CvLuaPlayer::lGetPotentialInternationalTradeRouteDestinations(lua_State* L) {
SNIP!
  CvPlayerTrade* pPlayerTrade = pkPlayer->GetTrade();
SNIP!
  lua_createtable(L, 0, 0);
  for (uint uiYield = 0; uiYield < NUM_YIELD_TYPES; uiYield++) {
    lua_createtable(L, 0, 0);
    const int t2 = lua_gettop(L);
    lua_pushinteger(L, pPlayerTrade->GetTradeConnectionValueTimes100(kTradeConnection, (YieldTypes)uiYield, true));
    lua_setfield(L, t2, "Mine");
    lua_pushinteger(L, pOtherPlayerTrade->GetTradeConnectionValueTimes100(kTradeConnection, (YieldTypes)uiYield, false));
    lua_setfield(L, t2, "Theirs");
    lua_rawseti(L, -2, iInnerIndex++);
  }
SNIP!
}
So we're interested in CvPlayerTrade::GetTradeConnectionValueTimes100(...)
Code:
int CvPlayerTrade::GetTradeConnectionValueTimes100 (const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer) {
SNIP
  case YIELD_SCIENCE:
    int iBaseValue = GetTradeConnectionBaseValueTimes100(kTradeConnection, eYield, bAsOriginPlayer);
    iValue = iBaseValue;
    int iModifier = 100;
  
    iValue *= iModifier;
    iValue /= 100;
    break;
  }
SNIP
}
So the base science comes from CvPlayerTrade::GetTradeConnectionBaseValueTimes100()
Code:
int CvPlayerTrade::GetTradeConnectionBaseValueTimes100(const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer) {
  else if (eYield == YIELD_SCIENCE) {
    int iTechDifference = GC.getGame().GetGameTrade()->GetTechDifference(kTradeConnection.m_eOriginOwner, kTradeConnection.m_eDestOwner);
    int iAdjustedTechDifference = 0;
    if (iTechDifference > 0) {
     [COLOR="Red"][B] int iCeilTechDifference = (int)ceil(iTechDifference / 2.0f);[/B][/COLOR]
      iAdjustedTechDifference = max(iCeilTechDifference, 1);
    }

    // Cultural influence bump
    int iInfluenceBoost = GET_PLAYER(kTradeConnection.m_eOriginOwner).GetCulture()->GetInfluenceTradeRouteScienceBonus(kTradeConnection.m_eDestOwner);
    iAdjustedTechDifference += iInfluenceBoost;

    return iAdjustedTechDifference * 100;
  }
SNIP
}
So science from trade routes is hard-coded as half of the difference in techs rounded up

Simples!
 
We know the trade route science is displayed when choosing where to send a trade unit ...
So search C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V\ for files matching "trade*.lua"
ChooseInternationalTradeRoutePopup.lua looks like a good place to start
Code:
local g_ItemManagers = {
  InstanceManager:new( "ItemInstance", "Button", Controls.YourCitiesStack ),
  InstanceManager:new( "ItemInstance", "Button", Controls.MajorCivsStack ),
  InstanceManager:new( "ItemInstance", "Button", Controls.CityStatesStack ),
}
means I need to find where "g_ItemManagers[2]" is used - as that's the IM that hands out major city list items.
It's not, but "g_ItemManagers[tradeRoute.Category]" is the only usage of g_ItemManagers, so it's got to be in that loop
"itemInstance.Bonuses:SetText(tradeRoute.Bonuses);" looks promising, so where does tradeRoute.Bonuses come from? ... g_Model
Which itself is populated from "table.insert(g_Model, tradeRoute);", where bonuses comes from "tradeRoute.Bonuses = strOutput;"
strOutput is built from myBonuses and theirBonuses
myBonuses is built from "u.Mine / 100" and u.Mine comes from "for j,u in ipairs(v.Yields) do"
v comes from "for i,v in ipairs(potentialTradeSpots) do" and potentialTradeSpots from pPlayer:GetPotentialInternationalTradeRouteDestinations(pUnit)
So we're looking for CvLuaPlayer::GetPotentialInternationalTradeRouteDestinations()
Which, unlike most Lua API methods doesn't just call a CvPlayer method, but contains a lot of code itself
Code:
int CvLuaPlayer::lGetPotentialInternationalTradeRouteDestinations(lua_State* L) {
SNIP!
  CvPlayerTrade* pPlayerTrade = pkPlayer->GetTrade();
SNIP!
  lua_createtable(L, 0, 0);
  for (uint uiYield = 0; uiYield < NUM_YIELD_TYPES; uiYield++) {
    lua_createtable(L, 0, 0);
    const int t2 = lua_gettop(L);
    lua_pushinteger(L, pPlayerTrade->GetTradeConnectionValueTimes100(kTradeConnection, (YieldTypes)uiYield, true));
    lua_setfield(L, t2, "Mine");
    lua_pushinteger(L, pOtherPlayerTrade->GetTradeConnectionValueTimes100(kTradeConnection, (YieldTypes)uiYield, false));
    lua_setfield(L, t2, "Theirs");
    lua_rawseti(L, -2, iInnerIndex++);
  }
SNIP!
}
So we're interested in CvPlayerTrade::GetTradeConnectionValueTimes100(...)
Code:
int CvPlayerTrade::GetTradeConnectionValueTimes100 (const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer) {
SNIP
  case YIELD_SCIENCE:
    int iBaseValue = GetTradeConnectionBaseValueTimes100(kTradeConnection, eYield, bAsOriginPlayer);
    iValue = iBaseValue;
    int iModifier = 100;
  
    iValue *= iModifier;
    iValue /= 100;
    break;
  }
SNIP
}
So the base science comes from CvPlayerTrade::GetTradeConnectionBaseValueTimes100()
Code:
int CvPlayerTrade::GetTradeConnectionBaseValueTimes100(const TradeConnection& kTradeConnection, YieldTypes eYield, bool bAsOriginPlayer) {
  else if (eYield == YIELD_SCIENCE) {
    int iTechDifference = GC.getGame().GetGameTrade()->GetTechDifference(kTradeConnection.m_eOriginOwner, kTradeConnection.m_eDestOwner);
    int iAdjustedTechDifference = 0;
    if (iTechDifference > 0) {
     [COLOR="Red"][B] int iCeilTechDifference = (int)ceil(iTechDifference / 2.0f);[/B][/COLOR]
      iAdjustedTechDifference = max(iCeilTechDifference, 1);
    }

    // Cultural influence bump
    int iInfluenceBoost = GET_PLAYER(kTradeConnection.m_eOriginOwner).GetCulture()->GetInfluenceTradeRouteScienceBonus(kTradeConnection.m_eDestOwner);
    iAdjustedTechDifference += iInfluenceBoost;

    return iAdjustedTechDifference * 100;
  }
SNIP
}
So science from trade routes is hard-coded as half of the difference in techs rounded up

Simples!

:confused:
But very well explained, maybe i should read i t again lol.
Thanks for the feedback, well iam a lua noob, but this looks all so weird coded.
That make it even harder for us guys how have only some modding knowledge, to understand.
I followed much of your tutorials and your mods for understanding the ways CiV worked.
So i just wanna say, that this game would be big failure. If we just hasnt so nice modders like you, that spend so much time in introducing and modding for the community.
 
a) can we change the amount of reasearch per trade route and
b) how

The short answer is "Not via XML or easily via Lua, as it's been hard coded in the DLL"
 
And sometimes you find one to make you laugh :D

CvDiplomacyAI:: DoDugUpMyYardStatement(...)

And then you see things that make you wonder what is happening in the code we can't see... :rolleyes:
Code:
m_strNameIAmNotSupposedToBeUsedAnyMoreBecauseThisShouldNotBeCheckedAndWeNeedToPreserveSaveGameCompatibility
 
:nono:

There are plenty of things to make us laugh and cry when it comes to the source code, but we must be grateful for what Firaxis does for us modders. :yup:

Not many companies are willing to release source code warts and all. We code for fun, most of them code for a pay check. Obviously the 80-20 rule has been used quite liberally :satan:
 
:nono:

There are plenty of things to make us laugh and cry when it comes to the source code, but we must be grateful for what Firaxis does for us modders. :yup:

Not many companies are willing to release source code warts and all. We code for fun, most of them code for a pay check. Obviously the 80-20 rule has been used quite liberally :satan:

I am grateful, an AAA game dev releasing a significant portion of their game's source is unheard of outside these forums. I'm just betting that that was all done by a summer intern who was too lazy/inexperienced to figure out the 'proper' solution to the problem.
 
Sometimes I just want to strangle someone

Code:
if ((isEmbarked() && !pkBuildInfo->IsCanBeEmbarked())  && (strcmp("UNIT_JAPANESE_SAMURAI", getUnitInfo().GetType()) != 0))

So does this explain why my little mod that tries to make workers replace workboats not work?
Have they made the new Samurai fishing ability hardcoded?
 
Well that is just ridiculous. Who makes these sort of stupid decisions?
Someone at Firaxis needs to actually be involved with the modding communities and give input into those sort of things.
Why hardcode this? Are they smoking crack or something?
I am not happy.:mad::cry:
 
Who makes these sort of stupid decisions?

Same design guru who decided that all three religious units should be hard-coded to the standard unit types and not the unit class types

Code:
/// Time to spawn a Great Prophet?
bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) {
	UnitTypes eUnit = (UnitTypes)GC.getInfoTypeForString("[COLOR="Red"][B]UNIT_PROPHET[/B][/COLOR]", true);

(many places in the code)
 
The SDK updated for me yesterday with a new pitboss server but no new source. Did Firaxis not release the source for the Fall Patch final release? :(
 
Were you subscribed to the beta sdk, 'cos' mine's not updated ... off to force an update ...
 
It has updated for me and I did not subscribe to the beta. I don't know yet if the updated code matches the current version of the game, haven't tried using it.

Maybe there were no DLL changes between the last version of the beta patch and the final patch?
 
It has updated for me and I did not subscribe to the beta. I don't know yet if the updated code matches the current version of the game, haven't tried using it.

Maybe there were no DLL changes between the last version of the beta patch and the final patch?

The DLL in the ciV directory was last modified yesterday (10/15/2013), while the source was last modified with the 2nd beta update (10/4/2013). I double checked and am not subscribed to any betas for it anymore.
 
Back
Top Bottom