Example #1
0
bool LocalPlayer::canPlaceNode(const v3s16& p, const MapNode& n)
{
	bool noclip = m_gamedef->checkLocalPrivilege("noclip") &&
		g_settings->getBool("noclip");
	// Dont place node when player would be inside new node
	// NOTE: This is to be eventually implemented by a mod as client-side Lua

	if (m_gamedef->ndef()->get(n).walkable && !noclip && !g_settings->getBool("enable_build_where_you_stand")) {
		std::vector<aabb3f> nodeboxes;
		n.getNodeBoxes(m_gamedef->ndef(), &nodeboxes);
		aabb3f player_box = m_collisionbox;
		v3f position(getPosition());
		v3f node_pos(p.X, p.Y, p.Z);
		v3f center = player_box.getCenter();
		v3f min_edge = (player_box.MinEdge - center) * 0.999f;
		v3f max_edge = (player_box.MaxEdge - center) * 0.999f;
		player_box.MinEdge = center + min_edge;
		player_box.MaxEdge = center + max_edge;
		player_box.MinEdge += position;
		player_box.MaxEdge += position;
		for(auto box : nodeboxes) {
			box.MinEdge += node_pos * BS;
			box.MaxEdge += node_pos * BS;
			if(box.intersectsWithBox(player_box)) {
				return false;
			}
		}
	}
	return true;
}
Example #2
0
void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
{
  XBT_VERB("cluster getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
  xbt_assert(not private_links_.empty(),
             "Cluster routing: no links attached to the source node - did you use host_link tag?");

  if ((src->id() == dst->id()) && has_loopback_) {
    xbt_assert(not src->is_router(), "Routing from a cluster private router to itself is meaningless");

    std::pair<resource::LinkImpl*, resource::LinkImpl*> info = private_links_.at(node_pos(src->id()));
    route->link_list.push_back(info.first);
    if (lat)
      *lat += info.first->get_latency();
    return;
  }

  if (not src->is_router()) { // No private link for the private router
    if (has_limiter_) {      // limiter for sender
      std::pair<resource::LinkImpl*, resource::LinkImpl*> info = private_links_.at(node_pos_with_loopback(src->id()));
      route->link_list.push_back(info.first);
    }

    std::pair<resource::LinkImpl*, resource::LinkImpl*> info =
        private_links_.at(node_pos_with_loopback_limiter(src->id()));
    if (info.first) { // link up
      route->link_list.push_back(info.first);
      if (lat)
        *lat += info.first->get_latency();
    }
  }

  if (backbone_) {
    route->link_list.push_back(backbone_);
    if (lat)
      *lat += backbone_->get_latency();
  }

  if (not dst->is_router()) { // No specific link for router

    std::pair<resource::LinkImpl*, resource::LinkImpl*> info =
        private_links_.at(node_pos_with_loopback_limiter(dst->id()));
    if (info.second) { // link down
      route->link_list.push_back(info.second);
      if (lat)
        *lat += info.second->get_latency();
    }
    if (has_limiter_) { // limiter for receiver
      info = private_links_.at(node_pos_with_loopback(dst->id()));
      route->link_list.push_back(info.first);
    }
  }
}