Project

General

Profile

Actions

Bug #2179

open

Server segfault when city cannot provide goods

Added by Dean Brown 1 day ago. Updated 1 day ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
08/29/2026
Due date:
% Done:

0%

Estimated time:

Description

Supplied rulesets are OK, but a clumsy custom ruleset author can make a game.ruleset goods section such that it may sometimes be impossible for a city to provide any goods. In that case, routine goods_from_city_to_unit() returns NULL, and some places in the code down the line that depend on it are not checking.

This patch prevents crashing, but I'm not entirely happy about the resulting situation. That poor good-less trade unit will likely never be able to "Enter Marketplace" nor "Establish Trade Route", and its owner (human or AI) will have no clue why. Could still do "Help Wonder" or "Disband Unit Recover". I thought of an alternate solution - instead of returning NULL, have goods_from_city_to_unit() return a pointer to a static struct goods_type called default_goods, but that is problematic. That good would not be in the ruleset but might have the same name, the struct's id would have to be outside the legal range, and I don't know any way to construct a struct requirement_vector for it.

Another alternate solution that I think would not be workable is to check at ruleset loading time that cities can always provide goods.


Files

2179_Main.patch (9.01 KB) 2179_Main.patch Dean Brown, 08/29/2026 05:06 AM
2179_S3_3.patch (8.76 KB) 2179_S3_3.patch Dean Brown, 08/29/2026 05:06 AM
Actions

Also available in: Atom PDF