I’m the new guy I suppose, and as such, it’s my duty to destabilize some things and brake others and then spend too many hours fixing them.
Right now the main contribution that the safemode branch has brought to vegastrike is an std::list backend to UnitCollection and a total redesign of the UnitIterator UnitCollection classes. It’s important to note that the current incarnation of those classes are not the final incarnation that I envision. Right now there are still some lingering issues with how the rest of the program and the Python data files utilize the UnitCollection both via the regular UnitIterator’s and PythonUnitIter’s and PlanetIterators. A lack of testing by other people, however, has made detection of the wrong behaviors hard….as I dont spend much time playing the game compared to developing it. The safemode branch also brings a cleanup effort both in the form of code formatting and in the form of numerous minor bugfixes/optimizations. For right now that is it. The evolution of the UnitCollection class and UnitIterator class may make it slower at times than the older version, but that is only temporary, once all the code has been properly updated, and the UnitCollection class is in it’s final form, it should be much more streamlined and most if not all of the conditionals regarding correct values will be gone.
So, what’s the status?
Right now UnitCollection and UnitIterator and UnitConstIterator exist as the base classes. PlanetIterator and PythonUnitIter exist as derived classes of UnitIterator.
UnitCollection uses an std::list to hold it’s Units*’s.
UnitCollection’s methods still operate and attempt to completely mimic exactly how the old UnitCollection worked.
UnitCollection also uses an std::vector of UnitIterator*’s to maintain a registry of active iterator’s to it’s list. This allows it to make sure one iterator doesn’t invalidate the position of another iterator that may also be active. It does this currently by incrementing the iterators at the same position, and then erasing the position. Erasing is currently the only method that cares about this, since in std::list, erase is the only method that can invalidate positions. The registry is by no means a permanent thing, it’s only there because i needed a solution to the problem of invalidating positions held by other iterator’s. I may go with another solution later on when I think of one.
UnitIterator’s also work almost exactly like their previous incarnation. Backwards compatibility is only maintained in the PythonUnitIter class. The current() method has been removed in favor of the operator*(). Eventually UnitIterator will have only those methods that an std::iterator has. The UnitCollection class would have mostly only those methods than an std container class has.
Other than that work, I’m stil chugging along reformatting code to a more legible state. I’ve halted it for now because of all the issues i’ve been having with UnitCollection, but once that’s taken care of, I’ll be reformatting source left and right.
Future:
I make semi-regular merges to the svn head since _most_ of my changes are fix related or cosmetic. The purpose of the safemode branch is to clean up VS, simplify where possible and optimize via good programming practices. That means most of my work will result in no change to gameplay, so regular users wont notice much at all except hopefully, a lighter and more responsive game. A lot of the code fights against me *cough*unit_generic.cpp/.h*cough* . Code cleaning sounds non-invasive but cleaning can be very invasive, the std::list change began as a cleaning of the UnitCollection class. This invasiveness will hopefully dive deep enough to actually do something constructive to help vegastrike but not too deep that it becomes something not doable with our current resources.
For the most part, I really want to fix the Unit class. I think it’s entirely too much of a victim to feature creep and abandoned code. It’s way too large, non-compartmentalized, lacking any sort of api or layer system, and it combines templates and inheritance, making most of the benefits of using templates nullified. I feel very strongly about needing to clean it up and it’s at the top of my list once my current things are complete.
This is going to take time since i’m juggling it between 12 hours of work and real life.
So now you know why your latest pull of the SVN may be acting funny. It’s not bad, it’s progress.. Just dont flip out and throw a line either on the wiki or via the forum about the problem. We really need more testers willing to give feedback. Especially those that can run gdb or some alternative and give backtraces (if the game actually segfaults). Thanks.
Clocking out,
Ed Sweetman.