mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-01-03 16:13:34 +08:00
[saco] Add directory setup functions
This commit is contained in:
parent
66a3722fbf
commit
fed514aa5b
@ -1,6 +1,8 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "../main.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define NUM_RADAR_COLORS 1000
|
||||
|
||||
@ -1031,4 +1033,26 @@ DWORD __stdcall TranslateColorCodeToRGBA(int iCode)
|
||||
void GameResetRadarColors()
|
||||
{
|
||||
memcpy(&dwUseHudColors[0],&dwHudColors[0],sizeof(DWORD)*NUM_RADAR_COLORS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
BOOL IsFileOrDirectoryExists(char * szPath)
|
||||
{
|
||||
struct _stat buf;
|
||||
|
||||
return _stat(szPath, &buf) == 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -6,3 +6,5 @@ void __stdcall SetRadarColor(int nIndex,DWORD dwColor);
|
||||
DWORD __stdcall TranslateColorCodeToRGBA(int iCode);
|
||||
|
||||
void GameResetRadarColors();
|
||||
|
||||
BOOL IsFileOrDirectoryExists(char * szPath);
|
||||
|
@ -1,9 +1,15 @@
|
||||
|
||||
#include "main.h"
|
||||
#include "game/util.h"
|
||||
|
||||
int iGtaVersion=0;
|
||||
|
||||
GAME_SETTINGS tSettings;
|
||||
|
||||
CHAR szArtworkProxy[MAX_PATH+1];
|
||||
CHAR szSAMPDir[MAX_PATH+1];
|
||||
CHAR szCacheDir[MAX_PATH+1];
|
||||
|
||||
CConfig *pConfig=0;
|
||||
CChatWindow *pChatWindow=0;
|
||||
CCmdWindow *pCmdWindow=0;
|
||||
@ -79,6 +85,88 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
PCHAR GetSAMPPath()
|
||||
{
|
||||
return szSAMPDir;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
PCHAR GetCachePath()
|
||||
{
|
||||
return szCacheDir;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
void SetupCacheDirectories()
|
||||
{
|
||||
ZeroMemory(szCacheDir, sizeof(szCacheDir));
|
||||
|
||||
CHAR szPath[MAX_PATH+1];
|
||||
DWORD cbData = MAX_PATH;
|
||||
HKEY hKey;
|
||||
DWORD dwType;
|
||||
ZeroMemory(szPath, sizeof(szPath));
|
||||
|
||||
sprintf(szCacheDir, "%s\\cache", szSAMPDir);
|
||||
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\SAMP", 0, KEY_READ, &hKey) == ERROR_SUCCESS &&
|
||||
RegQueryValueEx(hKey, "model_cache", NULL, &dwType, (LPBYTE) szPath, &cbData) == ERROR_SUCCESS)
|
||||
{
|
||||
strncpy(szCacheDir, szPath, MAX_PATH+1);
|
||||
}
|
||||
if(!IsFileOrDirectoryExists(szCacheDir))
|
||||
CreateDirectoryA(szCacheDir, NULL);
|
||||
|
||||
CHAR szLocalDir[MAX_PATH+1];
|
||||
sprintf(szLocalDir, "%s\\local", szCacheDir);
|
||||
if(!IsFileOrDirectoryExists(szLocalDir))
|
||||
CreateDirectoryA(szLocalDir, NULL);
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
PCHAR GetArtworkProxy()
|
||||
{
|
||||
ZeroMemory(szArtworkProxy, sizeof(szArtworkProxy));
|
||||
|
||||
DWORD cbData = MAX_PATH;
|
||||
HKEY hKey;
|
||||
DWORD dwType;
|
||||
|
||||
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\SAMP", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
if(RegQueryValueEx(hKey, "artwork_proxy", NULL, &dwType, (LPBYTE) szArtworkProxy, &cbData) != ERROR_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
return szArtworkProxy;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
void SetupDirectories()
|
||||
{
|
||||
ZeroMemory(szSAMPDir, sizeof(szSAMPDir));
|
||||
|
||||
if(strlen((char*)0xC92368) == 0) {
|
||||
GetCurrentDirectory(MAX_PATH+1, szSAMPDir);
|
||||
} else {
|
||||
sprintf(szSAMPDir, "%s\\SAMP", (char*)0xC92368);
|
||||
if(!IsFileOrDirectoryExists(szSAMPDir))
|
||||
CreateDirectoryA(szSAMPDir, NULL);
|
||||
|
||||
CHAR szScreensDir[MAX_PATH+1];
|
||||
sprintf(szScreensDir, "%s\\screens", szSAMPDir);
|
||||
if(!IsFileOrDirectoryExists(szScreensDir))
|
||||
CreateDirectoryA(szScreensDir, NULL);
|
||||
|
||||
SetupCacheDirectories();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
void TheGraphicsLoop()
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user