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
// This file contains the routines to convert HyperRogue's old vector graphics into 3D models
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file 3d-models.cpp
* \brief This file contains the routines to convert HyperRogue's old vector graphics into 3D models
*/
#include "earcut.hpp"
namespace hr {
@ -221,11 +223,6 @@ void geometry_information::make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
shift_last(-BODY);
}
/*
void make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 0.90); }
void make_armor_3d(hpcshape& sh, ld scale = 1) { make_ha_3d(sh, true, scale); }
*/
void geometry_information::make_humanoid_3d(hpcshape& sh) { make_ha_3d(sh, false, 1); }
void geometry_information::addtri(array<hyperpoint, 3> hs, int kind) {

View File

@ -1,5 +1,11 @@
// Hyperbolic Rogue -- achievements
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- Achievements
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file achievements.cpp
* \brief This file implements routines related to achievements and leaderboards
*
* This routines are general, i.e., not necessarily Steam-specific.
*/
namespace hr {
@ -84,9 +90,12 @@ EX void upload_score(int id, int v);
string achievementMessage[3];
int achievementTimer;
// achievements received this game
/** achievements received this game */
EX vector<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) {
if(cheater) return true;
if(flags == rg::global) return false;
@ -147,9 +156,11 @@ EX void achievement_log(const char* s, char flags) {
EX void achievement_init();
EX string myname();
EX void achievement_close();
// gain the achievement with the given name.
// flags: 'e' - for Euclidean, 's' - for Shmup, '7' - for heptagonal
// Only awarded if special modes are matched exactly.
/** gain the given achievement.
* @param s name of the achievement, e.g., DIAMOND1
* @param flags one of the constants from namespace rg. The achievement is only awarded if special modes are matched exactly.
*/
EX void achievement_gain(const char* s, char flags IS(0));
#if ISSTEAM
@ -476,7 +487,12 @@ EX void achievement_collection(eItem it, int prevgold, int newgold) {
}
}
// this is used for 'counting' achievements, such as kill 10 monsters at the same time.
/** This function awards 'counting' achievements, such as kill 10 monsters at the same time.
* @param s name of the group of achievements, e.g. GOLEM.
* @param current our score, e.g., the the achievement GOLEM2 will be awared with current >= 5.
* @param prev previous value of the score.
*/
EX void achievement_count(const string& s, int current, int prev) {
if(cheater) return;
if(shmup::on) return;
@ -622,8 +638,9 @@ EX void improveItemScores() {
int next_stat_tick;
// gain the final achievements. Called with really=false whenever the user
// looks at their score, and really=true when the game really ends.
/** gain the final achievements.
* @param really false: the user is simply looking at the score; true: the game really ended.
*/
EX void achievement_final(bool really_final) {
if(offlineMode) return;
@ -740,8 +757,9 @@ EX void check_total_victory() {
achievement_gain("TOTALVICTORY");
}
// gain the victory achievements. Set 'hyper' to true for
// the Hyperstone victory, and false for the Orb of Yendor victory.
/** gain the victory achievements.
* @param hyper true for the Hyperstone victory, and false for the Orb of Yendor victory.
*/
EX void achievement_victory(bool hyper) {
DEBBI(DF_STEAM, ("achievement_victory"))
if(offlineMode) return;
@ -812,14 +830,14 @@ EX void achievement_victory(bool hyper) {
#endif
}
// call the achievement callbacks
/** call the achievement callbacks */
EX void achievement_pump();
#ifndef HAVE_ACHIEVEMENTS
void achievement_pump() {}
#endif
// display the last achievement gained.
/** display the last achievement gained. */
EX void achievement_display() {
#ifdef HAVE_ACHIEVEMENTS
if(achievementTimer) {

View File

@ -1,6 +1,11 @@
// Hyperbolic Rogue
// This file implements the 'Archimedean tilings' geometry.
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- Archimedean Tilings
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file archimedean.cpp
* \brief Archimedean tilings
*
* These are tilings available in the 'Archimedean' option in Geometry Experiments; simpler Archimedean tilings are defined in other files.
*/
namespace hr {
@ -80,22 +85,23 @@ static const int sfSEMILINE = 16;
EX archimedean_tiling current;
// id of vertex in the archimedean tiling
// odd numbers = reflected tiles
// 0, 2, ..., 2(N-1) = as in the symbol
// 2N = bitruncated tile
/** id of vertex in the archimedean tiling
* odd numbers = reflected tiles
* 0, 2, ..., 2(N-1) = as in the symbol
* 2N = bitruncated tile
*/
EX short& id_of(heptagon *h) {
return h->zebraval;
}
// which index in id_of's neighbor list does h->move[0] have
/** which index in id_of's neighbor list does h->move(0) have */
EX short& parent_index_of(heptagon *h) {
return h->emeraldval;
}
// total number of neighbors
/** total number of neighbors */
EX int neighbors_of(heptagon *h) {
return isize(current.triangles[id_of(h)]);
@ -726,7 +732,7 @@ void connectHeptagons(heptspin hi, heptspin hs) {
// heptagon *hnew = build_child(h, d, get_adj(h, d).first, get_adj(h, d).second);
}
// T and X are supposed to be equal -- move T so that it is closer to X
/** T and X are supposed to be equal -- move T so that it is closer to X */
void fixup_matrix(transmatrix& T, const transmatrix& X, ld step) {
for(int i=0; i<MDIM; i++)
for(int j=0; j<MDIM; j++)

View File

@ -1,6 +1,9 @@
// Hyperbolic Rogue -- Barriers
// This file implements routines related to barriers (Great Walls and similar).
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file barriers.cpp
* \brief This file implements routines related to barriers (Great Walls and similar).
*/
namespace hr {
@ -32,6 +35,7 @@ EX bool hasbardir(cell *c) {
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) {
if(c && c->bardir == NODIR) c->bardir = NOBARRIERS;
}
@ -60,7 +64,7 @@ EX bool checkBarriersBack(cellwalker bb, int q IS(5), bool cross IS(false)) {
return checkBarriersFront(bb, q);
}
// warp coasts use a different algorithm when has_nice_dual() is on
/** warp coasts use a different algorithm for nowall barriers when has_nice_dual() is on. Check whether we should use this different algorithm when the lands are l1 and l2 */
EX bool warped_version(eLand l1, eLand l2) {
return (has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast)) || (VALENCE == 3);
}

View File

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

View File

@ -1,10 +1,17 @@
// This file implements:
// * routines related to (horo)cycles
// * routines related to equidistants
// * 'setland' routines for other geometries
// * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators.
// Hyperbolic Rogue -- Big Stuff
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file bigstuff.cpp
* \brief Large map structures, such as (horo)cycles and equidistants.
*
* This file implements:
* * routines related to (horo)cycles
* * routines related to equidistants
* * 'setland' routines for other geometries
* * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators.
* This routines are general, i.e., not necessarily Steam-specific.
*/
// horocycles
namespace hr {

View File

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

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- special graphical effects, such as the Blizzard
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- Blizzard
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file blizzard.cpp
* \brief special graphical effects, such as the Blizzard and arrow traps
*/
namespace hr {

View File

@ -1,7 +1,11 @@
// Hyperbolic Rogue -- cells
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// cells the game is played on
/** \file cell.cpp
* \brief General cells and maps
*
* Start with locations.cpp
*/
namespace hr {
@ -35,7 +39,7 @@ struct hrmap {
virtual vector<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 {
void draw() override;
transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hint) override;
@ -124,7 +128,7 @@ hrmap_hyperbolic::hrmap_hyperbolic() {
h.c7 = newCell(S7, origin);
}
// very similar to createMove in heptagon.cpp
/** very similar to createMove in heptagon.cpp */
EX cell *createMov(cell *c, int d) {
if(d<0 || d>= c->type) {
printf("ERROR createmov\n");
@ -253,7 +257,7 @@ EX euc_pointer euclideanAtCreate(int vec) {
hookset<hrmap*()> *hooks_newmap;
// initializer (also inits origin from heptagon.cpp)
/** create a map in the current geometry */
EX void initcells() {
DEBB(DF_INIT, ("initcells"));

View File

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

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

View File

@ -1,9 +1,12 @@
// Hyperbolic Rogue
// namespaces for new complex lands for HR11
// Hyperbolic Rogue - Complex features part II
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file complex2.cpp
* \brief Continuation of complex.cpp
*
* Includes: Brownian, Irradiated, Free Fall
*/
#ifdef CAP_COMPLEX2
namespace hr {

View File

@ -1,7 +1,10 @@
// Hyperbolic Rogue -- configuration
// Copyright (C) 2017-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file config.cpp
* \brief Configuration -- initial settings, saving/loading ini files, menus, etc.
*/
namespace hr {
#if HDR

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- control
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file control.cpp
* \brief Routines related to controlling the game
*/
namespace hr {

View File

@ -1,19 +1,14 @@
// Hyperbolic Rogue
// This file implements the multi-dimensional (aka crystal) geometries.
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- Crystal geometries
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file crystal.cpp
* \brief Multi-dimensional (aka crystal) geometries.
*/
namespace hr {
EX namespace crystal {
#if CAP_CRYSTAL
// Crystal can be bitruncated either by changing variation to bitruncated.
// In case of the 4D Crystal, the standard HyperRogue bitruncation becomes
// confused by having both the original and new vertices of degree 8.
// Hence Crystal implements its own bitruncation, which is selected/checked
// by setting ginf[gCrystal].vertex to 3. Additionally, this lets us double
// bitruncate.
// Function pure() checks for both kinds of bitruncation (or any other variations).
#if HDR
static const int MAXDIM = 7;
@ -24,6 +19,15 @@ typedef array<ld, MAXDIM> ldcoord;
static const ldcoord ldc0 = {};
#endif
/** Crystal can be bitruncated either by changing variation to bitruncated.
* In case of the 4D Crystal, the standard HyperRogue bitruncation becomes
* confused by having both the original and new vertices of degree 8.
* Hence Crystal implements its own bitruncation, which is selected/checked
* by setting ginf[gCrystal].vertex to 3. Additionally, this lets us double
* bitruncate.
* Function pure() checks for both kinds of bitruncation (or any other variations).
*/
EX bool pure() {
return PURE && ginf[gCrystal].vertex == 4;
}
@ -54,14 +58,14 @@ void resize2(vector<vector<int>>& v, int a, int b, int z) {
for(auto& w: v) w.resize(b, z);
}
// in the "pure" form, the adjacent vertices are internaly spaced by 2...
/** in the "pure" form, the adjacent vertices are internaly spaced by 2 */
const int FULLSTEP = 2;
// ... to make space for the additional vertices which are added in the bitruncated version
/** to make space for the additional vertices which are added in the bitruncated version */
const int HALFSTEP = 1;
// with variations, the connections of the vertex at coordinate v+FULLSTEP mirror the connections
// of the vertex at coordinate v. Therefore, the period of our construction is actually 2*FULLSTEP.
/** with variations, the connections of the vertex at coordinate v+FULLSTEP mirror the connections
* of the vertex at coordinate v. Therefore, the period of our construction is actually 2*FULLSTEP. */
const int PERIOD = 2 * FULLSTEP;
struct crystal_structure {
@ -347,19 +351,6 @@ int fiftyrule(coord c) {
if(res[index] == -1) exit(1);
return res[index];
/*
int res = 0;
int d = (c[0]&1) + 2 * (c[1]&1) + 4 * (c[2]&1) + 8 * (c[3]&1);
if(d == 0) res = 0;
else if(d == 3 || d == 12) res = 2;
else if(d == 6 || d == 9) res = 4;
else return -1;
bool odd = (c[0]^c[1]^c[2]^c[3])&2;
if(odd)
res ^= 32;
// the '1' bit set by hand
*/
}
bool is_bi(crystal_structure& cs, coord co);

View File

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

View File

@ -1,18 +1,9 @@
// Hyperbolic Rogue -- dialogs
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/* Missing.
#if ISMOBILE==0
dialog::addItemHelp(16, XLAT("use Shift to decrease and Ctrl to fine tune "));
dialog::addItemHelp(17, XLAT("(e.g. Shift+Ctrl+Z)"));
#endif
if(xuni == 'i') {
}
*/
/** \file dialogs.cpp
* \brief Implementation of various generic dialogs and elements of dialog windows
*/
namespace hr {

View File

@ -1,8 +1,10 @@
// implementation of the rendering queue
// Hyperbolic Rogue -- rendering
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file drawing.cpp
* \brief Rendering shapes (dqi_draw), queue of shapes to render (ptds), etc.
*/
namespace hr {
#if HDR
@ -110,8 +112,6 @@ bool fatborder;
EX color_t poly_outline;
// #define STLSORT
EX vector<unique_ptr<drawqueueitem>> ptds;
#if CAP_GL

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- Euclidean geometry, including 2D, 3D, and quotient spaces
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- Euclidean geometry
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file euclid.cpp
* \brief Euclidean geometry, including 2D, 3D, and quotient spaces
*/
namespace hr {

View File

@ -1,5 +1,12 @@
// HyperRogue -- expansion_analyzer
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- expansion analyzer
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file expansion.cpp
* \brief exponential growth of hyperbolic geometries
*
* Calculations related to this exponential growth.
* Screens which display this exponential growth (e.g. 'size of the world' in geometry experiments) are also implemented here.
*/
namespace hr {

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
/** \file fieldpattern.cpp
* \brief Field Quotient geometry
*/
#if CAP_FIELD
namespace hr {

View File

@ -1,26 +1,10 @@
// Hyperbolic Rogue
// implementation of various simple flags for lands, items, monsters, and walls
// Hyperbolic Rogue - Flags
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/*
rewritten
*/
// itemclass
// slimegroup (wall)
/*
it == itOrbLove ? shLoveRing :
isRangedOrb(it) ? shTargetRing :
isOffensiveOrb(it) ? shSawRing :
isFriendOrb(it) ? shPeaceRing :
isUtilityOrb(it) ? shGearRing :
isDirectionalOrb(it) ? shSpearRing :
among(it, itOrb37, itOrbGravity) ? shHeptaRing :
shRing;
*/
/** \file flags.cpp
* \brief Implementation of various simple flags for lands, items, monsters, and walls.
*/
namespace hr {

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

134
game.cpp
View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue
// main game routines: movement etc.
// Hyperbolic Rogue - Game routines
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file game.cpp
* \brief Routines for game itself: movement of PC and monsters, basic mechanics, etc.
*/
namespace hr {
@ -78,7 +80,7 @@ EX bool canmove = true;
int sagephase = 0;
// number of Grails collected, to show you as a knight
/** number of Grails collected, to show you as a knight */
int knighted = 0;
bool usedSafety = false;
@ -87,8 +89,10 @@ int safetyseed;
int showid = 0;
/** last move was invisible */
EX bool invismove = false;
EX bool invisfish = false; // last move was invisible [due to Fish]
/** last move was invisible due to Orb of Fish (thus Fish still see you)*/
EX bool invisfish = false;
int noiseuntil; // noise until the given turn
@ -104,69 +108,86 @@ bool landvisited[landtypes];
bool eq(short a, short b) { return a==b; }
// game state
/** for treasures, the number collected; for orbs, the number of charges */
EX array<int, ittypes> items;
/** how many instances of each monster type has been killed */
EX array<int, motypes> kills;
EX int explore[10], exploreland[10][landtypes], landcount[landtypes];
EX map<modecode_t, array<int, ittypes> > hiitems;
bool orbused[ittypes], lastorbused[ittypes];
EX bool playermoved = true; // center on the PC?
EX bool flipplayer = true; // flip the player image after move, do not flip after attack
EX int cheater = 0; // did the player cheat?
/** should we center the screen on the PC? */
EX bool playermoved = true;
/** if false, make the PC look in direction cwt.spin (after attack); otherwise, make them look the other direction (after move) */
EX bool flipplayer = true;
/** did the player cheat? how many times? */
EX int cheater = 0;
int anthraxBonus = 0; // for using Safety in tactical Camelot
/** this value is used when using Orb of Safety in the Camelot in Pure Tactics Mode */
int anthraxBonus = 0;
EX vector<cell*> dcal; // queue for cpdist
vector<cell*> pathq; // queue for pathdist
/** the list of all nearby cells, according to cpdist */
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)
vector<cell*> targets; // list of monster targets
/** list of monsters to move (pathq restriced to monsters) */
vector<cell*> pathqm;
// 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;
/** temporary changes during bfs */
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;
// additional direction information for BFS algorithms
// it remembers from where we have got to this location
// the opposite cell will be added to the queue first,
// which helps the AI
/** monsters to move, ordered by the number of possible good moves */
vector<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 bool singleused() { return !(shmup::on || multi::players > 1); }
// the main random number generator for the game
// all the random calls related to the game mechanics (land generation, AI...) should use hrngen
// random calls not related to the game mechanics (graphical effects) should not use hrngen
// this ensures that the game should unfold exactly the same if given the same seed and the same input
/** the main random number generator for the game
* all the random calls related to the game mechanics (land generation, AI...) should use hrngen
* random calls not related to the game mechanics (graphical effects) should not use hrngen
* this ensures that the game should unfold exactly the same if given the same seed and the same input
*/
std::mt19937 hrngen;
/** initialize hrngen @see hrngen */
EX void shrand(int i) {
hrngen.seed(i);
}
/** generate a large number with hrngen */
EX int hrandpos() { return hrngen() & HRANDMAX; }
// using our own implementations rather than ones from <random>,
// to make sure that they return the same values on different compilers
/** A random integer from [0..i), generated from hrngen.
* We are using our own implementations rather than ones from <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) {
unsigned d = hrngen() - hrngen.min();
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)]); }
#endif
/** Use hrngen to generate a floating point number between 0 and 1.
* @see hrngen
*/
EX ld hrandf() {
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() {
std::mt19937 r2 = hrngen;
return r2() & HRANDMAX;
@ -1059,7 +1087,7 @@ EX int realstuntime(cell *c) {
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) {
if(isAnyIvy(w->monst)) {
int lim = 0;
@ -2929,12 +2957,14 @@ EX void buildAirmap() {
sort(airmap.begin(), airmap.end());
}
/** current state of the rose scent
* rosemap[c] &3 can be:
* 0 - wave not reached
* 1 - wave expanding
* 2 - wave phase 1
* 3 - wave phase 2
*/
map<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) {
if(!(havewhat&HF_ROSE)) return 0;
@ -3126,7 +3156,7 @@ EX void addButterfly(cell *c) {
butterflies.push_back(make_pair(c, 0));
}
// calculate cpdist, 'have' flags, and do general fixings
/** calculate cpdist, 'have' flags, and do general fixings */
EX void bfs() {
calcTidalPhase();
@ -3541,9 +3571,10 @@ EX void activateArrowTrap(cell *c) {
}
// effect of moving monster m from cf to ct
// this is called from moveMonster, or separately from moveIvy/moveWorm,
// or when a dead bird falls (then m == moDeadBird)
/** effect of moving monster m from cf to ct
* this is called from moveMonster, or separately from moveIvy/moveWorm,
* or when a dead bird falls (then m == moDeadBird)
*/
EX void moveEffect(cell *ct, cell *cf, eMonster m, int direction_hint) {
@ -4008,7 +4039,10 @@ EX int landheattype(cell *c) {
return 1;
}
// move value
/** for the monster at c1, evaluation of the move to c2
* @param mf what moves are allowed
*/
EX int moveval(cell *c1, cell *c2, int d, flagtype mf) {
if(!c2) return -5000;
@ -5539,12 +5573,11 @@ EX bool cellDangerous(cell *c) {
return cellUnstableOrChasm(c) || isFire(c) || c->wall == waClosedGate;
}
// negative: die, attack friend, stay against rose, hit a wall, move against rose, hit the player
EX bool hasPrincessWeapon(eMonster m) {
return m == moPalace || m == moFatGuard;
}
/** for an ally m at c, evaluate staying in place */
EX int stayvalue(eMonster m, cell *c) {
if(!passable_for(c->monst, c, NULL, P_MONSTER | P_MIRROR))
return -1501;
@ -5554,7 +5587,7 @@ EX int stayvalue(eMonster m, cell *c) {
return 100;
}
// friendly version of moveval
/** for an ally m at c, evaluate moving to c2 */
EX int movevalue(eMonster m, cell *c, cell *c2, flagtype flags) {
int val = 0;
@ -5758,9 +5791,10 @@ EX int nearestPathPlayer(cell *c) {
return 0;
}
// note: butterflies don't use moveNormal for two reasons:
// 1) to make sure that they move AFTER bulls
// 2) to make sure that they move offscreen
/** note: butterflies don't use moveNormal for two reasons:
* 1) to make sure that they move AFTER bulls
* 2) to make sure that they move offscreen
*/
EX void moveButterflies() {
int j = 0;
for(int i=0; i<isize(butterflies); i++) {

View File

@ -1,7 +1,11 @@
// 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 {

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue
// geometrical constants
// Hyperbolic Rogue -- basic geometry
// 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 {
@ -76,35 +78,51 @@ struct escher_floorshape : floorshape {
int shapeid0, shapeid1, noftype, shapeid2;
ld scale;
};
/** basic geometry parameters */
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
// hexf: distance from heptagon center to small heptagon vertex
// hcrossf: distance from heptagon center to big heptagon vertex
// crossf: distance from heptagon center to adjacent cell center (either hcrossf or tessf)
// hexhexdist: distance between adjacent hexagon vertices
// hexvdist: distance between hexagon vertex and hexagon center
// hepvdist: distance between heptagon vertex and hexagon center (either hcrossf or something else)
// rhexf: distance from heptagon center to heptagon vertex (either hexf or hcrossf)
ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
/** distance from heptagon center to adjacent cell center (either hcrossf or tessf) */
ld crossf;
/** distance from heptagon center to small heptagon vertex */
ld hexf;
/** distance from heptagon center to big heptagon vertex */
ld hcrossf;
/** 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 invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
int base_distlimit;
/* shape parameters */
/** size of the Sword (from Orb of the Sword), used in the shmup mode */
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 hexshift;
ld asteroid_size[8];
ld wormscale;
ld tentacle_length;
/* 3D parameters */
/** various parameters related to the 3D view */
ld INFDEEP, BOTTOM, HELLSPIKE, LAKE, WALL, FLOOR, STUFF,
SLEV[4], FLATEYE,
LEG0, LEG1, LEG, LEG3, GROIN, GROIN1, GHOST,
@ -360,14 +378,12 @@ hpcshape
};
#endif
// the results are:
// hexf = 0.378077 hcrossf = 0.620672 tessf = 1.090550
// hexhexdist = 0.566256
/** values of hcrossf and hexf for the standard geometry. Since polygons are
* usually drawn in this geometry, the scale in other geometries is usually
* based on comparing these values to the values in the other geometry.
*/
ld hcrossf7 = 0.620672;
ld hexf7 = 0.378077;
// the distance between two hexagon centers
ld hcrossf7 = 0.620672, hexf7 = 0.378077, tessf7 = 1.090550, hexhexdist7 = 0.566256;
bool scale_used() { return (shmup::on && geometry == gNormal && BITRUNCATED) ? (cheater || autocheat) : true; }

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue
// advanced geometry
// Hyperbolic Rogue -- 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 {
@ -148,16 +150,6 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
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;
}

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

View File

@ -1,8 +1,9 @@
// Hyperbolic Rogue -- main graphics file
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// basic graphics:
/** \file graph.cpp
* \brief Drawing cells, monsters, items, etc.
*/
namespace hr {

View File

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

View File

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

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- heads-up display
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- Heads-Up Display
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file hud.cpp
* \brief Heads-Up display: items collected, monsters killed, radar, etc.
*/
namespace hr {

View File

@ -1,5 +1,5 @@
// Hyperbolic Rogue
// Copyright (C) 2011-2018 Zeno Rogue
// Copyright (C) 2011-2019 Zeno Rogue
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -15,6 +15,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/** \file hyper.cpp
* \brief the hyper_main function
*/
#include "init.cpp"
#if CU_HYPER

394
hyper.h
View File

@ -1,5 +1,13 @@
// This is the main header file of HyperRogue. Mostly everything is dumped here.
// It is quite chaotic.
// Hyperbolic Rogue -- main header file
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file Hyper.h
* \brief The main header file of HyperRogue
*
* Contains general utility macros, various value macros, using clauses for standard library functions,
* implementation of the basic connection_table, walker, cell and heptagon classes,
* and general routines which did not fit elsewhere
*/
// version numbers
#define VER "11.1i"
@ -320,332 +328,8 @@ extern videopar vid;
#define self (*this)
extern int cellcount, heptacount;
// cell information for the game
struct gcell {
#if CAP_BITFIELD
// main fields
eLand land : 8;
eWall wall : 8;
eMonster monst : 8;
eItem item : 8;
// if this is a barrier, what lands on are on the sides?
eLand barleft : 8, barright : 8;
unsigned ligon : 1; // is it sparkling with lightning?
signed
mpdist : 7,
pathdist : 8, // player distance wrt usual movement
cpdist : 8; // current/minimum player distance
unsigned
mondir : 8, // monster direction, for multi-tile monsters and graphics
bardir : 8, // barrier direction
stuntime : 8, // stun time left (for Palace Guards and Skeletons)
hitpoints : 7, // hitpoints left (for Palace Guards, also reused as cpid for mirrors)
monmirror : 1; // monster mirroring state for nonorientable geometries
unsigned landflags : 8; // extra flags for land
#else
eLand land;
eWall wall;
eMonster monst;
eItem item;
eLand barleft, barright;
bool ligon, monmirror;
signed char pathdist, cpdist, mpdist;
unsigned char mondir, bardir, stuntime, hitpoints;
unsigned char landflags;
#endif
// 'landparam' is used for:
// heat in Icy/Cocytus;
// heat in Dry (0..10);
// CR2 structure;
// hive Weird Rock color / pheromones;
// Ocean/coast depth;
// Bomberbird Egg hatch time / mine marking;
// number of Ancient Jewelry;
// improved tracking in Trollheim
union {
int32_t landpar;
unsigned int landpar_color;
float heat;
char bytes[4];
struct fieldinfo {
uint16_t fieldval;
unsigned rval : 4;
unsigned flowerdist : 4;
unsigned walldist : 4;
unsigned walldist2 : 4;
} fi;
} LHU;
#ifdef CELLID
int cellid;
#endif
gcell() { cellcount++;
#ifdef CELLID
cellid = cellcount;
#endif
}
~gcell() { cellcount--; }
};
#define landparam LHU.landpar
#define landparam_color LHU.landpar_color
#define fval LHU.fi.fieldval
#define NODIR 126
#define NOBARRIERS 127
#define MODFIXER (2*10090080*17)
#define MAX_EDGE 18
template<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 big_unlock (inv::on && !chaosmode)
@ -689,7 +373,7 @@ struct movedir {
#define MD_UNDECIDED (-3)
#define MD_USE_ORB (-4)
int subdir; // for normal movement (0+): turn left or right
cell *tgt; // for MD_USE_ORB: target cell
struct cell *tgt; // for MD_USE_ORB: target cell
};
// shmup
@ -704,7 +388,7 @@ typedef function<bool()> bool_reaction_t;
#define HELPFUN(x) (help_delegate = x, "HELPFUN")
typedef function<int(cell*)> cellfunction;
typedef function<int(struct cell*)> cellfunction;
// passable flags
@ -968,10 +652,6 @@ namespace scores { void load(); }
namespace leader { void showMenu(); void handleKey(int sym, int uni); }
#endif
namespace mirror {
cellwalker reflect(const cellwalker& cw);
}
struct hint {
time_t last;
function<bool()> usable;
@ -1026,56 +706,6 @@ const eLand NOWALLSEP_USED = laWhirlpool;
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
#define BEHIND_LIMIT 1e-6

View File

@ -1,6 +1,13 @@
// Hyperbolic Rogue
// This file contains hyperbolic points and matrices.
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- basic computations in non-Euclidean geometry
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file hyperpoint.cpp
* \brief basic computations in non-Euclidean geometry
*
* This implements hyperpoint (a point in non-Euclidean space), transmatrix (a transformation matrix),
* and various basic routines related to them: rotations, translations, inverses and determinants, etc.
* For nonisotropic geometries, it rather refers to nonisotropic.cpp.
*/
namespace hr {

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- hyperbolic graphics
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file hypgraph.cpp
* \brief mapping hyperpoints to the screen, and related functions
*/
namespace hr {

View File

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

View File

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

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 {
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 {

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- land availability
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// land statistics and flags
/** \file landlock.cpp
* \brief unlocking lands, which lands could be found beyond the wall, validity of various lands depending on the settings
*/
namespace hr {
@ -14,7 +16,7 @@ EX bool nodisplay(eMonster m) {
m == moIvyDead;
}
// returns: 2 = treasure increaser, 1 = just appears, 0 = does not appear
/** returns: 2 = treasure increaser, 1 = just appears, 0 = does not appear */
EX int isNative(eLand l, eMonster m) {
switch(l) {
#define LAND(a,b,c,d,e,f,g) case c:

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue language support
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Hyperbolic Rogue -- language support
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file language.cpp
* \brief localization support
*/
// #define CHECKTRANS
@ -24,28 +28,6 @@ struct stringpar {
};
#endif
/*
string dnameofEnum(eItem i) {
FILE *f = fopen("classes.cpp", "rt");
while(!feof(f)) {
char buf[256];
fgets(buf, 256, f);
if(strstr(buf, "eItem")) {
string ret;
int qty = i;
while(qty > -1) {
char c = fgetc(f);
if(c == ' ' || c == '\n' || c == '\r') continue;
else if(c == ',') qty--;
else if(!qty) ret += c;
}
return ret;
}
}
return "?";
}
*/
void rep(string& pattern, string what, string to) {
while(true) {
size_t at = pattern.find(what);
@ -332,6 +314,7 @@ void parrep(string& x, string w, stringpar p) {
void postrep(string& s) {
}
/** translate the string @x */
EX string XLAT(string x) {
basicrep(x);
postrep(x);

View File

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

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 <iostream>
#include <fstream>

View File

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

View File

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

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

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

View File

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

View File

@ -1,11 +1,15 @@
// Hyperbolic Rogue -- built-in font
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file nofont.cpp
* \brief built-in font (used e.g. in the web version)
*/
namespace hr {
#if CAP_TABFONT
// compile with -DCAP_CREATEFONT=1 to generate this table
// this variant has been created for non-translated HyperRogue
/** compile with -DCAP_CREATEFONT=1 to generate this table
* this variant has been created for non-translated HyperRogue */
unsigned char fonttable[] = {
43,13,0,255,0,255,0,49,
43,16,0,133,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,243,255,5,95,0,9,223,255,5,74,0,9,191,255,5,42,0,9,159,255,5,11,0,9,128,255,4,235,0,10,96,255,4,203,0,10,64,255,4,171,0,10,32,255,4,139,0,58,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,9,244,255,5,96,0,148,

View File

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

View File

@ -1,5 +1,9 @@
// Hyperbolic Rogue -- orb generation routines
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file orbgen.cpp
* \brief Orb generation: which orbs in which lands, functions generating prize/local orbs, etc.
*/
namespace hr {
// orbgen flags

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

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 {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- Kite-and-dart tiling
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file penrose.cpp
* \brief Kite-and-dart tiling, both in R^2 and H^3
*/
namespace hr {
EX namespace kite {

View File

@ -1,8 +1,10 @@
// HyperRogue, shapes used for the vector graphics
// Hyperbolic Rogue -- shapes used for the vector graphics
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file polygons.cpp
* \brief shapes used for the vector graphics, mostly hand-drawn (the vector data is here), some procedurally generated
*/
#if CAP_SHAPES
namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- the mission screen
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file quit.cpp
* \brief the mission screen, and routines related to it
*/
namespace hr {
EX bool quitsaves() { return (items[itOrbSafety] && CAP_SAVE && !archimedean); }

View File

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

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

View File

@ -1,8 +1,14 @@
// Hyperbolic Rogue -- regular honeycombs
// works with spherical and hyperbolic ones -- Euclidean cubic tiling implemented in euclid.cpp
// hyperbolic honeycombs rely on binary:: to deal with floating point errors (just like archimedean)
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file reg3.cpp
* \brief regular honeycombs
*
* works with spherical and hyperbolic ones -- Euclidean cubic tiling implemented in euclid.cpp
* includes non-quotient spaces as well as field quotient and elliptic spaces
* hyperbolic honeycombs rely on binary:: to deal with floating point errors (just like archimedean)
*/
namespace hr {
#if MAXMDIM >= 4
transmatrix cpush(int cid, ld alpha);

View File

@ -1,9 +1,13 @@
// Hyperbolic Rogue
// This file implements the 'renderbuffer', which is an object
// that can be used to draw a HyperRogue screen into,
// and then either used as a OpenGL texture, or saved.
// Hyperbolic Rogue -- drawing screens to buffers
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file renderbuffer.cpp
* \brief drawing screens to buffers
*
* This file implements the 'renderbuffer', which is an object
* that can be used to draw a HyperRogue screen into,
* and then either used as a OpenGL texture (e.g. in the Hypersian Rug mode), or saved.
*/
namespace hr {

View File

@ -1,7 +1,11 @@
// Hyperbolic Rogue
// Hyperbolic Rogue - Hypersian Rug mode
// Copyright (C) 2011-2016 Zeno Rogue, see 'hyper.cpp' for details
// implementation of the Hypersian Rug mode
/** \file rug.cpp
* \brief Hypersian Rug mode
*
* See also surface.cpp for constant curvature surfaces.
*/
namespace hr {

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
/** \file memory.cpp
* \brief memory saving: memory saving mode, memory warnings, etc.
*/
namespace hr {
#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
/** \file scores.cpp
* \brief local highscore lists
*/
#if CAP_SAVE
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
/** \file screenshot.cpp
* \brief screenshots, SVG format, animations, start animations
*/
namespace hr {
bool hide_hud = true;

View File

@ -1,6 +1,12 @@
// Hyperbolic Rogue -- basic GL transformations
// If CAP_SHADER is 0, OpenGL 1.0 is used.
// If CAP_SHADER is 1, GLSL is used.
// Hyperbolic Rogue -- low-level OpenGL routines
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file shaders.cpp
* \brief low-level OpenGL routines
*
* If CAP_SHADER is 0, OpenGL 1.0 is used.
* If CAP_SHADER is 1, we are using GLSL shaders.
*/
namespace hr {

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
// implementation of the shoot'em up mode
/** \file shmup.cpp
* \brief shoot'em up mode
*/
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
/** \file sound.cpp
* \brief sound effects and music
*/
namespace hr {
EX const char *musicfile = "";

View File

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

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
// This file implements the surfaces of constant negative curvature
// See http://webmath2.unito.it/paginepersonali/sergio.console/CurveSuperfici/AG15.pdf for a nice reference
/** \file surface.cpp
* \brief surfaces of constant negative curvature
*
* See http://webmath2.unito.it/paginepersonali/sergio.console/CurveSuperfici/AG15.pdf for a nice reference
*/
#if CAP_SURFACE
namespace hr {

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- set compiler flags, and include all the required system headers
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file sysconfig.h
* \brief set compiler flags, and include all the required system headers
*/
#ifdef MAC
#define ISMAC 1
#endif

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

View File

@ -1,6 +1,10 @@
// Hyperbolic Rogue -- texture mode
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file textures.cpp
* \brief texture mode, also the basic definitions of textures, used in 3D mode
*/
#if CAP_TEXTURE
namespace hr {

View File

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

View File

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

View File

@ -1,7 +1,9 @@
// Hyperbolic Rogue
// Hyperbolic Rogue -- basic utility functions
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
// basic utility functions
/** \file util.cpp
* \brief basic utility functions: maths, parsing expressions
*/
namespace hr {

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