From 8b5c0bbe700eb6a343dce4286d980e245f8f6045 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 19 Aug 2021 01:25:18 +0200 Subject: [PATCH] rulegen:: better export/error reporting --- rulegen.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rulegen.cpp b/rulegen.cpp index deed18c1..a5f4718d 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -287,7 +287,7 @@ struct shortcut { }; #endif -map> > shortcuts; +EX map> > shortcuts; vector root_path(twalker cw) { cw += wstep; @@ -481,7 +481,8 @@ void be_solid(tcell *c) { ufindc(c); if(c->dist == MYSTERY_DIST) { println(hlog, "set solid but no dist ", c); - exit(3); + debuglist = { c }; + throw rulegen_failure("set solid but no dist"); } c->is_solid = true; } @@ -586,7 +587,7 @@ EX int get_parent_dir(tcell *c) { for(int i=0; icmove(i); be_solid(c1); - if(parent_debug) println(hlog, "direction = ", i, " distance = ", c1->dist); + if(parent_debug) println(hlog, "direction = ", i, " is ", c1, " distance = ", c1->dist); if(c1->dist < d) nearer.push_back(i); } @@ -632,6 +633,7 @@ EX int get_parent_dir(tcell *c) { } } + if(parent_debug) println(hlog, "set parent_dir to ", bestd); c->parent_dir = bestd; return bestd; } @@ -798,7 +800,7 @@ int get_side(twalker what) { while(w.at != tw.at) { steps++; if(steps > 1000000) { debuglist = {what, w, tw}; - throw rulegen_failure("get_side freeze"); + throw rulegen_failure("qsidefreeze"); } ufind(w); ufind(tw); if(w.at->dist > tw.at->dist) @@ -901,7 +903,9 @@ EX pair get_code(tcell *c) { int id = isize(treestates); code_to_id[v] = id; - if(c->code != MYSTERY && (c->code != id || c->parent_dir != bestd)) exit(1); + if(c->code != MYSTERY && (c->code != id || c->parent_dir != bestd)) { + throw rulegen_retry("exit from get_code"); + } c->code = id; treestates.emplace_back(); @@ -927,7 +931,7 @@ EX int rule_root; vector gen_rule(twalker cwmain); EX int try_count; -vector important; +EX vector important; vector cq;