Merge branch 'christof/icetea_quickfix' into 'master'

hotfix for sunflow ice tea costing 16x the amount of its ingredients

See merge request veloren/veloren!3258
This commit is contained in:
Marcel 2022-03-05 14:22:29 +00:00
commit 9fe45ddb89

View File

@ -442,7 +442,9 @@ impl TradePricing {
} }
}); });
if PRICING_DEBUG { if PRICING_DEBUG {
tracing::debug!("{:?}", recipes); for i in recipes.iter() {
tracing::debug!("{:?}", *i);
}
} }
//info!(? recipes); //info!(? recipes);
recipes recipes
@ -514,7 +516,9 @@ impl TradePricing {
} }
})); }));
if PRICING_DEBUG { if PRICING_DEBUG {
tracing::debug!("{:?}", result.items.0); for i in result.items.0.iter() {
tracing::debug!("before recipes {:?}", *i);
}
} }
// Apply recipe book // Apply recipe book
@ -549,7 +553,7 @@ impl TradePricing {
// (start with cheap ones to avoid changing material prices after evaluation) // (start with cheap ones to avoid changing material prices after evaluation)
while result.sort_by_price(&mut ordered_recipes) { while result.sort_by_price(&mut ordered_recipes) {
ordered_recipes.retain(|recipe| { ordered_recipes.retain(|recipe| {
if recipe.material_cost.map_or(false, |p| p < 1e-5) { if recipe.material_cost.map_or(false, |p| p < 1e-5) || recipe.amount == 0 {
// don't handle recipes which have no raw materials // don't handle recipes which have no raw materials
false false
} else if recipe.material_cost.is_some() { } else if recipe.material_cost.is_some() {
@ -565,12 +569,16 @@ impl TradePricing {
}); });
let item = Item::new_from_asset_expect(&recipe.output); let item = Item::new_from_asset_expect(&recipe.output);
let stackable = item.is_stackable(); let stackable = item.is_stackable();
result.items.add_alternative(PriceEntry { let new_entry = PriceEntry {
name: recipe.output.clone(), name: recipe.output.clone(),
price: usage * (recipe.amount as f32) * Self::CRAFTING_FACTOR, price: usage * (1.0 / (recipe.amount as f32 * Self::CRAFTING_FACTOR)),
sell: output_tradeable, sell: output_tradeable,
stackable, stackable,
}); };
if PRICING_DEBUG {
tracing::trace!("Recipe {:?}", new_entry);
}
result.items.add_alternative(new_entry);
} else { } else {
error!("Recipe {:?} incomplete confusion", recipe); error!("Recipe {:?} incomplete confusion", recipe);
} }