26 Commits

Author SHA1 Message Date
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
gfgtdf
f8bd32eb15 Deploy and refactor config::optional_child
Previously the config class had an operator bool and
it was a common pattern to use if(const config& = cfg.child(..)).
While this pattern was nice to use. It has severe drawbacks, in
particular it was unclear whether a function that took a config&
parameter allowed "invalid" configs, while most functions
did not, there were some that did. Furtheremore it lead to a few
buggy codes that were unconvered by this change (Not fixed though!),
in particular codes that tested local config objects that were
not references to being invalid, which could never be the case.
This commits replaces those with just `true` in order to not
change behaviour.

Some obvious cases were also removed including for example
things like `assert(config());` There is ony case in the ai code
that i'm not 100% sure of where one implementation of a virtual
function checked for an invalid config and another one that didn't.

With this, all code that check for a config child to be
present now uses config::optional_child which returns an object
that behaves similar to optional<(const) config&>, so it throws
on invalid dereferencing. But it also has operator[string] for
convinience, in particular to make is similary
easy to use the the previous `if (config& = .. child())`.
Also it has a tool DEBUG_CONFIG which tests whether all
optional_config values are checked before they are derefereneced.

Another method manditory_child was
added that throws when the key is not found, which replaces all
occurances of child() that did not check whether the result was
valid. This was neccecary (this= adding a new method instead of
renaming .child) to keep track of converted changes, and be sure
no occurances of child() were accidentally changed to the
throwing version.

We might want to rename one of mandatory_child or optional_child
to just child later. Not sure which one yet. I think it's better
to keep it in the current state (no config::child() ) for a while
though, so that people that currently used child() in their open
prs or other work get an error and not wrongly rely on the previous
behviour of config::child.

The interface of vconfig was not changed in this commit.
2023-04-03 00:39:12 +02:00
gfgtdf
d0176732a4 Fix redo error after reloading #7253
The code was checking for [commands] instead of [command]
when loading savefiles.
2023-03-20 01:06:40 +01:00
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
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
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
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Celtic Minstrel
eb0947c863 Some improvements to the new Lua music API
- Allow removing a track by index and fixup the "set track" interface
- Commit music changes only after event completes, not after any control=flow tag is executed
- Allow inserting a track into the middle of the playlist
- Allow assigning a config to an existing track to overwrite it
- Use std::find when checking for duplicate tracks
2017-04-27 17:09:16 -04:00
Charles Dang
55481c9949 Added a bunch of missing copyright notices
[ci_skip]
2017-03-20 11:59:06 +11:00
gfgtdf
532e4c7de6 use the original action codepath when redoding
this removes all those redo() functions for each undo actions. Instead,
the game now just uses the replaywml that was taken from the replay when
undoing the action to redo it by calling the usual synced:context::run
function, just like when that action was executed for the first time.

The main advantage is that [on_redo] is no longer nesasary since the
game will ow just fire the action related wml events again when redoing
the actions.

See also http://gna.org/bugs/?25472
2017-02-24 00:46:30 +01:00
Charles Dang
ed15163b95 Convert uses of resources::units to resources::gameboard->units()
This mirrors the similar conversion of resources::teams in 6235e18bbd127.
2016-12-02 12:00:08 +11:00
gfgtdf
d11974ccc5 fix unit having wrong locations in on undo/redo handler
this code caused the unit location stored in the unit structure to be different from the real unit position on the map (as stored in the unit_map structure), which lead to bugs in the executed wml later.
2016-11-23 23:24:15 +01:00
Gregory A Lundberg
d31555f8cf Pedantic includes
Change all includes to start at the base instead of assuming the directory where included from.

This makes it more apparent exactly which header has been included, since many have the same name.

This also allows moving all header files out of the src directory.
2016-11-11 11:00:22 -06:00
Gregory A Lundberg
86adfc47f8 GCC complains about float/double and useless cast 2016-10-16 10:55:09 -05:00
gfgtdf
553ac0fd05 add wml_x/y() getter & setter in map_location 2016-09-16 22:35:41 +02:00
Celtic Minstrel
dc3d22a5e4 Merge pull request #710 from spixi/call_events_by_id
Allow firing an event by id instead of name.
2016-07-30 01:21:12 -04: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
Spixi
5588642c81 Allow firing an event by id instead of name. 2016-07-23 12:23:19 +02:00
Charles Dang
2d0721185f Assigned some initial variable values to silence some warnings 2016-04-08 04:22:57 +11:00
Celtic Minstrel
4af12203d8 [on_undo] and [on_redo] now get a snapshot of the event context
This means they can access auto-stored variables.
However, using [unstore_unit] for $unit or $second_unit is not recommended.
Also, $unit.x and $unit.y may not be the same as they were during the original event.
(The same with $second_unit)
2016-04-05 21:21:48 -04:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -04: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
6010455f56 add [on_undo]/[on_redo] actionwml
[on_undo]/[on_redo] contains tags that are executed when undoing the
current actions.
2015-09-11 22:33:32 +02:00
gfgtdf
138f7c92c4 refactor undo_action class
First we split the undo_ation into subclasses (undo_action_base, undo_action
and shroud_clearing_action) so that undo actions that don't clear shroud don't
contain the route and view_info data.
Also the non undoable actions now don't need to implement undo() and redo()

Second we move the undo action classes to different files.
2015-05-20 00:50:26 +02:00