Example #1
0
int		cmd_tin(t_server *s, t_client *c, char *cmd, e_client_type type)
{
  (void)type;
  char		*team;
  char		*trame;
  int		nb_players;
  int		nb_players_lvl_8;

  nb_players = 0;
  nb_players_lvl_8 = 0;
  team = xmalloc((strlen(cmd) - 3) * sizeof(char));
  bzero(team, strlen(cmd) - 3);
  sscanf(cmd, "tin %s", team);
  printf("TEAM = %s\n", team);
  nb_players = get_nb_players_by_team(s->clients, team);
  nb_players_lvl_8 = get_nb_players_lvl_8_by_team(s->clients, team);
  trame = malloc_and_memset((8 + strlen(team)
		   + istm(nb_players)
		   + istm(nb_players_lvl_8)) * sizeof(char));
  sprintf(trame, "tin %s %d %d\n", team, nb_players, nb_players_lvl_8);
  printf("trame = %s", trame);
  send_data(c->fd, trame);
  free(trame);
  return (SUCCESS);
}
Example #2
0
int		cmd_pie(t_server *s, t_client *c,
			char *cmd, e_client_type type)
{
  (void)s;
  (void)cmd;
  (void)type;
  int		size_malloc;
  char		*str;

  size_malloc = 8 + istm(c->pos->x) + istm(c->pos->y) + 1;
  str = malloc_and_memset(size_malloc);
  sprintf(str, "pie %d %d %d\n", c->pos->x, c->pos->y, 1);
  send_data_to_gui(s->clients, str);
  free(str);
  return (SUCCESS);
}
Example #3
0
int		cmd_pfk(t_client *c, t_list *clients)
{
  int		size_malloc;
  char		*str;

  size_malloc = 7 + istm(c->fd);
  str = malloc_and_memset(size_malloc);
  sprintf(str, "pfk #%d\n", c->fd);
  send_data_to_gui(clients, str);
  free(str);
  return (SUCCESS);
}
Example #4
0
std::vector<std::string> splitString(std::string src, char c)
{
    std::vector<std::string> out;
    if (src.empty())
        return out;
    std::istringstream istm(src);
    std::string temp;
    while (std::getline(istm, temp, c)) {
        out.push_back(temp);
    }
    return out;
}