X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fclient.h;h=1a7ef924ac53d7b9085c4a75e59e480dd60f9761;hb=9c94538fb7a7d7712d8da21d16790359a853f575;hp=a1b1c66b4a0d7381217b76b5533caf3354d9e6e0;hpb=1c90f9fc2eba43be71f9d49dad75c5d0514d4e50;p=oweals%2Fminetest.git diff --git a/src/client.h b/src/client.h index a1b1c66b4..1a7ef924a 100644 --- a/src/client.h +++ b/src/client.h @@ -28,6 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "jmutex.h" #include #include "clientobject.h" +#include "utility.h" // For IntervalLimiter + +struct MeshMakeData; class ClientNotReadyException : public BaseException { @@ -43,18 +46,8 @@ struct QueuedMeshUpdate MeshMakeData *data; bool ack_block_to_server; - QueuedMeshUpdate(): - p(-1337,-1337,-1337), - data(NULL), - ack_block_to_server(false) - { - } - - ~QueuedMeshUpdate() - { - if(data) - delete data; - } + QueuedMeshUpdate(); + ~QueuedMeshUpdate(); }; /* @@ -63,76 +56,18 @@ struct QueuedMeshUpdate class MeshUpdateQueue { public: - MeshUpdateQueue() - { - m_mutex.Init(); - } - - ~MeshUpdateQueue() - { - JMutexAutoLock lock(m_mutex); + MeshUpdateQueue(); - core::list::Iterator i; - for(i=m_queue.begin(); i!=m_queue.end(); i++) - { - QueuedMeshUpdate *q = *i; - delete q; - } - } + ~MeshUpdateQueue(); /* peer_id=0 adds with nobody to send to */ - void addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_server) - { - DSTACK(__FUNCTION_NAME); - - assert(data); - - JMutexAutoLock lock(m_mutex); - - /* - Find if block is already in queue. - If it is, update the data and quit. - */ - core::list::Iterator i; - for(i=m_queue.begin(); i!=m_queue.end(); i++) - { - QueuedMeshUpdate *q = *i; - if(q->p == p) - { - if(q->data) - delete q->data; - q->data = data; - if(ack_block_to_server) - q->ack_block_to_server = true; - return; - } - } - - /* - Add the block - */ - QueuedMeshUpdate *q = new QueuedMeshUpdate; - q->p = p; - q->data = data; - q->ack_block_to_server = ack_block_to_server; - m_queue.push_back(q); - } + void addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_server); // Returned pointer must be deleted // Returns NULL if queue is empty - QueuedMeshUpdate * pop() - { - JMutexAutoLock lock(m_mutex); - - core::list::Iterator i = m_queue.begin(); - if(i == m_queue.end()) - return NULL; - QueuedMeshUpdate *q = *i; - m_queue.erase(i); - return q; - } + QueuedMeshUpdate * pop(); u32 size() { @@ -271,10 +206,14 @@ public: // Wrapper to Map NodeMetadata* getNodeMetadata(v3s16 p); - v3f getPlayerPosition(); + // Get the player position, and optionally put the + // eye position in *eye_position + v3f getPlayerPosition(v3f *eye_position=NULL); void setPlayerControl(PlayerControl &control); - + + void selectPlayerItem(u16 item); + // Returns true if the inventory of the local player has been // updated from the server. If it is true, it is set to false. bool getLocalInventoryUpdated(); @@ -309,40 +248,8 @@ public: u16 getHP(); - //void updateSomeExpiredMeshes(); - - void setTempMod(v3s16 p, NodeMod mod) - { - //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out - assert(m_env.getMap().mapType() == MAPTYPE_CLIENT); - - core::map affected_blocks; - ((ClientMap&)m_env.getMap()).setTempMod(p, mod, - &affected_blocks); - - for(core::map::Iterator - i = affected_blocks.getIterator(); - i.atEnd() == false; i++) - { - i.getNode()->getValue()->updateMesh(m_env.getDayNightRatio()); - } - } - void clearTempMod(v3s16 p) - { - //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out - assert(m_env.getMap().mapType() == MAPTYPE_CLIENT); - - core::map affected_blocks; - ((ClientMap&)m_env.getMap()).clearTempMod(p, - &affected_blocks); - - for(core::map::Iterator - i = affected_blocks.getIterator(); - i.atEnd() == false; i++) - { - i.getNode()->getValue()->updateMesh(m_env.getDayNightRatio()); - } - } + void setTempMod(v3s16 p, NodeMod mod); + void clearTempMod(v3s16 p); float getAvgRtt() { @@ -363,6 +270,12 @@ public: void addChatMessage(const std::wstring &message) { + if (message[0] == L'/') { + m_chat_queue.push_back( + (std::wstring)L"issued command: "+message); + return; + } + //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out LocalPlayer *player = m_env.getLocalPlayer(); assert(player != NULL); @@ -389,6 +302,15 @@ public: { return m_access_denied_reason; } + + /* + This should only be used for calling the special drawing stuff in + ClientEnvironment + */ + ClientEnvironment * getEnv() + { + return &m_env; + } private: @@ -402,13 +324,15 @@ private: 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); float m_packetcounter_timer; - float m_delete_unused_sectors_timer; 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 + IntervalLimiter m_map_timer_and_unload_interval; MeshUpdateThread m_mesh_update_thread;