It seems to me that Firaxis was very conservative about member variables of CvPlot, using only a minimal selection of values and using short wherever possible. That makes sense considering how many plots in particular large maps can have. In my mod, the map I am about to use has 15000 plots, so anything that is being added gets multiplied by that number and can have a big impact.
Especially in my mod, I have to keep track of a "settler value" and "war value" (controlling AI city site and war target selection) for each plot for each civilization. It seems that it's worth thinking about optimizing this, considering how memory is at a premium for Civ4.
But how? Does it actually help to go down from int fields to shorts (I think with a better selection of the range of possible values I can even bring them down to byte size)? A cursory read of some discussion on SOF suggests that in practice a smaller type does not actually use less memory because it still occupies an integer sized register, which introduces processing overhead rather than memory saving, and the overall recommendation seems to be not to bother with sub-int types.
The exception seems to be arrays. Some of these plot fields are already arrays (like settler/war value as per-civilization arrays), but others aren't. Does that mean using smaller types is actually worth it? Is it worth it to go one step further and instead of storing these as members of the CvPlot class, to create one big short/byte array in CvMap that is index by plot ID?
Another aspect is that roughly half of the map is water where these values do not matter but memory still has to be reserved for them. Is it worth optimizing for that, and how could I do that?
Especially in my mod, I have to keep track of a "settler value" and "war value" (controlling AI city site and war target selection) for each plot for each civilization. It seems that it's worth thinking about optimizing this, considering how memory is at a premium for Civ4.
But how? Does it actually help to go down from int fields to shorts (I think with a better selection of the range of possible values I can even bring them down to byte size)? A cursory read of some discussion on SOF suggests that in practice a smaller type does not actually use less memory because it still occupies an integer sized register, which introduces processing overhead rather than memory saving, and the overall recommendation seems to be not to bother with sub-int types.
The exception seems to be arrays. Some of these plot fields are already arrays (like settler/war value as per-civilization arrays), but others aren't. Does that mean using smaller types is actually worth it? Is it worth it to go one step further and instead of storing these as members of the CvPlot class, to create one big short/byte array in CvMap that is index by plot ID?
Another aspect is that roughly half of the map is water where these values do not matter but memory still has to be reserved for them. Is it worth optimizing for that, and how could I do that?