diff options
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.h | 1 | ||||
-rw-r--r-- | src/Entities/TNTEntity.cpp | 13 | ||||
-rw-r--r-- | src/Entities/TNTEntity.h | 10 |
3 files changed, 13 insertions, 11 deletions
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 8bc941354..627c1ce71 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -241,6 +241,7 @@ public: int GetChunkX(void) const { return FloorC(m_Position.x / cChunkDef::Width); } int GetChunkZ(void) const { return FloorC(m_Position.z / cChunkDef::Width); } + // Get the Entity's axis aligned bounding box, with absolute (world-relative) coordinates. cBoundingBox GetBoundingBox() const { return cBoundingBox(GetPosition(), GetWidth() / 2, GetHeight()); } void SetHeadYaw (double a_HeadYaw); diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp index aaf3261b4..6aea6e228 100644 --- a/src/Entities/TNTEntity.cpp +++ b/src/Entities/TNTEntity.cpp @@ -8,7 +8,7 @@ -cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) : +cTNTEntity::cTNTEntity(Vector3d a_Pos, unsigned a_FuseTicks) : Super(etTNT, a_Pos, 0.98, 0.98), m_FuseTicks(a_FuseTicks) { @@ -33,10 +33,14 @@ void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle) void cTNTEntity::Explode(void) { - m_FuseTicks = 0; - Destroy(); FLOGD("BOOM at {0}", GetPosition()); - m_World->DoExplosionAt(4.0, GetPosX(), GetPosY(), GetPosZ(), true, esPrimedTNT, this); + + // Destroy first so the Explodinator doesn't find us (when iterating through entities): + Destroy(); + + // TODO: provided centred coordinates to all calls to DoExplosionAt, from entities and blocks + // This is to ensure maximum efficiency of explosions + m_World->DoExplosionAt(4.0, GetPosX(), GetPosY() + GetHeight() / 2, GetPosZ(), true, esPrimedTNT, this); } @@ -51,6 +55,7 @@ void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) // The base class tick destroyed us return; } + BroadcastMovementUpdate(); m_FuseTicks -= 1; diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h index ef8b8ec3c..5b1c853bd 100644 --- a/src/Entities/TNTEntity.h +++ b/src/Entities/TNTEntity.h @@ -19,7 +19,7 @@ public: // tolua_export CLASS_PROTODEF(cTNTEntity) - cTNTEntity(Vector3d a_Pos, int a_FuseTicks = 80); + cTNTEntity(Vector3d a_Pos, unsigned a_FuseTicks = 80); // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; @@ -31,17 +31,13 @@ public: // tolua_export void Explode(void); /** Returns the fuse ticks until the tnt will explode */ - int GetFuseTicks(void) const { return m_FuseTicks; } + unsigned GetFuseTicks(void) const { return m_FuseTicks; } /** Set the fuse ticks until the tnt will explode */ - void SetFuseTicks(int a_FuseTicks) { m_FuseTicks = a_FuseTicks; } + void SetFuseTicks(unsigned a_FuseTicks) { m_FuseTicks = a_FuseTicks; } // tolua_end protected: int m_FuseTicks; ///< How much ticks is left, while the tnt will explode }; // tolua_export - - - - |