Follow-up Comment #6, bug #22341 (project freeciv):

Adding constructions like:

--- a/common/scriptcore/api_game_methods.c
+++ b/common/scriptcore/api_game_methods.c
@@ -583,7 +583,7 @@ bool api_methods_tile_has_base(lua_State *L, Tile *ptile,

     pbase = base_type_by_rule_name(name);

-    return tile_has_extra(ptile, base_extra_get(pbase));
+    return (pbase ? tile_has_extra(ptile, base_extra_get(pbase)) : FALSE);

@@ -610,7 +610,7 @@ bool api_methods_tile_has_road(lua_State *L, Tile *ptile,

     proad = road_type_by_rule_name(name);

-    return tile_has_extra(ptile, road_extra_get(proad));
+    return (proad ? tile_has_extra(ptile, road_extra_get(proad)) : FALSE);

    would provide some guard for the provision of a non-matching name, but it
seems like that would potentially require a lot of changes to cover all the
cases where there is a lookup-by-name for script-provided data: perhaps there
is a better solution?  We have guard code for an absent name, but from comment
#5, I wonder if that is being called (it should not be prone to this
particular crash).  For S2_5 and S2_4, the content of the function call in the
return statement differs, but the same guard provides protection from the
assertion failures.

    On the specific bindings: this is probably best implemented by providing
per-ruleset lua with ruleset-specific bindings (as has_fortress() is just a
call to has_base("Fortress")), which might be a sensible separate patch.


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to