From dbcd71cb452682d285b93a14439aa27e3017d8f8 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 27 Dec 2017 11:57:30 +0100 Subject: [PATCH] used enum for geometry classes; moved from hyper.h to init.cpp --- classes.cpp | 28 ++++++++++++++-------------- classes.h | 4 +++- hyper.h | 9 --------- init.cpp | 11 +++++++++++ 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/classes.cpp b/classes.cpp index e68bdee0..0f4e16c3 100644 --- a/classes.cpp +++ b/classes.cpp @@ -1607,19 +1607,19 @@ vector randlands = { }; geometryinfo ginf[gGUARD] = { - {"standard", "HR", 7, 3, 0, 0, {{7, 5}}}, - {"Euclidean", "euclid", 6, 3, 0, 1, {{7, FORBIDDEN}}}, - {"spherical", "sphere", 5, 3, 0, 2, {{SEE_ALL, SEE_ALL}}}, - {"elliptic", "elliptic", 5, 3, qELLIP, 2, {{SEE_ALL, SEE_ALL}}}, - {"Zebra quotient", "Zebra", 7, 3, qZEBRA, 0, {{7, 5}}}, - {"field quotient", "field", 7, 3, qFIELD, 0, {{7, 5}}}, - {"torus", "torus", 6, 3, qTORUS, 1, {{7, FORBIDDEN}}}, - {"octagons", "oct", 8, 3, 0, 0, {{6, 4}}}, - {"four pentagons", "4x5", 5, 4, 0, 0, {{6, 4}}}, - {"four hexagons", "4x6", 6, 4, 0, 0, {{5, 3}}}, - {"four heptagons", "4x7", 7, 4, 0, 0, {{4, 3}}}, - {"cube", "3x4", 4, 3, 0, 2, {{SEE_ALL, SEE_ALL}}}, - {"tetrahedron (buggy)", "3x3", 3, 3, 0, 2, {{SEE_ALL, SEE_ALL}}}, - {"square grid", "4x4", 4, 4, 0, 1, {{7, 7}}} + {"standard", "HR", 7, 3, 0, gcHyperbolic, {{7, 5}}}, + {"Euclidean", "euclid", 6, 3, 0, gcEuclid, {{7, FORBIDDEN}}}, + {"spherical", "sphere", 5, 3, 0, gcSphere, {{SEE_ALL, SEE_ALL}}}, + {"elliptic", "elliptic", 5, 3, qELLIP, gcSphere, {{SEE_ALL, SEE_ALL}}}, + {"Zebra quotient", "Zebra", 7, 3, qZEBRA, gcHyperbolic, {{7, 5}}}, + {"field quotient", "field", 7, 3, qFIELD, gcHyperbolic, {{7, 5}}}, + {"torus", "torus", 6, 3, qTORUS, gcEuclid, {{7, FORBIDDEN}}}, + {"octagons", "oct", 8, 3, 0, gcHyperbolic, {{6, 4}}}, + {"four pentagons", "4x5", 5, 4, 0, gcHyperbolic, {{6, 4}}}, + {"four hexagons", "4x6", 6, 4, 0, gcHyperbolic, {{5, 3}}}, + {"four heptagons", "4x7", 7, 4, 0, gcHyperbolic, {{4, 3}}}, + {"cube", "3x4", 4, 3, 0, gcSphere, {{SEE_ALL, SEE_ALL}}}, + {"tetrahedron (buggy)", "3x3", 3, 3, 0, gcSphere, {{SEE_ALL, SEE_ALL}}}, + {"square grid", "4x4", 4, 4, 0, gcEuclid, {{7, 7}}} }; diff --git a/classes.h b/classes.h index e6b837dd..52ae8d0c 100644 --- a/classes.h +++ b/classes.h @@ -189,13 +189,15 @@ enum eLand { laNone, laBarrier, laCrossroads, laDesert, laIce, laCaves, laJungle enum eGeometry {gNormal, gEuclid, gSphere, gElliptic, gQuotient, gQuotient2, gTorus, gOctagon, g45, g46, g47, gSmallSphere, gTinySphere, gEuclidSquare, gGUARD}; +enum eGeometryClass { gcHyperbolic, gcEuclid, gcSphere }; + struct geometryinfo { const char* name; const char* shortname; int sides; int vertex; int quotientstyle; - int cclass; // 0-hyperbolic, 1-Euclidean, 2-spherical + eGeometryClass cclass; array distlimit; // truncated, non-truncated }; diff --git a/hyper.h b/hyper.h index 1e29e555..5201126a 100644 --- a/hyper.h +++ b/hyper.h @@ -2077,15 +2077,6 @@ int celldistAlt(cell *c); int celldist(cell *c); int getHemisphere(cell *c, int which); -#define euclid (ginf[geometry].cclass == 1) -#define sphere (ginf[geometry].cclass == 2) -#define elliptic (ginf[geometry].quotientstyle & 4) -#define quotient (ginf[geometry].quotientstyle & 3) -#define torus (ginf[geometry].quotientstyle & 8) -#define doall (ginf[geometry].quotientstyle) -#define smallbounded (sphere || quotient == 1 || torus) -#define bounded (sphere || quotient || torus) - namespace tactic { extern bool on; extern bool trailer; diff --git a/init.cpp b/init.cpp index e9af3446..7d3e7d96 100644 --- a/init.cpp +++ b/init.cpp @@ -356,6 +356,17 @@ void addMessage(string s, char spamtype = 0); #define weirdhyperbolic (S7 > 7 || S3 > 3) #define stdhyperbolic (S7 == 7 && S3 == 3) +#define cgclass (ginf[geometry].cclass) +#define euclid (cgclass == gcEuclid) +#define sphere (cgclass == gcSphere) +#define hyperbolic (cgclass == gcHyperbolic) +#define elliptic (ginf[geometry].quotientstyle & qELLIP) +#define quotient (ginf[geometry].quotientstyle & (qZEBRA | qFIELD)) +#define torus (ginf[geometry].quotientstyle & qTORUS) +#define doall (ginf[geometry].quotientstyle) +#define smallbounded (sphere || (quotient & qZEBRA) || torus) +#define bounded (sphere || quotient || torus) + #define a4 (S3 == 4) #define a45 (S3 == 4 && S7 == 5) #define a46 (S3 == 4 && S7 == 6)