I kinda assumed this should never happen due to the cleanup stage, but it seems there are
still cases where it does. Since the code already checks that the lock is valid before
returning, this isn't apparently needed and just breaks things.
This ensures all names are always valid to use in by-name lookup and are stored consistently.
Also fixes a potential issue in 2c12d1328b. I should have called standardize_name on each
name entry in the cleanup phase like when done in the registration phase, but this commit
ensures that's not needed anymore.
* Fixed assertion failure when removing single-use custom events. Not actually something
broken, I just forgot to add a "not already disabled" check when doing so since I added
that assertion in event_handler::disable.
* Added a message to the aforementioned assertion.
* Ensure handler cleanup actually happens when removing custom events.
* Account for events with multiple names in cleanup.
1. Undo now works again in the scenario.
2. Lava now works again.
3. Triggering on a moveto event was not good, as several shorter moves
would make rate of lava grow much faster than fewer longer moves.
This code ended up ignoring *all* MP test failures, in particular the one
fixed in commit 11d7b9f0cf.
I'd test the code and fix it if I could, but unfortunately I can no longer
develop on GNU/Linux because of PC issues (which I mentioned in Discord).
Therefore I'm just reverting the entire change.
We only use it in once place. At that point we can guarantee we stay in-bounds. So there is no need to use at() to check we remain in-bounds.
This eliminates a warning when building Debug for Windows (quieting Appveyor).
AI0886 had a similar issue building using GCC 6.3 on Boost 1.62
Reverting ca03818fa8 and 0cbab6eeed since this changeset should correct both issues.
This throws out the custom smart_list class in favor of a plain std::list. It also greatly simplifies
a few things. First, event handlers no longer remove themselves from the main list in event_handlers.
Now they just flag themselves as disabled (which means they will never execute once marked) and cleaned
up later in a newly added cleanup stage. This means a handler no longer needs to keep its index in the
active handler vector.
This removal of reliance on indices also means I could add the aforementioned cleanup stage. With the
smart_list code, event handlers were never actually removed from the active vector, nor any weak_ptrs
pointing to them removed either. This wasn't exactly a problem, since the handlers were stored via
shared_ptrs which would then simply be null after one deleted itself. Still, it's cleaner to drop any
invalid ones (and unlockable weak_ptrs) from any relevant containers. I've opted to do this in
manager::execute_on_events. Seems a good enough place as any.
The net result of this is the code is much cleaner. We're able to get rid of a bunch of unnecessary
feelers into various classes. This also makes the manager::iteration dereference code a lot easier
to understand. There certainly could be further refactoring, but I think this is a good start.
This is a small subset of a change made on accelerated_rendering. Essentially, since drawing
doesn't happen until events::pump is called, and that function also drops all but one DRAW
event from the queue, sending a DRAW event every 20 ms is just useless noise and excessive
CPU use.
There should be no change in the actual rate GUI2 dialogs are redrawn with this change.
After testing, it seems these calls to raise_draw_event and display/game_display::draw()
were unnecessary - or at least, became unnecessary at some point. One or two are definitely
still needed, but removing these doesn't seem to cause anything to to glitch out. Likely
explanation is anything that needs updating just gets updated either immediately or on the
next play_slice loop.
Sceptre (15x4) is now stronger than the uncut ruby of fire (14x4) for
regular mainline users Thursagan and Konard II. Level 3 Konrad & Li'sar
in HttT are still exceptional users of the sceptre (18x4 & 16x4).
From discussions with zookeeper in irc.
Copying the blit_helper objects when adding them to the drawing buffer was expensive since
blit_helper contains a vector of surfaces. We definitely want to copy that as little as
possible.
Also used std::move when fetching fog/shroud images. This function apparently has little
overhead, but still nice to not make copies here.
Also made get_terrain_images return void (this is just minor cleanup, not an optimization).
No need for it to return a reference to a class member.
Also removed CVideo reference passed to make_screenshot() and its argument function, since the
reference is only used in the one specific screenshot() function anyway.
These were emptied out when SDL 1.2 was removed (358bd1235f). I seem to recall
someone saying it might be worth keeping them around in case something needed to be put
back, but it's been a year and a half. Not much worth in keeping empty files.
* Added a point ctor that takes an SDL_Point.
* Added a toggle_fullscreen function to CVideo.
* Change all management of resolution data to use point instead of std::pair<int, int>. This
shortens the code considerably.
* Cleaned up preferences_dialog::set_resolution_list
* Made CVideo::set_resolution return a bool indicating whether resolution was changed.
* Swapped which of the two set_resolution overloads contains the main implementation.
* Moved the events::raise_resize_event() call when setting resolution to the CVideo function
where it should have always been (instead of the prefs dialog callback). This is a pretty
essential component and having it localized in one place meant any other area of the code
that might have called set_resolution wouldn't have it.
I thought changing what the return value of sdl_event_handler::hotkey_pressed meant wouldn't
cause any regressions, but apparently I was wrong. This made it so certain key-down events
were never fired at all, meaning the associated keys could never be entered in a textbox.
Pretty serious!
I've restored the bool retval to dispatcher::execute_hotkey. It will return false if there's
no associated hotkey function (like before), and true otherwise. sdl_event_handler::hotkey_pressed
has also been reverted to return the value of that function.
* 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.
Play_controller::play_slice() that the aforementioned function calls
redraws the game anyway. Calling redraw code from two places makes
profiling data harder to investigate.