Core/Vehicles:

- Grab correct npc entry from npc_spellclick_spells in case of player vehicle. Fixes DB errors added in my previous changeset
- Allow aura's with SPELL_AURA_CONTROL_VEHICLE to stack if there are enough free seats, even if spellIds are identical.
- Fix a possible infinite loop. Thanks to manuel for spotting
This commit is contained in:
Machiavelli
2011-02-27 03:58:41 +01:00
parent aa2455b586
commit 683cea9e83
11 changed files with 75 additions and 26 deletions
+18 -4
View File
@@ -27,7 +27,8 @@
#include "CreatureAI.h"
#include "ZoneScript.h"
Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleInfo(vehInfo), m_usableSeatNum(0), m_bonusHP(0)
Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo, uint32 creatureEntry)
: me(unit), m_vehicleInfo(vehInfo), m_usableSeatNum(0), m_bonusHP(0), m_creatureEntry(creatureEntry)
{
for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i)
{
@@ -119,9 +120,11 @@ void Vehicle::Install()
sScriptMgr->OnInstall(this);
}
void Vehicle::InstallAllAccessories(uint32 entry)
void Vehicle::InstallAllAccessories()
{
VehicleAccessoryList const* mVehicleList = sObjectMgr->GetVehicleAccessoryList(entry);
me->RemoveAurasByType(SPELL_AURA_CONTROL_VEHICLE); // We might have aura's saved in the DB with now invalid casters - remove
VehicleAccessoryList const* mVehicleList = sObjectMgr->GetVehicleAccessoryList(m_creatureEntry);
if (!mVehicleList)
return;
@@ -167,7 +170,7 @@ void Vehicle::Reset()
}
else
{
InstallAllAccessories(me->GetEntry());
InstallAllAccessories();
if (m_usableSeatNum)
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
}
@@ -528,3 +531,14 @@ SeatMap::iterator Vehicle::GetSeatIteratorForPassenger(Unit* passenger)
return m_Seats.end();
}
uint8 Vehicle::GetAvailableSeatCount() const
{
uint8 ret = 0;
SeatMap::const_iterator itr;
for (itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
if (!itr->second.passenger && (itr->second.seatInfo->CanEnterOrExit() || itr->second.seatInfo->IsUsableByOverride()))
++ret;
return ret;
}