* The vector of surfaces is now a class member variable instead of a local
variable. This saves a memory allocation every time the function is called
- which is worth it in this case, as the function is a major performance
bottleneck.
* The surfaces are now being moved instead of copied where possible. Turns
out that freeing a SDL surface is fairly expensive in performance-critical
code.
* Pointers to ToDs are now cached, reducing the number of calls to
get_time_of_day() from 37 to 7.
In a stress-test in Aetheryn's Mod at 50 % zoom, the FPS I was getting on
my PC (Intel Core i5-4430) increased from 16 to 23.
Partial revert of commit 010edbe1b9.
The commit caused every GUI2 window to be fully invalidated and redrawn 50
times per second, with massive CPU usage cost. No wonder that some players
have been complaining about too high CPU usage while idling in fullscreen
GUI dialogs.
I couldn't find any obvious regressions with this change. It looks like the
underlying issue has disappeared at some point.
In my tests, CPU usage while idling in the addon manager dropped from 17 %
to 2.5 % (across all cores).
This halves the CPU usage cost of animations, which is useful especially in
water-heavy scenarios such as Dead Water.
I was worried about the possibility of regressions, but I didn't find any
in my playtesting: moved and killed units disappear from their hexes like
they should.
The FPS cap, originally implemented in 2007, is very poorly done. It
doesn't take frame time variance into account, and is therefore almost
guaranteed to cause missed frames all the time. It doesn't increase timer
granularity on Windows, which causes SDL_Delay() to often take much longer
than intended. And it's hardcoded for 50 FPS, which fits poorly with 60 Hz
displays.
This new implementation fixes all those issues.
My experience is that the game feels much, much smoother with the new
implementation, perfectly competitive with 1.12. In my opinion, performance
is now at an acceptable level for a stable release.
Previously double-clicking always installed the add-on, even if installing
wasn't a sensible choice (e.g. for add-ons which are already installed).
Now double-click always does something sensible, e.g. it uninstalls add-ons
which are already installed.