style: deixant guapetes les capçaleres de les classes

This commit is contained in:
2025-11-10 13:53:29 +01:00
parent 5dd463ad5a
commit b70b728b75
23 changed files with 492 additions and 595 deletions

View File

@@ -21,9 +21,9 @@ auto ItemTracker::get() -> ItemTracker* {
// Comprueba si el objeto ya ha sido cogido
auto ItemTracker::hasBeenPicked(const std::string& name, SDL_FPoint pos) -> bool {
// Primero busca si ya hay una entrada con ese nombre
if (const int INDEX = findByName(name); INDEX != -1) {
if (const int INDEX = findByName(name); INDEX != NOT_FOUND) {
// Luego busca si existe ya una entrada con esa posición
if (findByPos(INDEX, pos) != -1) {
if (findByPos(INDEX, pos) != NOT_FOUND) {
return true;
}
}
@@ -36,12 +36,12 @@ void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) {
// Comprueba si el objeto no ha sido recogido con anterioridad
if (!hasBeenPicked(name, pos)) {
// Primero busca si ya hay una entrada con ese nombre
if (const int INDEX = findByName(name); INDEX != -1) {
item_list_.at(INDEX).pos.push_back(pos);
if (const int INDEX = findByName(name); INDEX != NOT_FOUND) {
items_.at(INDEX).pos.push_back(pos);
}
// En caso contrario crea la entrada
else {
item_list_.emplace_back(name, pos);
items_.emplace_back(name, pos);
}
}
}
@@ -50,26 +50,26 @@ void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) {
auto ItemTracker::findByName(const std::string& name) -> int {
int i = 0;
for (const auto& l : item_list_) {
if (l.name == name) {
for (const auto& item : items_) {
if (item.name == name) {
return i;
}
i++;
}
return -1;
return NOT_FOUND;
}
// Busca una entrada en la lista por posición
auto ItemTracker::findByPos(int index, SDL_FPoint pos) -> int {
int i = 0;
for (const auto& l : item_list_[index].pos) {
if ((l.x == pos.x) && (l.y == pos.y)) {
for (const auto& item : items_[index].pos) {
if ((item.x == pos.x) && (item.y == pos.y)) {
return i;
}
i++;
}
return -1;
return NOT_FOUND;
}