I have encountered another issue (so soon
) when looking at the canAutoCrossEurope function. We use that function to set a unit traveling towards its destination Europe Plot. In that function it makes a check for "Plot->isEuropeAccessable()" which basically checks the distance to the Nearest Europe plot. But sense we have multiple Europes, aka Trade Screens, we need a way to differentiate between the Europes when making this check. Again, I can add a new int Array to Plots that records the distance to each Europe when this calculation is made. I don't think a bitmap array can be used for this right? I don't know much about bitmap arrays, I seen your post (Nightinggale) about that and it looks promising, but I would need you to set it up.
A bitmap uses bools and the code uses int. You are touching a piece of code, which uses the int as a bool, but I figure it would have been a bool if it is only used as a bool. I went hunting for a reason for using int and found
CvGame::updateOceanDistances() and
CvPlot::findNearbyOceanPlot(). The update function sets distance for all ocean plots to 0, then it spreads out and stores the distance to the nearest ocean for all water plots. Water in lakes are unreachable by this spread and will have the default value, which is the one you check for (the bool usage of the int).
CvPlot::findNearbyOceanPlot() finds the nearest plot by being on a plot, then jump to the lowest scored nearby plot in a loop until it reaches 0. This plot will be the nearest Europe access plot. In other words the distance int is a pathfinding cache and I think it is a powerful one. It greatly simplifies the calculations needed to find the nearest plot. However actually going there is still done by the normal pathfinder, which will avoid enemy presence etc. (I think)
From what I can tell, we really should have this cache for all trade screens. Bitmaps will not work. Instead we should have an int just-in-time array for trade screens in each plot. I don't mind coding it, but it mean you should commit your work first. Maybe we should consider a branch or we could simply say "master is work in process" until we have dealt with this. It would be correct to branch, but I have yet to write a guide on branching
I wonder what to do with land access plots. The code here appears to be hardcoded to water movement. In fact following the logics in this approach, the entire cache should be recalculated on an island/continent if a forest appears or is removed. I will postpone even looking at this issue until it works for all water based trade screens.
Note to self: finding the nearest plot should be done locally and then goto that plot should be done with doCommand(). This way only the sending player uses CPU time to find the plot in network games and not all players. This appears to be important for land based access plots, which may need to be found without the aid of a cache.