fix: bug de lectura en windows en Room::loadRoomTileFile()

This commit is contained in:
2025-11-01 17:51:05 +01:00
parent b21c52092a
commit b80e81dab3

View File

@@ -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 != "</data>") { // 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);
}
}
}