From c63bdf748d2f991413ebdd79b99bccaef00eae8c Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 5 May 2015 23:32:50 +0200 Subject: [PATCH] SA-MP User Files fix --- SilentPatchSA/SilentPatchSA.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 7f6e2a0..649406f 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -661,29 +661,30 @@ void DrawRect_HalfPixel_Steam(CRect& rect, const CRGBA& rgba) ((void(*)(const CRect&, const CRGBA&))0x75CDA0)(rect, rgba); } -static char** const ppUserFilesDir = AddressByVersion(0x74503F, 0x74586F, 0x77EE50, 0x77902B, 0x778F1B); - char* GetMyDocumentsPath() { static char cUserFilesPath[MAX_PATH]; + static char* ppTempBufPtr = *GetVer() == 0 ? *AddressByRegion_10(0x744FE5) : cUserFilesPath; - if ( cUserFilesPath[0] == '\0' ) + if (ppTempBufPtr[0] == '\0') { + static char** const ppUserFilesDir = AddressByVersion(0x74503F, 0x74586F, 0x77EE50, 0x77902B, 0x778F1B); + char cTmpPath[MAX_PATH]; - SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); - PathAppend(cUserFilesPath, *ppUserFilesDir); - CreateDirectory(cUserFilesPath, nullptr); + SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, ppTempBufPtr); + PathAppend(ppTempBufPtr, *ppUserFilesDir); + CreateDirectory(ppTempBufPtr, nullptr); - strcpy(cTmpPath, cUserFilesPath); + strcpy(cTmpPath, ppTempBufPtr); PathAppend(cTmpPath, "Gallery"); CreateDirectory(cTmpPath, nullptr); - strcpy(cTmpPath, cUserFilesPath); + strcpy(cTmpPath, ppTempBufPtr); PathAppend(cTmpPath, "User Tracks"); CreateDirectory(cTmpPath, nullptr); } - return cUserFilesPath; + return ppTempBufPtr; } #include