Core: More functions moved to const
This commit is contained in:
@@ -35,7 +35,7 @@ Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(prop
|
||||
|
||||
void Totem::Update(uint32 time)
|
||||
{
|
||||
if (!m_owner->isAlive() || !isAlive())
|
||||
if (!GetOwner()->isAlive() || !isAlive())
|
||||
{
|
||||
UnSummon(); // remove self
|
||||
return;
|
||||
@@ -55,7 +55,7 @@ void Totem::Update(uint32 time)
|
||||
void Totem::InitStats(uint32 duration)
|
||||
{
|
||||
// client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER
|
||||
if (GetOwner()->GetTypeId() == TYPEID_PLAYER
|
||||
&& m_Properties->Slot >= SUMMON_SLOT_TOTEM
|
||||
&& m_Properties->Slot < MAX_TOTEM_SLOT)
|
||||
{
|
||||
@@ -64,10 +64,10 @@ void Totem::InitStats(uint32 duration)
|
||||
data << uint64(GetGUID());
|
||||
data << uint32(duration);
|
||||
data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
m_owner->ToPlayer()->SendDirectMessage(&data);
|
||||
GetOwner()->ToPlayer()->SendDirectMessage(&data);
|
||||
|
||||
// set display id depending on caster's race
|
||||
SetDisplayId(m_owner->GetModelForTotem(PlayerTotemType(m_Properties->Id)));
|
||||
SetDisplayId(GetOwner()->GetModelForTotem(PlayerTotemType(m_Properties->Id)));
|
||||
}
|
||||
|
||||
Minion::InitStats(duration);
|
||||
@@ -82,7 +82,7 @@ void Totem::InitStats(uint32 duration)
|
||||
|
||||
m_duration = duration;
|
||||
|
||||
SetLevel(m_owner->getLevel());
|
||||
SetLevel(GetOwner()->getLevel());
|
||||
}
|
||||
|
||||
void Totem::InitSummon()
|
||||
@@ -111,21 +111,21 @@ void Totem::UnSummon(uint32 msTime)
|
||||
// clear owner's totem slot
|
||||
for (int i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i)
|
||||
{
|
||||
if (m_owner->m_SummonSlot[i] == GetGUID())
|
||||
if (GetOwner()->m_SummonSlot[i] == GetGUID())
|
||||
{
|
||||
m_owner->m_SummonSlot[i] = 0;
|
||||
GetOwner()->m_SummonSlot[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_owner->RemoveAurasDueToSpell(GetSpell(), GetGUID());
|
||||
GetOwner()->RemoveAurasDueToSpell(GetSpell(), GetGUID());
|
||||
|
||||
// Remove Sentry Totem Aura
|
||||
if (GetEntry() == SENTRY_TOTEM_ENTRY)
|
||||
m_owner->RemoveAurasDueToSpell(SENTRY_TOTEM_SPELLID);
|
||||
GetOwner()->RemoveAurasDueToSpell(SENTRY_TOTEM_SPELLID);
|
||||
|
||||
//remove aura all party members too
|
||||
if (Player* owner = m_owner->ToPlayer())
|
||||
if (Player* owner = GetOwner()->ToPlayer())
|
||||
{
|
||||
owner->SendAutoRepeatCancel(this);
|
||||
|
||||
|
||||
@@ -180,11 +180,6 @@ Transport::~Transport()
|
||||
(*itr)->SetTransport(NULL);
|
||||
GetMap()->AddObjectToRemoveList(*itr);
|
||||
}
|
||||
|
||||
m_NPCPassengerSet.clear();
|
||||
|
||||
m_WayPoints.clear();
|
||||
m_passengers.clear();
|
||||
}
|
||||
|
||||
bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)
|
||||
@@ -553,7 +548,7 @@ void Transport::Update(uint32 p_diff)
|
||||
else
|
||||
{
|
||||
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z, GetAngle(m_next->second.x, m_next->second.y) + float(M_PI));
|
||||
UpdateNPCPositions(); // COME BACK MARKER
|
||||
UpdatePassengerPositions(); // COME BACK MARKER
|
||||
}
|
||||
|
||||
sScriptMgr->OnRelocate(this, m_curr->first, m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
|
||||
@@ -686,10 +681,10 @@ void Transport::UpdatePosition(MovementInfo* mi)
|
||||
float transport_z = mi->pos.m_positionZ - mi->t_pos.m_positionZ;
|
||||
|
||||
Relocate(transport_x, transport_y, transport_z, transport_o);
|
||||
UpdateNPCPositions();
|
||||
UpdatePassengerPositions();
|
||||
}
|
||||
|
||||
void Transport::UpdateNPCPositions()
|
||||
void Transport::UpdatePassengerPositions()
|
||||
{
|
||||
for (CreatureSet::iterator itr = m_NPCPassengerSet.begin(); itr != m_NPCPassengerSet.end(); ++itr)
|
||||
{
|
||||
@@ -705,7 +700,7 @@ void Transport::UpdateNPCPositions()
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o)
|
||||
void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o) const
|
||||
{
|
||||
float inx = x, iny = y, inz = z, ino = o;
|
||||
o = GetOrientation() + ino;
|
||||
@@ -714,7 +709,7 @@ void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float&
|
||||
z = GetPositionZ() + inz;
|
||||
}
|
||||
|
||||
void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o)
|
||||
void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o) const
|
||||
{
|
||||
o -= GetOrientation();
|
||||
z -= GetPositionZ();
|
||||
|
||||
@@ -47,13 +47,13 @@ class Transport : public GameObject, public TransportBase
|
||||
CreatureSet m_NPCPassengerSet;
|
||||
uint32 AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim=0);
|
||||
void UpdatePosition(MovementInfo* mi);
|
||||
void UpdateNPCPositions();
|
||||
void UpdatePassengerPositions();
|
||||
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float& o);
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const;
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float& o);
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const;
|
||||
|
||||
void BuildStartMovePacket(Map const* targetMap);
|
||||
void BuildStopMovePacket(Map const* targetMap);
|
||||
|
||||
@@ -674,7 +674,7 @@ uint8 Vehicle::GetAvailableSeatCount() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float& o)
|
||||
void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float& o) const
|
||||
{
|
||||
float inx = x, iny = y, inz = z, ino = o;
|
||||
o = GetBase()->GetOrientation() + ino;
|
||||
@@ -683,7 +683,7 @@ void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float& o)
|
||||
z = GetBase()->GetPositionZ() + inz;
|
||||
}
|
||||
|
||||
void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float& o)
|
||||
void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float& o) const
|
||||
{
|
||||
o -= GetBase()->GetOrientation();
|
||||
z -= GetBase()->GetPositionZ();
|
||||
@@ -841,7 +841,7 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
|
||||
|
||||
if (Target->GetBase()->GetTypeId() == TYPEID_UNIT && Passenger->GetTypeId() == TYPEID_PLAYER &&
|
||||
Seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
ASSERT(Target->GetBase()->SetCharmedBy(Passenger, CHARM_TYPE_VEHICLE)) // SMSG_CLIENT_CONTROL
|
||||
ASSERT(Target->GetBase()->SetCharmedBy(Passenger, CHARM_TYPE_VEHICLE)); // SMSG_CLIENT_CONTROL
|
||||
|
||||
Passenger->SendClearTarget(); // SMSG_BREAK_TARGET
|
||||
Passenger->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
|
||||
@@ -854,10 +854,10 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
|
||||
init.SetTransportEnter();
|
||||
init.Launch();
|
||||
|
||||
if (Target->GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
if (Creature* creature = Target->GetBase()->ToCreature())
|
||||
{
|
||||
if (Target->GetBase()->ToCreature()->IsAIEnabled)
|
||||
Target->GetBase()->ToCreature()->AI()->PassengerBoarded(Passenger, Seat->first, true);
|
||||
if (creature->IsAIEnabled)
|
||||
creature->AI()->PassengerBoarded(Passenger, Seat->first, true);
|
||||
|
||||
sScriptMgr->OnAddPassenger(Target, Passenger, Seat->first);
|
||||
|
||||
|
||||
@@ -89,10 +89,10 @@ class Vehicle : public TransportBase
|
||||
void InitMovementInfoForBase();
|
||||
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float& o);
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const;
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float& o);
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const;
|
||||
|
||||
void RemovePendingEvent(VehicleJoinEvent* e);
|
||||
void RemovePendingEventsForSeat(int8 seatId);
|
||||
|
||||
@@ -77,14 +77,16 @@ typedef std::map<int8, VehicleSeat> SeatMap;
|
||||
|
||||
class TransportBase
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
TransportBase() { }
|
||||
virtual ~TransportBase() { }
|
||||
|
||||
public:
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
virtual void CalculatePassengerPosition(float& x, float& y, float& z, float& o) = 0;
|
||||
virtual void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const = 0;
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
virtual void CalculatePassengerOffset(float& x, float& y, float& z, float& o) = 0;
|
||||
virtual void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user