1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-09-06 12:27:57 +00:00

added/fixed some \brief descriptions

This commit is contained in:
Zeno Rogue
2020-03-27 21:47:09 +01:00
parent eadd1d90c0
commit 0412f077e6
10 changed files with 164 additions and 150 deletions

View File

@@ -21,23 +21,23 @@ extern int cellcount, heptacount;
#define NODIR 126
#define NOBARRIERS 127
/** Cell information for the game. struct cell builds on this */
/** \brief Cell information for the game. struct cell builds on this */
struct gcell {
#if CAP_BITFIELD
/** which land does this cell belong to */
/** \brief which land does this cell belong to */
eLand land : 8;
/** wall type (waNone for no walls) */
/** \brief wall type (waNone for no walls) */
eWall wall : 8;
/** monster on this cell -- note that player characters are handled separately */
/** \brief monster on this cell -- note that player characters are handled separately */
eMonster monst : 8;
/** item on this cell */
/** \brief item on this cell */
eItem item : 8;
/** if this is a barrier, what lands on are on the sides? */
/** \brief if this is a barrier, what lands on are on the sides? */
eLand barleft : 8, barright : 8;
/** is it currently sparkling with lightning? */
/** \brief is it currently sparkling with lightning? */
unsigned ligon : 1;
signed
@@ -91,7 +91,7 @@ struct gcell {
} LHU;
/** wall parameter, used e.g. for remaining power of Bonfires and Thumpers */
/** \brief wall parameter, used e.g. for remaining power of Bonfires and Thumpers */
char wparam;
#ifdef CELLID
@@ -129,35 +129,35 @@ int gmod(int i, int j);
template<class T> struct connection_table {
/** Table of moves. This is the maximum size, but tailored_alloc allocates less. */
/** \brief Table of moves. This is the maximum size, but tailored_alloc allocates less. */
T* move_table[FULL_EDGE + (FULL_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 */
/** \brief 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 */
/** \brief 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] */
/** \brief 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 */
/** \brief 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()) */
/** \brief 'fix' the edge number d to get the actual index in [0, degree()) */
int fix(int d) { return gmod(d, full()->degree()); }
/** T in the direction i */
/** \brief T in the direction i */
T*& move(int i) { return move_table[i]; }
/** T in the direction i, modulo degree() */
/** \brief 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 */
/** \brief 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 */
/** \brief 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();
@@ -170,10 +170,10 @@ template<class T> struct connection_table {
}
};
/** Allocate a class T with a connection_table, but
* with only `degree` connections. Also set yet
* unknown connections to NULL.
/** \brief 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.
*/
@@ -193,7 +193,7 @@ template<class T> T* tailored_alloc(int degree) {
return result;
}
/** Counterpart to tailored_alloc(). */
/** \brief Counterpart to hr::tailored_alloc(). */
template<class T> void tailored_delete(T* x) {
x->~T();
delete[] ((char*) (x));
@@ -206,31 +206,31 @@ static const struct revstep_t { revstep_t() {}} revstep;
extern int hrand(int);
/** the walker structure is used for walking on surfaces defined via \ref connection_table. */
/** \brief the walker structure is used for walking on surfaces defined via \ref connection_table. */
template<class T> struct walker {
/** where we are at */
/** \brief where we are at */
T *at;
/** in which direction (edge) we are facing */
/** \brief in which direction (edge) we are facing */
int spin;
/** are we mirrored */
/** \brief 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 */
/** \brief 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 */
/** \brief 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 */
/** \brief 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 */
/** \brief 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);
@@ -239,14 +239,14 @@ template<class T> struct walker {
spin = nspin;
return (*this);
}
/** add wrev to face the other direction, may be non-deterministic and use hrand */
/** \brief 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 */
/** \brief adding revstep is equivalent to adding rev and step */
walker<T>& operator += (revstep_t) {
(*this) += rev; return (*this) += wstep;
}
@@ -265,13 +265,13 @@ template<class T> struct walker {
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 */
/** \brief what T are we facing, without creating it */
T*& peek() { return at->move(spin); }
/** what T are we facing, with creating it */
/** \brief what T are we facing, with creating it */
T* cpeek() { return at->cmove(spin); }
/** would we create a new T if we stepped forwards? */
/** \brief would we create a new T if we stepped forwards? */
bool creates() { return !peek(); }
/** mirror this walker with respect to the d-th edge */
/** \brief 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); }
};
@@ -288,11 +288,13 @@ struct cdata {
int bits;
};
/** Limit on the 'distance' value in heptagon. This value is signed (negative distances are used
in horocycle implementation. Distance is currently a short, and we need a bit of breathing room.
It would not be a technical problem to use a larger type, but 32000 is close to what fits in
the memory of a normal computer. Farlands appear close to this limit.
*/
/** \brief Limit on the 'distance' value in heptagon.
*
* This value is signed (negative distances are used
* in horocycle implementation. Distance is currently a short, and we need a bit of breathing room.
* It would not be a technical problem to use a larger type, but 32000 is close to what fits in
* the memory of a normal computer. Farlands appear close to this limit.
**/
constexpr int global_distance_limit = 32000;
@@ -300,44 +302,45 @@ constexpr int global_distance_limit = 32000;
data (e.g., circular dragon). It should be larger than global_distance_limit */
constexpr int iteration_limit = 10000000;
/** in bitruncated/irregular/Goldberg geometries, heptagons form the
/** \brief underlying tiling
* 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 */
/** \brief Automata are used to generate the standard maps. s is the state of this automaton */
hstate s : 6;
/** distance modulo 4, in heptagons */
/** \brief distance modulo 4, in heptagons */
unsigned int dm4: 2;
/** distance from the origin; based on the final geometry of cells, not heptagons themselves */
/** \brief 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. */
/** \brief Wmerald/wineyard generator. May have different meaning in other geometries. */
short emeraldval;
/** Palace pattern generator. May have different meaning in other geometries. */
/** \brief Palace pattern generator. May have different meaning in other geometries. */
short fiftyval;
/** Zebra pattern generator. May have different meaning in other geometries. */
/** \brief Zebra pattern generator. May have different meaning in other geometries. */
short zebraval;
/** Field quotient pattern ID. May have different meaning in other geometries. */
/** \brief Field quotient pattern ID. May have different meaning in other geometries. */
int fieldval : 24;
/** the number of adjacent heptagons */
/** \brief the number of adjacent heptagons */
unsigned char type : 8;
/** data for fractal landscapes */
/** \brief 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
/** \brief 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 */
/** \brief associated generator of alternate structure, for Camelot and horocycles */
heptagon *alt;
/** connection table */
/** \brief 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); }
@@ -379,23 +382,23 @@ struct cell : gcell {
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.
/** \brief 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 */
/** \brief list of cells in this list */
vector<cell*> lst;
vector<int> tmps;
/** is the given cell on the list? */
/** \brief 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 */
/** \brief add a cell to the list */
bool add(cell *c) {
if(listed(c)) return false;
tmps.push_back(c->listindex);
@@ -409,7 +412,7 @@ struct manual_celllister {
}
};
/** automatically generate a list of nearby cells */
/** \brief automatically generate a list of nearby cells */
struct celllister : manual_celllister {
vector<int> dists;
@@ -417,7 +420,7 @@ struct celllister : manual_celllister {
if(add(c)) dists.push_back(d);
}
/** automatically generate a list of nearby cells
/** \brief 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
@@ -439,11 +442,11 @@ struct celllister : manual_celllister {
}
}
/** for a given cell c on the list, return its distance from orig */
/** \brief 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 */
/** \brief 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); }
@@ -451,10 +454,6 @@ inline cellwalker operator+ (heptspin hs, cth_t) { return cellwalker(hs.at->c7,
#endif
#if HDR
/** a structure for representing movements
* mostly for 'proper' moves where s->move(d) == t,
* but also sometimes for other moves
*/
constexpr int STRONGWIND = 99;
constexpr int FALL = 98;
@@ -464,6 +463,12 @@ constexpr int JUMP = 95;
namespace whirlwind { cell *jumpDestination(cell*); }
/** \brief a structure for representing movements
*
* mostly for 'proper' moves where s->move(d) == t,
* but also sometimes for other moves
*/
struct movei {
cell *s;
cell *t;