From 3db66b453152c3610b858aa1650e1ab3f545a430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sat, 29 Apr 2017 17:25:25 +0200 Subject: Client & ClientEnvirnment: don't create fake events (#5676) Instead of create fake events on the stack on each loop call (Game::run), verify is queue is empty or not and handle event directly if there is. This prevents fake ClientEvent creation & memory allocations Same fix is also applied on ClientEnvironment, & rename getClientEvent to getClientEnvEvent to match ClientEnvEvent object --- src/clientenvironment.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/clientenvironment.h') diff --git a/src/clientenvironment.h b/src/clientenvironment.h index c273ede54..79b4797ad 100644 --- a/src/clientenvironment.h +++ b/src/clientenvironment.h @@ -126,8 +126,9 @@ public: void getActiveObjects(v3f origin, f32 max_d, std::vector &dest); - // Get event from queue. CEE_NONE is returned if queue is empty. - ClientEnvEvent getClientEvent(); + bool hasClientEnvEvents() const { return !m_client_event_queue.empty(); } + // Get event from queue. If queue is empty, it triggers an assertion failure. + ClientEnvEvent getClientEnvEvent(); /*! * Gets closest object pointed by the shootline. -- cgit v1.2.3