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;
|
std::string line;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (std::getline(ss, line)) {
|
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
|
// Almacena solo las lineas que no empiezan por # o no esten vacias
|
||||||
const bool test1 = line.substr(0, 1) != "#";
|
const bool test1 = line.substr(0, 1) != "#";
|
||||||
const bool test2 = !line.empty();
|
const bool test2 = !line.empty();
|
||||||
if (test1 && test2) {
|
if (test1 && test2) {
|
||||||
|
if (index >= MAX_TEXT_STRINGS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
mTextStrings[index] = line;
|
mTextStrings[index] = line;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,15 @@ static animatedSprite_t parseAnimationStream(std::istream &file, Texture *textur
|
|||||||
if (verbose) {
|
if (verbose) {
|
||||||
std::cout << "Animation loaded: " << filename << std::endl;
|
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)) {
|
while (std::getline(file, line)) {
|
||||||
|
strip_cr(line);
|
||||||
if (line == "[animation]") {
|
if (line == "[animation]") {
|
||||||
animation_t buffer;
|
animation_t buffer;
|
||||||
buffer.speed = 0;
|
buffer.speed = 0;
|
||||||
@@ -29,7 +37,8 @@ static animatedSprite_t parseAnimationStream(std::istream &file, Texture *textur
|
|||||||
buffer.completed = false;
|
buffer.completed = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
std::getline(file, line);
|
if (!std::getline(file, line)) break;
|
||||||
|
strip_cr(line);
|
||||||
int pos = line.find("=");
|
int pos = line.find("=");
|
||||||
if (pos != (int)line.npos) {
|
if (pos != (int)line.npos) {
|
||||||
if (line.substr(0, pos) == "name") {
|
if (line.substr(0, pos) == "name") {
|
||||||
|
|||||||
@@ -10357,6 +10357,5 @@ static const uint8_t kcrtpi_frag_spv[] = {
|
|||||||
0x38,
|
0x38,
|
||||||
0x00,
|
0x00,
|
||||||
0x01,
|
0x01,
|
||||||
0x00,
|
0x00};
|
||||||
};
|
|
||||||
static const size_t kcrtpi_frag_spv_size = 10356;
|
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::vector<std::string> lines;
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(ss, 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);
|
lines.push_back(line);
|
||||||
}
|
}
|
||||||
animationLines_[bname] = std::move(lines);
|
animationLines_[bname] = std::move(lines);
|
||||||
|
|||||||
+14
-1
@@ -98,7 +98,16 @@ bool Menu::parseFromStream(std::istream &file, const std::string &filename) {
|
|||||||
std::string line;
|
std::string line;
|
||||||
(void)filename;
|
(void)filename;
|
||||||
|
|
||||||
|
// Normalitza CRLF: en Windows els .men es llegeixen en binari (resource
|
||||||
|
// pack o ifstream sense flag de text) i std::getline només talla pel \n,
|
||||||
|
// deixant un \r residual. Sense això, "[item]" no fa match i el vector
|
||||||
|
// d'items queda buit → reset() accedeix a item[0] i crasheja.
|
||||||
|
auto strip_cr = [](std::string &s) {
|
||||||
|
if (!s.empty() && s.back() == '\r') s.pop_back();
|
||||||
|
};
|
||||||
|
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
|
strip_cr(line);
|
||||||
if (line == "[item]") {
|
if (line == "[item]") {
|
||||||
item_t newItem;
|
item_t newItem;
|
||||||
newItem.label = "";
|
newItem.label = "";
|
||||||
@@ -110,7 +119,8 @@ bool Menu::parseFromStream(std::istream &file, const std::string &filename) {
|
|||||||
newItem.line = false;
|
newItem.line = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
std::getline(file, line);
|
if (!std::getline(file, line)) break;
|
||||||
|
strip_cr(line);
|
||||||
int pos = line.find("=");
|
int pos = line.find("=");
|
||||||
if (!setItem(&newItem, line.substr(0, pos), line.substr(pos + 1, line.length()))) {
|
if (!setItem(&newItem, line.substr(0, pos), line.substr(pos + 1, line.length()))) {
|
||||||
success = false;
|
success = false;
|
||||||
@@ -438,6 +448,9 @@ int Menu::getWidestItem() {
|
|||||||
void Menu::reset() {
|
void Menu::reset() {
|
||||||
itemSelected = MENU_NO_OPTION;
|
itemSelected = MENU_NO_OPTION;
|
||||||
selector.index = 0;
|
selector.index = 0;
|
||||||
|
if (item.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
||||||
selector.originH = selector.targetH = item[0].rect.h;
|
selector.originH = selector.targetH = item[0].rect.h;
|
||||||
selector.moving = false;
|
selector.moving = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user