create check for existing setting file, write new data version to file after fix-up

This commit is contained in:
jvnpr 2026-03-11 01:53:14 -05:00
parent 6449cd82c3
commit a58cf0cc39
2 changed files with 40 additions and 13 deletions

View file

@ -794,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;i<XUSER_MAX_COUNT;i++)
@ -1606,26 +1619,36 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
}
}
void CMinecraftApp::SettingFixer()
void CMinecraftApp::SettingFixer() // jvnpr -- used to convert settings data when necessary
{
unsigned int version = ProfileManager.GetPrimaryPad()]->uiSettingDataVersion
int iPad = ProfileManager.GetPrimaryPad();
if (GameSettingsA[version != currentSettingDataVersion)
unsigned int version = GameSettingsA[iPad]->uiSettingDataVersion;
if (GetSettingsFileLoaded())
{
DebugPrintf("[SettingFixer]: Fixing Settings!\n");
if (version != currentSettingDataVersion)
{
DebugPrintf("[SettingFixer]: Fixing Settings!\n");
/* ex:
if (version < 1) fix v1 setting changes;
if (version < 2) fix v2 setting changes;
...
*/
// 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]: Nothing to do.\n");
DebugPrintf("[SettingFixer]: No settings file found, nothing to do.\n");
}
GameSettingsA[ProfileManager.GetPrimaryPad()]->uiSettingDataVersion = currentSettingDataVersion;
}
void CMinecraftApp::SetPlayerSkin(int iPad,const wstring &name)

View file

@ -237,11 +237,15 @@ public:
#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);
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);