X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Feditor.c;h=3fa42f10eab74c5accddb47ecc8d90872e340f06;hp=1c7edbea94e919afc5bb2a9af3908922a20d4c05;hb=f37c86753d5005bf7ae341d0cbcc15ef75393567;hpb=a412e5ffa431630da69ac6c64fd5bb50974a4947 diff --git a/src/editor.c b/src/editor.c index 1c7edbea..3fa42f10 100644 --- a/src/editor.c +++ b/src/editor.c @@ -11660,11 +11660,21 @@ static void ResetIntelliDraw(void) static boolean draw_mode_hires = FALSE; +static boolean isHiresTileElement(int element) +{ + return (IS_MM_WALL(element) || element == EL_EMPTY); +} + +static boolean isHiresDrawElement(int element) +{ + return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY); +} + static void SetDrawModeHiRes(int element) { draw_mode_hires = (level.game_engine_type == GAME_ENGINE_TYPE_MM && - (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY)); + isHiresDrawElement(element)); } static boolean getDrawModeHiRes(void) @@ -12705,9 +12715,13 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) } else if (!button_press_event) { + int old_element = (IN_LEV_FIELD(lx, ly) ? Feld[lx][ly] : EL_UNDEFINED); + boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM && + isHiresTileElement(old_element) && + isHiresDrawElement(new_element)); + // prevent handling events for every pixel position when moving mouse - if ((sx == last_sx && sy == last_sy && - !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) || + if ((sx == last_sx && sy == last_sy && !hires_drawing) || (sx2 == last_sx2 && sy2 == last_sy2)) return; } @@ -12777,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);