aboutsummaryrefslogtreecommitdiff
path: root/src/clientenvironment.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-04-29 17:25:25 +0200
committerGitHub <noreply@github.com>2017-04-29 17:25:25 +0200
commit3db66b453152c3610b858aa1650e1ab3f545a430 (patch)
treed1d625c50f8c350ff1f52b7ed446bd0ed2ea4e6b /src/clientenvironment.cpp
parentf727f54192644f6427ac1b2c86df8c64c7c5fdf0 (diff)
downloadminetest-3db66b453152c3610b858aa1650e1ab3f545a430.tar.gz
minetest-3db66b453152c3610b858aa1650e1ab3f545a430.tar.bz2
minetest-3db66b453152c3610b858aa1650e1ab3f545a430.zip
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
Diffstat (limited to 'src/clientenvironment.cpp')
-rw-r--r--src/clientenvironment.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/clientenvironment.cpp b/src/clientenvironment.cpp
index cc75fd2d6..36e4437b6 100644
--- a/src/clientenvironment.cpp
+++ b/src/clientenvironment.cpp
@@ -598,15 +598,13 @@ void ClientEnvironment::getActiveObjects(v3f origin, f32 max_d,
}
}
-ClientEnvEvent ClientEnvironment::getClientEvent()
+ClientEnvEvent ClientEnvironment::getClientEnvEvent()
{
- ClientEnvEvent event;
- if(m_client_event_queue.empty())
- event.type = CEE_NONE;
- else {
- event = m_client_event_queue.front();
- m_client_event_queue.pop();
- }
+ FATAL_ERROR_IF(m_client_event_queue.empty(),
+ "ClientEnvironment::getClientEnvEvent(): queue is empty");
+
+ ClientEnvEvent event = m_client_event_queue.front();
+ m_client_event_queue.pop();
return event;
}