165 Commits

Author SHA1 Message Date
gfgtdf
6157603ed9 don't write unset attributes in the scenario editor 2020-09-26 12:08:22 +02:00
gfgtdf
194b903918 fewer units/types.hpp includes 2020-06-20 02:21:14 +02:00
gfgtdf
cacd68342f small illuminates optimisation
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.
2020-04-18 01:56:43 +02:00
gfgtdf
d50e37c2e3 make tod_manager more robust & code cleanups
the setters in tod_manager now ake sure that their parameter
is valid
2020-02-21 22:27:31 +01:00
gfgtdf
ebbecb3b04 support [time_area] with no specific time schedule
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.
2020-02-21 22:27:31 +01:00
Celtic Minstrel
7b358440f6 Merge pull request #2664 from holius-fr/liminal_bonus 2018-11-17 13:04:49 -05:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Charles Dang
d9fb6c0bf5 Catch all exceptions (where possible) as const references
A few catch blocks modify something in their exceptions, so those are kept non-const.

(cherry-picked from commit 2bf4d68c87b69256266b7745a9e3453693794e35)
2018-10-07 03:20:58 +00:00
gfgtdf
cf63206d3c fix segfault on area= filter.
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)
2018-10-07 03:19:57 +00:00
Charles Dang
2b65a8c5c8 Units: refactor display_context parameter out of ability functions
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)
2018-10-07 03:19:34 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f6935176b70a035d3e1c03080f79687f94)
2018-10-07 03:17:59 +00:00
fsd
ec1c7cb2d8 use has_attribute(liminal_bonus) as suggested 2018-03-16 15:59:07 +01:00
fsd
40483874ea change liminal implementation, from a night and day malus to a twilight bonus 2018-03-16 09:44:49 +01:00
Charles Dang
a7f6862210 More include cleanups
Cleaned up unnecessary inclusions of:
* event.hpp
* exceptions.hpp
* formatter.hpp
* hash.hpp
* image.hpp
* sound.hpp
* team.hpp
* tstring.hpp
* wml_exception.hpp
2018-03-11 23:22:02 +11:00
Charles Dang
a3a9697d14 Cleaned up unnecessary inclusion of formula/string_utils.hpp
These were either not needed, or serialization/string_utils.hpp was desired instead.
2018-03-03 20:22:17 +11:00
Charles Dang
ae53a38835 Use std::array for adjacent map_location arrays
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.
2018-02-20 11:33:51 +11:00
Charles Dang
8903ea9446 ToD Manager: don't write stub ToD to scenario file (fixes #2302) 2018-01-24 16:24:50 +11:00
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
Jyrki Vesterinen
0db553ef36 Restore bounded_add()
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.
2018-01-21 17:27:51 +02:00
Charles Dang
ecbb15e1c6 Minor cleanups to math utils
* 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.
2018-01-21 18:12:06 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Jyrki Vesterinen
a4018faad1 ToD manager: ensure that there is at least one ToD
Complete lack of ToDs is an unsupported use case,
causing crashes and undefined behavior. See time_of_day::parse_times().

Fixes #2301.
2018-01-01 12:36:12 +02:00
Jyrki Vesterinen
b710af1716 Fix #2285: GCC-dev compiler warnings 2017-12-09 18:30:49 +02:00
Celtic Minstrel
96ca0b026e Replace config_of with new variadic config constructor 2017-05-21 16:27:46 -04:00
Charles Dang
e41a415588 Deployed yet even more further additional emplace_back 2017-05-10 14:15:15 +11:00
Charles Dang
e90d11d02a Renamed namespace 'random' to 'randomness'
This is because GCC 4.x has a problem with symbol name collisions with 'random'
2017-04-21 03:05:52 +11:00
Charles Dang
d8ed11c2b1 Drop the _new suffix from random_new
The 'old' random code has long been removed.
2017-04-20 08:48:47 +11:00
Rikard Falkeborn
94e73a7ccc Add const to some more functions 2017-04-17 16:51:30 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
9754d3e08b Fixed a few of the simpler warnings reported by cppcheck 2017-03-16 22:12:15 +11:00
Wedge009
5d14459594 Initialise member has_tod_bonus_changed_ in constructor (bug #25218) 2016-10-23 21:49:31 +11:00
Jyrki Vesterinen
7573678201 Fix crash on placing a unit with the scenario editor
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.
2016-09-06 23:03:09 +03:00
Jyrki Vesterinen
531e05af9e Implement tod_manager::resolve_random() without Boost.Range (#711)
In order to do this, it was necessary to switch from boost::copy to
standard library algorithms, which is less space-efficient.
2016-07-25 01:31:20 -04:00
gfgtdf
52f0e3ecd6 refactor mp and menu_events code
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.
2016-06-05 14:50:53 +02:00
Charles Dang
71b154b6e3 Refactored out savegame::savegame_config class
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).
2016-04-05 18:10:44 +11:00
Celtic Minstrel
1bdce5b937 Fix build
This fixes my build and should also fix the Travis builds.
2016-04-04 15:55:04 -04:00
Charles Dang
aa449ee304 Removed two unnecessary boost includes 2016-04-04 02:23:45 +11:00
Charles Dang
0ca4e6c943 Convert uses of boost functional to standard library variants
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.
2016-04-04 02:20:52 +11:00
Celtic Minstrel
fe818f8005 Add Lua API function to set the current time of day 2016-04-02 09:38:34 -04:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -04:00
Celtic Minstrel
c86b4ee5a9 Implement invalidate_on_tod_change for aspects 2016-03-22 07:22:22 -07:00
Charles Dang
4d342447ea Cleaned up inclusions of team.hpp 2016-03-21 21:43:52 +11:00
Celtic Minstrel
bc711f5f43 Consolidate related files into subdirectories 2016-03-20 16:20:09 -04:00
Celtic Minstrel
fe0df45947 Consolidate formula and hotkey files in corresponding dirs 2016-03-20 16:15:50 -04:00
gfgtdf
b282ef7236 use game_data* instead of boost::optional<game_data&> in tod_manager
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.
2016-02-24 18:06:59 +01:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Elvish_Hunter
9b7b1751fd Removed trailing tabs and whitespaces from C++ source
I used this command line: find <source directory> -name \*.\[ch\]pp -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
2015-12-21 20:39:46 +01:00
gfgtdf
4afe65b4da move it_is_a_new_turn_ variable to tod_manager
it_is_a_new_turn_ is part of the gamestate so it should be part of the game_state object.
2015-09-09 16:31:33 +02:00
gfgtdf
3dc1cd55ab Add a comment 2015-07-08 15:01:11 +02:00
gfgtdf
9e1aae1f79 inform the server about turn changes by wml
The server uses this to display the current turn in the lobby.
2015-06-10 14:26:08 +02:00