[new asserts that throw an exception instead
Andreas Röver <roever@users.sourceforge.net>**20051022192028
 
 this new scheme allows to catch after the lib produces
 an unsolvabale error. A window with some information is
 displayed and the program doesn't crash
 
 Sadly FLTK is by default compiled without exception support
 (what a crap) so the exceptions don't go through the callbacks
 and so the program still crashed on asserts in the GUI
 instead of saving the puzzle and shutting down
] {
addfile ./src/lib/assert.h
move ./src/lib/assert.h ./src/lib/bt_assert.h
hunk ./src/converter.cpp 78
-    assert(v);
+    bt_assert(v);
hunk ./src/converter.cpp 102
-      assert(v);
+      bt_assert(v);
hunk ./src/gui/BlockList.cpp 211
-  assert(pz);
+  bt_assert(pz);
hunk ./src/gui/BlockList.cpp 248
-  assert(pz);
+  bt_assert(pz);
hunk ./src/gui/BlockList.cpp 268
-  assert(pz);
+  bt_assert(pz);
hunk ./src/gui/BlockList.cpp 288
-  assert(pz);
+  bt_assert(pz);
hunk ./src/gui/BlockList.cpp 333
-  assert(p);
+  bt_assert(p);
hunk ./src/gui/BlockList.cpp 421
-  assert(pz);
+  bt_assert(pz);
hunk ./src/gui/BlockList.cpp 658
-  assert(pz);
+  bt_assert(pz);
hunk ./src/gui/BlockList.h 161
-  ColorSelector(int x, int y, int w, int h, puzzle_c * p, bool incNeutr) : SelectableTextList(x, y, w, h), puzzle(p), includeNeutral(incNeutr) { assert(p); }
+  ColorSelector(int x, int y, int w, int h, puzzle_c * p, bool incNeutr) : SelectableTextList(x, y, w, h), puzzle(p), includeNeutral(incNeutr) { bt_assert(p); }
hunk ./src/gui/BlockList.h 189
-  PieceSelector(int x, int y, int w, int h, puzzle_c * p) : SelectableTextList(x, y, w, h), puzzle(p) { assert(p); }
+  PieceSelector(int x, int y, int w, int h, puzzle_c * p) : SelectableTextList(x, y, w, h), puzzle(p) { bt_assert(p); }
hunk ./src/gui/BlockList.h 209
-  { assert(p); }
+  { bt_assert(p); }
hunk ./src/gui/BlockList.h 234
-  PiecesList(int x, int y, int w, int h, puzzle_c * p) : TextList(x, y, w, h), puzzle(p), problem(0) { assert(p); }
+  PiecesList(int x, int y, int w, int h, puzzle_c * p) : TextList(x, y, w, h), puzzle(p), problem(0) { bt_assert(p); }
hunk ./src/gui/BlockList.h 276
-    assert(piece < puzzle->probPieceNumber(problem));
+    bt_assert(piece < puzzle->probPieceNumber(problem));
hunk ./src/gui/DisasmToMoves.cpp 49
-  assert(piece < tree->getPieceNumber());
+  bt_assert(piece < tree->getPieceNumber());
hunk ./src/gui/DisasmToMoves.cpp 53
-  assert(piece < tree->getPieceNumber());
+  bt_assert(piece < tree->getPieceNumber());
hunk ./src/gui/DisasmToMoves.cpp 57
-  assert(piece < tree->getPieceNumber());
+  bt_assert(piece < tree->getPieceNumber());
hunk ./src/gui/DisasmToMoves.cpp 61
-  assert(piece < tree->getPieceNumber());
+  bt_assert(piece < tree->getPieceNumber());
hunk ./src/gui/DisasmToMoves.cpp 92
-  assert(tree);
+  bt_assert(tree);
hunk ./src/gui/MainWindow.cpp 79
+  bt_assert(0);
+
hunk ./src/gui/MainWindow.cpp 603
-  assert(assmThread == 0);
+  bt_assert(assmThread == 0);
hunk ./src/gui/MainWindow.cpp 632
-  assert(assmThread);
+  bt_assert(assmThread);
hunk ./src/gui/MainWindow.cpp 1492
+    // check, if the thread has thrown an exception, if so rethrow it
+    if (assmThread->getAssertException()) {
+
+      assertWindow * aw = new assertWindow("Because of an internal error the current puzzle\n"
+                                           "can not be solved\n",
+                                           assmThread->getAssertException());
+
+      aw->show();
+    
+      while (aw->visible())
+        Fl::wait();
+
+      delete aw;
+      delete assmThread;
+      assmThread = 0;
+      return;
+    }
+
hunk ./src/gui/MainWindow.cpp 1692
-  assert(hi > 30);
+  bt_assert(hi > 30);
hunk ./src/gui/MainWindow.cpp 1839
-  assert(hi > 30);
+  bt_assert(hi > 30);
hunk ./src/gui/MainWindow.cpp 2054
-  assert(hi > 30);
+  bt_assert(hi > 30);
hunk ./src/gui/MainWindow.cpp 2154
-    assert(lh == 0);
+    bt_assert(lh == 0);
hunk ./src/gui/MainWindow.h 151
+  /* this is used on assert to save the current puzzle */
+  const puzzle_c * getPuzzle(void) const { return puzzle; }
+
hunk ./src/gui/PlacementBrowser.cpp 73
-  assert(puzzle->probGetAssembler(problem));
+  bt_assert(puzzle->probGetAssembler(problem));
hunk ./src/gui/VoxelView.cpp 199
-  assert((v1x >= 0) && (v1y >= 0) && (v1z >= 0));
-  assert((v2x >= 0) && (v2y >= 0) && (v2z >= 0));
+  bt_assert((v1x >= 0) && (v1y >= 0) && (v1z >= 0));
+  bt_assert((v2x >= 0) && (v2y >= 0) && (v2z >= 0));
hunk ./src/gui/WindowWidgets.cpp 23
+#include <FL/Fl_Multiline_Output.H>
+
hunk ./src/gui/WindowWidgets.cpp 356
-  assert(p);
+  bt_assert(p);
hunk ./src/gui/WindowWidgets.cpp 670
+}
+
+
+#define ASSERT_WINDOW_X 500
+#define ASSERT_WINDOW_Y 400
+
+#define ASSERT_TXT1 40
+#define ASSERT_TXT2 60
+
+#define ASSERT_BTN_X 100
+
+static void cb_assertClose_stub(Fl_Widget* o, void* v) { ((Fl_Double_Window*)v)->hide(); }
+
+assertWindow::assertWindow(const char * text, assert_exception * a) : Fl_Double_Window(0, 0, ASSERT_WINDOW_X, ASSERT_WINDOW_Y) {
+
+  char txt[1000];
+
+  // first the text given
+  (new Fl_Box(5, 5, ASSERT_WINDOW_X-10, ASSERT_TXT1, text))->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_LEFT);
+
+  // now some standard text
+  (new Fl_Box(5, 10+ASSERT_TXT1, ASSERT_WINDOW_X-10, ASSERT_TXT2,
+             "Please send the text in the following box to roever@@users.sf.net\n"
+             "if possible include a file of the puzzle that failed and a description\n"
+             "of what you did until this error occured,   thank you."
+            ))->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_LEFT);
+
+  // finally the text box
+  int pos = snprintf(txt, 1000,
+                     "Assert failed in\n"
+                     "file: %s\n"
+                     "function: %s\n"
+                     "line: %i\n"
+                     "condition: %s\n",
+                     a->file, a->function, a->line, a->expr);
+
+  // append the log
+  if (assert_log->lines()) {
+
+    pos += snprintf(txt+pos, 1000-pos, "log:\n");
+
+    for (unsigned int l = 0; l < assert_log->lines(); l++)
+      pos += snprintf(txt+pos, 1000-pos, "%s\n", assert_log->line(l));
+  }
+
+  printf(txt);
+
+  (new Fl_Multiline_Output(5, 15+ASSERT_TXT1+ASSERT_TXT2, ASSERT_WINDOW_X-10, ASSERT_WINDOW_Y - 25 - 20 - ASSERT_TXT1 - ASSERT_TXT2))->value(txt);
+
+  (new Fl_Button((ASSERT_WINDOW_X-ASSERT_BTN_X)/2, ASSERT_WINDOW_Y-25, ASSERT_BTN_X, 20, "Close"))->callback(cb_assertClose_stub, this);
+
+  label("Error");
hunk ./src/gui/WindowWidgets.h 38
+#include <FL/Fl_Double_Window.H>
hunk ./src/gui/WindowWidgets.h 322
+
+// this window is used to display assert messages
+class assertWindow : public Fl_Double_Window {
+
+public:
+
+  assertWindow(const char * text, assert_exception * a);
+
+};
+
hunk ./src/gui/configuration.cpp 22
-#include <assert.h>
+
+#include "../lib/bt_assert.h"
hunk ./src/gui/configuration.cpp 139
-          default: assert(0);
+          default: bt_assert(0);
hunk ./src/gui/configuration.cpp 206
-  assert(f);
+  bt_assert(f);
hunk ./src/gui/configuration.cpp 225
-    default: assert(0);
+    default: bt_assert(0);
hunk ./src/gui/configuration.cpp 272
-      default: assert(0);
+      default: bt_assert(0);
hunk ./src/gui/configuration.cpp 309
-      default: assert(0);
+      default: bt_assert(0);
hunk ./src/gui/main.cpp 21
+#include "WindowWidgets.h"
+#include "gzstream.h"
hunk ./src/gui/main.cpp 30
+#include "../lib/bt_assert.h"
+
hunk ./src/gui/main.cpp 55
+  bt_assert_init();
hunk ./src/gui/main.cpp 58
+
+  int res = 0;
+
+  try {
+
+    ui->show(argc, argv);
+
+    res = my_Fl::run(ui);
+  }
+
+  catch (assert_exception *a) {
+
+    assertWindow * aw = new assertWindow("I'm sorry there is a bug in this program. It needs to be closed.\n"
+                                         "I try to save the current puzzle in '__rescue.xmpuzzle'\n",
+                                         a);
+
+    aw->show();
hunk ./src/gui/main.cpp 76
-  ui->show(argc, argv);
+    while (aw->visible())
+      Fl::wait();
hunk ./src/gui/main.cpp 79
-  int res = my_Fl::run(ui);
+    delete aw;
hunk ./src/gui/main.cpp 81
-  delete ui;
+    ogzstream ostr("__rescue.xmpuzzle");
+  
+    if (ostr)
+      ostr << ui->getPuzzle()->save();
hunk ./src/gui/main.cpp 86
+    return -1;
+  }
+
+  catch (...) {
+    printf(" exception\n");
+  }
+
+  delete ui;
hunk ./src/lib/AssemblyCallbacks.cpp 39
-  /* first check, if there is an assembler available with the
-   * problem, if there is one take that
-   */
-  if (p->puzzle->probGetAssembler(p->prob))
-    p->assm = (assm_0_frontend_0_c*)p->puzzle->probGetAssembler(p->prob);
-
-  else {
-
-    /* otherwise we have to chreate a new one
+  try {
+  
+    /* first check, if there is an assembler available with the
+     * problem, if there is one take that
hunk ./src/lib/AssemblyCallbacks.cpp 44
-    p->action = assemblerThread::ACT_PREPARATION;
-    p->assm = new assm_0_frontend_0_c();
-
-    p->errState = p->assm->createMatrix(p->puzzle, p->prob);
-    if (p->errState != assm_0_frontend_0_c::ERR_NONE) {
-
-      p->errParam = p->assm->getErrorsParam();
-
-      p->action = assemblerThread::ACT_ERROR;
-
-      delete p->assm;
-      return 0;
-    }
-
-    if (p->_reduce) {
-
-      if (!p->stopPressed)
-        p->action = assemblerThread::ACT_REDUCE;
+    if (p->puzzle->probGetAssembler(p->prob))
+      p->assm = (assm_0_frontend_0_c*)p->puzzle->probGetAssembler(p->prob);
hunk ./src/lib/AssemblyCallbacks.cpp 47
-      p->assm->reduce();
+    else {
+  
+      /* otherwise we have to chreate a new one
+       */
+      p->action = assemblerThread::ACT_PREPARATION;
+      p->assm = new assm_0_frontend_0_c();
+  
+      p->errState = p->assm->createMatrix(p->puzzle, p->prob);
+      if (p->errState != assm_0_frontend_0_c::ERR_NONE) {
+  
+        p->errParam = p->assm->getErrorsParam();
+  
+        p->action = assemblerThread::ACT_ERROR;
+  
+        delete p->assm;
+        return 0;
+      }
+  
+      if (p->_reduce) {
+  
+        if (!p->stopPressed)
+          p->action = assemblerThread::ACT_REDUCE;
+    
+        p->assm->reduce();
+      }
+  
+      /* set the assembler to the problem as soon as it is finished
+       * with initialisation, NOT EARLIER as the function
+       * also restores the assembler state to a state that might
+       * be saved within the problem
+       */
+      p->errState = p->puzzle->probSetAssembler(p->prob, p->assm);
+      if (p->errState != assm_0_frontend_0_c::ERR_NONE) {
+        p->action = assemblerThread::ACT_ERROR;
+        return 0;
+      }
hunk ./src/lib/AssemblyCallbacks.cpp 84
-
-    /* set the assembler to the problem as soon as it is finished
-     * with initialisation, NOT EARLIER as the function
-     * also restores the assembler state to a state that might
-     * be saved within the problem
-     */
-    p->errState = p->puzzle->probSetAssembler(p->prob, p->assm);
-    if (p->errState != assm_0_frontend_0_c::ERR_NONE) {
-      p->action = assemblerThread::ACT_ERROR;
-      return 0;
-    }
-  }
-
-  if (!p->stopPressed) {
-
-    p->action = assemblerThread::ACT_ASSEMBLING;
-    p->assm->assemble(p);
hunk ./src/lib/AssemblyCallbacks.cpp 85
-    if (p->assm->getFinished() >= 1) {
-      p->action = assemblerThread::ACT_FINISHED;
-      p->puzzle->probFinishedSolving(p->prob);
+    if (!p->stopPressed) {
+  
+      p->action = assemblerThread::ACT_ASSEMBLING;
+      p->assm->assemble(p);
+    
+      if (p->assm->getFinished() >= 1) {
+        p->action = assemblerThread::ACT_FINISHED;
+        p->puzzle->probFinishedSolving(p->prob);
+      } else
+        p->action = assemblerThread::ACT_PAUSING;
+  
hunk ./src/lib/AssemblyCallbacks.cpp 98
+  
+    p->puzzle->probAddTime(p->prob, time(0)-p->startTime);
+  }
hunk ./src/lib/AssemblyCallbacks.cpp 102
-  } else
-    p->action = assemblerThread::ACT_PAUSING;
+  catch (assert_exception *a) {
hunk ./src/lib/AssemblyCallbacks.cpp 104
-  p->puzzle->probAddTime(p->prob, time(0)-p->startTime);
+    p->ae = a;
+
+  }
+
hunk ./src/lib/AssemblyCallbacks.cpp 117
-disassm(puz, problemNum)
+disassm(puz, problemNum),
+ae(0)
hunk ./src/lib/AssemblyCallbacks.h 26
+#include "bt_assert.h"
hunk ./src/lib/AssemblyCallbacks.h 52
+  assert_exception *ae;
+
hunk ./src/lib/AssemblyCallbacks.h 106
+
+  assert_exception * getAssertException(void) { return ae; }
hunk ./src/lib/Makefile.am 23
-                  grouping.h grouping.cpp
+                  grouping.h grouping.cpp \
+                  bt_assert.h bt_assert.cpp
hunk ./src/lib/assembler_0.cpp 89
-  assert(0);
+  bt_assert(0);
hunk ./src/lib/assembler_0.cpp 561
-    assert(getPiece(i) < getPiecenumber());
+    bt_assert(getPiece(i) < getPiecenumber());
hunk ./src/lib/assembler_0.cpp 946
-  assert(pos == 0);
+  bt_assert(pos == 0);
hunk ./src/lib/assembly.cpp 21
+#include "bt_assert.h"
hunk ./src/lib/assembly.cpp 251
-  assert(placements.size() == b.placements.size());
-  assert(pivot < placements.size());
+  bt_assert(placements.size() == b.placements.size());
+  bt_assert(pivot < placements.size());
hunk ./src/lib/assembly.h 24
+#include "bt_assert.h"
hunk ./src/lib/assembly.h 110
-    assert(tran < NUM_TRANSFORMATIONS);
+    bt_assert(tran < NUM_TRANSFORMATIONS);
hunk ./src/lib/assembly.h 121
-    assert(num < placements.size());
+    bt_assert(num < placements.size());
hunk ./src/lib/assembly.h 126
-    assert(num < placements.size());
+    bt_assert(num < placements.size());
hunk ./src/lib/assembly.h 131
-    assert(num < placements.size());
+    bt_assert(num < placements.size());
hunk ./src/lib/assembly.h 136
-    assert(num < placements.size());
+    bt_assert(num < placements.size());
hunk ./src/lib/assembly.h 156
-    assert(placements.size() == b.placements.size());
+    bt_assert(placements.size() == b.placements.size());
hunk ./src/lib/bt_assert.h 1
+/* Burr Solver
+ * Copyright (C) 2003-2005  Andreas Röver
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/* this module contains an assert that throws an exception with information about
+ * the assert, this exception can be caught at the end of the program and
+ * the information displayed
+ */
+
+#ifndef __ASSERT_H__
+#define __ASSERT_H__
+
+#include <vector>
+
+class assert_log_c {
+
+  std::vector<const char *> list;
+
+public:
+
+  void addLine(const char * line) {
+    list.push_back(strdup(line));
+  }
+
+  unsigned int lines(void) const { return list.size(); }
+  const char * line(unsigned int l) const { return list[l]; }
+
+};
+
+class assert_exception {
+
+public:
+
+  const char * expr;
+  const char * file;
+  const char * function;
+  unsigned int line;
+
+  assert_exception(const char * e, const char * f, unsigned int l, const char * fkt) : expr(e), file(f), function(fkt), line(l) {}
+
+};
+
+extern assert_log_c * assert_log;
+
+void bt_assert_init(void);
+
+#ifdef NDEBUG
+
+#define bt_assert(expr)
+#define bt_assert_line(line)
+
+#else
+
+#define bt_assert(expr)  (expr) ? 0 : throw new assert_exception(__STRING(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define bt_assert_line(line) assert_log->addLine(line)
+
+#endif
+
+#endif
hunk ./src/lib/disassembler_0.cpp 23
+#include "bt_assert.h"
hunk ./src/lib/disassembler_0.cpp 107
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembler_0.cpp 111
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembler_0.cpp 115
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembler_0.cpp 119
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembler_0.cpp 123
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembler_0.cpp 134
-    assert(nr < piecenumber);
+    bt_assert(nr < piecenumber);
hunk ./src/lib/disassembler_0.cpp 442
-  assert(num == part);
+  bt_assert(num == part);
hunk ./src/lib/disassembler_0.cpp 573
-      assert((part1 > 0) && (part2 > 0));
+      bt_assert((part1 > 0) && (part2 > 0));
hunk ./src/lib/disassembler_0.cpp 687
-  assert(piecenumber == assembly->placementCount());
+  bt_assert(piecenumber == assembly->placementCount());
hunk ./src/lib/disassembly.cpp 182
-  assert(dx && dy && dz);
+  bt_assert(dx && dy && dz);
hunk ./src/lib/disassembly.cpp 192
-  assert(piece < piecenumber);
+  bt_assert(piece < piecenumber);
hunk ./src/lib/disassembly.cpp 199
-  assert(i < piecenumber);
+  bt_assert(i < piecenumber);
hunk ./src/lib/disassembly.cpp 310
-      assert(it->get_attributes().find("type") != it->get_attributes().end());
+      bt_assert(it->get_attributes().find("type") != it->get_attributes().end());
hunk ./src/lib/disassembly.cpp 339
-  assert(states.size());
+  bt_assert(states.size());
hunk ./src/lib/disassembly.cpp 350
-  assert(st->piecenumber == piecenumber);
+  bt_assert(st->piecenumber == piecenumber);
hunk ./src/lib/disassembly.h 26
+#include "bt_assert.h"
hunk ./src/lib/disassembly.h 105
-    assert(num < states.size());
+    bt_assert(num < states.size());
hunk ./src/lib/disassembly.h 130
-    assert(num < piecenumber);
+    bt_assert(num < piecenumber);
hunk ./src/lib/disassembly.h 165
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembly.h 169
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembly.h 173
-    assert(i < piecenumber);
+    bt_assert(i < piecenumber);
hunk ./src/lib/disassembly.h 187
-  /* one assert needs to check the piecenumber */
+  /* on assert needs to check the piecenumber */
hunk ./src/lib/movementcache.cpp 154
-        assert(sh1->isEmpty2(x, y, z) || sh2->isEmpty2(x-dx, y-dy, z-dz));
+        bt_assert(sh1->isEmpty2(x, y, z) || sh2->isEmpty2(x-dx, y-dy, z-dz));
hunk ./src/lib/movementcache.cpp 190
-  assert((mx >= 0) && (my >= 0) && (mz >= 0));
+  bt_assert((mx >= 0) && (my >= 0) && (mz >= 0));
hunk ./src/lib/puzzle.cpp 57
-    assert(pcCol < colors);
-    assert(resCol < colors);
+    bt_assert(pcCol < colors);
+    bt_assert(resCol < colors);
hunk ./src/lib/puzzle.cpp 69
-    assert(pcCol < colors);
-    assert(resCol < colors);
+    bt_assert(pcCol < colors);
+    bt_assert(resCol < colors);
hunk ./src/lib/puzzle.cpp 120
-  assert(col <= colors);
+  bt_assert(col <= colors);
hunk ./src/lib/puzzle.cpp 695
-  assert(col <= colors.size());
+  bt_assert(col <= colors.size());
hunk ./src/lib/puzzle.cpp 715
-  assert(idx < colors.size());
+  bt_assert(idx < colors.size());
hunk ./src/lib/puzzle.cpp 724
-  assert(idx < colors.size());
+  bt_assert(idx < colors.size());
hunk ./src/lib/puzzle.cpp 737
-  assert(prob < problems.size());
-  assert(pc <= colors.size());
-  assert(res <= colors.size());
+  bt_assert(prob < problems.size());
+  bt_assert(pc <= colors.size());
+  bt_assert(res <= colors.size());
hunk ./src/lib/puzzle.cpp 748
-  assert(prob < problems.size());
-  assert(pc <= colors.size());
-  assert(res <= colors.size());
+  bt_assert(prob < problems.size());
+  bt_assert(pc <= colors.size());
+  bt_assert(res <= colors.size());
hunk ./src/lib/puzzle.cpp 759
-  assert(prob < problems.size());
-  assert(pc <= colors.size());
-  assert(res <= colors.size());
+  bt_assert(prob < problems.size());
+  bt_assert(pc <= colors.size());
+  bt_assert(res <= colors.size());
hunk ./src/lib/puzzle.cpp 887
-  assert(idx < shapes.size());
+  bt_assert(idx < shapes.size());
hunk ./src/lib/puzzle.cpp 893
-  assert(idx < shapes.size());
+  bt_assert(idx < shapes.size());
hunk ./src/lib/puzzle.cpp 945
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 955
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 962
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 969
-  assert(prob < problems.size());
-  assert(problems[prob]->result < shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(problems[prob]->result < shapes.size());
hunk ./src/lib/puzzle.cpp 976
-  assert(prob < problems.size());
-  assert(problems[prob]->result < shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(problems[prob]->result < shapes.size());
hunk ./src/lib/puzzle.cpp 984
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 991
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 999
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 1007
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1013
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1025
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 1032
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1045
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
-  assert(problems[prob]->shapes[shapeID].shapeId < shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(problems[prob]->shapes[shapeID].shapeId < shapes.size());
hunk ./src/lib/puzzle.cpp 1053
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
-  assert(problems[prob]->shapes[shapeID].shapeId < shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(problems[prob]->shapes[shapeID].shapeId < shapes.size());
hunk ./src/lib/puzzle.cpp 1062
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 1078
-  assert(prob < problems.size());
-  assert(problems[prob]->assm);
+  bt_assert(prob < problems.size());
+  bt_assert(problems[prob]->assm);
hunk ./src/lib/puzzle.cpp 1085
-  assert(prob < problems.size());
-  assert(problems[prob]->assm);
+  bt_assert(prob < problems.size());
+  bt_assert(problems[prob]->assm);
hunk ./src/lib/puzzle.cpp 1108
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1121
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1126
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1131
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1138
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1143
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1148
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1156
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1161
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1184
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1189
-  assert(prob < problems.size());
-  assert(sol < problems[prob]->solutions.size());
+  bt_assert(prob < problems.size());
+  bt_assert(sol < problems[prob]->solutions.size());
hunk ./src/lib/puzzle.cpp 1196
-  assert(prob < problems.size());
-  assert(sol < problems[prob]->solutions.size());
+  bt_assert(prob < problems.size());
+  bt_assert(sol < problems[prob]->solutions.size());
hunk ./src/lib/puzzle.cpp 1203
-  assert(prob < problems.size());
-  assert(sol < problems[prob]->solutions.size());
+  bt_assert(prob < problems.size());
+  bt_assert(sol < problems[prob]->solutions.size());
hunk ./src/lib/puzzle.cpp 1210
-  assert(prob < problems.size());
-  assert(sol < problems[prob]->solutions.size());
+  bt_assert(prob < problems.size());
+  bt_assert(sol < problems[prob]->solutions.size());
hunk ./src/lib/puzzle.cpp 1217
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1246
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1251
-  assert(prob < problems.size());
+  bt_assert(prob < problems.size());
hunk ./src/lib/puzzle.cpp 1256
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 1278
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 1285
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.cpp 1292
-  assert(prob < problems.size());
-  assert(shapeID < problems[prob]->shapes.size());
+  bt_assert(prob < problems.size());
+  bt_assert(shapeID < problems[prob]->shapes.size());
hunk ./src/lib/puzzle.h 35
-#include <assert.h>
-
hunk ./src/lib/symmetries.cpp 24
-#include <assert.h>
+#include "bt_assert.h"
hunk ./src/lib/symmetries.cpp 270
-  assert(p < NUM_TRANSFORMATIONS);
+  bt_assert(p < NUM_TRANSFORMATIONS);
hunk ./src/lib/symmetries.cpp 274
-  assert(p < NUM_TRANSFORMATIONS);
+  bt_assert(p < NUM_TRANSFORMATIONS);
hunk ./src/lib/symmetries.cpp 278
-  assert(p < NUM_TRANSFORMATIONS);
+  bt_assert(p < NUM_TRANSFORMATIONS);
hunk ./src/lib/symmetries.cpp 283
-  assert(t1 < NUM_TRANSFORMATIONS_MIRROR);
-  assert(t2 < NUM_TRANSFORMATIONS_MIRROR);
+  bt_assert(t1 < NUM_TRANSFORMATIONS_MIRROR);
+  bt_assert(t2 < NUM_TRANSFORMATIONS_MIRROR);
hunk ./src/lib/symmetries.cpp 290
-  assert(s < NUM_SYMMETRY_GROUOPS);
-  assert(t < NUM_TRANSFORMATIONS_MIRROR);
+  bt_assert(s < NUM_SYMMETRY_GROUOPS);
+  bt_assert(t < NUM_TRANSFORMATIONS_MIRROR);
hunk ./src/lib/symmetries.cpp 298
-  assert(s < NUM_SYMMETRY_GROUOPS);
-  assert(trans < NUM_TRANSFORMATIONS_MIRROR);
+  bt_assert(s < NUM_SYMMETRY_GROUOPS);
+  bt_assert(trans < NUM_TRANSFORMATIONS_MIRROR);
hunk ./src/lib/symmetries.cpp 306
-  assert(s1 < NUM_SYMMETRY_GROUOPS);
-  assert(s2 < NUM_SYMMETRY_GROUOPS);
+  bt_assert(s1 < NUM_SYMMETRY_GROUOPS);
+  bt_assert(s2 < NUM_SYMMETRY_GROUOPS);
hunk ./src/lib/symmetries.cpp 322
-  assert(resultSym < NUM_SYMMETRY_GROUOPS);
-  assert(s2 < NUM_SYMMETRY_GROUOPS);
+  bt_assert(resultSym < NUM_SYMMETRY_GROUOPS);
+  bt_assert(s2 < NUM_SYMMETRY_GROUOPS);
hunk ./src/lib/symmetries.cpp 332
-  assert(pp);
+  bt_assert(pp);
hunk ./src/lib/symmetries.cpp 365
-      printf("%llx\n", s);
+      char txt[50];
+      snprintf(txt, 50, "%llx\n", s);
+      bt_assert_line(txt);
hunk ./src/lib/symmetries.cpp 370
-    assert(s == symmetries[i]);
+    bt_assert(s == symmetries[i]);
hunk ./src/lib/voxel.cpp 38
-  assert(space);
+  bt_assert(space);
hunk ./src/lib/voxel.cpp 60
-  assert(space);
+  bt_assert(space);
hunk ./src/lib/voxel.cpp 84
-  assert(space);
+  bt_assert(space);
hunk ./src/lib/voxel.cpp 840
-  assert(x + sx * (y + sy * z) == p);
+  bt_assert(x + sx * (y + sy * z) == p);
hunk ./src/lib/voxel.cpp 856
-  assert(nr < NUM_TRANSFORMATIONS_MIRROR);
+  bt_assert(nr < NUM_TRANSFORMATIONS_MIRROR);
hunk ./src/lib/voxel.cpp 971
-        assert(getColor(i) < 100);
+        bt_assert(getColor(i) < 100);
hunk ./src/lib/voxel.cpp 980
-        assert(getColor(i) < 100);
+        bt_assert(getColor(i) < 100);
hunk ./src/lib/voxel.cpp 1025
-  assert(space);
+  bt_assert(space);
hunk ./src/lib/voxel.h 31
-#include <assert.h>
+#include "bt_assert.h"
hunk ./src/lib/voxel.h 226
-    assert((x<sx)&&(y<sy)&&(z<sz));
+    bt_assert((x<sx)&&(y<sy)&&(z<sz));
hunk ./src/lib/voxel.h 266
-    assert((p>=0)&&(p<voxels));
+    bt_assert((p>=0)&&(p<voxels));
hunk ./src/lib/voxel.h 289
-    assert((p>=0)&&(p<voxels));
+    bt_assert((p>=0)&&(p<voxels));
hunk ./src/lib/voxel.h 438
-  void setColor(unsigned int x, unsigned int y, unsigned int z, unsigned int color) { assert(color < 64); set(x, y, z, (get(x, y, z) & 0x3) | color << 2); }
+  void setColor(unsigned int x, unsigned int y, unsigned int z, unsigned int color) { bt_assert(color < 64); set(x, y, z, (get(x, y, z) & 0x3) | color << 2); }
hunk ./src/lib/voxel.h 440
-  void setColor(unsigned int i, unsigned int color) { assert(color < 64); set(i, (get(i) & 0x3) | color << 2); }
+  void setColor(unsigned int i, unsigned int color) { bt_assert(color < 64); set(i, (get(i) & 0x3) | color << 2); }
hunk ./src/tester.cpp 83
-  assert(nr < NUM_TRANSFORMATIONS);
+  bt_assert(nr < NUM_TRANSFORMATIONS);
hunk ./src/tester.cpp 293
-        printf("assert(s == %i);\nreturn (symmetries_t)%i; //%s\n",lastfound, lastfound, longlong2string(foundSym[lastfound]));
+        printf("bt_assert(s == %i);\nreturn (symmetries_t)%i; //%s\n",lastfound, lastfound, longlong2string(foundSym[lastfound]));
}
