diff --git a/attack.cpp b/attack.cpp index d9f80c59..088897bf 100644 --- a/attack.cpp +++ b/attack.cpp @@ -1211,7 +1211,7 @@ EX void stabbingAttack(movei mi, eMonster who, int bonuskill IS(0)) { cell *mf = mi.s; cell *mt = mi.t; - int backdir = mi.rev_dir(); + int backdir = mi.rev_dir_mirror(); do_swords(mi, who, [&] (cell *c, int bb) { if(swordAttack(mt, who, c, bb)) numbb[bb]++, numslash++; }); @@ -1279,7 +1279,7 @@ EX void stabbingAttack(movei mi, eMonster who, int bonuskill IS(0)) { if(!logical_adjacent(mt, who, c)) continue; eMonster mm = c->monst; int flag = AF_APPROACH; - if(anglestraight(mt, backdir, t)) flag |= AF_HORNS; + if(proper(mt, backdir) && anglestraight(mt, backdir, t)) flag |= AF_HORNS; if(canAttack(mt,who,c,c->monst, flag)) { changes.ccell(c); if(attackMonster(c, flag | AF_MSG, who)) numlance++; diff --git a/complex.cpp b/complex.cpp index 937f1abd..8368b6aa 100644 --- a/complex.cpp +++ b/complex.cpp @@ -2872,7 +2872,7 @@ EX namespace sword { cell *c2 = mi.t; if(!mi.proper()) return d; int s1 = mi.d; - int s2 = mi.rev_dir(); + int s2 = mi.rev_dir_force(); neighborId(c2, c1); if(s1 < 0 || s2 < 0) return d; if(SWORDDIM == 2) { diff --git a/locations.cpp b/locations.cpp index e52e3cb5..7b1aaf8f 100644 --- a/locations.cpp +++ b/locations.cpp @@ -452,6 +452,8 @@ inline cellwalker operator+ (heptspin hs, cth_t) { return cellwalker(hs.at->c7, #endif +EX bool proper(cell *c, int d) { return d >= 0 && d < c->type; } + #if HDR constexpr int STRONGWIND = 99; @@ -485,7 +487,8 @@ struct movei { movei rev() const { return movei(t, s, rev_dir_or(d)); } int dir_or(int x) const { return proper() ? d : x; } int rev_dir_or(int x) const { return proper() ? s->c.spin(d) : x; } - int rev_dir() const { return s->c.spin(d); } + int rev_dir_mirror() const { return proper() ? s->c.spin(d) : d; } + int rev_dir_force() const { hassert(proper()); return s->c.spin(d); } bool mirror() { return s->c.mirror(d); } }; #endif diff --git a/monstermove.cpp b/monstermove.cpp index 661113cd..e4545817 100644 --- a/monstermove.cpp +++ b/monstermove.cpp @@ -765,12 +765,12 @@ EX void mountmove(const movei& mi, bool fp) { animateMovement(mi, LAYER_SMALL); if(multi::players > 1) { multi::player[i].at = mi.t; - multi::player[i].spin = mi.rev_dir(); + multi::player[i].spin = mi.rev_dir_force(); multi::flipped[i] = fp; } else { cwt.at = mi.t; - cwt.spin = mi.rev_dir(); + cwt.spin = mi.rev_dir_force(); flipplayer = fp; } afterplayermoved();