forked from jaildesigner-jailgames/jaildoctors_dilemma
Optimizaciones de código
This commit is contained in:
@@ -57,31 +57,33 @@ void ItemTracker::addItem(std::string name, SDL_Point pos)
|
||||
// Busca una entrada en la lista por nombre
|
||||
int ItemTracker::findByName(std::string name)
|
||||
{
|
||||
const int c = -1;
|
||||
int i = 0;
|
||||
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
for (auto l : list)
|
||||
{
|
||||
if (list[i].name == name)
|
||||
if (l.name == name)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
return c;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Busca una entrada en la lista por posición
|
||||
int ItemTracker::findByPos(int index, SDL_Point pos)
|
||||
{
|
||||
const int c = -1;
|
||||
int i = 0;
|
||||
|
||||
for (int i = 0; i < list[index].pos.size(); i++)
|
||||
for (auto l:list[index].pos)
|
||||
{
|
||||
if ((list[index].pos[i].x == pos.x) && (list[index].pos[i].y == pos.y))
|
||||
if ((l.x == pos.x) && (l.y == pos.y))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
return c;
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user