]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client.h
when pause menu is activated, move mouse cursor on top of the disconnect button,...
[dragonfireclient.git] / src / client.h
index ef3dd435a04b5692dd49dfea576456da82e87893..f661838cee216ce5466d352845558721f41085a4 100644 (file)
@@ -174,55 +174,28 @@ class MeshUpdateThread : public SimpleThread
        MutexedQueue<MeshUpdateResult> 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
                        );
        
@@ -281,6 +255,9 @@ class Client : public con::PeerHandler, public InventoryManager
        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);
@@ -330,6 +307,8 @@ class Client : public con::PeerHandler, public InventoryManager
 
        u32 getDayNightRatio();
 
+       u16 getHP();
+
        //void updateSomeExpiredMeshes();
        
        void setTempMod(v3s16 p, NodeMod mod)
@@ -394,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
@@ -419,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;
        
@@ -453,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<ClientEvent> m_client_event_queue;
 };
 
 #endif // !SERVER