414 Commits

Author SHA1 Message Date
Charles Dang
6e2f3e099e Removed utils/functional.hpp 2020-12-04 15:30:46 +11:00
gfgtdf
c544d1beec fix duplicated events from era and modification 2020-06-10 20:26:50 +02:00
gfgtdf
528dbccd94
support scenario files in map_file (#4804)
* support scenario files in map_file

Now a scenario generated by the scenario editor can be loaded
just like a simple map file.

fixes #4803
2020-03-15 13:24:26 +01:00
Charles Dang
4a3be684f4 Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the same command from 9b7b1751fdda.

Excludes:
* lua/
* spirit_po/
2019-08-04 22:31:10 +11:00
Jyrki Vesterinen
b879702545 Config::valid_tag(): replace std::isalnum() with a manual check 2019-01-19 18:11:48 +02:00
Jyrki Vesterinen
ccedb51101 WML attribute names must also be valid tag names
"_" isn't a valid attribute name, either.

I also made config::validate_wml() check attribute names in addition to
just the tag names.
2019-01-19 17:29:39 +02:00
Jyrki Vesterinen
cb2a236dbf Allow WML tags with leading underscore (#3877)
@gfgtdf pointed out that the WML parser can deal with such tags after all.
I had missed that when I implemented the check that the game state is
valid WML before saving it (commit 3bc36efa5898a95ce793195e24b4dee1b546c222).

Such tags are still disallowed in the Lua API because allowing them would
be an API change.
2019-01-18 22:15:20 +02:00
gfgtdf
8160d9add4
fixup 'fix config::add_child_at_total' 2018-12-06 16:45:46 +01:00
gfgtdf
f1dc5de631
fix config::add_child_at_total
this in particular fixes a bug where events were put in disorder at [load_resource]
2018-12-06 15:28:40 +01:00
gfgtdf
36bf3a0107
fix [load_resouce] bug #3757
thisfixesan assertion failure when using [load_resource]
2018-12-06 01:37:18 +01:00
gfgtdf
7599746b25 put [resource] before other content (again); fixes #3345
Now content that is loaded via [load_resource] is placed to the position
where the [load_resource] was. This fixes a problem where previously one could
not use lua variables/functions created by the [resource][lua] because the
engine would put the [lua] tags from the [resource] after the [resource] from the
scenario.

This time it uses size_t indicies instad of vector iterators to prevent
possible bugs arisong from invalidating iterators when the size of the
vector changes.

This reverts commit b3e1680f886ec27c29150912bb27949d7cdd7f6e.

In the long run i think it might actually be better to allow [event] and
[lua] to have a order/priority attribute similar to lua on_event events.
Then this commit would probably not be needed anymore.
2018-10-18 19:25:49 +02:00
Jyrki Vesterinen
b3e1680f88 Revert "put [resource] before other content; fixes #3345"
This reverts commit 706740220957a9313909f5cc358ba5aba3bf4118.

The commit used the `pos` iterator after invalidating
it (passing an iterator to `config::add_child_at()`
invalidates it), resulting in undefined behavior.
2018-10-17 19:53:09 +03:00
gfgtdf
7067402209 put [resource] before other content; fixes #3345
Now content that is loaded via [load_resource] is placed to the position
where the [load_resource] was. This fixes a problem where previously one could
not use lua variables/functions created by the [resource][lua] because the
engine would put the [lua] tags from the [resource] after the [resource] from the
scenario.

(cherry-picked from commit 1ac635ec63e775dcd1aa90d04b9adf3f061ef476)
2018-10-07 03:24:42 +00:00
Martin Hrubý
96bbebb514 Fix building with Xcode 10 (#3460)
Resolves #3458.

(cherry-picked from commit 50301f84e33d828c39835bc47f04dd1107631960)
2018-10-07 03:24:17 +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
Charles Dang
f05ca6536d Use '\t' instead of static_cast<char>(9)
(cherry-picked from commit 4c29a0dd5895784b94a2393feddf0613742f3a0c)
2018-10-07 03:23:25 +00:00
Charles Dang
ee619b999f Convert a few remaining C-style casts (for char) too static_cast
(cherry-picked from commit ce85c170200aee86ebd0b7a98ef7102a03e62dd5)
2018-10-07 03:23:25 +00:00
Charles Dang
eb9a219c5f Used std::string::front() and back() in more places
(cherry-picked from commit ed8a8a48f70174dae128afbdb07b1488b5a8d1d9)
2018-10-07 03:21:54 +00:00
Celtic Minstrel
6c068684d6 Add a way in [filter_wml] to match key values against a glob
(cherry-picked from commit 5ee9b094708e456e94e1b6ac2309bccac3d03a9d)
2018-10-07 03:18:38 +00:00
Celtic Minstrel
165e8a63fa Fix [filter_wml] implementation so that [or] tags actually work
(cherry-picked from commit b483d96f500827ccacc78f3c2e89fc6690a3d2df)
2018-10-07 03:18:38 +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
Celtic Minstrel
82fd82d534 Accept [and] and [or] in [filter_wml] 2018-03-16 17:10:59 +11:00
Charles Dang
e117e2cede Config: fixup 5fc9d8d1739576302fc6da9c90c13cbffd0f023b
No operator+ is present is config_key_type is boost::string_view.
2018-03-05 13:56:36 +11:00
Celtic Minstrel
b0559eb0bf Use an enum for deprecation levels (C++ only)
This is not done for Lua and WML due to some complications.
It could still be done for them later, if desired.
2018-03-04 21:21:33 -05:00
Celtic Minstrel
5fc9d8d173 Use new deprecated_message() function wherever possible (C++)
This also covers handling of legacy DescriptionWML for [set_menu_item],
and tweaks its handling in the other cases (mainly [multiplayer_side]).

I added the next_dev_version constant intending to use it, but then
decided not to do so; however I left it in in case someone finds it useful.
2018-03-04 21:21:33 -05:00
Charles Dang
a2eb75db6c Config: fixed possibly unspecified behavior when using append_children_by_move 2018-02-21 16:41:31 +11:00
Charles Dang
7b4f98075c Config: optimized merge_children and merge_children_by_attribute
This should mean a performance boost when the game config manager processes [units] tags.
Since they're all merged into one, it's very likely whole addon's worth of unit type configs
were being copied (twice)! Worth noting that a lot of addons use the tag amendment syntax
([+units]), but it's unlikely that meant no copying was done at all.
2018-02-21 16:40:58 +11:00
Charles Dang
35d9b30463 Config: fixed typo in function name
[ci skip]
2018-02-21 15:17:54 +11:00
Charles Dang
a77652986a Used std::distance instead of iterator arithmetic when possible 2018-02-20 11:33:52 +11:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11: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
69f5d9c260 Made more use of std::isalnum and std::isalpha (std::locale versions)
I didn't also deploy std::isdigit since @jyrkive said he feels digit comparison is fast
and simple enough.
2018-02-02 17:42:06 +11:00
Jyrki Vesterinen
fbb0e0229c Improve consistency of WML name validation functions
* moved the new function next to valid_id()
* renamed to valid_tag(), and renamed valid_id() to valid_attribute()
* removed unnecessary parentheses I forgot in
* changed the name of valid_id()'s parameter from "id" to "name"
* changed WML parser to use valid_tag() when it validates tag names

Thanks to @CelticMinstrel who told me about config::valid_id().
2018-01-19 20:27:53 +02:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Jyrki Vesterinen
7aa39dc451 Go back to std::isalnum()
It turned out that it works fine as long as it's called with a char
rather than unsigned char. (But to add to the confusion, the other
variant of the function in <cctype> *requires* that cast.)
2018-01-18 10:05:24 +02:00
Jyrki Vesterinen
19e17e9417 Replace std::isalnum() with a hand-rolled implementation
The function seems to just throw std::bad_cast() in libstdc++ and libc++.
Fortunately it's very easy to write our own implementation instead.

Thanks to @Pentarctagon for the stack trace.
2018-01-18 09:41:57 +02:00
Jyrki Vesterinen
3bc36efa58 Refuse to save if game state can't be represented as valid WML (#2375)
Such a save file can't be loaded anyway.
This way, at least the player can't overwrite an existing, working save
with one that cannot be loaded.
2018-01-17 21:05:44 +02:00
gfgtdf
652270e045 fix options not working if a scenairo uses [variables] in [scenario] 2017-12-02 19:18:32 +01:00
Charles Dang
192fbdc173 Config: added function to move children from one config to another
The regular append_children function makes a copy of the applicable child tags. This moves them
from the source to the destination configs. Do note it leaves the source tags empty.
2017-11-09 21:11:59 +11:00
Charles Dang
b5934273ad Added non-member swap() functions for classes with member swap() functions
This is to enable them to work with std::swap.
2017-09-03 01:07:06 +11:00
Jyrki Vesterinen
59d59bb9f9 Add config::remove_children()
The function removes children for which the provided predicate returns
true. I didn't need it in the end, but it may still be useful for someone
else.
2017-08-10 20:32:25 +03:00
Charles Dang
932677d36e Config: more range-for 2017-05-22 11:06:09 +11:00
Charles Dang
1707070d6f Reformat config and config attribute code 2017-05-22 10:49:13 +11:00
Charles Dang
96ea0eb6b9 Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the command used in 9b7b1751fdda, excluding results in lua/ and spirit_po/.

Also, once again, for some reason actions/vision.hpp gets registered as massively changed
(similar to f11fa0652af0) despite nothing really having changed at all.
2017-05-16 06:46:43 +11:00
Charles Dang
849860a0bb Deployed const_clone alias templates 2017-05-16 03:15:20 +11:00
gfgtdf
514ec83ada remvoe now unused config_clear_state 2017-05-15 02:27:18 +02:00
gfgtdf
13b00f73ff move config::attribte_value out of config.?pp
this has 2 advantages:
1) we can now forwaed declare the class config_attribute_value without
including config.hpp
2) the config.?pp files are a little easier to read.
2017-05-15 02:27:18 +02:00
gfgtdf
d06e9c30b2 use unique_ptr in config::child_map 2017-05-15 02:27:16 +02:00
gfgtdf
b6e398fdb1 fix configs member variables not following our naming convention 2017-05-15 02:27:15 +02:00
gfgtdf
e7d2108ba6 deploy a range for 2017-05-12 19:46:08 +02:00