This commit is contained in:
2025-10-27 11:53:12 +01:00
parent 231dcd4b3b
commit 5d8811026d
69 changed files with 899 additions and 888 deletions

View File

@@ -10,21 +10,21 @@
#include "game/ui/notifier.hpp" // Para Notifier
// [SINGLETON]
Cheevos* Cheevos::cheevos_ = nullptr;
Cheevos* Cheevos::cheevos = nullptr;
// [SINGLETON] Crearemos el objeto con esta función estática
void Cheevos::init(const std::string& file) {
Cheevos::cheevos_ = new Cheevos(file);
Cheevos::cheevos = new Cheevos(file);
}
// [SINGLETON] Destruiremos el objeto con esta función estática
void Cheevos::destroy() {
delete Cheevos::cheevos_;
delete Cheevos::cheevos;
}
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
Cheevos* Cheevos::get() {
return Cheevos::cheevos_;
return Cheevos::cheevos;
}
// Constructor
@@ -88,11 +88,11 @@ void Cheevos::unlock(int id) {
// Invalida un logro
void Cheevos::setUnobtainable(int id) {
const int index = find(id);
const int INDEX = find(id);
// Si el índice es válido, se invalida el logro
if (index != -1) {
cheevos_list_.at(index).obtainable = false;
if (INDEX != -1) {
cheevos_list_.at(INDEX).obtainable = false;
}
}
@@ -107,16 +107,16 @@ void Cheevos::loadFromFile() {
}
// Crea el fichero en modo escritura (binario)
std::ofstream newFile(file_, std::ios::binary);
std::ofstream new_file(file_, std::ios::binary);
if (newFile) {
if (new_file) {
if (Options::console) {
std::cout << "New " << file_ << " created!" << std::endl;
}
// Guarda la información
for (const auto& cheevo : cheevos_list_) {
newFile.write(reinterpret_cast<const char*>(&cheevo.completed), sizeof(bool));
new_file.write(reinterpret_cast<const char*>(&cheevo.completed), sizeof(bool));
}
} else {
if (Options::console) {