Core/Vehicles: In CMSG_ATTACKSWING check if current vehicle seat flags permit attacking before updating standstate etc. Client also checks this.

Furthermore, removed incorrect vehicle_seat_flag_b definition and added an unknown vehicle_seat_flag that was found in the client.
This commit is contained in:
Machiavelli
2011-12-11 14:44:58 +01:00
parent 1e60e9ee8f
commit c7cdd786fe
2 changed files with 21 additions and 6 deletions
+2 -2
View File
@@ -417,7 +417,7 @@ enum SummonPropFlags
enum VehicleSeatFlags enum VehicleSeatFlags
{ {
VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden
VEHICLE_SEAT_FLAG_UNK11 = 0x00000400, // needed for CGCamera__SyncFreeLookFacing VEHICLE_SEAT_FLAG_UNK1 = 0x00000400, // needed for CGCamera__SyncFreeLookFacing
VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat
VEHICLE_SEAT_FLAG_CAN_CAST_MOUNT_SPELL = 0x00001000, // Can cast spells with SPELL_AURA_MOUNTED from seat (possibly 4.x only, 0 seats on 3.3.5a) VEHICLE_SEAT_FLAG_CAN_CAST_MOUNT_SPELL = 0x00001000, // Can cast spells with SPELL_AURA_MOUNTED from seat (possibly 4.x only, 0 seats on 3.3.5a)
VEHICLE_SEAT_FLAG_UNCONTROLLED = 0x00002000, // can override !& VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT VEHICLE_SEAT_FLAG_UNCONTROLLED = 0x00002000, // can override !& VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT
@@ -425,6 +425,7 @@ enum VehicleSeatFlags
VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT = 0x02000000, // Lua_CanExitVehicle - can enter and exit at free will 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 VEHICLE_SEAT_FLAG_CAN_SWITCH = 0x04000000, // Lua_CanSwitchVehicleSeats
VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI
VEHICLE_SEAT_FLAG_UNK2 = 0x40000000, // checked in conjunction with 0x800 in CastSpell2
}; };
enum VehicleSeatFlagsB enum VehicleSeatFlagsB
@@ -435,7 +436,6 @@ enum VehicleSeatFlagsB
VEHICLE_SEAT_FLAG_B_EJECTABLE = 0x00000020, // ejectable VEHICLE_SEAT_FLAG_B_EJECTABLE = 0x00000020, // ejectable
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040, VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100, 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 VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000, // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000
}; };
@@ -23,13 +23,15 @@
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "CreatureAI.h" #include "CreatureAI.h"
#include "ObjectDefines.h" #include "ObjectDefines.h"
#include "Vehicle.h"
#include "VehicleDefines.h"
void WorldSession::HandleAttackSwingOpcode(WorldPacket & recv_data) void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data)
{ {
uint64 guid; uint64 guid;
recv_data >> guid; recv_data >> guid;
sLog->outStaticDebug("WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid)); sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid));
Unit* pEnemy = ObjectAccessor::GetUnit(*_player, guid); Unit* pEnemy = ObjectAccessor::GetUnit(*_player, guid);
@@ -47,6 +49,20 @@ void WorldSession::HandleAttackSwingOpcode(WorldPacket & recv_data)
return; return;
} }
//! Client explicitly checks the following before sending CMSG_ATTACKSWING packet,
//! so we'll place the same check here. Note that it might be possible to reuse this snippet
//! in other places as well.
if (Vehicle* vehicle = _player->GetVehicle())
{
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(_player);
ASSERT(seat);
if (!(seat->m_flags & VEHICLE_SEAT_FLAG_CAN_ATTACK))
{
SendAttackStop(pEnemy);
return;
}
}
_player->Attack(pEnemy, true); _player->Attack(pEnemy, true);
} }
@@ -55,7 +71,7 @@ void WorldSession::HandleAttackStopOpcode(WorldPacket & /*recv_data*/)
GetPlayer()->AttackStop(); GetPlayer()->AttackStop();
} }
void WorldSession::HandleSetSheathedOpcode(WorldPacket & recv_data) void WorldSession::HandleSetSheathedOpcode(WorldPacket& recv_data)
{ {
uint32 sheathed; uint32 sheathed;
recv_data >> sheathed; recv_data >> sheathed;
@@ -79,4 +95,3 @@ void WorldSession::SendAttackStop(Unit const* enemy)
data << uint32(0); // unk, can be 1 also data << uint32(0); // unk, can be 1 also
SendPacket(&data); SendPacket(&data);
} }