1
0
Fork 0

Use ref instead of pointer

This commit is contained in:
Lukas Pioch 2017-08-24 13:26:23 +02:00
parent 7b3372ad38
commit b55e5f5ad1
3 changed files with 8 additions and 8 deletions

View File

@ -83,7 +83,7 @@ void cLeashKnot::TiePlayersLeashedMobs(cPlayer & a_Player, bool a_ShouldBroadCas
// All conditions met, unleash from player and leash to fence // All conditions met, unleash from player and leash to fence
PotentialLeashed->Unleash(false, false); PotentialLeashed->Unleash(false, false);
PotentialLeashed->LeashTo(m_Knot, m_ShouldBroadcast); PotentialLeashed->LeashTo(*m_Knot, m_ShouldBroadcast);
return false; return false;
} }
} LookForLeashedsCallback(this, &a_Player, a_ShouldBroadCast); } LookForLeashedsCallback(this, &a_Player, a_ShouldBroadCast);

View File

@ -431,7 +431,7 @@ void cMonster::CalcLeashActions()
auto LeashKnot = cLeashKnot::FindKnotAtPos(*m_World, { FloorC(m_LeashToPos->x), FloorC(m_LeashToPos->y), FloorC(m_LeashToPos->z) }); auto LeashKnot = cLeashKnot::FindKnotAtPos(*m_World, { FloorC(m_LeashToPos->x), FloorC(m_LeashToPos->y), FloorC(m_LeashToPos->z) });
if (LeashKnot != nullptr) if (LeashKnot != nullptr)
{ {
LeashTo(LeashKnot); LeashTo(*LeashKnot);
SetLeashToPos(nullptr); SetLeashToPos(nullptr);
} }
} }
@ -688,7 +688,7 @@ void cMonster::OnRightClicked(cPlayer & a_Player)
{ {
a_Player.GetInventory().RemoveOneEquippedItem(); a_Player.GetInventory().RemoveOneEquippedItem();
} }
LeashTo(&a_Player); LeashTo(a_Player);
} }
} }
@ -1407,7 +1407,7 @@ cMonster::eFamily cMonster::GetMobFamily(void) const
void cMonster::LeashTo(cEntity * a_Entity, bool a_ShouldBroadcast) void cMonster::LeashTo(cEntity & a_Entity, bool a_ShouldBroadcast)
{ {
// Do nothing if already leashed // Do nothing if already leashed
if (m_LeashedTo != nullptr) if (m_LeashedTo != nullptr)
@ -1415,13 +1415,13 @@ void cMonster::LeashTo(cEntity * a_Entity, bool a_ShouldBroadcast)
return; return;
} }
m_LeashedTo = a_Entity; m_LeashedTo = &a_Entity;
a_Entity->AddLeashedMob(this); a_Entity.AddLeashedMob(this);
if (a_ShouldBroadcast) if (a_ShouldBroadcast)
{ {
m_World->BroadcastLeashEntity(*this, *a_Entity); m_World->BroadcastLeashEntity(*this, a_Entity);
} }
m_IsLeashActionJustDone = true; m_IsLeashActionJustDone = true;

View File

@ -84,7 +84,7 @@ public:
bool IsLeashed() const { return (m_LeashedTo != nullptr); } bool IsLeashed() const { return (m_LeashedTo != nullptr); }
/** Leash the monster to an entity. */ /** Leash the monster to an entity. */
void LeashTo(cEntity * a_Entity, bool a_ShouldBroadcast = true); void LeashTo(cEntity & a_Entity, bool a_ShouldBroadcast = true);
/** Unleash the monster. Overload for the Unleash(bool, bool) function for plugins */ /** Unleash the monster. Overload for the Unleash(bool, bool) function for plugins */
void Unleash(bool a_ShouldDropLeashPickup); void Unleash(bool a_ShouldDropLeashPickup);