31 Commits

Author SHA1 Message Date
Pentarctagon
8e2996661f
Prevents logging of duplicate deprecation messages and messages missing timestamps.
Fixes #5942
2021-07-24 18:51:42 -05:00
Celtic Minstrel
d507833199 Make the log_domain constructor explicit
Implicitly constructing a log_domain from a string has the effect of resetting its severity to 1 (or whatever severity was passed to the constructor). This is probably fine when it's declared as a file static, but no good if passing the log_domain to a log_scope2() or dont_log() call.
2021-04-15 23:23:42 -04: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
Celtic Minstrel
d422f2172c Fixup last commit
(cherry-picked from commit cf385537c234f00e34dc9892b0acd6ecf302aea5)
2018-10-07 03:18:10 +00:00
Celtic Minstrel
e92c97c18b Don't bother trying to standardize event name if there isn't one
(cherry-picked from commit f7cc1842bb630bd8c642ea025124ddbfa1c57433)
2018-10-07 03:18:10 +00:00
Celtic Minstrel
6aaf275a4e Don't show a message for missing name in [event] if it has an id
(cherry-picked from commit e317f346e8d9c4363075532efb762cc42646d42f)
2018-10-07 03:18:10 +00:00
Charles Dang
c916a85d1e Game Events: some safeguards
* Don't register an empty event
* Raise a WML error if a event is missing a name= key (the wiki declares it mandatory)
2018-02-02 08:34:15 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
88b0fe5953 Further reworking of event iteration interface
Fixes #2312. Turns out constructing a list of matching handlers breaks some undocumented
behavior, namely events being executed in the order they're added (usually the order in
which they appear in the WML). It also broke certain variable substitution by moving variable
interpolation wholly before any event execution, as opposed to between each event.

This commit implements an even simpler method: simply iterating through every registered
handler in order, checking for a name match on each one, and if it passes, immediately
executing the provided function. Cleanup will only occur once the toplevel call to
execute_on_events is completed.

This commit also removes the immediately cleanup upon removing a handler. This should
ensure (I didn't test explicitly, but from other incidental issues I'm sure this is the
case) the size of the main vector doesn't change during iteration.

I also changed the pre-add standardization code to only affect event names without variables.
Variable names are standardized later after variable substitution.
2018-01-11 13:12:28 -05:00
Charles Dang
35e5cdf291 Game Events: include cleanup
* Removed a ton of unnecessary includes
* Moved handler type aliases to fwd.hpp
* Added copyright notice to fwd.hpp
2017-12-01 14:52:39 +11:00
Charles Dang
238a994429 Fixup 2c12d1328ba6fc6 (don't try to dereference a nullptr) 2017-12-01 10:57:57 +11:00
Charles Dang
e5cea35169 Game Events: ensure event names are properly standardized in the config
This ensures all names are always valid to use in by-name lookup and are stored consistently.

Also fixes a potential issue in 2c12d1328ba6. I should have called standardize_name on each
name entry in the cleanup phase like when done in the registration phase, but this commit
ensures that's not needed anymore.
2017-11-30 11:44:06 +11:00
Charles Dang
fb5fd3f3c4 Game Events: made use of some emplace_back when constructing handlers
And added a clarifying comment about types.
2017-11-30 10:06:46 +11:00
Charles Dang
2c12d1328b Game Events: fixed a few oversights in 056d7ac8f88c
* Fixed assertion failure when removing single-use custom events. Not actually something
  broken, I just forgot to add a "not already disabled" check when doing so since I added
  that assertion in event_handler::disable.
* Added a message to the aforementioned assertion.
* Ensure handler cleanup actually happens when removing custom events.
* Account for events with multiple names in cleanup.
2017-11-30 09:56:02 +11:00
Charles Dang
056d7ac8f8 Game Events: refactored event handler storage
This throws out the custom smart_list class in favor of a plain std::list. It also greatly simplifies
a few things. First, event handlers no longer remove themselves from the main list in event_handlers.
Now they just flag themselves as disabled (which means they will never execute once marked) and cleaned
up later in a newly added cleanup stage. This means a handler no longer needs to keep its index in the
active handler vector.

This removal of reliance on indices also means I could add the aforementioned cleanup stage. With the
smart_list code, event handlers were never actually removed from the active vector, nor any weak_ptrs
pointing to them removed either. This wasn't exactly a problem, since the handlers were stored via
shared_ptrs which would then simply be null after one deleted itself. Still, it's cleaner to drop any
invalid ones (and unlockable weak_ptrs) from any relevant containers. I've opted to do this in
manager::execute_on_events. Seems a good enough place as any.

The net result of this is the code is much cleaner. We're able to get rid of a bunch of unnecessary
feelers into various classes. This also makes the manager::iteration dereference code a lot easier
to understand. There certainly could be further refactoring, but I think this is a good start.
2017-11-29 08:04:08 +11:00
Charles Dang
79ffbbe9b4 Game Events: include manager in pump header to avoid having its include in so many places 2017-05-21 07:52:42 +11:00
Charles Dang
c02968ec2d Game Events/Manager: minor code simplification 2017-05-20 08:56:52 +11:00
Charles Dang
c3f0e1e15b Game Events: reformatted manager code 2017-05-20 08:56:51 +11:00
Charles Dang
2b5d1b80d6 Simplify event_handlers::standardize_name with boost string utils 2017-05-18 01:17:03 +11:00
Charles Dang
731e6916b8 Cleaned up resources.hpp includes
Includes one change of the source of a CVideo variable to remove a resources usecase.
2017-03-20 11:53:51 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
4d48ed1319 Cleaned up util.hpp includes 2016-12-08 14:21:18 +11:00
Celtic Minstrel
a498ceafe7 Rename WML event handling classes to remove t_ prefix 2016-11-09 01:13:17 -05:00
Charles Dang
8c92a9ee8e Formatting cleanup: moved const qualifiers before type names 2016-10-31 01:04:18 +11:00
Spixi
5588642c81 Allow firing an event by id instead of name. 2016-07-23 12:23:19 +02:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -04:00
Celtic Minstrel
fe0df45947 Consolidate formula and hotkey files in corresponding dirs 2016-03-20 16:15:50 -04:00
Celtic Minstrel
8e588972f4 Ensure logging objects are constructed on first used
This makes it safe to log messages during static initialization.
2016-03-19 21:12:11 -04: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
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
aff3cb8da5 split game_events::manager code into separate files 2014-12-14 20:50:39 -05:00