diff --git a/3d-models.cpp b/3d-models.cpp index 480cd99f..dd0e01ee 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -1,8 +1,10 @@ // HyperRogue -// This file contains the routines to convert HyperRogue's old vector graphics into 3D models - // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file 3d-models.cpp + * \brief This file contains the routines to convert HyperRogue's old vector graphics into 3D models + */ + #include "earcut.hpp" namespace hr { @@ -221,11 +223,6 @@ void geometry_information::make_ha_3d(hpcshape& sh, bool isarmor, ld scale) { shift_last(-BODY); } -/* -void make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 0.90); } -void make_armor_3d(hpcshape& sh, ld scale = 1) { make_ha_3d(sh, true, scale); } -*/ - void geometry_information::make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 1); } void geometry_information::addtri(array hs, int kind) { diff --git a/achievement.cpp b/achievement.cpp index 04998348..2b6afbbc 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -1,5 +1,11 @@ -// Hyperbolic Rogue -- achievements -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- Achievements +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file achievements.cpp + * \brief This file implements routines related to achievements and leaderboards + * + * This routines are general, i.e., not necessarily Steam-specific. + */ namespace hr { @@ -84,9 +90,12 @@ EX void upload_score(int id, int v); string achievementMessage[3]; int achievementTimer; -// achievements received this game +/** achievements received this game */ EX vector achievementsReceived; +/** Returns true if the given achievement cannot be obtained in the current mode. + * @param flags Mode requested by the achievement. + */ EX bool wrongMode(char flags) { if(cheater) return true; if(flags == rg::global) return false; @@ -147,9 +156,11 @@ EX void achievement_log(const char* s, char flags) { EX void achievement_init(); EX string myname(); EX void achievement_close(); -// gain the achievement with the given name. -// flags: 'e' - for Euclidean, 's' - for Shmup, '7' - for heptagonal -// Only awarded if special modes are matched exactly. + +/** gain the given achievement. + * @param s name of the achievement, e.g., DIAMOND1 + * @param flags one of the constants from namespace rg. The achievement is only awarded if special modes are matched exactly. + */ EX void achievement_gain(const char* s, char flags IS(0)); #if ISSTEAM @@ -476,7 +487,12 @@ EX void achievement_collection(eItem it, int prevgold, int newgold) { } } -// this is used for 'counting' achievements, such as kill 10 monsters at the same time. +/** This function awards 'counting' achievements, such as kill 10 monsters at the same time. + * @param s name of the group of achievements, e.g. GOLEM. + * @param current our score, e.g., the the achievement GOLEM2 will be awared with current >= 5. + * @param prev previous value of the score. + */ + EX void achievement_count(const string& s, int current, int prev) { if(cheater) return; if(shmup::on) return; @@ -622,8 +638,9 @@ EX void improveItemScores() { int next_stat_tick; -// gain the final achievements. Called with really=false whenever the user -// looks at their score, and really=true when the game really ends. +/** gain the final achievements. + * @param really false: the user is simply looking at the score; true: the game really ended. + */ EX void achievement_final(bool really_final) { if(offlineMode) return; @@ -740,8 +757,9 @@ EX void check_total_victory() { achievement_gain("TOTALVICTORY"); } -// gain the victory achievements. Set 'hyper' to true for -// the Hyperstone victory, and false for the Orb of Yendor victory. +/** gain the victory achievements. + * @param hyper true for the Hyperstone victory, and false for the Orb of Yendor victory. + */ EX void achievement_victory(bool hyper) { DEBBI(DF_STEAM, ("achievement_victory")) if(offlineMode) return; @@ -812,14 +830,14 @@ EX void achievement_victory(bool hyper) { #endif } -// call the achievement callbacks +/** call the achievement callbacks */ EX void achievement_pump(); #ifndef HAVE_ACHIEVEMENTS void achievement_pump() {} #endif -// display the last achievement gained. +/** display the last achievement gained. */ EX void achievement_display() { #ifdef HAVE_ACHIEVEMENTS if(achievementTimer) { diff --git a/archimedean.cpp b/archimedean.cpp index fa071946..4f4d2aac 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -1,6 +1,11 @@ -// Hyperbolic Rogue -// This file implements the 'Archimedean tilings' geometry. -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- Archimedean Tilings +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file archimedean.cpp + * \brief Archimedean tilings + * + * These are tilings available in the 'Archimedean' option in Geometry Experiments; simpler Archimedean tilings are defined in other files. + */ namespace hr { @@ -80,22 +85,23 @@ static const int sfSEMILINE = 16; EX archimedean_tiling current; -// id of vertex in the archimedean tiling -// odd numbers = reflected tiles -// 0, 2, ..., 2(N-1) = as in the symbol -// 2N = bitruncated tile +/** id of vertex in the archimedean tiling + * odd numbers = reflected tiles + * 0, 2, ..., 2(N-1) = as in the symbol + * 2N = bitruncated tile + */ EX short& id_of(heptagon *h) { return h->zebraval; } -// which index in id_of's neighbor list does h->move[0] have +/** which index in id_of's neighbor list does h->move(0) have */ EX short& parent_index_of(heptagon *h) { return h->emeraldval; } -// total number of neighbors +/** total number of neighbors */ EX int neighbors_of(heptagon *h) { return isize(current.triangles[id_of(h)]); @@ -726,7 +732,7 @@ void connectHeptagons(heptspin hi, heptspin hs) { // heptagon *hnew = build_child(h, d, get_adj(h, d).first, get_adj(h, d).second); } -// T and X are supposed to be equal -- move T so that it is closer to X +/** T and X are supposed to be equal -- move T so that it is closer to X */ void fixup_matrix(transmatrix& T, const transmatrix& X, ld step) { for(int i=0; ibardir != NODIR && c->bardir != NOBARRIERS; } +/** return true if the cell c is not allowed to generate barriers because of other large things already existing nearby. */ EX void preventbarriers(cell *c) { if(c && c->bardir == NODIR) c->bardir = NOBARRIERS; } @@ -60,7 +64,7 @@ EX bool checkBarriersBack(cellwalker bb, int q IS(5), bool cross IS(false)) { return checkBarriersFront(bb, q); } -// warp coasts use a different algorithm when has_nice_dual() is on +/** warp coasts use a different algorithm for nowall barriers when has_nice_dual() is on. Check whether we should use this different algorithm when the lands are l1 and l2 */ EX bool warped_version(eLand l1, eLand l2) { return (has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast)) || (VALENCE == 3); } diff --git a/basegraph.cpp b/basegraph.cpp index 5023711a..f4fce0da 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -1,20 +1,34 @@ // Hyperbolic Rogue -- basic graphics // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file basegraph.cpp + * \brief This file implements the basic graphical routines + */ + namespace hr { #if HDR +/** configuration of the current view */ struct display_data { - transmatrix view_matrix; // current rotation, relative to viewctr - transmatrix player_matrix; // player-relative view + /** This specifies the heptagon the view is currently centered on. + * Unused in masterless tilings -- precise_center is used there. + */ heptspin view_center; + /** The current rotation, relative to viewctr. */ + transmatrix view_matrix; + /** The view relative to the player character. */ + transmatrix player_matrix; + /** The cell which is precisely in the center. */ cellwalker precise_center; + /** On-screen coordinates for all the visible cells. */ unordered_map cellmatrices, old_cellmatrices; - ld xmin, ymin, xmax, ymax; // relative - ld xtop, ytop, xsize, ysize; // in pixels + /** Position of the current map view, relative to the screen (0 to 1). */ + ld xmin, ymin, xmax, ymax; + /** Position of the current map view, in pixels. */ + ld xtop, ytop, xsize, ysize; display_data() { xmin = ymin = 0; xmax = ymax = 1; } - // paramaters calculated from the above + /** Center of the current map view, in pixels. */ int xcenter, ycenter; ld radius; int scrsize; @@ -47,6 +61,7 @@ struct display_data { EX display_data default_display; EX display_data *current_display = &default_display; +/** Color of the background. */ EX unsigned backcolor = 0; EX unsigned bordcolor = 0; EX unsigned forecolor = 0xFFFFFF; @@ -1232,8 +1247,6 @@ ld textscale() { return vid.fsize / (current_display->radius * cgi.crossf) * (1+vid.alpha) * 2; } -// bool notgl = false; - bool setfsize = true; EX bool vsync_off; diff --git a/bigstuff.cpp b/bigstuff.cpp index 9e9d619a..ef0c031e 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -1,10 +1,17 @@ -// This file implements: -// * routines related to (horo)cycles -// * routines related to equidistants -// * 'setland' routines for other geometries -// * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators. +// Hyperbolic Rogue -- Big Stuff // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file bigstuff.cpp + * \brief Large map structures, such as (horo)cycles and equidistants. + * + * This file implements: + * * routines related to (horo)cycles + * * routines related to equidistants + * * 'setland' routines for other geometries + * * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators. + * This routines are general, i.e., not necessarily Steam-specific. + */ + // horocycles namespace hr { diff --git a/binary-tiling.cpp b/binary-tiling.cpp index e2a40f54..baccc699 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -1,8 +1,10 @@ - -// implementation of the binary tilings - +// Hyperbolic Rogue -- binary tilings // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file binary-tiling.cpp + * \brief Binary tilings in 2D and 3D + */ + namespace hr { EX namespace binary { diff --git a/blizzard.cpp b/blizzard.cpp index 52aa6d81..50aacf32 100644 --- a/blizzard.cpp +++ b/blizzard.cpp @@ -1,5 +1,9 @@ -// Hyperbolic Rogue -- special graphical effects, such as the Blizzard -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- Blizzard +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file blizzard.cpp + * \brief special graphical effects, such as the Blizzard and arrow traps + */ namespace hr { diff --git a/cell.cpp b/cell.cpp index 44cb88bf..1a0b92aa 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1,7 +1,11 @@ // Hyperbolic Rogue -- cells -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// cells the game is played on +/** \file cell.cpp + * \brief General cells and maps + * + * Start with locations.cpp + */ namespace hr { @@ -35,7 +39,7 @@ struct hrmap { virtual vector get_vertices(cell*); }; -// hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient +/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient */ struct hrmap_standard : hrmap { void draw() override; transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hint) override; @@ -124,7 +128,7 @@ hrmap_hyperbolic::hrmap_hyperbolic() { h.c7 = newCell(S7, origin); } -// very similar to createMove in heptagon.cpp +/** very similar to createMove in heptagon.cpp */ EX cell *createMov(cell *c, int d) { if(d<0 || d>= c->type) { printf("ERROR createmov\n"); @@ -253,7 +257,7 @@ EX euc_pointer euclideanAtCreate(int vec) { hookset *hooks_newmap; -// initializer (also inits origin from heptagon.cpp) +/** create a map in the current geometry */ EX void initcells() { DEBB(DF_INIT, ("initcells")); diff --git a/commandline.cpp b/commandline.cpp index 23bd98f8..670c9ce9 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- commandline options // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file commandline.cpp + * \brief Commandline options support + */ + namespace hr { #if CAP_COMMANDLINE diff --git a/complex.cpp b/complex.cpp index a7178b23..8f55e3f1 100644 --- a/complex.cpp +++ b/complex.cpp @@ -1,9 +1,11 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- Complex features +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// namespaces for complex features (whirlwind, whirlpool, elec, princess, clearing, -// mirror, hive, heat + livecaves, etc.) - -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file complex.cpp + * \brief This file implements the gameplay/generation for the more complex lands and mechanics. + * + * Includes: whirlwind, whirlpool, elec, princess, clearing, mirror, hive, heat + livecaves, etc. + */ namespace hr { @@ -1543,7 +1545,7 @@ EX namespace mirror { for(int i=0; ilandparam & 255) == 0) { bool cando = false; diff --git a/complex2.cpp b/complex2.cpp index 204023a9..129c029c 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -1,9 +1,12 @@ -// Hyperbolic Rogue - -// namespaces for new complex lands for HR11 - +// Hyperbolic Rogue - Complex features part II // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file complex2.cpp + * \brief Continuation of complex.cpp + * + * Includes: Brownian, Irradiated, Free Fall + */ + #ifdef CAP_COMPLEX2 namespace hr { diff --git a/config.cpp b/config.cpp index 65cde672..83334070 100644 --- a/config.cpp +++ b/config.cpp @@ -1,7 +1,10 @@ // Hyperbolic Rogue -- configuration - // Copyright (C) 2017-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file config.cpp + * \brief Configuration -- initial settings, saving/loading ini files, menus, etc. + */ + namespace hr { #if HDR diff --git a/control.cpp b/control.cpp index 31131dba..caf4284c 100644 --- a/control.cpp +++ b/control.cpp @@ -1,5 +1,9 @@ // Hyperbolic Rogue -- control -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file control.cpp + * \brief Routines related to controlling the game + */ namespace hr { diff --git a/crystal.cpp b/crystal.cpp index 1f2a6ac7..0774d0ad 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -1,19 +1,14 @@ -// Hyperbolic Rogue -// This file implements the multi-dimensional (aka crystal) geometries. -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- Crystal geometries +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file crystal.cpp + * \brief Multi-dimensional (aka crystal) geometries. + */ namespace hr { EX namespace crystal { #if CAP_CRYSTAL -// Crystal can be bitruncated either by changing variation to bitruncated. -// In case of the 4D Crystal, the standard HyperRogue bitruncation becomes -// confused by having both the original and new vertices of degree 8. -// Hence Crystal implements its own bitruncation, which is selected/checked -// by setting ginf[gCrystal].vertex to 3. Additionally, this lets us double -// bitruncate. - -// Function pure() checks for both kinds of bitruncation (or any other variations). #if HDR static const int MAXDIM = 7; @@ -24,6 +19,15 @@ typedef array ldcoord; static const ldcoord ldc0 = {}; #endif +/** Crystal can be bitruncated either by changing variation to bitruncated. + * In case of the 4D Crystal, the standard HyperRogue bitruncation becomes + * confused by having both the original and new vertices of degree 8. + * Hence Crystal implements its own bitruncation, which is selected/checked + * by setting ginf[gCrystal].vertex to 3. Additionally, this lets us double + * bitruncate. + * Function pure() checks for both kinds of bitruncation (or any other variations). + */ + EX bool pure() { return PURE && ginf[gCrystal].vertex == 4; } @@ -54,14 +58,14 @@ void resize2(vector>& v, int a, int b, int z) { for(auto& w: v) w.resize(b, z); } -// in the "pure" form, the adjacent vertices are internaly spaced by 2... +/** in the "pure" form, the adjacent vertices are internaly spaced by 2 */ const int FULLSTEP = 2; -// ... to make space for the additional vertices which are added in the bitruncated version +/** to make space for the additional vertices which are added in the bitruncated version */ const int HALFSTEP = 1; -// with variations, the connections of the vertex at coordinate v+FULLSTEP mirror the connections -// of the vertex at coordinate v. Therefore, the period of our construction is actually 2*FULLSTEP. +/** with variations, the connections of the vertex at coordinate v+FULLSTEP mirror the connections + * of the vertex at coordinate v. Therefore, the period of our construction is actually 2*FULLSTEP. */ const int PERIOD = 2 * FULLSTEP; struct crystal_structure { @@ -347,19 +351,6 @@ int fiftyrule(coord c) { if(res[index] == -1) exit(1); return res[index]; - - /* - int res = 0; - int d = (c[0]&1) + 2 * (c[1]&1) + 4 * (c[2]&1) + 8 * (c[3]&1); - if(d == 0) res = 0; - else if(d == 3 || d == 12) res = 2; - else if(d == 6 || d == 9) res = 4; - else return -1; - bool odd = (c[0]^c[1]^c[2]^c[3])&2; - if(odd) - res ^= 32; - // the '1' bit set by hand - */ } bool is_bi(crystal_structure& cs, coord co); diff --git a/debug.cpp b/debug.cpp index 6e28186f..18188402 100644 --- a/debug.cpp +++ b/debug.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- debugging routines // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file debug.cpp + * \brief Debugging and cheating + */ + namespace hr { EX int steplimit = 0; @@ -471,8 +475,7 @@ EX void push_debug_screen() { pushScreen(ds); } -// -- cheat menu -- - +/** show the cheat menu */ EX void showCheatMenu() { gamescreen(1); dialog::init("cheat menu"); @@ -515,6 +518,7 @@ EX void showCheatMenu() { }; } +/** view all the monsters and items */ EX void viewall() { celllister cl(cwt.at, 20, 2000, NULL); @@ -550,6 +554,7 @@ EX void viewall() { } } +/** launch a debugging screen, and continue normal working only after this screen is closed */ EX void modalDebug(cell *c) { viewctr.at = c->master; if(noGUI) { diff --git a/dialogs.cpp b/dialogs.cpp index ebd246be..1f5c2b5c 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -1,18 +1,9 @@ // Hyperbolic Rogue -- dialogs // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details -/* Missing. - -#if ISMOBILE==0 - dialog::addItemHelp(16, XLAT("use Shift to decrease and Ctrl to fine tune ")); - dialog::addItemHelp(17, XLAT("(e.g. Shift+Ctrl+Z)")); -#endif - - if(xuni == 'i') { - } - - -*/ +/** \file dialogs.cpp + * \brief Implementation of various generic dialogs and elements of dialog windows + */ namespace hr { diff --git a/drawing.cpp b/drawing.cpp index 0bd1a7b3..b52ea95a 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1,8 +1,10 @@ - -// implementation of the rendering queue - +// Hyperbolic Rogue -- rendering // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file drawing.cpp + * \brief Rendering shapes (dqi_draw), queue of shapes to render (ptds), etc. + */ + namespace hr { #if HDR @@ -110,8 +112,6 @@ bool fatborder; EX color_t poly_outline; -// #define STLSORT - EX vector> ptds; #if CAP_GL diff --git a/euclid.cpp b/euclid.cpp index c502fde4..f57e8ac3 100644 --- a/euclid.cpp +++ b/euclid.cpp @@ -1,5 +1,9 @@ -// Hyperbolic Rogue -- Euclidean geometry, including 2D, 3D, and quotient spaces -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- Euclidean geometry +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file euclid.cpp + * \brief Euclidean geometry, including 2D, 3D, and quotient spaces + */ namespace hr { diff --git a/expansion.cpp b/expansion.cpp index 01438a27..7c4764ba 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -1,5 +1,12 @@ -// HyperRogue -- expansion_analyzer -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- expansion analyzer +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file expansion.cpp + * \brief exponential growth of hyperbolic geometries + * + * Calculations related to this exponential growth. + * Screens which display this exponential growth (e.g. 'size of the world' in geometry experiments) are also implemented here. + */ namespace hr { diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 8842300d..b7ce7b6e 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -1,6 +1,10 @@ -// Hyperbolic Rogue -- implementation of the quotient geometries based on fields +// Hyperbolic Rogue -- Field Quotient geometry // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file fieldpattern.cpp + * \brief Field Quotient geometry + */ + #if CAP_FIELD namespace hr { diff --git a/flags.cpp b/flags.cpp index fa2bd094..bd9495d7 100644 --- a/flags.cpp +++ b/flags.cpp @@ -1,26 +1,10 @@ -// Hyperbolic Rogue -// implementation of various simple flags for lands, items, monsters, and walls +// Hyperbolic Rogue - Flags -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details - -/* -rewritten -*/ - -// itemclass -// slimegroup (wall) - -/* - it == itOrbLove ? shLoveRing : - isRangedOrb(it) ? shTargetRing : - isOffensiveOrb(it) ? shSawRing : - isFriendOrb(it) ? shPeaceRing : - isUtilityOrb(it) ? shGearRing : - isDirectionalOrb(it) ? shSpearRing : - among(it, itOrb37, itOrbGravity) ? shHeptaRing : - shRing; -*/ +/** \file flags.cpp + * \brief Implementation of various simple flags for lands, items, monsters, and walls. + */ namespace hr { diff --git a/floorshapes.cpp b/floorshapes.cpp index db6a9535..5f3149da 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -1,3 +1,11 @@ +// Hyperbolic Rogue - Floor Shapes + +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file floorshapes.cpp + * \brief Adjusting the floor shapes to various geometries. + */ + namespace hr { #if CAP_SHAPES diff --git a/game.cpp b/game.cpp index 89173aa4..99c5d744 100644 --- a/game.cpp +++ b/game.cpp @@ -1,7 +1,9 @@ -// Hyperbolic Rogue -// main game routines: movement etc. +// Hyperbolic Rogue - Game routines +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file game.cpp + * \brief Routines for game itself: movement of PC and monsters, basic mechanics, etc. + */ namespace hr { @@ -78,7 +80,7 @@ EX bool canmove = true; int sagephase = 0; -// number of Grails collected, to show you as a knight +/** number of Grails collected, to show you as a knight */ int knighted = 0; bool usedSafety = false; @@ -87,8 +89,10 @@ int safetyseed; int showid = 0; +/** last move was invisible */ EX bool invismove = false; -EX bool invisfish = false; // last move was invisible [due to Fish] +/** last move was invisible due to Orb of Fish (thus Fish still see you)*/ +EX bool invisfish = false; int noiseuntil; // noise until the given turn @@ -104,69 +108,86 @@ bool landvisited[landtypes]; bool eq(short a, short b) { return a==b; } -// game state +/** for treasures, the number collected; for orbs, the number of charges */ EX array items; +/** how many instances of each monster type has been killed */ EX array kills; EX int explore[10], exploreland[10][landtypes], landcount[landtypes]; EX map > hiitems; bool orbused[ittypes], lastorbused[ittypes]; -EX bool playermoved = true; // center on the PC? -EX bool flipplayer = true; // flip the player image after move, do not flip after attack -EX int cheater = 0; // did the player cheat? +/** should we center the screen on the PC? */ +EX bool playermoved = true; +/** if false, make the PC look in direction cwt.spin (after attack); otherwise, make them look the other direction (after move) */ +EX bool flipplayer = true; +/** did the player cheat? how many times? */ +EX int cheater = 0; -int anthraxBonus = 0; // for using Safety in tactical Camelot +/** this value is used when using Orb of Safety in the Camelot in Pure Tactics Mode */ +int anthraxBonus = 0; -EX vector dcal; // queue for cpdist -vector pathq; // queue for pathdist +/** the list of all nearby cells, according to cpdist */ +EX vector dcal; +/** the list of all nearby cells, according to current pathdist */ +vector pathq; -vector offscreen; // offscreen cells to take care off +/** offscreen cells to take care off */ +vector offscreen; -vector pathqm; // list of monsters to move (pathq restriced to monsters) - -vector targets; // list of monster targets +/** list of monsters to move (pathq restriced to monsters) */ +vector pathqm; -// monsters of specific types to move +/** list of cells that the monsters are targetting (PCs, allies, Thumpers, etc.) */ +vector targets; + +/** monsters of specific types to move */ vector worms, ivies, ghosts, golems, hexsnakes; /** temporary changes during bfs */ vector> tempmonsters; -// a bit nicer way of DFS +/** additional direction information for BFS algorithms. + * It remembers from where we have got to this location + * the opposite cell will be added to the queue first, + * which helps the AI. + **/ vector reachedfrom; -// additional direction information for BFS algorithms -// it remembers from where we have got to this location -// the opposite cell will be added to the queue first, -// which helps the AI +/** monsters to move, ordered by the number of possible good moves */ vector movesofgood[MAX_EDGE+1]; -int first7; // the position of the first monster at distance 7 in dcal +/** The position of the first cell in dcal in distance 7. New wandering monsters can be generated in dcal[first7..]. */ +int first7; -EX cellwalker cwt; // single player character position +/** Cellwalker describing the single player. Also used temporarily in shmup and multiplayer modes. */ +EX cellwalker cwt; EX inline cell*& singlepos() { return cwt.at; } EX inline bool singleused() { return !(shmup::on || multi::players > 1); } -// the main random number generator for the game -// all the random calls related to the game mechanics (land generation, AI...) should use hrngen -// random calls not related to the game mechanics (graphical effects) should not use hrngen -// this ensures that the game should unfold exactly the same if given the same seed and the same input +/** the main random number generator for the game + * all the random calls related to the game mechanics (land generation, AI...) should use hrngen + * random calls not related to the game mechanics (graphical effects) should not use hrngen + * this ensures that the game should unfold exactly the same if given the same seed and the same input + */ std::mt19937 hrngen; +/** initialize hrngen @see hrngen */ EX void shrand(int i) { hrngen.seed(i); } +/** generate a large number with hrngen */ EX int hrandpos() { return hrngen() & HRANDMAX; } -// using our own implementations rather than ones from , -// to make sure that they return the same values on different compilers +/** A random integer from [0..i), generated from hrngen. + * We are using our own implementations rather than ones from , + * to make sure that they return the same values on different compilers. +m * + * @see hrngen + **/ -// a random integer from [0..i), generated by the game's main generator -// we want the same world to be generated if the seed is the same. For this purpose, -// hrand should be used for all the game-related generation, and nowhere else EX int hrand(int i) { unsigned d = hrngen() - hrngen.min(); long long m = (long long) (hrngen.max() - hrngen.min()) + 1; @@ -181,10 +202,17 @@ template T pick(T x, U... u) { std::initializer_list i = template void hrandom_shuffle(T* x, int n) { for(int k=1; kmonst)) { int lim = 0; @@ -2929,12 +2957,14 @@ EX void buildAirmap() { sort(airmap.begin(), airmap.end()); } +/** current state of the rose scent + * rosemap[c] &3 can be: + * 0 - wave not reached + * 1 - wave expanding + * 2 - wave phase 1 + * 3 - wave phase 2 + */ map rosemap; -// rosemap&3: -// 0 - wave not reached -// 1 - wave expanding -// 2 - wave phase 1 -// 3 - wave phase 2 EX int rosedist(cell *c) { if(!(havewhat&HF_ROSE)) return 0; @@ -3126,7 +3156,7 @@ EX void addButterfly(cell *c) { butterflies.push_back(make_pair(c, 0)); } -// calculate cpdist, 'have' flags, and do general fixings +/** calculate cpdist, 'have' flags, and do general fixings */ EX void bfs() { calcTidalPhase(); @@ -3541,9 +3571,10 @@ EX void activateArrowTrap(cell *c) { } -// effect of moving monster m from cf to ct -// this is called from moveMonster, or separately from moveIvy/moveWorm, -// or when a dead bird falls (then m == moDeadBird) +/** effect of moving monster m from cf to ct + * this is called from moveMonster, or separately from moveIvy/moveWorm, + * or when a dead bird falls (then m == moDeadBird) + */ EX void moveEffect(cell *ct, cell *cf, eMonster m, int direction_hint) { @@ -4008,7 +4039,10 @@ EX int landheattype(cell *c) { return 1; } -// move value +/** for the monster at c1, evaluation of the move to c2 + * @param mf what moves are allowed + */ + EX int moveval(cell *c1, cell *c2, int d, flagtype mf) { if(!c2) return -5000; @@ -5539,12 +5573,11 @@ EX bool cellDangerous(cell *c) { return cellUnstableOrChasm(c) || isFire(c) || c->wall == waClosedGate; } -// negative: die, attack friend, stay against rose, hit a wall, move against rose, hit the player - EX bool hasPrincessWeapon(eMonster m) { return m == moPalace || m == moFatGuard; } +/** for an ally m at c, evaluate staying in place */ EX int stayvalue(eMonster m, cell *c) { if(!passable_for(c->monst, c, NULL, P_MONSTER | P_MIRROR)) return -1501; @@ -5554,7 +5587,7 @@ EX int stayvalue(eMonster m, cell *c) { return 100; } -// friendly version of moveval +/** for an ally m at c, evaluate moving to c2 */ EX int movevalue(eMonster m, cell *c, cell *c2, flagtype flags) { int val = 0; @@ -5758,9 +5791,10 @@ EX int nearestPathPlayer(cell *c) { return 0; } -// note: butterflies don't use moveNormal for two reasons: -// 1) to make sure that they move AFTER bulls -// 2) to make sure that they move offscreen +/** note: butterflies don't use moveNormal for two reasons: + * 1) to make sure that they move AFTER bulls + * 2) to make sure that they move offscreen + */ EX void moveButterflies() { int j = 0; for(int i=0; i 1e-3)) { - printf("ERROR\n"); - display(sol); - display(sol2); - exit(1); - } - } */ return gm * where; } diff --git a/goldberg.cpp b/goldberg.cpp index 038c57cd..8b5a782a 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -1,3 +1,12 @@ +// Hyperbolic Rogue -- Goldberg-Coxeter construction +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file goldberg.cpp + * \brief Goldberg-Coxeter construction + * + * This is generally not used for standard pure and bitruncated tilings, even though they are technically Goldberg too. + */ + namespace hr { EX namespace gp { diff --git a/graph.cpp b/graph.cpp index 8677dae1..7c7e05ac 100644 --- a/graph.cpp +++ b/graph.cpp @@ -1,8 +1,9 @@ // Hyperbolic Rogue -- main graphics file +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// basic graphics: +/** \file graph.cpp + * \brief Drawing cells, monsters, items, etc. + */ namespace hr { diff --git a/help.cpp b/help.cpp index 4cd49b27..4c42fbd0 100644 --- a/help.cpp +++ b/help.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- help routines // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file help.cpp + * \brief Building and displaying help text + */ + namespace hr { EX string help; diff --git a/heptagon.cpp b/heptagon.cpp index b82243fe..82ca7930 100644 --- a/heptagon.cpp +++ b/heptagon.cpp @@ -1,8 +1,11 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- Heptagon // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details -// heptagon here refers to underlying heptagonal tesselation -// (which you can see by changing the conditions in graph.cpp) +/** \file heptagon.cpp + * \brief implementation of Heptagons + * + * Start with locations.cpp + */ namespace hr { @@ -13,13 +16,12 @@ int heptacount = 0; struct cell; cell *newCell(int type, heptagon *master); -// spintable functions - -// the automaton is used to generate each heptagon in an unique way -// (you can see the tree obtained by changing the conditions in graph.cpp) -// from the origin we can go further in any direction, and from other heptagons -// we can go in directions 3 and 4 (0 is back to origin, so 3 and 4 go forward), -// and sometimes in direction 5 +/** the automaton is used to generate each heptagon in an unique way. + * See http://roguetemple.com/z/dev.php for more help. + * From the origin we can go further in any direction, and from other heptagons + * we can go in directions 3 and 4 (0 is back to origin, so 3 and 4 go forward), + * and sometimes in direction 5 + */ hstate transition(hstate s, int dir) { if(sphere) { @@ -210,11 +212,9 @@ void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) { extern int hrand(int); -// a structure used to walk on the heptagonal tesselation -// (remembers not only the heptagon, but also direction) - -hookset *hooks_createStep; +EX hookset *hooks_createStep; +// create h->move(d) if not created yet heptagon *createStep(heptagon *h, int d) { d = h->c.fix(d); if(h->move(d)) return h->move(d); @@ -282,7 +282,4 @@ void hsshow(const heptspin& t) { printf("ORIGIN"); backtrace(t.at); printf(" (spin %d)\n", t.spin); } -// create h->move(d) if not created yet -heptagon *createStep(heptagon *h, int d); - } diff --git a/hud.cpp b/hud.cpp index 755840ca..3127b5f0 100644 --- a/hud.cpp +++ b/hud.cpp @@ -1,5 +1,9 @@ -// Hyperbolic Rogue -- heads-up display -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- Heads-Up Display +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file hud.cpp + * \brief Heads-Up display: items collected, monsters killed, radar, etc. + */ namespace hr { diff --git a/hyper.cpp b/hyper.cpp index d403ad0d..68239ff9 100644 --- a/hyper.cpp +++ b/hyper.cpp @@ -1,5 +1,5 @@ // Hyperbolic Rogue -// Copyright (C) 2011-2018 Zeno Rogue +// Copyright (C) 2011-2019 Zeno Rogue // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -15,6 +15,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +/** \file hyper.cpp + * \brief the hyper_main function + */ + #include "init.cpp" #if CU_HYPER diff --git a/hyper.h b/hyper.h index efb98cb1..62354eeb 100644 --- a/hyper.h +++ b/hyper.h @@ -1,5 +1,13 @@ -// This is the main header file of HyperRogue. Mostly everything is dumped here. -// It is quite chaotic. +// Hyperbolic Rogue -- main header file +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file Hyper.h + * \brief The main header file of HyperRogue + * + * Contains general utility macros, various value macros, using clauses for standard library functions, + * implementation of the basic connection_table, walker, cell and heptagon classes, + * and general routines which did not fit elsewhere + */ // version numbers #define VER "11.1i" @@ -320,332 +328,8 @@ extern videopar vid; #define self (*this) -extern int cellcount, heptacount; -// cell information for the game - -struct gcell { - -#if CAP_BITFIELD - // main fields - eLand land : 8; - eWall wall : 8; - eMonster monst : 8; - eItem item : 8; - - // if this is a barrier, what lands on are on the sides? - eLand barleft : 8, barright : 8; - - unsigned ligon : 1; // is it sparkling with lightning? - - signed - mpdist : 7, - pathdist : 8, // player distance wrt usual movement - cpdist : 8; // current/minimum player distance - - unsigned - mondir : 8, // monster direction, for multi-tile monsters and graphics - bardir : 8, // barrier direction - stuntime : 8, // stun time left (for Palace Guards and Skeletons) - hitpoints : 7, // hitpoints left (for Palace Guards, also reused as cpid for mirrors) - monmirror : 1; // monster mirroring state for nonorientable geometries - - unsigned landflags : 8; // extra flags for land -#else - eLand land; - eWall wall; - eMonster monst; - eItem item; - eLand barleft, barright; - bool ligon, monmirror; - signed char pathdist, cpdist, mpdist; - - unsigned char mondir, bardir, stuntime, hitpoints; - unsigned char landflags; -#endif - - // 'landparam' is used for: - // heat in Icy/Cocytus; - // heat in Dry (0..10); - // CR2 structure; - // hive Weird Rock color / pheromones; - // Ocean/coast depth; - // Bomberbird Egg hatch time / mine marking; - // number of Ancient Jewelry; - // improved tracking in Trollheim - union { - int32_t landpar; - unsigned int landpar_color; - float heat; - char bytes[4]; - struct fieldinfo { - uint16_t fieldval; - unsigned rval : 4; - unsigned flowerdist : 4; - unsigned walldist : 4; - unsigned walldist2 : 4; - } fi; - - } LHU; - - #ifdef CELLID - int cellid; - #endif - - gcell() { cellcount++; - #ifdef CELLID - cellid = cellcount; - #endif - } - ~gcell() { cellcount--; } - }; - -#define landparam LHU.landpar -#define landparam_color LHU.landpar_color - -#define fval LHU.fi.fieldval - -#define NODIR 126 -#define NOBARRIERS 127 #define MODFIXER (2*10090080*17) -#define MAX_EDGE 18 - -template struct walker; - -template struct connection_table { - - // Assumption: class T has a field c of type connection_table. - - // NOTE: since aconnection_table may be allocated with - // less than MAX_EDGE neighbors (see tailored_alloc), - // the order of fields matters. - - T* move_table[MAX_EDGE + (MAX_EDGE + sizeof(char*) - 1) / sizeof(char*)]; - - unsigned char *spintable() { return (unsigned char*) (&move_table[full()->degree()]); } - - T* full() { T* x = (T*) this; return (T*)((char*)this - ((char*)(&(x->c)) - (char*)x)); } - void setspin(int d, int spin, bool mirror) { - unsigned char& c = spintable() [d]; - c = spin; - if(mirror) c |= 128; - } - // we are spin(i)-th neighbor of move[i] - int spin(int d) { return spintable() [d] & 127; } - bool mirror(int d) { return spintable() [d] & 128; } - int fix(int d) { return (d + MODFIXER) % full()->degree(); } - T*& modmove(int i) { return move(fix(i)); } - T*& move(int i) { return move_table[i]; } - unsigned char modspin(int i) { return spin(fix(i)); } - void fullclear() { - for(int i=0; idegree(); i++) move_table[i] = NULL; - } - void connect(int d0, T* c1, int d1, bool m) { - move(d0) = c1; - c1->move(d1) = full(); - setspin(d0, d1, m); - c1->c.setspin(d1, d0, m); - } - void connect(int d0, walker hs) { - connect(d0, hs.at, hs.spin, hs.mirrored); - } - }; - -// Allocate a class T with a connection_table, but -// with only `degree` connections. Also set yet -// unknown connections to NULL. - -// Generating the hyperbolic world consumes lots of -// RAM, so we really need to be careful on low memory devices. - -template T* tailored_alloc(int degree) { - const T* sample = (T*) °ree; - T* result; -#ifndef NO_TAILORED_ALLOC - int b = (char*)&sample->c.move_table[degree] + degree - (char*) sample; - result = (T*) new char[b]; - new (result) T(); -#else - result = new T; -#endif - result->type = degree; - for(int i=0; ic.move_table[i] = NULL; - return result; - } - -template void tailored_delete(T* x) { - x->~T(); - delete[] ((char*) (x)); - } - -static const struct wstep_t { wstep_t() {} } wstep; -static const struct wmirror_t { wmirror_t() {}} wmirror; -static const struct rev_t { rev_t() {} } rev; -static const struct revstep_t { revstep_t() {}} revstep; - -// unused for heptagons -inline vector reverse_directions(struct heptagon *c, int i) { return {i}; } - -int hrand(int); - -template struct walker { - T *at; - int spin; - bool mirrored; - walker (T *at = NULL, int s = 0, bool m = false) : at(at), spin(s), mirrored(m) { if(at) s = at->c.fix(s); } - walker& operator += (int i) { - spin = at->c.fix(spin+(mirrored?-i:i)); - return (*this); - } - walker& operator -= (int i) { - spin = at->c.fix(spin-(mirrored?-i:i)); - return (*this); - } - walker& operator += (wmirror_t) { - mirrored = !mirrored; - return (*this); - } - walker& operator += (wstep_t) { - at->cmove(spin); - int nspin = at->c.spin(spin); - if(at->c.mirror(spin)) mirrored = !mirrored; - at = at->move(spin); - spin = nspin; - return (*this); - } - walker& operator += (rev_t) { - auto rd = reverse_directions(at, spin); - if(rd.size() == 1) spin = rd[0]; - else spin = rd[hrand(rd.size())]; - return (*this); - } - walker& operator += (revstep_t) { - (*this) += rev; return (*this) += wstep; - } - bool operator != (const walker& x) const { - return at != x.at || spin != x.spin || mirrored != x.mirrored; - } - bool operator == (const walker& x) const { - return at == x.at && spin == x.spin && mirrored == x.mirrored; - } - - bool operator < (const walker& cw2) const { - return tie(at, spin, mirrored) < tie(cw2.at, cw2.spin, cw2.mirrored); - } - - walker& operator ++ (int) { return (*this) += 1; } - walker& operator -- (int) { return (*this) -= 1; } - template walker operator + (U t) const { walker w = *this; w += t; return w; } - template walker operator - (U t) const { walker w = *this; w += (-t); return w; } - T*& peek() { return at->move(spin); } - T* cpeek() { return at->cmove(spin); } - bool creates() { return !peek(); } - walker mirrorat(int d) { return walker (at, at->c.fix(d+d - spin), !mirrored); } - }; - -struct cell; - -// automaton state -enum hstate { hsOrigin, hsA, hsB, hsError, hsA0, hsA1, hsB0, hsB1, hsC }; - -struct cell *createMov(struct cell *c, int d); -struct heptagon *createStep(struct heptagon *c, int d); - -struct cdata { - int val[4]; - int bits; - }; - -// in bitruncated/irregular/Goldberg geometries, heptagons form the -// underlying regular tiling (not necessarily heptagonal); in pure -// geometries, they correspond 1-1 to tiles; in 'masterless' geometries -// heptagons are unused - -struct heptagon { - // automaton state - hstate s : 6; - unsigned int dm4: 2; - // distance from the origin - short distance; - // note: all the 'val' values may have different meaning in other geometries - // emerald/wineyard generator - short emeraldval; - // fifty generator - short fiftyval; - // zebra generator (1B actually) - short zebraval; - // field id - int fieldval : 24; - // degree - unsigned char type : 8; - // data for fractal landscapes - short rval0, rval1; - // for alternate structures, cdata contains the pointer to the original - // for the main map, it contains the fractal landscape data - struct cdata *cdata; - // central cell of this underlying tiling - cell *c7; - // associated generator of alternate structure, for Camelot and horocycles - heptagon *alt; - // connection table - connection_table c; - heptagon*& move(int d) { return c.move(d); } - heptagon*& modmove(int d) { return c.modmove(d); } - // functions - heptagon () { heptacount++; } - ~heptagon () { heptacount--; } - heptagon *cmove(int d) { return createStep(this, d); } - heptagon *cmodmove(int d) { return createStep(this, c.fix(d)); } - inline int degree() { return type; } - - // prevent accidental copying - heptagon(const heptagon&) = delete; - heptagon& operator=(const heptagon&) = delete; - // do not add any fields after connection_table (see tailored_alloc) - }; - -struct cell : gcell { - char type; int degree() { return type; } - - // wall parameter, used for remaining power of Bonfires and Thumpers - char wparam; - - // used by celllister - int listindex; - - // heptagon who owns us; for 'masterless' tilings it contains coordinates instead - heptagon *master; - - connection_table c; - cell*& move(int d) { return c.move(d); } - cell*& modmove(int d) { return c.modmove(d); } - cell* cmove(int d) { return createMov(this, d); } - cell* cmodmove(int d) { return createMov(this, c.fix(d)); } - cell() {} - - // prevent accidental copying - cell(const cell&) = delete; - heptagon& operator=(const cell&) = delete; - // do not add any fields after connection_table (see tailored_alloc) - }; - -/* -namespace arcm { int degree(heptagon *h); int valence(); } - -int heptagon::degree() { - #if CAP_ARCM - if(archimedean) return arcm::degree(this); else - #endif - return S7; - } */ - -typedef walker heptspin; -typedef walker cellwalker; - -static const struct cth_t { cth_t() {}} cth; -inline heptspin operator+ (cellwalker cw, cth_t) { return heptspin(cw.at->master, cw.spin * DUALMUL, cw.mirrored); } -inline cellwalker operator+ (heptspin hs, cth_t) { return cellwalker(hs.at->c7, hs.spin / DUALMUL, hs.mirrored); } - #define BUGCOLORS 3 #define big_unlock (inv::on && !chaosmode) @@ -689,7 +373,7 @@ struct movedir { #define MD_UNDECIDED (-3) #define MD_USE_ORB (-4) int subdir; // for normal movement (0+): turn left or right - cell *tgt; // for MD_USE_ORB: target cell + struct cell *tgt; // for MD_USE_ORB: target cell }; // shmup @@ -704,7 +388,7 @@ typedef function bool_reaction_t; #define HELPFUN(x) (help_delegate = x, "HELPFUN") -typedef function cellfunction; +typedef function cellfunction; // passable flags @@ -968,10 +652,6 @@ namespace scores { void load(); } namespace leader { void showMenu(); void handleKey(int sym, int uni); } #endif -namespace mirror { - cellwalker reflect(const cellwalker& cw); - } - struct hint { time_t last; function usable; @@ -1026,56 +706,6 @@ const eLand NOWALLSEP_USED = laWhirlpool; extern vector dcal; -// list all cells in distance at most maxdist, or until when maxcount cells are reached - -struct manual_celllister { - vector lst; - vector tmps; - - bool listed(cell *c) { - return c->listindex >= 0 && c->listindex < isize(lst) && lst[c->listindex] == c; - } - - bool add(cell *c) { - if(listed(c)) return false; - tmps.push_back(c->listindex); - c->listindex = isize(lst); - lst.push_back(c); - return true; - } - - ~manual_celllister() { - for(int i=0; ilistindex = tmps[i]; - } - }; - - -struct celllister : manual_celllister { - vector dists; - - void add_at(cell *c, int d) { - if(add(c)) dists.push_back(d); - } - - celllister(cell *orig, int maxdist, int maxcount, cell *breakon) { - add_at(orig, 0); - cell *last = orig; - for(int i=0; i= maxcount || dists[i]+1 == maxdist) break; - last = lst[isize(lst)-1]; - } - } - } - - int getdist(cell *c) { return dists[c->listindex]; } - }; - // z to close to this limit => do not draw #define BEHIND_LIMIT 1e-6 diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 106a9826..ac77b553 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -1,6 +1,13 @@ -// Hyperbolic Rogue -// This file contains hyperbolic points and matrices. -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- basic computations in non-Euclidean geometry +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file hyperpoint.cpp + * \brief basic computations in non-Euclidean geometry + * + * This implements hyperpoint (a point in non-Euclidean space), transmatrix (a transformation matrix), + * and various basic routines related to them: rotations, translations, inverses and determinants, etc. + * For nonisotropic geometries, it rather refers to nonisotropic.cpp. + */ namespace hr { diff --git a/hypgraph.cpp b/hypgraph.cpp index 0e19e355..672d956b 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1,5 +1,9 @@ // Hyperbolic Rogue -- hyperbolic graphics -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file hypgraph.cpp + * \brief mapping hyperpoints to the screen, and related functions + */ namespace hr { diff --git a/init.cpp b/init.cpp index 95eebc12..0097c4e9 100644 --- a/init.cpp +++ b/init.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- initialization, and stuff related to mobiles // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file init.cpp + * \brief initialization, and stuff related to mobiles + */ + #include "compileunits.h" namespace hr { diff --git a/inventory.cpp b/inventory.cpp index fcdf171f..44d6e59d 100644 --- a/inventory.cpp +++ b/inventory.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- Orb Strategy Mode // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file inventory.cpp + * \brief Orb Strategy Mode + */ + namespace hr { EX namespace inv { diff --git a/irregular.cpp b/irregular.cpp index 852ac966..1670d7c0 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -1,3 +1,10 @@ +// Hyperbolic Rogue -- Irregular (Voronoi) tilings +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file irregular.cpp + * \brief Irregular (Voronoi) tilings + */ + namespace hr { EX namespace irr { diff --git a/landgen.cpp b/landgen.cpp index 9d9f4c91..64fec5c6 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -1,6 +1,11 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- land generation +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file landgen.cpp + * \brief generating various lands + * + * See also bigstuff.cpp (for larger structures) and complex.cpp (for more complex land generation) + */ namespace hr { diff --git a/landlock.cpp b/landlock.cpp index 20a4c1c0..58c5b147 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -1,7 +1,9 @@ -// Hyperbolic Rogue -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- land availability +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// land statistics and flags +/** \file landlock.cpp + * \brief unlocking lands, which lands could be found beyond the wall, validity of various lands depending on the settings + */ namespace hr { @@ -14,7 +16,7 @@ EX bool nodisplay(eMonster m) { m == moIvyDead; } -// returns: 2 = treasure increaser, 1 = just appears, 0 = does not appear +/** returns: 2 = treasure increaser, 1 = just appears, 0 = does not appear */ EX int isNative(eLand l, eMonster m) { switch(l) { #define LAND(a,b,c,d,e,f,g) case c: diff --git a/language.cpp b/language.cpp index 338593f7..151300e4 100644 --- a/language.cpp +++ b/language.cpp @@ -1,5 +1,9 @@ -// Hyperbolic Rogue language support -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- language support +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file language.cpp + * \brief localization support + */ // #define CHECKTRANS @@ -24,28 +28,6 @@ struct stringpar { }; #endif -/* -string dnameofEnum(eItem i) { - FILE *f = fopen("classes.cpp", "rt"); - while(!feof(f)) { - char buf[256]; - fgets(buf, 256, f); - if(strstr(buf, "eItem")) { - string ret; - int qty = i; - while(qty > -1) { - char c = fgetc(f); - if(c == ' ' || c == '\n' || c == '\r') continue; - else if(c == ',') qty--; - else if(!qty) ret += c; - } - return ret; - } - } - return "?"; - } -*/ - void rep(string& pattern, string what, string to) { while(true) { size_t at = pattern.find(what); @@ -332,6 +314,7 @@ void parrep(string& x, string w, stringpar p) { void postrep(string& s) { } +/** translate the string @x */ EX string XLAT(string x) { basicrep(x); postrep(x); diff --git a/legacy.cpp b/legacy.cpp index 5bfbd138..4b8c29fb 100644 --- a/legacy.cpp +++ b/legacy.cpp @@ -1,5 +1,5 @@ -// old config file format (disabled by default) -// Copyright (C) 2017-2019 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- old config file format (disabled by default) +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details #if CAP_LEGACY namespace hr { diff --git a/locations.cpp b/locations.cpp new file mode 100644 index 00000000..f4d29442 --- /dev/null +++ b/locations.cpp @@ -0,0 +1,441 @@ +// Hyperbolic Rogue -- Locations +// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details + +/** \file locations.cpp + * \brief definition of connection tables, walkers, cell and heptagon structures + * + * The standard geometry uses 'heptagons' for the underlying heptagonal tessellation, + * and 'cells' for the tessellation that the game is actually played on. + * Other geometries also use the class 'heptagon' even if they are not heptagon-based; + * there may be one 'heptagon' per each cell. Heptagons are not used in masterless + * geometries, though. This file implements the basic types and functions for navigating both graphs. + */ + +namespace hr { + +#if HDR + +extern int cellcount, heptacount; + +#define NODIR 126 +#define NOBARRIERS 127 + +/** Cell information for the game. struct cell builds on this */ +struct gcell { + +#if CAP_BITFIELD + /** which land does this cell belong to */ + eLand land : 8; + /** wall type (waNone for no walls) */ + eWall wall : 8; + /** monster on this cell -- note that player characters are handled separately */ + eMonster monst : 8; + /** item on this cell */ + eItem item : 8; + + /** if this is a barrier, what lands on are on the sides? */ + eLand barleft : 8, barright : 8; + + /** is it currently sparkling with lightning? */ + unsigned ligon : 1; + + signed + mpdist : 7, ///< minimum player distance, the smaller value, the more generated it is */ + pathdist : 8, ///< distance from the target -- actual meaning may change + cpdist : 8; ///< current distance to the player + + unsigned + mondir : 8, ///< which direction the monster is facing (if relevant), also used for boats + bardir : 8, ///< may equal NODIR (no barrier here), NOBARRIERS (barriers not allowed here), or the barrier direction + stuntime : 8, ///< for stunned monsters, stun time left; also used for Mutant Ivy timing + hitpoints : 7, ///< hitpoints left, for Palace monsters, Dragons, Krakens etc. Also reused as cpid for mirrors + monmirror : 1; ///< monster mirroring state for nonorientable geometries + + unsigned landflags : 8; ///< some lands need additional flags +#else + eLand land; + eWall wall; + eMonster monst; + eItem item; + eLand barleft, barright; + bool ligon, monmirror; + signed char pathdist, cpdist, mpdist; + + unsigned char mondir, bardir, stuntime, hitpoints; + unsigned char landflags; +#endif + + /** 'landparam' is used for: + * heat in Icy/Cocytus; + * heat in Dry (0..10); + * CR2 structure; + * hive Weird Rock color / pheromones; + * Ocean/coast depth; + * Bomberbird Egg hatch time / mine marking; + * number of Ancient Jewelry; + * improved tracking in Trollheim + */ + union { + int32_t landpar; + unsigned int landpar_color; + float heat; + char bytes[4]; + struct fieldinfo { + uint16_t fieldval; + unsigned rval : 4; + unsigned flowerdist : 4; + unsigned walldist : 4; + unsigned walldist2 : 4; + } fi; + + } LHU; + + /** wall parameter, used e.g. for remaining power of Bonfires and Thumpers */ + char wparam; + + #ifdef CELLID + int cellid; + #endif + + gcell() { cellcount++; + #ifdef CELLID + cellid = cellcount; + #endif + } + ~gcell() { cellcount--; } + }; + +#define landparam LHU.landpar +#define landparam_color LHU.landpar_color +#define fval LHU.fi.fieldval + +#define MAX_EDGE 18 + +template struct walker; + +/** Connection tables are used by heptagon and cell structures. They basically + * describe the structure of the graph on the given manifold. We assume that + * the class T has a field c of type connection_table, + * as its last field. Edges are listed in the clockwise order (for 2D tilings, + * for 3D tilings the order is more arbitrary). For each edge we remember which other T + * we are connected to, as well as the index of this edge in the other T, and whether it is + * mirrored (for graphs on non-orientable manifolds). + * To conserve memory, these classes need to be allocated with tailored_alloc + * and freed with tailored_free. + */ + +template struct connection_table { + + /** Table of moves. This is the maximum size, but tailored_alloc allocates less. */ + T* move_table[MAX_EDGE + (MAX_EDGE + sizeof(char*) - 1) / sizeof(char*)]; + + unsigned char *spintable() { return (unsigned char*) (&move_table[full()->degree()]); } + + /** get the full T from the pointer to this connection table */ + T* full() { T* x = (T*) this; return (T*)((char*)this - ((char*)(&(x->c)) - (char*)x)); } + /** for the edge d, set the `spin` and `mirror` attributes */ + void setspin(int d, int spin, bool mirror) { + unsigned char& c = spintable() [d]; + c = spin; + if(mirror) c |= 128; + } + /** we are spin(i)-th neighbor of move[i] */ + int spin(int d) { return spintable() [d] & 127; } + /** on non-orientable surfaces, the d-th edge may be mirrored */ + bool mirror(int d) { return spintable() [d] & 128; } + /** 'fix' the edge number d to get the actual index in [0, degree()) */ + int fix(int d) { return (d + MODFIXER) % full()->degree(); } + /** T in the direction i */ + T*& move(int i) { return move_table[i]; } + /** T in the direction i, modulo degree() */ + T*& modmove(int i) { return move(fix(i)); } + unsigned char modspin(int i) { return spin(fix(i)); } + /** initialize the table */ + void fullclear() { + for(int i=0; idegree(); i++) move_table[i] = NULL; + } + /** connect this in direction d0 to c1 in direction d1, possibly mirrored */ + void connect(int d0, T* c1, int d1, bool m) { + move(d0) = c1; + c1->move(d1) = full(); + setspin(d0, d1, m); + c1->c.setspin(d1, d0, m); + } + /* like the other connect, but take the parameters of the other cell from a walker */ + void connect(int d0, walker hs) { + connect(d0, hs.at, hs.spin, hs.mirrored); + } + }; + +/** Allocate a class T with a connection_table, but + * with only `degree` connections. Also set yet + * unknown connections to NULL. + + * Generating the hyperbolic world consumes lots of + * RAM, so we really need to be careful on low memory devices. + */ + +template T* tailored_alloc(int degree) { + const T* sample = (T*) °ree; + T* result; +#ifndef NO_TAILORED_ALLOC + int b = (char*)&sample->c.move_table[degree] + degree - (char*) sample; + result = (T*) new char[b]; + new (result) T(); +#else + result = new T; +#endif + result->type = degree; + for(int i=0; ic.move_table[i] = NULL; + return result; + } + +/** Counterpart to @see tailored_alloc. */ +template void tailored_delete(T* x) { + x->~T(); + delete[] ((char*) (x)); + } + +static const struct wstep_t { wstep_t() {} } wstep; +static const struct wmirror_t { wmirror_t() {}} wmirror; +static const struct rev_t { rev_t() {} } rev; +static const struct revstep_t { revstep_t() {}} revstep; + +extern int hrand(int); + +/** reverse directions are currently not implemented for heptagons */ +inline vector reverse_directions(struct heptagon *c, int i) { throw "unimplemented"; } + +/** the walker structure is used for walking on surfaces defined via @see connection_table. @connection_table */ +template struct walker { + /** where we are at */ + T *at; + /** in which direction (edge) we are facing */ + int spin; + /** are we mirrored */ + bool mirrored; + walker (T *at = NULL, int s = 0, bool m = false) : at(at), spin(s), mirrored(m) { if(at) s = at->c.fix(s); } + /** spin by i to the left (or right, when mirrored */ + walker& operator += (int i) { + spin = at->c.fix(spin+(mirrored?-i:i)); + return (*this); + } + /** spin by i to the right (or left, when mirrored */ + walker& operator -= (int i) { + spin = at->c.fix(spin-(mirrored?-i:i)); + return (*this); + } + /** add wmirror to mirror this walker */ + walker& operator += (wmirror_t) { + mirrored = !mirrored; + return (*this); + } + /** add wstep to make a single step, after which we are facing the T we were originally on */ + walker& operator += (wstep_t) { + at->cmove(spin); + int nspin = at->c.spin(spin); + if(at->c.mirror(spin)) mirrored = !mirrored; + at = at->move(spin); + spin = nspin; + return (*this); + } + /** add wrev to face the other direction, may be non-deterministic and use hrand */ + walker& operator += (rev_t) { + auto rd = reverse_directions(at, spin); + if(rd.size() == 1) spin = rd[0]; + else spin = rd[hrand(rd.size())]; + return (*this); + } + /** adding revstep is equivalent to adding rev and step */ + walker& operator += (revstep_t) { + (*this) += rev; return (*this) += wstep; + } + bool operator != (const walker& x) const { + return at != x.at || spin != x.spin || mirrored != x.mirrored; + } + bool operator == (const walker& x) const { + return at == x.at && spin == x.spin && mirrored == x.mirrored; + } + + bool operator < (const walker& cw2) const { + return tie(at, spin, mirrored) < tie(cw2.at, cw2.spin, cw2.mirrored); + } + + walker& operator ++ (int) { return (*this) += 1; } + walker& operator -- (int) { return (*this) -= 1; } + template walker operator + (U t) const { walker w = *this; w += t; return w; } + template walker operator - (U t) const { walker w = *this; w += (-t); return w; } + /** what T are we facing, without creating it */ + T*& peek() { return at->move(spin); } + /** what T are we facing, with creating it */ + T* cpeek() { return at->cmove(spin); } + /** would we create a new T if we stepped forwards? */ + bool creates() { return !peek(); } + /** mirror this walker with respect to the d-th edge */ + walker mirrorat(int d) { return walker (at, at->c.fix(d+d - spin), !mirrored); } + }; + +struct cell; + +// automaton state +enum hstate { hsOrigin, hsA, hsB, hsError, hsA0, hsA1, hsB0, hsB1, hsC }; + +struct cell *createMov(struct cell *c, int d); +struct heptagon *createStep(struct heptagon *c, int d); + +struct cdata { + int val[4]; + int bits; + }; + +/** in bitruncated/irregular/Goldberg geometries, heptagons form the + * underlying regular tiling (not necessarily heptagonal); in pure + * geometries, they correspond 1-1 to tiles; in 'masterless' geometries + * heptagons are unused + */ + +struct heptagon { + /** Automata are used to generate the standard maps. s is the state of this automaton */ + hstate s : 6; + /** distance modulo 4, in heptagons */ + unsigned int dm4: 2; + /** distance from the origin; based on the final geometry of cells, not heptagons themselves */ + short distance; + /** Wmerald/wineyard generator. May have different meaning in other geometries. */ + short emeraldval; + /** Palace pattern generator. May have different meaning in other geometries. */ + short fiftyval; + /** Zebra pattern generator. May have different meaning in other geometries. */ + short zebraval; + /** Field quotient pattern ID. May have different meaning in other geometries. */ + int fieldval : 24; + /** the number of adjacent heptagons */ + unsigned char type : 8; + /** data for fractal landscapes */ + short rval0, rval1; + /** for the main map, it contains the fractal landscape data + * + * For alternate structures, cdata contains the pointer to the original. + */ + struct cdata *cdata; + /** which central cell does this heptagon correspond too + * + * For alternate geometries, c7 is NULL + */ + cell *c7; + /** associated generator of alternate structure, for Camelot and horocycles */ + heptagon *alt; + /** connection table */ + connection_table c; + // DO NOT add any fields after connection_table! (see tailored_alloc) + heptagon*& move(int d) { return c.move(d); } + heptagon*& modmove(int d) { return c.modmove(d); } + // functions + heptagon () { heptacount++; } + ~heptagon () { heptacount--; } + heptagon *cmove(int d) { return createStep(this, d); } + heptagon *cmodmove(int d) { return createStep(this, c.fix(d)); } + inline int degree() { return type; } + + // prevent accidental copying + heptagon(const heptagon&) = delete; + heptagon& operator=(const heptagon&) = delete; + }; + +struct cell : gcell { + char type; ///< our degree + int degree() { return type; } + + int listindex; ///< used by celllister + heptagon *master; ///< heptagon who owns us; for 'masterless' tilings it contains coordinates instead + + connection_table c; + // DO NOT add any fields after connection_table! (see tailored_alloc) + + cell*& move(int d) { return c.move(d); } + cell*& modmove(int d) { return c.modmove(d); } + cell* cmove(int d) { return createMov(this, d); } + cell* cmodmove(int d) { return createMov(this, c.fix(d)); } + cell() {} + + // prevent accidental copying + cell(const cell&) = delete; + heptagon& operator=(const cell&) = delete; + }; + +/** abbreviations */ +typedef walker heptspin; +typedef walker cellwalker; + +/** A structure useful when walking on the cell graph in arbitrary way, + * or listing cells in general. + * Only one celllister may be active at a time, using the stack semantics. + * Only the most recently created one works; the previous one will resume + * working when this one is destroyed. + */ +struct manual_celllister { + /** list of cells in this list */ + vector lst; + vector tmps; + + /** is the given cell on the list? */ + bool listed(cell *c) { + return c->listindex >= 0 && c->listindex < isize(lst) && lst[c->listindex] == c; + } + + /** add a cell to the list */ + bool add(cell *c) { + if(listed(c)) return false; + tmps.push_back(c->listindex); + c->listindex = isize(lst); + lst.push_back(c); + return true; + } + + ~manual_celllister() { + for(int i=0; ilistindex = tmps[i]; + } + }; + +/** automatically generate a list of nearby cells */ +struct celllister : manual_celllister { + vector dists; + + void add_at(cell *c, int d) { + if(add(c)) dists.push_back(d); + } + + /** automatically generate a list of nearby cells + @param orig where to start + @param maxdist maximum distance to cover + @param maxcount maximum number of cells to cover + @param breakon we are actually looking for this cell, so stop when reaching it + */ + celllister(cell *orig, int maxdist, int maxcount, cell *breakon) { + add_at(orig, 0); + cell *last = orig; + for(int i=0; i= maxcount || dists[i]+1 == maxdist) break; + last = lst[isize(lst)-1]; + } + } + } + + /** for a given cell c on the list, return its distance from orig */ + int getdist(cell *c) { return dists[c->listindex]; } + }; + +/** translate heptspins to cellwalkers and vice versa */ +static const struct cth_t { cth_t() {}} cth; +inline heptspin operator+ (cellwalker cw, cth_t) { return heptspin(cw.at->master, cw.spin * DUALMUL, cw.mirrored); } +inline cellwalker operator+ (heptspin hs, cth_t) { return cellwalker(hs.at->c7, hs.spin / DUALMUL, hs.mirrored); } + +#endif + +} diff --git a/makeh.cpp b/makeh.cpp index b42520bc..371b4bf7 100644 --- a/makeh.cpp +++ b/makeh.cpp @@ -1,3 +1,4 @@ +// generate autohdr.h based on the `EX` and `#if HDR` in *.cpp files #include #include #include diff --git a/mapeditor.cpp b/mapeditor.cpp index 90d06dca..407ee8f6 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -1,5 +1,9 @@ -// HyperRogue map editor -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- map editor and vector graphics editor +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file mapedit.cpp + * \brief HyperRogue editors (map and vector graphics) + */ namespace hr { diff --git a/menus.cpp b/menus.cpp index 08b366b6..cb445847 100644 --- a/menus.cpp +++ b/menus.cpp @@ -1,5 +1,9 @@ -// HyperRogue menus -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- menus +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file menus.cpp + * \brief generic menus (start menu, main menu, Overview, etc.) + */ // -- overview -- diff --git a/models.cpp b/models.cpp index 34b608f9..6e11a54f 100644 --- a/models.cpp +++ b/models.cpp @@ -1,3 +1,13 @@ +// Hyperbolic Rogue -- models of hyperbolic geometry +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file models.cpp + * \brief models of hyperbolic geometry: their properties, projection menu + * + * The actual models are implemented in hypgraph.cpp. Also shaders.cpp, + * drawing.cpp, and basegraph.cpp are important. + */ + namespace hr { EX namespace polygonal { diff --git a/monstergen.cpp b/monstergen.cpp index a8830a97..88a73c4b 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -1,8 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- monster generation +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// Routines concentrating on monster generation. +/** \file monstergen.cpp + * \brief monster generation + */ namespace hr { @@ -40,8 +41,7 @@ EX int buildIvy(cell *c, int children, int minleaf) { else return leaf; } -// the 'chasmify' functions create a simulation of the path the monster came by - +/** the 'chasmify' functions create a simulation of the path the monster came by */ EX void chasmify(cell *c) { c->wall = waChasm; c->item = itNone; int q = 0; @@ -104,7 +104,7 @@ EX void chasmifyElemental(cell *c) { c->wparam = 100; c->item = itNone; } -// an appropriate monster for the Crossroads +/** generate a monster appropriate for the Crossroads */ EX eMonster crossroadsMonster() { @@ -305,6 +305,7 @@ EX eItem wanderingTreasure(cell *c) { return treasureType(l); } +/** generate the wandering monsters */ EX void wandering() { if(bounded && specialland == laMinefield) { kills[moBomberbird] = 0; diff --git a/multi.cpp b/multi.cpp index cda3d2e5..49489895 100644 --- a/multi.cpp +++ b/multi.cpp @@ -1,8 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- multiplayer features +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// implementation of the multiplayer features +/** \file multi.cpp + * \brief multiplayer features, also input configuration + */ namespace hr { diff --git a/multigame.cpp b/multigame.cpp index 3ada3824..063f3727 100644 --- a/multigame.cpp +++ b/multigame.cpp @@ -1,20 +1,21 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- multi-game features +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// gamedata structure, for recording the game data in memory temporarily -// namespace dual (dual mode) +/** \file multi.cpp + * \brief running several games at once -- used in the Tutorial and Dual Geometry mode + */ namespace hr { #if HDR +/** gamedata structure, for recording the game data in memory temporarily */ struct gamedata { - // important parameters should be visible + /** important parameters should be visible */ eGeometry geo; eVariation var; eLand specland; bool active; - // other properties are recorded + /** other properties are recorded here */ vector record; int index, mode; void storegame(); @@ -103,7 +104,7 @@ EX namespace gamestack { EX } EX namespace dual { - // 0 = dualmode off, 1 = in dualmode (no game chosen), 2 = in dualmode (working on one of subgames) + /** 0 = dualmode off, 1 = in dualmode (no game chosen), 2 = in dualmode (working on one of subgames) */ EX int state; EX int currently_loaded; diff --git a/netgen.cpp b/netgen.cpp index 9497027b..bd299560 100644 --- a/netgen.cpp +++ b/netgen.cpp @@ -1,5 +1,9 @@ -// HyperRogue paper model generator -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Hyperbolic Rogue -- paper model generator +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file netgen.cpp + * \brief paper model generator + */ #if CAP_MODEL namespace hr { namespace netgen { diff --git a/nofont.cpp b/nofont.cpp index 2c52385d..965e4b8f 100644 --- a/nofont.cpp +++ b/nofont.cpp @@ -1,11 +1,15 @@ // Hyperbolic Rogue -- built-in font -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file nofont.cpp + * \brief built-in font (used e.g. in the web version) + */ namespace hr { #if CAP_TABFONT -// compile with -DCAP_CREATEFONT=1 to generate this table -// this variant has been created for non-translated HyperRogue +/** compile with -DCAP_CREATEFONT=1 to generate this table + * this variant has been created for non-translated HyperRogue */ unsigned char fonttable[] = { 43,13,0,255,0,255,0,49, 43,16,0,133,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,243,255,5,95,0,9,223,255,5,74,0,9,191,255,5,42,0,9,159,255,5,11,0,9,128,255,4,235,0,10,96,255,4,203,0,10,64,255,4,171,0,10,32,255,4,139,0,58,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,148, diff --git a/nonisotropic.cpp b/nonisotropic.cpp index cb989a53..a381f949 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -1,8 +1,10 @@ - -// implementation of the Solv space - +// Hyperbolic Rogue -- nonisotropic spaces (Solv and Nil) // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file nonisotropic.cpp + * \brief nonisotropic spaces (Solv and Nil) + */ + namespace hr { EX namespace nisot { diff --git a/orbgen.cpp b/orbgen.cpp index 34c5bd34..83fcdf8d 100644 --- a/orbgen.cpp +++ b/orbgen.cpp @@ -1,5 +1,9 @@ // Hyperbolic Rogue -- orb generation routines -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file orbgen.cpp + * \brief Orb generation: which orbs in which lands, functions generating prize/local orbs, etc. + */ namespace hr { // orbgen flags diff --git a/orbs.cpp b/orbs.cpp index c4020368..44e06448 100644 --- a/orbs.cpp +++ b/orbs.cpp @@ -1,8 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- orbs +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// Orb-related routines +/** \file orbs.cpp + * \brief Implementation of various Orb effects, and their properties such as default and maximum charges + */ namespace hr { diff --git a/pattern2.cpp b/pattern2.cpp index 51dea561..71aa5660 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1,6 +1,12 @@ -// HyperRogue patterns: compute codes for actual cells +// Hyperbolic Rogue -- patterns +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file pattern2.cpp + * \brief various functions computing the standings of individual cells with respect to various patterns + * + * Patterns include simple ones (hexagon or heptagon, three-colorings, Chessboard) + * as well as more complex ones (Emerald, Palace, Field Pattern) + */ namespace hr { diff --git a/patterns.cpp b/patterns.cpp index 4fb3646f..a6e73965 100644 --- a/patterns.cpp +++ b/patterns.cpp @@ -1,6 +1,9 @@ -// HyperRogue patterns: tables to give codes to heptagons +// Hyperbolic Rogue -- pattern tables +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file patterns.cpp + * \brief tables that the complex patterns (Emerald, Palace, Field Pattern) are based on + */ namespace hr { diff --git a/penrose.cpp b/penrose.cpp index ba13a440..25e5303e 100644 --- a/penrose.cpp +++ b/penrose.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- Kite-and-dart tiling // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file penrose.cpp + * \brief Kite-and-dart tiling, both in R^2 and H^3 + */ + namespace hr { EX namespace kite { diff --git a/polygons.cpp b/polygons.cpp index 5bbcad35..5b5b73c5 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -1,8 +1,10 @@ - -// HyperRogue, shapes used for the vector graphics - +// Hyperbolic Rogue -- shapes used for the vector graphics // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file polygons.cpp + * \brief shapes used for the vector graphics, mostly hand-drawn (the vector data is here), some procedurally generated + */ + #if CAP_SHAPES namespace hr { diff --git a/quit.cpp b/quit.cpp index 83042897..b5b61c46 100644 --- a/quit.cpp +++ b/quit.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- the mission screen // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file quit.cpp + * \brief the mission screen, and routines related to it + */ + namespace hr { EX bool quitsaves() { return (items[itOrbSafety] && CAP_SAVE && !archimedean); } diff --git a/quotient.cpp b/quotient.cpp index e0c65436..b4f83324 100644 --- a/quotient.cpp +++ b/quotient.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- quotient spaces // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file quotient.cpp + * \brief quotient spaces + */ + namespace hr { // --- quotient geometry --- diff --git a/racing.cpp b/racing.cpp index 4715fb31..2cc40aa7 100644 --- a/racing.cpp +++ b/racing.cpp @@ -1,9 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue - Racing +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// namespaces for complex features (whirlwind, whirlpool, elec, princess, clearing, -// mirror, hive, heat + livecaves, etc.) - -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file racing.cpp + * \brief racing mode + */ namespace hr { diff --git a/reg3.cpp b/reg3.cpp index 41533c06..8b49e876 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -1,8 +1,14 @@ // Hyperbolic Rogue -- regular honeycombs -// works with spherical and hyperbolic ones -- Euclidean cubic tiling implemented in euclid.cpp -// hyperbolic honeycombs rely on binary:: to deal with floating point errors (just like archimedean) // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file reg3.cpp + * \brief regular honeycombs + * + * works with spherical and hyperbolic ones -- Euclidean cubic tiling implemented in euclid.cpp + * includes non-quotient spaces as well as field quotient and elliptic spaces + * hyperbolic honeycombs rely on binary:: to deal with floating point errors (just like archimedean) + */ + namespace hr { #if MAXMDIM >= 4 transmatrix cpush(int cid, ld alpha); diff --git a/renderbuffer.cpp b/renderbuffer.cpp index 3feec70e..a8c36a4b 100644 --- a/renderbuffer.cpp +++ b/renderbuffer.cpp @@ -1,9 +1,13 @@ -// Hyperbolic Rogue -// This file implements the 'renderbuffer', which is an object -// that can be used to draw a HyperRogue screen into, -// and then either used as a OpenGL texture, or saved. +// Hyperbolic Rogue -- drawing screens to buffers +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file renderbuffer.cpp + * \brief drawing screens to buffers + * + * This file implements the 'renderbuffer', which is an object + * that can be used to draw a HyperRogue screen into, + * and then either used as a OpenGL texture (e.g. in the Hypersian Rug mode), or saved. + */ namespace hr { diff --git a/rug.cpp b/rug.cpp index 8afe5e60..50544afc 100644 --- a/rug.cpp +++ b/rug.cpp @@ -1,7 +1,11 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue - Hypersian Rug mode // Copyright (C) 2011-2016 Zeno Rogue, see 'hyper.cpp' for details -// implementation of the Hypersian Rug mode +/** \file rug.cpp + * \brief Hypersian Rug mode + * + * See also surface.cpp for constant curvature surfaces. + */ namespace hr { diff --git a/savemem.cpp b/savemem.cpp index 8cba75f2..1111c547 100644 --- a/savemem.cpp +++ b/savemem.cpp @@ -1,6 +1,11 @@ -// Hyperbolic Rogue -- smart memory cleaner +// Hyperbolic Rogue -- memory saving // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file memory.cpp + * \brief memory saving: memory saving mode, memory warnings, etc. + */ + + namespace hr { #if HDR diff --git a/scores.cpp b/scores.cpp index 10a55af5..1b11ead2 100644 --- a/scores.cpp +++ b/scores.cpp @@ -1,6 +1,10 @@ -// Hyperbolic Rogue -- local score system +// Hyperbolic Rogue -- local highscore lists // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file scores.cpp + * \brief local highscore lists + */ + #if CAP_SAVE namespace hr { namespace scores { diff --git a/screenshot.cpp b/screenshot.cpp index 537dea98..4274239f 100644 --- a/screenshot.cpp +++ b/screenshot.cpp @@ -1,6 +1,10 @@ -// Hyperbolic Rogue -- screenshots in SVG and PNG formats +// Hyperbolic Rogue -- screenshots and animations // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file screenshot.cpp + * \brief screenshots, SVG format, animations, start animations + */ + namespace hr { bool hide_hud = true; diff --git a/shaders.cpp b/shaders.cpp index c924ac48..02957921 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -1,6 +1,12 @@ -// Hyperbolic Rogue -- basic GL transformations -// If CAP_SHADER is 0, OpenGL 1.0 is used. -// If CAP_SHADER is 1, GLSL is used. +// Hyperbolic Rogue -- low-level OpenGL routines +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details + +/** \file shaders.cpp + * \brief low-level OpenGL routines + * + * If CAP_SHADER is 0, OpenGL 1.0 is used. + * If CAP_SHADER is 1, we are using GLSL shaders. + */ namespace hr { diff --git a/shmup.cpp b/shmup.cpp index b625c49d..f2d81f6b 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1,8 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- shoot'em up mode +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// implementation of the shoot'em up mode +/** \file shmup.cpp + * \brief shoot'em up mode + */ namespace hr { diff --git a/sound.cpp b/sound.cpp index 66570c87..3858fcee 100644 --- a/sound.cpp +++ b/sound.cpp @@ -1,6 +1,10 @@ -// Hyperbolic Rogue -- routines related to sounds +// Hyperbolic Rogue -- sound effects and music // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file sound.cpp + * \brief sound effects and music + */ + namespace hr { EX const char *musicfile = ""; diff --git a/sphere.cpp b/sphere.cpp index b4d30287..ed45847e 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- spherical spaces // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file sphere.cpp + * \brief spherical spaces + */ + namespace hr { // --- spherical geometry --- diff --git a/surface.cpp b/surface.cpp index 2b523f48..f10685e4 100644 --- a/surface.cpp +++ b/surface.cpp @@ -1,7 +1,11 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- surfaces of constant negative curvature // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details -// This file implements the surfaces of constant negative curvature -// See http://webmath2.unito.it/paginepersonali/sergio.console/CurveSuperfici/AG15.pdf for a nice reference + +/** \file surface.cpp + * \brief surfaces of constant negative curvature + * + * See http://webmath2.unito.it/paginepersonali/sergio.console/CurveSuperfici/AG15.pdf for a nice reference + */ #if CAP_SURFACE namespace hr { diff --git a/sysconfig.h b/sysconfig.h index 0f08d9d7..315d3bac 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- set compiler flags, and include all the required system headers // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file sysconfig.h + * \brief set compiler flags, and include all the required system headers + */ + #ifdef MAC #define ISMAC 1 #endif diff --git a/system.cpp b/system.cpp index 5eb2600b..9ef50684 100644 --- a/system.cpp +++ b/system.cpp @@ -1,8 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- starting and ending games +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// routines for: initializing/closing, loading/saving, and cheating +/** \file system.cpp + * \brief changing game modes, starting, closing, loading and saving games + */ namespace hr { diff --git a/textures.cpp b/textures.cpp index 889712ab..1e5e91ea 100644 --- a/textures.cpp +++ b/textures.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- texture mode // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file textures.cpp + * \brief texture mode, also the basic definitions of textures, used in 3D mode + */ + #if CAP_TEXTURE namespace hr { diff --git a/tour.cpp b/tour.cpp index a5f06507..3c6b8bb3 100644 --- a/tour.cpp +++ b/tour.cpp @@ -1,6 +1,10 @@ // Hyperbolic Rogue -- the Tutorial/presentation // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details +/** \file tour.cpp + * \brief the Tutorial and presentation system + */ + namespace hr { EX namespace tour { diff --git a/usershapes.cpp b/usershapes.cpp index 785094a0..4955060e 100644 --- a/usershapes.cpp +++ b/usershapes.cpp @@ -1,9 +1,12 @@ -#if CAP_SHAPES - -// HyperRogue, some functions for user-defined shapes - +// HyperRogue -- user-defined shapes // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details +/** \file usershapes.cpp + * \brief user-defined shapes + */ + +#if CAP_SHAPES + namespace hr { EX int usershape_changes; diff --git a/util.cpp b/util.cpp index ab23432a..78aad7e2 100644 --- a/util.cpp +++ b/util.cpp @@ -1,7 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- basic utility functions // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details -// basic utility functions +/** \file util.cpp + * \brief basic utility functions: maths, parsing expressions + */ namespace hr { diff --git a/yendor.cpp b/yendor.cpp index 043d7c4c..f5537ca6 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -1,9 +1,9 @@ -// Hyperbolic Rogue +// Hyperbolic Rogue -- minor modes +// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -// Yendor Quest, together with the Yendor Challenge -// also, the Pure Tactics Mode and the Peace Mode +/** \file yendor.cpp + * \brief Yendor Quest/Challenge, Pure Tactics Mode, Peace Mode + */ namespace hr {