This is better here.

This commit is contained in:
Murilo Pereira 2011-02-09 23:51:07 -02:00
parent f28c1ce6fd
commit e8cf7b92a0

View File

@ -10,16 +10,6 @@ static bool maneuvre_stack(struct stack *stack) {
return(stack->card->frame->start_y >= MANEUVRE_STACKS_STARTING_Y); return(stack->card->frame->start_y >= MANEUVRE_STACKS_STARTING_Y);
} }
static void refresh_card_coordinates(struct stack *origin, struct stack *destination) {
origin->card->frame->start_x = destination->card->frame->start_x;
origin->card->frame->start_y = destination->card->frame->start_y;
if (!empty(destination) && maneuvre_stack(destination)) {
origin->card->frame->start_y++;
}
return;
}
void allocate_stack(struct stack **stack) { void allocate_stack(struct stack **stack) {
if (!(*stack = malloc(sizeof(**stack)))) { if (!(*stack = malloc(sizeof(**stack)))) {
fprintf(stderr, "%s: %s (%s:%d)\n", program_name, strerror(errno), __FILE__, __LINE__ - 1); fprintf(stderr, "%s: %s (%s:%d)\n", program_name, strerror(errno), __FILE__, __LINE__ - 1);
@ -102,7 +92,11 @@ struct stack *pop(struct stack **stack) {
void move_card(struct stack **origin, struct stack **destination) { void move_card(struct stack **origin, struct stack **destination) {
struct stack *stack = NULL; struct stack *stack = NULL;
refresh_card_coordinates(*origin, *destination); (*origin)->card->frame->start_x = (*destination)->card->frame->start_x;
(*origin)->card->frame->start_y = (*destination)->card->frame->start_y;
if (!empty(*destination) && maneuvre_stack(*destination)) {
(*origin)->card->frame->start_y++;
}
stack = pop(origin); stack = pop(origin);
push(destination, stack->card); push(destination, stack->card);