diff options
Diffstat (limited to 'cpp/012transform')
-rw-r--r-- | cpp/012transform | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cpp/012transform b/cpp/012transform index bb130187..8cd29c94 100644 --- a/cpp/012transform +++ b/cpp/012transform @@ -25,4 +25,30 @@ void transform_all() { r.transformed_until = t; } } + parse_int_reagents(); // do this after all other transforms have run +} + +void parse_int_reagents() { +//? cout << "parse_int_reagents\n"; //? 1 + for (unordered_map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + recipe& r = p->second; + if (r.steps.empty()) continue; + for (size_t index = 0; index < r.steps.size(); ++index) { + instruction& inst = r.steps[index]; + for (size_t i = 0; i < inst.ingredients.size(); ++i) { + populate_value(inst.ingredients[i]); + } + for (size_t i = 0; i < inst.products.size(); ++i) { + populate_value(inst.products[i]); + } + } + } +} + +void populate_value(reagent& r) { + char* end = NULL; + int result = strtol(r.name.c_str(), &end, /*any base*/0); + if (*end != '\0') return; +//? cout << "setting value\n"; //? 1 + r.value = result; } |