From e8e76a6058988cb0cff222579049fb6aa3cdb9c1 Mon Sep 17 00:00:00 2001 From: narroo Date: Mon, 10 Feb 2014 20:00:07 -0500 Subject: Fixed bug #385. UnloadUnusedChunks now has the same interface as SaveAllChunks. Meaning, QueueUnloadUnusedChunks and the supporting cTaskUnloadUnusedChunks has been added. Use QueueUnloadUnusedChunks from now on to prevent deadlocking. --- src/World.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 0174be03b..e4036d8df 100644 --- a/src/World.h +++ b/src/World.h @@ -99,6 +99,15 @@ public: } ; + class cTaskUnloadUnusedChunks : + public cTask + { + protected: + // cTask overrides: + virtual void Run(cWorld & a_World) override; + }; + + static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates { return "cWorld"; @@ -243,7 +252,12 @@ public: bool IsChunkValid (int a_ChunkX, int a_ChunkZ) const; bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const; - void UnloadUnusedChunks(void); // tolua_export + + /*Unloads all chunks immediately. Dangerous interface, may deadlock, use QueueUnloadUnusedChunks() instead*/ + void UnloadUnusedChunks(void); + + /*Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/ + void QueueUnloadUnusedChunks(void); // tolua_export void CollectPickupsByPlayer(cPlayer * a_Player); -- cgit v1.2.3 From d7f32ed682b19cded6c54f14e4e46792695399a7 Mon Sep 17 00:00:00 2001 From: narroo Date: Tue, 11 Feb 2014 08:01:25 -0500 Subject: Fixed formatting of previous commit. --- src/World.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index e4036d8df..5161c7fd6 100644 --- a/src/World.h +++ b/src/World.h @@ -253,10 +253,10 @@ public: bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const; - /*Unloads all chunks immediately. Dangerous interface, may deadlock, use QueueUnloadUnusedChunks() instead*/ + /** Unloads all chunks immediately. Dangerous interface, may deadlock, use QueueUnloadUnusedChunks() instead*/ void UnloadUnusedChunks(void); - /*Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/ + /** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/ void QueueUnloadUnusedChunks(void); // tolua_export void CollectPickupsByPlayer(cPlayer * a_Player); -- cgit v1.2.3 From e53b331b4a17234c89f0ac54e724a5f48de4c4be Mon Sep 17 00:00:00 2001 From: narroo Date: Tue, 11 Feb 2014 14:38:28 -0500 Subject: Fixed formatting. Moved UnloadUnusedChunks from public to private. --- src/World.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 5161c7fd6..f22a8f49c 100644 --- a/src/World.h +++ b/src/World.h @@ -252,10 +252,6 @@ public: bool IsChunkValid (int a_ChunkX, int a_ChunkZ) const; bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const; - - /** Unloads all chunks immediately. Dangerous interface, may deadlock, use QueueUnloadUnusedChunks() instead*/ - void UnloadUnusedChunks(void); - /** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/ void QueueUnloadUnusedChunks(void); // tolua_export @@ -882,6 +878,9 @@ private: /** Ticks all clients that are in this world */ void TickClients(float a_Dt); + /** Unloads all chunks immediately.*/ + void UnloadUnusedChunks(void); + void UpdateSkyDarkness(void); /** Generates a random spawnpoint on solid land by walking chunks and finding their biomes */ -- cgit v1.2.3 From ceb16ea2f714cc1b9f52750446e3842e2b6a5820 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 15 Feb 2014 11:38:20 +0100 Subject: Exported cWorld::BroadcastParticleEffect. --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index fa83fe73e..9049971be 100644 --- a/src/World.h +++ b/src/World.h @@ -183,7 +183,7 @@ public: void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL); - void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); + void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); void BroadcastScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); -- cgit v1.2.3 From 0f1f7583aeea65335b2ee051585a857b1142a927 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 15 Feb 2014 23:16:44 +0100 Subject: Implemented cCompositeChat. This allows plugins to send composite chat messages, containing URLs, commands to run and cmdline suggestions. Fixes #678. --- src/World.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index ca1b7dcc5..2fbc51038 100644 --- a/src/World.h +++ b/src/World.h @@ -46,6 +46,7 @@ class cDispenserEntity; class cFurnaceEntity; class cNoteEntity; class cMobCensus; +class cCompositeChat; typedef std::list< cPlayer * > cPlayerList; @@ -167,7 +168,7 @@ public: void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude - void LoopPlayersAndBroadcastChat(const AString & a_Message, ChatPrefixCodes a_ChatPrefix, const cClientHandle * a_Exclude = NULL); + void LoopPlayersAndBroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix, const cClientHandle * a_Exclude = NULL); void BroadcastChatDeath (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtDeath, a_Exclude); } // tolua_begin @@ -177,6 +178,7 @@ public: void BroadcastChatSuccess(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtSuccess, a_Exclude); } void BroadcastChatWarning(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtWarning, a_Exclude); } void BroadcastChatFatal (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtFailure, a_Exclude); } + void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = NULL); // tolua_end void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); -- cgit v1.2.3 From 52cd9dfe9f7cfc7c229049d98993f13b6b8ddd5d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 15 Feb 2014 23:26:19 +0100 Subject: Removed the unnecessary LoopPlayersAndBroadcastChat() functions. --- src/World.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 2fbc51038..97358b88a 100644 --- a/src/World.h +++ b/src/World.h @@ -168,16 +168,14 @@ public: void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude - void LoopPlayersAndBroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix, const cClientHandle * a_Exclude = NULL); - void BroadcastChatDeath (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtDeath, a_Exclude); } - // tolua_begin - void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtCustom, a_Exclude); } - void BroadcastChatInfo (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtInformation, a_Exclude); } - void BroadcastChatFailure(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtFailure, a_Exclude); } - void BroadcastChatSuccess(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtSuccess, a_Exclude); } - void BroadcastChatWarning(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtWarning, a_Exclude); } - void BroadcastChatFatal (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { LoopPlayersAndBroadcastChat(a_Message, mtFailure, a_Exclude); } + void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = NULL, eMessageType a_ChatPrefix = mtCustom); + void BroadcastChatInfo (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(a_Message, a_Exclude, mtInformation); } + void BroadcastChatFailure(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(a_Message, a_Exclude, mtFailure); } + void BroadcastChatSuccess(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(a_Message, a_Exclude, mtSuccess); } + void BroadcastChatWarning(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(a_Message, a_Exclude, mtWarning); } + void BroadcastChatFatal (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(a_Message, a_Exclude, mtFailure); } + void BroadcastChatDeath (const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(a_Message, a_Exclude, mtDeath); } void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = NULL); // tolua_end -- cgit v1.2.3 From fc8743df9671172158d9d491843b8e208d3e25f3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 18 Feb 2014 08:25:29 +0100 Subject: Added a bit more documentation to cForEachChunkProvider. --- src/World.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 97358b88a..f885040ba 100644 --- a/src/World.h +++ b/src/World.h @@ -64,7 +64,10 @@ typedef cItemCallback cCommandBlockCallback; // tolua_begin -class cWorld : public cForEachChunkProvider, public cWorldInterface, public cBroadcastInterface +class cWorld : + public cForEachChunkProvider, + public cWorldInterface, + public cBroadcastInterface { public: @@ -401,15 +404,15 @@ public: Prefer cBlockArea::Write() instead, this is the internal implementation; cBlockArea does error checking, too. a_DataTypes is a bitmask of cBlockArea::baXXX constants ORed together. */ - virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes); + virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override; // tolua_begin /** Spawns item pickups for each item in the list. May compress pickups if too many entities: */ - virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false); + virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false); // override; cannot specify it here due to tolua /** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: */ - virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false); + virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false); // override; cannot specify it here due to tolua /** Spawns an falling block entity at the given position. It returns the UniqueID of the spawned falling block. */ int SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta); -- cgit v1.2.3 From 803ea412361ee2f4b1d74a811ddbee05f50c9345 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 18 Feb 2014 13:06:18 +0100 Subject: Added cWorld:SetAreaBiome() API function. Fixes #675. --- src/World.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index f885040ba..dc286598c 100644 --- a/src/World.h +++ b/src/World.h @@ -47,6 +47,7 @@ class cFurnaceEntity; class cNoteEntity; class cMobCensus; class cCompositeChat; +class cCuboid; typedef std::list< cPlayer * > cPlayerList; @@ -306,9 +307,14 @@ public: /** Removes the client from all chunks it is present in */ void RemoveClientFromChunks(cClientHandle * a_Client); - /** Sends the chunk to the client specified, if the chunk is valid. If not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid+lighted) */ + /** Sends the chunk to the client specified, if the client doesn't have the chunk yet. + If chunk not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid + lighted). */ void SendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); + /** Sends the chunk to the client specified, even if the client already has the chunk. + If the chunk's not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid + lighted). */ + void ForceSendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); + /** Removes client from ChunkSender's queue of chunks to be sent */ void RemoveClientFromChunkSender(cClientHandle * a_Client); @@ -549,6 +555,18 @@ public: /** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */ EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ); + + /** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded). + Doesn't resend the chunk to clients, use ForceSendChunkTo() for that. */ + bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome); + + /** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded). + (Re)sends the chunks to their relevant clients if successful. */ + bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome); + + /** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded). + (Re)sends the chunks to their relevant clients if successful. */ + bool SetAreaBiome(const cCuboid & a_Area, EMCSBiome a_Biome); /** Returns the name of the world */ const AString & GetName(void) const { return m_WorldName; } -- cgit v1.2.3 From b1c6b4f5843d1f466cd12dd159bc717ae46059b5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 18 Feb 2014 13:44:40 +0100 Subject: The cuboid for cWorld::SetAreaBiome() doesn't need sorting. --- src/World.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index dc286598c..d79de3b87 100644 --- a/src/World.h +++ b/src/World.h @@ -565,7 +565,8 @@ public: bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome); /** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded). - (Re)sends the chunks to their relevant clients if successful. */ + (Re)sends the chunks to their relevant clients if successful. + The cuboid needn't be sorted. */ bool SetAreaBiome(const cCuboid & a_Area, EMCSBiome a_Biome); /** Returns the name of the world */ -- cgit v1.2.3 From 52c41f886927cf62ed592ba7fec974eee6b16844 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 18 Feb 2014 21:40:02 +0100 Subject: Add Heads completely --- src/World.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 97358b88a..4e83833ed 100644 --- a/src/World.h +++ b/src/World.h @@ -45,6 +45,7 @@ class cChestEntity; class cDispenserEntity; class cFurnaceEntity; class cNoteEntity; +class cSkullEntity; class cMobCensus; class cCompositeChat; @@ -57,6 +58,7 @@ typedef cItemCallback cDispenserCallback; typedef cItemCallback cFurnaceCallback; typedef cItemCallback cNoteBlockCallback; typedef cItemCallback cCommandBlockCallback; +typedef cItemCallback cSkullBlockCallback; @@ -510,6 +512,9 @@ public: /** Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found */ bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback); // Exported in ManualBindings.cpp + /** Calls the callback for the skull block at the specified coords; returns false if there's no skull block at those coords or callback returns true, returns true if found */ + bool DoWithSkullBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cSkullBlockCallback & a_Callback); // Exported in ManualBindings.cpp + /** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */ bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp -- cgit v1.2.3 From d63ce62f3bbe4b8e89b8c54af4b71d77bcc7e052 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 19 Feb 2014 14:45:09 +0100 Subject: Rename SkullEntity to MobHeadEntity --- src/World.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 4e83833ed..9c7079a92 100644 --- a/src/World.h +++ b/src/World.h @@ -45,7 +45,7 @@ class cChestEntity; class cDispenserEntity; class cFurnaceEntity; class cNoteEntity; -class cSkullEntity; +class cMobHeadEntity; class cMobCensus; class cCompositeChat; @@ -58,7 +58,7 @@ typedef cItemCallback cDispenserCallback; typedef cItemCallback cFurnaceCallback; typedef cItemCallback cNoteBlockCallback; typedef cItemCallback cCommandBlockCallback; -typedef cItemCallback cSkullBlockCallback; +typedef cItemCallback cMobHeadBlockCallback; @@ -512,8 +512,8 @@ public: /** Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found */ bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback); // Exported in ManualBindings.cpp - /** Calls the callback for the skull block at the specified coords; returns false if there's no skull block at those coords or callback returns true, returns true if found */ - bool DoWithSkullBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cSkullBlockCallback & a_Callback); // Exported in ManualBindings.cpp + /** Calls the callback for the mob head block at the specified coords; returns false if there's no mob head block at those coords or callback returns true, returns true if found */ + bool DoWithMobHeadBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadBlockCallback & a_Callback); // Exported in ManualBindings.cpp /** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */ bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp -- cgit v1.2.3