From 8219740b9f0df9aacfbc8ce33d0898345ac8d14b Mon Sep 17 00:00:00 2001 From: XProger Date: Sun, 10 Dec 2017 05:03:22 +0300 Subject: [PATCH] #15 fix emscripten compilation --- src/gameflow.h | 8 ++++---- src/utils.h | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gameflow.h b/src/gameflow.h index 96c8f10..4f074c4 100644 --- a/src/gameflow.h +++ b/src/gameflow.h @@ -526,9 +526,9 @@ namespace TR { } else if (id == LVL_TR2_TITLE) { sprintf(dst, "DATA/%s.tr2", LEVEL_INFO[id].name); } else if (id == LVL_TR2_EMPRTOMB) { - dst = "DATA/Emprtomb.tr2"; + strcpy(dst, "DATA/Emprtomb.tr2"); } else { - sprintf(dst, "DATA/%s.TR2", LEVEL_INFO[id]); + sprintf(dst, "DATA/%s.TR2", LEVEL_INFO[id].name); } if (Stream::existsContent(dst)) break; strcpy(dst, LEVEL_INFO[id].name); @@ -536,7 +536,7 @@ namespace TR { strcat(dst, ".TR2"); break; } - case VER_TR2_PSX : sprintf(dst, "DATA/%s.PSX", LEVEL_INFO[id]); break; + case VER_TR2_PSX : sprintf(dst, "DATA/%s.PSX", LEVEL_INFO[id].name); break; case VER_TR3_PC : sprintf(dst, isCutsceneLevel(id) ? "cuts/%s.TR2" : "data/%s.TR2", LEVEL_INFO[id].name); break; default : ASSERT(false); } @@ -548,7 +548,7 @@ namespace TR { strcat(dst, LEVEL_INFO[id].name); #ifdef __EMSCRIPTEN__ - strcat(buf, ".PSX"); + strcat(dst, ".PSX"); #else switch (version) { case VER_TR1_PC : strcat(dst, ".PHD"); break; diff --git a/src/utils.h b/src/utils.h index a79ff3c..51f1859 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1007,11 +1007,12 @@ struct Stream { FILE *f; char *data; + char *name; int size, pos; - Stream(const void *data, int size) : callback(NULL), userData(NULL), f(NULL), data((char*)data), size(size), pos(0) {} + Stream(const void *data, int size) : callback(NULL), userData(NULL), f(NULL), data((char*)data), name(NULL), size(size), pos(0) {} - Stream(const char *name, Callback *callback = NULL, void *userData = NULL) : callback(callback), userData(userData), data(NULL), size(-1), pos(0) { + Stream(const char *name, Callback *callback = NULL, void *userData = NULL) : callback(callback), userData(userData), data(NULL), name(NULL), size(-1), pos(0) { if (contentDir[0] && (!cacheDir[0] || !strstr(name, cacheDir))) { char path[255]; path[0] = 0; @@ -1050,6 +1051,7 @@ struct Stream { } ~Stream() { + delete[] name; if (f) fclose(f); } @@ -1114,9 +1116,10 @@ namespace String { void toLower(char *str) { if (!str) return; - while (*str) { - *str = tolower(*str); - str++; + + while (char &c = *str++) { + if (c >= 'A' && c <= 'Z') + c -= 'Z' - 'z'; } }