static void AddLaserEdge(int lx, int ly)
{
- int clx = dSX + lx;
- int cly = dSY + ly;
+ int full_sxsize = MAX(FULL_SXSIZE, lev_fieldx * TILEX);
+ int full_sysize = MAX(FULL_SYSIZE, lev_fieldy * TILEY);
- if (clx < -2 || cly < -2 || clx >= SXSIZE + 2 || cly >= SYSIZE + 2)
+ // check if laser is still inside visible playfield area (or inside level)
+ if (cSX + lx < REAL_SX || cSX + lx >= REAL_SX + full_sxsize ||
+ cSY + ly < REAL_SY || cSY + ly >= REAL_SY + full_sysize)
{
Warn("AddLaserEdge: out of bounds: %d, %d", lx, ly);
static int getMaskFromElement(int element)
{
- if (IS_GRID(element))
- return MM_MASK_GRID_1 + get_element_phase(element);
- else if (IS_MCDUFFIN(element))
+ if (IS_MCDUFFIN(element))
return MM_MASK_MCDUFFIN_RIGHT + get_element_phase(element);
- else if (IS_RECTANGLE(element) || IS_DF_GRID(element))
+ else if (IS_GRID(element))
+ return MM_MASK_GRID_1 + get_element_phase(element);
+ else if (IS_DF_GRID(element))
+ return MM_MASK_RECTANGLE;
+ else if (IS_RECTANGLE(element))
return MM_MASK_RECTANGLE;
else
return MM_MASK_CIRCLE;
}
else
{
+ // check if laser is still inside visible playfield area
pixel = (cSX + px < REAL_SX || cSX + px >= REAL_SX + FULL_SXSIZE ||
cSY + py < REAL_SY || cSY + py >= REAL_SY + FULL_SYSIZE);
}
#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))
{
+ // laser next step position
+ int x = cSX + LX + XS;
+ int y = cSY + LY + YS;
+
+ // check if next step of laser is still inside visible playfield area
+ if (x >= REAL_SX && x < REAL_SX + FULL_SXSIZE &&
+ y >= REAL_SY && y < REAL_SY + FULL_SYSIZE)
+ {
+ // go on with another step
+ LX += XS;
+ LY += YS;
+
+ continue;
+ }
+
element = EL_EMPTY;
laser.dest_element = element;
IS_POLAR_CROSS(element) ||
IS_DF_MIRROR(element) ||
IS_DF_MIRROR_AUTO(element) ||
+ IS_DF_MIRROR_FIXED(element) ||
element == EL_PRISM ||
element == EL_REFRACTOR)
{
if (IS_MIRROR(element) ||
IS_MIRROR_FIXED(element) ||
IS_DF_MIRROR(element) ||
- IS_DF_MIRROR_AUTO(element))
+ IS_DF_MIRROR_AUTO(element) ||
+ IS_DF_MIRROR_FIXED(element))
laser.current_angle = get_mirrored_angle(laser.current_angle,
get_element_angle(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];
IS_GRID_WOOD_AUTO(element) ||
IS_GRID_STEEL_AUTO(element) ||
element == EL_REFRACTOR)
+ {
RotateMirror(x, y, MB_RIGHTBUTTON);
+
+ laser.redraw = TRUE;
+ }
}
}
}