X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclient.h;h=f661838cee216ce5466d352845558721f41085a4;hb=3f0ac7adce0985b5ca35342f4b94dc218b922dd9;hp=611116d45b8b4cb6b10db0c770bc720a204b5e2c;hpb=4a92df6ff021f1bfa645f97fd551c648d1ef8e3b;p=dragonfireclient.git diff --git a/src/client.h b/src/client.h index 611116d45..f661838ce 100644 --- a/src/client.h +++ b/src/client.h @@ -174,55 +174,28 @@ class MeshUpdateThread : public SimpleThread MutexedQueue m_queue_out; }; -#if 0 -struct IncomingPacket +enum ClientEventType { - IncomingPacket() - { - m_data = NULL; - m_datalen = 0; - m_refcount = NULL; - } - IncomingPacket(const IncomingPacket &a) - { - m_data = a.m_data; - m_datalen = a.m_datalen; - m_refcount = a.m_refcount; - if(m_refcount != NULL) - (*m_refcount)++; - } - IncomingPacket(u8 *data, u32 datalen) - { - m_data = new u8[datalen]; - memcpy(m_data, data, datalen); - m_datalen = datalen; - m_refcount = new s32(1); - } - ~IncomingPacket() - { - if(m_refcount != NULL){ - assert(*m_refcount > 0); - (*m_refcount)--; - if(*m_refcount == 0){ - if(m_data != NULL) - delete[] m_data; - delete m_refcount; - } - } - } - /*IncomingPacket & operator=(IncomingPacket a) - { - m_data = a.m_data; - m_datalen = a.m_datalen; - m_refcount = a.m_refcount; - (*m_refcount)++; - return *this; - }*/ - u8 *m_data; - u32 m_datalen; - s32 *m_refcount; + CE_NONE, + CE_PLAYER_DAMAGE, + CE_PLAYER_FORCE_MOVE +}; + +struct ClientEvent +{ + ClientEventType type; + union{ + struct{ + } none; + struct{ + u8 amount; + } player_damage; + struct{ + f32 pitch; + f32 yaw; + } player_force_move; + }; }; -#endif class Client : public con::PeerHandler, public InventoryManager { @@ -234,6 +207,7 @@ class Client : public con::PeerHandler, public InventoryManager Client( IrrlichtDevice *device, const char *playername, + std::string password, MapDrawControl &control ); @@ -275,11 +249,15 @@ class Client : public con::PeerHandler, public InventoryManager void groundAction(u8 action, v3s16 nodepos_undersurface, v3s16 nodepos_oversurface, u16 item); void clickObject(u8 button, v3s16 blockpos, s16 id, u16 item); + void clickActiveObject(u8 button, u16 id, u16 item); void sendSignText(v3s16 blockpos, s16 id, std::string text); void sendSignNodeText(v3s16 p, std::string text); void sendInventoryAction(InventoryAction *a); void sendChatMessage(const std::wstring &message); + void sendChangePassword(const std::wstring oldpassword, + const std::wstring newpassword); + void sendDamage(u8 damage); // locks envlock void removeNode(v3s16 p); @@ -316,11 +294,21 @@ class Client : public con::PeerHandler, public InventoryManager core::line3d shootline_on_map ); + // Gets closest object pointed by the shootline + // Returns NULL if not found + ClientActiveObject * getSelectedActiveObject( + f32 max_d, + v3f from_pos_f_on_map, + core::line3d shootline_on_map + ); + // Prints a line or two of info void printDebugInfo(std::ostream &os); u32 getDayNightRatio(); + u16 getHP(); + //void updateSomeExpiredMeshes(); void setTempMod(v3s16 p, NodeMod mod) @@ -385,13 +373,18 @@ class Client : public con::PeerHandler, public InventoryManager u64 getMapSeed(){ return m_map_seed; } - /* - These are not thread-safe - */ void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false); // Including blocks at appropriate edges void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false); + // Get event from queue. CE_NONE is returned if queue is empty. + ClientEvent getClientEvent(); + + inline bool accessDenied() + { + return m_access_denied; + } + private: // Virtual methods from con::PeerHandler @@ -410,6 +403,7 @@ class Client : public con::PeerHandler, public InventoryManager float m_connection_reinit_timer; float m_avg_rtt_timer; float m_playerpos_send_timer; + float m_ignore_damage_timer; // Used after server moves player MeshUpdateThread m_mesh_update_thread; @@ -444,7 +438,12 @@ class Client : public con::PeerHandler, public InventoryManager // The seed returned by the server in TOCLIENT_INIT is stored here u64 m_map_seed; + std::string m_password; + bool m_access_denied; + InventoryContext m_inventory_context; + + Queue m_client_event_queue; }; #endif // !SERVER