59 Commits

Author SHA1 Message Date
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Charles Dang
4d54b2a7fd Used std::optional directly since we support C++17 now 2021-01-17 11:48:14 +11:00
Charles Dang
a4b749524b Cleaned up ridiculously excessive passing around of terrain data cache
Keep in mind ter_data_cache is simply a shared_ptr, and in all call locations it was grabbed from game_config_manager::terrain_types().

1. campaign_controller took and kept a member, which was passed to either...
2. playsingle_controller or playmp_controller, which passed it to their parent class...
3. play_controller, which kept a member to initialize...
4. game_state, which passed it on to...
5. game_board, which passed it on to...
6. gamemap, where it was *finally* actually needed.

This entire chain has been replaced with a single call to game_config_manager::terrain_types() in the game_board constructor.
gamemap retains its ctor parameter since editor_map passes in its own object.

The ter_data_cache alias has also been removed. It was just confusing.
2021-01-02 17:03:15 +11:00
Pentarctagon
4c2b725ec0 Change all doxygen comments to the same format. 2020-12-31 23:59:28 -06:00
Charles Dang
cb537f781b
Converted uses of boost::optional to utils::optional (#5329) 2020-12-02 08:16:05 +11:00
gfgtdf
45a33e6e3a add wesnoth.create_side()
wesnoth.create_side() can create a side while the scenario
is running, this is especially useful for [modification]s
that can not define sides by default.
2019-11-18 18:56:38 +01:00
josteph
5ce2f2df37 Healing: Instead of hardcoding a turn-and-side-number check, indirect through a boolean.
This boolean may be exposed to WML in the future (ask gtgtdf).
2018-10-21 17:16:53 +00: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
gfgtdf
2e235f785d
allow specifying the next player number in end_turn
fixes #1392
2018-02-26 03:28:00 +01:00
Charles Dang
a003633c5a Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the same command from 9b7b1751fdda.

Excludes:
* lua/
* spirit_po/
2018-02-04 01:01:39 +11:00
Charles Dang
16ce2af32e Made display class no longer inherit from filter_context
The only function that display meaningfully implemented was get_disp_context. It did implement
get_tod_man, but only meaningfully in its two derived classes (it returned the result of
resources::tod_manager in display). Additionally, the long-ass comment in the header stated the
display class should *not* inherit from filter_context. Do note that get_disp_context was retained
as a display member function.

Upon further investigation, I found that there were only two places where the display class was
passed to unit_filter. All others passed resources::filter_con. The editor_display class was also
assigned to resources::filter_con in editor::context_manager. So, I removed the second filter_context
argument from unit_filter and initialized it from resources::filter_con in all cases.

unit_filter only used the filter_context to get its display_context and the unit_map within anyway.
When using display::get_disp_context in-game, that would return a game_board object. Using
resources::filter_con in the same context would return the game_state object that owned the
aforementioned game_board, and calling get_disp_context on that game_state would return the board
as well. So we end up in the same place.

To be complete, I also made editor::context_manager inherit from filter_context. It makes much more
sense, since it can nicely implement 2/4 of the fc functions. It also ensures resources::filter_con
is valid in the editor, in case it's needed. I'm not 100% sure it is, but since it was assigned
before (to editor_display), it's very likely.

Another side effect of the above is that get_tod_man is now implemented in a more apropos class
in the editor. Essentially, editor_display (where it was implemented before by reaching into the
context_manager) holds an editor_controller which holds a context_manager (where it's now implemented).
It wasn't even really needed in editor_display and was only called once.

Similarly, get_tod_man has been removed from game_display. Again, it was only present to "properly"
implement the function in display, which only existed because display inherited from filter_context.
And get_tod_man wasn't even needed in display, game_display, or editor_display (save for the one
aforementioned call)!!! AND in game_display, it simply dereferenced a pointer to the *actual* ToD
manager in the game_state class, WHICH IN AND OF ITSELF INHERITS FROM FILTER_CONTEXT!!!

I have removed the tod_manager pointer in game_display and replaced its use with resources::tod_manager,
which in the context of the game (where game_display) would be use, point to the same thing the class
pointer did. I suppose I could have left it, since I'm trying to remove/improve the use of the
resources pointers, but I felt it better to decouple the two classes (game_display and game_state)
slightly, especially since its main purpose for existing (overriding display::get_tod_man) no longer
exists.

Finally, some of the instances where a unit_filter object is created had to be changed to use brace
initialization or else the build failed. @celticminstrel tells me this might be because of some "most
vexing parse" issue.

Some formatting and virtual/override specifiers were also applied/added.

*huffs*
2018-01-29 15:54:01 +11:00
Jyrki Vesterinen
c8b0833b1a Make AI manager a singleton
Fixes #2372.

It turned out that the AI kept dangling references to the old Lua state,
and crashed while destroying AI contexts for destroyed sides.

The best way to avoid it is to ensure that game_state, which already owns
the Lua state, also owns the AI. That way, the AI will be destroyed before
the Lua state and a dangling reference can't stay.
2018-01-24 14:29:01 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
1ea8e0f05c Renamed wmi_container to wmi_manager
Since it's not a container anymore, it shouldn't be called such.
2017-05-19 06:50:57 +11:00
Charles Dang
2101353d36 Convert include guards to the shorter #pragma once
Turns out I mistook @celticminstrel's opinion that we should use include guards over pragma (737916e).
Since all major compilers support `#pragma once`, there's no reason not to use it.

For future mergability reasons, this excludes src/spirit_po and src/xBRZ. It also excludes src/boost-patched.
2017-05-09 19:41:37 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Celtic Minstrel
08852f6131 Rename most remaining non-GUI2 types to avoid t- prefix 2016-11-09 01:17:14 -05:00
Celtic Minstrel
22bbe5465b Rename some misc classes to drop t_ prefix 2016-11-09 01:13:17 -05:00
Celtic Minstrel
a498ceafe7 Rename WML event handling classes to remove t_ prefix 2016-11-09 01:13:17 -05:00
Charles Dang
05092ba2f6 Refactor most boost pointer related stuff to use their stdlib counterparts
This constitutes drop-in replacements for:

* boost::shared_ptr
* boost::scoped_ptr
* boost::weak_ptr
* boost::enable_shared_from_this
* boost::static_pointer_cast
* boost::dynamic_pointer_cast

This excludes boost::intrusive_ptr, except for stray includes. Refactoring that is more complicated.
2016-07-25 09:28:42 +11:00
Celtic Minstrel
d9eab21bd0 Remove redundant gamestate::bind() 2016-03-31 21:40:11 -04:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
Celtic Minstrel
bc711f5f43 Consolidate related files into subdirectories 2016-03-20 16:20:09 -04:00
Charles Dang
85430507de Remove the correct superfluous const (fixup 540df80ff5cb) 2016-02-29 00:08:12 +11:00
Charles Dang
540df80ff5 Remove superfluous const (fixup ddb873d492db) 2016-02-29 00:00:39 +11:00
Charles Dang
ddb873d492 Fixed assertion in replays with all AI sides (bug #24439) 2016-02-28 23:28:48 +11: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
gfgtdf
1aea4da8cf Attempt to fix broken [event] in [unit_type]
This reverts commit c5e31e83f171dee025b24cba662dd3c21faff684.
This reverts commit 8447ebbb88c480301624a33dd1789a533dd0150e.

[event] in [unit_type] was broken during a refactor of the gamestate
initilisation that also involved the commits above. The commits above
didn't directly cause this bug but reverting them makes fixing this bug
much easier.

We fix the bug by initilizing the game_events manager before creating the
units.
2015-12-14 16:46:05 +01:00
gfgtdf
4fa11dd3e4 partly revert 'simplify game_state construction'
It turned out that it isn't really possible to create the gamestate
without access to te gamestate from everywhere (resourcces::) the main
problem were the [effect] filters when creating units.
2015-09-30 02:58:38 +02:00
gfgtdf
5a82b19335 move end_level_data_ to gamestate class 2015-09-30 02:55:10 +02:00
gfgtdf
8b1f3c856c move undo_stack to gamestate class
the undo stack must be part of the gamestate becasue it is used for the
delayed shroud updates.
2015-09-11 22:29:44 +02:00
gfgtdf
90566fd082 store the server request counter in the snapshot
this fixes sone OOS that can happen when using the mp replay feature
(reset_gamestate)
2015-09-10 01:38:54 +02:00
gfgtdf
02990bafbf fix some compiler warnings 2015-09-09 22:15:13 +02:00
gfgtdf
7b9b85cd63 move loading_game_ member to game_state class 2015-09-09 22:15:07 +02:00
gfgtdf
ec8bf1e1f7 move reset_gamestate function (reset_replay) to play_controller 2015-09-09 17:46:10 +02:00
gfgtdf
941f00e491 move player_number_ to game_state 2015-09-09 17:46:08 +02:00
gfgtdf
8e875b8458 move init_side_done_ to game_state class 2015-09-09 17:46:06 +02:00
gfgtdf
20fafdee28 simplify game_state construction
instead of calling constructor and init you now only have to call the
constructor.

In order to make this work this commit removes the uses of
resources::gameboard/units during team construction. while doing that i
moved the unit_creator class to a new file.

This commit also removes the ticks parameter from game_startes
constructor and replaces it with a ticks() function in play_controller,
other classes were also changed to use the play_controller::ticks()
function.
2015-09-09 17:46:04 +02:00
gfgtdf
58874bdd0b remove level_ from game_state class
The intention is to remove the level config (mainly to decrease memory usage)
2015-09-09 16:31:38 +02:00
gfgtdf
12b901933a make the unit id manager a member of game_board
previously it was a singleton

the next unit id counter is part of the gamestate so it should be part of the game_state object.
2015-09-09 16:31:34 +02:00
gfgtdf
4074851203 Add synced=yes(default)/no to [set_menu_item]
Allows to add 'unsynced' wml menu hotkeys which are not sended to other
players and are also clickable off-turn.

This can for example used for help menus and similar.
2015-06-22 15:52:49 +02:00
gfgtdf
c39598e723 fix resetting of variables in replay
I also moved wml_emnu_items member out of game_data to to prevent possible problems when resetting game_data.
2015-03-27 21:19:05 +01:00
gfgtdf
3ec831493f use void 'write(config&)' instead of 'config to_config()'
this speeds up play_controller::to_config from 130 milliseconds to 80
milliseconds.
2015-01-02 00:03:01 +01:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
d42b86ad3f fixup gamestate initialization
- eliminate the "gamestate::init returns a whiteboard" hack
- store all resources used in game_events in a shared_ptr for easy
access
- add a bind function for binding the gamestate to play_controller
assets
- eliminate obsoleted functions

This fixes up commit fbcfa99c811c91538588e783dfc2d97406ab84ee
2014-12-23 05:47:03 -05:00
Chris Beck
fbcfa99c81 bug fix: whiteboard initialized before gamestate init'ed
the whiteboard needs for resources::teams.size() to have the
correct value, which only occurs after teambuilder phase, in
gamestate init.

this commit is an easy way to fix but it is pretty ugly, it will
be refactored soon.
2014-12-23 04:50:05 -05:00
Chris Beck
0fce6e7c68 add tod_manager, lua kernel to filter context
this allows to remove the resources:: links from the filter
implementations
2014-12-23 01:34:24 -05:00
Chris Beck
78c42acc48 move game_events and lua kernel into class game_state
After this commit,

- almost all data which is part of the game in the sense of being
synchronized / saved is in the game_state class
- still missing is the code / data related to determining whose
turn is next
- the game state needs to be bound to a play_controller, via its
init function. This is needed so that lua / game_events manager
callbacks can be evaluated, but future refactor should make it
unnecessary
- bug # 23071 should be fixed

TODO:
- allow the game state to manage whose turn it is, leave only UI
 details in play_controller
- expose the lua kernel via the filter_context interface, and
make filters use it instead of resources
- make a proper copy ctor for game state, and improve encapsulation
2014-12-22 23:21:20 -05:00