CleverRaven/Cataclysm-DDA

Item groups with type "distribution" lack proper consistency checks

Open

#62,446 opened on Nov 28, 2022

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C++ (3,991 forks)batch import
(S2 - Confirmed)Code: TestsHelp WantedSpawn[C++]

Repository metrics

Stars
 (9,264 stars)
PR merge metrics
 (Avg merge 6d 5h) (292 merged PRs in 30d)

Description

Describe the bug

There are item groups that can cause rare CI errors as already pointet out in other issues (#60784, #59873). They're hard to identify because consistency checks are incomplete. Item_spawn_data::check_consistency is supposed to create a maximized item group, but completely ignores it for groups with the type distribution.

https://github.com/CleverRaven/Cataclysm-DDA/blob/4034a38d4bae1abb7f208ba1a63630e05de02662/src/item_group.cpp#L701-L721

For collections it checks for flags & spawn_flag::maximized to spawn everything without randomness, but it's obviously not that easy for distributions where there are multiple paths that would all have to be checked.

Steps to reproduce

Add an item group like this where one entry fits the container, the other doesn't:

  {
    "id": "test_group_faulty_distribution",
    "type": "item_group",
    "subtype": "distribution",
    "container-item": "bottle_plastic",
    "entries": [ { "item": "anvil" }, { "item": "paper" } ]
  }

Then run tests (with all test cases filtered out, just loading the json) and only see it sometimes fail on the anvil.

Expected behavior

Item groups don't have errors and creators are informed if there can be issues.

Screenshots

No response

Versions and configuration

4034a38d4bae1abb7f208ba1a63630e05de02662

Additional context

No response

Contributor guide