From f2b7746c1b26348c74bf60622c99694b9e2a774d Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 3 May 2020 14:56:41 -0400 Subject: [PATCH] Move all defaulting-of-`CAP_FOO` to sysconfig.h. - The phrase `#ifdef CAP_` should never appear anywhere. - The phrase `#ifndef CAP_` should appear only in sysconfig.h. - The phrases `#if CAP_` and `#if !CAP_` may appear wherever, as long as "sysconfig.h" is included first. The rules for `CAP_FOO` equally apply to `ISFOO`. There are many one-off macros still tested with `#ifdef`, including `HAVE_ACHIEVEMENTS`, `PRINT_ACHIEVEMENTS`, `FAKEWEB`, `FAKE_SDL`, `EASY`, and `WHATEVER`. I don't have much grasp on what these are used for or how they're configured, so I'm leaving them alone. --- achievement.cpp | 4 ++-- complex.cpp | 4 ++-- complex2.cpp | 2 +- config.cpp | 18 +++++++++--------- control.cpp | 2 +- dialogs.cpp | 2 +- drawing.cpp | 10 +++++----- glhr.cpp | 4 ---- graph.cpp | 2 +- help.cpp | 4 ++-- hyper.h | 4 ++-- hyperweb.cpp | 4 ---- inventory.cpp | 2 +- items.cpp | 2 +- menus.cpp | 8 ++++---- mobile.cpp | 2 +- multi.cpp | 6 +++--- quit.cpp | 10 +++++----- rogueviz/newconf.cpp | 7 ------- rogueviz/rogueviz.cpp | 4 ---- surface.cpp | 4 ---- sysconfig.h | 22 +++++++++++++++++++++- system.cpp | 4 ++-- 23 files changed, 64 insertions(+), 67 deletions(-) diff --git a/achievement.cpp b/achievement.cpp index a9ef209b..cabf156d 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -952,12 +952,12 @@ EX void achievement_display() { col /= 10; col *= 0x10101; displayfr(vid.xres/2, vid.yres/4, 2, vid.fsize * 2, achievementMessage[0], col & 0xFFFF00, 8); int w = 2 * vid.fsize; -#if ISMOBILE==0 +#if !ISMOBILE while(w>3 && textwidth(w, achievementMessage[1]) > vid.xres) w--; #endif displayfr(vid.xres/2, vid.yres/4 + vid.fsize*2, 2, w, achievementMessage[1], col, 8); w = vid.fsize; -#if ISMOBILE==0 +#if !ISMOBILE while(w>3 && textwidth(w, achievementMessage[2]) > vid.xres) w--; #endif displayfr(vid.xres/2, vid.yres/4 + vid.fsize*4, 2, w, achievementMessage[2], col, 8); diff --git a/complex.cpp b/complex.cpp index 3940d371..15f7b1dc 100644 --- a/complex.cpp +++ b/complex.cpp @@ -3848,12 +3848,12 @@ EX namespace halloween { } int id = hrand(100); if(items[itTreat] == 1) { -#if ISMOBILE==0 +#if !ISMOBILE addMessage(XLAT("Hint: use arrow keys to scroll.")); #endif } else if(items[itTreat] == 2) { -#if ISMOBILE==0 +#if !ISMOBILE addMessage(XLAT("Hint: press 1 2 3 4 to change the projection.")); #endif } diff --git a/complex2.cpp b/complex2.cpp index e861c827..11c490b2 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -8,7 +8,7 @@ */ #include "hyper.h" -#ifdef CAP_COMPLEX2 +#if CAP_COMPLEX2 namespace hr { diff --git a/config.cpp b/config.cpp index d872ae27..820d462c 100644 --- a/config.cpp +++ b/config.cpp @@ -800,7 +800,7 @@ EX void saveConfig() { fprintf(f, "%s=%s\n", s->name.c_str(), s->save().c_str()); fclose(f); -#if ISMOBILE==0 +#if !ISMOBILE addMessage(s0 + "Configuration saved to: " + conffile); #else addMessage(s0 + "Configuration saved"); @@ -1642,12 +1642,12 @@ EX void show3D() { gamescreen(0); dialog::init(XLAT("3D configuration")); -#if MAXMDIM >= 4 +#if MAXMDIM >= 4 if(WDIM == 2) { dialog::addBoolItem(XLAT("use the full 3D models"), vid.always3, 'U'); dialog::add_action(geom3::switch_always3); } -#endif +#endif if(vid.use_smart_range == 0 && GDIM == 2) { dialog::addSelItem(XLAT("High detail range"), fts(vid.highdetail), 'n'); dialog::addSelItem(XLAT("Mid detail range"), fts(vid.middetail), 'm'); @@ -1749,12 +1749,12 @@ EX void show3D() { dialog::add_action(geom3::switch_tpp); } -#if MAXMDIM >=4 +#if MAXMDIM >=4 if(WDIM == 2) { dialog::addBoolItem(XLAT("configure FPP automatically"), GDIM == 3, 'F'); dialog::add_action(geom3::switch_fpp); } -#endif +#endif if(0); #if CAP_RUG @@ -2422,22 +2422,22 @@ EX int read_config_args() { PHASEFROM(2); nomenukey = true; } -#if MAXMDIM >= 4 +#if MAXMDIM >= 4 else if(argis("-switch-fpp")) { PHASEFROM(2); geom3::switch_fpp(); } -#endif +#endif else if(argis("-switch-tpp")) { PHASEFROM(2); geom3::switch_tpp(); } -#if MAXMDIM >= 4 +#if MAXMDIM >= 4 else if(argis("-switch-3d")) { PHASEFROM(2); geom3::switch_always3(); } -#endif +#endif else if(argis("-nohelp")) { PHASEFROM(2); nohelp = true; diff --git a/control.cpp b/control.cpp index c7d78ca5..44313257 100644 --- a/control.cpp +++ b/control.cpp @@ -1021,7 +1021,7 @@ EX void mainloop() { #endif } -#if ISMOBILE==1 +#if ISMOBILE EX void displayabutton(int px, int py, string s, int col) { // TMP int siz = vid.yres > vid.xres ? vid.fsize*2 : vid.fsize * 3/2; diff --git a/dialogs.cpp b/dialogs.cpp index 7c914f67..dcf0018f 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -803,7 +803,7 @@ EX namespace dialog { else addSlider(ne.sc.direct(ne.vmin), ne.sc.direct(*ne.editwhat), ne.sc.direct(ne.vmax), 500); addBreak(100); -#if ISMOBILE==0 +#if !ISMOBILE addHelp(XLAT("You can scroll with arrow keys -- Ctrl to fine-tune")); addBreak(100); #endif diff --git a/drawing.cpp b/drawing.cpp index 21f11d8d..0c4081de 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -239,7 +239,7 @@ EX void glflush() { } #endif -#if ISMOBILE==0 +#if !ISMOBILE SDL_Surface *aux; #endif @@ -1661,7 +1661,7 @@ void dqi_poly::draw() { } #endif - #if CAP_SVG==1 + #if CAP_SVG if(svg::in) { coords_to_poly(); color_t col = color; @@ -1678,10 +1678,10 @@ void dqi_poly::draw() { coords_to_poly(); - #if CAP_XGD==1 + #if CAP_XGD gdpush(1); gdpush(color); gdpush(outline); gdpush(polyi); for(int i=0; i> 8); #else diff --git a/glhr.cpp b/glhr.cpp index 7fa5e7b8..7fc08fc1 100644 --- a/glhr.cpp +++ b/glhr.cpp @@ -24,10 +24,6 @@ EX void glError(const char* GLcall, const char* file, const int line) { } } -#ifndef CAP_VERTEXBUFFER -#define CAP_VERTEXBUFFER (ISWEB) -#endif - #if HDR #if CAP_SHADER && CAP_NOSHADER #define WITHSHADER(x, y) if(glhr::noshaders) y else x diff --git a/graph.cpp b/graph.cpp index 411c6f89..85ed945f 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4052,7 +4052,7 @@ EX void queuecircleat(cell *c, double rad, color_t col) { } #endif -#if ISMOBILE==1 +#if ISMOBILE #define MOBON (clicked) #else #define MOBON true diff --git a/help.cpp b/help.cpp index 64215864..40be1742 100644 --- a/help.cpp +++ b/help.cpp @@ -357,7 +357,7 @@ EX string generateHelpForItem(eItem it) { " You need to go deep to collect lots of them."); } -#if ISMOBILE==1 +#if ISMOBILE if(it == itOrbSafety) help += XLAT("This might be very useful for devices with limited memory."); #else @@ -525,7 +525,7 @@ void addMinefieldExplanation(string& s) { ); s += "\n\n"; -#if ISMOBILE==0 +#if !ISMOBILE s += XLAT("Known mines may be marked by pressing 'm'. Your allies won't step on marked mines."); #else s += XLAT("Known mines may be marked by touching while in drag mode. Your allies won't step on marked mines."); diff --git a/hyper.h b/hyper.h index 797a0430..bec7a9bb 100644 --- a/hyper.h +++ b/hyper.h @@ -731,7 +731,7 @@ struct colortable: vector { namespace scores { void load(); } -#if ISMOBILE==1 +#if ISMOBILE namespace leader { void showMenu(); void handleKey(int sym, int uni); } #endif @@ -740,7 +740,7 @@ int textwidth(int siz, const string &str); int gl_width(int size, const char *s); #endif -#ifdef ISMOBILE +#if ISMOBILE extern int andmode; extern bool longclick; extern bool useRangedOrb; diff --git a/hyperweb.cpp b/hyperweb.cpp index b393b2b1..8e9b5e48 100644 --- a/hyperweb.cpp +++ b/hyperweb.cpp @@ -30,10 +30,6 @@ #define EMSCRIPTEN #endif -#ifndef CAP_ORIENTATION -#define CAP_ORIENTATION 1 -#endif - #ifdef FAKEWEB namespace hr { void mainloopiter(); } template void emscripten_set_main_loop(A a, B b, C c) { while(true) mainloopiter(); } diff --git a/inventory.cpp b/inventory.cpp index 436e6e5e..6ac1c6b1 100644 --- a/inventory.cpp +++ b/inventory.cpp @@ -588,7 +588,7 @@ EX namespace inv { displaystr(vid.xres/2, vid.yres - vid.fsize*6, 2, vid.fsize, osminfo(which), icol, 8); } -#if ISMOBILE==0 +#if !ISMOBILE string hot = XLAT1("Hotkey: "); hot += getcstat; displaystr(vid.xres/2, vid.yres - vid.fsize*5, 2, vid.fsize, hot, icol, 8); #endif diff --git a/items.cpp b/items.cpp index b7ed30d6..6bf99556 100644 --- a/items.cpp +++ b/items.cpp @@ -467,7 +467,7 @@ EX void gainItem(eItem it) { if(chaosmode && gold() >= 300) achievement_gain_once("CHAOS", rg::chaos); -#if ISMOBILE==1 +#if ISMOBILE if(g < lastsafety + R30*3/2 && g2 >= lastsafety + R30*3/2) addMessage(XLAT("The Orb of Safety from the Land of Eternal Motion might save you.")); #endif diff --git a/menus.cpp b/menus.cpp index 7eb0b72c..7888a607 100644 --- a/menus.cpp +++ b/menus.cpp @@ -230,7 +230,7 @@ EX void showMainMenu() { dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R'); string q; - #if ISMOBILE==1 + #if ISMOBILE dialog::addItem(XLAT("visit the website"), 'q'); #else q = quitsaves() ? "save" : "quit"; @@ -248,7 +248,7 @@ EX void showMainMenu() { if(inv::on) dialog::addItem(XLAT("inventory"), 'i'); -#if ISMOBILE==1 +#if ISMOBILE #if CAP_ACHIEVE dialog::addItem(XLAT("leaderboards/achievements"), '3'); #endif @@ -305,7 +305,7 @@ EX void showMainMenu() { #endif else if(sym == SDLK_ESCAPE) showMissionScreen(); - #if ISMOBILE==1 + #if ISMOBILE #ifdef HAVE_ACHIEVEMENTS else if(NUMBERKEY == '3') { achievement_final(false); @@ -382,7 +382,7 @@ EX void enable_cheat() { else if(!cheater) dialog::cheat_if_confirmed([] { cheater++; addMessage(XLAT("You activate your demonic powers!")); -#if ISMOBILE==0 +#if !ISMOBILE addMessage(XLAT("Shift+F, Shift+O, Shift+T, Shift+L, Shift+U, etc.")); #endif popScreen(); diff --git a/mobile.cpp b/mobile.cpp index 31e2e5b9..312724db 100644 --- a/mobile.cpp +++ b/mobile.cpp @@ -44,7 +44,7 @@ string buildScoreDescription() { } #endif -#if ISMOBILE==1 +#if ISMOBILE int andmode; diff --git a/multi.cpp b/multi.cpp index 622c259d..7cdbdc41 100644 --- a/multi.cpp +++ b/multi.cpp @@ -549,7 +549,7 @@ EX void initConfig() { t[(int)'s'] = 16 + 6; t[(int)'a'] = 16 + 7; -#if ISMOBILE==0 +#if !ISMOBILE t[SDLK_KP8] = 16 + 4; t[SDLK_KP6] = 16 + 5; t[SDLK_KP2] = 16 + 6; @@ -572,7 +572,7 @@ EX void initConfig() { t[(int)'p'] = 32 + 10; t[(int)'['] = 32 + pcCenter; -#if ISMOBILE==0 +#if !ISMOBILE t[SDLK_UP] = 48 ; t[SDLK_RIGHT] = 48 + 1; t[SDLK_DOWN] = 48 + 2; @@ -973,4 +973,4 @@ EX void handleInput(int delta) { EX } -} \ No newline at end of file +} diff --git a/quit.cpp b/quit.cpp index e398e7e8..c20a4d70 100644 --- a/quit.cpp +++ b/quit.cpp @@ -122,7 +122,7 @@ EX hint hints[] = { []() { return true; }, []() { dialog::addInfo(XLAT( -#if ISMOBILE==1 +#if ISMOBILE "The 'world overview' shows all the lands in HyperRogue." #else "Press 'o' to see all the lands in HyperRogue." @@ -457,12 +457,12 @@ EX void showMission() { dialog::addItem(XLAT("inventory"), 'i'); if(racing::on) dialog::addItem(XLAT("racing menu"), 'o'); - #if ISMOBILE==0 +#if !ISMOBILE dialog::addItem(XLAT(quitsaves() ? "save" : "quit"), SDLK_F10); - #endif - #if CAP_ANDROIDSHARE +#endif +#if CAP_ANDROIDSHARE dialog::addItem(XLAT("SHARE"), 's'-96); - #endif +#endif } dialog::addItem(XLAT("message log"), 'l'); diff --git a/rogueviz/newconf.cpp b/rogueviz/newconf.cpp index 68c25941..cd73cd86 100644 --- a/rogueviz/newconf.cpp +++ b/rogueviz/newconf.cpp @@ -4,14 +4,7 @@ #include "../hyper.h" -#ifndef CAP_NCONF -#define CAP_NCONF 0 -#endif - #if CAP_NCONF -#ifndef CAP_DRAW -#define CAP_DRAW 0 -#endif #define main nconf_main #undef unordered_map #undef self diff --git a/rogueviz/rogueviz.cpp b/rogueviz/rogueviz.cpp index cff1abce..2ebba69f 100644 --- a/rogueviz/rogueviz.cpp +++ b/rogueviz/rogueviz.cpp @@ -913,10 +913,6 @@ void close() { relmatrices.clear(); } -#ifndef CAP_RVSLIDES -#define CAP_RVSLIDES (CAP_TOUR && !ISWEB) -#endif - #if CAP_COMMANDLINE int readArgs() { using namespace arg; diff --git a/surface.cpp b/surface.cpp index 81d0708a..50d1769e 100644 --- a/surface.cpp +++ b/surface.cpp @@ -370,10 +370,6 @@ int dexp_comb_colors[16] = { int coverage_style; EX vector > coverage; -#ifndef CAP_KUEN_MAP -#define CAP_KUEN_MAP 0 -#endif - #if CAP_KUEN_MAP void draw_kuen_map() { SDL_Surface *kuen_map = SDL_CreateRGBSurface(SDL_SWSURFACE,512,512,32,0,0,0,0); diff --git a/sysconfig.h b/sysconfig.h index 4d337864..418aeea9 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -63,6 +63,14 @@ #define ISMINI 0 #endif +#ifndef CAP_NCONF +#define CAP_NCONF 0 +#endif + +#ifndef CAP_DRAW +#define CAP_DRAW 0 +#endif + #ifndef CAP_XGD #define CAP_XGD (ISANDROID || ISFAKEMOBILE) #endif @@ -85,6 +93,10 @@ #define NOLICENSE ISSTEAM #endif +#ifndef CAP_VERTEXBUFFER +#define CAP_VERTEXBUFFER (ISWEB) +#endif + #ifndef CAP_SHADER #define CAP_SHADER CAP_GL #endif @@ -153,6 +165,10 @@ #define CAP_SURFACE CAP_RUG #endif +#ifndef CAP_KUEN_MAP +#define CAP_KUEN_MAP 0 +#endif + #ifndef CAP_EDIT #define CAP_EDIT (CAP_FILES && !ISWEB && !ISMINI) #endif @@ -197,6 +213,10 @@ #define CAP_ROGUEVIZ 0 #endif +#ifndef CAP_RVSLIDES +#define CAP_RVSLIDES (CAP_TOUR && !ISWEB) +#endif + #ifndef CAP_PROFILING #define CAP_PROFILING 0 #endif @@ -210,7 +230,7 @@ #endif #ifndef CAP_ORIENTATION -#define CAP_ORIENTATION ISMOBILE +#define CAP_ORIENTATION (ISMOBILE || ISWEB) #endif #ifndef CAP_MOUSEGRAB diff --git a/system.cpp b/system.cpp index fa620319..351e9572 100644 --- a/system.cpp +++ b/system.cpp @@ -1068,7 +1068,7 @@ EX void saveStats(bool emergency IS(false)) { fprintf(f, "\n\n\n"); -#if ISMOBILE==0 +#if !ISMOBILE DEBB(DF_INIT, ("Game statistics saved to ", scorefile)); addMessage(XLAT("Game statistics saved to %1", scorefile)); #endif @@ -1556,7 +1556,7 @@ EX void finishAll() { saveStats(); #endif clearMemory(); -#if ISMOBILE==0 +#if !ISMOBILE cleargraph(); #endif