fixed wrap-around with entering EM style door (gate) for EM engine
[rocksndiamonds.git] / src / game_em / logic.c
index bfb387f468727b5dce51e57b2e766b8de5b69593..a56547b14a462365e830a8cdfbdb59ac0adead0b 100644 (file)
@@ -7695,10 +7695,12 @@ void logic_move(void)
     if (ply[i].x < lev.left ||
        ply[i].x > lev.right - 1)
     {
-      ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
+      int direction = (ply[i].x < lev.left ? -1 : 1);
+
+      ply[i].x += -direction * lev.width;
 
       if (!lev.infinite_true)
-       ply[i].y += (ply[i].x == lev.left ? 1 : -1);
+       ply[i].y += direction;
 
       game.centered_player_nr_next = i;
       game.set_centered_player = TRUE;