summaryrefslogtreecommitdiff
path: root/src/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.h')
-rw-r--r--src/client.h130
1 files changed, 21 insertions, 109 deletions
diff --git a/src/client.h b/src/client.h
index a1b1c66b4..0150b687e 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 <ostream>
#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();
- ~MeshUpdateQueue()
- {
- JMutexAutoLock lock(m_mutex);
-
- core::list<QueuedMeshUpdate*>::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<QueuedMeshUpdate*>::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<QueuedMeshUpdate*>::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()
{
@@ -309,40 +244,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<v3s16, MapBlock*> affected_blocks;
- ((ClientMap&)m_env.getMap()).setTempMod(p, mod,
- &affected_blocks);
-
- for(core::map<v3s16, MapBlock*>::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<v3s16, MapBlock*> affected_blocks;
- ((ClientMap&)m_env.getMap()).clearTempMod(p,
- &affected_blocks);
-
- for(core::map<v3s16, MapBlock*>::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()
{
@@ -389,6 +292,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:
@@ -404,11 +316,11 @@ private:
void sendPlayerInfo();
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;