Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FF8 Steam: #329 fix chocobo world crash #414

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down