diff --git a/achievement.cpp b/achievement.cpp index 47b3640e..e2ebc3e4 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- achievements // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + #define NUMLEADER 78 bool offlineMode = false; @@ -781,4 +783,6 @@ int score_default(int i) { #ifndef HAVE_ACHIEVEMENTS int get_sync_status() { return 0; } void set_priority_board(int) { } -#endif \ No newline at end of file +#endif + +} diff --git a/barriers.cpp b/barriers.cpp index e0211026..ed5b738a 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -2,6 +2,8 @@ // This file implements routines related to barriers (Great Walls and similar). // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + bool checkBarriersFront(cellwalker bb, int q, bool cross) { if(!ctof(bb.c)) @@ -765,3 +767,4 @@ bool buildBarrierNowall(cell *c, eLand l2, int forced_dir) { return false; } +} diff --git a/basegraph.cpp b/basegraph.cpp index 4b252e21..85873d90 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- basic graphics // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + unsigned backcolor = 0; unsigned bordcolor = 0; unsigned forecolor = 0xFFFFFF; @@ -1256,3 +1258,4 @@ int calcfps() { return (1000 * CFPS) / ret; } +} diff --git a/bigstuff.cpp b/bigstuff.cpp index b2636237..a01ce557 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -7,6 +7,8 @@ // horocycles +namespace hr { + int newRoundTableRadius() { return 28 + 2 * items[itHolyGrail]; } @@ -1351,3 +1353,5 @@ void moreBigStuff(cell *c) { } } } + +} \ No newline at end of file diff --git a/blizzard.cpp b/blizzard.cpp index efa09d3b..9d7db125 100644 --- a/blizzard.cpp +++ b/blizzard.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- special graphical effects, such as the Blizzard // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + double randd() { return (rand() + .5) / (RAND_MAX + 1.); } double cellgfxdist(cell *c, int i) { @@ -261,3 +263,5 @@ auto ccm_blizzard = addHook(clearmemory, 0, [] () { addHook(hooks_removecells, 0, [] () { eliminate_if(arrowtraps, is_cell_removed); }); + +} diff --git a/cell.cpp b/cell.cpp index 799022ba..e45fbc54 100644 --- a/cell.cpp +++ b/cell.cpp @@ -3,6 +3,8 @@ // cells the game is played on +namespace hr { + int fix6(int a) { return (a+MODFIXER)%S6; } int fix7(int a) { return (a+MODFIXER)%S7; } @@ -1478,3 +1480,4 @@ void clearCellMemory() { auto cellhooks = addHook(clearmemory, 500, clearCellMemory); +} diff --git a/classes.cpp b/classes.cpp index 4798114a..50044f32 100644 --- a/classes.cpp +++ b/classes.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- items, monsters, walls, lands, descriptions, etc. // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + // --- help --- const char *wormdes = @@ -1674,3 +1676,4 @@ geometryinfo ginf[gGUARD] = { {"cube/elliptic", "e3x4", 4, 3, qELLIP, gcSphere, 0x10600, {{SEE_ALL, SEE_ALL}}}, }; +} diff --git a/classes.h b/classes.h index adf2294f..c889d3c7 100644 --- a/classes.h +++ b/classes.h @@ -1,3 +1,5 @@ +namespace hr { + static const int motypes = 162; struct monstertype { @@ -206,7 +208,7 @@ struct geometryinfo { int quotientstyle; eGeometryClass cclass; int xcode; - array distlimit; // bitrunc, non-bitrunc + std::array distlimit; // bitrunc, non-bitrunc }; static const int qZEBRA = 1; @@ -232,3 +234,5 @@ enum cpatterntype { }; struct landtacinfo { eLand l; int tries, multiplier; }; + +} diff --git a/commandline.cpp b/commandline.cpp index 3c1a3090..9d43a267 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- commandline options // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + #if CAP_COMMANDLINE const char *scorefile = "hyperrogue.log"; const char *conffile = "hyperrogue.ini"; @@ -628,3 +630,5 @@ namespace arg { } } #endif + +} diff --git a/compileunits.h b/compileunits.h index 1a5bb7bf..b804d699 100644 --- a/compileunits.h +++ b/compileunits.h @@ -11,9 +11,14 @@ #define IN_CU(x) (CU == x) #endif +#include "sysconfig.h" #include "classes.h" #include "hyper.h" +#if CAP_ROGUEVIZ +#include "rogueviz.h" +#endif + #define CU_INIT IN_CU(0) #define CU_HYPER IN_CU(0) @@ -97,7 +102,7 @@ bool inv::activating; #if CAP_DAILY #include "private/daily.cpp" #else -namespace daily { bool on; } +namespace hr::daily { bool on; } #endif #endif diff --git a/complex.cpp b/complex.cpp index 7a02ed37..7840f8e8 100644 --- a/complex.cpp +++ b/complex.cpp @@ -7,6 +7,8 @@ #include +namespace hr { + namespace whirlwind { int fzebra3(cell *c) { @@ -3674,3 +3676,5 @@ namespace dungeon { if(d == 7 && c->land == laDungeon) buildPlates(c); } } + +} diff --git a/config.cpp b/config.cpp index aa17119c..26e0ac03 100644 --- a/config.cpp +++ b/config.cpp @@ -2,6 +2,8 @@ // Copyright (C) 2017-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + videopar vid; #define DEFAULT_WALLMODE (ISMOBILE ? 3 : 5) @@ -1354,3 +1356,4 @@ void selectLanguageScreen() { } #endif +} diff --git a/conformal.cpp b/conformal.cpp index 6308309a..ee04baeb 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -3,6 +3,8 @@ #include +namespace hr { + #if ISMOBWEB typedef double precise; #else @@ -885,3 +887,5 @@ namespace conformal { }); } + +} diff --git a/control.cpp b/control.cpp index aab82033..d0bf4a3d 100644 --- a/control.cpp +++ b/control.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- control // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + int frames; bool outoffocus = false; @@ -885,3 +887,5 @@ bool handleCompass() { return false; } + +} diff --git a/debug.cpp b/debug.cpp index c575abf0..72abebc3 100644 --- a/debug.cpp +++ b/debug.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- debugging routines // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + int steplimit = 0; int cstep; @@ -436,3 +438,5 @@ void raiseBuggyGeneration(cell *c, const char *s) { else c->item = itBuggy; } + +} diff --git a/dialogs.cpp b/dialogs.cpp index 31012540..1d228a08 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -14,6 +14,8 @@ */ +namespace hr { + const char* COLORBAR = "###"; namespace dialog { @@ -1039,3 +1041,5 @@ namespace dialog { } }; + +} diff --git a/fake-mobile.cpp b/fake-mobile.cpp index e47ed3e3..57517f73 100644 --- a/fake-mobile.cpp +++ b/fake-mobile.cpp @@ -5,17 +5,20 @@ #define MOBPAR_FORMAL int #define MOBPAR_ACTUAL 0 #define MIX_MAX_VOLUME 128 - -const char *scorefile = "fakemobile_score.txt"; -const char *conffile = "fakemobile_config.txt"; - #include -std::string levelfile = "fakemobile_level.txt"; -std::string picfile = "fakemobile_pic.txt"; + +namespace hr { + const char *scorefile = "fakemobile_score.txt"; + const char *conffile = "fakemobile_config.txt"; + + std::string levelfile = "fakemobile_level.txt"; + std::string picfile = "fakemobile_pic.txt"; + } #include #include "init.cpp" +using namespace hr; #include #include diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 0d3199fe..dd71ba96 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- implementation of the quotient geometries based on fields // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + namespace fieldpattern { extern int subpathid; @@ -398,7 +400,7 @@ struct fpattern { } void analyze() { - + DEBB(DF_FIELD, (debugfile, "nonbitrunc = %d\n", nonbitrunc)); int N = connections.size(); @@ -783,3 +785,4 @@ int currfp_gmul(int a, int b) { return currfp.gmul(a,b); } int currfp_inverses(int i) { return currfp.inverses[i]; } int currfp_distwall(int i) { return currfp.distwall[i]; } +} diff --git a/flags.cpp b/flags.cpp index 1b5d5638..a37e11a3 100644 --- a/flags.cpp +++ b/flags.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + bool isIcyLand(eLand l) { return l == laIce || l == laCocytus || l == laBlizzard; } @@ -758,3 +760,4 @@ bool isTechnicalLand(eLand l) { l == laMirrorWall2 || l == laMercuryRiver || l == laMemory; } +} diff --git a/floorshapes.cpp b/floorshapes.cpp index 2b506986..3a8c316a 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -1,3 +1,5 @@ +namespace hr { + vector all_plain_floorshapes; vector all_escher_floorshapes; @@ -587,3 +589,4 @@ if(0) { } */ } +} diff --git a/game.cpp b/game.cpp index f2472961..2868be09 100644 --- a/game.cpp +++ b/game.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + int lastsafety; int mutantphase; int turncount; @@ -142,8 +144,6 @@ cellwalker cwt; // single player character position inline cell*& singlepos() { return cwt.c; } inline bool singleused() { return !(shmup::on || multi::players > 1); } -#include - mt19937 r; void shrand(int i) { @@ -8053,3 +8053,4 @@ bool warningprotection() { return true; } +} diff --git a/geom-exp.cpp b/geom-exp.cpp index 56a231bf..325379d0 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -3,6 +3,8 @@ // -- geometry menu -- +namespace hr { + int eupage = 0; int euperpage = 21; @@ -453,3 +455,4 @@ void runGeometryExperiments() { pushScreen(showEuclideanMenu); } +} diff --git a/geometry.cpp b/geometry.cpp index cb1a19bd..db7ca1c7 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + bool debug_geometry = false; ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf; @@ -340,3 +342,4 @@ void initgeo() { // printf("%Lf\n", (ld) hdist0(xpush(-1)*ypush(0.01)*xpush(1)*C0)); precalc(); } +} diff --git a/goldberg.cpp b/goldberg.cpp index 83543116..1c18bbb8 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -1,4 +1,4 @@ -namespace gp { +namespace hr::gp { bool on; loc param(1, 0); diff --git a/graph.cpp b/graph.cpp index 1dc8b50d..89bc5b49 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4,6 +4,8 @@ // basic graphics: +namespace hr { + int inmirrorcount = 0; bool wmspatial, wmescher, wmplain, wmblack, wmascii; @@ -5825,3 +5827,4 @@ bool inscreenrange(cell *c) { return heptdistance(viewcenter(), c) <= 8; } +} diff --git a/help.cpp b/help.cpp index b542865f..4e23ec36 100644 --- a/help.cpp +++ b/help.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- help routines // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + string help; function help_delegate; @@ -1015,3 +1017,4 @@ void gotoHelpFor(eLand l) { }}); else listbeasts(); } +} diff --git a/heptagon.cpp b/heptagon.cpp index 304d836b..40cb8843 100644 --- a/heptagon.cpp +++ b/heptagon.cpp @@ -4,6 +4,8 @@ // heptagon here refers to underlying heptagonal tesselation // (which you can see by changing the conditions in graph.cpp) +namespace hr { + #define MIRR(x) x.mirrored int heptacount = 0; @@ -275,3 +277,4 @@ void hsshow(const heptspin& t) { // create h->move[d] if not created yet heptagon *createStep(heptagon *h, int d); +} diff --git a/hud.cpp b/hud.cpp index a03ce777..fc18b15d 100644 --- a/hud.cpp +++ b/hud.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- heads-up display // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + purehookset hooks_stats; int monsterclass(eMonster m) { @@ -567,3 +569,4 @@ XLAT( callhooks(hooks_stats); } +} diff --git a/hyper.cpp b/hyper.cpp index 0fb436a5..455cb12d 100644 --- a/hyper.cpp +++ b/hyper.cpp @@ -40,10 +40,11 @@ void moreStack() { } #endif -hookset *hooks_main; +hr::hookset *hr::hooks_main; #ifndef NOMAIN int main(int argc, char **argv) { + using namespace hr; #if ISWEB emscripten_get_commandline(); #else diff --git a/hyper.h b/hyper.h index 702f1014..ea977ae0 100644 --- a/hyper.h +++ b/hyper.h @@ -1,6 +1,71 @@ // This is the main header file of HyperRogue. Mostly everything is dumped here. // It is quite chaotic. +// version numbers +#define VER "10.4a" +#define VERNUM 10401 +#define VERNUM_HEX 0xA0B1 + +namespace hr { + +using namespace std; + +// genus (in grammar) +#define GEN_M 0 +#define GEN_F 1 +#define GEN_N 2 +#define GEN_O 3 + +void addMessage(string s, char spamtype = 0); + +// geometry-dependent constants + +#define ALPHA (M_PI*2/S7) +#define S7 ginf[geometry].sides +#define S3 ginf[geometry].vertex +#define hyperbolic_37 (S7 == 7 && S3 == 3) +#define hyperbolic_not37 ((S7 > 7 || S3 > 3) && hyperbolic) +#define weirdhyperbolic ((S7 > 7 || S3 > 3 || gp::on) && hyperbolic) +#define stdhyperbolic (S7 == 7 && S3 == 3 && !gp::on) + +#define cgclass (ginf[geometry].cclass) +#define euclid (cgclass == gcEuclid) +#define sphere (cgclass == gcSphere) +#define hyperbolic (cgclass == gcHyperbolic) +#define elliptic (ginf[geometry].quotientstyle & qELLIP) +#define quotient (ginf[geometry].quotientstyle & (qZEBRA | qFIELD)) +#define torus (ginf[geometry].quotientstyle & qTORUS) +#define doall (ginf[geometry].quotientstyle) +#define smallbounded (sphere || (quotient & qZEBRA) || torus) +#define bounded (sphere || quotient || torus) + +#define a4 (S3 == 4) +#define a45 (S3 == 4 && S7 == 5) +#define a46 (S3 == 4 && S7 == 6) +#define a47 (S3 == 4 && S7 == 7) +#define a457 (S3 == 4 && S7 != 6) +#define a467 (S3 == 4 && S7 >= 6) +#define a38 (S7 == 8) +#define sphere4 (sphere && S7 == 4) +#define stdeuc (geometry == gNormal || geometry == gEuclid || geometry == gEuclidSquare) +#define smallsphere (S7 < 5) +#define bigsphere (S7 == 5) +#define ap4 (a4 && nonbitrunc) +#define euclid4 (euclid && a4) +#define euclid6 (euclid && !a4) + +#define S6 (S3*2) +#define S42 (S7*S6) +#define S12 (S6*2) +#define S14 (S7*2) +#define S21 (S7*S3) +#define S28 (S7*4) +#define S36 (S6*6) +#define S84 (S7*S6*2) +#define MAX_EDGE 8 +#define MAX_S3 4 +#define MAX_S84 240 + #define NUMWITCH 7 // achievements @@ -1598,25 +1663,6 @@ enum eGlyphsortorder { extern eGlyphsortorder glyphsortorder; -#if CAP_ROGUEVIZ -namespace rogueviz { - extern bool on; - string describe(shmup::monster *m); - void describe(cell *c); - void activate(shmup::monster *m); - void drawVertex(const transmatrix &V, cell *c, shmup::monster *m); - bool virt(shmup::monster *m); - void turn(int delta); - void drawExtra(); - void fixparam(); - int readArgs(); - void close(); - void mark(cell *c); - void showMenu(); - string makehelp(); - } -#endif - void explodeMine(cell *c); bool mayExplodeMine(cell *c, eMonster who); @@ -1781,16 +1827,6 @@ namespace tour { }; #endif -namespace rogueviz { - extern bool rog3; - extern bool rvwarp; -#if CAP_TOUR - namespace rvtour { - extern tour::slide rvslides[]; - } -#endif - }; - extern bool doCross; void optimizeview(); @@ -3390,10 +3426,7 @@ void set_priority_board(int id); int get_sync_status(); bool score_loaded(int id); int score_default(int id); -#if CAP_SDL -union SDL_Event; void handle_event(SDL_Event& ev); -#endif #ifndef XPRINTF template void Xprintf(const char *fmt, T... t) { printf(fmt, t...); } @@ -3458,3 +3491,12 @@ extern plain_floorshape shBigTriangle, shTriheptaFloor, shBigHepta; extern escher_floorshape shDragonFloor, shPowerFloor, shRedRockFloor[3]; + +#if ISMOBILE +bool buttonclicked; +void gdpush(int t); +#endif + +extern int fontscale; + +} \ No newline at end of file diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 2aade363..2819bb8e 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -2,6 +2,8 @@ // This file contains hyperbolic points and matrices. // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + eGeometry geometry, targetgeometry; // for the pure heptagonal grid @@ -597,3 +599,4 @@ transmatrix rotmatrix(double rotation, int c0, int c1) { return t; } +} diff --git a/hyperweb.cpp b/hyperweb.cpp index bdeebf34..e6d102ad 100644 --- a/hyperweb.cpp +++ b/hyperweb.cpp @@ -19,21 +19,23 @@ #endif #ifdef FAKEWEB -void mainloopiter(); +namespace hr { void mainloopiter(); } template void emscripten_set_main_loop(A a, B b, C c) { while(true) mainloopiter(); } #else #include #include #endif -void initweb(); -void emscripten_get_commandline(); +namespace hr { + void initweb(); + void emscripten_get_commandline(); -void loadCompressedChar(int &otwidth, int &otheight, int *tpix); + void loadCompressedChar(int &otwidth, int &otheight, int *tpix); -const char *wheresounds; + const char *wheresounds; + } -#include "hyper.cpp" +namespace hr { // -- demo -- @@ -192,4 +194,6 @@ void emscripten_get_commandline() { free(str); #endif } +} +#include "hyper.cpp" diff --git a/hypgraph.cpp b/hypgraph.cpp index ae0f9e98..637b449d 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- hyperbolic graphics // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + ld ghx, ghy, ghgx, ghgy; hyperpoint ghpm = C0; @@ -850,3 +852,4 @@ transmatrix atscreenpos(ld x, ld y, ld size) { return V; } +} diff --git a/init.cpp b/init.cpp index b61ebd3f..b665aa7d 100644 --- a/init.cpp +++ b/init.cpp @@ -1,445 +1,10 @@ // Hyperbolic Rogue -- initialization, and stuff related to mobiles // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details -#ifdef MAC -#define ISMAC 1 -#endif - - -#ifdef LINUX -#define ISLINUX 1 -#endif - -#ifdef WINDOWS -#define ISWINDOWS 1 -#endif - -#if ISSTEAM -#define NOLICENSE -#endif - -#define VER "10.4a" -#define VERNUM 10401 - -#ifndef CAP_SHADER -#define CAP_SHADER CAP_GL -#endif - -#define VERNUM_HEX 0xA0B1 - -#define GEN_M 0 -#define GEN_F 1 -#define GEN_N 2 -#define GEN_O 3 - -// OS settings - -#ifndef ISMAC -#define ISMAC 0 -#endif - -#ifndef ISLINUX -#define ISLINUX 0 -#endif - -#ifndef ISWINDOWS -#define ISWINDOWS 0 -#endif - -#ifndef ISPANDORA -#define ISPANDORA 0 -#endif - -#ifndef ISIOS -#define ISIOS 0 -#endif - -#ifndef ISANDROID -#define ISANDROID 0 -#endif - -#ifndef ISWEB -#define ISWEB 0 -#endif - -#ifndef ISFAKEMOBILE -#define ISFAKEMOBILE 0 -#endif - -#define ISMOBILE (ISIOS || ISANDROID || ISFAKEMOBILE) -#define ISMOBWEB (ISMOBILE || ISWEB) - -#ifndef ISMINI -#define ISMINI 0 -#endif - -#ifndef CAP_XGD -#define CAP_XGD (ISANDROID || ISFAKEMOBILE) -#endif - -#define CAP_FRAMELIMIT (!ISMOBWEB) - -#if ISMOBILE==1 -#define EXTERNALFONT -#endif - -#ifndef CAP_FILES -#define CAP_FILES 1 -#endif - -#ifndef CAP_INV -#define CAP_INV 1 -#endif - -#ifndef CAP_ANDROIDSHARE -#define CAP_ANDROIDSHARE (ISANDROID) -#endif - -#ifndef CAP_SDL -#define CAP_SDL (!ISMOBILE) -#endif - -#ifdef CAP_COMPASS -#define CAP_COMPASS ISMOBILE -#endif - -#ifndef CAP_SDLGFX -#define CAP_SDLGFX (CAP_SDL && !ISWEB) -#endif - -#ifndef CAP_GL -#define CAP_GL (ISMOBILE || CAP_SDL) -#endif - -#ifndef CAP_AUDIO -#define CAP_AUDIO ((ISMOBILE || CAP_SDL) && !ISWEB && !ISMINI) -#endif - -#define CAP_GLORNOT (CAP_GL && !ISWEB && !ISIOS) - -#if ISSTEAM -#define CAP_DAILY 1 -#endif - -#ifndef CAP_DAILY -#define CAP_DAILY 0 -#endif - -#ifndef CAP_CERTIFY -#define CAP_CERTIFY 0 -#endif - -#ifndef CAP_RUG -#define CAP_RUG (!ISMINI && CAP_GL) -#endif - -#ifndef CAP_SURFACE -#define CAP_SURFACE CAP_RUG -#endif - -#ifndef CAP_EDIT -#define CAP_EDIT (CAP_FILES && !ISWEB && !ISMINI) -#endif - -#ifndef CAP_ODS -#define CAP_ODS 0 -#endif - -#ifndef CAP_TEXTURE -#define CAP_TEXTURE (CAP_GL && (CAP_PNG || CAP_SDL_IMG) && !ISMINI) -#endif - -#ifndef CAP_MODEL -#define CAP_MODEL (!ISMOBWEB && !ISMINI && CAP_SDLGFX) -#endif - -#ifndef CAP_SAVE -#define CAP_SAVE (CAP_FILES && !ISWEB && !ISMINI) -#endif - -#ifndef CAP_CONFIG -#define CAP_CONFIG (CAP_FILES && !ISWEB && !ISMINI) -#endif - -#ifndef CAP_TRANS -#define CAP_TRANS (!ISWEB && !ISMINI) -#endif - -#ifndef CAP_TOUR -#define CAP_TOUR (!ISWEB && !ISMINI) -#endif - -#ifndef CAP_ROGUEVIZ -#define CAP_ROGUEVIZ 0 -#endif - -#ifndef CAP_PROFILING -#define CAP_PROFILING 0 -#endif - -#define PSEUDOKEY_WHEELDOWN 2501 -#define PSEUDOKEY_WHEELUP 2502 -#define PSEUDOKEY_RELEASE 2503 - -#ifndef CAP_PNG -#define CAP_PNG (!ISMOBWEB) -#endif - -#ifndef CAP_ORIENTATION -#define CAP_ORIENTATION ISMOBILE -#endif - -#ifndef CAP_COMMANDLINE -#define CAP_COMMANDLINE (!ISMOBILE) -#endif - -#define CAP_SDLAUDIO (CAP_SDL && CAP_AUDIO) - -#ifndef CAP_SVG -#define CAP_SVG (!ISMOBILE) -#endif - -#ifndef CAP_POLY -#define CAP_POLY (CAP_SDLGFX || CAP_GL || CAP_SVG) -#endif - -#define CAP_QUEUE CAP_POLY -#define CAP_CURVE CAP_POLY - -#ifndef CAP_SDLJOY -#define CAP_SDLJOY (CAP_SDL && !ISWEB) -#endif - -#ifndef CAP_SDL_IMG -#define CAP_SDL_IMG 0 -#endif - -#ifndef CAP_SDLTTF -#define CAP_SDLTTF (CAP_SDL && !ISMOBILE && !ISWEB) -#endif - -#define CAP_GLFONT (CAP_GL && !ISMOBILE) - -#ifndef CAP_TABFONT -#define CAP_TABFONT (ISWEB) -#endif - -#ifndef CAP_CREATEFONT -#define CAP_CREATEFONT 0 -#endif - -#ifndef CAP_FIXEDSIZE -#define CAP_FIXEDSIZE (CAP_CREATEFONT || CAP_TABFONT ? 36 : 0) -#endif - -#ifndef CAP_SHMUP -#define CAP_SHMUP 1 -#endif - -#ifdef ISSTEAM -#define CAP_ACHIEVE 1 -#endif - -#ifndef CAP_BITFIELD -#define CAP_BITFIELD (!ISWEB) -#endif - -#ifndef CAP_ACHIEVE -#define CAP_ACHIEVE 0 -#endif - -#ifndef CAP_SHMUP_GOOD -#define CAP_SHMUP_GOOD (!ISMOBWEB) -#endif - -extern int fontscale; - -#if ISMOBILE -#define EXTRALICENSE "\n\nHyperRogue soundtrack by Shawn Parrotte (http://www.shawnparrotte.com), under the Creative Commons BY-SA 3.0 license, http://creativecommons.org/licenses/by-sa/3.0/" -#undef XEXTRALICENSE - -bool buttonclicked; -void gdpush(int t); -#endif - -#ifndef HYPERPATH -#define HYPERPATH "" -#endif - -#include - -#if CAP_SDL -#include - -#if !ISMAC -#undef main -#endif - -#if CAP_SDLAUDIO -#include -#endif - -#if CAP_SDLTTF -#include -#endif - -#if CAP_SDLGFX -#include -#endif - -#elif !ISFAKEMOBILE -#define SDLK_F1 (123001) -#define SDLK_F2 (123002) -#define SDLK_F3 (123003) -#define SDLK_F4 (123004) -#define SDLK_F5 (123005) -#define SDLK_F6 (123006) -#define SDLK_F7 (123007) -#define SDLK_F8 (123008) -#define SDLK_F9 (123009) -#define SDLK_F10 (123010) -#define SDLK_ESCAPE (123099) -#define SDLK_F12 (123012) -#define SDLK_HOME (123013) -#define SDLK_LEFT (123014) -#define SDLK_RIGHT (123015) -#define SDLK_END (123016) -#define MIX_MAX_VOLUME 128 -#define SDLK_UP (123021) -#define SDLK_DOWN (123022) -#define SDLK_PAGEUP (123023) -#define SDLK_PAGEDOWN (123024) -#define SDLK_RETURN (123025) -#define SDLK_KP1 (123031) -#define SDLK_KP2 (123032) -#define SDLK_KP3 (123033) -#define SDLK_KP4 (123034) -#define SDLK_KP5 (123035) -#define SDLK_KP6 (123036) -#define SDLK_KP7 (123037) -#define SDLK_KP8 (123038) -#define SDLK_KP9 (123039) -#define SDLK_KP_PERIOD (123051) -#define SDLK_KP_MINUS (123053) -#define SDLK_DELETE (123052) -#define SDLK_DELETE (123052) -#define SDLK_KP_ENTER (123054) -#define SDLK_BACKSPACE (123055) -typedef int SDL_Event; -typedef unsigned int Uint32; -#endif - -#if ISWEB -extern "C" { - Uint8 *SDL_GetKeyState(void*); -} -// inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; } -#endif - - -#ifndef CAP_GLEW -#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB) -#endif - -#if CAP_GL -#if CAP_GLEW - #include -#else - #define GL_GLEXT_PROTOTYPES 1 - #if ISMAC - #include - #include - #include - #elif ISIOS - // already included - #elif ISANDROID - #include - #include - #include - #include - #define GLES_ONLY - #else - #include - #include - #include - #endif - #endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef USE_UNORDERED_MAP -#include -#else -#define unordered_map map -#endif - -using namespace std; - -void addMessage(string s, char spamtype = 0); - -#define ALPHA (M_PI*2/S7) -#define S7 ginf[geometry].sides -#define S3 ginf[geometry].vertex -#define hyperbolic_37 (S7 == 7 && S3 == 3) -#define hyperbolic_not37 ((S7 > 7 || S3 > 3) && hyperbolic) -#define weirdhyperbolic ((S7 > 7 || S3 > 3 || gp::on) && hyperbolic) -#define stdhyperbolic (S7 == 7 && S3 == 3 && !gp::on) - -#define cgclass (ginf[geometry].cclass) -#define euclid (cgclass == gcEuclid) -#define sphere (cgclass == gcSphere) -#define hyperbolic (cgclass == gcHyperbolic) -#define elliptic (ginf[geometry].quotientstyle & qELLIP) -#define quotient (ginf[geometry].quotientstyle & (qZEBRA | qFIELD)) -#define torus (ginf[geometry].quotientstyle & qTORUS) -#define doall (ginf[geometry].quotientstyle) -#define smallbounded (sphere || (quotient & qZEBRA) || torus) -#define bounded (sphere || quotient || torus) - -#define a4 (S3 == 4) -#define a45 (S3 == 4 && S7 == 5) -#define a46 (S3 == 4 && S7 == 6) -#define a47 (S3 == 4 && S7 == 7) -#define a457 (S3 == 4 && S7 != 6) -#define a467 (S3 == 4 && S7 >= 6) -#define a38 (S7 == 8) -#define sphere4 (sphere && S7 == 4) -#define stdeuc (geometry == gNormal || geometry == gEuclid || geometry == gEuclidSquare) -#define smallsphere (S7 < 5) -#define bigsphere (S7 == 5) -#define ap4 (a4 && nonbitrunc) -#define euclid4 (euclid && a4) -#define euclid6 (euclid && !a4) - -#define S6 (S3*2) -#define S42 (S7*S6) -#define S12 (S6*2) -#define S14 (S7*2) -#define S21 (S7*S3) -#define S28 (S7*4) -#define S36 (S6*6) -#define S84 (S7*S6*2) -#define MAX_EDGE 8 -#define MAX_S3 4 -#define MAX_S84 240 - #include "compileunits.h" +namespace hr { + #if CU_INIT int fontscale = 100; @@ -851,3 +416,4 @@ void playSound(cell*, const string &s, int vol) { printf("play sound: %s vol %d\ #endif #endif +} diff --git a/inventory.cpp b/inventory.cpp index 2f41bcf5..6fd01f60 100644 --- a/inventory.cpp +++ b/inventory.cpp @@ -1,7 +1,7 @@ // Hyperbolic Rogue -- Orb Strategy Mode // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details -namespace inv { +namespace hr::inv { bool on; array usedup; diff --git a/landgen.cpp b/landgen.cpp index 8f2ed7a9..7ab40161 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -2,6 +2,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + // land generation routines bool safety = false; @@ -2485,3 +2487,5 @@ void setdist(cell *c, int d, cell *from) { mapeditor::applyModelcell(c); #endif } + +} diff --git a/landlock.cpp b/landlock.cpp index 716df452..b31b535b 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -3,6 +3,8 @@ // land statistics and flags +namespace hr { + bool nodisplay(eMonster m) { return m == moIvyDead || @@ -1415,3 +1417,4 @@ int checkLands() { auto hookcl = addHook(hooks_args, 100, checkLands); */ +} diff --git a/language.cpp b/language.cpp index f48262ab..fbd01068 100644 --- a/language.cpp +++ b/language.cpp @@ -5,6 +5,8 @@ #define NUMLAN 7 +namespace hr { + const char *dnameof(eMonster m) { return minf[m].name; } const char *dnameof(eLand l) { return linf[l].name; } const char *dnameof(eWall w) { return winf[w].name; } @@ -391,3 +393,4 @@ string XLAT1(string x) { string XLATT1(stringpar p) { return XLAT1(p.v); } +} diff --git a/mapeditor.cpp b/mapeditor.cpp index e81495bd..dc2936e7 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -11,6 +11,8 @@ #include #endif +namespace hr { + namespace mapeditor { struct editwhat { @@ -1794,3 +1796,4 @@ namespace mapeditor { } +} diff --git a/menus.cpp b/menus.cpp index 33fbb5c6..30e4b0e2 100644 --- a/menus.cpp +++ b/menus.cpp @@ -6,6 +6,7 @@ #define BLACKISH 0x404040 #define REDDISH 0x400000 +namespace hr { ld whatever = 0; int PREC(ld x) { @@ -908,3 +909,4 @@ void showMessageLog() { else if(doexiton(sym, uni)) popScreen(); }; } +} diff --git a/monstergen.cpp b/monstergen.cpp index 05337bc8..f7af3067 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -4,6 +4,8 @@ // Routines concentrating on monster generation. +namespace hr { + bool timerghost = true; int buildIvy(cell *c, int children, int minleaf) { @@ -705,3 +707,4 @@ void generateSnake(cell *c, int i) { } else c2->mondir = NODIR; } +} diff --git a/netgen.cpp b/netgen.cpp index 9a76c30e..b619a71c 100644 --- a/netgen.cpp +++ b/netgen.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details #if CAP_MODEL -namespace netgen { +namespace hr::netgen { // We need a two-dimensional vector class for this. diff --git a/nofont.cpp b/nofont.cpp index e134ade8..1611d78d 100644 --- a/nofont.cpp +++ b/nofont.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- built-in font // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + #if CAP_TABFONT // compile with -DCAP_CREATEFONT=1 to generate this table // this variant has been created for non-translated HyperRogue @@ -164,3 +166,4 @@ void generateFont(int ch, SDL_Surface *txt) { } } #endif +} diff --git a/orbgen.cpp b/orbgen.cpp index 333db561..9569ea6e 100644 --- a/orbgen.cpp +++ b/orbgen.cpp @@ -3,6 +3,7 @@ #define ORBLINES 70 +namespace hr { // orbgen flags namespace orbgenflags { @@ -548,3 +549,4 @@ void placeOceanOrbs(cell *c) { } } +} diff --git a/orbs.cpp b/orbs.cpp index e211f954..b273b040 100644 --- a/orbs.cpp +++ b/orbs.cpp @@ -4,6 +4,8 @@ // Orb-related routines +namespace hr { + bool markOrb(eItem it) { if(!items[it]) return false; orbused[it] = true; @@ -1396,3 +1398,4 @@ void orboflava(int i) { forCellEx(c2, c) makelava(c2, i); } } +} diff --git a/pattern2.cpp b/pattern2.cpp index 4a72949a..fb3a89a5 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -2,6 +2,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + int gp_threecolor() { if(!gp::on) return 0; if((gp::param.first - gp::param.second) % 3 == 0) return 2; @@ -2011,3 +2013,4 @@ int val46(cell *c) { return si.id; } +} diff --git a/patterngen.cpp b/patterngen.cpp index cb8a9284..02971a12 100644 --- a/patterngen.cpp +++ b/patterngen.cpp @@ -2,6 +2,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + void spill50(cell *c, eWall w, int r) { c->wall = w; if(r) for(int i=0; itype; i++) spill50(createMov(c, i), w, r-1); @@ -443,3 +445,4 @@ void buildAutomatonRule(cell *c) { } // #define BUILDZEBRA +} diff --git a/patterns.cpp b/patterns.cpp index a50c41a8..2f5e62ae 100644 --- a/patterns.cpp +++ b/patterns.cpp @@ -2,6 +2,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + // === EMERALD PATTERN === // rules for the emeraldvalues of heptagons. @@ -1141,3 +1143,4 @@ int fifty_38(int f, int d) { + (((c + (dockflip[dock][d2]&3)) % 3) << 1) + (dockflip[dock][d2]&~3); } +} diff --git a/polygons.cpp b/polygons.cpp index 210cf66f..697d8174 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -4,6 +4,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + // draw the lines static const int POLY_DRAWLINES = 1; // draw the area @@ -3371,3 +3373,4 @@ NEWSHAPE #endif +} diff --git a/quit.cpp b/quit.cpp index e4da558d..50ad50dc 100644 --- a/quit.cpp +++ b/quit.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- the mission screen // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + bool quitsaves() { return (items[itOrbSafety] && havesave); } bool needConfirmation() { @@ -540,3 +542,4 @@ void showMissionScreen() { dialog::highlight_text = contstr(); } +} diff --git a/renderbuffer.cpp b/renderbuffer.cpp index fea9e805..d323008b 100644 --- a/renderbuffer.cpp +++ b/renderbuffer.cpp @@ -5,6 +5,8 @@ // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + #if CAP_GL #if !CAP_GLEW #if ISLINUX @@ -214,3 +216,4 @@ void resetbuffer::reset() { #endif } +} diff --git a/rogueviz-kohonen.cpp b/rogueviz-kohonen.cpp index 19dd1a3d..1b9b60ed 100644 --- a/rogueviz-kohonen.cpp +++ b/rogueviz-kohonen.cpp @@ -4,7 +4,7 @@ // Kohonen's self-organizing networks. // This is a part of RogueViz, not a part of HyperRogue. -namespace kohonen { +namespace rogueviz::kohonen { int cols; @@ -1125,11 +1125,10 @@ auto hooks = addHook(hooks_args, 100, readArgs); auto hooks2 = addHook(hooks_frame, 50, levelline::draw); } -void mark(cell *c) { +void rogueviz::mark(cell *c) { using namespace kohonen; if(kind == kKohonen && inited >= 1) { distfrom = getNeuronSlow(c); coloring(); } } - diff --git a/rogueviz-staircase.cpp b/rogueviz-staircase.cpp index e6466b7a..34721fd4 100644 --- a/rogueviz-staircase.cpp +++ b/rogueviz-staircase.cpp @@ -4,7 +4,7 @@ // Kohonen's self-organizing networks. // This is a part of RogueViz, not a part of HyperRogue. -namespace staircase { +namespace rogueviz::staircase { using namespace hyperpoint_vec; diff --git a/rogueviz.cpp b/rogueviz.cpp index 53de85d3..2d27d5ba 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -20,10 +20,10 @@ // hyper -tess -- visualize a horocyclic tesselation, -#include "rogueviz.h" - namespace rogueviz { +using namespace hr; + void init(); bool showlabels = false; @@ -935,9 +935,9 @@ string describe(shmup::monster *m) { sort(alledges.begin(), alledges.end(), edgecmp); - ::help = "Edges: "; + hr::help = "Edges: "; - if(vd.info) ::help = (*vd.info) + "\n" + help; + if(vd.info) hr::help = (*vd.info) + "\n" + help; for(int j=0; j prec; + cell *orig; + int lastdraw; + edgeinfo() { visible = true; orig = NULL; lastdraw = -1; } + }; -struct edgeinfo { - int i, j; - double weight, weight2; - bool visible; - vector prec; - cell *orig; - int lastdraw; - edgeinfo() { visible = true; orig = NULL; lastdraw = -1; } - }; - -struct colorpair { - int color1, color2; - char shade; - colorpair(int col = 0xC0C0C0FF) { shade = 0; color1 = col; } - }; - -struct vertexdata { - vector > edges; - string name; - colorpair cp; - edgeinfo *virt; - bool special; - int data; - string *info; - shmup::monster *m; - vertexdata() { virt = NULL; m = NULL; info = NULL; special = false; } - }; - -extern vector vdata; + struct colorpair { + int color1, color2; + char shade; + colorpair(int col = 0xC0C0C0FF) { shade = 0; color1 = col; } + }; + + struct vertexdata { + vector > edges; + string name; + colorpair cp; + edgeinfo *virt; + bool special; + int data; + string *info; + shmup::monster *m; + vertexdata() { virt = NULL; m = NULL; info = NULL; special = false; } + }; + + extern vector vdata; void storeall(); @@ -47,4 +63,29 @@ extern vector vdata; extern ld ggamma; extern bool showlabels; + + extern bool rog3; + extern bool rvwarp; +#if CAP_TOUR + namespace rvtour { + extern tour::slide rvslides[]; + } +#endif + + namespace kohonen { + extern int samples; + void showsample(int id); + void showsample(string id); + void describe(cell *c); + void steps(); + void showMenu(); + bool handleMenu(int sym, int uni); + } + + namespace staircase { + extern bool on; + void showMenu(); + void make_staircase(); + } } + diff --git a/rug.cpp b/rug.cpp index 3586359f..07672398 100644 --- a/rug.cpp +++ b/rug.cpp @@ -3,6 +3,7 @@ // implementation of the Hypersian Rug mode +namespace hr { #if CAP_RUG @@ -1666,7 +1667,7 @@ hyperpoint gethyper(ld x, ld y) { videopar svid = vid; setVidParam(); - hyperpoint h = ::gethyper(px, py); + hyperpoint h = hr::gethyper(px, py); vid = svid; return h; @@ -1944,3 +1945,4 @@ namespace rug { } #endif +} diff --git a/savemem.cpp b/savemem.cpp index 628543c9..2dbc3fe8 100644 --- a/savemem.cpp +++ b/savemem.cpp @@ -1,9 +1,11 @@ // Hyperbolic Rogue -- smart memory cleaner // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + bool memory_saving_mode = true; -#define LIM 150 +static const int LIM = 150; heptagon *last_cleared; @@ -168,3 +170,5 @@ bool is_cell_removed(cell *c) { void set_if_removed(cell*& c, cell *val) { if(is_cell_removed(c)) c = val; } + +} diff --git a/scores.cpp b/scores.cpp index ca9df69b..650f1311 100644 --- a/scores.cpp +++ b/scores.cpp @@ -3,7 +3,7 @@ #if CAP_SAVE -namespace scores { +namespace hr::scores { vector scores; score *currentgame; diff --git a/shaders.cpp b/shaders.cpp index 41d71e6c..56140f16 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -2,6 +2,8 @@ // If CAP_SHADER is 0, OpenGL 1.0 is used. // If CAP_SHADER is 1, GLSL is used. +namespace hr { + #ifndef DEBUG_GL #define DEBUG_GL 0 #endif @@ -640,3 +642,4 @@ void set_depthtest(bool b) { } } } +} diff --git a/shmup.cpp b/shmup.cpp index ad5b9e11..3ec6592f 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -4,6 +4,8 @@ // implementation of the shoot'em up mode +namespace hr { + extern int mousex, mousey; extern bool clicked; @@ -368,7 +370,7 @@ void handleConfig(int sym, int uni) { shmupcfg = !shmupcfg; #if CAP_CONFIG else if(uni == 'c') - ::saveConfig(); + hr::saveConfig(); #endif else if(uni == 'n' || uni == 'N') { vid.scfg.players += shiftmul > 0 ? 1 : -1; @@ -2263,7 +2265,7 @@ void moveBullet(monster *m, int delta) { bool revive = m2->type == moMirrorSpirit && !m2->dead; killMonster(m2, m->parent ? m->parent->type : moNone); if(revive && m2->dead) { - ::kills[moMirrorSpirit]--; + hr::kills[moMirrorSpirit]--; multi::kills[cpid]--; mirrorspirits++; } @@ -3576,3 +3578,4 @@ auto hooks = addHook(clearmemory, 0, shmup::clearMemory) + }); } +} diff --git a/sound.cpp b/sound.cpp index 03a65ed7..5744d06c 100644 --- a/sound.cpp +++ b/sound.cpp @@ -1,6 +1,8 @@ // Hyperbolic Rogue -- routines related to sounds // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +namespace hr { + bool audio; string musiclicense; string musfname[landtypes]; @@ -216,3 +218,4 @@ void playSound(cell *c, const string& fname, int vol) { void resetmusic() {} #endif +} diff --git a/surface.cpp b/surface.cpp index f8c8ebf0..bfd7c14d 100644 --- a/surface.cpp +++ b/surface.cpp @@ -4,7 +4,7 @@ // See http://webmath2.unito.it/paginepersonali/sergio.console/CurveSuperfici/AG15.pdf for a nice reference #if CAP_SURFACE -namespace surface { +namespace hr::surface { using namespace hyperpoint_vec; diff --git a/sysconfig.h b/sysconfig.h new file mode 100644 index 00000000..9ed9dd66 --- /dev/null +++ b/sysconfig.h @@ -0,0 +1,378 @@ +// Hyperbolic Rogue -- set compiler flags, and include all the required system headers +// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details + +#ifdef MAC +#define ISMAC 1 +#endif + +#ifdef LINUX +#define ISLINUX 1 +#endif + +#ifdef WINDOWS +#define ISWINDOWS 1 +#endif + +#if ISSTEAM +#define NOLICENSE +#endif + +#ifndef CAP_SHADER +#define CAP_SHADER CAP_GL +#endif + +// OS settings + +#ifndef ISMAC +#define ISMAC 0 +#endif + +#ifndef ISLINUX +#define ISLINUX 0 +#endif + +#ifndef ISWINDOWS +#define ISWINDOWS 0 +#endif + +#ifndef ISPANDORA +#define ISPANDORA 0 +#endif + +#ifndef ISIOS +#define ISIOS 0 +#endif + +#ifndef ISANDROID +#define ISANDROID 0 +#endif + +#ifndef ISWEB +#define ISWEB 0 +#endif + +#ifndef ISFAKEMOBILE +#define ISFAKEMOBILE 0 +#endif + +#define ISMOBILE (ISIOS || ISANDROID || ISFAKEMOBILE) +#define ISMOBWEB (ISMOBILE || ISWEB) + +#ifndef ISMINI +#define ISMINI 0 +#endif + +#ifndef CAP_XGD +#define CAP_XGD (ISANDROID || ISFAKEMOBILE) +#endif + +#define CAP_FRAMELIMIT (!ISMOBWEB) + +#if ISMOBILE==1 +#define EXTERNALFONT +#endif + +#ifndef CAP_FILES +#define CAP_FILES 1 +#endif + +#ifndef CAP_INV +#define CAP_INV 1 +#endif + +#ifndef CAP_ANDROIDSHARE +#define CAP_ANDROIDSHARE (ISANDROID) +#endif + +#ifndef CAP_SDL +#define CAP_SDL (!ISMOBILE) +#endif + +#ifdef CAP_COMPASS +#define CAP_COMPASS ISMOBILE +#endif + +#ifndef CAP_SDLGFX +#define CAP_SDLGFX (CAP_SDL && !ISWEB) +#endif + +#ifndef CAP_GL +#define CAP_GL (ISMOBILE || CAP_SDL) +#endif + +#ifndef CAP_AUDIO +#define CAP_AUDIO ((ISMOBILE || CAP_SDL) && !ISWEB && !ISMINI) +#endif + +#define CAP_GLORNOT (CAP_GL && !ISWEB && !ISIOS) + +#if ISSTEAM +#define CAP_DAILY 1 +#endif + +#ifndef CAP_DAILY +#define CAP_DAILY 0 +#endif + +#ifndef CAP_CERTIFY +#define CAP_CERTIFY 0 +#endif + +#ifndef CAP_RUG +#define CAP_RUG (!ISMINI && CAP_GL) +#endif + +#ifndef CAP_SURFACE +#define CAP_SURFACE CAP_RUG +#endif + +#ifndef CAP_EDIT +#define CAP_EDIT (CAP_FILES && !ISWEB && !ISMINI) +#endif + +#ifndef CAP_ODS +#define CAP_ODS 0 +#endif + +#ifndef CAP_TEXTURE +#define CAP_TEXTURE (CAP_GL && (CAP_PNG || CAP_SDL_IMG) && !ISMINI) +#endif + +#ifndef CAP_MODEL +#define CAP_MODEL (!ISMOBWEB && !ISMINI && CAP_SDLGFX) +#endif + +#ifndef CAP_SAVE +#define CAP_SAVE (CAP_FILES && !ISWEB && !ISMINI) +#endif + +#ifndef CAP_CONFIG +#define CAP_CONFIG (CAP_FILES && !ISWEB && !ISMINI) +#endif + +#ifndef CAP_TRANS +#define CAP_TRANS (!ISWEB && !ISMINI) +#endif + +#ifndef CAP_TOUR +#define CAP_TOUR (!ISWEB && !ISMINI) +#endif + +#ifndef CAP_ROGUEVIZ +#define CAP_ROGUEVIZ 0 +#endif + +#ifndef CAP_PROFILING +#define CAP_PROFILING 0 +#endif + +#define PSEUDOKEY_WHEELDOWN 2501 +#define PSEUDOKEY_WHEELUP 2502 +#define PSEUDOKEY_RELEASE 2503 + +#ifndef CAP_PNG +#define CAP_PNG (!ISMOBWEB) +#endif + +#ifndef CAP_ORIENTATION +#define CAP_ORIENTATION ISMOBILE +#endif + +#ifndef CAP_COMMANDLINE +#define CAP_COMMANDLINE (!ISMOBILE) +#endif + +#define CAP_SDLAUDIO (CAP_SDL && CAP_AUDIO) + +#ifndef CAP_SVG +#define CAP_SVG (!ISMOBILE) +#endif + +#ifndef CAP_POLY +#define CAP_POLY (CAP_SDLGFX || CAP_GL || CAP_SVG) +#endif + +#define CAP_QUEUE CAP_POLY +#define CAP_CURVE CAP_POLY + +#ifndef CAP_SDLJOY +#define CAP_SDLJOY (CAP_SDL && !ISWEB) +#endif + +#ifndef CAP_SDL_IMG +#define CAP_SDL_IMG 0 +#endif + +#ifndef CAP_SDLTTF +#define CAP_SDLTTF (CAP_SDL && !ISMOBILE && !ISWEB) +#endif + +#define CAP_GLFONT (CAP_GL && !ISMOBILE) + +#ifndef CAP_TABFONT +#define CAP_TABFONT (ISWEB) +#endif + +#ifndef CAP_CREATEFONT +#define CAP_CREATEFONT 0 +#endif + +#ifndef CAP_FIXEDSIZE +#define CAP_FIXEDSIZE (CAP_CREATEFONT || CAP_TABFONT ? 36 : 0) +#endif + +#ifndef CAP_SHMUP +#define CAP_SHMUP 1 +#endif + +#ifdef ISSTEAM +#define CAP_ACHIEVE 1 +#endif + +#ifndef CAP_BITFIELD +#define CAP_BITFIELD (!ISWEB) +#endif + +#ifndef CAP_ACHIEVE +#define CAP_ACHIEVE 0 +#endif + +#ifndef CAP_SHMUP_GOOD +#define CAP_SHMUP_GOOD (!ISMOBWEB) +#endif + +#if ISMOBILE +#define EXTRALICENSE "\n\nHyperRogue soundtrack by Shawn Parrotte (http://www.shawnparrotte.com), under the Creative Commons BY-SA 3.0 license, http://creativecommons.org/licenses/by-sa/3.0/" +#undef XEXTRALICENSE +#endif + +#ifndef HYPERPATH +#define HYPERPATH "" +#endif + +#include + +#if CAP_SDL +#include + +#if !ISMAC +#undef main +#endif + +#if CAP_SDLAUDIO +#include +#endif + +#if CAP_SDLTTF +#include +#endif + +#if CAP_SDLGFX +#include +#endif + +#elif !ISFAKEMOBILE +#define SDLK_F1 (123001) +#define SDLK_F2 (123002) +#define SDLK_F3 (123003) +#define SDLK_F4 (123004) +#define SDLK_F5 (123005) +#define SDLK_F6 (123006) +#define SDLK_F7 (123007) +#define SDLK_F8 (123008) +#define SDLK_F9 (123009) +#define SDLK_F10 (123010) +#define SDLK_ESCAPE (123099) +#define SDLK_F12 (123012) +#define SDLK_HOME (123013) +#define SDLK_LEFT (123014) +#define SDLK_RIGHT (123015) +#define SDLK_END (123016) +#define MIX_MAX_VOLUME 128 +#define SDLK_UP (123021) +#define SDLK_DOWN (123022) +#define SDLK_PAGEUP (123023) +#define SDLK_PAGEDOWN (123024) +#define SDLK_RETURN (123025) +#define SDLK_KP1 (123031) +#define SDLK_KP2 (123032) +#define SDLK_KP3 (123033) +#define SDLK_KP4 (123034) +#define SDLK_KP5 (123035) +#define SDLK_KP6 (123036) +#define SDLK_KP7 (123037) +#define SDLK_KP8 (123038) +#define SDLK_KP9 (123039) +#define SDLK_KP_PERIOD (123051) +#define SDLK_KP_MINUS (123053) +#define SDLK_DELETE (123052) +#define SDLK_DELETE (123052) +#define SDLK_KP_ENTER (123054) +#define SDLK_BACKSPACE (123055) +typedef int SDL_Event; +typedef unsigned int Uint32; +#endif + +#if ISWEB +extern "C" { + Uint8 *SDL_GetKeyState(void*); +} +// inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; } +#endif + + +#ifndef CAP_GLEW +#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB) +#endif + +#if CAP_GL +#if CAP_GLEW + #include +#else + #define GL_GLEXT_PROTOTYPES 1 + #if ISMAC + #include + #include + #include + #elif ISIOS + // already included + #elif ISANDROID + #include + #include + #include + #include + #define GLES_ONLY + #else + #include + #include + #include + #endif + #endif +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_UNORDERED_MAP +#include +#else +#define unordered_map map +#endif + +#if CAP_SDL +union SDL_Event; +#endif diff --git a/system.cpp b/system.cpp index cb22ab5a..2c7e6778 100644 --- a/system.cpp +++ b/system.cpp @@ -4,6 +4,8 @@ // routines for: initializing/closing, loading/saving, and cheating +namespace hr { + bool need_reset_geometry = true; bool game_active; @@ -1308,3 +1310,4 @@ addHook(hooks_removecells, 0, [] () { for(int i=0; i