Summary: Scripting: Restore script state does not work
                 Project: Freeciv
            Submitted by: englabenny
            Submitted on: måndag 2010-03-22 den 19:52
                Category: general
                Severity: 3 - Normal
                Priority: 1 - Later
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 2.2
         Discussion Lock: Any
        Operating System: None
         Planned Release: 



Testing restoring variables in the script state, some types of variables
(cities, units, governments and tiles) can not always be restored.

Proposing a fix in 3 patches, the first requiring the most scrutiny:
Proposing to move restoring script state to the absolute last point in the
savegame load process.

Testing was done by saving one value of each type in global script values
that are dumped to script.vars in a savegame. Then loading this savegame and
printing the values restored.

Before saving we have:

Player 0 = userdata: 0x0x108bf288
Monarchy = userdata: 0x0x108bf2d0
Nation 1 = userdata: 0x0x108bf318
Tech 1 = userdata: 0x0x108bf360
Terrain 1 = userdata: 0x0x108bf3a8
Tile 1x1 = userdata: 0x0x108bf3f0
Latest unit = userdata: 0x0x10875810
Latest unit type = userdata: 0x0x1086fd60
Latest city = userdata: 0x0x10870cb8

Before fixing bugs we have, on restore:

Player 0 = userdata: 0x0x105a6108
Monarchy = nil
Nation 1 = userdata: 0x0x105a6060
Tech 1 = userdata: 0x0x105a44c8
Terrain 1 = userdata: 0x0x105a62b8
(Tile 1x1 = nil)
Latest unit = nil
Latest unit type = userdata: 0x0x105a5800
Latest city = nil

(Tile in brackets because its restore code is a syntax/code error that has to
be commented out, the script evaluation fails)

If we move script state restore to after all other savegame loading:

Player 0 = userdata: 0x0x104e0390
Monarchy = nil                          <-- ust be found by name
Nation 1 = userdata: 0x0x104e0ee8
Tech 1 = userdata: 0x0x1065cac0
Terrain 1 = userdata: 0x0x104e0f30
(Tile 1x1 = nil)                        <-- Fix with new find.tile(index)
Latest unit = userdata: 0x0x104e0610
Latest unit type = userdata: 0x0x104e05f0
Latest city = userdata: 0x0x104dfff0

And if we apply two patches (in total then 3), to fix dumping of governments
(I can't make lookup by index work), and to implement index lookup for

Player 0 = userdata: 0x0x108d9878
Monarchy = userdata: 0x0x108d8f90
Nation 1 = userdata: 0x0x108da6a0
Tech 1 = userdata: 0x0x108da4a8
Terrain 1 = userdata: 0x0x108da6e8
Tile 1x1 = userdata: 0x0x108d9020
Latest unit = userdata: 0x0x105ed488
Latest unit type = userdata: 0x0x105f1030
Latest city = userdata: 0x0x108d98d8


Reply to this item at:


  Meddelandet skickades via/av Gna!

Freeciv-dev mailing list

Reply via email to