summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-09-01 13:04:50 +0200
committerMattes D <github@xoft.cz>2017-09-01 13:04:50 +0200
commit496c337cdfa593654018c171f6a74c28272265b5 (patch)
treefab48316d8fd6de97500ca1b8c8c5792eb578acc /src/World.cpp
parentUpdate Core plugin (diff)
downloadcuberite-496c337cdfa593654018c171f6a74c28272265b5.tar
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.gz
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.bz2
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.lz
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.xz
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.zst
cuberite-496c337cdfa593654018c171f6a74c28272265b5.zip
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp196
1 files changed, 63 insertions, 133 deletions
diff --git a/src/World.cpp b/src/World.cpp
index acec3049e..9baf9500a 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1,4 +1,4 @@
-
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "World.h"
@@ -1117,59 +1117,52 @@ void cWorld::TickMobs(std::chrono::milliseconds a_Dt)
{
m_ChunkMap->SpawnMobs(Spawner);
// do the spawn
- for (cMobSpawner::tSpawnedContainer::const_iterator itr2 = Spawner.getSpawned().begin(); itr2 != Spawner.getSpawned().end(); ++itr2)
+ for (auto & Mob : Spawner.getSpawned())
{
- SpawnMobFinalize(std::move(const_cast<std::unique_ptr<cMonster> &>(*itr2)));
+ SpawnMobFinalize(std::move(Mob));
}
}
} // for i - AllFamilies[]
} // if (Spawning enabled)
- class cCallback : public cEntityCallback
- {
- virtual bool Item(cEntity * a_Entity) override
+ ForEachEntity([=](cEntity & a_Entity)
{
- if (!a_Entity->IsMob())
+ if (!a_Entity.IsMob())
{
return false;
}
- if (!a_Entity->IsTicking())
+ if (!a_Entity.IsTicking())
{
return false;
}
- auto Monster = static_cast<cMonster *>(a_Entity);
- ASSERT(Monster->GetParentChunk() != nullptr); // A ticking entity must have a valid parent chunk
+ auto & Monster = static_cast<cMonster &>(a_Entity);
+ ASSERT(Monster.GetParentChunk() != nullptr); // A ticking entity must have a valid parent chunk
// Tick close mobs
- if (Monster->GetParentChunk()->HasAnyClients())
+ if (Monster.GetParentChunk()->HasAnyClients())
{
- Monster->Tick(m_Dt, *(a_Entity->GetParentChunk()));
+ Monster.Tick(a_Dt, *(a_Entity.GetParentChunk()));
}
// Destroy far hostile mobs except if last target was a player
- else if ((Monster->GetMobFamily() == cMonster::eFamily::mfHostile) && !Monster->WasLastTargetAPlayer())
+ else if ((Monster.GetMobFamily() == cMonster::eFamily::mfHostile) && !Monster.WasLastTargetAPlayer())
{
- if (Monster->GetMobType() != eMonsterType::mtWolf)
+ if (Monster.GetMobType() != eMonsterType::mtWolf)
{
- Monster->Destroy(true);
+ Monster.Destroy(true);
}
else
{
- auto Wolf = static_cast<cWolf *>(Monster);
- if (Wolf->IsAngry())
+ auto & Wolf = static_cast<cWolf &>(Monster);
+ if (Wolf.IsAngry())
{
- Monster->Destroy(true);
+ Monster.Destroy(true);
}
}
}
return false;
}
- public:
- std::chrono::milliseconds m_Dt;
- } Callback;
-
- Callback.m_Dt = a_Dt;
- ForEachEntity(Callback);
+ );
}
@@ -1321,7 +1314,7 @@ void cWorld::WakeUpSimulatorsInArea(const cCuboid & a_Area)
-bool cWorld::ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback)
+bool cWorld::ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, const cBlockEntityCallback & a_Callback)
{
return m_ChunkMap->ForEachBlockEntityInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1330,7 +1323,7 @@ bool cWorld::ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityC
-bool cWorld::ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, cBrewingstandCallback & a_Callback)
+bool cWorld::ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, const cBrewingstandCallback & a_Callback)
{
return m_ChunkMap->ForEachBrewingstandInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1339,7 +1332,7 @@ bool cWorld::ForEachBrewingstandInChunk(int a_ChunkX, int a_ChunkZ, cBrewingstan
-bool cWorld::ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback & a_Callback)
+bool cWorld::ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, const cChestCallback & a_Callback)
{
return m_ChunkMap->ForEachChestInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1348,7 +1341,7 @@ bool cWorld::ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback & a_
-bool cWorld::ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback & a_Callback)
+bool cWorld::ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, const cDispenserCallback & a_Callback)
{
return m_ChunkMap->ForEachDispenserInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1357,7 +1350,7 @@ bool cWorld::ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallb
-bool cWorld::ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback & a_Callback)
+bool cWorld::ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, const cDropperCallback & a_Callback)
{
return m_ChunkMap->ForEachDropperInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1366,7 +1359,7 @@ bool cWorld::ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback
-bool cWorld::ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback & a_Callback)
+bool cWorld::ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, const cDropSpenserCallback & a_Callback)
{
return m_ChunkMap->ForEachDropSpenserInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1375,7 +1368,7 @@ bool cWorld::ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserC
-bool cWorld::ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback & a_Callback)
+bool cWorld::ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, const cFurnaceCallback & a_Callback)
{
return m_ChunkMap->ForEachFurnaceInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1430,7 +1423,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
-bool cWorld::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback)
+bool cWorld::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cBlockEntityCallback & a_Callback)
{
return m_ChunkMap->DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1439,7 +1432,7 @@ bool cWorld::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBloc
-bool cWorld::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback)
+bool cWorld::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cBeaconCallback & a_Callback)
{
return m_ChunkMap->DoWithBeaconAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1448,7 +1441,7 @@ bool cWorld::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCal
-bool cWorld::DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback & a_Callback)
+bool cWorld::DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cBedCallback & a_Callback)
{
return m_ChunkMap->DoWithBedAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1457,7 +1450,7 @@ bool cWorld::DoWithBedAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBedCallback
-bool cWorld::DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBrewingstandCallback & a_Callback)
+bool cWorld::DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cBrewingstandCallback & a_Callback)
{
return m_ChunkMap->DoWithBrewingstandAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1466,7 +1459,7 @@ bool cWorld::DoWithBrewingstandAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBre
-bool cWorld::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback)
+bool cWorld::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cChestCallback & a_Callback)
{
return m_ChunkMap->DoWithChestAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1475,7 +1468,7 @@ bool cWorld::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
-bool cWorld::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback)
+bool cWorld::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cDispenserCallback & a_Callback)
{
return m_ChunkMap->DoWithDispenserAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1484,7 +1477,7 @@ bool cWorld::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispen
-bool cWorld::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback & a_Callback)
+bool cWorld::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cDropperCallback & a_Callback)
{
return m_ChunkMap->DoWithDropperAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1493,7 +1486,7 @@ bool cWorld::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperC
-bool cWorld::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback & a_Callback)
+bool cWorld::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cDropSpenserCallback & a_Callback)
{
return m_ChunkMap->DoWithDropSpenserAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1502,7 +1495,7 @@ bool cWorld::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDrop
-bool cWorld::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback)
+bool cWorld::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cFurnaceCallback & a_Callback)
{
return m_ChunkMap->DoWithFurnaceAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1511,7 +1504,7 @@ bool cWorld::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceC
-bool cWorld::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback & a_Callback)
+bool cWorld::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cNoteBlockCallback & a_Callback)
{
return m_ChunkMap->DoWithNoteBlockAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1520,7 +1513,7 @@ bool cWorld::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBl
-bool cWorld::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback)
+bool cWorld::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cCommandBlockCallback & a_Callback)
{
return m_ChunkMap->DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1529,7 +1522,7 @@ bool cWorld::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCom
-bool cWorld::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback & a_Callback)
+bool cWorld::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cMobHeadCallback & a_Callback)
{
return m_ChunkMap->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1538,7 +1531,7 @@ bool cWorld::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadC
-bool cWorld::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback & a_Callback)
+bool cWorld::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cFlowerPotCallback & a_Callback)
{
return m_ChunkMap->DoWithFlowerPotAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
}
@@ -1556,7 +1549,7 @@ bool cWorld::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_
-bool cWorld::DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback)
+bool cWorld::DoWithChunk(int a_ChunkX, int a_ChunkZ, const cChunkCallback & a_Callback)
{
return m_ChunkMap->DoWithChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -1565,31 +1558,7 @@ bool cWorld::DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback
-bool cWorld::DoWithChunk(int a_ChunkX, int a_ChunkZ, std::function<bool(cChunk &)> a_Callback)
-{
- struct cCallBackWrapper : cChunkCallback
- {
- cCallBackWrapper(std::function<bool(cChunk &)> a_InnerCallback) :
- m_Callback(a_InnerCallback)
- {
- }
-
- virtual bool Item(cChunk * a_Chunk)
- {
- return m_Callback(*a_Chunk);
- }
-
- private:
- std::function<bool(cChunk &)> m_Callback;
- } callback(a_Callback);
- return m_ChunkMap->DoWithChunk(a_ChunkX, a_ChunkZ, callback);
-}
-
-
-
-
-
-bool cWorld::DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback)
+bool cWorld::DoWithChunkAt(Vector3i a_BlockPos, const cChunkCallback & a_Callback)
{
return m_ChunkMap->DoWithChunkAt(a_BlockPos, a_Callback);
}
@@ -3163,18 +3132,13 @@ bool cWorld::IsPlayerReferencedInWorldOrChunk(cPlayer & a_Player)
-bool cWorld::ForEachPlayer(cPlayerListCallback & a_Callback)
+bool cWorld::ForEachPlayer(const cPlayerListCallback & a_Callback)
{
// Calls the callback for each player in the list
cCSLock Lock(m_CSPlayers);
- for (cPlayerList::iterator itr = m_Players.begin(), itr2 = itr; itr != m_Players.end(); itr = itr2)
+ for (auto & Player : m_Players)
{
- ++itr2;
- if (!(*itr)->IsTicking())
- {
- continue;
- }
- if (a_Callback.Item(*itr))
+ if (Player->IsTicking() && a_Callback(*Player))
{
return false;
}
@@ -3186,19 +3150,15 @@ bool cWorld::ForEachPlayer(cPlayerListCallback & a_Callback)
-bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback)
+bool cWorld::DoWithPlayer(const AString & a_PlayerName, const cPlayerListCallback & a_Callback)
{
// Calls the callback for the specified player in the list
cCSLock Lock(m_CSPlayers);
- for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ for (auto & Player : m_Players)
{
- if (!(*itr)->IsTicking())
- {
- continue;
- }
- if (NoCaseCompare((*itr)->GetName(), a_PlayerName) == 0)
+ if (Player->IsTicking() && (NoCaseCompare(Player->GetName(), a_PlayerName) == 0))
{
- a_Callback.Item(*itr);
+ a_Callback(*Player);
return true;
}
} // for itr - m_Players[]
@@ -3209,7 +3169,7 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_
-bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback)
+bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, const cPlayerListCallback & a_Callback)
{
cPlayer * BestMatch = nullptr;
size_t BestRating = 0;
@@ -3236,7 +3196,7 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa
if (BestMatch != nullptr)
{
- return a_Callback.Item (BestMatch);
+ return a_Callback(*BestMatch);
}
return false;
}
@@ -3245,27 +3205,14 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa
-bool cWorld::DoWithPlayerByUUID(const cUUID & a_PlayerUUID, cPlayerListCallback & a_Callback)
-{
- return DoWithPlayerByUUID(a_PlayerUUID, std::bind(&cPlayerListCallback::Item, &a_Callback, std::placeholders::_1));
-}
-
-
-
-
-
-bool cWorld::DoWithPlayerByUUID(const cUUID & a_PlayerUUID, cLambdaPlayerCallback a_Callback)
+bool cWorld::DoWithPlayerByUUID(const cUUID & a_PlayerUUID, const cPlayerListCallback & a_Callback)
{
cCSLock Lock(m_CSPlayers);
- for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ for (auto & Player : m_Players)
{
- if (!(*itr)->IsTicking())
+ if (Player->IsTicking() && (Player->GetUUID() == a_PlayerUUID))
{
- continue;
- }
- if ((*itr)->GetUUID() == a_PlayerUUID)
- {
- return a_Callback(*itr);
+ return a_Callback(*Player);
}
}
return false;
@@ -3333,7 +3280,7 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
-bool cWorld::ForEachEntity(cEntityCallback & a_Callback)
+bool cWorld::ForEachEntity(const cEntityCallback & a_Callback)
{
return m_ChunkMap->ForEachEntity(a_Callback);
}
@@ -3342,7 +3289,7 @@ bool cWorld::ForEachEntity(cEntityCallback & a_Callback)
-bool cWorld::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback & a_Callback)
+bool cWorld::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, const cEntityCallback & a_Callback)
{
return m_ChunkMap->ForEachEntityInChunk(a_ChunkX, a_ChunkZ, a_Callback);
}
@@ -3351,7 +3298,7 @@ bool cWorld::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback &
-bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback)
+bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, const cEntityCallback & a_Callback)
{
return m_ChunkMap->ForEachEntityInBox(a_Box, a_Callback);
}
@@ -3360,16 +3307,7 @@ bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_
-bool cWorld::DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback & a_Callback)
-{
- return DoWithEntityByID(a_UniqueID, std::bind(&cEntityCallback::Item, &a_Callback, std::placeholders::_1));
-}
-
-
-
-
-
-bool cWorld::DoWithEntityByID(UInt32 a_UniqueID, cLambdaEntityCallback a_Callback)
+bool cWorld::DoWithEntityByID(UInt32 a_UniqueID, const cEntityCallback & a_Callback)
{
// First check the entities-to-add:
{
@@ -3378,7 +3316,7 @@ bool cWorld::DoWithEntityByID(UInt32 a_UniqueID, cLambdaEntityCallback a_Callbac
{
if (ent->GetUniqueID() == a_UniqueID)
{
- a_Callback(ent.get());
+ a_Callback(*ent);
return true;
}
} // for ent - m_EntitiesToAdd[]
@@ -3510,20 +3448,12 @@ bool cWorld::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AStrin
bool cWorld::SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command)
{
- class cUpdateCommandBlock : public cCommandBlockCallback
- {
- AString m_Command;
- public:
- cUpdateCommandBlock(const AString & a_CallbackCommand) : m_Command(a_CallbackCommand) {}
-
- virtual bool Item(cCommandBlockEntity * a_CommandBlock) override
+ return DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, [&](cCommandBlockEntity & a_CommandBlock)
{
- a_CommandBlock->SetCommand(m_Command);
+ a_CommandBlock.SetCommand(a_Command);
return false;
}
- } CmdBlockCB (a_Command);
-
- return DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, CmdBlockCB);
+ );
}
@@ -3618,7 +3548,7 @@ bool cWorld::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunk
-bool cWorld::ForEachLoadedChunk(std::function<bool(int, int)> a_Callback)
+bool cWorld::ForEachLoadedChunk(const std::function<bool(int, int)> & a_Callback)
{
return m_ChunkMap->ForEachLoadedChunk(a_Callback);
}
@@ -3649,7 +3579,7 @@ void cWorld::QueueSaveAllChunks(void)
void cWorld::QueueTask(std::function<void(cWorld &)> a_Task)
{
cCSLock Lock(m_CSTasks);
- m_Tasks.emplace_back(0, a_Task);
+ m_Tasks.emplace_back(0, std::move(a_Task));
}
@@ -3663,7 +3593,7 @@ void cWorld::ScheduleTask(int a_DelayTicks, std::function<void (cWorld &)> a_Tas
// Insert the task into the list of scheduled tasks
{
cCSLock Lock(m_CSTasks);
- m_Tasks.emplace_back(TargetTick, a_Task);
+ m_Tasks.emplace_back(TargetTick, std::move(a_Task));
}
}