-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move constructions to generic factory, fix some blueprint precalc bugs #1729
Move constructions to generic factory, fix some blueprint precalc bugs #1729
Conversation
901351a
to
7bf4666
Compare
Ready, I think. Many blueprints have become cheaper in terms of resources due to no longer requiring wacky semi-random construction steps, and many now take slightly longer to complete due to time now being properly accumulated from all steps. Copy-from is a bit awkward when it comes to requirements: construction must either use parent's reqs, or completely overwrite them. Not sure whether that's solvable until reqs themselves support copy-from. |
(cherry picked from commit 46dd680875754839976f0238d1a3e64c824abc77)
(cherry picked from commit d0c62ab0f105052339c5bac6600a21d08f208beb)
(cherry picked from commit 4780fd5d7f4392d0bf8b22829497baf3821e066d)
(cherry picked from commit c9461c372aadf8ae8fe183b73bf45f848fddc301)
c5d6397
to
91652d1
Compare
Being able to |
Summary
SUMMARY: Infrastructure "Move constructions to generic factory, fix some blueprint precalc bugs"
Purpose of change
Constructions:
copy-from
for constructionsstring_id<T>
andint_id<T>
that work in conjunction with singlegeneric_factory<T>
N/A
UI note for constructions that don't require skillst_resin_hole_c
same as similar resin terrainconstruction.h
headerBlueprint requirements autocalc:
Fix tool duplication in requirements when list already contains replacing type (e.g. if list hasMoved into Requirements: fix tool duplication when list already contains replacing type #1756fake_welder
andwelder
,fake_welder
would show up twice)t_wall_w
)Describe the solution
Constructions:
No skills required
description
to usetranslation
class, and group constructions by a dedicated construction group id (port of Use class translation in construction and group construction by group id instead of description CleverRaven/Cataclysm-DDA#44566).Auto-generate construction groups for individual construction recipes to cut down on boilerplate. Use script to replace descriptions with group ids (included in "Additional context" section)Scrapped this idea, it doesn't play nicely withcopy-from
.submap.h
that includedconstruction.h
only to get definition ofpartial_con
structure. Moved that structure into separate header,construction_partial.h
, and madesubmap.h
include that instead.Blueprint requirements autocalc:
Check if the list already contains replacing type before adding it.
There were 2 problems here:
constr_window_taped
andconstr_revert_window_taped
), and construction recipes that allow alternative ways of building object (e.g.constr_table
andconstr_place_table
). As such, they form a directed graph with loops and parallel edges, and autocalc must have some deterministic way to decide on a single path through it.Solution here is to introduce "construction sequences". It's basically sequences of construction recipes that tell autocalc how to get from empty tile to desired terrain/furniture. To cut down on boilerplate, a construction sequence of 1 element is automatically generated for each construction recipe that starts with empty tile and results in a terrain/furniture, but only if there is only 1 such recipe that produces that specific terrain/furniture. This automates handling of trivial cases while forcing manual intervention for when it's unclear on which recipe(s) should be used.
Hide accessor for raw construction recipes list, and instead build a sorted list on finalization and use that to iterate. The recipes are sorted by string ids, so iteration order becomes independent from definition order.
Now that we have a concrete list of construction sequences, autocalc can tell for sure when it doesn't know how to build specific terrain/furniture and will show an error. The developer (or modder) then can decide on course of action:
Since construction sequences now have concrete definitions, autocalc doesn't have to guess and pick some random solution that may not be a solution at all due to bug N2.
Run
tools/update_blueprint_needs.py
and feed itdebug.log
produced after with the fixes.Describe alternatives you've considered
Testing
Constructed a bunch of stuff, constructed a bunch of copy-from'ed stuff.
Manually calculated a few blueprints, compared with autocalc.
TODO list
Check autogeneration of construction groups forNot needed anymorecopy-from
ed constructionsAdditional context
Yet another rabbit hole...
Also, here's the script to replace descriptions with group ids. It's an altered version from the original PR (CleverRaven/Cataclysm-DDA#44566) that doesn't produce groups that would have 1 elementSpoiler