mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[12218] Add abstract Board/Unboard Passenger functions to TransportBase
Signed-off-by: Schmoozerd <schmoozerd@cmangos>
This commit is contained in:
parent
45d0e5babe
commit
6ceee0e4b7
3 changed files with 37 additions and 3 deletions
|
|
@ -24,7 +24,7 @@
|
||||||
* This file contains the code needed for MaNGOS to provide abstract support for transported entities
|
* This file contains the code needed for MaNGOS to provide abstract support for transported entities
|
||||||
* Currently implemented
|
* Currently implemented
|
||||||
* - Calculating between local and global coords
|
* - Calculating between local and global coords
|
||||||
*
|
* - Abstract storage of passengers (added by BoardPassenger, UnboardPassenger)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TransportSystem.h"
|
#include "TransportSystem.h"
|
||||||
|
|
@ -136,6 +136,34 @@ void TransportBase::CalculateGlobalPositionOf(float lx, float ly, float lz, floa
|
||||||
go = NormalizeOrientation(lo + m_owner->GetOrientation());
|
go = NormalizeOrientation(lo + m_owner->GetOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransportBase::BoardPassenger(WorldObject* passenger, float lx, float ly, float lz, float lo, uint8 seat)
|
||||||
|
{
|
||||||
|
TransportInfo* transportInfo = new TransportInfo(passenger, this, lx, ly, lz, lo, seat);
|
||||||
|
|
||||||
|
// Insert our new passenger
|
||||||
|
m_passengers.insert(PassengerMap::value_type(passenger, transportInfo));
|
||||||
|
|
||||||
|
// The passenger needs fast access to transportInfo
|
||||||
|
passenger->SetTransportInfo(transportInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransportBase::UnBoardPassenger(WorldObject* passenger)
|
||||||
|
{
|
||||||
|
PassengerMap::const_iterator itr = m_passengers.find(passenger);
|
||||||
|
|
||||||
|
if (itr == m_passengers.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set passengers transportInfo to NULL
|
||||||
|
passenger->SetTransportInfo(NULL);
|
||||||
|
|
||||||
|
// Delete transportInfo
|
||||||
|
delete itr->second;
|
||||||
|
|
||||||
|
// Unboard finally
|
||||||
|
m_passengers.erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
/* **************************************** TransportInfo ****************************************/
|
/* **************************************** TransportInfo ****************************************/
|
||||||
|
|
||||||
TransportInfo::TransportInfo(WorldObject* owner, TransportBase* transport, float lx, float ly, float lz, float lo, uint8 seat) :
|
TransportInfo::TransportInfo(WorldObject* owner, TransportBase* transport, float lx, float ly, float lz, float lo, uint8 seat) :
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class TransportBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TransportBase(WorldObject* owner);
|
explicit TransportBase(WorldObject* owner);
|
||||||
~TransportBase();
|
virtual ~TransportBase();
|
||||||
|
|
||||||
void Update(uint32 diff);
|
void Update(uint32 diff);
|
||||||
void UpdateGlobalPositions();
|
void UpdateGlobalPositions();
|
||||||
|
|
@ -68,6 +68,10 @@ class TransportBase
|
||||||
void CalculateGlobalPositionOf(float lx, float ly, float lz, float lo, float& gx, float& gy, float& gz, float& go) const;
|
void CalculateGlobalPositionOf(float lx, float ly, float lz, float lo, float& gx, float& gy, float& gz, float& go) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// Helper functions to add/ remove a passenger from the list
|
||||||
|
void BoardPassenger(WorldObject* passenger, float lx, float ly, float lz, float lo, uint8 seat);
|
||||||
|
void UnBoardPassenger(WorldObject* passenger);
|
||||||
|
|
||||||
WorldObject* m_owner; ///< The transporting unit
|
WorldObject* m_owner; ///< The transporting unit
|
||||||
PassengerMap m_passengers; ///< List of passengers and their transport-information
|
PassengerMap m_passengers; ///< List of passengers and their transport-information
|
||||||
|
|
||||||
|
|
@ -88,7 +92,9 @@ class TransportInfo
|
||||||
public:
|
public:
|
||||||
explicit TransportInfo(WorldObject* owner, TransportBase* transport, float lx, float ly, float lz, float lo, uint8 seat);
|
explicit TransportInfo(WorldObject* owner, TransportBase* transport, float lx, float ly, float lz, float lo, uint8 seat);
|
||||||
|
|
||||||
|
// Set local positions
|
||||||
void SetLocalPosition(float lx, float ly, float lz, float lo);
|
void SetLocalPosition(float lx, float ly, float lz, float lo);
|
||||||
|
void SetTransportSeat(uint8 seat) { m_seat = seat; }
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
WorldObject* GetTransport() const { return m_transport->GetOwner(); }
|
WorldObject* GetTransport() const { return m_transport->GetOwner(); }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "12217"
|
#define REVISION_NR "12218"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue