summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockBed.cpp13
-rw-r--r--src/Blocks/WorldInterface.h5
-rw-r--r--src/ClientHandle.cpp3
-rw-r--r--src/World.cpp25
-rw-r--r--src/World.h18
5 files changed, 11 insertions, 53 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index 23cb5a042..e56f4bfe0 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -1,13 +1,9 @@
#include "Globals.h"
#include "BlockBed.h"
-
-
-
#include "BroadcastInterface.h"
#include "Entities/../World.h"
#include "Entities/Player.h"
-#include "WorldInterface.h"
@@ -127,7 +123,14 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
a_Player->SetIsInBed(true);
a_Player->SendMessageSuccess("Home position set successfully");
- a_WorldInterface.ScheduleTask(20, cWorld::cTaskTryAwakeSleepingPlayers(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_ChunkInterface));
+ cTimeFastForwardTester Tester;
+ if (a_WorldInterface.ForEachPlayer(Tester))
+ {
+ cPlayerBedStateUnsetter Unsetter(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_ChunkInterface);
+ a_WorldInterface.ForEachPlayer(Unsetter);
+ a_WorldInterface.SetTimeOfDay(0);
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x0b); // Clear the "occupied" bit of the bed's block
+ }
}
}
else
diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h
index dcb7eee00..106c314e7 100644
--- a/src/Blocks/WorldInterface.h
+++ b/src/Blocks/WorldInterface.h
@@ -11,7 +11,6 @@ typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
class cMonster;
class cPlayer;
-class cTask;
class cWorldInterface
@@ -60,8 +59,4 @@ public:
/** Wakes up the simulators for the specified block */
virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
- /** Queues a task onto the tick thread, with the specified delay.
- The task object will be deleted once the task is finished */
- virtual void ScheduleTask(int a_DelayTicks, cTask * a_Task) = 0;
-
};
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 61ec73633..9a3c59b86 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1740,7 +1740,8 @@ void cClientHandle::HandleEntityLeaveBed(int a_EntityID)
return;
}
- cBlockBedHandler::SetBedOccupationState(cChunkInterface(GetPlayer()->GetWorld()->GetChunkMap()), GetPlayer()->GetLastBedPos(), false);
+ cChunkInterface Interface(GetPlayer()->GetWorld()->GetChunkMap());
+ cBlockBedHandler::SetBedOccupationState(Interface, GetPlayer()->GetLastBedPos(), false);
GetPlayer()->SetIsInBed(false);
}
diff --git a/src/World.cpp b/src/World.cpp
index 0f3740877..e0e32c86b 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -47,7 +47,6 @@
#include "Generating/Trees.h"
#include "Bindings/PluginManager.h"
#include "Blocks/BlockHandler.h"
-#include "Blocks/BlockBed.cpp"
#include "Tracer.h"
@@ -3622,30 +3621,6 @@ void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World)
////////////////////////////////////////////////////////////////////////////////
-// cWorld::cTaskSendBlockToAllPlayers
-
-cWorld::cTaskTryAwakeSleepingPlayers::cTaskTryAwakeSleepingPlayers(const Vector3i & a_Position, cChunkInterface & a_ChunkInterface) :
- m_Position(a_Position),
- m_ChunkInterface(a_ChunkInterface)
-{
-}
-
-void cWorld::cTaskTryAwakeSleepingPlayers::Run(cWorld & a_World)
-{
- cTimeFastForwardTester Tester;
- if (a_World.ForEachPlayer(Tester))
- {
- cPlayerBedStateUnsetter Unsetter(m_Position, m_ChunkInterface);
- a_World.ForEachPlayer(Unsetter);
- a_World.SetTimeOfDay(0);
- }
-}
-
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////
// cWorld::cChunkGeneratorCallbacks:
cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) :
diff --git a/src/World.h b/src/World.h
index 8b33cea58..3cac71a36 100644
--- a/src/World.h
+++ b/src/World.h
@@ -45,7 +45,6 @@ class cEntity;
class cBlockEntity;
class cWorldGenerator; // The generator that actually generates the chunks for a single world
class cChunkGenerator; // The thread responsible for generating chunks
-class cChunkInterface;
class cBeaconEntity;
class cChestEntity;
class cDispenserEntity;
@@ -141,21 +140,6 @@ public:
std::vector<Vector3i> m_SendQueue;
};
- class cTaskTryAwakeSleepingPlayers :
- public cTask
- {
- public:
- cTaskTryAwakeSleepingPlayers(const Vector3i & a_Position, cChunkInterface & a_ChunkInterface);
-
- protected:
- // cTask overrides:
- virtual void Run(cWorld & a_World) override;
-
- private:
- Vector3i m_Position;
- cChunkInterface & m_ChunkInterface;
- };
-
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
{
@@ -711,7 +695,7 @@ public:
/** Queues a task onto the tick thread, with the specified delay.
The task object will be deleted once the task is finished */
- virtual void ScheduleTask(int a_DelayTicks, cTask * a_Task) override;
+ void ScheduleTask(int a_DelayTicks, cTask * a_Task);
/** Returns the number of chunks loaded */
int GetNumChunks() const; // tolua_export