1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-03-25 05:59:43 +00:00

new system for debug logs

This commit is contained in:
Zeno Rogue
2025-10-19 15:47:01 +02:00
parent 94024dd5f1
commit 113e75d5e1
43 changed files with 601 additions and 447 deletions

View File

@@ -10,6 +10,8 @@
#include "hyper.h"
namespace hr {
EX debugflag debug_map_warnings = {"map_warnings", true};
#if HDR
extern int default_levs();
@@ -570,9 +572,11 @@ EX cell *fractal_rep(cell *c) {
}
}
EX debugflag debug_init_cells = {"init_cells", true};
/** create a map in the current geometry */
EX void initcells() {
DEBB(DF_INIT, ("initcells"));
indenter_finish dif(debug_init_cells, "initcells");
if(embedded_plane) {
geom3::swap_direction = -1;
@@ -627,19 +631,25 @@ EX void initcells() {
// origin->emeraldval =
}
EX debugflag debug_memory_cell = {"memory_cell"};
EX void clearcell(cell *c) {
if(!c) return;
DEBB(DF_MEMORY, (hr::format("c%d %p\n", c->type, hr::voidp(c))));
indenter_finish(debug_memory_cell, hr::format("memory_cell %d %p\n", c->type, hr::voidp(c)));
for(int t=0; t<c->type; t++) if(c->move(t)) {
DEBB(DF_MEMORY, (hr::format("mov %p [%p] S%d\n", hr::voidp(c->move(t)), hr::voidp(c->move(t)->move(c->c.spin(t))), c->c.spin(t))));
if(debug_memory_cell)
println(hlog, hr::format("mov %p [%p] S%d\n", hr::voidp(c->move(t)), hr::voidp(c->move(t)->move(c->c.spin(t))), c->c.spin(t)));
if(c->move(t)->move(c->c.spin(t)) != NULL &&
c->move(t)->move(c->c.spin(t)) != c) {
DEBB(DF_MEMORY | DF_ERROR, (hr::format("cell error: type = %d %d -> %d\n", c->type, t, c->c.spin(t))));
if(worst_precision_error < 1e-3) exit(1);
if(debug_errors || debug_memory_cell)
println(hlog, hr::format("cell error: type = %d %d -> %d\n", c->type, t, c->c.spin(t)));
if(worst_precision_error < 1e-3)
throw hr_exception("clearcell");
}
c->move(t)->move(c->c.spin(t)) = NULL;
}
DEBB(DF_MEMORY, (hr::format("DEL %p\n", hr::voidp(c))));
if(debug_memory_cell)
println(hlog, hr::format("DEL %p\n", hr::voidp(c)));
gp::delete_mapped(c);
destroy_cell(c);
}
@@ -692,11 +702,12 @@ EX void clearfrom(heptagon *at) {
at = q.front();
// if(q.size() > maxq) maxq = q.size();
q.pop();
DEBB(DF_MEMORY, ("from %p", at));
if(debug_memory_cell) println(hlog, "from %p", at);
if(!at->c7 && !ls::voronoi_structure()) {
heptagon *h = dynamic_cast<heptagon*> ((cdata_or_heptagon*) at->cdata);
if(h) {
if(h->alt != at) { DEBB(DF_MEMORY | DF_ERROR, ("alt error :: h->alt = ", h->alt, " expected ", at)); }
if(h->alt != at && (debug_memory_cell || debug_errors))
println(hlog, "alt error :: h->alt = ", h->alt, " expected ", at);
cell *c = h->c7;
subcell(c, destroycellcontents);
h->alt = NULL;
@@ -710,12 +721,10 @@ EX void clearfrom(heptagon *at) {
q.push(at->move(i));
unlink_cdata(at->move(i));
at->move(i)->alt = &deletion_marker;
DEBB(DF_MEMORY, ("!mov ", at->move(i), " [", at->move(i)->move(at->c.spin(i)), "]"));
if(debug_memory_cell) println(hlog, "!mov ", at->move(i), " [", at->move(i)->move(at->c.spin(i)), "]");
if(at->move(i)->move(at->c.spin(i)) != NULL &&
at->move(i)->move(at->c.spin(i)) != at) {
DEBB(DF_MEMORY | DF_ERROR, ("hept error"));
exit(1);
}
at->move(i)->move(at->c.spin(i)) != at)
throw hr_exception("hept error");
at->move(i)->move(at->c.spin(i)) = NULL;
at->move(i) = NULL;
}
@@ -733,7 +742,7 @@ EX void verifycell(cell *c) {
if(BITRUNCATED && c == c->master->c7) verifycell(c2);
if(c2->move(c->c.spin(i)) && c2->move(c->c.spin(i)) != c) {
printf("cell error %p:%d [%d] %p:%d [%d]\n", hr::voidp(c), i, c->type, hr::voidp(c2), c->c.spin(i), c2->type);
exit(1);
throw hr_exception("error during verifycell");
}
}
}
@@ -1759,7 +1768,7 @@ EX int auto_compute_range(cell *c) {
int z = isize(cl.dists);
int d = cl.dists.back();
while(cl.dists[z-1] == d) z--;
if(cgflags & DF_GEOM) {
if(debug_geometry) {
println(hlog, "last distance = ", cl.dists.back());
println(hlog, "ball size = ", isize(cl.dists));
println(hlog, "previous ball size = ", z);