forked from jaildesigner-jailgames/jaildoctors_dilemma
fix: bug de lectura en windows en Room::loadRoomTileFile()
This commit is contained in:
@@ -962,15 +962,28 @@ auto Room::loadRoomTileFile(const std::string& file_path, bool verbose) -> std::
|
|||||||
if (line.find("data encoding") != std::string::npos) {
|
if (line.find("data encoding") != std::string::npos) {
|
||||||
// Lee la primera linea
|
// Lee la primera linea
|
||||||
std::getline(stream, line);
|
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
|
while (line != "</data>") { // Procesa lineas mientras haya
|
||||||
std::stringstream ss(line);
|
std::stringstream ss(line);
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
while (getline(ss, 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
|
// Lee la siguiente linea
|
||||||
std::getline(stream, line);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user