Skip to content

Commit 7f7d995

Browse files
authored
Revert "Win64: configurable username (username.txt) and persistent game setti…" (#234)
This reverts commit b8a7f81.
1 parent 77a161e commit 7f7d995

File tree

5 files changed

+8
-132
lines changed

5 files changed

+8
-132
lines changed

Minecraft.Client/Common/Consoles_App.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -760,43 +760,6 @@ bool CMinecraftApp::LoadBeaconMenu(int iPad ,shared_ptr<Inventory> inventory, sh
760760
//////////////////////////////////////////////
761761
// GAME SETTINGS
762762
//////////////////////////////////////////////
763-
764-
#ifdef _WINDOWS64
765-
static void Win64_GetSettingsPath(char *outPath, DWORD size)
766-
{
767-
GetModuleFileNameA(NULL, outPath, size);
768-
char *lastSlash = strrchr(outPath, '\\');
769-
if (lastSlash) *(lastSlash + 1) = '\0';
770-
strncat_s(outPath, size, "settings.dat", _TRUNCATE);
771-
}
772-
static void Win64_SaveSettings(GAME_SETTINGS *gs)
773-
{
774-
if (!gs) return;
775-
char filePath[MAX_PATH] = {};
776-
Win64_GetSettingsPath(filePath, MAX_PATH);
777-
FILE *f = NULL;
778-
if (fopen_s(&f, filePath, "wb") == 0 && f)
779-
{
780-
fwrite(gs, sizeof(GAME_SETTINGS), 1, f);
781-
fclose(f);
782-
}
783-
}
784-
static void Win64_LoadSettings(GAME_SETTINGS *gs)
785-
{
786-
if (!gs) return;
787-
char filePath[MAX_PATH] = {};
788-
Win64_GetSettingsPath(filePath, MAX_PATH);
789-
FILE *f = NULL;
790-
if (fopen_s(&f, filePath, "rb") == 0 && f)
791-
{
792-
GAME_SETTINGS temp = {};
793-
if (fread(&temp, sizeof(GAME_SETTINGS), 1, f) == 1)
794-
memcpy(gs, &temp, sizeof(GAME_SETTINGS));
795-
fclose(f);
796-
}
797-
}
798-
#endif
799-
800763
void CMinecraftApp::InitGameSettings()
801764
{
802765
for(int i=0;i<XUSER_MAX_COUNT;i++)
@@ -817,8 +780,6 @@ void CMinecraftApp::InitGameSettings()
817780
// clear this for now - it will come from reading the system values
818781
memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS));
819782
SetDefaultOptions(pProfileSettings,i);
820-
Win64_LoadSettings(GameSettingsA[i]);
821-
ApplyGameSettingsChanged(i);
822783
#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__
823784
C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i);
824785
// 4J-PB - don't cause an options write to happen here
@@ -2411,9 +2372,6 @@ void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPa
24112372
StorageManager.WriteToProfile(i,true, bOverride5MinuteTimer);
24122373
#else
24132374
ProfileManager.WriteToProfile(i,true, bOverride5MinuteTimer);
2414-
#ifdef _WINDOWS64
2415-
Win64_SaveSettings(GameSettingsA[i]);
2416-
#endif
24172375
#endif
24182376
GameSettingsA[i]->bSettingsChanged=false;
24192377
}
@@ -2427,9 +2385,6 @@ void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPa
24272385
StorageManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
24282386
#else
24292387
ProfileManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
2430-
#ifdef _WINDOWS64
2431-
Win64_SaveSettings(GameSettingsA[iPad]);
2432-
#endif
24332388
#endif
24342389
GameSettingsA[iPad]->bSettingsChanged=false;
24352390
}

Minecraft.Client/Extrax64Stubs.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,10 @@ DWORD IQNetPlayer::GetSendQueueSize(IQNetPlayer * player, DWORD dwFlags) { retur
199199
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
200200
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
201201
bool IQNetPlayer::IsGuest() { return false; }
202-
bool IQNetPlayer::IsLocal() { return true; }
203-
PlayerUID IQNetPlayer::GetXuid() { return INVALID_XUID; }
204-
extern wstring g_playerName;
205-
LPCWSTR IQNetPlayer::GetGamertag() { return g_playerName.empty() ? L"Windows" : g_playerName.c_str(); }
206-
int IQNetPlayer::GetSessionIndex() { return 0; }
202+
bool IQNetPlayer::IsLocal() { return !m_isRemote; }
203+
PlayerUID IQNetPlayer::GetXuid() { return (PlayerUID)(0xe000d45248242f2e + m_smallId); }
204+
LPCWSTR IQNetPlayer::GetGamertag() { return m_gamertag; }
205+
int IQNetPlayer::GetSessionIndex() { return m_smallId; }
207206
bool IQNetPlayer::IsTalking() { return false; }
208207
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
209208
bool IQNetPlayer::HasVoice() { return false; }

Minecraft.Client/Windows64/Windows64_App.cpp

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,11 @@
1010
#include "..\..\Minecraft.World\BiomeSource.h"
1111
#include "..\..\Minecraft.World\LevelType.h"
1212

13-
wstring g_playerName;
14-
1513
CConsoleMinecraftApp app;
1614

17-
static void LoadPlayerName()
18-
{
19-
if (!g_playerName.empty()) return;
20-
g_playerName = L"Windows";
21-
22-
char exePath[MAX_PATH] = {};
23-
GetModuleFileNameA(NULL, exePath, MAX_PATH);
24-
char *lastSlash = strrchr(exePath, '\\');
25-
if (lastSlash) *(lastSlash + 1) = '\0';
26-
char filePath[MAX_PATH] = {};
27-
_snprintf_s(filePath, sizeof(filePath), _TRUNCATE, "%susername.txt", exePath);
28-
29-
FILE *f = NULL;
30-
if (fopen_s(&f, filePath, "r") == 0 && f)
31-
{
32-
char buf[128] = {};
33-
if (fgets(buf, sizeof(buf), f))
34-
{
35-
int len = (int)strlen(buf);
36-
while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r' || buf[len-1] == ' '))
37-
buf[--len] = '\0';
38-
if (len > 0)
39-
{
40-
wchar_t wbuf[128] = {};
41-
mbstowcs(wbuf, buf, 127);
42-
g_playerName = wbuf;
43-
}
44-
}
45-
fclose(f);
46-
}
47-
}
48-
4915
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
5016
{
5117
m_bShutdown = false;
52-
LoadPlayerName();
5318
}
5419

5520
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
@@ -70,27 +35,9 @@ void CConsoleMinecraftApp::FatalLoadError()
7035

7136
void CConsoleMinecraftApp::CaptureSaveThumbnail()
7237
{
73-
RenderManager.CaptureThumbnail(&m_ThumbnailBuffer);
7438
}
7539
void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize)
7640
{
77-
// On a save caused by a create world, the thumbnail capture won't have happened
78-
if (m_ThumbnailBuffer.Allocated())
79-
{
80-
if (pbData)
81-
{
82-
*pbData = new BYTE[m_ThumbnailBuffer.GetBufferSize()];
83-
*pdwSize = m_ThumbnailBuffer.GetBufferSize();
84-
memcpy(*pbData, m_ThumbnailBuffer.GetBufferPointer(), *pdwSize);
85-
}
86-
m_ThumbnailBuffer.Release();
87-
}
88-
else
89-
{
90-
// No capture happened (e.g. first save on world creation) leave thumbnail as NULL
91-
if (pbData) *pbData = NULL;
92-
if (pdwSize) *pdwSize = 0;
93-
}
9441
}
9542
void CConsoleMinecraftApp::ReleaseSaveThumbnail()
9643
{
@@ -110,8 +57,8 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
11057
Minecraft *pMinecraft=Minecraft::GetInstance();
11158
app.ReleaseSaveThumbnail();
11259
ProfileManager.SetLockedProfile(0);
113-
LoadPlayerName();
114-
pMinecraft->user->name = g_playerName;
60+
extern wchar_t g_Win64UsernameW[17];
61+
pMinecraft->user->name = g_Win64UsernameW;
11562
app.ApplyGameSettingsChanged(0);
11663

11764
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit

Minecraft.Client/Windows64/Windows64_App.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#pragma once
2-
#include "4JLibs\inc\4J_Render.h"
32

43
class CConsoleMinecraftApp : public CMinecraftApp
54
{
6-
ImageFileBuffer m_ThumbnailBuffer;
75
public:
86
CConsoleMinecraftApp();
97

Minecraft.Client/Windows64/Windows64_Minecraft.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -729,16 +729,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
729729
UNREFERENCED_PARAMETER(hPrevInstance);
730730
UNREFERENCED_PARAMETER(lpCmdLine);
731731

732-
// 4J-Win64: set CWD to exe dir so asset paths resolve correctly
733-
{
734-
char szExeDir[MAX_PATH] = {};
735-
GetModuleFileNameA(NULL, szExeDir, MAX_PATH);
736-
char *pSlash = strrchr(szExeDir, '\\');
737-
if (pSlash) { *(pSlash + 1) = '\0'; SetCurrentDirectoryA(szExeDir); }
738-
}
739-
740-
// Declare DPI awareness so GetSystemMetrics returns physical pixels
741-
SetProcessDPIAware();
732+
dyn_SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
742733
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
743734
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
744735

@@ -1272,21 +1263,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
12721263
}
12731264
}
12741265

1275-
// F3 toggles the debug console overlay, F11 toggles fullscreen
1276-
if (KMInput.IsKeyPressed(VK_F3))
1277-
{
1278-
static bool s_debugConsole = false;
1279-
s_debugConsole = !s_debugConsole;
1280-
ui.ShowUIDebugConsole(s_debugConsole);
1281-
}
1282-
1283-
#ifdef _DEBUG_MENUS_ENABLED
1284-
if (KMInput.IsKeyPressed(VK_F4))
1285-
{
1286-
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_DebugOverlay, NULL, eUILayer_Debug);
1287-
}
1288-
#endif
1289-
1266+
// F11 toggles fullscreen
12901267
if (KMInput.IsKeyPressed(VK_F11))
12911268
{
12921269
ToggleFullscreen();

0 commit comments

Comments
 (0)