removes a call to get_ability_bool, in case that get_ability_bool
would return false, it would ot be faster than get_abilities, in
case that it returns true it is useless.
now the c++ code does no longer add a dummy time when
there are no times defines for an [time_area]. this is
in particular useful when one wants to define areas in
the map editor that is then used ingame for example in
filters.
We should consider renamaing [time_area] to just [area]
[time_area]s that don't define their own times schedule
are now ignored during tod calculation.
A few catch blocks modify something in their exceptions, so those are kept non-const.
(cherry-picked from commit 2bf4d68c87b69256266b7745a9e3453693794e35)
areas_ might be empty, so areas_[0] might crash, also returning areas_[0].hexes didn't really make sense in the first place
(cherry-picked from commit 41d7df970c43cd74413a93b635058e494dd67d78)
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 7e442cbb541b0bfbc5f3511fd1510fea80a4d34e)
I left the implementation of get_adjacent_tiles using messy C ptr arithmetic
since it most simply accounts for a few cases using arrays that are larger than
6 (such as in tod_manager) or underlying vector storage.
Also made use of std::array::size where applicable, and one case of std::array
iterators.
aspect_attacks_base::analyze_targets was changed to take a adjacent_loc_array_t
reference.
Partial revert of commit ecbb15e1c6d1106ff2f8e540c584523481426c04.
Replacing bounded_add() with std::clamp() in these contexts disables
time-of-day bonuses, since ToD bonuses (the base value in these functions)
are almost always outside the range set in terrain properties.
* Dropped bounded_add for clamp. There's a slight behavior change with this, namely that
base is no longer returned if it falls outside the bounds. However, for both usecases of
bounded_add, that behavior doesn't make sense. The wiki clearly states min/max_light=
define the bounds for light=.
* Replaced gcd with Boost's gcd function. We already use the latter in the Preferences
dialog, so this is more consistent.
* Simplified the implementation of in_ranges.
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.
This adds play_controller::is_networked_mp() and
play_controller::send_to_wesnothd() which are now used to comminucate
with wesnothd during a game instead of using network::send_data and
network::nconnections() directly.
The main intention is to make future changes to this code easier
specially:
1) to have more than one connection during a game, for example to check
for updates
2) to replace the clientsided network code with boost asio.
In order to do that i needed a little change to the chat_handler class
which is used both ingame and in the mp lobby. And to do that i
had to cleanup up the menu_events.cpp file and move huge helper
classes into their own files.
This was basically an unnecessary stub class. It also allows us to
remove the unused soundsource::manager::to_config() function (write_sourcespecs()
did the actual job).
This commit converts the following function calls:
* boost::bind -> std::bind
* boost::function and boost::functionN -> std::function
* boost::ref and boost::cref -> std::ref and std::cref
* boost::bad_function_call -> std::bad_function_call
In the process, it was discovered that std::bind has trouble with overloaded
functions. There were two such cases in the code:
* gui2::twindow had an ancient unused overload to draw(). The overload was removed.
* gui2::trepeating_button was binding tdispatcher::fire. This case was converted
to a lambda.
after updating to boost 1.60 boost have me erros related to
boost::optional<game_data&> in stage_sf_with_rca.cpp where game_data is
not defined (only declared).
Using game_data* solved this problems and also simplies the code by
using simpler datatypes.