1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-14 09:26:52 +00:00

removed function dirfromto as it was equal to neighborId

This commit is contained in:
Zeno Rogue 2019-08-10 00:08:16 +02:00
parent 986bf0ee9a
commit 245ee5878f
4 changed files with 8 additions and 15 deletions

View File

@ -462,11 +462,6 @@ EX int celldistAlt(cell *c) {
return mi; return mi;
} }
EX int dirfromto(cell *cfrom, cell *cto) {
for(int i=0; i<cfrom->type; i++) if(cfrom->move(i) == cto) return i;
return -1;
}
#if HDR #if HDR
static const int RPV_MODULO = 5; static const int RPV_MODULO = 5;
static const int RPV_RAND = 0; static const int RPV_RAND = 0;

View File

@ -835,7 +835,7 @@ bool ghostmove(eMonster m, cell* to, cell* from) {
bool slimepassable(cell *w, cell *c) { bool slimepassable(cell *w, cell *c) {
if(w == c || !c) return true; if(w == c || !c) return true;
int u = dirfromto(c, w); int u = neighborId(c, w);
if(nonAdjacent(w,c)) return false; if(nonAdjacent(w,c)) return false;
if(isPlayerOn(w)) return true; if(isPlayerOn(w)) return true;
int group = slimegroup(c); int group = slimegroup(c);

View File

@ -849,8 +849,6 @@ namespace mirror {
void act(int dir, int flags); void act(int dir, int flags);
} }
int neighborId(cell *c1, cell *c2);
struct movedir { struct movedir {
int d; int d;
// non-negative numbers denote 'rotate +d steps and act in this direction // non-negative numbers denote 'rotate +d steps and act in this direction

View File

@ -1032,7 +1032,7 @@ void movePlayer(monster *m, int delta) {
} }
else { else {
if(isWatery(m->base)) if(isWatery(m->base))
m->base->wall = waBoat, m->base->mondir = dirfromto(m->base, c2); m->base->wall = waBoat, m->base->mondir = neighborId(m->base, c2);
else if(boatStrandable(m->base)) else if(boatStrandable(m->base))
m->base->wall = waStrandedBoat; m->base->wall = waStrandedBoat;
else if(boatStrandable(c2)) else if(boatStrandable(c2))
@ -1041,7 +1041,7 @@ void movePlayer(monster *m, int delta) {
} }
} }
else if(isPushable(c2->wall) && !nonAdjacent(c2, m->base)) { else if(isPushable(c2->wall) && !nonAdjacent(c2, m->base)) {
int sd = dirfromto(c2, m->base); int sd = neighborId(c2, m->base);
int subdir = 1; int subdir = 1;
double bestd = 9999; double bestd = 9999;
pushmonsters(); pushmonsters();
@ -1053,7 +1053,7 @@ void movePlayer(monster *m, int delta) {
if(d<bestd) bestd=d, subdir = di; if(d<bestd) bestd=d, subdir = di;
} }
visibleFor(300); visibleFor(300);
cellwalker push(c2, dirfromto(c2, m->base)); cellwalker push(c2, neighborId(c2, m->base));
push = push + 3 * (-subdir) + wstep; push = push + 3 * (-subdir) + wstep;
if(!canPushThumperOn(push.at, c2, m->base) && c2->type == 7) { if(!canPushThumperOn(push.at, c2, m->base) && c2->type == 7) {
push = push + wstep - subdir + wstep; push = push + wstep - subdir + wstep;
@ -1109,7 +1109,7 @@ void movePlayer(monster *m, int delta) {
if(items[itOrbDigging]) { if(items[itOrbDigging]) {
visibleFor(400); visibleFor(400);
int d = dirfromto(m->base, c2); int d = neighborId(m->base, c2);
if(d >= 0 && earthMove(m->base, d)) markOrb(itOrbDigging); if(d >= 0 && earthMove(m->base, d)) markOrb(itOrbDigging);
} }
@ -2171,7 +2171,7 @@ void moveMonster(monster *m, int delta) {
if(c2 != m->base && m->type == moFireElemental) makeflame(m->base, 20, false); if(c2 != m->base && m->type == moFireElemental) makeflame(m->base, 20, false);
if(c2 != m->base && m->type == moWaterElemental) placeWater(c2, m->base); if(c2 != m->base && m->type == moWaterElemental) placeWater(c2, m->base);
if(c2 != m->base && m->type == moEarthElemental) { if(c2 != m->base && m->type == moEarthElemental) {
int d = dirfromto(m->base, c2); int d = neighborId(m->base, c2);
if(d >= 0) earthMove(m->base, d); if(d >= 0) earthMove(m->base, d);
} }
@ -2194,7 +2194,7 @@ void moveMonster(monster *m, int delta) {
if(c2 != m->base && m->type == moNecromancer && !c2->monst) { if(c2 != m->base && m->type == moNecromancer && !c2->monst) {
for(int i=0; i<m->base->type; i++) { for(int i=0; i<m->base->type; i++) {
cell *c3 = m->base->move(i); cell *c3 = m->base->move(i);
if(dirfromto(c3, c2) != -1 && c3->wall == waFreshGrave && gmatrix.count(c3)) { if(neighborId(c3, c2) != -1 && c3->wall == waFreshGrave && gmatrix.count(c3)) {
bool monstersNear = false; bool monstersNear = false;
for(monster *m2: nonvirtual) { for(monster *m2: nonvirtual) {
if(m2 != m && intval(m2->pat*C0, gmatrix[c3]*C0) < SCALE2 * .3) if(m2 != m && intval(m2->pat*C0, gmatrix[c3]*C0) < SCALE2 * .3)
@ -2251,7 +2251,7 @@ void moveMonster(monster *m, int delta) {
} }
if(passable_for(m->type, c2, m->base, P_CHAIN | P_ONPLAYER | reflectflag) && !isWatery(c2) && m->inBoat) { if(passable_for(m->type, c2, m->base, P_CHAIN | P_ONPLAYER | reflectflag) && !isWatery(c2) && m->inBoat) {
if(isWatery(m->base)) if(isWatery(m->base))
m->base->wall = waBoat, m->base->mondir = dirfromto(m->base, c2); m->base->wall = waBoat, m->base->mondir = neighborId(m->base, c2);
else if(boatStrandable(c2)) c2->wall = waStrandedBoat; else if(boatStrandable(c2)) c2->wall = waStrandedBoat;
else if(boatStrandable(m->base)) m->base->wall = waStrandedBoat; else if(boatStrandable(m->base)) m->base->wall = waStrandedBoat;
m->inBoat = false; m->inBoat = false;