1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-13 20:27:10 +00:00

brief fixup

This commit is contained in:
Zeno Rogue
2020-03-27 21:54:15 +01:00
parent 6feec1307f
commit 4e1f955d67

View File

@@ -13,37 +13,37 @@ EX bool keepLightning = false;
EX bool seenSevenMines = false; EX bool seenSevenMines = false;
/** have we been warned about the Haunted Woods? */ /** \brief have we been warned about the Haunted Woods? */
EX bool hauntedWarning; EX bool hauntedWarning;
/** is the Survivalist achievement still valid? have we received it? */ /** \brief is the Survivalist achievement still valid? have we received it? */
EX bool survivalist; EX bool survivalist;
EX void fail_survivalist() { EX void fail_survivalist() {
changes.value_set(survivalist, false); changes.value_set(survivalist, false);
} }
/** last move was invisible */ /** \brief last move was invisible */
EX bool invismove = false; EX bool invismove = false;
/** last move was invisible due to Orb of Fish (thus Fish still see you)*/ /** \brief last move was invisible due to Orb of Fish (thus Fish still see you)*/
EX bool invisfish = false; EX bool invisfish = false;
/** if false, make the PC look in direction cwt.spin (after attack); otherwise, make them look the other direction (after move) */ /** \brief 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; EX bool flipplayer = true;
/** Cellwalker describing the single player. Also used temporarily in shmup and multiplayer modes. */ /** \brief Cellwalker describing the single player. Also used temporarily in shmup and multiplayer modes. */
EX cellwalker cwt; EX cellwalker cwt;
EX cell*& singlepos() { return cwt.at; } EX cell*& singlepos() { return cwt.at; }
EX inline bool singleused() { return !(shmup::on || multi::players > 1); } EX inline bool singleused() { return !(shmup::on || multi::players > 1); }
/** should we center the screen on the PC? */ /** \brief should we center the screen on the PC? */
EX bool playermoved = true; EX bool playermoved = true;
/** did the player cheat? how many times? */ /** \brief did the player cheat? how many times? */
EX int cheater = 0; EX int cheater = 0;
/** lands visited -- unblock some modes */ /** \brief lands visited -- unblock some modes */
EX bool landvisited[landtypes]; EX bool landvisited[landtypes];
EX int noiseuntil; // noise until the given turn EX int noiseuntil; // noise until the given turn
@@ -401,7 +401,8 @@ EX void copy_metadata(cell *x, const gcell *y) {
extern void playSound(cell *c, const string& fname, int vol); extern void playSound(cell *c, const string& fname, int vol);
/** A structure to keep track of changes made during the player movement. /** \brief A structure to keep track of changes made during the player movement.
*
* This is a singleton object, \link hr::changes \endlink. * This is a singleton object, \link hr::changes \endlink.
*/ */
@@ -412,7 +413,8 @@ struct changes_t {
bool checking; bool checking;
/** /**
* Start keeping track of changes, perform changes. * \brief Start keeping track of changes, perform changes.
*
* init(false) if you intend to commit the changes (if successful), or * init(false) if you intend to commit the changes (if successful), or
* init(true) if you just want to check whether the move would be successful, * init(true) if you just want to check whether the move would be successful,
* without performing it if it is. * without performing it if it is.
@@ -428,9 +430,7 @@ struct changes_t {
checking = ch; checking = ch;
} }
/** /** \brief Commit the changes. Should only be called after init(false). */
* Commit the changes. Should only be called after init(false).
*/
void commit() { void commit() {
on = false; on = false;
@@ -439,9 +439,7 @@ struct changes_t {
commits.clear(); commits.clear();
} }
/** /** \brief Rollback the changes. */
* Rollback the changes. Should only be called after init(true).
*/
void rollback(int pos = 0) { void rollback(int pos = 0) {
on = false; on = false;
@@ -453,18 +451,14 @@ struct changes_t {
commits.clear(); commits.clear();
} }
/** /** \brief The changes to cell c will be rolled back when rollback() is called. */
* The changes to cell c will be rolled back when rollback() is called.
*/
void ccell(cell *c) { void ccell(cell *c) {
if(!on) return; if(!on) return;
gcell a = *c; gcell a = *c;
rollbacks.push_back([c, a] { copy_metadata(c, &a); }); rollbacks.push_back([c, a] { copy_metadata(c, &a); });
} }
/** /** \brief Set the value of what to value. This change will be rolled back if necessary. */
* Set the value of what to value. This change will be rolled back if necessary.
*/
template<class T> void value_set(T& what, T value) { template<class T> void value_set(T& what, T value) {
if(!on) { what = value; return; } if(!on) { what = value; return; }
if(what == value) return; if(what == value) return;
@@ -473,9 +467,7 @@ struct changes_t {
what = value; what = value;
} }
/** /** \brief Add step to the value of what. This change will be rolled back if necessary. */
* Add step to the value of what. This change will be rolled back if necessary.
*/
template<class T> void value_add(T& what, T step) { template<class T> void value_add(T& what, T step) {
value_keep(what); what += step; value_keep(what); what += step;
@@ -483,9 +475,7 @@ struct changes_t {
template<class T> void value_inc(T& what) { value_add(what, 1); } template<class T> void value_inc(T& what) { value_add(what, 1); }
/** /** \brief Any change to the value of what will be rolled back if necessary. */
* Any change to the value of what will be rolled back if necessary.
*/
template<class T> void value_keep(T& what) { template<class T> void value_keep(T& what) {
if(!on) return; if(!on) return;
@@ -493,9 +483,7 @@ struct changes_t {
rollbacks.push_back([&what, old] { what = old; }); rollbacks.push_back([&what, old] { what = old; });
} }
/** /** \brief Like value_keep but for maps. */
* Like value_keep but for maps.
*/
template<class T, class U, class V> void map_value(map<T, U>& vmap, V& key) { template<class T, class U, class V> void map_value(map<T, U>& vmap, V& key) {
if(vmap.count(key)) { if(vmap.count(key)) {
@@ -507,18 +495,14 @@ struct changes_t {
} }
} }
/** /** \brief Perform the given action on commit. @see LATE */
* Perform the given action on commit. @see LATE
*/
void at_commit(reaction_t act) { void at_commit(reaction_t act) {
if(!on) act(); if(!on) act();
else commits.emplace_back(act); else commits.emplace_back(act);
} }
/** /** \brief Perform the given action on rollback. */
* Perform the given action on rollback.
*/
void at_rollback(reaction_t act) { void at_rollback(reaction_t act) {
if(on) rollbacks.emplace_back(act); if(on) rollbacks.emplace_back(act);
@@ -526,9 +510,7 @@ struct changes_t {
}; };
#endif #endif
/** /** \brief The only instance of hr::changes_t */
* The only instance of hr::changes_t
*/
EX changes_t changes; EX changes_t changes;
/** /**
@@ -539,8 +521,9 @@ bool switch_lhu_in(eLand l) {
return among(l, laBrownian, laMinefield, laTerracotta, laHive); return among(l, laBrownian, laMinefield, laTerracotta, laHive);
} }
/** /** \brief Apply the Orb of Chaos.
* Apply the Orb of Chaos. We assume that the player moves from cwt.peek, in *
* We assume that the player moves from cwt.peek, in
* in the direction given by cwt.spin. * in the direction given by cwt.spin.
*/ */
void apply_chaos() { void apply_chaos() {