aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMachiavelli <machiavelli.trinity@gmail.com>2011-02-19 21:58:50 +0100
committerMachiavelli <machiavelli.trinity@gmail.com>2011-02-19 21:58:50 +0100
commitc0b29fd0ad42017cf37f1c773f907b52f184a5d8 (patch)
tree27dfba719c6a05752bb564e1e40e3902b278401c /src
parent7e2ddb2fd3e509a273137395a5cb476498813384 (diff)
Core/Vehicles: Chart VEHICLE_SEAT_FLAG_UNCONTROLLED and implement usage. Concerns vehicleseat enter/exit capabilities. Fixes vehicles related to Malygos encounter.
Original research by rsa, thanks to Manuel for pointing out.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/DataStores/DBCStructure.h2
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp15
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h2
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp8
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.h11
5 files changed, 17 insertions, 21 deletions
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index 3ece8f93e39..e004c1492d6 100755
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -1867,7 +1867,7 @@ struct VehicleSeatEntry
bool CanEnterOrExit() const { return m_flags & VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT; }
bool CanSwitchFromSeat() const { return m_flags & VEHICLE_SEAT_FLAG_B_CANSWITCH; }
- 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); }
+ bool IsUsableByOverride() const { return m_flags & VEHICLE_SEAT_FLAG_UNCONTROLLED; }
bool IsEjectable() const { return m_flagsB & VEHICLE_SEAT_FLAG_B_EJECTABLE; }
};
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 2d359ba2fa7..36a63e4ff33 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -16417,7 +16417,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
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, aurApp != NULL);
+ ChangeSeat(seatId);
}
return;
}
@@ -16451,7 +16451,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
ASSERT(!m_vehicle);
m_vehicle = vehicle;
- if (!m_vehicle->AddPassenger(this, seatId, aurApp != NULL))
+ if (!m_vehicle->AddPassenger(this, seatId))
{
m_vehicle = NULL;
return;
@@ -16471,14 +16471,14 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * a
}
-void Unit::ChangeSeat(int8 seatId, bool next, bool byAura)
+void Unit::ChangeSeat(int8 seatId, bool next)
{
if (!m_vehicle)
return;
if (seatId < 0)
{
- seatId = m_vehicle->GetNextEmptySeat(GetTransSeat(), next, byAura);
+ seatId = m_vehicle->GetNextEmptySeat(GetTransSeat(), next);
if (seatId < 0)
return;
}
@@ -16486,7 +16486,7 @@ void Unit::ChangeSeat(int8 seatId, bool next, bool byAura)
return;
m_vehicle->RemovePassenger(this);
- if (!m_vehicle->AddPassenger(this, seatId, byAura))
+ if (!m_vehicle->AddPassenger(this, seatId))
ASSERT(false);
}
@@ -16565,11 +16565,6 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
break;
}
- if (Vehicle* pVehicle = GetVehicle())
- if (!HasUnitMovementFlag(MOVEMENTFLAG_ROOT))
- sLog->outError("Unit (GUID: " UI64FMTD ", entry: %u) does not have MOVEMENTFLAG_ROOT but is in vehicle (ID: %u)!",
- GetGUID(), GetEntry(), pVehicle->GetVehicleInfo()->m_ID);
-
*data << uint32(GetUnitMovementFlags()); // movement flags
*data << uint16(m_movementInfo.flags2); // 2.3.0
*data << uint32(getMSTime()); // time
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 050770668d8..3e496fec526 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -2029,7 +2029,7 @@ class Unit : public WorldObject
void EnterVehicle(Unit *base, int8 seatId = -1, AuraApplication const * aurApp = NULL) { EnterVehicle(base->GetVehicleKit(), seatId, aurApp); }
void EnterVehicle(Vehicle *vehicle, int8 seatId = -1, AuraApplication const * aurApp = NULL);
void ExitVehicle();
- void ChangeSeat(int8 seatId, bool next = true, bool byAura = false);
+ void ChangeSeat(int8 seatId, bool next = true);
void BuildMovementPacket(ByteBuffer *data) const;
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index 114cf6b1caa..b73db80185c 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -220,13 +220,13 @@ Unit *Vehicle::GetPassenger(int8 seatId) const
return ObjectAccessor::GetUnit(*GetBase(), seat->second.passenger);
}
-int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next, bool byAura) const
+int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
{
SeatMap::const_iterator seat = m_Seats.find(seatId);
if (seat == m_Seats.end())
return -1;
- while (seat->second.passenger || (!byAura && !seat->second.seatInfo->CanEnterOrExit()) || (byAura && !seat->second.seatInfo->IsUsableByAura()))
+ while (seat->second.passenger || (!seat->second.seatInfo->CanEnterOrExit() && !seat->second.seatInfo->IsUsableByOverride()))
{
if (next)
{
@@ -277,7 +277,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion)
}
}
-bool Vehicle::AddPassenger(Unit *unit, int8 seatId, bool byAura)
+bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
{
if (unit->GetVehicle() != this)
return false;
@@ -286,7 +286,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId, bool byAura)
if (seatId < 0) // no specific seat requirement
{
for (seat = m_Seats.begin(); seat != m_Seats.end(); ++seat)
- if (!seat->second.passenger && ((!byAura && seat->second.seatInfo->CanEnterOrExit()) || (byAura && seat->second.seatInfo->IsUsableByAura())))
+ if (!seat->second.passenger && (seat->second.seatInfo->CanEnterOrExit() || seat->second.seatInfo->IsUsableByOverride()))
break;
if (seat == m_Seats.end()) // no available seat
diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h
index 4001ae6a0dc..7dbbd32e1ff 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.h
+++ b/src/server/game/Entities/Vehicle/Vehicle.h
@@ -52,6 +52,7 @@ enum VehicleSeatFlags
VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden
VEHICLE_SEAT_FLAG_UNK11 = 0x00000400, // needed for CGCamera__SyncFreeLookFacing
VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat
+ VEHICLE_SEAT_FLAG_UNCONTROLLED = 0x00002000, // can override !& VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT
VEHICLE_SEAT_FLAG_CAN_ATTACK = 0x00004000, // Can attack, cast spells and use items from vehicle?
VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT = 0x02000000, // Lua_CanExitVehicle - can enter and exit at free will
VEHICLE_SEAT_FLAG_CAN_SWITCH = 0x04000000, // Lua_CanSwitchVehicleSeats
@@ -61,11 +62,11 @@ enum VehicleSeatFlags
enum VehicleSeatFlagsB
{
VEHICLE_SEAT_FLAG_B_NONE = 0x00000000,
- VEHICLE_SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
+ //VEHICLE_SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
VEHICLE_SEAT_FLAG_B_TARGETS_IN_RAIDUI = 0x00000008, // Lua_UnitTargetsVehicleInRaidUI
VEHICLE_SEAT_FLAG_B_EJECTABLE = 0x00000020, // ejectable
- VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
- VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100,
+ //VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
+ //VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100,
VEHICLE_SEAT_FLAG_B_CANSWITCH = 0x04000000, // can switch seats
VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000, // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000
};
@@ -123,9 +124,9 @@ class Vehicle
bool HasEmptySeat(int8 seatId) const;
Unit *GetPassenger(int8 seatId) const;
- int8 GetNextEmptySeat(int8 seatId, bool next, bool byAura = false) const;
+ int8 GetNextEmptySeat(int8 seatId, bool next) const;
- bool AddPassenger(Unit *passenger, int8 seatId = -1, bool byAura = false);
+ bool AddPassenger(Unit *passenger, int8 seatId = -1);
void EjectPassenger(Unit* passenger, Unit* controller);
void RemovePassenger(Unit *passenger);
void RelocatePassengers(float x, float y, float z, float ang);