From f0b1b91a9f1d11a7fb242c6db09f52f70e810536 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 6 Oct 2012 21:28:15 -0400 Subject: [PATCH] client removes Shot objects when they expire --- src/client/Client.cc | 9 +++++++++ src/client/Client.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index 1599f71..b53f7b3 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -291,6 +291,15 @@ void Client::update(double elapsed_time) } } + for (m_shots_iterator_t it = m_shots.begin(); it != m_shots.end(); ) + { + sf::Vector3f shot_position = (*it)->get_position(); + if (shot_position.z <= 0.0) + it = m_shots.erase(it); + else + it++; + } + // For now, we are going to do a very crude shove data into // packet from keyboard and mouse events. // TODO: Clean this up and make it more robust diff --git a/src/client/Client.h b/src/client/Client.h index 4c37d2f..a4cd811 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -75,6 +75,7 @@ class Client float m_drawing_shot_distance; bool m_shot_fired; std::list< refptr > m_shots; + typedef std::list< refptr >::iterator m_shots_iterator_t; }; #endif