diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index 58a2638..67457be 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -962,15 +962,28 @@ auto Room::loadRoomTileFile(const std::string& file_path, bool verbose) -> std:: if (line.find("data encoding") != std::string::npos) { // Lee la primera linea std::getline(stream, line); + // Trim line to handle Windows line endings + line.erase(0, line.find_first_not_of(" \t\r\n")); + line.erase(line.find_last_not_of(" \t\r\n") + 1); while (line != "") { // Procesa lineas mientras haya std::stringstream ss(line); std::string tmp; while (getline(ss, tmp, ',')) { - tile_map_file.push_back(std::stoi(tmp) - 1); + // Trim whitespace (including \r, \n, spaces, tabs) + tmp.erase(0, tmp.find_first_not_of(" \t\r\n")); + tmp.erase(tmp.find_last_not_of(" \t\r\n") + 1); + + // Skip empty strings (from trailing commas) + if (!tmp.empty()) { + tile_map_file.push_back(std::stoi(tmp) - 1); + } } // Lee la siguiente linea std::getline(stream, line); + // Trim line to handle Windows line endings + line.erase(0, line.find_first_not_of(" \t\r\n")); + line.erase(line.find_last_not_of(" \t\r\n") + 1); } } }