Core/Vehicles: Some research on VehicleSeatFlagsB.

It is assumed that VehicleSeatFlagsB & 322 means the seat can be used indirectly (ie. by aura 236 (SPELL_AURA_CONTROL_VEHICLE)) even though !(VehicleSeatFlags & VEHICLE_SEAT_FLAG_USABLE).
More research to be done Soon (tm).

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-12-27 16:55:17 +01:00
parent ef347b53ef
commit dd745ef326
6 changed files with 37 additions and 27 deletions

View File

@@ -1847,7 +1847,8 @@ struct VehicleSeatEntry
uint32 m_flagsB; // 45
// 46-57 added in 3.1, floats mostly
bool IsUsable() const { return m_flags & VEHICLE_SEAT_FLAG_USABLE; }
bool IsUsableByPlayer() const { return m_flags & VEHICLE_SEAT_FLAG_USABLE; }
bool IsUsableByAura() const { return m_flagsB & (VEHICLE_SEAT_FLAG_B_USABLE_FORCED | VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 | VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3); }
};
struct WMOAreaTableEntry

View File

@@ -16676,7 +16676,7 @@ bool Unit::CheckPlayerCondition(Player* pPlayer)
}
}
void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, bool byAura)
{
if (!isAlive() || GetVehicleKit() == vehicle)
return;
@@ -16685,10 +16685,10 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
{
if (m_vehicle == vehicle)
{
if (seatId >= 0)
if (seatId >= 0 && seatId != GetTransSeat())
{
sLog->outDebug("EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_vehicle->GetBase()->GetEntry(), GetTransSeat(), seatId);
ChangeSeat(seatId);
ChangeSeat(seatId, byAura);
}
return;
}
@@ -16717,7 +16717,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
ASSERT(!m_vehicle);
m_vehicle = vehicle;
if (!m_vehicle->AddPassenger(this, seatId))
if (!m_vehicle->AddPassenger(this, seatId, byAura))
{
m_vehicle = NULL;
return;
@@ -16735,14 +16735,14 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
}
}
void Unit::ChangeSeat(int8 seatId, bool next)
void Unit::ChangeSeat(int8 seatId, bool next, bool byAura)
{
if (!m_vehicle)
return;
if (seatId < 0)
{
seatId = m_vehicle->GetNextEmptySeat(GetTransSeat(), next);
seatId = m_vehicle->GetNextEmptySeat(GetTransSeat(), next, byAura);
if (seatId < 0)
return;
}
@@ -16750,7 +16750,7 @@ void Unit::ChangeSeat(int8 seatId, bool next)
return;
m_vehicle->RemovePassenger(this);
if (!m_vehicle->AddPassenger(this, seatId))
if (!m_vehicle->AddPassenger(this, seatId, byAura))
ASSERT(false);
}

View File

@@ -1968,10 +1968,10 @@ class Unit : public WorldObject
bool m_ControlledByPlayer;
bool CheckPlayerCondition(Player* pPlayer);
void EnterVehicle(Unit *base, int8 seatId = -1) { EnterVehicle(base->GetVehicleKit(), seatId); }
void EnterVehicle(Vehicle *vehicle, int8 seatId = -1);
void EnterVehicle(Unit *base, int8 seatId = -1, bool byAura = false) { EnterVehicle(base->GetVehicleKit(), seatId, byAura); }
void EnterVehicle(Vehicle *vehicle, int8 seatId = -1, bool byAura = false);
void ExitVehicle();
void ChangeSeat(int8 seatId, bool next = true);
void ChangeSeat(int8 seatId, bool next = true, bool byAura = false);
void BuildMovementPacket(ByteBuffer *data) const;

View File

@@ -35,7 +35,7 @@ Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleI
if (VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(seatId))
{
m_Seats.insert(std::make_pair(i, VehicleSeat(veSeat)));
if (veSeat->IsUsable())
if (veSeat->IsUsableByPlayer())
++m_usableSeatNum;
}
}
@@ -213,12 +213,15 @@ Unit *Vehicle::GetPassenger(int8 seatId) const
return seat->second.passenger;
}
int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next, bool byAura) const
{
SeatMap::const_iterator seat = m_Seats.find(seatId);
if (seat == m_Seats.end()) return -1;
while (seat->second.passenger || !seat->second.seatInfo->IsUsable())
if (seat == m_Seats.end())
return -1;
while (seat->second.passenger || (!byAura && !seat->second.seatInfo->IsUsableByPlayer()) || (byAura && !seat->second.seatInfo->IsUsableByAura()))
{
sLog->outDebug("Vehicle::GetNextEmptySeat: m_flags: %u, m_flagsB:%u", seat->second.seatInfo->m_flags, seat->second.seatInfo->m_flagsB);
if (next)
{
++seat;
@@ -235,6 +238,7 @@ int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
if (seat->first == seatId)
return -1; // no available seat
}
return seat->first;
}
@@ -267,7 +271,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion)
}
}
bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
bool Vehicle::AddPassenger(Unit *unit, int8 seatId, bool byAura)
{
if (unit->GetVehicle() != this)
return false;
@@ -276,7 +280,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
if (seatId < 0) // no specific seat requirement
{
for (seat = m_Seats.begin(); seat != m_Seats.end(); ++seat)
if (!seat->second.passenger && seat->second.seatInfo->IsUsable())
if (!seat->second.passenger && ((!byAura && seat->second.seatInfo->IsUsableByPlayer() || (byAura && seat->second.seatInfo->IsUsableByAura()))))
break;
if (seat == m_Seats.end()) // no available seat
@@ -297,7 +301,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
sLog->outDebug("Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), me->GetEntry(), m_vehicleInfo->m_ID, me->GetGUIDLow(), (int32)seat->first);
seat->second.passenger = unit;
if (seat->second.seatInfo->IsUsable())
if (seat->second.seatInfo->IsUsableByPlayer())
{
ASSERT(m_usableSeatNum);
--m_usableSeatNum;
@@ -380,7 +384,7 @@ void Vehicle::RemovePassenger(Unit *unit)
sLog->outDebug("Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), me->GetEntry(), m_vehicleInfo->m_ID, me->GetGUIDLow(), (int32)seat->first);
seat->second.passenger = NULL;
if (seat->second.seatInfo->IsUsable())
if (seat->second.seatInfo->IsUsableByPlayer())
{
if (!m_usableSeatNum)
{

View File

@@ -53,6 +53,14 @@ enum VehicleSeatFlags
VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI
};
enum VehicleSeatFlagsB
{
VEHICLE_SEAT_FLAG_B_NONE = 0x00000000,
VEHICLE_SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100,
};
enum VehicleSpells
{
VEHICLE_SPELL_PARACHUTE = 45472
@@ -103,8 +111,8 @@ class Vehicle
bool HasEmptySeat(int8 seatId) const;
Unit *GetPassenger(int8 seatId) const;
int8 GetNextEmptySeat(int8 seatId, bool next) const;
bool AddPassenger(Unit *passenger, int8 seatId = -1);
int8 GetNextEmptySeat(int8 seatId, bool next, bool byAura = false) const;
bool AddPassenger(Unit *passenger, int8 seatId = -1, bool byAura = false);
void RemovePassenger(Unit *passenger);
void RelocatePassengers(float x, float y, float z, float ang);
void RemoveAllPassengers();
@@ -116,7 +124,7 @@ class Vehicle
protected:
Unit *me;
VehicleEntry const *m_vehicleInfo;
uint32 m_usableSeatNum;
uint32 m_usableSeatNum; // Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags
uint32 m_bonusHP;
void InstallAccessory(uint32 entry, int8 seatId, bool minion = true);

View File

@@ -4225,11 +4225,8 @@ void AuraEffect::HandleAuraControlVehicle(AuraApplication const * aurApp, uint8
return;
if (apply)
{
//if (caster->GetTypeId() == TYPEID_PLAYER)
// if (Pet *pet = caster->ToPlayer()->GetPet())
// pet->Remove(PET_SAVE_AS_CURRENT);
caster->EnterVehicle(target->GetVehicleKit(), m_amount - 1);
{
caster->EnterVehicle(target->GetVehicleKit(), m_amount - 1, true);
}
else
{