[10808] Small cleanup and optimization in transport current point update.

This commit is contained in:
VladimirMangos 2010-12-02 02:14:46 +03:00
parent 2277b24207
commit 7657d4faf1
3 changed files with 13 additions and 13 deletions

View file

@ -418,9 +418,10 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
// sLog.outDetail(" Generated %lu waypoints, total time %u.", (unsigned long)m_WayPoints.size(), timer);
m_curr = m_WayPoints.begin();
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
m_next = m_WayPoints.begin(); // will used in MoveToNextWayPoint for init m_curr
MoveToNextWayPoint(); // m_curr -> first point
MoveToNextWayPoint(); // skip first point
m_pathTime = timer;
m_nextNodeTime = m_curr->first;
@ -428,13 +429,13 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
return true;
}
Transport::WayPointMap::const_iterator Transport::GetNextWayPoint()
void Transport::MoveToNextWayPoint()
{
WayPointMap::const_iterator iter = m_curr;
++iter;
if (iter == m_WayPoints.end())
iter = m_WayPoints.begin();
return iter;
m_curr = m_next;
++m_next;
if (m_next == m_WayPoints.end())
m_next = m_WayPoints.begin();
}
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
@ -506,8 +507,7 @@ void Transport::Update(uint32 /*p_time*/)
DoEventIfAny(*m_curr,true);
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
MoveToNextWayPoint();
DoEventIfAny(*m_curr,false);

View file

@ -76,6 +76,6 @@ class Transport : public GameObject
void TeleportTransport(uint32 newMapid, float x, float y, float z);
void UpdateForMap(Map const* map);
void DoEventIfAny(WayPointMap::value_type const& node, bool departure);
WayPointMap::const_iterator GetNextWayPoint();
void MoveToNextWayPoint(); // move m_next/m_cur to next points
};
#endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10807"
#define REVISION_NR "10808"
#endif // __REVISION_NR_H__