From: Mikko Rasa Date: Sun, 15 Jun 2014 08:24:01 +0000 (+0300) Subject: Remove unregistered ports that are no longer active X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=74e1edfd950869696ace92278987b946ef445190;p=netvis.git Remove unregistered ports that are no longer active --- diff --git a/source/netvis.cpp b/source/netvis.cpp index 17f113a..83dbd1a 100644 --- a/source/netvis.cpp +++ b/source/netvis.cpp @@ -173,6 +173,19 @@ void NetVis::tick() } } + for(map::iterator i=ports.begin(); i!=ports.end();) + { + i->second->tick(dt); + + if(!i->second->is_registered() && i->second->get_activity()<0.1) + { + delete i->second; + ports.erase(i++); + } + else + ++i; + } + for(list::iterator i=packets.begin(); i!=packets.end();) { (*i)->tick(dt); @@ -227,10 +240,12 @@ void NetVis::render() GL::pop_matrix(); GL::push_matrix(); - GL::translate(-500, -360, 0); + GL::translate(-500, -348, 0); GL::scale_uniform(10); font->draw_string(format("%d hosts", hosts.size()+disabled_hosts.size())); GL::translate(0, -1.2, 0); + font->draw_string(format("%d ports", ports.size())); + GL::translate(0, -1.2, 0); font->draw_string(format("%.2f fps", fps)); GL::Texture::unbind(); GL::pop_matrix();