Summary: Scripting: Make all fields constant
                 Project: Freeciv
            Submitted by: englabenny
            Submitted on: torsdag 2010-03-25 den 16:47
                Category: None
                Severity: 3 - Normal
                Priority: 1 - Later
                  Status: None
             Assigned to: englabenny
        Originator Email: 
             Open/Closed: Open
                 Release: 2.2
         Discussion Lock: Any
        Operating System: None
         Planned Release: 



The Scripting API provides read and **write** access to many fields of Units,
Cities, Unit_Types etc, all fields that are not declared 'const' in api.pkg.

This access is probably unintended, and modifies pointers directly (not using
accessors). Mostly, freeciv does not cope well with changes, for example,
changing unit owner:

> lua u = find.unit(find.player(1), 113)  
> lua print(u.utype)
userdata: 0x0x112a2160
> lua print(u.utype:rule_name())
> lua u.owner = find.player(2)
1: in srv_running() [srv_main.c::2073]: Failed at
[sanitycheck.c::545]:!(unit_owner(punit) == pplayer)
1: in begin_phase() [srv_main.c::818]: last message repeated 2 times
1: in begin_phase() [srv_main.c::818]: Failed at [sanitycheck.c::548]:!(phome
= player_find_city_by_id(pplayer, punit->homecity))
1: can_unit_do_activity_targeted_at() unknown activity -1
1: in get_activity_text() [unit.c::620]: assertion 'FALSE' failed.

I have yet to find any settable field that freeciv can cope with. Changing
building or Unit_Type's build_cost does not appear to have any effect. (Any
changes like that that we don't save into the savegame, are even more


Reply to this item at:


  Meddelandet skickades via/av Gna!

Freeciv-dev mailing list

Reply via email to