From: Holger Schemel Date: Wed, 29 Jan 2020 21:54:12 +0000 (+0100) Subject: added using cave buffer offsets in EM level conversion and game logic X-Git-Tag: 4.2.0.0~162 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a19843471dc3ebab17890f54cb2eb8aa82a7ac8a;p=rocksndiamonds.git added using cave buffer offsets in EM level conversion and game logic --- diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 5553772e..65efdcc1 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -938,22 +938,20 @@ void prepare_em_level(void) /* reset all runtime variables to their initial values */ + game_init_cave_buffers(); + lev.left = CAVE_BUFFER_XOFFSET; lev.top = CAVE_BUFFER_YOFFSET; lev.right = lev.left + lev.width; lev.bottom = lev.top + lev.height; - for (y = 0; y < CAVE_HEIGHT; y++) - for (x = 0; x < CAVE_WIDTH; x++) + for (x = 0; x < lev.width; x++) + for (y = 0; y < lev.height; y++) lev.cave[lev.left + x][lev.top + y] = native_em_level.cave[x][y]; - for (y = 0; y < CAVE_BUFFER_HEIGHT; y++) - for (x = 0; x < CAVE_BUFFER_WIDTH; x++) - lev.next[x][y] = lev.cave[x][y]; - - for (y = 0; y < CAVE_BUFFER_HEIGHT; y++) - for (x = 0; x < CAVE_BUFFER_WIDTH; x++) - lev.draw[x][y] = lev.cave[x][y]; + for (x = lev.left; x < lev.right; x++) + for (y = lev.top; y < lev.bottom; y++) + lev.next[x][y] = lev.draw[x][y] = lev.cave[x][y]; lev.time_initial = lev.time_seconds; lev.time = lev.time_initial; diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 808db47d..89de4ee5 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -6273,8 +6273,8 @@ void logic_2(void) seed = RandomEM; score = 0; - for (y = 1; y < CAVE_BUFFER_HEIGHT - 1; y++) - for (x = 0; x < CAVE_BUFFER_WIDTH; x++) + for (y = lev.top; y < lev.bottom; y++) + for (x = lev.left; x < lev.right; x++) handle_tile(x, y); if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive) @@ -6346,13 +6346,13 @@ void logic_3(void) /* handle explosions */ - for (y = 1; y < CAVE_BUFFER_HEIGHT - 1; y++) - for (x = 1; x < CAVE_BUFFER_WIDTH - 1; x++) + for (y = lev.top; y < lev.bottom; y++) + for (x = lev.left; x < lev.right; x++) Lexplode(x, y); /* triple buffering */ - for (y = 0; y < CAVE_BUFFER_HEIGHT; y++) - for (x = 0; x < CAVE_BUFFER_WIDTH; x++) + for (y = lev.top; y < lev.bottom; y++) + for (x = lev.left; x < lev.right; x++) next[x][y] = cave[x][y]; }