Exemple #1
0
static void	push_map(t_map **map, int x, int y)
{
  t_map		*tmp;

  if ((tmp = malloc(sizeof(t_map))) == NULL)
    exit_mess(666, "Error: Bad malloc");
  tmp->x = x;
  tmp->y = y;
  tmp->objects = NULL;
  tmp->players = NULL;
  if (*map == NULL)
    {
      tmp->next = tmp;
      tmp->prev = tmp;
      *map = tmp;
    }
  else
    {
      tmp->prev = (*map)->prev;
      tmp->next = *map;
    }
  (*map)->prev->next = tmp;
  (*map)->prev = tmp;
  *map = tmp;
}
Exemple #2
0
void		push_queue(t_queu **queue, char *comm, char *param)
{
  t_queu	*tmp;

  if ((tmp = malloc(sizeof(t_queu))) == NULL)
    exit_mess(666, "Error: Bad malloc");
  tmp->comm = strdup(comm);
  tmp->param = strdup(param);
  if (strncmp(comm, "fork", 4) == 0)
    tmp->delay = 42;
  else if (strncmp(comm, "incantation", 11) == 0)
    tmp->delay = 300;
  else
    tmp->delay = strncmp(comm, "connect_nbr", 11) == 0 ? 0 : 7;
  tmp->next = *queue;
  *queue = tmp;
}