From db0169d46d153f293802293d41234255b8c4d196 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 16 Apr 2022 07:27:40 +0300 Subject: [PATCH 56/56] _freeciv_state_dump(): Save by rule_name() or name() when possible The old code was saving all user data by id. That's not right for ruleset objects for which the id might change between version. Save the data based on the methods and properties available for the type. Reported by nef See osdn #44383 Signed-off-by: Marko Lindqvist --- common/scriptcore/tolua_common_a.pkg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/scriptcore/tolua_common_a.pkg b/common/scriptcore/tolua_common_a.pkg index 41e81c7b22..df7fcf51ee 100644 --- a/common/scriptcore/tolua_common_a.pkg +++ b/common/scriptcore/tolua_common_a.pkg @@ -148,6 +148,12 @@ function _freeciv_state_dump() res = res .. k .. '=find.' .. method if method == 'city' or method == 'unit' then res = res .. '(nil,' .. string.format("%d", v.id) .. ')' + elseif type(v.rule_name) == 'function' then + res = res .. '(' .. string.format("'%s'", v.rule_name(v)) .. ')' + elseif type(v.name) == 'function' then + res = res .. '(' .. string.format("'%s'", v.name(v)) .. ')' + elseif v.name ~= nil then + res = res .. '(' .. string.format("'%s'", v.name) .. ')' elseif v.id then res = res .. '(' .. string.format("%d", v.id) .. ')' else -- 2.35.1