From b653e6a01271c05bdbd947ab7120d10d30ecee91 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 21 Feb 2012 16:27:30 +0000 Subject: Removed cChunkPtrs from everywhere but internal cChunkMap usage. Now we should finally be threadsafe :) Also fixed a threading issue when a player connecting might have gotten stuck in "Downloading world" forever git-svn-id: http://mc-server.googlecode.com/svn/trunk@304 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunkMap.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source/cChunkMap.h') diff --git a/source/cChunkMap.h b/source/cChunkMap.h index 026594f11..98698cfe3 100644 --- a/source/cChunkMap.h +++ b/source/cChunkMap.h @@ -13,6 +13,7 @@ class cWorld; class cEntity; +class cItem; class MTRand; @@ -27,10 +28,6 @@ public: cChunkMap(cWorld* a_World ); ~cChunkMap(); - // TODO: Get rid of these (put into Private section) in favor of the direct action methods: - cChunkPtr GetChunk ( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); // Also queues the chunk for loading / generating if not valid - cChunkPtr GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); // Also queues the chunk for loading if not valid; doesn't generate - // Direct action methods: /// Broadcast a_Packet to all clients in the chunk specified void BroadcastToChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cPacket & a_Packet, cClientHandle * a_Exclude = NULL); @@ -56,6 +53,10 @@ public: void CollectPickupsByPlayer(cPlayer * a_Player); char GetBlock (int a_X, int a_Y, int a_Z); char GetBlockMeta (int a_X, int a_Y, int a_Z); + void SetBlockMeta (int a_X, int a_Y, int a_Z, char a_BlockMeta); + void SetBlock (int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta); + bool DigBlock (int a_X, int a_Y, int a_Z, cItem & a_PickupItem); + void SendBlockTo (int a_X, int a_Y, int a_Z, cPlayer * a_Player); /// Compares clients of two chunks, calls the callback accordingly void CompareChunkClients(int a_ChunkX1, int a_ChunkY1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkY2, int a_ChunkZ2, cClientDiffCallback & a_Callback); @@ -63,6 +64,9 @@ public: /// Adds client to a chunk, if not already present; returns true if added, false if present bool AddChunkClient(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHandle * a_Client); + /// Removes the client from the chunk + void RemoveChunkClient(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHandle * a_Client); + /// Removes the client from all chunks specified void RemoveClientFromChunks(cClientHandle * a_Client, const cChunkCoordsList & a_Chunks); @@ -74,6 +78,11 @@ public: /// Removes the entity from the chunk specified void RemoveEntityFromChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkY, int a_ChunkZ); + + /// Touches the chunk, causing it to be loaded or generated + void TouchChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ); + + void UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); void Tick( float a_Dt, MTRand & a_TickRand ); @@ -113,6 +122,8 @@ public: private: + friend class cChunk; // Temporary (until we have a separate Lighting thread), so that cChunk's lighting calc can ask for neighbor chunks + class cChunkLayer { public: @@ -153,6 +164,9 @@ private: cEvent m_evtChunkValid; // Set whenever any chunk becomes valid, via ChunkValidated() cWorld * m_World; + + cChunkPtr GetChunk ( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); // Also queues the chunk for loading / generating if not valid + cChunkPtr GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); // Also queues the chunk for loading if not valid; doesn't generate }; -- cgit v1.2.3