mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-01 03:39:16 +00:00
3d: Euclidean uses constant COORDMAX instead of magic 1000
This commit is contained in:
parent
1a381d9e1a
commit
1eee434094
14
euclid.cpp
14
euclid.cpp
@ -471,6 +471,8 @@ namespace euclid3 {
|
|||||||
|
|
||||||
typedef long long coord;
|
typedef long long coord;
|
||||||
|
|
||||||
|
static const long long COORDMAX = (1<<16);
|
||||||
|
|
||||||
struct hrmap_euclid3 : hrmap {
|
struct hrmap_euclid3 : hrmap {
|
||||||
map<coord, heptagon*> spacemap;
|
map<coord, heptagon*> spacemap;
|
||||||
map<heptagon*, coord> ispacemap;
|
map<heptagon*, coord> ispacemap;
|
||||||
@ -502,8 +504,8 @@ namespace euclid3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
heptagon *createStep(heptagon *parent, int d) {
|
heptagon *createStep(heptagon *parent, int d) {
|
||||||
int at = ispacemap[parent];
|
coord at = ispacemap[parent];
|
||||||
coord shifttable[6] = { +1, +1000, +1000000, -1, -1000, -1000000 };
|
const coord shifttable[6] = { +1, +COORDMAX, +COORDMAX*COORDMAX, -1, -COORDMAX, -COORDMAX*COORDMAX };
|
||||||
return build(parent, d, at + shifttable[d]);
|
return build(parent, d, at + shifttable[d]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -521,10 +523,10 @@ namespace euclid3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getcoord(coord x, int a) {
|
int getcoord(coord x, int a) {
|
||||||
for(int k=0; k<a; k++) { x -= getcoord(x, 0); x /= 1000; }
|
for(int k=0; k<a; k++) { x -= getcoord(x, 0); x /= COORDMAX; }
|
||||||
x %= 1000;
|
x %= COORDMAX;
|
||||||
if(x>500) x -= 1000;
|
if(x>COORDMAX/2) x -= COORDMAX;
|
||||||
if(x<-500) x += 1000;
|
if(x<-COORDMAX/2) x += COORDMAX;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user