Announcement

Collapse
No announcement yet.

trade route calculation?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • trade route calculation?

    Hello, I've seen some Trade Route formulas posted under the CIV2 forum, I'm just wondering if anyone knows the trade route formula for CTP2. Or maybe a hint on which cpp file I should search under

  • #2
    Cursory investigation suggests that it's pretty simple. From TradeRouteData.cpp:

    Code:
    sint32 TradeRouteData::GetValue() const
    {
    	if(m_sourceRouteType != ROUTE_TYPE_RESOURCE)
    		return 0;
    
    	
    	double baseValue = g_theWorld->GetGoodValue(m_sourceResource);
    	double distance = double(m_destinationCity->GetCityData()->GetDistanceToGood(m_sourceResource));
    	return sint32(baseValue * distance);
    }
    That GetDistanceToGood is in terms of least movement cost to the good (I'm not sure if this gets recalculated as more roads, etc. are built).

    I guess this may be processed further (taking into account city populations, or something like that). I suggest you investigate - I guess you'd either want to look for calls to the above function or else work the other way from wherever the values get used (e.g. the trade screen).

    Comment


    • #3
      Wow, what a fast reply!!! Thank you very much for your help. I will look into that file =)

      Comment

      Working...
      X