]> git.lizzy.rs Git - minetest.git/blobdiff - src/client.cpp
Particles: Do not add digging particles for airlike nodes (#6392)
[minetest.git] / src / client.cpp
index 658b10393d3ade8eb00eb088daa02abc1c6a83c7..09ac5196d8e9c94c7ffa8ef2b7bc4d09b334258c 100644 (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"
@@ -251,8 +252,6 @@ Client::~Client()
 
 void Client::connect(Address address, bool is_local_server)
 {
-       DSTACK(FUNCTION_NAME);
-
        initLocalMapSaving(address, m_address_name, is_local_server);
 
        m_con->SetTimeoutMs(0);
@@ -261,8 +260,6 @@ void Client::connect(Address address, bool is_local_server)
 
 void Client::step(float dtime)
 {
-       DSTACK(FUNCTION_NAME);
-
        // Limit a bit
        if(dtime > 2.0)
                dtime = 2.0;
@@ -425,9 +422,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);
                        }
                }
@@ -772,7 +769,6 @@ void Client::initLocalMapSaving(const Address &address,
 
 void Client::ReceiveAll()
 {
-       DSTACK(FUNCTION_NAME);
        u64 start_ms = porting::getTimeMs();
        for(;;)
        {
@@ -798,7 +794,6 @@ void Client::ReceiveAll()
 
 void Client::Receive()
 {
-       DSTACK(FUNCTION_NAME);
        NetworkPacket pkt;
        m_con->Receive(&pkt);
        ProcessData(&pkt);
@@ -815,8 +810,6 @@ inline void Client::handleCommand(NetworkPacket* pkt)
 */
 void Client::ProcessData(NetworkPacket *pkt)
 {
-       DSTACK(FUNCTION_NAME);
-
        ToClientCommand command = (ToClientCommand) pkt->getCommand();
        u32 sender_peer_id = pkt->getPeerId();
 
@@ -1234,8 +1227,6 @@ void Client::sendChangePassword(const std::string &oldpassword,
 
 void Client::sendDamage(u8 damage)
 {
-       DSTACK(FUNCTION_NAME);
-
        NetworkPacket pkt(TOSERVER_DAMAGE, sizeof(u8));
        pkt << damage;
        Send(&pkt);
@@ -1243,8 +1234,6 @@ void Client::sendDamage(u8 damage)
 
 void Client::sendBreath(u16 breath)
 {
-       DSTACK(FUNCTION_NAME);
-
        // Protocol v29 make this obsolete
        if (m_proto_ver >= 29)
                return;
@@ -1256,16 +1245,12 @@ void Client::sendBreath(u16 breath)
 
 void Client::sendRespawn()
 {
-       DSTACK(FUNCTION_NAME);
-
        NetworkPacket pkt(TOSERVER_RESPAWN, 0);
        Send(&pkt);
 }
 
 void Client::sendReady()
 {
-       DSTACK(FUNCTION_NAME);
-
        NetworkPacket pkt(TOSERVER_CLIENT_READY,
                        1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(g_version_hash));
 
@@ -1661,12 +1646,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 +1850,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;