From: Holger Schemel Date: Sat, 30 Sep 2023 09:24:32 +0000 (+0200) Subject: fixed CE condition that checks touching the player at some side X-Git-Tag: 4.3.7.0~19 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=d271674493a6d9fc022cc2e8895c5e36449ac585 fixed CE condition that checks touching the player at some side In the level editor on the "change" tab of a custom element, when using the CE condition "[x] element changes ..." in combination with "[x][touching] element []" with "at [] side", there was wrong behaviour in some cases when "" was the player. This was caused by not checking the side of the player (that was being touched by the custom element), but by checking the side of the custom element (touching the player), which is the exact opposite side here. This change fixes the bug, now always checking the correct side as it is configured in the level editor. (Regarding to the game engine test suite, this functional game engine change did not break any tapes.) --- diff --git a/src/game.c b/src/game.c index a025b4b9..31177730 100644 --- a/src/game.c +++ b/src/game.c @@ -13465,8 +13465,9 @@ void TestIfPlayerTouchesCustomElement(int x, int y) incorrectly give EL_PLAYER_1 for "player->element_nr") */ int player_element = PLAYERINFO(x, y)->initial_element; + // as element "X" is the player here, check opposite (center) side CheckElementChangeBySide(xx, yy, border_element, player_element, - CE_TOUCHING_X, border_side); + CE_TOUCHING_X, center_side); } } else if (IS_PLAYER(xx, yy)) // player found at border element @@ -13492,8 +13493,9 @@ void TestIfPlayerTouchesCustomElement(int x, int y) incorrectly give EL_PLAYER_1 for "player->element_nr") */ int player_element = PLAYERINFO(xx, yy)->initial_element; + // as element "X" is the player here, check opposite (border) side CheckElementChangeBySide(x, y, center_element, player_element, - CE_TOUCHING_X, center_side); + CE_TOUCHING_X, border_side); } break; @@ -13600,7 +13602,7 @@ void TestIfElementTouchesCustomElement(int x, int y) CheckElementChangeBySide(xx, yy, border_element, center_element, CE_TOUCHING_X, center_side); - // (center element cannot be player, so we dont have to check this here) + // (center element cannot be player, so we don't have to check this here) } for (i = 0; i < NUM_DIRECTIONS; i++) @@ -13627,6 +13629,7 @@ void TestIfElementTouchesCustomElement(int x, int y) incorrectly give EL_PLAYER_1 for "player->element_nr") */ int player_element = PLAYERINFO(xx, yy)->initial_element; + // as element "X" is the player here, check opposite (border) side CheckElementChangeBySide(x, y, center_element, player_element, CE_TOUCHING_X, border_side); }