Fix small error

This commit is contained in:
TotallyNotElite 2018-08-25 18:07:31 +02:00
parent 106ea5203e
commit 37cc893458
2 changed files with 7 additions and 4 deletions

View File

@ -25,7 +25,7 @@ bool Prepare();
void CreateMove(); void CreateMove();
void Draw(); void Draw();
size_t FindInVector(size_t id); int FindInVector(size_t id);
class inactivityTracker class inactivityTracker
{ {
@ -303,9 +303,12 @@ struct MAP : public micropather::Graph
if (inactiveTracker.IsIgnored( if (inactiveTracker.IsIgnored(
std::pair{ area->m_id, i.area->m_id })) std::pair{ area->m_id, i.area->m_id }))
continue; continue;
int id = FindInVector(i.area->m_id);
if (id == -1)
return;
micropather::StateCost cost; micropather::StateCost cost;
cost.state = cost.state =
static_cast<void *>(&areas.at(FindInVector(i.area->m_id))); static_cast<void *>(&areas.at(id));
cost.cost = area->m_center.DistTo(i.area->m_center); cost.cost = area->m_center.DistTo(i.area->m_center);
adjacent->push_back(cost); adjacent->push_back(cost);
} }

View File

@ -17,9 +17,9 @@ static std::unique_ptr<MAP> TF2MAP;
// Function to get place in Vector by connection ID // Function to get place in Vector by connection ID
// Todo: find an alternative for this, maybe a map for storing ptrs to the // Todo: find an alternative for this, maybe a map for storing ptrs to the
// std::vector? // std::vector?
size_t FindInVector(size_t id) int FindInVector(size_t id)
{ {
for (size_t i = 0; i < areas.size(); i++) for (int i = 0; i < areas.size(); i++)
{ {
if (areas.at(i).m_id == id) if (areas.at(i).m_id == id)
return i; return i;