mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 01:20:37 +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:
parent
4de6e9d3e4
commit
3095afc94b
@ -1597,7 +1597,7 @@ namespace hive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
random_shuffle(bugtomove.begin(), bugtomove.end());
|
hrandom_shuffle(&bugtomove[0], size(bugtomove));
|
||||||
sort(bugtomove.begin(), bugtomove.end());
|
sort(bugtomove.begin(), bugtomove.end());
|
||||||
|
|
||||||
int battlecount = 0;
|
int battlecount = 0;
|
||||||
@ -2613,7 +2613,7 @@ namespace kraken {
|
|||||||
int qdir = 0;
|
int qdir = 0;
|
||||||
cell *ctab[MAX_EDGE];
|
cell *ctab[MAX_EDGE];
|
||||||
forCellEx(c2, c) if(isWatery(c2)) ctab[qdir++] = c2;
|
forCellEx(c2, c) if(isWatery(c2)) ctab[qdir++] = c2;
|
||||||
random_shuffle(ctab, ctab+qdir);
|
hrandom_shuffle(ctab, qdir);
|
||||||
while(qdir--) trymove(ctab[qdir]);
|
while(qdir--) trymove(ctab[qdir]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3083,7 +3083,7 @@ namespace windmap {
|
|||||||
bool inqueue[N];
|
bool inqueue[N];
|
||||||
vector<int> tocheck;
|
vector<int> tocheck;
|
||||||
for(int i=0; i<N; i++) tocheck.push_back(i), inqueue[i] = true;
|
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++) {
|
for(int a=0; a<size(tocheck); a++) {
|
||||||
if(a >= 200*N) { printf("does not converge\n"); break; }
|
if(a >= 200*N) { printf("does not converge\n"); break; }
|
||||||
|
19
game.cpp
19
game.cpp
@ -154,6 +154,11 @@ ld hrandf() {
|
|||||||
return (r() & HRANDMAX) / (HRANDMAX + 1.0);
|
return (r() & HRANDMAX) / (HRANDMAX + 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hrandstate() {
|
||||||
|
mt19937 r2 = r;
|
||||||
|
return r2() % 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
void initcell(cell *c) {
|
void initcell(cell *c) {
|
||||||
c->mpdist = INFD; // minimum distance from the player, ever
|
c->mpdist = INFD; // minimum distance from the player, ever
|
||||||
c->cpdist = INFD; // current distance from the player
|
c->cpdist = INFD; // current distance from the player
|
||||||
@ -1308,7 +1313,8 @@ int monstersnear2() {
|
|||||||
dynamicval<eMonster> sw(passive_switch, passive_switch);
|
dynamicval<eMonster> sw(passive_switch, passive_switch);
|
||||||
|
|
||||||
// check for safe orbs and switching first
|
// 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)) {
|
if(hasSafeOrb(sm.moveto)) {
|
||||||
multi::cpid--; return 0;
|
multi::cpid--; return 0;
|
||||||
}
|
}
|
||||||
@ -1318,8 +1324,10 @@ int monstersnear2() {
|
|||||||
if(canPickupItemWithMagnetism(c2, sm.comefrom)) {
|
if(canPickupItemWithMagnetism(c2, sm.comefrom)) {
|
||||||
if(itemclass(c2->item) == IC_TREASURE)
|
if(itemclass(c2->item) == IC_TREASURE)
|
||||||
passive_switch = active_switch();
|
passive_switch = active_switch();
|
||||||
if(hasSafeOrb(c2))
|
if(hasSafeOrb(c2)) {
|
||||||
|
multi::cpid--;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4053,7 +4061,7 @@ void killThePlayer(eMonster m, int id, flagtype flags) {
|
|||||||
items[itOrbSafety] = 0;
|
items[itOrbSafety] = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("confused!\n");
|
// printf("confused!\n");
|
||||||
addMessage(XLAT("%The1 is confused!", m));
|
addMessage(XLAT("%The1 is confused!", m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4495,7 +4503,8 @@ void groupmove(eMonster movtype, flagtype mf) {
|
|||||||
int dirtable[10], qdirtable=0;
|
int dirtable[10], qdirtable=0;
|
||||||
|
|
||||||
forCellIdAll(c2,t,c) dirtable[qdirtable++] = t;
|
forCellIdAll(c2,t,c) dirtable[qdirtable++] = t;
|
||||||
random_shuffle(dirtable, dirtable + qdirtable);
|
hrandom_shuffle(dirtable, qdirtable);
|
||||||
|
|
||||||
while(qdirtable--) {
|
while(qdirtable--) {
|
||||||
int t = dirtable[qdirtable];
|
int t = dirtable[qdirtable];
|
||||||
groupmove2(c->mov[t],c,t,movtype,mf);
|
groupmove2(c->mov[t],c,t,movtype,mf);
|
||||||
@ -6008,7 +6017,7 @@ void activateSafety(eLand l) {
|
|||||||
l = laCrossroads;
|
l = laCrossroads;
|
||||||
firstland = l;
|
firstland = l;
|
||||||
safetyland = l;
|
safetyland = l;
|
||||||
safetyseed = time(NULL);
|
safetyseed = 0;
|
||||||
clear_euland(firstland);
|
clear_euland(firstland);
|
||||||
safety = true; avengers = 0;
|
safety = true; avengers = 0;
|
||||||
clearMemory();
|
clearMemory();
|
||||||
|
15
hyper.h
15
hyper.h
@ -109,7 +109,15 @@ struct gcell {
|
|||||||
|
|
||||||
} LHU;
|
} LHU;
|
||||||
|
|
||||||
gcell() { cellcount++; }
|
#ifdef CELLID
|
||||||
|
int cellid;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gcell() { cellcount++;
|
||||||
|
#ifdef CELLID
|
||||||
|
cellid = cellcount;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
~gcell() { cellcount--; }
|
~gcell() { cellcount--; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2445,3 +2453,8 @@ bool cannotPickupItem(cell *c, bool telekinesis);
|
|||||||
bool canPickupItemWithMagnetism(cell *c, cell *from);
|
bool canPickupItemWithMagnetism(cell *c, cell *from);
|
||||||
void pickupMovedItems(cell *c);
|
void pickupMovedItems(cell *c);
|
||||||
eMonster genRuinMonster(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)]);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user