示例#1
0
static int select_user_callback(void *data, int argc, char *argv[], char *columns[])
{
  bgg_client::data::user * user = (bgg_client::data::user *) data;
  user->setForumNick("");
  user->setBggNick("");
  user->accessCollection().clear();

  for (uint32_t i = 0; i < argc; i++) {
    if (argv[i] == nullptr) break;

    if (std::string(columns[i]) == "bggnick") {
      user->setBggNick(std::string(argv[i]));
    }

    if (std::string(columns[i]) == "forumnick") {
      user->setForumNick(std::string(argv[i]));
    }

    if (std::string(columns[i]) == "games") {
      std::string plain_list(argv[i]);
      ssize_t last_pos(0);
      ssize_t pos(0);

      while ((pos = plain_list.find(" ", last_pos)) != std::string::npos) {
        bgg_client::data::game g;
        g.setGameId(std::atoi(plain_list.substr(last_pos, pos).c_str()));
        user->accessCollection().push_back(g);
        last_pos = pos + 1;
      }
    }
  }

  return 0;
}
示例#2
0
static int game_by_id_callback(void *data, int argc, char *argv[], char *column[])
{
  bgg_client::data::game * game = (bgg_client::data::game *) data;

  for (uint32_t i = 0; i < argc; i++) {
    if (argv[i] == nullptr) break;
    std::string col(column[i]);

    if (col == "id")
      game->setGameId(atoi(argv[i]));

    else if (col == "name")
      game->setGameName(argv[i]);

    else if (col == "description")
      game->setDescription(argv[i]);

    else if (col == "minplayers")
      game->setMinPlayers(atoi(argv[i]));

    else if (col == "maxplayers")
      game->setMaxPlayers(atoi(argv[i]));

    else if (col == "playingtime")
      game->setPlayingTime(atoi(argv[i]));

    else if (col == "yearpublished")
      game->setYearPublished(atoi(argv[i]));

    else if (col == "rank")
      game->setRank(atoi(argv[i]));

    else if (col == "extension")
      game->setIsExtension(atoi(argv[i]));

    else if (col == "thumbnail")
      game->setThumbnailUrl(argv[i]);

    else if (col == "expands")
      game->setExpands(atoi(argv[i]));

    else if (col == "authors") {
      std::string authors(argv[i]);
      ssize_t last_pos(0);
      ssize_t pos(0);

      while ((pos = authors.find(", ", last_pos)) != std::string::npos) {
        game->setAuthor(authors.substr(last_pos, pos - last_pos).c_str());
        last_pos = pos + 2;
      }

      std::string last_author = authors.substr(last_pos, authors.size());
      if (not last_author.empty()) {
        game->setAuthor(last_author);
      }
    }
  }
  return 0;
}
示例#3
0
void GameInstSet::update_instance_for_step(InstanceState* state,
		GameInst* inst) {
	if (inst->destroyed)
		return;
	if (true || inst->solid) {
		Pos last_pos(inst->last_x, inst->last_y), new_pos(inst->x, inst->y);
		LANARTS_ASSERT(within_bounds_check(last_pos));
		LANARTS_ASSERT(within_bounds_check(new_pos));
		__update_collision_position(state, last_pos, new_pos);
	}
	inst->last_x = inst->x, inst->last_y = inst->y;
}
示例#4
0
// --------------------------
//  マウス移動中
// --------------------------
void DrawGL::move_mouse(int x, int y)
{
    int x_disp, y_disp;
    x_disp = x - _last_pos.x;
    y_disp = y - _last_pos.y;

    // 左クリック
    if(_mouse_mode == 1) {
         _polar.azimuth += (float) x_disp / 0.8;
        _polar.elevation += (float) y_disp / 0.8;
    }
    // 右クリック
    else if(_mouse_mode == 2) {
        _polar.distance += (float) y_disp / 0.2;
        _polar.twist += (float) x_disp / 0.8;
    }
    last_pos(x, y);
}
示例#5
0
CubitStatus Faceter::get_curve_facets( RefEdge* curve, DLIList<CubitPoint*>& segments ) const
{
//const double COS_ANGLE_TOL =  0.965925826289068312213715; // cos(15)
  const double COS_ANGLE_TOL =  0.984807753012208020315654; // cos(10)
//const double COS_ANGLE_TOL =  0.996194698091745545198705; // cos(5)
  GMem curve_graphics;
  const double dist_tol = GEOMETRY_RESABS;
  const double dist_tol_sqr = dist_tol*dist_tol;
  Curve* curve_ptr = curve->get_curve_ptr();
  curve_ptr->get_geometry_query_engine()->get_graphics( curve_ptr, &curve_graphics );
  
  GPoint* gp = curve_graphics.point_list();
  CubitPoint* last = (CubitPoint*) new FaceterPointData( gp->x, gp->y, gp->z );
  ((FaceterPointData*)last)->owner(dynamic_cast<RefEntity*>(curve));
  CubitVector lastv = last->coordinates();
  segments.append( last );
  GPoint* end = gp + curve_graphics.pointListCount - 1;
  
  for( gp++; gp < end; gp++ )
  {
    CubitVector pos(  gp->x, gp->y, gp->z );
    CubitVector step1 = (pos - lastv);
    double len1 = step1.length();
    if( len1 < dist_tol ) continue;
    
    GPoint* np = gp + 1;
    CubitVector next( np->x, np->y, np->z );
    CubitVector step2 = next - pos;
    double len2 = step2.length();
    if( len2 < dist_tol ) continue;
    
    double cosine = (step1 % step2) / (len1 * len2);
    if( cosine > COS_ANGLE_TOL ) continue;
    
    last = new FaceterPointData( pos );
    ((FaceterPointData*)last)->owner(dynamic_cast<RefEntity*>(curve));
    segments.append( last );
    lastv = last->coordinates();
  }
  
  CubitVector last_pos( gp->x, gp->y, gp->z );
  segments.last();
  while( (last_pos - (segments.get()->coordinates())).length_squared() < dist_tol_sqr )
  {
    delete segments.pop();
    segments.last();
  }
  CubitPoint *tmp_point = (CubitPoint*) new FaceterPointData( last_pos );
  segments.append( tmp_point );
  ((FaceterPointData*)tmp_point)->owner( dynamic_cast<RefEntity*>(curve) );
    
  // Now check if the segment list is reversed wrt the curve direction.
  segments.reset();
  double u1, u2;
  if( segments.size() > 2 )
  {
    u1 = curve->u_from_position( (segments.next(1)->coordinates()) );
    u2 = curve->u_from_position( (segments.next(2)->coordinates()) );    
  }
  else
  {
    u1 = curve->u_from_position( (segments.get()->coordinates() ) );
    u2 = curve->u_from_position( (segments.next()->coordinates()) );
  }
  if( (u2 < u1) && (curve->start_param() <= curve->end_param()) )
    segments.reverse();

    //Make sure we don't have duplicate points.
  int jj;
  CubitVector curr, prev;
  for ( jj = segments.size(); jj > 0; jj-- )
  {
    prev = segments.prev()->coordinates();
    curr = segments.get_and_step()->coordinates();
    if ( prev.about_equal(curr) )
    {
      PRINT_DEBUG_129("Points on curve %d within tolerance...\n", curve->id());
      segments.back();
      delete segments.remove();
    }
  }
  return CUBIT_SUCCESS;
}