void cmd_expulse(t_server *serv, int actual, char *buff) { int *who; int i; int j; (void)buff; i = 0; who = (int *)ft_memalloc(sizeof(int) * serv->connected); j = find_client_to_expulse(serv, actual, who); while (i < j) { if (serv->clients[actual].dir % 2 == 0) cmd_expulse2(serv, actual, who[i]); else cmd_expulse3(serv, actual, who[i]); if (serv->gfx.sock) ppo(serv->gfx.sock, &serv->clients[who[i]]); cmd_expulse4(serv, actual, who[i]); i++; } if (j == 0) write_client(serv->clients[actual].sock, "ko"); else write_client(serv->clients[actual].sock, "ok"); }
void cmd_droite(t_server *serv, int actual, char *buff) { (void)buff; serv->clients[actual].dir = (serv->clients[actual].dir + 1) % 4; if (serv->gfx.sock) ppo(serv->gfx.sock, &serv->clients[actual]); write_client(serv->clients[actual].sock, "ok"); }
void gauche(t_env *env, t_action *action) { if (difftime(time(NULL), action->time) >= 7 / env->time) { action->client->player.dir = (action->client->player.dir + 1) % 4; add_output(action->client, strdup("ok\n")); ppo(env, action->client); delete_action(action); } }
static void cmd_avance2(t_server *serv, int actual) { if (serv->gfx.sock) ppo(serv->gfx.sock, &serv->clients[actual]); write_client(serv->clients[actual].sock, "ok"); printf("YOUR POSITION IS NOW: x: %d y: %d dir:%d\n", serv->clients[actual].x, serv->clients[actual].y, serv->clients[actual].dir); printf("player %d avance\n", actual); }
const char *_player_right(t_player *player, const t_server *server, void *arg) { (void)arg; if (!player->is_allowed(player)) return ("ko\n"); look_in_good_direction(player); notify_graph(server, ppo(player)); return ("ok\n"); }
void cmd_gauche(t_server *serv, int actual, char *buff) { if ((serv->clients[actual].dir - 1) == -1) serv->clients[actual].dir = 3; else serv->clients[actual].dir--; if (serv->gfx.sock) ppo(serv->gfx.sock, &serv->clients[actual]); write_client(serv->clients[actual].sock, "ok"); (void)buff; }
int event_players_expulsed(t_srv *srv, t_client *client) { t_graphic g; char buff[11]; bzero(buff, 11); g.graphic = srv->views; g.length_graphic = -1; sprintf(buff, "%d", client->fd); return (ppo(srv, &g, buff, NULL)); }
void fptr_ppo(t_env *env, t_action *action) { int id; char *err; t_client *client; err = NULL; if (action->input[1] == NULL) sbp(env); else { id = strtol(action->input[1], &err, 10); if (err[0] != '\0' || (client = find_by_id(env, id)) == NULL) sbp(env); else ppo(env, client); } delete_action(action); }
void gfx_player_expulse(t_ctrl *c, t_player *p, int *ids) { t_jm_list *l; int i; i = 0; l = c->l; while (l) { if (l->fd != -1 && l->data && ((t_handler *)l->data)->t == GFX) { pex(l, p->id); while (ids[i]) { ppo(c, l, ids[i]); i++; } } l = l->next; } }