Beispiel #1
0
int calculate(GPS_INFO *gps_info, ROAD_INFO *road_info, struct ev_loop *loop)
{

	long current_roadID = road_info->road_rootID * 1000 + road_info->segmentID;
	long old_roadID = 1;
	KV_IMEI kv_IMEI = {0};
	KV_ROADID kv_roadID = {0};
	int flag = get_IMEI_road(gps_info->IMEI, current_roadID, &kv_IMEI, gps_info);
	
	switch(flag) {
		case 0:
			old_roadID = change_road(gps_info, current_roadID, &kv_IMEI, &kv_roadID);
			if (0 == old_roadID){
				return -1;
			}
			update_to_redis(&kv_roadID, old_roadID, loop);
			break;
		case 1:
			if(same_road(gps_info, current_roadID, &kv_IMEI) == -1) {
				return -1;
			}
			break;
		case 2:
			if (set_IMEI_to_kv(gps_info, current_roadID, &kv_IMEI, 1) == -1){
				x_printf(E, "Failed to set the kv value what the key is IMEI FIRST!\n");
				return -1;
			}
			x_printf(D, "this IMEI is the first!\n");
			break;
		default:
			break;
	}
	return 0;
}
Beispiel #2
0
int			change_scene_two_zero(t_data *data)
{
  t_bunny_position	pos;

  pos.x = WIDTH - 100;
  pos.y = 400;
  if (data->mv_s->mouse->x + data->mv_s->mv_bck >= 1948
      && data->mv_s->mouse->x + data->mv_s->mv_bck <= 2048
      && data->mv_s->mouse->y <= 500 && data->mv_s->mouse->y >= 400)
    {
      put_pix_in_pix(data->pixel, data->tab[13].front, pos, 0);
      if (data->mv_s->click == 1)
	{
	  data->mv_s->s_nb = 0;
	  data->mv_s->mv_fr = 0;
	  data->mv_s->mv_bck = 0;
	  data->mv_s->click = 0;
	  if ((data->p = change_road(0, data->p)) == NULL
	      || (data->node = change_list(data->p)) == NULL)
	    return (1);
	  pos_player(data->player, data->node);
	}
    }
  return (0);
}
Beispiel #3
0
int			change_scene_two_four(t_data *data)
{
  t_bunny_position	pos;

  pos.x = 1150 - data->mv_s->mv_bck;
  pos.y = 300;
  if (data->mv_s->mouse->x + data->mv_s->mv_bck >= 1150
      && data->mv_s->mouse->x + data->mv_s->mv_bck <= 1250
      && data->mv_s->mouse->y <= 400 && data->mv_s->mouse->y >= 300)
    {
      put_pix_in_pix(data->pixel, data->tab[11].front, pos, 0);
      if (data->mv_s->click == 1)
	{
	  data->mv_s->s_nb = 4;
	  data->mv_s->mv_fr = WIDTH - 4;
	  data->mv_s->mv_bck = WIDTH - 4;
	  data->mv_s->click = 0;
	  if ((data->p = change_road(0, data->p)) == NULL
	      || (data->node = change_list(data->p)) == NULL)
	    return (1);
	  pos_player(data->player, data->node);
	}
    }
  return (0);
}
Beispiel #4
0
int			change_scene_six_seven(t_data *data)
{
  t_bunny_position	pos;

  pos.x = 200;
  pos.y = 400;
  if (data->mv_s->mouse->x >= 200
      && data->mv_s->mouse->x <= 300
      && data->mv_s->mouse->y <= 500 && data->mv_s->mouse->y >= 400)
    {
      put_pix_in_pix(data->pixel, data->tab[10].front, pos, 0);
      if (data->mv_s->click == 1)
	{
	  data->mv_s->s_nb = 7;
	  data->mv_s->mv_fr = 0;
	  data->mv_s->mv_bck = 0;
	  data->mv_s->click = 0;
	  if ((data->p = change_road(7, data->p)) == NULL
	      || (data->node = change_list(data->p)) == NULL)
	    return (1);
	  pos_player(data->player, data->node);
	}
    }
  return (0);
}