From 6449cd82c3d6ce7070e2ad4e1ee2e31eeca185c4 Mon Sep 17 00:00:00 2001 From: jvnpr Date: Tue, 10 Mar 2026 03:49:00 -0500 Subject: [PATCH] add setting data version variables and introduce settingfixer system --- Minecraft.Client/Common/App_enums.h | 3 ++ Minecraft.Client/Common/App_structs.h | 2 + Minecraft.Client/Common/Consoles_App.cpp | 40 ++++++++++++++++++- Minecraft.Client/Common/Consoles_App.h | 1 + .../Windows64/Windows64_Minecraft.cpp | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index 15a179787..88167f43d 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -178,6 +178,9 @@ enum eGameSetting // PSVita eGameSetting_PSVita_NetworkModeAdhoc, + // Add setting data version + eGameSetting_SettingDataVersion, + }; diff --git a/Minecraft.Client/Common/App_structs.h b/Minecraft.Client/Common/App_structs.h index 6a6e03546..ad827e5f7 100644 --- a/Minecraft.Client/Common/App_structs.h +++ b/Minecraft.Client/Common/App_structs.h @@ -108,6 +108,8 @@ typedef struct // was 192 //unsigned char ucUnused[192-TUTORIAL_PROFILE_STORAGE_BYTES-sizeof(DWORD)-sizeof(char)-sizeof(char)-sizeof(char)-sizeof(char)-sizeof(LONG)-sizeof(LONG)-sizeof(DWORD)]; // 4J-PB - don't need to define the padded space, the union with ucReservedSpace will make the sizeof GAME_SETTINGS correct + + unsigned int uiSettingDataVersion; }; unsigned char ucReservedSpace[192]; diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index c3a623d5f..44a233985 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -84,6 +84,8 @@ int CMinecraftApp::s_iHTMLFontSizesA[eHTMLSize_COUNT] = #endif }; +// jvnpr -- update this anytime settingfixer needs to convert old settings to new settings! +const int currentSettingDataVersion = 1; CMinecraftApp::CMinecraftApp() { @@ -904,6 +906,8 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con app.SetGameHostOption(eGameHostOption_NaturalRegeneration, 1 ); app.SetGameHostOption(eGameHostOption_DoDaylightCycle, 1 ); + app.SetGameSettings(iPad, eGameSetting_SettingDataVersion, currentSettingDataVersion); + // 4J-PB - leave these in, or remove from everywhere they are referenced! // Although probably best to leave in unless we split the profile settings into platform specific classes - having different meaning per platform for the same bitmask could get confusing //#ifdef __PS3__ @@ -1362,6 +1366,7 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad) ActionGameSettings(iPad,eGameSetting_PS3_EULA_Read); + ActionGameSettings(iPad,eGameSetting_SettingDataVersion); } void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) @@ -1596,9 +1601,33 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_PSVita_NetworkModeAdhoc: //nothing to do here break; + case eGameSetting_SettingDataVersion: + break; } } +void CMinecraftApp::SettingFixer() +{ + unsigned int version = ProfileManager.GetPrimaryPad()]->uiSettingDataVersion + + if (GameSettingsA[version != currentSettingDataVersion) + { + DebugPrintf("[SettingFixer]: Fixing Settings!\n"); + + /* ex: + if (version < 1) fix v1 setting changes; + if (version < 2) fix v2 setting changes; + ... + */ + } + else + { + DebugPrintf("[SettingFixer]: Nothing to do.\n"); + } + + GameSettingsA[ProfileManager.GetPrimaryPad()]->uiSettingDataVersion = currentSettingDataVersion; +} + void CMinecraftApp::SetPlayerSkin(int iPad,const wstring &name) { DWORD skinId = app.getSkinIdFromPath(name); @@ -2306,7 +2335,14 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV GameSettingsA[iPad]->bSettingsChanged=true; } break; + case eGameSetting_SettingDataVersion: + if (GameSettingsA[iPad]->uiSettingDataVersion != ucVal) + { + GameSettingsA[iPad]->uiSettingDataVersion = ucVal; + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } } } @@ -2441,7 +2477,9 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) case eGameSetting_PSVita_NetworkModeAdhoc: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PSVITANETWORKMODEADHOC)>>17; - + + case eGameSetting_SettingDataVersion: + return GameSettingsA[iPad]->uiSettingDataVersion; } return 0; } diff --git a/Minecraft.Client/Common/Consoles_App.h b/Minecraft.Client/Common/Consoles_App.h index 0c1c261ef..072868115 100644 --- a/Minecraft.Client/Common/Consoles_App.h +++ b/Minecraft.Client/Common/Consoles_App.h @@ -241,6 +241,7 @@ public: void SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucVal); unsigned char GetGameSettings(int iPad,eGameSetting eVal); unsigned char GetGameSettings(eGameSetting eVal); // for the primary pad + void SettingFixer(); // jvnpr -- used to convert any old settings values to new settings based on uiSettingDataVersion / eGameSetting_SettingDataVersion void SetPlayerSkin(int iPad,const wstring &name); void SetPlayerSkin(int iPad,DWORD dwSkinId); void SetPlayerCape(int iPad,const wstring &name); diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 70aeb22bf..4bf076871 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -1345,6 +1345,7 @@ static Minecraft* InitialiseMinecraftRuntime() return nullptr; app.InitGameSettings(); + app.SettingFixer(); app.InitialiseTips(); return pMinecraft;