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

Fix freeze if Ancient Jewelry ends up on a tile with a large landparam

This commit is contained in:
Joseph C. Sible
2025-10-11 21:04:32 -04:00
parent f061dd6cf6
commit de6f84815d
3 changed files with 13 additions and 5 deletions

View File

@@ -256,8 +256,8 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int
}
else if(it == itBarrow && c) {
for(int i = 0; i<c->landparam; i++)
queuepolyat(Vit * spin(TAU * i / c->landparam) * xpush(.15 * cgi.scalefactor) * spinptick(1500, 0), *xsh, darkena(icol, 0, hidden ? 0x40 :
for(int i = 0; i<barrowCount(c); i++)
queuepolyat(Vit * spin(TAU * i / barrowCount(c)) * xpush(.15 * cgi.scalefactor) * spinptick(1500, 0), *xsh, darkena(icol, 0, hidden ? 0x40 :
(highwall(c) && wmspatial) ? 0x60 : 0xFF),
PPR::HIDDEN);
}

View File

@@ -1084,7 +1084,7 @@ EX void describeMouseover() {
if(c->item && !itemHiddenFromSight(c)) {
out += ", ";
out += XLAT1(iinf[c->item].name);
if(c->item == itBarrow) out += " (x" + its(c->landparam) + ")";
if(c->item == itBarrow) out += " (x" + its(barrowCount(c)) + ")";
#if CAP_COMPLEX2
if(c->land == laHunting) {
int i = ambush::size(c, c->item);

View File

@@ -314,7 +314,7 @@ EX bool collectItem(cell *c2, cell *last, bool telekinesis IS(false)) {
int q_el = items[itElemental];
if(c2->item == itBarrow)
for(int i=0; i<c2->landparam; i++) gainItem(c2->item);
for(int i=0; i<barrowCount(c2); i++) gainItem(c2->item);
else if(c2->item) gainItem(c2->item);
if(c2->item && items[c2->item] > q && (vid.bubbles_all || (threshold_met(items[c2->item]) > threshold_met(q) && vid.bubbles_threshold))) {
@@ -742,7 +742,7 @@ EX void collectMessage(cell *c2, eItem which) {
addMessage(XLAT("A castle in the Crossroads..."));
else if(which == itShard) ;
else {
int qty = (which == itBarrow) ? c2->landparam : 1;
int qty = (which == itBarrow) ? barrowCount(c2) : 1;
string t;
if(which == itBarrow && items[which] < 25 && items[which] + qty >= 25)
t = XLAT("Your energy swords get stronger!");
@@ -758,4 +758,12 @@ EX bool itemHiddenFromSight(cell *c) {
&& !(shmup::on && shmup::boatAt(c)) && !(c->cpdist <= 1 && playerInWater());
}
EX int barrowCount(cell *c) {
// This should always be 2 or 3.
// Clamping to exactly that would make bugs go unnoticed.
// Not clamping at all would lead to freezes when it's absurdly large.
// Clamping to [1,4] means any incorrect values will be apparent but not game-breaking.
return min(max(c->landparam, 1), 4);
}
}