Lua API: Make wml.tostring a lossless conversion
This means that wml.parse(wml.tostring(cfg)) now returns a perfect clone of the original config. Addresses #3696
This commit is contained in:
parent
0041b0c9e0
commit
be3ebd53aa
2 changed files with 7 additions and 4 deletions
|
@ -55,6 +55,7 @@
|
|||
### Lua API
|
||||
* Fix wesnoth.set_dialog_callback calling the function immediately when used in the previous callback. (issue #3794)
|
||||
* Fix wesnoth.set_dialog_value not triggering re-layout. (issue #3572)
|
||||
* wml.tostring() now outputs a string that can be parsed back to WML without loss of data.
|
||||
### Miscellaneous and bug fixes
|
||||
* Fix crash with custom themes on desktop PCs. (issue #3599)
|
||||
* Add --campaign-skip-story command line switch for skipping directly to turn 1. (issue #3472)
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
#include "utils/functional.hpp"
|
||||
#include "utils/name_generator.hpp"
|
||||
#include "utils/markov_generator.hpp"
|
||||
|
@ -406,10 +407,11 @@ static int intf_format_list(lua_State* L)
|
|||
* - Arg 1: wml table or vconfig userdata
|
||||
* - Ret 1: string
|
||||
*/
|
||||
static int intf_debug(lua_State* L) {
|
||||
static int intf_wml_tostring(lua_State* L) {
|
||||
const config& arg = luaW_checkconfig(L, 1);
|
||||
const std::string& result = arg.debug();
|
||||
lua_pushstring(L, result.c_str());
|
||||
std::ostringstream stream;
|
||||
write(stream, arg);
|
||||
lua_pushstring(L, stream.str().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -508,7 +510,7 @@ lua_kernel_base::lua_kernel_base()
|
|||
|
||||
static luaL_Reg const callbacks[] {
|
||||
{ "compare_versions", &intf_compare_versions },
|
||||
{ "debug", &intf_debug },
|
||||
{ "debug", &intf_wml_tostring },
|
||||
{ "deprecated_message", &intf_deprecated_message },
|
||||
{ "have_file", &lua_fileops::intf_have_file },
|
||||
{ "read_file", &lua_fileops::intf_read_file },
|
||||
|
|
Loading…
Add table
Reference in a new issue