[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); // sLog.outDetail(" Generated %lu waypoints, total time %u.", (unsigned long)m_WayPoints.size(), timer);
m_curr = m_WayPoints.begin(); m_next = m_WayPoints.begin(); // will used in MoveToNextWayPoint for init m_curr
m_curr = GetNextWayPoint(); MoveToNextWayPoint(); // m_curr -> first point
m_next = GetNextWayPoint(); MoveToNextWayPoint(); // skip first point
m_pathTime = timer; m_pathTime = timer;
m_nextNodeTime = m_curr->first; m_nextNodeTime = m_curr->first;
@ -428,13 +429,13 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
return true; return true;
} }
Transport::WayPointMap::const_iterator Transport::GetNextWayPoint() void Transport::MoveToNextWayPoint()
{ {
WayPointMap::const_iterator iter = m_curr; m_curr = m_next;
++iter;
if (iter == m_WayPoints.end()) ++m_next;
iter = m_WayPoints.begin(); if (m_next == m_WayPoints.end())
return iter; m_next = m_WayPoints.begin();
} }
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) 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); DoEventIfAny(*m_curr,true);
m_curr = GetNextWayPoint(); MoveToNextWayPoint();
m_next = GetNextWayPoint();
DoEventIfAny(*m_curr,false); 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 TeleportTransport(uint32 newMapid, float x, float y, float z);
void UpdateForMap(Map const* map); void UpdateForMap(Map const* map);
void DoEventIfAny(WayPointMap::value_type const& node, bool departure); void DoEventIfAny(WayPointMap::value_type const& node, bool departure);
WayPointMap::const_iterator GetNextWayPoint(); void MoveToNextWayPoint(); // move m_next/m_cur to next points
}; };
#endif #endif

View file

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