summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-12-13 13:11:01 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-12-13 13:11:01 +0100
commit4b20a615192baeb5ef0a04a10161a03428cda8cd (patch)
treec6f25102267b0cc4a444f6e746679405948142b0 /src/Protocol
parentFixed compilation? (diff)
parentMerge pull request #1660 from Seadragon91/master (diff)
downloadcuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.tar
cuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.tar.gz
cuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.tar.bz2
cuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.tar.lz
cuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.tar.xz
cuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.tar.zst
cuberite-4b20a615192baeb5ef0a04a10161a03428cda8cd.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/MojangAPI.cpp22
-rw-r--r--src/Protocol/Protocol17x.cpp14
-rw-r--r--src/Protocol/Protocol18x.cpp13
3 files changed, 43 insertions, 6 deletions
diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp
index 67f513e44..570754204 100644
--- a/src/Protocol/MojangAPI.cpp
+++ b/src/Protocol/MojangAPI.cpp
@@ -161,26 +161,38 @@ class cMojangAPI::cUpdateThread :
{
typedef cIsThread super;
public:
- cUpdateThread() :
- super("cMojangAPI::cUpdateThread")
+ cUpdateThread(cMojangAPI & a_MojangAPI) :
+ super("cMojangAPI::cUpdateThread"),
+ m_MojangAPI(a_MojangAPI)
{
}
~cUpdateThread()
{
+ // Notify the thread that it should stop:
+ m_ShouldTerminate = true;
m_evtNotify.Set();
+
+ // Wait for the thread to actually finish work:
Stop();
}
protected:
+
+ /** The cMojangAPI instance to update. */
+ cMojangAPI & m_MojangAPI;
+
+ /** The event used for notifying that the thread should terminate, as well as timing. */
cEvent m_evtNotify;
+
+ // cIsThread override:
virtual void Execute(void) override
{
do
{
- cRoot::Get()->GetMojangAPI().Update();
- } while (!m_evtNotify.Wait(60 * 60 * 1000)); // Repeat every 60 minutes
+ m_MojangAPI.Update();
+ } while (!m_ShouldTerminate && !m_evtNotify.Wait(60 * 60 * 1000)); // Repeat every 60 minutes until termination request
}
} ;
@@ -197,7 +209,7 @@ cMojangAPI::cMojangAPI(void) :
m_UUIDToProfileServer(DEFAULT_UUID_TO_PROFILE_SERVER),
m_UUIDToProfileAddress(DEFAULT_UUID_TO_PROFILE_ADDRESS),
m_RankMgr(nullptr),
- m_UpdateThread(new cUpdateThread())
+ m_UpdateThread(new cUpdateThread(*this))
{
}
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 1d108ce9c..1e5fe5586 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -42,6 +42,7 @@ Implements the 1.7.x protocol classes:
#include "../BlockEntities/BeaconEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/MobHeadEntity.h"
+#include "../BlockEntities/MobSpawnerEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
#include "Bindings/PluginManager.h"
@@ -2662,6 +2663,18 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
+ case E_BLOCK_MOB_SPAWNER:
+ {
+ cMobSpawnerEntity & MobSpawnerEntity = (cMobSpawnerEntity &)a_BlockEntity;
+
+ Writer.AddInt("x", MobSpawnerEntity.GetPosX());
+ Writer.AddInt("y", MobSpawnerEntity.GetPosY());
+ Writer.AddInt("z", MobSpawnerEntity.GetPosZ());
+ Writer.AddString("EntityId", cMonster::MobTypeToVanillaName(MobSpawnerEntity.GetEntity()));
+ Writer.AddShort("Delay", MobSpawnerEntity.GetSpawnDelay());
+ Writer.AddString("id", "MobSpawner");
+ break;
+ }
default: break;
}
@@ -3134,4 +3147,3 @@ void cProtocol176::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
-
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 8170a494f..ce580d73e 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -41,6 +41,7 @@ Implements the 1.8.x protocol classes:
#include "../BlockEntities/BeaconEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/MobHeadEntity.h"
+#include "../BlockEntities/MobSpawnerEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
#include "Bindings/PluginManager.h"
@@ -2972,6 +2973,18 @@ void cProtocol180::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
+ case E_BLOCK_MOB_SPAWNER:
+ {
+ cMobSpawnerEntity & MobSpawnerEntity = (cMobSpawnerEntity &)a_BlockEntity;
+
+ Writer.AddInt("x", MobSpawnerEntity.GetPosX());
+ Writer.AddInt("y", MobSpawnerEntity.GetPosY());
+ Writer.AddInt("z", MobSpawnerEntity.GetPosZ());
+ Writer.AddString("EntityId", cMonster::MobTypeToVanillaName(MobSpawnerEntity.GetEntity()));
+ Writer.AddShort("Delay", MobSpawnerEntity.GetSpawnDelay());
+ Writer.AddString("id", "MobSpawner");
+ break;
+ }
default: break;
}