From df3e21b310994567725b18df70e3022402159900 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 13 May 2019 01:57:40 +0200 Subject: [PATCH] debug cleanup --- 3d-models.cpp | 13 +++++-- achievement.cpp | 6 ++-- archimedean.cpp | 83 +++++++++++++++++++++---------------------- basegraph.cpp | 18 +++++----- cell.cpp | 19 +++++----- commandline.cpp | 16 +++++---- complex.cpp | 4 +-- config.cpp | 6 ++-- control.cpp | 14 ++++---- euclid.cpp | 2 +- fieldpattern.cpp | 24 ++++++------- floorshapes.cpp | 8 +++-- game.cpp | 92 +++++++++++++++++++++++------------------------- geometry.cpp | 11 +++--- goldberg.cpp | 45 +++++++++++------------ graph.cpp | 21 +++++------ help.cpp | 4 +-- hyper.h | 46 +++++++++++++++--------- hypgraph.cpp | 6 ++-- init.cpp | 8 +---- menus.cpp | 4 +-- polygons.cpp | 15 ++++---- renderbuffer.cpp | 2 +- savemem.cpp | 8 ++--- sound.cpp | 4 +-- system.cpp | 14 ++++---- yendor.cpp | 2 +- 27 files changed, 251 insertions(+), 244 deletions(-) diff --git a/3d-models.cpp b/3d-models.cpp index 5a96d2d2..0ca74e80 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -768,9 +768,7 @@ void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q qtyall++; } - if(&eye == &shSkullEyes) println(hlog, "skull pos = ", pos); - if(&eye == &shSkullEyes) - pos = zc(eyepos) - 0.06 * SH * 0.05; + if(&eye == &shSkullEyes) pos = zc(eyepos) - 0.06 * SH * 0.05; make_ball(eye, rad, 0); transmatrix T = zpush(-shift_eye) * rgpushxto0(center) * zpush(pos); @@ -832,6 +830,7 @@ void queueball(const transmatrix& V, ld rad, color_t col, eItem what) { void make_3d_models() { if(DIM == 2) return; + DEBBI(DF_POLY, ("make_3d_models")); shcenter = C0; if(floor_textures) { @@ -840,6 +839,7 @@ void make_3d_models() { utt.texture_id = floor_textures->renderedTexture; } + DEBB(DF_POLY, ("humanoids")); make_humanoid_3d(shPBody); make_humanoid_3d(shYeti); make_humanoid_3d(shFemaleBody); @@ -854,6 +854,7 @@ void make_3d_models() { // shRaiderBody = shPBody; // shJiangShi = shPBody; + DEBB(DF_POLY, ("heads")); make_head_3d(shFemaleHair); make_head_3d(shPHead); make_head_3d(shTurban1); @@ -879,6 +880,7 @@ void make_3d_models() { make_head_3d(shJiangShiCap2); make_head_3d(shTerraHead); + DEBB(DF_POLY, ("armors")); make_armor_3d(shKnightArmor); make_armor_3d(shKnightCloak, 2); make_armor_3d(shPrinceDress); @@ -897,6 +899,7 @@ void make_3d_models() { make_armor_3d(shHood, 2); + DEBB(DF_POLY, ("feet and paws")); make_foot_3d(shHumanFoot); make_foot_3d(shYetiFoot); make_skeletal(shSkeletalFoot, WDIM == 2 ? zc(0.5) + geom3::human_height/40 - geom3::FLOOR : 0); @@ -906,6 +909,7 @@ void make_3d_models() { make_paw_3d(shDogFrontPaw, shDogFrontLeg); make_paw_3d(shDogRearPaw, shDogRearLeg); + DEBB(DF_POLY, ("revolution")); // make_abody_3d(shWolfBody, 0.01); // make_ahead_3d(shWolfHead); // make_ahead_3d(shFamiliarHead); @@ -1009,6 +1013,7 @@ void make_3d_models() { make_head_only(); + DEBB(DF_POLY, ("balls")); make_ball(shDisk, orbsize*.2, 2); make_ball(shHeptaMarker, zhexf*.2, 1); make_ball(shSnowball, zhexf*.1, 0); @@ -1043,6 +1048,7 @@ void make_3d_models() { shift_shape(shThorns, geom3::FLOOR - geom3::human_height * 1/40); shift_shape(shRose, geom3::FLOOR - geom3::human_height * 1/20); + DEBB(DF_POLY, ("slime")); bshape(shSlime, PPR::MONSTER_BODY); hyperpoint tip = xpush0(1); hyperpoint atip = xpush0(-1); @@ -1066,6 +1072,7 @@ void make_3d_models() { shift_shape(shMagicSword, geom3::ABODY); shift_shape(shMagicShovel, geom3::ABODY); + DEBB(DF_POLY, ("eyes")); adjust_eye(shSlimeEyes, shSlime, geom3::FLATEYE, 0, 2, 2); adjust_eye(shGhostEyes, shGhost, geom3::GHOST, geom3::GHOST, 2, WDIM == 2 ? 2 : 4); adjust_eye(shMiniEyes, shMiniGhost, geom3::GHOST, geom3::GHOST, 2, 2); diff --git a/achievement.cpp b/achievement.cpp index 18fceba3..6872a647 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -714,7 +714,7 @@ void check_total_victory() { } void achievement_victory(bool hyper) { - DEBB(DF_STEAM, (debugfile,"achievement_victory\n")) + DEBBI(DF_STEAM, ("achievement_victory")) if(offlineMode) return; #ifdef HAVE_ACHIEVEMENTS if(cheater) return; @@ -726,7 +726,7 @@ void achievement_victory(bool hyper) { if(peace::on) return; if(tactic::on) return; if(chaosmode) return; - DEBB(DF_STEAM, (debugfile,"after checks\n")) + DEBB(DF_STEAM, ("after checks")) int t = getgametime(); @@ -777,7 +777,7 @@ void achievement_victory(bool hyper) { } } - DEBB(DF_STEAM, (debugfile, "uploading scores\n")) + DEBB(DF_STEAM, ("uploading scores")) upload_score(ih1, t); upload_score(ih2, turncount); #endif diff --git a/archimedean.cpp b/archimedean.cpp index dd00aad0..59639df7 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -7,7 +7,6 @@ namespace hr { namespace arcm { #if CAP_ARCM -#define SDEBUG(x) if(debug_geometry) { x; fflush(stdout); } static const int sfPH = 1; static const int sfLINE = 2; @@ -42,7 +41,7 @@ int gcd(int x, int y) { return x ? gcd(y%x, x) : y < 0 ? -y : y; } void archimedean_tiling::make_match(int a, int i, int b, int j) { if(isize(adjacent[a]) != isize(adjacent[b])) { - SDEBUG(printf("(error here)")); + DEBB(DF_GEOM, ("(error here)")); errormsg = XLAT("polygons match incorrectly"); errors++; } @@ -122,9 +121,9 @@ void archimedean_tiling::prepare() { for(int oi=0; oi<1; oi++) { int at = (i+oi)%N; int inv = oi; - SDEBUG(printf("vertex ");) + DEBB0(DF_GEOM, ("vertex ")); for(int z=0; z [%d %d]\n", at, inv);) + DEBB(DF_GEOM, (format("-> [%d %d]\n", at, inv))); } } for(int i=0; i= isize(adjacent[ai])) aj = 0; } - SDEBUG( printf("-> [%d %d]\n", ai, aj); ) + DEBB(DF_GEOM, (format("-> [%d %d]\n", ai, aj))); make_match(i, j, ai, aj); } } @@ -234,10 +234,11 @@ void archimedean_tiling::regroup() { for(int i=0; i dv(geometry, gArchimedean); @@ -313,7 +314,7 @@ void archimedean_tiling::compute_geometry() { if(euclid) break; } - SDEBUG( printf("computed edgelength = %f\n", float(edgelength)); ) + DEBB(DF_GEOM, (format("computed edgelength = %f\n", float(edgelength)))); triangles.clear(); triangles.resize(2*N+2); @@ -334,11 +335,11 @@ void archimedean_tiling::compute_geometry() { // printf("total = %lf\n", double(total)); } - SDEBUG( for(auto& ts: triangles) { - printf("T"); - for(auto& t: ts) printf(" %f@%f", float(t.first), float(t.second)); - printf("\n"); - } ) + if(debugflags & DF_GEOM) for(auto& ts: triangles) { + DEBB0(DF_GEOM, ("T")); + for(auto& t: ts) DEBB0(DF_GEOM, (format(" %f@%f", float(t.first), float(t.second)))); + DEBB(DF_GEOM, ()); + } } @@ -454,7 +455,7 @@ struct hrmap_archimedean : hrmap { heptagon *create_step(heptagon *h, int d) { - SDEBUG( printf("%p.%d ~ ?\n", h, d); ) + DEBB(DF_GEOM, (format("%p.%d ~ ?\n", h, d))); heptspin hi(h, d); @@ -482,16 +483,15 @@ struct hrmap_archimedean : hrmap { if(euclid) alt = encodeId(pair_to_vec(int(T[0][GDIM]), int(T[1][GDIM]))); - SDEBUG( println(hlog, "look for: ", alt, " / ", T * C0); ) + DEBB(DF_GEOM, ("look for: ", alt, " / ", T * C0)); for(auto& p2: altmap[alt]) if(intval(p2.second * C0, T * C0) < 1e-4) { - SDEBUG( println(hlog, "cell found: ", p2.first); ) + DEBB(DF_GEOM, ("cell found: ", p2.first)); for(int d2=0; d2degree(); d2++) { heptspin hs(p2.first, d2); auto& t2 = current.get_triangle(p2.first, d2); transmatrix T1 = T * spin(M_PI + t2.first); - SDEBUG( print(hlog, "compare: ", T1 * xpush0(1)); ) - SDEBUG( println(hlog, ":: ", p2.second * xpush0(1)); ) + DEBB(DF_GEOM, ("compare: ", T1 * xpush0(1), ":: ", p2.second * xpush0(1))); if(intval(T1 * xpush0(1), p2.second * xpush0(1)) < 1e-4) { // T1 = p2.second @@ -510,7 +510,7 @@ struct hrmap_archimedean : hrmap { return h->move(d); } } - SDEBUG( println(hlog, "but rotation not found")); + DEBB(DF_GEOM, ("but rotation not found")); } auto& t2 = current.get_triangle(current.get_adj(hi)); @@ -584,7 +584,7 @@ hrmap *new_map() { return new hrmap_archimedean; } heptagon *build_child(heptspin p, pair adj) { indenter ind; auto h = buildHeptagon1(tailored_alloc (isize(current.adjacent[adj.first])), p.at, p.spin, hstate(1), 0); - SDEBUG( printf("NEW %p.%d ~ %p.0\n", p.at, p.spin, h); ) + DEBB(DF_GEOM, (format("NEW %p.%d ~ %p.0\n", p.at, p.spin, h))); id_of(h) = adj.first; parent_index_of(h) = adj.second; int nei = neighbors_of(h); @@ -628,23 +628,23 @@ void connect_digons_too(heptspin h1, heptspin h2) { // no need to specify archimedean_gmatrix and altmap hnew->c.connect(1, h2); h1--, h2++; - SDEBUG( printf("OL2 %p.%d ~ %p.%d\n", h1.at, h1.spin, h2.at, h2.spin); ) + DEBB(DF_GEOM, (format("OL2 %p.%d ~ %p.%d\n", h1.at, h1.spin, h2.at, h2.spin))); h1.at->c.connect(h1.spin, h2); } } void connectHeptagons(heptspin hi, heptspin hs) { - SDEBUG( printf("OLD %p.%d ~ %p.%d\n", hi.at, hi.spin, hs.at, hs.spin); ) + DEBB(DF_GEOM, (format("OLD %p.%d ~ %p.%d\n", hi.at, hi.spin, hs.at, hs.spin))); if(hi.at->move(hi.spin) == hs.at && hi.at->c.spin(hi.spin) == hs.spin) { - SDEBUG( printf("WARNING: already connected\n"); ) + DEBB(DF_GEOM, (format("WARNING: already connected\n"))); return; } if(hi.peek()) { - SDEBUG( printf("ERROR: already connected left\n"); ) + DEBB(DF_GEOM, (format("ERROR: already connected left\n"))); exit(1); } if(hs.peek()) { - SDEBUG( printf("ERROR: already connected right\n"); ) + DEBB(DF_GEOM, (format("ERROR: already connected right\n"))); exit(1); } hi.at->c.connect(hi.spin, hs); @@ -781,7 +781,7 @@ int readArgs() { archimedean_tiling at; shift(); at.parse(args()); if(at.errors) { - println(hlog, "error: ", at.errormsg); + DEBB(DF_ERROR | DF_GEOM, ("error: ", at.errormsg)); } else { set_geometry(gArchimedean); @@ -790,7 +790,6 @@ int readArgs() { showstartmenu = false; } } - else if(argis("-dgeom")) debug_geometry = true; else if(argis("-dual")) { PHASEFROM(2); set_variation(eVariation::dual); } else if(argis("-d:arcm")) launch_dialog(show); @@ -1035,7 +1034,7 @@ void show() { archimedean_tiling tested; tested.parse(s); if(tested.errors) { - println(hlog, "WARNING: ", tested.errors, " errors on ", s, " '", tested.errormsg, "'"); + DEBB(DF_GEOM | DF_WARN, ("WARNING: ", tested.errors, " errors on ", s, " '", tested.errormsg, "'")); } else { tested.coloring = col; diff --git a/basegraph.cpp b/basegraph.cpp index d5f892bc..e619fa14 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -212,7 +212,7 @@ void display_data::set_all(int ed) { } void display_data::set_projection(int ed) { - DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n")); + DEBBI(DF_GRAPH, ("current_display->set_projection")); bool pers3 = false; bool apply_models = !among(pmodel, mdUnchanged, mdFlatten, mdRug); @@ -367,7 +367,7 @@ bool model_needs_depth() { } void setGLProjection(color_t col) { - DEBB(DF_GRAPH, (debugfile,"setGLProjection\n")); + DEBBI(DF_GRAPH, ("setGLProjection")); GLERR("pre_setGLProjection"); glClearColor(part(col, 2) / 255.0, part(col, 1) / 255.0, part(col, 0) / 255.0, 1); @@ -483,7 +483,7 @@ void sdltogl(SDL_Surface *txt, glfont_t& f, int ch) { void init_glfont(int size) { if(glfont[size]) return; - DEBB(DF_INIT, (debugfile,"init GL font: %d\n", size)); + DEBBI(DF_GRAPH, ("init GL font: ", size)); #if !CAP_TABFONT loadfont(size); @@ -680,7 +680,7 @@ bool gl_print(int x, int y, int shift, int size, const char *s, color_t color, i purehookset hooks_resetGL; void resetGL() { - DEBB(DF_INIT, (debugfile,"reset GL\n")); + DEBBI(DF_INIT | DF_GRAPH, ("reset GL")) callhooks(hooks_resetGL); #if CAP_GLFONT for(int i=0; i<128; i++) if(glfont[i]) { @@ -903,7 +903,7 @@ void addMessageToLog(msginfo& m, vector& log) { void clearMessages() { msgs.clear(); } void addMessage(string s, char spamtype) { - DEBB(DF_MSG, (debugfile,"addMessage: %s\n", s.c_str())); + DEBB(DF_MSG, ("addMessage: ", s)); msginfo m; m.msg = s; m.spamtype = spamtype; m.flashout = false; m.stamp = ticks; @@ -973,7 +973,7 @@ void drawmessage(const string& s, int& y, color_t col) { } void drawmessages() { - DEBB(DF_GRAPH, (debugfile,"draw messages\n")); + DEBBI(DF_GRAPH, ("draw messages")); int i = 0; int t = ticks; for(int j=0; j vid.xscr) vid.xres = vid.xscr * 9/10, setfsize = true; @@ -1191,7 +1191,7 @@ bool noGUI = false; void initgraph() { - DEBB(DF_INIT, (debugfile,"initgraph\n")); + DEBBI(DF_INIT | DF_GRAPH, ("initgraph")); initConfig(); @@ -1270,7 +1270,7 @@ void initgraph() { } void cleargraph() { - DEBB(DF_INIT, (debugfile,"clear graph\n")); + DEBBI(DF_INIT, ("clear graph")); #if CAP_SDLTTF for(int i=0; i<256; i++) if(font[i]) TTF_CloseFont(font[i]); #endif diff --git a/cell.cpp b/cell.cpp index 7eeaca36..20a3cfe0 100644 --- a/cell.cpp +++ b/cell.cpp @@ -214,7 +214,7 @@ hookset *hooks_newmap; // initializer (also inits origin from heptagon.cpp) void initcells() { - DEBB(DF_INIT, (debugfile,"initcells\n")); + DEBB(DF_INIT, ("initcells")); hrmap* res = callhandlers((hrmap*)nullptr, hooks_newmap); if(res) currentmap = res; @@ -250,18 +250,17 @@ void initcells() { void clearcell(cell *c) { if(!c) return; - DEBMEM ( printf("c%d %p\n", c->type, c); ) + DEBB(DF_MEMORY, (format("c%d %p\n", c->type, c))); for(int t=0; ttype; t++) if(c->move(t)) { - DEBMEM ( printf("mov %p [%p] S%d\n", c->move(t), c->move(t)->move(c->c.spin(t)), c->c.spin(t)); ) + DEBB(DF_MEMORY, (format("mov %p [%p] S%d\n", c->move(t), 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) { - printf("type = %d %d -> %d\n", c->type, t, c->c.spin(t)); - printf("cell error\n"); + DEBB(DF_MEMORY | DF_ERROR, (format("cell error: type = %d %d -> %d\n", c->type, t, c->c.spin(t)))); exit(1); } c->move(t)->move(c->c.spin(t)) = NULL; } - DEBMEM ( printf("DEL %p\n", c); ) + DEBB(DF_MEMORY, (format("DEL %p\n", c))); tailored_delete(c); } @@ -308,11 +307,11 @@ void clearfrom(heptagon *at) { at = q.front(); // if(q.size() > maxq) maxq = q.size(); q.pop(); - DEBMEM ( printf("from %p\n", at); ) + DEBB(DF_MEMORY, ("from %p", at)); if(!at->c7) { heptagon *h = (heptagon*) at->cdata; if(h) { - if(h->alt != at) printf("alt error :: h->alt = %p\n", h->alt); + if(h->alt != at) { DEBB(DF_MEMORY | DF_ERROR, ("alt error :: h->alt = ", h->alt)); } cell *c = h->c7; subcell(c, destroycellcontents); h->alt = NULL; @@ -326,10 +325,10 @@ void clearfrom(heptagon *at) { q.push(at->move(i)); unlink_cdata(at->move(i)); at->move(i)->alt = &deletion_marker; - DEBMEM ( printf("!mov %p [%p]\n", at->move(i), at->move(i)->move[at->c.spin(i)]); ) + DEBB(DF_MEMORY, ("!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) { - printf("hept error\n"); + DEBB(DF_MEMORY | DF_ERROR, ("hept error")); exit(1); } at->move(i)->move(at->c.spin(i)) = NULL; diff --git a/commandline.cpp b/commandline.cpp index 6085d16a..3a935e92 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -112,13 +112,15 @@ int arg::readCommon() { PHASE(1); offlineMode = true; } - else if(argis("-debugf")) { - debugfile = fopen("hyperrogue-debug.txt", "w"); - shift(); debugflags = argi(); - } - else if(argis("-debuge")) { - debugfile = stderr; - shift(); debugflags = argi(); + else if(argis("-debf")) { + shift(); + string s = args(); + for(char c: s) { + for(int i=0; iprincess) || is_cell_removed(i->prison)) { - DEBSM(printf("removing a princess\n");) + DEBB(DF_MEMORY, ("removing a princess")) if(i->princess && !is_cell_removed(i->princess)) { - DEBSM(printf("faking a princess\n");) + DEBB(DF_MEMORY, ("faking a princess")) princess::newFakeInfo(i->princess); } delete i; diff --git a/config.cpp b/config.cpp index 02f18b04..d93c83a7 100644 --- a/config.cpp +++ b/config.cpp @@ -527,7 +527,7 @@ void resetConfig() { #if CAP_CONFIG void saveConfig() { - DEBB(DF_INIT, (debugfile,"save config\n")); + DEBB(DF_INIT, ("save config\n")); FILE *f = fopen(conffile, "wt"); if(!f) { addMessage(s0 + "Could not open the config file: " + conffile); @@ -599,7 +599,7 @@ void loadNewConfig(FILE *f) { void loadConfig() { - DEBB(DF_INIT, (debugfile,"load config\n")); + DEBB(DF_INIT, ("load config")); vid.xres = 9999; vid.yres = 9999; vid.framelimit = 300; FILE *f = fopen(conffile, "rt"); if(f) { @@ -616,7 +616,7 @@ void loadConfig() { } fclose(f); - DEBB(DF_INIT, (debugfile,"Loaded configuration: %s\n", conffile)); + DEBB(DF_INIT, ("Loaded configuration: %s\n", conffile)); } polygonal::solve(); diff --git a/control.cpp b/control.cpp index 93c23ac5..e306d212 100644 --- a/control.cpp +++ b/control.cpp @@ -101,7 +101,7 @@ hyperpoint move_destination_vec(int d) { } void movepckeydir(int d) { - DEBB(DF_GRAPH, (debugfile,"movepckeydir\n")); + DEBB(DF_GRAPH, ("movepckeydir\n")); // EUCLIDEAN movedir md = vectodir(move_destination_vec(d)); @@ -162,7 +162,7 @@ SDL_Joystick* sticks[8]; int numsticks; void initJoysticks() { - DEBB(DF_INIT, (debugfile,"init joysticks\n")); + DEBB(DF_INIT, ("init joysticks")); numsticks = SDL_NumJoysticks(); if(numsticks > 8) numsticks = 8; for(int i=0; i void sizeto(T& t, int n) { // !siid equals pseudohept(c) void generate_floorshapes_for(int id, cell *c, int siid, int sidir) { + DEBBI(DF_POLY, ("generate_floorshapes_for ", id)); for(auto pfsh: all_plain_floorshapes) { auto& fsh = *pfsh; @@ -565,11 +566,12 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) { void generate_floorshapes() { + DEBBI(DF_POLY, ("generate_floorshapes")); if(WDIM == 3) ; #if CAP_IRR else if(IRREGULAR) { - printf("generating irregular floorshapes...\n"); + DEBBI(DF_POLY, ("generate_floorshapes: irregular")); cell model; int cc = isize(irr::cells); @@ -640,8 +642,7 @@ namespace gp { bool master = !(li.relative.first||li.relative.second); int cor = master ? S7 : SG6; if(master) li.last_dir = -1; - if(debug_geometry) - printf("last=%d at=%d,%d tot=%d siid=%d sidir=%d cor=%d id=%d\n", li.last_dir, li.relative.first, li.relative.second, li.total_dir, siid, sidir, cor, id); + DEBB(DF_GP, (format("last=%d at=%d,%d tot=%d siid=%d sidir=%d cor=%d id=%d\n", li.last_dir, li.relative.first, li.relative.second, li.total_dir, siid, sidir, cor, id))); generate_floorshapes_for(id, c0, siid, sidir); @@ -870,6 +871,7 @@ const int FLOORTEXTURESIZE = 4096; void make_floor_textures() { if(1) { + DEBBI(DF_POLY, ("make_floor_textures")); dynamicval g(geometry, gEuclidSquare); dynamicval gm(pmodel, mdDisk); dynamicval va(variation, eVariation::pure); diff --git a/game.cpp b/game.cpp index 29c40a06..5523543a 100644 --- a/game.cpp +++ b/game.cpp @@ -93,10 +93,6 @@ int currentLocalTreasure; bool landvisited[landtypes]; -extern void DEBT(const char *buf); - -#define DEBT(x) DEBB(DF_TURN, (debugfile,"%s\n", x)) - bool eq(short a, short b) { return a==b; } // game state @@ -2063,7 +2059,7 @@ void killMutantIvy(cell *c, eMonster who) { void killMonster(cell *c, eMonster who, flagtype deathflags) { eMonster m = c->monst; - DEBB(DF_TURN, (debugfile,"killmonster %s", dnameof(m))); + DEBBI(DF_TURN, ("killmonster ", dnameof(m))); if(!m) return; @@ -5513,10 +5509,10 @@ void movegolems(flagtype flags) { bool recorduse[ittypes]; for(int i=0; itype; k++) if(c->move(k)) { cell *c2 = c->move(k); int val = movevalue(m, c, c2, flags); @@ -5565,7 +5561,7 @@ void movegolems(flagtype flags) { } else { passable_for(m, c2, c, P_DEADLY); - DEBT("move"); + DEBB(DF_TURN, ("move")); moveMonster(c2, c, dir); if(m != moTameBomberbird && m != moFriendlyGhost) moveBoatIfUsingOne(c2, c, dir); @@ -5582,7 +5578,7 @@ void movegolems(flagtype flags) { empathyMove(c, c2, dir); } - DEBT("other"); + DEBB(DF_TURN, ("other")); } } achievement_count("GOLEM", qg, 0); @@ -6122,7 +6118,7 @@ void movehex_all() { void movemonsters() { ambush_distance = 0; - DEBT("lava1"); + DEBB(DF_TURN, ("lava1")); orboflava(1); checkAmbushState(); @@ -6132,70 +6128,70 @@ void movemonsters() { specialMoves(); - DEBT("ghosts"); + DEBB(DF_TURN, ("ghosts")); moveghosts(); - DEBT("butterflies"); + DEBB(DF_TURN, ("butterflies")); moveButterflies(); - DEBT("normal"); + DEBB(DF_TURN, ("normal")); moveNormals(moYeti); - DEBT("slow"); + DEBB(DF_TURN, ("slow")); if(havewhat & HF_SLOW) moveNormals(moTortoise); if(sagefresh) sagephase = 0; - DEBT("ivy"); + DEBB(DF_TURN, ("ivy")); moveivy(); - DEBT("slimes"); + DEBB(DF_TURN, ("slimes")); groupmove(moSlime, 0); - DEBT("sharks"); + DEBB(DF_TURN, ("sharks")); if(havewhat & HF_SHARK) groupmove(moShark, 0); - DEBT("eagles"); + DEBB(DF_TURN, ("eagles")); if(havewhat & HF_BIRD) groupmove(moEagle, 0); if(havewhat & HF_EAGLES) groupmove(moEagle, MF_NOATTACKS | MF_ONLYEAGLE); - DEBT("eagles"); + DEBB(DF_TURN, ("eagles")); if(havewhat & HF_REPTILE) groupmove(moReptile, 0); - DEBT("air"); + DEBB(DF_TURN, ("air")); if(havewhat & HF_AIR) { airmap.clear(); groupmove(moAirElemental, 0); buildAirmap(); } - DEBT("earth"); + DEBB(DF_TURN, ("earth")); if(havewhat & HF_EARTH) groupmove(moEarthElemental, 0); - DEBT("water"); + DEBB(DF_TURN, ("water")); if(havewhat & HF_WATER) groupmove(moWaterElemental, 0); - DEBT("void"); + DEBB(DF_TURN, ("void")); if(havewhat & HF_VOID) groupmove(moVoidBeast, 0); - DEBT("leader"); + DEBB(DF_TURN, ("leader")); if(havewhat & HF_LEADER) groupmove(moPirate, 0); - DEBT("mutant"); + DEBB(DF_TURN, ("mutant")); if((havewhat & HF_MUTANT) || (bounded && among(specialland, laOvergrown, laClearing))) movemutant(); - DEBT("bugs"); + DEBB(DF_TURN, ("bugs")); if(havewhat & HF_BUG) hive::movebugs(); - DEBT("whirlpool"); + DEBB(DF_TURN, ("whirlpool")); if(havewhat & HF_WHIRLPOOL) whirlpool::move(); - DEBT("whirlwind"); + DEBB(DF_TURN, ("whirlwind")); if(havewhat & HF_WHIRLWIND) whirlwind::move(); #if CAP_COMPLEX2 - DEBT("westwall"); + DEBB(DF_TURN, ("westwall")); if(havewhat & HF_WESTWALL) westwall::move(); #endif for(int i=0; iitem == itOrbSafety) return; - DEBT("river"); + DEBB(DF_TURN, ("river")); if(havewhat & HF_RIVER) prairie::move(); - /* DEBT("magnet"); + /* DEBB(DF_TURN, ("magnet")); if(havewhat & HF_MAGNET) groupmove(moSouthPole, 0), groupmove(moNorthPole, 0); */ - DEBT("bugs"); + DEBB(DF_TURN, ("bugs")); if(havewhat & HF_HEXD) groupmove(moHexDemon, 0); if(havewhat & HF_ALT) groupmove(moAltDemon, 0); if(havewhat & HF_MONK) groupmove(moMonk, 0); - DEBT("worm"); + DEBB(DF_TURN, ("worm")); cell *savepos[MAXPLAYER]; for(int i=0; iitem == itOrbSafety) { @@ -7575,10 +7571,10 @@ void monstersTurn() { refreshFriend(dcal[i]); } } - DEBT("rop"); + DEBB(DF_TURN, ("rop")); reduceOrbPowers(); int phase1 = (1 & items[itOrbSpeed]); - DEBT("lc"); + DEBB(DF_TURN, ("lc")); if(!phase1) livecaves(); if(!phase1) ca::simulate(); if(!phase1) heat::processfires(); @@ -7596,7 +7592,7 @@ void monstersTurn() { crush_now = move(crush_next); crush_next.clear(); - DEBT("heat"); + DEBB(DF_TURN, ("heat")); heat::processheat(); // if(elec::havecharge) elec::drawcharges(); @@ -7609,7 +7605,7 @@ void monstersTurn() { if(multi::playerActive(i)) checkFreedom(playerpos(i)); - DEBT("check"); + DEBB(DF_TURN, ("check")); checkmove(); if(canmove) elec::checklightningfast(); @@ -7797,7 +7793,7 @@ bool movepcto(int d, int subdir, bool checkonly) { flipplayer = false; if(multi::players > 1) multi::flipped[multi::cpid] = false; } - if(!checkonly) { DEBB(DF_TURN, (debugfile,"movepc\n")); } + DEBBI(checkonly ? 0 : DF_TURN, ("movepc")); int origd = d; if(d >= 0) { cwt += d; @@ -8390,7 +8386,7 @@ bool movepcto(int d, int subdir, bool checkonly) { achievement_gain("SEVENMINE"); } - DEBT("done"); + DEBB(DF_TURN, ("done")); return true; } diff --git a/geometry.cpp b/geometry.cpp index 096231f8..48b1f9a4 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -5,8 +5,6 @@ namespace hr { -bool debug_geometry = false; - ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf; // tessf: distance from heptagon center to another heptagon center @@ -44,7 +42,7 @@ ld scalefactor, orbsize, floorrad0, floorrad1, zhexf; void precalc() { - DEBB(DF_INIT, (debugfile,"precalc\n")); + DEBBI(DF_INIT | DF_POLY | DF_GEOM, ("precalc")); hexshift = 0; @@ -140,9 +138,9 @@ void precalc() { hexvdist = hdist(xpush0(hexf), xspinpush0(ALPHA/2, hcrossf)); - if(debug_geometry) - printf("S7=%d S6=%d hexf = " LDF" hcross = " LDF" tessf = " LDF" hexshift = " LDF " hexhex = " LDF " hexv = " LDF "\n", S7, S6, hexf, hcrossf, tessf, hexshift, - hexhexdist, hexvdist); + DEBB(DF_GEOM | DF_POLY, + (format("S7=%d S6=%d hexf = " LDF" hcross = " LDF" tessf = " LDF" hexshift = " LDF " hexhex = " LDF " hexv = " LDF "\n", S7, S6, hexf, hcrossf, tessf, hexshift, + hexhexdist, hexvdist))); base_distlimit = ginf[geometry].distlimit[!BITRUNCATED]; @@ -282,6 +280,7 @@ namespace geom3 { } void compute() { + DEBBI(DF_INIT | DF_POLY | DF_GEOM, ("geom3::compute")); // tanh(depth) / tanh(camera) == vid.alpha invalid = ""; diff --git a/goldberg.cpp b/goldberg.cpp index 82f515a0..96f385a2 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -58,8 +58,6 @@ namespace hr { namespace gp { int fixg6(int x) { return (x + MODFIXER) % SG6; } -#define WHD(x) // x - int get_code(const local_info& li) { return ((li.relative.first & 15) << 0) + @@ -158,7 +156,7 @@ namespace hr { namespace gp { if(peek(wcw)) { auto wcw1 = get_localwalk(wc1, dir1); if(wcw + wstep != wcw1) { - WHD( println(hlog, at1, " : ", (wcw+wstep), " / ", wcw1, " (pull error from ", at, " :: ", wcw, ")") ); + DEBB(DF_GP, (at1, " : ", (wcw+wstep), " / ", wcw1, " (pull error from ", at, " :: ", wcw, ")") ); exit(1); } } @@ -166,7 +164,7 @@ namespace hr { namespace gp { } if(peek(wcw)) { set_localwalk(wc1, dir1, wcw + wstep); - WHD( println(hlog, at1, " :", wcw+wstep, " (pulled from ", at, " :: ", wcw, ")")); + DEBB(DF_GP, (at1, " :", wcw+wstep, " (pulled from ", at, " :: ", wcw, ")")); return true; } return false; @@ -176,12 +174,12 @@ namespace hr { namespace gp { auto& wc = get_mapping(at); auto wcw = get_localwalk(wc, dir); auto& wc1 = get_mapping(at + eudir(dir)); - WHD( print(hlog, format(" md:%02d s:%d", wc.mindir, wc.cw.spin)); ) - WHD( print(hlog, " connection ", at, "/", dir, " ", wc.cw+dir, "=", wcw, " ~ ", at+eudir(dir), "/", dir1); ) + DEBB0(DF_GP, (format(" md:%02d s:%d", wc.mindir, wc.cw.spin)); ) + DEBB0(DF_GP, (" connection ", at, "/", dir, " ", wc.cw+dir, "=", wcw, " ~ ", at+eudir(dir), "/", dir1); ) if(!wc1.cw.at) { wc1.start = wc.start; if(peek(wcw)) { - WHD( print(hlog, "(pulled) "); ) + DEBB0(DF_GP, ("(pulled) "); ) set_localwalk(wc1, dir1, wcw + wstep); } else { @@ -189,25 +187,25 @@ namespace hr { namespace gp { wcw.at->c.setspin(wcw.spin, 0, false); set_localwalk(wc1, dir1, wcw + wstep); spawn++; - WHD( print(hlog, "(created) "); ) + DEBB0(DF_GP, ("(created) "); ) } } - WHD( Xprintf("%s ", dcw(wc1.cw+dir1)); ) + DEBB0(DF_GP, (wc1.cw+dir1, " ")); auto wcw1 = get_localwalk(wc1, dir1); if(peek(wcw)) { if(wcw+wstep != wcw1) { - WHD( println(hlog, "FAIL: ", wcw, " / ", wcw1); exit(1); ) + DEBB(DF_GP, ("FAIL: ", wcw, " / ", wcw1); exit(1); ) } else { - WHD( println(hlog, "(was there)\n");) + DEBB(DF_GP, ("(was there)")); } } else { - WHD(Xprintf("ok\n"); ) + DEBB(DF_GP, ("ok")); peek(wcw) = wcw1.at; wcw.at->c.setspin(wcw.spin, wcw1.spin, wcw.mirrored != wcw1.mirrored); if(wcw+wstep != wcw1) { - println(hlog, "assertion failed"); + DEBB(DF_GP | DF_ERROR, ("assertion failed")); exit(1); } } @@ -222,15 +220,15 @@ namespace hr { namespace gp { auto& ac0 = get_mapping(at); ac0.cw = cellwalker(hs.at->c7, hs.spin, hs.mirrored); ac0.start = at; - WHD( println(hlog, at, " : ", dcw(ac0.cw)); ) + DEBB(DF_GP, (at, " : ", ac0.cw)); return ac0; } void extend_map(cell *c, int d) { - WHD( Xprintf("EXTEND %p %d\n", c, d); ) + DEBB(DF_GP, ("EXTEND ",c, " ", d)); if(c->master->c7 != c) { while(c->master->c7 != c) { - WHD( println(hlog, c, " direction 0 corresponds to ", c->move(0), " direction ", c->c.spinm(0)); ) + DEBB(DF_GP, (c, " direction 0 corresponds to ", c->move(0), " direction ", c->c.spin(0)); ) d = c->c.spin(0); c = c->move(0); } @@ -316,11 +314,11 @@ namespace hr { namespace gp { for(int i=0; i SEE_ALL) base_distlimit = SEE_ALL; prepare_matrices(); - if(debug_geometry) - println(hlog, "scale = ", scale); + DEBB(DF_GEOM | DF_POLY, ("scale = ", scale)); } else { alpha = 0; diff --git a/graph.cpp b/graph.cpp index b14dbf68..1bcb81e0 100644 --- a/graph.cpp +++ b/graph.cpp @@ -6423,6 +6423,8 @@ void precise_mouseover() { } void drawthemap() { + DEBBI(DF_GRAPH, ("draw the map")); + last_firelimit = firelimit; firelimit = 0; @@ -6468,8 +6470,6 @@ void drawthemap() { if(!spatial_graphics) wmspatial = mmspatial = false; if(DIM == 3) wmspatial = mmspatial = true; - DEBB(DF_GRAPH, (debugfile,"draw the map\n")); - for(int m=0; mxtop = vid.xres * cd->xmin; cd->ytop = vid.yres * cd->ymin; @@ -6707,7 +6707,7 @@ bool force_sphere_outline = false; void drawfullmap() { - DEBB(DF_GRAPH, (debugfile,"draw full map\n")); + DEBBI(DF_GRAPH, ("draw full map")); ptds.clear(); @@ -6869,9 +6869,9 @@ int cmode; void drawscreen() { - if(vid.xres == 0 || vid.yres == 0) return; + DEBBI(DF_GRAPH, ("drawscreen")); - DEBB(DF_GRAPH, (debugfile,"drawscreen\n")); + if(vid.xres == 0 || vid.yres == 0) return; calcparam(); // rug::setVidParam(); @@ -6962,7 +6962,7 @@ void drawscreen() { // SDL_UnlockSurface(s); glflush(); - DEBT("swapbuffers"); + DEBB(DF_GRAPH, ("swapbuffers")); #if CAP_SDL #if CAP_GL if(vid.usingGL) SDL_GL_SwapBuffers(); else @@ -6974,7 +6974,7 @@ void drawscreen() { } void restartGraph() { - DEBB(DF_INIT, (debugfile,"restartGraph\n")); + DEBBI(DF_INIT, ("restartGraph")); View = Id; if(!autocheat) linepatterns::clearAll(); @@ -6998,13 +6998,14 @@ void clearAnimations() { } auto graphcm = addHook(clearmemory, 0, [] () { - DEBB(DF_INIT, (debugfile,"clear graph memory\n")); + DEBBI(DF_MEMORY, ("clear graph memory")); mouseover = centerover.at = lmouseover = NULL; gmatrix.clear(); gmatrix0.clear(); clearAnimations(); }); void resetGeometry() { + DEBBI(DF_POLY | DF_GRAPH, ("resetGeometry")); #if MAXMDIM >= 4 if(DIM == 3 && !floor_textures) make_floor_textures(); diff --git a/help.cpp b/help.cpp index 16d43f14..51a2a1d2 100644 --- a/help.cpp +++ b/help.cpp @@ -48,7 +48,7 @@ vector extra_keys = { }; void buildHelpText() { - DEBB(DF_GRAPH, (debugfile,"buildHelpText\n")); + DEBBI(DF_GRAPH, ("buildHelpText")); help = XLAT("Welcome to HyperRogue"); #if ISANDROID @@ -729,7 +729,7 @@ int windtotal; hookset *hooks_mouseover; void describeMouseover() { - DEBB(DF_GRAPH, (debugfile,"describeMouseover\n")); + DEBBI(DF_GRAPH, ("describeMouseover")); cell *c = mousing ? mouseover : playermoved ? NULL : centerover.at; string& out = mouseovers; diff --git a/hyper.h b/hyper.h index 1519054d..097fb700 100644 --- a/hyper.h +++ b/hyper.h @@ -191,10 +191,6 @@ typedef long double ld; typedef complex cld; -#define DEBMEM(x) // { x fflush(stdout); } - -#define DEBSM(x) - #if MAXMDIM == 3 #define WDIM 2 #else @@ -3157,7 +3153,7 @@ struct hrmap_hyperbolic : hrmap_standard { hrmap_hyperbolic(heptagon *origin); heptagon *getOrigin() override { return origin; } ~hrmap_hyperbolic() { - DEBMEM ( verifycells(origin); ) + // verifycells(origin); // printf("Deleting hyperbolic map: %p\n", this); dynamicval ph(variation, mvar); clearfrom(origin); @@ -3665,20 +3661,31 @@ transmatrix cpush(int cid, ld alpha); bool eqmatrix(transmatrix A, transmatrix B, ld eps = 1e-2); void set_column(transmatrix& T, int i, const hyperpoint& H); -#define DF_INIT 0 // always display these -#define DF_MSG 0 // always display these -#define DF_STEAM 1 -#define DF_GRAPH 2 -#define DF_TURN 4 -#define DF_FIELD 8 +#define DF_INIT 1 // always display these +#define DF_MSG 2 // always display these +#define DF_WARN 4 // always display these +#define DF_ERROR 8 // always display these +#define DF_STEAM 16 +#define DF_GRAPH 32 +#define DF_TURN 64 +#define DF_FIELD 128 +#define DF_GEOM 256 +#define DF_MEMORY 512 +#define DF_TIME 1024 // a flag to display timestamps +#define DF_GP 2048 +#define DF_POLY 4096 +#define DF_KEYS "imwesxufgbtop" #if ISANDROID #define DEBB(r,x) +#define DEBB0(r,x) +#define DEBBI(r,x) #else -#define DEBB(r,x) { if(debugfile && (!(r) || (debugflags & (r)))) { fprintf x; fflush(debugfile); } } +#define DEBB(r,x) { if(debugflags & (r)) { println_log x; } } +#define DEBB0(r,x) { if(debugflags & (r)) { print_log x; } } +#define DEBBI(r,x) { if(debugflags & (r)) { println_log x; } } indenter_finish _debbi(debugflags & (r)); #endif -extern FILE *debugfile; extern int debugflags; int gmod(int i, int j); int gdiv(int i, int j); @@ -4190,8 +4197,6 @@ namespace gp { plainshape& get_plainshape(); } -extern bool debug_geometry; - #if CAP_SHAPES dqi_poly& queuepoly(const transmatrix& V, const hpcshape& h, color_t col); dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR prio); @@ -4705,11 +4710,15 @@ struct logger : hstream { int indentation; bool doindent; logger() { doindent = false; } - virtual void write_char(char c) { if(doindent) { doindent = false; for(int i=0; i void println_log(T... t) { println(hlog, t...); } +template void print_log(T... t) { print(hlog, t...); } #ifdef __GNUC__ __attribute__((__format__ (__printf__, 1, 2))) @@ -4737,6 +4746,11 @@ struct indenter { indenter(int i = 2) : ind(hlog.indentation, hlog.indentation + (i)) {} }; +struct indenter_finish : indenter { + indenter_finish(bool b): indenter(b ? 2:0) {} + ~indenter_finish() { if(hlog.indentation != ind.backup) println(hlog, "(done)"); } + }; + void appendHelp(string s); transmatrix rspintox(const hyperpoint& H); diff --git a/hypgraph.cpp b/hypgraph.cpp index ee0ab73f..6c5ca083 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1112,7 +1112,7 @@ void centerpc(ld aspd) { if(ors::mode == 2 && vid.sspeed < 5) return; if(vid.sspeed >= 4.99) aspd = 1000; - DEBB(DF_GRAPH, (debugfile,"center pc\n")); + DEBBI(DF_GRAPH, ("center pc")); ors::unrotate(cwtV); ors::unrotate(View); @@ -1172,7 +1172,7 @@ void optimizeview() { } #endif - DEBB(DF_GRAPH, (debugfile,"optimize view\n")); + DEBBI(DF_GRAPH, ("optimize view")); int turn = 0; ld best = INF; @@ -1246,7 +1246,7 @@ void ballgeometry() { } void resetview() { - DEBB(DF_GRAPH, (debugfile,"reset view\n")); + DEBBI(DF_GRAPH, ("reset view")); View = Id; // EUCLIDEAN if(!masterless) diff --git a/init.cpp b/init.cpp index 5436a7dc..e65d4dc6 100644 --- a/init.cpp +++ b/init.cpp @@ -8,12 +8,7 @@ namespace hr { #if CU_INIT int fontscale = 100; -#if ISANDROID -FILE *debfile; -#endif - -FILE *debugfile; -int debugflags; +int debugflags = DF_INIT | DF_ERROR | DF_WARN | DF_MSG | DF_TIME; string s0; @@ -297,7 +292,6 @@ void mobile_draw(MOBPAR_FORMAL) { if(!inmenu && vid.stereo_mode == sLR && ors::mode) mousex = vid.xres/2, mousey = vid.yres/2, mouseh = sphereflip * C0; -// if(debfile) fprintf(debfile, "d1\n"), fflush(debfile); frames++; conformal::configure(); diff --git a/menus.cpp b/menus.cpp index 4a212641..7fc1640d 100644 --- a/menus.cpp +++ b/menus.cpp @@ -18,7 +18,7 @@ int PREC(ld x) { void showOverview() { cmode = sm::ZOOMABLE | sm::OVERVIEW; - DEBB(DF_GRAPH, (debugfile,"show overview\n")); + DEBBI(DF_GRAPH, ("show overview")); if(dialog::infix != "") mouseovers = dialog::infix; @@ -905,7 +905,7 @@ string gettimestamp(msginfo& m) { } void showMessageLog() { - DEBB(DF_GRAPH, (debugfile,"show message log\n")); + DEBBI(DF_GRAPH, ("show message log")); int lines = vid.yres / vid.fsize - 2; int maxpos = isize(gamelog) - lines; diff --git a/polygons.cpp b/polygons.cpp index 068c53bc..5e3e3cd5 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -2732,7 +2732,7 @@ void buildpolys() { #if CAP_GP gp::clear_plainshapes(); #endif - DEBB(DF_INIT, (debugfile,"buildpolys\n")); + DEBBI(DF_POLY, ("buildpolys")); if(WDIM == 3) { if(sphere) SD3 = 3, SD7 = 5; @@ -3176,7 +3176,7 @@ void buildpolys() { bshapeend(); prehpc = isize(hpc); - DEBB(DF_INIT, (debugfile,"hpc = %d\n", prehpc)); + DEBB(DF_POLY, ("hpc = ", prehpc)); user_triangles_texture.tvertices.clear(); @@ -3192,9 +3192,9 @@ void buildpolys() { static int qhpc0; int qhpc = isize(hpc); - if(qhpc != qhpc0 && debug_geometry) { - printf("qhpc = %d (%d+%d)\n", qhpc0 = qhpc, prehpc, qhpc-prehpc); - printf("shapes = %d\n", isize(allshapes)); + if(qhpc != qhpc0 && (debugflags & (DF_GEOM | DF_POLY))) { + println(hlog, "qhpc = ", qhpc0=qhpc, " (", prehpc, "+", qhpc-prehpc, ")"); + println(hlog, "shapes = ", isize(allshapes)); int inve=0, issi=0, vcon=0, ccon=0; for(auto sh: allshapes) { if(sh->flags & POLY_INVERSE) inve++; @@ -3202,10 +3202,7 @@ void buildpolys() { if(sh->flags & POLY_VCONVEX) vcon++; if(sh->flags & POLY_CCONVEX) ccon++; } - printf("triangle flags = %x\n", shTriangle.flags); - printf("plain floor flags = %x\n", shFloor.b[0].flags); - printf("ball flags = %x\n", shDisk.flags); - printf("inverse = %d isside = %d vcon = %d ccon = %d\n", inve, issi, vcon, ccon); + println(hlog, format("inverse = %d isside = %d vcon = %d ccon = %d", inve, issi, vcon, ccon)); } initPolyForGL(); diff --git a/renderbuffer.cpp b/renderbuffer.cpp index 7acf5fd4..3cab0e58 100644 --- a/renderbuffer.cpp +++ b/renderbuffer.cpp @@ -94,7 +94,7 @@ renderbuffer::renderbuffer(int x, int y, bool gl) : x(x), y(y) { else valid = true; - printf("Framebuffer remains = %d (%d)\n", FramebufferName, valid); + DEBB(DF_GRAPH, ("Framebuffer remains = ", int(FramebufferName), " (", int(valid), ")")); GLERR("initialization"); rb.reset(); diff --git a/savemem.cpp b/savemem.cpp index be559e03..9ab2dfb9 100644 --- a/savemem.cpp +++ b/savemem.cpp @@ -58,13 +58,13 @@ void recursive_delete(heptagon *h, int i) { if(h2->move(i) && h2->move(i)->move(0) == h2) recursive_delete(h2, i); } if(h2->alt && h2->alt->alt == h2->alt) { - DEBSM(printf("destroying alternate map %p\n", h2->alt);) + DEBB(DF_MEMORY, ("destroying alternate map ", h2->alt)); for(hrmap *& hm: allmaps) { if(hm->getOrigin() == h2->alt) { delete hm; hm = allmaps.back(); allmaps.pop_back(); - DEBSM(printf("map found (%d altmaps total)\n", isize(allmaps));) + DEBB(DF_MEMORY, ("map found (", isize(allmaps), " altmaps total)")); break; } } @@ -140,7 +140,7 @@ void save_memory() { if(last_cleared && celldist(at->c7) < celldist(last_cleared->c7)) return; - DEBSM(printf("celldist = %d, %d\n", celldist(cwt.at), celldist(at->c7));) + DEBB(DF_MEMORY, ("celldist = ", make_pair(celldist(cwt.at), celldist(at->c7)))); heptagon *at1 = at; while(at != last_cleared && at != orig) { @@ -153,7 +153,7 @@ void save_memory() { } last_cleared = at1; - DEBSM(printf("current cellcount = %d\n", cellcount);) + DEBB(DF_MEMORY, ("current cellcount = ", cellcount)); sort(removed_cells.begin(), removed_cells.end()); callhooks(hooks_removecells); diff --git a/sound.cpp b/sound.cpp index d142d7b6..b5261cae 100644 --- a/sound.cpp +++ b/sound.cpp @@ -74,7 +74,7 @@ eLand cid = laNone; hookset *hooks_music; void handlemusic() { - DEBB(DF_GRAPH, (debugfile,"handle music\n")); + DEBBI(DF_GRAPH, ("handle music")); if(audio && musicvolume) { eLand id = getCurrentLandForMusic(); if(callhandlers(false, hooks_music, id)) return; @@ -120,7 +120,7 @@ void resetmusic() { } bool loadMusicInfo(string dir) { - DEBB(DF_INIT, (debugfile,"load music info\n")); + DEBBI(DF_INIT, ("load music info")); if(dir == "") return false; FILE *f = fopen(dir.c_str(), "rt"); if(f) { diff --git a/system.cpp b/system.cpp index 83b5a912..5830339e 100644 --- a/system.cpp +++ b/system.cpp @@ -102,7 +102,7 @@ hookset *hooks_initgame; // initialize the game void initgame() { - DEBB(DF_INIT, (debugfile,"initGame\n")); + DEBBI(DF_INIT, ("initGame")); callhooks(hooks_initgame); if(multi::players < 1 || multi::players > MAXPLAYER) @@ -826,7 +826,7 @@ void remove_emergency_save() { } void saveStats(bool emergency = false) { - DEBB(DF_INIT, (debugfile,"saveStats [%s]\n", scorefile)); + DEBBI(DF_INIT, ("saveStats [%s]", scorefile)); if(autocheat) return; #if CAP_TOUR @@ -940,7 +940,7 @@ void saveStats(bool emergency = false) { fprintf(f, "\n\n\n"); #if ISMOBILE==0 - DEBB(DF_INIT, (debugfile, "Game statistics saved to %s\n", scorefile)); + DEBB(DF_INIT, ("Game statistics saved to ", scorefile)); if(!tactic::trailer) addMessage(XLAT("Game statistics saved to %1", scorefile)); #endif @@ -953,7 +953,7 @@ void loadsave() { #if CAP_TOUR if(tour::on) return; #endif - DEBB(DF_INIT, (debugfile,"loadSave\n")); + DEBBI(DF_INIT, ("loadSave")); gamecount = 0; @@ -1139,7 +1139,7 @@ void popAllGames() { void stop_game() { if(!game_active) return; - DEBB(DF_INIT, (debugfile,"stop_game\n")); + DEBBI(DF_INIT, ("stop_game")); achievement_final(true); #if CAP_SAVE saveStats(); @@ -1232,7 +1232,7 @@ void set_variation(eVariation target) { } void switch_game_mode(char switchWhat) { - DEBB(DF_INIT, (debugfile,"switch_game_mode\n")); + DEBBI(DF_INIT, ("switch_game_mode ", switchWhat)); switch(switchWhat) { case rg::peace: peace::on = !peace::on; @@ -1351,7 +1351,7 @@ void switch_game_mode(char switchWhat) { void start_game() { if(game_active) return; - DEBB(DF_INIT, (debugfile,"start_game\n")); + DEBBI(DF_INIT, ("start_game")); restart: game_active = true; gamegen_failure = false; diff --git a/yendor.cpp b/yendor.cpp index 00a0769f..55c9aeac 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -720,7 +720,7 @@ namespace yendor { }) + addHook(hooks_removecells, 0, [] () { eliminate_if(yendor::yi, [] (yendorinfo& i) { for(int j=0; j