任务单 #42944

assert failure in is_goods_type_in_range()

开放日期: 2021-09-29 08:17 最后更新: 2021-10-11 03:39

报告人:
属主:
类型:
状态:
关闭
组件:
里程碑:
优先:
5 - Medium
严重性:
5 - Medium
处理结果:
Fixed
文件:
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

任务单历史 (3/12 Histories)

2021-09-29 08:17 Updated by: ddeanbrown
  • New Ticket "assert failure in is_goods_type_in_range()" created
2021-09-29 08:21 Updated by: cazfi
评论

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 Updated by: ddeanbrown
评论

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

2021-10-07 10:38 Updated by: ddeanbrown
评论

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 Updated by: cazfi
  • 里程碑 Update from (无) to 3.0.0 (关闭)
  • 组件 Update from (无) to General
评论

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 Updated by: cazfi
评论

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 Updated by: cazfi)
2021-10-07 17:31 Updated by: cazfi
评论

Additional inconsistency reported as #42992

2021-10-07 18:06 Updated by: cazfi
评论

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 Updated by: cazfi
  • 处理结果 Update from to Accepted
评论

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 Updated by: cazfi
  • 状态 Update from 开启 to 关闭
  • 属主 Update from (无) to cazfi
  • 处理结果 Update from Accepted to Fixed

编辑

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