summaryrefslogtreecommitdiffstats
path: root/src/World.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/World.h')
-rw-r--r--src/World.h58
1 files changed, 49 insertions, 9 deletions
diff --git a/src/World.h b/src/World.h
index 6c0548ae6..aeab7bfa5 100644
--- a/src/World.h
+++ b/src/World.h
@@ -103,8 +103,12 @@ public:
class cTask
{
public:
+ cTask(const cTask & other) = default;
virtual ~cTask() {}
virtual void Run(cWorld & a_World) = 0;
+
+ protected:
+ cTask() {}
} ;
typedef SharedPtr<cTask> cTaskPtr;
@@ -142,6 +146,21 @@ public:
std::vector<Vector3i> m_SendQueue;
};
+ class cTaskLambda :
+ public cTask
+ {
+
+ public:
+ cTaskLambda(std::function<void(cWorld&)> a_Func) :
+ m_func(a_Func)
+ { }
+
+ protected:
+ virtual void Run(cWorld & a_World) override;
+
+ std::function<void(cWorld&)> m_func;
+ };
+
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
{
@@ -203,10 +222,10 @@ public:
bool VillagersShouldHarvestCrops(void) const { return m_VillagersShouldHarvestCrops; }
- virtual eDimension GetDimension(void) const { return m_Dimension; }
+ virtual eDimension GetDimension(void) const override { return m_Dimension; }
/** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
- virtual int GetHeight(int a_BlockX, int a_BlockZ);
+ virtual int GetHeight(int a_BlockX, int a_BlockZ) override;
// tolua_end
@@ -216,7 +235,7 @@ public:
// Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
- void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
+ void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
@@ -231,7 +250,6 @@ public:
void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = nullptr);
// tolua_end
- void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = nullptr);
void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
@@ -253,7 +271,7 @@ public:
void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode);
void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display);
- void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr); // tolua_export
+ void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) override; // tolua_export
void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
@@ -385,7 +403,7 @@ public:
The specified chunk is queued to be loaded or generated, and lit if needed.
The specified callback is called after the chunk has been prepared. If there's no preparation to do, only the callback is called.
It is legal to call with no callback. */
- void PrepareChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallAfter = nullptr);
+ void PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallAfter = {});
/** Marks the chunk as failed-to-load: */
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ);
@@ -409,7 +427,7 @@ public:
void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */
- void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = nullptr);
+ void QueueLightChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_Callback = {});
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ);
@@ -609,6 +627,7 @@ public:
/** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback);
+ bool DoWithChunk(int a_ChunkX, int a_ChunkZ, std::function<bool(cChunk &)> a_Callback);
/** Calls the callback for the chunk at the block position specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback **/
bool DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback);
@@ -694,6 +713,18 @@ public:
AString GetLinkedOverworldName(void) const { return m_LinkedOverworldName; }
void SetLinkedOverworldName(const AString & a_Name) { m_LinkedOverworldName = a_Name; }
+ /** Returns or sets the minumim or maximum netherportal width */
+ virtual int GetMinNetherPortalWidth(void) const override { return m_MinNetherPortalWidth; }
+ virtual int GetMaxNetherPortalWidth(void) const override { return m_MaxNetherPortalWidth; }
+ virtual void SetMinNetherPortalWidth(int a_NewMinWidth) override { m_MinNetherPortalWidth = a_NewMinWidth; }
+ virtual void SetMaxNetherPortalWidth(int a_NewMaxWidth) override { m_MaxNetherPortalWidth = a_NewMaxWidth; }
+
+ /** Returns or sets the minumim or maximum netherportal height */
+ virtual int GetMinNetherPortalHeight(void) const override { return m_MinNetherPortalHeight; }
+ virtual int GetMaxNetherPortalHeight(void) const override { return m_MaxNetherPortalHeight; }
+ virtual void SetMinNetherPortalHeight(int a_NewMinHeight) override { m_MinNetherPortalHeight = a_NewMinHeight; }
+ virtual void SetMaxNetherPortalHeight(int a_NewMaxHeight) override { m_MaxNetherPortalHeight = a_NewMaxHeight; }
+
// tolua_end
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
@@ -705,6 +736,9 @@ public:
/** Queues a task onto the tick thread. The task object will be deleted once the task is finished */
void QueueTask(cTaskPtr a_Task); // Exported in ManualBindings.cpp
+ /** Queues a lambda task onto the tick thread, with the specified delay. */
+ void ScheduleTask(int a_DelayTicks, std::function<void(cWorld&)> a_Func);
+
/** Queues a task onto the tick thread, with the specified delay. */
void ScheduleTask(int a_DelayTicks, cTaskPtr a_Task);
@@ -788,7 +822,7 @@ public:
bool IsWeatherWet(void) const { return !IsWeatherSunny(); }
/** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
- virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ)
+ virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) override
{
return (IsWeatherWet() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
}
@@ -817,7 +851,7 @@ public:
UInt32 CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = nullptr); // tolua_export
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
- int GetTickRandomNumber(int a_Range) { return (int)(m_TickRand.randInt(a_Range)); }
+ int GetTickRandomNumber(int a_Range) { return static_cast<int>(m_TickRand.randInt(a_Range)); }
/** Appends all usernames starting with a_Text (case-insensitive) into Results */
void TabCompleteUserName(const AString & a_Text, AStringVector & a_Results);
@@ -920,6 +954,12 @@ private:
double m_SpawnY;
double m_SpawnZ;
+ // Variables defining the minimum and maximum size for a nether portal
+ int m_MinNetherPortalWidth;
+ int m_MaxNetherPortalWidth;
+ int m_MinNetherPortalHeight;
+ int m_MaxNetherPortalHeight;
+
bool m_BroadcastDeathMessages;
bool m_BroadcastAchievementMessages;