This commit is contained in:
aria 2026-04-21 20:03:58 -04:00 committed by GitHub
commit c772dd97b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 73 additions and 1 deletions

View file

@ -178,6 +178,9 @@ enum eGameSetting
// PSVita
eGameSetting_PSVita_NetworkModeAdhoc,
// Add setting data version
eGameSetting_SettingDataVersion,
};

View file

@ -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];

View file

@ -88,6 +88,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()
{
@ -814,10 +816,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++)
@ -926,6 +941,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__
@ -1384,6 +1401,7 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad)
ActionGameSettings(iPad,eGameSetting_PS3_EULA_Read);
ActionGameSettings(iPad,eGameSetting_SettingDataVersion);
}
void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
@ -1618,6 +1636,40 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
case eGameSetting_PSVita_NetworkModeAdhoc:
//nothing to do here
break;
case eGameSetting_SettingDataVersion:
break;
}
}
void CMinecraftApp::SettingFixer() // jvnpr -- used to convert settings data when necessary
{
int iPad = ProfileManager.GetPrimaryPad();
unsigned int version = GameSettingsA[iPad]->uiSettingDataVersion;
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");
}
}
@ -2328,7 +2380,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;
}
}
}
@ -2463,7 +2522,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;
}

View file

@ -237,6 +237,11 @@ 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);

View file

@ -1300,6 +1300,7 @@ static Minecraft* InitialiseMinecraftRuntime()
return nullptr;
app.InitGameSettings();
app.SettingFixer();
app.InitialiseTips();
return pMinecraft;