Missing gun variants with `expand_snippet` omit parent item's description
Describe the bug
When an item has "variant_type": "gun" and variants defined, and the variants have expand_snippets but the parent item doesn't, with "Show gun brand names" off, the parent shows a blank line for its description.
If the parent has expand_snippets too, the description of the parent is shown.
Attach save file
Minimal repro mod
[
{
"type": "MOD_INFO",
"id": "variant_snippet_repro",
"name": "Gun variants bug repro",
"description": "Gun variants bug repro",
"category": "content",
"dependencies": ["dda"]
},
{
"type": "snippet",
"category": "",
"text": ["Snippet expanded."]
},
{
"id": "repro_broken",
"type": "ITEM",
"name": { "str": "Broken repro item" },
"description": "No `expand_snippets` at top level.",
"weight": "100 g",
"volume": "100 ml",
"symbol": ",",
"color": "light_gray",
"variant_type": "gun",
"variants": [
{
"id": "repro_broken_variant",
"name": { "str": "Broken repro item variant" },
"description": "Variant description with snippet. ",
"expand_snippets": true
}
]
},
{
"id": "repro_no_expand",
"type": "ITEM",
"name": { "str": "No-expand repro item" },
"description": "Description.",
"weight": "100 g",
"volume": "100 ml",
"symbol": ",",
"color": "light_gray",
"variant_type": "gun",
"variants": [
{
"id": "repro_no_expand_variant",
"name": { "str": "No-expand repro item variant" },
"description": "Variant description."
}
]
},
{
"id": "repro_fixed",
"type": "ITEM",
"name": { "str": "'Fixed' repro item" },
"description": "Has `expand_snippets` at top level. ",
"expand_snippets": true,
"weight": "100 g",
"volume": "100 ml",
"symbol": ",",
"color": "light_gray",
"variant_type": "gun",
"variants": [
{
"id": "repro_fixed_variant",
"name": { "str": "'Fixed' repro item variant" },
"description": "Variant description with snippet. ",
"expand_snippets": true
}
]
}
]Steps to reproduce
See minimal repro mod above.
- Set "Show gun brand names" in game settings to
false. - Create a world with the mod and load into it with a random character.
- Open item-spawn menu, search for
repro.
You should see three items (plus 3 variants, one per) with the word repro in their names. Broken repro item should have no description in the item view with "Show gun brand names" off. With it on, both the variant and the parent item have the description of the variant.
Expected behavior
Parent item should show its description if it has variants and "Show gun brand names" is off.
Screenshots
With "Show gun brand names" offVersions and configuration
- OS: Linux
- OS Version: Distributor ID: Elementary; Description: elementary OS 8; Release: 8; Codename: circe;
- Game Version: cdda-0.I-2026-09-19-2324 7b2efa5 [64-bit]
- Graphics Version: Tiles
- Game Language: System language []
- Mods loaded: [ Dark Days Ahead [dda], Gun variants bug repro [variant_snippet_repro] ]
Additional context
The issue is in item.cpp, in the following line:
if( option.expand_snippets ) {It only checks for whether expand_snippet is present. It should (probably?) also check for has_itype_variant() like it does in the constructor above, because that's where SHOW_GUN_VARIANT is checked:
if( option.expand_snippets && has_itype_variant() ) {Source: CleverRaven/Cataclysm-DDA