forked from jaildesigner-jailgames/jaildoctors_dilemma
corregides les lectures de fitxers de text en windows. fallava per culpa del final de linea
This commit is contained in:
@@ -1022,6 +1022,10 @@ auto Room::loadRoomFile(const std::string& file_path, bool verbose) -> Data {
|
||||
|
||||
// Procesa el fichero linea a linea
|
||||
while (std::getline(stream, line)) {
|
||||
// Remove Windows line ending if present
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
// Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo
|
||||
if (line == "[enemy]") {
|
||||
room.enemies.push_back(loadEnemyFromFile(stream, FILE_NAME, verbose));
|
||||
@@ -1075,6 +1079,10 @@ auto Room::loadEnemyFromFile(std::istream& file, const std::string& file_name, b
|
||||
std::string line;
|
||||
do {
|
||||
std::getline(file, line);
|
||||
// Remove Windows line ending if present
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
auto [key, value] = parseKeyValue(line);
|
||||
|
||||
if (!setEnemy(&enemy, key, value)) {
|
||||
@@ -1095,6 +1103,10 @@ auto Room::loadItemFromFile(std::istream& file, const std::string& file_name, bo
|
||||
std::string line;
|
||||
do {
|
||||
std::getline(file, line);
|
||||
// Remove Windows line ending if present
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
auto [key, value] = parseKeyValue(line);
|
||||
|
||||
if (!setItem(&item, key, value)) {
|
||||
|
||||
Reference in New Issue
Block a user