Skip to content

Conversation

@Dorus
Copy link
Collaborator

@Dorus Dorus commented May 10, 2024

This change needs some investigation re #109 (review)

The old code did effectively this:

Recipe[] allProduction;
if (goods == null)
{
  allProduction = [];
}
else
{
  if (variants == null)
  {
    allProduction = goods.production;
  }
  else
  {
    allProduction = variants.SelectMany(x => x.production).Distinct().ToArray();
  }
}

The new code is doing this:

Recipe[] allProduction;
if (variants != null)
{
    allProduction = variants.SelectMany(x => x.production).Distinct().ToArray();
}
else if (goods != null)
{
   allProduction = goods.production;
}
else
{
  allProduction = [];
}
goods variants old new
n n [] []
n y [] variants
y n goods goods
y y variants variants

Need to investigate what it means for goods or variants to be null. I've been running some scenario's in YaFC but couldn't find one where goods was null and variants wasn't. Some help would be appreciated.

@Dorus Dorus force-pushed the ProductionTableView-allProduction branch from ea21db1 to 5167cac Compare May 10, 2024 09:28
@Dorus
Copy link
Collaborator Author

Dorus commented May 10, 2024

What i did find so far:

The only place where variants is not null is when we're called from ProductionTableView.cs:424:

var ingredient = recipe.recipe.ingredients[i];
var link = recipe.links.ingredients[i];
var goods = recipe.links.ingredientGoods[i];
grid.Next();
view.BuildGoodsIcon(gui, goods, link, (float)(ingredient.amount * recipe.recipesPerSecond), ProductDropdownType.Ingredient, recipe, recipe.linkRoot, ingredient.variants);

So goods = recipe.links.ingredientGoods[i] and variants = recipe.recipe.ingredients[i].variants.
recipe is in both cases a RecipeRow (ProductionTableContent.cs:173)

So goods will end up as Goods and variants will end up as Goods[]. After goods.production and variants.SelectMany(...) both are Recipe[].

@Dorus
Copy link
Collaborator Author

Dorus commented May 10, 2024

One thing i noticed while investigating this:

Before when you disable a recipe, the item row is emptied. Old projects still have this state stored:

afbeelding

If i enable them now and disable again, i get the recipes visible:
afbeelding

I'm not sure if this was intended, i tried to go to older versions along the master branch, but couldn't find any yet without this problem until i ran into the ones with the libf problem.

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.

1 participant