Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,378
CvCityAI::AI_setPort(). However I can't find where it is supposed to be called. I just had an idea regarding this issue. If I understand DllExport correctly, those function names should be written in the exe in plain text. Grep or an hex editor should be able to find them if that is the case and then we can make a list of functions, which are known to be used inside the exe. Hopefully the list will be rather short.I discovered that they will only trade if they have an AI_isPort() City. Where is AI_isPort() set? I find nothing in the DLL so can only assume it is in the exe.
While we can't control when and what the exe calls, we can always make our own code like that. We should make our code as independent from the exe as possible. I looked at the function to get the bonus from a plot once. The exe calls it all the time, presumably the screen drawing code.Anyway, I am adding my own code, like when a City is created it checks if it is a NationState, checks if it can access Europe tiles, then sets that city as a Port city. Once I did that Rome started trading.
I realized that we should presumably make our own version of this function and make it return what the plot has while the vanilla function should return what should be drawn. That way we can hide bonuses before they are invented (at least I assume that). There are lots of options for the exe interaction, but figuring out what to actually do is tricky without access to the exe source code or at least documentation.
The entire AI yield behaviour seems a bit hackish and should be reviewed. We should make code to calculate how many yields a unit will make with a specific profession and use that everywhere, including GUI, AI and whereever needs this info. AI_professionValue() should then estimate value based on output, not input. That way AI_professionValue() will no longer care for input yields and it will be more resistant to bugs if we change something somewhere else later.Also, I discovered that we need to add code to check whether a Product requires Two or more Yields in the AI_professionValue() code. If one Yield is Present and the other is not it will still assign Citizens to work Buildings that produce no Yields.
This is not just an issue with AI_professionValue(). We have lots of values, which are calculated in multiple locations and nobody knows if they are calculated to be the same everywhere.