Ticket #42944

assert failure in is_goods_type_in_range()

Eröffnet am: 2021-09-29 08:17 Letztes Update: 2021-10-11 03:39

Auswertung:
Verantwortlicher:
Typ:
Status:
Geschlossen
Komponente:
Meilenstein:
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Gefixt
Datei:
2

Details

3.0.0-beta2
Playing with my custom ruleset, got this error msg at runtime (ruleset loaded OK) -

Please report this message at https://osdn.net/projects/freeciv/ticket/
in is_goods_type_in_range() [../../freeciv-3.0.0/common/requirements.c::1792]: assertion 'FALSE' failed.
Invalid range 4.

Cause is this effect in my effects.ruleset -

; Make minimum trade from a traderoute >= 1; change down-round to up-round by
; adding 1 to city center.
[effect_traderoute_minimum0\]
type = "Output_Add_Tile"
value = 1
reqs =

{ "type", "name", "range"
"Good", "Goods", "Traderoute"
"CityTile", "Center", "Local"
"OutputType", "Trade", "Local"
}


This line looks like the trigger. I think it should be OK, according to the wiki page https://freeciv.fandom.com/wiki/Requirements -

"Good", "Goods", "Traderoute"


game.ruleset has -

[goods_0\]
name=_("Goods")
from_pct=0
to_pct=0
onetime_pct=0

Ticket-Verlauf (3/12 Historien)

2021-09-29 08:17 Aktualisiert von: ddeanbrown
  • New Ticket "assert failure in is_goods_type_in_range()" created
2021-09-29 08:21 Aktualisiert von: cazfi
Kommentar

While this should be caught at ruleset loading time instead of triggering runtime assert, the doc/README.effects list "City" as the only valid range for "Good" requirement.

2021-09-29 09:11 Aktualisiert von: ddeanbrown
Kommentar

OK, I've corrected the wiki page https://freeciv.fandom.com/wiki/Requirements

2021-10-07 10:38 Aktualisiert von: ddeanbrown
Kommentar

Ihnatus reverted my change to the wiki page, saying -
Code says it's possible to supply "Traderoute" range, plz discuss if not

2021-10-07 13:32 Aktualisiert von: cazfi
  • Meilenstein Update from (Keine) to 3.0.0 (closed)
  • Komponente Update from (Keine) to General
Kommentar

1) req_from_str() accepts both "City" and "Traderoute" ranges for "Good" requirement when the ruleset is loaded
2) is_goods_type_in_range() does not have implementation for Traderoute range, giving the assert seen in this ticket instead
3) doc/README.effects list only "City" as a supported range.

In S3_0 (d3f) I would say that the correct behavior is what the documentation (README.effects) says -> fix req_from_str()
In later branches we could look in to supporting Traderoute range -> change is_goods_type_in_range() and documentation

2021-10-07 13:38 Aktualisiert von: cazfi
Kommentar

Reply To cazfi

In later branches we could look in to supporting Traderoute range -> change is_goods_type_in_range() and documentation

The question is, does it ever make sense to use that range? It would mean that "For City A, does there exist a traderoute to a city B, to which a specific good is imported (via another traderoute) from a city C? (As a special case, C can be the same as A)"

(Edited, 2021-10-07 17:39 Aktualisiert von: cazfi)
2021-10-07 17:31 Aktualisiert von: cazfi
Kommentar

Additional inconsistency reported as #42992

2021-10-07 18:06 Aktualisiert von: cazfi
Kommentar

For those confused by the semantics: Remember that the concept of "Good" is that it *travels via a trade route* (it only exist within trade route). The source city never has it (it doesn't travel there), but only the city where it's imported to has. The source city might have requirements, such as specific "Resource", for exporting the good.

Note that even if "Good" requirement evaluated true also when the city is the one exporting the good, it wouldn't make it easier to handle cases where we want something enabled when a city either has "something" by itself, or by importing the same thing. The Good would still not be available in the source city either when there's no trade route. Maybe it makes sense in a future version to implement something that allows a city to provide goods to itself?

2021-10-08 02:08 Aktualisiert von: cazfi
  • Lösung Update from Keine to Accepted
Kommentar

Reply To cazfi

In S3_0 (d3f) I would say that the correct behavior is what the documentation (README.effects) says -> fix req_from_str()
In later branches we could look in to supporting Traderoute range -> change is_goods_type_in_range() and documentation

Future development is future development (and new ticket, if someone wants it). Attached patches make the ruleset loading time check to disallow "Traderoute" range in all branches for now.

2021-10-11 03:39 Aktualisiert von: cazfi
  • Status Update from Offen to Geschlossen
  • Verantwortlicher Update from (Keine) to cazfi
  • Lösung Update from Accepted to Gefixt

Bearbeiten

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Anmelden