ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
+ // make sure that tile size is always a power of 2
+ ed_tilesize = (1 << log_2(ed_tilesize));
+
if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
{
ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
};
static int last_x = -1;
static int last_y = -1;
- int old_element = IntelliDrawBuffer[x][y];
if (new_element == EL_UNDEFINED)
{
return;
}
+ int old_element = IntelliDrawBuffer[x][y];
+
if (IS_TUBE(new_element))
{
int last_element_new = EL_UNDEFINED;
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)
char *clipboard_text = SDL_GetClipboardText();
char *ptr = clipboard_text;
+ boolean allow_new_row = FALSE;
boolean stop = FALSE;
while (*ptr && !stop)
{
boolean prefix_found = FALSE;
+ boolean start_new_row = FALSE;
// level sketch element number prefixes (may be multi-byte characters)
char *prefix_list[] = { "`", "ΒΈ" };
}
}
- // continue with next character if prefix not found
- if (!prefix_found)
- {
- ptr++; // !!! FIX THIS for real UTF-8 handling !!!
-
- continue;
- }
-
- // continue with next character if prefix not found
- if (strlen(ptr) < 3)
- break;
-
- if (ptr[0] >= '0' && ptr[0] <= '9' &&
+ // check if prefix found and followed by three numbers
+ if (prefix_found &&
+ strlen(ptr) >= 3 &&
+ ptr[0] >= '0' && ptr[0] <= '9' &&
ptr[1] >= '0' && ptr[1] <= '9' &&
ptr[2] >= '0' && ptr[2] <= '9')
{
x++;
- if (x >= MAX_LEV_FIELDX || *ptr == '\n')
- {
- x = 0;
- y++;
+ if (x >= MAX_LEV_FIELDX)
+ start_new_row = TRUE;
- if (y >= MAX_LEV_FIELDY)
- stop = TRUE;
- }
+ allow_new_row = TRUE;
+ }
+ else
+ {
+ if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
+ start_new_row = TRUE;
+
+ ptr++; // !!! FIX THIS for real UTF-8 handling !!!
+ }
+
+ if (start_new_row)
+ {
+ x = 0;
+ y++;
+
+ if (y >= MAX_LEV_FIELDY)
+ stop = TRUE;
+
+ allow_new_row = FALSE;
}
}
}
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;
}
{
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);