Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Minecraft.Client/Common/App_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ enum eGameSetting
// PSVita
eGameSetting_PSVita_NetworkModeAdhoc,

// Add setting data version
eGameSetting_SettingDataVersion,


};

Expand Down
2 changes: 2 additions & 0 deletions Minecraft.Client/Common/App_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
63 changes: 62 additions & 1 deletion Minecraft.Client/Common/Consoles_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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;i<XUSER_MAX_COUNT;i++)
Expand Down Expand Up @@ -904,6 +919,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__
Expand Down Expand Up @@ -1362,6 +1379,7 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad)

ActionGameSettings(iPad,eGameSetting_PS3_EULA_Read);

ActionGameSettings(iPad,eGameSetting_SettingDataVersion);
}

void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
Expand Down Expand Up @@ -1596,6 +1614,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");
}
}

Expand Down Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions Minecraft.Client/Common/Consoles_App.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Minecraft.Client/Windows64/Windows64_Minecraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ static Minecraft* InitialiseMinecraftRuntime()
return nullptr;

app.InitGameSettings();
app.SettingFixer();
app.InitialiseTips();

return pMinecraft;
Expand Down