1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[mod] Religion and Revolution Extended (modmod of Religion and Revolution)

Discussion in 'Civ4Col - Mods and Files' started by Nightinggale, Jun 11, 2013.

  1. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    Basically you have the choice between setting up complex traderoutes or use feeder service. I haven't tested them together, but I assume if you use feeder on a yield you manually set a traderoute to import, then that traderoute will forget it once feeder deactivates it and will not re-enable it once it starts importing again.

    Traderoutes focuses on a chain of colonies to visit in a specific order. Feeder service is made from the point of view from a colony which will not care where the yield comes from.

    The same setup with feeder service.
    A and B exports at 50. B sets feeder and C imports.
    Automated wagon trains will then take the yield from A directly to B or C. If B reaches 50, then excess is exported to C. B will then not import until it only has 37 left.

    Maybe C should have export too (but not feeder). This will allow C to transfer to B in case A decides to send everything to C. Remember that B will not accept anything from C unless it actually needs it. C will have no problem importing and exporting at the same time without feeder as long as it's the only one importing without feeder.

    The trick here is that you can have multiple colonies set just like B. Since they both import and export it will create loops, but the feeder will prevent them from importing and exporting at the same time, which breaks such loops. This means building a new colony allows you to set up import/export and it fits into the transport system just fine without looking at the other colonies or modify possibly fairly complex traderoutes.

    Manually setting up traderoutes will likely be the most efficient usage of wagon trains. However it does use a lot of micromanagement and which system to use depends on what you want from the game. I added feeder and any player can use it if they like. If not, they can still do just like in RaR as I didn't modify that system at all. Doing both in the same colony isn't recommended and will likely cause issues.
     
  2. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,522
    Gender:
    Male
    Location:
    Stuttgart, Germany
    What do you mean with "issues" ?

    Does that mean, this feature will break "Transport Routes" the player has created ?
    Or are we talking about bugs ?
     
  3. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    Looks like a very promising mod, I"m glad you're working on it! :king:

    I'm really looking forward to have some way to limit the amount of micromanagement of large amounts of local transport minutiae, but still a little confused about how this is supposed to work. Is the feeder system simply the third box that sets imports to off when over 75% of the threshold? I get that it's meant to avoid a problem with repeating loops in the previous system, but I'm not exactly clear how it's meant to be used. Anyway, I should just go back over the explanations and try it out for a bit.

    I got one assert message while playing it; this was after sailing onto a Sail to Europe plot then getting the "favorable wind" event. (However I'm guessing its likely a previous assert unrelated to this mod itself.)

     
  4. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    To be honest the combo isn't well tested. What I think could happen would be that the route from A to B could be deleted from the traderoute and not reactivated once B imports again. To be honest I don't see the usefulness of the mix of systems. If you set up a traderoute you normally wouldn't have to consider overloading your colony or you did a poor job setting up the traderoute. Do people think it would make sense to mix them?
    Also can somebody actually test if it causes problems mixing?
     
  5. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    A savegame would help a lot here. I know which line which failed, but not specifically what went wrong. Running the game through a debugger would tell a whole lot more.

    Also it may take a while before I can test it. It looks like my windows problems turned into a HD hardware failure. That's the second HD hardware failure in a row I had without any data losses. I think my backup plan is working as intended.
     
  6. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    I've got the following two asserts:

    Spoiler :



    The savegames are in the file ("before" - autosave and "after" - manual save immediately after the assert messages)

    Please just give me notive after having dl'ed the file so that I can delete it.
    And I know about your trouble with your computer, so don't be in a hurry. View attachment 353322
     

    Attached Files:

  7. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    I changed the install instructions for installing and updating without git based on feedback from Commander Bello. Using git would still be "the right way" of doing it. Hopefully some day in a not too distant future I can make a bat file to handle it for people without installing git.
     
  8. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    I'm currently getting this assert over and over and over:

    Assert Failed

    File: CvCity.cpp
    Line: 4685
    Expression: iValue >= 0 || eYield == YIELD_FOOD
    Message:
     
  9. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    Windows is working again :woohoo:
    It turned out to be the SATA control chip which fried. The HD itself is fine and works as intended when moved to a different controller. Luckily I didn't reformat the HD as I kept that as a last resort after checking everything else.

    Also I found Git-portable, which is a version of git which works without being installed. I'm not sure it can handle graphics well, but the CLI mode looks promissing. While it doesn't handle all git commands, it should handle everything I need to make a bat file installer/updater. Something useful may appear in the near future.
    I still recommend installing a proper GUI based Git client if you intend to modify anything.
     
  10. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    I downloaded the savegame and you can delete it from the forum.

    I have a problem getting the assert though. The problem is that I can't get it to assert the way you did. Instead I get an assert about canMoveInto(pPlot, true) :confused:
    I encountered this assert before, but this is the first time I got it with a debugger running and I get it each time. Now I have a chance of actually doing something about that bug.

    Could you give a precise description of what to do to get your assert, possibly with a savegame where I just have to hit end turn.

    Also why did you call the mod "364 CBM_RaR_1.5"? It would have been easier for me to load it if it were called Religion_and_Revolution_Extended.

    Another thing. I have no use for an "after assert" savegame. I want to catch the bug in the act.
     
  11. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,522
    Gender:
    Male
    Location:
    Stuttgart, Germany
    @Nightinggale:

    Since currently there is nobody working on the RaR base mod, I thought I could tell this to you.

    I found a few more missing sounds in the logs:

    Spoiler :

    AS3D_IMPROV_SPICE_WORKED
    AS3D_UN_OCEAN_SPRAY_LOW
    AS3D_UN_ELEPHANT_FORT_VOX
    AS3D_UN_DEATH_HIT_LOW2
    AS3D_UN_BODY_FALL_LOW
    AS3D_UN_WOOD_SHIELD_DROP_LOW
    AS3D_UN_HIT_VOX


    It is no real problem of course, if they are missing,
    But maybe you want to resolve this in your modmod as well. :dunno:
     
  12. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    Sorry, no, I don't remember the actions I did :(


    Once again, sorry, did forget to tell you.

    The reason for renaming was that initially I wanted to do some changes of my own with that mod, and then just used it for testing your modmod as I wasn't aware that yours comes with a debug dll.


    Ok, then I know for the future. :)
     
  13. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    Fixed the bug where the AI tried to attack plots it couldn't move into with the attacking unit.


    That's not important. Once I fixed one assert, another appeared. This time it's the one you found as well.

    It isn't a debug dll. It's a release dll with asserts enabled. The game would be way to slow if it were a debug dll. I customized my makefile to do a few new tricks. I plan to release it once I'm sure everything is working as intended.

    What did you do? Is it related to professions and/or unit types?
    Because my brief check of the assert indicates that a unit acting as a silver miner is captured, yet the unit in question isn't a citizen in a colony. Either you changed something or I read the variables wrong (I get indexes, not units as text). I want to know if you could have caused this before I dig deep into this.

    I guess I should make a list of precisely where those sounds are used and add this to the post about missing graphics. This way somebody might show up with a useful sound file. That somebody will likely not be myself.

    Hmmm... Something is trying to set the yield stored in a colony to something negative. Why it tries to set number of say stored tobacco to -10 is beyond me. Maybe the domestic marked tries to sell goods which aren't available.
     
  14. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    I hadn't done anything yet. The naming was just to prepare for my planned changes, but first I wanted to test the new features of RaR1.5

    Then I detected your work here and wanted to test the savegame compatibilty, therefore I just copied your files over to this folder.
     
  15. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,522
    Gender:
    Male
    Location:
    Stuttgart, Germany
    You do not need to know where they are used.
    The XML entries and probably the sound files themselves are simply missing.

    So all that needs to be done, is to find the XML entries and sound files they are referencing in Civ4/Civ4Bts and copy/paste them accordingly.

    Such log entries for missing sounds are usually introduced when units or improvements are adapted from Civ4/Civ4Bts.
    People mostly forget about the sounds then, because these sounds are referenced in the graphics and not in the XML.

    Again, it is no big deal if they keep missing.
    It is your choice if you want to get rid of such tiny errors as well.
    (Just thought, I might tell you.)
     
  16. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,522
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Another tiny bug which has been on my todo-list but never got fixed:
    UnitArtStyles of attached Great Generals get assigned wrong after loading a savegame

    This issue already exists in TAC and did not get fixed in Religion and Revolution.
    (It has nothing to do with Nightinggale's work.)

    -----

    Let me try to explain:

    1. AI gets a General
    -> UnitArtStyles work (nationspecific displayed)

    2. AI attaches the General to another Unit
    -> UnitArtStyles work (nationspecific displayed)

    3. Game is saved and loaded again
    -> attached General suddenly shows UnitArtStyle of Human Player
    (It is UnitArtStyle of Human Player and not default graphics.)

    -----

    Everything is perfect for Generals of Human Player.
    Everything is perfect for AI Generals that are not yet attached.
    Everything is perfect for all other Units as well.
    Everything is perfect before saving and reloading.

    -----

    It is no big issue, but it is still a bug. :dunno:
    (It might be relatively easy to fix, but I simply did not find the time to analyze the code properly.)

    Sorry to post bugs from Religion and Revolution base mod. (It was already reported in RaR.)
    But since you said you want to fix some of the existing bugs in RaR for your modmod, I thought you might want to know.
     
  17. HermanHeydt

    HermanHeydt Chieftain

    Joined:
    Mar 8, 2006
    Messages:
    75
    Location:
    Oslo,Norway
    Great initiative Nightinggale!

    Will be able to help with graphics once I finish my other chores.
     
  18. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    I fixed the assert
    Code:
    eCaptureProfession == NO_PROFESSION || !GC.getProfessionInfo(eCaptureProfession).isCitizen()
    It turned out to be the AOD code I copied, which didn't clear the profession of the criminal it freed. When it tried to kill it, it went "you forgot to remove it from the colony first".

    Also I committed a cache for colony teach level. Now it's recalculated on load and whenever a building is added/removed instead of each time it's read (which is several times each turn).

    Read the log at Github as I will not continue to post every single commit here. Also the first post should tell how to get email notifications. Major changes will always be announced here.

    Now there is one mystery left with that savegame. Somehow it decided that native braves should have afree promotion. It's not like that in the XML file and the braves don't have that promotion, yet it asserts when braves join settlements because it tries to remove something, which isn't there. I wonder if the savegame is corrupt, but if that is the case, then how did it end up like that :confused:
    EDIT: now those asserts stop on their own even though I didn't do anything. I guess that's really a mystery bug :confused: Let's hope it will never return.

    Ahh. Sounds easy. I thought I had to find 3rd party sounds somewhere else.
     
  19. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,356
    I have major news. I figured out how to profile the DLL. Turns out that the forum wasn't really helpful and that I needed to customize my makefile even further, but now I can see the amount of CPU time spent in not only each function, but even each C++ line. I will upload the makefile and instructions on how to profile in the near future.

    I took a huge savegame and did some profiling when hitting end turn and stopped when the next turn started. Turns out the most used function in the DLL is CvPlayer::getYieldEquipmentAmount().

    Looking into it didn't help much as it turned out that it really isn't that badly written. Making it faster is rather tricky. The issue is not really slow code, but more the fact that the AI calls it over and over. It calculates yields used to make certain professions, like scouts uses 50 horses, 0 lumber etc. I decided to cache the output for each input combo and make the calls access a lookup table.

    Before I did anything it took 40 seconds to reach next turn.

    With the cache it took 35 seconds. However now it added 15 kB data to each player, most of it 0. I decided to use just-in-time arrays. Those arrays will not allocate memory until a non-zero value is written to it and reading unallocated arrays always return 0. It's designed to be just as fast to read as normal arrays, though writing to it can be a little bit slower. Perfect for this even though I wrote it with something else in mind. Runtime is still 35 seconds (perfect), but memory usage is reduced by 216 bytes for each profession not needing anything (most of them) and increase by 4 bytes for each using something.

    Just-in-time arrays have a nice little feature to tell if they are allocated or not in virtually no time (check for NULL pointer). This made me look up all places calling getYieldEquipmentAmount() and changed them into only looping through all yieldtypes if the array is allocated (provided it made sense for the caller). This should save some time as most arrays aren't allocated.

    Runtime is now 33 seconds or in other words, wait time for the AI is reduced by 17,5% :eek:
    Not bad for improving a function which is profiled to use 6,7% of the time. Part of the reason for this is that the time is the time spend in the function. If it calls another function and waits for the return value the profiler will mark the other function as the active one.

    I ran out of obvious places to improve this cache even further and committed my changes. I recommend everybody to pull the newest dll right away. Be on the lookout for units using the wrong yields, though I'm fairly sure the cache will be kept up to date. The cache isn't saved and will be recalculated when loading savegames.

    Oh one interesting point to this change: I modified vanilla code exclusively. Well there is a single place which calls getYieldEquipmentAmount(), which has to do with new warehouse capacity, but the impact from that place appears to be too low to be measured. I wasn't too happy with the vanilla code to begin with and this certainly didn't improve my impression of it.

    I did do one tradeoff. The number of professions is now hardcoded into the dll as I needed that info at compiletime. Adding more professions will need a new dll file. I added a check and error popup for mismatches. I plan to do this with more data from the XML files as knowledge of the numbers at compiletime provides faster code and open up some more coding features.
     
  20. orlanth

    orlanth Storm God. Yarr!

    Joined:
    Nov 17, 2001
    Messages:
    1,776
    Wow impressive job Nightinggale :cool: sounds like Firaxis should have hired u instead! :king:

    But, hardcoding data about game content items into the DLL could make it impossible for others to use your RaRE DLL for modmods, and it sounds like it's something all mods could benefit from using. Would it be possible to have it directly identify the # of professions on the initial load of XML data then store that in a global variable (or if it's needed to declare an array size when compiling, set a comfortable max threshold that most mods won't exceed?) For me as a modmodder trying to make a conversion with limited c++ knowledge, turn speed wasn't as much an issue as many hard to find crashes caused by various bits of hardcoded content buried throughout the vanilla DLL :sad::crazyeye:
     

Share This Page