about summary refs log tree commit diff stats
path: root/012transform.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-03-19 11:57:47 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-03-19 11:57:47 -0700
commit1f69d061c17d83b0a665c4fee2407fac1b714b68 (patch)
tree940e2c878a902fa1b1b49e6f799d3c638d5cc869 /012transform.cc
parentd97bafd318567c0f4ae7c80234ecde6cf7658b1c (diff)
downloadmu-1f69d061c17d83b0a665c4fee2407fac1b714b68.tar.gz
2797 - bugfix: transform can create recipes
When I started to make channels generic in 2784, I introduced an
infinite loop when running until just layer 72. This happens because
transform_all() can create new recipes while specializing, and these
were getting added to Recently_added_recipes and then deleted. I didn't
notice until now because layer 91 was clearing Recently_added_recipes
soon after.

Solution: make calls to transform_all after calls to load_permanently
also clear Recently_added_recipes like load_permanently does.

No transforms yet create new types. If they do we'll need to start
handling the other Recently_added_* variables as well.

I should rethink this whole approach of tracking changes to global state
while running tests, and undoing such changes. Ideally I wouldn't need
to manually track changes for each global. I should just encapsulate all
global state in an object, copy it for each test and delete the copy
when I'm done.
Diffstat (limited to '012transform.cc')
-rw-r--r--012transform.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/012transform.cc b/012transform.cc
index a416c20a..0130cd16 100644
--- a/012transform.cc
+++ b/012transform.cc
@@ -56,6 +56,13 @@ void transform_all() {
   // End Transform All
 }
 
+// Later we'll have transforms create recipes out of other recipes. This
+// helper will help ensure we don't lose the new recipes.
+void transform_permanently() {
+  transform_all();
+  Recently_added_recipes.clear();
+}
+
 void parse_int_reagents() {
   trace(9991, "transform") << "--- parsing any uninitialized reagents as integers" << end();
   for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) {