Just pushed to SVN (3604):
- Fixed memory corruption when loading or saving with new combat mod
@TB (et al) - I'm also a bit concerned about the memory footprint the combat mod changes imply. Just looking at units, you've added approximately 16K bytes per unit. Large games can easily have 10000 units, so even just for the unit stuff that's an extra 160M or so on the footprint of the game. You need to look at not initializing arrays that are not used (check out most of the CvInfo class arrays which are left unallocated if all members have the default value)
I understand the second part of that (see below). But I'm wondering if you're also implying the sheer volume of tags is a concern. I might like to point out that all of those tags are not necessary to express on any given units - none are required. Thus if the unit needs definition there, it should be included but it doesn't need to include the unused tags like many of our xml entries tend to do. Along the same lines of thinking, it could be useful for space, although not handy for modding so much, if all empty tags that aren't listed as required (most) were removed from entries. This is not just an issue on units either. Only here, where we have SO many units/techs/promos/civics and on and on do we start seeing enough cause to consider that it may be worthwhile to streamline by eliminating unused taglines.
Then again, you might not being pointing at that at all...
It would be better to just store it in a different format, similar to what TB actually did in CvInfo. Storing sparsely populated arrays in that manner is a waste of memory.
Ok... I KNEW this was an issue as I was programming it. But my understanding of the vectors is not agile enough yet to have converted it to application for those. So I programmed it how I understood to do so but did so knowing it would need to be changed. I'd simply request that one of you establish on just one of those arrays the correct method to employ complete with commentary to help me 'get it'. I knew enough to know it'd need to be improved for the sake of processing, and to have an idea of the method it would need to employ, but not enough to actually DO it and expect it to be done right.
What threw me is that in the info files I was able to establish a procedure that worked, but utilizing the same thinking into the Unit file presented some new challenges. Rather than take extra weeks to sort out the new procedure and struggle to understand your efforts to help through written explanation, I figured being able to see it done right would teach me far faster.
Heck... I'm just happy I understood what you guys were getting at with these comments here! lol Helped that I knew I'd hear this kind of feedback on those arrays.
But vectors should probably also be employed on the totals functions (where its combining information from unit promotions, leader influences, base unit information etc to come up with the final definitions on given units.) This is another area I wanted to improve with vectors once I'd learned to employ them in the infos but was not quite sure about how to best go about it, something else I would ask for an example of and then I can go back in and go to town rewriting based on the example.
Thanks in advance if either of you decide to help me by converting one of each for the sake of example.
@GiuseppeIII: It probably won't break the game per se at this point but there still could be lurking instability issues. If you do update, just let us know if you experience anything that doesn't seem right (as usual).