Skip to content

Commit

Permalink
fix: Continue loading after encountering undefined recipes. (shpaass#367
Browse files Browse the repository at this point in the history
)

As reported [on
Discord](https://discord.com/channels/560199483065892894/1210135763422027837/1312102716352368721),
melon is trying to unlock an undefined recipe.

This fills in just enough data so loading can continue, though the
recipe ends up with no ingredients, products, or crafters.
  • Loading branch information
shpaass authored Nov 29, 2024
2 parents 5266e93 + 9cd05e5 commit 3f2060c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
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

0 comments on commit 3f2060c

Please sign in to comment.