Commit graph

76 commits

Author SHA1 Message Date
P. J. McDermott
b5d073a2ad Rename src/lua/*.h to src/lua/wrapper_*.h
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|;
    > '
2024-02-11 23:21:15 -06:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Charles Dang
48c44b4d34 Removed last usecase of XBRZ 2023-12-27 16:40:43 -05:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Tommy
1fe87c4e24 Remove "<< '\n';" from log lines 2022-07-20 15:20:57 +12:00
Tommy
1c25ebdfa2 Remove std::endl from log lines, now that it's added automatically 2022-07-20 15:20:57 +12:00
Pentarctagon
1a3498cbf3 Rename nowarn/ to lua/
Also cleanup the includes.
2022-03-09 15:01:37 -06:00
Pentarctagon
dd947db289 Avoid lua build warning without altering source code. 2022-03-09 15:01:37 -06:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
c4c292fa3b Replace all remaining usages if MAKE_ENUM. 2022-03-03 21:23:02 -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
Celtic Minstrel
f5e9a2cac6 Lua API: Add vision and jamming as unit attributes 2021-07-07 01:32:05 -04:00
Charles Dang
ee28ac0e26
Unit: converted upkeep handling to std::variant (#5459)
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.
2021-01-19 14:24:05 +11:00
Charles Dang
b54ce01134 Deployed structured bindings
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).
2021-01-18 09:43:59 +11:00
gfgtdf
2435fc425b
fix lua unit.loc and unit.goto
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
2020-08-26 01:20:30 +02:00
gfgtdf
194b903918 fewer units/types.hpp includes 2020-06-20 02:21:14 +02:00
Celtic Minstrel
dc0d389a22 Make unit.undead_variation not write-only 2019-11-16 17:57:48 -05:00
Celtic Minstrel
eab3692372 Deprecate unit.petrified 2019-11-16 17:46:28 -05:00
Celtic Minstrel
feeb57934d Allow writing to unit.loc on off-map units 2019-11-16 17:28:39 -05:00
Celtic Minstrel
cd6283f8db Add a few more tags to the [modify_unit] optimized path 2019-11-16 15:14:09 -05:00
Celtic Minstrel
1f36590e80 Add a few more attributes to the [modify_unit] optimized path 2019-11-16 15:14:09 -05:00
Celtic Minstrel
4dc986f028 Lua: Flip functions moved to the units module
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.
2019-11-15 22:39:08 -05:00
Celtic Minstrel
8374306009 Add six more known attributes to the [modify_unit] optimized path 2019-11-12 23:03:55 -05:00
josteph
8caf887088 lua: Make unit.__tostring report units on recall lists 2019-10-16 04:13:30 +00:00
josteph
a67b9d07ed lua: Add __tostring to units
Makes it easier to test SUFs with wesnoth.get_units{} in the lua console.
2019-10-16 04:13:30 +00:00
Charles Dang
b7fe28c03e Fixup 601c67d970
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)
2018-10-28 02:52:59 +00:00
gfgtdf
783dc0767b more modifiable attributes to lua units 2018-10-27 17:43:11 +02:00
gfgtdf
5d267578f4 add goto_x/y to unit lua proxy 2018-10-21 17:42:24 +02:00
gfgtdf
6bdbcc1644 make max_moves a modifiable unit property 2018-10-21 03:06:09 +02:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
Jyrki Vesterinen
cd2f8d21b8 Revert "Disallow units with negative HP"
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)
2018-10-07 03:21:55 +00:00
Jyrki Vesterinen
a81e06d6fc Disallow units with negative HP
Damage calculation code can't tolerate presence of such units.

Fixes #3042.

(cherry-picked from commit ef60deaa2b)
2018-10-07 03:20:43 +00:00
Charles Dang
6092803222 Revert "Utilized 2x xBRZ scaling for portraitless units in game dialog"
This reverts commit 601c67d970 and 98ed802290.

(cherry-picked from commit 28b1ab2861)
2018-10-07 03:19:25 +00:00
Charles Dang
33be7d5a8c Fixup 601c67d970
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)
2018-10-07 03:19:23 +00:00
Charles Dang
e270a7c665 Formatting cleanup: > > to '>>`
Allowed since C++11. Might as well use it everywhere.
2018-02-21 12:11:21 +11:00
lundberg
7ba6c80a24 Fix variable hides local variable warning 2018-02-09 12:51:41 -06:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11:00
Charles Dang
c1cfcdb472 Lua: don't allow setting a unit's x,y coordinated to an off-map location 2018-02-04 12:56:52 +11:00
Charles Dang
cfd0f774e4 Rework 883b4f1856 (*much* simpler method) 2018-02-04 12:56:52 +11:00
Charles Dang
883b4f1856 Expand 13cacd1d1e by allowing unit.loc = {x, y} 2018-02-04 12:29:20 +11:00
Charles Dang
7c49995981 Fixup 13cacd1 (use luaL_checkinteger over luaL_checknumber) 2018-02-04 04:21:41 +11:00
Charles Dang
40da35d8de Made use of std::tie for certain unit_map operations 2018-02-04 04:20:22 +11:00
Charles Dang
13cacd1d1e Allow moving on-map units by setting unit.x an unit.y fields. 2018-02-04 03:08:29 +11:00
Charles Dang
a012e7f0c3 Lua/Unit: allow modifying of id field for Lua-only units (fixes #2433)
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).
2018-02-04 02:07:19 +11:00
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Jeffrey 'Sigurd' Westcoat
6aada966d3 Fixup lua unit.upkeep getter (#1816) 2017-06-23 20:19:33 -04:00
Celtic Minstrel
bb4402489c Lua Units: Fix incorrect argument referenced from an error message 2017-05-11 16:00:54 -04:00
Celtic Minstrel
263aadcaa0 Lua: Allow clearing unit and side variables 2017-05-11 16:00:53 -04:00