From c7f5fed797302568ecda7c0c73b4591d06bbabc6 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 8 Aug 2025 21:20:40 +0200 Subject: [PATCH] GamepadManager::saveToFile() no guarda el nom del mando si no existeix --- source/options.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/source/options.h b/source/options.h index 1c9422f..2628556 100644 --- a/source/options.h +++ b/source/options.h @@ -2,16 +2,16 @@ #include // Para SDL_ScaleMode -#include // Para copy -#include // Para array -#include // Para size_t -#include // Para exception -#include // Para basic_ostream, operator<<, basic_ofstream, basic_ostream::operator<<, ofstream -#include // Para shared_ptr, swap -#include // Para out_of_range, invalid_argument -#include // Para char_traits, string, allocator, operator==, swap, operator<<, basic_string, stoi -#include // Para string_view -#include // Para vector +#include // Para copy +#include // Para array +#include // Para size_t +#include // Para exception +#include // Para basic_ostream, operator<<, basic_ofstream, basic_ostream::operator<<, ofstream +#include // Para shared_ptr, swap +#include // Para out_of_range, invalid_argument +#include // Para char_traits, string, allocator, operator==, swap, operator<<, basic_string, stoi +#include // Para string_view +#include // Para vector #include "difficulty.h" // Para Code #include "input.h" // Para Input @@ -158,11 +158,15 @@ class GamepadManager { std::swap(gamepads_[0].path, gamepads_[1].path); } - // Para serialización/deserialización void saveToFile(std::ofstream& file) const { for (size_t i = 0; i < MAX_PLAYERS; ++i) { const auto& gamepad = gamepads_[i]; - file << "controller." << i << ".name=" << gamepad.name << "\n"; + // Guardar el nombre solo si hay path (mando real asignado) + if (!gamepad.path.empty()) { + file << "controller." << i << ".name=" << gamepad.name << "\n"; + } else { + file << "controller." << i << ".name=\n"; // vacío + } file << "controller." << i << ".path=" << gamepad.path << "\n"; file << "controller." << i << ".player=" << static_cast(gamepad.player_id) << "\n"; }