initial reformatting of comments for Doxygen

This commit is contained in:
Zeno Rogue 2019-08-10 13:43:24 +02:00
parent 4450cb5a08
commit 8b1c7bffe4
81 changed files with 1096 additions and 755 deletions

View File

@ -1,8 +1,10 @@
// HyperRogue // 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 // 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" #include "earcut.hpp"
namespace hr { namespace hr {
@ -221,11 +223,6 @@ void geometry_information::make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
shift_last(-BODY); 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::make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 1); }
void geometry_information::addtri(array<hyperpoint, 3> hs, int kind) { void geometry_information::addtri(array<hyperpoint, 3> hs, int kind) {

View File

@ -1,5 +1,11 @@
// Hyperbolic Rogue -- achievements // Hyperbolic Rogue -- Achievements
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
@ -84,9 +90,12 @@ EX void upload_score(int id, int v);
string achievementMessage[3]; string achievementMessage[3];
int achievementTimer; int achievementTimer;
// achievements received this game /** achievements received this game */
EX vector<string> achievementsReceived; EX vector<string> 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) { EX bool wrongMode(char flags) {
if(cheater) return true; if(cheater) return true;
if(flags == rg::global) return false; if(flags == rg::global) return false;
@ -147,9 +156,11 @@ EX void achievement_log(const char* s, char flags) {
EX void achievement_init(); EX void achievement_init();
EX string myname(); EX string myname();
EX void achievement_close(); EX void achievement_close();
// gain the achievement with the given name.
// flags: 'e' - for Euclidean, 's' - for Shmup, '7' - for heptagonal /** gain the given achievement.
// Only awarded if special modes are matched exactly. * @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)); EX void achievement_gain(const char* s, char flags IS(0));
#if ISSTEAM #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) { EX void achievement_count(const string& s, int current, int prev) {
if(cheater) return; if(cheater) return;
if(shmup::on) return; if(shmup::on) return;
@ -622,8 +638,9 @@ EX void improveItemScores() {
int next_stat_tick; int next_stat_tick;
// gain the final achievements. Called with really=false whenever the user /** gain the final achievements.
// looks at their score, and really=true when the game really ends. * @param really false: the user is simply looking at the score; true: the game really ended.
*/
EX void achievement_final(bool really_final) { EX void achievement_final(bool really_final) {
if(offlineMode) return; if(offlineMode) return;
@ -740,8 +757,9 @@ EX void check_total_victory() {
achievement_gain("TOTALVICTORY"); achievement_gain("TOTALVICTORY");
} }
// gain the victory achievements. Set 'hyper' to true for /** gain the victory achievements.
// the Hyperstone victory, and false for the Orb of Yendor victory. * @param hyper true for the Hyperstone victory, and false for the Orb of Yendor victory.
*/
EX void achievement_victory(bool hyper) { EX void achievement_victory(bool hyper) {
DEBBI(DF_STEAM, ("achievement_victory")) DEBBI(DF_STEAM, ("achievement_victory"))
if(offlineMode) return; if(offlineMode) return;
@ -812,14 +830,14 @@ EX void achievement_victory(bool hyper) {
#endif #endif
} }
// call the achievement callbacks /** call the achievement callbacks */
EX void achievement_pump(); EX void achievement_pump();
#ifndef HAVE_ACHIEVEMENTS #ifndef HAVE_ACHIEVEMENTS
void achievement_pump() {} void achievement_pump() {}
#endif #endif
// display the last achievement gained. /** display the last achievement gained. */
EX void achievement_display() { EX void achievement_display() {
#ifdef HAVE_ACHIEVEMENTS #ifdef HAVE_ACHIEVEMENTS
if(achievementTimer) { if(achievementTimer) {

View File

@ -1,6 +1,11 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- Archimedean Tilings
// This file implements the 'Archimedean tilings' geometry. // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 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 { namespace hr {
@ -80,22 +85,23 @@ static const int sfSEMILINE = 16;
EX archimedean_tiling current; EX archimedean_tiling current;
// id of vertex in the archimedean tiling /** id of vertex in the archimedean tiling
// odd numbers = reflected tiles * odd numbers = reflected tiles
// 0, 2, ..., 2(N-1) = as in the symbol * 0, 2, ..., 2(N-1) = as in the symbol
// 2N = bitruncated tile * 2N = bitruncated tile
*/
EX short& id_of(heptagon *h) { EX short& id_of(heptagon *h) {
return h->zebraval; 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) { EX short& parent_index_of(heptagon *h) {
return h->emeraldval; return h->emeraldval;
} }
// total number of neighbors /** total number of neighbors */
EX int neighbors_of(heptagon *h) { EX int neighbors_of(heptagon *h) {
return isize(current.triangles[id_of(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); // 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) { void fixup_matrix(transmatrix& T, const transmatrix& X, ld step) {
for(int i=0; i<MDIM; i++) for(int i=0; i<MDIM; i++)
for(int j=0; j<MDIM; j++) for(int j=0; j<MDIM; j++)

View File

@ -1,6 +1,9 @@
// Hyperbolic Rogue -- Barriers // Hyperbolic Rogue -- Barriers
// This file implements routines related to barriers (Great Walls and similar). // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file barriers.cpp
* \brief This file implements routines related to barriers (Great Walls and similar).
*/
namespace hr { namespace hr {
@ -32,6 +35,7 @@ EX bool hasbardir(cell *c) {
return c->bardir != NODIR && c->bardir != NOBARRIERS; return c->bardir != 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) { EX void preventbarriers(cell *c) {
if(c && c->bardir == NODIR) c->bardir = NOBARRIERS; 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); 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) { EX bool warped_version(eLand l1, eLand l2) {
return (has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast)) || (VALENCE == 3); return (has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast)) || (VALENCE == 3);
} }

View File

@ -1,20 +1,34 @@
// Hyperbolic Rogue -- basic graphics // Hyperbolic Rogue -- basic graphics
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file basegraph.cpp
* \brief This file implements the basic graphical routines
*/
namespace hr { namespace hr {
#if HDR #if HDR
/** configuration of the current view */
struct display_data { struct display_data {
transmatrix view_matrix; // current rotation, relative to viewctr /** This specifies the heptagon the view is currently centered on.
transmatrix player_matrix; // player-relative view * Unused in masterless tilings -- precise_center is used there.
*/
heptspin view_center; 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; cellwalker precise_center;
/** On-screen coordinates for all the visible cells. */
unordered_map<cell*, transmatrix> cellmatrices, old_cellmatrices; unordered_map<cell*, transmatrix> cellmatrices, old_cellmatrices;
ld xmin, ymin, xmax, ymax; // relative /** Position of the current map view, relative to the screen (0 to 1). */
ld xtop, ytop, xsize, ysize; // in pixels 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; } display_data() { xmin = ymin = 0; xmax = ymax = 1; }
// paramaters calculated from the above /** Center of the current map view, in pixels. */
int xcenter, ycenter; int xcenter, ycenter;
ld radius; ld radius;
int scrsize; int scrsize;
@ -47,6 +61,7 @@ struct display_data {
EX display_data default_display; EX display_data default_display;
EX display_data *current_display = &default_display; EX display_data *current_display = &default_display;
/** Color of the background. */
EX unsigned backcolor = 0; EX unsigned backcolor = 0;
EX unsigned bordcolor = 0; EX unsigned bordcolor = 0;
EX unsigned forecolor = 0xFFFFFF; EX unsigned forecolor = 0xFFFFFF;
@ -1232,8 +1247,6 @@ ld textscale() {
return vid.fsize / (current_display->radius * cgi.crossf) * (1+vid.alpha) * 2; return vid.fsize / (current_display->radius * cgi.crossf) * (1+vid.alpha) * 2;
} }
// bool notgl = false;
bool setfsize = true; bool setfsize = true;
EX bool vsync_off; EX bool vsync_off;

View File

@ -1,10 +1,17 @@
// This file implements: // Hyperbolic Rogue -- Big Stuff
// * routines related to (horo)cycles
// * routines related to equidistants
// * 'setland' routines for other geometries
// * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators.
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 // horocycles
namespace hr { namespace hr {

View File

@ -1,8 +1,10 @@
// Hyperbolic Rogue -- binary tilings
// implementation of the binary tilings
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file binary-tiling.cpp
* \brief Binary tilings in 2D and 3D
*/
namespace hr { namespace hr {
EX namespace binary { EX namespace binary {

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- special graphical effects, such as the Blizzard // Hyperbolic Rogue -- Blizzard
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {

View File

@ -1,7 +1,11 @@
// Hyperbolic Rogue -- cells // 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 { namespace hr {
@ -35,7 +39,7 @@ struct hrmap {
virtual vector<hyperpoint> get_vertices(cell*); virtual vector<hyperpoint> 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 { struct hrmap_standard : hrmap {
void draw() override; void draw() override;
transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hint) 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); 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) { EX cell *createMov(cell *c, int d) {
if(d<0 || d>= c->type) { if(d<0 || d>= c->type) {
printf("ERROR createmov\n"); printf("ERROR createmov\n");
@ -253,7 +257,7 @@ EX euc_pointer euclideanAtCreate(int vec) {
hookset<hrmap*()> *hooks_newmap; hookset<hrmap*()> *hooks_newmap;
// initializer (also inits origin from heptagon.cpp) /** create a map in the current geometry */
EX void initcells() { EX void initcells() {
DEBB(DF_INIT, ("initcells")); DEBB(DF_INIT, ("initcells"));

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- commandline options // Hyperbolic Rogue -- commandline options
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file commandline.cpp
* \brief Commandline options support
*/
namespace hr { namespace hr {
#if CAP_COMMANDLINE #if CAP_COMMANDLINE

View File

@ -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, /** \file complex.cpp
// mirror, hive, heat + livecaves, etc.) * \brief This file implements the gameplay/generation for the more complex lands and mechanics.
*
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details * Includes: whirlwind, whirlpool, elec, princess, clearing, mirror, hive, heat + livecaves, etc.
*/
namespace hr { namespace hr {
@ -1543,7 +1545,7 @@ EX namespace mirror {
for(int i=0; i<CACHESIZE; i++) cache[i].first = NULL; for(int i=0; i<CACHESIZE; i++) cache[i].first = NULL;
} }
cellwalker reflect(const cellwalker& cw) { EX cellwalker reflect(const cellwalker& cw) {
if(!cw.at) return cw; if(!cw.at) return cw;
if((cw.at->landparam & 255) == 0) { if((cw.at->landparam & 255) == 0) {
bool cando = false; bool cando = false;

View File

@ -1,9 +1,12 @@
// Hyperbolic Rogue // Hyperbolic Rogue - Complex features part II
// namespaces for new complex lands for HR11
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // 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 #ifdef CAP_COMPLEX2
namespace hr { namespace hr {

View File

@ -1,7 +1,10 @@
// Hyperbolic Rogue -- configuration // Hyperbolic Rogue -- configuration
// Copyright (C) 2017-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
#if HDR #if HDR

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- control // 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 { namespace hr {

View File

@ -1,19 +1,14 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- Crystal geometries
// This file implements the multi-dimensional (aka crystal) geometries. // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file crystal.cpp
* \brief Multi-dimensional (aka crystal) geometries.
*/
namespace hr { namespace hr {
EX namespace crystal { EX namespace crystal {
#if CAP_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 #if HDR
static const int MAXDIM = 7; static const int MAXDIM = 7;
@ -24,6 +19,15 @@ typedef array<ld, MAXDIM> ldcoord;
static const ldcoord ldc0 = {}; static const ldcoord ldc0 = {};
#endif #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() { EX bool pure() {
return PURE && ginf[gCrystal].vertex == 4; return PURE && ginf[gCrystal].vertex == 4;
} }
@ -54,14 +58,14 @@ void resize2(vector<vector<int>>& v, int a, int b, int z) {
for(auto& w: v) w.resize(b, 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; 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; const int HALFSTEP = 1;
// with variations, the connections of the vertex at coordinate v+FULLSTEP mirror the connections /** 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. * of the vertex at coordinate v. Therefore, the period of our construction is actually 2*FULLSTEP. */
const int PERIOD = 2 * FULLSTEP; const int PERIOD = 2 * FULLSTEP;
struct crystal_structure { struct crystal_structure {
@ -347,19 +351,6 @@ int fiftyrule(coord c) {
if(res[index] == -1) exit(1); if(res[index] == -1) exit(1);
return res[index]; 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); bool is_bi(crystal_structure& cs, coord co);

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- debugging routines // Hyperbolic Rogue -- debugging routines
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file debug.cpp
* \brief Debugging and cheating
*/
namespace hr { namespace hr {
EX int steplimit = 0; EX int steplimit = 0;
@ -471,8 +475,7 @@ EX void push_debug_screen() {
pushScreen(ds); pushScreen(ds);
} }
// -- cheat menu -- /** show the cheat menu */
EX void showCheatMenu() { EX void showCheatMenu() {
gamescreen(1); gamescreen(1);
dialog::init("cheat menu"); dialog::init("cheat menu");
@ -515,6 +518,7 @@ EX void showCheatMenu() {
}; };
} }
/** view all the monsters and items */
EX void viewall() { EX void viewall() {
celllister cl(cwt.at, 20, 2000, NULL); 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) { EX void modalDebug(cell *c) {
viewctr.at = c->master; viewctr.at = c->master;
if(noGUI) { if(noGUI) {

View File

@ -1,18 +1,9 @@
// Hyperbolic Rogue -- dialogs // Hyperbolic Rogue -- dialogs
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/* Missing. /** \file dialogs.cpp
* \brief Implementation of various generic dialogs and elements of dialog windows
#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') {
}
*/
namespace hr { namespace hr {

View File

@ -1,8 +1,10 @@
// Hyperbolic Rogue -- rendering
// implementation of the rendering queue
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
#if HDR #if HDR
@ -110,8 +112,6 @@ bool fatborder;
EX color_t poly_outline; EX color_t poly_outline;
// #define STLSORT
EX vector<unique_ptr<drawqueueitem>> ptds; EX vector<unique_ptr<drawqueueitem>> ptds;
#if CAP_GL #if CAP_GL

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- Euclidean geometry, including 2D, 3D, and quotient spaces // Hyperbolic Rogue -- Euclidean geometry
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {

View File

@ -1,5 +1,12 @@
// HyperRogue -- expansion_analyzer // Hyperbolic Rogue -- expansion analyzer
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {

View File

@ -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 // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file fieldpattern.cpp
* \brief Field Quotient geometry
*/
#if CAP_FIELD #if CAP_FIELD
namespace hr { namespace hr {

View File

@ -1,26 +1,10 @@
// Hyperbolic Rogue // Hyperbolic Rogue - Flags
// implementation of various simple flags for lands, items, monsters, and walls
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file flags.cpp
/* * \brief Implementation of various simple flags for lands, items, monsters, and walls.
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;
*/
namespace hr { namespace hr {

View File

@ -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 { namespace hr {
#if CAP_SHAPES #if CAP_SHAPES

134
game.cpp
View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue // Hyperbolic Rogue - Game routines
// main game routines: movement etc. // 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 { namespace hr {
@ -78,7 +80,7 @@ EX bool canmove = true;
int sagephase = 0; 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; int knighted = 0;
bool usedSafety = false; bool usedSafety = false;
@ -87,8 +89,10 @@ int safetyseed;
int showid = 0; int showid = 0;
/** last move was invisible */
EX bool invismove = false; 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 int noiseuntil; // noise until the given turn
@ -104,69 +108,86 @@ bool landvisited[landtypes];
bool eq(short a, short b) { return a==b; } bool eq(short a, short b) { return a==b; }
// game state /** for treasures, the number collected; for orbs, the number of charges */
EX array<int, ittypes> items; EX array<int, ittypes> items;
/** how many instances of each monster type has been killed */
EX array<int, motypes> kills; EX array<int, motypes> kills;
EX int explore[10], exploreland[10][landtypes], landcount[landtypes]; EX int explore[10], exploreland[10][landtypes], landcount[landtypes];
EX map<modecode_t, array<int, ittypes> > hiitems; EX map<modecode_t, array<int, ittypes> > hiitems;
bool orbused[ittypes], lastorbused[ittypes]; bool orbused[ittypes], lastorbused[ittypes];
EX bool playermoved = true; // center on the PC? /** should we center the screen on the PC? */
EX bool flipplayer = true; // flip the player image after move, do not flip after attack EX bool playermoved = true;
EX int cheater = 0; // did the player cheat? /** 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<cell*> dcal; // queue for cpdist /** the list of all nearby cells, according to cpdist */
vector<cell*> pathq; // queue for pathdist EX vector<cell*> dcal;
/** the list of all nearby cells, according to current pathdist */
vector<cell*> pathq;
vector<cell*> offscreen; // offscreen cells to take care off /** offscreen cells to take care off */
vector<cell*> offscreen;
vector<cell*> pathqm; // list of monsters to move (pathq restriced to monsters) /** list of monsters to move (pathq restriced to monsters) */
vector<cell*> pathqm;
vector<cell*> targets; // list of monster targets
// monsters of specific types to move /** list of cells that the monsters are targetting (PCs, allies, Thumpers, etc.) */
vector<cell*> targets;
/** monsters of specific types to move */
vector<cell*> worms, ivies, ghosts, golems, hexsnakes; vector<cell*> worms, ivies, ghosts, golems, hexsnakes;
/** temporary changes during bfs */ /** temporary changes during bfs */
vector<pair<cell*, eMonster>> tempmonsters; vector<pair<cell*, eMonster>> 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<int> reachedfrom; vector<int> reachedfrom;
// additional direction information for BFS algorithms /** monsters to move, ordered by the number of possible good moves */
// 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<cell*> movesofgood[MAX_EDGE+1]; vector<cell*> 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 cell*& singlepos() { return cwt.at; }
EX inline bool singleused() { return !(shmup::on || multi::players > 1); } EX inline bool singleused() { return !(shmup::on || multi::players > 1); }
// the main random number generator for the game /** the main random number generator for the game
// all the random calls related to the game mechanics (land generation, AI...) should use hrngen * 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 * 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 * this ensures that the game should unfold exactly the same if given the same seed and the same input
*/
std::mt19937 hrngen; std::mt19937 hrngen;
/** initialize hrngen @see hrngen */
EX void shrand(int i) { EX void shrand(int i) {
hrngen.seed(i); hrngen.seed(i);
} }
/** generate a large number with hrngen */
EX int hrandpos() { return hrngen() & HRANDMAX; } EX int hrandpos() { return hrngen() & HRANDMAX; }
// using our own implementations rather than ones from <random>, /** A random integer from [0..i), generated from hrngen.
// to make sure that they return the same values on different compilers * We are using our own implementations rather than ones from <random>,
* 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) { EX int hrand(int i) {
unsigned d = hrngen() - hrngen.min(); unsigned d = hrngen() - hrngen.min();
long long m = (long long) (hrngen.max() - hrngen.min()) + 1; long long m = (long long) (hrngen.max() - hrngen.min()) + 1;
@ -181,10 +202,17 @@ template<class T, class... U> T pick(T x, U... u) { std::initializer_list<T> i =
template<class T> void hrandom_shuffle(T* x, int n) { for(int k=1; k<n; k++) swap(x[k], x[hrand(k+1)]); } template<class T> void hrandom_shuffle(T* x, int n) { for(int k=1; k<n; k++) swap(x[k], x[hrand(k+1)]); }
#endif #endif
/** Use hrngen to generate a floating point number between 0 and 1.
* @see hrngen
*/
EX ld hrandf() { EX ld hrandf() {
return (hrngen() - hrngen.min()) / (hrngen.max() + 1.0 - hrngen.min()); return (hrngen() - hrngen.min()) / (hrngen.max() + 1.0 - hrngen.min());
} }
/** Returns an integer corresponding to the current state of hrngen.
* @see hrngen
*/
EX int hrandstate() { EX int hrandstate() {
std::mt19937 r2 = hrngen; std::mt19937 r2 = hrngen;
return r2() & HRANDMAX; return r2() & HRANDMAX;
@ -1059,7 +1087,7 @@ EX int realstuntime(cell *c) {
bool childbug = false; bool childbug = false;
// is w killed if killed is killed? /** Is `w` killed if the part of an ivy `killed` is killed? */
EX bool isChild(cell *w, cell *killed) { EX bool isChild(cell *w, cell *killed) {
if(isAnyIvy(w->monst)) { if(isAnyIvy(w->monst)) {
int lim = 0; int lim = 0;
@ -2929,12 +2957,14 @@ EX void buildAirmap() {
sort(airmap.begin(), airmap.end()); 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<cell*, int> rosemap; map<cell*, int> rosemap;
// rosemap&3:
// 0 - wave not reached
// 1 - wave expanding
// 2 - wave phase 1
// 3 - wave phase 2
EX int rosedist(cell *c) { EX int rosedist(cell *c) {
if(!(havewhat&HF_ROSE)) return 0; if(!(havewhat&HF_ROSE)) return 0;
@ -3126,7 +3156,7 @@ EX void addButterfly(cell *c) {
butterflies.push_back(make_pair(c, 0)); 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() { EX void bfs() {
calcTidalPhase(); calcTidalPhase();
@ -3541,9 +3571,10 @@ EX void activateArrowTrap(cell *c) {
} }
// effect of moving monster m from cf to ct /** effect of moving monster m from cf to ct
// this is called from moveMonster, or separately from moveIvy/moveWorm, * this is called from moveMonster, or separately from moveIvy/moveWorm,
// or when a dead bird falls (then m == moDeadBird) * or when a dead bird falls (then m == moDeadBird)
*/
EX void moveEffect(cell *ct, cell *cf, eMonster m, int direction_hint) { EX void moveEffect(cell *ct, cell *cf, eMonster m, int direction_hint) {
@ -4008,7 +4039,10 @@ EX int landheattype(cell *c) {
return 1; 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) { EX int moveval(cell *c1, cell *c2, int d, flagtype mf) {
if(!c2) return -5000; if(!c2) return -5000;
@ -5539,12 +5573,11 @@ EX bool cellDangerous(cell *c) {
return cellUnstableOrChasm(c) || isFire(c) || c->wall == waClosedGate; 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) { EX bool hasPrincessWeapon(eMonster m) {
return m == moPalace || m == moFatGuard; return m == moPalace || m == moFatGuard;
} }
/** for an ally m at c, evaluate staying in place */
EX int stayvalue(eMonster m, cell *c) { EX int stayvalue(eMonster m, cell *c) {
if(!passable_for(c->monst, c, NULL, P_MONSTER | P_MIRROR)) if(!passable_for(c->monst, c, NULL, P_MONSTER | P_MIRROR))
return -1501; return -1501;
@ -5554,7 +5587,7 @@ EX int stayvalue(eMonster m, cell *c) {
return 100; 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) { EX int movevalue(eMonster m, cell *c, cell *c2, flagtype flags) {
int val = 0; int val = 0;
@ -5758,9 +5791,10 @@ EX int nearestPathPlayer(cell *c) {
return 0; return 0;
} }
// note: butterflies don't use moveNormal for two reasons: /** note: butterflies don't use moveNormal for two reasons:
// 1) to make sure that they move AFTER bulls * 1) to make sure that they move AFTER bulls
// 2) to make sure that they move offscreen * 2) to make sure that they move offscreen
*/
EX void moveButterflies() { EX void moveButterflies() {
int j = 0; int j = 0;
for(int i=0; i<isize(butterflies); i++) { for(int i=0; i<isize(butterflies); i++) {

View File

@ -1,7 +1,11 @@
// Hyperbolic Rogue -- the 'experiments with geometry' menu // Hyperbolic Rogue -- the 'experiments with geometry' menu
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// -- geometry menu -- /** \file geom-exp.cpp
* \brief The 'experiments with geometry' menu
*
* Implementation of this menu, and computation of the statistics shown there
*/
namespace hr { namespace hr {

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- basic geometry
// geometrical constants // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details /** \file geometry.cpp
* \brief Calculation of basic, and less basic, constants in each geometry
*/
namespace hr { namespace hr {
@ -76,35 +78,51 @@ struct escher_floorshape : floorshape {
int shapeid0, shapeid1, noftype, shapeid2; int shapeid0, shapeid1, noftype, shapeid2;
ld scale; ld scale;
}; };
/** basic geometry parameters */
struct geometry_information { struct geometry_information {
/* basic geometry parameters */ /** distance from heptagon center to another heptagon center */
ld tessf;
// tessf: distance from heptagon center to another heptagon center /** distance from heptagon center to adjacent cell center (either hcrossf or tessf) */
// hexf: distance from heptagon center to small heptagon vertex ld crossf;
// hcrossf: distance from heptagon center to big heptagon vertex
// crossf: distance from heptagon center to adjacent cell center (either hcrossf or tessf) /** distance from heptagon center to small heptagon vertex */
// hexhexdist: distance between adjacent hexagon vertices ld hexf;
// hexvdist: distance between hexagon vertex and hexagon center
// hepvdist: distance between heptagon vertex and hexagon center (either hcrossf or something else) /** distance from heptagon center to big heptagon vertex */
// rhexf: distance from heptagon center to heptagon vertex (either hexf or hcrossf) ld hcrossf;
ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
/** distance between adjacent hexagon vertices */
ld hexhexdist;
/** distance between hexagon vertex and hexagon center */
ld hexvdist;
/** distance between heptagon vertex and hexagon center (either hcrossf or something else) */
ld hepvdist;
/** distance from heptagon center to heptagon vertex (either hexf or hcrossf) */
ld rhexf;
transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE]; transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];
transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE]; transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
int base_distlimit; int base_distlimit;
/* shape parameters */ /** size of the Sword (from Orb of the Sword), used in the shmup mode */
ld sword_size; ld sword_size;
ld scalefactor, orbsize, floorrad0, floorrad1, zhexf; /** scale factor for the graphics of most things*/
ld scalefactor;
ld orbsize, floorrad0, floorrad1, zhexf;
ld corner_bonus; ld corner_bonus;
ld hexshift; ld hexshift;
ld asteroid_size[8]; ld asteroid_size[8];
ld wormscale; ld wormscale;
ld tentacle_length; ld tentacle_length;
/* 3D parameters */ /** various parameters related to the 3D view */
ld INFDEEP, BOTTOM, HELLSPIKE, LAKE, WALL, FLOOR, STUFF, ld INFDEEP, BOTTOM, HELLSPIKE, LAKE, WALL, FLOOR, STUFF,
SLEV[4], FLATEYE, SLEV[4], FLATEYE,
LEG0, LEG1, LEG, LEG3, GROIN, GROIN1, GHOST, LEG0, LEG1, LEG, LEG3, GROIN, GROIN1, GHOST,
@ -360,14 +378,12 @@ hpcshape
}; };
#endif #endif
// the results are: /** values of hcrossf and hexf for the standard geometry. Since polygons are
// hexf = 0.378077 hcrossf = 0.620672 tessf = 1.090550 * usually drawn in this geometry, the scale in other geometries is usually
// hexhexdist = 0.566256 * based on comparing these values to the values in the other geometry.
*/
ld hcrossf7 = 0.620672; ld hcrossf7 = 0.620672, hexf7 = 0.378077, tessf7 = 1.090550, hexhexdist7 = 0.566256;
ld hexf7 = 0.378077;
// the distance between two hexagon centers
bool scale_used() { return (shmup::on && geometry == gNormal && BITRUNCATED) ? (cheater || autocheat) : true; } bool scale_used() { return (shmup::on && geometry == gNormal && BITRUNCATED) ? (cheater || autocheat) : true; }

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- advanced geometry
// advanced geometry // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details /** \file geometry2.cpp
* \brief Matrices to transform between coordinates of various cells, coordinates of cell corners, etc.
*/
namespace hr { namespace hr {
@ -148,16 +150,6 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
gm = gm * cgi.invheptmove[sp]; gm = gm * cgi.invheptmove[sp];
} }
} }
/*if(hsol) {
transmatrix sol2 = gm * where;
for(int i=0; i<3; i++) for(int j=0; j<3; j++)
if(fabs(sol2[i][j]-sol[i][j] > 1e-3)) {
printf("ERROR\n");
display(sol);
display(sol2);
exit(1);
}
} */
return gm * where; return gm * where;
} }

View File

@ -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 { namespace hr {
EX namespace gp { EX namespace gp {

View File

@ -1,8 +1,9 @@
// Hyperbolic Rogue -- main graphics file // 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 /** \file graph.cpp
* \brief Drawing cells, monsters, items, etc.
// basic graphics: */
namespace hr { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- help routines // Hyperbolic Rogue -- help routines
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file help.cpp
* \brief Building and displaying help text
*/
namespace hr { namespace hr {
EX string help; EX string help;

View File

@ -1,8 +1,11 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- Heptagon
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// heptagon here refers to underlying heptagonal tesselation /** \file heptagon.cpp
// (which you can see by changing the conditions in graph.cpp) * \brief implementation of Heptagons
*
* Start with locations.cpp
*/
namespace hr { namespace hr {
@ -13,13 +16,12 @@ int heptacount = 0;
struct cell; struct cell;
cell *newCell(int type, heptagon *master); cell *newCell(int type, heptagon *master);
// spintable functions /** the automaton is used to generate each heptagon in an unique way.
* See http://roguetemple.com/z/dev.php for more help.
// the automaton is used to generate each heptagon in an unique way * From the origin we can go further in any direction, and from other heptagons
// (you can see the tree obtained by changing the conditions in graph.cpp) * we can go in directions 3 and 4 (0 is back to origin, so 3 and 4 go forward),
// from the origin we can go further in any direction, and from other heptagons * and sometimes in direction 5
// 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) { hstate transition(hstate s, int dir) {
if(sphere) { if(sphere) {
@ -210,11 +212,9 @@ void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) {
extern int hrand(int); extern int hrand(int);
// a structure used to walk on the heptagonal tesselation EX hookset<void(heptagon*, int)> *hooks_createStep;
// (remembers not only the heptagon, but also direction)
hookset<void(heptagon*, int)> *hooks_createStep;
// create h->move(d) if not created yet
heptagon *createStep(heptagon *h, int d) { heptagon *createStep(heptagon *h, int d) {
d = h->c.fix(d); d = h->c.fix(d);
if(h->move(d)) return h->move(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); 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);
} }

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- heads-up display // Hyperbolic Rogue -- Heads-Up Display
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {

View File

@ -1,5 +1,5 @@
// Hyperbolic Rogue // 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 // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // 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 // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/** \file hyper.cpp
* \brief the hyper_main function
*/
#include "init.cpp" #include "init.cpp"
#if CU_HYPER #if CU_HYPER

394
hyper.h
View File

@ -1,5 +1,13 @@
// This is the main header file of HyperRogue. Mostly everything is dumped here. // Hyperbolic Rogue -- main header file
// It is quite chaotic. // 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 // version numbers
#define VER "11.1i" #define VER "11.1i"
@ -320,332 +328,8 @@ extern videopar vid;
#define self (*this) #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 MODFIXER (2*10090080*17)
#define MAX_EDGE 18
template<class T> struct walker;
template<class T> struct connection_table {
// Assumption: class T has a field c of type connection_table<T>.
// 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; i<full()->degree(); 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<T> 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<class T> T* tailored_alloc(int degree) {
const T* sample = (T*) &degree;
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; i<degree; i++) result->c.move_table[i] = NULL;
return result;
}
template<class T> 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<int> reverse_directions(struct heptagon *c, int i) { return {i}; }
int hrand(int);
template<class T> struct walker {
T *at;
int spin;
bool mirrored;
walker<T> (T *at = NULL, int s = 0, bool m = false) : at(at), spin(s), mirrored(m) { if(at) s = at->c.fix(s); }
walker<T>& operator += (int i) {
spin = at->c.fix(spin+(mirrored?-i:i));
return (*this);
}
walker<T>& operator -= (int i) {
spin = at->c.fix(spin-(mirrored?-i:i));
return (*this);
}
walker<T>& operator += (wmirror_t) {
mirrored = !mirrored;
return (*this);
}
walker<T>& 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<T>& 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<T>& operator += (revstep_t) {
(*this) += rev; return (*this) += wstep;
}
bool operator != (const walker<T>& x) const {
return at != x.at || spin != x.spin || mirrored != x.mirrored;
}
bool operator == (const walker<T>& x) const {
return at == x.at && spin == x.spin && mirrored == x.mirrored;
}
bool operator < (const walker<T>& cw2) const {
return tie(at, spin, mirrored) < tie(cw2.at, cw2.spin, cw2.mirrored);
}
walker<T>& operator ++ (int) { return (*this) += 1; }
walker<T>& operator -- (int) { return (*this) -= 1; }
template<class U> walker operator + (U t) const { walker<T> w = *this; w += t; return w; }
template<class U> walker operator - (U t) const { walker<T> w = *this; w += (-t); return w; }
T*& peek() { return at->move(spin); }
T* cpeek() { return at->cmove(spin); }
bool creates() { return !peek(); }
walker<T> mirrorat(int d) { return walker<T> (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<heptagon> 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<cell> 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<heptagon> heptspin;
typedef walker<cell> 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 BUGCOLORS 3
#define big_unlock (inv::on && !chaosmode) #define big_unlock (inv::on && !chaosmode)
@ -689,7 +373,7 @@ struct movedir {
#define MD_UNDECIDED (-3) #define MD_UNDECIDED (-3)
#define MD_USE_ORB (-4) #define MD_USE_ORB (-4)
int subdir; // for normal movement (0+): turn left or right 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 // shmup
@ -704,7 +388,7 @@ typedef function<bool()> bool_reaction_t;
#define HELPFUN(x) (help_delegate = x, "HELPFUN") #define HELPFUN(x) (help_delegate = x, "HELPFUN")
typedef function<int(cell*)> cellfunction; typedef function<int(struct cell*)> cellfunction;
// passable flags // passable flags
@ -968,10 +652,6 @@ namespace scores { void load(); }
namespace leader { void showMenu(); void handleKey(int sym, int uni); } namespace leader { void showMenu(); void handleKey(int sym, int uni); }
#endif #endif
namespace mirror {
cellwalker reflect(const cellwalker& cw);
}
struct hint { struct hint {
time_t last; time_t last;
function<bool()> usable; function<bool()> usable;
@ -1026,56 +706,6 @@ const eLand NOWALLSEP_USED = laWhirlpool;
extern vector<cell*> dcal; extern vector<cell*> dcal;
// list all cells in distance at most maxdist, or until when maxcount cells are reached
struct manual_celllister {
vector<cell*> lst;
vector<int> 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; i<isize(lst); i++) lst[i]->listindex = tmps[i];
}
};
struct celllister : manual_celllister {
vector<int> 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<isize(lst); i++) {
cell *c = lst[i];
if(maxdist) forCellCM(c2, c) {
add_at(c2, dists[i]+1);
if(c2 == breakon) return;
}
if(c == last) {
if(isize(lst) >= 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 // z to close to this limit => do not draw
#define BEHIND_LIMIT 1e-6 #define BEHIND_LIMIT 1e-6

View File

@ -1,6 +1,13 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- basic computations in non-Euclidean geometry
// This file contains hyperbolic points and matrices. // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 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 { namespace hr {

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- hyperbolic graphics // 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 { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- initialization, and stuff related to mobiles // Hyperbolic Rogue -- initialization, and stuff related to mobiles
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file init.cpp
* \brief initialization, and stuff related to mobiles
*/
#include "compileunits.h" #include "compileunits.h"
namespace hr { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- Orb Strategy Mode // Hyperbolic Rogue -- Orb Strategy Mode
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file inventory.cpp
* \brief Orb Strategy Mode
*/
namespace hr { namespace hr {
EX namespace inv { EX namespace inv {

View File

@ -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 { namespace hr {
EX namespace irr { EX namespace irr {

View File

@ -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 { namespace hr {

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- land availability
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
@ -14,7 +16,7 @@ EX bool nodisplay(eMonster m) {
m == moIvyDead; 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) { EX int isNative(eLand l, eMonster m) {
switch(l) { switch(l) {
#define LAND(a,b,c,d,e,f,g) case c: #define LAND(a,b,c,d,e,f,g) case c:

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue language support // Hyperbolic Rogue -- language support
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file language.cpp
* \brief localization support
*/
// #define CHECKTRANS // #define CHECKTRANS
@ -24,28 +28,6 @@ struct stringpar {
}; };
#endif #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) { void rep(string& pattern, string what, string to) {
while(true) { while(true) {
size_t at = pattern.find(what); size_t at = pattern.find(what);
@ -332,6 +314,7 @@ void parrep(string& x, string w, stringpar p) {
void postrep(string& s) { void postrep(string& s) {
} }
/** translate the string @x */
EX string XLAT(string x) { EX string XLAT(string x) {
basicrep(x); basicrep(x);
postrep(x); postrep(x);

View File

@ -1,5 +1,5 @@
// old config file format (disabled by default) // Hyperbolic Rogue -- old config file format (disabled by default)
// Copyright (C) 2017-2019 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
#if CAP_LEGACY #if CAP_LEGACY
namespace hr { namespace hr {

441
locations.cpp Normal file
View File

@ -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<class T> 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<T>,
* 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<class T> 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; i<full()->degree(); 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<T> 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<class T> T* tailored_alloc(int degree) {
const T* sample = (T*) &degree;
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; i<degree; i++) result->c.move_table[i] = NULL;
return result;
}
/** Counterpart to @see tailored_alloc. */
template<class T> 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<int> 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<class T> struct walker {
/** where we are at */
T *at;
/** in which direction (edge) we are facing */
int spin;
/** are we mirrored */
bool mirrored;
walker<T> (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<T>& operator += (int i) {
spin = at->c.fix(spin+(mirrored?-i:i));
return (*this);
}
/** spin by i to the right (or left, when mirrored */
walker<T>& operator -= (int i) {
spin = at->c.fix(spin-(mirrored?-i:i));
return (*this);
}
/** add wmirror to mirror this walker */
walker<T>& 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<T>& 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<T>& 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<T>& operator += (revstep_t) {
(*this) += rev; return (*this) += wstep;
}
bool operator != (const walker<T>& x) const {
return at != x.at || spin != x.spin || mirrored != x.mirrored;
}
bool operator == (const walker<T>& x) const {
return at == x.at && spin == x.spin && mirrored == x.mirrored;
}
bool operator < (const walker<T>& cw2) const {
return tie(at, spin, mirrored) < tie(cw2.at, cw2.spin, cw2.mirrored);
}
walker<T>& operator ++ (int) { return (*this) += 1; }
walker<T>& operator -- (int) { return (*this) -= 1; }
template<class U> walker operator + (U t) const { walker<T> w = *this; w += t; return w; }
template<class U> walker operator - (U t) const { walker<T> 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<T> mirrorat(int d) { return walker<T> (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<heptagon> 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<cell> 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<heptagon> heptspin;
typedef walker<cell> 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<cell*> lst;
vector<int> 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; i<isize(lst); i++) lst[i]->listindex = tmps[i];
}
};
/** automatically generate a list of nearby cells */
struct celllister : manual_celllister {
vector<int> 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<isize(lst); i++) {
cell *c = lst[i];
if(maxdist) forCellCM(c2, c) {
add_at(c2, dists[i]+1);
if(c2 == breakon) return;
}
if(c == last) {
if(isize(lst) >= 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
}

View File

@ -1,3 +1,4 @@
// generate autohdr.h based on the `EX` and `#if HDR` in *.cpp files
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>

View File

@ -1,5 +1,9 @@
// HyperRogue map editor // Hyperbolic Rogue -- map editor and vector graphics editor
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file mapedit.cpp
* \brief HyperRogue editors (map and vector graphics)
*/
namespace hr { namespace hr {

View File

@ -1,5 +1,9 @@
// HyperRogue menus // Hyperbolic Rogue -- menus
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file menus.cpp
* \brief generic menus (start menu, main menu, Overview, etc.)
*/
// -- overview -- // -- overview --

View File

@ -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 { namespace hr {
EX namespace polygonal { EX namespace polygonal {

View File

@ -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 /** \file monstergen.cpp
* \brief monster generation
// Routines concentrating on monster generation. */
namespace hr { namespace hr {
@ -40,8 +41,7 @@ EX int buildIvy(cell *c, int children, int minleaf) {
else return leaf; 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) { EX void chasmify(cell *c) {
c->wall = waChasm; c->item = itNone; c->wall = waChasm; c->item = itNone;
int q = 0; int q = 0;
@ -104,7 +104,7 @@ EX void chasmifyElemental(cell *c) {
c->wparam = 100; c->item = itNone; c->wparam = 100; c->item = itNone;
} }
// an appropriate monster for the Crossroads /** generate a monster appropriate for the Crossroads */
EX eMonster crossroadsMonster() { EX eMonster crossroadsMonster() {
@ -305,6 +305,7 @@ EX eItem wanderingTreasure(cell *c) {
return treasureType(l); return treasureType(l);
} }
/** generate the wandering monsters */
EX void wandering() { EX void wandering() {
if(bounded && specialland == laMinefield) { if(bounded && specialland == laMinefield) {
kills[moBomberbird] = 0; kills[moBomberbird] = 0;

View File

@ -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 /** \file multi.cpp
* \brief multiplayer features, also input configuration
// implementation of the multiplayer features */
namespace hr { namespace hr {

View File

@ -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 /** \file multi.cpp
* \brief running several games at once -- used in the Tutorial and Dual Geometry mode
// gamedata structure, for recording the game data in memory temporarily */
// namespace dual (dual mode)
namespace hr { namespace hr {
#if HDR #if HDR
/** gamedata structure, for recording the game data in memory temporarily */
struct gamedata { struct gamedata {
// important parameters should be visible /** important parameters should be visible */
eGeometry geo; eGeometry geo;
eVariation var; eVariation var;
eLand specland; eLand specland;
bool active; bool active;
// other properties are recorded /** other properties are recorded here */
vector<char> record; vector<char> record;
int index, mode; int index, mode;
void storegame(); void storegame();
@ -103,7 +104,7 @@ EX namespace gamestack {
EX } EX }
EX namespace dual { 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 state;
EX int currently_loaded; EX int currently_loaded;

View File

@ -1,5 +1,9 @@
// HyperRogue paper model generator // Hyperbolic Rogue -- paper model generator
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file netgen.cpp
* \brief paper model generator
*/
#if CAP_MODEL #if CAP_MODEL
namespace hr { namespace netgen { namespace hr { namespace netgen {

View File

@ -1,11 +1,15 @@
// Hyperbolic Rogue -- built-in font // 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 { namespace hr {
#if CAP_TABFONT #if CAP_TABFONT
// compile with -DCAP_CREATEFONT=1 to generate this table /** compile with -DCAP_CREATEFONT=1 to generate this table
// this variant has been created for non-translated HyperRogue * this variant has been created for non-translated HyperRogue */
unsigned char fonttable[] = { unsigned char fonttable[] = {
43,13,0,255,0,255,0,49, 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, 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,

View File

@ -1,8 +1,10 @@
// Hyperbolic Rogue -- nonisotropic spaces (Solv and Nil)
// implementation of the Solv space
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file nonisotropic.cpp
* \brief nonisotropic spaces (Solv and Nil)
*/
namespace hr { namespace hr {
EX namespace nisot { EX namespace nisot {

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- orb generation routines // 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 { namespace hr {
// orbgen flags // orbgen flags

View File

@ -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 /** \file orbs.cpp
* \brief Implementation of various Orb effects, and their properties such as default and maximum charges
// Orb-related routines */
namespace hr { namespace hr {

View File

@ -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 { namespace hr {

View File

@ -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 { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- Kite-and-dart tiling // Hyperbolic Rogue -- Kite-and-dart tiling
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
EX namespace kite { EX namespace kite {

View File

@ -1,8 +1,10 @@
// Hyperbolic Rogue -- shapes used for the vector graphics
// HyperRogue, shapes used for the vector graphics
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // 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 #if CAP_SHAPES
namespace hr { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- the mission screen // Hyperbolic Rogue -- the mission screen
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
EX bool quitsaves() { return (items[itOrbSafety] && CAP_SAVE && !archimedean); } EX bool quitsaves() { return (items[itOrbSafety] && CAP_SAVE && !archimedean); }

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- quotient spaces // Hyperbolic Rogue -- quotient spaces
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file quotient.cpp
* \brief quotient spaces
*/
namespace hr { namespace hr {
// --- quotient geometry --- // --- quotient geometry ---

View File

@ -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, /** \file racing.cpp
// mirror, hive, heat + livecaves, etc.) * \brief racing mode
*/
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
namespace hr { namespace hr {

View File

@ -1,8 +1,14 @@
// Hyperbolic Rogue -- regular honeycombs // 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 // 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 { namespace hr {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
transmatrix cpush(int cid, ld alpha); transmatrix cpush(int cid, ld alpha);

View File

@ -1,9 +1,13 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- drawing screens to buffers
// This file implements the 'renderbuffer', which is an object // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// that can be used to draw a HyperRogue screen into,
// and then either used as a OpenGL texture, or saved.
// 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 { namespace hr {

View File

@ -1,7 +1,11 @@
// Hyperbolic Rogue // Hyperbolic Rogue - Hypersian Rug mode
// Copyright (C) 2011-2016 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {

View File

@ -1,6 +1,11 @@
// Hyperbolic Rogue -- smart memory cleaner // Hyperbolic Rogue -- memory saving
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {
#if HDR #if HDR

View File

@ -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 // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file scores.cpp
* \brief local highscore lists
*/
#if CAP_SAVE #if CAP_SAVE
namespace hr { namespace scores { namespace hr { namespace scores {

View File

@ -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 // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file screenshot.cpp
* \brief screenshots, SVG format, animations, start animations
*/
namespace hr { namespace hr {
bool hide_hud = true; bool hide_hud = true;

View File

@ -1,6 +1,12 @@
// Hyperbolic Rogue -- basic GL transformations // Hyperbolic Rogue -- low-level OpenGL routines
// If CAP_SHADER is 0, OpenGL 1.0 is used. // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// If CAP_SHADER is 1, GLSL is used.
/** \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 { namespace hr {

View File

@ -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 /** \file shmup.cpp
* \brief shoot'em up mode
// implementation of the shoot'em up mode */
namespace hr { namespace hr {

View File

@ -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 // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file sound.cpp
* \brief sound effects and music
*/
namespace hr { namespace hr {
EX const char *musicfile = ""; EX const char *musicfile = "";

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- spherical spaces // Hyperbolic Rogue -- spherical spaces
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file sphere.cpp
* \brief spherical spaces
*/
namespace hr { namespace hr {
// --- spherical geometry --- // --- spherical geometry ---

View File

@ -1,7 +1,11 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- surfaces of constant negative curvature
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 #if CAP_SURFACE
namespace hr { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- set compiler flags, and include all the required system headers // Hyperbolic Rogue -- set compiler flags, and include all the required system headers
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 #ifdef MAC
#define ISMAC 1 #define ISMAC 1
#endif #endif

View File

@ -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 /** \file system.cpp
* \brief changing game modes, starting, closing, loading and saving games
// routines for: initializing/closing, loading/saving, and cheating */
namespace hr { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- texture mode // Hyperbolic Rogue -- texture mode
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 #if CAP_TEXTURE
namespace hr { namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- the Tutorial/presentation // Hyperbolic Rogue -- the Tutorial/presentation
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file tour.cpp
* \brief the Tutorial and presentation system
*/
namespace hr { namespace hr {
EX namespace tour { EX namespace tour {

View File

@ -1,9 +1,12 @@
#if CAP_SHAPES // HyperRogue -- user-defined shapes
// HyperRogue, some functions for user-defined shapes
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file usershapes.cpp
* \brief user-defined shapes
*/
#if CAP_SHAPES
namespace hr { namespace hr {
EX int usershape_changes; EX int usershape_changes;

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue // Hyperbolic Rogue -- basic utility functions
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // 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 { namespace hr {

View File

@ -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 /** \file yendor.cpp
* \brief Yendor Quest/Challenge, Pure Tactics Mode, Peace Mode
// Yendor Quest, together with the Yendor Challenge */
// also, the Pure Tactics Mode and the Peace Mode
namespace hr { namespace hr {