From 8d57e68bc93aa190d4ac7df5a62f315516da35e1 Mon Sep 17 00:00:00 2001 From: myst6re Date: Mon, 14 Mar 2022 13:59:45 +0100 Subject: [PATCH] FF8 Steam: #329 fix chocobo world crash --- src/common.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index eac179ad..77ad8246 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -2900,19 +2900,23 @@ __declspec(dllexport) HANDLE __stdcall dotemuCreateFileA(LPCSTR lpFileName, DWOR ret = CreateFileA(newPath, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); } - else if (strstr(lpFileName, R"(SAVE\)") != NULL) + else if (StrStrIA(lpFileName, R"(SAVE\)") != NULL) // SAVE\SLOTX\saveN or save\chocorpg { CHAR newPath[260]{ 0 }; CHAR saveFileName[50]{ 0 }; // Search for the next character pointer after "SAVE\" - const char* pos = strstr(lpFileName, R"(SAVE\)") + 5; + const char* pos = StrStrIA(lpFileName, R"(SAVE\)") + 5; strcpy(saveFileName, pos); _strlwr(saveFileName); - *(strstr(saveFileName, R"(\)")) = 95; + char* posSeparator = strstr(saveFileName, R"(\)"); + if (posSeparator != NULL) + { + *posSeparator = '_'; + } strcat(saveFileName, R"(.ff8)"); - get_userdata_path(newPath, 260, true); + get_userdata_path(newPath, sizeof(newPath), true); PathAppendA(newPath, saveFileName); ret = CreateFileA(newPath, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);