Пример #1
0
static GLvoid resolve_fragment_fixed (GLuint e[], slang_export_data_table *tbl)
{
	e[SLANG_FRAGMENT_FIXED_FRAGCOORD] = gd (tbl, "gl_FragCoord");
	e[SLANG_FRAGMENT_FIXED_FRONTFACING] = gd (tbl, "gl_FrontFacing");
	e[SLANG_FRAGMENT_FIXED_FRAGCOLOR] = gd (tbl, "gl_FragColor");
	e[SLANG_FRAGMENT_FIXED_FRAGDATA] = gd (tbl, "gl_FragData");
	e[SLANG_FRAGMENT_FIXED_FRAGDEPTH] = gd (tbl, "gl_FragDepth");
	e[SLANG_FRAGMENT_FIXED_COLOR] = gd (tbl, "gl_Color");
	e[SLANG_FRAGMENT_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");
	e[SLANG_FRAGMENT_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");
	e[SLANG_FRAGMENT_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");
}
Пример #2
0
double minibatch_gradient_descent::train(vi::nn::network& network, const vi::la::matrix& features,
                                         const vi::la::matrix& targets,
                                         vi::nn::cost_function& cost_function) {
  assert(_batch_size <= features.row_count());
  const size_t effective_batch_size = std::min(_batch_size, features.row_count());
  const size_t batch_count(features.row_count() / effective_batch_size);

  const size_t batches_to_average(std::min(20LU, batch_count));
  running_average average(batches_to_average);

  for (size_t epoch = 1U; epoch <= _max_epoch_count; ++epoch) {
    batch_gradient_descent gd(_batch_iteration_count, _learning_rate);

    for (size_t batch = 0U; batch < batch_count; ++batch) {
      size_t batch_start = batch * effective_batch_size;
      size_t batch_end = batch_start + effective_batch_size - 1U;

      vi::la::matrix batch_features = features.rows(batch_start, batch_end);
      vi::la::matrix batch_targets = targets.rows(batch_start, batch_end);

      const double batch_cost = gd.train(network, batch_features, batch_targets, cost_function);
      average.add_value(batch_cost);
    }

    const double current_average = average.calculate();
    if (_stop_early && _stop_early(network, epoch, current_average)) {
      return current_average;
    }
  }

  return average.calculate();
}
Пример #3
0
double run_soft_sphere(double reduced_density, double temp) {
  Functional f = SoftFluid(sigma, 1, 0);
  const double mu = find_chemical_potential(OfEffectivePotential(f), temp, reduced_density*pow(2,-5.0/2.0));
  printf("mu is %g for reduced_density = %g at temperature %g\n", mu, reduced_density, temp);

  //printf("Filling fraction is %g with functional %s at temperature %g\n", reduced_density, teff);
  //fflush(stdout);
  temperature = temp;
  //if (kT == 0) kT = ;1

  Lattice lat(Cartesian(xmax,0,0), Cartesian(0,ymax,0), Cartesian(0,0,zmax));
  GridDescription gd(lat, dx);

  Grid softspherepotential(gd);
  softspherepotential.Set(soft_sphere_potential);

  f = SoftFluid(sigma, 1, mu); // compute approximate energy with chemical potential mu
  const double approx_energy = f(temperature, reduced_density*pow(2,-5.0/2.0))*xmax*ymax*zmax;
  const double precision = fabs(approx_energy*1e-9);

  f = OfEffectivePotential(SoftFluid(sigma, 1, mu) + ExternalPotential(softspherepotential));

  static Grid *potential = 0;
  potential = new Grid(gd);
  *potential = softspherepotential - temperature*log(reduced_density*pow(2,-5.0/2.0)/(1.0*radius*radius*radius))*VectorXd::Ones(gd.NxNyNz); // Bad starting guess
  printf("\tMinimizing to %g absolute precision from %g from %g...\n", precision, approx_energy, temperature);
  fflush(stdout);

  Minimizer min = Precision(precision,
                            PreconditionedConjugateGradient(f, gd, temperature,
                                potential,
                                QuadraticLineMinimizer));
  took("Setting up the variables");
  for (int i=0; min.improve_energy(true) && i<100; i++) {
  }

  took("Doing the minimization");
  min.print_info();

  Grid density(gd, EffectivePotentialToDensity()(temperature, gd, *potential));
  //printf("# per area is %g at filling fraction %g\n", density.sum()*gd.dvolume/dw/dw, reduced_density);

  char *plotname = (char *)malloc(1024);

  sprintf(plotname, "papers/fuzzy-fmt/figs/radial-wca-%06.4f-%04.2f.dat", temp, reduced_density);
  z_plot(plotname, Grid(gd, pow(2,5.0/2.0)*density));
  free(plotname);

  {
    //double peak = peak_memory()/1024.0/1024;
    //double current = current_memory()/1024.0/1024;
    //printf("Peak memory use is %g M (current is %g M)\n", peak, current);

  }

  took("Plotting stuff");
  printf("density %g gives ff %g for reduced_density = %g and T = %g\n", density(0,0,gd.Nz/2),
         density(0,0,gd.Nz/2)*4*M_PI/3, reduced_density, temp);
  return density(0, 0, gd.Nz/2)*4*M_PI/3; // return bulk filling fraction
}
Пример #4
0
static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
	const char *title = 0;
	const char *extra;

	if (g.flags & ADGF_USEEXTRAASTITLE) {
		title = g.extra;
		extra = "";
	} else {
		while (sg->gameId) {
			if (!scumm_stricmp(g.gameId, sg->gameId))
				title = sg->description;
			sg++;
		}

		extra = g.extra;
	}

	GameSupportLevel gsl = kStableGame;
	if (g.flags & ADGF_UNSTABLE)
		gsl = kUnstableGame;
	else if (g.flags & ADGF_TESTING)
		gsl = kTestingGame;

	GameDescriptor gd(g.gameId, title, g.language, g.platform, 0, gsl);
	gd.updateDesc(extra);
	return gd;
}
Пример #5
0
inline void load_construct_data(Archive & /*ar*/, gregorian::partial_date* pd, 
                                const unsigned int /*file_version*/)
{
  gregorian::greg_month gm(1);
  gregorian::greg_day gd(1);
  ::new(pd) gregorian::partial_date(gd,gm);
}
Пример #6
0
void Shell::runshell(const std::string& exec, size_t argc, const std::string* argv)
{
	class _FDGuard
	{
		SessionClient* session;
	public:
		_FDGuard(SessionClient* _ss) : session(_ss) {}
		void operator () (int fd) { session->closeFile(fd); }
	};

	//检查是否有可读权限
	SafeInfo sfInfo;
	std::string shellPath = evrPath(exec);
	if(!session->getItemSafeInfo(shellPath.c_str(), &sfInfo))
	{
		printError(session->getErrno());
		return;
	}
	if((sfInfo.uid == uid && !(sfInfo.sign & PM_U_EXECUTE)) || (sfInfo.uid != uid && !(sfInfo.sign & PM_O_EXECUTE)))
	{
		printError(ERR_FILE_COULD_NOT_EXEC);
		return;
	}

	std::string sh;

	const size_t BUFSIZE = 64;
	std::unique_ptr<char> buf(new char[BUFSIZE + 1]);
	//打开文件
	int fd = session->openFile(shellPath.c_str(), OPTYPE_READ);
	if(fd <= 0)
	{
		printError(session->getErrno());
		return;
	}
	Guard<int, _FDGuard> gd(fd, _FDGuard(session));
	size_t start = 0;
	//把文件内容写入sh中
	while(true)
	{
		int len = session->readFile(fd, buf.get(), BUFSIZE);
		if(len < 0)
		{
			printError(session->getErrno());
			return;
		}
		else if(len == 0)
			break;
		else
		{
			start += len;
			buf.get()[len] = '\0';
			sh += buf.get();
		}
	}

	//开启个新的沙盒运行之
	SandBox sd(this, sh);
	sd.run(argc, argv);
}
Пример #7
0
void level_graph::incremental_junction_update()
{
	iter_junc::graph_data gd(g, node_locations);
	gk::g_node n = boost::vertex(junc_iter_data.node_index, g);

	for(auto& in_if: junctions[n].in_interfaces)
	{
		if(in_if.first)
		{
			iter_junc::direct_junctions::in_edge_interface ideal = iter_junc::direct_junctions().ideal_in_interface(
				junctions[n],
				*in_if.first,
				gd);
			in_if.second = ideal;
		}
	}

	for(auto& out_if: junctions[n].out_interfaces)
	{
		if(out_if.first)
		{
			iter_junc::direct_junctions::out_edge_interface ideal = iter_junc::direct_junctions().ideal_out_interface(
				junctions[n],
				*out_if.first,
				gd);
			out_if.second = ideal;
		}
	}

	splines = iter_junc::direct_junctions().create_spline_accessor(junctions, gd);

	++junc_iter_data.node_index;
	junc_iter_data.node_index %= boost::num_vertices(g);
}
Пример #8
0
void test_energy(const char *name, Functional f, double kT,
                 double true_energy, double fraccuracy = 1e-15) {
  printf("\n************");
  for (unsigned i=0;i<strlen(name);i++) printf("*");
  printf("\n* Testing %s *\n", name);
  for (unsigned i=0;i<strlen(name);i++) printf("*");
  printf("************\n\n");

  Lattice lat(Cartesian(0,.5,.5), Cartesian(.5,0,.5), Cartesian(.5,.5,0));
  int resolution = 20;
  GridDescription gd(lat, resolution, resolution, resolution);
  Grid density(gd);
  density = 1e-3*(-500*r2(gd)).cwise().exp()
    + 1e-7*VectorXd::Ones(gd.NxNyNz);

  retval += f.run_finite_difference_test(name, kT, density);

  double e = f.integral(kT, density);
  printf("Energy = %.16g\n", e);
  printf("Fractional error = %g\n", (e - true_energy)/fabs(true_energy));
  if (e < true_energy) {
    printf("FAIL: the energy is too low! (it is %.16g)\n", e);
    retval++;
  }
  if (!(fabs((e - true_energy)/true_energy) < fraccuracy)) {
    printf("FAIL: Error in the energy is too big!\n");
    retval++;
  }
}
Пример #9
0
int Thread::interrupt(Thread *thread) {
    if (thread->state == THREAD_RUNNING)
    {
        if (thread->id == main_threadid)
        {
            /*
            * Shutdown all running threads
            * and de-allocate all allocated
            * memory. If we do not call join()
            * to wait for all other threads
            * regardless of what they are doing, we
            * stop them.
            */
            vm->shutdown();
            masterShutdown = true;
        }
        else
        {
            std::lock_guard<std::mutex> gd(thread->mutex);
            thread->state = THREAD_KILLED; // terminate thread
            return 0;
        }
    }

    return 2;
}
Пример #10
0
void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
{
  gregorian::greg_day gd(1);
  gregorian::greg_month gm(1);
  ar & make_nvp("partial_date_day", gd);
  ar & make_nvp("partial_date_month", gm);
  pd = gregorian::partial_date(gd,gm);
}
Пример #11
0
void save(Archive & ar, const gregorian::partial_date& pd, 
          unsigned int /*version*/)
{
  gregorian::greg_day gd(pd.day());
  gregorian::greg_month gm(pd.month().as_number());
  ar & make_nvp("partial_date_day", gd);
  ar & make_nvp("partial_date_month", gm);
}
Пример #12
0
void level_graph::generate_junctions(random_gen_t& rgen)
{
	junctions = iter_junc::direct_junctions::node_junction_map();
	iter_junc::graph_data gd(g, node_locations);
	iter_junc::direct_junctions().generate_initial_junctions(junctions, gd);

	splines = iter_junc::direct_junctions().create_spline_accessor(junctions, gd);
}
Пример #13
0
void Thread::suspendThread(Thread *thread) {
    if(thread->id == thread_self->id)
        suspendSelf();
    else {
        std::lock_guard<std::mutex> gd(thread->mutex);
        thread->suspendPending = true;
    }
}
Пример #14
0
int main(int, char **) {
  FILE *o = fopen("paper/figs/constrained-water.dat", "w");

  Functional f = OfEffectivePotential(SaftFluidSlow(water_prop.lengthscale,
                                                    water_prop.epsilonAB, water_prop.kappaAB,
                                                    water_prop.epsilon_dispersion,
                                                    water_prop.lambda_dispersion, water_prop.length_scaling, 0));
  double mu_satp = find_chemical_potential(f, water_prop.kT,
                                           water_prop.liquid_density);
  Lattice lat(Cartesian(width,0,0), Cartesian(0,width,0), Cartesian(0,0,zmax));
  GridDescription gd(lat, 0.1);

  Grid potential(gd);
  Grid constraint(gd);
  constraint.Set(notinwall);

  f = constrain(constraint,
                OfEffectivePotential(SaftFluidSlow(water_prop.lengthscale,
                                                   water_prop.epsilonAB, water_prop.kappaAB,
                                                   water_prop.epsilon_dispersion,
                                                   water_prop.lambda_dispersion, water_prop.length_scaling, mu_satp)));


  Minimizer min = Precision(0, PreconditionedConjugateGradient(f, gd, water_prop.kT, &potential,
                                                               QuadraticLineMinimizer));

  potential = water_prop.liquid_density*constraint
    + water_prop.vapor_density*VectorXd::Ones(gd.NxNyNz);
  //potential = water_prop.liquid_density*VectorXd::Ones(gd.NxNyNz);
  potential = -water_prop.kT*potential.cwise().log();

  const int numiters = 50;
  for (int i=0;i<numiters && min.improve_energy(true);i++) {
    fflush(stdout);
    Grid density(gd, EffectivePotentialToDensity()(water_prop.kT, gd, potential));
    density.epsNative1d("paper/figs/1d-constrained-plot.eps",
			Cartesian(0,0,0), Cartesian(0,0,zmax),
			water_prop.liquid_density, 1, "Y axis: , x axis: ");
  }
  min.print_info();

  double energy = min.energy()/width/width;
  printf("Energy is %.15g\n", energy);

  double N = 0;
  {
    Grid density(gd, EffectivePotentialToDensity()(water_prop.kT, gd, potential));
    for (int i=0;i<gd.NxNyNz;i++) N += density[i]*gd.dvolume;
  }
  N = N/width/width;
  printf("N is %.15g\n", N);

    Grid density(gd, EffectivePotentialToDensity()(water_prop.kT, gd, potential));
    density.epsNative1d("paper/figs/1d-constrained-plot.eps", Cartesian(0,0,0), Cartesian(0,0,zmax), water_prop.liquid_density, 1, "Y axis: , x axis: ");
    //potential.epsNative1d("hard-wall-potential.eps", Cartesian(0,0,0), Cartesian(0,0,zmax), 1, 1);

    fclose(o);
}
Пример #15
0
void test_GradientDescent(){
	GradientDescent gd("gradient_descent_data.txt");
	gd.batch_gradient_descent();
	gd.print_theta();

	GradientDescent gd1("gradient_descent_data.txt");
	gd1.stochastic_gradient_descent();
	gd1.print_theta();
}
Пример #16
0
void SMOnlineStats::TransferDoneQueue()
{
	MLockPtr< queue<GameStats*> > gd(m_gamesDone, m_gamesDoneMUTEX);

	while (!gd->empty())
	{
		m_gamesSend.push(gd->front());
		gd->pop();
	}
}
Пример #17
0
	size graphics_context::draw_glyph(const point& aPoint, const glyph& aGlyph, const font& aFont, const colour& aColour) const
	{
		size result;
		{
			glyph_drawing gd(*this);
			result = iNativeGraphicsContext->draw_glyph(to_device_units(aPoint) + iOrigin, aGlyph, aFont, aColour);
		}
		if (iDrawingGlyphs == 0 && (aGlyph.underline() || (mnemonics_shown() && aGlyph.mnemonic())))
			draw_glyph_underline(aPoint, aGlyph, aFont, aColour);
		return result;
	}
Пример #18
0
double rgamma(double mean, double var, boost::mt19937& rng) {
    // Note that boost's only gamma distribution requires scale = 1
    // See http://www.boost.org/doc/libs/1_43_0/boost/math/distributions/gamma.hpp
    // Convert by multiplying by scale after: see http://www.johndcook.com/cpp_TR1_random.html#gamma
    double shape = (mean*mean) / var;
    double scale = var / mean;
    assert(shape > 0);
    assert(scale > 0);
    boost::gamma_distribution<> gd(shape);
    boost::variate_generator<boost::mt19937&, boost::gamma_distribution<> > var_gamma(rng, gd);
    return scale*var_gamma();
}
Пример #19
0
    static bool parse(State& s, UserState& us)
    {
        state_cur_guard<State> gd(s);

        while (!ParserB::parse(s, us)) {
            if (!ParserA::parse(s, us))
                return false;
        }

        gd.dismiss();
        return true;
    }
Пример #20
0
double run_walls(double reduced_density, const char *name, Functional fhs, double teff) {
  double kT = teff;
  if (kT == 0) kT = 1;

  Functional f = OfEffectivePotential(fhs);

  const double zmax = width + 2*spacing;
  Lattice lat(Cartesian(dw,0,0), Cartesian(0,dw,0), Cartesian(0,0,zmax));
  GridDescription gd(lat, dx);

  Grid constraint(gd);
  constraint.Set(notinwall);
  f = constrain(constraint, f);

  Grid potential(gd);
  potential = pow(2,-5.0/2.0)*(reduced_density*constraint + 1e-4*reduced_density*VectorXd::Ones(gd.NxNyNz));
  potential = -kT*potential.cwise().log();

  const double approx_energy = fhs(kT, reduced_density*pow(2,-5.0/2.0))*dw*dw*width;
  const double precision = fabs(approx_energy*1e-11);
  printf("\tMinimizing to %g absolute precision from %g from %g...\n", precision, approx_energy, kT);
  fflush(stdout);

  Minimizer min = Precision(precision,
                            PreconditionedConjugateGradient(f, gd, kT,
                                                            &potential,
                                                            QuadraticLineMinimizer));
  took("Setting up the variables");
  if (strcmp(name, "hard") != 0 && false) {
    printf("For now, SoftFluid doesn't work properly, so we're skipping the\n");
    printf("minimization at temperature %g.\n", teff);
  } else {
    for (int i=0;min.improve_energy(false) && i<100;i++) {
    }
  }
  took("Doing the minimization");
  min.print_info();

  Grid density(gd, EffectivePotentialToDensity()(kT, gd, potential));
  //printf("# per area is %g at filling fraction %g\n", density.sum()*gd.dvolume/dw/dw, eta);

  char *plotname = (char *)malloc(1024);

  sprintf(plotname, "papers/fuzzy-fmt/figs/walls%s-%06.4f-%04.2f.dat", name, teff, reduced_density);
  z_plot(plotname, Grid(gd, density*pow(2,5.0/2.0)));
  free(plotname);

  took("Plotting stuff");
  printf("density %g gives ff %g for reduced density = %g and T = %g\n", density(0,0,gd.Nz/2),
         density(0,0,gd.Nz/2)*4*M_PI/3, reduced_density, teff);
  return density(0, 0, gd.Nz/2)*4*M_PI/3; // return bulk filling fraction
}
Пример #21
0
Mat HistologicalEntities::getRBC(const std::vector<Mat>& bgr,
		::cciutils::SimpleCSVLogger *logger, ::cciutils::cv::IntermediateResultHandler *iresHandler) {
	CV_Assert(bgr.size() == 3);
	/*
	%T1=2.5; T2=2;
    T1=5; T2=4;

	imR2G = double(r)./(double(g)+eps);
    bw1 = imR2G > T1;
    bw2 = imR2G > T2;
    ind = find(bw1);
    if ~isempty(ind)
        [rows, cols]=ind2sub(size(imR2G),ind);
        rbc = bwselect(bw2,cols,rows,8) & (double(r)./(double(b)+eps)>1);
    else
        rbc = zeros(size(imR2G));
    end
	 */
	std::cout.precision(5);
	double T1 = 5.0;
	double T2 = 4.0;
	Size s = bgr[0].size();
	Mat bd(s, CV_32FC1);
	Mat gd(s, bd.type());
	Mat rd(s, bd.type());

	bgr[0].convertTo(bd, bd.type(), 1.0, FLT_EPSILON);
	bgr[1].convertTo(gd, gd.type(), 1.0, FLT_EPSILON);
	bgr[2].convertTo(rd, rd.type(), 1.0, 0.0);

	Mat imR2G = rd / gd;
	Mat imR2B = (rd / bd) > 1.0;

	if (iresHandler) iresHandler->saveIntermediate(imR2G, 101);
	if (iresHandler) iresHandler->saveIntermediate(imR2B, 102);


	Mat bw1 = imR2G > T1;
	Mat bw2 = imR2G > T2;
	Mat rbc;
	if (countNonZero(bw1) > 0) {
//		imwrite("test/in-bwselect-marker.pgm", bw2);
//		imwrite("test/in-bwselect-mask.pgm", bw1);
		rbc = bwselect<unsigned char>(bw2, bw1, 8) & imR2B;
	} else {
		rbc = Mat::zeros(bw2.size(), bw2.type());
	}

	return rbc;
}
Пример #22
0
GameDescriptor FrotzMetaEngine::findGame(const char *gameId) {
	for (const PlainGameDescriptor *pd = INFOCOM_GAME_LIST; pd->gameId; ++pd) {
		if (!strcmp(gameId, pd->gameId)) {
			GameDescriptor gd(*pd);
			gd._options |= OPTION_INFOCOM;
			return gd;
		}
	}
	for (const PlainGameDescriptor *pd = ZCODE_GAME_LIST; pd->gameId; ++pd) {
		if (!strcmp(gameId, pd->gameId))
			return *pd;
	}

	return GameDescriptor::empty();
}
Пример #23
0
    bool aux(State& s, RangeOfRange& rngs)
    {
        state_cur_guard<State> gd(s);

        typedef typename oven::range_iterator<RangeOfRange>::type iter_t;
        for (iter_t it = boost::begin(rngs), last = boost::end(rngs); it != last; ++it) {
            typename optional_iterator<State>::type opit = biscuit::state_parse(s, *it);
            if (!opit)
                return false;

            s.set_cur(*opit);
        }

        gd.dismiss();
        return true;
    }
Пример #24
0
 Mat make_standard_helix(int n) {
     std::lock_guard<std::mutex> gd(mt);
     if (_cache.count(n)) return _cache[n];
     else {
         Mat helix = Mat::Zero(n * 2 + 2, 3);
         for (int i = 0; i < n + 1; i++) {
             helix(i, 0) = _par.R*std::cos(i*_par.theta);
             helix(i, 1) = _par.R*std::sin(i*_par.theta);
             helix(i, 2) = i*_par.h;
             helix(2*n+1-i, 0) = _par.R*std::cos(i*_par.theta+_par.phi);
             helix(2*n+1-i, 1) = _par.R*std::sin(i*_par.theta+_par.phi);
             helix(2*n+1-i, 2) = i*_par.h+_par.d;
         }
         return helix;
     }
 }
Пример #25
0
I ea(I f,A a,A w)
{
  A z,*p;I at,k,wt=0,j=0;
  C *ap,*wp=0;
  if(w)ND2 else ND1;
  at=a->t,k=a->r?Tt(at,1):0,ap=(C*)a->p;
  if(w)
    if(wt=w->t,wp=(C*)w->p,j=w->r?Tt(wt,1):0,k&&j)
    {
      Q(a->r!=w->r,7);
      Q(cm(a->d,w->d,a->r),8);
    }
  W(gd(Et,j?w:a));
  *--Y=zr(z),p=(A*)z->p;
  DO(z->n,
     if(at<Et||(a=*(A*)ap,QF(a)))a=gc(at,0,1,0,(I*)ap);
     else ic(a);
Пример #26
0
void Shell::cat(size_t argc, const std::string* argv)
{
	class _FDGuard
	{
		SessionClient* session;
	public:
		_FDGuard(SessionClient* _ss) : session(_ss) {}
		void operator () (int fd) { session->closeFile(fd); }
	};
	if(argc < 1)
	{
		printError(ERR_ARGS_INVALID);
		return;
	}
	const size_t BUFSIZE = 64;
	std::unique_ptr<char> buf(new char[BUFSIZE + 1]);
	int fd = session->openFile(absPath(argv[0]).c_str(), OPTYPE_READ);
	if(fd <= 0)
	{
		printError(session->getErrno());
		return;
	}
	Guard<int, _FDGuard> gd(fd, _FDGuard(session));
	size_t start = 0;
	while(true)
	{
		int len = session->readFile(fd, buf.get(), BUFSIZE);
		if(len < 0)
		{
			printError(session->getErrno());
			return;
		}
		else if(len == 0)
			break;
		else
		{
			start += len;
			buf.get()[len] = '\0';
			std::cout << buf.get();
		}
	}
	std::cout << std::endl;
	std::cout << "-------END-------" << std::endl;
}
Пример #27
0
	inline void draw_glyph_text(const graphics_context& aGraphicsContext, const point& aPoint, Iter aTextBegin, Iter aTextEnd, const font& aFont, const colour& aColour)
	{
		{
			graphics_context::glyph_drawing gd(aGraphicsContext);
			point pos = aPoint;
			for (Iter i = aTextBegin; i != aTextEnd; ++i)
			{
				aGraphicsContext.draw_glyph(pos + i->offset(), *i, aFont, aColour);
				pos.x += i->advance().cx;
			}
		}
		point pos = aPoint;
		for (Iter i = aTextBegin; i != aTextEnd; ++i)
		{
			if (i->underline() || (aGraphicsContext.mnemonics_shown() && i->mnemonic()))
				aGraphicsContext.draw_glyph_underline(pos, *i, aFont, aColour);
			pos.x += i->advance().cx;
		}
	}
Пример #28
0
boost::shared_ptr<const netcode::RawPacket> CNetProtocol::GetData()
{
	boost::shared_ptr<const netcode::RawPacket> ret = serverConn->GetData();

	if (ret) {
		if (record) {
			record->SaveToDemo(ret->data, ret->length);
		}
		else if (ret->data[0] == NETMSG_GAMEDATA) {
			logOutput.Print("Starting demo recording");
			GameData gd(ret);
			record.reset(new CDemoRecorder());
			record->WriteSetupText(gd.GetSetup());
			record->SaveToDemo(ret->data, ret->length);
		}
	}

	return ret;
}
Пример #29
0
main(int argc, char *argv[])
{ 
  int fd;

  if (argc > 1)
     device = argv[1];

  fd = open(device, O_RDONLY);
  if (fd < 0){
     printf("open %s failed\n", device);
     exit(1);
  }
  super(fd);
  gd(fd);
  bmap(fd);
  imap(fd);
  inode(fd);
  dir(fd);
}
Пример #30
0
static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
    const char *title = 0;
    const char *extra;

    if (g.flags & ADGF_USEEXTRAASTITLE) {
        title = g.extra;
        extra = "";
    } else {
        while (sg->gameid) {
            if (!scumm_stricmp(g.gameid, sg->gameid))
                title = sg->description;
            sg++;
        }

        extra = g.extra;
    }

    GameDescriptor gd(g.gameid, title, g.language, g.platform);
    gd.updateDesc(extra);
    return gd;
}