summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-19 09:58:35 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-19 09:58:35 +0100
commita776337e5ecc4ba9fe54a46069f3423fbad56ec4 (patch)
tree637e5302c5c5affc5f3c52d4c195cba5607aac30 /src/Mobs
parentMerge pull request #3020 from cuberite/ice_block (diff)
parentProper entity destruction in non-ticking chunks (diff)
downloadcuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.tar
cuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.tar.gz
cuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.tar.bz2
cuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.tar.lz
cuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.tar.xz
cuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.tar.zst
cuberite-a776337e5ecc4ba9fe54a46069f3423fbad56ec4.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Monster.cpp6
-rw-r--r--src/Mobs/PassiveMonster.cpp16
-rw-r--r--src/Mobs/PassiveMonster.h2
3 files changed, 17 insertions, 7 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 28cb10238..fad54a00d 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -256,7 +256,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
if ((GetTarget() != nullptr))
{
- ASSERT(!GetTarget()->IsDestroyed());
+ ASSERT(GetTarget()->IsTicking());
if (GetTarget()->IsPlayer())
{
@@ -912,7 +912,7 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
/** Sets the target. */
void cMonster::SetTarget (cPawn * a_NewTarget)
{
- ASSERT((a_NewTarget == nullptr) || (!IsDestroyed()));
+ ASSERT((a_NewTarget == nullptr) || (IsTicking()));
if (m_Target == a_NewTarget)
{
return;
@@ -928,7 +928,7 @@ void cMonster::SetTarget (cPawn * a_NewTarget)
if (a_NewTarget != nullptr)
{
- ASSERT(!a_NewTarget->IsDestroyed());
+ ASSERT(a_NewTarget->IsTicking());
// Notify the new target that we are now targeting it.
m_Target->TargetingMe(this);
}
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index 53288a54c..000f3d5a4 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -65,6 +65,18 @@ void cPassiveMonster::ResetLoveMode()
+void cPassiveMonster::Destroyed()
+{
+ if (m_LovePartner != nullptr)
+ {
+ m_LovePartner->ResetLoveMode();
+ }
+}
+
+
+
+
+
void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -73,10 +85,6 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
CheckEventLostPlayer();
}
- if ((m_LovePartner != nullptr) && m_LovePartner->IsDestroyed())
- {
- m_LovePartner = nullptr;
- }
// if we have a partner, mate
if (m_LovePartner != nullptr)
diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h
index 1106ffb91..9a2627417 100644
--- a/src/Mobs/PassiveMonster.h
+++ b/src/Mobs/PassiveMonster.h
@@ -45,6 +45,8 @@ public:
/** Returns whether the monster is tired of breeding and is in the cooldown state. */
bool IsInLoveCooldown() const { return (m_LoveCooldown > 0); }
+ virtual void Destroyed(void) override;
+
protected:
/** The monster's breeding partner. */
cPassiveMonster * m_LovePartner;