Port::Port(NetVis &v, unsigned n):
netvis(v),
number(n),
+ registered(false),
mesh((GL::COLOR4_UBYTE, GL::VERTEX2))
{
char buf[128];
addr.sin_addr.s_addr = 0;
int err = getnameinfo(reinterpret_cast<sockaddr *>(&addr), sizeof(sockaddr_in), 0, 0, buf, sizeof(buf), 0);
if(err==0)
+ {
name = buf;
+ registered = !isdigit(name[0]);
+ }
else
name = Msp::lexical_cast(number);
const map<unsigned, Port *> &ports = netvis.get_ports();
unsigned tries = 100;
- if(ports.size()>100 && number>=1024)
+ if(ports.size()>100 && !registered)
tries = 10000/ports.size()+1;
float best_score = 0;
for(unsigned i=0; (i<tries && best_score<1); ++i)
c.b = rand()*1.0/RAND_MAX;
float high = max(max(c.r, c.g), c.b);
c = c*(1.0/high);
- if(number<1024)
+ if(registered)
{
float low = min(min(c.r, c.g), c.b);
c = (c+-low)*(1/(1-low));
float score = 2;
for(map<unsigned, Port *>::const_iterator j=ports.begin(); j!=ports.end(); ++j)
{
- if(number<1024 && j->first>1024)
+ if(registered && !j->second->is_registered())
break;
const GL::Color &other = j->second->get_color();
float dr = c.r-other.r;
private:
NetVis &netvis;
unsigned number;
+ bool registered;
std::string name;
Msp::GL::Color color;
Msp::GL::Mesh mesh;
Port(NetVis &, unsigned);
unsigned get_number() const { return number; }
+ bool is_registered() const { return registered; }
const std::string &get_name() const { return name; }
const Msp::GL::Color &get_color() const { return color; }