The key value returned by lua_next, on the Lua stack, cannot be modified.
Certain tests such as lua_isstring will convert the value.
The solution is, instead of testing if they key can be converted to a string, test if it actually is a string by using lua_type.
[ci skip]
I ran the command used in 9b7b1751fd, excluding results in lua/ and spirit_po/.
Also, once again, for some reason actions/vision.hpp gets registered as massively changed
(similar to f11fa0652a) despite nothing really having changed at all.
This can make some Lua error messages more helpful.
Unfortunately it's rather difficult to deploy, as most
calls to luaW_type_error are within "check" functions,
where the info needed for the new version is unknown.
This fixes 797613f760
which changed the luaW_pcall code from.
if(lua_pcall(..)) {
...
lua_pop(L, 2);
return;
}
lua_remove(L, error_handler_index);
to
int r = lua_pcall(..);
lua_remove(L, error_handler_index);
if(r) {
...
lua_pop(L, 2);
return;
}
so that three values were removed from the stack in case of an error which caused random segfaults later.
Lua deprecated luaL_typerror. Wesnoth needs it. Traditionally this was handled as a by-hand edit to the Lua source kit. Refactored into Wesnoth as luaW_type_error.
This also fixed compilation with boost veryion < 1.56 by using
iterator_range::pop_front() instead of iterator_range::drop_front()
which was added in boost 1.56
This also makes config::all_children_iterator a random access iterator.
The variadic form now uses a variadic template, and a vector form has been added.
Since the nullptr sentinel argument is no longer required, it has been removed from all calls.
This also changes nearly all API functions taking locations to use the new functions.
As a result, these functions can now accept their location arguments in any of three formats:
- An array of two integers
- A table with x and y keys
- Two separate, consecutive integer arguments
Functions that return locations mostly still use whatever format they used before.
This is because changing return values is a more compatibility-breaking change.
This temporarily breaks compatibiliy for the following AI functions:
- ai.get_targets()
- ai.get_avoid()
- ai.get_attacks()
lua string now use a locale indpenedent comparision, this prevents OOS.
This commit also implements comparision operators for lua tstring which
use a language dependend collate facet from boost locale. (which usually
uses an icu or a winapi backend)
unit.variables now uses the same functionality as
wesnoth.get/set_variable (just for the unit variable instead of the game
variables) which makes it possible to access table values. Its also
posible to access subvariables as
unit.variables["list1[2].list2.length"]
headers from lua/.. contain macros that can break other headers in
wesnoth, boost or other libraries.
In this case it was a macro
#define cast(t, exp) ((t)(exp))
defined in lua/llimits.h that broke a boost header.