Fix invalid spot's segfaults added with the new code.
This commit is contained in:
parent
ff0dd068be
commit
656f8e6190
@ -168,46 +168,53 @@ static void handle_card_movement(struct cursor *cursor) {
|
|||||||
if (maneuvre_stack(*origin) && marked_cards > 0) {
|
if (maneuvre_stack(*origin) && marked_cards > 0) {
|
||||||
erase_stack(*origin);
|
erase_stack(*origin);
|
||||||
unmark_cards(*origin);
|
unmark_cards(*origin);
|
||||||
|
draw_stack(*origin);
|
||||||
}
|
}
|
||||||
if (marked_cards > 1 && maneuvre_stack(*origin) && maneuvre_stack(*destination)) {
|
if (destination) {
|
||||||
struct stack *block = *origin;
|
if (marked_cards > 1 &&
|
||||||
for (int i = 1; i < marked_cards; block = block->next, i++)
|
maneuvre_stack(*origin) &&
|
||||||
;
|
maneuvre_stack(*destination)) {
|
||||||
if (destination && valid_move(block, *destination)) {
|
struct stack *block = *origin;
|
||||||
erase_stack(*origin);
|
for (int i = 1; i < marked_cards; block = block->next, i++)
|
||||||
struct stack *tmp;
|
;
|
||||||
allocate_stack(&tmp);
|
if (valid_move(block, *destination)) {
|
||||||
initialize_stack(tmp);
|
erase_stack(*origin);
|
||||||
for (int i = 0; i < marked_cards; i++) {
|
struct stack *tmp;
|
||||||
push(&tmp, pop(origin));
|
allocate_stack(&tmp);
|
||||||
|
initialize_stack(tmp);
|
||||||
|
for (int i = 0; i < marked_cards; i++) {
|
||||||
|
push(&tmp, pop(origin));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < marked_cards; i++) {
|
||||||
|
move_card(&tmp, destination);
|
||||||
|
}
|
||||||
|
if (length(*destination) > 1) {
|
||||||
|
erase_cursor(cursor);
|
||||||
|
cursor->y += marked_cards;
|
||||||
|
}
|
||||||
|
free_stack(tmp);
|
||||||
|
draw_stack(*origin);
|
||||||
|
draw_stack(*destination);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < marked_cards; i++) {
|
} else {
|
||||||
move_card(&tmp, destination);
|
if (valid_move(*origin, *destination)) {
|
||||||
}
|
erase_stack(*origin);
|
||||||
if (length(*destination) > 1) {
|
move_card(origin, destination);
|
||||||
erase_cursor(cursor);
|
if (maneuvre_stack(*destination) && length(*destination) > 1) {
|
||||||
cursor->y += marked_cards;
|
erase_cursor(cursor);
|
||||||
}
|
cursor->y++;
|
||||||
free_stack(tmp);
|
}
|
||||||
}
|
draw_stack(*origin);
|
||||||
} else {
|
draw_stack(*destination);
|
||||||
if (destination && valid_move(*origin, *destination)) {
|
|
||||||
erase_stack(*origin);
|
|
||||||
move_card(origin, destination);
|
|
||||||
if (maneuvre_stack(*destination) && length(*destination) > 1) {
|
|
||||||
erase_cursor(cursor);
|
|
||||||
cursor->y++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (maneuvre_stack(*origin) && *origin == *destination) {
|
||||||
if (maneuvre_stack(*origin) && destination && *origin == *destination) {
|
erase_cursor(cursor);
|
||||||
erase_cursor(cursor);
|
cursor->y--;
|
||||||
cursor->y--;
|
}
|
||||||
}
|
}
|
||||||
unmark_cursor(cursor);
|
unmark_cursor(cursor);
|
||||||
draw_cursor(cursor);
|
draw_cursor(cursor);
|
||||||
draw_stack(*origin);
|
|
||||||
draw_stack(*destination);
|
|
||||||
return;
|
return;
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
if (cursor_stack(cursor) == origin && maneuvre_stack(*origin)) {
|
if (cursor_stack(cursor) == origin && maneuvre_stack(*origin)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user