diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-28 20:02:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-28 20:02:23 +0200 |
commit | 5f38fe33f89e87b56ab95370c2f07fe6117b5eb0 (patch) | |
tree | e2a497bb99f37ce6baae56d2979a2ae957829dc2 /src/client.cpp | |
parent | 6fd8a27c91b09f51693243586af3615f962d1730 (diff) | |
download | hax-minetest-server-5f38fe33f89e87b56ab95370c2f07fe6117b5eb0.tar.gz hax-minetest-server-5f38fe33f89e87b56ab95370c2f07fe6117b5eb0.zip |
Clientevent refactor (#6320)
* Refactor clientevent structure
* Move structure outside of client header
* Create client events on heap not stack, this remove the ClientEvent object copy
* Use clientEventHandler to route events
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/client.cpp b/src/client.cpp index 658b10393..6fd007181 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "network/connection.h" #include "network/networkpacket.h" #include "threading/mutex_auto_lock.h" +#include "client/clientevent.h" #include "client/renderingengine.h" #include "util/auth.h" #include "util/directiontables.h" @@ -425,9 +426,9 @@ void Client::step(float dtime) sendDamage(damage); // Add to ClientEvent queue - ClientEvent event; - event.type = CE_PLAYER_DAMAGE; - event.player_damage.amount = damage; + ClientEvent *event = new ClientEvent(); + event->type = CE_PLAYER_DAMAGE; + event->player_damage.amount = damage; m_client_event_queue.push(event); } } @@ -1661,12 +1662,12 @@ void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool ur } } -ClientEvent Client::getClientEvent() +ClientEvent *Client::getClientEvent() { FATAL_ERROR_IF(m_client_event_queue.empty(), "Cannot getClientEvent, queue is empty."); - ClientEvent event = m_client_event_queue.front(); + ClientEvent *event = m_client_event_queue.front(); m_client_event_queue.pop(); return event; } @@ -1865,6 +1866,11 @@ bool Client::shouldShowMinimap() const return !m_minimap_disabled_by_server; } +void Client::pushToEventQueue(ClientEvent *event) +{ + m_client_event_queue.push(event); +} + void Client::showGameChat(const bool show) { m_game_ui_flags->show_chat = show; |