]> git.lizzy.rs Git - minetest.git/blobdiff - src/client.h
Cleanup some header inclusions to improve compilation times
[minetest.git] / src / client.h
index efd373e4266db7f707414f0082b73deb223ed182..f84246deb49c07dc25b2f91d29a5078fedcb7fc7 100644 (file)
@@ -21,9 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define CLIENT_HEADER
 
 #include "network/connection.h"
-#include "environment.h"
+#include "clientenvironment.h"
 #include "irrlichttypes_extrabloated.h"
-#include "jthread/jmutex.h"
+#include "threading/mutex.h"
 #include <ostream>
 #include <map>
 #include <set>
@@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "localplayer.h"
 #include "hud.h"
 #include "particles.h"
-#include "network/networkpacket.h"
+#include "mapnode.h"
 
 struct MeshMakeData;
 class MapBlockMesh;
@@ -50,6 +50,8 @@ struct PointedThing;
 class Database;
 class Mapper;
 struct MinimapMapblock;
+class Camera;
+class NetworkPacket;
 
 struct QueuedMeshUpdate
 {
@@ -89,14 +91,14 @@ class MeshUpdateQueue
 
        u32 size()
        {
-               JMutexAutoLock lock(m_mutex);
+               MutexAutoLock lock(m_mutex);
                return m_queue.size();
        }
 
 private:
        std::vector<QueuedMeshUpdate*> m_queue;
        std::set<v3s16> m_urgents;
-       JMutex m_mutex;
+       Mutex m_mutex;
 };
 
 struct MeshUpdateResult
@@ -119,19 +121,14 @@ class MeshUpdateThread : public UpdateThread
        MeshUpdateQueue m_queue_in;
 
 protected:
-       const char *getName()
-       { return "MeshUpdateThread"; }
        virtual void doUpdate();
 
 public:
 
-       MeshUpdateThread()
-       {
-       }
+       MeshUpdateThread() : UpdateThread("Mesh") {}
 
        void enqueueUpdate(v3s16 p, MeshMakeData *data,
                        bool ack_block_to_server, bool urgent);
-
        MutexedQueue<MeshUpdateResult> m_queue_out;
 
        v3s16 m_camera_offset;
@@ -186,6 +183,7 @@ struct ClientEvent
                        f32 expirationtime;
                        f32 size;
                        bool collisiondetection;
+                       bool collision_removal;
                        bool vertical;
                        std::string *texture;
                } spawn_particle;
@@ -203,6 +201,8 @@ struct ClientEvent
                        f32 minsize;
                        f32 maxsize;
                        bool collisiondetection;
+                       bool collision_removal;
+                       u16 attached_id;
                        bool vertical;
                        std::string *texture;
                        u32 id;
@@ -403,9 +403,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
 
        void ProcessData(NetworkPacket *pkt);
 
-       // Returns true if something was received
-       bool AsyncProcessPacket();
-       bool AsyncProcessData();
        void Send(NetworkPacket* pkt);
 
        void interact(u8 action, const PointedThing& pointed);
@@ -423,8 +420,9 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        void sendRespawn();
        void sendReady();
 
-       ClientEnvironment& getEnv()
-       { return m_env; }
+       ClientEnvironment& getEnv() { return m_env; }
+       ITextureSource *tsrc() { return getTextureSource(); }
+       ISoundManager *sound() { return getSoundManager(); }
 
        // Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
        void removeNode(v3s16 p);
@@ -446,28 +444,19 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        Inventory* getInventory(const InventoryLocation &loc);
        void inventoryAction(InventoryAction *a);
 
-       // 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<f32> shootline_on_map
-       );
-
-       std::list<std::string> getConnectedPlayerNames();
+       const std::list<std::string> &getConnectedPlayerNames()
+       {
+               return m_env.getPlayerNames();
+       }
 
        float getAnimationTime();
 
        int getCrackLevel();
        void setCrack(int level, v3s16 pos);
 
-       void setHighlighted(v3s16 pos, bool show_higlighted);
-       v3s16 getHighlighted(){ return m_highlighted_pos; }
-
        u16 getHP();
-       u16 getBreath();
 
-       bool checkPrivilege(const std::string &priv)
+       bool checkPrivilege(const std::string &priv) const
        { return (m_privileges.count(priv) != 0); }
 
        bool getChatMessage(std::wstring &message);
@@ -489,6 +478,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        bool accessDenied()
        { return m_access_denied; }
 
+       bool reconnectRequested() { return m_access_denied_reconnect; }
+
        std::string accessDeniedReason()
        { return m_access_denied_reason; }
 
@@ -502,6 +493,9 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        u8 getProtoVersion()
        { return m_proto_ver; }
 
+       bool connectedToServer()
+       { return m_con.Connected(); }
+
        float mediaReceiveProgress();
 
        void afterContentReceived(IrrlichtDevice *device);
@@ -513,18 +507,28 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        Mapper* getMapper ()
        { return m_mapper; }
 
+       void setCamera(Camera* camera)
+       { m_camera = camera; }
+
+       Camera* getCamera ()
+       { return m_camera; }
+
+       bool isMinimapDisabledByServer()
+       { return m_minimap_disabled_by_server; }
+
        // IGameDef interface
        virtual IItemDefManager* getItemDefManager();
        virtual INodeDefManager* getNodeDefManager();
        virtual ICraftDefManager* getCraftDefManager();
-       virtual ITextureSource* getTextureSource();
+       ITextureSource* getTextureSource();
        virtual IShaderSource* getShaderSource();
-       virtual scene::ISceneManager* getSceneManager();
+       IShaderSource *shsrc() { return getShaderSource(); }
+       scene::ISceneManager* getSceneManager();
        virtual u16 allocateUnknownNodeId(const std::string &name);
        virtual ISoundManager* getSoundManager();
        virtual MtEventManager* getEventManager();
        virtual ParticleManager* getParticleManager();
-       virtual bool checkLocalPrivilege(const std::string &priv)
+       bool checkLocalPrivilege(const std::string &priv)
        { return checkPrivilege(priv); }
        virtual scene::IAnimatedMesh* getMesh(const std::string &filename);
 
@@ -592,22 +596,28 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        ParticleManager m_particle_manager;
        con::Connection m_con;
        IrrlichtDevice *m_device;
+       Camera *m_camera;
        Mapper *m_mapper;
+       bool m_minimap_disabled_by_server;
        // Server serialization version
        u8 m_server_ser_ver;
+
        // Used version of the protocol with server
+       // Values smaller than 25 only mean they are smaller than 25,
+       // and aren't accurate. We simply just don't know, because
+       // the server didn't send the version back then.
+       // If 0, server init hasn't been received yet.
        u8 m_proto_ver;
+
        u16 m_playeritem;
        bool m_inventory_updated;
        Inventory *m_inventory_from_server;
        float m_inventory_from_server_age;
        PacketCounter m_packetcounter;
-       bool m_show_highlighted;
        // Block mesh animation parameters
        float m_animation_time;
        int m_crack_level;
        v3s16 m_crack_pos;
-       v3s16 m_highlighted_pos;
        // 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
        //s32 m_daynight_i;
        //u32 m_daynight_ratio;
@@ -630,6 +640,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
 
 
        bool m_access_denied;
+       bool m_access_denied_reconnect;
        std::string m_access_denied_reason;
        std::queue<ClientEvent> m_client_event_queue;
        bool m_itemdef_received;
@@ -647,18 +658,18 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        // Sounds
        float m_removed_sounds_check_timer;
        // Mapping from server sound ids to our sound ids
-       std::map<s32, int> m_sounds_server_to_client;
+       UNORDERED_MAP<s32, int> m_sounds_server_to_client;
        // And the other way!
-       std::map<int, s32> m_sounds_client_to_server;
+       UNORDERED_MAP<int, s32> m_sounds_client_to_server;
        // And relations to objects
-       std::map<int, u16> m_sounds_to_objects;
+       UNORDERED_MAP<int, u16> m_sounds_to_objects;
 
        // Privileges
-       std::set<std::string> m_privileges;
+       UNORDERED_SET<std::string> m_privileges;
 
        // Detached inventories
        // key = name
-       std::map<std::string, Inventory*> m_detached_inventories;
+       UNORDERED_MAP<std::string, Inventory*> m_detached_inventories;
 
        // Storage for mesh data for creating multiple instances of the same mesh
        StringMap m_mesh_data;
@@ -674,6 +685,9 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        // TODO: Add callback to update these when g_settings changes
        bool m_cache_smooth_lighting;
        bool m_cache_enable_shaders;
+       bool m_cache_use_tangent_vertices;
+
+       DISABLE_CLASS_COPY(Client);
 };
 
 #endif // !CLIENT_HEADER