From a0da10b408bd470426dfeeeb1b4f468b09755dce Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 20:51:27 -0500 Subject: [PATCH 01/13] Remove extraneous semicolons to quiet pedantic GCC warnings. --- achievement.cpp | 2 +- archimedean.cpp | 2 +- classes.cpp | 2 +- dialogs.cpp | 8 ++++---- euclid.cpp | 4 ++-- graph.cpp | 4 ++-- help.cpp | 4 ++-- hypgraph.cpp | 2 +- landlock.cpp | 2 +- langen.cpp | 2 +- mapeditor.cpp | 2 +- pattern2.cpp | 2 +- raycaster.cpp | 4 ++-- rogueviz/newconf.cpp | 4 ++-- rogueviz/rogueviz.cpp | 2 +- surface.cpp | 2 +- system.cpp | 2 +- yendor.cpp | 2 +- 18 files changed, 26 insertions(+), 26 deletions(-) diff --git a/achievement.cpp b/achievement.cpp index 92a8b4a8..374ebe7b 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -964,7 +964,7 @@ EX void achievement_display() { EX bool isAscending(int i) { return i == 13 || i == 14 || i == 15 || i == 16 || i == 29 || i == 30 || i == 45; - }; + } EX int score_default(int i) { if(isAscending(i)) return 1999999999; diff --git a/archimedean.cpp b/archimedean.cpp index 14b6fbc4..ac5addbd 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -1144,7 +1144,7 @@ function setcanvas(char c) { patterns::whichCanvas = c; start_game(); }; - }; + } EX void show() { if(lastsample < isize(samples)) { diff --git a/classes.cpp b/classes.cpp index 45be9060..00f6ab7e 100644 --- a/classes.cpp +++ b/classes.cpp @@ -931,7 +931,7 @@ namespace mf { static const flagtype band = (cylindrical | pseudocylindrical | uses_bandshift); static const flagtype pseudoband = (pseudocylindrical | uses_bandshift); - }; + } struct modelinfo { const char *name_hyperbolic; diff --git a/dialogs.cpp b/dialogs.cpp index 43444ed9..8146aa87 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -37,7 +37,7 @@ EX namespace dialog { bool positive; }; - static inline ld identity_f(ld x) { return x; }; + static inline ld identity_f(ld x) { return x; } const static scaler identity = {identity_f, identity_f, false}; const static scaler logarithmic = {log, exp, true}; @@ -100,7 +100,7 @@ EX namespace dialog { if(clicked) hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, hicolor, align); return clicked; } - EX }; + EX } #if CAP_MENUSCALING && CAP_SDL EX void handleZooming(SDL_Event &ev) { @@ -142,7 +142,7 @@ EX namespace dialog { EX void handler(int sym, int uni) { dialog::handleNavigation(sym, uni); if(doexiton(sym, uni)) popScreen(); - }; + } EX void init() { items.clear(); @@ -1268,6 +1268,6 @@ EX namespace dialog { } #endif - }; + } } diff --git a/euclid.cpp b/euclid.cpp index 67879159..795684b8 100644 --- a/euclid.cpp +++ b/euclid.cpp @@ -459,7 +459,7 @@ EX namespace euc { cat += val * main_axes[i]; } return cat; - }; + } EX bool valid_third_turn(const intmatrix& m) { if(m[0][2] != -m[0][0]-m[0][1]) return false; @@ -630,7 +630,7 @@ EX namespace euc { int diagonal_cross(const coord& a, const coord& b) { return a[0]*b[1] + a[1]*b[2] + a[2]*b[0] - b[0]*a[1] - b[1]*a[2] - b[2]*a[0]; - }; + } void torus_config_full::canonicalize(coord& x, coord& d, transmatrix& M, bool& mirr) { if(!twisted) { diff --git a/graph.cpp b/graph.cpp index 836ec3c6..dfa33545 100644 --- a/graph.cpp +++ b/graph.cpp @@ -483,7 +483,7 @@ EX namespace tortoise { return gradient(0x487830, mcol, 0, dd, 0xFF); } - EX }; + EX } double footfun(double d) { d -= floor(d); @@ -5019,7 +5019,7 @@ namespace sm { static const int DIALOG_STRICT_X = 32768; // do not interpret dialog clicks outside of the X region static const int EXPANSION = (1<<16); static const int HEXEDIT = (1<<17); - }; + } #endif EX int cmode; diff --git a/help.cpp b/help.cpp index 05c1f32c..85ceea49 100644 --- a/help.cpp +++ b/help.cpp @@ -755,11 +755,11 @@ void gotoHelpFor(eItem i) { void gotoHelpFor(eWall w) { help = generateHelpForWall(w); - }; + } void gotoHelpFor(eMonster m) { help = generateHelpForMonster(m); - }; + } EX void appendHelp(string s) { auto h = helpgenerator; diff --git a/hypgraph.cpp b/hypgraph.cpp index d6d39b67..1ab9d276 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -307,7 +307,7 @@ hyperpoint compute_hybrid(hyperpoint H, int rootid) { return ret; } -EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); }; +EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); } EX void applymodel(hyperpoint H, hyperpoint& ret) { diff --git a/landlock.cpp b/landlock.cpp index 5e204c20..6c753798 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -516,7 +516,7 @@ namespace lv { static const flagtype appears_in_ptm = 8; static const flagtype display_in_help = 16; static const flagtype one_and_half = 32; - }; + } struct land_validity_t { int quality_level; // 0 (dont show), 1 (1/2), 2 (ok), 3(1!) diff --git a/langen.cpp b/langen.cpp index 03a911c3..531ececb 100644 --- a/langen.cpp +++ b/langen.cpp @@ -325,7 +325,7 @@ int main() { printf("#define NUMEXTRA %d\n", isize(vchars)); printf("#define NATCHARS {"); for(auto&& elt : vchars) printf("\"%s\",", elt.c_str()); - printf("};\n"); + printf("}\n"); printf("extern const char* natchars[NUMEXTRA];\n"); printf("#endif\n"); printf("#endif\n"); diff --git a/mapeditor.cpp b/mapeditor.cpp index b7bae2c0..2258e102 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -2141,7 +2141,7 @@ namespace mapeditor { addHook(hooks_removecells, 0, [] () { modelcell.clear(); set_if_removed(mapeditor::copysource.at, NULL); - });;; + }); #endif EX void initdraw(cell *c) { diff --git a/pattern2.cpp b/pattern2.cpp index 37919c38..eeae7d54 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -2889,7 +2889,7 @@ EX namespace linepatterns { dialog::display(); } - }; + } int val46(cell *c) { patterns::patterninfo si; diff --git a/raycaster.cpp b/raycaster.cpp index 5af5f95f..a5050bc4 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -136,7 +136,7 @@ struct raycaster : glhr::GLprogram { shared_ptr our_raycaster; -EX void reset_raycaster() { our_raycaster = nullptr; }; +EX void reset_raycaster() { our_raycaster = nullptr; } int deg; @@ -846,7 +846,7 @@ array enc(int i, int a) { res[0] = ((i%per_row) * deg + a + .5) / length; res[1] = ((i / per_row) + .5) / rows; return res; - }; + } color_t color_out_of_range = 0x0F0800FF; diff --git a/rogueviz/newconf.cpp b/rogueviz/newconf.cpp index 3bec3436..b666d3ba 100644 --- a/rogueviz/newconf.cpp +++ b/rogueviz/newconf.cpp @@ -120,7 +120,7 @@ struct coord { char out = '-'; -char& fmap_at(coord c) { return c.x >= 0 && c.x < isize(fmap[0]) && c.y >= 0 && c.y < isize(fmap) ? fmap[c.y][c.x] : out; }; +char& fmap_at(coord c) { return c.x >= 0 && c.x < isize(fmap[0]) && c.y >= 0 && c.y < isize(fmap) ? fmap[c.y][c.x] : out; } ld vx[256][256], vy[256][256]; @@ -398,7 +398,7 @@ void changepoint(int x, int y, bool can_add) { for(int k=0; k<4; k++) if(!live[k]) fmap_at(cc+k) = '0'; } - }; + } bool showmenu = true; diff --git a/rogueviz/rogueviz.cpp b/rogueviz/rogueviz.cpp index 2c4909b6..5cb963d3 100644 --- a/rogueviz/rogueviz.cpp +++ b/rogueviz/rogueviz.cpp @@ -2474,7 +2474,7 @@ auto hooks = addHook(hooks_markers, 100, search_marker) + 0; -}; +} #include "kohonen.cpp" #include "staircase.cpp" diff --git a/surface.cpp b/surface.cpp index fa78830d..ad2de140 100644 --- a/surface.cpp +++ b/surface.cpp @@ -192,7 +192,7 @@ bool flag_clamp_max(ld& coord, ld maxv) { bool flag_clamp(ld& coord, ld minv, ld maxv) { return flag_clamp_min(coord, minv) & flag_clamp_max(coord, maxv); - }; + } bool flag_clamp_sym(ld& coord, ld v) { return flag_clamp(coord, -v, v); diff --git a/system.cpp b/system.cpp index b6c6241d..8a4d6dd0 100644 --- a/system.cpp +++ b/system.cpp @@ -1572,5 +1572,5 @@ addHook(hooks_removecells, 0, [] () { eliminate_if(butterflies, [] (pair& p) { return is_cell_removed(p.first); }); for(int i=0; i Date: Fri, 21 Feb 2020 23:26:57 -0500 Subject: [PATCH 02/13] Eliminate `-Wmissing-field-initializers` warnings. --- .travis.yml | 2 +- Makefile.simple | 4 +-- classes.cpp | 64 ++++++++++++++++++++------------------- mymake.cpp | 2 +- rogueviz/banachtarski.cpp | 6 ++-- savepng.cpp | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1ca9058..b564c558 100644 --- a/.travis.yml +++ b/.travis.yml @@ -137,7 +137,7 @@ script: # Build hyperrogue. if [[ "$TRAVIS_BUILD_SYSTEM" == "autotools" ]]; then autoreconf -vi - ./configure CXXFLAGS="-Wall -Werror -Wno-unknown-warning-option -Wno-maybe-uninitialized" + ./configure CXXFLAGS="-W -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-unused-parameter -Wno-maybe-uninitialized" make elif [[ "$TRAVIS_BUILD_SYSTEM" == "Makefile" ]]; then make -f Makefile.simple CXX="${HYPERROGUE_CXX-g++}" diff --git a/Makefile.simple b/Makefile.simple index 7c626a61..af7f750f 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -82,13 +82,13 @@ endif ifeq (${TOOLCHAIN},clang) CXXFLAGS_EARLY += -std=c++11 -march=native CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic - CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-format-pedantic -Wno-missing-field-initializers -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized + CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-format-pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized endif ifeq (${TOOLCHAIN},gcc) CXXFLAGS_EARLY += -std=c++11 -march=native CXXFLAGS_EARLY += -W -Wall -Wextra -Werror - CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized + CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized endif ifeq (${TOOLCHAIN},mingw) diff --git a/classes.cpp b/classes.cpp index 00f6ab7e..32be1090 100644 --- a/classes.cpp +++ b/classes.cpp @@ -971,43 +971,45 @@ enum eModel : int { // (other bits are used for other information) #define X3(x) x, x, x +#define DEFAULTS 0, 0, 0, 0, 0, nullptr /** list of available models (i.e., projections) */ EX vector mdinf = { - {"disk/Gans", "general perspective", "general perspective", mf::azimuthal | mf::conformal}, - {"half-plane", "inversion", "half-plane", mf::conformal}, - {"band", "band", "Mercator", mf::band | mf::conformal}, - {X3("polygonal"), mf::conformal}, - {X3("formula"), 0}, - {X3("azimuthal equidistant"), mf::azimuthal | mf::equidistant | mf::euc_boring}, - {X3("azimuthal equi-area"), mf::azimuthal | mf::equiarea | mf::euc_boring}, - {X3("ball model"), mf::conformal | mf::azimuthal | mf::space}, - {"Minkowski hyperboloid", "plane", "sphere", mf::conformal | mf::space | mf::euc_boring}, - {"hemisphere", "sphere", "sphere", mf::conformal | mf::space}, - {X3("band equidistant"), mf::band | mf::equidistant | mf::euc_boring}, - {X3("band equi-area"), mf::band | mf::equiarea | mf::euc_boring}, - {X3("sinusoidal"), mf::pseudoband | mf::equiarea | mf::euc_boring}, - {X3("two-point equidistant"), mf::equidistant | mf::euc_boring | mf::twopoint}, - {X3("fisheye"), 0}, - {X3("Joukowsky transform"), mf::hyper_only | mf::conformal}, - {X3("Joukowsky+inversion"), mf::hyper_only | mf::conformal}, - {X3("rotated hyperboles"), mf::hyper_only}, - {X3("spiral/ring"), mf::hyper_or_torus | mf::uses_bandshift}, - {X3("native perspective"), 0}, - {X3("azimuthal equi-volume"), mf::azimuthal | mf::equivolume | mf::euc_boring}, - {X3("central inversion"), mf::azimuthal | mf::conformal}, - {X3("two-point azimuthal"), mf::euc_boring | mf::twopoint}, - {X3("two-point hybrid"), mf::euc_boring | mf::twopoint}, - {X3("geodesic"), 0}, - {X3("Mollweide"), mf::euc_boring | mf::pseudoband | mf::equiarea }, - {X3("central cylindrical"), mf::euc_boring | mf::band }, - {X3("Collignon"), mf::pseudoband | mf::equiarea }, - {X3("horocyclic coordinates"), mf::euc_boring }, - {X3("guard"), 0}, - {X3("polynomial"), mf::conformal} + {"disk/Gans", "general perspective", "general perspective", mf::azimuthal | mf::conformal, DEFAULTS}, + {"half-plane", "inversion", "half-plane", mf::conformal, DEFAULTS}, + {"band", "band", "Mercator", mf::band | mf::conformal, DEFAULTS}, + {X3("polygonal"), mf::conformal, DEFAULTS}, + {X3("formula"), 0, DEFAULTS}, + {X3("azimuthal equidistant"), mf::azimuthal | mf::equidistant | mf::euc_boring, DEFAULTS}, + {X3("azimuthal equi-area"), mf::azimuthal | mf::equiarea | mf::euc_boring, DEFAULTS}, + {X3("ball model"), mf::conformal | mf::azimuthal | mf::space, DEFAULTS}, + {"Minkowski hyperboloid", "plane", "sphere", mf::conformal | mf::space | mf::euc_boring, DEFAULTS}, + {"hemisphere", "sphere", "sphere", mf::conformal | mf::space, DEFAULTS}, + {X3("band equidistant"), mf::band | mf::equidistant | mf::euc_boring, DEFAULTS}, + {X3("band equi-area"), mf::band | mf::equiarea | mf::euc_boring, DEFAULTS}, + {X3("sinusoidal"), mf::pseudoband | mf::equiarea | mf::euc_boring, DEFAULTS}, + {X3("two-point equidistant"), mf::equidistant | mf::euc_boring | mf::twopoint, DEFAULTS}, + {X3("fisheye"), 0, DEFAULTS}, + {X3("Joukowsky transform"), mf::hyper_only | mf::conformal, DEFAULTS}, + {X3("Joukowsky+inversion"), mf::hyper_only | mf::conformal, DEFAULTS}, + {X3("rotated hyperboles"), mf::hyper_only, DEFAULTS}, + {X3("spiral/ring"), mf::hyper_or_torus | mf::uses_bandshift, DEFAULTS}, + {X3("native perspective"), 0, DEFAULTS}, + {X3("azimuthal equi-volume"), mf::azimuthal | mf::equivolume | mf::euc_boring, DEFAULTS}, + {X3("central inversion"), mf::azimuthal | mf::conformal, DEFAULTS}, + {X3("two-point azimuthal"), mf::euc_boring | mf::twopoint, DEFAULTS}, + {X3("two-point hybrid"), mf::euc_boring | mf::twopoint, DEFAULTS}, + {X3("geodesic"), 0, DEFAULTS}, + {X3("Mollweide"), mf::euc_boring | mf::pseudoband | mf::equiarea, DEFAULTS}, + {X3("central cylindrical"), mf::euc_boring | mf::band, DEFAULTS}, + {X3("Collignon"), mf::pseudoband | mf::equiarea, DEFAULTS}, + {X3("horocyclic coordinates"), mf::euc_boring, DEFAULTS}, + {X3("guard"), 0, DEFAULTS}, + {X3("polynomial"), mf::conformal, DEFAULTS}, }; #undef X3 +#undef DEFAULTS #if HDR static inline bool orbProtection(eItem it) { return false; } // not implemented diff --git a/mymake.cpp b/mymake.cpp index 1208ca20..35f76421 100644 --- a/mymake.cpp +++ b/mymake.cpp @@ -25,7 +25,7 @@ string preprocessor = "g++ -E"; string compiler = - "g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-unused-parameter -Wno-implicit-fallthrough -rdynamic -fdiagnostics-color=always -c"; + "g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-implicit-fallthrough -rdynamic -fdiagnostics-color=always -c"; string linker = "g++ -rdynamic -o hyper"; diff --git a/rogueviz/banachtarski.cpp b/rogueviz/banachtarski.cpp index 39fddac5..e399166a 100644 --- a/rogueviz/banachtarski.cpp +++ b/rogueviz/banachtarski.cpp @@ -151,10 +151,8 @@ void recursive_paint(cwpath& pinv, vector& way, int noway) { else gid = 3; - infos[c] = cellinfo{c, gid, 0}; - infos[c].way = way; - infos[c].pinv = pinv; - + infos[c] = cellinfo{c, gid, 0, waNone, itNone, laNone, moNone, way, pinv}; + // c->landparam ^= ((isize(way)&1) * 0x3F3F3F); // c->landparam = hsh; // d * 5 + 256 * (hsh&0xFFFF) + 0x400000; if(cidd>112899) c->landparam = 0x101010; diff --git a/savepng.cpp b/savepng.cpp index bc74ce50..ca05e308 100644 --- a/savepng.cpp +++ b/savepng.cpp @@ -41,7 +41,7 @@ extern "C" SDL_Surface *SDL_PNGFormatAlpha(SDL_Surface *src) { SDL_Surface *surf; - SDL_Rect rect = { 0 }; + SDL_Rect rect = { 0, 0, 0, 0 }; /* NO-OP for images < 32bpp and 32bpp images that already have Alpha channel */ if (src->format->BitsPerPixel <= 24 || src->format->Amask) { From 13bf666e291b9160342ed05bb20030f40d4863c4 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 22:42:52 -0500 Subject: [PATCH 03/13] Lambdas can't have default arguments until C++14. Arguably this is a reason to upgrade from C++11 to C++14, or to give up completely on `-pedantic`, but I think it's easy enough to eliminate these few nits. --- floorshapes.cpp | 16 ++++++++-------- graph.cpp | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/floorshapes.cpp b/floorshapes.cpp index d99b2815..359ed96e 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -35,7 +35,7 @@ void geometry_information::init_floorshapes() { for(auto s: all_plain_floorshapes) s->is_plain = true; - auto init_escher = [this] (escher_floorshape& sh, int s0, int s1, int noft=0, int s2=0) { + auto init_escher = [this] (escher_floorshape& sh, int s0, int s1, int noft, int s2) { sh.shapeid0 = s0; sh.shapeid1 = s1; sh.noftype = noft; @@ -45,22 +45,22 @@ void geometry_information::init_floorshapes() { all_escher_floorshapes.push_back(&sh); }; - init_escher(shStarFloor, 1,2); - init_escher(shCloudFloor, 3, 4); + init_escher(shStarFloor, 1, 2, 0, 0); + init_escher(shCloudFloor, 3, 4, 0, 0); init_escher(shCrossFloor, 5, 6, 2, 54); init_escher(shChargedFloor, 7, 385, 1, 10); - init_escher(shSStarFloor, 11, 12); + init_escher(shSStarFloor, 11, 12, 0, 0); init_escher(shOverFloor, 13, 15, 1, 14); init_escher(shTriFloor, 17, 18, 0, 385); init_escher(shFeatherFloor, 19, 21, 1, 20); init_escher(shBarrowFloor, 23, 24, 1, 25); init_escher(shNewFloor, 26, 27, 2, 54); - init_escher(shTrollFloor, 28, 29); + init_escher(shTrollFloor, 28, 29, 0, 0); init_escher(shButterflyFloor, 325, 326, 1, 178); init_escher(shLavaFloor, 359, 360, 1, 178); init_escher(shLavaSeabed, 386, 387, 1, 178); - init_escher(shSeabed, 334, 335); - init_escher(shCloudSeabed, 336, 337); + init_escher(shSeabed, 334, 335, 0, 0); + init_escher(shCloudSeabed, 336, 337, 0, 0); init_escher(shCaveSeabed, 338, 339, 2, 54); init_escher(shPalaceFloor, 45, 46, 0, 385); init_escher(shDemonFloor, 51, 50, 1, 178); @@ -71,7 +71,7 @@ void geometry_information::init_floorshapes() { init_escher(shSwitchFloor, 377, 378, 1, 379); init_escher(shTurtleFloor, 176, 177, 1, 178); for(int i: {0,1,2}) - init_escher(shRedRockFloor[i], 55, 56); + init_escher(shRedRockFloor[i], 55, 56, 0, 0); init_escher(shDragonFloor, 181, 182, 2, 183); /* dragon */ int ids = 0; diff --git a/graph.cpp b/graph.cpp index dfa33545..5a7884c7 100644 --- a/graph.cpp +++ b/graph.cpp @@ -750,7 +750,7 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int #else char xch = iinf[it].glyph; auto sinptick = [c, pticks] (int period) { return c ? sintick(period) : sin(animation_factor * pticks / period);}; - auto spinptick = [c, pticks] (int period, ld phase=0) { return c ? spintick(period, phase) : spin((animation_factor * pticks + phase) / period); }; + auto spinptick = [c, pticks] (int period, ld phase) { return c ? spintick(period, phase) : spin((animation_factor * pticks + phase) / period); }; int ct6 = c ? ctof(c) : 1; hpcshape *xsh = (it == itPirate || it == itKraken) ? &cgi.shPirateX : @@ -805,17 +805,17 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int } else if(it == itStrongWind) { - queuepoly(Vit * spinptick(750), cgi.shFan, darkena(icol, 0, 255)); + queuepoly(Vit * spinptick(750, 0), cgi.shFan, darkena(icol, 0, 255)); } else if(it == itWarning) { - queuepoly(Vit * spinptick(750), cgi.shTriangle, darkena(icol, 0, 255)); + queuepoly(Vit * spinptick(750, 0), cgi.shTriangle, darkena(icol, 0, 255)); } else if(it == itBabyTortoise) { int bits = c ? tortoise::babymap[c] : tortoise::last; int over = c && c->monst == moTortoise; - tortoise::draw(Vit * spinptick(5000) * ypush(cgi.crossf*.15), bits, over ? 4 : 2, 0); + tortoise::draw(Vit * spinptick(5000, 0) * ypush(cgi.crossf*.15), bits, over ? 4 : 2, 0); // queuepoly(Vit, cgi.shHeptaMarker, darkena(tortoise::getMatchColor(bits), 0, 0xC0)); } @@ -903,12 +903,12 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int else if(it == itRose) { for(int u=0; u<4; u++) - queuepoly(Vit * spinptick(1500) * spin(2*M_PI / 3 / 4 * u), cgi.shRoseItem, darkena(icol, 0, hidden ? 0x30 : 0xA0)); + queuepoly(Vit * spinptick(1500, 0) * spin(2*M_PI / 3 / 4 * u), cgi.shRoseItem, darkena(icol, 0, hidden ? 0x30 : 0xA0)); } else if(it == itBarrow && c) { for(int i = 0; ilandparam; i++) - queuepolyat(Vit * spin(2 * M_PI * i / c->landparam) * xpush(.15) * spinptick(1500), *xsh, darkena(icol, 0, hidden ? 0x40 : + queuepolyat(Vit * spin(2 * M_PI * i / c->landparam) * xpush(.15) * spinptick(1500, 0), *xsh, darkena(icol, 0, hidden ? 0x40 : (highwall(c) && wmspatial) ? 0x60 : 0xFF), PPR::HIDDEN); @@ -923,7 +923,7 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int if(it == itLotus) icol = 0x101010; if(it == itSwitch) icol = minf[active_switch()].color; - transmatrix V2 = Vit * spinptick(1500); + transmatrix V2 = Vit * spinptick(1500, 0); if(xsh == &cgi.shBookCover && mmitem) { if(GDIM == 3) @@ -957,11 +957,11 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int color_t col = darkena(icol, 0, int(0x80 + 0x70 * sinptick(300))); if(it == itOrbFish) - queuepolyat(Vit * spinptick(1500), cgi.shFishTail, col, PPR::ITEM_BELOW); + queuepolyat(Vit * spinptick(1500, 0), cgi.shFishTail, col, PPR::ITEM_BELOW); queuepolyat(Vit, cgi.shDisk, darkena(icol1, 0, inice ? 0x80 : hidden ? 0x20 : 0xC0), prio); - queuepolyat(Vit * spinptick(1500), orbshape(iinf[it].orbshape), col, prio); + queuepolyat(Vit * spinptick(1500, 0), orbshape(iinf[it].orbshape), col, prio); } else if(it) return true; From 7a706478dc946beddb8553f9286135fb36b2f969 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 21:48:46 -0500 Subject: [PATCH 04/13] Add a helper function `voidp` to silence GCC warnings about `%p`. We must fully qualify calls to `hr::voidp` because the expression `voidp(x)` is ambiguous or worse. "/usr/include/zconf.h" defines `voidp` in the global namespace as a typedef for `void*`. We don't want an unsafe functional-style cast to `void*`; we want to call our nice safe helper function. So we qualify the name. --- archimedean.cpp | 8 ++++---- barriers.cpp | 18 +++++++++--------- bigstuff.cpp | 20 ++++++++++---------- cell.cpp | 14 +++++++------- complex.cpp | 4 ++-- debug.cpp | 10 +++++----- help.cpp | 2 +- hyper.h | 5 +++++ irregular.cpp | 16 ++++++++-------- rogueviz/kohonen.cpp | 4 ++-- 10 files changed, 53 insertions(+), 48 deletions(-) diff --git a/archimedean.cpp b/archimedean.cpp index ac5addbd..73210aef 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -557,7 +557,7 @@ struct hrmap_archimedean : hrmap { heptagon *create_step(heptagon *h, int d) override { - DEBB(DF_GEOM, (format("%p.%d ~ ?\n", h, d))); + DEBB(DF_GEOM, (format("%p.%d ~ ?\n", hr::voidp(h), d))); heptspin hi(h, d); @@ -707,7 +707,7 @@ EX 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); - DEBB(DF_GEOM, (format("NEW %p.%d ~ %p.0\n", p.at, p.spin, h))); + DEBB(DF_GEOM, (format("NEW %p.%d ~ %p.0\n", hr::voidp(p.at), p.spin, hr::voidp(h)))); id_of(h) = adj.first; parent_index_of(h) = adj.second; int nei = neighbors_of(h); @@ -751,13 +751,13 @@ void connect_digons_too(heptspin h1, heptspin h2) { // no need to specify archimedean_gmatrix and altmap hnew->c.connect(1, h2); h1--, h2++; - DEBB(DF_GEOM, (format("OL2 %p.%d ~ %p.%d\n", h1.at, h1.spin, h2.at, h2.spin))); + DEBB(DF_GEOM, (format("OL2 %p.%d ~ %p.%d\n", hr::voidp(h1.at), h1.spin, hr::voidp(h2.at), h2.spin))); h1.at->c.connect(h1.spin, h2); } } void connectHeptagons(heptspin hi, heptspin hs) { - DEBB(DF_GEOM, (format("OLD %p.%d ~ %p.%d\n", hi.at, hi.spin, hs.at, hs.spin))); + DEBB(DF_GEOM, (format("OLD %p.%d ~ %p.%d\n", hr::voidp(hi.at), hi.spin, hr::voidp(hs.at), hs.spin))); if(hi.at->move(hi.spin) == hs.at && hi.at->c.spin(hi.spin) == hs.spin) { DEBB(DF_GEOM, (format("WARNING: already connected\n"))); return; diff --git a/barriers.cpp b/barriers.cpp index 357fb60d..6520fc76 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -43,7 +43,7 @@ EX void preventbarriers(cell *c) { } EX bool checkBarriersBack(cellwalker bb, int q IS(5), bool cross IS(false)) { - // printf("back, %p, s%d\n", bb.at, bb.spin); + // printf("back, %p, s%d\n", hr::voidp(bb.at), bb.spin); // if(mark) { printf("mpdist = %d [%d] bardir = %d spin=%d q=%d cross=%d\n", bb.at->mpdist, BARLEV, bb.at->bardir, bb.spin, q, cross); } @@ -172,7 +172,7 @@ EX bool mirrorwall(cell *c) { } EX void extendBarrierFront(cell *c) { - limitgen("extend front %p\n", c); + limitgen("extend front %p\n", hr::voidp(c)); if(buggyGeneration) return; int ht = c->landparam; extendcheck(c); @@ -222,7 +222,7 @@ EX void extendBarrierFront(cell *c) { } EX void extendBarrierBack(cell *c) { - limitgen("extend back %p\n", c); + limitgen("extend back %p\n", hr::voidp(c)); if(buggyGeneration) return; int ht = c->landparam; extendcheck(c); @@ -343,14 +343,14 @@ EX bool isbar4(cell *c) { } EX void extendBarrier(cell *c) { - limitgen("extend barrier %p\n", c); + limitgen("extend barrier %p\n", hr::voidp(c)); if(buggyGeneration) return; if(c->barleft == NOWALLSEP_USED) return; extendcheck(c); - // printf("build barrier at %p", c); + // printf("build barrier at %p", hr::voidp(c)); if(c->land == laBarrier || c->land == laElementalWall || c->land == laHauntedWall || c->land == laOceanWall || c->land == laMirrorWall || c->land == laMirrorWall2 || c->land == laMercuryRiver) { // printf("-> ready\n"); @@ -456,7 +456,7 @@ EX void buildBarrier(cell *c, int d, eLand l IS(laNone)) { } EX bool buildBarrier6(cellwalker cw, int type) { - limitgen("build6 %p/%d (%d)\n", cw.at, cw.spin, type); + limitgen("build6 %p/%d (%d)\n", hr::voidp(cw.at), cw.spin, type); cellwalker b[4]; @@ -481,7 +481,7 @@ EX bool buildBarrier6(cellwalker cw, int type) { if(false) { for(int z=0; z<4; z++) { - printf("%p/%d\n", b[z].at, b[z].spin); + printf("%p/%d\n", hr::voidp(b[z].at), b[z].spin); b[z].at->wall = waStrandedBoat; b[z].at->land = laAlchemist; b[z].at->mondir = b[z].spin; b[z].at->mpdist = 7; @@ -567,7 +567,7 @@ EX bool buildBarrier6(cellwalker cw, int type) { } EX bool buildBarrier4(cell *c, int d, int mode, eLand ll, eLand lr) { - limitgen("build4 %p\n", c); + limitgen("build4 %p\n", hr::voidp(c)); if(buggyGeneration) return true; d %= 7; @@ -833,7 +833,7 @@ EX bool buildBarrierNowall(cell *c, eLand l2, int forced_dir IS(NODIR)) { #endif if(c->land == laNone) { - printf("barrier nowall! [%p]\n", c); + printf("barrier nowall! [%p]\n", hr::voidp(c)); raiseBuggyGeneration(c, "barrier nowall!"); return false; } diff --git a/bigstuff.cpp b/bigstuff.cpp index 31ba450d..e71cc032 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -168,10 +168,10 @@ void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) { } if(relspin == -4 && geometry != gFieldQuotient) { if(h->alt != h->alt->alt) { - printf("relspin {%p:%p}\n", h->alt, h->alt->alt); - {for(int i=0; ialt->move(i));} printf(" ALT\n"); - {for(int i=0; imove(i));} printf(" REAL\n"); - {for(int i=0; imove(i)->alt);} printf(" REAL ALT\n"); + printf("relspin {%p:%p}\n", hr::voidp(h->alt), hr::voidp(h->alt->alt)); + {for(int i=0; ialt->move(i)));} printf(" ALT\n"); + {for(int i=0; imove(i)));} printf(" REAL\n"); + {for(int i=0; imove(i)->alt));} printf(" REAL ALT\n"); } relspin = 3; } } @@ -183,8 +183,8 @@ void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) { heptagon *hm = h->alt->move(ir); heptagon *ho = createStep(h, i); // printf("[%p:%d ~ %p:%d] %p ~ %p\n", -// h, i, h->alt, ir, -// ho, hm); +// hr::voidp(h), i, hr::voidp(h->alt), ir, +// hr::voidp(ho), hr::voidp(hm)); if(ho->alt && ho->alt != hm) { if(ho->alt->alt == hm->alt && !quotient) { printf("ERROR: alt cross! [%d -> %d]\n", ho->alt->distance, hm->distance); @@ -287,7 +287,7 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special heptagon *alt = tailored_alloc (h->type); allmaps.push_back(newAltMap(alt)); -//printf("new alt {%p}\n", alt); +//printf("new alt {%p}\n", hr::voidp(alt)); alt->s = firststate; alt->emeraldval = 0; alt->zebraval = 0; @@ -328,7 +328,7 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special } return alt; -//for(int d=rad; d>=0; d--) printf("%3d. %p {%d}\n", d, cx[d]->master, cx[d]->master->alt->distance); +//for(int d=rad; d>=0; d--) printf("%3d. %p {%d}\n", d, hr::voidp(cx[d]->master), cx[d]->master->alt->distance); } EX void beCIsland(cell *c) { @@ -393,7 +393,7 @@ EX void generateTreasureIsland(cell *c) { if(cc->wall != waCTree) end = false; } - // printf("%p: end=%d, qc=%d, dist=%d\n", c, end, qc, celldistAlt(c)); + // printf("%p: end=%d, qc=%d, dist=%d\n", hr::voidp(c), end, qc, celldistAlt(c)); if(end) c->item = itPirate; else c->item = itCompass; } @@ -567,7 +567,7 @@ EX void buildEquidistant(cell *c) { eLand b = c->land; if(chaosmode && !inmirror(b)) return; if(!b) { - printf("land missing at %p\n", c); + printf("land missing at %p\n", hr::voidp(c)); describeCell(c); for(int i=0; itype; i++) if(c->move(i)) describeCell(c->move(i)); diff --git a/cell.cpp b/cell.cpp index 388da364..44a676ea 100644 --- a/cell.cpp +++ b/cell.cpp @@ -85,7 +85,7 @@ struct hrmap_hyperbolic : hrmap_standard { heptagon *getOrigin() override { return origin; } ~hrmap_hyperbolic() { // verifycells(origin); - // printf("Deleting hyperbolic map: %p\n", this); + // printf("Deleting hyperbolic map: %p\n", hr::voidp(this)); clearfrom(origin); } void verify() override { verifycells(origin); } @@ -203,7 +203,7 @@ EX cell *createMov(cell *c, int d) { else if(GOLDBERG) { gp::extend_map(c, d); if(!c->move(d)) { - printf("extend failed to create for %p/%d\n", c, d); + printf("extend failed to create for %p/%d\n", hr::voidp(c), d); exit(1); } hybrid::link(); @@ -314,9 +314,9 @@ EX void initcells() { EX void clearcell(cell *c) { if(!c) return; - DEBB(DF_MEMORY, (format("c%d %p\n", c->type, c))); + DEBB(DF_MEMORY, (format("c%d %p\n", c->type, hr::voidp(c)))); for(int t=0; ttype; t++) if(c->move(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)))); + DEBB(DF_MEMORY, (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, (format("cell error: type = %d %d -> %d\n", c->type, t, c->c.spin(t)))); @@ -324,7 +324,7 @@ EX void clearcell(cell *c) { } c->move(t)->move(c->c.spin(t)) = NULL; } - DEBB(DF_MEMORY, (format("DEL %p\n", c))); + DEBB(DF_MEMORY, (format("DEL %p\n", hr::voidp(c)))); tailored_delete(c); } @@ -416,7 +416,7 @@ EX void verifycell(cell *c) { if(c2) { 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", c, i, c->type, c2, c->c.spin(i), c2->type); + 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); } } @@ -426,7 +426,7 @@ EX void verifycell(cell *c) { EX void verifycells(heptagon *at) { if(GOLDBERG || IRREGULAR || arcm::in()) return; for(int i=0; itype; i++) if(at->move(i) && at->move(i)->move(at->c.spin(i)) && at->move(i)->move(at->c.spin(i)) != at) { - printf("hexmix error %p [%d s=%d] %p %p\n", at, i, at->c.spin(i), at->move(i), at->move(i)->move(at->c.spin(i))); + printf("hexmix error %p [%d s=%d] %p %p\n", hr::voidp(at), i, at->c.spin(i), hr::voidp(at->move(i)), hr::voidp(at->move(i)->move(at->c.spin(i)))); } if(!sphere && !quotient) for(int i=0; imove(i) && at->c.spin(i) == 0 && at->s != hsOrigin) diff --git a/complex.cpp b/complex.cpp index be138181..60ae262a 100644 --- a/complex.cpp +++ b/complex.cpp @@ -2629,7 +2629,7 @@ EX namespace dragon { } if(cmode & sm::MAP) return c; if(!history::includeHistory) { - printf("dragon bug #3 (%p -> %p)\n", cor, c); + printf("dragon bug #3 (%p -> %p)\n", hr::voidp(cor), hr::voidp(c)); dragbugs = true; } c->monst = moDragonHead; return c; @@ -3119,7 +3119,7 @@ EX namespace prairie { forCellEx(c2, c) forCellEx(c3, c2) if(barrierhept(c3)) barclose++; - printf("c = %p bc = %d\n", c, barclose); + printf("c = %p bc = %d\n", hr::voidp(c), barclose); raiseBuggyGeneration(c, "could not set river fval"); } diff --git a/debug.cpp b/debug.cpp index d139b475..7185782a 100644 --- a/debug.cpp +++ b/debug.cpp @@ -44,7 +44,7 @@ bool errorReported = false; EX void describeCell(cell *c) { if(!c) { printf("NULL\n"); return; } - printf("describe %p: ", c); + printf("describe %p: ", hr::voidp(c)); printf("%-15s", linf[c->land].name); printf("%-15s", winf[c->wall].name); printf("%-15s", iinf[c->item].name); @@ -285,7 +285,7 @@ EX bool applyCheat(char u, cell *c IS(NULL)) { if(u == 'L'-64) { cell *c = mouseover; describeCell(c); - printf("Neighbors:"); for(int i=0; itype; i++) printf("%p ", c->move(i)); + printf("Neighbors:"); for(int i=0; itype; i++) printf("%p ", hr::voidp(c->move(i))); printf("Barrier: dir=%d left=%d right=%d\n", c->bardir, c->barleft, c->barright); return true; @@ -358,7 +358,7 @@ struct debugScreen { queuepoly(gmatrix[what], cgi.shAsymmetric, 0x80808080); #endif char buf[200]; - sprintf(buf, "%p", what); + sprintf(buf, "%p", hr::voidp(what)); dialog::addSelItem("mpdist", its(what->mpdist), 'd'); dialog::add_action([what] () { bitfield_editor(what->mpdist, [what] (int i) { what->mpdist = 0; }, "generation level"); @@ -561,7 +561,7 @@ EX void viewall() { EX void modalDebug(cell *c) { centerover = c; View = Id; if(noGUI) { - fprintf(stderr, "fatal: modalDebug called on %p without GUI\n", c); + fprintf(stderr, "fatal: modalDebug called on %p without GUI\n", hr::voidp(c)); exit(1); } push_debug_screen(); @@ -583,7 +583,7 @@ void test_distances(int max) { EX void raiseBuggyGeneration(cell *c, const char *s) { - printf("procgen error (%p): %s\n", c, s); + printf("procgen error (%p): %s\n", hr::voidp(c), s); if(!errorReported) { addMessage(string("something strange happened in: ") + s); diff --git a/help.cpp b/help.cpp index 85ceea49..32227e7c 100644 --- a/help.cpp +++ b/help.cpp @@ -832,7 +832,7 @@ EX void describeMouseover() { if(c->land == laTortoise && tortoise::seek()) out += " " + tortoise::measure(getBits(c)); if(buggyGeneration) { - char buf[80]; sprintf(buf, " %p H=%d M=%d", c, c->landparam, c->mpdist); out += buf; + char buf[80]; sprintf(buf, " %p H=%d M=%d", hr::voidp(c), c->landparam, c->mpdist); out += buf; } if(randomPatternsMode) diff --git a/hyper.h b/hyper.h index f04f735b..c1e5d055 100644 --- a/hyper.h +++ b/hyper.h @@ -35,6 +35,11 @@ template void ignore(T&&) { } +const void *voidp(const void *p) { + // a simple static_cast for use with printf("%p") + return p; + } + /** Is the value of first parameter equal to one of the remaining parameters? */ template bool among(T x, V y) { return x == y; } template bool among(T x, V y, U... u) { return x==y || among(x,u...); } diff --git a/irregular.cpp b/irregular.cpp index fcfe6532..75750737 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -144,7 +144,7 @@ void rebase(cellinfo& ci) { cell *cx = ci.owner; virtualRebase(ci.owner, ci.p); if(ci.owner != cx) { - printf("rebased %p to %p\n", cx, ci.owner); + printf("rebased %p to %p\n", hr::voidp(cx), hr::voidp(ci.owner)); set_relmatrices(ci); } } @@ -463,7 +463,7 @@ bool step(int delta) { int heptas = 0; for(auto p: cells_of_heptagon) { - printf("%p: %d\n", p.first, isize(p.second)); + printf("%p: %d\n", hr::voidp(p.first), isize(p.second)); heptas++; } @@ -583,7 +583,7 @@ struct heptinfo { EX map periodmap; EX void link_to_base(heptagon *h, heptspin base) { - // printf("linking %p to %p/%d\n", h, base.at, base.spin); + // printf("linking %p to %p/%d\n", hr::voidp(h), hr::voidp(base.at), base.spin); auto &hi = periodmap[h]; hi.base = base; for(int k: cells_of_heptagon[base.at]) { @@ -612,7 +612,7 @@ EX void link_start(heptagon *h) { EX void link_next(heptagon *parent, int d) { if(!periodmap.count(parent)) link_to_base(parent, heptspin(cells[0].owner->master, 0)); - // printf("linking next: %p direction %d [s%d]\n", parent, d, parent->c.spin(d)); + // printf("linking next: %p direction %d [s%d]\n", hr::voidp(parent), d, parent->c.spin(d)); auto *h = parent->move(d); heptspin hs = periodmap[parent].base + d + wstep - parent->c.spin(d); link_to_base(h, hs); @@ -625,7 +625,7 @@ EX void may_link_next(heptagon *parent, int d) { EX void link_cell(cell *c, int d) { - // printf("linking cell: %p direction %d\n", c, d); + // printf("linking cell: %p direction %d\n", hr::voidp(c), d); int ci = cellindex[c]; auto& sc = cells[ci]; int ci2 = sc.neid[d]; @@ -644,7 +644,7 @@ EX void link_cell(cell *c, int d) { heptspin hss(c->master, d); hss += wstep; master2 = hss.at; - // printf("master2 is %p; base = %p; should be = %p\n", master2, periodmap[master2].base.at, sc2.owner->master); + // printf("master2 is %p; base = %p; should be = %p\n", hr::voidp(master2), hr::voidp(periodmap[master2].base.at), hr::voidp(sc2.owner->master)); dirs++; } if(dirs != 1) { printf("dirs error\n"); exit(1); } @@ -674,7 +674,7 @@ map last_on_horocycle; void compute_horocycle(heptagon *); void compute_distances(heptagon *h, bool alts) { - /* if(alts) printf("[%p] compute_distances %p\n", h->alt->alt, h); + /* if(alts) printf("[%p] compute_distances %p\n", hr::voidp(h->alt->alt), hr::voidp(h)); printf("neighbors:"); for(int i=0; ialt->distance, master, alt); + // printf("computing horocycle, master distance = %d [M=%p, A=%p]\n", master->alt->distance, hr::voidp(master), hr::voidp(alt)); static const int LOOKUP = 16; set hs[LOOKUP]; diff --git a/rogueviz/kohonen.cpp b/rogueviz/kohonen.cpp index 0bed85ef..24a7b11e 100644 --- a/rogueviz/kohonen.cpp +++ b/rogueviz/kohonen.cpp @@ -480,14 +480,14 @@ void verify_crawlers() { if(allcrawlers.count(id.first)) { bool b = verify_crawler(allcrawlers[id.first], cellwalker(c, id.second)); if(!b) { - printf("cell %p: type = %d id = %d dir = %d / earlier crawler failed\n", c, c->type, id.first, id.second); + printf("cell %p: type = %d id = %d dir = %d / earlier crawler failed\n", hr::voidp(c), c->type, id.first, id.second); failures++; } } else { for(int i=0; itype; i++) for(auto& cc: allcrawlers) if(verify_crawler(cc.second, cellwalker(c, i))) { - printf("cell %p: type = %d id = %d dir = %d / also works id %d in direction %d\n", c, c->type, id.first, id.second, cc.first, i); + printf("cell %p: type = %d id = %d dir = %d / also works id %d in direction %d\n", hr::voidp(c), c->type, id.first, id.second, cc.first, i); uniq--; goto breakcheck; } From 561a3ebade491df314b319fc20b01b399af30527 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 22:03:32 -0500 Subject: [PATCH 05/13] Silence a pedantic GCC warning by adding reinterpret_cast. Here we're casting a function pointer to `void*`, which is not doable with our implicit-conversions-only `hr::voidp(x)` helper, and is not even doable with a `static_cast`; we must `reinterpret_cast`. --- glhr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glhr.cpp b/glhr.cpp index e23d454f..7fa5e7b8 100644 --- a/glhr.cpp +++ b/glhr.cpp @@ -625,7 +625,7 @@ void init() { printf("Failed to initialize GLEW\n"); return; } - printf("CreateProgram = %p\n", __glewCreateProgram); + printf("CreateProgram = %p\n", reinterpret_cast(__glewCreateProgram)); if(!__glewCreateProgram) noshaders = true; } #endif From 364c33b1d875b590539e5e79a6bb804b2ca7d599 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 22:40:10 -0500 Subject: [PATCH 06/13] Fix a (likely harmless) integer overflow in shmup.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit shmup.cpp: In function ‘void hr::shmup::moveMonster(hr::shmup::monster*, int)’: shmup.cpp:1851:41: error: overflow in implicit constant conversion [-Werror=overflow] else killMonster(m, moNone, AF_CRUSH); ^ --- shmup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shmup.cpp b/shmup.cpp index bbce9723..de4ebde6 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -238,7 +238,7 @@ bool isMonster(monster *m) { return m->type != moPlayer && m->type != moBullet; EX hookset *hooks_kill; -void killMonster(monster* m, eMonster who_kills, int flags = 0) { +void killMonster(monster* m, eMonster who_kills, flagtype flags = 0) { int tk = tkills(); if(callhandlers(false, hooks_kill, m)) return; if(m->dead) return; From e59d22e3993c9c855e616cc03fd5bd86ed6b5992 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 22:49:26 -0500 Subject: [PATCH 07/13] Silence some pedantic format warnings from Clang. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rogueviz/rogueviz.cpp: In function ‘hr::color_t rogueviz::parse1(const string&)’: rogueviz/rogueviz.cpp:76:75: error: format ‘%x’ expects argument of type ‘unsigned int*’, but argument 3 has type ‘int*’ [-Werror=format=] sscanf(s.c_str(), "R%x,%x,%x,%d,%d", &mh, &minh, &alpha, &step, &start); ^ I believe these three variables should have been `color_t` all along. I think this fix doesn't change any of the arithmetic, but I could be wrong. --- rogueviz/rogueviz.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rogueviz/rogueviz.cpp b/rogueviz/rogueviz.cpp index 5cb963d3..03bc13b1 100644 --- a/rogueviz/rogueviz.cpp +++ b/rogueviz/rogueviz.cpp @@ -72,7 +72,8 @@ color_t parse1(const string& s) { // color can be given as RRGGBB // or as 'Rmax,min,alpha,step,start', for rainbow Collatz if(s[0] == 'R') { - int mh = 192, minh = 0, alpha = 255, step = 50, start = 0; + color_t mh = 192, minh = 0, alpha = 255; + int step = 50, start = 0; sscanf(s.c_str(), "R%x,%x,%x,%d,%d", &mh, &minh, &alpha, &step, &start); vector hues; color_t difh = mh - minh; From b450ca1596d91f3406b45ae075d672738a9ca654 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 00:20:08 -0500 Subject: [PATCH 08/13] Add `-pedantic` to the compiler options, and clean up some cruft. --- .travis.yml | 2 +- Makefile.simple | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index b564c558..30a3f5b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -137,7 +137,7 @@ script: # Build hyperrogue. if [[ "$TRAVIS_BUILD_SYSTEM" == "autotools" ]]; then autoreconf -vi - ./configure CXXFLAGS="-W -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-unused-parameter -Wno-maybe-uninitialized" + ./configure CXXFLAGS="-W -Wall -Wextra -Werror -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-unknown-warning-option" make elif [[ "$TRAVIS_BUILD_SYSTEM" == "Makefile" ]]; then make -f Makefile.simple CXX="${HYPERROGUE_CXX-g++}" diff --git a/Makefile.simple b/Makefile.simple index af7f750f..e199942f 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -82,19 +82,19 @@ endif ifeq (${TOOLCHAIN},clang) CXXFLAGS_EARLY += -std=c++11 -march=native CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic - CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-format-pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized + CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option endif ifeq (${TOOLCHAIN},gcc) CXXFLAGS_EARLY += -std=c++11 -march=native - CXXFLAGS_EARLY += -W -Wall -Wextra -Werror - CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized + CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic + CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized endif ifeq (${TOOLCHAIN},mingw) CXXFLAGS_EARLY += -std=c++11 -march=native CXXFLAGS_EARLY += -W -Wall -Wextra -Werror - CXXFLAGS_EARLY += -Wno-unknown-warning-option -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized + CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized endif From af69faa64646ea9fde2cac9a4052e01384286eeb Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Feb 2020 23:47:30 -0500 Subject: [PATCH 09/13] Fix a harmless misuse of `DEBBI`. --- system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system.cpp b/system.cpp index 8a4d6dd0..e605cfd1 100644 --- a/system.cpp +++ b/system.cpp @@ -918,7 +918,7 @@ EX void remove_emergency_save() { } EX void saveStats(bool emergency IS(false)) { - DEBBI(DF_INIT, ("saveStats [%s]", scorefile)); + DEBBI(DF_INIT, ("saveStats [", scorefile, "]")); if(autocheat) return; #if CAP_TOUR From 2461b29ea25234fa9932d8a7da4f7820f6aaf338 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 23 Mar 2020 14:45:59 -0400 Subject: [PATCH 10/13] Include for the benefit of "hprint.cpp". --- sysconfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sysconfig.h b/sysconfig.h index ae2c51cc..c5b71623 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -421,6 +421,7 @@ extern "C" { #include #include #include +#include #include #include #include From 5cc8a41beb5f780543502ddd44d8d0eeadcc058b Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 23 Mar 2020 14:48:41 -0400 Subject: [PATCH 11/13] Turn C-style casts into reinterpret_casts for clarity. NFC. --- graph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph.cpp b/graph.cpp index 5a7884c7..09eb170b 100644 --- a/graph.cpp +++ b/graph.cpp @@ -595,7 +595,7 @@ transmatrix otherbodyparts(const transmatrix& V, color_t col, eMonster who, doub #define VAHEAD mmscale(V, cgi.AHEAD) #define VFISH V -#define VBIRD ((GDIM == 3 || (where && bird_disruption(where))) ? (WDIM == 2 ? mmscale(V, cgi.BIRD) : V) : mmscale(V, cgi.BIRD + .05 * sintick(1000, (int) (size_t(where))/1000.))) +#define VBIRD ((GDIM == 3 || (where && bird_disruption(where))) ? (WDIM == 2 ? mmscale(V, cgi.BIRD) : V) : mmscale(V, cgi.BIRD + .05 * sintick(1000, static_cast(reinterpret_cast(where))/1000.))) #define VGHOST mmscale(V, cgi.GHOST) #define VSLIMEEYE mscale(V, cgi.FLATEYE) From f49c57c4f0098e746187bb7366356135a5670b92 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 23 Mar 2020 14:48:56 -0400 Subject: [PATCH 12/13] Fix a bug found by Clang's `-Wtautological-overlap-compare`. ./help.cpp:880:89: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if(!((c->wall == waCavefloor || c->wall == waCavewall) && (c->land == laEmerald && c->land == laCaves))) ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ --- help.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help.cpp b/help.cpp index 32227e7c..4c69038d 100644 --- a/help.cpp +++ b/help.cpp @@ -877,7 +877,7 @@ EX void describeMouseover() { "Trees in this forest can be chopped down. Big trees take two turns to chop down."; else if(c->wall != waSea && c->wall != waPalace && c->wall != waDeadfloor) - if(!((c->wall == waCavefloor || c->wall == waCavewall) && (c->land == laEmerald && c->land == laCaves))) + if(!((c->wall == waCavefloor || c->wall == waCavewall) && (c->land == laEmerald || c->land == laCaves))) if(!((isAlch(c->wall) && c->land == laAlchemist))) help = bygen([c] () { gotoHelpFor(c->wall); }); } From 14c098eaf979608201ef2d0f422e5641ea3a4ba6 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 23 Mar 2020 14:50:56 -0400 Subject: [PATCH 13/13] Add whitespace to silence Clang's `-Wmisleading-indentation`. NFC. ./fieldpattern.cpp:440:5: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] if(isize(res) > limitp) return res; ^ --- fieldpattern.cpp | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 8cc90e0f..292ae5b7 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -409,34 +409,34 @@ vector fpattern::generate_isometries3() { if(dis && dis->stop_it) return res; #endif - for(T[0][2]=low; T[0][2] limitp) return res; }