Beispiel #1
0
int64 FE(int n, int d) {
	if (n == 0) {
		if (d == 0) return 1;
		return 0;
	}
	if (d < 0 || n < d || n < 0) return 0;
	if (n == 1) {
		if (d == 1) return 1;
		return 0;
	}
	if (fe[n][d] != -1) return fe[n][d];
	int64 ret = 0, t;
	for (int i = 0; i < n; ++i) {
		t = FE(i, d-1) * FL(n-1-i, d-1) % MOD + 
			FL(i, d-1) * FE(n-1-i, d-1) % MOD - 
			FE(i, d-1) * FE(n-1-i, d-1) % MOD;
		_MOD(t);
		if (i < n-1 && c[n-2][i] > 0) t *= c[n-2][i];
		_MOD(t);
		ret += t;
		_MOD(ret);
	}
	ret *= n;
	_MOD(ret);
	return fe[n][d] = ret;
}
void		cli_gauche(t_request_data *rqd, t_server *t, t_world *w)
{
  char		response[251];

  (void) w;
  rqd->user->orientation = _MOD(rqd->user->orientation - 1, 4);
  cli_answer(rqd->user, t, "ok\n");
  sprintf(response, "ppo %d %d %d %d\n", rqd->user->number,
	  rqd->user->posx, rqd->user->posy, rqd->user->orientation + 1);
  cli_answer_to_all_graph(t, response);
}
Beispiel #3
0
int		graph_command_bct(t_graph_data *rqd,
				  t_server *s, t_world *w)
{
  int		x;
  int		y;
  int       map_info[2];
  char		response[STR_LIMIT];

  (void) s;
  x = -1;
  y = -1;
  sscanf(rqd->message, "bct %d %d\n", &x, &y);
  if (x < 0 || y < 0)
    return (cli_answer_to_graph(rqd->user, "sbp\n"));
  x = _MOD(x, w->width);
  y = _MOD(y, w->height);
  map_info[0] = x;
  map_info[1] = y;
  sprintf(response, "bct %d %d", x, y);
  get_content(map_info, response, w);
  strcat(response, "\n");
  cli_answer_to_graph(rqd->user, response);
  return (0);
}
void		cli_avance(t_request_data *rqd, t_server *t, t_world *w)
{
  t_point	n;
  char		response[ANSWER_SIZE + 1];

  n.x = _MOD(rqd->user->posx + g_steps[rqd->user->orientation].x,
	     w->width);
  n.y = _MOD(rqd->user->posy + g_steps[rqd->user->orientation].y,
	     w->height);
  if (n.x != rqd->user->posx || n.y != rqd->user->posy)
    {
      item_delete_by_content(w->surface[rqd->user->posy]
			     [rqd->user->posx].players,
			     (void*)(rqd->user));
      rqd->user->posx = n.x;
      rqd->user->posy = n.y;
      item_pf(w->surface[rqd->user->posy][rqd->user->posx].players,
	      (void*)(rqd->user), sizeof(t_user_player));
    }
  cli_answer(rqd->user, t, "ok\n");
  sprintf(response, "ppo %d %d %d %d\n", rqd->user->number,
	  rqd->user->posx, rqd->user->posy, rqd->user->orientation + 1);
  cli_answer_to_all_graph(t, response);
}