Esempio n. 1
0
int		complete_effect(FILE *fd, int *effect)
{
  char		*tmp;
  char		**tab;
  int		size_tab;

  if ((tmp = get_line(fd)) == NULL)
    return (error("Sorry, obj[effect][undeclared] error\n"));
  tab = my_str_to_word_tab(&size_tab, tmp, ' ');
  if (size_tab != 2)
    return (error_parsing(tmp, "Sorry, effect[nb_arg] error at this line : "));
  if (my_strcmp(tab[0], "effect") != 0)
    return (error_parsing(tmp,
			  "Sorry, function call[effect] error at this line : "));
  *effect = my_getnbr(tab[1]);
  free_tab(tab, size_tab);
  free(tmp);
  return (SUCCES);
}
Esempio n. 2
0
int		complete_brillance(FILE *fd, float *brillance)
{
  char		*tmp;
  char		**tab;
  int		size_tab;

  if ((tmp = get_line(fd)) == NULL)
    return (error("Sorry, obj[brillance][undeclared] error\n"));
  tab = my_str_to_word_tab(&size_tab, tmp, ' ');
  if (size_tab != 2)
    return (error_parsing(tmp,
			  "Sorry, brillance[nb_arg] error at this line : "));
  if (my_strcmp(tab[0], "brillance") != 0)
    return (error_parsing(tmp,
			  "Sorry, func call[brillance] error at this line : "));
  *brillance = my_getnbr(tab[1]);
  free_tab(tab, size_tab);
  free(tmp);
  return (SUCCES);
}
Esempio n. 3
0
int		complete_color(FILE *fd, int *color)
{
  char		*tmp;
  char		**tab;
  int		size_tab;

  if ((tmp = get_line(fd)) == NULL)
    return (error("Sorry, obj[color][undeclared] error\n"));
  tab = my_str_to_word_tab(&size_tab, tmp, ' ');
  if (size_tab != 2)
    return (error_parsing(tmp,
			  "Sorry, color[nb_arg] error at this line : "));
  if (my_strcmp(tab[0], "color") != 0)
    return (error_parsing(tmp,
			  "Sorry, function call[color] error at this line : "));
  *color = my_getnbr_hex(tab[1]);
  free_tab(tab, size_tab);
  free(tmp);
  return (SUCCES);
}
Esempio n. 4
0
int		complete_def_norme(FILE *fd, int *def_norme)
{
  char		*tmp;
  char		**tab;
  int		size_tab;

  if ((tmp = get_line(fd)) == NULL)
    return (error("Sorry, obj[def_norme][undeclared] error\n"));
  tab = my_str_to_word_tab(&size_tab, tmp, ' ');
  if (size_tab != 2)
    return (error_parsing(tmp,
			  "Sorry, def_norme[nb_arg] error at this line : "));
  if (my_strcmp(tab[0], "def_norme") != 0)
    {
      my_putstr("Sorry, function call[def norme]");
      return (error_parsing(tmp, "error at this line : "));
    }
  *def_norme = my_getnbr(tab[1]);
  free_tab(tab, size_tab);
  free(tmp);
  return (SUCCES);
}
Esempio n. 5
0
int		complete_pos(FILE *fd, t_coordonne *pos)
{
  char		*tmp;
  char		**tab;
  int		size_tab;

  if ((tmp = get_line(fd)) == NULL)
    return (error("Sorry, obj[pos][undeclared] error"));
  tab = my_str_to_word_tab(&size_tab, tmp, ' ');
  if (size_tab != 4)
    return (error_parsing(tmp,
			  "Sorry, pos[nb_arg] error at this line : "));
  if (my_strcmp(tab[0], "pos") != 0)
    return (error_parsing(tmp,
			  "Sorry, function call[pos] error at this line : "));
  pos->x = my_getnbr(tab[1]);
  pos->y = my_getnbr(tab[2]);
  pos->z = my_getnbr(tab[3]);
  free_tab(tab, size_tab);
  free(tmp);
  return (SUCCES);
}
static int	check_input_champ(char **ag, t_list **list,
				  t_game *game, int i)
{
  char		**tab;

  if (ag[i] == NULL)
    return (my_perror(ERR_ARG));
  while (ag[i] != NULL)
    {
      if ((tab = my_str_to_word_tab(ag[i])) == NULL)
	return (my_perror(STR_TAB));
      if ((use_input(tab, list)) == ERROR)
	{
	  my_free_tab(tab);
	  return (ERROR);
	}
      i = i + 1;
      my_free_tab(tab);
    }
  if (i == 1 && game->dump_cycle == -1)
    return (my_perror(ERR_ARG));
  return (GOOD);
}
Esempio n. 7
0
int		complete_lim_max(FILE *fd, t_coordonne *lim)
{
  char		*tmp;
  char		**tab;
  int		size_tab;

  if ((tmp = get_line(fd)) == NULL)
    return (error("Sorry, obj[lim][undeclared] error\n"));
  tab = my_str_to_word_tab(&size_tab, tmp, ' ');
  if (size_tab != 4)
    return (error_parsing(tmp,
			  "Sorry, lim[nb_arg] error at this line : "));
  if (my_strcmp(tab[0], "lim_max") != 0)
    {
      my_putstr("Sorry, function call[lim]");
      return (error_parsing(tmp, "error at this line : "));
    }
  lim->x = my_getnbr(tab[1]);
  lim->y = my_getnbr(tab[2]);
  lim->z = my_getnbr(tab[3]);
  free_tab(tab, size_tab);
  free(tmp);
  return (SUCCES);
}