Skip to content

Commit

Permalink
[12233] Implement Vehicle Unboarding. Patch based on work of a long h…
Browse files Browse the repository at this point in the history
…istory

Signed-off-by: Schmoozerd <schmoozerd@cmangos>
  • Loading branch information
kid10 authored and Salja committed Sep 15, 2012
1 parent fb0a6f6 commit 882fc51
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
41 changes: 38 additions & 3 deletions src/game/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* This file contains the code needed for CMaNGOS to support vehicles
* Currently implemented
* - TODO Board
* - TODO Unboard
* - Unboard to unboard a passenger from the vehicle
* - TODO Switch
* - CanBoard to check if a passenger can board a vehicle
* - Internal helper to set the controlling and spells for a vehicle's seat
Expand Down Expand Up @@ -89,7 +89,7 @@ void VehicleInfo::Board(Unit* passenger, uint8 seat)
{
MANGOS_ASSERT(passenger);

DEBUG_LOG("VehicleInfo::Board: Try to board passenger %s to seat %u", passenger->GetObjectGuid().GetString().c_str(), seat);
DEBUG_LOG("VehicleInfo::Board: Try to board passenger %s to seat %u", passenger->GetGuidStr().c_str(), seat);
}

/**
Expand All @@ -114,7 +114,42 @@ void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle)
{
MANGOS_ASSERT(passenger);

DEBUG_LOG("VehicleInfo::Unboard: passenger: %s", passenger->GetObjectGuid().GetString().c_str());
DEBUG_LOG("VehicleInfo::Unboard: passenger: %s", passenger->GetGuidStr().c_str());

PassengerMap::const_iterator itr = m_passengers.find(passenger);
MANGOS_ASSERT(itr != m_passengers.end());

VehicleSeatEntry const* seatEntry = GetSeatEntry(itr->second->GetTransportSeat());
MANGOS_ASSERT(seatEntry);

UnBoardPassenger(passenger); // Use TransportBase to remove the passenger from storage list

if (!changeVehicle) // Send expected unboarding packages
{
// Update movementInfo
passenger->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT);
passenger->m_movementInfo.ClearTransportData();

if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;
pPlayer->ResummonPetTemporaryUnSummonedIfAny();

// SMSG_PET_DISMISS_SOUND (?)
}

if (passenger->IsRooted())
passenger->SetRoot(false);

Movement::MoveSplineInit init(*passenger);
// ToDo: Set proper unboard coordinates
init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ());
init.SetExitVehicle();
init.Launch();
}

// Remove passenger modifications
RemoveSeatMods(passenger, seatEntry->m_flags);
}

/**
Expand Down
19 changes: 19 additions & 0 deletions src/game/VehicleHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,31 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket& recvPacket)

recvPacket >> vehicleGuid.ReadAsPacked();
recvPacket >> movementInfo;

TransportInfo* transportInfo = _player->GetTransportInfo();
if (!transportInfo || !transportInfo->IsOnVehicle())
return;

Unit* vehicle = (Unit*)transportInfo->GetTransport();

// Something went wrong
if (vehicleGuid != vehicle->GetObjectGuid())
return;

// Remove Vehicle Control Aura
vehicle->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE, _player->GetObjectGuid());
}

void WorldSession::HandleRequestVehicleExit(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_VEHICLE_EXIT");
recvPacket.hexlike();

TransportInfo* transportInfo = _player->GetTransportInfo();
if (!transportInfo || !transportInfo->IsOnVehicle())
return;

((Unit*)transportInfo->GetTransport())->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE, _player->GetObjectGuid());
}

void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket& recvPacket)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12232"
#define REVISION_NR "12233"
#endif // __REVISION_NR_H__

0 comments on commit 882fc51

Please sign in to comment.