Esempio n. 1
0
static void
pmandoc(struct mparse *mp, int fd, const char *fn, int list)
{
	struct roff_man	*man;
	int		 line, col;

	mparse_readfd(mp, fd, fn);
	close(fd);
	mparse_result(mp, &man, NULL);
	line = 1;
	col = 0;

	if (man == NULL)
		return;
	if (man->macroset == MACROSET_MDOC) {
		mdoc_validate(man);
		pmdoc(man->first->child, &line, &col, list);
	} else {
		man_validate(man);
		pman(man->first->child, &line, &col, list);
	}

	if ( ! list)
		putchar('\n');
}
Esempio n. 2
0
static void
pmandoc(struct mparse *mp, int fd, const char *fn, int list)
{
	struct mdoc	*mdoc;
	struct man	*man;
	int		 line, col;

	if (mparse_readfd(mp, fd, fn) >= MANDOCLEVEL_FATAL) {
		fprintf(stderr, "%s: Parse failure\n", fn);
		return;
	}

	mparse_result(mp, &mdoc, &man, NULL);
	line = 1;
	col = 0;

	if (mdoc) 
		pmdoc(mdoc_node(mdoc), &line, &col, list);
	else if (man)
		pman(man_node(man), &line, &col, list);
	else
		return;

	if ( ! list)
		putchar('\n');
}
Esempio n. 3
0
		text::text(const std::string& str, const std::string& font, int size, const SDL_Color& color)
			: str_(str), color_(color)
		{
			profile::manager pman("text::text");
			// XXX handle changes and stuff
			font_ = font::get_font(font, size);
			surface_ptr surf = surface_ptr(TTF_RenderUTF8_Blended(font_.get(), str_.c_str(), color_.as_sdl_color()), SDL_FreeSurface);
			ASSERT_LOG(surf != NULL, "Couldn't render text into texture");
			tex_ = texture::get(surf);
		}
Esempio n. 4
0
static void
pman(const struct roff_node *p, int *line, int *col, int list)
{

	for ( ; p; p = p->next) {
		if (MAN_LINE & p->flags)
			pline(p->line, line, col, list);
		if (ROFFT_TEXT == p->type)
			pstring(p->string, p->pos, col, list);
		if (p->child)
			pman(p->child, line, col, list);
	}
}
Esempio n. 5
0
	void world::build_infinite()
	{
		profile::manager pman("Built voxel::world in");

		int x_smoothness = rand() % 480 + 32;
		int z_smoothness = rand() % 480 + 32;

		// Generates initial chunks
		for(int x = 0; x != initial_chunks; ++x) {
			for(int y = 0; y != 4; y++) {
				for(int z = 0; z != initial_chunks; ++z) {
					std::cerr << "Generating chunk: " << x << "," << y << "," << z << std::endl;
					std::map<variant,variant> m;
					variant_builder rnd;

					glm::ivec3 worldspace_pos(x * chunk_size, y * chunk_size, z * chunk_size);
				
					rnd.add("width", chunk_size);
					rnd.add("height", chunk_size);
					rnd.add("depth", chunk_size);
					//rnd.add("noise_height", rand() % chunk_size*2);
					rnd.add("noise_height", 128);
					rnd.add("type", graphics::color("medium_sea_green").write());
					rnd.add("seed", seed_);
					rnd.add("x_smoothness", x_smoothness);		// 32 is very spiky, 512 is very flat
					rnd.add("z_smoothness", z_smoothness);

					m[variant("type")] = variant("colored");
					m[variant("shader")] = variant(shader_->name());
					std::vector<variant> v;
					v.push_back(variant(worldspace_pos.x));
					v.push_back(variant(worldspace_pos.y));
					v.push_back(variant(worldspace_pos.z));
					m[variant("worldspace_position")] = variant(&v);
					m[variant("random")] = rnd.build();

					chunk_ptr cp = voxel::chunk_factory::create(shader_, logical_world_ptr(), variant(&m));
					chunks_[position(worldspace_pos.x,worldspace_pos.y,worldspace_pos.z)] = cp;
					active_chunks_.push_back(cp);
				}
			}
		}
		//get_active_chunks();
	}
Esempio n. 6
0
static void
pmandoc(struct mparse *mp, int fd, const char *fn, int list)
{
	struct mdoc	*mdoc;
	struct man	*man;
	int		 line, col;

	mparse_readfd(mp, fd, fn);
	mparse_result(mp, &mdoc, &man, NULL);
	line = 1;
	col = 0;

	if (mdoc)
		pmdoc(mdoc_node(mdoc), &line, &col, list);
	else if (man)
		pman(man_node(man), &line, &col, list);
	else
		return;

	if ( ! list)
		putchar('\n');
}
Esempio n. 7
0
	pathfinding::directed_graph_ptr logical_world::create_directed_graph(bool allow_diagonals) const
	{
		profile::manager pman("logical_world::create_directed_graph");

		std::vector<variant> vertex_list;
		std::map<std::pair<int,int>, int> vlist;

		for(auto p : heightmap_) {
			int x = p.first.first;
			int y = p.second;
			int z = p.first.second;

			if(y < size_y() - 1) {
				if(is_solid(x, y+1, z) == false) {
					vertex_list.push_back(variant_list_from_position(x,y+1,z));
					vlist[std::make_pair(x,z)] = y+1;
				}
			} else {
				vertex_list.push_back(variant_list_from_position(x,y+1,z));
				vlist[std::make_pair(x,z)] = y+1;
			}
		}
	
		pathfinding::graph_edge_list edges;
		for(auto p : vertex_list) {
			const int x = p[0].as_int();
			const int y = p[1].as_int();
			const int z = p[2].as_int();

			std::vector<variant> current_edges;
			
			auto it = vlist.find(std::make_pair(x+1,z));
			if(it != vlist.end() && !is_xedge(x+1) && !is_solid(x+1,it->second,z)) {
				current_edges.push_back(variant_list_from_position(x+1,it->second,z));
			}
			it = vlist.find(std::make_pair(x-1,z));
			if(it != vlist.end() && !is_xedge(x-1) && !is_solid(x-1,it->second,z)) {
				current_edges.push_back(variant_list_from_position(x-1,it->second,z));
			}
			it = vlist.find(std::make_pair(x,z+1));
			if(it != vlist.end() && !is_zedge(z+1) && !is_solid(x,it->second,z+1)) {
				current_edges.push_back(variant_list_from_position(x,it->second,z+1));
			}
			it = vlist.find(std::make_pair(x,z-1));
			if(it != vlist.end() && !is_zedge(z-1) && !is_solid(x,it->second,z-1)) {
				current_edges.push_back(variant_list_from_position(x,it->second,z-1));
			}
			if(allow_diagonals) {
				it = vlist.find(std::make_pair(x+1,z+1));
				if(it != vlist.end() && !is_xedge(x+1) && !is_zedge(z+1) && !is_solid(x+1,it->second,z+1)) {
					current_edges.push_back(variant_list_from_position(x+1,it->second,z+1));
				}
				it = vlist.find(std::make_pair(x+1,z-1));
				if(it != vlist.end() && !is_xedge(x+1) && !is_zedge(z-1) && !is_solid(x+1,it->second,z-1)) {
					current_edges.push_back(variant_list_from_position(x+1,it->second,z-1));
				}
				it = vlist.find(std::make_pair(x-1,z+1));
				if(it != vlist.end() && !is_xedge(x-1) && !is_zedge(z+1) && !is_solid(x-1,it->second,z+1)) {
					current_edges.push_back(variant_list_from_position(x-1,it->second,z+1));
				}
				it = vlist.find(std::make_pair(x-1,z-1));
				if(it != vlist.end() && !is_xedge(x-1) && !is_zedge(z-1) && !is_solid(x-1,it->second,z-1)) {
					current_edges.push_back(variant_list_from_position(x-1,it->second,z-1));
				}
			}
			edges[variant_list_from_position(x, y, z)] = current_edges;
		}
		return pathfinding::directed_graph_ptr(new pathfinding::directed_graph(&vertex_list, &edges));
	}