Closed hemoridos closed 6 days ago
Is the concern here the consistency of the data in AIPlanet (ie. building/surface data loaded later might not be consistent with planet statistics loaded at AI assign, though I'm not sure this is possible) or "just" a possible race conditions? If the latter, then I would rather make an attempt at implementing some thread safety around the fetch operations first. I believe the possible savings here would still worth it, as it turned out during testing (Level 5 mid-to-late game) that around half of started planning operations get to the point where buildings data is needed. This is even less for surfaces, around 5%.
Note: For what it's worth this time around I did a campaign playthrough to make sure I did not break much.
Consistency is one aspect. Accessing mutable state from a background thread so freely is the main concern and a big no-no. Trying to make it thread safe is very very difficult and causes inefficiencies elsewere. Today, memory is not a concern. We can just up the requirements to 1-1.5GB.
Please just leave the state-copy as it was.
Started as a commit to reduce memory usage of the AI when copying planet surfaces, turned into a collection of optimizations and also fixed some of my bugs I found while playtesting.
Added a new class for storing basic information about the surface of a planet. This data is used for pathing and building placement so it only stores what kind of object is in a surface cell. The class consists of a byte array where each element represents a surface cell, and methods for accessing this array, converting location coordinates to indices etc. This data is now also used for handling surface pavements.
Optimizations:
Fixes:
Misc: