1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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
This commit is contained in:
Loïc Blot 2017-08-28 20:02:23 +02:00 committed by GitHub
parent 6fd8a27c91
commit 5f38fe33f8
7 changed files with 608 additions and 505 deletions

View file

@ -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;