feat: username.txt support
This commit is contained in:
@@ -26,6 +26,38 @@ bool CSys::IsGuest(int iQuadrant)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSys::LoadGamertag()
|
||||
{
|
||||
wchar_t exeDir[MAX_PATH] = {};
|
||||
GetModuleFileNameW(NULL, exeDir, MAX_PATH);
|
||||
wchar_t *lastSlash = wcsrchr(exeDir, '\\');
|
||||
if (lastSlash) *(lastSlash + 1) = '\0';
|
||||
|
||||
wchar_t filePath[MAX_PATH] = {};
|
||||
if(wcscpy_s(filePath, _countof(filePath), exeDir) != 0 || wcsncat_s(filePath, _countof(filePath), L"username.txt", _TRUNCATE) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *file = NULL;
|
||||
if (_wfopen_s(&file, filePath, L"r") == 0 && file)
|
||||
{
|
||||
wchar_t buffer[128] = {};
|
||||
if(fgetws(buffer, _countof(buffer), file))
|
||||
{
|
||||
size_t len = wcslen(buffer);
|
||||
while (len > 0 && (buffer[len-1] == '\n' || buffer[len-1] == '\r' || buffer[len-1] == ' ')) buffer[--len] = '\0';
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
wcscpy_s(fakeGamerTagW, _countof(fakeGamerTagW), buffer);
|
||||
WideCharToMultiByte(CP_UTF8, 0, fakeGamerTagW, -1, fakeGamerTag, sizeof(fakeGamerTag), nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void CSys::SetFakeGamertag(char *name)
|
||||
{
|
||||
size_t chars = 0;
|
||||
|
||||
Reference in New Issue
Block a user