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

fix: Prevent silent solver failures. #259

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

DaleStan
Copy link
Collaborator

@DaleStan DaleStan commented Sep 4, 2024

Crafters with no energy source would halt the solver with silently-ignored exceptions. Turn them into user-visible errors, and let the solver do its best with the information it has.

I discovered this while playing with Exotic Industries. With this mod-fix and project, the solver will silently refuse to deal with the page. (Remove the "Bio matter: insulated wire" tech, and the solver will come back to life.) With this fix, Yafc will display an error on the "Bio matter: insulated wire" tech, and will solve the page.

(The fix a mod developer should make is to uncomment the commented line in the mod-fix, but silent errors are bad UX, even if the error is someone else's fault.)

DaleStan and others added 2 commits September 4, 2024 08:40
Crafters with no energy source would halt the solver
with silently-ignored exceptions.

Turn them into user-visible errors, and let the solver
do its best with the information it has.
The main idea of the commit is to change this:
if ((recipe.entity.energy?.fuels.Length ?? 0) == 0)
into this
if (energy == null || energy.fuels.Length == 0)
with the assumption that these two lines serve the identical purpose.
If this assumption is wrong then this commit is wrong.

The reason for this change is the desire to get rid of the "??" and
make the understanding of the "if" easier.

The rest of the changes are the application of the rename because
why not.

Also wrap a line, so it does not go beyond 120 character limit.
Copy link
Owner

@shpaass shpaass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some adjustments. Please check that they are fine.

@DaleStan DaleStan merged commit dfa3574 into shpaass:master Sep 4, 2024
1 check passed
@DaleStan DaleStan deleted the fix-solver-failures branch September 6, 2024 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants