1313#include " CObject.h"
1414#include " CLogger.h"
1515#include " Utils.h"
16+ #include " CGame.h"
17+ #include " packets/CElementRPCPacket.h"
18+ #include < net/rpc_enums.h>
1619
1720extern CGame* g_pGame;
1821
@@ -271,12 +274,12 @@ void CObject::SetPosition(const CVector& vecPosition)
271274
272275void CObject::GetRotation (CVector& vecRotation)
273276{
274- vecRotation = m_vecRotation;
275-
276277 // Are we attached to something?
277278 if (m_pAttachedTo)
279+ {
280+ vecRotation = m_vecRotation;
278281 GetAttachedRotation (vecRotation);
279-
282+ }
280283 // Are we moving?
281284 else if (IsMoving ())
282285 {
@@ -289,6 +292,11 @@ void CObject::GetRotation(CVector& vecRotation)
289292 }
290293 vecRotation = m_vecRotation;
291294 }
295+ else
296+ {
297+ // Not moving and not attached, return stored rotation
298+ vecRotation = m_vecRotation;
299+ }
292300}
293301
294302void CObject::SetRotation (const CVector& vecRotation)
@@ -352,18 +360,18 @@ void CObject::Move(const CPositionRotationAnimation& a_rMoveAnimation)
352360
353361void CObject::StopMoving ()
354362{
355- // Were we moving in the first place
356- if (m_pMoveAnimation != NULL )
363+ if (m_pMoveAnimation != nullptr )
357364 {
358365 SPositionRotation positionRotation;
359366 m_pMoveAnimation->GetValue (positionRotation);
360367 m_vecPosition = positionRotation.m_vecPosition ;
361368 m_vecRotation = positionRotation.m_vecRotation ;
362369
363370 delete m_pMoveAnimation;
364- m_pMoveAnimation = NULL ;
371+ m_pMoveAnimation = nullptr ;
365372
366373 UpdateSpatialData ();
374+ NotifyMovementComplete ();
367375 }
368376}
369377
@@ -375,7 +383,7 @@ const CPositionRotationAnimation* CObject::GetMoveAnimation()
375383 }
376384 else
377385 {
378- return NULL ;
386+ return nullptr ;
379387 }
380388}
381389
@@ -427,7 +435,7 @@ bool CObject::SetLowLodObject(CObject* pNewLowLodObject)
427435
428436 // Clear there and here
429437 ListRemove (m_pLowLodObject->m_HighLodObjectList , this );
430- m_pLowLodObject = NULL ;
438+ m_pLowLodObject = nullptr ;
431439 return true ;
432440 }
433441 else
@@ -437,7 +445,7 @@ bool CObject::SetLowLodObject(CObject* pNewLowLodObject)
437445 return false ;
438446
439447 // Remove any previous link
440- SetLowLodObject (NULL );
448+ SetLowLodObject (nullptr );
441449
442450 // Make new link
443451 m_pLowLodObject = pNewLowLodObject;
@@ -449,6 +457,18 @@ bool CObject::SetLowLodObject(CObject* pNewLowLodObject)
449457CObject* CObject::GetLowLodObject ()
450458{
451459 if (m_bIsLowLod)
452- return NULL ;
460+ return nullptr ;
453461 return m_pLowLodObject;
454462}
463+
464+ void CObject::NotifyMovementComplete ()
465+ {
466+ CBitStream BitStream;
467+ BitStream.pBitStream ->Write (m_vecPosition.fX );
468+ BitStream.pBitStream ->Write (m_vecPosition.fY );
469+ BitStream.pBitStream ->Write (m_vecPosition.fZ );
470+ BitStream.pBitStream ->Write (m_vecRotation.fX );
471+ BitStream.pBitStream ->Write (m_vecRotation.fY );
472+ BitStream.pBitStream ->Write (m_vecRotation.fZ );
473+ g_pGame->GetPlayerManager ()->BroadcastOnlyJoined (CElementRPCPacket (this , STOP_OBJECT, *BitStream.pBitStream ));
474+ }
0 commit comments