]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client.h
SQLite rollback
[dragonfireclient.git] / src / client.h
index 570a6b3b0847055336bf1eee6e0a2d7b469f6da1..9f5eb833bfec872432613e86287971e76f4ca7e6 100644 (file)
@@ -23,14 +23,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "connection.h"
 #include "environment.h"
 #include "irrlichttypes_extrabloated.h"
-#include "jmutex.h"
+#include "jthread/jmutex.h"
 #include <ostream>
+#include <map>
 #include <set>
 #include <vector>
 #include "clientobject.h"
 #include "gamedef.h"
 #include "inventorymanager.h"
-#include "filesys.h"
 #include "filecache.h"
 #include "localplayer.h"
 #include "server.h"
@@ -157,7 +157,13 @@ enum ClientEventType
        CE_PLAYER_FORCE_MOVE,
        CE_DEATHSCREEN,
        CE_TEXTURES_UPDATED,
-       CE_SHOW_FORMSPEC
+       CE_SHOW_FORMSPEC,
+       CE_SPAWN_PARTICLE,
+       CE_ADD_PARTICLESPAWNER,
+       CE_DELETE_PARTICLESPAWNER,
+       CE_HUDADD,
+       CE_HUDRM,
+       CE_HUDCHANGE
 };
 
 struct ClientEvent
@@ -180,14 +186,117 @@ struct ClientEvent
                        f32 camera_point_target_z;
                } deathscreen;
                struct{
-                       std::stringformspec;
-                       std::stringformname;
+                       std::string *formspec;
+                       std::string *formname;
                } show_formspec;
                struct{
                } textures_updated;
+               struct{
+                       v3f *pos;
+                       v3f *vel;
+                       v3f *acc;
+                       f32 expirationtime;
+                       f32 size;
+                       bool collisiondetection;
+                       std::string *texture;
+               } spawn_particle;
+               struct{
+                       u16 amount;
+                       f32 spawntime;
+                       v3f *minpos;
+                       v3f *maxpos;
+                       v3f *minvel;
+                       v3f *maxvel;
+                       v3f *minacc;
+                       v3f *maxacc;
+                       f32 minexptime;
+                       f32 maxexptime;
+                       f32 minsize;
+                       f32 maxsize;
+                       bool collisiondetection;
+                       std::string *texture;
+                       u32 id;
+               } add_particlespawner;
+               struct{
+                       u32 id;
+               } delete_particlespawner;
+               struct{
+                       u32 id;
+                       u8 type;
+                       v2f *pos;
+                       std::string *name;
+                       v2f *scale;
+                       std::string *text;
+                       u32 number;
+                       u32 item;
+                       u32 dir;
+                       v2f *align;
+                       v2f *offset;
+               } hudadd;
+               struct{
+                       u32 id;
+               } hudrm;
+               struct{
+                       u32 id;
+                       HudElementStat stat;
+                       v2f *v2fdata;
+                       std::string *sdata;
+                       u32 data;
+               } hudchange;
        };
 };
 
+/*
+       Packet counter
+*/
+
+class PacketCounter
+{
+public:
+       PacketCounter()
+       {
+       }
+
+       void add(u16 command)
+       {
+               std::map<u16, u16>::iterator n = m_packets.find(command);
+               if(n == m_packets.end())
+               {
+                       m_packets[command] = 1;
+               }
+               else
+               {
+                       n->second++;
+               }
+       }
+
+       void clear()
+       {
+               for(std::map<u16, u16>::iterator
+                               i = m_packets.begin();
+                               i != m_packets.end(); ++i)
+               {
+                       i->second = 0;
+               }
+       }
+
+       void print(std::ostream &o)
+       {
+               for(std::map<u16, u16>::iterator
+                               i = m_packets.begin();
+                               i != m_packets.end(); ++i)
+               {
+                       o<<"cmd "<<i->first
+                                       <<" count "<<i->second
+                                       <<std::endl;
+               }
+       }
+
+private:
+       // command, count
+       std::map<u16, u16> m_packets;
+};
+
 class Client : public con::PeerHandler, public InventoryManager, public IGameDef
 {
 public:
@@ -205,7 +314,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
                        IWritableItemDefManager *itemdef,
                        IWritableNodeDefManager *nodedef,
                        ISoundManager *sound,
-                       MtEventManager *event
+                       MtEventManager *event,
+                       bool ipv6
        );
        
        ~Client();
@@ -247,6 +357,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        void sendChangePassword(const std::wstring oldpassword,
                        const std::wstring newpassword);
        void sendDamage(u8 damage);
+       void sendBreath(u16 breath);
        void sendRespawn();
 
        ClientEnvironment& getEnv()
@@ -283,7 +394,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        // Prints a line or two of info
        void printDebugInfo(std::ostream &os);
 
-       std::list<std::wstring> getConnectedPlayerNames();
+       std::list<std::string> getConnectedPlayerNames();
 
        float getAnimationTime();
 
@@ -291,6 +402,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        void setCrack(int level, v3s16 pos);
 
        u16 getHP();
+       u16 getBreath();
 
        bool checkPrivilege(const std::string &priv)
        { return (m_privileges.count(priv) != 0); }
@@ -327,7 +439,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        bool nodedefReceived()
        { return m_nodedef_received; }
        
-       void afterContentReceived();
+       void afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font);
 
        float getRTT(void);
 
@@ -358,8 +470,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        void Receive();
        
        void sendPlayerPos();
-       // This sends the player's current name etc to the server
-       void sendPlayerInfo();
        // Send the item number 'item' as player item to the server
        void sendPlayerItem(u16 item);
        
@@ -412,7 +522,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        u32 m_media_received_count;
        bool m_itemdef_received;
        bool m_nodedef_received;
-       friend class FarMesh;
 
        // time_of_day speed approximation for old protocol
        bool m_time_of_day_set;