1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-22 09:27:40 +00:00

Merge branch 'master' into mymake

This commit is contained in:
Zeno Rogue
2020-05-15 12:14:04 +02:00
committed by GitHub
108 changed files with 6543 additions and 4322 deletions

122
hyper.h
View File

@@ -13,8 +13,8 @@
#define _HYPER_H_
// version numbers
#define VER "11.3i"
#define VERNUM_HEX 0xA829
#define VER "11.3l"
#define VERNUM_HEX 0xA82C
#include "sysconfig.h"
@@ -142,6 +142,7 @@ void addMessage(string s, char spamtype = 0);
#define sl2 (cgclass == gcSL2)
#define prod (cgclass == gcProduct)
#define hybri (cgflags & qHYBRID)
#define rotspace (geometry == gRotSpace)
#define hyperbolic (cgclass == gcHyperbolic)
#define nonisotropic (among(cgclass, gcSolNIH, gcNil, gcSL2))
#define translatable (euclid || nonisotropic)
@@ -228,9 +229,46 @@ enum eStereo { sOFF, sAnaglyph, sLR, sODS };
enum eModel : int;
/** configuration of the projection */
struct projection_configuration {
eModel model; /**< which projection, see classes.cpp */
ld xposition, yposition; /**< move the center to another position */
ld scale, alpha, camera_angle, fisheye_param, twopoint_param, stretch, ballangle, ballproj, euclid_to_sphere;
ld clip_min, clip_max;
ld model_orientation, halfplane_scale, model_orientation_yz;
ld collignon_parameter;
bool collignon_reflected;
string formula;
eModel basic_model;
ld top_z;
ld model_transition;
ld spiral_angle;
ld spiral_x;
ld spiral_y;
bool use_atan;
ld right_spiral_multiplier;
ld any_spiral_multiplier;
ld sphere_spiral_multiplier;
ld spiral_cone;
ld skiprope;
ld product_z_scale;
projection_configuration() {
formula = "z^2"; top_z = 5; model_transition = 1; spiral_angle = 70; spiral_x = 10; spiral_y = 7;
right_spiral_multiplier = 1;
any_spiral_multiplier = 1;
sphere_spiral_multiplier = 2;
spiral_cone = 360;
use_atan = false;
product_z_scale = 1;
}
};
struct videopar {
ld scale, alpha, sspeed, mspeed, yshift, camera_angle;
ld ballangle, ballproj, euclid_to_sphere, twopoint_param, fisheye_param, stretch, binary_width, fixed_facing_dir;
projection_configuration projection_config, rug_config;
ld yshift;
ld sspeed, mspeed;
ld binary_width, fixed_facing_dir;
int mobilecompasssize;
int radarsize; // radar for 3D geometries
ld radarrange;
@@ -251,8 +289,6 @@ struct videopar {
int xscr, yscr;
ld xposition, yposition;
bool grid;
bool particles;
@@ -304,8 +340,6 @@ struct videopar {
int cells_drawn_limit;
int cells_generated_limit; // limit on cells generated per frame
ld skiprope;
eStereo stereo_mode;
ld ipd;
ld lr_eyewidth, anaglyph_eyewidth;
@@ -319,7 +353,6 @@ struct videopar {
ld depth; // world level below the plane
ld camera; // camera level above the plane
ld wall_height, creature_scale, height_width;
eModel vpmodel;
ld lake_top, lake_bottom;
ld rock_wall_ratio;
ld human_wall_ratio;
@@ -331,7 +364,6 @@ struct videopar {
ld eye;
bool auto_eye;
ld collignon_parameter; bool collignon_reflected;
ld plevel_factor;
bool bubbles_special, bubbles_threshold, bubbles_all;
int joysmooth;
@@ -341,7 +373,7 @@ extern videopar vid;
#define WDIM cginf.g.gameplay_dimension
#define GDIM cginf.g.graphical_dimension
#define MDIM cginf.g.homogeneous_dimension
#define MDIM (MAXMDIM == 3 ? 3 : cginf.g.homogeneous_dimension)
#define LDIM (MDIM-1)
#define cclass g.kind
@@ -407,8 +439,41 @@ struct movedir {
// shmup
template<class T> class hookset : public map<int, function<T>> {};
typedef hookset<void()> *purehookset;
template<class T>
class hookset {
std::map<int, std::function<T>> *map_ = nullptr;
public:
template<class U>
int add(int prio, U&& hook) {
if (map_ == nullptr) map_ = new std::map<int, std::function<T>>();
while (map_->count(prio)) {
prio++;
}
map_->emplace(prio, static_cast<U&&>(hook));
return 0;
}
template<class... U>
void callhooks(U&&... args) const {
if (map_ == nullptr) return;
for (const auto& p : *map_) {
p.second(static_cast<U&&>(args)...);
}
}
template<class V, class... U>
V callhandlers(V zero, U&&... args) const {
if (map_ == nullptr) return zero;
for (const auto& p : *map_) {
auto z = p.second(static_cast<U&&>(args)...);
if (z != zero) return z;
}
return zero;
}
};
using purehookset = hookset<void()>;
static const int NOHINT = -1;
@@ -621,33 +686,24 @@ enum orbAction { roMouse, roKeyboard, roCheck, roMouseForce, roMultiCheck, roMul
#define MODELCOUNT ((int) mdGUARD)
#define pmodel (vid.vpmodel)
#define pconf vid.projection_config
#define vpconf (rug::rugged ? vid.rug_config : vid.projection_config)
#define pmodel (pconf.model)
color_t darkena(color_t c, int lev, int a);
static const int DISTANCE_UNKNOWN = 127;
#include <functional>
template<class T, class U> int addHook(hookset<T>*& m, int prio, const U& hook) {
if(!m) m = new hookset<T> ();
while(m->count(prio)) {
prio++;
}
(*m)[prio] = hook;
return 0;
template<class T, class U> int addHook(hookset<T>& m, int prio, U&& hook) {
return m.add(prio, static_cast<U&&>(hook));
}
template<class T, class... U> void callhooks(hookset<T> *h, U&&... args) {
if(h) for(auto& p: *h) p.second(std::forward<U>(args)...);
template<class T, class... U> void callhooks(const hookset<T>& h, U&&... args) {
return h.callhooks(static_cast<U&&>(args)...);
}
template<class T, class V, class... U> V callhandlers(V zero, hookset<T> *h, U&&... args) {
if(h) for(auto& p: *h) {
auto z = p.second(std::forward<U>(args)...);
if(z != zero) return z;
}
return zero;
template<class T, class V, class... U> V callhandlers(V zero, const hookset<T>& h, U&&... args) {
return h.callhandlers(zero, static_cast<U&&>(args)...);
}
string XLAT(string);
@@ -670,7 +726,7 @@ struct colortable: vector<color_t> {
namespace scores { void load(); }
#if ISMOBILE==1
#if ISMOBILE
namespace leader { void showMenu(); void handleKey(int sym, int uni); }
#endif
@@ -679,7 +735,7 @@ int textwidth(int siz, const string &str);
int gl_width(int size, const char *s);
#endif
#ifdef ISMOBILE
#if ISMOBILE
extern int andmode;
extern bool longclick;
extern bool useRangedOrb;