From 74e1edfd950869696ace92278987b946ef445190 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 15 Jun 2014 11:24:01 +0300 Subject: [PATCH] Remove unregistered ports that are no longer active --- source/netvis.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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(); -- 2.45.2