- split the availability gate into gate_recipe and craftable_now
- check_can_craft_nested uses them instead of a full availability
- added cached_availability for the menu's availability cache
- detail pane child list reads the cache
- added nested_availability_expectations test
- check_can_craft_nested takes camp_crafting and inventory_override
- availability passes both through to each child
- detail pane child list passes the menu's camp context
- added nested_availability_follows_the_camp_inventory test
A few variables got renamed for better readability. (For example r is now recipe)
Some renundant function calls for defining a state got pulled out to bool values.
I also reordered some comparision checks to first evaluate local bool values, since they are cheaper to check first.
Like why evaluate a fat function call first if the second && is a false bool flag?
With the new order we can avoid some of the expensive inventory lookups.
The old logic had some lookups that ran regardless of how the flags were set.
I also reran all the tests and every one of them still worked.
I reran the profiler and also saw an improvement.
Its now a bit faster, but will still require more work.
Step recipes called proficiency_time_malus() every turn via
step_budget_moves(), which pulled book bonuses from
crafting_inventory(). The inventory cache was always stale
(invalidated by set_moves(0) earlier in the same do_turn call),
causing a full O(N^2) inventory rebuild per turn -- the same bug
pattern that was previously fixed for batch_time().
- Add crafting_cost_context struct bundling book_proficiency_bonuses
and tool_speeds; require it on batch_time, time_to_craft_moves,
step_budget_moves -- no implicit fallback, no hidden scans
- Add for_recipe() and for_proficiencies() factories so callers
compute the context once at the evaluation boundary
- Add Character::book_bonuses_nearby() -- lightweight spatial query
that walks map tiles and vehicle cargo in-place without copying
items or running stacking logic
- Add map::for_each_reachable_item() as shared primitive for
reachability/accessibility/ownership/vehicle-cargo iteration,
eliminating semantic duplication with form_from_map()
- Thread required book_proficiency_bonuses through
proficiency_time_malus, proficiency_skill_malus, and their
wrappers so they cannot silently trigger inventory scans
- Cache crafting_cost_context in craft_activity_actor, recomputed
only on speed/assistant/proficiency changes (5% boundaries)
- Precompute context in crafting GUI paths (availability cache,
step display, recipe sort) to avoid redundant per-recipe scans
Move the recipe list building pipeline from the recalc block in
select_crafter_and_crafting_recipe() into a testable build_recipe_list()
function in crafting_gui_helpers.
- build_recipe_list() takes a raw recipe vector and applies: hidden
filtering, availability caching, sort, nested expansion. Returns
recipe_list_data struct with entries/indent/available/num_hidden.
- list_nested() moved as public helper (generates colored tree text
for the nested recipe info panel)
- expand_recipes() and recursively_expand_recipes() moved as file-local
statics in helpers.cpp
Fixes a pre-existing bug where nested child availability was computed
with default camp_crafting=false/inventory_override=nullptr instead of
forwarding the actual values from the caller. Both functions now take
camp_crafting and inventory_override parameters.
The skip_sort flag is derived from subtab independently of filter state,
preserving the existing behavior where the Recent tab keeps recency
order even when a filter is active.
New tests cover hidden filtering, skip_hidden_filter bypass, craftable-
first sort invariant, nested expansion with indent, and list_nested
tree generation.
Move the recipe result info builder out of crafting_gui.cpp into
crafting_gui_helpers so both the curses UI and the future ImGui
implementation can share it.
- get_recipe_result_item() creates a display-ready item from a recipe,
handling VARSIZE/FIT sizing, variant, charges, and recipe_exemplar
- recipe_result_info() generates the iteminfo vector for the result
panel, covering containers, byproducts, section headers, and batch
quantity scaling
- get_byproducts_data, get_item_details, get_item_header, and
insert_block_separator move as file-local helpers in the .cpp
- recipe_result_info_cache stays in crafting_gui.cpp as a thin cache
wrapper delegating to recipe_result_info()
- The curses dependency (getmaxx + TERMX) is replaced with an int
panel_width parameter
- New test recipes: water_clean_test_in_jar (container) and
test_longshirt_test_poor_fit (VARSIZE poor-fit warning)
- Seven new tests covering result item properties, structural sections,
batch scaling, and the VARSIZE poor-fit component warning
Move the recipe filter/search engine from crafting_gui.cpp into
crafting_gui_helpers so both the curses UI and the future ImGui
implementation can share it.
- filter_recipes() parses comma-separated prefix queries and delegates
to recipe_subset::reduce()
- query_is_yes() moves as file-local static in the helpers .cpp
- SearchPrefix struct, prefixes vector, and filter_help_start
translation move as extern const declarations
- filter_crafting_recipes() (the popup dialog) stays in crafting_gui.cpp
since it has UI coupling
Also fix the duplicated sort comparator in nested recipe expansion:
- Rename recursively_expance_recipes -> recursively_expand_recipes
- Replace inline sort lambda with recipe_sort_compare()
Guard recipe_subset::search() cancelability check with test_mode so
unit tests can exercise reduce()/search() without throwing.
New test cases cover name, exclude, component, primary skill, skill,
difficulty range, comma chaining, memorized yes/no, book source, and
two characterization tests for pre-existing quirks (r: prefix replaces
instead of intersecting, malformed l: matches all).
Move the recipe info text builders out of crafting_gui.cpp into
crafting_gui_helpers so both the curses UI and the future ImGui
implementation can share them.
- recipe_info() builds the recipe info panel text
- practice_recipe_description() builds practice recipe text
- craft_success_chance_string() and cata_fail_chance_string() move as
file-local helpers in the .cpp
- flag_BLIND_EASY / flag_BLIND_HARD inlined as string literals
- practice_recipe_description() now guards against null practice_data
- test_tallow gets book_learn for "Written in:" test coverage
- New test cases covering recipe info output, practice descriptions,
NPC helper "Known by:" branch, and book source "Written in:" branch
Move the availability struct and related helpers out of an anonymous
namespace in crafting_gui.cpp into a new crafting_gui_helpers.h header.
This lets tests (and the future ImGui crafting menu) access them
directly.
Also extract two small helpers from the monolithic crafting menu
function:
- can_start_craft(): pure validation for the CONFIRM action, checking
craftability and lighting without the interactive container prompt.
- recipe_sort_compare(): recipe list sort comparator with read-state
passed explicitly instead of reading global uistate.
Add 20 test cases covering availability computation, CONFIRM
validation, and sort ordering. Add a test_nested_weapons fixture to
TEST_DATA for nested category testing.