1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Fractional trade counting

Discussion in 'Civ4 - Unofficial Patches' started by Mylon, May 8, 2009.

  1. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    I hate it when I have four trade routes that are at +75% each and I still only get 4 commerce, instead of the 7 commerce this should be! All of those bonuses mean nothing until it it hits the magic 2.0 size or the city gets big enough to start having 1.1 base value trades and such.

    Anyhow, I've developed the code to make these factional trades count and make this information show up in the interface. Is this something you would like to see added to the UP?
     
  2. r_rolo1

    r_rolo1 King of myself

    Joined:
    May 19, 2006
    Messages:
    13,818
    Location:
    Lisbon, Portugal
    I pretty much second this.
     
  3. Roland Johansen

    Roland Johansen Chieftain

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    Sounds logical because everything commerce related is counted in 2 decimals. I hate rounding issues as when you want to play optimal, you'll have to take them into account meaning more micromanagement. And it also means that some buildings which add a fractional bonus will be far less effective as some starting players would expect them to be.
     
  4. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    So I noticed... When you add up the trades, it chops off the decimal there too. So if the city generates 3.75 commerce in trade, and if that trade gets cut into 80%, then multiplied by 1.25 (or whatever) to determine beakers, there's a lot of rounding that takes place! I could accept loosing up to 0.05 to rounding, but it's more than that. So I'm wondering if I should expand the scope of my fix. It'll go a bit beyond just trade, but also making all commerce fractional.
     
  5. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    I love this idea!
     
  6. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    I'll post the code snippets later this evening, but as far as I can tell no one seems to be maintaining the UP code anymore.
     
  7. Roland Johansen

    Roland Johansen Chieftain

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    There are various mods that integrate the unofficial patch in their mod. They might use your code if they feel the same way about it as we do. The only issue is whether they notice this thread.
     
  8. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Just a little heads up that this won't be a trivial change code-wise. Commerce is already handled Times100 in the code, but yields are not. If the :commerce: from trade routes were handled separately, that wouldn't be such a problem. However, it's added in to the :commerce: from other sources.

    I'm not trying to discourage you. I think it's a good idea as well.

    There is one more consideration, however. I believe that this will break saved game compatibility. I haven't looked at the code that saves the game, but I do know that CvCity stores an array of current yields, m_aiBaseYieldRate. If you change these values to be Times100 and they are saved to disk, you won't be able to share that game with other players.

    You could create a secondary Times100 array and use that only in-memory. When the CvCity is loaded from disk, you'll need to recalculate the values to put into the array.
     
  9. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    The code I have doesn't break saves at all. The game stores the value of trades as a separate yield, which is also added to total yield when that gets calculated. I changed the function that calculates that value and it outputs a whole number (not the "decimal" of times100).

    The only downside is the final decimal portion of trade value still gets chopped off. So in the event of running that civic, there's a few cases where the rounded-off trade would have been helpful. Example: 0.75 commerce left over from trade which gets chopped off * 1.2 for civic * 0.8 for research * 2 for various +research buildings = 1.4. Not a whole lot of beakers wasted, but if there's 20 cities in the map...

    Edit: All of the code is here, though buried in a Fall Further modmodmod(mod): http://forums.civfanatics.com/downloads.php?do=file&id=12396

    Should be bracketed by "Fraction Trade Counting"
    CvCity.cpp+h contains the important changes, but there are changes in other areas for the interface side of things.
     

Share This Page