aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-12-27 16:55:17 +0100
committerMachiavelli <none@none>2010-12-27 16:55:17 +0100
commitdd745ef3264aa7a63a4bfaf0bb755aa3b410e7fe (patch)
treedb2bef9ae217ca15b54d88fd5d94f9a5d1055599 /src
parentef347b53ef98922b5178afbc7f4cb9f47e56b86d (diff)
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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/DataStores/DBCStructure.h3
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp14
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h6
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp20
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.h14
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp7
6 files changed, 37 insertions, 27 deletions
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index bfc590259a1..22f2bf785ab 100755
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -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
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 3cfc497a0a2..44659254e7c 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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);
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 33001d30080..15b248a5fff 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -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;
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index b9912eec152..5e48fdc551d 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -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)
{
diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h
index fd8e426cc94..a2514aab360 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.h
+++ b/src/server/game/Entities/Vehicle/Vehicle.h
@@ -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);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 7b2f873c865..e8d1a2345b7 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -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
{