Exemplo n.º 1
0
	Footholdtree::Footholdtree(InPacket& recv)
	{
		int16_t leftw = 30000;
		int16_t rightw = -30000;
		int16_t botb = -30000;
		int16_t topb = 30000;

		uint16_t numbase = recv.readshort();
		for (uint16_t i = 0; i < numbase; i++)
		{
			uint8_t layer = recv.readbyte();
			uint16_t nummid = recv.readshort();
			for (uint16_t j = 0; j < nummid; j++)
			{
				uint16_t numlast = recv.readshort();
				for (uint16_t k = 0; k < numlast; k++)
				{
					Foothold foothold = Foothold(recv, layer);

					if (foothold.getl() < leftw)
					{
						leftw = foothold.getl();
					}
					else if (foothold.getr() > rightw)
					{
						rightw = foothold.getr();
					}

					if (foothold.getb() > botb)
					{
						botb = foothold.getb();
					}
					else if (foothold.gett() < topb)
					{
						topb = foothold.gett();
					}

					uint16_t id = foothold.getid();
					footholds[id] = foothold;

					if (abs(foothold.getslope()) < 0.5)
					{
						int16_t start = foothold.getl();
						int16_t end = foothold.getr();
						for (int16_t i = start; i <= end; i++)
						{
							footholdsbyx.insert(std::make_pair(i, id));
						}
					}
				}
			}
		}

		walls = Range<int16_t>(leftw + 25, rightw - 25);
		borders = Range<int16_t>(topb - 400, botb + 400);
	}
Exemplo n.º 2
0
	Footholdtree::Footholdtree(node src)
	{
		int16_t leftw = 30000;
		int16_t rightw = -30000;
		int16_t botb = -30000;
		int16_t topb = 30000;

		for (node basef : src)
		{
			uint8_t layer;
			try
			{
				layer = static_cast<uint8_t>(stoi(basef.name()));
			}
			catch (const std::exception&)
			{
				continue;
			}

			for (node midf : basef)
			{
				for (node lastf : midf)
				{
					Foothold foothold = Foothold(lastf, layer);

					if (foothold.getl() < leftw)
					{
						leftw = foothold.getl();
					}
					else if (foothold.getr() > rightw)
					{
						rightw = foothold.getr();
					}

					if (foothold.getb() > botb)
					{
						botb = foothold.getb();
					}
					else if (foothold.gett() < topb)
					{
						topb = foothold.gett();
					}

					uint16_t id = foothold.getid();
					footholds[id] = foothold;

					if (!foothold.iswall())
					{
						int16_t start = foothold.getl();
						int16_t end = foothold.getr();
						for (int16_t i = start; i <= end; i++)
						{
							footholdsbyx.insert(std::make_pair(i, id));
						}
					}
				}
			}
		}

		walls = Range<int16_t>(leftw + 25, rightw - 25);
		borders = Range<int16_t>(topb - 300, botb + 80);
	}