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/client.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/client.h') diff --git a/src/client.h b/src/client.h index 699550eac..f5b03f19d 100644 --- a/src/client.h +++ b/src/client.h @@ -414,7 +414,8 @@ public: void updateCameraOffset(v3s16 camera_offset) { m_mesh_update_thread.m_camera_offset = camera_offset; } - // Get event from queue. CE_NONE is returned if queue is empty. + bool hasClientEvents() const { return !m_client_event_queue.empty(); } + // Get event from queue. If queue is empty, it triggers an assertion failure. ClientEvent getClientEvent(); bool accessDenied() const { return m_access_denied; } -- cgit v1.2.3