Advertisement
Weegee

Untitled

Aug 14th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. int destroy_obstacle(WINDOW * win_game, struct obstaclelist * olist, struct obstacle * target_ob)
  2. {
  3.     mvwaddch(win_game, ob->y_pos, ob->x_pos, ' ');
  4.     wrefresh(win_game);
  5.    
  6.     struct obstacle * prev;
  7.     struct obstacle * cur;
  8.     int state = EXIT_FAILURE;
  9.    
  10.     if (target_ob == olist->head)
  11.     {
  12.         olist->head = target_ob->next;
  13.         free(target_ob);
  14.         state = EXIT_SUCCESS;
  15.         olist->count--;
  16.     }
  17.     else
  18.     {
  19.         /* Go through the list */
  20.         for (cur = olist->head; cur != NULL; prev = cur, cur = cur->next)
  21.         {
  22.             if (cur == target_ob)
  23.             {
  24.                 prev->next = cur->next;
  25.                 free(cur);
  26.                 state = EXIT_SUCCESS;
  27.                 olist->count--;
  28.                 break;
  29.             }
  30.         }
  31.     }
  32.    
  33.     return state;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement