1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

clearing:: fixed some bugs when reached too far into the center

This commit is contained in:
Zeno Rogue 2020-03-01 02:35:19 +01:00
parent 62734bbfc5
commit 70d7fde8d4
4 changed files with 28 additions and 11 deletions

View File

@ -914,7 +914,7 @@ EX namespace clearing {
// printf("R %4d C %4d\n", celldistAlt(bd.root), celldistAlt(c));
if(celldistAlt(c) > celldistAlt(bd.root)) {
stepcount++;
if(stepcount > 1000) {
if(stepcount > 100000000) {
printf("buggy #1\n");
return;
}
@ -933,7 +933,7 @@ EX namespace clearing {
}
else {
bd.dist--;
if(bd.dist < -1000) {
if(bd.dist < -100000000) {
for(int i=0; i<steps; i++)
onpath[i]->item = itBuggy;
for(int i=0; i<(int) rpath.size(); i++)

View File

@ -237,7 +237,7 @@ heptagon *hrmap_standard::create_step(heptagon *h, int d) {
pard = 3; // to do: randomize
else if(S3 == 4)
pard = 3;
buildHeptagon(h, 0, h->distance < -10000 ? hsOrigin : hsA, pard);
buildHeptagon(h, 0, h->distance < -32500 ? hsOrigin : hsA, pard);
}
if(h->move(d)) return h->move(d);
if(h->s == hsOrigin) {

10
hud.cpp
View File

@ -255,14 +255,8 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int
buttonsize / 3;
if(id == moMutant + ittypes && clearing::imputed.nonzero()) {
ld d = qty + clearing::imputed.approx_ld();
if(d < 100000) str = its(int(d));
else {
int digits = 0;
while(d >= 10) digits++, d /= 10;
str = its(int(d*100)) + "E" + its(digits);
str.insert(1, ".");
}
bignum bn = clearing::imputed + qty;
str = short_form(bn);
bsize = buttonsize / 4;
}

View File

@ -514,6 +514,29 @@ string bignum::get_str(int max_length) const {
return ret;
}
EX string short_form(bignum b) {
if(b < 0) return "-" + short_form(0-b);
else if(b < 100000) return its(b.approx_int());
else {
long long val;
int q;
if(isize(b.digits) >= 2) {
q = max(isize(b.digits) - 2, 0);
val = b.digits[q] + (long long)(bignum::BASE) * b.digits[q+1];
}
else {
q = 0;
val = b.digits[0];
}
int digits = q * 9;
while(val >= 1000) { val /= 10; digits++; }
string str = its(val) + "E" + its(digits + 2);
str.insert(1, ".");
return str;
}
}
bignum::bignum(ld d) {
if(d == 0) return;
int n = 1;