Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] (PR#13025) script variables aren't saved?
Home

[Freeciv-Dev] (PR#13025) script variables aren't saved?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#13025) script variables aren't saved?
From: "Vasco Alexandre da Silva Costa" <vasco.costa@xxxxxxxxx>
Date: Sat, 3 Dec 2005 11:18:28 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13025 >

> [jdorje - Tue May 10 07:00:14 2005]:
> 
> Begin playing the tutorial scenario.  Do a few actions.  Then save it.
> 
> Reloading resets the scenario state.  Looking into the savegame there is
> no script.vars entry.

Turns out _freeciv_state_dump was busted for boolean variables.

We use the _freeciv_state_dump embedded Lua function to do introspection
of the variables to a code string.

I figured _freeciv_state_dump was busted when I saw it wasn't returning
anything. I fixed it for booleans and numbers, and added an error
message so we will catch bug more easily if/when it happens again.

Patch attached, to commit ASAP.

Index: server/scripting/script.c
===================================================================
--- server/scripting/script.c   (revision 11297)
+++ server/scripting/script.c   (working copy)
@@ -309,6 +309,9 @@
       if (vars) {
        secfile_insert_str(file, vars, "script.vars");
       }
+    } else {
+      /* _freeciv_state_dump in api.pkg is busted */
+      freelog(LOG_ERROR, "lua error: Failed to dump variables");
     }
   }
 }
Index: server/scripting/api.pkg
===================================================================
--- server/scripting/api.pkg    (revision 11297)
+++ server/scripting/api.pkg    (working copy)
@@ -221,8 +221,11 @@
     if k == '_VERSION' then
       -- ignore _VERSION variable.
     elseif type(v) == 'boolean'
-       or type(v) == 'number'
-       or type(v) == 'string' then
+       or type(v) == 'number' then
+      local rvalue = tostring(v)
+
+      res = res .. k .. '=' .. rvalue .. '\n'
+    elseif type(v) == 'string' then
       local rvalue = string.format('%q', v)
 
       res = res .. k .. '=' .. rvalue .. '\n'
Index: data/scenario/tutorial.sav
===================================================================
--- data/scenario/tutorial.sav  (revision 11297)
+++ data/scenario/tutorial.sav  (working copy)
@@ -370,7 +370,7 @@
 hutmsg = false
 signal.connect('hut_enter', 'hut_entered_callback')
 
-print 'Loading tutorial events.'
+print('Loading tutorial events.')
 "
 
 [game]

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13025) script variables aren't saved?, Vasco Alexandre da Silva Costa <=