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: Continue loading after encountering undefined recipes. #367

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Yafc.Parser/Data/FactorioDataDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public Project LoadData(string projectPath, LuaTable data, LuaTable prototypes,

UpdateSplitFluids();
var iconRenderTask = renderIcons ? Task.Run(RenderIcons) : Task.CompletedTask;
UpdateRecipeIngredientFluids();
UpdateRecipeIngredientFluids(errorCollector);
UpdateRecipeCatalysts();
CalculateMaps(netProduction);
ExportBuiltData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ private void UpdateRecipeCatalysts() {
}
}

private void UpdateRecipeIngredientFluids() {
private void UpdateRecipeIngredientFluids(ErrorCollector errorCollector) {
foreach (var recipe in allObjects.OfType<Recipe>()) {
if (recipe.ingredients == null || recipe.products == null) {
errorCollector.Error($"The recipe '{recipe.name}' is not defined in data.raw[\"recipe\"].", ErrorSeverity.Important);
recipe.ingredients = [];
recipe.products = [];
continue;
}
foreach (var ingredient in recipe.ingredients) {
if (ingredient.goods is Fluid fluid && fluid.variants != null) {
int min = -1, max = fluid.variants.Count - 1;
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Version:
Date:
Fixes:
- "Map generated" entities that don't generate in any locations could break automation analysis.
- Recipes that are referenced without being defined do not prevent YAFC from loading.
----------------------------------------------------------------------------------------------------------------------
Version: 2.4.0
Date: November 21st 2024
Expand Down