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

Further automation and template ** in cities ***

Discussion in 'Civ4Col - We The People' started by Vorpal+5, May 13, 2020.

  1. Vorpal+5

    Vorpal+5 Venturing in Erebus

    Joined:
    Mar 25, 2008
    Messages:
    633
    I realize that overtime my colonies mature and always want the same thing. At first some wood and food, tools, then a further need of stone, and perhaps more wood and tools stockpiled. They will also export a bit of their natural product.

    Then further down the road, they will want manufactured goods to earn some money at the local market. And then further again, they will act as a relay for newer colonies deeper in the land. So they will want almost all goods, but they will want to keep their own stockpile while exporting the rest.

    It all can be set remarkably and reliably well with the Governor button and export and import .

    Except ... I always do the same things and there are many goods. Why not having the possibility to save and load templates, as it is done for trade routes, except this is not a trade route, but a preset of exported and imported goods.

    It would save so many fiddling and clicks ...
     
  2. FlaviusBelisarius

    FlaviusBelisarius Chieftain

    Joined:
    May 13, 2020
    Messages:
    10
    Gender:
    Male
    Location:
    Finland
    Regarding import/export templates, I would really like to see this feature too.

    In fact, I would like to implement it - can some of the more experienced modders just point me to the right direction, where to look? How to approach this, would it be easy or not? Could I reuse the trade route template approach here or not? I can do xml, python, even C code editing to get this done if necessary.
     
    Vorpal+5 likes this.
  3. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,360
    This has been on my todo list for ages. There are some buttons for some hardcoded setups, which should reduce the need for templates, or rather they are hardcoded templates. Not good enough, but I find them to be very good compared to how quickly I made them.

    Sounds good. The current implementation is in CvDLLButtonPopup.cpp and you can search that file for BUTTONPOPUP_YIELD_IMPORT_EXPORT.

    Since this is a user input for something, which needs to be done in sync on all computers in network games, the actual change needs to be done using gDLL->sendDoTask() on the computer getting the user input (read: just one computer). It will in turn call CvCity::doTask in parallel on all computers where the city (this pointer) is the first argument in sendDoTask and the rest of the arguments are just copied.

    I can say a whole lot more about this as well as how to save templates in savegames, but for now you should take a look and then come back when you know what more specifically to ask for.
     
    Vorpal+5 likes this.
  4. Vorpal+5

    Vorpal+5 Venturing in Erebus

    Joined:
    Mar 25, 2008
    Messages:
    633
    Can end-users access your hard coded setup while Belisarius conquers new swathe of Colonization code? :)
     
  5. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,360
    Assets\XML\Terrain\CIV4YieldInfos.xml
    After bCargo, there are some yields, which have the line
    Code:
    <bIsExportYield>1</bIsExportYield>
    Those set to 1 will trigger with the import/export all buttons. Set it to 0 or remove it to let it not trigger. The order of tags matter.

    Yes it's not an awesome way to control it, but you can alter your own game settings without the aid of a compiler.
     
    Vorpal+5 likes this.
  6. FlaviusBelisarius

    FlaviusBelisarius Chieftain

    Joined:
    May 13, 2020
    Messages:
    10
    Gender:
    Male
    Location:
    Finland
    Thanks. I will take a look at the code.

    Another thing I would like to implement would be to have the trade route UI give an option to activate all trade routes connecting city A to city B (both ways). The user would only need to choose those two city names and the associated boxes would be selected. That would be a very smooth way to organize a 1:1 city link trade network (wagons only haul stuff from their two towns forming a network of pairwise links).
     
  7. Lord Chambers

    Lord Chambers Emperor

    Joined:
    Nov 23, 2001
    Messages:
    1,004
    Could you share a 3-screenshot guide describing how you use it remarkably well? I find it unintuitive , particularly that I can name quantities to import and export, and it's not clear which box sets a reserve to hold in the city. As well, I think the cart chooses goods to load based on value, so I get unexpected observations after setting routes in motion. I don't understand how what quantities I set in city governor relates to the behavior of a wagon using a trade route. I just find the governor to be a less obtuse way to build up options in the trade-route interface.

    Edit: I just saw this video that may serve as a guide. https://forums.civfanatics.com/threads/an-introduction-to-trade-automation.657915/
     
    Last edited: May 14, 2020
  8. FlaviusBelisarius

    FlaviusBelisarius Chieftain

    Joined:
    May 13, 2020
    Messages:
    10
    Gender:
    Male
    Location:
    Finland
    Update on my progress. I wanted to get a better idea of what is happening in the code so I read the code a lot. And used (astro)grep to the code base to try and track how things work. Things are quite convoluted there to say the least.

    Then I set out to do an exercise to support my learning. I added a forth button in addition to Nighttingale's three old buttons. The forth auto function reads new tags from the xml and sets import feeder on to those yields - but in addition it sets the storage low and high limits that can also be set in respective new xml tags. It seems to work now after a bit of bug hunting and fixing:)

    I am quite dissatisfied with the standard popup size. How difficult it would be to move away from the basic popup and use a view more like the "Assign Transport Routes" -button?

    In order to get to the actual goal, I need to look at the save/load functionality of the mentioned interface anyway. Any hints?
     
  9. FlaviusBelisarius

    FlaviusBelisarius Chieftain

    Joined:
    May 13, 2020
    Messages:
    10
    Gender:
    Male
    Location:
    Finland
    Another progress update.

    I modified the import feeder so that the default 75% threshold can be customized on a per-yield basis. This happens using a third "spinbox" element in the popup in addition to min/max storage limits. This required new data to be kept in memory that I managed to make work - so that the custom feeder parameter persists and save/load keeps the data. So now I have learned the basic ability to add data to be serialized and kept in save games files.

    Perhaps next I even get to the actual task: saving/loading import & export governor profiles.
     
    Mr. ZorG and XSamatan like this.

Share This Page