Commit graph

83373 commits

Author SHA1 Message Date
OrekOrek
4e2cd280ab
HttT S11 Make the objective clearer (#8326)
* Konrad on a sand hex ends the scenario (previously he needed to reach flat terrain)
* Adjust the map so there's more water before reaching the sand hexes.
2024-02-12 12:29:53 +01:00
pentarctagon
5d7b25b302 add tooltip for start game hotkey 2024-02-11 23:44:47 -06:00
P. J. McDermott
f36e611ab6 Test CMake's system Lua option in Docker CI 2024-02-11 23:21:15 -06:00
P. J. McDermott
69fa5c199e Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf17.

Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1c) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't.  It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).

Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.

Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md.  The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4 and make even less sense now with preceding commits for
updating CMake modules.
2024-02-11 23:21:15 -06:00
P. J. McDermott
bfaabe0831 Modify FindLua.cmake to find Lua compiled as C++ 2024-02-11 23:21:15 -06:00
P. J. McDermott
473a4d19bd Add FindLua.cmake and include()d modules
https://gitlab.kitware.com/cmake/cmake/-/raw/3e2094fb/Modules/FindLua.cmake
https://gitlab.kitware.com/cmake/cmake/-/raw/07f0a788/Modules/FindPackageHandleStandardArgs.cmake
https://gitlab.kitware.com/cmake/cmake/-/raw/4ecfd1a7/Modules/FindPackageMessage.cmake
2024-02-11 23:21:15 -06:00
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
P. J. McDermott
78d3b0c05c Store jailbreak exceptions in constructors, not in LUAI_TRY()
LUAI_TRY() is an internal part of Lua that may not exist forever, and
reliance on overriding it prevents the use of system copies of Lua.

Document in lua_jailbreak_exception this requirement to call
this->store() in derived class constructors.

Also, count the luaW_pcall_internal() recursion depth and store and
rethrow jailbreak exceptions until the recursion depth reaches 0,
because:

 1. luaW_pcall_internal() sometimes runs recursively (C++ calls Lua
    calls C++ calls Lua calls C++), so the middle C++ layer needs to
    rethrow exceptions instead of clearing them.  LUAI_TRY() previously
    stored them each time, but now lua_jailbreak_exception::rethrow()
    needs to know when not to clear().

 2. Jailbreak exceptions can be thrown while no Lua code is running.
    Now that constructors store() all exceptions instead of LUAI_TRY()
    storing only those caught by Lua, lua_jailbreak_exception::store()
    needs to know when not to store them.  Otherwise, for example,
    leaving a game to return to the menu while no Lua code is running
    throws and needlessly stores an exception that isn't cleared, with
    two possible effects:

     a. If another jailbreak exception is thrown and the constructor
        tries to store it, we abort from assert() because one is already
        stored.

     b. Otherwise, if luaW_pcall_internal() runs without a new jailbreak
        exception being thrown, the stored one is rethrown and handled a
        second time (e.g. immediately leaving a new game).
2024-02-11 23:21:15 -06:00
P. J. McDermott
a5b8b559af Mark lua_jailbreak_exception's derived classes and functions as final
The documentation for IMPLEMENT_LUA_JAILBREAK_EXCEPTION() says, "This
macro needs to be placed in the definition of the most derived class,
which uses lua_jailbreak_exception as baseclass."  Storing exceptions
in constructors will require this to mean that classes that derive
from lua_jailbreak_exception must be treated as final, because of the
"assert(!jailbreak_exception);" in lua_jailbreak_exception::store().
Specifying overridden clone() and execute() functions as final in
IMPLEMENT_LUA_JAILBREAK_EXCEPTION() enforces this.

leavegame_wesnothd_error is derived from a class that derives from
lua_jailbreak_exception, so also fix this inheritance and a block that
might catch leavegame_wesnothd_error.
2024-02-11 23:21:15 -06:00
P. J. McDermott
4b5c1696ee Remove old LUA_COMPAT_* macros from src/wesnoth_lua_config.h
These macros were in Lua 5.3 but have been removed in Lua 5.4:
https://github.com/lua/lua/commit/34b00c1
2024-02-11 23:21:15 -06:00
P. J. McDermott
5a0a3d0d72 Log all Lua errors
Wesnoth's Lua submodule is built with LUAI_TRY() defined to catch a
std::exception, push its what() string onto the Lua stack, and call the
error handler given via lua_pcall() (which push_error_handler() and
luaW_pcall_internal() set to Lua's debug.traceback()) or in Lua via
xpcall().

If lua_pcall() returns an error code, luaW_pcall() logs an error, but
only if it finds an exception string on the stack (due to an apparent
oversight in commit 3820b14eb8, version 1.9.5) and that exception
string doesn't contain "~lua:" (oversight in commit e5562a1b52,
version 1.9.0).  But stock LUAI_TRY() doesn't push an exception string
onto the stack, so luaW_pcall() won't log the error.

Either way, luaW_pcall() always returns false when lua_pcall() returns
an error, so the calling C++ code works the same with either Wesnoth
or stock LUAI_TRY().  The only consequence is that strict mode doesn't
break, because the error isn't logged.

This will cause the filter_formula_unit_error test to return a result
of "PASS TEST (0)" instead of "BROKE STRICT (PASS) (9)" with stock
LUAI_TRY().  In other words, the test passes normally either way, but
strict mode doesn't break.

Fix this by making luaW_pcall() log all errors, including those without
exception strings on the stack, as well as those with exception strings
containing "~lua:".
2024-02-11 23:21:15 -06:00
P. J. McDermott
83ad348037 Wrap Lua pcall() and xpcall() to rethrow jailbreak exceptions
Jailbreak exceptions thrown in Wesnoth C++ code called under Lua pcall()
or xpcall() aren't handled immediately, allowing such exceptions to
potentially accumulate and cause a failed assertion.

For example, if a user tries to quit while Lua code is running under
pcall() or xpcall(), LUAI_TRY() stores and consumes the jailbreak
exception and the rest of the Lua code continues running.  If the user
tries to quit again before the Lua code finishes, LUAI_TRY() attempts to
store another jailbreak exception, which causes wesnoth to abort.

This is a longstanding bug (since jailbreak exceptions were introduced
in commit d6512a0ef5, version 1.9.5) that could affect World Conquest
and 16 of the 588 addons in 1.16 and 7 of the 141 in 1.17.

Fix this by wrapping pcall() and xpcall() to rethrow jailbreak
exceptions.
2024-02-11 23:21:15 -06:00
pentarctagon
bcec952e1e Fix duplicate mod ids breaking mod selection
Fixes #6780
2024-02-11 14:38:14 -06:00
Steve Cotton
9146db7d5d EI S04b: Fix Hahid's name having a trailing comma
This doesn't change a translatable string, it removes a comma
that was immediately after the translatable string.
2024-02-11 16:55:20 +01:00
Steve Cotton
862f0af9f8 Removing auto-generated text from en@shaw translation
This update is just removing auto-generated text. When the empty .po files were
created, the tool filled in msgstrs for both en_GB and en@shaw. However, while
Shavian is English it uses a different alphabet with phonetic spellings.
2024-02-11 13:10:58 +01:00
Toom
925dd0d3a4
Add a composite hero/leader ellipse, closes #8011 closes #6258 (#8375) 2024-02-10 14:29:32 -06:00
Nils Kneuper
32c4cc0f87 updated French translation 2024-02-10 11:12:57 +01:00
Nils Kneuper
9a0a339f54 updated Czech translation 2024-02-10 11:12:13 +01:00
Nils Kneuper
46c268c4d2 updated Arabic translation 2024-02-10 11:11:11 +01:00
Steve Cotton
6828b54ac7 Log instead of assert for incorrect [teleport] tags in ActionWML
Each [teleport] tag should have exactly one each of [source],
[target] and [filter]. Missing any of those is caught immediately
above the new conditional block, so this makes having two or more
of any of them be treated the same.

The log should maybe be made more visible, but it's a case that
can already be detected by schema validation, so validate it
there instead.

The code in teleport.cpp uses assert() in the cases that the
newly-added code in this commit catches. That's bug 8175, and
it's probably still reachable for units with teleport abilities,
so this doesn't close that bug.
2024-02-09 14:45:03 +01:00
P. J. McDermott
73824b95cc Update COPYING.txt for jQuery and tablesorter
Commit 81c31c40c5 updated jQuery to 3.7.0 and tablesorter to 2.31.3.

Update homepages, in particular for the tablesorter fork.

jQuery dropped the confusing and unnecessary dual licensing in 2012:
- https://blog.jquery.com/2012/09/10/jquery-licensing-changes/

Also specify the GPL version used by tablesorter and clarify the "MIT"
license.  The license actually comes from Expat and is one of many
licenses used by MIT (including the X11 license, which is also commonly
called "the MIT license"):
- https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants
- https://www.gnu.org/licenses/license-list.html#Expat
2024-02-08 21:39:17 -06:00
shijie.chen
5d7479b0e1
Remove unnecessary includes (#8347) 2024-02-08 09:40:17 -06:00
pentarctagon
9b004bcb9f use correct name 2024-02-08 09:22:19 -06:00
Celtic Minstrel
2b05ed7339 [LuaDoc] Fix function signature for wesnoth.game_display 2024-02-07 22:10:33 -05:00
Celtic Minstrel
09c88d2b47 [LuaDoc] Fix typo 2024-02-07 22:10:33 -05:00
Celtic Minstrel
3276b9a36c [LuaDoc] Fix missing and incorrectly optional arguments to gui.widget.remove_items_at 2024-02-07 22:10:33 -05:00
Celtic Minstrel
249f9e70f9 [Lua] Fix an error reading filters in wesnoth.game_events.add 2024-02-07 22:09:55 -05:00
Celtic Minstrel
a9c0d37525
[Lua] Prevent divide by 0 in rushers recruit AI 2024-02-07 20:13:13 -05:00
Celtic Minstrel
d19858a150 [Lua] Fix missing parentheses in rusher recruit AI
Fixes #8297
2024-02-07 19:06:47 -05:00
Steve Cotton
5b35ca3edd SoF S02: Alanin has planned (unshrouded) his escape route
The intro to this map shows Rugnur running into the stronghold, with the
elves not far behind. Those moves were running into shroud, which
generated "could not find move_unit_fake route" warnings because the
animation prefers routes that moving side can already see.

Also, have the conversation between Alanin and Rugnur take place with
Alanin on a road hex, because if he starts on the keep then he takes a
long route to avoid cave terrain.
2024-02-08 00:47:28 +01:00
P. J. McDermott
1f1a68e94e Check for and fix copyrights.csv rows with wrong numbers of fields
This should prevent accidental uses of commas in fields without quotes.
It would have caught the previous issue of str.join() not quoting fields
that contain commas.  For now though, it found a different issue: three
rows added in commit c631345314 had duplicated MD5 fields.
2024-02-07 11:12:55 +01:00
P. J. McDermott
5a048ad303 Fix how update_copyrights writes fields with commas
str.join() isn't smart enough to quote CSV fields when necessary, so
a field containing field separators (commas) would get parsed by the
second update_copyrights run as multiple fields.  Upon finding some rows
containing an extra field, the csv.reader() object then added an extra
blank field to each of all the other rows.

Use csv.writer() instead of str.join() to write proper CSV output.

This commit also undoes the removal of commas from fields that was
necessary in commit 676c1fa2b9.
2024-02-07 11:12:55 +01:00
Celtic Minstrel
ba3b00f3df [LuaDoc] Add a type alias for a compiled formula function 2024-02-06 22:21:09 -05:00
Celtic Minstrel
e644613cae [LuaDoc] mathx.random_choice can return nil if the input list is empty 2024-02-06 19:04:02 -05:00
Celtic Minstrel
121f0a3cac [LuaDoc] Add unit.loc field 2024-02-06 19:04:02 -05:00
Celtic Minstrel
a38e67da45 [LuaDoc] Title is optional for alert/confirm 2024-02-06 19:04:02 -05:00
Celtic Minstrel
dc75045eea [LuaDoc] Add comments for micro_ai_helper.lua 2024-02-06 19:04:01 -05:00
Celtic Minstrel
265aea7da4 [LuaDoc] Document the third element of the location triple returned from paths.find_reach 2024-02-06 19:04:01 -05:00
Celtic Minstrel
f9c7336f1a [LuaDoc] Document location_set operators 2024-02-06 19:04:01 -05:00
Celtic Minstrel
3a7bd26067 [LuaDoc] Document ndirs member of a directory listing 2024-02-06 19:04:01 -05:00
Celtic Minstrel
3bf903e2a4 [LuaDoc] Avoid "Missing required fields" warnings by annotating the fields as optional.
This is probably rather unfortunate in the case of the unit fields, as it may now interpret it as meaning the fields can be nil. We'll see if this causes issues.
2024-02-06 19:04:01 -05:00
Celtic Minstrel
c7741907c2 [LuaDoc] Fix several errors in the inline documentation 2024-02-06 19:04:00 -05:00
Celtic Minstrel
795bb22be9 [LuaDoc] Add annotations for micro_ai_self_data.lua 2024-02-06 19:04:00 -05:00
Celtic Minstrel
5a51a309a4 [LuaDoc] Fix several minor errors in the specification of API 2024-02-06 19:04:00 -05:00
Celtic Minstrel
2aa7d9357d [LuaDoc] Fix failure to detect that the string type's metatable was overridden
This isn't a generic solution, but at least makes all our built-in stringx methods work.
2024-02-06 19:04:00 -05:00
gfgtdf
60ae0db611
remove nonsensial comment
we call do_replay() after at_end() so its clearly possible  to be at the end here
2024-02-06 02:51:36 +01:00
Steve Cotton
cfb28fbfb5 Use -Wno-dangling-reference when building with GCC-13
Version 13 of GCC added the -Wdangling-reference option, however
due to false positives it had to be moved from -Wall to -Wextra.
Discussion about its status in GCC-14 is in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110075

The warning is for C++ only and the flag will generate a warning
when compiling C files if the flag is set in Scon's CCFLAGS.

The docs don't explain exactly what triggers the warning, but here's the
explanation from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106393#c1
> The warning works by checking if a reference is initialized with a function
> that returns a reference, and at least one parameter of the function is a
> reference that is bound to a temporary. It assumes that such a function
> actually returns one of its arguments! ... suppress the warning when we've
> seen the definition of the function and we can say that it can return a
> variable with static storage duration.

Consistent with that, we're getting warnings on functions of the form
find(container, const std::string&). All of the things triggering it
seem to be false positives:

* Calls to find_widget<...>.
* Calls to theme::get_theme_config.
* Calls to race::gender_value.
* In src/actions/attack.cpp, any `attacker->attacks()[i]`.
    Although there's an iterator in there, the eventual reference
    is to a member of the array, not the iterator.
* In src/gui/dialogs/unit_advance.cpp, `cfg.child_range("...").back()`
    That returns an object indirectly owned by cfg.

We'd like the other warnings of -Wextra, so turn off -Wdangling-reference.
2024-02-05 20:03:40 +01:00
Steve Cotton
78e929e075 SoF S02: Don't [allow_undo] when activating the runes
Standing on the runes changes some hexes to impassable,
so it's a change to the game state. It isn't a random
event, so it would be possible to add an [on_undo], but
that seems unnecessary, and would need to handle
multiple runes.
2024-02-05 16:18:34 +01:00
Severin Glöckner
dd40711d79 Avoid linebreak in title text of help pages
* doesn't clutter unit help tree when a unit variation is displayed
* when displaying a unit variation in the help, it displays the links
  below the unit image at the same line as when displaying the base unit
patch from #6011
2024-02-04 21:20:52 -06:00
Celtic Minstrel
c143dfdfeb Fix shallow_literal/shallow_parsed not returning named tuples for the WML tags 2024-02-04 16:23:25 -05:00