* Removed create_neutral_surface in favor of a surface ctor that takes w/h dimensions.
* Removed make_neutral_surface in favor of a surface::make_neutral function. Most usecases of this were
to make a copy of a surface anyway, so I added a new surface::clone function
* Moved the pixel format validation and conversion to the surface class. Now *all* surfaces should be
guaranteed to be in the 'neutral' format. Any new surface that is created (with clone() or the dimension
ctor will be in that format, and any time a raw SDL_Surface* ptr is assigned, it is also converted. This
applies both to the ctor and assignment operators.
* Removed create_compatible_surface. All surfaces should be compatible in the first place.
* Removed surface::assign was in favor of simple assignment operators. The existing assignment operators
already just called assign().
* Removed surface::null in favor of the implicit SDL_Surface* conversion operator for consistency. We were
already using null and implicit pointer bool conversion, so I decided to go with the latter. I was going
to add an operator bool(), but it was ambiguous in surface-to-surface comparisons.
This was essentially only needed for the affects_side() helper. THAT'S IT. All this code just for
one single line... Anyway...
Utilized the display singleton's display_context getter instead. This also means fewer explicit
uses of resources::gameboard as the display_context object, meaning more compatibility with the
editor (not that that's relevant for most of the changed usecases, such as the AI, but it does
affect unit::get_abilities, which might be useful there in the future).
This also removes the display_context parameter from unit::invisible() since it was only passed to
unit::get_ability_bool().
unit::is_visible_to_team() also had its display_context parameter removed. It was used once as an
argument for invisible() and the other case was replaced with display::get_map().
(cherry-picked from commit 7e442cbb54)
These changes cover areas from PR #2101, excluding the removal of the numeric ID color ranges.
That can't be done yet (it breaks things).
This also excludes any changes to the connect_engine color handling. That needs to be refactored
separately. Despite the fact that it's done very similar to the new get_side_color_id function,
I need to deal with the fact that every side_engine member in the connect engine keeps a copy of
the default color options.
* Added a general-purpose function to extract color data from a config.
* Refactored the team class's general get-side's-color-data function so it always returns a color
ID instead of falling back on a number.
* Deployed this change for the leader image coloring in the save_index; said coloring is now always
done by ID.
* Save color data by ID in team_info instead of using the side number if no color was provided.
* Renamed get_side_color_index to get_side_color_id to better reflect its purpose.
I reverted the aforementioned commit after being informed it would be inferior, performance-wise.
However, this should solve that as the map is no longer constantly recreated.
This also addresses some issues I had with the original commit where I had to make some member
functions non-const.
This only includes cases where this can be done without triggering warnings about narrowing conversion.
Also includes cleanups of sdl/rect.hpp includes.
Units are rendered at 0.5 alpha when they are invisible (for example, Elvish Avengers' Ambush ability). An issue arises with the Shadow (and Nightgaunt) ghost unit which has the Nightstalker ability allowing it to be invisible at night time - in combination with its fluctuating alpha animation, it can be quite hard for the player to see at night time (https://gna.org/bugs/?14503). So this change slightly increases the alpha level of invisible units from 0.5 to 0.6.
This (should) allow sdl/utils.hpp to be modified without a huge rebuild, since a number
of widely used headers included that file simply for the surface class type.
Commands run:
find . -type f -name "*.hpp" | xargs coan source --replace --no-transients -U"SDL_GPU"
find . -type f -name "*.cpp" | xargs coan source --replace --no-transients -U"SDL_GPU"
This was followed by grepping and a bit of manual editing to remove
defunct TODO items and the empty sdl/gpu.hpp file.
The unit::get_ability_bool() function accessed resources::gameboard that
is not set in the editor. Now the function receives the display context
as a parameter instead.
I also fixed two crashes on editor startup in MSVC debug builds (both
caused by indexing the teams vector when there aren't any teams), and the
GUI2 unit list dialog showing wrong status icons.
The halo is recreated when the mage starts to move, and it's initially
placed in the top-left corner of the screen. On the next frame the game
corrects its position. Correcting the position clears the list of hexes the
halo overlaps, which essentially means "the overlapped hexes aren't known,
update them when the halo is redrawn". However, the game also uses the list
of overlapped hexes to determine when the halo should be invalidated, and
thus redrawn: because the list was empty, the halo was never invalidated,
and it stayed at the top-left corner.
Fixed by placing the halo in the right position to begin with. This commit
includes my previous fixes as well, though, because the code was simply
incorrect before (even if it doesn't break anything any more).