X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=64df11ffb2d200aefd9a0532bc8ea99bdebb7572;hb=34b1ec9d816877389df293fb4f9ec10cc2a43729;hp=ea6faa9527b662366f5dc027f776f994729d3a43;hpb=9b9fc7c5d5990aae8f7c1b403c3ab1ed338018da;p=rocksndiamonds.git diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index ea6faa95..64df11ff 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -139,11 +139,10 @@ static DelayCounter overload_delay = { 0 }; #define MM_MASK_GRID_2 5 #define MM_MASK_GRID_3 6 #define MM_MASK_GRID_4 7 -#define MM_MASK_GRID_CLOSED 8 -#define MM_MASK_RECTANGLE 9 -#define MM_MASK_CIRCLE 10 +#define MM_MASK_RECTANGLE 8 +#define MM_MASK_CIRCLE 9 -#define NUM_MM_MASKS 11 +#define NUM_MM_MASKS 10 // element masks for scanning pixels of MM elements static const char mm_masks[NUM_MM_MASKS][16][16 + 1] = @@ -292,24 +291,6 @@ static const char mm_masks[NUM_MM_MASKS][16][16 + 1] = " XXX XXXX ", " XX XXXXX ", }, - { - " XXXXXX XXXXXX ", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - " XXXXXXXXXXXXXX ", - " XXXXXXXXXXXXXX ", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - "XXXXXXXXXXXXXXXX", - " XXXXXX XXXXXX ", - }, { "XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXX", @@ -847,11 +828,12 @@ static void GameOver_MM(int game_over_cause) static void AddLaserEdge(int lx, int ly) { - int sxsize = MAX(SXSIZE, lev_fieldx * TILEX); - int sysize = MAX(SYSIZE, lev_fieldy * TILEY); + int full_sxsize = MAX(FULL_SXSIZE, lev_fieldx * TILEX); + int full_sysize = MAX(FULL_SYSIZE, lev_fieldy * TILEY); - if (dSX + lx < -2 || dSX + lx >= sxsize + 2 || - dSY + ly < -2 || dSY + ly >= 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); @@ -904,13 +886,23 @@ static int getMaskFromElement(int element) else if (IS_GRID(element)) return MM_MASK_GRID_1 + get_element_phase(element); else if (IS_DF_GRID(element)) - return MM_MASK_GRID_CLOSED; + return MM_MASK_RECTANGLE; else if (IS_RECTANGLE(element)) return MM_MASK_RECTANGLE; else return MM_MASK_CIRCLE; } +static int getLevelFromLaserX(int x) +{ + return x / TILEX - (x < 0 ? 1 : 0); // correct negative values +} + +static int getLevelFromLaserY(int y) +{ + return y / TILEY - (y < 0 ? 1 : 0); // correct negative values +} + static int ScanPixel(void) { int hit_mask = 0; @@ -962,8 +954,8 @@ static int ScanPixel(void) int py = LY + (i / 2) * 2; int dx = px % TILEX; int dy = py % TILEY; - int lx = (px + TILEX) / TILEX - 1; // ...+TILEX...-1 to get correct - int ly = (py + TILEY) / TILEY - 1; // negative values! + int lx = getLevelFromLaserX(px); + int ly = getLevelFromLaserY(py); Pixel pixel; if (IN_LEV_FIELD(lx, ly)) @@ -989,6 +981,7 @@ static int ScanPixel(void) } 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); } @@ -1080,8 +1073,8 @@ static void ScanLaser(void) #endif // hit something -- check out what it was - ELX = (LX + XS + TILEX) / TILEX - 1; // ...+TILEX...-1 to get correct - ELY = (LY + YS + TILEY) / TILEY - 1; // negative values! + ELX = getLevelFromLaserX(LX + XS); + ELY = getLevelFromLaserY(LY + YS); #if 0 Debug("game:mm:ScanLaser", "hit_mask (1) == '%x' (%d, %d) (%d, %d)", @@ -1090,6 +1083,21 @@ static void ScanLaser(void) 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; @@ -1101,8 +1109,8 @@ static void ScanLaser(void) 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); + boolean cross_x = (getLevelFromLaserX(LX) != getLevelFromLaserX(LX + 2)); + boolean cross_y = (getLevelFromLaserY(LY) != getLevelFromLaserY(LY + 2)); // handle special case of laser hitting two diagonally adjacent elements // (with or without a third corner element behind these two elements) @@ -1694,6 +1702,7 @@ static boolean HitElement(int element, int hit_mask) IS_POLAR_CROSS(element) || IS_DF_MIRROR(element) || IS_DF_MIRROR_AUTO(element) || + IS_DF_MIRROR_FIXED(element) || element == EL_PRISM || element == EL_REFRACTOR) { @@ -1712,7 +1721,8 @@ static boolean HitElement(int element, int hit_mask) 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));