Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,378
This is one reasons we shouldn't change stuff just before a release. The issue isn't what we intend to change, but rather what we change without intending to.I introduced a bug one of my last pushes were you no longer gain Trading Points after the first Trade Tech. I was attempting to remove all the old Vanilla Constitution code but removed to much![]()
There are two design goals here, which clashes hard.Technically I am thinking that initial trade routes only need to be set up once when the game initializes. The variable m_ba_TradeRouteTypes is saved so there is no need to reconfigure it on load up.
- recalculating on load to update correctly from XML changes
- enable trade screens by other means than civics
The best solution I can think of is to make an allowed array just like with professions and all that. We can then give civics the option to add or remove enable points. This will allow something like a slave market trade screen, which is only enabled for civs, which picks the slavery civic.
As we would like to enable screens by moving on to plots, we have to have a bool array telling if you have reached an access plot. If this bool is true, then it will give you an enable score of +1 for that screen.
By only saving the "reached access plot" array, the actual allowed screen array can be recalculated correctly on load. That way it will update correctly to XML changes.
There are a few details to figure out, but overall the code for this approach is already there as we have the generic array enable code used by all the other arrays.
As for CvPlayer::init() vs CvPlayer::reset(). Reset is called by init() and read(). On the other hand init() seems to be called from the exe and we have little control of that one. Generally speaking we should write everything in reset(). It is my impression that if we set a variable in init, change it during the game and then load a savegame, it will not revert back to init state. However it will if it is set in reset. As the exe allocates the players at startup and reuse that memory between games, this is an important issue, which as far as I can tell only applies to players.