From 0410f54d43ec6942cdb5c3c1492595df5110219e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 15 Apr 2023 01:24:16 +0200 Subject: [PATCH] rogueviz:: added some guards --- rogueviz/ascending-descending.cpp | 2 ++ rogueviz/dhrg-pres.cpp | 3 ++- rogueviz/gobot.cpp | 4 ++-- rogueviz/hypcity.cpp | 5 ++++- rogueviz/hyperbolic-analogs.cpp | 3 ++- rogueviz/hyperbolic-minesweeper-pres.cpp | 4 ++-- rogueviz/intra-demos.cpp | 3 ++- rogueviz/noniso-honeycombs.cpp | 4 ++++ rogueviz/objmodels.cpp | 3 ++- rogueviz/pentagonal.cpp | 2 +- rogueviz/planets.cpp | 2 ++ rogueviz/platformer.cpp | 3 ++- rogueviz/playing-with-impossibility.cpp | 3 ++- rogueviz/rogueviz-all.cpp | 4 ++++ rogueviz/rogueviz.h | 8 ++++++++ rogueviz/snow.cpp | 11 ++++++++++- rogueviz/staircase.cpp | 2 ++ 17 files changed, 53 insertions(+), 13 deletions(-) diff --git a/rogueviz/ascending-descending.cpp b/rogueviz/ascending-descending.cpp index cd64fb66..0a70389e 100644 --- a/rogueviz/ascending-descending.cpp +++ b/rogueviz/ascending-descending.cpp @@ -2,6 +2,7 @@ namespace hr { +#if CAP_MODELS namespace ply { using namespace rogueviz::objmodels; @@ -296,4 +297,5 @@ auto plyhook = }); } +#endif } diff --git a/rogueviz/dhrg-pres.cpp b/rogueviz/dhrg-pres.cpp index 25e08c40..de5da323 100644 --- a/rogueviz/dhrg-pres.cpp +++ b/rogueviz/dhrg-pres.cpp @@ -3,7 +3,7 @@ #include "rogueviz.h" #define RVPATH HYPERPATH "rogueviz/" - +#if CAP_RVPRES namespace dhrg { void graphv(std::string s); extern double graph_R; @@ -749,3 +749,4 @@ int dhrg_phooks = }); } +#endif diff --git a/rogueviz/gobot.cpp b/rogueviz/gobot.cpp index 96808e58..29230a63 100644 --- a/rogueviz/gobot.cpp +++ b/rogueviz/gobot.cpp @@ -21,7 +21,7 @@ #include "rogueviz.h" namespace hr { - +#if CAP_THREADS EX namespace gobot { eWall empty = waChasm; @@ -615,6 +615,6 @@ auto gobot_hook = #endif EX } - +#endif EX } diff --git a/rogueviz/hypcity.cpp b/rogueviz/hypcity.cpp index 96802fc1..9991ca38 100644 --- a/rogueviz/hypcity.cpp +++ b/rogueviz/hypcity.cpp @@ -15,6 +15,7 @@ // add -PM 0 -alpha 1 namespace hr { +#if CAP_MODELS namespace hypcity { using namespace rogueviz::objmodels; @@ -165,4 +166,6 @@ auto hypcity_ah = arg::add3("-hypcity", enable) cb(XLAT("non-Euclidean city"), &hypcity_slides[0], 'c'); }); -}} +} +#endif +} diff --git a/rogueviz/hyperbolic-analogs.cpp b/rogueviz/hyperbolic-analogs.cpp index 8c3afc44..a21d22ef 100644 --- a/rogueviz/hyperbolic-analogs.cpp +++ b/rogueviz/hyperbolic-analogs.cpp @@ -4,7 +4,7 @@ // run: -analogs namespace hr { - +#if CAP_TEXTURE namespace analogs { patterns::ePattern wp; @@ -464,5 +464,6 @@ auto msc = arg::add3("-analogs", enable) }); } +#endif } diff --git a/rogueviz/hyperbolic-minesweeper-pres.cpp b/rogueviz/hyperbolic-minesweeper-pres.cpp index 4eb2dba8..0290d0a0 100644 --- a/rogueviz/hyperbolic-minesweeper-pres.cpp +++ b/rogueviz/hyperbolic-minesweeper-pres.cpp @@ -5,7 +5,7 @@ #include "dynamic-wfc.cpp" namespace hr { - +#if CAP_RVSLIDES cell* starter; void geom_euc_rec() { @@ -966,7 +966,7 @@ int phooks = addHook_slideshows(100, [] (tour::ss::slideshow_callback cb) { cb(XLAT("Hyperbolic Minesweeper is in P"), &sweeper_slides[0], 'h'); }); - +#endif } // kolor zmienic dziada diff --git a/rogueviz/intra-demos.cpp b/rogueviz/intra-demos.cpp index 9d7f1419..3af8484d 100644 --- a/rogueviz/intra-demos.cpp +++ b/rogueviz/intra-demos.cpp @@ -8,6 +8,7 @@ namespace hr { +#if CAP_RAY && MAXMDIM >= 4 namespace intraf { using namespace intra; @@ -629,5 +630,5 @@ auto hooks = {loader{"run this visualization", 'r', load("solv-h3-scene.lev", 0.05, 3000)}}); })); } - +#endif } diff --git a/rogueviz/noniso-honeycombs.cpp b/rogueviz/noniso-honeycombs.cpp index 00227881..3f8f16bd 100644 --- a/rogueviz/noniso-honeycombs.cpp +++ b/rogueviz/noniso-honeycombs.cpp @@ -8,6 +8,7 @@ bool alone = true; bool in_special = false; +#if CAP_RVSLIDES auto geoslide(eGeometry g, char canvas, int jhole, int jblock) { using namespace tour; return [=] (presmode mode) { @@ -85,9 +86,11 @@ auto geoslide(eGeometry g, char canvas, int jhole, int jblock) { } }; } +#endif string cap = "honeycombs/"; +#if CAP_RVSLIDES void honey(string s, vector& v) { if(s != "noniso") return; using namespace tour; @@ -148,6 +151,7 @@ void honey(string s, vector& v) { }); } +#endif #if CAP_RVSLIDES vector noniso_slides; diff --git a/rogueviz/objmodels.cpp b/rogueviz/objmodels.cpp index 89391e5d..5379b62e 100644 --- a/rogueviz/objmodels.cpp +++ b/rogueviz/objmodels.cpp @@ -3,7 +3,7 @@ #include "rogueviz.h" namespace rogueviz { - +#if CAP_MODELS namespace objmodels { bool scan(fhstream& hs, char& c) { return fscanf(hs.f, "%c", &c) == 1; } @@ -330,4 +330,5 @@ auto cf = addHook(hooks_configfile, 100, [] { }); } +#endif } diff --git a/rogueviz/pentagonal.cpp b/rogueviz/pentagonal.cpp index c7263fc7..63666350 100644 --- a/rogueviz/pentagonal.cpp +++ b/rogueviz/pentagonal.cpp @@ -86,8 +86,8 @@ void make_texture() { } tdata.loadTextureGL(); - #endif rug::alternate_texture = tdata.textureid; + #endif } void create_model(); diff --git a/rogueviz/planets.cpp b/rogueviz/planets.cpp index 49ce418d..77faefb0 100644 --- a/rogueviz/planets.cpp +++ b/rogueviz/planets.cpp @@ -2,6 +2,7 @@ namespace hr { +#if CAP_TEXTURE namespace planets { texture::texture_data earth, neptune, mars, moon, sun; @@ -544,5 +545,6 @@ auto msc = }); } +#endif } diff --git a/rogueviz/platformer.cpp b/rogueviz/platformer.cpp index a567eb99..5a4e1fdf 100644 --- a/rogueviz/platformer.cpp +++ b/rogueviz/platformer.cpp @@ -24,7 +24,7 @@ Have fun! */ namespace hr { - +#if CAP_TEXTURE namespace platformer { /* the size of a block, in pixels */ @@ -863,4 +863,5 @@ auto chk = arg::add3("-platformer", enable) }); } +#endif } diff --git a/rogueviz/playing-with-impossibility.cpp b/rogueviz/playing-with-impossibility.cpp index b38bebf1..75ce163f 100644 --- a/rogueviz/playing-with-impossibility.cpp +++ b/rogueviz/playing-with-impossibility.cpp @@ -6,6 +6,7 @@ namespace rogueviz { +#if CAP_MODELS #ifndef RV_ALL namespace cylon { extern void enable(); @@ -1306,7 +1307,7 @@ int phooks = }); } - +#endif } // kolor zmienic dziada diff --git a/rogueviz/rogueviz-all.cpp b/rogueviz/rogueviz-all.cpp index fa4b3d17..3f2701fb 100644 --- a/rogueviz/rogueviz-all.cpp +++ b/rogueviz/rogueviz-all.cpp @@ -3,7 +3,9 @@ /* basics */ #include "rogueviz.cpp" #include "presentation.cpp" +#if CAP_MODELS #include "objmodels.cpp" +#endif #include "smoothcam.cpp" #include "staircase.cpp" @@ -44,7 +46,9 @@ #include "weirdmaze.cpp" #include "inner-maps.cpp" +#if CAP_TEXTURE #include "planets.cpp" +#endif #include "hyperbolic-analogs.cpp" #define RV_ALL diff --git a/rogueviz/rogueviz.h b/rogueviz/rogueviz.h index afe9042f..91f6f17c 100644 --- a/rogueviz/rogueviz.h +++ b/rogueviz/rogueviz.h @@ -14,6 +14,10 @@ #define CAP_RVSLIDES (CAP_TOUR && !ISWEB) #endif +#ifndef CAP_MODELS +#define CAP_MODELS (!ISWEB) +#endif + namespace rogueviz { using namespace hr; @@ -367,6 +371,10 @@ namespace objmodels { for(Res r: results) res += r; return res; } + #else + template auto parallelize(long long N, T action) -> decltype(action(0,0)) { + return action(0, N); + } #endif } diff --git a/rogueviz/snow.cpp b/rogueviz/snow.cpp index 63af3236..ef94be7e 100644 --- a/rogueviz/snow.cpp +++ b/rogueviz/snow.cpp @@ -20,6 +20,7 @@ namespace rogueviz { namespace snow { +#if CAP_MODELS using rogueviz::objmodels::model; using rogueviz::objmodels::tf_result; @@ -31,6 +32,7 @@ struct snowmodel : model { }; vector models; +#endif ld snow_lambda = 0; @@ -162,17 +164,20 @@ bool draw_snow(cell *c, const shiftmatrix& V) { snowball b{just_centered ? Id : random_snow_matrix(c), 0, -1, snow_color}; if(random_colors) b.color = (hrand(0x1000000) << 8) | 0x808080FF; + #if CAP_MODELS if(isize(models)) { b.model_id = hrand(isize(models)); if(single_objects) b.object_id = hrand(isize(models[b.model_id].get().objindex)-1); } + #endif v.emplace_back(b); } } poly_outline = 0xFF; for(auto& T: snowballs_at[c]) { + #if CAP_MODELS if(models.size()) { if(T.object_id == -1) models[T.model_id].render(V*T.T); @@ -184,7 +189,9 @@ bool draw_snow(cell *c, const shiftmatrix& V) { } } } - else { + else + #endif + { auto& p = queuepoly(V * T.T, shapeid(snow_shape), T.color); if(!snow_texture) p.tinf = nullptr; if(snow_intense) p.flags |= POLY_INTENSE; @@ -285,6 +292,7 @@ auto hchook = addHook(hooks_drawcell, 100, draw_snow) else if(argis("-snow-glitch")) { snow_test = true; } + #if CAP_MODELS else if(argis("-use-model")) { shift(); string s = args(); shift(); ld scale = argf(); @@ -296,6 +304,7 @@ auto hchook = addHook(hooks_drawcell, 100, draw_snow) s = "/" + s; } } + #endif else return 1; return 0; }) diff --git a/rogueviz/staircase.cpp b/rogueviz/staircase.cpp index 16ec930f..167b4285 100644 --- a/rogueviz/staircase.cpp +++ b/rogueviz/staircase.cpp @@ -219,7 +219,9 @@ void draw_staircase() { p.offset = 0; p.offset_texture = 0; p.tinf = &tinf; + #if CAP_TEXTURE tinf.texture_id = tdata.textureid; + #endif } void enable_hooks() {