1. Firaxis celebrates the "Asian American and Pacific Islander Heritage Month", and offers a give-away of a Civ6 anthology copy (5 in total)! For all the details, please check the thread here. .
    Dismiss Notice
  2. Old World has finally been released on GOG and Steam, besides also being available in the Epic store . Come to our Old World forum and discuss with us!
    Dismiss Notice

AND2 and SVN Bug Reports - A New Dawn 2 ONLY

Discussion in 'Rise of Mankind: A New Dawn' started by 45°38'N-13°47'E, Aug 31, 2012.

  1. Zepolak

    Zepolak Chieftain

    Joined:
    Apr 1, 2020
    Messages:
    10
    If you have big cities activated, that would be possibly considered part of the (potential) city radius possibly ?
     
  2. Samson

    Samson Deity

    Joined:
    Oct 24, 2003
    Messages:
    12,628
    Location:
    Cambridge
    It is one outside of that radius (3 diagonally).
     
  3. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    Zepolak, 45°38'N-13°47'E, I can confirm Imperium bug.

    And I've already proposed how it can be connected with espionage. When other civ changes to Imperium, you starting to get some negative income ( if this civ has stronger military than yours ). There is somewhere place in the code that sees this negative income and move science slider to compensate it. And probably there is another place, that set espionage slider to as ( 100 - science slider - commerce slider - culture slider ), so it changes espionage slider automatically. And probably there is a third place in code that calls every time espionage slider changes not by human, that set this "espionage weights".
    This is just hypothesis - I just looked through the code not carefully, may be it is even more complicated.
    When in current game I'll reach the stage of other civs imperium - I can send saves before and after, it is totally reproducible.

    Also I can confirm Leonardo Workshop bug - after getting Leonardo Workshop my science increased in one game from 2k to 6k, some weird science amounts out of air appeared. I had Leonardo only once ( usually AI get it first ) so I can't say is it reproducible or intermittent.

    And another bug with strange commerce points. This game I've placed in excel every single move all variables that games uses to calculate commerce and science amounts and rechecked the calculations. My goal was to find the first move when this bug will happen to find the root cause. And finally I get it - at move 204. I believe the reason is because at move 203 I've built CaravanSarai, but this is just the hypothesys.

    This is the calculations.

    For both moves 203 and 204 everything is identical ( even the same - 35 number of foreign connections ) , so science should be the same.
    But I am getting 112.75 at move 203 and 93.75 at move 204.

    Let's check calculations. I have:

    34 coins from cells
    27 coins from buildings ( 8 - palace, 5 - great lighthouse, 2 - wheelwright, 2 - candlemaker, 1 - apiary, and 9 - caravansarai ( 1 from base , and i have 35 foreign connections that gives 35/4 = 8 more ) )
    +20% from Senate
    This gives 61 * 1.20 = 73.20 coins.
    Also bakers : 10 bakers from academy, 3 from School of Scribes, 1 from Myth of the Sea + 3 from Scientist = 17 bakers
    Academy gives 25% on science production, slider at 100%.

    That gives total bakers: ( (34 + 27) * 1.2 + 17 ) * 1.25 = 112.75.

    Looking how game calculated it at move 203:



    A little bit strange numbers in the middle, but final result is correct.

    The same calculations at move 204:



    Now final result incorrect too.

    Numbers at Finance Advisor screen:

    upload_2020-4-3_19-49-40.png


    And at move 204:

    upload_2020-4-3_19-51-42.png


    So, 16 commerce lost somehow. Just a hypothesis: it is this "foreign trade" from Caravan Sarai. Instead of +8 it somehow changed to -8, and that gave this lost bakers. At least I can say that before building Caravan Sarai all calculations were correct.
    Attaching two saves - before and after if somebody wants to look.
     

    Attached Files:

    Last edited: Apr 3, 2020
  4. Vokarya

    Vokarya Deity

    Joined:
    Mar 25, 2011
    Messages:
    6,237
    I'll have to fix that. This is Python code that I can edit. It looks for every Peak that you own in a rectangle around the building city and chooses one of them at random. It doesn't check the distance to the city.
     
    Samson likes this.
  5. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    Okay, another bug is ( and this time I know exact line with mistake! ) that in CvCity.cpp somebody forgot to add clearing of variable m_iExtraCapitalCommerce in function
    void CvCity::clearModifierTotals()

    This causes that this variable is not resetting during each recalculation and this means it is growing, and growing and growing....
    In my save each recalculation gives me extra 7 commerce from "extra capital connection":

    upload_2020-4-4_3-47-3.png

    Probably problem is not only with this variable, we should compare the list with all variables from function Reset - or merge this two functionality into one to avoid code duplication.


    Another issue as you can see at this screenshot is in reporting: in function

    void CvGameTextMgr::setYieldHelp(CvWStringBuffer &szBuffer, CvCity& city, YieldTypes eYieldType)

    When it is calculating iBaseProduction, it is first substract all modifiers:

    Code:
        iBaseProduction -= iExtraCapitalCommerce;
        iBaseProduction -= iExtraForeignCapitalCommerce;
        iBaseProduction -= iDomesticConnectednessCommerce;
        iBaseProduction -= iForeignConnectednessCommerce;
        iBaseProduction += iSeizedConnectednessCommerceTimes100 / 100;
    And only then do the logic:

    Code:
        //Undo civic modifiers, they are already included in iDomesticConnectednessCommerce and iForeignConnectednessCommerce
    
        //Undo trait modifiers
    
    This should be in opposite order.
    This bug makes iBaseProduction ( "Base commerce" at my screenshot ) negative, that looks funny)


    The question is: if I decide to create a patch for it - is there anywhere instruction how I can rebuild this DLL and test it before creating pull request? I am not a C++ developer.
    Is it https://forums.civfanatics.com/threads/a-simple-guide-to-compiling-the-dll.405444/
    still actual?
     
    Last edited: Apr 3, 2020
    45°38'N-13°47'E likes this.
  6. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    I was able to fix bug with commerce calculations due to wrong connectedness calculations
    and several other issues. How I can create PR to master?
     
    45°38'N-13°47'E likes this.
  7. rtt4a

    rtt4a Prince

    Joined:
    Mar 3, 2009
    Messages:
    554
    Great job:goodjob: I have known long time that recalc is broken but had no idea whats the problem.
     
  8. 45°38'N-13°47'E

    45°38'N-13°47'E Deity

    Joined:
    Jun 7, 2008
    Messages:
    5,974
    Location:
    Just wonder...
    Looks great, can you post your changes here so I can have a look in the next days? Then if it's ok with you, I can upload your changes and add you to the credits page.
     
  9. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    So...
    Bug number 1: When we are doing recalculation, we are doing connectedness recalculation ( pLoopCity->doConnectednessCalculations(); ) during cycle that process buildings. But the thing is, that we don't have technologies at the moment. And this means that when we calculating number of connected foreign cities, we don't take into account, for example, those of them that you can reach only by technologies ( for example, that you can reach with coast by Ship Building iirc ).
    And in interface you see the correct number of connected foreign cities because recalculation add technologies later.

    So, to fix this we need to do connectedness recalculation after technologies processing, for example, at the very end. I've solved it by adding this in update_routes procedure:

    upload_2020-4-7_17-51-26.png

    And I believe from performance point of view we can remove this calculations from everywhere else. This should be calculated at the very end, once. And currently we are doing it for every building that has foreign connections bonus. But I was not brave enough to do this.


    Bug number 2:

    We are not resetting some variables in ClearModifiersTotals. This causes that each recalculation this variable is growing. But because of calculations what extra you get in variable m_extraCapitalCommerce, this amount with be distructed from iBaseProduction at the same time.
    It is easy to see: just run CTRL+SHIFT+T several times and look every time in city that has some extra commerce from capital connection (for example from Wheelwright ). You'll see it is increasing every time. And base commerce will at the same time decrease on the same exact amount, so it can even become negative:

    (my old screenshot )
    https://forums.civfanatics.com/threads/and2-and-svn-bug-reports-a-new-dawn-2-only.474185/page-352

    The fix I did:

    upload_2020-4-7_17-58-27.png

    Looks like only this variables we are not resetting now ( checked in debug).
    This also fix this thing when you see negative base commerce at your city screen - this can happen if you got from this extra capital too much)

    Bug number 3.
    This is just reporting from main screen. Probably everybody saw that numbers when you get hint for commerce description are not inline with each other are not match? Probably you even saw negative amounts in base yield. Fix in two places
    in function
    void CvGameTextMgr::setYieldHelp(CvWStringBuffer &szBuffer, CvCity& city, YieldTypes eYieldType) :

    First: we don't need to add commerce from buildings, as it already accounted in iBaseProduction for commerce ( so I've just added if (eYieldType != YIELD_COMMERCE) condition for one line ):

    :

    upload_2020-4-7_18-3-25.png

    Second - somebody just made copy-paste mistype ( extraCapitalCommerce two times instead of iExtraForeignCommerce at the second time ):

    upload_2020-4-7_18-5-0.png

    Now numbers are correct and match each other:

    upload_2020-4-7_18-7-36.png
     
    Last edited: Apr 7, 2020
    45°38'N-13°47'E and <Nexus> like this.
  10. os79

    os79 Deity

    Joined:
    Mar 14, 2009
    Messages:
    3,095
    Location:
    Eastern USA Coast
    Hello, I'm wondering...
    Repeatedly, I had seen my set percentages of commerce's compnents being changed without my tweaking them, often to 100% research. This irritates most of time but easy to tweak back. However, sometimes when I'm running low in gold, that change can send me into bankruptcy. So what is causing this mess-up of the commerce's components' tweakings? Spies? Or what? Or actually a bug in itself?
     
  11. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    just qq: when this happens:
    1. is your civic "imperium"?
    2. do you see that during this move some AI converted to "imperium" or from it?
     
  12. 45°38'N-13°47'E

    45°38'N-13°47'E Deity

    Joined:
    Jun 7, 2008
    Messages:
    5,974
    Location:
    Just wonder...
    Thanks valergrad, I'm running some test with your code; just out of curiosity, have you added some other code in CvGameTextMgr.cpp? I noticed that line numbers don't match in my version, there's a difference of 14 lines so I was wondering if you changed anything else. Hopefully I can find some time to dig into that Imperium bug too.
    If everything goes well, I'll release the new dll and add you to the credit page. Thanks again!
     
  13. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    In my version I've added some debug code here and there, hence line numbers are not in-line...

    I am playing current game ( with very slow speed - 1% per day) , and if I'll face with imperium bug earlier I also will try to look...
     
  14. os79

    os79 Deity

    Joined:
    Mar 14, 2009
    Messages:
    3,095
    Location:
    Eastern USA Coast
    No, Imperium is not set on my civics listing. No idea about the AI's civic choices... Do you suspect that civic?
     
  15. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    No idea about the AI's civic choices... - you can check this in foreign advisor.
    F4 - tab "Info".
    Also, I believe that when somebody converts you get the message.
     
  16. 45°38'N-13°47'E

    45°38'N-13°47'E Deity

    Joined:
    Jun 7, 2008
    Messages:
    5,974
    Location:
    Just wonder...
    I'm checking the code and Imperium might be responsible, although I am not sure how and I haven't reproduced the bug yet. As for your fixes, they don't seem to cause any troubles so I will upload them soon. Anyway it looks like there are other problems inside thr city screen's calculations for commerce. For example after recalc +10% from power vanishes and connectedness is not taken into account. I'm looking into it.
     
  17. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    Yes, definitely. Yesterday I've faced one at move 257: again different values before-after recalculation.
    I'll try today to debug and find an issue.
    But in my case probably the thing is just : when number of foreign connected cities changes, recalculation doesn't happen.

    To be honest this recalculation logic extremely complicated. So I have to ask: why we need to do this recalculation at all? I understand that we need it when DLL or assets changed, but why we need during just normal game?
     
    Last edited: Apr 10, 2020
  18. 45°38'N-13°47'E

    45°38'N-13°47'E Deity

    Joined:
    Jun 7, 2008
    Messages:
    5,974
    Location:
    Just wonder...
    Normally, recalc is only performed when something has changed in the dll when a new revision is released; this is because there might be new options, tags or mechanics which might change commerce/science/culture/espionage/gold. Or, it can be performed manually with Ctrl+Shift+T, but it's usually not necessary. There's only another occasion when recalc is perfomed silently and automatically and it's used as a workaround to solve a problem with some resources being improperly multiplied when discovering Ship Building and Navigation. I was wondering, why were you performing some recalc, for example in turn 257 as described in your post?
    Anyway, I'm delaying the release of your proposed bugfixes because there's still something strange now that I look into it. For some reasons either in rev1087 or rev1087+your changes some connectedness modifiers caused by civics are not being taken into account at all: foreign commerce added to base commerce is working and modifier is working too, except when you use some more advanced civics which add or subtract a percentage of commerce due to domestic/foreign connectedness, for example Post-Scarcity. That percentage is never taken into account. I think I need some time to understand what's going on. Also, I was wondering about your negative base commerce, never seen anything like that.
     
  19. os79

    os79 Deity

    Joined:
    Mar 14, 2009
    Messages:
    3,095
    Location:
    Eastern USA Coast
    Thanks, Valgerad, for the info on getting other civs' civics details. F4 is useful. I don't really pay attention to messages because they are overwhelming.
    I'll be happy when the bug I described earlier stop happening. I can accept changes in the component values as differing situations arise. But I dislike when my set percentages are changed behind my back, so to speak.
    Connectedness replaced trade routes in RAND modpack. Maybe now is good time to clarify and clean up the code surrounding the concept of connectedness, indeed.
    For a game relseased in 2005(?), this mod has an awesome staying power!

    PS: I checked the foreign adviser and saw that every single of other civs (nine of them) has Imperium civic. I understand the leaders are modeled on people with high opinion of themselves but I would think that the code will teach the AI civs to cool off with Imperium when it's unhealthy for them?
     
    Last edited: Apr 10, 2020
  20. valergrad

    valergrad Warlord

    Joined:
    May 26, 2013
    Messages:
    172
    Take any save where some city has some extra capital commerce ( for example 1 is from WheelWright, 5 from Great Lighthouse etc., so with Great Lighthouse it will be easily visible )
    Look at base commerce in City Screen ( when you click on commerce to describe it ).
    Run CTRL+SHIFT+T - look how baseCommerce decreased.
    If you run it several times you will see it negative.
    ( this is of course should be done on version before my fixes ).


    I did recalc because without recalc I got incorrect value for commerce. After recalc it became correct.
     

Share This Page