fixes per a windows: CRLF en parsers de text i SPV de postfx
This commit is contained in:
@@ -67,10 +67,20 @@ bool Lang::setLang(Uint8 lang) {
|
||||
std::string line;
|
||||
int index = 0;
|
||||
while (std::getline(ss, line)) {
|
||||
// Normaliza CRLF: en Windows els fitxers es llegeixen en binari i
|
||||
// getline només talla pel \n, deixant un \r residual que faria que les
|
||||
// línies en blanc no semblen buides (i sobreescriguen més enllà de
|
||||
// mTextStrings, corrompent el heap).
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
// Almacena solo las lineas que no empiezan por # o no esten vacias
|
||||
const bool test1 = line.substr(0, 1) != "#";
|
||||
const bool test2 = !line.empty();
|
||||
if (test1 && test2) {
|
||||
if (index >= MAX_TEXT_STRINGS) {
|
||||
break;
|
||||
}
|
||||
mTextStrings[index] = line;
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,15 @@ static animatedSprite_t parseAnimationStream(std::istream &file, Texture *textur
|
||||
if (verbose) {
|
||||
std::cout << "Animation loaded: " << filename << std::endl;
|
||||
}
|
||||
// Normalitza CRLF: fitxers .ani amb terminadors de Windows fan que
|
||||
// line == "[animation]" no faci match i el parser entri en bucle
|
||||
// infinit / no carregui cap animació.
|
||||
auto strip_cr = [](std::string &s) {
|
||||
if (!s.empty() && s.back() == '\r') s.pop_back();
|
||||
};
|
||||
|
||||
while (std::getline(file, line)) {
|
||||
strip_cr(line);
|
||||
if (line == "[animation]") {
|
||||
animation_t buffer;
|
||||
buffer.speed = 0;
|
||||
@@ -29,7 +37,8 @@ static animatedSprite_t parseAnimationStream(std::istream &file, Texture *textur
|
||||
buffer.completed = false;
|
||||
|
||||
do {
|
||||
std::getline(file, line);
|
||||
if (!std::getline(file, line)) break;
|
||||
strip_cr(line);
|
||||
int pos = line.find("=");
|
||||
if (pos != (int)line.npos) {
|
||||
if (line.substr(0, pos) == "name") {
|
||||
|
||||
@@ -10357,6 +10357,5 @@ static const uint8_t kcrtpi_frag_spv[] = {
|
||||
0x38,
|
||||
0x00,
|
||||
0x01,
|
||||
0x00,
|
||||
};
|
||||
0x00};
|
||||
static const size_t kcrtpi_frag_spv_size = 10356;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,6 +101,9 @@ void Resource::preloadAll() {
|
||||
std::vector<std::string> lines;
|
||||
std::string line;
|
||||
while (std::getline(ss, line)) {
|
||||
// Normalitza CRLF perquè loadFromVector compari línies amb literals
|
||||
// ("[animation]", "[/animation]") sense \r residual.
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
lines.push_back(line);
|
||||
}
|
||||
animationLines_[bname] = std::move(lines);
|
||||
|
||||
Reference in New Issue
Block a user