From: Holger Schemel Date: Sun, 2 Feb 2020 19:53:37 +0000 (+0100) Subject: added support for EM wrap-around levels also to level editor X-Git-Tag: 4.2.0.0~158 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4872058f102fa8ded1e215227620d6b33a9c465a;p=rocksndiamonds.git added support for EM wrap-around levels also to level editor Previously, when running a level created with the R'n'D level editor that uses the EM game engine, that level was forced to have a border of indestructible game elements, which made it impossible to create wrap-around levels to be played with the EM engine. This limitation was removed, so no additional steel wall will ever be added around a level. --- diff --git a/src/files.c b/src/files.c index 3539e822..4590665e 100644 --- a/src/files.c +++ b/src/files.c @@ -3578,25 +3578,15 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) for (x = 0; x < EM_MAX_CAVE_WIDTH; x++) level_em->cave[x][y] = Zborder; - if (BorderElement == EL_STEELWALL) - { - for (y = 0; y < lev->height + 2; y++) - for (x = 0; x < lev->width + 2; x++) - level_em->cave[x][y] = map_element_RND_to_EM(EL_STEELWALL); - } - // then copy the real level contents from level file into the playfield for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++) { int new_element = map_element_RND_to_EM(level->field[x][y]); - int offset = (BorderElement == EL_STEELWALL ? 1 : 0); - int xx = x + offset; - int yy = y + offset; if (level->field[x][y] == EL_AMOEBA_DEAD) new_element = map_element_RND_to_EM(EL_AMOEBA_WET); - level_em->cave[xx][yy] = new_element; + level_em->cave[x][y] = new_element; } for (i = 0; i < MAX_PLAYERS; i++) @@ -3611,22 +3601,13 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) if (ELEM_IS_PLAYER(level->field[x][y])) { int player_nr = GET_PLAYER_NR(level->field[x][y]); - int offset = (BorderElement == EL_STEELWALL ? 1 : 0); - int xx = x + offset; - int yy = y + offset; - ply[player_nr]->x_initial = xx; - ply[player_nr]->y_initial = yy; + ply[player_nr]->x_initial = x; + ply[player_nr]->y_initial = y; - level_em->cave[xx][yy] = map_element_RND_to_EM(EL_EMPTY); + level_em->cave[x][y] = map_element_RND_to_EM(EL_EMPTY); } } - - if (BorderElement == EL_STEELWALL) - { - lev->width += 2; - lev->height += 2; - } } static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) diff --git a/src/game_em/emerald.h b/src/game_em/emerald.h index d83a182d..1afbfbfc 100644 --- a/src/game_em/emerald.h +++ b/src/game_em/emerald.h @@ -51,11 +51,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* define these to use additional elements */ #define EM_ENGINE_USE_ADDITIONAL_ELEMENTS -/* with border for steelwall, if needed (when converted from R'n'D level) */ -#define CAVE_WIDTH (MAX_PLAYFIELD_WIDTH + 2) -#define CAVE_HEIGHT (MAX_PLAYFIELD_HEIGHT + 2) +#define CAVE_WIDTH MAX_PLAYFIELD_WIDTH +#define CAVE_HEIGHT MAX_PLAYFIELD_HEIGHT -/* with border for Zborder elements (surrounding the visible playfield) */ +/* additional padding for Zborder elements and linked cave buffer columns */ #define CAVE_BUFFER_XOFFSET 4 #define CAVE_BUFFER_YOFFSET 2 #define CAVE_BUFFER_WIDTH (CAVE_WIDTH + 2 * CAVE_BUFFER_XOFFSET) diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 616e80c1..a1afd713 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -6344,8 +6344,8 @@ void logic_3(void) for (count = lev.amoeba_time; count--;) { - x = lev.left - 1 + (random >> 10) % CAVE_WIDTH; - y = lev.top - 1 + (random >> 20) % CAVE_HEIGHT; + x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2); + y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2); if (x >= lev.left && x < lev.right && y >= lev.top && y < lev.bottom)