These will be changed to conditionally include system Lua headers,
e.g. "lua.h", instead of submodule Lua headers, e.g. "module/lua/lua.h".
If a header named "lua.h" includes "lua.h", the build will fail due to
recursion.
This can't be solved using angle brackets to include system headers,
because macos builds won't find them:
In file included from /Users/runner/work/wesnoth/wesnoth/src/ai/registry.cpp:30:
In file included from /Users/runner/work/wesnoth/wesnoth/src/ai/composite/aspect.hpp:24:
In file included from /Users/runner/work/wesnoth/wesnoth/src/ai/lua/lua_object.hpp:25:
/Users/runner/work/wesnoth/wesnoth/src/lua/lua.h:4:14: error: 'lua.h' file not found with <angled> include; use "quotes" instead
#include <lua.h>
^~~~~~~
"lua.h"
Renamed with (requires GNU sed):
$ for f in src/lua/*.h; do
> git mv "${f}" "src/lua/wrapper_${f#src/lua/}";
> done
$ git grep -El -- '#[ \t]*include[ \t]+"lua/[^"]+[.]h"' src | \
> xargs sed -Ei -- '
> s|(#[ \t]*include[ \t]+"lua/)(lua[.]h")( )?|\1wrapper_\2|;
> s|(#[ \t]*include[ \t]+"lua/)(lualib[.]h")( )?|\1wrapper_\2|;
> s|(#[ \t]*include[ \t]+"lua/)(lauxlib[.]h")( )?|\1wrapper_\2|;
> '
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.
Since MacOS doesn't properly support std::variant (it has problems with std::visit specifically) unless it targets MacOS 10.14 or later, this adds a wrapper class that uses std::variant and friends on all platforms except MacOS, where boost::variant is used. The USING_BOOST_VARIANT define is then defined on MacOS and should be used to guard for code (such as inheriting from boost::static_visitor) that isn't needed with std::variant.
unit::upkeep_parser_visitor is still unconditionally boost::variant-compatible since it's used by const_attribute_value::apply_visitor, and configs still use boost::variant under the hood.
Additionally, these visitors are used in multiple places, so I can't convert them to lambas in-class.
Finally, I used brace-init for the upkeep types and visitors to make it clearer these are not functions.
As for the static_cast changes, for some reason mingw had issues converting double or long long int to the upkeep variant (which keeps an int specifically). No idea why it had no problem dealing with this with boost::variant.
This doesn't touch cases where `std::tie` was used with `std::ignore`, since there isn't a way to
ignore a variable in structured bindings and choosing a random variable name might trigger unused
variable warnings on CI (will have to confirm that, though).
A property cannot returns multiple values, the old code never worked.
Also the value returned by unit.loc the getter is now of the same type as
taken by the unit.loc getter.
this in particular fixes#5098
This means that they are now added to the units module by default in C++, and only duplicated to the Wesnoth module in Lua.
Some additional functions were moved:
- wesnoth.create_unit -> wesnoth.units.create
- wesnoth.get_units -> wesnoth.units.find
- wesnoth.get_unit -> wesnoth.units.get
Deprecated wesnoth.get_recall_units in favour of wesnoth.get_units, which has gained the ability to match units on the recall list if x="recall" or y="recall" appears in the filter at toplevel.
The wesnoth.units module now acts like a metatable for unit userdata, meaning that any functions (or attributes) added to the module will be visible through any unit.
Turns out that commit broke TC on unit images in messages since it broke the equality
check in lua_unit.cpp. Added the XBRZ IPF as part of the Lua unit portrait attribute
instead.
I *think* this is the proper place to do it.
(cherry picked from commit fab229b5e8)
This reverts commit ef60deaa2b.
@ln-zookeeper pointed out that units with negative HP are documented in
the wiki, and thus disallowing them is an API
change.
(cherry-picked from commit 0200487aad)
Turns out that commit broke TC on unit images in messages since it broke the equality
check in lua_unit.cpp. Added the XBRZ IPF as part of the Lua unit portrait attribute
instead.
I *think* this is the proper place to do it.
(cherry-picked from commit 98ed802290)
Celticminstrel recommends restricting this to off-map units until we can be sure
changing the ID is safe in all contexts. I don't see why not, though... but this
should be enough for the situation described in the bug (a unit made with copy_unit).