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..525b5ab0a 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() { @@ -792,10 +794,23 @@ static void Win64_LoadSettings(GAME_SETTINGS *gs) if (fread(&temp, sizeof(GAME_SETTINGS), 1, f) == 1) memcpy(gs, &temp, sizeof(GAME_SETTINGS)); fclose(f); + CMinecraftApp::SetSettingsFileLoaded(true); } } #endif +bool CMinecraftApp::settingFileLoaded = false; + +void CMinecraftApp::SetSettingsFileLoaded(bool loaded) +{ + settingFileLoaded = loaded; +} + +bool CMinecraftApp::GetSettingsFileLoaded() +{ + return settingFileLoaded; +} + void CMinecraftApp::InitGameSettings() { for(int i=0;iuiSettingDataVersion; + + if (GetSettingsFileLoaded()) + { + if (version != currentSettingDataVersion) + { + DebugPrintf("[SettingFixer]: Fixing Settings!\n"); + + // perform fixing up + + GameSettingsA[iPad]->uiSettingDataVersion = currentSettingDataVersion; + GameSettingsA[iPad]->bSettingsChanged = true; + CheckGameSettingsChanged(true, iPad); + + DebugPrintf("[SettingFixer]: Settings fixed and saved.\n"); + + } + else + { + DebugPrintf("[SettingFixer]: Nothing to do.\n"); + } + } + else + { + DebugPrintf("[SettingFixer]: No settings file found, nothing to do.\n"); } } @@ -2306,7 +2358,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 +2500,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..6da11d629 100644 --- a/Minecraft.Client/Common/Consoles_App.h +++ b/Minecraft.Client/Common/Consoles_App.h @@ -237,6 +237,11 @@ class CMinecraftApp #endif virtual void SetRichPresenceContext(int iPad, int contextId) = 0; + // jvnpr -- SettingFixer & related checks + void SettingFixer(); + static void SetSettingsFileLoaded(bool loaded); + static bool GetSettingsFileLoaded(); + static bool settingFileLoaded; void SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucVal); unsigned char GetGameSettings(int iPad,eGameSetting eVal); 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;