From: Holger Schemel Date: Sun, 17 Feb 2019 18:35:56 +0000 (+0100) Subject: fixed removing same player in level editor when drawing new player X-Git-Tag: 4.1.2.0~9 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=37580702ec235276fd1bc656c01e5cc9ae48a683;p=rocksndiamonds.git fixed removing same player in level editor when drawing new player Before this fix, this feature did not work with player 2, 3 and 4, and it also did not work with "sokoban field with player" element. --- diff --git a/src/editor.c b/src/editor.c index 12562f76..3fa42f10 100644 --- a/src/editor.c +++ b/src/editor.c @@ -12791,13 +12791,37 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) { SetDrawModeHiRes(new_element); - if (new_element == EL_PLAYER_1) + if (ELEM_IS_PLAYER(new_element)) { // remove player at old position for (y = 0; y < lev_fieldy; y++) + { for (x = 0; x < lev_fieldx; x++) - if (Feld[x][y] == EL_PLAYER_1) - SetElement(x, y, EL_EMPTY); + { + int old_element = Feld[x][y]; + + if (ELEM_IS_PLAYER(old_element)) + { + int replaced_with_element = + (old_element == EL_SOKOBAN_FIELD_PLAYER && + new_element == EL_PLAYER_1 ? EL_SOKOBAN_FIELD_EMPTY : + + old_element == EL_SOKOBAN_FIELD_PLAYER && + new_element == old_element ? EL_SOKOBAN_FIELD_EMPTY : + + new_element == EL_SOKOBAN_FIELD_PLAYER && + old_element == EL_PLAYER_1 ? EL_EMPTY : + + new_element >= EL_PLAYER_1 && + new_element <= EL_PLAYER_4 && + new_element == old_element ? EL_EMPTY : + + old_element); + + SetElement(x, y, replaced_with_element); + } + } + } } SetElementButton(lx, ly, dx, dy, new_element, button);