static void RemoveMovingField_MM(int, int);
static void InitMovingField_MM(int, int, int);
static void ContinueMoving_MM(int, int);
-static void Moving2Blocked_MM(int, int, int *, int *);
static void AddLaserEdge(int, int);
static void ScanLaser(void);
{
int clx = dSX + lx;
int cly = dSY + ly;
+ int sxsize = MAX(SXSIZE, lev_fieldx * TILEX);
+ int sysize = MAX(SYSIZE, lev_fieldy * TILEY);
- if (clx < -2 || cly < -2 || clx >= SXSIZE + 2 || cly >= SYSIZE + 2)
+ if (clx < -2 || cly < -2 || clx >= sxsize + 2 || cly >= sysize + 2)
{
Warn("AddLaserEdge: out of bounds: %d, %d", lx, ly);
#endif
// hit something -- check out what it was
- ELX = (LX + XS) / TILEX;
- ELY = (LY + YS) / TILEY;
+ ELX = (LX + XS + TILEX) / TILEX - 1; // ...+TILEX...-1 to get correct
+ ELY = (LY + YS + TILEY) / TILEY - 1; // negative values!
#if 0
Debug("game:mm:ScanLaser", "hit_mask (1) == '%x' (%d, %d) (%d, %d)",
hit_mask, LX, LY, ELX, ELY);
#endif
- if (!IN_LEV_FIELD(ELX, ELY) || !IN_PIX_FIELD(LX, LY))
+ if (!IN_LEV_FIELD(ELX, ELY))
{
element = EL_EMPTY;
laser.dest_element = element;
int x, y;
} move_xy[] =
{
- { 0, 0 },
- {-1, 0 },
- {+1, 0 },
- { 0, 0 },
- { 0, -1 },
- { 0, 0 }, { 0, 0 }, { 0, 0 },
- { 0, +1 }
+ { 0, 0 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, 0 },
+ { 0, -1 },
+ { 0, 0 }, { 0, 0 }, { 0, 0 },
+ { 0, +1 }
};
static struct
{
int left, right, back;
} turn[] =
{
- { 0, 0, 0 },
+ { 0, 0, 0 },
{ MV_DOWN, MV_UP, MV_RIGHT },
- { MV_UP, MV_DOWN, MV_LEFT },
- { 0, 0, 0 },
- { MV_LEFT, MV_RIGHT, MV_DOWN },
- { 0,0,0 }, { 0,0,0 }, { 0,0,0 },
- { MV_RIGHT, MV_LEFT, MV_UP }
+ { MV_UP, MV_DOWN, MV_LEFT },
+ { 0, 0, 0 },
+ { MV_LEFT, MV_RIGHT, MV_DOWN },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { MV_RIGHT, MV_LEFT, MV_UP }
};
int element = Tile[x][y];
// now make next step
- Moving2Blocked_MM(x, y, &newx, &newy); // get next screen position
+ Moving2Blocked(x, y, &newx, &newy); // get next screen position
if (element == EL_PACMAN &&
IN_LEV_FIELD(newx, newy) && IS_EATABLE4PACMAN(Tile[newx][newy]) &&
Tile[newx][newy] = EL_BLOCKED;
}
-static void Moving2Blocked_MM(int x, int y, int *goes_to_x, int *goes_to_y)
-{
- int direction = MovDir[x][y];
- int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
- int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
-
- *goes_to_x = newx;
- *goes_to_y = newy;
-}
-
-static void Blocked2Moving_MM(int x, int y,
- int *comes_from_x, int *comes_from_y)
-{
- int oldx = x, oldy = y;
- int direction = MovDir[x][y];
-
- if (direction == MV_LEFT)
- oldx++;
- else if (direction == MV_RIGHT)
- oldx--;
- else if (direction == MV_UP)
- oldy++;
- else if (direction == MV_DOWN)
- oldy--;
-
- *comes_from_x = oldx;
- *comes_from_y = oldy;
-}
-
static int MovingOrBlocked2Element_MM(int x, int y)
{
int element = Tile[x][y];
{
int oldx, oldy;
- Blocked2Moving_MM(x, y, &oldx, &oldy);
+ Blocked2Moving(x, y, &oldx, &oldy);
return Tile[oldx][oldy];
}
if (IS_MOVING(x, y))
{
- Moving2Blocked_MM(x, y, &newx, &newy);
+ Moving2Blocked(x, y, &newx, &newy);
if (Tile[newx][newy] != EL_BLOCKED)
return;
}
else if (Tile[x][y] == EL_BLOCKED)
{
- Blocked2Moving_MM(x, y, &oldx, &oldy);
+ Blocked2Moving(x, y, &oldx, &oldy);
if (!IS_MOVING(oldx, oldy))
return;
}