From: Holger Schemel Date: Sun, 2 Feb 2020 16:18:35 +0000 (+0100) Subject: added support for wrap-around levels in EM engine X-Git-Tag: 4.2.0.0~159 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=aabdde1f5e4f678c5896c48454acdbe3f6c0535c;p=rocksndiamonds.git added support for wrap-around levels in EM engine --- diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 65efdcc1..d25c4593 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -945,6 +945,20 @@ void prepare_em_level(void) lev.right = lev.left + lev.width; lev.bottom = lev.top + lev.height; + /* add linked cave buffer columns for wrap-around movement */ + for (x = 0; x < lev.left; x++) + { + lev.cavecol[x] = lev.cavecol[lev.width + x]; + lev.nextcol[x] = lev.nextcol[lev.width + x]; + lev.drawcol[x] = lev.drawcol[lev.width + x]; + lev.boomcol[x] = lev.boomcol[lev.width + x]; + + lev.cavecol[lev.right + x] = lev.cavecol[lev.left + x]; + lev.nextcol[lev.right + x] = lev.nextcol[lev.left + x]; + lev.drawcol[lev.right + x] = lev.drawcol[lev.left + x]; + lev.boomcol[lev.right + x] = lev.boomcol[lev.left + 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]; diff --git a/src/game_em/logic.c b/src/game_em/logic.c index d126415b..616e80c1 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -6228,6 +6228,16 @@ void logic_1(void) for (i = 0; i < MAX_PLAYERS; i++) { + /* check for wrap-around movement */ + if (ply[i].x < lev.left || + ply[i].x > lev.right - 1) + { + ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left); + + game.centered_player_nr_next = i; + game.set_centered_player = TRUE; + } + ply[i].oldx = ply[i].x; ply[i].oldy = ply[i].y; ply[i].anim = PLY_still;