Esempio n. 1
3
void					putnbr(int n)
{
	if (n < 0)
	{
		ft_putchar('-');
		n = -n;
	}
	if (n > 9)
	{
		putnbr(n / 10);
		putnbr(n % 10);
	}
	else
		ft_putchar((char)(n + '0'));
}
Esempio n. 2
1
void			get_inventory(t_client *client,
				      char *buff,
				      t_info *info)
{
  int			i;
  struct timeval	tp;

  i = 0;
  gettimeofday(&tp, NULL);
  strcpy(buff, START_CMD);
  strcat(buff, gl_ressource[NB_INVENTORY - 1].name);
  strcat(buff, SEPARATOR_ELM);
  putnbr((client->hp - tp.tv_sec - tp.tv_usec / 1e6) / (FOOD_HP * info->time),
	 buff);
  while (i < NB_INVENTORY - 1)
    {
      if (i != (NB_INVENTORY - 1))
	strcat(strcat(buff, SEPARATOR_CMD), SEPARATOR_ELM);
      strcat(buff, gl_ressource[i].name);
      strcat(buff, SEPARATOR_ELM);
      putnbr(client->qte_ressource[i], buff);
      i++;
    }
  strcat(buff, END_CMD);
}
Esempio n. 3
-1
File: main.c Progetto: jay77190/42
void    putnbr(int n)
{
	if (n >= 10)
	{
		putnbr(n / 10);
		putnbr(n % 10);
	}
	else
	  putchar(48 + n);
}
Esempio n. 4
-1
void	putnbr(int nb)
{
	if (nb > 9)
	{
		putnbr(nb/10);
		putnbr(nb%10);
	}
	else
		ft_putchar(nb + '0');
}
Esempio n. 5
-1
int		act_broadcast(char *param, t_client *client,
			      t_info *info)
{
  t_list	*clients;
  t_client	*c;

  clients = info->clients;
  while (clients)
    {
      c = (t_client *)clients->data;
      if (c->status != ST_CLIENT)
	{
	  clients = clients->next;
	  continue;
	}
      if (c != client && client->status == ST_CLIENT)
	{
	  SEND(c->buf_write, MESSAGE);
	  putnbr(give_me_the_k(c, client, info), c->buf_write);
	  SEND(c->buf_write, ",");
	  SEND(c->buf_write, param);
	  SEND(c->buf_write, "\n");
	}
      clients = clients->next;
    }
  SEND(client->buf_write, OK);
  return (0);
}
Esempio n. 6
-1
int main(int ac, char **av)
{
	if (ac > 1)
		putnbr(ac - 1);
	ft_putchar('\n');
	return (0);
}
Esempio n. 7
-1
static void	levelup(t_client *client, t_info *info)
{
  t_list	*t;
  t_client	*c;
  void		*data;
  int		x;
  int		y;

  t = info->zone[client->x][client->y].clients;
  while (t)
    {
      c = t->data;
      c->level++;
      SEND(c->buf_write, LVLUP_OK);
      putnbr(c->level, c->buf_write);
      SEND(c->buf_write, "\n");
      t = t->next;
    }
  while ((data = pop_list(&(info->zone[client->x][client->y].ressources))))
    {
      x = get_random(info->x, client->x);
      y = get_random(info->y, client->y);
      push_list(&(info->zone[x][y].ressources), data);
      obs_send_new_item(info->observator, x, y, data);
    }
}
Esempio n. 8
-1
void    my_put_nbr(int nb)
{
  if (nb < 0)
    my_putchar('-');
  if (nb == 0)
    my_putchar('0');
  putnbr(nb);
}
Esempio n. 9
-1
void isr_handler(registers_t regs)
{
  puts(INFO_COLOR "interrupt handler\n" DEF_COLOR);
  puts("Interrupt number: ");
  putnbr(regs.int_no);
  putc('\n');
  if (regs.err_code)
    {
      puts("Error code: ");
      putnbr(regs.err_code);
      putc('\n');
    }
  if (handlers[regs.int_no])
    handlers[regs.int_no](&regs);
  else
    PANIC("Unhandled interruption\n");
}
Esempio n. 10
-1
void	obs_add_client_in_char(char *buf, t_client *client,
			       t_info *info, char is_a_bird)
{
  char	buff[LEN_INVENTORY];

  buff[0] = 0;
  strcat(buf, "ADD_CLIENT ");
  putnbr(is_a_bird, buf);
  strcat(buf, " ");
  putnbr(client->id, buf);
  strcat(buf, " ");
  strcat(buf, client->team->name);
  strcat(buf, " ");
  putnbr(get_position_from_list(info->team, client->team), buf);
  strcat(buf, " ");
  putnbr(client->level, buf);
  strcat(buf, " ");
  putnbr(client->x, buf);
  strcat(buf, " ");
  putnbr(client->y, buf);
  strcat(buf, " ");
  putnbr(client->direction, buf);
  strcat(buf, " ");
  get_inventory_id(client, buff, info);
  strcat(buf, buff);
  strcat(buf, "\n");
}
Esempio n. 11
-1
void    putnbr(int nb)
{
  int   n;

  if (nb != 0)
    {
      n = nb % 10;
      putnbr(nb / 10);
      my_putchar('0' + n);
    }
}
Esempio n. 12
-1
void	putnbr(int nb)
{
  int	ch1;
  int	ch2;

  if (nb < 0)
    {
      nb *= -1;
      write(1, "-", 1);
    }
  ch1 = nb % 10;
  ch2 = nb / 10;
  if (ch2 > 9)
    putnbr(ch2);
  else if (ch2 > 0)
    write(1, ch2 + '0', 1);
  write(1, ch1 + '0', 1);
}