This also correctly handles the case of the laser hitting the inner
corner of two diagonally adjacent game elements with a third game
element behind these two elements (in the direction of the laser).
It also makes sure that no "inner corners" of diagonally adjacent
mini tiles (MM wall tiles) are handled, which are not interesting
here (as they are always the same type of wall), but only diagonal
corners between full tile positions.
This change also makes sure that randomly selecting which element to
handle is only done if really necessary (to not break existing tapes
by additional calls to the random number generator).
- if (hit_mask == HIT_MASK_DIAGONAL_1 || hit_mask == HIT_MASK_DIAGONAL_2)
+ // check if laser scan has hit two diagonally adjacent element corners
+ boolean diag_1 = ((hit_mask & HIT_MASK_DIAGONAL_1) == HIT_MASK_DIAGONAL_1);
+ boolean diag_2 = ((hit_mask & HIT_MASK_DIAGONAL_2) == HIT_MASK_DIAGONAL_2);
+
+ // check if laser scan has crossed element boundaries (not just mini tiles)
+ boolean cross_x = (LX / TILEX != (LX + 2) / TILEX);
+ boolean cross_y = (LY / TILEY != (LY + 2) / TILEY);
+
+ // handle special case of laser hitting two diagonally adjacent elements
+ // (with or without a third corner element behind these two elements)
+ if ((diag_1 || diag_2) && cross_x && cross_y)
- // we have hit two diagonally adjacent elements -- compare them
- boolean dia_1 = (hit_mask == HIT_MASK_DIAGONAL_1);
+ // compare the two diagonally adjacent elements
- int yoffset = 2 * (dia_1 ? -1 : +1);
+ int yoffset = 2 * (diag_1 ? -1 : +1);
int elx1 = (LX - xoffset) / TILEX;
int ely1 = (LY + yoffset) / TILEY;
int elx2 = (LX + xoffset) / TILEX;
int elx1 = (LX - xoffset) / TILEX;
int ely1 = (LY + yoffset) / TILEY;
int elx2 = (LX + xoffset) / TILEX;
}
else if (IS_WALL_AMOEBA(e1) || IS_WALL_AMOEBA(e2))
{
}
else if (IS_WALL_AMOEBA(e1) || IS_WALL_AMOEBA(e2))
{
- if (IS_WALL_AMOEBA(e1) && IS_WALL_AMOEBA(e2))
- use_element_1 = (RND(2) ? TRUE : FALSE);
- else if (IS_WALL_AMOEBA(e1))
+ // if both tiles match, we can just select the first one
+ if (IS_WALL_AMOEBA(e1))
use_element_1 = TRUE;
}
else if (IS_ABSORBING_BLOCK(e1) || IS_ABSORBING_BLOCK(e2))
{
use_element_1 = TRUE;
}
else if (IS_ABSORBING_BLOCK(e1) || IS_ABSORBING_BLOCK(e2))
{
- if (IS_ABSORBING_BLOCK(e1) && IS_ABSORBING_BLOCK(e2))
- use_element_1 = (RND(2) ? TRUE : FALSE);
- else if (IS_ABSORBING_BLOCK(e1))
+ // if both tiles match, we can just select the first one
+ if (IS_ABSORBING_BLOCK(e1))