Skip to content
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

Multiblock regression and bug fixes, new Jammed state #6

Merged
merged 7 commits into from
Jun 3, 2024

Conversation

Exaxxion
Copy link
Collaborator

@Exaxxion Exaxxion commented Jun 1, 2024

Regression

After merging #2, a regression in behavior occurred where structures would void crafts when broken unlike before where the craft would only void if the controller was broken. This feature branch restores the prior behavior.

Voiding Bug

While working on it I discovered a related issue where multiblocks were recording all possible recipe outputs rather than truncated outputs determined during recipe setup, and if there was insufficient space to merge all outputs then all outputs would silently void instead of the excess outputs. This has been corrected.

Jammed State

As a contingency against undefined behavior when a machine is broken and reformed with a configuration that cannot handle the running recipe, that machine will become Jammed. In this state, recipe progress will be frozen, no additional power will be drawn, the multiblock controller's GUI will indicate the machine is Jammed, and the craft will not progress or complete until the player rectifies the configuration issue.

For example, if recipe outputs are computed with an LV output bus resulting in more than one output, then the structure is broken and the bus is replaced with a ULV bus, the machine would Jam until the structure is rebuilt with enough output space for all outputs.

The Jammed state logic also calls RecipeMapMultiblockController::checkRecipe() to allow for polymorphic behaviors unique to specific multiblocks. For example an EBF will become Jammed if the coils were replaced with different ones of an insufficient tier for the recipe (e.g replacing Kanthal coils with Cupronickel).

Shared Parts Considerations

Shared multiblock parts risk a race condition where another multiblock completes its craft, obstructing the outputs for other machines. If there is insufficient space for all outputs when a machine tries to complete the craft, the merge will fail and all outputs of that type would be voided.

To prevent this from happening, MultiblockRecipeLogic will verify all recipe conditions are satisfied before allowing the craft to complete. If validation fails, the machine will become Jammed. Validation will be performed each time the structure is invalidated and reformed, or the outputs notify the controller of state change. Once validation succeeds, the machine will stop being Jammed and the recipe will complete.

Exaxxion added 5 commits May 31, 2024 04:05
Resolves regression where multiblocks were improperly voiding all
outputs if there was insufficient output space for items upon recipe
completion, caused by recording the pre-truncation outputs during
recipe setup.

Restores prior behavior where excess outputs are voided and those that
can fit in available space (as determined during recipe setup) are
produced as expected (e.g. with a ULV output bus, Hot Titanium will be
produced but MgCl2 will be voided).
Since recipes no longer clear when a structure is broken (so long as the
controller isn't broken, anyway), a contingency is needed to avoid
undefined behavior when the player reforms the structure with less
output space than was available when the recipe was initialized.

Structures will become "Jammed" if at the time of recipe completion,
there is insufficient space for all outputs as computed during recipe
setup. This behavior will enforce additional constraints via
RecipeMapMultiblockController::checkRecipe(Recipe, boolean).

While Jammed, crafting will pause at 100% and the controller GUI will
indicate the structure cannot complete the recipe as configured.

When the player reforms the structure appropriately, the
Jammed status will clear and the craft will complete.
@Exaxxion Exaxxion added the bug Something isn't working label Jun 1, 2024
@Exaxxion Exaxxion self-assigned this Jun 1, 2024
Exaxxion added 2 commits June 2, 2024 06:54
- ru_ru translation provided by NotMyWing
- zh_cn text was machine translated
- Jammed checking now takes effect immediately after a structure is
  broken and reformed, instead of when the recipe finishes crafting.

- This check will also occur when when the outputs notify of changes,
  as the standard Jammed state check is predicated on output space.

- Prevent a race condition with shared multiblock parts feature, where
  structures with shared outputs have sufficient space during recipe
  setup, but when the recipe completes other machines may have reduced
  available space such that the outputs can no longer fit.

- MultiblockRecipeLogic will now verify there is sufficient space for
  the recipe's outputs at the end of the craft before attempting to
  output them and finish the craft. If the check fails, the machine
  will jam until both space becomes available and structure-specific
  conditions via checkRecipe are satisfied.
@Exaxxion Exaxxion marked this pull request as ready for review June 2, 2024 23:48
@Exaxxion Exaxxion merged commit c68049f into master Jun 3, 2024
@Exaxxion Exaxxion deleted the fix-deform-resetting-recipe branch June 3, 2024 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant