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); }
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); }
Footholdtree::Footholdtree(node src) { for (node basef = src.begin(); basef != src.end(); ++basef) { int8_t layer = static_cast<int8_t>(stoi(basef.name())); for (node midf = basef.begin(); midf != basef.end(); ++midf) { for (node lastf = midf.begin(); lastf != midf.end(); ++lastf) { uint16_t id = stoi(lastf.name()); footholds[id] = Foothold(id, layer, lastf); if (footholds[id].getprev() == 0) { edgesl.push_back(id); } else if (footholds[id].getnext() == 0) { edgesr.push_back(id); } } } } int32_t leftw = 65536; for (vector<uint16_t>::iterator fhit = edgesl.begin(); fhit != edgesl.end(); ++fhit) { int32_t lit = footholds[*fhit].getl(); if (lit < leftw) { leftw = lit; } } int32_t rightw = -65536; for (vector<uint16_t>::iterator fhit = edgesr.begin(); fhit != edgesr.end(); ++fhit) { int32_t rit = footholds[*fhit].getr(); if (rit > rightw) { rightw = rit; } } walls = vector2d<int32_t>(leftw + 25, rightw - 25); int32_t botb = -65536; for (map<uint16_t, Foothold>::iterator fhit = footholds.begin(); fhit != footholds.end(); ++fhit) { int32_t btit = fhit->second.getb(); if (btit > botb) { botb = btit; } } int32_t topb = 65536; for (map<uint16_t, Foothold>::iterator fhit = footholds.begin(); fhit != footholds.end(); ++fhit) { int32_t tpit = fhit->second.gett(); if (tpit < topb) { topb = tpit; } } borders = vector2d<int32_t>(topb - 400, botb + 400); }