From aabdde1f5e4f678c5896c48454acdbe3f6c0535c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 2 Feb 2020 17:18:35 +0100 Subject: [PATCH] added support for wrap-around levels in EM engine --- src/game_em/convert.c | 14 ++++++++++++++ src/game_em/logic.c | 10 ++++++++++ 2 files changed, 24 insertions(+) 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; -- 2.34.1