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

cellid / fixed some situations when the same seed did not reproduce the same game / fixed a bug with multi::cpid overflow / golems no longer consider Orbs of Safety safe

This commit is contained in:
Zeno Rogue 2018-01-13 19:23:02 +01:00
parent 4de6e9d3e4
commit 3095afc94b
3 changed files with 32 additions and 10 deletions

View File

@ -1597,7 +1597,7 @@ namespace hive {
}
}
random_shuffle(bugtomove.begin(), bugtomove.end());
hrandom_shuffle(&bugtomove[0], size(bugtomove));
sort(bugtomove.begin(), bugtomove.end());
int battlecount = 0;
@ -2613,7 +2613,7 @@ namespace kraken {
int qdir = 0;
cell *ctab[MAX_EDGE];
forCellEx(c2, c) if(isWatery(c2)) ctab[qdir++] = c2;
random_shuffle(ctab, ctab+qdir);
hrandom_shuffle(ctab, qdir);
while(qdir--) trymove(ctab[qdir]);
}
}
@ -3083,7 +3083,7 @@ namespace windmap {
bool inqueue[N];
vector<int> tocheck;
for(int i=0; i<N; i++) tocheck.push_back(i), inqueue[i] = true;
random_shuffle(tocheck.begin(), tocheck.end());
hrandom_shuffle(&tocheck[0], size(tocheck));
for(int a=0; a<size(tocheck); a++) {
if(a >= 200*N) { printf("does not converge\n"); break; }

View File

@ -154,6 +154,11 @@ ld hrandf() {
return (r() & HRANDMAX) / (HRANDMAX + 1.0);
}
int hrandstate() {
mt19937 r2 = r;
return r2() % 1000000;
}
void initcell(cell *c) {
c->mpdist = INFD; // minimum distance from the player, ever
c->cpdist = INFD; // current distance from the player
@ -1308,7 +1313,8 @@ int monstersnear2() {
dynamicval<eMonster> sw(passive_switch, passive_switch);
// check for safe orbs and switching first
for(auto &sm: stalemate::moves) {
for(auto &sm: stalemate::moves) if(sm.who == moPlayer) {
if(hasSafeOrb(sm.moveto)) {
multi::cpid--; return 0;
}
@ -1318,8 +1324,10 @@ int monstersnear2() {
if(canPickupItemWithMagnetism(c2, sm.comefrom)) {
if(itemclass(c2->item) == IC_TREASURE)
passive_switch = active_switch();
if(hasSafeOrb(c2))
if(hasSafeOrb(c2)) {
multi::cpid--;
return 0;
}
}
}
@ -4053,7 +4061,7 @@ void killThePlayer(eMonster m, int id, flagtype flags) {
items[itOrbSafety] = 0;
}
else {
printf("confused!\n");
// printf("confused!\n");
addMessage(XLAT("%The1 is confused!", m));
}
}
@ -4495,7 +4503,8 @@ void groupmove(eMonster movtype, flagtype mf) {
int dirtable[10], qdirtable=0;
forCellIdAll(c2,t,c) dirtable[qdirtable++] = t;
random_shuffle(dirtable, dirtable + qdirtable);
hrandom_shuffle(dirtable, qdirtable);
while(qdirtable--) {
int t = dirtable[qdirtable];
groupmove2(c->mov[t],c,t,movtype,mf);
@ -5008,7 +5017,7 @@ int stayvalue(eMonster m, cell *c) {
// friendly version of moveval
int movevalue(eMonster m, cell *c, cell *c2, flagtype flags) {
int val = 0;
if(isPlayerOn(c2)) val = -3000;
else if(againstRose(c, c2) && !ignoresSmell(m)) return -1200;
else if(m == moPrincess && c2->stuntime && hasPrincessWeapon(c2->monst) &&
@ -6008,7 +6017,7 @@ void activateSafety(eLand l) {
l = laCrossroads;
firstland = l;
safetyland = l;
safetyseed = time(NULL);
safetyseed = 0;
clear_euland(firstland);
safety = true; avengers = 0;
clearMemory();

15
hyper.h
View File

@ -109,7 +109,15 @@ struct gcell {
} LHU;
gcell() { cellcount++; }
#ifdef CELLID
int cellid;
#endif
gcell() { cellcount++;
#ifdef CELLID
cellid = cellcount;
#endif
}
~gcell() { cellcount--; }
};
@ -2445,3 +2453,8 @@ bool cannotPickupItem(cell *c, bool telekinesis);
bool canPickupItemWithMagnetism(cell *c, cell *from);
void pickupMovedItems(cell *c);
eMonster genRuinMonster(cell *c);
template<class T> void hrandom_shuffle(T* x, int n) {
for(int k=1; k<n; k++) swap(x[k], x[hrand(k+1)]);
}