<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40409 >
When hut code decides to give a city, but tile is not good for one, unit with "Settlers" flag is given. Instead, one with "Cities" flag should be given. Attached patch corrects this. Also fixes crash when there is no proper unittype available. - ML
diff -Nurd -X.diff_ignore freeciv/data/default/script.lua freeciv/data/default/script.lua --- freeciv/data/default/script.lua 2008-07-05 14:46:52.000000000 +0300 +++ freeciv/data/default/script.lua 2008-07-27 15:19:10.000000000 +0300 @@ -59,16 +59,18 @@ -- Get new city from hut, or settlers (nomads) if terrain is poor. function hut_get_city(unit) local owner = unit.owner - local settlers = find.role_unit_type('Settlers', owner) + local settlers = find.role_unit_type('Cities', owner) if unit:is_on_possible_city_tile() then create_city(owner, unit.tile, "") notify.event(owner, unit.tile, E.HUT_CITY, _("You found a friendly city.")) else - create_unit(owner, unit.tile, settlers, 0, unit:get_homecity(), -1) - notify.event(owner, unit.tile, E.HUT_SETTLER, - _("Friendly nomads are impressed by you, and join you.")) + if settlers then + notify.event(owner, unit.tile, E.HUT_SETTLER, + _("Friendly nomads are impressed by you, and join you.")) + create_unit(owner, unit.tile, settlers, 0, unit:get_homecity(), -1) + end end end diff -Nurd -X.diff_ignore freeciv/server/scripting/api_actions.c freeciv/server/scripting/api_actions.c --- freeciv/server/scripting/api_actions.c 2008-06-25 12:21:38.000000000 +0300 +++ freeciv/server/scripting/api_actions.c 2008-07-27 15:26:35.000000000 +0300 @@ -42,6 +42,11 @@ int veteran_level, City *homecity, int moves_left) { + if (ptype == NULL + || ptype < unit_type_array_first() || ptype > unit_type_array_last()) { + return NULL; + } + return create_unit(pplayer, ptile, ptype, veteran_level, homecity ? homecity->id : 0, moves_left); }
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev