chore: add .clang_format for consistent code formatting

This commit is contained in:
Patoke
2026-03-01 20:03:40 -03:00
parent 67332bbc79
commit 6e6440f0f3
25 changed files with 3960 additions and 4000 deletions

View File

@@ -2,33 +2,33 @@
#include "STO_DLC.h"
#include "STO_Main.h"
XCONTENT_DATA& CDLC::GetDLC(DWORD dw)
XCONTENT_DATA &CDLC::GetDLC(DWORD dw)
{
return m_vInstalledDLCs[dw];
return m_vInstalledDLCs[dw];
}
CDLC::CDLC(void) : m_vInstalledDLCs(), m_szMountPath(), m_vDLCDriveMappings()
{
m_iHasNewInstalledDLCs = false;
dword0 = 0;
dwordC0 = 0;
m_iHasNewMountedDLCs = false; // @Patoke fix
m_iHasNewInstalledDLCs = false;
dword0 = 0;
dwordC0 = 0;
m_iHasNewMountedDLCs = false; // @Patoke fix
ZeroMemory(m_szDLCProductCode, sizeof(m_szDLCProductCode));
ZeroMemory(m_szProductUpgradeKey, sizeof(m_szProductUpgradeKey));
ZeroMemory(m_szDLCProductCode, sizeof(m_szDLCProductCode));
ZeroMemory(m_szProductUpgradeKey, sizeof(m_szProductUpgradeKey));
}
C4JStorage::EDLCStatus CDLC::GetOffers(int iPad, int(*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask)
C4JStorage::EDLCStatus CDLC::GetOffers(int iPad, int (*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask)
{
return C4JStorage::EDLC_NoOffers;
return C4JStorage::EDLC_NoOffers;
}
void CDLC::ClearOffers()
{
;
;
}
C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, int), LPVOID lpParam)
C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, int), LPVOID lpParam)
{
if (m_iHasNewInstalledDLCs)
{
@@ -37,7 +37,7 @@ C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, i
m_pInstalledDLCFunc = Func;
m_pInstalledDLCParam = lpParam;
m_iHasNewInstalledDLCs = true;
m_iHasNewInstalledDLCs = true;
bool ret = false;
DWORD atts = GetFileAttributesA("Windows64Media/DLC");
@@ -54,196 +54,195 @@ C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, i
return C4JStorage::EDLC_Error;
}
_WIN32_FIND_DATAA hFind;
HANDLE hFindFile;
if (ret)
{
hFindFile = FindFirstFileA("Windows64/DLC/*", &hFind);
}
else
{
hFindFile = FindFirstFileA("Windows64Media/DLC/*", &hFind);
}
_WIN32_FIND_DATAA hFind;
HANDLE hFindFile;
if (ret)
{
hFindFile = FindFirstFileA("Windows64/DLC/*", &hFind);
}
else
{
hFindFile = FindFirstFileA("Windows64Media/DLC/*", &hFind);
}
if (hFindFile != (HANDLE)-1LL)
{
do
{
atts = hFind.dwFileAttributes;
if (hFindFile != (HANDLE)-1LL)
{
do
{
atts = hFind.dwFileAttributes;
bool isArt = hFind.dwFileAttributes != -1 && (hFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
if (isArt && hFind.cFileName[0] != '.')
{
XCONTENT_DATA data;
bool isArt = hFind.dwFileAttributes != -1 && (hFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
if (isArt && hFind.cFileName[0] != '.')
{
XCONTENT_DATA data;
if (ret)
{
sprintf(data.szFileName, "Windows64/DLC/%s", hFind.cFileName);
}
else
{
sprintf(data.szFileName, "Windows64Media/DLC/%s", hFind.cFileName);
}
if (ret)
{
sprintf(data.szFileName, "Windows64/DLC/%s", hFind.cFileName);
}
else
{
sprintf(data.szFileName, "Windows64Media/DLC/%s", hFind.cFileName);
}
swprintf(data.szDisplayName, 256, L"%s", hFind.cFileName);
int displayNameLen = wcslen(data.szDisplayName);
swprintf(data.szDisplayName, 256, L"%s", hFind.cFileName);
int displayNameLen = wcslen(data.szDisplayName);
data.DeviceID = 0;
data.dwContentType = 0;
data.DeviceID = 0;
data.dwContentType = 0;
AddInstalled(&data);
}
} while (FindNextFileA(hFindFile, &hFind));
FindClose(hFindFile);
}
AddInstalled(&data);
}
} while (FindNextFileA(hFindFile, &hFind));
FindClose(hFindFile);
}
return C4JStorage::EDLC_Idle;
return C4JStorage::EDLC_Idle;
}
DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive)
DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive)
{
this->m_pMountedDLCFunc = Func;
this->m_pMountedDLCParam = lpParam;
this->m_pMountedDLCFunc = Func;
this->m_pMountedDLCParam = lpParam;
if (szMountDrive)
{
m_szMountPath = szMountDrive;
}
else
{
m_szMountPath = this->m_szPackageRoot;
}
if (szMountDrive)
{
m_szMountPath = szMountDrive;
}
else
{
m_szMountPath = this->m_szPackageRoot;
}
this->m_uiCurrentMappedDLC = dwDLC;
this->m_uiCurrentMappedDLC = dwDLC;
char* dlcdirPath = m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName;
m_vDLCDriveMappings.push_back(DriveMapping(dlcdirPath, m_szMountPath));
char *dlcdirPath = m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName;
m_vDLCDriveMappings.push_back(DriveMapping(dlcdirPath, m_szMountPath));
m_iHasNewMountedDLCs = true;
m_iHasNewMountedDLCs = true;
return 997;
return 997;
}
DWORD CDLC::UnmountInstalledDLC(LPCSTR szMountDrive)
{
LPCSTR szDrive = nullptr;
LPCSTR szDrive = nullptr;
if (szMountDrive)
{
szDrive = szMountDrive;
}
else
{
szDrive = this->m_szPackageRoot;
}
if (szMountDrive)
{
szDrive = szMountDrive;
}
else
{
szDrive = this->m_szPackageRoot;
}
for (int i = 0; i < this->m_vDLCDriveMappings.size(); i++)
{
if (m_vDLCDriveMappings[i].m_szDirectoryPath == szDrive)
{
m_vDLCDriveMappings.erase(m_vDLCDriveMappings.begin() + i);
for (int i = 0; i < this->m_vDLCDriveMappings.size(); i++)
{
if (m_vDLCDriveMappings[i].m_szDirectoryPath == szDrive)
{
m_vDLCDriveMappings.erase(m_vDLCDriveMappings.begin() + i);
return 0;
}
}
return 0;
return 0;
}
}
return 0;
}
void CDLC::GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList)
void CDLC::GetMountedDLCFileList(const char *szMountDrive, std::vector<std::string> &fileList)
{
char* dlcdirPath = new char[256];
sprintf(dlcdirPath, "%s/*", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName);
char *dlcdirPath = new char[256];
sprintf(dlcdirPath, "%s/*", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName);
_WIN32_FIND_DATAA atts;
HANDLE hFind = FindFirstFileA(dlcdirPath, &atts);
if (hFind != (HANDLE)-1LL)
{
do
{
if (atts.dwFileAttributes == -1 || (atts.dwFileAttributes & 0x10) != 0x10)
{
char dir[256];
sprintf(dir, "%s/%s", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName, atts.cFileName);
_WIN32_FIND_DATAA atts;
HANDLE hFind = FindFirstFileA(dlcdirPath, &atts);
if (hFind != (HANDLE)-1LL)
{
do
{
if (atts.dwFileAttributes == -1 || (atts.dwFileAttributes & 0x10) != 0x10)
{
char dir[256];
sprintf(dir, "%s/%s", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName, atts.cFileName);
fileList.push_back(dir);
}
} while (FindNextFileA(hFind, &atts));
FindClose(hFind);
}
delete[] dlcdirPath;
fileList.push_back(dir);
}
} while (FindNextFileA(hFind, &atts));
FindClose(hFind);
}
delete[] dlcdirPath;
}
std::string CDLC::GetMountedPath(std::string szMount)
{
for (int ch = 0; ch < szMount.size(); ++ch)
{
if (szMount[ch] == '/' || szMount[ch] == '\\')
{
return "";
}
for (int ch = 0; ch < szMount.size(); ++ch)
{
if (szMount[ch] == '/' || szMount[ch] == '\\')
{
return "";
}
if (szMount[ch] == ':')
{
std::string driveName = szMount.substr(0, ch);
for (int i = 0; i < m_vDLCDriveMappings.size(); ++i)
{
if (m_vDLCDriveMappings[i].m_szDirectoryPath == driveName)
{
std::string newPath = m_vDLCDriveMappings[i].m_szMountPath;
if (szMount[ch] == ':')
{
std::string driveName = szMount.substr(0, ch);
for (int i = 0; i < m_vDLCDriveMappings.size(); ++i)
{
if (m_vDLCDriveMappings[i].m_szDirectoryPath == driveName)
{
std::string newPath = m_vDLCDriveMappings[i].m_szMountPath;
newPath.append(szMount.substr(ch + 1, -1));
newPath.append(szMount.substr(ch + 1, -1));
return newPath;
}
}
break;
}
}
return newPath;
}
}
break;
}
}
return "";
return "";
}
void CDLC::SetDLCProductCode(const char* szProductCode)
void CDLC::SetDLCProductCode(const char *szProductCode)
{
strcpy(m_szDLCProductCode, szProductCode);
strcpy(m_szDLCProductCode, szProductCode);
}
void CDLC::SetProductUpgradeKey(const char* szProductCode)
void CDLC::SetProductUpgradeKey(const char *szProductCode)
{
strcpy(m_szProductUpgradeKey, szProductCode);
strcpy(m_szProductUpgradeKey, szProductCode);
}
int CDLC::GetAvailableDLCCount(int iPad)
{
return 0;
return 0;
}
void CDLC::SetPackageRoot(char* pszDLCRoot)
void CDLC::SetPackageRoot(char *pszDLCRoot)
{
strcpy(this->m_szPackageRoot, pszDLCRoot);
strcpy(this->m_szPackageRoot, pszDLCRoot);
}
void CDLC::Tick(void)
{
if (m_iHasNewInstalledDLCs)
{
m_iHasNewInstalledDLCs = false;
m_pInstalledDLCFunc(m_pInstalledDLCParam, m_vInstalledDLCs.size(), 0);
}
if (m_iHasNewMountedDLCs)
{
m_iHasNewMountedDLCs = false;
m_pMountedDLCFunc(m_pMountedDLCParam, 0, 0, dword94);
}
if (m_iHasNewInstalledDLCs)
{
m_iHasNewInstalledDLCs = false;
m_pInstalledDLCFunc(m_pInstalledDLCParam, m_vInstalledDLCs.size(), 0);
}
if (m_iHasNewMountedDLCs)
{
m_iHasNewMountedDLCs = false;
m_pMountedDLCFunc(m_pMountedDLCParam, 0, 0, dword94);
}
}
void CDLC::AddInstalled(XCONTENT_DATA* data)
void CDLC::AddInstalled(XCONTENT_DATA *data)
{
m_vInstalledDLCs.push_back(*data);
m_vInstalledDLCs.push_back(*data);
}
DWORD CDLC::CancelOffers(void)
{
return 0;
return 0;
}