diff --git a/Minecraft.Client/Platform/Common/Consoles_App.cpp b/Minecraft.Client/Platform/Common/Consoles_App.cpp index 3c82a36d6..6c0ce3853 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.cpp +++ b/Minecraft.Client/Platform/Common/Consoles_App.cpp @@ -70,2103 +70,2161 @@ #include "Leaderboards/LeaderboardManager.h" -//CMinecraftApp app; +// CMinecraftApp app; unsigned int CMinecraftApp::m_uiLastSignInData = 0; -const float CMinecraftApp::fSafeZoneX = 64.0f; // 5% of 1280 -const float CMinecraftApp::fSafeZoneY = 36.0f; // 5% of 720 +const float CMinecraftApp::fSafeZoneX = 64.0f; // 5% of 1280 +const float CMinecraftApp::fSafeZoneY = 36.0f; // 5% of 720 -int CMinecraftApp::s_iHTMLFontSizesA[eHTMLSize_COUNT] = -{ +int CMinecraftApp::s_iHTMLFontSizesA[eHTMLSize_COUNT] = { #ifdef _XBOX - 14,12,14,24 + 14, 12, 14, 24 #else - //20,15,20,24 - 20,13,20,26 + // 20,15,20,24 + 20, 13, 20, 26 #endif }; - -CMinecraftApp::CMinecraftApp() -{ - if(GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS)) - { - // 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES in Xbox_App.h - DebugPrintf("WARNING: The size of the profile GAME_SETTINGS struct has changed, so all stat data is likely incorrect. Is: %d, Should be: %d\n",sizeof(GAME_SETTINGS),GAME_SETTINGS_PROFILE_DATA_BYTES); +CMinecraftApp::CMinecraftApp() { + if (GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS)) { + // 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES in + // Xbox_App.h + DebugPrintf( + "WARNING: The size of the profile GAME_SETTINGS struct has " + "changed, so all stat data is likely incorrect. Is: %d, Should be: " + "%d\n", + sizeof(GAME_SETTINGS), GAME_SETTINGS_PROFILE_DATA_BYTES); #ifndef _CONTENT_PACKAGE - __debugbreak(); + __debugbreak(); #endif - } + } - for(int i=0;i; - } + for (int i = 0; i < XUSER_MAX_COUNT; i++) { + m_vBannedListA[i] = new std::vector; + } - LocaleAndLanguageInit(); + LocaleAndLanguageInit(); #ifdef _XBOX_ONE - m_hasReachedMainMenu = false; + m_hasReachedMainMenu = false; #endif } - - -void CMinecraftApp::DebugPrintf(const char *szFormat, ...) -{ - +void CMinecraftApp::DebugPrintf(const char* szFormat, ...) { #ifndef _FINAL_BUILD - char buf[1024]; - va_list ap; - va_start(ap, szFormat); - vsnprintf(buf, sizeof(buf), szFormat, ap); - va_end(ap); - OutputDebugStringA(buf); + char buf[1024]; + va_list ap; + va_start(ap, szFormat); + vsnprintf(buf, sizeof(buf), szFormat, ap); + va_end(ap); + OutputDebugStringA(buf); #endif - } -void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...) -{ - if(user == USER_NONE) - return; - char buf[1024]; - va_list ap; - va_start(ap, szFormat); - vsnprintf(buf, sizeof(buf), szFormat, ap); - va_end(ap); +void CMinecraftApp::DebugPrintf(int user, const char* szFormat, ...) { + if (user == USER_NONE) return; + char buf[1024]; + va_list ap; + va_start(ap, szFormat); + vsnprintf(buf, sizeof(buf), szFormat, ap); + va_end(ap); } -const wchar_t *CMinecraftApp::GetString(int iID) -{ - //return L"Değişiklikler ve Yenilikler"; - //return L"ÕÕÕÕÖÖÖÖ"; - return app.m_stringTable->getString(iID); +const wchar_t* CMinecraftApp::GetString(int iID) { + // return L"Değişiklikler ve Yenilikler"; + // return L"ÕÕÕÕÖÖÖÖ"; + return app.m_stringTable->getString(iID); } -void CMinecraftApp::SetAction(int iPad, eXuiAction action, void *param) -{ - if(m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail && action != eAppAction_Idle) - { - app.DebugPrintf("Invalid change of App action for pad %d from %d to %d, ignoring\n", iPad, m_eXuiAction[iPad], action); - } - else - { - app.DebugPrintf("Changing App action for pad %d from %d to %d\n", iPad, m_eXuiAction[iPad], action); - m_eXuiAction[iPad]=action; - m_eXuiActionParam[iPad] = param; - } -} +void CMinecraftApp::SetAction(int iPad, eXuiAction action, void* param) { + if (m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail && + action != eAppAction_Idle) { + app.DebugPrintf( + "Invalid change of App action for pad %d from %d to %d, ignoring\n", + iPad, m_eXuiAction[iPad], action); + } else { + app.DebugPrintf("Changing App action for pad %d from %d to %d\n", iPad, + m_eXuiAction[iPad], action); + m_eXuiAction[iPad] = action; + m_eXuiActionParam[iPad] = param; + } +} -bool CMinecraftApp::IsAppPaused() -{ +bool CMinecraftApp::IsAppPaused() { #if defined(_XBOX_ONE) || defined(__ORBIS__) - bool paused = m_bIsAppPaused; - EnterCriticalSection(&m_saveNotificationCriticalSection); - if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 ) - { - paused |= m_saveNotificationDepth > 0; - } - LeaveCriticalSection(&m_saveNotificationCriticalSection); - return paused; + bool paused = m_bIsAppPaused; + EnterCriticalSection(&m_saveNotificationCriticalSection); + if (g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1) { + paused |= m_saveNotificationDepth > 0; + } + LeaveCriticalSection(&m_saveNotificationCriticalSection); + return paused; #else - return m_bIsAppPaused; + return m_bIsAppPaused; #endif } -void CMinecraftApp::SetAppPaused(bool val) -{ - m_bIsAppPaused = val; +void CMinecraftApp::SetAppPaused(bool val) { m_bIsAppPaused = val; } + +void CMinecraftApp::HandleButtonPresses() { + for (int i = 0; i < 4; i++) { + HandleButtonPresses(i); + } } -void CMinecraftApp::HandleButtonPresses() -{ - for(int i=0;i<4;i++) - { - HandleButtonPresses(i); - } +void CMinecraftApp::HandleButtonPresses(int iPad) { + // // test an update of the profile data + // void *pData=ProfileManager.GetGameDefinedProfileData(iPad); + // + // unsigned char *pchData= (unsigned char *)pData; + // int iCount=0; + // for(int i=0;i player, + bool bNavigateBack) { + bool success = true; -// // test an update of the profile data -// void *pData=ProfileManager.GetGameDefinedProfileData(iPad); -// -// unsigned char *pchData= (unsigned char *)pData; -// int iCount=0; -// for(int i=0;iplayer = player; + initData->bNavigateBack = bNavigateBack; + initData->iPad = iPad; + + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData); + } + + return success; } -bool CMinecraftApp::LoadInventoryMenu(int iPad,std::shared_ptr player,bool bNavigateBack) -{ - bool success = true; +bool CMinecraftApp::LoadCreativeMenu(int iPad, + std::shared_ptr player, + bool bNavigateBack) { + bool success = true; - InventoryScreenInput* initData = new InventoryScreenInput(); - initData->player = player; - initData->bNavigateBack=bNavigateBack; - initData->iPad = iPad; + InventoryScreenInput* initData = new InventoryScreenInput(); + initData->player = player; + initData->bNavigateBack = bNavigateBack; + initData->iPad = iPad; - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_InventoryMenu,initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_InventoryMenu,initData); - } + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData); + } - return success; + return success; } -bool CMinecraftApp::LoadCreativeMenu(int iPad,std::shared_ptr player,bool bNavigateBack) -{ - bool success = true; +bool CMinecraftApp::LoadCrafting2x2Menu(int iPad, + std::shared_ptr player) { + bool success = true; - InventoryScreenInput* initData = new InventoryScreenInput(); - initData->player = player; - initData->bNavigateBack=bNavigateBack; - initData->iPad = iPad; + CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); + initData->player = player; + initData->iContainerType = RECIPE_TYPE_2x2; + initData->iPad = iPad; + initData->x = 0; + initData->y = 0; + initData->z = 0; - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_CreativeMenu,initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_CreativeMenu,initData); - } + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData); + } - return success; + return success; } -bool CMinecraftApp::LoadCrafting2x2Menu(int iPad,std::shared_ptr player) -{ - bool success = true; +bool CMinecraftApp::LoadCrafting3x3Menu(int iPad, + std::shared_ptr player, + int x, int y, int z) { + bool success = true; - CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); - initData->player = player; - initData->iContainerType=RECIPE_TYPE_2x2; - initData->iPad = iPad; - initData->x = 0; - initData->y = 0; - initData->z = 0; + CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); + initData->player = player; + initData->iContainerType = RECIPE_TYPE_3x3; + initData->iPad = iPad; + initData->x = x; + initData->y = y; + initData->z = z; - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_Crafting2x2Menu, initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_Crafting2x2Menu, initData); - } + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData); + } - return success; + return success; } -bool CMinecraftApp::LoadCrafting3x3Menu(int iPad,std::shared_ptr player, int x, int y, int z) -{ - bool success = true; +bool CMinecraftApp::LoadEnchantingMenu(int iPad, + std::shared_ptr inventory, + int x, int y, int z, Level* level) { + bool success = true; - CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); - initData->player = player; - initData->iContainerType=RECIPE_TYPE_3x3; - initData->iPad = iPad; - initData->x = x; - initData->y = y; - initData->z = z; + EnchantingScreenInput* initData = new EnchantingScreenInput(); + initData->inventory = inventory; + initData->level = level; + initData->x = x; + initData->y = y; + initData->z = z; + initData->iPad = iPad; - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_Crafting3x3Menu, initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_Crafting3x3Menu, initData); - } + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData); + } - return success; + return success; } -bool CMinecraftApp::LoadEnchantingMenu(int iPad,std::shared_ptr inventory, int x, int y, int z, Level *level) -{ - bool success = true; +bool CMinecraftApp::LoadFurnaceMenu( + int iPad, std::shared_ptr inventory, + std::shared_ptr furnace) { + bool success = true; - EnchantingScreenInput* initData = new EnchantingScreenInput(); - initData->inventory = inventory; - initData->level = level; - initData->x = x; - initData->y = y; - initData->z = z; - initData->iPad = iPad; + FurnaceScreenInput* initData = new FurnaceScreenInput(); - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_EnchantingMenu, initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_EnchantingMenu, initData); - } + initData->furnace = furnace; + initData->inventory = inventory; + initData->iPad = iPad; - return success; + // Load the scene. + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData); + } + + return success; } -bool CMinecraftApp::LoadFurnaceMenu(int iPad,std::shared_ptr inventory, std::shared_ptr furnace) -{ - bool success = true; +bool CMinecraftApp::LoadBrewingStandMenu( + int iPad, std::shared_ptr inventory, + std::shared_ptr brewingStand) { + bool success = true; - FurnaceScreenInput* initData = new FurnaceScreenInput(); + BrewingScreenInput* initData = new BrewingScreenInput(); - initData->furnace = furnace; - initData->inventory = inventory; - initData->iPad = iPad; + initData->brewingStand = brewingStand; + initData->inventory = inventory; + initData->iPad = iPad; - // Load the scene. - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_FurnaceMenu, initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_FurnaceMenu, initData); - } + // Load the scene. + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData); + } - return success; + return success; } -bool CMinecraftApp::LoadBrewingStandMenu(int iPad,std::shared_ptr inventory, std::shared_ptr brewingStand) -{ - bool success = true; +bool CMinecraftApp::LoadContainerMenu(int iPad, + std::shared_ptr inventory, + std::shared_ptr container) { + bool success = true; - BrewingScreenInput* initData = new BrewingScreenInput(); + ContainerScreenInput* initData = new ContainerScreenInput(); - initData->brewingStand = brewingStand; - initData->inventory = inventory; - initData->iPad = iPad; + initData->inventory = inventory; + initData->container = container; + initData->iPad = iPad; - // Load the scene. - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_BrewingStandMenu, initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_BrewingStandMenu, initData); - } + // Load the scene. + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; - return success; + bool bLargeChest = + (initData->container->getContainerSize() > 3 * 9) ? true : false; + if (bLargeChest) { + success = + ui.NavigateToScene(iPad, eUIScene_LargeContainerMenu, initData); + } else { + success = + ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData); + } + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData); + } + + return success; } +bool CMinecraftApp::LoadTrapMenu(int iPad, std::shared_ptr inventory, + std::shared_ptr trap) { + bool success = true; -bool CMinecraftApp::LoadContainerMenu(int iPad,std::shared_ptr inventory, std::shared_ptr container) -{ - bool success = true; + TrapScreenInput* initData = new TrapScreenInput(); - ContainerScreenInput* initData = new ContainerScreenInput(); + initData->inventory = inventory; + initData->trap = trap; + initData->iPad = iPad; - initData->inventory = inventory; - initData->container = container; - initData->iPad = iPad; + // Load the scene. + if (app.GetLocalPlayerCount() > 1) { + initData->bSplitscreen = true; + success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData); + } else { + initData->bSplitscreen = false; + success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData); + } - // Load the scene. - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - - bool bLargeChest = (initData->container->getContainerSize() > 3*9)?true:false; - if(bLargeChest) - { - success = ui.NavigateToScene(iPad,eUIScene_LargeContainerMenu,initData); - } - else - { - success = ui.NavigateToScene(iPad,eUIScene_ContainerMenu,initData); - } - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_ContainerMenu,initData); - } - - return success; + return success; } -bool CMinecraftApp::LoadTrapMenu(int iPad,std::shared_ptr inventory, std::shared_ptr trap) -{ - bool success = true; +bool CMinecraftApp::LoadSignEntryMenu(int iPad, + std::shared_ptr sign) { + bool success = true; - TrapScreenInput* initData = new TrapScreenInput(); + SignEntryScreenInput* initData = new SignEntryScreenInput(); - initData->inventory = inventory; - initData->trap = trap; - initData->iPad = iPad; + initData->sign = sign; + initData->iPad = iPad; - // Load the scene. - if(app.GetLocalPlayerCount()>1) - { - initData->bSplitscreen=true; - success = ui.NavigateToScene(iPad,eUIScene_DispenserMenu, initData); - } - else - { - initData->bSplitscreen=false; - success = ui.NavigateToScene(iPad,eUIScene_DispenserMenu, initData); - } + success = ui.NavigateToScene(iPad, eUIScene_SignEntryMenu, initData); - return success; + delete initData; + + return success; } -bool CMinecraftApp::LoadSignEntryMenu(int iPad,std::shared_ptr sign) -{ - bool success = true; +bool CMinecraftApp::LoadRepairingMenu(int iPad, + std::shared_ptr inventory, + Level* level, int x, int y, int z) { + bool success = true; - SignEntryScreenInput* initData = new SignEntryScreenInput(); + AnvilScreenInput* initData = new AnvilScreenInput(); + initData->inventory = inventory; + initData->level = level; + initData->x = x; + initData->y = y; + initData->z = z; + initData->iPad = iPad; + if (app.GetLocalPlayerCount() > 1) + initData->bSplitscreen = true; + else + initData->bSplitscreen = false; - initData->sign = sign; - initData->iPad = iPad; + success = ui.NavigateToScene(iPad, eUIScene_AnvilMenu, initData); - success = ui.NavigateToScene(iPad,eUIScene_SignEntryMenu, initData); - - delete initData; - - return success; + return success; } -bool CMinecraftApp::LoadRepairingMenu(int iPad,std::shared_ptr inventory, Level *level, int x, int y, int z) -{ - bool success = true; +bool CMinecraftApp::LoadTradingMenu(int iPad, + std::shared_ptr inventory, + std::shared_ptr trader, + Level* level) { + bool success = true; - AnvilScreenInput *initData = new AnvilScreenInput(); - initData->inventory = inventory; - initData->level = level; - initData->x = x; - initData->y = y; - initData->z = z; - initData->iPad = iPad; - if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true; - else initData->bSplitscreen=false; + TradingScreenInput* initData = new TradingScreenInput(); + initData->inventory = inventory; + initData->trader = trader; + initData->level = level; + initData->iPad = iPad; + if (app.GetLocalPlayerCount() > 1) + initData->bSplitscreen = true; + else + initData->bSplitscreen = false; - success = ui.NavigateToScene(iPad,eUIScene_AnvilMenu, initData); + success = ui.NavigateToScene(iPad, eUIScene_TradingMenu, initData); - return success; + return success; } -bool CMinecraftApp::LoadTradingMenu(int iPad, std::shared_ptr inventory, std::shared_ptr trader, Level *level) -{ - bool success = true; - - TradingScreenInput *initData = new TradingScreenInput(); - initData->inventory = inventory; - initData->trader = trader; - initData->level = level; - initData->iPad = iPad; - if(app.GetLocalPlayerCount()>1) initData->bSplitscreen=true; - else initData->bSplitscreen=false; - - success = ui.NavigateToScene(iPad,eUIScene_TradingMenu, initData); - - return success; -} - - ////////////////////////////////////////////// // GAME SETTINGS ////////////////////////////////////////////// -void CMinecraftApp::InitGameSettings() -{ - for(int i=0;ibSettingsChanged=false; + // clear the flag to say the settings have changed + GameSettingsA[i]->bSettingsChanged = false; - //SetDefaultGameSettings(i); - done on a callback from the profile manager + // SetDefaultGameSettings(i); - done on a callback from the profile + // manager - // 4J-PB - adding in for Windows & PS3 to set the defaults for the joypad -#if defined _WINDOWS64// || defined __PSVITA__ - C_4JProfile::PROFILESETTINGS *pProfileSettings=ProfileManager.GetDashboardProfileSettings(i); - // clear this for now - it will come from reading the system values - memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS)); - SetDefaultOptions(pProfileSettings,i); -#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ - C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i); - // 4J-PB - don't cause an options write to happen here - SetDefaultOptions(pProfileSettings,i,false); + // 4J-PB - adding in for Windows & PS3 to set the defaults for the + // joypad +#if defined _WINDOWS64 // || defined __PSVITA__ + C_4JProfile::PROFILESETTINGS* pProfileSettings = + ProfileManager.GetDashboardProfileSettings(i); + // clear this for now - it will come from reading the system values + memset(pProfileSettings, 0, sizeof(C_4JProfile::PROFILESETTINGS)); + SetDefaultOptions(pProfileSettings, i); +#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__ + C4JStorage::PROFILESETTINGS* pProfileSettings = + StorageManager.GetDashboardProfileSettings(i); + // 4J-PB - don't cause an options write to happen here + SetDefaultOptions(pProfileSettings, i, false); #else - // 4jcrqaft: Linux (and any other platform): profile data is zero-initialised, so explicitly apply defaults - C_4JProfile::PROFILESETTINGS *pProfileSettings=ProfileManager.GetDashboardProfileSettings(i); - memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS)); - SetDefaultOptions(pProfileSettings,i); + // 4jcrqaft: Linux (and any other platform): profile data is + // zero-initialised, so explicitly apply defaults + C_4JProfile::PROFILESETTINGS* pProfileSettings = + ProfileManager.GetDashboardProfileSettings(i); + memset(pProfileSettings, 0, sizeof(C_4JProfile::PROFILESETTINGS)); + SetDefaultOptions(pProfileSettings, i); #endif - } + } } -#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) -int CMinecraftApp::SetDefaultOptions(C4JStorage::PROFILESETTINGS *pSettings,const int iPad,bool bWriteProfile) +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) +int CMinecraftApp::SetDefaultOptions(C4JStorage::PROFILESETTINGS* pSettings, + const int iPad, bool bWriteProfile) #else -int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,const int iPad) +int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings, + const int iPad) #endif { - SetGameSettings(iPad,eGameSetting_MusicVolume,DEFAULT_VOLUME_LEVEL); - SetGameSettings(iPad,eGameSetting_SoundFXVolume,DEFAULT_VOLUME_LEVEL); - SetGameSettings(iPad,eGameSetting_Gamma,50); + SetGameSettings(iPad, eGameSetting_MusicVolume, DEFAULT_VOLUME_LEVEL); + SetGameSettings(iPad, eGameSetting_SoundFXVolume, DEFAULT_VOLUME_LEVEL); + SetGameSettings(iPad, eGameSetting_Gamma, 50); - // 4J-PB - Don't reset the difficult level if we're in-game - if(Minecraft::GetInstance()->level==NULL) - { - app.DebugPrintf("SetDefaultOptions - Difficulty = 1\n"); - SetGameSettings(iPad,eGameSetting_Difficulty,1); - } - SetGameSettings(iPad,eGameSetting_Sensitivity_InGame,100); - SetGameSettings(iPad,eGameSetting_ViewBob,1); - SetGameSettings(iPad,eGameSetting_ControlScheme,0); - SetGameSettings(iPad,eGameSetting_ControlInvertLook,(pSettings->iYAxisInversion!=0)?1:0); - SetGameSettings(iPad,eGameSetting_ControlSouthPaw,pSettings->bSwapSticks?1:0); - SetGameSettings(iPad,eGameSetting_SplitScreenVertical,0); - SetGameSettings(iPad,eGameSetting_GamertagsVisible,1); + // 4J-PB - Don't reset the difficult level if we're in-game + if (Minecraft::GetInstance()->level == NULL) { + app.DebugPrintf("SetDefaultOptions - Difficulty = 1\n"); + SetGameSettings(iPad, eGameSetting_Difficulty, 1); + } + SetGameSettings(iPad, eGameSetting_Sensitivity_InGame, 100); + SetGameSettings(iPad, eGameSetting_ViewBob, 1); + SetGameSettings(iPad, eGameSetting_ControlScheme, 0); + SetGameSettings(iPad, eGameSetting_ControlInvertLook, + (pSettings->iYAxisInversion != 0) ? 1 : 0); + SetGameSettings(iPad, eGameSetting_ControlSouthPaw, + pSettings->bSwapSticks ? 1 : 0); + SetGameSettings(iPad, eGameSetting_SplitScreenVertical, 0); + SetGameSettings(iPad, eGameSetting_GamertagsVisible, 1); - // Interim TU 1.6.6 - SetGameSettings(iPad,eGameSetting_Sensitivity_InMenu,100); - SetGameSettings(iPad,eGameSetting_DisplaySplitscreenGamertags,1); - SetGameSettings(iPad,eGameSetting_Hints,1); - SetGameSettings(iPad,eGameSetting_Autosave,2); - SetGameSettings(iPad,eGameSetting_Tooltips,1); - SetGameSettings(iPad,eGameSetting_InterfaceOpacity,80); + // Interim TU 1.6.6 + SetGameSettings(iPad, eGameSetting_Sensitivity_InMenu, 100); + SetGameSettings(iPad, eGameSetting_DisplaySplitscreenGamertags, 1); + SetGameSettings(iPad, eGameSetting_Hints, 1); + SetGameSettings(iPad, eGameSetting_Autosave, 2); + SetGameSettings(iPad, eGameSetting_Tooltips, 1); + SetGameSettings(iPad, eGameSetting_InterfaceOpacity, 80); - // TU 5 - SetGameSettings(iPad,eGameSetting_Clouds,1); - SetGameSettings(iPad,eGameSetting_Online,1); - SetGameSettings(iPad,eGameSetting_InviteOnly,0); - SetGameSettings(iPad,eGameSetting_FriendsOfFriends,1); + // TU 5 + SetGameSettings(iPad, eGameSetting_Clouds, 1); + SetGameSettings(iPad, eGameSetting_Online, 1); + SetGameSettings(iPad, eGameSetting_InviteOnly, 0); + SetGameSettings(iPad, eGameSetting_FriendsOfFriends, 1); - // default the update changes message to zero - // 4J-PB - We'll only display the message if the profile is pre-TU5 - //SetGameSettings(iPad,eGameSetting_DisplayUpdateMessage,0); + // default the update changes message to zero + // 4J-PB - We'll only display the message if the profile is pre-TU5 + // SetGameSettings(iPad,eGameSetting_DisplayUpdateMessage,0); - // TU 6 - SetGameSettings(iPad,eGameSetting_BedrockFog,0); - SetGameSettings(iPad,eGameSetting_DisplayHUD,1); - SetGameSettings(iPad,eGameSetting_DisplayHand,1); + // TU 6 + SetGameSettings(iPad, eGameSetting_BedrockFog, 0); + SetGameSettings(iPad, eGameSetting_DisplayHUD, 1); + SetGameSettings(iPad, eGameSetting_DisplayHand, 1); - // TU 7 - SetGameSettings(iPad,eGameSetting_CustomSkinAnim,1); + // TU 7 + SetGameSettings(iPad, eGameSetting_CustomSkinAnim, 1); - // TU 9 - SetGameSettings(iPad,eGameSetting_DeathMessages,1); - SetGameSettings(iPad,eGameSetting_UISize,1); - SetGameSettings(iPad,eGameSetting_UISizeSplitscreen,2); - SetGameSettings(iPad,eGameSetting_AnimatedCharacter,1); + // TU 9 + SetGameSettings(iPad, eGameSetting_DeathMessages, 1); + SetGameSettings(iPad, eGameSetting_UISize, 1); + SetGameSettings(iPad, eGameSetting_UISizeSplitscreen, 2); + SetGameSettings(iPad, eGameSetting_AnimatedCharacter, 1); - // TU 12 - GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=0; - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } + // TU 12 + GameSettingsA[iPad]->ucCurrentFavoriteSkinPos = 0; + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + GameSettingsA[iPad]->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } - // TU 13 - GameSettingsA[iPad]->uiMashUpPackWorldsDisplay=0xFFFFFFFF; + // TU 13 + GameSettingsA[iPad]->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // 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__ - // PS3DEC13 - SetGameSettings(iPad,eGameSetting_PS3_EULA_Read,0); // EULA not read + // 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__ + // PS3DEC13 + SetGameSettings(iPad, eGameSetting_PS3_EULA_Read, 0); // EULA not read - // PS3 1.05 - added Greek - GameSettingsA[iPad]->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language -//#endif + // PS3 1.05 - added Greek + GameSettingsA[iPad]->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // #endif -#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - GameSettingsA[iPad]->bSettingsChanged=bWriteProfile; +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + GameSettingsA[iPad]->bSettingsChanged = bWriteProfile; #endif - return 0; + return 0; } -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) -int CMinecraftApp::DefaultOptionsCallback(void *pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad) +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) +int CMinecraftApp::DefaultOptionsCallback( + void* pParam, C4JStorage::PROFILESETTINGS* pSettings, const int iPad) #else -int CMinecraftApp::DefaultOptionsCallback(void *pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad) +int CMinecraftApp::DefaultOptionsCallback( + void* pParam, C_4JProfile::PROFILESETTINGS* pSettings, const int iPad) #endif { - CMinecraftApp *pApp=(CMinecraftApp *)pParam; + CMinecraftApp* pApp = (CMinecraftApp*)pParam; - // flag the default options to be set + // flag the default options to be set - pApp->DebugPrintf("Setting default options for player %d", iPad); - pApp->SetAction(iPad,eAppAction_SetDefaultOptions, pSettings); - //pApp->SetDefaultOptions(pSettings,iPad); - - // if the profile data has been changed, then force a profile write - // It seems we're allowed to break the 5 minute rule if it's the result of a user action - //pApp->CheckGameSettingsChanged(); + pApp->DebugPrintf("Setting default options for player %d", iPad); + pApp->SetAction(iPad, eAppAction_SetDefaultOptions, pSettings); + // pApp->SetDefaultOptions(pSettings,iPad); - return 0; + // if the profile data has been changed, then force a profile write + // It seems we're allowed to break the 5 minute rule if it's the result of a + // user action + // pApp->CheckGameSettingsChanged(); + + return 0; } -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) #ifdef __ORBIS__ -int CMinecraftApp::OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired) -{ - CMinecraftApp *pApp=(CMinecraftApp *)pParam; - pApp->m_eOptionsStatusA[iPad]=eStatus; - pApp->m_eOptionsBlocksRequiredA[iPad]=iBlocksRequired; - return 0; +int CMinecraftApp::OptionsDataCallback(void* pParam, int iPad, + unsigned short usVersion, + C4JStorage::eOptionsCallback eStatus, + int iBlocksRequired) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + pApp->m_eOptionsStatusA[iPad] = eStatus; + pApp->m_eOptionsBlocksRequiredA[iPad] = iBlocksRequired; + return 0; } -int CMinecraftApp::GetOptionsBlocksRequired(int iPad) -{ - return m_eOptionsBlocksRequiredA[iPad]; +int CMinecraftApp::GetOptionsBlocksRequired(int iPad) { + return m_eOptionsBlocksRequiredA[iPad]; } #else -int CMinecraftApp::OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus) -{ - CMinecraftApp *pApp=(CMinecraftApp *)pParam; - pApp->m_eOptionsStatusA[iPad]=eStatus; - return 0; +int CMinecraftApp::OptionsDataCallback(void* pParam, int iPad, + unsigned short usVersion, + C4JStorage::eOptionsCallback eStatus) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + pApp->m_eOptionsStatusA[iPad] = eStatus; + return 0; } #endif -C4JStorage::eOptionsCallback CMinecraftApp::GetOptionsCallbackStatus(int iPad) -{ - return m_eOptionsStatusA[iPad]; +C4JStorage::eOptionsCallback CMinecraftApp::GetOptionsCallbackStatus(int iPad) { + return m_eOptionsStatusA[iPad]; } -void CMinecraftApp::SetOptionsCallbackStatus(int iPad, C4JStorage::eOptionsCallback eStatus) -{ - m_eOptionsStatusA[iPad]=eStatus; +void CMinecraftApp::SetOptionsCallbackStatus( + int iPad, C4JStorage::eOptionsCallback eStatus) { + m_eOptionsStatusA[iPad] = eStatus; } #endif -int CMinecraftApp::OldProfileVersionCallback(void *pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad) -{ - // check what needs to be done with this version to update to the current one +int CMinecraftApp::OldProfileVersionCallback(void* pParam, + unsigned char* pucData, + const unsigned short usVersion, + const int iPad) { + // check what needs to be done with this version to update to the current + // one - switch(usVersion) - { + switch (usVersion) { #ifdef _XBOX - case PROFILE_VERSION_1: - case PROFILE_VERSION_2: - // need to fill in values for the new profile data. No need to save the profile - that'll happen if they get changed, or if the auto save for the profile kicks in - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu - pGameSettings->ucInterfaceOpacity=80; //eGameSetting_Sensitivity_InMenu - pGameSettings->usBitmaskValues|=0x0200; //eGameSetting_DisplaySplitscreenGamertags - on - pGameSettings->usBitmaskValues|=0x0400; //eGameSetting_Hints - on - pGameSettings->usBitmaskValues|=0x1000; //eGameSetting_Autosave - 2 - pGameSettings->usBitmaskValues|=0x8000; //eGameSetting_Tooltips - on + case PROFILE_VERSION_1: + case PROFILE_VERSION_2: + // need to fill in values for the new profile data. No need to save + // the profile - that'll happen if they get changed, or if the auto + // save for the profile kicks in + { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; + pGameSettings->ucMenuSensitivity = + 100; // eGameSetting_Sensitivity_InMenu + pGameSettings->ucInterfaceOpacity = + 80; // eGameSetting_Sensitivity_InMenu + pGameSettings->usBitmaskValues |= + 0x0200; // eGameSetting_DisplaySplitscreenGamertags - on + pGameSettings->usBitmaskValues |= + 0x0400; // eGameSetting_Hints - on + pGameSettings->usBitmaskValues |= + 0x1000; // eGameSetting_Autosave - 2 + pGameSettings->usBitmaskValues |= + 0x8000; // eGameSetting_Tooltips - on - // 4J-PB - Let's also award all the achievements they have again because of the profile bug that seemed to stop the awards of some - // Changing this to check the system achievements at sign-in and award any that the game says we have and the system says we haven't - //ProfileManager.ReAwardAchievements(iPad); + // 4J-PB - Let's also award all the achievements they have again + // because of the profile bug that seemed to stop the awards of + // some Changing this to check the system achievements at + // sign-in and award any that the game says we have and the + // system says we haven't + // ProfileManager.ReAwardAchievements(iPad); - pGameSettings->uiBitmaskValues=0L; // reset - pGameSettings->uiBitmaskValues|=GAMESETTING_CLOUDS; //eGameSetting_Clouds - on - pGameSettings->uiBitmaskValues|=GAMESETTING_ONLINE; //eGameSetting_GameSetting_Online - on - //eGameSetting_GameSetting_Invite - off - pGameSettings->uiBitmaskValues|=GAMESETTING_FRIENDSOFFRIENDS; //eGameSetting_GameSetting_FriendsOfFriends - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) - // TU6 - pGameSettings->uiBitmaskValues&=~GAMESETTING_BEDROCKFOG; //eGameSetting_BedrockFog - off - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHUD; //eGameSetting_DisplayHUD - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHAND; //eGameSetting_DisplayHand - on - // TU7 - pGameSettings->uiBitmaskValues|=GAMESETTING_CUSTOMSKINANIM; //eGameSetting_CustomSkinAnim - on - // TU9 - pGameSettings->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE&0x00000800); // uisize 2 - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE_SPLITSCREEN&0x00004000); // splitscreen ui size 3 - pGameSettings->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + pGameSettings->uiBitmaskValues = 0L; // reset + pGameSettings->uiBitmaskValues |= + GAMESETTING_CLOUDS; // eGameSetting_Clouds - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on + // eGameSetting_GameSetting_Invite - + // off + pGameSettings->uiBitmaskValues |= + GAMESETTING_FRIENDSOFFRIENDS; // eGameSetting_GameSetting_FriendsOfFriends + // - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage + // (counter) + // TU6 + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_BEDROCKFOG; // eGameSetting_BedrockFog - off + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHUD; // eGameSetting_DisplayHUD - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHAND; // eGameSetting_DisplayHand - on + // TU7 + pGameSettings->uiBitmaskValues |= + GAMESETTING_CUSTOMSKINANIM; // eGameSetting_CustomSkinAnim + // - on + // TU9 + pGameSettings->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - + // on + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE & 0x00000800); // uisize 2 + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE_SPLITSCREEN & + 0x00004000); // splitscreen ui size 3 + pGameSettings->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter + // - on + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the + // Mash-up pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language - } - break; - case PROFILE_VERSION_3: + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language + } + break; + case PROFILE_VERSION_3: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - pGameSettings->uiBitmaskValues=0L; // reset - pGameSettings->uiBitmaskValues|=GAMESETTING_CLOUDS; //eGameSetting_Clouds - on - pGameSettings->uiBitmaskValues|=GAMESETTING_ONLINE; //eGameSetting_GameSetting_Online - on - //eGameSetting_GameSetting_Invite - off - pGameSettings->uiBitmaskValues|=GAMESETTING_FRIENDSOFFRIENDS; //eGameSetting_GameSetting_FriendsOfFriends - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) - // TU6 - pGameSettings->uiBitmaskValues&=~GAMESETTING_BEDROCKFOG; //eGameSetting_BedrockFog - off - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHUD; //eGameSetting_DisplayHUD - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHAND; //eGameSetting_DisplayHand - on - // TU7 - pGameSettings->uiBitmaskValues|=GAMESETTING_CUSTOMSKINANIM; //eGameSetting_CustomSkinAnim - on - // TU9 - pGameSettings->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE&0x00000800); // uisize 2 - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE_SPLITSCREEN&0x00004000); // splitscreen ui size 3 - pGameSettings->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; + pGameSettings->uiBitmaskValues = 0L; // reset + pGameSettings->uiBitmaskValues |= + GAMESETTING_CLOUDS; // eGameSetting_Clouds - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on + // eGameSetting_GameSetting_Invite - off + pGameSettings->uiBitmaskValues |= + GAMESETTING_FRIENDSOFFRIENDS; // eGameSetting_GameSetting_FriendsOfFriends + // - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage + // (counter) + // TU6 + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_BEDROCKFOG; // eGameSetting_BedrockFog - off + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHUD; // eGameSetting_DisplayHUD - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHAND; // eGameSetting_DisplayHand - on + // TU7 + pGameSettings->uiBitmaskValues |= + GAMESETTING_CUSTOMSKINANIM; // eGameSetting_CustomSkinAnim - on + // TU9 + pGameSettings->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - on + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE & 0x00000800); // uisize 2 + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE_SPLITSCREEN & + 0x00004000); // splitscreen ui size 3 + pGameSettings->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter + // - on + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language - } - break; - case PROFILE_VERSION_4: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - - pGameSettings->uiBitmaskValues&=~GAMESETTING_BEDROCKFOG; //eGameSetting_BedrockFog - off - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHUD; //eGameSetting_DisplayHUD - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHAND; //eGameSetting_DisplayHand - on - // TU7 - pGameSettings->uiBitmaskValues|=GAMESETTING_CUSTOMSKINANIM; //eGameSetting_CustomSkinAnim - on - // TU9 - pGameSettings->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE&0x00000800); // uisize 2 - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE_SPLITSCREEN&0x00004000); // splitscreen ui size 3 - pGameSettings->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on + } break; + case PROFILE_VERSION_4: { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; - // Set the online flag to on, so it's not saved if a game starts offline when the user didn't change it to be offline (xbox disconnected from LIVE) - pGameSettings->uiBitmaskValues|=GAMESETTING_ONLINE; //eGameSetting_GameSetting_Online - on - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_BEDROCKFOG; // eGameSetting_BedrockFog - off + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHUD; // eGameSetting_DisplayHUD - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHAND; // eGameSetting_DisplayHand - on + // TU7 + pGameSettings->uiBitmaskValues |= + GAMESETTING_CUSTOMSKINANIM; // eGameSetting_CustomSkinAnim - on + // TU9 + pGameSettings->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - on + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE & 0x00000800); // uisize 2 + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE_SPLITSCREEN & + 0x00004000); // splitscreen ui size 3 + pGameSettings->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter + // - on - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // Set the online flag to on, so it's not saved if a game starts + // offline when the user didn't change it to be offline (xbox + // disconnected from LIVE) + pGameSettings->uiBitmaskValues |= + GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - } + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language - break; - case PROFILE_VERSION_5: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; + } - // reset the display new message counter - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) - // TU7 - pGameSettings->uiBitmaskValues|=GAMESETTING_CUSTOMSKINANIM; //eGameSetting_CustomSkinAnim - on - // TU9 - pGameSettings->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE&0x00000800); // uisize 2 - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE_SPLITSCREEN&0x00004000); // splitscreen ui size 3 - pGameSettings->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on - // Set the online flag to on, so it's not saved if a game starts offline when the user didn't change it to be offline (xbox disconnected from LIVE) - pGameSettings->uiBitmaskValues|=GAMESETTING_ONLINE; //eGameSetting_GameSetting_Online - on - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + break; + case PROFILE_VERSION_5: { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // reset the display new message counter + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage + // (counter) + // TU7 + pGameSettings->uiBitmaskValues |= + GAMESETTING_CUSTOMSKINANIM; // eGameSetting_CustomSkinAnim - on + // TU9 + pGameSettings->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - on + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE & 0x00000800); // uisize 2 + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE_SPLITSCREEN & + 0x00004000); // splitscreen ui size 3 + pGameSettings->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter + // - on + // Set the online flag to on, so it's not saved if a game starts + // offline when the user didn't change it to be offline (xbox + // disconnected from LIVE) + pGameSettings->uiBitmaskValues |= + GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language - } + } - break; - case PROFILE_VERSION_6: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; + break; + case PROFILE_VERSION_6: { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; - // Added gui size for splitscreen and fullscreen - // Added death messages toggle + // Added gui size for splitscreen and fullscreen + // Added death messages toggle - // reset the display new message counter - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) - // TU9 - pGameSettings->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE&0x00000800); // uisize 2 - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE_SPLITSCREEN&0x00004000); // splitscreen ui size 3 - pGameSettings->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on - // Set the online flag to on, so it's not saved if a game starts offline when the user didn't change it to be offline (xbox disconnected from LIVE) - pGameSettings->uiBitmaskValues|=GAMESETTING_ONLINE; //eGameSetting_GameSetting_Online - on - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + // reset the display new message counter + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage + // (counter) + // TU9 + pGameSettings->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - on + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE & 0x00000800); // uisize 2 + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE_SPLITSCREEN & + 0x00004000); // splitscreen ui size 3 + pGameSettings->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter + // - on + // Set the online flag to on, so it's not saved if a game starts + // offline when the user didn't change it to be offline (xbox + // disconnected from LIVE) + pGameSettings->uiBitmaskValues |= + GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language + } - } + break; - break; + case PROFILE_VERSION_7: { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; + // reset the display new message counter + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage + // (counter) - case PROFILE_VERSION_7: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - // reset the display new message counter - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language - - - } - break; + } break; #endif - case PROFILE_VERSION_8: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - // reset the display new message counter - //pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) + case PROFILE_VERSION_8: { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; + // reset the display new message counter + // pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; + // //eGameSetting_DisplayUpdateMessage (counter) - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // PS3DEC13 - pGameSettings->uiBitmaskValues&=~GAMESETTING_PS3EULAREAD; //eGameSetting_PS3_EULA_Read - off + // PS3DEC13 + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_PS3EULAREAD; // eGameSetting_PS3_EULA_Read - off - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language - } - break; - case PROFILE_VERSION_9: - // PS3DEC13 - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - pGameSettings->uiBitmaskValues&=~GAMESETTING_PS3EULAREAD; //eGameSetting_PS3_EULA_Read - off - - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + } break; + case PROFILE_VERSION_9: + // PS3DEC13 + { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_PS3EULAREAD; // eGameSetting_PS3_EULA_Read - + // off - } - break; - case PROFILE_VERSION_10: - { - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language + } + break; + case PROFILE_VERSION_10: { + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language - } - break; + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language + } break; - default: - { - // This might be from a version during testing of new profile updates - app.DebugPrintf("Don't know what to do with this profile version!\n"); - #ifndef _CONTENT_PACKAGE - // __debugbreak(); - #endif + default: { + // This might be from a version during testing of new profile + // updates + app.DebugPrintf( + "Don't know what to do with this profile version!\n"); +#ifndef _CONTENT_PACKAGE +// __debugbreak(); +#endif - GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu - pGameSettings->ucInterfaceOpacity=80; //eGameSetting_Sensitivity_InMenu - pGameSettings->usBitmaskValues|=0x0200; //eGameSetting_DisplaySplitscreenGamertags - on - pGameSettings->usBitmaskValues|=0x0400; //eGameSetting_Hints - on - pGameSettings->usBitmaskValues|=0x1000; //eGameSetting_Autosave - 2 - pGameSettings->usBitmaskValues|=0x8000; //eGameSetting_Tooltips - on + GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)pucData; + pGameSettings->ucMenuSensitivity = + 100; // eGameSetting_Sensitivity_InMenu + pGameSettings->ucInterfaceOpacity = + 80; // eGameSetting_Sensitivity_InMenu + pGameSettings->usBitmaskValues |= + 0x0200; // eGameSetting_DisplaySplitscreenGamertags - on + pGameSettings->usBitmaskValues |= 0x0400; // eGameSetting_Hints - + // on + pGameSettings->usBitmaskValues |= + 0x1000; // eGameSetting_Autosave - 2 + pGameSettings->usBitmaskValues |= + 0x8000; // eGameSetting_Tooltips - on - pGameSettings->uiBitmaskValues=0L; // reset - pGameSettings->uiBitmaskValues|=GAMESETTING_CLOUDS; //eGameSetting_Clouds - on - pGameSettings->uiBitmaskValues|=GAMESETTING_ONLINE; //eGameSetting_GameSetting_Online - on - //eGameSetting_GameSetting_Invite - off - pGameSettings->uiBitmaskValues|=GAMESETTING_FRIENDSOFFRIENDS; //eGameSetting_GameSetting_FriendsOfFriends - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) - pGameSettings->uiBitmaskValues&=~GAMESETTING_BEDROCKFOG; //eGameSetting_BedrockFog - off - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHUD; //eGameSetting_DisplayHUD - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHAND; //eGameSetting_DisplayHand - on - pGameSettings->uiBitmaskValues|=GAMESETTING_CUSTOMSKINANIM; //eGameSetting_CustomSkinAnim - on - pGameSettings->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE&0x00000800); // uisize 2 - pGameSettings->uiBitmaskValues|=(GAMESETTING_UISIZE_SPLITSCREEN&0x00004000); // splitscreen ui size 3 - pGameSettings->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on - // TU12 - // favorite skins added, but only set in TU12 - set to FFs - for(int i=0;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } - pGameSettings->ucCurrentFavoriteSkinPos=0; - // Added a bitmask in TU13 to enable/disable display of the Mash-up pack worlds in the saves list - pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + pGameSettings->uiBitmaskValues = 0L; // reset + pGameSettings->uiBitmaskValues |= + GAMESETTING_CLOUDS; // eGameSetting_Clouds - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on + // eGameSetting_GameSetting_Invite - off + pGameSettings->uiBitmaskValues |= + GAMESETTING_FRIENDSOFFRIENDS; // eGameSetting_GameSetting_FriendsOfFriends + // - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage + // (counter) + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_BEDROCKFOG; // eGameSetting_BedrockFog - off + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHUD; // eGameSetting_DisplayHUD - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DISPLAYHAND; // eGameSetting_DisplayHand - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_CUSTOMSKINANIM; // eGameSetting_CustomSkinAnim - on + pGameSettings->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - on + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE & 0x00000800); // uisize 2 + pGameSettings->uiBitmaskValues |= + (GAMESETTING_UISIZE_SPLITSCREEN & + 0x00004000); // splitscreen ui size 3 + pGameSettings->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter + // - on + // TU12 + // favorite skins added, but only set in TU12 - set to FFs + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } + pGameSettings->ucCurrentFavoriteSkinPos = 0; + // Added a bitmask in TU13 to enable/disable display of the Mash-up + // pack worlds in the saves list + pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; - // PS3DEC13 - pGameSettings->uiBitmaskValues&=~GAMESETTING_PS3EULAREAD; //eGameSetting_PS3_EULA_Read - off + // PS3DEC13 + pGameSettings->uiBitmaskValues &= + ~GAMESETTING_PS3EULAREAD; // eGameSetting_PS3_EULA_Read - off - // PS3 1.05 - added Greek - pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language + // PS3 1.05 - added Greek + pGameSettings->ucLanguage = + MINECRAFT_LANGUAGE_DEFAULT; // use the system language - } - break; - } + } break; + } - return 0; + return 0; } -void CMinecraftApp::ApplyGameSettingsChanged(int iPad) -{ - ActionGameSettings(iPad,eGameSetting_MusicVolume ); - ActionGameSettings(iPad,eGameSetting_SoundFXVolume ); - ActionGameSettings(iPad,eGameSetting_Gamma ); - ActionGameSettings(iPad,eGameSetting_Difficulty ); - ActionGameSettings(iPad,eGameSetting_Sensitivity_InGame ); - ActionGameSettings(iPad,eGameSetting_ViewBob ); - ActionGameSettings(iPad,eGameSetting_ControlScheme ); - ActionGameSettings(iPad,eGameSetting_ControlInvertLook); - ActionGameSettings(iPad,eGameSetting_ControlSouthPaw); - ActionGameSettings(iPad,eGameSetting_SplitScreenVertical); - ActionGameSettings(iPad,eGameSetting_GamertagsVisible); +void CMinecraftApp::ApplyGameSettingsChanged(int iPad) { + ActionGameSettings(iPad, eGameSetting_MusicVolume); + ActionGameSettings(iPad, eGameSetting_SoundFXVolume); + ActionGameSettings(iPad, eGameSetting_Gamma); + ActionGameSettings(iPad, eGameSetting_Difficulty); + ActionGameSettings(iPad, eGameSetting_Sensitivity_InGame); + ActionGameSettings(iPad, eGameSetting_ViewBob); + ActionGameSettings(iPad, eGameSetting_ControlScheme); + ActionGameSettings(iPad, eGameSetting_ControlInvertLook); + ActionGameSettings(iPad, eGameSetting_ControlSouthPaw); + ActionGameSettings(iPad, eGameSetting_SplitScreenVertical); + ActionGameSettings(iPad, eGameSetting_GamertagsVisible); - // Interim TU 1.6.6 - ActionGameSettings(iPad,eGameSetting_Sensitivity_InMenu ); - ActionGameSettings(iPad,eGameSetting_DisplaySplitscreenGamertags); - ActionGameSettings(iPad,eGameSetting_Hints); - ActionGameSettings(iPad,eGameSetting_InterfaceOpacity); - ActionGameSettings(iPad,eGameSetting_Tooltips); + // Interim TU 1.6.6 + ActionGameSettings(iPad, eGameSetting_Sensitivity_InMenu); + ActionGameSettings(iPad, eGameSetting_DisplaySplitscreenGamertags); + ActionGameSettings(iPad, eGameSetting_Hints); + ActionGameSettings(iPad, eGameSetting_InterfaceOpacity); + ActionGameSettings(iPad, eGameSetting_Tooltips); - ActionGameSettings(iPad,eGameSetting_Clouds); - ActionGameSettings(iPad,eGameSetting_BedrockFog); - ActionGameSettings(iPad,eGameSetting_DisplayHUD); - ActionGameSettings(iPad,eGameSetting_DisplayHand); - ActionGameSettings(iPad,eGameSetting_CustomSkinAnim); - ActionGameSettings(iPad,eGameSetting_DeathMessages); - ActionGameSettings(iPad,eGameSetting_UISize); - ActionGameSettings(iPad,eGameSetting_UISizeSplitscreen); - ActionGameSettings(iPad,eGameSetting_AnimatedCharacter); - - ActionGameSettings(iPad,eGameSetting_PS3_EULA_Read); + ActionGameSettings(iPad, eGameSetting_Clouds); + ActionGameSettings(iPad, eGameSetting_BedrockFog); + ActionGameSettings(iPad, eGameSetting_DisplayHUD); + ActionGameSettings(iPad, eGameSetting_DisplayHand); + ActionGameSettings(iPad, eGameSetting_CustomSkinAnim); + ActionGameSettings(iPad, eGameSetting_DeathMessages); + ActionGameSettings(iPad, eGameSetting_UISize); + ActionGameSettings(iPad, eGameSetting_UISizeSplitscreen); + ActionGameSettings(iPad, eGameSetting_AnimatedCharacter); + ActionGameSettings(iPad, eGameSetting_PS3_EULA_Read); } -void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) -{ - Minecraft *pMinecraft=Minecraft::GetInstance(); - switch(eVal) - { - case eGameSetting_MusicVolume: - if(iPad==ProfileManager.GetPrimaryPad()) - { - pMinecraft->options->set(Options::Option::MUSIC,((float)GameSettingsA[iPad]->ucMusicVolume)/100.0f); - } - break; - case eGameSetting_SoundFXVolume: - if(iPad==ProfileManager.GetPrimaryPad()) - { - pMinecraft->options->set(Options::Option::SOUND,((float)GameSettingsA[iPad]->ucSoundFXVolume)/100.0f); - } - break; - case eGameSetting_Gamma: - if(iPad==ProfileManager.GetPrimaryPad()) - { - // ucGamma range is 0-100, UpdateGamma is 0 - 32768 - float fVal=((float)GameSettingsA[iPad]->ucGamma)*327.68f; - RenderManager.UpdateGamma((unsigned short)fVal); - } +void CMinecraftApp::ActionGameSettings(int iPad, eGameSetting eVal) { + Minecraft* pMinecraft = Minecraft::GetInstance(); + switch (eVal) { + case eGameSetting_MusicVolume: + if (iPad == ProfileManager.GetPrimaryPad()) { + pMinecraft->options->set( + Options::Option::MUSIC, + ((float)GameSettingsA[iPad]->ucMusicVolume) / 100.0f); + } + break; + case eGameSetting_SoundFXVolume: + if (iPad == ProfileManager.GetPrimaryPad()) { + pMinecraft->options->set( + Options::Option::SOUND, + ((float)GameSettingsA[iPad]->ucSoundFXVolume) / 100.0f); + } + break; + case eGameSetting_Gamma: + if (iPad == ProfileManager.GetPrimaryPad()) { + // ucGamma range is 0-100, UpdateGamma is 0 - 32768 + float fVal = ((float)GameSettingsA[iPad]->ucGamma) * 327.68f; + RenderManager.UpdateGamma((unsigned short)fVal); + } - break; - case eGameSetting_Difficulty: - if(iPad==ProfileManager.GetPrimaryPad()) - { - pMinecraft->options->toggle(Options::Option::DIFFICULTY,GameSettingsA[iPad]->usBitmaskValues&0x03); - app.DebugPrintf("Difficulty toggle to %d\n",GameSettingsA[iPad]->usBitmaskValues&0x03); + break; + case eGameSetting_Difficulty: + if (iPad == ProfileManager.GetPrimaryPad()) { + pMinecraft->options->toggle( + Options::Option::DIFFICULTY, + GameSettingsA[iPad]->usBitmaskValues & 0x03); + app.DebugPrintf("Difficulty toggle to %d\n", + GameSettingsA[iPad]->usBitmaskValues & 0x03); - // Update the Game Host setting - app.SetGameHostOption(eGameHostOption_Difficulty,pMinecraft->options->difficulty); + // Update the Game Host setting + app.SetGameHostOption(eGameHostOption_Difficulty, + pMinecraft->options->difficulty); - // send this to the other players if we are in-game - bool bInGame=pMinecraft->level!=NULL; + // send this to the other players if we are in-game + bool bInGame = pMinecraft->level != NULL; - // Game Host only (and for now we can't change the diff while in game, so this shouldn't happen) - if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) - { - app.SetXuiServerAction(iPad,eXuiServerAction_ServerSettingChanged_Difficulty); - } - } - else - { - app.DebugPrintf("NOT ACTIONING DIFFICULTY - Primary pad is %d, This pad is %d\n",ProfileManager.GetPrimaryPad(),iPad); - } - - break; - case eGameSetting_Sensitivity_InGame: - // 4J-PB - we don't use the options value - // tell the input that we've changed the sensitivity - range of the slider is 0 to 200, default is 100 - pMinecraft->options->set(Options::Option::SENSITIVITY,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); - //InputManager.SetJoypadSensitivity(iPad,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); + // Game Host only (and for now we can't change the diff while in + // game, so this shouldn't happen) + if (bInGame && g_NetworkManager.IsHost() && + (iPad == ProfileManager.GetPrimaryPad())) { + app.SetXuiServerAction( + iPad, eXuiServerAction_ServerSettingChanged_Difficulty); + } + } else { + app.DebugPrintf( + "NOT ACTIONING DIFFICULTY - Primary pad is %d, This pad is " + "%d\n", + ProfileManager.GetPrimaryPad(), iPad); + } - break; - case eGameSetting_ViewBob: - // 4J-PB - not handled here any more - it's read from the gamesettings per player - //pMinecraft->options->toggle(Options::Option::VIEW_BOBBING,GameSettingsA[iPad]->usBitmaskValues&0x04); - break; - case eGameSetting_ControlScheme: - InputManager.SetJoypadMapVal(iPad,(GameSettingsA[iPad]->usBitmaskValues&0x30)>>4); - break; + break; + case eGameSetting_Sensitivity_InGame: + // 4J-PB - we don't use the options value + // tell the input that we've changed the sensitivity - range of the + // slider is 0 to 200, default is 100 + pMinecraft->options->set( + Options::Option::SENSITIVITY, + ((float)GameSettingsA[iPad]->ucSensitivity) / 100.0f); + // InputManager.SetJoypadSensitivity(iPad,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); - case eGameSetting_ControlInvertLook: - // Nothing specific to do for this setting. - break; + break; + case eGameSetting_ViewBob: + // 4J-PB - not handled here any more - it's read from the + // gamesettings per player + // pMinecraft->options->toggle(Options::Option::VIEW_BOBBING,GameSettingsA[iPad]->usBitmaskValues&0x04); + break; + case eGameSetting_ControlScheme: + InputManager.SetJoypadMapVal( + iPad, (GameSettingsA[iPad]->usBitmaskValues & 0x30) >> 4); + break; - case eGameSetting_ControlSouthPaw: - // What is the setting? - if ( GameSettingsA[iPad]->usBitmaskValues & 0x80 ) - { - // Southpaw. - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_LX, AXIS_MAP_RX ); - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_LY, AXIS_MAP_RY ); - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_RX, AXIS_MAP_LX ); - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_RY, AXIS_MAP_LY ); - InputManager.SetJoypadStickTriggerMap( iPad, TRIGGER_MAP_0, TRIGGER_MAP_1 ); - InputManager.SetJoypadStickTriggerMap( iPad, TRIGGER_MAP_1, TRIGGER_MAP_0 ); - } - else - { - // Right handed. - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_LX, AXIS_MAP_LX ); - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_LY, AXIS_MAP_LY ); - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_RX, AXIS_MAP_RX ); - InputManager.SetJoypadStickAxisMap( iPad, AXIS_MAP_RY, AXIS_MAP_RY ); - InputManager.SetJoypadStickTriggerMap( iPad, TRIGGER_MAP_0, TRIGGER_MAP_0 ); - InputManager.SetJoypadStickTriggerMap( iPad, TRIGGER_MAP_1, TRIGGER_MAP_1 ); - } - break; - case eGameSetting_SplitScreenVertical: - if(iPad==ProfileManager.GetPrimaryPad()) - { - pMinecraft->updatePlayerViewportAssignments(); - } - break; - case eGameSetting_GamertagsVisible: - { - bool bInGame=pMinecraft->level!=NULL; + case eGameSetting_ControlInvertLook: + // Nothing specific to do for this setting. + break; - // Game Host only - if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) - { - // Update the Game Host setting if you are the host and you are in-game - app.SetGameHostOption(eGameHostOption_Gamertags,((GameSettingsA[iPad]->usBitmaskValues&0x0008)!=0)?1:0); - app.SetXuiServerAction(iPad,eXuiServerAction_ServerSettingChanged_Gamertags); + case eGameSetting_ControlSouthPaw: + // What is the setting? + if (GameSettingsA[iPad]->usBitmaskValues & 0x80) { + // Southpaw. + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_LX, + AXIS_MAP_RX); + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_LY, + AXIS_MAP_RY); + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_RX, + AXIS_MAP_LX); + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_RY, + AXIS_MAP_LY); + InputManager.SetJoypadStickTriggerMap(iPad, TRIGGER_MAP_0, + TRIGGER_MAP_1); + InputManager.SetJoypadStickTriggerMap(iPad, TRIGGER_MAP_1, + TRIGGER_MAP_0); + } else { + // Right handed. + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_LX, + AXIS_MAP_LX); + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_LY, + AXIS_MAP_LY); + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_RX, + AXIS_MAP_RX); + InputManager.SetJoypadStickAxisMap(iPad, AXIS_MAP_RY, + AXIS_MAP_RY); + InputManager.SetJoypadStickTriggerMap(iPad, TRIGGER_MAP_0, + TRIGGER_MAP_0); + InputManager.SetJoypadStickTriggerMap(iPad, TRIGGER_MAP_1, + TRIGGER_MAP_1); + } + break; + case eGameSetting_SplitScreenVertical: + if (iPad == ProfileManager.GetPrimaryPad()) { + pMinecraft->updatePlayerViewportAssignments(); + } + break; + case eGameSetting_GamertagsVisible: { + bool bInGame = pMinecraft->level != NULL; - PlayerList *players = MinecraftServer::getInstance()->getPlayerList(); - for(AUTO_VAR(it3, players->players.begin()); it3 != players->players.end(); ++it3) - { - std::shared_ptr decorationPlayer = *it3; - decorationPlayer->setShowOnMaps((app.GetGameHostOption(eGameHostOption_Gamertags)!=0)?true:false); - } - } - } - break; -// Interim TU 1.6.6 - case eGameSetting_Sensitivity_InMenu: - // 4J-PB - we don't use the options value - // tell the input that we've changed the sensitivity - range of the slider is 0 to 200, default is 100 - //pMinecraft->options->set(Options::Option::SENSITIVITY,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); - //InputManager.SetJoypadSensitivity(iPad,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); + // Game Host only + if (bInGame && g_NetworkManager.IsHost() && + (iPad == ProfileManager.GetPrimaryPad())) { + // Update the Game Host setting if you are the host and you are + // in-game + app.SetGameHostOption( + eGameHostOption_Gamertags, + ((GameSettingsA[iPad]->usBitmaskValues & 0x0008) != 0) ? 1 + : 0); + app.SetXuiServerAction( + iPad, eXuiServerAction_ServerSettingChanged_Gamertags); - break; + PlayerList* players = + MinecraftServer::getInstance()->getPlayerList(); + for (AUTO_VAR(it3, players->players.begin()); + it3 != players->players.end(); ++it3) { + std::shared_ptr decorationPlayer = *it3; + decorationPlayer->setShowOnMaps( + (app.GetGameHostOption(eGameHostOption_Gamertags) != 0) + ? true + : false); + } + } + } break; + // Interim TU 1.6.6 + case eGameSetting_Sensitivity_InMenu: + // 4J-PB - we don't use the options value + // tell the input that we've changed the sensitivity - range of the + // slider is 0 to 200, default is 100 + // pMinecraft->options->set(Options::Option::SENSITIVITY,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); + // InputManager.SetJoypadSensitivity(iPad,((float)GameSettingsA[iPad]->ucSensitivity)/100.0f); - case eGameSetting_DisplaySplitscreenGamertags: - for(std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) - { - if(pMinecraft->localplayers[idx] != NULL) - { - if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN) - { - ui.DisplayGamertag(idx,false); - } - else - { - ui.DisplayGamertag(idx,true); - } - } - } + break; - break; - case eGameSetting_InterfaceOpacity: - // update the tooltips display - ui.RefreshTooltips( iPad); + case eGameSetting_DisplaySplitscreenGamertags: + for (std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { + if (pMinecraft->localplayers[idx] != NULL) { + if (pMinecraft->localplayers[idx]->m_iScreenSection == + C4JRender::VIEWPORT_TYPE_FULLSCREEN) { + ui.DisplayGamertag(idx, false); + } else { + ui.DisplayGamertag(idx, true); + } + } + } - break; - case eGameSetting_Hints: - //nothing to do here - break; - case eGameSetting_Tooltips: - if((GameSettingsA[iPad]->usBitmaskValues&0x8000)!=0) - { - ui.SetEnableTooltips(iPad, true); - } - else - { - ui.SetEnableTooltips(iPad, false); - } - break; - case eGameSetting_Clouds: - //nothing to do here - break; - case eGameSetting_Online: - //nothing to do here - break; - case eGameSetting_InviteOnly: - //nothing to do here - break; - case eGameSetting_FriendsOfFriends: - //nothing to do here - break; - case eGameSetting_BedrockFog: - { - bool bInGame=pMinecraft->level!=NULL; + break; + case eGameSetting_InterfaceOpacity: + // update the tooltips display + ui.RefreshTooltips(iPad); - // Game Host only - if(bInGame && g_NetworkManager.IsHost() && (iPad==ProfileManager.GetPrimaryPad())) - { - // Update the Game Host setting if you are the host and you are in-game - app.SetGameHostOption(eGameHostOption_BedrockFog,GetGameSettings(iPad,eGameSetting_BedrockFog)?1:0); - app.SetXuiServerAction(iPad,eXuiServerAction_ServerSettingChanged_BedrockFog); - } - } - break; - case eGameSetting_DisplayHUD: - //nothing to do here - break; - case eGameSetting_DisplayHand: - //nothing to do here - break; - case eGameSetting_CustomSkinAnim: - //nothing to do here - break; - case eGameSetting_DeathMessages: - //nothing to do here - break; - case eGameSetting_UISize: - //nothing to do here - break; - case eGameSetting_UISizeSplitscreen: - //nothing to do here - break; - case eGameSetting_AnimatedCharacter: - //nothing to do here - break; - case eGameSetting_PS3_EULA_Read: - //nothing to do here - break; - case eGameSetting_PSVita_NetworkModeAdhoc: - //nothing to do here - break; - default: - break; - } + break; + case eGameSetting_Hints: + // nothing to do here + break; + case eGameSetting_Tooltips: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x8000) != 0) { + ui.SetEnableTooltips(iPad, true); + } else { + ui.SetEnableTooltips(iPad, false); + } + break; + case eGameSetting_Clouds: + // nothing to do here + break; + case eGameSetting_Online: + // nothing to do here + break; + case eGameSetting_InviteOnly: + // nothing to do here + break; + case eGameSetting_FriendsOfFriends: + // nothing to do here + break; + case eGameSetting_BedrockFog: { + bool bInGame = pMinecraft->level != NULL; + + // Game Host only + if (bInGame && g_NetworkManager.IsHost() && + (iPad == ProfileManager.GetPrimaryPad())) { + // Update the Game Host setting if you are the host and you are + // in-game + app.SetGameHostOption( + eGameHostOption_BedrockFog, + GetGameSettings(iPad, eGameSetting_BedrockFog) ? 1 : 0); + app.SetXuiServerAction( + iPad, eXuiServerAction_ServerSettingChanged_BedrockFog); + } + } break; + case eGameSetting_DisplayHUD: + // nothing to do here + break; + case eGameSetting_DisplayHand: + // nothing to do here + break; + case eGameSetting_CustomSkinAnim: + // nothing to do here + break; + case eGameSetting_DeathMessages: + // nothing to do here + break; + case eGameSetting_UISize: + // nothing to do here + break; + case eGameSetting_UISizeSplitscreen: + // nothing to do here + break; + case eGameSetting_AnimatedCharacter: + // nothing to do here + break; + case eGameSetting_PS3_EULA_Read: + // nothing to do here + break; + case eGameSetting_PSVita_NetworkModeAdhoc: + // nothing to do here + break; + default: + break; + } } -void CMinecraftApp::SetPlayerSkin(int iPad,const std::wstring &name) -{ - std::uint32_t skinId = app.getSkinIdFromPath(name); +void CMinecraftApp::SetPlayerSkin(int iPad, const std::wstring& name) { + std::uint32_t skinId = app.getSkinIdFromPath(name); - SetPlayerSkin(iPad,skinId); + SetPlayerSkin(iPad, skinId); } -void CMinecraftApp::SetPlayerSkin(int iPad,std::uint32_t dwSkinId) -{ - DebugPrintf("Setting skin for %d to %08X\n", iPad, dwSkinId); +void CMinecraftApp::SetPlayerSkin(int iPad, std::uint32_t dwSkinId) { + DebugPrintf("Setting skin for %d to %08X\n", iPad, dwSkinId); - GameSettingsA[iPad]->dwSelectedSkin = dwSkinId; - GameSettingsA[iPad]->bSettingsChanged = true; + GameSettingsA[iPad]->dwSelectedSkin = dwSkinId; + GameSettingsA[iPad]->bSettingsChanged = true; - TelemetryManager->RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); + TelemetryManager->RecordSkinChanged(iPad, + GameSettingsA[iPad]->dwSelectedSkin); - if(Minecraft::GetInstance()->localplayers[iPad]!=NULL) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(dwSkinId); + if (Minecraft::GetInstance()->localplayers[iPad] != NULL) + Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin( + dwSkinId); } - -std::wstring CMinecraftApp::GetPlayerSkinName(int iPad) -{ - return app.getSkinPathFromId(GameSettingsA[iPad]->dwSelectedSkin); +std::wstring CMinecraftApp::GetPlayerSkinName(int iPad) { + return app.getSkinPathFromId(GameSettingsA[iPad]->dwSelectedSkin); } -std::uint32_t CMinecraftApp::GetPlayerSkinId(int iPad) -{ - // 4J-PB -check the user has rights to use this skin - they may have had at some point but the entitlement has been removed. - DLCPack *Pack=NULL; - DLCSkinFile *skinFile=NULL; - std::uint32_t dwSkin=GameSettingsA[iPad]->dwSelectedSkin; - wchar_t chars[256]; +std::uint32_t CMinecraftApp::GetPlayerSkinId(int iPad) { + // 4J-PB -check the user has rights to use this skin - they may have had at + // some point but the entitlement has been removed. + DLCPack* Pack = NULL; + DLCSkinFile* skinFile = NULL; + std::uint32_t dwSkin = GameSettingsA[iPad]->dwSelectedSkin; + wchar_t chars[256]; - if( GET_IS_DLC_SKIN_FROM_BITMASK(dwSkin) ) - { - // 4J Stu - DLC skins are numbered using decimal rather than hex to make it easier to number manually - swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(dwSkin)); - - Pack=app.m_dlcManager.getPackContainingSkin(chars); + if (GET_IS_DLC_SKIN_FROM_BITMASK(dwSkin)) { + // 4J Stu - DLC skins are numbered using decimal rather than hex to make + // it easier to number manually + swprintf(chars, 256, L"dlcskin%08d.png", + GET_DLC_SKIN_ID_FROM_BITMASK(dwSkin)); - if(Pack) - { - skinFile = Pack->getSkinFile(chars); + Pack = app.m_dlcManager.getPackContainingSkin(chars); - bool bSkinIsFree = skinFile->getParameterAsBool( DLCManager::e_DLCParamType_Free ); - bool bLicensed = Pack->hasPurchasedFile( DLCManager::e_DLCType_Skin, skinFile->getPath() ); + if (Pack) { + skinFile = Pack->getSkinFile(chars); - if(bSkinIsFree || bLicensed) - { - return dwSkin; - } - else - { - return 0; - } - } - } + bool bSkinIsFree = + skinFile->getParameterAsBool(DLCManager::e_DLCParamType_Free); + bool bLicensed = Pack->hasPurchasedFile(DLCManager::e_DLCType_Skin, + skinFile->getPath()); + if (bSkinIsFree || bLicensed) { + return dwSkin; + } else { + return 0; + } + } + } - return dwSkin; + return dwSkin; } - std::uint32_t CMinecraftApp::GetAdditionalModelParts(int iPad) - { - return m_dwAdditionalModelParts[iPad]; - } - - -void CMinecraftApp::SetPlayerCape(int iPad,const std::wstring &name) -{ - std::uint32_t capeId = Player::getCapeIdFromPath(name); - - SetPlayerCape(iPad,capeId); +std::uint32_t CMinecraftApp::GetAdditionalModelParts(int iPad) { + return m_dwAdditionalModelParts[iPad]; } -void CMinecraftApp::SetPlayerCape(int iPad,std::uint32_t dwCapeId) -{ - DebugPrintf("Setting cape for %d to %08X\n", iPad, dwCapeId); +void CMinecraftApp::SetPlayerCape(int iPad, const std::wstring& name) { + std::uint32_t capeId = Player::getCapeIdFromPath(name); - GameSettingsA[iPad]->dwSelectedCape = dwCapeId; - GameSettingsA[iPad]->bSettingsChanged = true; - - //SentientManager.RecordSkinChanged(iPad, GameSettingsA[iPad]->dwSelectedSkin); - - if(Minecraft::GetInstance()->localplayers[iPad]!=NULL) Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(dwCapeId); + SetPlayerCape(iPad, capeId); } -std::wstring CMinecraftApp::GetPlayerCapeName(int iPad) -{ - return Player::getCapePathFromId(GameSettingsA[iPad]->dwSelectedCape); +void CMinecraftApp::SetPlayerCape(int iPad, std::uint32_t dwCapeId) { + DebugPrintf("Setting cape for %d to %08X\n", iPad, dwCapeId); + + GameSettingsA[iPad]->dwSelectedCape = dwCapeId; + GameSettingsA[iPad]->bSettingsChanged = true; + + // SentientManager.RecordSkinChanged(iPad, + // GameSettingsA[iPad]->dwSelectedSkin); + + if (Minecraft::GetInstance()->localplayers[iPad] != NULL) + Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape( + dwCapeId); } -std::uint32_t CMinecraftApp::GetPlayerCapeId(int iPad) -{ - return GameSettingsA[iPad]->dwSelectedCape; +std::wstring CMinecraftApp::GetPlayerCapeName(int iPad) { + return Player::getCapePathFromId(GameSettingsA[iPad]->dwSelectedCape); } -void CMinecraftApp::SetPlayerFavoriteSkin(int iPad, int iIndex,unsigned int uiSkinID) -{ - DebugPrintf("Setting favorite skin for %d to %08X\n", iPad, uiSkinID); - - GameSettingsA[iPad]->uiFavoriteSkinA[iIndex] = uiSkinID; - GameSettingsA[iPad]->bSettingsChanged = true; +std::uint32_t CMinecraftApp::GetPlayerCapeId(int iPad) { + return GameSettingsA[iPad]->dwSelectedCape; } -unsigned int CMinecraftApp::GetPlayerFavoriteSkin(int iPad,int iIndex) -{ - return GameSettingsA[iPad]->uiFavoriteSkinA[iIndex]; +void CMinecraftApp::SetPlayerFavoriteSkin(int iPad, int iIndex, + unsigned int uiSkinID) { + DebugPrintf("Setting favorite skin for %d to %08X\n", iPad, uiSkinID); + + GameSettingsA[iPad]->uiFavoriteSkinA[iIndex] = uiSkinID; + GameSettingsA[iPad]->bSettingsChanged = true; } -unsigned char CMinecraftApp::GetPlayerFavoriteSkinsPos(int iPad) -{ - return GameSettingsA[iPad]->ucCurrentFavoriteSkinPos; +unsigned int CMinecraftApp::GetPlayerFavoriteSkin(int iPad, int iIndex) { + return GameSettingsA[iPad]->uiFavoriteSkinA[iIndex]; } -void CMinecraftApp::SetPlayerFavoriteSkinsPos(int iPad, int iPos) -{ - GameSettingsA[iPad]->ucCurrentFavoriteSkinPos=(unsigned char)iPos; - GameSettingsA[iPad]->bSettingsChanged = true; +unsigned char CMinecraftApp::GetPlayerFavoriteSkinsPos(int iPad) { + return GameSettingsA[iPad]->ucCurrentFavoriteSkinPos; } -unsigned int CMinecraftApp::GetPlayerFavoriteSkinsCount(int iPad) -{ - unsigned int uiCount=0; - for(int i=0;iuiFavoriteSkinA[i]!=0xFFFFFFFF) - { - uiCount++; - } - else - { - break; - } - } - return uiCount; +void CMinecraftApp::SetPlayerFavoriteSkinsPos(int iPad, int iPos) { + GameSettingsA[iPad]->ucCurrentFavoriteSkinPos = (unsigned char)iPos; + GameSettingsA[iPad]->bSettingsChanged = true; } -void CMinecraftApp::ValidateFavoriteSkins(int iPad) -{ - unsigned int uiCount=GetPlayerFavoriteSkinsCount(iPad); - - // remove invalid skins - unsigned int uiValidSkin=0; - wchar_t chars[256]; +unsigned int CMinecraftApp::GetPlayerFavoriteSkinsCount(int iPad) { + unsigned int uiCount = 0; + for (int i = 0; i < MAX_FAVORITE_SKINS; i++) { + if (GameSettingsA[iPad]->uiFavoriteSkinA[i] != 0xFFFFFFFF) { + uiCount++; + } else { + break; + } + } + return uiCount; +} - for(unsigned int i=0;igetFile(DLCManager::e_DLCType_Skin,chars); - DLCSkinFile *pSkinFile = pDLCPack->getSkinFile(chars); + for (unsigned int i = 0; i < uiCount; i++) { + // get the pack number from the skin id + swprintf(chars, 256, L"dlcskin%08d.png", + app.GetPlayerFavoriteSkin(iPad, i)); - if( pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") || (pSkinFile && pSkinFile->isFree())) - { - GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=GameSettingsA[iPad]->uiFavoriteSkinA[i]; - } - } - } + // Also check they haven't reverted to a trial pack + DLCPack* pDLCPack = app.m_dlcManager.getPackContainingSkin(chars); - for(unsigned int i=uiValidSkin;iuiFavoriteSkinA[i]=0xFFFFFFFF; - } + if (pDLCPack != NULL) { + // 4J-PB - We should let players add the free skins to their + // favourites as well! + // DLCFile + // *pDLCFile=pDLCPack->getFile(DLCManager::e_DLCType_Skin,chars); + DLCSkinFile* pSkinFile = pDLCPack->getSkinFile(chars); + + if (pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") || + (pSkinFile && pSkinFile->isFree())) { + GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++] = + GameSettingsA[iPad]->uiFavoriteSkinA[i]; + } + } + } + + for (unsigned int i = uiValidSkin; i < MAX_FAVORITE_SKINS; i++) { + GameSettingsA[iPad]->uiFavoriteSkinA[i] = 0xFFFFFFFF; + } } // Mash-up pack worlds -void CMinecraftApp::HideMashupPackWorld(int iPad, unsigned int iMashupPackID) -{ - unsigned int uiPackID=iMashupPackID - 1024; // mash-up ids start at 1024 - GameSettingsA[iPad]->uiMashUpPackWorldsDisplay&=~(1<bSettingsChanged = true; +void CMinecraftApp::HideMashupPackWorld(int iPad, unsigned int iMashupPackID) { + unsigned int uiPackID = iMashupPackID - 1024; // mash-up ids start at 1024 + GameSettingsA[iPad]->uiMashUpPackWorldsDisplay &= ~(1 << uiPackID); + GameSettingsA[iPad]->bSettingsChanged = true; } -void CMinecraftApp::SetMinecraftLanguage(int iPad, unsigned char ucLanguage) -{ - GameSettingsA[iPad]->ucLanguage = ucLanguage; - GameSettingsA[iPad]->bSettingsChanged = true; +void CMinecraftApp::SetMinecraftLanguage(int iPad, unsigned char ucLanguage) { + GameSettingsA[iPad]->ucLanguage = ucLanguage; + GameSettingsA[iPad]->bSettingsChanged = true; } -void CMinecraftApp::EnableMashupPackWorlds(int iPad) -{ - GameSettingsA[iPad]->uiMashUpPackWorldsDisplay=0xFFFFFFFF; - GameSettingsA[iPad]->bSettingsChanged = true; +void CMinecraftApp::EnableMashupPackWorlds(int iPad) { + GameSettingsA[iPad]->uiMashUpPackWorldsDisplay = 0xFFFFFFFF; + GameSettingsA[iPad]->bSettingsChanged = true; } -unsigned int CMinecraftApp::GetMashupPackWorlds(int iPad) -{ - return GameSettingsA[iPad]->uiMashUpPackWorldsDisplay; +unsigned int CMinecraftApp::GetMashupPackWorlds(int iPad) { + return GameSettingsA[iPad]->uiMashUpPackWorldsDisplay; } -unsigned char CMinecraftApp::GetMinecraftLanguage(int iPad) -{ - // if there are no game settings read yet, return the default language - if(GameSettingsA[iPad]==NULL) - { - return 0; - } - else - { - return GameSettingsA[iPad]->ucLanguage; - } +unsigned char CMinecraftApp::GetMinecraftLanguage(int iPad) { + // if there are no game settings read yet, return the default language + if (GameSettingsA[iPad] == NULL) { + return 0; + } else { + return GameSettingsA[iPad]->ucLanguage; + } } -void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucVal) -{ - //Minecraft *pMinecraft=Minecraft::GetInstance(); +void CMinecraftApp::SetGameSettings(int iPad, eGameSetting eVal, + unsigned char ucVal) { + // Minecraft *pMinecraft=Minecraft::GetInstance(); - switch(eVal) - { - case eGameSetting_MusicVolume: - if(GameSettingsA[iPad]->ucMusicVolume!=ucVal) - { - GameSettingsA[iPad]->ucMusicVolume=ucVal; - if(iPad==ProfileManager.GetPrimaryPad()) - { - ActionGameSettings(iPad,eVal); - } - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_SoundFXVolume: - if(GameSettingsA[iPad]->ucSoundFXVolume!=ucVal) - { - GameSettingsA[iPad]->ucSoundFXVolume=ucVal; - if(iPad==ProfileManager.GetPrimaryPad()) - { - ActionGameSettings(iPad,eVal); - } - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_Gamma: - if(GameSettingsA[iPad]->ucGamma!=ucVal) - { - GameSettingsA[iPad]->ucGamma=ucVal; - if(iPad==ProfileManager.GetPrimaryPad()) - { - ActionGameSettings(iPad,eVal); - } - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_Difficulty: - if((GameSettingsA[iPad]->usBitmaskValues&0x03)!=(ucVal&0x03)) - { - GameSettingsA[iPad]->usBitmaskValues&=~0x03; - GameSettingsA[iPad]->usBitmaskValues|=ucVal&0x03; - if(iPad==ProfileManager.GetPrimaryPad()) - { - ActionGameSettings(iPad,eVal); - } - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_Sensitivity_InGame: - if(GameSettingsA[iPad]->ucSensitivity!=ucVal) - { - GameSettingsA[iPad]->ucSensitivity=ucVal; - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_ViewBob: - if((GameSettingsA[iPad]->usBitmaskValues&0x0004)!=((ucVal&0x01)<<2)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0004; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0004; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_ControlScheme: // bits 5 and 6 - if((GameSettingsA[iPad]->usBitmaskValues&0x30)!=((ucVal&0x03)<<4)) - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0030; - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=(ucVal&0x03)<<4; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + switch (eVal) { + case eGameSetting_MusicVolume: + if (GameSettingsA[iPad]->ucMusicVolume != ucVal) { + GameSettingsA[iPad]->ucMusicVolume = ucVal; + if (iPad == ProfileManager.GetPrimaryPad()) { + ActionGameSettings(iPad, eVal); + } + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_SoundFXVolume: + if (GameSettingsA[iPad]->ucSoundFXVolume != ucVal) { + GameSettingsA[iPad]->ucSoundFXVolume = ucVal; + if (iPad == ProfileManager.GetPrimaryPad()) { + ActionGameSettings(iPad, eVal); + } + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_Gamma: + if (GameSettingsA[iPad]->ucGamma != ucVal) { + GameSettingsA[iPad]->ucGamma = ucVal; + if (iPad == ProfileManager.GetPrimaryPad()) { + ActionGameSettings(iPad, eVal); + } + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_Difficulty: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x03) != + (ucVal & 0x03)) { + GameSettingsA[iPad]->usBitmaskValues &= ~0x03; + GameSettingsA[iPad]->usBitmaskValues |= ucVal & 0x03; + if (iPad == ProfileManager.GetPrimaryPad()) { + ActionGameSettings(iPad, eVal); + } + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_Sensitivity_InGame: + if (GameSettingsA[iPad]->ucSensitivity != ucVal) { + GameSettingsA[iPad]->ucSensitivity = ucVal; + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_ViewBob: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0004) != + ((ucVal & 0x01) << 2)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0004; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0004; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_ControlScheme: // bits 5 and 6 + if ((GameSettingsA[iPad]->usBitmaskValues & 0x30) != + ((ucVal & 0x03) << 4)) { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0030; + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= (ucVal & 0x03) << 4; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; - case eGameSetting_ControlInvertLook: - if((GameSettingsA[iPad]->usBitmaskValues&0x0040)!=((ucVal&0x01)<<6)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0040; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0040; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + case eGameSetting_ControlInvertLook: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0040) != + ((ucVal & 0x01) << 6)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0040; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0040; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; - case eGameSetting_ControlSouthPaw: - if((GameSettingsA[iPad]->usBitmaskValues&0x0080)!=((ucVal&0x01)<<7)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0080; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0080; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_SplitScreenVertical: - if((GameSettingsA[iPad]->usBitmaskValues&0x0100)!=((ucVal&0x01)<<8)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0100; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0100; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_GamertagsVisible: - if((GameSettingsA[iPad]->usBitmaskValues&0x0008)!=((ucVal&0x01)<<3)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0008; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0008; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + case eGameSetting_ControlSouthPaw: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0080) != + ((ucVal & 0x01) << 7)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0080; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0080; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_SplitScreenVertical: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0100) != + ((ucVal & 0x01) << 8)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0100; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0100; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_GamertagsVisible: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0008) != + ((ucVal & 0x01) << 3)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0008; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0008; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; - // 4J-PB - Added for Interim TU for 1.6.6 - case eGameSetting_Sensitivity_InMenu: - if(GameSettingsA[iPad]->ucMenuSensitivity!=ucVal) - { - GameSettingsA[iPad]->ucMenuSensitivity=ucVal; - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_DisplaySplitscreenGamertags: - if((GameSettingsA[iPad]->usBitmaskValues&0x0200)!=((ucVal&0x01)<<9)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0200; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0200; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_Hints: - if((GameSettingsA[iPad]->usBitmaskValues&0x0400)!=((ucVal&0x01)<<10)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x0400; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x0400; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_Autosave: - if((GameSettingsA[iPad]->usBitmaskValues&0x7800)!=((ucVal&0x0F)<<11)) - { - GameSettingsA[iPad]->usBitmaskValues&=~0x7800; - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=(ucVal&0x0F)<<11; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + // 4J-PB - Added for Interim TU for 1.6.6 + case eGameSetting_Sensitivity_InMenu: + if (GameSettingsA[iPad]->ucMenuSensitivity != ucVal) { + GameSettingsA[iPad]->ucMenuSensitivity = ucVal; + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_DisplaySplitscreenGamertags: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0200) != + ((ucVal & 0x01) << 9)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0200; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0200; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_Hints: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x0400) != + ((ucVal & 0x01) << 10)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x0400; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x0400; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_Autosave: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x7800) != + ((ucVal & 0x0F) << 11)) { + GameSettingsA[iPad]->usBitmaskValues &= ~0x7800; + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= (ucVal & 0x0F) + << 11; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; - case eGameSetting_Tooltips: - if((GameSettingsA[iPad]->usBitmaskValues&0x8000)!=((ucVal&0x01)<<15)) - { - if(ucVal!=0) - { - GameSettingsA[iPad]->usBitmaskValues|=0x8000; - } - else - { - GameSettingsA[iPad]->usBitmaskValues&=~0x8000; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_InterfaceOpacity: - if(GameSettingsA[iPad]->ucInterfaceOpacity!=ucVal) - { - GameSettingsA[iPad]->ucInterfaceOpacity=ucVal; - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + case eGameSetting_Tooltips: + if ((GameSettingsA[iPad]->usBitmaskValues & 0x8000) != + ((ucVal & 0x01) << 15)) { + if (ucVal != 0) { + GameSettingsA[iPad]->usBitmaskValues |= 0x8000; + } else { + GameSettingsA[iPad]->usBitmaskValues &= ~0x8000; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_InterfaceOpacity: + if (GameSettingsA[iPad]->ucInterfaceOpacity != ucVal) { + GameSettingsA[iPad]->ucInterfaceOpacity = ucVal; + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - case eGameSetting_Clouds: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_CLOUDS)!=(ucVal&0x01)) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_CLOUDS; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_CLOUDS; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + break; + case eGameSetting_Clouds: + if ((GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_CLOUDS) != + (ucVal & 0x01)) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= GAMESETTING_CLOUDS; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= ~GAMESETTING_CLOUDS; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; + break; - case eGameSetting_Online: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_ONLINE)!=(ucVal&0x01)<<1) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_ONLINE; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_ONLINE; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + case eGameSetting_Online: + if ((GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_ONLINE) != + (ucVal & 0x01) << 1) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= GAMESETTING_ONLINE; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= ~GAMESETTING_ONLINE; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - case eGameSetting_InviteOnly: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_INVITEONLY)!=(ucVal&0x01)<<2) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_INVITEONLY; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_INVITEONLY; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + break; + case eGameSetting_InviteOnly: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_INVITEONLY) != (ucVal & 0x01) << 2) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_INVITEONLY; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_INVITEONLY; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - case eGameSetting_FriendsOfFriends: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_FRIENDSOFFRIENDS)!=(ucVal&0x01)<<3) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_FRIENDSOFFRIENDS; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_FRIENDSOFFRIENDS; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + break; + case eGameSetting_FriendsOfFriends: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_FRIENDSOFFRIENDS) != (ucVal & 0x01) << 3) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_FRIENDSOFFRIENDS; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_FRIENDSOFFRIENDS; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - case eGameSetting_DisplayUpdateMessage: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYUPDATEMSG)!=(ucVal&0x03)<<4) - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_DISPLAYUPDATEMSG; - if(ucVal>0) - { - GameSettingsA[iPad]->uiBitmaskValues|=(ucVal&0x03)<<4; - } + break; + case eGameSetting_DisplayUpdateMessage: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DISPLAYUPDATEMSG) != (ucVal & 0x03) << 4) { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_DISPLAYUPDATEMSG; + if (ucVal > 0) { + GameSettingsA[iPad]->uiBitmaskValues |= (ucVal & 0x03) << 4; + } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; + break; - case eGameSetting_BedrockFog: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_BEDROCKFOG)!=(ucVal&0x01)<<6) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_BEDROCKFOG; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_BEDROCKFOG; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + case eGameSetting_BedrockFog: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_BEDROCKFOG) != (ucVal & 0x01) << 6) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_BEDROCKFOG; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_BEDROCKFOG; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - case eGameSetting_DisplayHUD: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYHUD)!=(ucVal&0x01)<<7) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_DISPLAYHUD; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_DISPLAYHUD; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + break; + case eGameSetting_DisplayHUD: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DISPLAYHUD) != (ucVal & 0x01) << 7) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_DISPLAYHUD; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_DISPLAYHUD; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - case eGameSetting_DisplayHand: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYHAND)!=(ucVal&0x01)<<8) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_DISPLAYHAND; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_DISPLAYHAND; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + break; + case eGameSetting_DisplayHand: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DISPLAYHAND) != (ucVal & 0x01) << 8) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_DISPLAYHAND; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_DISPLAYHAND; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; + break; - case eGameSetting_CustomSkinAnim: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_CUSTOMSKINANIM)!=(ucVal&0x01)<<9) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_CUSTOMSKINANIM; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_CUSTOMSKINANIM; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } + case eGameSetting_CustomSkinAnim: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_CUSTOMSKINANIM) != (ucVal & 0x01) << 9) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_CUSTOMSKINANIM; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_CUSTOMSKINANIM; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } - break; - // TU9 - case eGameSetting_DeathMessages: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DEATHMESSAGES)!=(ucVal&0x01)<<10) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_DEATHMESSAGES; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_DEATHMESSAGES; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_UISize: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE)!=((ucVal&0x03)<<11)) - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_UISIZE; - if(ucVal!=0) - { - GameSettingsA[iPad]->uiBitmaskValues|=(ucVal&0x03)<<11; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_UISizeSplitscreen: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE_SPLITSCREEN)!=((ucVal&0x03)<<13)) - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_UISIZE_SPLITSCREEN; - if(ucVal!=0) - { - GameSettingsA[iPad]->uiBitmaskValues|=(ucVal&0x03)<<13; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_AnimatedCharacter: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_ANIMATEDCHARACTER)!=(ucVal&0x01)<<15) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_ANIMATEDCHARACTER; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_ANIMATEDCHARACTER; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_PS3_EULA_Read: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PS3EULAREAD)!=(ucVal&0x01)<<16) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_PS3EULAREAD; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_PS3EULAREAD; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_PSVita_NetworkModeAdhoc: - if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PSVITANETWORKMODEADHOC)!=(ucVal&0x01)<<17) - { - if(ucVal==1) - { - GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_PSVITANETWORKMODEADHOC; - } - else - { - GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_PSVITANETWORKMODEADHOC; - } - ActionGameSettings(iPad,eVal); - GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - - } + break; + // TU9 + case eGameSetting_DeathMessages: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DEATHMESSAGES) != (ucVal & 0x01) << 10) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_DEATHMESSAGES; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_DEATHMESSAGES; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_UISize: + if ((GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_UISIZE) != + ((ucVal & 0x03) << 11)) { + GameSettingsA[iPad]->uiBitmaskValues &= ~GAMESETTING_UISIZE; + if (ucVal != 0) { + GameSettingsA[iPad]->uiBitmaskValues |= (ucVal & 0x03) + << 11; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_UISizeSplitscreen: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_UISIZE_SPLITSCREEN) != ((ucVal & 0x03) << 13)) { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_UISIZE_SPLITSCREEN; + if (ucVal != 0) { + GameSettingsA[iPad]->uiBitmaskValues |= (ucVal & 0x03) + << 13; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_AnimatedCharacter: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_ANIMATEDCHARACTER) != (ucVal & 0x01) << 15) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_ANIMATEDCHARACTER; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_ANIMATEDCHARACTER; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_PS3_EULA_Read: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_PS3EULAREAD) != (ucVal & 0x01) << 16) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_PS3EULAREAD; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_PS3EULAREAD; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + case eGameSetting_PSVita_NetworkModeAdhoc: + if ((GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_PSVITANETWORKMODEADHOC) != (ucVal & 0x01) << 17) { + if (ucVal == 1) { + GameSettingsA[iPad]->uiBitmaskValues |= + GAMESETTING_PSVITANETWORKMODEADHOC; + } else { + GameSettingsA[iPad]->uiBitmaskValues &= + ~GAMESETTING_PSVITANETWORKMODEADHOC; + } + ActionGameSettings(iPad, eVal); + GameSettingsA[iPad]->bSettingsChanged = true; + } + break; + } } -unsigned char CMinecraftApp::GetGameSettings(eGameSetting eVal) -{ - int iPad=ProfileManager.GetPrimaryPad(); +unsigned char CMinecraftApp::GetGameSettings(eGameSetting eVal) { + int iPad = ProfileManager.GetPrimaryPad(); - return GetGameSettings(iPad,eVal); + return GetGameSettings(iPad, eVal); } -unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) -{ - switch(eVal) - { - case eGameSetting_MusicVolume: - return GameSettingsA[iPad]->ucMusicVolume; - break; - case eGameSetting_SoundFXVolume: - return GameSettingsA[iPad]->ucSoundFXVolume; - break; - case eGameSetting_Gamma: - return GameSettingsA[iPad]->ucGamma; - break; - case eGameSetting_Difficulty: - return GameSettingsA[iPad]->usBitmaskValues&0x0003; - break; - case eGameSetting_Sensitivity_InGame: - return GameSettingsA[iPad]->ucSensitivity; - break; - case eGameSetting_ViewBob: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0004)>>2); - break; - case eGameSetting_GamertagsVisible: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0008)>>3); - break; - case eGameSetting_ControlScheme: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0030)>>4); // 2 bits - break; - case eGameSetting_ControlInvertLook: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0040)>>6); - break; - case eGameSetting_ControlSouthPaw: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0080)>>7); - break; - case eGameSetting_SplitScreenVertical: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0100)>>8); - break; - // 4J-PB - Added for Interim TU for 1.6.6 - case eGameSetting_Sensitivity_InMenu: - return GameSettingsA[iPad]->ucMenuSensitivity; - break; +unsigned char CMinecraftApp::GetGameSettings(int iPad, eGameSetting eVal) { + switch (eVal) { + case eGameSetting_MusicVolume: + return GameSettingsA[iPad]->ucMusicVolume; + break; + case eGameSetting_SoundFXVolume: + return GameSettingsA[iPad]->ucSoundFXVolume; + break; + case eGameSetting_Gamma: + return GameSettingsA[iPad]->ucGamma; + break; + case eGameSetting_Difficulty: + return GameSettingsA[iPad]->usBitmaskValues & 0x0003; + break; + case eGameSetting_Sensitivity_InGame: + return GameSettingsA[iPad]->ucSensitivity; + break; + case eGameSetting_ViewBob: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0004) >> 2); + break; + case eGameSetting_GamertagsVisible: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0008) >> 3); + break; + case eGameSetting_ControlScheme: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0030) >> + 4); // 2 bits + break; + case eGameSetting_ControlInvertLook: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0040) >> 6); + break; + case eGameSetting_ControlSouthPaw: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0080) >> 7); + break; + case eGameSetting_SplitScreenVertical: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0100) >> 8); + break; + // 4J-PB - Added for Interim TU for 1.6.6 + case eGameSetting_Sensitivity_InMenu: + return GameSettingsA[iPad]->ucMenuSensitivity; + break; - case eGameSetting_DisplaySplitscreenGamertags: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0200)>>9); - break; + case eGameSetting_DisplaySplitscreenGamertags: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0200) >> 9); + break; - case eGameSetting_Hints: - return ((GameSettingsA[iPad]->usBitmaskValues&0x0400)>>10); - break; - case eGameSetting_Autosave: - { - unsigned char ucVal=(GameSettingsA[iPad]->usBitmaskValues&0x7800)>>11; - return ucVal; - } - break; - case eGameSetting_Tooltips: - return ((GameSettingsA[iPad]->usBitmaskValues&0x8000)>>15); - break; + case eGameSetting_Hints: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x0400) >> 10); + break; + case eGameSetting_Autosave: { + unsigned char ucVal = + (GameSettingsA[iPad]->usBitmaskValues & 0x7800) >> 11; + return ucVal; + } break; + case eGameSetting_Tooltips: + return ((GameSettingsA[iPad]->usBitmaskValues & 0x8000) >> 15); + break; - case eGameSetting_InterfaceOpacity: - return GameSettingsA[iPad]->ucInterfaceOpacity; - break; - - case eGameSetting_Clouds: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_CLOUDS); - break; - case eGameSetting_Online: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_ONLINE)>>1; - break; - case eGameSetting_InviteOnly: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_INVITEONLY)>>2; - break; - case eGameSetting_FriendsOfFriends: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_FRIENDSOFFRIENDS)>>3; - break; - case eGameSetting_DisplayUpdateMessage: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYUPDATEMSG)>>4; - break; - case eGameSetting_BedrockFog: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_BEDROCKFOG)>>6; - break; - case eGameSetting_DisplayHUD: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYHUD)>>7; - break; - case eGameSetting_DisplayHand: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYHAND)>>8; - break; - case eGameSetting_CustomSkinAnim: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_CUSTOMSKINANIM)>>9; - break; - // TU9 - case eGameSetting_DeathMessages: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DEATHMESSAGES)>>10; - break; - case eGameSetting_UISize: - { - unsigned char ucVal=(GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE)>>11; - return ucVal; - } - break; - case eGameSetting_UISizeSplitscreen: - { - unsigned char ucVal=(GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE_SPLITSCREEN)>>13; - return ucVal; - } - break; - case eGameSetting_AnimatedCharacter: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_ANIMATEDCHARACTER)>>15; + case eGameSetting_InterfaceOpacity: + return GameSettingsA[iPad]->ucInterfaceOpacity; + break; - case eGameSetting_PS3_EULA_Read: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PS3EULAREAD)>>16; + case eGameSetting_Clouds: + return (GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_CLOUDS); + break; + case eGameSetting_Online: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_ONLINE) >> + 1; + break; + case eGameSetting_InviteOnly: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_INVITEONLY) >> + 2; + break; + case eGameSetting_FriendsOfFriends: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_FRIENDSOFFRIENDS) >> + 3; + break; + case eGameSetting_DisplayUpdateMessage: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DISPLAYUPDATEMSG) >> + 4; + break; + case eGameSetting_BedrockFog: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_BEDROCKFOG) >> + 6; + break; + case eGameSetting_DisplayHUD: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DISPLAYHUD) >> + 7; + break; + case eGameSetting_DisplayHand: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DISPLAYHAND) >> + 8; + break; + case eGameSetting_CustomSkinAnim: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_CUSTOMSKINANIM) >> + 9; + break; + // TU9 + case eGameSetting_DeathMessages: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_DEATHMESSAGES) >> + 10; + break; + case eGameSetting_UISize: { + unsigned char ucVal = + (GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_UISIZE) >> + 11; + return ucVal; + } break; + case eGameSetting_UISizeSplitscreen: { + unsigned char ucVal = (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_UISIZE_SPLITSCREEN) >> + 13; + return ucVal; + } break; + case eGameSetting_AnimatedCharacter: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_ANIMATEDCHARACTER) >> + 15; - case eGameSetting_PSVita_NetworkModeAdhoc: - return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PSVITANETWORKMODEADHOC)>>17; + case eGameSetting_PS3_EULA_Read: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_PS3EULAREAD) >> + 16; - } - return 0; + case eGameSetting_PSVita_NetworkModeAdhoc: + return (GameSettingsA[iPad]->uiBitmaskValues & + GAMESETTING_PSVITANETWORKMODEADHOC) >> + 17; + } + return 0; } -void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPad) -{ - // If the settings have changed, write them to the profile +void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, + int iPad) { + // If the settings have changed, write them to the profile - if(iPad==XUSER_INDEX_ANY) - { - for(int i=0;ibSettingsChanged) - { -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ ) - StorageManager.WriteToProfile(i,true, bOverride5MinuteTimer); + if (iPad == XUSER_INDEX_ANY) { + for (int i = 0; i < XUSER_MAX_COUNT; i++) { + if (GameSettingsA[i]->bSettingsChanged) { +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + StorageManager.WriteToProfile(i, true, bOverride5MinuteTimer); #else - ProfileManager.WriteToProfile(i,true, bOverride5MinuteTimer); + ProfileManager.WriteToProfile(i, true, bOverride5MinuteTimer); #endif - GameSettingsA[i]->bSettingsChanged=false; - } - } - } - else - { - if(GameSettingsA[iPad]->bSettingsChanged) - { -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - StorageManager.WriteToProfile(iPad,true, bOverride5MinuteTimer); + GameSettingsA[i]->bSettingsChanged = false; + } + } + } else { + if (GameSettingsA[iPad]->bSettingsChanged) { +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + StorageManager.WriteToProfile(iPad, true, bOverride5MinuteTimer); #else - ProfileManager.WriteToProfile(iPad,true, bOverride5MinuteTimer); + ProfileManager.WriteToProfile(iPad, true, bOverride5MinuteTimer); #endif - GameSettingsA[iPad]->bSettingsChanged=false; - } - } + GameSettingsA[iPad]->bSettingsChanged = false; + } + } } -void CMinecraftApp::ClearGameSettingsChangedFlag(int iPad) -{ - GameSettingsA[iPad]->bSettingsChanged=false; +void CMinecraftApp::ClearGameSettingsChangedFlag(int iPad) { + GameSettingsA[iPad]->bSettingsChanged = false; } /////////////////////////// @@ -2175,1423 +2233,1566 @@ void CMinecraftApp::ClearGameSettingsChangedFlag(int iPad) // //////////////////////////// #ifndef _DEBUG_MENUS_ENABLED -unsigned int CMinecraftApp::GetGameSettingsDebugMask(int iPad,bool bOverridePlayer) //bOverridePlayer is to force the send for the server to get the read options +unsigned int CMinecraftApp::GetGameSettingsDebugMask( + int iPad, bool bOverridePlayer) // bOverridePlayer is to force the send for + // the server to get the read options { - return 0; + return 0; } -void CMinecraftApp::SetGameSettingsDebugMask(int iPad, unsigned int uiVal) -{ -} +void CMinecraftApp::SetGameSettingsDebugMask(int iPad, unsigned int uiVal) {} -void CMinecraftApp::ActionDebugMask(int iPad,bool bSetAllClear) -{ -} +void CMinecraftApp::ActionDebugMask(int iPad, bool bSetAllClear) {} #else -unsigned int CMinecraftApp::GetGameSettingsDebugMask(int iPad,bool bOverridePlayer) //bOverridePlayer is to force the send for the server to get the read options +unsigned int CMinecraftApp::GetGameSettingsDebugMask( + int iPad, bool bOverridePlayer) // bOverridePlayer is to force the send for + // the server to get the read options { - if(iPad==-1) - { - iPad=ProfileManager.GetPrimaryPad(); - } - if(iPad < 0) iPad = 0; + if (iPad == -1) { + iPad = ProfileManager.GetPrimaryPad(); + } + if (iPad < 0) iPad = 0; - std::shared_ptr player = Minecraft::GetInstance()->localplayers[iPad]; + std::shared_ptr player = + Minecraft::GetInstance()->localplayers[iPad]; - if(bOverridePlayer || player==NULL) - { - return GameSettingsA[iPad]->uiDebugBitmask; - } - else - { - return player->GetDebugOptions(); - } + if (bOverridePlayer || player == NULL) { + return GameSettingsA[iPad]->uiDebugBitmask; + } else { + return player->GetDebugOptions(); + } } - -void CMinecraftApp::SetGameSettingsDebugMask(int iPad, unsigned int uiVal) -{ +void CMinecraftApp::SetGameSettingsDebugMask(int iPad, unsigned int uiVal) { #ifndef _CONTENT_PACKAGE - GameSettingsA[iPad]->bSettingsChanged=true; - GameSettingsA[iPad]->uiDebugBitmask=uiVal; + GameSettingsA[iPad]->bSettingsChanged = true; + GameSettingsA[iPad]->uiDebugBitmask = uiVal; - // update the value so the network server can use it - std::shared_ptr player = Minecraft::GetInstance()->localplayers[iPad]; + // update the value so the network server can use it + std::shared_ptr player = + Minecraft::GetInstance()->localplayers[iPad]; - if(player) - { - Minecraft::GetInstance()->localgameModes[iPad]->handleDebugOptions(uiVal,player); - } + if (player) { + Minecraft::GetInstance()->localgameModes[iPad]->handleDebugOptions( + uiVal, player); + } #endif } -void CMinecraftApp::ActionDebugMask(int iPad,bool bSetAllClear) -{ - unsigned int ulBitmask=app.GetGameSettingsDebugMask(iPad); +void CMinecraftApp::ActionDebugMask(int iPad, bool bSetAllClear) { + unsigned int ulBitmask = app.GetGameSettingsDebugMask(iPad); - if(bSetAllClear) ulBitmask=0L; + if (bSetAllClear) ulBitmask = 0L; + // these settings should only be actioned for the primary player + if (ProfileManager.GetPrimaryPad() != iPad) return; + for (int i = 0; i < eDebugSetting_Max; i++) { + switch (i) { + case eDebugSetting_LoadSavesFromDisk: + if (ulBitmask & (1 << i)) { + app.SetLoadSavesFromFolderEnabled(true); + } else { + app.SetLoadSavesFromFolderEnabled(false); + } + break; - // these settings should only be actioned for the primary player - if(ProfileManager.GetPrimaryPad()!=iPad) return; + case eDebugSetting_WriteSavesToDisk: + if (ulBitmask & (1 << i)) { + app.SetWriteSavesToFolderEnabled(true); + } else { + app.SetWriteSavesToFolderEnabled(false); + } + break; - for(int i=0;iiPad, actionInfo->action); +void CMinecraftApp::SetActionConfirmed(void* param) { + XuiActionParam* actionInfo = (XuiActionParam*)param; + app.SetAction(actionInfo->iPad, actionInfo->action); } +void CMinecraftApp::HandleXuiActions(void) { + eXuiAction eAction; + eTMSAction eTMS; + void* param; + Minecraft* pMinecraft = Minecraft::GetInstance(); + std::shared_ptr player; -void CMinecraftApp::HandleXuiActions(void) -{ - eXuiAction eAction; - eTMSAction eTMS; - void *param; - Minecraft *pMinecraft=Minecraft::GetInstance(); - std::shared_ptr player; + // are there any global actions to deal with? + eAction = app.GetGlobalXuiAction(); + if (eAction != eAppAction_Idle) { + switch (eAction) { + case eAppAction_DisplayLavaMessage: + // Display a warning about placing lava in the spawn area + { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + C4JStorage::EMessageResult result = ui.RequestMessageBox( + IDS_CANT_PLACE_NEAR_SPAWN_TITLE, + IDS_CANT_PLACE_NEAR_SPAWN_TEXT, uiIDA, 1, + XUSER_INDEX_ANY, NULL, NULL, app.GetStringTable()); + if (result != C4JStorage::EMessage_Busy) + SetGlobalXuiAction(eAppAction_Idle); + } + break; + default: + break; + } + } - // are there any global actions to deal with? - eAction = app.GetGlobalXuiAction(); - if(eAction!=eAppAction_Idle) - { - switch(eAction) - { - case eAppAction_DisplayLavaMessage: - // Display a warning about placing lava in the spawn area - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_CANT_PLACE_NEAR_SPAWN_TITLE, IDS_CANT_PLACE_NEAR_SPAWN_TEXT, uiIDA,1,XUSER_INDEX_ANY,NULL,NULL, app.GetStringTable()); - if(result != C4JStorage::EMessage_Busy) SetGlobalXuiAction(eAppAction_Idle); + // are there any app actions to deal with? + for (int i = 0; i < XUSER_MAX_COUNT; i++) { + eAction = app.GetXuiAction(i); + param = m_eXuiActionParam[i]; - } - break; - default: - break; - } - } + if (eAction != eAppAction_Idle) { + switch (eAction) { + // the renderer will capture a screenshot + case eAppAction_SocialPost: + if (ProfileManager.IsFullVersion()) { + // Facebook Share + if (CSocialManager::Instance() + ->IsTitleAllowedToPostImages() && + CSocialManager::Instance() + ->AreAllUsersAllowedToPostImages()) { + // disable character name tags for the shot + // m_bwasHidingGui = pMinecraft->options->hideGui; + // // 4J Stu - Removed 1.8.2 bug fix (TU6) as don't + // need this + pMinecraft->options->hideGui = true; - // are there any app actions to deal with? - for(int i=0;ioptions->hideGui = bKeepHiding; - if(eAction!=eAppAction_Idle) - { - switch(eAction) - { - // the renderer will capture a screenshot - case eAppAction_SocialPost: - if(ProfileManager.IsFullVersion()) - { - // Facebook Share - if( CSocialManager::Instance()->IsTitleAllowedToPostImages() && CSocialManager::Instance()->AreAllUsersAllowedToPostImages() ) - { - // disable character name tags for the shot - //m_bwasHidingGui = pMinecraft->options->hideGui; // 4J Stu - Removed 1.8.2 bug fix (TU6) as don't need this - pMinecraft->options->hideGui = true; + // Facebook Share - SetAction(i,eAppAction_SocialPostScreenshot); - } - else - { - SetAction(i,eAppAction_Idle); - } - } - else - { - SetAction(i,eAppAction_Idle); - } - break; - case eAppAction_SocialPostScreenshot: - { - SetAction(i,eAppAction_Idle); - bool bKeepHiding = false; - for(int j=0; j < XUSER_MAX_COUNT;++j) - { - if(app.GetXuiAction(j) == eAppAction_SocialPostScreenshot) - { - bKeepHiding = true; - break; - } - } - pMinecraft->options->hideGui=bKeepHiding; + if (app.GetLocalPlayerCount() > 1) { + ui.NavigateToScene(i, eUIScene_SocialPost); + } else { + ui.NavigateToScene(i, eUIScene_SocialPost); + } + } break; + case eAppAction_SaveGame: + SetAction(i, eAppAction_Idle); + if (!GetChangingSessionType()) { + // If this is the trial game, do an upsell + if (ProfileManager.IsFullVersion()) { + // flag the render to capture the screenshot for the + // save + SetAction(i, eAppAction_SaveGameCapturedThumbnail); + } else { + // ask the player if they would like to upgrade, or + // they'll lose the level - // Facebook Share + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_OK; + uiIDA[1] = IDS_CONFIRM_CANCEL; + ui.RequestMessageBox( + IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, + 2, i, &CMinecraftApp::UnlockFullSaveReturned, + this, app.GetStringTable()); + } + } - if(app.GetLocalPlayerCount()>1) - { - ui.NavigateToScene(i,eUIScene_SocialPost); - } - else - { - ui.NavigateToScene(i,eUIScene_SocialPost); - } - } - break; - case eAppAction_SaveGame: - SetAction(i,eAppAction_Idle); - if(!GetChangingSessionType()) - { - // If this is the trial game, do an upsell - if(ProfileManager.IsFullVersion()) - { + break; + case eAppAction_AutosaveSaveGame: { + // Need to run a check to see if the save exists in order to + // stop the dialog asking if we want to overwrite it coming + // up on an autosave + bool bSaveExists; + StorageManager.DoesSaveExist(&bSaveExists); - // flag the render to capture the screenshot for the save - SetAction(i,eAppAction_SaveGameCapturedThumbnail); - } - else - { - // ask the player if they would like to upgrade, or they'll lose the level - - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_OK; - uiIDA[1]=IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, 2,i,&CMinecraftApp::UnlockFullSaveReturned,this,app.GetStringTable()); - } - } + SetAction(i, eAppAction_Idle); + if (!GetChangingSessionType()) { + // flag the render to capture the screenshot for the + // save + SetAction(i, + eAppAction_AutosaveSaveGameCapturedThumbnail); + } + } - break; - case eAppAction_AutosaveSaveGame: - { - // Need to run a check to see if the save exists in order to stop the dialog asking if we want to overwrite it coming up on an autosave - bool bSaveExists; - StorageManager.DoesSaveExist(&bSaveExists); + break; - SetAction(i,eAppAction_Idle); - if(!GetChangingSessionType()) - { + case eAppAction_SaveGameCapturedThumbnail: + // reset the autosave timer + app.SetAutosaveTimerTime(); + SetAction(i, eAppAction_Idle); + // Check that there is a name for the save - if we're saving + // from the tutorial and this is the first save from the + // tutorial, we'll not have a name + /*if(StorageManager.GetSaveName()==NULL) + { + app.NavigateToScene(i,eUIScene_SaveWorld); + } + else*/ + { + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - // flag the render to capture the screenshot for the save - SetAction(i,eAppAction_AutosaveSaveGameCapturedThumbnail); - } - } + // Hide the other players scenes + ui.ShowOtherPlayersBaseScene( + ProfileManager.GetPrimaryPad(), false); - break; + // INT saveOrCheckpointId = 0; + // bool validSave = + // StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); + // SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), + // saveOrCheckpointId); - case eAppAction_SaveGameCapturedThumbnail: - // reset the autosave timer - app.SetAutosaveTimerTime(); - SetAction(i,eAppAction_Idle); - // Check that there is a name for the save - if we're saving from the tutorial and this is the first save from the tutorial, we'll not have a name - /*if(StorageManager.GetSaveName()==NULL) - { - app.NavigateToScene(i,eUIScene_SaveWorld); - } - else*/ - { - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &UIScene_PauseMenu::SaveWorldThreadProc; + loadingParams->lpParam = (LPVOID) false; - // Hide the other players scenes - ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); + // 4J-JEV - PS4: Fix for #5708 - [ONLINE] - If the user + // pulls their network cable out while saving the title + // will hang. + loadingParams->waitForThreadToDelete = true; - //INT saveOrCheckpointId = 0; - //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); - //SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId); - - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; - loadingParams->lpParam = (LPVOID)false; + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->type = + e_ProgressCompletion_NavigateBackToScene; + completionData->iPad = ProfileManager.GetPrimaryPad(); - // 4J-JEV - PS4: Fix for #5708 - [ONLINE] - If the user pulls their network cable out while saving the title will hang. - loadingParams->waitForThreadToDelete = true; + if (ui.IsSceneInStack(ProfileManager.GetPrimaryPad(), + eUIScene_EndPoem)) { + completionData->scene = eUIScene_EndPoem; + } else { + completionData->scene = eUIScene_PauseMenu; + } - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->type = e_ProgressCompletion_NavigateBackToScene; - completionData->iPad = ProfileManager.GetPrimaryPad(); + loadingParams->completionData = completionData; - if( ui.IsSceneInStack( ProfileManager.GetPrimaryPad(), eUIScene_EndPoem ) ) - { - completionData->scene = eUIScene_EndPoem; - } - else - { - completionData->scene = eUIScene_PauseMenu; - } - - loadingParams->completionData = completionData; - - // 4J Stu - Xbox only + // 4J Stu - Xbox only #ifdef _XBOX - // Temporarily make this scene fullscreen - CXuiSceneBase::SetPlayerBaseScenePosition( ProfileManager.GetPrimaryPad(), CXuiSceneBase::e_BaseScene_Fullscreen ); + // Temporarily make this scene fullscreen + CXuiSceneBase::SetPlayerBaseScenePosition( + ProfileManager.GetPrimaryPad(), + CXuiSceneBase::e_BaseScene_Fullscreen); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams , eUILayer_Fullscreen, eUIGroup_Fullscreen); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams, eUILayer_Fullscreen, + eUIGroup_Fullscreen); + } + break; + case eAppAction_AutosaveSaveGameCapturedThumbnail: - } - break; - case eAppAction_AutosaveSaveGameCapturedThumbnail: - - { - app.SetAutosaveTimerTime(); - SetAction(i,eAppAction_Idle); + { + app.SetAutosaveTimerTime(); + SetAction(i, eAppAction_Idle); #if defined(_XBOX_ONE) || defined(__ORBIS__) - app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_AutoSaveGame); + app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), + eXuiServerAction_AutoSaveGame); - if(app.GetGameHostOption(eGameHostOption_DisableSaving)) StorageManager.SetSaveDisabled(true); + if (app.GetGameHostOption(eGameHostOption_DisableSaving)) + StorageManager.SetSaveDisabled(true); #else - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - //app.CloseAllPlayersXuiScenes(); - // Hide the other players scenes - ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); + // app.CloseAllPlayersXuiScenes(); + // Hide the other players scenes + ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), + false); - // This just allows it to be shown - if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); - - //INT saveOrCheckpointId = 0; - //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); - //SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId); + // This just allows it to be shown + if (pMinecraft + ->localgameModes[ProfileManager.GetPrimaryPad()] != + NULL) + pMinecraft + ->localgameModes[ProfileManager.GetPrimaryPad()] + ->getTutorial() + ->showTutorialPopup(false); - - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; + // INT saveOrCheckpointId = 0; + // bool validSave = + // StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); + // SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), + // saveOrCheckpointId); - loadingParams->lpParam = (LPVOID)true; + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &UIScene_PauseMenu::SaveWorldThreadProc; - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->type = e_ProgressCompletion_AutosaveNavigateBack; - completionData->iPad = ProfileManager.GetPrimaryPad(); - //completionData->bAutosaveWasMenuDisplayed=ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad()); - loadingParams->completionData = completionData; - - // 4J Stu - Xbox only + loadingParams->lpParam = (LPVOID) true; + + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->type = + e_ProgressCompletion_AutosaveNavigateBack; + completionData->iPad = ProfileManager.GetPrimaryPad(); + // completionData->bAutosaveWasMenuDisplayed=ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad()); + loadingParams->completionData = completionData; + + // 4J Stu - Xbox only #ifdef _XBOX - // Temporarily make this scene fullscreen - CXuiSceneBase::SetPlayerBaseScenePosition( ProfileManager.GetPrimaryPad(), CXuiSceneBase::e_BaseScene_Fullscreen ); + // Temporarily make this scene fullscreen + CXuiSceneBase::SetPlayerBaseScenePosition( + ProfileManager.GetPrimaryPad(), + CXuiSceneBase::e_BaseScene_Fullscreen); #endif - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams , eUILayer_Fullscreen, eUIGroup_Fullscreen); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams, eUILayer_Fullscreen, + eUIGroup_Fullscreen); #endif - } - break; - case eAppAction_ExitPlayer: - // a secondary player has chosen to quit - { - int iPlayerC=g_NetworkManager.GetPlayerCount(); + } break; + case eAppAction_ExitPlayer: + // a secondary player has chosen to quit + { + int iPlayerC = g_NetworkManager.GetPlayerCount(); - // Since the player is exiting, let's flush any profile writes for them, and hope we're not breaking TCR 136... -#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - StorageManager.ForceQueuedProfileWrites(i); - LeaderboardManager::Instance()->OpenSession(); - for (int j = 0; j < XUSER_MAX_COUNT; j++) - { - if( ProfileManager.IsSignedIn(j) ) - { - app.DebugPrintf("Stats save for an offline game for the player at index %d\n", 0); - Minecraft::GetInstance()->forceStatsSave(j); - } - } - LeaderboardManager::Instance()->CloseSession(); + // Since the player is exiting, let's flush any profile + // writes for them, and hope we're not breaking TCR + // 136... +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + StorageManager.ForceQueuedProfileWrites(i); + LeaderboardManager::Instance()->OpenSession(); + for (int j = 0; j < XUSER_MAX_COUNT; j++) { + if (ProfileManager.IsSignedIn(j)) { + app.DebugPrintf( + "Stats save for an offline game for the " + "player at index %d\n", + 0); + Minecraft::GetInstance()->forceStatsSave(j); + } + } + LeaderboardManager::Instance()->CloseSession(); #else - ProfileManager.ForceQueuedProfileWrites(i); + ProfileManager.ForceQueuedProfileWrites(i); #endif - // not required - it's done within the removeLocalPlayerIdx - // if(pMinecraft->level->isClientSide) - // { - // // we need to remove the qnetplayer, or this player won't be able to get back into the game until qnet times out and removes them - // g_NetworkManager.NotifyPlayerLeaving(g_NetworkManager.GetLocalPlayerByUserIndex(i)); - // } + // not required - it's done within the + // removeLocalPlayerIdx + // if(pMinecraft->level->isClientSide) + // { + // // we need to + // remove the qnetplayer, or this player won't be able + // to get back into the game until qnet times out and + // removes them + // g_NetworkManager.NotifyPlayerLeaving(g_NetworkManager.GetLocalPlayerByUserIndex(i)); + // } - // if there are any tips showing, we need to close them + // if there are any tips showing, we need to close them - pMinecraft->gui->clearMessages(i); + pMinecraft->gui->clearMessages(i); - // Make sure we've not got this player selected as current - this shouldn't be the case anyway - pMinecraft->setLocalPlayerIdx(ProfileManager.GetPrimaryPad()); - pMinecraft->removeLocalPlayerIdx(i); + // Make sure we've not got this player selected as + // current - this shouldn't be the case anyway + pMinecraft->setLocalPlayerIdx( + ProfileManager.GetPrimaryPad()); + pMinecraft->removeLocalPlayerIdx(i); #ifdef _XBOX - // tell the xui scenes a splitscreen player left - has to come after removeLocalPlayerIdx which calls updatePlayerViewportAssignments - XUIMessage xuiMsg; - CustomMessage_Splitscreenplayer_Struct myMsgData; - CustomMessage_Splitscreenplayer( &xuiMsg, &myMsgData, false); + // tell the xui scenes a splitscreen player left - has + // to come after removeLocalPlayerIdx which calls + // updatePlayerViewportAssignments + XUIMessage xuiMsg; + CustomMessage_Splitscreenplayer_Struct myMsgData; + CustomMessage_Splitscreenplayer(&xuiMsg, &myMsgData, + false); - // send the message - for(int idx=0;idxlocalplayers[idx]!=NULL)) - { - XuiBroadcastMessage( CXuiSceneBase::GetPlayerBaseScene(idx), &xuiMsg ); - } - } + // send the message + for (int idx = 0; idx < XUSER_MAX_COUNT; idx++) { + if ((i != idx) && + (pMinecraft->localplayers[idx] != NULL)) { + XuiBroadcastMessage( + CXuiSceneBase::GetPlayerBaseScene(idx), + &xuiMsg); + } + } #endif #ifndef _XBOX - // Wipe out the tooltips - ui.SetTooltips(i, -1); + // Wipe out the tooltips + ui.SetTooltips(i, -1); #endif - // Change the presence info - // Are we offline or online, and how many players are there - if(iPlayerC>2) // one player is about to leave here - they'll be set to idle in the qnet manager player leave - { - for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { - if(g_NetworkManager.IsLocalGame()) - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); - } - else - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER,false); - } - } - } - } - else - { - for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { - if(g_NetworkManager.IsLocalGame()) - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); - } - else - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); - } - } - } - } - + // Change the presence info + // Are we offline or online, and how many players are + // there + if (iPlayerC > 2) // one player is about to leave here + // - they'll be set to idle in the + // qnet manager player leave + { + for (int iPlayer = 0; iPlayer < XUSER_MAX_COUNT; + iPlayer++) { + if ((iPlayer != i) && + pMinecraft->localplayers[iPlayer]) { + if (g_NetworkManager.IsLocalGame()) { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, + false); + } else { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYER, + false); + } + } + } + } else { + for (int iPlayer = 0; iPlayer < XUSER_MAX_COUNT; + iPlayer++) { + if ((iPlayer != i) && + pMinecraft->localplayers[iPlayer]) { + if (g_NetworkManager.IsLocalGame()) { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, + false); + } else { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYER_1P, + false); + } + } + } + } + #ifdef _DURANGO - ProfileManager.RemoveGamepadFromGame(i); -#endif - - SetAction(i,eAppAction_Idle); - } - break; - case eAppAction_ExitPlayerPreLogin: - { - int iPlayerC=g_NetworkManager.GetPlayerCount(); - // Since the player is exiting, let's flush any profile writes for them, and hope we're not breaking TCR 136... -#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - StorageManager.ForceQueuedProfileWrites(i); + ProfileManager.RemoveGamepadFromGame(i); +#endif + + SetAction(i, eAppAction_Idle); + } + break; + case eAppAction_ExitPlayerPreLogin: { + int iPlayerC = g_NetworkManager.GetPlayerCount(); + // Since the player is exiting, let's flush any profile + // writes for them, and hope we're not breaking TCR 136... +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + StorageManager.ForceQueuedProfileWrites(i); #else - ProfileManager.ForceQueuedProfileWrites(i); -#endif - // if there are any tips showing, we need to close them + ProfileManager.ForceQueuedProfileWrites(i); +#endif + // if there are any tips showing, we need to close them - pMinecraft->gui->clearMessages(i); + pMinecraft->gui->clearMessages(i); - // Make sure we've not got this player selected as current - this shouldn't be the case anyway - pMinecraft->setLocalPlayerIdx(ProfileManager.GetPrimaryPad()); - pMinecraft->removeLocalPlayerIdx(i); + // Make sure we've not got this player selected as current - + // this shouldn't be the case anyway + pMinecraft->setLocalPlayerIdx( + ProfileManager.GetPrimaryPad()); + pMinecraft->removeLocalPlayerIdx(i); #ifdef _XBOX - // tell the xui scenes a splitscreen player left - has to come after removeLocalPlayerIdx which calls updatePlayerViewportAssignments - XUIMessage xuiMsg; - CustomMessage_Splitscreenplayer_Struct myMsgData; - CustomMessage_Splitscreenplayer( &xuiMsg, &myMsgData, false); + // tell the xui scenes a splitscreen player left - has to + // come after removeLocalPlayerIdx which calls + // updatePlayerViewportAssignments + XUIMessage xuiMsg; + CustomMessage_Splitscreenplayer_Struct myMsgData; + CustomMessage_Splitscreenplayer(&xuiMsg, &myMsgData, false); - // send the message - for(int idx=0;idxlocalplayers[idx]!=NULL)) - { - XuiBroadcastMessage( CXuiSceneBase::GetPlayerBaseScene(idx), &xuiMsg ); - } - } + // send the message + for (int idx = 0; idx < XUSER_MAX_COUNT; idx++) { + if ((i != idx) && + (pMinecraft->localplayers[idx] != NULL)) { + XuiBroadcastMessage( + CXuiSceneBase::GetPlayerBaseScene(idx), + &xuiMsg); + } + } #endif #ifndef _XBOX - // Wipe out the tooltips - ui.SetTooltips(i, -1); + // Wipe out the tooltips + ui.SetTooltips(i, -1); #endif - // Change the presence info - // Are we offline or online, and how many players are there - if(iPlayerC>2) // one player is about to leave here - they'll be set to idle in the qnet manager player leave - { - for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { - if(g_NetworkManager.IsLocalGame()) - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); - } - else - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER,false); - } - } - } - } - else - { - for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { - if(g_NetworkManager.IsLocalGame()) - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); - } - else - { - ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); - } - } - } - } - SetAction(i,eAppAction_Idle); - } - break; + // Change the presence info + // Are we offline or online, and how many players are there + if (iPlayerC > + 2) // one player is about to leave here - they'll be + // set to idle in the qnet manager player leave + { + for (int iPlayer = 0; iPlayer < XUSER_MAX_COUNT; + iPlayer++) { + if ((iPlayer != i) && + pMinecraft->localplayers[iPlayer]) { + if (g_NetworkManager.IsLocalGame()) { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, + false); + } else { + ProfileManager.SetCurrentGameActivity( + iPlayer, CONTEXT_PRESENCE_MULTIPLAYER, + false); + } + } + } + } else { + for (int iPlayer = 0; iPlayer < XUSER_MAX_COUNT; + iPlayer++) { + if ((iPlayer != i) && + pMinecraft->localplayers[iPlayer]) { + if (g_NetworkManager.IsLocalGame()) { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, + false); + } else { + ProfileManager.SetCurrentGameActivity( + iPlayer, + CONTEXT_PRESENCE_MULTIPLAYER_1P, false); + } + } + } + } + SetAction(i, eAppAction_Idle); + } break; #ifdef __ORBIS__ - case eAppAction_OptionsSaveNoSpace: - { - SetAction(i,eAppAction_Idle); + case eAppAction_OptionsSaveNoSpace: { + SetAction(i, eAppAction_Idle); - SceSaveDataDialogParam param; - SceSaveDataDialogSystemMessageParam sysParam; - SceSaveDataDialogItems items; - SceSaveDataDirName dirName; + SceSaveDataDialogParam param; + SceSaveDataDialogSystemMessageParam sysParam; + SceSaveDataDialogItems items; + SceSaveDataDirName dirName; - sceSaveDataDialogParamInitialize(¶m); - param.mode = SCE_SAVE_DATA_DIALOG_MODE_SYSTEM_MSG; - param.dispType = SCE_SAVE_DATA_DIALOG_TYPE_SAVE; - memset(&sysParam,0,sizeof(sysParam)); - param.sysMsgParam = &sysParam; - param.sysMsgParam->sysMsgType = SCE_SAVE_DATA_DIALOG_SYSMSG_TYPE_NOSPACE_CONTINUABLE; - param.sysMsgParam->value = app.GetOptionsBlocksRequired(i); - memset(&items, 0, sizeof(items)); - param.items = &items; - param.items->userId = ProfileManager.getUserID(i); + sceSaveDataDialogParamInitialize(¶m); + param.mode = SCE_SAVE_DATA_DIALOG_MODE_SYSTEM_MSG; + param.dispType = SCE_SAVE_DATA_DIALOG_TYPE_SAVE; + memset(&sysParam, 0, sizeof(sysParam)); + param.sysMsgParam = &sysParam; + param.sysMsgParam->sysMsgType = + SCE_SAVE_DATA_DIALOG_SYSMSG_TYPE_NOSPACE_CONTINUABLE; + param.sysMsgParam->value = app.GetOptionsBlocksRequired(i); + memset(&items, 0, sizeof(items)); + param.items = &items; + param.items->userId = ProfileManager.getUserID(i); - int ret = sceSaveDataDialogInitialize(); - ret = sceSaveDataDialogOpen(¶m); + int ret = sceSaveDataDialogInitialize(); + ret = sceSaveDataDialogOpen(¶m); - app.SetOptionsSaveDataDialogRunning(true);//m_bOptionsSaveDataDialogRunning = true; - //pClass->m_eSaveIncompleteType = saveIncompleteType; + app.SetOptionsSaveDataDialogRunning( + true); // m_bOptionsSaveDataDialogRunning = true; + // pClass->m_eSaveIncompleteType = saveIncompleteType; - //StorageManager.SetSaveDisabled(true); - //pClass->EnterSaveNotificationSection(); + // StorageManager.SetSaveDisabled(true); + // pClass->EnterSaveNotificationSection(); - } - break; + } break; #endif - case eAppAction_ExitWorld: - pMinecraft->exitingWorldRightNow = true; - SetAction(i,eAppAction_Idle); + case eAppAction_ExitWorld: + pMinecraft->exitingWorldRightNow = true; + SetAction(i, eAppAction_Idle); - // If we're already leaving don't exit - if (g_NetworkManager.IsLeavingGame()) - { - break; - } + // If we're already leaving don't exit + if (g_NetworkManager.IsLeavingGame()) { + break; + } - pMinecraft->gui->clearMessages(); + pMinecraft->gui->clearMessages(); - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - // reset the flag stopping new dlc message being shown if you've seen the message before - DisplayNewDLCTipAgain(); + // reset the flag stopping new dlc message being shown if + // you've seen the message before + DisplayNewDLCTipAgain(); - // clear the autosave timer that might be on screen - ui.ShowAutosaveCountdownTimer(false); + // clear the autosave timer that might be on screen + ui.ShowAutosaveCountdownTimer(false); - // Hide the selected item text - ui.HideAllGameUIElements(); + // Hide the selected item text + ui.HideAllGameUIElements(); - // Since the player forced the exit, let's flush any profile writes, and hope we're not breaking TCR 136... -#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - StorageManager.ForceQueuedProfileWrites(); - LeaderboardManager::Instance()->OpenSession(); - for (int j = 0; j < XUSER_MAX_COUNT; j++) - { - if( ProfileManager.IsSignedIn(j) ) - { - app.DebugPrintf("Stats save for an offline game for the player at index %d\n", 0); - Minecraft::GetInstance()->forceStatsSave(j); - } - } - LeaderboardManager::Instance()->CloseSession(); + // Since the player forced the exit, let's flush any profile + // writes, and hope we're not breaking TCR 136... +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + StorageManager.ForceQueuedProfileWrites(); + LeaderboardManager::Instance()->OpenSession(); + for (int j = 0; j < XUSER_MAX_COUNT; j++) { + if (ProfileManager.IsSignedIn(j)) { + app.DebugPrintf( + "Stats save for an offline game for the player " + "at index %d\n", + 0); + Minecraft::GetInstance()->forceStatsSave(j); + } + } + LeaderboardManager::Instance()->CloseSession(); #elif (defined _XBOX) - ProfileManager.ForceQueuedProfileWrites(); + ProfileManager.ForceQueuedProfileWrites(); #endif - // 4J-PB - cancel any possible string verifications queued with LIVE - //InputManager.CancelAllVerifyInProgress(); + // 4J-PB - cancel any possible string verifications queued + // with LIVE + // InputManager.CancelAllVerifyInProgress(); - if(ProfileManager.IsFullVersion()) - { - - // In a split screen, only the primary player actually quits the game, others just remove their players - if( i != ProfileManager.GetPrimaryPad() ) - { - // Make sure we've not got this player selected as current - this shouldn't be the case anyway - pMinecraft->setLocalPlayerIdx(ProfileManager.GetPrimaryPad()); - pMinecraft->removeLocalPlayerIdx(i); + if (ProfileManager.IsFullVersion()) { + // In a split screen, only the primary player actually + // quits the game, others just remove their players + if (i != ProfileManager.GetPrimaryPad()) { + // Make sure we've not got this player selected as + // current - this shouldn't be the case anyway + pMinecraft->setLocalPlayerIdx( + ProfileManager.GetPrimaryPad()); + pMinecraft->removeLocalPlayerIdx(i); #ifdef _DURANGO - ProfileManager.RemoveGamepadFromGame(i); -#endif - SetAction(i,eAppAction_Idle); - return; - } - // flag to capture the save thumbnail - SetAction(i,eAppAction_ExitWorldCapturedThumbnail, param); - } - else - { - // ask the player if they would like to upgrade, or they'll lose the level - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_OK; - uiIDA[1]=IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, 2, i,&CMinecraftApp::UnlockFullExitReturned,this,app.GetStringTable()); - } - - // Change the presence info - // Are we offline or online, and how many players are there - - if(g_NetworkManager.GetPlayerCount()>1) - { - for(int j=0;jlocalplayers[j]) - { - if(g_NetworkManager.IsLocalGame()) - { - app.SetRichPresenceContext(j,CONTEXT_GAME_STATE_BLANK); - ProfileManager.SetCurrentGameActivity(j,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); - } - else - { - app.SetRichPresenceContext(j,CONTEXT_GAME_STATE_BLANK); - ProfileManager.SetCurrentGameActivity(j,CONTEXT_PRESENCE_MULTIPLAYER,false); - } - TelemetryManager->RecordLevelExit(j, eSen_LevelExitStatus_Exited); - } - } - } - else - { - app.SetRichPresenceContext(i,CONTEXT_GAME_STATE_BLANK); - if(g_NetworkManager.IsLocalGame()) - { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); - } - else - { - ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1P,false); - } - TelemetryManager->RecordLevelExit(i, eSen_LevelExitStatus_Exited); - } - break; - case eAppAction_ExitWorldCapturedThumbnail: - { - SetAction(i,eAppAction_Idle); - // Stop app running - SetGameStarted(false); - SetChangingSessionType(true); // Added to stop handling ethernet disconnects - - ui.CloseAllPlayersScenes(); - - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); - - // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save - for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) - { -#ifdef _XBOX - app.TutorialSceneNavigateBack(idx,true); + ProfileManager.RemoveGamepadFromGame(i); #endif - - // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial - // It doesn't matter if they were in the tutorial already - pMinecraft->playerLeftTutorial( idx ); - } + SetAction(i, eAppAction_Idle); + return; + } + // flag to capture the save thumbnail + SetAction(i, eAppAction_ExitWorldCapturedThumbnail, + param); + } else { + // ask the player if they would like to upgrade, or + // they'll lose the level + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_OK; + uiIDA[1] = IDS_CONFIRM_CANCEL; + ui.RequestMessageBox( + IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, 2, + i, &CMinecraftApp::UnlockFullExitReturned, this, + app.GetStringTable()); + } - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &UIScene_PauseMenu::ExitWorldThreadProc; - loadingParams->lpParam = param; + // Change the presence info + // Are we offline or online, and how many players are there - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - // If param is non-null then this is a forced exit by the server, so make sure the player knows why - // 4J Stu - Changed - Don't use the FullScreenProgressScreen for action, use a dialog instead - completionData->bRequiresUserAction = FALSE;//(param != NULL) ? TRUE : FALSE; - completionData->bShowTips = (param != NULL) ? FALSE : TRUE; - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->type = e_ProgressCompletion_NavigateToHomeMenu; - completionData->iPad = DEFAULT_XUI_MENU_USER; - loadingParams->completionData = completionData; + if (g_NetworkManager.GetPlayerCount() > 1) { + for (int j = 0; j < XUSER_MAX_COUNT; j++) { + if (pMinecraft->localplayers[j]) { + if (g_NetworkManager.IsLocalGame()) { + app.SetRichPresenceContext( + j, CONTEXT_GAME_STATE_BLANK); + ProfileManager.SetCurrentGameActivity( + j, CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, + false); + } else { + app.SetRichPresenceContext( + j, CONTEXT_GAME_STATE_BLANK); + ProfileManager.SetCurrentGameActivity( + j, CONTEXT_PRESENCE_MULTIPLAYER, false); + } + TelemetryManager->RecordLevelExit( + j, eSen_LevelExitStatus_Exited); + } + } + } else { + app.SetRichPresenceContext(i, CONTEXT_GAME_STATE_BLANK); + if (g_NetworkManager.IsLocalGame()) { + ProfileManager.SetCurrentGameActivity( + i, CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, + false); + } else { + ProfileManager.SetCurrentGameActivity( + i, CONTEXT_PRESENCE_MULTIPLAYER_1P, false); + } + TelemetryManager->RecordLevelExit( + i, eSen_LevelExitStatus_Exited); + } + break; + case eAppAction_ExitWorldCapturedThumbnail: { + SetAction(i, eAppAction_Idle); + // Stop app running + SetGameStarted(false); + SetChangingSessionType( + true); // Added to stop handling ethernet disconnects - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); - } - break; - case eAppAction_ExitWorldTrial: - { - SetAction(i,eAppAction_Idle); + ui.CloseAllPlayersScenes(); - pMinecraft->gui->clearMessages(); + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); - - // Stop app running - SetGameStarted(false); - - ui.CloseAllPlayersScenes(); - - // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save - for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) - { + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving + // then exiting and selecting to save + for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX - app.TutorialSceneNavigateBack(idx,true); + app.TutorialSceneNavigateBack(idx, true); #endif - - // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial - // It doesn't matter if they were in the tutorial already - pMinecraft->playerLeftTutorial( idx ); - } - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &UIScene_PauseMenu::ExitWorldThreadProc; - loadingParams->lpParam = param; + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title + // crashed after exiting the tutorial It doesn't matter + // if they were in the tutorial already + pMinecraft->playerLeftTutorial(idx); + } - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->type = e_ProgressCompletion_NavigateToHomeMenu; - completionData->iPad = DEFAULT_XUI_MENU_USER; - loadingParams->completionData = completionData; - - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); - } + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &UIScene_PauseMenu::ExitWorldThreadProc; + loadingParams->lpParam = param; - break; - case eAppAction_ExitTrial: - //XLaunchNewImage(XLAUNCH_KEYWORD_DASH_ARCADE, 0); - ExitGame(); - break; + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + // If param is non-null then this is a forced exit by the + // server, so make sure the player knows why 4J Stu - + // Changed - Don't use the FullScreenProgressScreen for + // action, use a dialog instead + completionData->bRequiresUserAction = + FALSE; //(param != NULL) ? TRUE : FALSE; + completionData->bShowTips = (param != NULL) ? FALSE : TRUE; + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->type = + e_ProgressCompletion_NavigateToHomeMenu; + completionData->iPad = DEFAULT_XUI_MENU_USER; + loadingParams->completionData = completionData; - case eAppAction_Respawn: - { - ConnectionProgressParams *param = new ConnectionProgressParams(); - param->iPad = i; - param->stringId = IDS_PROGRESS_RESPAWNING; - param->showTooltips = false; - param->setFailTimer = false; - ui.NavigateToScene(i,eUIScene_ConnectingProgress, param); - - // Need to reset this incase the player has already died and respawned - pMinecraft->localplayers[i]->SetPlayerRespawned(false); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams); + } break; + case eAppAction_ExitWorldTrial: { + SetAction(i, eAppAction_Idle); - SetAction(i,eAppAction_WaitForRespawnComplete); - if( app.GetLocalPlayerCount()>1 ) - { - // In split screen mode, we don't want to do any async loading or flushing of the cache, just a simple respawn - pMinecraft->localplayers[i]->respawn(); + pMinecraft->gui->clearMessages(); - // If the respawn requires a dimension change then the action will have changed - //if(app.GetXuiAction(i) == eAppAction_Respawn) - //{ - // SetAction(i,eAppAction_Idle); - // CloseXuiScenes(i); - //} - } - else - { - //SetAction(i,eAppAction_WaitForRespawnComplete); + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - //LoadingInputParams *loadingParams = new LoadingInputParams(); - //loadingParams->func = &CScene_Death::RespawnThreadProc; - //loadingParams->lpParam = (LPVOID)i; + // Stop app running + SetGameStarted(false); - // Disable game & update thread whilst we do any of this - //app.SetGameStarted(false); - pMinecraft->gameRenderer->DisableUpdateThread(); - - // 4J Stu - We don't need this on a thread in multiplayer as respawning is asynchronous. - pMinecraft->localplayers[i]->respawn(); + ui.CloseAllPlayersScenes(); - //app.SetGameStarted(true); - pMinecraft->gameRenderer->EnableUpdateThread(); - - //UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - //completionData->bShowBackground=TRUE; - //completionData->bShowLogo=TRUE; - //completionData->type = e_ProgressCompletion_CloseUIScenes; - //completionData->iPad = i; - //loadingParams->completionData = completionData; - - //app.NavigateToScene(i,eUIScene_FullscreenProgress, loadingParams, true); - } - } - break; - case eAppAction_WaitForRespawnComplete: - player = pMinecraft->localplayers[i]; - if(player != NULL && player->GetPlayerRespawned()) - { - SetAction(i,eAppAction_Idle); - - if(ui.IsSceneInStack(i, eUIScene_EndPoem)) - { - ui.NavigateBack(i,false,eUIScene_EndPoem); - } - else - { - ui.CloseUIScenes(i); - } - - // clear the progress messages - -// pMinecraft->progressRenderer->progressStart(-1); -// pMinecraft->progressRenderer->progressStage(-1); - } - else if(!g_NetworkManager.IsInGameplay()) - { - SetAction(i,eAppAction_Idle); - } - break; - case eAppAction_WaitForDimensionChangeComplete: - player = pMinecraft->localplayers[i]; - if(player != NULL && player->connection && player->connection->isStarted()) - { - SetAction(i,eAppAction_Idle); - ui.CloseUIScenes(i); - } - else if(!g_NetworkManager.IsInGameplay()) - { - SetAction(i,eAppAction_Idle); - } - break; - case eAppAction_PrimaryPlayerSignedOut: - { - //SetAction(i,eAppAction_Idle); - - // clear the autosavetimer that might be displayed - ui.ShowAutosaveCountdownTimer(false); - - // If the player signs out before the game started the server can be killed a bit earlier to stop - // the loading or saving of a new game continuing running while the UI/Guide is up - if(!app.GetGameStarted()) MinecraftServer::HaltServer(true); - - // inform the player they are being returned to the menus because they signed out - StorageManager.SetSaveDeviceSelected(i,false); - // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game - StatsCounter* pStats = Minecraft::GetInstance()->stats[ i ]; - pStats->clear(); - - // 4J-PB - the libs will display the Returned to Title screen -// unsigned int uiIDA[1]; -// uiIDA[0]=IDS_CONFIRM_OK; -// -// ui.RequestMessageBox(IDS_RETURNEDTOMENU_TITLE, IDS_RETURNEDTOTITLESCREEN_TEXT, uiIDA, 1, i,&CMinecraftApp::PrimaryPlayerSignedOutReturned,this,app.GetStringTable()); - if( g_NetworkManager.IsInSession() ) - { - app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned); - } - else - { - app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned_Menus); - MinecraftServer::resetFlags(); - } - } - break; - case eAppAction_EthernetDisconnected: - { - app.DebugPrintf("Handling eAppAction_EthernetDisconnected\n"); - SetAction(i,eAppAction_Idle); - - // 4J Stu - Fix for #12530 -TCR 001 BAS Game Stability: Title will crash if the player disconnects while starting a new world and then opts to play the tutorial once they have been returned to the Main Menu. - if(!g_NetworkManager.IsLeavingGame()) - { - app.DebugPrintf("Handling eAppAction_EthernetDisconnected - Not leaving game\n"); - // 4J-PB - not the same as a signout. We should only leave the game if this machine is not the host. We shouldn't get rid of the save device either. - if( g_NetworkManager.IsHost() ) - { - app.DebugPrintf("Handling eAppAction_EthernetDisconnected - Is Host\n"); - // If it's already a local game, then an ethernet disconnect should have no effect - if( !g_NetworkManager.IsLocalGame() && g_NetworkManager.IsInGameplay() ) - { - // Change the session to an offline session - SetAction(i,eAppAction_ChangeSessionType); - } - else if(!g_NetworkManager.IsLocalGame() && !g_NetworkManager.IsInGameplay() ) - { - // There are two cases here, either: - // 1. We're early enough in the create/load game that we can do a really minimal shutdown or - // 2. We're far enough in (game has started but the actual game started flag hasn't been set) that we should just wait until we're in the game and switch to offline mode - - // If there's a non-null level then, for our purposes, the game has started - bool gameStarted = false; - for(int i = 0; i < pMinecraft->levels.length; i++) - { - if (pMinecraft->levels.data[i] != nullptr) - { - gameStarted = true; - break; - } - } - - if (!gameStarted) - { - // 1. Exit - MinecraftServer::HaltServer(); - - // Fix for #12530 - TCR 001 BAS Game Stability: Title will crash if the player disconnects while starting a new world and then opts to play the tutorial once they have been returned to the Main Menu. - // 4J Stu - Leave the session - g_NetworkManager.LeaveGame(FALSE); - - // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game - StatsCounter* pStats = Minecraft::GetInstance()->stats[ i ]; - pStats->clear(); - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - - ui.RequestMessageBox(g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST), g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE), uiIDA, 1, i,&CMinecraftApp::EthernetDisconnectReturned,this, app.GetStringTable()); - } - else - { - // 2. Switch to offline - SetAction(i,eAppAction_ChangeSessionType); - } - } - } - else - { - app.DebugPrintf("Handling eAppAction_EthernetDisconnected - Not host\n"); - // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game - StatsCounter* pStats = Minecraft::GetInstance()->stats[ i ]; - pStats->clear(); - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - - ui.RequestMessageBox(g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST), g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE), uiIDA, 1, i,&CMinecraftApp::EthernetDisconnectReturned,this, app.GetStringTable()); - } - } - } - break; - // We currently handle both these returns the same way. - case eAppAction_EthernetDisconnectedReturned: - case eAppAction_PrimaryPlayerSignedOutReturned: - { - SetAction(i,eAppAction_Idle); - - pMinecraft->gui->clearMessages(); - - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); - - // set the state back to pre-game - ProfileManager.ResetProfileProcessState(); - - - if( g_NetworkManager.IsLeavingGame() ) - { - // 4J Stu - If we are already leaving the game, then we just need to signal that the player signed out to stop saves - pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME ); - pMinecraft->progressRenderer->progressStage(-1); - // This has no effect on client machines - MinecraftServer::HaltServer(true); - } - else - { - // Stop app running - SetGameStarted(false); - - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); - - ui.CloseAllPlayersScenes(); - - // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save - for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) - { + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving + // then exiting and selecting to save + for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX - app.TutorialSceneNavigateBack(idx,true); + app.TutorialSceneNavigateBack(idx, true); #endif - - // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial - // It doesn't matter if they were in the tutorial already - pMinecraft->playerLeftTutorial( idx ); - } - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CMinecraftApp::SignoutExitWorldThreadProc; + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title + // crashed after exiting the tutorial It doesn't matter + // if they were in the tutorial already + pMinecraft->playerLeftTutorial(idx); + } - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->iPad=DEFAULT_XUI_MENU_USER; - completionData->type = e_ProgressCompletion_NavigateToHomeMenu; - loadingParams->completionData = completionData; + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &UIScene_PauseMenu::ExitWorldThreadProc; + loadingParams->lpParam = param; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); - } - } - break; - case eAppAction_PrimaryPlayerSignedOutReturned_Menus: - SetAction(i,eAppAction_Idle); - // set the state back to pre-game - ProfileManager.ResetProfileProcessState(); - // clear the save device - StorageManager.SetSaveDeviceSelected(i,false); + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->type = + e_ProgressCompletion_NavigateToHomeMenu; + completionData->iPad = DEFAULT_XUI_MENU_USER; + loadingParams->completionData = completionData; - ui.UpdatePlayerBasePositions(); - // there are multiple layers in the help menu, so a navigate back isn't enough - ui.NavigateToHomeMenu(); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams); + } - break; - case eAppAction_EthernetDisconnectedReturned_Menus: - SetAction(i,eAppAction_Idle); - // set the state back to pre-game - ProfileManager.ResetProfileProcessState(); + break; + case eAppAction_ExitTrial: + // XLaunchNewImage(XLAUNCH_KEYWORD_DASH_ARCADE, 0); + ExitGame(); + break; - ui.UpdatePlayerBasePositions(); + case eAppAction_Respawn: { + ConnectionProgressParams* param = + new ConnectionProgressParams(); + param->iPad = i; + param->stringId = IDS_PROGRESS_RESPAWNING; + param->showTooltips = false; + param->setFailTimer = false; + ui.NavigateToScene(i, eUIScene_ConnectingProgress, param); - // there are multiple layers in the help menu, so a navigate back isn't enough - ui.NavigateToHomeMenu(); + // Need to reset this incase the player has already died and + // respawned + pMinecraft->localplayers[i]->SetPlayerRespawned(false); - break; + SetAction(i, eAppAction_WaitForRespawnComplete); + if (app.GetLocalPlayerCount() > 1) { + // In split screen mode, we don't want to do any async + // loading or flushing of the cache, just a simple + // respawn + pMinecraft->localplayers[i]->respawn(); - case eAppAction_TrialOver: - { - SetAction(i,eAppAction_Idle); - unsigned int uiIDA[2]; - uiIDA[0]=IDS_UNLOCK_TITLE; - uiIDA[1]=IDS_EXIT_GAME; + // If the respawn requires a dimension change then the + // action will have changed + // if(app.GetXuiAction(i) == eAppAction_Respawn) + //{ + // SetAction(i,eAppAction_Idle); + // CloseXuiScenes(i); + //} + } else { + // SetAction(i,eAppAction_WaitForRespawnComplete); - ui.RequestMessageBox(IDS_TRIALOVER_TITLE, IDS_TRIALOVER_TEXT, uiIDA, 2, i,&CMinecraftApp::TrialOverReturned,this,app.GetStringTable()); - } - break; + // LoadingInputParams *loadingParams = new + // LoadingInputParams(); loadingParams->func = + // &CScene_Death::RespawnThreadProc; + // loadingParams->lpParam = (LPVOID)i; - // INVITES - case eAppAction_DashboardTrialJoinFromInvite: - { - TelemetryManager->RecordUpsellPresented(i, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID); + // Disable game & update thread whilst we do any of this + // app.SetGameStarted(false); + pMinecraft->gameRenderer->DisableUpdateThread(); - SetAction(i,eAppAction_Idle); - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_OK; - uiIDA[1]=IDS_CONFIRM_CANCEL; + // 4J Stu - We don't need this on a thread in + // multiplayer as respawning is asynchronous. + pMinecraft->localplayers[i]->respawn(); - ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_ACCEPT_INVITE, uiIDA, 2, i,&CMinecraftApp::UnlockFullInviteReturned,this,app.GetStringTable()); - } - break; - case eAppAction_ExitAndJoinFromInvite: - { - unsigned int uiIDA[3]; + // app.SetGameStarted(true); + pMinecraft->gameRenderer->EnableUpdateThread(); - SetAction(i,eAppAction_Idle); - // Check the player really wants to do this + // UIFullscreenProgressCompletionData *completionData = + // new UIFullscreenProgressCompletionData(); + // completionData->bShowBackground=TRUE; + // completionData->bShowLogo=TRUE; + // completionData->type = + // e_ProgressCompletion_CloseUIScenes; + // completionData->iPad = i; + // loadingParams->completionData = completionData; + + // app.NavigateToScene(i,eUIScene_FullscreenProgress, + // loadingParams, true); + } + } break; + case eAppAction_WaitForRespawnComplete: + player = pMinecraft->localplayers[i]; + if (player != NULL && player->GetPlayerRespawned()) { + SetAction(i, eAppAction_Idle); + + if (ui.IsSceneInStack(i, eUIScene_EndPoem)) { + ui.NavigateBack(i, false, eUIScene_EndPoem); + } else { + ui.CloseUIScenes(i); + } + + // clear the progress messages + + // pMinecraft->progressRenderer->progressStart(-1); + // pMinecraft->progressRenderer->progressStage(-1); + } else if (!g_NetworkManager.IsInGameplay()) { + SetAction(i, eAppAction_Idle); + } + break; + case eAppAction_WaitForDimensionChangeComplete: + player = pMinecraft->localplayers[i]; + if (player != NULL && player->connection && + player->connection->isStarted()) { + SetAction(i, eAppAction_Idle); + ui.CloseUIScenes(i); + } else if (!g_NetworkManager.IsInGameplay()) { + SetAction(i, eAppAction_Idle); + } + break; + case eAppAction_PrimaryPlayerSignedOut: { + // SetAction(i,eAppAction_Idle); + + // clear the autosavetimer that might be displayed + ui.ShowAutosaveCountdownTimer(false); + + // If the player signs out before the game started the + // server can be killed a bit earlier to stop the loading or + // saving of a new game continuing running while the + // UI/Guide is up + if (!app.GetGameStarted()) + MinecraftServer::HaltServer(true); + + // inform the player they are being returned to the menus + // because they signed out + StorageManager.SetSaveDeviceSelected(i, false); + // need to clear the player stats - can't assume it'll be + // done in setlevel - we may not be in the game + StatsCounter* pStats = Minecraft::GetInstance()->stats[i]; + pStats->clear(); + + // 4J-PB - the libs will display the Returned to Title + // screen + // unsigned int uiIDA[1]; + // uiIDA[0]=IDS_CONFIRM_OK; + // + // ui.RequestMessageBox(IDS_RETURNEDTOMENU_TITLE, + // IDS_RETURNEDTOTITLESCREEN_TEXT, uiIDA, 1, + // i,&CMinecraftApp::PrimaryPlayerSignedOutReturned,this,app.GetStringTable()); + if (g_NetworkManager.IsInSession()) { + app.SetAction( + i, eAppAction_PrimaryPlayerSignedOutReturned); + } else { + app.SetAction( + i, eAppAction_PrimaryPlayerSignedOutReturned_Menus); + MinecraftServer::resetFlags(); + } + } break; + case eAppAction_EthernetDisconnected: { + app.DebugPrintf( + "Handling eAppAction_EthernetDisconnected\n"); + SetAction(i, eAppAction_Idle); + + // 4J Stu - Fix for #12530 -TCR 001 BAS Game Stability: + // Title will crash if the player disconnects while starting + // a new world and then opts to play the tutorial once they + // have been returned to the Main Menu. + if (!g_NetworkManager.IsLeavingGame()) { + app.DebugPrintf( + "Handling eAppAction_EthernetDisconnected - Not " + "leaving game\n"); + // 4J-PB - not the same as a signout. We should only + // leave the game if this machine is not the host. We + // shouldn't get rid of the save device either. + if (g_NetworkManager.IsHost()) { + app.DebugPrintf( + "Handling eAppAction_EthernetDisconnected - Is " + "Host\n"); + // If it's already a local game, then an ethernet + // disconnect should have no effect + if (!g_NetworkManager.IsLocalGame() && + g_NetworkManager.IsInGameplay()) { + // Change the session to an offline session + SetAction(i, eAppAction_ChangeSessionType); + } else if (!g_NetworkManager.IsLocalGame() && + !g_NetworkManager.IsInGameplay()) { + // There are two cases here, either: + // 1. We're early enough in the + //create/load game that we can do a really + //minimal shutdown or + // 2. We're far enough in (game has started + // but the actual game started flag hasn't + // been set) that we should just wait until + // we're in the game and switch to offline + // mode + + // If there's a non-null level then, for our + // purposes, the game has started + bool gameStarted = false; + for (int i = 0; i < pMinecraft->levels.length; + i++) { + if (pMinecraft->levels.data[i] != nullptr) { + gameStarted = true; + break; + } + } + + if (!gameStarted) { + // 1. Exit + MinecraftServer::HaltServer(); + + // Fix for #12530 - TCR 001 BAS Game + // Stability: Title will crash if the player + // disconnects while starting a new world + // and then opts to play the tutorial once + // they have been returned to the Main Menu. + // 4J Stu - Leave the session + g_NetworkManager.LeaveGame(FALSE); + + // need to clear the player stats - can't + // assume it'll be done in setlevel - we may + // not be in the game + StatsCounter* pStats = + Minecraft::GetInstance()->stats[i]; + pStats->clear(); + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + + ui.RequestMessageBox( + g_NetworkManager.CorrectErrorIDS( + IDS_CONNECTION_LOST), + g_NetworkManager.CorrectErrorIDS( + IDS_CONNECTION_LOST_LIVE), + uiIDA, 1, i, + &CMinecraftApp:: + EthernetDisconnectReturned, + this, app.GetStringTable()); + } else { + // 2. Switch to offline + SetAction(i, eAppAction_ChangeSessionType); + } + } + } else { + app.DebugPrintf( + "Handling eAppAction_EthernetDisconnected - " + "Not host\n"); + // need to clear the player stats - can't assume + // it'll be done in setlevel - we may not be in the + // game + StatsCounter* pStats = + Minecraft::GetInstance()->stats[i]; + pStats->clear(); + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + + ui.RequestMessageBox( + g_NetworkManager.CorrectErrorIDS( + IDS_CONNECTION_LOST), + g_NetworkManager.CorrectErrorIDS( + IDS_CONNECTION_LOST_LIVE), + uiIDA, 1, i, + &CMinecraftApp::EthernetDisconnectReturned, + this, app.GetStringTable()); + } + } + } break; + // We currently handle both these returns the same way. + case eAppAction_EthernetDisconnectedReturned: + case eAppAction_PrimaryPlayerSignedOutReturned: { + SetAction(i, eAppAction_Idle); + + pMinecraft->gui->clearMessages(); + + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); + + // set the state back to pre-game + ProfileManager.ResetProfileProcessState(); + + if (g_NetworkManager.IsLeavingGame()) { + // 4J Stu - If we are already leaving the game, then we + // just need to signal that the player signed out to + // stop saves + pMinecraft->progressRenderer->progressStartNoAbort( + IDS_EXITING_GAME); + pMinecraft->progressRenderer->progressStage(-1); + // This has no effect on client machines + MinecraftServer::HaltServer(true); + } else { + // Stop app running + SetGameStarted(false); + + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); + + ui.CloseAllPlayersScenes(); + + // 4J Stu - Fix for #12368 - Crash: Game crashes when + // saving then exiting and selecting to save + for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; + ++idx) { +#ifdef _XBOX + app.TutorialSceneNavigateBack(idx, true); +#endif + + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title + // crashed after exiting the tutorial It doesn't + // matter if they were in the tutorial already + pMinecraft->playerLeftTutorial(idx); + } + + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &CMinecraftApp::SignoutExitWorldThreadProc; + + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->iPad = DEFAULT_XUI_MENU_USER; + completionData->type = + e_ProgressCompletion_NavigateToHomeMenu; + loadingParams->completionData = completionData; + + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams); + } + } break; + case eAppAction_PrimaryPlayerSignedOutReturned_Menus: + SetAction(i, eAppAction_Idle); + // set the state back to pre-game + ProfileManager.ResetProfileProcessState(); + // clear the save device + StorageManager.SetSaveDeviceSelected(i, false); + + ui.UpdatePlayerBasePositions(); + // there are multiple layers in the help menu, so a navigate + // back isn't enough + ui.NavigateToHomeMenu(); + + break; + case eAppAction_EthernetDisconnectedReturned_Menus: + SetAction(i, eAppAction_Idle); + // set the state back to pre-game + ProfileManager.ResetProfileProcessState(); + + ui.UpdatePlayerBasePositions(); + + // there are multiple layers in the help menu, so a navigate + // back isn't enough + ui.NavigateToHomeMenu(); + + break; + + case eAppAction_TrialOver: { + SetAction(i, eAppAction_Idle); + unsigned int uiIDA[2]; + uiIDA[0] = IDS_UNLOCK_TITLE; + uiIDA[1] = IDS_EXIT_GAME; + + ui.RequestMessageBox(IDS_TRIALOVER_TITLE, + IDS_TRIALOVER_TEXT, uiIDA, 2, i, + &CMinecraftApp::TrialOverReturned, + this, app.GetStringTable()); + } break; + + // INVITES + case eAppAction_DashboardTrialJoinFromInvite: { + TelemetryManager->RecordUpsellPresented( + i, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID); + + SetAction(i, eAppAction_Idle); + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_OK; + uiIDA[1] = IDS_CONFIRM_CANCEL; + + ui.RequestMessageBox( + IDS_UNLOCK_TITLE, IDS_UNLOCK_ACCEPT_INVITE, uiIDA, 2, i, + &CMinecraftApp::UnlockFullInviteReturned, this, + app.GetStringTable()); + } break; + case eAppAction_ExitAndJoinFromInvite: { + unsigned int uiIDA[3]; + + SetAction(i, eAppAction_Idle); + // Check the player really wants to do this #if defined(_XBOX_ONE) || defined(__ORBIS__) - // Show save option is saves ARE disabled - if(ProfileManager.IsFullVersion() && StorageManager.GetSaveDisabled() && i==ProfileManager.GetPrimaryPad() && g_NetworkManager.IsHost() && GetGameStarted() ) - { - uiIDA[0]=IDS_CONFIRM_CANCEL; - uiIDA[1]=IDS_EXIT_GAME_SAVE; - uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; + // Show save option is saves ARE disabled + if (ProfileManager.IsFullVersion() && + StorageManager.GetSaveDisabled() && + i == ProfileManager.GetPrimaryPad() && + g_NetworkManager.IsHost() && GetGameStarted()) { + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_EXIT_GAME_SAVE; + uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; - ui.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, 3, i,&CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned,this, app.GetStringTable(), 0, 0, false); - } - else + ui.RequestMessageBox( + IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, + 3, i, + &CMinecraftApp:: + ExitAndJoinFromInviteSaveDialogReturned, + this, app.GetStringTable(), 0, 0, false); + } else #else - if(ProfileManager.IsFullVersion() && !StorageManager.GetSaveDisabled() && i==ProfileManager.GetPrimaryPad() && g_NetworkManager.IsHost() && GetGameStarted() ) - { - uiIDA[0]=IDS_CONFIRM_CANCEL; - uiIDA[1]=IDS_EXIT_GAME_SAVE; - uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; + if (ProfileManager.IsFullVersion() && + !StorageManager.GetSaveDisabled() && + i == ProfileManager.GetPrimaryPad() && + g_NetworkManager.IsHost() && GetGameStarted()) { + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_EXIT_GAME_SAVE; + uiIDA[2] = IDS_EXIT_GAME_NO_SAVE; - ui.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, 3, i,&CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned,this, app.GetStringTable(), 0, 0, false); - } - else + ui.RequestMessageBox( + IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, + 3, i, + &CMinecraftApp:: + ExitAndJoinFromInviteSaveDialogReturned, + this, app.GetStringTable(), 0, 0, false); + } else #endif - { - if(!ProfileManager.IsFullVersion()) - { - TelemetryManager->RecordUpsellPresented(i, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID); + { + if (!ProfileManager.IsFullVersion()) { + TelemetryManager->RecordUpsellPresented( + i, eSen_UpsellID_Full_Version_Of_Game, + app.m_dwOfferID); - // upsell - uiIDA[0]=IDS_CONFIRM_OK; - uiIDA[1]=IDS_CONFIRM_CANCEL; - ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_ACCEPT_INVITE, uiIDA, 2, i,&CMinecraftApp::UnlockFullInviteReturned,this,app.GetStringTable()); - } - else - { - uiIDA[0]=IDS_CONFIRM_CANCEL; - uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, 2,i,&CMinecraftApp::ExitAndJoinFromInvite,this,app.GetStringTable(), 0, 0, false); - } - } - } - break; - case eAppAction_ExitAndJoinFromInviteConfirmed: - { - SetAction(i,eAppAction_Idle); + // upsell + uiIDA[0] = IDS_CONFIRM_OK; + uiIDA[1] = IDS_CONFIRM_CANCEL; + ui.RequestMessageBox( + IDS_UNLOCK_TITLE, IDS_UNLOCK_ACCEPT_INVITE, + uiIDA, 2, i, + &CMinecraftApp::UnlockFullInviteReturned, this, + app.GetStringTable()); + } else { + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_CONFIRM_OK; + ui.RequestMessageBox( + IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, + uiIDA, 2, i, + &CMinecraftApp::ExitAndJoinFromInvite, this, + app.GetStringTable(), 0, 0, false); + } + } + } break; + case eAppAction_ExitAndJoinFromInviteConfirmed: { + SetAction(i, eAppAction_Idle); - pMinecraft->gui->clearMessages(); + pMinecraft->gui->clearMessages(); - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - // Stop app running - SetGameStarted(false); + // Stop app running + SetGameStarted(false); - ui.CloseAllPlayersScenes(); - - // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save - for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) - { + ui.CloseAllPlayersScenes(); + + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving + // then exiting and selecting to save + for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX - app.TutorialSceneNavigateBack(idx,true); + app.TutorialSceneNavigateBack(idx, true); #endif - - // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial - // It doesn't matter if they were in the tutorial already - pMinecraft->playerLeftTutorial( idx ); - } - // 4J-PB - may have been using a texture pack with audio , so clean up anything texture pack related here + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title + // crashed after exiting the tutorial It doesn't matter + // if they were in the tutorial already + pMinecraft->playerLeftTutorial(idx); + } - // unload any texture pack audio - // if there is audio in use, clear out the audio, and unmount the pack - TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=NULL; + // 4J-PB - may have been using a texture pack with audio , + // so clean up anything texture pack related here - if(pTexPack->hasAudio()) - { - // get the dlc texture pack, and store it - pDLCTexPack=(DLCTexturePack *)pTexPack; - } + // unload any texture pack audio + // if there is audio in use, clear out the audio, and + // unmount the pack + TexturePack* pTexPack = + Minecraft::GetInstance()->skins->getSelected(); + DLCTexturePack* pDLCTexPack = NULL; - // change to the default texture pack - pMinecraft->skins->selectTexturePackById(TexturePackRepository::DEFAULT_TEXTURE_PACK_ID); + if (pTexPack->hasAudio()) { + // get the dlc texture pack, and store it + pDLCTexPack = (DLCTexturePack*)pTexPack; + } - if(pTexPack->hasAudio()) - { - // need to stop the streaming audio - by playing streaming audio from the default texture pack now - // reset the streaming sounds back to the normal ones + // change to the default texture pack + pMinecraft->skins->selectTexturePackById( + TexturePackRepository::DEFAULT_TEXTURE_PACK_ID); + + if (pTexPack->hasAudio()) { + // need to stop the streaming audio - by playing + // streaming audio from the default texture pack now + // reset the streaming sounds back to the normal ones #ifndef _XBOX - pMinecraft->soundEngine->SetStreamingSounds(eStream_Overworld_Calm1,eStream_Overworld_piano3, - eStream_Nether1,eStream_Nether4, - eStream_end_dragon,eStream_end_end, - eStream_CD_1); + pMinecraft->soundEngine->SetStreamingSounds( + eStream_Overworld_Calm1, eStream_Overworld_piano3, + eStream_Nether1, eStream_Nether4, + eStream_end_dragon, eStream_end_end, eStream_CD_1); #endif - pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); + pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 1, + 1); #ifdef _XBOX - if(pDLCTexPack->m_pStreamedWaveBank!=NULL) - { - pDLCTexPack->m_pStreamedWaveBank->Destroy(); - } - if(pDLCTexPack->m_pSoundBank!=NULL) - { - pDLCTexPack->m_pSoundBank->Destroy(); - } + if (pDLCTexPack->m_pStreamedWaveBank != NULL) { + pDLCTexPack->m_pStreamedWaveBank->Destroy(); + } + if (pDLCTexPack->m_pSoundBank != NULL) { + pDLCTexPack->m_pSoundBank->Destroy(); + } #endif #ifdef _DURANGO - const unsigned int result = StorageManager.UnmountInstalledDLC(L"TPACK"); + const unsigned int result = + StorageManager.UnmountInstalledDLC(L"TPACK"); #else - const unsigned int result = StorageManager.UnmountInstalledDLC("TPACK"); + const unsigned int result = + StorageManager.UnmountInstalledDLC("TPACK"); #endif - app.DebugPrintf("Unmount result is %d\n",result); - } + app.DebugPrintf("Unmount result is %d\n", result); + } #ifdef _XBOX_ONE - // 4J Stu - It's possible that we can sign in/remove players between the mask initially being set and this point - m_InviteData.dwLocalUsersMask = 0; - for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index) - { - if(ProfileManager.IsSignedIn(index) ) - { - if(index==i || pMinecraft->localplayers[index]!=NULL ) - { - m_InviteData.dwLocalUsersMask |= g_NetworkManager.GetLocalPlayerMask( index ); - } - } - } + // 4J Stu - It's possible that we can sign in/remove players + // between the mask initially being set and this point + m_InviteData.dwLocalUsersMask = 0; + for (unsigned int index = 0; index < XUSER_MAX_COUNT; + ++index) { + if (ProfileManager.IsSignedIn(index)) { + if (index == i || + pMinecraft->localplayers[index] != NULL) { + m_InviteData.dwLocalUsersMask |= + g_NetworkManager.GetLocalPlayerMask(index); + } + } + } #endif - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CGameNetworkManager::ExitAndJoinFromInviteThreadProc; - loadingParams->lpParam = (LPVOID)&m_InviteData; + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &CGameNetworkManager::ExitAndJoinFromInviteThreadProc; + loadingParams->lpParam = (LPVOID)&m_InviteData; - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->iPad=DEFAULT_XUI_MENU_USER; - completionData->type = e_ProgressCompletion_NoAction; - loadingParams->completionData = completionData; + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->iPad = DEFAULT_XUI_MENU_USER; + completionData->type = e_ProgressCompletion_NoAction; + loadingParams->completionData = completionData; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); - } + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams); + } - break; - case eAppAction_JoinFromInvite: - { - SetAction(i,eAppAction_Idle); + break; + case eAppAction_JoinFromInvite: { + SetAction(i, eAppAction_Idle); - // 4J Stu - Move this state block from CPlatformNetworkManager::ExitAndJoinFromInviteThreadProc, as g_NetworkManager.JoinGameFromInviteInfo ultimately can call NavigateToScene, - /// and we should only be calling that from the main thread - app.SetTutorialMode( false ); + // 4J Stu - Move this state block from + // CPlatformNetworkManager::ExitAndJoinFromInviteThreadProc, + // as g_NetworkManager.JoinGameFromInviteInfo ultimately can + // call NavigateToScene, + /// and we should only be calling that from the main thread + app.SetTutorialMode(false); - g_NetworkManager.SetLocalGame(false); + g_NetworkManager.SetLocalGame(false); - JoinFromInviteData *inviteData = (JoinFromInviteData *)param; - // 4J-PB - clear any previous connection errors - Minecraft::GetInstance()->clearConnectionFailed(); + JoinFromInviteData* inviteData = (JoinFromInviteData*)param; + // 4J-PB - clear any previous connection errors + Minecraft::GetInstance()->clearConnectionFailed(); - app.DebugPrintf( "Changing Primary Pad on an invite accept - pad was %d, and is now %d\n", ProfileManager.GetPrimaryPad(), inviteData->dwUserIndex ); - ProfileManager.SetLockedProfile(inviteData->dwUserIndex); - ProfileManager.SetPrimaryPad(inviteData->dwUserIndex); + app.DebugPrintf( + "Changing Primary Pad on an invite accept - pad was " + "%d, and is now %d\n", + ProfileManager.GetPrimaryPad(), + inviteData->dwUserIndex); + ProfileManager.SetLockedProfile(inviteData->dwUserIndex); + ProfileManager.SetPrimaryPad(inviteData->dwUserIndex); #ifdef _XBOX_ONE - // 4J Stu - If a player is signed in (i.e. locked) but not in the mask, unlock them - for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index) - { - if( index != inviteData->dwUserIndex && ProfileManager.IsSignedIn(index) ) - { - if( (m_InviteData.dwLocalUsersMask & g_NetworkManager.GetLocalPlayerMask( index ) ) == 0 ) - { - ProfileManager.RemoveGamepadFromGame(index); - } - } - } + // 4J Stu - If a player is signed in (i.e. locked) but not + // in the mask, unlock them + for (unsigned int index = 0; index < XUSER_MAX_COUNT; + ++index) { + if (index != inviteData->dwUserIndex && + ProfileManager.IsSignedIn(index)) { + if ((m_InviteData.dwLocalUsersMask & + g_NetworkManager.GetLocalPlayerMask(index)) == + 0) { + ProfileManager.RemoveGamepadFromGame(index); + } + } + } #endif - // change the minecraft player name - Minecraft::GetInstance()->user->name = convStringToWstring( ProfileManager.GetGamertag(ProfileManager.GetPrimaryPad())); + // change the minecraft player name + Minecraft::GetInstance()->user->name = + convStringToWstring(ProfileManager.GetGamertag( + ProfileManager.GetPrimaryPad())); - bool success = g_NetworkManager.JoinGameFromInviteInfo( - inviteData->dwUserIndex, // dwUserIndex - inviteData->dwLocalUsersMask, // dwUserMask - inviteData->pInviteInfo ); // pInviteInfo + bool success = g_NetworkManager.JoinGameFromInviteInfo( + inviteData->dwUserIndex, // dwUserIndex + inviteData->dwLocalUsersMask, // dwUserMask + inviteData->pInviteInfo); // pInviteInfo - if( !success ) - { - app.DebugPrintf( "Failed joining game from invite\n" ); - //return hr; + if (!success) { + app.DebugPrintf("Failed joining game from invite\n"); + // return hr; - // 4J Stu - Copied this from XUI_FullScreenProgress to properly handle the fail case, as the thread will no longer be failing - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox( IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); - - ui.NavigateToHomeMenu(); - ui.UpdatePlayerBasePositions(); - } - } - break; - case eAppAction_ChangeSessionType: - { - // If we are not in gameplay yet, then wait until the server is setup before changing the session type - if( g_NetworkManager.IsInGameplay() ) - { - // This kicks off a thread that waits for the server to end, then closes the current session, starts a new one and joins the local players into it - - SetAction(i,eAppAction_Idle); + // 4J Stu - Copied this from XUI_FullScreenProgress to + // properly handle the fail case, as the thread will no + // longer be failing + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_CONNECTION_FAILED, + IDS_CONNECTION_LOST_SERVER, uiIDA, + 1, ProfileManager.GetPrimaryPad(), + NULL, NULL, app.GetStringTable()); - if( !GetChangingSessionType() && !g_NetworkManager.IsLocalGame() ) - { - SetGameStarted(false); - SetChangingSessionType(true); - SetReallyChangingSessionType(true); + ui.NavigateToHomeMenu(); + ui.UpdatePlayerBasePositions(); + } + } break; + case eAppAction_ChangeSessionType: { + // If we are not in gameplay yet, then wait until the server + // is setup before changing the session type + if (g_NetworkManager.IsInGameplay()) { + // This kicks off a thread that waits for the server to + // end, then closes the current session, starts a new + // one and joins the local players into it - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); + SetAction(i, eAppAction_Idle); - if( !ui.IsSceneInStack( ProfileManager.GetPrimaryPad(), eUIScene_EndPoem ) ) - { - ui.CloseAllPlayersScenes(); - } - ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), true); - - // Remove this line to fix: - // #49084 - TU5: Code: Gameplay: The title crashes every time client navigates to 'Play game' menu and loads/creates new game after a "Connection to Xbox LIVE was lost" message has appeared. - //app.NavigateToScene(0,eUIScene_Main); - - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CGameNetworkManager::ChangeSessionTypeThreadProc; - loadingParams->lpParam = NULL; + if (!GetChangingSessionType() && + !g_NetworkManager.IsLocalGame()) { + SetGameStarted(false); + SetChangingSessionType(true); + SetReallyChangingSessionType(true); - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); + // turn off the gamertags in splitscreen for the + // primary player, since they are about to be made + // fullscreen + ui.HideAllGameUIElements(); + + if (!ui.IsSceneInStack( + ProfileManager.GetPrimaryPad(), + eUIScene_EndPoem)) { + ui.CloseAllPlayersScenes(); + } + ui.ShowOtherPlayersBaseScene( + ProfileManager.GetPrimaryPad(), true); + + // Remove this line to fix: + // #49084 - TU5: Code: Gameplay: The title crashes + // every time client navigates to 'Play game' menu + // and loads/creates new game after a "Connection to + // Xbox LIVE was lost" message has appeared. + // app.NavigateToScene(0,eUIScene_Main); + + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = + &CGameNetworkManager:: + ChangeSessionTypeThreadProc; + loadingParams->lpParam = NULL; + + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); #ifdef __PS3__ - completionData->bRequiresUserAction=FALSE; + completionData->bRequiresUserAction = FALSE; #else - completionData->bRequiresUserAction=TRUE; + completionData->bRequiresUserAction = TRUE; #endif - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->iPad=DEFAULT_XUI_MENU_USER; - if( ui.IsSceneInStack( ProfileManager.GetPrimaryPad(), eUIScene_EndPoem ) ) - { - completionData->type = e_ProgressCompletion_NavigateBackToScene; - completionData->scene = eUIScene_EndPoem; - } - else - { - completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; - } - loadingParams->completionData = completionData; + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->iPad = DEFAULT_XUI_MENU_USER; + if (ui.IsSceneInStack( + ProfileManager.GetPrimaryPad(), + eUIScene_EndPoem)) { + completionData->type = + e_ProgressCompletion_NavigateBackToScene; + completionData->scene = eUIScene_EndPoem; + } else { + completionData->type = + e_ProgressCompletion_CloseAllPlayersUIScenes; + } + loadingParams->completionData = completionData; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); - } - } - else if( g_NetworkManager.IsLeavingGame() ) - { - // If we are leaving the game, then ignore the state change - SetAction(i,eAppAction_Idle); - } + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams); + } + } else if (g_NetworkManager.IsLeavingGame()) { + // If we are leaving the game, then ignore the state + // change + SetAction(i, eAppAction_Idle); + } #if 0 // 4J-HG - Took this out since ChangeSessionType is only set in two places (both in EthernetDisconnected) and this case is handled there, plus this breaks // this if statements original purpose (to allow us to wait for IsInGameplay before actioning switching to offline @@ -3606,463 +3807,518 @@ void CMinecraftApp::HandleXuiActions(void) } } #endif - } - break; - case eAppAction_SetDefaultOptions: - SetAction(i,eAppAction_Idle); -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - SetDefaultOptions((C4JStorage::PROFILESETTINGS *)param,i); + } break; + case eAppAction_SetDefaultOptions: + SetAction(i, eAppAction_Idle); +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + SetDefaultOptions((C4JStorage::PROFILESETTINGS*)param, i); #else - SetDefaultOptions((C_4JProfile::PROFILESETTINGS *)param,i); + SetDefaultOptions((C_4JProfile::PROFILESETTINGS*)param, i); #endif - // if the profile data has been changed, then force a profile write - // It seems we're allowed to break the 5 minute rule if it's the result of a user action - CheckGameSettingsChanged(true,i); + // if the profile data has been changed, then force a + // profile write It seems we're allowed to break the 5 + // minute rule if it's the result of a user action + CheckGameSettingsChanged(true, i); - break; - - case eAppAction_RemoteServerSave: - { - // If the remote server save has already finished, don't complete the action - if (GetGameStarted()) - { - SetAction(ProfileManager.GetPrimaryPad(), eAppAction_Idle); - break; - } + break; - SetAction(i,eAppAction_WaitRemoteServerSaveComplete); - - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { - ui.CloseUIScenes(i, true); - } + case eAppAction_RemoteServerSave: { + // If the remote server save has already finished, don't + // complete the action + if (GetGameStarted()) { + SetAction(ProfileManager.GetPrimaryPad(), + eAppAction_Idle); + break; + } - // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen - ui.HideAllGameUIElements(); + SetAction(i, eAppAction_WaitRemoteServerSaveComplete); - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CMinecraftApp::RemoteSaveThreadProc; - loadingParams->lpParam = NULL; + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { + ui.CloseUIScenes(i, true); + } - UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); - completionData->bRequiresUserAction=FALSE; - completionData->bShowBackground=TRUE; - completionData->bShowLogo=TRUE; - completionData->iPad=DEFAULT_XUI_MENU_USER; - if( ui.IsSceneInStack( ProfileManager.GetPrimaryPad(), eUIScene_EndPoem ) ) - { - completionData->type = e_ProgressCompletion_NavigateBackToScene; - completionData->scene = eUIScene_EndPoem; - } - else - { - completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; - } - loadingParams->completionData = completionData; + // turn off the gamertags in splitscreen for the primary + // player, since they are about to be made fullscreen + ui.HideAllGameUIElements(); - loadingParams->cancelFunc = &CMinecraftApp::ExitGameFromRemoteSave; - loadingParams->cancelText = IDS_TOOLTIPS_EXIT; + LoadingInputParams* loadingParams = + new LoadingInputParams(); + loadingParams->func = &CMinecraftApp::RemoteSaveThreadProc; + loadingParams->lpParam = NULL; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); - } - break; - case eAppAction_WaitRemoteServerSaveComplete: - // Do nothing - break; - case eAppAction_FailedToJoinNoPrivileges: - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); - if(result != C4JStorage::EMessage_Busy) SetAction(i,eAppAction_Idle); - } - break; - case eAppAction_ProfileReadError: - // Return player to the main menu - code largely copied from that for handling - // eAppAction_PrimaryPlayerSignedOut, although I don't think we should have got as - // far as needing to halt the server, or running the game, before returning to the menu - if(!app.GetGameStarted()) MinecraftServer::HaltServer(true); + UIFullscreenProgressCompletionData* completionData = + new UIFullscreenProgressCompletionData(); + completionData->bRequiresUserAction = FALSE; + completionData->bShowBackground = TRUE; + completionData->bShowLogo = TRUE; + completionData->iPad = DEFAULT_XUI_MENU_USER; + if (ui.IsSceneInStack(ProfileManager.GetPrimaryPad(), + eUIScene_EndPoem)) { + completionData->type = + e_ProgressCompletion_NavigateBackToScene; + completionData->scene = eUIScene_EndPoem; + } else { + completionData->type = + e_ProgressCompletion_CloseAllPlayersUIScenes; + } + loadingParams->completionData = completionData; - if( g_NetworkManager.IsInSession() ) - { - app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned); - } - else - { - app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned_Menus); - MinecraftServer::resetFlags(); - } - break; - - case eAppAction_BanLevel: - { - // It's possible that this state can get set after the game has been exited (e.g. by network disconnection) so we can't ban the level at that point - if(g_NetworkManager.IsInGameplay() && !g_NetworkManager.IsLeavingGame()) - { - TelemetryManager->RecordBanLevel(i); + loadingParams->cancelFunc = + &CMinecraftApp::ExitGameFromRemoteSave; + loadingParams->cancelText = IDS_TOOLTIPS_EXIT; -#if defined _XBOX - INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); - // write the level to the banned level list, and exit the world - AddLevelToBannedLevelList(i,((NetworkPlayerXbox *)pHost)->GetUID(),GetUniqueMapName(),true); -#elif defined _XBOX_ONE - INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); - AddLevelToBannedLevelList(i,pHost->GetUID(),GetUniqueMapName(),true); -#endif - // primary player would exit the world, secondary would exit the player - if(ProfileManager.GetPrimaryPad()==i) - { - SetAction(i,eAppAction_ExitWorld); - } - else - { - SetAction(i,eAppAction_ExitPlayer); - } - } - } - break; - case eAppAction_LevelInBanLevelList: - { - unsigned int uiIDA[2]; - uiIDA[0]=IDS_BUTTON_REMOVE_FROM_BAN_LIST; - uiIDA[1]=IDS_EXIT_GAME; + ui.NavigateToScene(ProfileManager.GetPrimaryPad(), + eUIScene_FullscreenProgress, + loadingParams); + } break; + case eAppAction_WaitRemoteServerSaveComplete: + // Do nothing + break; + case eAppAction_FailedToJoinNoPrivileges: { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + C4JStorage::EMessageResult result = ui.RequestMessageBox( + IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, + IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, NULL, + app.GetStringTable()); + if (result != C4JStorage::EMessage_Busy) + SetAction(i, eAppAction_Idle); + } break; + case eAppAction_ProfileReadError: + // Return player to the main menu - code largely copied from + // that for handling eAppAction_PrimaryPlayerSignedOut, + // although I don't think we should have got as far as + // needing to halt the server, or running the game, before + // returning to the menu + if (!app.GetGameStarted()) + MinecraftServer::HaltServer(true); - // pass in the gamertag format string - WCHAR wchFormat[40]; - INetworkPlayer *player = g_NetworkManager.GetLocalPlayerByUserIndex(i); + if (g_NetworkManager.IsInSession()) { + app.SetAction( + i, eAppAction_PrimaryPlayerSignedOutReturned); + } else { + app.SetAction( + i, eAppAction_PrimaryPlayerSignedOutReturned_Menus); + MinecraftServer::resetFlags(); + } + break; - // If not the primary player, but the primary player has banned this level and decided not to unban - // then we may have left the game by now - if(player) - { - swprintf(wchFormat, 40, L"%ls\n\n%%ls",player->GetOnlineName()); + case eAppAction_BanLevel: { + // It's possible that this state can get set after the game + // has been exited (e.g. by network disconnection) so we + // can't ban the level at that point + if (g_NetworkManager.IsInGameplay() && + !g_NetworkManager.IsLeavingGame()) { + TelemetryManager->RecordBanLevel(i); - C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_BANNED_LEVEL_TITLE, IDS_PLAYER_BANNED_LEVEL, uiIDA,2,i,&CMinecraftApp::BannedLevelDialogReturned,this, app.GetStringTable(),wchFormat); - if(result != C4JStorage::EMessage_Busy) SetAction(i,eAppAction_Idle); - } - else - { - SetAction(i,eAppAction_Idle); - } - } - break; - case eAppAction_DebugText: - // launch the xui for text entry - { -#ifdef _XBOX - CScene_TextEntry::XuiTextInputParams *pDebugTextParams= new CScene_TextEntry::XuiTextInputParams; - pDebugTextParams->iPad=i; - pDebugTextParams->wch=(WCHAR)param; - - app.NavigateToScene(i,eUIScene_TextEntry,pDebugTextParams); -#endif - SetAction(i,eAppAction_Idle); - } - break; - - case eAppAction_ReloadTexturePack: - { - SetAction(i,eAppAction_Idle); - Minecraft *pMinecraft = Minecraft::GetInstance(); - pMinecraft->textures->reloadAll(); - pMinecraft->skins->updateUI(); - - if(!pMinecraft->skins->isUsingDefaultSkin()) - { - TexturePack *pTexturePack = pMinecraft->skins->getSelected(); - - DLCPack *pDLCPack=pTexturePack->getDLCPack(); - - bool purchased = false; - // do we have a license? - if(pDLCPack && pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { - purchased = true; - } -#ifdef _XBOX - TelemetryManager->RecordTexturePackLoaded(i, pTexturePack->getId(), purchased?1:0); -#endif - } - - // 4J-PB - If the texture pack has audio, we need to switch to this - if(pMinecraft->skins->getSelected()->hasAudio()) - { - Minecraft::GetInstance()->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); - } - } - - break; - - case eAppAction_TexturePackRequired: - { -#ifdef _XBOX - ULONGLONG ullOfferID_Full; - app.GetDLCFullOfferIDForPackID(app.GetRequiredTexturePackID(),&ullOfferID_Full); - - TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); -#endif - unsigned int uiIDA[2]; - - uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION; - uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION; - - // Give the player a warning about the texture pack missing - ui.RequestMessageBox(IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::TexturePackDialogReturned,this,app.GetStringTable()); - SetAction(i,eAppAction_Idle); - } - - break; - default: - break; - } - } - - // Any TMS actions? - - eTMS = app.GetTMSAction(i); - - if(eTMS!=eTMSAction_Idle) - { - switch(eTMS) - { - // TMS++ actions - case eTMSAction_TMSPP_RetrieveFiles_CreateLoad_SignInReturned: - case eTMSAction_TMSPP_RetrieveFiles_RunPlayGame: -#ifdef _XBOX - app.TMSPP_SetTitleGroupID(GROUP_ID); - SetTMSAction(i,eTMSAction_TMSPP_GlobalFileList); -#elif defined _XBOX_ONE - SetTMSAction(i,eTMSAction_TMSPP_GlobalFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_Title,eTMSAction_TMSPP_UserFileList); -#else - SetTMSAction(i,eTMSAction_TMSPP_UserFileList); - #endif - break; - -#ifdef _XBOX - case eTMSAction_TMSPP_GlobalFileList: - SetTMSAction(i,eTMSAction_TMSPP_GlobalFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_Title,"\\",eTMSAction_TMSPP_UserFileList); - break; -#endif - case eTMSAction_TMSPP_UserFileList: - // retrieve the file list first -#if defined _XBOX - SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,"\\",eTMSAction_TMSPP_XUIDSFile); -#elif defined _XBOX_ONE - SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,eTMSAction_TMSPP_DLCFile); -#else - SetTMSAction(i,eTMSAction_TMSPP_XUIDSFile); -#endif - break; - case eTMSAction_TMSPP_XUIDSFile: -#ifdef _XBOX - SetTMSAction(i,eTMSAction_TMSPP_XUIDSFile_Waiting); - // pass in the next app action on the call or callback completing - app.TMSPP_ReadXuidsFile(i,eTMSAction_TMSPP_DLCFile); -#else - SetTMSAction(i,eTMSAction_TMSPP_DLCFile); -#endif - - break; - case eTMSAction_TMSPP_DLCFile: -#if defined _XBOX || defined _XBOX_ONE - SetTMSAction(i,eTMSAction_TMSPP_DLCFile_Waiting); - // pass in the next app action on the call or callback completing - app.TMSPP_ReadDLCFile(i,eTMSAction_TMSPP_BannedListFile); -#else - SetTMSAction(i,eTMSAction_TMSPP_BannedListFile); -#endif - break; - case eTMSAction_TMSPP_BannedListFile: - // If we have one in TMSPP, then we can assume we can ignore TMS #if defined _XBOX - SetTMSAction(i,eTMSAction_TMSPP_BannedListFile_Waiting); - // pass in the next app action on the call or callback completing - if(app.TMSPP_ReadBannedList(i,eTMSAction_TMS_RetrieveFiles_Complete)==false) - { - // we don't have a banned list in TMSPP, so we should check TMS - app.ReadBannedList(i, eTMSAction_TMS_RetrieveFiles_Complete,true); - } + INetworkPlayer* pHost = + g_NetworkManager.GetHostPlayer(); + // write the level to the banned level list, and exit + // the world + AddLevelToBannedLevelList( + i, ((NetworkPlayerXbox*)pHost)->GetUID(), + GetUniqueMapName(), true); #elif defined _XBOX_ONE - SetTMSAction(i,eTMSAction_TMSPP_BannedListFile_Waiting); - // pass in the next app action on the call or callback completing - app.TMSPP_ReadBannedList(i,eTMSAction_TMS_RetrieveFiles_Complete); - -#else - SetTMSAction(i,eTMSAction_TMS_RetrieveFiles_Complete); + INetworkPlayer* pHost = + g_NetworkManager.GetHostPlayer(); + AddLevelToBannedLevelList(i, pHost->GetUID(), + GetUniqueMapName(), true); #endif - break; + // primary player would exit the world, secondary would + // exit the player + if (ProfileManager.GetPrimaryPad() == i) { + SetAction(i, eAppAction_ExitWorld); + } else { + SetAction(i, eAppAction_ExitPlayer); + } + } + } break; + case eAppAction_LevelInBanLevelList: { + unsigned int uiIDA[2]; + uiIDA[0] = IDS_BUTTON_REMOVE_FROM_BAN_LIST; + uiIDA[1] = IDS_EXIT_GAME; - // SPECIAL CASE - where the user goes directly in to Help & Options from the main menu - case eTMSAction_TMSPP_RetrieveFiles_HelpAndOptions: - case eTMSAction_TMSPP_RetrieveFiles_DLCMain: - // retrieve the file list first -#if defined _XBOX - // pass in the next app action on the call or callback completing - SetTMSAction(i,eTMSAction_TMSPP_XUIDSFile_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_Title,"\\",eTMSAction_TMSPP_DLCFileOnly); -#elif defined _XBOX_ONE - SetTMSAction(i,eTMSAction_TMSPP_GlobalFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_Title,eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly); -#else - SetTMSAction(i,eTMSAction_TMSPP_DLCFileOnly); + // pass in the gamertag format string + WCHAR wchFormat[40]; + INetworkPlayer* player = + g_NetworkManager.GetLocalPlayerByUserIndex(i); + + // If not the primary player, but the primary player has + // banned this level and decided not to unban then we may + // have left the game by now + if (player) { + swprintf(wchFormat, 40, L"%ls\n\n%%ls", + player->GetOnlineName()); + + C4JStorage::EMessageResult result = + ui.RequestMessageBox( + IDS_BANNED_LEVEL_TITLE, IDS_PLAYER_BANNED_LEVEL, + uiIDA, 2, i, + &CMinecraftApp::BannedLevelDialogReturned, this, + app.GetStringTable(), wchFormat); + if (result != C4JStorage::EMessage_Busy) + SetAction(i, eAppAction_Idle); + } else { + SetAction(i, eAppAction_Idle); + } + } break; + case eAppAction_DebugText: + // launch the xui for text entry + { +#ifdef _XBOX + CScene_TextEntry::XuiTextInputParams* pDebugTextParams = + new CScene_TextEntry::XuiTextInputParams; + pDebugTextParams->iPad = i; + pDebugTextParams->wch = (WCHAR)param; + + app.NavigateToScene(i, eUIScene_TextEntry, + pDebugTextParams); #endif - break; - case eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly: -#if defined _XBOX - SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,"\\",eTMSAction_TMSPP_XUIDSFile); + SetAction(i, eAppAction_Idle); + } + break; + + case eAppAction_ReloadTexturePack: { + SetAction(i, eAppAction_Idle); + Minecraft* pMinecraft = Minecraft::GetInstance(); + pMinecraft->textures->reloadAll(); + pMinecraft->skins->updateUI(); + + if (!pMinecraft->skins->isUsingDefaultSkin()) { + TexturePack* pTexturePack = + pMinecraft->skins->getSelected(); + + DLCPack* pDLCPack = pTexturePack->getDLCPack(); + + bool purchased = false; + // do we have a license? + if (pDLCPack && + pDLCPack->hasPurchasedFile( + DLCManager::e_DLCType_Texture, L"")) { + purchased = true; + } +#ifdef _XBOX + TelemetryManager->RecordTexturePackLoaded( + i, pTexturePack->getId(), purchased ? 1 : 0); +#endif + } + + // 4J-PB - If the texture pack has audio, we need to switch + // to this + if (pMinecraft->skins->getSelected()->hasAudio()) { + Minecraft::GetInstance()->soundEngine->playStreaming( + L"", 0, 0, 0, 1, 1); + } + } + + break; + + case eAppAction_TexturePackRequired: { +#ifdef _XBOX + ULONGLONG ullOfferID_Full; + app.GetDLCFullOfferIDForPackID( + app.GetRequiredTexturePackID(), &ullOfferID_Full); + + TelemetryManager->RecordUpsellPresented( + ProfileManager.GetPrimaryPad(), + eSet_UpsellID_Texture_DLC, + ullOfferID_Full & 0xFFFFFFFF); +#endif + unsigned int uiIDA[2]; + + uiIDA[0] = IDS_TEXTUREPACK_FULLVERSION; + uiIDA[1] = IDS_TEXTURE_PACK_TRIALVERSION; + + // Give the player a warning about the texture pack missing + ui.RequestMessageBox( + IDS_DLC_TEXTUREPACK_NOT_PRESENT_TITLE, + IDS_DLC_TEXTUREPACK_NOT_PRESENT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::TexturePackDialogReturned, this, + app.GetStringTable()); + SetAction(i, eAppAction_Idle); + } + + break; + default: + break; + } + } + + // Any TMS actions? + + eTMS = app.GetTMSAction(i); + + if (eTMS != eTMSAction_Idle) { + switch (eTMS) { + // TMS++ actions + case eTMSAction_TMSPP_RetrieveFiles_CreateLoad_SignInReturned: + case eTMSAction_TMSPP_RetrieveFiles_RunPlayGame: +#ifdef _XBOX + app.TMSPP_SetTitleGroupID(GROUP_ID); + SetTMSAction(i, eTMSAction_TMSPP_GlobalFileList); #elif defined _XBOX_ONE - //StorageManager.TMSPP_DeleteFile(i,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",NULL,NULL, 0); - SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); - app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,eTMSAction_TMSPP_DLCFileOnly); + SetTMSAction(i, eTMSAction_TMSPP_GlobalFileList_Waiting); + app.TMSPP_RetrieveFileList(i, + C4JStorage::eGlobalStorage_Title, + eTMSAction_TMSPP_UserFileList); #else - SetTMSAction(i,eTMSAction_TMSPP_DLCFileOnly); + SetTMSAction(i, eTMSAction_TMSPP_UserFileList); +#endif + break; + +#ifdef _XBOX + case eTMSAction_TMSPP_GlobalFileList: + SetTMSAction(i, eTMSAction_TMSPP_GlobalFileList_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_Title, "\\", + eTMSAction_TMSPP_UserFileList); + break; +#endif + case eTMSAction_TMSPP_UserFileList: + // retrieve the file list first +#if defined _XBOX + SetTMSAction(i, eTMSAction_TMSPP_UserFileList_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_TitleUser, "\\", + eTMSAction_TMSPP_XUIDSFile); +#elif defined _XBOX_ONE + SetTMSAction(i, eTMSAction_TMSPP_UserFileList_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_TitleUser, + eTMSAction_TMSPP_DLCFile); +#else + SetTMSAction(i, eTMSAction_TMSPP_XUIDSFile); +#endif + break; + case eTMSAction_TMSPP_XUIDSFile: +#ifdef _XBOX + SetTMSAction(i, eTMSAction_TMSPP_XUIDSFile_Waiting); + // pass in the next app action on the call or callback + // completing + app.TMSPP_ReadXuidsFile(i, eTMSAction_TMSPP_DLCFile); +#else + SetTMSAction(i, eTMSAction_TMSPP_DLCFile); #endif - break; - - case eTMSAction_TMSPP_DLCFileOnly: + break; + case eTMSAction_TMSPP_DLCFile: #if defined _XBOX || defined _XBOX_ONE - SetTMSAction(i,eTMSAction_TMSPP_DLCFile_Waiting); - // pass in the next app action on the call or callback completing - app.TMSPP_ReadDLCFile(i,eTMSAction_TMSPP_RetrieveFiles_Complete); + SetTMSAction(i, eTMSAction_TMSPP_DLCFile_Waiting); + // pass in the next app action on the call or callback + // completing + app.TMSPP_ReadDLCFile(i, eTMSAction_TMSPP_BannedListFile); #else - SetTMSAction(i,eTMSAction_TMSPP_RetrieveFiles_Complete); + SetTMSAction(i, eTMSAction_TMSPP_BannedListFile); #endif - break; + break; + case eTMSAction_TMSPP_BannedListFile: + // If we have one in TMSPP, then we can assume we can ignore + // TMS +#if defined _XBOX + SetTMSAction(i, eTMSAction_TMSPP_BannedListFile_Waiting); + // pass in the next app action on the call or callback + // completing + if (app.TMSPP_ReadBannedList( + i, eTMSAction_TMS_RetrieveFiles_Complete) == + false) { + // we don't have a banned list in TMSPP, so we should + // check TMS + app.ReadBannedList( + i, eTMSAction_TMS_RetrieveFiles_Complete, true); + } +#elif defined _XBOX_ONE + SetTMSAction(i, eTMSAction_TMSPP_BannedListFile_Waiting); + // pass in the next app action on the call or callback + // completing + app.TMSPP_ReadBannedList( + i, eTMSAction_TMS_RetrieveFiles_Complete); - - case eTMSAction_TMSPP_RetrieveFiles_Complete: - SetTMSAction(i,eTMSAction_Idle); - break; - - - // TMS files -/* case eTMSAction_TMS_RetrieveFiles_CreateLoad_SignInReturned: - case eTMSAction_TMS_RetrieveFiles_RunPlayGame: -#ifdef _XBOX - SetTMSAction(i,eTMSAction_TMS_XUIDSFile_Waiting); - // pass in the next app action on the call or callback completing - app.ReadXuidsFileFromTMS(i,eTMSAction_TMS_DLCFile,true); #else - SetTMSAction(i,eTMSAction_TMS_DLCFile); + SetTMSAction(i, eTMSAction_TMS_RetrieveFiles_Complete); #endif - break; + break; - case eTMSAction_TMS_DLCFile: -#ifdef _XBOX - SetTMSAction(i,eTMSAction_TMS_DLCFile_Waiting); - // pass in the next app action on the call or callback completing - app.ReadDLCFileFromTMS(i,eTMSAction_TMS_BannedListFile,true); + // SPECIAL CASE - where the user goes directly in to Help & + // Options from the main menu + case eTMSAction_TMSPP_RetrieveFiles_HelpAndOptions: + case eTMSAction_TMSPP_RetrieveFiles_DLCMain: + // retrieve the file list first +#if defined _XBOX + // pass in the next app action on the call or callback + // completing + SetTMSAction(i, eTMSAction_TMSPP_XUIDSFile_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_Title, "\\", + eTMSAction_TMSPP_DLCFileOnly); +#elif defined _XBOX_ONE + SetTMSAction(i, eTMSAction_TMSPP_GlobalFileList_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_Title, + eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly); #else - SetTMSAction(i,eTMSAction_TMS_BannedListFile); + SetTMSAction(i, eTMSAction_TMSPP_DLCFileOnly); +#endif + break; + case eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly: +#if defined _XBOX + SetTMSAction(i, eTMSAction_TMSPP_UserFileList_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_TitleUser, "\\", + eTMSAction_TMSPP_XUIDSFile); +#elif defined _XBOX_ONE + // StorageManager.TMSPP_DeleteFile(i,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"TP06.png",NULL,NULL, + // 0); + SetTMSAction(i, eTMSAction_TMSPP_UserFileList_Waiting); + app.TMSPP_RetrieveFileList( + i, C4JStorage::eGlobalStorage_TitleUser, + eTMSAction_TMSPP_DLCFileOnly); +#else + SetTMSAction(i, eTMSAction_TMSPP_DLCFileOnly); #endif - break; + break; - case eTMSAction_TMS_RetrieveFiles_HelpAndOptions: - case eTMSAction_TMS_RetrieveFiles_DLCMain: -#ifdef _XBOX - SetTMSAction(i,eTMSAction_TMS_DLCFile_Waiting); - // pass in the next app action on the call or callback completing - app.ReadDLCFileFromTMS(i,eTMSAction_Idle,true); + case eTMSAction_TMSPP_DLCFileOnly: +#if defined _XBOX || defined _XBOX_ONE + SetTMSAction(i, eTMSAction_TMSPP_DLCFile_Waiting); + // pass in the next app action on the call or callback + // completing + app.TMSPP_ReadDLCFile( + i, eTMSAction_TMSPP_RetrieveFiles_Complete); #else - SetTMSAction(i,eTMSAction_Idle); + SetTMSAction(i, eTMSAction_TMSPP_RetrieveFiles_Complete); #endif + break; - break; - case eTMSAction_TMS_BannedListFile: -#ifdef _XBOX - SetTMSAction(i,eTMSAction_TMS_BannedListFile_Waiting); - // pass in the next app action on the call or callback completing - app.ReadBannedList(i, eTMSAction_TMS_RetrieveFiles_Complete,true); -#else - SetTMSAction(i,eTMSAction_TMS_RetrieveFiles_Complete); -#endif + case eTMSAction_TMSPP_RetrieveFiles_Complete: + SetTMSAction(i, eTMSAction_Idle); + break; - break; + // TMS files + /* case + eTMSAction_TMS_RetrieveFiles_CreateLoad_SignInReturned: case + eTMSAction_TMS_RetrieveFiles_RunPlayGame: #ifdef _XBOX + SetTMSAction(i,eTMSAction_TMS_XUIDSFile_Waiting); + // pass in the next app + action on the call or callback completing + app.ReadXuidsFileFromTMS(i,eTMSAction_TMS_DLCFile,true); + #else + SetTMSAction(i,eTMSAction_TMS_DLCFile); + #endif + break; - */ - case eTMSAction_TMS_RetrieveFiles_Complete: - SetTMSAction(i,eTMSAction_Idle); - // if(StorageManager.SetSaveDevice(&CScene_Main::DeviceSelectReturned,pClass)) - // { - // // save device already selected - // // ensure we've applied this player's settings - // app.ApplyGameSettingsChanged(ProfileManager.GetPrimaryPad()); - // app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_MultiGameJoinLoad); - // } - break; - default: - break; - } - } + case eTMSAction_TMS_DLCFile: + #ifdef _XBOX + SetTMSAction(i,eTMSAction_TMS_DLCFile_Waiting); + // pass in the next app + action on the call or callback completing + app.ReadDLCFileFromTMS(i,eTMSAction_TMS_BannedListFile,true); + #else + SetTMSAction(i,eTMSAction_TMS_BannedListFile); + #endif - } + break; + + case + eTMSAction_TMS_RetrieveFiles_HelpAndOptions: case + eTMSAction_TMS_RetrieveFiles_DLCMain: #ifdef _XBOX + SetTMSAction(i,eTMSAction_TMS_DLCFile_Waiting); + // pass in the next app + action on the call or callback completing + app.ReadDLCFileFromTMS(i,eTMSAction_Idle,true); + #else + SetTMSAction(i,eTMSAction_Idle); + #endif + + break; + case eTMSAction_TMS_BannedListFile: + #ifdef _XBOX + SetTMSAction(i,eTMSAction_TMS_BannedListFile_Waiting); + // pass in the next app + action on the call or callback completing + app.ReadBannedList(i, + eTMSAction_TMS_RetrieveFiles_Complete,true); #else + SetTMSAction(i,eTMSAction_TMS_RetrieveFiles_Complete); + #endif + + break; + + */ + case eTMSAction_TMS_RetrieveFiles_Complete: + SetTMSAction(i, eTMSAction_Idle); + // if(StorageManager.SetSaveDevice(&CScene_Main::DeviceSelectReturned,pClass)) + // { + // // save device already + // selected + // // ensure we've applied + // this player's settings + // app.ApplyGameSettingsChanged(ProfileManager.GetPrimaryPad()); + // app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_MultiGameJoinLoad); + // } + break; + default: + break; + } + } + } } -int CMinecraftApp::BannedLevelDialogReturned(void *pParam,int iPad,const C4JStorage::EMessageResult result) -{ - CMinecraftApp* pApp = (CMinecraftApp*)pParam; - //Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::BannedLevelDialogReturned( + void* pParam, int iPad, const C4JStorage::EMessageResult result) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + // Minecraft *pMinecraft=Minecraft::GetInstance(); - if(result==C4JStorage::EMessage_ResultAccept) - { + if (result == C4JStorage::EMessage_ResultAccept) { #if defined _XBOX || defined _XBOX_ONE - INetworkPlayer *pHost = g_NetworkManager.GetHostPlayer(); - // unban the level - if (pHost != NULL) - { + INetworkPlayer* pHost = g_NetworkManager.GetHostPlayer(); + // unban the level + if (pHost != NULL) { #if defined _XBOX - pApp->RemoveLevelFromBannedLevelList(iPad,((NetworkPlayerXbox *)pHost)->GetUID(),pApp->GetUniqueMapName()); + pApp->RemoveLevelFromBannedLevelList( + iPad, ((NetworkPlayerXbox*)pHost)->GetUID(), + pApp->GetUniqueMapName()); #else - pApp->RemoveLevelFromBannedLevelList(iPad,pHost->GetUID(),pApp->GetUniqueMapName()); + pApp->RemoveLevelFromBannedLevelList(iPad, pHost->GetUID(), + pApp->GetUniqueMapName()); #endif - } + } #endif - } - else - { - if( iPad == ProfileManager.GetPrimaryPad() ) - { - pApp->SetAction(iPad,eAppAction_ExitWorld); - } - else - { - pApp->SetAction(iPad,eAppAction_ExitPlayer); - } - } + } else { + if (iPad == ProfileManager.GetPrimaryPad()) { + pApp->SetAction(iPad, eAppAction_ExitWorld); + } else { + pApp->SetAction(iPad, eAppAction_ExitPlayer); + } + } - return 0; + return 0; } -void CMinecraftApp::loadMediaArchive() -{ - std::wstring mediapath = L""; +void CMinecraftApp::loadMediaArchive() { + std::wstring mediapath = L""; #ifdef __PS3__ - mediapath = L"Common\\Media\\MediaPS3.arc"; + mediapath = L"Common\\Media\\MediaPS3.arc"; #elif _WINDOWS64 - mediapath = L"Common\\Media\\MediaWindows64.arc"; + mediapath = L"Common\\Media\\MediaWindows64.arc"; #elif __linux__ - mediapath = L"Common/Media/MediaLinux.arc"; + mediapath = L"Common/Media/MediaLinux.arc"; #elif __ORBIS__ - mediapath = L"Common\\Media\\MediaOrbis.arc"; + mediapath = L"Common\\Media\\MediaOrbis.arc"; #elif _DURANGO - mediapath = L"Common\\Media\\MediaDurango.arc"; + mediapath = L"Common\\Media\\MediaDurango.arc"; #elif __PSVITA__ - mediapath = L"Common\\Media\\MediaPSVita.arc"; + mediapath = L"Common\\Media\\MediaPSVita.arc"; #endif - if (!mediapath.empty()) - { - m_mediaArchive = new ArchiveFile( File(mediapath) ); - } + if (!mediapath.empty()) { + m_mediaArchive = new ArchiveFile(File(mediapath)); + } #if 0 std::string path = "Common\\media.arc"; HANDLE hFile = CreateFile( path.c_str(), @@ -4104,829 +4360,914 @@ void CMinecraftApp::loadMediaArchive() #endif } -void CMinecraftApp::loadStringTable() -{ +void CMinecraftApp::loadStringTable() { #ifndef _XBOX - if(m_stringTable!=NULL) - { - // we need to unload the current string table, this is a reload - delete m_stringTable; - } - std::wstring localisationFile = L"languages.loc"; - if (m_mediaArchive->hasFile(localisationFile)) - { - byteArray locFile = m_mediaArchive->getFile(localisationFile); - m_stringTable = new StringTable(locFile.data, locFile.length); - delete[] locFile.data; - } - else - { - m_stringTable = NULL; - assert(false); - // AHHHHHHHHH. - } + if (m_stringTable != NULL) { + // we need to unload the current string table, this is a reload + delete m_stringTable; + } + std::wstring localisationFile = L"languages.loc"; + if (m_mediaArchive->hasFile(localisationFile)) { + byteArray locFile = m_mediaArchive->getFile(localisationFile); + m_stringTable = new StringTable(locFile.data, locFile.length); + delete[] locFile.data; + } else { + m_stringTable = NULL; + assert(false); + // AHHHHHHHHH. + } #endif } -int CMinecraftApp::PrimaryPlayerSignedOutReturned(void *pParam,int iPad,const C4JStorage::EMessageResult) -{ - //CMinecraftApp* pApp = (CMinecraftApp*)pParam; - //Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::PrimaryPlayerSignedOutReturned( + void* pParam, int iPad, const C4JStorage::EMessageResult) { + // CMinecraftApp* pApp = (CMinecraftApp*)pParam; + // Minecraft *pMinecraft=Minecraft::GetInstance(); - // if the player is null, we're in the menus - //if(Minecraft::GetInstance()->player!=NULL) + // if the player is null, we're in the menus + // if(Minecraft::GetInstance()->player!=NULL) - // We always create a session before kicking of any of the game code, so even though we may still be joining/creating a game - // at this point we want to handle it differently from just being in a menu - if( g_NetworkManager.IsInSession() ) - { - app.SetAction(iPad,eAppAction_PrimaryPlayerSignedOutReturned); - } - else - { - app.SetAction(iPad,eAppAction_PrimaryPlayerSignedOutReturned_Menus); - } - return 0; + // We always create a session before kicking of any of the game code, so + // even though we may still be joining/creating a game at this point we want + // to handle it differently from just being in a menu + if (g_NetworkManager.IsInSession()) { + app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned); + } else { + app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned_Menus); + } + return 0; } -int CMinecraftApp::EthernetDisconnectReturned(void *pParam,int iPad,const C4JStorage::EMessageResult) -{ - //CMinecraftApp* pApp = (CMinecraftApp*)pParam; - Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::EthernetDisconnectReturned( + void* pParam, int iPad, const C4JStorage::EMessageResult) { + // CMinecraftApp* pApp = (CMinecraftApp*)pParam; + Minecraft* pMinecraft = Minecraft::GetInstance(); - // if the player is null, we're in the menus - if(Minecraft::GetInstance()->player!=NULL) - { - app.SetAction(pMinecraft->player->GetXboxPad(),eAppAction_EthernetDisconnectedReturned); - } - else - { - // 4J-PB - turn off the PSN store icon just in case this happened when we were in one of the DLC menus + // if the player is null, we're in the menus + if (Minecraft::GetInstance()->player != NULL) { + app.SetAction(pMinecraft->player->GetXboxPad(), + eAppAction_EthernetDisconnectedReturned); + } else { + // 4J-PB - turn off the PSN store icon just in case this happened when + // we were in one of the DLC menus #ifdef __ORBIS__ - sceNpCommerceHidePsStoreIcon(); + sceNpCommerceHidePsStoreIcon(); #elif defined __PSVITA__ - sceNpCommerce2HidePsStoreIcon(); + sceNpCommerce2HidePsStoreIcon(); #endif - app.SetAction(iPad,eAppAction_EthernetDisconnectedReturned_Menus); - } - return 0; + app.SetAction(iPad, eAppAction_EthernetDisconnectedReturned_Menus); + } + return 0; } -int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) -{ +int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) { + // Share AABB & Vec3 pools with default (main thread) - should be ok as long + // as we don't tick the main thread whilst this thread is running + AABB::UseDefaultThreadStorage(); + Vec3::UseDefaultThreadStorage(); + Compression::UseDefaultThreadStorage(); - // Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); - Vec3::UseDefaultThreadStorage(); - Compression::UseDefaultThreadStorage(); + // app.SetGameStarted(false); - //app.SetGameStarted(false); + Minecraft* pMinecraft = Minecraft::GetInstance(); - Minecraft *pMinecraft=Minecraft::GetInstance(); + int exitReasonStringId = -1; - int exitReasonStringId = -1; - - bool saveStats = false; - if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession() ) - { - if(lpParameter != NULL ) - { - switch( app.GetDisconnectReason() ) - { - case DisconnectPacket::eDisconnect_Kicked: - exitReasonStringId = IDS_DISCONNECTED_KICKED; - break; - case DisconnectPacket::eDisconnect_NoUGC_AllLocal: - exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; - break; - case DisconnectPacket::eDisconnect_NoUGC_Single_Local: - exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; - break; + bool saveStats = false; + if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) { + if (lpParameter != NULL) { + switch (app.GetDisconnectReason()) { + case DisconnectPacket::eDisconnect_Kicked: + exitReasonStringId = IDS_DISCONNECTED_KICKED; + break; + case DisconnectPacket::eDisconnect_NoUGC_AllLocal: + exitReasonStringId = + IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; + break; + case DisconnectPacket::eDisconnect_NoUGC_Single_Local: + exitReasonStringId = + IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; + break; #ifdef _XBOX - case DisconnectPacket::eDisconnect_NoUGC_Remote: - exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE; - break; + case DisconnectPacket::eDisconnect_NoUGC_Remote: + exitReasonStringId = + IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE; + break; #endif - case DisconnectPacket::eDisconnect_NoFlying: - exitReasonStringId = IDS_DISCONNECTED_FLYING; - break; - case DisconnectPacket::eDisconnect_OutdatedServer: - exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD; - break; - case DisconnectPacket::eDisconnect_OutdatedClient: - exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD; - break; - default: - exitReasonStringId = IDS_DISCONNECTED; - } - pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); - // 4J - Force a disconnection, this handles the situation that the server has already disconnected - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(false); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(false); - } - else - { - exitReasonStringId = IDS_EXITING_GAME; - pMinecraft->progressRenderer->progressStartNoAbort( IDS_EXITING_GAME ); + case DisconnectPacket::eDisconnect_NoFlying: + exitReasonStringId = IDS_DISCONNECTED_FLYING; + break; + case DisconnectPacket::eDisconnect_OutdatedServer: + exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD; + break; + case DisconnectPacket::eDisconnect_OutdatedClient: + exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD; + break; + default: + exitReasonStringId = IDS_DISCONNECTED; + } + pMinecraft->progressRenderer->progressStartNoAbort( + exitReasonStringId); + // 4J - Force a disconnection, this handles the situation that the + // server has already disconnected + if (pMinecraft->levels[0] != NULL) + pMinecraft->levels[0]->disconnect(false); + if (pMinecraft->levels[1] != NULL) + pMinecraft->levels[1]->disconnect(false); + } else { + exitReasonStringId = IDS_EXITING_GAME; + pMinecraft->progressRenderer->progressStartNoAbort( + IDS_EXITING_GAME); - if( pMinecraft->levels[0] != NULL ) pMinecraft->levels[0]->disconnect(); - if( pMinecraft->levels[1] != NULL ) pMinecraft->levels[1]->disconnect(); - } + if (pMinecraft->levels[0] != NULL) + pMinecraft->levels[0]->disconnect(); + if (pMinecraft->levels[1] != NULL) + pMinecraft->levels[1]->disconnect(); + } - // 4J Stu - This only does something if we actually have a server, so don't need to do any other checks - MinecraftServer::HaltServer(true); + // 4J Stu - This only does something if we actually have a server, so + // don't need to do any other checks + MinecraftServer::HaltServer(true); - // We need to call the stats & leaderboards save before we exit the session - //pMinecraft->forceStatsSave(); - saveStats = false; + // We need to call the stats & leaderboards save before we exit the + // session + // pMinecraft->forceStatsSave(); + saveStats = false; - // 4J Stu - Leave the session once the disconnect packet has been sent - g_NetworkManager.LeaveGame(FALSE); - } - else - { - if(lpParameter != NULL ) - { - switch( app.GetDisconnectReason() ) - { - case DisconnectPacket::eDisconnect_Kicked: - exitReasonStringId = IDS_DISCONNECTED_KICKED; - break; - case DisconnectPacket::eDisconnect_NoUGC_AllLocal: - exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; - break; - case DisconnectPacket::eDisconnect_NoUGC_Single_Local: - exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; - break; -#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) - case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal: - exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER; - break; - case DisconnectPacket::eDisconnect_ContentRestricted_Single_Local: - exitReasonStringId = IDS_CONTENT_RESTRICTION; - break; + // 4J Stu - Leave the session once the disconnect packet has been sent + g_NetworkManager.LeaveGame(FALSE); + } else { + if (lpParameter != NULL) { + switch (app.GetDisconnectReason()) { + case DisconnectPacket::eDisconnect_Kicked: + exitReasonStringId = IDS_DISCONNECTED_KICKED; + break; + case DisconnectPacket::eDisconnect_NoUGC_AllLocal: + exitReasonStringId = + IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; + break; + case DisconnectPacket::eDisconnect_NoUGC_Single_Local: + exitReasonStringId = + IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; + break; +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + case DisconnectPacket::eDisconnect_ContentRestricted_AllLocal: + exitReasonStringId = IDS_CONTENT_RESTRICTION_MULTIPLAYER; + break; + case DisconnectPacket:: + eDisconnect_ContentRestricted_Single_Local: + exitReasonStringId = IDS_CONTENT_RESTRICTION; + break; #endif #ifdef _XBOX - case DisconnectPacket::eDisconnect_NoUGC_Remote: - exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE; - break; + case DisconnectPacket::eDisconnect_NoUGC_Remote: + exitReasonStringId = + IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE; + break; #endif - case DisconnectPacket::eDisconnect_OutdatedServer: - exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD; - break; - case DisconnectPacket::eDisconnect_OutdatedClient: - exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD; - default: - exitReasonStringId = IDS_DISCONNECTED; - } - pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId ); - } - } - pMinecraft->setLevel(NULL,exitReasonStringId,nullptr,saveStats,true); + case DisconnectPacket::eDisconnect_OutdatedServer: + exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD; + break; + case DisconnectPacket::eDisconnect_OutdatedClient: + exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD; + default: + exitReasonStringId = IDS_DISCONNECTED; + } + pMinecraft->progressRenderer->progressStartNoAbort( + exitReasonStringId); + } + } + pMinecraft->setLevel(NULL, exitReasonStringId, nullptr, saveStats, true); - // 4J-JEV: Fix for #106402 - TCR #014 BAS Debug Output: - // TU12: Mass Effect Mash-UP: Save file "Default_DisplayName" is created on all storage devices after signing out from a re-launched pre-generated world - app.m_gameRules.unloadCurrentGameRules(); // + // 4J-JEV: Fix for #106402 - TCR #014 BAS Debug Output: + // TU12: Mass Effect Mash-UP: Save file "Default_DisplayName" is created on + // all storage devices after signing out from a re-launched pre-generated + // world + app.m_gameRules.unloadCurrentGameRules(); // - MinecraftServer::resetFlags(); - - // We can't start/join a new game until the session is destroyed, so wait for it to be idle again - while( g_NetworkManager.IsInSession() ) - { - Sleep(1); - } + MinecraftServer::resetFlags(); - return 0; + // We can't start/join a new game until the session is destroyed, so wait + // for it to be idle again + while (g_NetworkManager.IsInSession()) { + Sleep(1); + } + + return 0; } -int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - //CMinecraftApp* pApp = (CMinecraftApp*)pParam; - Minecraft *pMinecraft=Minecraft::GetInstance(); - bool bNoPlayer; +int CMinecraftApp::UnlockFullInviteReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result) { + // CMinecraftApp* pApp = (CMinecraftApp*)pParam; + Minecraft* pMinecraft = Minecraft::GetInstance(); + bool bNoPlayer; - // bug 11285 - TCR 001: BAS Game Stability: CRASH - When trying to join a full version game with a trial version, the trial crashes - // 4J-PB - we may be in the main menus here, and we don't have a pMinecraft->player + // bug 11285 - TCR 001: BAS Game Stability: CRASH - When trying to join a + // full version game with a trial version, the trial crashes 4J-PB - we may + // be in the main menus here, and we don't have a pMinecraft->player - if(pMinecraft->player==NULL) - { - bNoPlayer=true; - } + if (pMinecraft->player == NULL) { + bNoPlayer = true; + } - if(result==C4JStorage::EMessage_ResultAccept) - { - if(ProfileManager.IsSignedInLive(iPad)) - { - // 4J-PB - need to check this user can access the store + if (result == C4JStorage::EMessage_ResultAccept) { + if (ProfileManager.IsSignedInLive(iPad)) { + // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) - bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); - if(bContentRestricted) - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); - } - else + bool bContentRestricted; + ProfileManager.GetChatAndContentRestrictions( + ProfileManager.GetPrimaryPad(), true, NULL, &bContentRestricted, + NULL); + if (bContentRestricted) { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, &app, + app.GetStringTable()); + } else #endif - { - ProfileManager.DisplayFullVersionPurchase(false,iPad,eSen_UpsellID_Full_Version_Of_Game); - } - } + { + ProfileManager.DisplayFullVersionPurchase( + false, iPad, eSen_UpsellID_Full_Version_Of_Game); + } + } #if defined(__PS3__) - else - { - // you're not signed in to PSN! - unsigned int uiIDA[2]; - uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; - uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); - - } + else { + // you're not signed in to PSN! + unsigned int uiIDA[2]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::MustSignInFullVersionPurchaseReturned, &app, + app.GetStringTable()); + } #endif - } - else - { - TelemetryManager->RecordUpsellResponded(iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, eSen_UpsellOutcome_Declined); - } + } else { + TelemetryManager->RecordUpsellResponded( + iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, + eSen_UpsellOutcome_Declined); + } - return 0; + return 0; } -int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - //CMinecraftApp* pApp = (CMinecraftApp*)pParam; - Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::UnlockFullSaveReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result) { + // CMinecraftApp* pApp = (CMinecraftApp*)pParam; + Minecraft* pMinecraft = Minecraft::GetInstance(); - if(result==C4JStorage::EMessage_ResultAccept) - { - if(ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad())) - { - // 4J-PB - need to check this user can access the store + if (result == C4JStorage::EMessage_ResultAccept) { + if (ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad())) { + // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) - bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); - if(bContentRestricted) - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); - } - else + bool bContentRestricted; + ProfileManager.GetChatAndContentRestrictions( + ProfileManager.GetPrimaryPad(), true, NULL, &bContentRestricted, + NULL); + if (bContentRestricted) { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, &app, + app.GetStringTable()); + } else #endif - { - ProfileManager.DisplayFullVersionPurchase(false,pMinecraft->player->GetXboxPad(),eSen_UpsellID_Full_Version_Of_Game); - } - } + { + ProfileManager.DisplayFullVersionPurchase( + false, pMinecraft->player->GetXboxPad(), + eSen_UpsellID_Full_Version_Of_Game); + } + } #if defined(__PS3__) - else - { - // you're not signed in to PSN! - unsigned int uiIDA[2]; - uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; - uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); - } + else { + // you're not signed in to PSN! + unsigned int uiIDA[2]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::MustSignInFullVersionPurchaseReturned, &app, + app.GetStringTable()); + } #elif defined(__ORBIS__) - else - { - // Determine why they're not "signed in live" - if (ProfileManager.isSignedInPSN(iPad)) - { - // Signed in to PSN but not connected (no internet access) - assert(!ProfileManager.isConnectedToPSN(iPad)); + else { + // Determine why they're not "signed in live" + if (ProfileManager.isSignedInPSN(iPad)) { + // Signed in to PSN but not connected (no internet access) + assert(!ProfileManager.isConnectedToPSN(iPad)); - unsigned int uiIDA[1]; - uiIDA[0] = IDS_OK; - ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); - } - else - { - // Not signed in to PSN - unsigned int uiIDA[1]; - uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable(), NULL, 0, false); - } - } + unsigned int uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, + uiIDA, 1, iPad, NULL, NULL, + app.GetStringTable()); + } else { + // Not signed in to PSN + unsigned int uiIDA[1]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + iPad, &CMinecraftApp::MustSignInFullVersionPurchaseReturned, + &app, app.GetStringTable(), NULL, 0, false); + } + } #endif - } - else - { - TelemetryManager->RecordUpsellResponded(iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, eSen_UpsellOutcome_Declined); - } + } else { + TelemetryManager->RecordUpsellResponded( + iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, + eSen_UpsellOutcome_Declined); + } - return 0; + return 0; } -int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - CMinecraftApp* pApp = (CMinecraftApp*)pParam; - Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::UnlockFullExitReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + Minecraft* pMinecraft = Minecraft::GetInstance(); - if(result==C4JStorage::EMessage_ResultAccept) - { - if(ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad())) - { - // 4J-PB - need to check this user can access the store + if (result == C4JStorage::EMessage_ResultAccept) { + if (ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad())) { + // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) - bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); - if(bContentRestricted) - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); - } - else + bool bContentRestricted; + ProfileManager.GetChatAndContentRestrictions( + ProfileManager.GetPrimaryPad(), true, NULL, &bContentRestricted, + NULL); + if (bContentRestricted) { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, &app, + app.GetStringTable()); + } else #endif - { - ProfileManager.DisplayFullVersionPurchase(false,pMinecraft->player->GetXboxPad(),eSen_UpsellID_Full_Version_Of_Game); + { + ProfileManager.DisplayFullVersionPurchase( + false, pMinecraft->player->GetXboxPad(), + eSen_UpsellID_Full_Version_Of_Game); #if defined __ORBIS__ || defined __PS3__ || defined __PSVITA__ - // still need to exit the trial or we'll be in the Pause menu with input ignored - pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); + // still need to exit the trial or we'll be in the Pause menu + // with input ignored + pApp->SetAction(pMinecraft->player->GetXboxPad(), + eAppAction_ExitWorldTrial); #endif - } - } + } + } #if defined(__PS3__) || defined __PSVITA__ - else - { - // you're not signed in to PSN! - unsigned int uiIDA[2]; - uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; - uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial,&app, app.GetStringTable()); - } + else { + // you're not signed in to PSN! + unsigned int uiIDA[2]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial, + &app, app.GetStringTable()); + } #elif defined(__ORBIS__) - else - { - // Determine why they're not "signed in live" - if (ProfileManager.isSignedInPSN(iPad)) - { - // Signed in to PSN but not connected (no internet access) - assert(!ProfileManager.isConnectedToPSN(iPad)); + else { + // Determine why they're not "signed in live" + if (ProfileManager.isSignedInPSN(iPad)) { + // Signed in to PSN but not connected (no internet access) + assert(!ProfileManager.isConnectedToPSN(iPad)); - unsigned int uiIDA[1]; - uiIDA[0] = IDS_OK; - ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); - // still need to exit the trial or we'll be in the Pause menu with input ignored - pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); - } - else - { - // Not signed in to PSN - unsigned int uiIDA[1]; - uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestMessageBox( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial,&app, app.GetStringTable(), NULL, 0, false); - } - } + unsigned int uiIDA[1]; + uiIDA[0] = IDS_OK; + ui.RequestMessageBox(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, + uiIDA, 1, iPad, NULL, NULL, + app.GetStringTable()); + // still need to exit the trial or we'll be in the Pause menu + // with input ignored + pApp->SetAction(pMinecraft->player->GetXboxPad(), + eAppAction_ExitWorldTrial); + } else { + // Not signed in to PSN + unsigned int uiIDA[1]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, + iPad, + &CMinecraftApp:: + MustSignInFullVersionPurchaseReturnedExitTrial, + &app, app.GetStringTable(), NULL, 0, false); + } + } #endif - } - else - { - TelemetryManager->RecordUpsellResponded(iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, eSen_UpsellOutcome_Declined); - pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); - } + } else { + TelemetryManager->RecordUpsellResponded( + iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, + eSen_UpsellOutcome_Declined); + pApp->SetAction(pMinecraft->player->GetXboxPad(), + eAppAction_ExitWorldTrial); + } - return 0; + return 0; } -int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - CMinecraftApp* pApp = (CMinecraftApp*)pParam; - Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::TrialOverReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + Minecraft* pMinecraft = Minecraft::GetInstance(); - if(result==C4JStorage::EMessage_ResultAccept) - { - // we need a signed in user for the unlock - if(ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad())) - { - // 4J-PB - need to check this user can access the store + if (result == C4JStorage::EMessage_ResultAccept) { + // we need a signed in user for the unlock + if (ProfileManager.IsSignedInLive(pMinecraft->player->GetXboxPad())) { + // 4J-PB - need to check this user can access the store #if defined(__PS3__) || defined(__PSVITA__) - bool bContentRestricted; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); - if(bContentRestricted) - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); - } - else + bool bContentRestricted; + ProfileManager.GetChatAndContentRestrictions( + ProfileManager.GetPrimaryPad(), true, NULL, &bContentRestricted, + NULL); + if (bContentRestricted) { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, &app, + app.GetStringTable()); + } else #endif - { - ProfileManager.DisplayFullVersionPurchase(false,pMinecraft->player->GetXboxPad(),eSen_UpsellID_Full_Version_Of_Game); - } - } - else - { + { + ProfileManager.DisplayFullVersionPurchase( + false, pMinecraft->player->GetXboxPad(), + eSen_UpsellID_Full_Version_Of_Game); + } + } else { #if defined(__PS3__) - // you're not signed in to PSN! - unsigned int uiIDA[2]; - uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; - uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); + // you're not signed in to PSN! + unsigned int uiIDA[2]; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::MustSignInFullVersionPurchaseReturned, &app, + app.GetStringTable()); - // 4J Stu - We can't actually exit the game, so just exit back to the main menu - //pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); + // 4J Stu - We can't actually exit the game, so just exit back to + // the main menu + // pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); #else - pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitTrial); + pApp->SetAction(pMinecraft->player->GetXboxPad(), + eAppAction_ExitTrial); #endif - } - } - else - { - TelemetryManager->RecordUpsellResponded(iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, eSen_UpsellOutcome_Declined); + } + } else { + TelemetryManager->RecordUpsellResponded( + iPad, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, + eSen_UpsellOutcome_Declined); #if defined(__PS3__) || defined(__ORBIS__) - // 4J Stu - We can't actually exit the game, so just exit back to the main menu - pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); + // 4J Stu - We can't actually exit the game, so just exit back to the + // main menu + pApp->SetAction(pMinecraft->player->GetXboxPad(), + eAppAction_ExitWorldTrial); #else - pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitTrial); + pApp->SetAction(pMinecraft->player->GetXboxPad(), eAppAction_ExitTrial); #endif - } + } - return 0; + return 0; } -void CMinecraftApp::ProfileReadErrorCallback(void *pParam) -{ - CMinecraftApp *pApp=(CMinecraftApp *)pParam; - int iPrimaryPlayer=ProfileManager.GetPrimaryPad(); - pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError); +void CMinecraftApp::ProfileReadErrorCallback(void* pParam) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); + pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError); } -void CMinecraftApp::ClearSignInChangeUsersMask() -{ - // 4J-PB - When in the main menu, the user is on pad 0, and any change they make to their profile will be to pad 0 data - // If they then go in as a secondary player to a splitscreen game, their profile will not be read again on pad 1 if they were previously in a splitscreen game - // This is because m_uiLastSignInData remembers they were in previously, and doesn't read the profile data for them again - // Fix this by resetting the m_uiLastSignInData on pressing play game for secondary users. The Primary user does a read profile on play game anyway - int iPrimaryPlayer=ProfileManager.GetPrimaryPad(); +void CMinecraftApp::ClearSignInChangeUsersMask() { + // 4J-PB - When in the main menu, the user is on pad 0, and any change they + // make to their profile will be to pad 0 data If they then go in as a + // secondary player to a splitscreen game, their profile will not be read + // again on pad 1 if they were previously in a splitscreen game This is + // because m_uiLastSignInData remembers they were in previously, and doesn't + // read the profile data for them again Fix this by resetting the + // m_uiLastSignInData on pressing play game for secondary users. The Primary + // user does a read profile on play game anyway + int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); - if(m_uiLastSignInData!=0) - { - if(iPrimaryPlayer>=0) - { - m_uiLastSignInData=1<= 0) { + m_uiLastSignInData = 1 << iPrimaryPlayer; + } else { + m_uiLastSignInData = 0; + } + } } -void CMinecraftApp::SignInChangeCallback(void *pParam,bool bPrimaryPlayerChanged,unsigned int uiSignInData) -{ +void CMinecraftApp::SignInChangeCallback(void* pParam, + bool bPrimaryPlayerChanged, + unsigned int uiSignInData) { #ifdef __PS3__ - // this is normally set in the main menu, but we can go online in the create world screens, and the primary player name isn't updated - Minecraft::GetInstance()->user->name = convStringToWstring( ProfileManager.GetGamertag(ProfileManager.GetPrimaryPad())); + // this is normally set in the main menu, but we can go online in the create + // world screens, and the primary player name isn't updated + Minecraft::GetInstance()->user->name = convStringToWstring( + ProfileManager.GetGamertag(ProfileManager.GetPrimaryPad())); #endif - CMinecraftApp *pApp=(CMinecraftApp *)pParam; - // check if the primary player signed out - int iPrimaryPlayer=ProfileManager.GetPrimaryPad(); + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + // check if the primary player signed out + int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); - if((ProfileManager.GetLockedProfile()!=-1) && iPrimaryPlayer!=-1) - { - if ( ((uiSignInData & (1<SetAction(iPrimaryPlayer,eAppAction_PrimaryPlayerSignedOut); - - // 4J-PB - invalidate their banned level list - pApp->InvalidateBannedList(iPrimaryPlayer); + if ((ProfileManager.GetLockedProfile() != -1) && iPrimaryPlayer != -1) { + if (((uiSignInData & (1 << iPrimaryPlayer)) == 0) || + bPrimaryPlayerChanged) { + // Primary Player gone or there's been a sign out and sign in of the + // primary player, so kick them out + pApp->SetAction(iPrimaryPlayer, eAppAction_PrimaryPlayerSignedOut); - // need to ditch any DLCOffers info - StorageManager.ClearDLCOffers(); - pApp->ClearAndResetDLCDownloadQueue(); - pApp->ClearDLCInstalled(); - } - else - { - unsigned int uiChangedPlayers = uiSignInData ^ m_uiLastSignInData; + // 4J-PB - invalidate their banned level list + pApp->InvalidateBannedList(iPrimaryPlayer); - if( g_NetworkManager.IsInSession() ) - { - bool hasGuestIdChanged = false; - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { - unsigned int guestNumber = 0; - if(ProfileManager.IsSignedIn(i)) - { - XUSER_SIGNIN_INFO info; - XUserGetSigninInfo(i,XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY ,&info); - pApp->DebugPrintf("Player at index %d has guest number %d\n", i,info.dwGuestNumber ); - guestNumber = info.dwGuestNumber; - } - if( pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && guestNumber != 0 && pApp->m_currentSigninInfo[i].dwGuestNumber != guestNumber ) - { - hasGuestIdChanged = true; - } - } + // need to ditch any DLCOffers info + StorageManager.ClearDLCOffers(); + pApp->ClearAndResetDLCDownloadQueue(); + pApp->ClearDLCInstalled(); + } else { + unsigned int uiChangedPlayers = uiSignInData ^ m_uiLastSignInData; - if( hasGuestIdChanged ) - { - unsigned int uiIDA[1]; - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_GUEST_ORDER_CHANGED_TITLE, IDS_GUEST_ORDER_CHANGED_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,NULL,app.GetStringTable()); - } + if (g_NetworkManager.IsInSession()) { + bool hasGuestIdChanged = false; + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { + unsigned int guestNumber = 0; + if (ProfileManager.IsSignedIn(i)) { + XUSER_SIGNIN_INFO info; + XUserGetSigninInfo( + i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info); + pApp->DebugPrintf( + "Player at index %d has guest number %d\n", i, + info.dwGuestNumber); + guestNumber = info.dwGuestNumber; + } + if (pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && + guestNumber != 0 && + pApp->m_currentSigninInfo[i].dwGuestNumber != + guestNumber) { + hasGuestIdChanged = true; + } + } - // 4J Stu - On PS4 we can also cause to exit players if they are signed out here, but we shouldn't do that if - // we are going to switch to an offline game as it will likely crash due to incompatible parallel processes - bool switchToOffline = false; - // If it's an online game, and the primary profile is no longer signed into LIVE then we act as if disconnected - if( !ProfileManager.IsSignedInLive( ProfileManager.GetLockedProfile() ) && !g_NetworkManager.IsLocalGame() ) - { - switchToOffline = true; - } + if (hasGuestIdChanged) { + unsigned int uiIDA[1]; + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_GUEST_ORDER_CHANGED_TITLE, + IDS_GUEST_ORDER_CHANGED_TEXT, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, + NULL, app.GetStringTable()); + } - //printf("Old: %x, New: %x, Changed: %x\n", m_ulLastSignInData, ulSignInData, changedPlayers); - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { - // Primary player shouldn't be subjected to these checks, and shouldn't call ExitPlayer - if(i == iPrimaryPlayer) continue; + // 4J Stu - On PS4 we can also cause to exit players if they are + // signed out here, but we shouldn't do that if we are going to + // switch to an offline game as it will likely crash due to + // incompatible parallel processes + bool switchToOffline = false; + // If it's an online game, and the primary profile is no longer + // signed into LIVE then we act as if disconnected + if (!ProfileManager.IsSignedInLive( + ProfileManager.GetLockedProfile()) && + !g_NetworkManager.IsLocalGame()) { + switchToOffline = true; + } - // A guest a signed in or out, out of order which invalidates all the guest players we have in the game - if(hasGuestIdChanged && pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && g_NetworkManager.GetLocalPlayerByUserIndex(i)!=NULL) - { - pApp->DebugPrintf("Recommending removal of player at index %d because their guest id changed\n",i); - pApp->SetAction(i,eAppAction_ExitPlayer); - } - else - { - XUSER_SIGNIN_INFO info; - XUserGetSigninInfo(i,XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY ,&info); - // 4J Stu - Also need to detect the case where the sign in mask is the same, but the player has swapped users (eg still signed in but xuid different) - // Fix for #48451 - TU5: Code: UI: Splitscreen: Title crashes when switching to a profile previously signed out via splitscreen profile selection + // printf("Old: %x, New: %x, Changed: %x\n", m_ulLastSignInData, + // ulSignInData, changedPlayers); + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { + // Primary player shouldn't be subjected to these checks, + // and shouldn't call ExitPlayer + if (i == iPrimaryPlayer) continue; - // 4J-PB - compiler complained about if below ('&&' within '||') - making it easier to read - bool bPlayerChanged=(uiChangedPlayers&(1<m_currentSigninInfo[i].dwGuestNumber != 0 && + g_NetworkManager.GetLocalPlayerByUserIndex(i) != NULL) { + pApp->DebugPrintf( + "Recommending removal of player at index %d " + "because their guest id changed\n", + i); + pApp->SetAction(i, eAppAction_ExitPlayer); + } else { + XUSER_SIGNIN_INFO info; + XUserGetSigninInfo( + i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info); + // 4J Stu - Also need to detect the case where the sign + // in mask is the same, but the player has swapped users + // (eg still signed in but xuid different) Fix for + // #48451 - TU5: Code: UI: Splitscreen: Title crashes + // when switching to a profile previously signed out via + // splitscreen profile selection - if( bPlayerChanged && (!bPlayerSignedIn || (bPlayerSignedIn && !ProfileManager.AreXUIDSEqual(pApp->m_currentSigninInfo[i].xuid, info.xuid) ) )) - { - // 4J-PB - invalidate their banned level list - pApp->DebugPrintf("Player at index %d Left - invalidating their banned list\n",i); - pApp->InvalidateBannedList(i); + // 4J-PB - compiler complained about if below ('&&' + // within '||') - making it easier to read + bool bPlayerChanged = + (uiChangedPlayers & (1 << i)) == (1 << i); + bool bPlayerSignedIn = ((uiSignInData & (1 << i)) != 0); - if(g_NetworkManager.GetLocalPlayerByUserIndex(i)!=NULL) - { - pApp->DebugPrintf("Player %d signed out\n", i); - pApp->SetAction(i,eAppAction_ExitPlayer); - } - } - } + if (bPlayerChanged && + (!bPlayerSignedIn || + (bPlayerSignedIn && + !ProfileManager.AreXUIDSEqual( + pApp->m_currentSigninInfo[i].xuid, + info.xuid)))) { + // 4J-PB - invalidate their banned level list + pApp->DebugPrintf( + "Player at index %d Left - invalidating their " + "banned list\n", + i); + pApp->InvalidateBannedList(i); + + if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != + NULL) { + pApp->DebugPrintf("Player %d signed out\n", i); + pApp->SetAction(i, eAppAction_ExitPlayer); + } + } + } #ifdef __ORBIS__ - // check if any of the addition players have signed out of PSN (primary player is handled below) - if(!switchToOffline && i != ProfileManager.GetLockedProfile() && !g_NetworkManager.IsLocalGame()) - { - if(g_NetworkManager.GetLocalPlayerByUserIndex(i)!=NULL) - { - if(ProfileManager.IsSignedInLive(i) == false) - { - pApp->DebugPrintf("Recommending removal of player at index %d because they're no longer signed into PSNd\n",i); - pApp->SetAction(i,eAppAction_ExitPlayer); - } - } - } + // check if any of the addition players have signed out of + // PSN (primary player is handled below) + if (!switchToOffline && + i != ProfileManager.GetLockedProfile() && + !g_NetworkManager.IsLocalGame()) { + if (g_NetworkManager.GetLocalPlayerByUserIndex(i) != + NULL) { + if (ProfileManager.IsSignedInLive(i) == false) { + pApp->DebugPrintf( + "Recommending removal of player at index " + "%d because they're no longer signed into " + "PSNd\n", + i); + pApp->SetAction(i, eAppAction_ExitPlayer); + } + } + } #endif - } + } - // If it's an online game, and the primary profile is no longer signed into LIVE then we act as if disconnected - if( switchToOffline ) - { - pApp->SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected); - } + // If it's an online game, and the primary profile is no longer + // signed into LIVE then we act as if disconnected + if (switchToOffline) { + pApp->SetAction(iPrimaryPlayer, + eAppAction_EthernetDisconnected); + } - - g_NetworkManager.HandleSignInChange(); - } - // Some menus require the player to be signed in to live, so if this callback happens and the primary player is - // no longer signed in then nav back - else if ( pApp->GetLiveLinkRequired() && !ProfileManager.IsSignedInLive( ProfileManager.GetLockedProfile() ) ) - { - pApp->SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected); - } + g_NetworkManager.HandleSignInChange(); + } + // Some menus require the player to be signed in to live, so if this + // callback happens and the primary player is no longer signed in + // then nav back + else if (pApp->GetLiveLinkRequired() && + !ProfileManager.IsSignedInLive( + ProfileManager.GetLockedProfile())) { + pApp->SetAction(iPrimaryPlayer, + eAppAction_EthernetDisconnected); + } -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ ) - // 4J-JEV: Need to kick of loading of profile data for sub-sign in players. - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { - if( i != iPrimaryPlayer - && ( uiChangedPlayers & (1<InvalidateBannedList(iPrimaryPlayer); + } + m_uiLastSignInData = uiSignInData; + } else if (iPrimaryPlayer != -1) { + // make sure the TMS banned list data is ditched - the player may have + // gone in to help & options, backed out, and signed out + pApp->InvalidateBannedList(iPrimaryPlayer); - // need to ditch any DLCOffers info - StorageManager.ClearDLCOffers(); - pApp->ClearAndResetDLCDownloadQueue(); - pApp->ClearDLCInstalled(); + // need to ditch any DLCOffers info + StorageManager.ClearDLCOffers(); + pApp->ClearAndResetDLCDownloadQueue(); + pApp->ClearDLCInstalled(); + } - } - - // Update the guest numbers to the current state - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { + // Update the guest numbers to the current state + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { #if defined(_XBOX) - if(FAILED(XUserGetSigninInfo(i,XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,&pApp->m_currentSigninInfo[i]))) - { - pApp->m_currentSigninInfo[i].xuid = INVALID_XUID; - pApp->m_currentSigninInfo[i].dwGuestNumber = 0; - } + if (FAILED(XUserGetSigninInfo(i, + XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, + &pApp->m_currentSigninInfo[i]))) { + pApp->m_currentSigninInfo[i].xuid = INVALID_XUID; + pApp->m_currentSigninInfo[i].dwGuestNumber = 0; + } #endif - app.DebugPrintf("Player at index %d has guest number %d\n", i,pApp->m_currentSigninInfo[i].dwGuestNumber ); - } + app.DebugPrintf("Player at index %d has guest number %d\n", i, + pApp->m_currentSigninInfo[i].dwGuestNumber); + } } -void CMinecraftApp::NotificationsCallback(void *pParam,std::uint32_t dwNotification, unsigned int uiParam) -{ - CMinecraftApp* pClass = (CMinecraftApp*)pParam; +void CMinecraftApp::NotificationsCallback(void* pParam, + std::uint32_t dwNotification, + unsigned int uiParam) { + CMinecraftApp* pClass = (CMinecraftApp*)pParam; - // push these on to the notifications to be handled in qnet's dowork + // push these on to the notifications to be handled in qnet's dowork - PNOTIFICATION pNotification = new NOTIFICATION; + PNOTIFICATION pNotification = new NOTIFICATION; - pNotification->dwNotification=dwNotification; - pNotification->uiParam=uiParam; + pNotification->dwNotification = dwNotification; + pNotification->uiParam = uiParam; - switch( dwNotification ) - { - case XN_SYS_SIGNINCHANGED: - { - pClass->DebugPrintf("Signing changed - %d\n", uiParam ); - } - break; - case XN_SYS_INPUTDEVICESCHANGED: - if(app.GetGameStarted() && g_NetworkManager.IsInSession()) - { - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { - if(!InputManager.IsPadConnected(i) && - Minecraft::GetInstance()->localplayers[i] != NULL && - !ui.IsPauseMenuDisplayed(i) && !ui.IsSceneInStack(i, eUIScene_EndPoem) ) - { - ui.CloseUIScenes(i); - ui.NavigateToScene(i,eUIScene_PauseMenu); - } - } - } - break; - case XN_LIVE_CONTENT_INSTALLED: - // Need to inform xuis that we've possibly had DLC installed - { - //app.m_dlcManager.SetNeedsUpdated(true); - // Clear the DLC installed flag to cause a GetDLC to run if it's called - app.ClearDLCInstalled(); + switch (dwNotification) { + case XN_SYS_SIGNINCHANGED: { + pClass->DebugPrintf("Signing changed - %d\n", uiParam); + } break; + case XN_SYS_INPUTDEVICESCHANGED: + if (app.GetGameStarted() && g_NetworkManager.IsInSession()) { + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { + if (!InputManager.IsPadConnected(i) && + Minecraft::GetInstance()->localplayers[i] != NULL && + !ui.IsPauseMenuDisplayed(i) && + !ui.IsSceneInStack(i, eUIScene_EndPoem)) { + ui.CloseUIScenes(i); + ui.NavigateToScene(i, eUIScene_PauseMenu); + } + } + } + break; + case XN_LIVE_CONTENT_INSTALLED: + // Need to inform xuis that we've possibly had DLC installed + { + // app.m_dlcManager.SetNeedsUpdated(true); + // Clear the DLC installed flag to cause a GetDLC to run if + // it's called + app.ClearDLCInstalled(); - ui.HandleDLCInstalled(ProfileManager.GetPrimaryPad()); - } - break; - case XN_SYS_STORAGEDEVICESCHANGED: - { + ui.HandleDLCInstalled(ProfileManager.GetPrimaryPad()); + } + break; + case XN_SYS_STORAGEDEVICESCHANGED: { #ifdef _XBOX - // If the devices have changed, and we've got a dlc pack with audio selected, and that pack's content device is no longer valid... then pull the plug on - // audio streaming, as if we leave this until later xact gets locked up attempting to destroy the streamed wave bank. - TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected(); - if(pTexPack->hasAudio()) - { - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)pTexPack; - XCONTENTDEVICEID deviceID = pDLCTexPack->GetDLCDeviceID(); - if( XContentGetDeviceState( deviceID, NULL ) != ERROR_SUCCESS ) - { - // Set texture pack flag so that it is now considered as not having audio - this is critical so that the next playStreaming does what it is meant to do, - // and also so that we don't try and unmount this again, or play any sounds from it in the future - pTexPack->setHasAudio(false); - // need to stop the streaming audio - by playing streaming audio from the default texture pack now - Minecraft::GetInstance()->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0); + // If the devices have changed, and we've got a dlc pack with audio + // selected, and that pack's content device is no longer valid... + // then pull the plug on audio streaming, as if we leave this until + // later xact gets locked up attempting to destroy the streamed wave + // bank. + TexturePack* pTexPack = + Minecraft::GetInstance()->skins->getSelected(); + if (pTexPack->hasAudio()) { + DLCTexturePack* pDLCTexPack = (DLCTexturePack*)pTexPack; + XCONTENTDEVICEID deviceID = pDLCTexPack->GetDLCDeviceID(); + if (XContentGetDeviceState(deviceID, NULL) != ERROR_SUCCESS) { + // Set texture pack flag so that it is now considered as not + // having audio - this is critical so that the next + // playStreaming does what it is meant to do, and also so + // that we don't try and unmount this again, or play any + // sounds from it in the future + pTexPack->setHasAudio(false); + // need to stop the streaming audio - by playing streaming + // audio from the default texture pack now + Minecraft::GetInstance()->soundEngine->playStreaming( + L"", 0, 0, 0, 0, 0); - if(pDLCTexPack->m_pStreamedWaveBank!=NULL) - { - pDLCTexPack->m_pStreamedWaveBank->Destroy(); - } - if(pDLCTexPack->m_pSoundBank!=NULL) - { - pDLCTexPack->m_pSoundBank->Destroy(); - } - const unsigned int result = StorageManager.UnmountInstalledDLC("TPACK"); - app.DebugPrintf("Unmount result is %d\n",result); - } - } + if (pDLCTexPack->m_pStreamedWaveBank != NULL) { + pDLCTexPack->m_pStreamedWaveBank->Destroy(); + } + if (pDLCTexPack->m_pSoundBank != NULL) { + pDLCTexPack->m_pSoundBank->Destroy(); + } + const unsigned int result = + StorageManager.UnmountInstalledDLC("TPACK"); + app.DebugPrintf("Unmount result is %d\n", result); + } + } #endif - } - break; - } + } break; + } - pClass->m_vNotifications.push_back(pNotification); + pClass->m_vNotifications.push_back(pNotification); } #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ -int CMinecraftApp::MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - if(result==C4JStorage::EMessage_ResultAccept) - { +int CMinecraftApp::MustSignInFullVersionPurchaseReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + if (result == C4JStorage::EMessage_ResultAccept) { #ifdef __PS3__ - SQRNetworkManager_PS3::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); + SQRNetworkManager_PS3::AttemptPSNSignIn( + &CMinecraftApp::NowDisplayFullVersionPurchase, &app, true); #elif defined __PSVITA__ - SQRNetworkManager_Vita::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); -#else // __PS4__ - SQRNetworkManager_Orbis::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); + SQRNetworkManager_Vita::AttemptPSNSignIn( + &CMinecraftApp::NowDisplayFullVersionPurchase, &app, true); +#else // __PS4__ + SQRNetworkManager_Orbis::AttemptPSNSignIn( + &CMinecraftApp::NowDisplayFullVersionPurchase, &app, true); #endif - } + } - return 0; + return 0; } #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ -int CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - if(result==C4JStorage::EMessage_ResultAccept) - { +int CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + if (result == C4JStorage::EMessage_ResultAccept) { #ifdef __PS3__ - SQRNetworkManager_PS3::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); + SQRNetworkManager_PS3::AttemptPSNSignIn( + &CMinecraftApp::NowDisplayFullVersionPurchase, &app, true); #elif defined __PSVITA__ - SQRNetworkManager_Vita::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); -#else // __PS4__ - SQRNetworkManager_Orbis::AttemptPSNSignIn(&CMinecraftApp::NowDisplayFullVersionPurchase, &app,true); + SQRNetworkManager_Vita::AttemptPSNSignIn( + &CMinecraftApp::NowDisplayFullVersionPurchase, &app, true); +#else // __PS4__ + SQRNetworkManager_Orbis::AttemptPSNSignIn( + &CMinecraftApp::NowDisplayFullVersionPurchase, &app, true); #endif - } + } - //4J-PB - we need to exit the trial, or we'll be in the pause menu with ignore input true - app.SetAction(iPad,eAppAction_ExitWorldTrial); + // 4J-PB - we need to exit the trial, or we'll be in the pause menu with + // ignore input true + app.SetAction(iPad, eAppAction_ExitWorldTrial); - return 0; + return 0; } #endif -int CMinecraftApp::NowDisplayFullVersionPurchase(void *pParam, bool bContinue, int iPad) -{ - app.m_bDisplayFullVersionPurchase=true; - return 0; +int CMinecraftApp::NowDisplayFullVersionPurchase(void* pParam, bool bContinue, + int iPad) { + app.m_bDisplayFullVersionPurchase = true; + return 0; } #endif -void CMinecraftApp::UpsellReturnedCallback(void *pParam, eUpsellType type, eUpsellResponse result, int iUserData) -{ - ESen_UpsellID senType; - ESen_UpsellOutcome senResponse; +void CMinecraftApp::UpsellReturnedCallback(void* pParam, eUpsellType type, + eUpsellResponse result, + int iUserData) { + ESen_UpsellID senType; + ESen_UpsellOutcome senResponse; #ifdef __PS3__ - unsigned int uiIDA[2]; + unsigned int uiIDA[2]; #endif - // Map the eUpsellResponse to the enum we use for sentient - switch(result) - { - case eUpsellResponse_Accepted_NoPurchase: - senResponse = eSen_UpsellOutcome_Went_To_Guide; - break; - case eUpsellResponse_Accepted_Purchase: - senResponse = eSen_UpsellOutcome_Accepted; - break; + // Map the eUpsellResponse to the enum we use for sentient + switch (result) { + case eUpsellResponse_Accepted_NoPurchase: + senResponse = eSen_UpsellOutcome_Went_To_Guide; + break; + case eUpsellResponse_Accepted_Purchase: + senResponse = eSen_UpsellOutcome_Accepted; + break; #ifdef __PS3__ - // special case for people who are not signed in to the PSN while playing the trial game - case eUpsellResponse_UserNotSignedInPSN: - - uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; - uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; - ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); + // special case for people who are not signed in to the PSN while + // playing the trial game + case eUpsellResponse_UserNotSignedInPSN: - return; + uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; + uiIDA[1] = IDS_PRO_NOTONLINE_DECLINE; + ui.RequestMessageBox( + IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::MustSignInFullVersionPurchaseReturned, &app, + app.GetStringTable()); - case eUpsellResponse_NotAllowedOnline: // On earning a trophy in the trial version, where the user is underage and can't go online to buy the game, but they selected to buy the game on the trophy upsell - uiIDA[0]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); - break; -#endif - case eUpsellResponse_Declined: - default: - senResponse = eSen_UpsellOutcome_Declined; - break; - }; + return; - // Map the eUpsellType to the enum we use for sentient - switch(type) - { - case eUpsellType_Custom: - senType = eSen_UpsellID_Full_Version_Of_Game; - break; - default: - senType = eSen_UpsellID_Undefined; - break; - }; + case eUpsellResponse_NotAllowedOnline: // On earning a trophy in the + // trial version, where the user + // is underage and can't go + // online to buy the game, but + // they selected to buy the game + // on the trophy upsell + uiIDA[0] = IDS_CONFIRM_OK; + ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), NULL, &app, + app.GetStringTable()); + break; +#endif + case eUpsellResponse_Declined: + default: + senResponse = eSen_UpsellOutcome_Declined; + break; + }; - // Always the primary pad that gets an upsell - TelemetryManager->RecordUpsellResponded(ProfileManager.GetPrimaryPad(), eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, senResponse); + // Map the eUpsellType to the enum we use for sentient + switch (type) { + case eUpsellType_Custom: + senType = eSen_UpsellID_Full_Version_Of_Game; + break; + default: + senType = eSen_UpsellID_Undefined; + break; + }; + + // Always the primary pad that gets an upsell + TelemetryManager->RecordUpsellResponded(ProfileManager.GetPrimaryPad(), + eSen_UpsellID_Full_Version_Of_Game, + app.m_dwOfferID, senResponse); } #ifdef _DEBUG_MENUS_ENABLED @@ -4937,152 +5278,144 @@ bool CMinecraftApp::DebugArtToolsOn() { } #endif -void CMinecraftApp::SetDebugSequence(const char *pchSeq) -{ - InputManager.SetDebugSequence(pchSeq,&CMinecraftApp::DebugInputCallback,this); +void CMinecraftApp::SetDebugSequence(const char* pchSeq) { + InputManager.SetDebugSequence(pchSeq, &CMinecraftApp::DebugInputCallback, + this); } -int CMinecraftApp::DebugInputCallback(void *pParam) -{ - CMinecraftApp* pClass = (CMinecraftApp*)pParam; - //printf("sequence matched\n"); - pClass->m_bDebugOptions=!pClass->m_bDebugOptions; +int CMinecraftApp::DebugInputCallback(void* pParam) { + CMinecraftApp* pClass = (CMinecraftApp*)pParam; + // printf("sequence matched\n"); + pClass->m_bDebugOptions = !pClass->m_bDebugOptions; - for(int i=0;ilocalplayers[i] != NULL) - { - iPlayerC++; - } - } +int CMinecraftApp::GetLocalPlayerCount(void) { + int iPlayerC = 0; + Minecraft* pMinecraft = Minecraft::GetInstance(); + for (int i = 0; i < XUSER_MAX_COUNT; i++) { + if (pMinecraft != NULL && pMinecraft->localplayers[i] != NULL) { + iPlayerC++; + } + } - return iPlayerC; + return iPlayerC; } -int CMinecraftApp::MarketplaceCountsCallback(void *pParam,C4JStorage::DLC_TMS_DETAILS *pTMSDetails, int iPad) -{ - app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n",pTMSDetails->dwNewOffers,pTMSDetails->dwTotalOffers); +int CMinecraftApp::MarketplaceCountsCallback( + void* pParam, C4JStorage::DLC_TMS_DETAILS* pTMSDetails, int iPad) { + app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n", + pTMSDetails->dwNewOffers, pTMSDetails->dwTotalOffers); - if(pTMSDetails->dwNewOffers>0) - { - app.m_bNewDLCAvailable=true; - app.m_bSeenNewDLCTip=false; - } - else - { - app.m_bNewDLCAvailable=false; - app.m_bSeenNewDLCTip=true; - } + if (pTMSDetails->dwNewOffers > 0) { + app.m_bNewDLCAvailable = true; + app.m_bSeenNewDLCTip = false; + } else { + app.m_bNewDLCAvailable = false; + app.m_bSeenNewDLCTip = true; + } - return 0; + return 0; } -bool CMinecraftApp::StartInstallDLCProcess(int iPad) -{ - app.DebugPrintf("--- CMinecraftApp::StartInstallDLCProcess: pad=%i.\n", iPad); +bool CMinecraftApp::StartInstallDLCProcess(int iPad) { + app.DebugPrintf("--- CMinecraftApp::StartInstallDLCProcess: pad=%i.\n", + iPad); - // If there is already a call to this in progress, then do nothing - // If the app says dlc is installed, then there has been no new system message to tell us there's new DLC since the last call to StartInstallDLCProcess - if((app.DLCInstallProcessCompleted()==false) && (m_bDLCInstallPending==false)) - { - app.m_dlcManager.resetUnnamedCorruptCount(); - m_bDLCInstallPending = true; - m_iTotalDLC = 0; - m_iTotalDLCInstalled = 0; - app.DebugPrintf("--- CMinecraftApp::StartInstallDLCProcess - StorageManager.GetInstalledDLC\n"); + // If there is already a call to this in progress, then do nothing + // If the app says dlc is installed, then there has been no new system + // message to tell us there's new DLC since the last call to + // StartInstallDLCProcess + if ((app.DLCInstallProcessCompleted() == false) && + (m_bDLCInstallPending == false)) { + app.m_dlcManager.resetUnnamedCorruptCount(); + m_bDLCInstallPending = true; + m_iTotalDLC = 0; + m_iTotalDLCInstalled = 0; + app.DebugPrintf( + "--- CMinecraftApp::StartInstallDLCProcess - " + "StorageManager.GetInstalledDLC\n"); - StorageManager.GetInstalledDLC(iPad,&CMinecraftApp::DLCInstalledCallback,this); - return true; - } - else - { - app.DebugPrintf("--- CMinecraftApp::StartInstallDLCProcess - nothing to do\n"); - - return false; - } + StorageManager.GetInstalledDLC( + iPad, &CMinecraftApp::DLCInstalledCallback, this); + return true; + } else { + app.DebugPrintf( + "--- CMinecraftApp::StartInstallDLCProcess - nothing to do\n"); + return false; + } } // Installed DLC callback -int CMinecraftApp::DLCInstalledCallback(void *pParam,int iInstalledC,int iPad) -{ - app.DebugPrintf("--- CMinecraftApp::DLCInstalledCallback: totalDLC=%i, pad=%i.\n", iInstalledC, iPad); - app.m_iTotalDLC = iInstalledC; - app.MountNextDLC(iPad); - return 0; +int CMinecraftApp::DLCInstalledCallback(void* pParam, int iInstalledC, + int iPad) { + app.DebugPrintf( + "--- CMinecraftApp::DLCInstalledCallback: totalDLC=%i, pad=%i.\n", + iInstalledC, iPad); + app.m_iTotalDLC = iInstalledC; + app.MountNextDLC(iPad); + return 0; } -void CMinecraftApp::MountNextDLC(int iPad) -{ - app.DebugPrintf("--- CMinecraftApp::MountNextDLC: pad=%i.\n", iPad); - if(m_iTotalDLCInstalled < m_iTotalDLC) - { - // Mount it - // We also need to match the ones the user wants to mount with the installed DLC - // We're supposed to use a generic save game as a cache of these to do this, with XUSER_ANY +void CMinecraftApp::MountNextDLC(int iPad) { + app.DebugPrintf("--- CMinecraftApp::MountNextDLC: pad=%i.\n", iPad); + if (m_iTotalDLCInstalled < m_iTotalDLC) { + // Mount it + // We also need to match the ones the user wants to mount with the + // installed DLC We're supposed to use a generic save game as a cache of + // these to do this, with XUSER_ANY - if(StorageManager.MountInstalledDLC(iPad,m_iTotalDLCInstalled,&CMinecraftApp::DLCMountedCallback,this)!=ERROR_IO_PENDING ) - { - // corrupt DLC - app.DebugPrintf("Failed to mount DLC %d for pad %d\n",m_iTotalDLCInstalled,iPad); - ++m_iTotalDLCInstalled; - app.MountNextDLC(iPad); - } - else - { - app.DebugPrintf("StorageManager.MountInstalledDLC ok\n"); - } - } - else - { - /* Removed - now loading these on demand instead of as each pack is mounted - if(m_iTotalDLCInstalled > 0) - { - Minecraft *pMinecraft=Minecraft::GetInstance(); - pMinecraft->levelRenderer->AddDLCSkinsToMemTextures(); - } - */ + if (StorageManager.MountInstalledDLC(iPad, m_iTotalDLCInstalled, + &CMinecraftApp::DLCMountedCallback, + this) != ERROR_IO_PENDING) { + // corrupt DLC + app.DebugPrintf("Failed to mount DLC %d for pad %d\n", + m_iTotalDLCInstalled, iPad); + ++m_iTotalDLCInstalled; + app.MountNextDLC(iPad); + } else { + app.DebugPrintf("StorageManager.MountInstalledDLC ok\n"); + } + } else { + /* Removed - now loading these on demand instead of as each pack is + mounted if(m_iTotalDLCInstalled > 0) + { + Minecraft *pMinecraft=Minecraft::GetInstance(); + pMinecraft->levelRenderer->AddDLCSkinsToMemTextures(); + } + */ - m_bDLCInstallPending = false; - m_bDLCInstallProcessCompleted=true; + m_bDLCInstallPending = false; + m_bDLCInstallProcessCompleted = true; - ui.HandleDLCMountingComplete(); + ui.HandleDLCMountingComplete(); #if defined(_XBOX_ONE) || defined(__ORBIS__) - // Check if the current texture pack is now installed - if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) - { - TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; + // Check if the current texture pack is now installed + if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { + TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected(); + DLCTexturePack* pDLCTexPack = (DLCTexturePack*)tPack; - DLCPack *pParentPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack(); + DLCPack* pParentPack = + pDLCTexPack->getDLCInfoParentPack(); // tPack->getDLCPack(); - if(pParentPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { - StorageManager.SetSaveDisabled(false); - } - } + if (pParentPack->hasPurchasedFile(DLCManager::e_DLCType_Texture, + L"")) { + StorageManager.SetSaveDisabled(false); + } + } #endif - } + } } // 4J-JEV: For the sake of clarity in DLCMountedCallback. @@ -5092,690 +5425,686 @@ void CMinecraftApp::MountNextDLC(int iPad) #define CONTENT_DATA_DISPLAY_NAME(a) (a.wszDisplayName) #endif -int CMinecraftApp::DLCMountedCallback(void *pParam,int iPad,std::uint32_t dwErr,std::uint32_t dwLicenceMask) -{ -#if defined(_XBOX) || defined(_DURANGO) || defined(__PS3__) || defined(__ORBIS__) || defined(_WINDOWS64) || defined (__PSVITA__) //Chris TODO - app.DebugPrintf("--- CMinecraftApp::DLCMountedCallback\n"); +int CMinecraftApp::DLCMountedCallback(void* pParam, int iPad, + std::uint32_t dwErr, + std::uint32_t dwLicenceMask) { +#if defined(_XBOX) || defined(_DURANGO) || defined(__PS3__) || \ + defined(__ORBIS__) || defined(_WINDOWS64) || \ + defined(__PSVITA__) // Chris TODO + app.DebugPrintf("--- CMinecraftApp::DLCMountedCallback\n"); - if(dwErr!=ERROR_SUCCESS) - { - // corrupt DLC - app.DebugPrintf("Failed to mount DLC for pad %d: %u\n",iPad,dwErr); - app.m_dlcManager.incrementUnnamedCorruptCount(); - } - else - { - XCONTENT_DATA ContentData = StorageManager.GetDLC(app.m_iTotalDLCInstalled); + if (dwErr != ERROR_SUCCESS) { + // corrupt DLC + app.DebugPrintf("Failed to mount DLC for pad %d: %u\n", iPad, dwErr); + app.m_dlcManager.incrementUnnamedCorruptCount(); + } else { + XCONTENT_DATA ContentData = + StorageManager.GetDLC(app.m_iTotalDLCInstalled); - DLCPack *pack = app.m_dlcManager.getPack( CONTENT_DATA_DISPLAY_NAME(ContentData) ); + DLCPack* pack = + app.m_dlcManager.getPack(CONTENT_DATA_DISPLAY_NAME(ContentData)); - if( pack != NULL && pack->IsCorrupt() ) - { - app.DebugPrintf("Pack '%ls' is corrupt, removing it from the DLC Manager.\n", CONTENT_DATA_DISPLAY_NAME(ContentData)); + if (pack != NULL && pack->IsCorrupt()) { + app.DebugPrintf( + "Pack '%ls' is corrupt, removing it from the DLC Manager.\n", + CONTENT_DATA_DISPLAY_NAME(ContentData)); - app.m_dlcManager.removePack(pack); - pack = NULL; - } - - if(pack == NULL) - { - app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n", CONTENT_DATA_DISPLAY_NAME(ContentData)); + app.m_dlcManager.removePack(pack); + pack = NULL; + } + + if (pack == NULL) { + app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n", + CONTENT_DATA_DISPLAY_NAME(ContentData)); #if defined(_XBOX) || defined(__PS3__) || defined(_WINDOWS64) - pack = new DLCPack(ContentData.szDisplayName,dwLicenceMask); + pack = new DLCPack(ContentData.szDisplayName, dwLicenceMask); #elif defined _XBOX_ONE - pack = new DLCPack(ContentData.wszDisplayName,ContentData.wszProductID,dwLicenceMask); + pack = new DLCPack(ContentData.wszDisplayName, + ContentData.wszProductID, dwLicenceMask); #else - pack = new DLCPack(ContentData.wszDisplayName,dwLicenceMask); + pack = new DLCPack(ContentData.wszDisplayName, dwLicenceMask); #endif - pack->SetDLCMountIndex(app.m_iTotalDLCInstalled); - pack->SetDLCDeviceID(ContentData.DeviceID); - app.m_dlcManager.addPack(pack); + pack->SetDLCMountIndex(app.m_iTotalDLCInstalled); + pack->SetDLCDeviceID(ContentData.DeviceID); + app.m_dlcManager.addPack(pack); - app.HandleDLC(pack); + app.HandleDLC(pack); - if(pack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) - { - Minecraft::GetInstance()->skins->addTexturePackFromDLC(pack, pack->GetPackId() ); - } - } - else - { - app.DebugPrintf("Pack \"%ls\" is already installed. Updating license to %u\n", CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask); + if (pack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) { + Minecraft::GetInstance()->skins->addTexturePackFromDLC( + pack, pack->GetPackId()); + } + } else { + app.DebugPrintf( + "Pack \"%ls\" is already installed. Updating license to %u\n", + CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask); - pack->SetDLCMountIndex(app.m_iTotalDLCInstalled); - pack->SetDLCDeviceID(ContentData.DeviceID); - pack->updateLicenseMask(dwLicenceMask); - } + pack->SetDLCMountIndex(app.m_iTotalDLCInstalled); + pack->SetDLCDeviceID(ContentData.DeviceID); + pack->updateLicenseMask(dwLicenceMask); + } - StorageManager.UnmountInstalledDLC(); - } - ++app.m_iTotalDLCInstalled; - app.MountNextDLC(iPad); + StorageManager.UnmountInstalledDLC(); + } + ++app.m_iTotalDLCInstalled; + app.MountNextDLC(iPad); -#endif // __PSVITA__ - return 0; +#endif // __PSVITA__ + return 0; } #undef CONTENT_DATA_DISPLAY_NAME // void CMinecraftApp::InstallDefaultCape() // { // if(!m_bDefaultCapeInstallAttempted) -// { -// // we only attempt to install the cape once per launch of the game -// m_bDefaultCapeInstallAttempted=true; -// +// { +// // we only attempt to install the cape once per launch of the +// game m_bDefaultCapeInstallAttempted=true; +// // std::wstring wTemp=L"Default_Cape.png"; // bool bRes=app.IsFileInMemoryTextures(wTemp); -// // if the file is not already in the memory textures, then read it from TMS -// if(!bRes) -// { +// // if the file is not already in the memory textures, then read +// it from TMS if(!bRes) +// { // BYTE *pBuffer=NULL; // DWORD dwSize=0; -// // 4J-PB - out for now for DaveK so he doesn't get the birthday cape -// #ifdef _CONTENT_PACKAGE -// C4JStorage::ETMSStatus eTMSStatus; -// eTMSStatus=StorageManager.ReadTMSFile(ProfileManager.GetPrimaryPad(),C4JStorage::eGlobalStorage_Title,C4JStorage::eTMS_FileType_Graphic, L"Default_Cape.png",&pBuffer, &dwSize); +// // 4J-PB - out for now for DaveK so he doesn't get the +// birthday cape #ifdef _CONTENT_PACKAGE C4JStorage::ETMSStatus eTMSStatus; +// eTMSStatus=StorageManager.ReadTMSFile(ProfileManager.GetPrimaryPad(),C4JStorage::eGlobalStorage_Title,C4JStorage::eTMS_FileType_Graphic, +// L"Default_Cape.png",&pBuffer, &dwSize); // if(eTMSStatus==C4JStorage::ETMSStatus_Idle) // { // app.AddMemoryTextureFile(wTemp,pBuffer,dwSize); -// } +// } // #endif // } // } // } - void CMinecraftApp::HandleDLC(DLCPack *pack) - { - unsigned int dwFilesProcessed = 0; +void CMinecraftApp::HandleDLC(DLCPack* pack) { + unsigned int dwFilesProcessed = 0; #ifndef _XBOX -#if defined(__PS3__) || defined(__ORBIS__) || defined(_WINDOWS64) || defined (__PSVITA__) || defined(__linux__) - std::vector dlcFilenames; +#if defined(__PS3__) || defined(__ORBIS__) || defined(_WINDOWS64) || \ + defined(__PSVITA__) || defined(__linux__) + std::vector dlcFilenames; #elif defined _DURANGO - std::vector dlcFilenames; + std::vector dlcFilenames; #endif - StorageManager.GetMountedDLCFileList("DLCDrive", dlcFilenames); - for(int i=0; i(qwDeltaTime.QuadPart); - m_Time.fAppTime = m_Time.fSecsPerTick * static_cast(m_Time.qwAppTime.QuadPart); - } - - - - - - - -bool CMinecraftApp::isXuidNotch(PlayerUID xuid) -{ - if(m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) - { - return ProfileManager.AreXUIDSEqual(xuid, m_xuidNotch); - } - return false; + // Zero out the elapsed and total time + m_Time.qwAppTime.QuadPart = 0; + m_Time.fAppTime = 0.0f; + m_Time.fElapsedTime = 0.0f; } -bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) -{ - AUTO_VAR(it, MojangData.find( xuid )); // 4J Stu - The .at and [] accessors insert elements if they don't exist - if (it != MojangData.end() ) - { - MOJANG_DATA *pMojangData=MojangData[xuid]; - if(pMojangData && pMojangData->eXuid==eXUID_Deadmau5) - { - return true; - } - } +//------------------------------------------------------------------------------------- +// Name: UpdateTime() +// Desc: Updates the elapsed time since our last frame. +//------------------------------------------------------------------------------------- +void CMinecraftApp::UpdateTime() { + LARGE_INTEGER qwNewTime; + LARGE_INTEGER qwDeltaTime; - return false; + QueryPerformanceCounter(&qwNewTime); + qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_Time.qwTime.QuadPart; + + m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; + m_Time.qwTime.QuadPart = qwNewTime.QuadPart; + + m_Time.fElapsedTime = + m_Time.fSecsPerTick * static_cast(qwDeltaTime.QuadPart); + m_Time.fAppTime = + m_Time.fSecsPerTick * static_cast(m_Time.qwAppTime.QuadPart); } -void CMinecraftApp::AddMemoryTextureFile(const std::wstring &wName, std::uint8_t *pbData, unsigned int byteCount) -{ - EnterCriticalSection(&csMemFilesLock); - // check it's not already in - PMEMDATA pData=NULL; - AUTO_VAR(it, m_MEM_Files.find(wName)); - if(it != m_MEM_Files.end()) - { +bool CMinecraftApp::isXuidNotch(PlayerUID xuid) { + if (m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) { + return ProfileManager.AreXUIDSEqual(xuid, m_xuidNotch); + } + return false; +} + +bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) { + AUTO_VAR(it, MojangData.find(xuid)); // 4J Stu - The .at and [] accessors + // insert elements if they don't exist + if (it != MojangData.end()) { + MOJANG_DATA* pMojangData = MojangData[xuid]; + if (pMojangData && pMojangData->eXuid == eXUID_Deadmau5) { + return true; + } + } + + return false; +} + +void CMinecraftApp::AddMemoryTextureFile(const std::wstring& wName, + std::uint8_t* pbData, + unsigned int byteCount) { + EnterCriticalSection(&csMemFilesLock); + // check it's not already in + PMEMDATA pData = NULL; + AUTO_VAR(it, m_MEM_Files.find(wName)); + if (it != m_MEM_Files.end()) { #ifndef _CONTENT_PACKAGE - wprintf(L"Incrementing the memory texture file count for %ls\n", wName.c_str()); + wprintf(L"Incrementing the memory texture file count for %ls\n", + wName.c_str()); #endif - pData = (*it).second; + pData = (*it).second; - if(pData->byteCount == 0 && byteCount != 0) - { - // This should never be NULL if byteCount is 0 - if(pData->pbData!=NULL) delete [] pData->pbData; + if (pData->byteCount == 0 && byteCount != 0) { + // This should never be NULL if byteCount is 0 + if (pData->pbData != NULL) delete[] pData->pbData; - pData->pbData=pbData; - pData->byteCount=byteCount; - } + pData->pbData = pbData; + pData->byteCount = byteCount; + } - ++pData->ucRefCount; - LeaveCriticalSection(&csMemFilesLock); - return; - } + ++pData->ucRefCount; + LeaveCriticalSection(&csMemFilesLock); + return; + } #ifndef _CONTENT_PACKAGE - //wprintf(L"Adding the memory texture file data for %ls\n", wName.c_str()); + // wprintf(L"Adding the memory texture file data for %ls\n", wName.c_str()); #endif - // this is a texture (png) file + // this is a texture (png) file - // add this texture to the list of memory texture files - it will then be picked up by the level renderer's AddEntity + // add this texture to the list of memory texture files - it will then be + // picked up by the level renderer's AddEntity - pData = new MEMDATA(); - pData->pbData=pbData; - pData->byteCount=byteCount; - pData->ucRefCount = 1; + pData = new MEMDATA(); + pData->pbData = pbData; + pData->byteCount = byteCount; + pData->ucRefCount = 1; - // use the xuid to access the skin data - m_MEM_Files[wName]=pData; + // use the xuid to access the skin data + m_MEM_Files[wName] = pData; - LeaveCriticalSection(&csMemFilesLock); + LeaveCriticalSection(&csMemFilesLock); } -void CMinecraftApp::RemoveMemoryTextureFile(const std::wstring &wName) -{ - EnterCriticalSection(&csMemFilesLock); - - AUTO_VAR(it, m_MEM_Files.find(wName)); - if(it != m_MEM_Files.end()) - { +void CMinecraftApp::RemoveMemoryTextureFile(const std::wstring& wName) { + EnterCriticalSection(&csMemFilesLock); + + AUTO_VAR(it, m_MEM_Files.find(wName)); + if (it != m_MEM_Files.end()) { #ifndef _CONTENT_PACKAGE - wprintf(L"Decrementing the memory texture file count for %ls\n", wName.c_str()); + wprintf(L"Decrementing the memory texture file count for %ls\n", + wName.c_str()); #endif - PMEMDATA pData = (*it).second; - --pData->ucRefCount; - if(pData->ucRefCount <= 0) - { + PMEMDATA pData = (*it).second; + --pData->ucRefCount; + if (pData->ucRefCount <= 0) { #ifndef _CONTENT_PACKAGE - wprintf(L"Erasing the memory texture file data for %ls\n", wName.c_str()); + wprintf(L"Erasing the memory texture file data for %ls\n", + wName.c_str()); #endif - delete pData; - m_MEM_Files.erase(wName); - } - } - LeaveCriticalSection(&csMemFilesLock); + delete pData; + m_MEM_Files.erase(wName); + } + } + LeaveCriticalSection(&csMemFilesLock); } -bool CMinecraftApp::DefaultCapeExists() -{ - std::wstring wTex=L"Special_Cape.png"; - bool val = false; +bool CMinecraftApp::DefaultCapeExists() { + std::wstring wTex = L"Special_Cape.png"; + bool val = false; - EnterCriticalSection(&csMemFilesLock); - AUTO_VAR(it, m_MEM_Files.find(wTex)); - if(it != m_MEM_Files.end()) val = true; - LeaveCriticalSection(&csMemFilesLock); + EnterCriticalSection(&csMemFilesLock); + AUTO_VAR(it, m_MEM_Files.find(wTex)); + if (it != m_MEM_Files.end()) val = true; + LeaveCriticalSection(&csMemFilesLock); - return val; + return val; } -bool CMinecraftApp::IsFileInMemoryTextures(const std::wstring &wName) -{ - bool val = false; +bool CMinecraftApp::IsFileInMemoryTextures(const std::wstring& wName) { + bool val = false; - EnterCriticalSection(&csMemFilesLock); - AUTO_VAR(it, m_MEM_Files.find(wName)); - if(it != m_MEM_Files.end()) val = true; - LeaveCriticalSection(&csMemFilesLock); + EnterCriticalSection(&csMemFilesLock); + AUTO_VAR(it, m_MEM_Files.find(wName)); + if (it != m_MEM_Files.end()) val = true; + LeaveCriticalSection(&csMemFilesLock); - return val; + return val; } -void CMinecraftApp::GetMemFileDetails(const std::wstring &wName, std::uint8_t **ppbData, unsigned int *pByteCount) -{ - EnterCriticalSection(&csMemFilesLock); - AUTO_VAR(it, m_MEM_Files.find(wName)); - if(it != m_MEM_Files.end()) - { - PMEMDATA pData = (*it).second; - *ppbData=pData->pbData; - *pByteCount=pData->byteCount; - } - LeaveCriticalSection(&csMemFilesLock); +void CMinecraftApp::GetMemFileDetails(const std::wstring& wName, + std::uint8_t** ppbData, + unsigned int* pByteCount) { + EnterCriticalSection(&csMemFilesLock); + AUTO_VAR(it, m_MEM_Files.find(wName)); + if (it != m_MEM_Files.end()) { + PMEMDATA pData = (*it).second; + *ppbData = pData->pbData; + *pByteCount = pData->byteCount; + } + LeaveCriticalSection(&csMemFilesLock); } -void CMinecraftApp::AddMemoryTPDFile(int iConfig, std::uint8_t *pbData, unsigned int byteCount) -{ - EnterCriticalSection(&csMemTPDLock); - // check it's not already in - PMEMDATA pData=NULL; - AUTO_VAR(it, m_MEM_TPD.find(iConfig)); - if(it == m_MEM_TPD.end()) - { - pData = new MEMDATA(); - pData->pbData=pbData; - pData->byteCount=byteCount; - pData->ucRefCount = 1; +void CMinecraftApp::AddMemoryTPDFile(int iConfig, std::uint8_t* pbData, + unsigned int byteCount) { + EnterCriticalSection(&csMemTPDLock); + // check it's not already in + PMEMDATA pData = NULL; + AUTO_VAR(it, m_MEM_TPD.find(iConfig)); + if (it == m_MEM_TPD.end()) { + pData = new MEMDATA(); + pData->pbData = pbData; + pData->byteCount = byteCount; + pData->ucRefCount = 1; - m_MEM_TPD[iConfig]=pData; - } + m_MEM_TPD[iConfig] = pData; + } - LeaveCriticalSection(&csMemTPDLock); + LeaveCriticalSection(&csMemTPDLock); } -void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) -{ - EnterCriticalSection(&csMemTPDLock); - // check it's not already in - PMEMDATA pData=NULL; - AUTO_VAR(it, m_MEM_TPD.find(iConfig)); - if(it != m_MEM_TPD.end()) - { - pData=m_MEM_TPD[iConfig]; - delete pData; - m_MEM_TPD.erase(iConfig); - } +void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) { + EnterCriticalSection(&csMemTPDLock); + // check it's not already in + PMEMDATA pData = NULL; + AUTO_VAR(it, m_MEM_TPD.find(iConfig)); + if (it != m_MEM_TPD.end()) { + pData = m_MEM_TPD[iConfig]; + delete pData; + m_MEM_TPD.erase(iConfig); + } - LeaveCriticalSection(&csMemTPDLock); + LeaveCriticalSection(&csMemTPDLock); } #ifdef _XBOX -int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) -{ - DLC_INFO *pDLCInfo=NULL; - // run through the DLC info to find the right texture pack/mash-up pack - for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) - { - ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); - pDLCInfo=app.GetDLCInfoForFullOfferID(ull); +int CMinecraftApp::GetTPConfigVal(WCHAR* pwchDataFile) { + DLC_INFO* pDLCInfo = NULL; + // run through the DLC info to find the right texture pack/mash-up pack + for (unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) { + ULONGLONG ull = app.GetDLCInfoTexturesFullOffer(i); + pDLCInfo = app.GetDLCInfoForFullOfferID(ull); - if(wcscmp(pwchDataFile,pDLCInfo->wchDataFile)==0) - { - return pDLCInfo->iConfig; - } - } + if (wcscmp(pwchDataFile, pDLCInfo->wchDataFile) == 0) { + return pDLCInfo->iConfig; + } + } - return -1; + return -1; } #elif defined _XBOX_ONE -int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) -{ - DLC_INFO *pDLCInfo=NULL; - // run through the DLC info to find the right texture pack/mash-up pack - for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) - { - pDLCInfo=app.GetDLCInfoForFullOfferID((WCHAR *)app.GetDLCInfoTexturesFullOffer(i).c_str()); +int CMinecraftApp::GetTPConfigVal(WCHAR* pwchDataFile) { + DLC_INFO* pDLCInfo = NULL; + // run through the DLC info to find the right texture pack/mash-up pack + for (unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i) { + pDLCInfo = app.GetDLCInfoForFullOfferID( + (WCHAR*)app.GetDLCInfoTexturesFullOffer(i).c_str()); - if(wcscmp(pwchDataFile,pDLCInfo->wchDataFile)==0) - { - return pDLCInfo->iConfig; - } - } + if (wcscmp(pwchDataFile, pDLCInfo->wchDataFile) == 0) { + return pDLCInfo->iConfig; + } + } - return -1; + return -1; } #elif defined _WINDOWS64 -int CMinecraftApp::GetTPConfigVal(WCHAR *pwchDataFile) -{ - return -1; -} +int CMinecraftApp::GetTPConfigVal(WCHAR* pwchDataFile) { return -1; } #endif -bool CMinecraftApp::IsFileInTPD(int iConfig) -{ - bool val = false; +bool CMinecraftApp::IsFileInTPD(int iConfig) { + bool val = false; - EnterCriticalSection(&csMemTPDLock); - AUTO_VAR(it, m_MEM_TPD.find(iConfig)); - if(it != m_MEM_TPD.end()) val = true; - LeaveCriticalSection(&csMemTPDLock); + EnterCriticalSection(&csMemTPDLock); + AUTO_VAR(it, m_MEM_TPD.find(iConfig)); + if (it != m_MEM_TPD.end()) val = true; + LeaveCriticalSection(&csMemTPDLock); - return val; + return val; } -void CMinecraftApp::GetTPD(int iConfig, std::uint8_t **ppbData, unsigned int *pByteCount) -{ - EnterCriticalSection(&csMemTPDLock); - AUTO_VAR(it, m_MEM_TPD.find(iConfig)); - if(it != m_MEM_TPD.end()) - { - PMEMDATA pData = (*it).second; - *ppbData=pData->pbData; - *pByteCount=pData->byteCount; - } - LeaveCriticalSection(&csMemTPDLock); +void CMinecraftApp::GetTPD(int iConfig, std::uint8_t** ppbData, + unsigned int* pByteCount) { + EnterCriticalSection(&csMemTPDLock); + AUTO_VAR(it, m_MEM_TPD.find(iConfig)); + if (it != m_MEM_TPD.end()) { + PMEMDATA pData = (*it).second; + *ppbData = pData->pbData; + *pByteCount = pData->byteCount; + } + LeaveCriticalSection(&csMemTPDLock); } - -// bool CMinecraftApp::UploadFileToGlobalStorage(int iQuadrant, C4JStorage::eGlobalStorage eStorageFacility, std::wstring *wsFile ) +// bool CMinecraftApp::UploadFileToGlobalStorage(int iQuadrant, +// C4JStorage::eGlobalStorage eStorageFacility, std::wstring *wsFile ) // { // bool bRes=false; // #ifndef _CONTENT_PACKAGE // // read the local file // File gtsFile( wsFile->c_str() ); -// +// // __int64 fileSize = gtsFile.length(); -// +// // if(fileSize!=0) // { // FileInputStream fis(gtsFile); // byteArray ba((int)fileSize); // fis.read(ba); // fis.close(); -// -// bRes=StorageManager.WriteTMSFile(iQuadrant,eStorageFacility,(WCHAR *)wsFile->c_str(),ba.data, ba.length); -// +// +// bRes=StorageManager.WriteTMSFile(iQuadrant,eStorageFacility,(WCHAR +// *)wsFile->c_str(),ba.data, ba.length); +// // } // #endif // return bRes; // } +void CMinecraftApp::StoreLaunchData() {} - - - - -void CMinecraftApp::StoreLaunchData() -{ - -} - -void CMinecraftApp::ExitGame() -{ -} +void CMinecraftApp::ExitGame() {} // Invites -void CMinecraftApp::ProcessInvite(std::uint32_t dwUserIndex, std::uint32_t dwLocalUsersMask, const INVITE_INFO * pInviteInfo) -{ - m_InviteData.dwUserIndex=dwUserIndex; - m_InviteData.dwLocalUsersMask=dwLocalUsersMask; - m_InviteData.pInviteInfo=pInviteInfo; - //memcpy(&m_InviteData,pJoinData,sizeof(JoinFromInviteData)); - SetAction(dwUserIndex,eAppAction_ExitAndJoinFromInvite); +void CMinecraftApp::ProcessInvite(std::uint32_t dwUserIndex, + std::uint32_t dwLocalUsersMask, + const INVITE_INFO* pInviteInfo) { + m_InviteData.dwUserIndex = dwUserIndex; + m_InviteData.dwLocalUsersMask = dwLocalUsersMask; + m_InviteData.pInviteInfo = pInviteInfo; + // memcpy(&m_InviteData,pJoinData,sizeof(JoinFromInviteData)); + SetAction(dwUserIndex, eAppAction_ExitAndJoinFromInvite); } -int CMinecraftApp::ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - CMinecraftApp* pApp = (CMinecraftApp*)pParam; - //Minecraft *pMinecraft=Minecraft::GetInstance(); +int CMinecraftApp::ExitAndJoinFromInvite(void* pParam, int iPad, + C4JStorage::EMessageResult result) { + CMinecraftApp* pApp = (CMinecraftApp*)pParam; + // Minecraft *pMinecraft=Minecraft::GetInstance(); - // buttons are swapped on this menu - if(result==C4JStorage::EMessage_ResultDecline) - { - pApp->SetAction(iPad,eAppAction_ExitAndJoinFromInviteConfirmed); - } + // buttons are swapped on this menu + if (result == C4JStorage::EMessage_ResultDecline) { + pApp->SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed); + } - return 0; + return 0; } -int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - CMinecraftApp *pClass = (CMinecraftApp *)pParam; - // Exit with or without saving - // Decline means save in this dialog - if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption) - { - if( result==C4JStorage::EMessage_ResultDecline ) // Save - { - // Check they have the full texture pack if they are using one - // 4J-PB - Is the player trying to save but they are using a trial texturepack ? - if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) - { - TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); +int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + CMinecraftApp* pClass = (CMinecraftApp*)pParam; + // Exit with or without saving + // Decline means save in this dialog + if (result == C4JStorage::EMessage_ResultDecline || + result == C4JStorage::EMessage_ResultThirdOption) { + if (result == C4JStorage::EMessage_ResultDecline) // Save + { + // Check they have the full texture pack if they are using one + // 4J-PB - Is the player trying to save but they are using a trial + // texturepack ? + if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { + TexturePack* tPack = + Minecraft::GetInstance()->skins->getSelected(); - DLCPack * pDLCPack=tPack->getDLCPack(); - if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { - // upsell - // get the dlc texture pack + DLCPack* pDLCPack = tPack->getDLCPack(); + if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture, + L"")) { + // upsell + // get the dlc texture pack #ifdef _XBOX - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; - ULONGLONG ullOfferID_Full; - app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full); + DLCTexturePack* pDLCTexPack = (DLCTexturePack*)tPack; + ULONGLONG ullOfferID_Full; + app.GetDLCFullOfferIDForPackID( + pDLCTexPack->getDLCParentPackId(), &ullOfferID_Full); - // tell sentient about the upsell of the full version of the skin pack - TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); + // tell sentient about the upsell of the full version of the + // skin pack + TelemetryManager->RecordUpsellPresented( + iPad, eSet_UpsellID_Texture_DLC, + ullOfferID_Full & 0xFFFFFFFF); #endif - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_OK; - uiIDA[1]=IDS_CONFIRM_CANCEL; + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_OK; + uiIDA[1] = IDS_CONFIRM_CANCEL; - // Give the player a warning about the trial version of the texture pack - ui.RequestMessageBox(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,pClass,app.GetStringTable()); + // Give the player a warning about the trial version of the + // texture pack + ui.RequestMessageBox( + IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, + IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad, + &CMinecraftApp::WarningTrialTexturePackReturned, pClass, + app.GetStringTable()); - return 0; - } - } + return 0; + } + } #ifndef _XBOX_ONE - // does the save exist? - bool bSaveExists; - StorageManager.DoesSaveExist(&bSaveExists); - // 4J-PB - we check if the save exists inside the libs - // we need to ask if they are sure they want to overwrite the existing game - if(bSaveExists) - { - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_CANCEL; - uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned,pClass, app.GetStringTable()); - return 0; - } - else + // does the save exist? + bool bSaveExists; + StorageManager.DoesSaveExist(&bSaveExists); + // 4J-PB - we check if the save exists inside the libs + // we need to ask if they are sure they want to overwrite the + // existing game + if (bSaveExists) { + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_CONFIRM_OK; + ui.RequestMessageBox( + IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned, + pClass, app.GetStringTable()); + return 0; + } else #endif - { + { #if defined(_XBOX_ONE) || defined(__ORBIS__) - StorageManager.SetSaveDisabled(false); + StorageManager.SetSaveDisabled(false); #endif - MinecraftServer::getInstance()->setSaveOnExit( true ); - } - } - else - { - // been a few requests for a confirm on exit without saving - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_CANCEL; - uiIDA[1]=IDS_CONFIRM_OK; - ui.RequestMessageBox(IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned,pClass, app.GetStringTable()); - return 0; - } + MinecraftServer::getInstance()->setSaveOnExit(true); + } + } else { + // been a few requests for a confirm on exit without saving + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_CONFIRM_OK; + ui.RequestMessageBox( + IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, + uiIDA, 2, ProfileManager.GetPrimaryPad(), + &CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned, + pClass, app.GetStringTable()); + return 0; + } - app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_ExitAndJoinFromInviteConfirmed); - } - return 0; + app.SetAction(ProfileManager.GetPrimaryPad(), + eAppAction_ExitAndJoinFromInviteConfirmed); + } + return 0; } -int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ +int CMinecraftApp::WarningTrialTexturePackReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { #ifdef _XBOX - CMinecraftApp* pClass = (CMinecraftApp*)pParam; + CMinecraftApp* pClass = (CMinecraftApp*)pParam; - TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); - // get the dlc texture pack - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; - ULONGLONG ullIndexA[1]; + TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected(); + // get the dlc texture pack + DLCTexturePack* pDLCTexPack = (DLCTexturePack*)tPack; + ULONGLONG ullIndexA[1]; - // Need to get the parent packs id, since this may be one of many child packs with their own ids - app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullIndexA[0]); + // Need to get the parent packs id, since this may be one of many child + // packs with their own ids + app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(), + &ullIndexA[0]); - if(result==C4JStorage::EMessage_ResultAccept) - { - if(ProfileManager.IsSignedIn(iPad)) - { - // need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth... - XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); + if (result == C4JStorage::EMessage_ResultAccept) { + if (ProfileManager.IsSignedIn(iPad)) { + // need to allow downloads here, or the player would need to quit + // the game to let the download of a texture pack happen. This might + // affect the network traffic, since the download could take all the + // bandwidth... + XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); - } - } - else - { - TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( ullIndexA[0] & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined); - } + StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); + } + } else { + TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, + (ullIndexA[0] & 0xFFFFFFFF), + eSen_UpsellOutcome_Declined); + } #endif - return 0; + return 0; } -int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - //CMinecraftApp* pClass = (CMinecraftApp*)pParam; +int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + // CMinecraftApp* pClass = (CMinecraftApp*)pParam; - // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) - { - int saveOrCheckpointId = 0; + // results switched for this dialog + if (result == C4JStorage::EMessage_ResultDecline) { + int saveOrCheckpointId = 0; - // Check they have the full texture pack if they are using one - // 4J-PB - Is the player trying to save but they are using a trial texturepack ? - if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) - { - TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); + // Check they have the full texture pack if they are using one + // 4J-PB - Is the player trying to save but they are using a trial + // texturepack ? + if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { + TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected(); - DLCPack * pDLCPack=tPack->getDLCPack(); - if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { - // upsell - // get the dlc texture pack + DLCPack* pDLCPack = tPack->getDLCPack(); + if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture, + L"")) { + // upsell + // get the dlc texture pack #ifdef _XBOX - DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack; - ULONGLONG ullOfferID_Full; - app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full); + DLCTexturePack* pDLCTexPack = (DLCTexturePack*)tPack; + ULONGLONG ullOfferID_Full; + app.GetDLCFullOfferIDForPackID( + pDLCTexPack->getDLCParentPackId(), &ullOfferID_Full); - // tell sentient about the upsell of the full version of the skin pack - TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); + // tell sentient about the upsell of the full version of the + // skin pack + TelemetryManager->RecordUpsellPresented( + iPad, eSet_UpsellID_Texture_DLC, + ullOfferID_Full & 0xFFFFFFFF); #endif - unsigned int uiIDA[2]; - uiIDA[0]=IDS_CONFIRM_OK; - uiIDA[1]=IDS_CONFIRM_CANCEL; + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_OK; + uiIDA[1] = IDS_CONFIRM_CANCEL; - // Give the player a warning about the trial version of the texture pack - ui.RequestMessageBox(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,&CMinecraftApp::WarningTrialTexturePackReturned,NULL,app.GetStringTable()); + // Give the player a warning about the trial version of the + // texture pack + ui.RequestMessageBox( + IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, + IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad, + &CMinecraftApp::WarningTrialTexturePackReturned, NULL, + app.GetStringTable()); - return 0; - } - } - //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); - //SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId); - MinecraftServer::getInstance()->setSaveOnExit( true ); - // flag a app action of exit and join game from invite - app.SetAction(iPad,eAppAction_ExitAndJoinFromInviteConfirmed); - } - return 0; + return 0; + } + } + // bool validSave = + // StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); + // SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), + // saveOrCheckpointId); + MinecraftServer::getInstance()->setSaveOnExit(true); + // flag a app action of exit and join game from invite + app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed); + } + return 0; } -int CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) - { +int CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + // results switched for this dialog + if (result == C4JStorage::EMessage_ResultDecline) { #if defined(_XBOX_ONE) || defined(__ORBIS__) - StorageManager.SetSaveDisabled(false); + StorageManager.SetSaveDisabled(false); #endif - MinecraftServer::getInstance()->setSaveOnExit( false ); - // flag a app action of exit and join game from invite - app.SetAction(iPad,eAppAction_ExitAndJoinFromInviteConfirmed); - } - return 0; + MinecraftServer::getInstance()->setSaveOnExit(false); + // flag a app action of exit and join game from invite + app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed); + } + return 0; } ////////////////////////////////////////////////////////////////////////// @@ -5787,3680 +6116,3548 @@ int CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned(void *pParam,int iPa // We have to assume that we've not been able to load the text for the game. // ////////////////////////////////////////////////////////////////////////// -void CMinecraftApp::FatalLoadError() -{ +void CMinecraftApp::FatalLoadError() {} -} - -TIPSTRUCT CMinecraftApp::m_GameTipA[MAX_TIPS_GAMETIP]= -{ - { 0, IDS_TIPS_GAMETIP_1}, - { 0, IDS_TIPS_GAMETIP_2}, - { 0, IDS_TIPS_GAMETIP_3}, - { 0, IDS_TIPS_GAMETIP_4}, - { 0, IDS_TIPS_GAMETIP_5}, - { 0, IDS_TIPS_GAMETIP_6}, - { 0, IDS_TIPS_GAMETIP_7}, - { 0, IDS_TIPS_GAMETIP_8}, - { 0, IDS_TIPS_GAMETIP_9}, - { 0, IDS_TIPS_GAMETIP_10}, - { 0, IDS_TIPS_GAMETIP_11}, - { 0, IDS_TIPS_GAMETIP_12}, - { 0, IDS_TIPS_GAMETIP_13}, - { 0, IDS_TIPS_GAMETIP_14}, - { 0, IDS_TIPS_GAMETIP_15}, - { 0, IDS_TIPS_GAMETIP_16}, - { 0, IDS_TIPS_GAMETIP_17}, - { 0, IDS_TIPS_GAMETIP_18}, - { 0, IDS_TIPS_GAMETIP_19}, - { 0, IDS_TIPS_GAMETIP_20}, - { 0, IDS_TIPS_GAMETIP_21}, - { 0, IDS_TIPS_GAMETIP_22}, - { 0, IDS_TIPS_GAMETIP_23}, - { 0, IDS_TIPS_GAMETIP_24}, - { 0, IDS_TIPS_GAMETIP_25}, - { 0, IDS_TIPS_GAMETIP_26}, - { 0, IDS_TIPS_GAMETIP_27}, - { 0, IDS_TIPS_GAMETIP_28}, - { 0, IDS_TIPS_GAMETIP_29}, - { 0, IDS_TIPS_GAMETIP_30}, - { 0, IDS_TIPS_GAMETIP_31}, - { 0, IDS_TIPS_GAMETIP_32}, - { 0, IDS_TIPS_GAMETIP_33}, - { 0, IDS_TIPS_GAMETIP_34}, - { 0, IDS_TIPS_GAMETIP_35}, - { 0, IDS_TIPS_GAMETIP_36}, - { 0, IDS_TIPS_GAMETIP_37}, - { 0, IDS_TIPS_GAMETIP_38}, - { 0, IDS_TIPS_GAMETIP_39}, - { 0, IDS_TIPS_GAMETIP_40}, - { 0, IDS_TIPS_GAMETIP_41}, - { 0, IDS_TIPS_GAMETIP_42}, - { 0, IDS_TIPS_GAMETIP_43}, - { 0, IDS_TIPS_GAMETIP_44}, - { 0, IDS_TIPS_GAMETIP_45}, - { 0, IDS_TIPS_GAMETIP_46}, - { 0, IDS_TIPS_GAMETIP_47}, - { 0, IDS_TIPS_GAMETIP_48}, - { 0, IDS_TIPS_GAMETIP_49}, - { 0, IDS_TIPS_GAMETIP_50}, +TIPSTRUCT CMinecraftApp::m_GameTipA[MAX_TIPS_GAMETIP] = { + {0, IDS_TIPS_GAMETIP_1}, {0, IDS_TIPS_GAMETIP_2}, + {0, IDS_TIPS_GAMETIP_3}, {0, IDS_TIPS_GAMETIP_4}, + {0, IDS_TIPS_GAMETIP_5}, {0, IDS_TIPS_GAMETIP_6}, + {0, IDS_TIPS_GAMETIP_7}, {0, IDS_TIPS_GAMETIP_8}, + {0, IDS_TIPS_GAMETIP_9}, {0, IDS_TIPS_GAMETIP_10}, + {0, IDS_TIPS_GAMETIP_11}, {0, IDS_TIPS_GAMETIP_12}, + {0, IDS_TIPS_GAMETIP_13}, {0, IDS_TIPS_GAMETIP_14}, + {0, IDS_TIPS_GAMETIP_15}, {0, IDS_TIPS_GAMETIP_16}, + {0, IDS_TIPS_GAMETIP_17}, {0, IDS_TIPS_GAMETIP_18}, + {0, IDS_TIPS_GAMETIP_19}, {0, IDS_TIPS_GAMETIP_20}, + {0, IDS_TIPS_GAMETIP_21}, {0, IDS_TIPS_GAMETIP_22}, + {0, IDS_TIPS_GAMETIP_23}, {0, IDS_TIPS_GAMETIP_24}, + {0, IDS_TIPS_GAMETIP_25}, {0, IDS_TIPS_GAMETIP_26}, + {0, IDS_TIPS_GAMETIP_27}, {0, IDS_TIPS_GAMETIP_28}, + {0, IDS_TIPS_GAMETIP_29}, {0, IDS_TIPS_GAMETIP_30}, + {0, IDS_TIPS_GAMETIP_31}, {0, IDS_TIPS_GAMETIP_32}, + {0, IDS_TIPS_GAMETIP_33}, {0, IDS_TIPS_GAMETIP_34}, + {0, IDS_TIPS_GAMETIP_35}, {0, IDS_TIPS_GAMETIP_36}, + {0, IDS_TIPS_GAMETIP_37}, {0, IDS_TIPS_GAMETIP_38}, + {0, IDS_TIPS_GAMETIP_39}, {0, IDS_TIPS_GAMETIP_40}, + {0, IDS_TIPS_GAMETIP_41}, {0, IDS_TIPS_GAMETIP_42}, + {0, IDS_TIPS_GAMETIP_43}, {0, IDS_TIPS_GAMETIP_44}, + {0, IDS_TIPS_GAMETIP_45}, {0, IDS_TIPS_GAMETIP_46}, + {0, IDS_TIPS_GAMETIP_47}, {0, IDS_TIPS_GAMETIP_48}, + {0, IDS_TIPS_GAMETIP_49}, {0, IDS_TIPS_GAMETIP_50}, }; -TIPSTRUCT CMinecraftApp::m_TriviaTipA[MAX_TIPS_TRIVIATIP]= -{ - { 0, IDS_TIPS_TRIVIA_1}, - { 0, IDS_TIPS_TRIVIA_2}, - { 0, IDS_TIPS_TRIVIA_3}, - { 0, IDS_TIPS_TRIVIA_4}, - { 0, IDS_TIPS_TRIVIA_5}, - { 0, IDS_TIPS_TRIVIA_6}, - { 0, IDS_TIPS_TRIVIA_7}, - { 0, IDS_TIPS_TRIVIA_8}, - { 0, IDS_TIPS_TRIVIA_9}, - { 0, IDS_TIPS_TRIVIA_10}, - { 0, IDS_TIPS_TRIVIA_11}, - { 0, IDS_TIPS_TRIVIA_12}, - { 0, IDS_TIPS_TRIVIA_13}, - { 0, IDS_TIPS_TRIVIA_14}, - { 0, IDS_TIPS_TRIVIA_15}, - { 0, IDS_TIPS_TRIVIA_16}, - { 0, IDS_TIPS_TRIVIA_17}, - { 0, IDS_TIPS_TRIVIA_18}, - { 0, IDS_TIPS_TRIVIA_19}, - { 0, IDS_TIPS_TRIVIA_20}, +TIPSTRUCT CMinecraftApp::m_TriviaTipA[MAX_TIPS_TRIVIATIP] = { + {0, IDS_TIPS_TRIVIA_1}, {0, IDS_TIPS_TRIVIA_2}, {0, IDS_TIPS_TRIVIA_3}, + {0, IDS_TIPS_TRIVIA_4}, {0, IDS_TIPS_TRIVIA_5}, {0, IDS_TIPS_TRIVIA_6}, + {0, IDS_TIPS_TRIVIA_7}, {0, IDS_TIPS_TRIVIA_8}, {0, IDS_TIPS_TRIVIA_9}, + {0, IDS_TIPS_TRIVIA_10}, {0, IDS_TIPS_TRIVIA_11}, {0, IDS_TIPS_TRIVIA_12}, + {0, IDS_TIPS_TRIVIA_13}, {0, IDS_TIPS_TRIVIA_14}, {0, IDS_TIPS_TRIVIA_15}, + {0, IDS_TIPS_TRIVIA_16}, {0, IDS_TIPS_TRIVIA_17}, {0, IDS_TIPS_TRIVIA_18}, + {0, IDS_TIPS_TRIVIA_19}, {0, IDS_TIPS_TRIVIA_20}, }; -Random *CMinecraftApp::TipRandom = new Random(); +Random* CMinecraftApp::TipRandom = new Random(); -int CMinecraftApp::TipsSortFunction(const void* a, const void* b) -{ - // 4jcraft, scince the sortvalues can be negative, i changed it - // to a three way comparison, - // scince subtracting of signed integers can cause overflow. - - int s1 = ((TIPSTRUCT*)a)->iSortValue; - int s2 = ((TIPSTRUCT*)b)->iSortValue; +int CMinecraftApp::TipsSortFunction(const void* a, const void* b) { + // 4jcraft, scince the sortvalues can be negative, i changed it + // to a three way comparison, + // scince subtracting of signed integers can cause overflow. - if(s1 > s2) { - return 1; + int s1 = ((TIPSTRUCT*)a)->iSortValue; + int s2 = ((TIPSTRUCT*)b)->iSortValue; - } else if (s1 == s2) { - return 0; - } + if (s1 > s2) { + return 1; - return -1; + } else if (s1 == s2) { + return 0; + } + + return -1; } -void CMinecraftApp::InitialiseTips() -{ - // We'll randomise the tips at start up based on their priority +void CMinecraftApp::InitialiseTips() { + // We'll randomise the tips at start up based on their priority - ZeroMemory(m_TipIDA, sizeof(m_TipIDA)); + ZeroMemory(m_TipIDA, sizeof(m_TipIDA)); - // Make the first tip tell you that you can play splitscreen in HD modes if you are in SD - if(!RenderManager.IsHiDef()) - { - m_GameTipA[0].uiStringID=IDS_TIPS_GAMETIP_0; - } - // randomise then quicksort - // going to leave the multiplayer tip so it is always first + // Make the first tip tell you that you can play splitscreen in HD modes if + // you are in SD + if (!RenderManager.IsHiDef()) { + m_GameTipA[0].uiStringID = IDS_TIPS_GAMETIP_0; + } + // randomise then quicksort + // going to leave the multiplayer tip so it is always first // Only randomise the content package build #ifdef _CONTENT_PACKAGE - - for(int i=1;inextInt(); - } - qsort( &m_GameTipA[1], MAX_TIPS_GAMETIP-1, sizeof(TIPSTRUCT), TipsSortFunction ); + + for (int i = 1; i < MAX_TIPS_GAMETIP; i++) { + m_GameTipA[i].iSortValue = TipRandom->nextInt(); + } + qsort(&m_GameTipA[1], MAX_TIPS_GAMETIP - 1, sizeof(TIPSTRUCT), + TipsSortFunction); #endif - for(int i=0;inextInt(); - } - qsort( m_TriviaTipA, MAX_TIPS_TRIVIATIP, sizeof(TIPSTRUCT), TipsSortFunction ); + for (int i = 0; i < MAX_TIPS_TRIVIATIP; i++) { + m_TriviaTipA[i].iSortValue = TipRandom->nextInt(); + } + qsort(m_TriviaTipA, MAX_TIPS_TRIVIATIP, sizeof(TIPSTRUCT), + TipsSortFunction); + int iCurrentGameTip = 0; + int iCurrentTriviaTip = 0; - int iCurrentGameTip=0; - int iCurrentTriviaTip=0; + for (int i = 0; i < MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP; i++) { + // Add a trivia one every third tip (if there are any left) + if ((i % 3 == 2) && (iCurrentTriviaTip < MAX_TIPS_TRIVIATIP)) { + // Add a trivia one + m_TipIDA[i] = m_TriviaTipA[iCurrentTriviaTip++].uiStringID; + } else { + if (iCurrentGameTip < MAX_TIPS_GAMETIP) { + // Add a gametip + m_TipIDA[i] = m_GameTipA[iCurrentGameTip++].uiStringID; + } else { + // Add a trivia one + m_TipIDA[i] = m_TriviaTipA[iCurrentTriviaTip++].uiStringID; + } + } - for(int i=0;iskins->getSelected()->getColourTable()->getColour(colour); +int CMinecraftApp::GetHTMLColour(eMinecraftColour colour) { + Minecraft* pMinecraft = Minecraft::GetInstance(); + return pMinecraft->skins->getSelected()->getColourTable()->getColour( + colour); } -int CMinecraftApp::GetHTMLFontSize(EHTMLFontSize size) -{ - return s_iHTMLFontSizesA[size]; +int CMinecraftApp::GetHTMLFontSize(EHTMLFontSize size) { + return s_iHTMLFontSizesA[size]; } -std::wstring CMinecraftApp::FormatHTMLString(int iPad, const std::wstring &desc, int shadowColour /*= 0xFFFFFFFF*/) -{ - std::wstring text(desc); - - wchar_t replacements[64]; - // We will also insert line breaks here as couldn't figure out how to get them to come through from strings.resx ! - text = replaceAll(text, L"{*B*}", L"
" ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_T1)); - text = replaceAll(text, L"{*T1*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_T2)); - text = replaceAll(text, L"{*T2*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_T3)); - text = replaceAll(text, L"{*T3*}", replacements ); // for How To Play - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_Black)); - text = replaceAll(text, L"{*ETB*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_White)); - text = replaceAll(text, L"{*ETW*}", replacements ); - text = replaceAll(text, L"{*EF*}", L"" ); +std::wstring CMinecraftApp::FormatHTMLString( + int iPad, const std::wstring& desc, int shadowColour /*= 0xFFFFFFFF*/) { + std::wstring text(desc); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_0), shadowColour); - text = replaceAll(text, L"{*C0*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_1), shadowColour); - text = replaceAll(text, L"{*C1*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_2), shadowColour); - text = replaceAll(text, L"{*C2*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_3), shadowColour); - text = replaceAll(text, L"{*C3*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_4), shadowColour); - text = replaceAll(text, L"{*C4*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_5), shadowColour); - text = replaceAll(text, L"{*C5*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_6), shadowColour); - text = replaceAll(text, L"{*C6*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_7), shadowColour); - text = replaceAll(text, L"{*C7*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_8), shadowColour); - text = replaceAll(text, L"{*C8*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_9), shadowColour); - text = replaceAll(text, L"{*C9*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_a), shadowColour); - text = replaceAll(text, L"{*CA*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_b), shadowColour); - text = replaceAll(text, L"{*CB*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_c), shadowColour); - text = replaceAll(text, L"{*CC*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_d), shadowColour); - text = replaceAll(text, L"{*CD*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_e), shadowColour); - text = replaceAll(text, L"{*CE*}", replacements ); - swprintf(replacements,64,L"", GetHTMLColour(eHTMLColor_f), shadowColour); - text = replaceAll(text, L"{*CF*}", replacements ); + wchar_t replacements[64]; + // We will also insert line breaks here as couldn't figure out how to get + // them to come through from strings.resx ! + text = replaceAll(text, L"{*B*}", L"
"); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_T1)); + text = replaceAll(text, L"{*T1*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_T2)); + text = replaceAll(text, L"{*T2*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_T3)); + text = replaceAll(text, L"{*T3*}", replacements); // for How To Play + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_Black)); + text = replaceAll(text, L"{*ETB*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_White)); + text = replaceAll(text, L"{*ETW*}", replacements); + text = replaceAll(text, L"{*EF*}", L""); - // Swap for southpaw. - if ( app.GetGameSettings(iPad,eGameSetting_ControlSouthPaw) ) - { - text = replaceAll(text, L"{*CONTROLLER_ACTION_MOVE*}", GetActionReplacement(iPad,MINECRAFT_ACTION_LOOK_RIGHT ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_LOOK*}", GetActionReplacement(iPad,MINECRAFT_ACTION_RIGHT ) ); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_0), shadowColour); + text = replaceAll(text, L"{*C0*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_1), shadowColour); + text = replaceAll(text, L"{*C1*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_2), shadowColour); + text = replaceAll(text, L"{*C2*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_3), shadowColour); + text = replaceAll(text, L"{*C3*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_4), shadowColour); + text = replaceAll(text, L"{*C4*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_5), shadowColour); + text = replaceAll(text, L"{*C5*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_6), shadowColour); + text = replaceAll(text, L"{*C6*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_7), shadowColour); + text = replaceAll(text, L"{*C7*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_8), shadowColour); + text = replaceAll(text, L"{*C8*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_9), shadowColour); + text = replaceAll(text, L"{*C9*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_a), shadowColour); + text = replaceAll(text, L"{*CA*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_b), shadowColour); + text = replaceAll(text, L"{*CB*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_c), shadowColour); + text = replaceAll(text, L"{*CC*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_d), shadowColour); + text = replaceAll(text, L"{*CD*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_e), shadowColour); + text = replaceAll(text, L"{*CE*}", replacements); + swprintf(replacements, 64, L"", + GetHTMLColour(eHTMLColor_f), shadowColour); + text = replaceAll(text, L"{*CF*}", replacements); - text = replaceAll(text, L"{*CONTROLLER_MENU_NAVIGATE*}", GetVKReplacement(VK_PAD_RTHUMB_LEFT) ); - } - else // Normal right handed. - { - text = replaceAll(text, L"{*CONTROLLER_ACTION_MOVE*}", GetActionReplacement(iPad,MINECRAFT_ACTION_RIGHT ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_LOOK*}", GetActionReplacement(iPad,MINECRAFT_ACTION_LOOK_RIGHT ) ); + // Swap for southpaw. + if (app.GetGameSettings(iPad, eGameSetting_ControlSouthPaw)) { + text = + replaceAll(text, L"{*CONTROLLER_ACTION_MOVE*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_LOOK*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_RIGHT)); - text = replaceAll(text, L"{*CONTROLLER_MENU_NAVIGATE*}", GetVKReplacement(VK_PAD_LTHUMB_LEFT) ); - } + text = replaceAll(text, L"{*CONTROLLER_MENU_NAVIGATE*}", + GetVKReplacement(VK_PAD_RTHUMB_LEFT)); + } else // Normal right handed. + { + text = replaceAll(text, L"{*CONTROLLER_ACTION_MOVE*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_RIGHT)); + text = + replaceAll(text, L"{*CONTROLLER_ACTION_LOOK*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT)); - text = replaceAll(text, L"{*CONTROLLER_ACTION_JUMP*}", GetActionReplacement(iPad,MINECRAFT_ACTION_JUMP ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_SNEAK*}", GetActionReplacement(iPad,MINECRAFT_ACTION_SNEAK_TOGGLE ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_USE*}", GetActionReplacement(iPad,MINECRAFT_ACTION_USE ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_ACTION*}", GetActionReplacement(iPad,MINECRAFT_ACTION_ACTION ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_LEFT_SCROLL*}", GetActionReplacement(iPad,MINECRAFT_ACTION_LEFT_SCROLL ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_RIGHT_SCROLL*}", GetActionReplacement(iPad,MINECRAFT_ACTION_RIGHT_SCROLL ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_INVENTORY*}", GetActionReplacement(iPad,MINECRAFT_ACTION_INVENTORY ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_CRAFTING*}", GetActionReplacement(iPad,MINECRAFT_ACTION_CRAFTING ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DROP*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DROP ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_CAMERA*}", GetActionReplacement(iPad,MINECRAFT_ACTION_RENDER_THIRD_PERSON ) ); - text = replaceAll(text, L"{*CONTROLLER_VK_A*}", GetVKReplacement(VK_PAD_A) ); - text = replaceAll(text, L"{*CONTROLLER_VK_B*}", GetVKReplacement(VK_PAD_B) ); - text = replaceAll(text, L"{*CONTROLLER_VK_X*}", GetVKReplacement(VK_PAD_X) ); - text = replaceAll(text, L"{*CONTROLLER_VK_Y*}", GetVKReplacement(VK_PAD_Y) ); - text = replaceAll(text, L"{*CONTROLLER_VK_LB*}", GetVKReplacement(VK_PAD_LSHOULDER) ); - text = replaceAll(text, L"{*CONTROLLER_VK_RB*}", GetVKReplacement(VK_PAD_RSHOULDER) ); - text = replaceAll(text, L"{*CONTROLLER_VK_LS*}", GetVKReplacement(VK_PAD_LTHUMB_UP) ); - text = replaceAll(text, L"{*CONTROLLER_VK_RS*}", GetVKReplacement(VK_PAD_RTHUMB_UP) ); - text = replaceAll(text, L"{*CONTROLLER_VK_LT*}", GetVKReplacement(VK_PAD_LTRIGGER) ); - text = replaceAll(text, L"{*CONTROLLER_VK_RT*}", GetVKReplacement(VK_PAD_RTRIGGER) ); - text = replaceAll(text, L"{*ICON_SHANK_01*}", GetIconReplacement(XZP_ICON_SHANK_01) ); - text = replaceAll(text, L"{*ICON_SHANK_03*}", GetIconReplacement(XZP_ICON_SHANK_03) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_UP*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_UP ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_DOWN*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_DOWN ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_RIGHT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_RIGHT ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_LEFT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_LEFT ) ); + text = replaceAll(text, L"{*CONTROLLER_MENU_NAVIGATE*}", + GetVKReplacement(VK_PAD_LTHUMB_LEFT)); + } + + text = replaceAll(text, L"{*CONTROLLER_ACTION_JUMP*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_JUMP)); + text = + replaceAll(text, L"{*CONTROLLER_ACTION_SNEAK*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_USE*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_USE)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_ACTION*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_ACTION)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_LEFT_SCROLL*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_LEFT_SCROLL)); + text = + replaceAll(text, L"{*CONTROLLER_ACTION_RIGHT_SCROLL*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_RIGHT_SCROLL)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_INVENTORY*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_INVENTORY)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_CRAFTING*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_CRAFTING)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DROP*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_DROP)); + text = replaceAll( + text, L"{*CONTROLLER_ACTION_CAMERA*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_RENDER_THIRD_PERSON)); + text = replaceAll(text, L"{*CONTROLLER_VK_A*}", GetVKReplacement(VK_PAD_A)); + text = replaceAll(text, L"{*CONTROLLER_VK_B*}", GetVKReplacement(VK_PAD_B)); + text = replaceAll(text, L"{*CONTROLLER_VK_X*}", GetVKReplacement(VK_PAD_X)); + text = replaceAll(text, L"{*CONTROLLER_VK_Y*}", GetVKReplacement(VK_PAD_Y)); + text = replaceAll(text, L"{*CONTROLLER_VK_LB*}", + GetVKReplacement(VK_PAD_LSHOULDER)); + text = replaceAll(text, L"{*CONTROLLER_VK_RB*}", + GetVKReplacement(VK_PAD_RSHOULDER)); + text = replaceAll(text, L"{*CONTROLLER_VK_LS*}", + GetVKReplacement(VK_PAD_LTHUMB_UP)); + text = replaceAll(text, L"{*CONTROLLER_VK_RS*}", + GetVKReplacement(VK_PAD_RTHUMB_UP)); + text = replaceAll(text, L"{*CONTROLLER_VK_LT*}", + GetVKReplacement(VK_PAD_LTRIGGER)); + text = replaceAll(text, L"{*CONTROLLER_VK_RT*}", + GetVKReplacement(VK_PAD_RTRIGGER)); + text = replaceAll(text, L"{*ICON_SHANK_01*}", + GetIconReplacement(XZP_ICON_SHANK_01)); + text = replaceAll(text, L"{*ICON_SHANK_03*}", + GetIconReplacement(XZP_ICON_SHANK_03)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_UP*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_DPAD_UP)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_DOWN*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_DPAD_DOWN)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_RIGHT*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_DPAD_RIGHT)); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_LEFT*}", + GetActionReplacement(iPad, MINECRAFT_ACTION_DPAD_LEFT)); #if defined _XBOX_ONE || defined __PSVITA__ - text = replaceAll(text, L"{*CONTROLLER_VK_START*}", GetVKReplacement(VK_PAD_START ) ); - text = replaceAll(text, L"{*CONTROLLER_VK_BACK*}", GetVKReplacement(VK_PAD_BACK ) ); + text = replaceAll(text, L"{*CONTROLLER_VK_START*}", + GetVKReplacement(VK_PAD_START)); + text = replaceAll(text, L"{*CONTROLLER_VK_BACK*}", + GetVKReplacement(VK_PAD_BACK)); #endif #ifdef _XBOX - std::wstring imageRoot = L""; + std::wstring imageRoot = L""; - Minecraft *pMinecraft = Minecraft::GetInstance(); - imageRoot = pMinecraft->skins->getSelected()->getXuiRootPath(); + Minecraft* pMinecraft = Minecraft::GetInstance(); + imageRoot = pMinecraft->skins->getSelected()->getXuiRootPath(); - text = replaceAll(text, L"{*IMAGEROOT*}", imageRoot); -#endif // _XBOX + text = replaceAll(text, L"{*IMAGEROOT*}", imageRoot); +#endif // _XBOX - // Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered with padding space, which looks no good - std::uint32_t dwLanguage = XGetLanguage( ); - switch(dwLanguage) - { - case XC_LANGUAGE_KOREAN: - case XC_LANGUAGE_JAPANESE: - case XC_LANGUAGE_TCHINESE: - text = replaceAll(text, L" ", L"" ); - break; - } + // Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered + // with padding space, which looks no good + std::uint32_t dwLanguage = XGetLanguage(); + switch (dwLanguage) { + case XC_LANGUAGE_KOREAN: + case XC_LANGUAGE_JAPANESE: + case XC_LANGUAGE_TCHINESE: + text = replaceAll(text, L" ", L""); + break; + } - return text; + return text; } -std::wstring CMinecraftApp::GetActionReplacement(int iPad, unsigned char ucAction) -{ - unsigned int input = InputManager.GetGameJoypadMaps(InputManager.GetJoypadMapVal(iPad) ,ucAction); +std::wstring CMinecraftApp::GetActionReplacement(int iPad, + unsigned char ucAction) { + unsigned int input = InputManager.GetGameJoypadMaps( + InputManager.GetJoypadMapVal(iPad), ucAction); #ifdef _XBOX - switch(input) - { - case _360_JOY_BUTTON_A: - return app.GetString( IDS_CONTROLLER_A ); - case _360_JOY_BUTTON_B: - return app.GetString( IDS_CONTROLLER_B ); - case _360_JOY_BUTTON_X: - return app.GetString( IDS_CONTROLLER_X ); - case _360_JOY_BUTTON_Y: - return app.GetString( IDS_CONTROLLER_Y ); - case _360_JOY_BUTTON_LSTICK_UP: - case _360_JOY_BUTTON_LSTICK_DOWN: - case _360_JOY_BUTTON_LSTICK_LEFT: - case _360_JOY_BUTTON_LSTICK_RIGHT: - return app.GetString( IDS_CONTROLLER_LEFT_STICK ); - case _360_JOY_BUTTON_RSTICK_LEFT: - case _360_JOY_BUTTON_RSTICK_RIGHT: - case _360_JOY_BUTTON_RSTICK_UP: - case _360_JOY_BUTTON_RSTICK_DOWN: - return app.GetString( IDS_CONTROLLER_RIGHT_STICK ); - case _360_JOY_BUTTON_LT: - return app.GetString( IDS_CONTROLLER_LEFT_TRIGGER ); - case _360_JOY_BUTTON_RT: - return app.GetString( IDS_CONTROLLER_RIGHT_TRIGGER ); - case _360_JOY_BUTTON_RB: - return app.GetString( IDS_CONTROLLER_RIGHT_BUMPER ); - case _360_JOY_BUTTON_LB: - return app.GetString( IDS_CONTROLLER_LEFT_BUMPER ); - case _360_JOY_BUTTON_BACK: - return app.GetString( IDS_CONTROLLER_BACK ); - case _360_JOY_BUTTON_START: - return app.GetString( IDS_CONTROLLER_START ); - case _360_JOY_BUTTON_RTHUMB: - return app.GetString( IDS_CONTROLLER_RIGHT_THUMBSTICK ); - case _360_JOY_BUTTON_LTHUMB: - return app.GetString( IDS_CONTROLLER_LEFT_THUMBSTICK ); - case _360_JOY_BUTTON_DPAD_LEFT: - return app.GetString( IDS_CONTROLLER_DPAD_L ); - case _360_JOY_BUTTON_DPAD_RIGHT: - return app.GetString( IDS_CONTROLLER_DPAD_R ); - case _360_JOY_BUTTON_DPAD_UP: - return app.GetString( IDS_CONTROLLER_DPAD_U ); - case _360_JOY_BUTTON_DPAD_DOWN: - return app.GetString( IDS_CONTROLLER_DPAD_D ); - }; - return L""; + switch (input) { + case _360_JOY_BUTTON_A: + return app.GetString(IDS_CONTROLLER_A); + case _360_JOY_BUTTON_B: + return app.GetString(IDS_CONTROLLER_B); + case _360_JOY_BUTTON_X: + return app.GetString(IDS_CONTROLLER_X); + case _360_JOY_BUTTON_Y: + return app.GetString(IDS_CONTROLLER_Y); + case _360_JOY_BUTTON_LSTICK_UP: + case _360_JOY_BUTTON_LSTICK_DOWN: + case _360_JOY_BUTTON_LSTICK_LEFT: + case _360_JOY_BUTTON_LSTICK_RIGHT: + return app.GetString(IDS_CONTROLLER_LEFT_STICK); + case _360_JOY_BUTTON_RSTICK_LEFT: + case _360_JOY_BUTTON_RSTICK_RIGHT: + case _360_JOY_BUTTON_RSTICK_UP: + case _360_JOY_BUTTON_RSTICK_DOWN: + return app.GetString(IDS_CONTROLLER_RIGHT_STICK); + case _360_JOY_BUTTON_LT: + return app.GetString(IDS_CONTROLLER_LEFT_TRIGGER); + case _360_JOY_BUTTON_RT: + return app.GetString(IDS_CONTROLLER_RIGHT_TRIGGER); + case _360_JOY_BUTTON_RB: + return app.GetString(IDS_CONTROLLER_RIGHT_BUMPER); + case _360_JOY_BUTTON_LB: + return app.GetString(IDS_CONTROLLER_LEFT_BUMPER); + case _360_JOY_BUTTON_BACK: + return app.GetString(IDS_CONTROLLER_BACK); + case _360_JOY_BUTTON_START: + return app.GetString(IDS_CONTROLLER_START); + case _360_JOY_BUTTON_RTHUMB: + return app.GetString(IDS_CONTROLLER_RIGHT_THUMBSTICK); + case _360_JOY_BUTTON_LTHUMB: + return app.GetString(IDS_CONTROLLER_LEFT_THUMBSTICK); + case _360_JOY_BUTTON_DPAD_LEFT: + return app.GetString(IDS_CONTROLLER_DPAD_L); + case _360_JOY_BUTTON_DPAD_RIGHT: + return app.GetString(IDS_CONTROLLER_DPAD_R); + case _360_JOY_BUTTON_DPAD_UP: + return app.GetString(IDS_CONTROLLER_DPAD_U); + case _360_JOY_BUTTON_DPAD_DOWN: + return app.GetString(IDS_CONTROLLER_DPAD_D); + }; + return L""; #else - std::wstring replacement = L""; + std::wstring replacement = L""; - // 4J Stu - Some of our actions can be mapped to multiple physical buttons, so replaces the switch that was here - if (input & _360_JOY_BUTTON_A) replacement = L"ButtonA"; - else if(input &_360_JOY_BUTTON_B) replacement = L"ButtonB"; - else if(input &_360_JOY_BUTTON_X) replacement = L"ButtonX"; - else if(input &_360_JOY_BUTTON_Y) replacement = L"ButtonY"; - else if( - (input &_360_JOY_BUTTON_LSTICK_UP) || - (input &_360_JOY_BUTTON_LSTICK_DOWN) || - (input &_360_JOY_BUTTON_LSTICK_LEFT) || - (input &_360_JOY_BUTTON_LSTICK_RIGHT) - ) - { - replacement = L"ButtonLeftStick"; - } - else if( - (input &_360_JOY_BUTTON_RSTICK_LEFT) || - (input &_360_JOY_BUTTON_RSTICK_RIGHT) || - (input &_360_JOY_BUTTON_RSTICK_UP) || - (input &_360_JOY_BUTTON_RSTICK_DOWN) - ) - { - replacement = L"ButtonRightStick"; - } - else if(input &_360_JOY_BUTTON_DPAD_LEFT) replacement = L"ButtonDpadL"; - else if(input &_360_JOY_BUTTON_DPAD_RIGHT) replacement = L"ButtonDpadR"; - else if(input &_360_JOY_BUTTON_DPAD_UP) replacement = L"ButtonDpadU"; - else if(input &_360_JOY_BUTTON_DPAD_DOWN) replacement = L"ButtonDpadD"; - else if(input &_360_JOY_BUTTON_LT) replacement = L"ButtonLeftTrigger"; - else if(input &_360_JOY_BUTTON_RT) replacement = L"ButtonRightTrigger"; - else if(input &_360_JOY_BUTTON_RB) replacement = L"ButtonRightBumper"; - else if(input &_360_JOY_BUTTON_LB) replacement = L"ButtonLeftBumper"; - else if(input &_360_JOY_BUTTON_BACK) replacement = L"ButtonBack"; - else if(input &_360_JOY_BUTTON_START) replacement = L"ButtonStart"; - else if(input &_360_JOY_BUTTON_RTHUMB) replacement = L"ButtonRS"; - else if(input &_360_JOY_BUTTON_LTHUMB) replacement = L"ButtonLS"; + // 4J Stu - Some of our actions can be mapped to multiple physical buttons, + // so replaces the switch that was here + if (input & _360_JOY_BUTTON_A) + replacement = L"ButtonA"; + else if (input & _360_JOY_BUTTON_B) + replacement = L"ButtonB"; + else if (input & _360_JOY_BUTTON_X) + replacement = L"ButtonX"; + else if (input & _360_JOY_BUTTON_Y) + replacement = L"ButtonY"; + else if ((input & _360_JOY_BUTTON_LSTICK_UP) || + (input & _360_JOY_BUTTON_LSTICK_DOWN) || + (input & _360_JOY_BUTTON_LSTICK_LEFT) || + (input & _360_JOY_BUTTON_LSTICK_RIGHT)) { + replacement = L"ButtonLeftStick"; + } else if ((input & _360_JOY_BUTTON_RSTICK_LEFT) || + (input & _360_JOY_BUTTON_RSTICK_RIGHT) || + (input & _360_JOY_BUTTON_RSTICK_UP) || + (input & _360_JOY_BUTTON_RSTICK_DOWN)) { + replacement = L"ButtonRightStick"; + } else if (input & _360_JOY_BUTTON_DPAD_LEFT) + replacement = L"ButtonDpadL"; + else if (input & _360_JOY_BUTTON_DPAD_RIGHT) + replacement = L"ButtonDpadR"; + else if (input & _360_JOY_BUTTON_DPAD_UP) + replacement = L"ButtonDpadU"; + else if (input & _360_JOY_BUTTON_DPAD_DOWN) + replacement = L"ButtonDpadD"; + else if (input & _360_JOY_BUTTON_LT) + replacement = L"ButtonLeftTrigger"; + else if (input & _360_JOY_BUTTON_RT) + replacement = L"ButtonRightTrigger"; + else if (input & _360_JOY_BUTTON_RB) + replacement = L"ButtonRightBumper"; + else if (input & _360_JOY_BUTTON_LB) + replacement = L"ButtonLeftBumper"; + else if (input & _360_JOY_BUTTON_BACK) + replacement = L"ButtonBack"; + else if (input & _360_JOY_BUTTON_START) + replacement = L"ButtonStart"; + else if (input & _360_JOY_BUTTON_RTHUMB) + replacement = L"ButtonRS"; + else if (input & _360_JOY_BUTTON_LTHUMB) + replacement = L"ButtonLS"; - wchar_t string[128]; + wchar_t string[128]; #ifdef __PS3__ - int size = 30; + int size = 30; #elif defined _WIN64 - int size = 45; - if(ui.getScreenWidth() < 1920) size = 30; + int size = 45; + if (ui.getScreenWidth() < 1920) size = 30; #else - int size = 45; + int size = 45; #endif - swprintf(string,128,L"", replacement.c_str(), size, size); + swprintf(string, 128, + L"", + replacement.c_str(), size, size); - return string; + return string; #endif } -std::wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) -{ +std::wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) { #ifdef _XBOX - switch(uiVKey) - { - case VK_PAD_A: - return app.GetString( IDS_CONTROLLER_A ); - case VK_PAD_B: - return app.GetString( IDS_CONTROLLER_B ); - case VK_PAD_X: - return app.GetString( IDS_CONTROLLER_X ); - case VK_PAD_Y: - return app.GetString( IDS_CONTROLLER_Y ); - case VK_PAD_LSHOULDER: - return app.GetString( IDS_CONTROLLER_LEFT_BUMPER ); - case VK_PAD_RSHOULDER: - return app.GetString( IDS_CONTROLLER_RIGHT_BUMPER ); - case VK_PAD_LTRIGGER: - return app.GetString( IDS_CONTROLLER_LEFT_TRIGGER ); - case VK_PAD_RTRIGGER: - return app.GetString( IDS_CONTROLLER_RIGHT_TRIGGER ); - case VK_PAD_LTHUMB_UP : - case VK_PAD_LTHUMB_DOWN : - case VK_PAD_LTHUMB_RIGHT : - case VK_PAD_LTHUMB_LEFT : - case VK_PAD_LTHUMB_UPLEFT : - case VK_PAD_LTHUMB_UPRIGHT : - case VK_PAD_LTHUMB_DOWNRIGHT: - case VK_PAD_LTHUMB_DOWNLEFT : - return app.GetString( IDS_CONTROLLER_LEFT_STICK ); - case VK_PAD_RTHUMB_UP : - case VK_PAD_RTHUMB_DOWN : - case VK_PAD_RTHUMB_RIGHT : - case VK_PAD_RTHUMB_LEFT : - case VK_PAD_RTHUMB_UPLEFT : - case VK_PAD_RTHUMB_UPRIGHT : - case VK_PAD_RTHUMB_DOWNRIGHT: - case VK_PAD_RTHUMB_DOWNLEFT : - return app.GetString( IDS_CONTROLLER_RIGHT_STICK ); - default: - break; - } - return NULL; + switch (uiVKey) { + case VK_PAD_A: + return app.GetString(IDS_CONTROLLER_A); + case VK_PAD_B: + return app.GetString(IDS_CONTROLLER_B); + case VK_PAD_X: + return app.GetString(IDS_CONTROLLER_X); + case VK_PAD_Y: + return app.GetString(IDS_CONTROLLER_Y); + case VK_PAD_LSHOULDER: + return app.GetString(IDS_CONTROLLER_LEFT_BUMPER); + case VK_PAD_RSHOULDER: + return app.GetString(IDS_CONTROLLER_RIGHT_BUMPER); + case VK_PAD_LTRIGGER: + return app.GetString(IDS_CONTROLLER_LEFT_TRIGGER); + case VK_PAD_RTRIGGER: + return app.GetString(IDS_CONTROLLER_RIGHT_TRIGGER); + case VK_PAD_LTHUMB_UP: + case VK_PAD_LTHUMB_DOWN: + case VK_PAD_LTHUMB_RIGHT: + case VK_PAD_LTHUMB_LEFT: + case VK_PAD_LTHUMB_UPLEFT: + case VK_PAD_LTHUMB_UPRIGHT: + case VK_PAD_LTHUMB_DOWNRIGHT: + case VK_PAD_LTHUMB_DOWNLEFT: + return app.GetString(IDS_CONTROLLER_LEFT_STICK); + case VK_PAD_RTHUMB_UP: + case VK_PAD_RTHUMB_DOWN: + case VK_PAD_RTHUMB_RIGHT: + case VK_PAD_RTHUMB_LEFT: + case VK_PAD_RTHUMB_UPLEFT: + case VK_PAD_RTHUMB_UPRIGHT: + case VK_PAD_RTHUMB_DOWNRIGHT: + case VK_PAD_RTHUMB_DOWNLEFT: + return app.GetString(IDS_CONTROLLER_RIGHT_STICK); + default: + break; + } + return NULL; #else - std::wstring replacement = L""; - switch(uiVKey) - { - case VK_PAD_A: -#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) - if( InputManager.IsCircleCrossSwapped() ) replacement = L"ButtonB"; - else replacement = L"ButtonA"; + std::wstring replacement = L""; + switch (uiVKey) { + case VK_PAD_A: +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + if (InputManager.IsCircleCrossSwapped()) + replacement = L"ButtonB"; + else + replacement = L"ButtonA"; #else - replacement = L"ButtonA"; + replacement = L"ButtonA"; #endif - break; - case VK_PAD_B: -#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) - if( InputManager.IsCircleCrossSwapped() ) replacement = L"ButtonA"; - else replacement = L"ButtonB"; + break; + case VK_PAD_B: +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + if (InputManager.IsCircleCrossSwapped()) + replacement = L"ButtonA"; + else + replacement = L"ButtonB"; #else - replacement = L"ButtonB"; + replacement = L"ButtonB"; #endif - break; - case VK_PAD_X: - replacement = L"ButtonX"; - break; - case VK_PAD_Y: - replacement = L"ButtonY"; - break; - case VK_PAD_LSHOULDER: - replacement = L"ButtonLeftBumper"; - break; - case VK_PAD_RSHOULDER: - replacement = L"ButtonRightBumper"; - break; - case VK_PAD_LTRIGGER: - replacement = L"ButtonLeftTrigger"; - break; - case VK_PAD_RTRIGGER: - replacement = L"ButtonRightTrigger"; - break; - case VK_PAD_LTHUMB_UP : - case VK_PAD_LTHUMB_DOWN : - case VK_PAD_LTHUMB_RIGHT : - case VK_PAD_LTHUMB_LEFT : - case VK_PAD_LTHUMB_UPLEFT : - case VK_PAD_LTHUMB_UPRIGHT : - case VK_PAD_LTHUMB_DOWNRIGHT: - case VK_PAD_LTHUMB_DOWNLEFT : - replacement = L"ButtonLeftStick"; - break; - case VK_PAD_RTHUMB_UP : - case VK_PAD_RTHUMB_DOWN : - case VK_PAD_RTHUMB_RIGHT : - case VK_PAD_RTHUMB_LEFT : - case VK_PAD_RTHUMB_UPLEFT : - case VK_PAD_RTHUMB_UPRIGHT : - case VK_PAD_RTHUMB_DOWNRIGHT: - case VK_PAD_RTHUMB_DOWNLEFT : - replacement = L"ButtonRightStick"; - break; + break; + case VK_PAD_X: + replacement = L"ButtonX"; + break; + case VK_PAD_Y: + replacement = L"ButtonY"; + break; + case VK_PAD_LSHOULDER: + replacement = L"ButtonLeftBumper"; + break; + case VK_PAD_RSHOULDER: + replacement = L"ButtonRightBumper"; + break; + case VK_PAD_LTRIGGER: + replacement = L"ButtonLeftTrigger"; + break; + case VK_PAD_RTRIGGER: + replacement = L"ButtonRightTrigger"; + break; + case VK_PAD_LTHUMB_UP: + case VK_PAD_LTHUMB_DOWN: + case VK_PAD_LTHUMB_RIGHT: + case VK_PAD_LTHUMB_LEFT: + case VK_PAD_LTHUMB_UPLEFT: + case VK_PAD_LTHUMB_UPRIGHT: + case VK_PAD_LTHUMB_DOWNRIGHT: + case VK_PAD_LTHUMB_DOWNLEFT: + replacement = L"ButtonLeftStick"; + break; + case VK_PAD_RTHUMB_UP: + case VK_PAD_RTHUMB_DOWN: + case VK_PAD_RTHUMB_RIGHT: + case VK_PAD_RTHUMB_LEFT: + case VK_PAD_RTHUMB_UPLEFT: + case VK_PAD_RTHUMB_UPRIGHT: + case VK_PAD_RTHUMB_DOWNRIGHT: + case VK_PAD_RTHUMB_DOWNLEFT: + replacement = L"ButtonRightStick"; + break; #if defined _XBOX_ONE || defined __PSVITA__ - case VK_PAD_START: - replacement = L"ButtonStart"; - break; - case VK_PAD_BACK: - replacement = L"ButtonBack"; - break; + case VK_PAD_START: + replacement = L"ButtonStart"; + break; + case VK_PAD_BACK: + replacement = L"ButtonBack"; + break; #endif - default: - break; - } - wchar_t string[128]; + default: + break; + } + wchar_t string[128]; #ifdef __PS3__ - int size = 30; + int size = 30; #elif defined _WIN64 - int size = 45; - if(ui.getScreenWidth() < 1920) size = 30; + int size = 45; + if (ui.getScreenWidth() < 1920) size = 30; #else - int size = 45; + int size = 45; #endif - swprintf(string,128,L"", replacement.c_str(), size, size); + swprintf(string, 128, + L"", + replacement.c_str(), size, size); - return string; + return string; #endif } -std::wstring CMinecraftApp::GetIconReplacement(unsigned int uiIcon) -{ +std::wstring CMinecraftApp::GetIconReplacement(unsigned int uiIcon) { #ifdef _XBOX - switch(uiIcon) - { - case XZP_ICON_SHANK_01: - return app.GetString( IDS_ICON_SHANK_01 ); - case XZP_ICON_SHANK_03: - return app.GetString( IDS_ICON_SHANK_03 ); - default: - break; - } - return NULL; + switch (uiIcon) { + case XZP_ICON_SHANK_01: + return app.GetString(IDS_ICON_SHANK_01); + case XZP_ICON_SHANK_03: + return app.GetString(IDS_ICON_SHANK_03); + default: + break; + } + return NULL; #else - wchar_t string[128]; + wchar_t string[128]; #ifdef __PS3__ - int size = 22; + int size = 22; #elif defined _WIN64 - int size = 33; - if(ui.getScreenWidth() < 1920) size = 22; + int size = 33; + if (ui.getScreenWidth() < 1920) size = 22; #else - int size = 33; + int size = 33; #endif - swprintf(string,128,L"", size, size); - std::wstring result = L""; - switch(uiIcon) - { - case XZP_ICON_SHANK_01: - result = string; - break; - case XZP_ICON_SHANK_03: - result.append(string).append(string).append(string); - break; - default: - break; - } - return result; + swprintf(string, 128, + L"", + size, size); + std::wstring result = L""; + switch (uiIcon) { + case XZP_ICON_SHANK_01: + result = string; + break; + case XZP_ICON_SHANK_03: + result.append(string).append(string).append(string); + break; + default: + break; + } + return result; #endif } -#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) -std::unordered_map CMinecraftApp::MojangData; -std::unordered_map CMinecraftApp::DLCTextures_PackID; -std::unordered_map CMinecraftApp::DLCInfo; -std::unordered_map CMinecraftApp::DLCInfo_SkinName; +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) +std::unordered_map + CMinecraftApp::MojangData; +std::unordered_map CMinecraftApp::DLCTextures_PackID; +std::unordered_map CMinecraftApp::DLCInfo; +std::unordered_map CMinecraftApp::DLCInfo_SkinName; #elif defined(_DURANGO) -std::unordered_map CMinecraftApp::MojangData; -std::unordered_map CMinecraftApp::DLCTextures_PackID; // for mash-up packs & texture packs -//std::unordered_map CMinecraftApp::DLCInfo_Trial; // full offerid, dlc_info -std::unordered_map CMinecraftApp::DLCInfo_Full; // full offerid, dlc_info -std::unordered_map CMinecraftApp::DLCInfo_SkinName; // skin name, full offer id +std::unordered_map + CMinecraftApp::MojangData; +std::unordered_map + CMinecraftApp::DLCTextures_PackID; // for mash-up packs & texture packs +// std::unordered_map CMinecraftApp::DLCInfo_Trial; // +// full offerid, dlc_info +std::unordered_map + CMinecraftApp::DLCInfo_Full; // full offerid, dlc_info +std::unordered_map + CMinecraftApp::DLCInfo_SkinName; // skin name, full offer id #else -std::unordered_map CMinecraftApp::MojangData; -std::unordered_map CMinecraftApp::DLCTextures_PackID; -std::unordered_map CMinecraftApp::DLCInfo_Trial; -std::unordered_map CMinecraftApp::DLCInfo_Full; -std::unordered_map CMinecraftApp::DLCInfo_SkinName; +std::unordered_map CMinecraftApp::MojangData; +std::unordered_map CMinecraftApp::DLCTextures_PackID; +std::unordered_map CMinecraftApp::DLCInfo_Trial; +std::unordered_map CMinecraftApp::DLCInfo_Full; +std::unordered_map CMinecraftApp::DLCInfo_SkinName; #endif +HRESULT CMinecraftApp::RegisterMojangData(WCHAR* pXuidName, PlayerUID xuid, + WCHAR* pSkin, WCHAR* pCape) { + HRESULT hr = 0; + eXUID eTempXuid = eXUID_Undefined; + MOJANG_DATA* pMojangData = NULL; + // ignore the names if we don't recognize them + if (pXuidName != NULL) { + if (wcscmp(pXuidName, L"XUID_NOTCH") == 0) { + eTempXuid = + eXUID_Notch; // might be needed for the apple at some point + } else if (wcscmp(pXuidName, L"XUID_DEADMAU5") == 0) { + eTempXuid = eXUID_Deadmau5; // Needed for the deadmau5 ears + } else { + eTempXuid = eXUID_NoName; + } + } -HRESULT CMinecraftApp::RegisterMojangData(WCHAR *pXuidName, PlayerUID xuid, WCHAR *pSkin, WCHAR *pCape) -{ - HRESULT hr=0; - eXUID eTempXuid=eXUID_Undefined; - MOJANG_DATA *pMojangData=NULL; + if (eTempXuid != eXUID_Undefined) { + pMojangData = new MOJANG_DATA; + ZeroMemory(pMojangData, sizeof(MOJANG_DATA)); + pMojangData->eXuid = eTempXuid; - // ignore the names if we don't recognize them - if(pXuidName!=NULL) - { - if( wcscmp( pXuidName, L"XUID_NOTCH" ) == 0 ) - { - eTempXuid = eXUID_Notch; // might be needed for the apple at some point - } - else if( wcscmp( pXuidName, L"XUID_DEADMAU5" ) == 0 ) - { - eTempXuid = eXUID_Deadmau5; // Needed for the deadmau5 ears - } - else - { - eTempXuid=eXUID_NoName; - } - } + wcsncpy(pMojangData->wchSkin, pSkin, MAX_CAPENAME_SIZE); + wcsncpy(pMojangData->wchCape, pCape, MAX_CAPENAME_SIZE); + MojangData[xuid] = pMojangData; + } - if(eTempXuid!=eXUID_Undefined) - { - pMojangData = new MOJANG_DATA; - ZeroMemory(pMojangData,sizeof(MOJANG_DATA)); - pMojangData->eXuid=eTempXuid; - - wcsncpy( pMojangData->wchSkin, pSkin, MAX_CAPENAME_SIZE); - wcsncpy( pMojangData->wchCape, pCape, MAX_CAPENAME_SIZE); - MojangData[xuid]=pMojangData; - } - - return hr; + return hr; } -MOJANG_DATA *CMinecraftApp::GetMojangDataForXuid(PlayerUID xuid) -{ - return MojangData[xuid]; +MOJANG_DATA* CMinecraftApp::GetMojangDataForXuid(PlayerUID xuid) { + return MojangData[xuid]; } -HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) -{ - HRESULT hr=0; +HRESULT CMinecraftApp::RegisterConfigValues(WCHAR* pType, int iValue) { + HRESULT hr = 0; -// #ifdef _XBOX -// if(pType!=NULL) -// { -// if(wcscmp(pType,L"XboxOneTransfer")==0) -// { -// if(iValue>0) -// { -// app.m_bTransferSavesToXboxOne=true; -// } -// else -// { -// app.m_bTransferSavesToXboxOne=false; -// } -// } -// else if(wcscmp(pType,L"TransferSlotCount")==0) -// { -// app.m_uiTransferSlotC=iValue; -// } -// -// } -// #endif + // #ifdef _XBOX + // if(pType!=NULL) + // { + // if(wcscmp(pType,L"XboxOneTransfer")==0) + // { + // if(iValue>0) + // { + // app.m_bTransferSavesToXboxOne=true; + // } + // else + // { + // app.m_bTransferSavesToXboxOne=false; + // } + // } + // else if(wcscmp(pType,L"TransferSlotCount")==0) + // { + // app.m_uiTransferSlotC=iValue; + // } + // + // } + // #endif - - return hr; + return hr; } #if (defined _XBOX || defined _WINDOWS64) -HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGender, __uint64 ullOfferID_Full, __uint64 ullOfferID_Trial, WCHAR *pFirstSkin, unsigned int uiSortIndex, int iConfig, WCHAR *pDataFile) -{ - HRESULT hr=0; - DLC_INFO *pDLCData=new DLC_INFO; - ZeroMemory(pDLCData,sizeof(DLC_INFO)); - pDLCData->ullOfferID_Full=ullOfferID_Full; - pDLCData->ullOfferID_Trial=ullOfferID_Trial; - pDLCData->eDLCType=e_DLC_NotDefined; - pDLCData->iGender=iGender; - pDLCData->uiSortIndex=uiSortIndex; - pDLCData->iConfig=iConfig; +HRESULT CMinecraftApp::RegisterDLCData(WCHAR* pType, WCHAR* pBannerName, + int iGender, __uint64 ullOfferID_Full, + __uint64 ullOfferID_Trial, + WCHAR* pFirstSkin, + unsigned int uiSortIndex, int iConfig, + WCHAR* pDataFile) { + HRESULT hr = 0; + DLC_INFO* pDLCData = new DLC_INFO; + ZeroMemory(pDLCData, sizeof(DLC_INFO)); + pDLCData->ullOfferID_Full = ullOfferID_Full; + pDLCData->ullOfferID_Trial = ullOfferID_Trial; + pDLCData->eDLCType = e_DLC_NotDefined; + pDLCData->iGender = iGender; + pDLCData->uiSortIndex = uiSortIndex; + pDLCData->iConfig = iConfig; #ifndef __ORBIS__ - // ignore the names if we don't recognize them - if(pBannerName!=L"") - { - wcsncpy_s( pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE); - } + // ignore the names if we don't recognize them + if (pBannerName != L"") { + wcsncpy_s(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE); + } - if(pDataFile[0]!=0) - { - wcsncpy_s( pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE); - } + if (pDataFile[0] != 0) { + wcsncpy_s(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE); + } #endif - if(pType!=NULL) - { - if(wcscmp(pType,L"Skin")==0) - { - pDLCData->eDLCType=e_DLC_SkinPack; - } - else if(wcscmp(pType,L"Gamerpic")==0) - { - pDLCData->eDLCType=e_DLC_Gamerpics; - } - else if(wcscmp(pType,L"Theme")==0) - { - pDLCData->eDLCType=e_DLC_Themes; - } - else if(wcscmp(pType,L"Avatar")==0) - { - pDLCData->eDLCType=e_DLC_AvatarItems; - } - else if(wcscmp(pType,L"MashUpPack")==0) - { - pDLCData->eDLCType=e_DLC_MashupPacks; - DLCTextures_PackID[pDLCData->iConfig]=ullOfferID_Full; - } - else if(wcscmp(pType,L"TexturePack")==0) - { - pDLCData->eDLCType=e_DLC_TexturePacks; - DLCTextures_PackID[pDLCData->iConfig]=ullOfferID_Full; - } + if (pType != NULL) { + if (wcscmp(pType, L"Skin") == 0) { + pDLCData->eDLCType = e_DLC_SkinPack; + } else if (wcscmp(pType, L"Gamerpic") == 0) { + pDLCData->eDLCType = e_DLC_Gamerpics; + } else if (wcscmp(pType, L"Theme") == 0) { + pDLCData->eDLCType = e_DLC_Themes; + } else if (wcscmp(pType, L"Avatar") == 0) { + pDLCData->eDLCType = e_DLC_AvatarItems; + } else if (wcscmp(pType, L"MashUpPack") == 0) { + pDLCData->eDLCType = e_DLC_MashupPacks; + DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full; + } else if (wcscmp(pType, L"TexturePack") == 0) { + pDLCData->eDLCType = e_DLC_TexturePacks; + DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full; + } + } + if (ullOfferID_Trial != 0ll) DLCInfo_Trial[ullOfferID_Trial] = pDLCData; + if (ullOfferID_Full != 0ll) DLCInfo_Full[ullOfferID_Full] = pDLCData; + if (pFirstSkin[0] != 0) DLCInfo_SkinName[pFirstSkin] = ullOfferID_Full; - } - - if(ullOfferID_Trial!=0ll) DLCInfo_Trial[ullOfferID_Trial]=pDLCData; - if(ullOfferID_Full!=0ll) DLCInfo_Full[ullOfferID_Full]=pDLCData; - if(pFirstSkin[0]!=0) DLCInfo_SkinName[pFirstSkin]=ullOfferID_Full; - - return hr; + return hr; } #elif defined _XBOX_ONE -std::unordered_map *CMinecraftApp::GetDLCInfo() -{ - return &DLCInfo_Full; +std::unordered_map* CMinecraftApp::GetDLCInfo() { + return &DLCInfo_Full; } -HRESULT CMinecraftApp::RegisterDLCData(eDLCContentType eType, WCHAR *pwchBannerName,WCHAR *pwchProductId, WCHAR *pwchProductName, WCHAR *pwchFirstSkin, int iConfig, unsigned int uiSortIndex) -{ - HRESULT hr=0; - // 4J-PB - need to convert the product id to uppercase because the catalog calls come back with upper case - WCHAR wchUppercaseProductID[64]; - if(pwchProductId[0]!=0) - { - for(int i=0;i<64;i++) - { - wchUppercaseProductID[i]=towupper((wchar_t)pwchProductId[i]); - } - } +HRESULT CMinecraftApp::RegisterDLCData(eDLCContentType eType, + WCHAR* pwchBannerName, + WCHAR* pwchProductId, + WCHAR* pwchProductName, + WCHAR* pwchFirstSkin, int iConfig, + unsigned int uiSortIndex) { + HRESULT hr = 0; + // 4J-PB - need to convert the product id to uppercase because the catalog + // calls come back with upper case + WCHAR wchUppercaseProductID[64]; + if (pwchProductId[0] != 0) { + for (int i = 0; i < 64; i++) { + wchUppercaseProductID[i] = towupper((wchar_t)pwchProductId[i]); + } + } - // check if we already have this info from the local DLC file - std::wstring wsTemp=wchUppercaseProductID; + // check if we already have this info from the local DLC file + std::wstring wsTemp = wchUppercaseProductID; - AUTO_VAR(it, DLCInfo_Full.find(wsTemp)); - if( it == DLCInfo_Full.end() ) - { - // Not found + AUTO_VAR(it, DLCInfo_Full.find(wsTemp)); + if (it == DLCInfo_Full.end()) { + // Not found - DLC_INFO *pDLCData=new DLC_INFO; - ZeroMemory(pDLCData,sizeof(DLC_INFO)); + DLC_INFO* pDLCData = new DLC_INFO; + ZeroMemory(pDLCData, sizeof(DLC_INFO)); - pDLCData->eDLCType=e_DLC_NotDefined; - pDLCData->uiSortIndex=uiSortIndex; - pDLCData->iConfig=iConfig; + pDLCData->eDLCType = e_DLC_NotDefined; + pDLCData->uiSortIndex = uiSortIndex; + pDLCData->iConfig = iConfig; - if(pwchProductId[0]!=0) - { - pDLCData->wsProductId=wchUppercaseProductID; - } + if (pwchProductId[0] != 0) { + pDLCData->wsProductId = wchUppercaseProductID; + } - // ignore the names if we don't recognize them - if(pwchBannerName!=L"") - { - wcsncpy_s( pDLCData->wchBanner, pwchBannerName, MAX_BANNERNAME_SIZE); - } + // ignore the names if we don't recognize them + if (pwchBannerName != L"") { + wcsncpy_s(pDLCData->wchBanner, pwchBannerName, MAX_BANNERNAME_SIZE); + } - if(pwchProductName[0]!=0) - { - pDLCData->wsDisplayName=pwchProductName; - } + if (pwchProductName[0] != 0) { + pDLCData->wsDisplayName = pwchProductName; + } - pDLCData->eDLCType=eType; + pDLCData->eDLCType = eType; - switch(eType) - { - case e_DLC_MashupPacks: - case e_DLC_TexturePacks: - DLCTextures_PackID[iConfig]=pDLCData->wsProductId; - break; - } + switch (eType) { + case e_DLC_MashupPacks: + case e_DLC_TexturePacks: + DLCTextures_PackID[iConfig] = pDLCData->wsProductId; + break; + } - if(pwchFirstSkin[0]!=0) DLCInfo_SkinName[pwchFirstSkin]=pDLCData->wsProductId; + if (pwchFirstSkin[0] != 0) + DLCInfo_SkinName[pwchFirstSkin] = pDLCData->wsProductId; - #ifdef _XBOX_ONE - // ignore the names, and use the product id instead - DLCInfo_Full[pDLCData->wsProductId]=pDLCData; - #else - DLCInfo_Full[pDLCData->wsDisplayName]=pDLCData; - #endif - } - app.DebugPrintf("DLCInfo - type - %d, productID - %ls, name - %ls , banner - %ls, iconfig - %d, sort index - %d\n",eType,pwchProductId, pwchProductName,pwchBannerName, iConfig, uiSortIndex); - return hr; +#ifdef _XBOX_ONE + // ignore the names, and use the product id instead + DLCInfo_Full[pDLCData->wsProductId] = pDLCData; +#else + DLCInfo_Full[pDLCData->wsDisplayName] = pDLCData; +#endif + } + app.DebugPrintf( + "DLCInfo - type - %d, productID - %ls, name - %ls , banner - %ls, " + "iconfig - %d, sort index - %d\n", + eType, pwchProductId, pwchProductName, pwchBannerName, iConfig, + uiSortIndex); + return hr; } #elif defined(__linux__) -HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGender, __uint64 ullOfferID_Full, __uint64 ullOfferID_Trial, WCHAR *pFirstSkin, unsigned int uiSortIndex, int iConfig, WCHAR *pDataFile) -{ - fprintf(stderr, "warning: CMinecraftApp::RegisterDLCData unimplemented for platform `__linux__`\n"); - return S_OK; +HRESULT CMinecraftApp::RegisterDLCData(WCHAR* pType, WCHAR* pBannerName, + int iGender, __uint64 ullOfferID_Full, + __uint64 ullOfferID_Trial, + WCHAR* pFirstSkin, + unsigned int uiSortIndex, int iConfig, + WCHAR* pDataFile) { + fprintf(stderr, + "warning: CMinecraftApp::RegisterDLCData unimplemented for " + "platform `__linux__`\n"); + return S_OK; } #else -HRESULT CMinecraftApp::RegisterDLCData(char *pchDLCName, unsigned int uiSortIndex,char *pchImageURL) -{ - // on PS3 we get all the required info from the name - char chDLCType[3]; - HRESULT hr=0; - DLC_INFO *pDLCData=new DLC_INFO; - ZeroMemory(pDLCData,sizeof(DLC_INFO)); +HRESULT CMinecraftApp::RegisterDLCData(char* pchDLCName, + unsigned int uiSortIndex, + char* pchImageURL) { + // on PS3 we get all the required info from the name + char chDLCType[3]; + HRESULT hr = 0; + DLC_INFO* pDLCData = new DLC_INFO; + ZeroMemory(pDLCData, sizeof(DLC_INFO)); - chDLCType[0]=pchDLCName[0]; - chDLCType[1]=pchDLCName[1]; - chDLCType[2]=0; + chDLCType[0] = pchDLCName[0]; + chDLCType[1] = pchDLCName[1]; + chDLCType[2] = 0; - pDLCData->iConfig = app.GetiConfigFromName(pchDLCName); - pDLCData->uiSortIndex=uiSortIndex; - pDLCData->eDLCType = app.GetDLCTypeFromName(pchDLCName); - strcpy(pDLCData->chImageURL,pchImageURL); - //bool bIsTrialDLC = app.GetTrialFromName(pchDLCName); + pDLCData->iConfig = app.GetiConfigFromName(pchDLCName); + pDLCData->uiSortIndex = uiSortIndex; + pDLCData->eDLCType = app.GetDLCTypeFromName(pchDLCName); + strcpy(pDLCData->chImageURL, pchImageURL); + // bool bIsTrialDLC = app.GetTrialFromName(pchDLCName); - switch(pDLCData->eDLCType) - { - case e_DLC_TexturePacks: - { - char *pchName=(char *)malloc(strlen(pchDLCName)+1); - strcpy(pchName,pchDLCName); - DLCTextures_PackID[pDLCData->iConfig]=pchName; - } - break; - case e_DLC_MashupPacks: - { - char *pchName=(char *)malloc(strlen(pchDLCName)+1); - strcpy(pchName,pchDLCName); - DLCTextures_PackID[pDLCData->iConfig]=pchName; - } - break; - default: - break; - } + switch (pDLCData->eDLCType) { + case e_DLC_TexturePacks: { + char* pchName = (char*)malloc(strlen(pchDLCName) + 1); + strcpy(pchName, pchDLCName); + DLCTextures_PackID[pDLCData->iConfig] = pchName; + } break; + case e_DLC_MashupPacks: { + char* pchName = (char*)malloc(strlen(pchDLCName) + 1); + strcpy(pchName, pchDLCName); + DLCTextures_PackID[pDLCData->iConfig] = pchName; + } break; + default: + break; + } - app.DebugPrintf(5,"Adding DLC - %s\n",pchDLCName); - DLCInfo[pchDLCName]=pDLCData; + app.DebugPrintf(5, "Adding DLC - %s\n", pchDLCName); + DLCInfo[pchDLCName] = pDLCData; -// if(ullOfferID_Trial!=0ll) DLCInfo_Trial[ullOfferID_Trial]=pDLCData; -// if(ullOfferID_Full!=0ll) DLCInfo_Full[ullOfferID_Full]=pDLCData; -// if(pFirstSkin[0]!=0) DLCInfo_SkinName[pFirstSkin]=ullOfferID_Full; + // if(ullOfferID_Trial!=0ll) DLCInfo_Trial[ullOfferID_Trial]=pDLCData; + // if(ullOfferID_Full!=0ll) DLCInfo_Full[ullOfferID_Full]=pDLCData; + // if(pFirstSkin[0]!=0) DLCInfo_SkinName[pFirstSkin]=ullOfferID_Full; -// DLCInfo[ullOfferID_Trial]=pDLCData; + // DLCInfo[ullOfferID_Trial]=pDLCData; - return hr; + return hr; } #endif - - -#if defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__) -bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,ULONGLONG *pullVal) -{ - AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin)); - if( it == DLCInfo_SkinName.end() ) - { - return false; - } - else - { - *pullVal=(ULONGLONG)it->second; - return true; - } +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) +bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, + ULONGLONG* pullVal) { + AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin)); + if (it == DLCInfo_SkinName.end()) { + return false; + } else { + *pullVal = (ULONGLONG)it->second; + return true; + } } -bool CMinecraftApp::GetDLCNameForPackID(const int iPackID,char **ppchKeyID) -{ - AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); - if( it == DLCTextures_PackID.end() ) - { - *ppchKeyID=NULL; - return false; - } - else - { - *ppchKeyID=(char *)it->second; - return true; - } +bool CMinecraftApp::GetDLCNameForPackID(const int iPackID, char** ppchKeyID) { + AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); + if (it == DLCTextures_PackID.end()) { + *ppchKeyID = NULL; + return false; + } else { + *ppchKeyID = (char*)it->second; + return true; + } } -DLC_INFO *CMinecraftApp::GetDLCInfo(char *pchDLCName) -{ - std::string tempString=pchDLCName; +DLC_INFO* CMinecraftApp::GetDLCInfo(char* pchDLCName) { + std::string tempString = pchDLCName; - if(DLCInfo.size()>0) - { - AUTO_VAR(it, DLCInfo.find(tempString)); + if (DLCInfo.size() > 0) { + AUTO_VAR(it, DLCInfo.find(tempString)); - if( it == DLCInfo.end() ) - { - // nothing for this - return NULL; - } - else - { - return it->second; - } - } - else return NULL; + if (it == DLCInfo.end()) { + // nothing for this + return NULL; + } else { + return it->second; + } + } else + return NULL; } -DLC_INFO *CMinecraftApp::GetDLCInfoFromTPackID(int iTPID) -{ - std::unordered_map::iterator it= DLCInfo.begin(); +DLC_INFO* CMinecraftApp::GetDLCInfoFromTPackID(int iTPID) { + std::unordered_map::iterator it = DLCInfo.begin(); - for(int i=0;isecond)->iConfig==iTPID) - { - return it->second; - } - ++it; - } - return NULL; + for (int i = 0; i < DLCInfo.size(); i++) { + if (((DLC_INFO*)it->second)->iConfig == iTPID) { + return it->second; + } + ++it; + } + return NULL; } -DLC_INFO *CMinecraftApp::GetDLCInfo(int iIndex) -{ - std::unordered_map::iterator it= DLCInfo.begin(); +DLC_INFO* CMinecraftApp::GetDLCInfo(int iIndex) { + std::unordered_map::iterator it = DLCInfo.begin(); - for(int i=0;isecond; + return it->second; } -char *CMinecraftApp::GetDLCInfoTextures(int iIndex) -{ - std::unordered_map::iterator it= DLCTextures_PackID.begin(); +char* CMinecraftApp::GetDLCInfoTextures(int iIndex) { + std::unordered_map::iterator it = DLCTextures_PackID.begin(); - for(int i=0;isecond; + return it->second; } #elif defined _XBOX_ONE -bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,std::wstring &ProductId) -{ - AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin)); - if( it == DLCInfo_SkinName.end() ) - { - return false; - } - else - { - ProductId=it->second; - return true; - } +bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, + std::wstring& ProductId) { + AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin)); + if (it == DLCInfo_SkinName.end()) { + return false; + } else { + ProductId = it->second; + return true; + } } -bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,std::wstring &ProductId) -{ - AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); - if( it == DLCTextures_PackID.end() ) - { - return false; - } - else - { - ProductId=it->second; - return true; - } +bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID, + std::wstring& ProductId) { + AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); + if (it == DLCTextures_PackID.end()) { + return false; + } else { + ProductId = it->second; + return true; + } } // DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(std::wstring &ProductId) // { // return NULL; // } -DLC_INFO *CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) -{ - return NULL; +DLC_INFO* CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) { return NULL; } +DLC_INFO* CMinecraftApp::GetDLCInfoFullOffer(int iIndex) { + std::unordered_map::iterator it = + DLCInfo_Full.begin(); + + for (int i = 0; i < iIndex; i++) { + ++it; + } + + return it->second; } -DLC_INFO *CMinecraftApp::GetDLCInfoFullOffer(int iIndex) -{ - std::unordered_map::iterator it= DLCInfo_Full.begin(); +std::wstring CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) { + std::unordered_map::iterator it = + DLCTextures_PackID.begin(); - for(int i=0;isecond; -} -std::wstring CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) -{ - std::unordered_map::iterator it= DLCTextures_PackID.begin(); - - for(int i=0;isecond; + return it->second; } #else -bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,ULONGLONG *pullVal) -{ - AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin)); - if( it == DLCInfo_SkinName.end() ) - { - return false; - } - else - { - *pullVal=(ULONGLONG)it->second; - return true; - } +bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, + ULONGLONG* pullVal) { + AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin)); + if (it == DLCInfo_SkinName.end()) { + return false; + } else { + *pullVal = (ULONGLONG)it->second; + return true; + } } -bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,ULONGLONG *pullVal) -{ - AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); - if( it == DLCTextures_PackID.end() ) - { - *pullVal=(ULONGLONG)0; - return false; - } - else - { - *pullVal=(ULONGLONG)it->second; - return true; - } +bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID, + ULONGLONG* pullVal) { + AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); + if (it == DLCTextures_PackID.end()) { + *pullVal = (ULONGLONG)0; + return false; + } else { + *pullVal = (ULONGLONG)it->second; + return true; + } } -DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) -{ - //DLC_INFO *pDLCInfo=NULL; - if(DLCInfo_Trial.size()>0) - { - AUTO_VAR(it, DLCInfo_Trial.find(ullOfferID_Trial)); +DLC_INFO* CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) { + // DLC_INFO *pDLCInfo=NULL; + if (DLCInfo_Trial.size() > 0) { + AUTO_VAR(it, DLCInfo_Trial.find(ullOfferID_Trial)); - if( it == DLCInfo_Trial.end() ) - { - // nothing for this - return NULL; - } - else - { - return it->second; - } - } - else return NULL; + if (it == DLCInfo_Trial.end()) { + // nothing for this + return NULL; + } else { + return it->second; + } + } else + return NULL; } -DLC_INFO *CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) -{ - std::unordered_map::iterator it= DLCInfo_Trial.begin(); +DLC_INFO* CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) { + std::unordered_map::iterator it = + DLCInfo_Trial.begin(); - for(int i=0;isecond; + return it->second; } -DLC_INFO *CMinecraftApp::GetDLCInfoFullOffer(int iIndex) -{ - std::unordered_map::iterator it= DLCInfo_Full.begin(); +DLC_INFO* CMinecraftApp::GetDLCInfoFullOffer(int iIndex) { + std::unordered_map::iterator it = + DLCInfo_Full.begin(); - for(int i=0;isecond; + return it->second; } -ULONGLONG CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) -{ - std::unordered_map::iterator it= DLCTextures_PackID.begin(); +ULONGLONG CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) { + std::unordered_map::iterator it = + DLCTextures_PackID.begin(); - for(int i=0;isecond; + return it->second; } #endif #ifdef _XBOX_ONE -DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(WCHAR *pwchProductID) -{ - std::wstring wsTemp = pwchProductID; - if(DLCInfo_Full.size()>0) - { - AUTO_VAR(it, DLCInfo_Full.find(wsTemp)); +DLC_INFO* CMinecraftApp::GetDLCInfoForFullOfferID(WCHAR* pwchProductID) { + std::wstring wsTemp = pwchProductID; + if (DLCInfo_Full.size() > 0) { + AUTO_VAR(it, DLCInfo_Full.find(wsTemp)); - if( it == DLCInfo_Full.end() ) - { - // nothing for this - return NULL; - } - else - { - return it->second; - } - } - else return NULL; + if (it == DLCInfo_Full.end()) { + // nothing for this + return NULL; + } else { + return it->second; + } + } else + return NULL; } -DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) -{ - std::unordered_map::iterator it= DLCInfo_Full.begin(); - std::wstring wsProductName=pwchProductName; +DLC_INFO* CMinecraftApp::GetDLCInfoForProductName(WCHAR* pwchProductName) { + std::unordered_map::iterator it = + DLCInfo_Full.begin(); + std::wstring wsProductName = pwchProductName; - for(int i=0;isecond; - if(wsProductName==pDLCInfo->wsDisplayName) - { - return pDLCInfo; - } - ++it; - } - - return NULL; + for (int i = 0; i < DLCInfo_Full.size(); i++) { + DLC_INFO* pDLCInfo = (DLC_INFO*)it->second; + if (wsProductName == pDLCInfo->wsDisplayName) { + return pDLCInfo; + } + ++it; + } + + return NULL; } -#elif defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) +#elif defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) #else -DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full) -{ +DLC_INFO* CMinecraftApp::GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full) { + if (DLCInfo_Full.size() > 0) { + AUTO_VAR(it, DLCInfo_Full.find(ullOfferID_Full)); - if(DLCInfo_Full.size()>0) - { - AUTO_VAR(it, DLCInfo_Full.find(ullOfferID_Full)); - - if( it == DLCInfo_Full.end() ) - { - // nothing for this - return NULL; - } - else - { - return it->second; - } - } - else return NULL; + if (it == DLCInfo_Full.end()) { + // nothing for this + return NULL; + } else { + return it->second; + } + } else + return NULL; } #endif -void CMinecraftApp::EnterSaveNotificationSection() -{ - EnterCriticalSection(&m_saveNotificationCriticalSection); - if( m_saveNotificationDepth++ == 0 ) - { - MinecraftServer::getInstance()->broadcastStartSavingPacket(); +void CMinecraftApp::EnterSaveNotificationSection() { + EnterCriticalSection(&m_saveNotificationCriticalSection); + if (m_saveNotificationDepth++ == 0) { + MinecraftServer::getInstance()->broadcastStartSavingPacket(); - if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 ) - { - app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_PauseServer,(void *)TRUE); - } - } - LeaveCriticalSection(&m_saveNotificationCriticalSection); + if (g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1) { + app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), + eXuiServerAction_PauseServer, (void*)TRUE); + } + } + LeaveCriticalSection(&m_saveNotificationCriticalSection); } -void CMinecraftApp::LeaveSaveNotificationSection() -{ - EnterCriticalSection(&m_saveNotificationCriticalSection); - if( --m_saveNotificationDepth == 0 ) - { - MinecraftServer::getInstance()->broadcastStopSavingPacket(); +void CMinecraftApp::LeaveSaveNotificationSection() { + EnterCriticalSection(&m_saveNotificationCriticalSection); + if (--m_saveNotificationDepth == 0) { + MinecraftServer::getInstance()->broadcastStopSavingPacket(); - if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 ) - { - app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_PauseServer,(void *)FALSE); - } - } - LeaveCriticalSection(&m_saveNotificationCriticalSection); + if (g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1) { + app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), + eXuiServerAction_PauseServer, (void*)FALSE); + } + } + LeaveCriticalSection(&m_saveNotificationCriticalSection); } +int CMinecraftApp::RemoteSaveThreadProc(void* lpParameter) { + // The game should be stopped while we are doing this, but the connections + // ticks may try to create some AABB's or Vec3's + AABB::UseDefaultThreadStorage(); + Vec3::UseDefaultThreadStorage(); + Compression::UseDefaultThreadStorage(); -int CMinecraftApp::RemoteSaveThreadProc( void* lpParameter ) -{ - // The game should be stopped while we are doing this, but the connections ticks may try to create some AABB's or Vec3's - AABB::UseDefaultThreadStorage(); - Vec3::UseDefaultThreadStorage(); - Compression::UseDefaultThreadStorage(); + // 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the + // Autosave in an online Multiplayer session, the game occasionally crashes + // for one or more Clients callstack - > if(tls->tileId != this->id) + // updateDefaultShape(); callstack - > + // default.exe!WaterlilyTile::getAABB(Level * level, int x, int y, int z) + // line 38 + 8 bytes C++ + // ... + // default.exe!CMinecraftApp::RemoteSaveThreadProc(void * + // lpParameter) line 6694 C++ + // host autosave, and the clients can crash on receiving handleMoveEntity + // when it's a tile within this thread, so need to do the tls for tiles + Tile::CreateNewThreadStorage(); - // 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the Autosave in an online Multiplayer session, the game occasionally crashes for one or more Clients - // callstack - > if(tls->tileId != this->id) updateDefaultShape(); - // callstack - > default.exe!WaterlilyTile::getAABB(Level * level, int x, int y, int z) line 38 + 8 bytes C++ - // ... - // default.exe!CMinecraftApp::RemoteSaveThreadProc(void * lpParameter) line 6694 C++ - // host autosave, and the clients can crash on receiving handleMoveEntity when it's a tile within this thread, so need to do the tls for tiles - Tile::CreateNewThreadStorage(); + Minecraft* pMinecraft = Minecraft::GetInstance(); - Minecraft *pMinecraft = Minecraft::GetInstance(); + pMinecraft->progressRenderer->progressStartNoAbort( + IDS_PROGRESS_HOST_SAVING); + pMinecraft->progressRenderer->progressStage(-1); + pMinecraft->progressRenderer->progressStagePercentage(0); - pMinecraft->progressRenderer->progressStartNoAbort( IDS_PROGRESS_HOST_SAVING ); - pMinecraft->progressRenderer->progressStage( -1 ); - pMinecraft->progressRenderer->progressStagePercentage(0); + while (!app.GetGameStarted() && + app.GetXuiAction(ProfileManager.GetPrimaryPad()) == + eAppAction_WaitRemoteServerSaveComplete) { + // Tick all the games connections + pMinecraft->tickAllConnections(); + Sleep(100); + } - while( !app.GetGameStarted() && app.GetXuiAction( ProfileManager.GetPrimaryPad() ) == eAppAction_WaitRemoteServerSaveComplete ) - { - // Tick all the games connections - pMinecraft->tickAllConnections(); - Sleep( 100 ); - } + if (app.GetXuiAction(ProfileManager.GetPrimaryPad()) != + eAppAction_WaitRemoteServerSaveComplete) { + // Something cancelled us? + return ERROR_CANCELLED; + } + app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_Idle); - if( app.GetXuiAction( ProfileManager.GetPrimaryPad() ) != eAppAction_WaitRemoteServerSaveComplete ) - { - // Something cancelled us? - return ERROR_CANCELLED; - } - app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_Idle); + ui.UpdatePlayerBasePositions(); - ui.UpdatePlayerBasePositions(); + Tile::ReleaseThreadStorage(); - Tile::ReleaseThreadStorage(); - - return 0; + return 0; } -void CMinecraftApp::ExitGameFromRemoteSave( void *lpParameter ) -{ - int primaryPad = ProfileManager.GetPrimaryPad(); - - unsigned int uiIDA[3]; - uiIDA[0]=IDS_CONFIRM_CANCEL; - uiIDA[1]=IDS_CONFIRM_OK; +void CMinecraftApp::ExitGameFromRemoteSave(void* lpParameter) { + int primaryPad = ProfileManager.GetPrimaryPad(); - ui.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,&CMinecraftApp::ExitGameFromRemoteSaveDialogReturned,NULL, app.GetStringTable(), 0, 0, false); + unsigned int uiIDA[3]; + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_CONFIRM_OK; + + ui.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, + primaryPad, + &CMinecraftApp::ExitGameFromRemoteSaveDialogReturned, + NULL, app.GetStringTable(), 0, 0, false); } -int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - //CScene_Pause* pClass = (CScene_Pause*)pParam; +int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { + // CScene_Pause* pClass = (CScene_Pause*)pParam; - // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) - { - app.SetAction(iPad,eAppAction_ExitWorld); - } - else - { + // results switched for this dialog + if (result == C4JStorage::EMessage_ResultDecline) { + app.SetAction(iPad, eAppAction_ExitWorld); + } else { #ifndef _XBOX - // Inform fullscreen progress scene that it's not being cancelled after all - UIScene_FullscreenProgress *pScene = (UIScene_FullscreenProgress *)ui.FindScene(eUIScene_FullscreenProgress); + // Inform fullscreen progress scene that it's not being cancelled after + // all + UIScene_FullscreenProgress* pScene = + (UIScene_FullscreenProgress*)ui.FindScene( + eUIScene_FullscreenProgress); #ifdef __PS3__ - if(pScene!=NULL) + if (pScene != NULL) #else - if (pScene != nullptr) + if (pScene != nullptr) #endif - { - pScene->SetWasCancelled(false); - } + { + pScene->SetWasCancelled(false); + } #else - // Don't have to worry about this on Xbox + // Don't have to worry about this on Xbox #endif - } - return 0; + } + return 0; } -void CMinecraftApp::SetSpecialTutorialCompletionFlag(int iPad, int index) -{ - if(index >= 0 && index < 32 && GameSettingsA[iPad] != NULL) - { - GameSettingsA[iPad]->uiSpecialTutorialBitmask |= (1<= 0 && index < 32 && GameSettingsA[iPad] != NULL) { + GameSettingsA[iPad]->uiSpecialTutorialBitmask |= (1 << index); + } } // BANNED LIST FUNCTIONS -void CMinecraftApp::SetUniqueMapName(char *pszUniqueMapName) -{ - memcpy(m_pszUniqueMapName,pszUniqueMapName,14); +void CMinecraftApp::SetUniqueMapName(char* pszUniqueMapName) { + memcpy(m_pszUniqueMapName, pszUniqueMapName, 14); } -char *CMinecraftApp::GetUniqueMapName(void) -{ - return m_pszUniqueMapName; -} +char* CMinecraftApp::GetUniqueMapName(void) { return m_pszUniqueMapName; } -void CMinecraftApp::InvalidateBannedList(int iPad) -{ - if(m_bRead_BannedListA[iPad]==true) - { - m_bRead_BannedListA[iPad]=false; - SetBanListCheck(iPad,false); - m_vBannedListA[iPad]->clear(); +void CMinecraftApp::InvalidateBannedList(int iPad) { + if (m_bRead_BannedListA[iPad] == true) { + m_bRead_BannedListA[iPad] = false; + SetBanListCheck(iPad, false); + m_vBannedListA[iPad]->clear(); - if(BannedListA[iPad].pBannedList) - { - delete [] BannedListA[iPad].pBannedList; - BannedListA[iPad].pBannedList=NULL; - } - } + if (BannedListA[iPad].pBannedList) { + delete[] BannedListA[iPad].pBannedList; + BannedListA[iPad].pBannedList = NULL; + } + } } #ifdef _XBOX_ONE -void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PBANNEDLISTDATA pBannedListData, bool bWriteToTMS) -{ - PlayerUID xuid= pBannedListData->wchPlayerUID; +void CMinecraftApp::AddLevelToBannedLevelList(int iPad, + PBANNEDLISTDATA pBannedListData, + bool bWriteToTMS) { + PlayerUID xuid = pBannedListData->wchPlayerUID; - AddLevelToBannedLevelList(iPad,xuid,pBannedListData->pszLevelName,bWriteToTMS); + AddLevelToBannedLevelList(iPad, xuid, pBannedListData->pszLevelName, + bWriteToTMS); } #endif -void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName, bool bWriteToTMS) -{ - // we will have retrieved the banned level list from TMS, so add this one to it and write it back to TMS +void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, + char* pszLevelName, + bool bWriteToTMS) { + // we will have retrieved the banned level list from TMS, so add this one to + // it and write it back to TMS - BANNEDLISTDATA *pBannedListData = new BANNEDLISTDATA; - memset(pBannedListData,0,sizeof(BANNEDLISTDATA)); + BANNEDLISTDATA* pBannedListData = new BANNEDLISTDATA; + memset(pBannedListData, 0, sizeof(BANNEDLISTDATA)); #ifdef _DURANGO - memcpy(&pBannedListData->wchPlayerUID, xuid.toString().c_str(), sizeof(WCHAR)*64); + memcpy(&pBannedListData->wchPlayerUID, xuid.toString().c_str(), + sizeof(WCHAR) * 64); #else - memcpy(&pBannedListData->xuid, &xuid, sizeof(PlayerUID)); + memcpy(&pBannedListData->xuid, &xuid, sizeof(PlayerUID)); #endif - strcpy(pBannedListData->pszLevelName,pszLevelName); - m_vBannedListA[iPad]->push_back(pBannedListData); + strcpy(pBannedListData->pszLevelName, pszLevelName); + m_vBannedListA[iPad]->push_back(pBannedListData); - if(bWriteToTMS) - { - const std::size_t bannedListCount = m_vBannedListA[iPad]->size(); - const unsigned int dataBytes = static_cast(sizeof(BANNEDLISTDATA) * bannedListCount); - PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount]; - int iCount=0; - for(AUTO_VAR(it, m_vBannedListA[iPad]->begin()); it != m_vBannedListA[iPad]->end(); ++it) - { - PBANNEDLISTDATA pData=*it; - memcpy(&pBannedList[iCount++],pData,sizeof(BANNEDLISTDATA)); - } + if (bWriteToTMS) { + const std::size_t bannedListCount = m_vBannedListA[iPad]->size(); + const unsigned int dataBytes = + static_cast(sizeof(BANNEDLISTDATA) * bannedListCount); + PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount]; + int iCount = 0; + for (AUTO_VAR(it, m_vBannedListA[iPad]->begin()); + it != m_vBannedListA[iPad]->end(); ++it) { + PBANNEDLISTDATA pData = *it; + memcpy(&pBannedList[iCount++], pData, sizeof(BANNEDLISTDATA)); + } - // 4J-PB - write to TMS++ now + // 4J-PB - write to TMS++ now - //bool bRes=StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dataBytes); + // bool + // bRes=StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, + // dataBytes); #ifdef _XBOX - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,C4JStorage::TMS_UGCTYPE_NONE,"BannedList",(PCHAR) pBannedList, dataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile( + iPad, C4JStorage::eGlobalStorage_TitleUser, + C4JStorage::TMS_FILETYPE_BINARY, C4JStorage::TMS_UGCTYPE_NONE, + "BannedList", (PCHAR)pBannedList, dataBytes, NULL, NULL, 0); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile( + iPad, C4JStorage::eGlobalStorage_TitleUser, + C4JStorage::TMS_FILETYPE_BINARY, L"BannedList", (PBYTE)pBannedList, + dataBytes, NULL, NULL, 0); #endif - delete[] pBannedList; - } - // update telemetry too + delete[] pBannedList; + } + // update telemetry too } -bool CMinecraftApp::IsInBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName) -{ - for(AUTO_VAR(it, m_vBannedListA[iPad]->begin()); it != m_vBannedListA[iPad]->end(); ++it) - { - PBANNEDLISTDATA pData=*it; +bool CMinecraftApp::IsInBannedLevelList(int iPad, PlayerUID xuid, + char* pszLevelName) { + for (AUTO_VAR(it, m_vBannedListA[iPad]->begin()); + it != m_vBannedListA[iPad]->end(); ++it) { + PBANNEDLISTDATA pData = *it; #ifdef _XBOX_ONE - PlayerUID bannedPlayerUID = pData->wchPlayerUID; - if(IsEqualXUID (bannedPlayerUID,xuid) && (strcmp(pData->pszLevelName,pszLevelName)==0)) -#else - if(IsEqualXUID (pData->xuid,xuid) && (strcmp(pData->pszLevelName,pszLevelName)==0)) + PlayerUID bannedPlayerUID = pData->wchPlayerUID; + if (IsEqualXUID(bannedPlayerUID, xuid) && + (strcmp(pData->pszLevelName, pszLevelName) == 0)) +#else + if (IsEqualXUID(pData->xuid, xuid) && + (strcmp(pData->pszLevelName, pszLevelName) == 0)) #endif - { - return true; - } - } + { + return true; + } + } - return false; + return false; } -void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName) -{ - //bool bFound=false; - //bool bRes; - - // we will have retrieved the banned level list from TMS, so remove this one from it and write it back to TMS - for(AUTO_VAR(it, m_vBannedListA[iPad]->begin()); it != m_vBannedListA[iPad]->end(); ) - { - PBANNEDLISTDATA pBannedListData = *it; - - if(pBannedListData!=NULL) - { +void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, + char* pszLevelName) { + // bool bFound=false; + // bool bRes; + + // we will have retrieved the banned level list from TMS, so remove this one + // from it and write it back to TMS + for (AUTO_VAR(it, m_vBannedListA[iPad]->begin()); + it != m_vBannedListA[iPad]->end();) { + PBANNEDLISTDATA pBannedListData = *it; + + if (pBannedListData != NULL) { #ifdef _XBOX_ONE - PlayerUID bannedPlayerUID = pBannedListData->wchPlayerUID; - if(IsEqualXUID (bannedPlayerUID,xuid) && (strcmp(pBannedListData->pszLevelName,pszLevelName)==0)) + PlayerUID bannedPlayerUID = pBannedListData->wchPlayerUID; + if (IsEqualXUID(bannedPlayerUID, xuid) && + (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) #else - if(IsEqualXUID (pBannedListData->xuid,xuid) && (strcmp(pBannedListData->pszLevelName,pszLevelName)==0)) + if (IsEqualXUID(pBannedListData->xuid, xuid) && + (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) #endif - { - TelemetryManager->RecordUnBanLevel(iPad); + { + TelemetryManager->RecordUnBanLevel(iPad); - // match found, so remove this entry - it = m_vBannedListA[iPad]->erase(it); - } - else - { - ++it; - } - } - else - { - ++it; - } - } + // match found, so remove this entry + it = m_vBannedListA[iPad]->erase(it); + } else { + ++it; + } + } else { + ++it; + } + } - const std::size_t bannedListCount = m_vBannedListA[iPad]->size(); - const unsigned int dataBytes = static_cast(sizeof(BANNEDLISTDATA) * bannedListCount); - if(dataBytes==0) - { - // wipe the file + const std::size_t bannedListCount = m_vBannedListA[iPad]->size(); + const unsigned int dataBytes = + static_cast(sizeof(BANNEDLISTDATA) * bannedListCount); + if (dataBytes == 0) { + // wipe the file #ifdef _XBOX - StorageManager.DeleteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList"); + StorageManager.DeleteTMSFile(iPad, C4JStorage::eGlobalStorage_TitleUser, + L"BannedList"); #elif defined _XBOX_ONE - StorageManager.TMSPP_DeleteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",NULL,NULL, 0); + StorageManager.TMSPP_DeleteFile( + iPad, C4JStorage::eGlobalStorage_TitleUser, + C4JStorage::TMS_FILETYPE_BINARY, L"BannedList", NULL, NULL, 0); #endif - } - else - { - PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount]; + } else { + PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount]; - for(std::size_t i = 0; i < bannedListCount; ++i) - { - PBANNEDLISTDATA pBannedListData =m_vBannedListA[iPad]->at(i); + for (std::size_t i = 0; i < bannedListCount; ++i) { + PBANNEDLISTDATA pBannedListData = m_vBannedListA[iPad]->at(i); - memcpy(&pBannedList[i],pBannedListData,sizeof(BANNEDLISTDATA)); - } + memcpy(&pBannedList[i], pBannedListData, sizeof(BANNEDLISTDATA)); + } #ifdef _XBOX - StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dataBytes); + StorageManager.WriteTMSFile(iPad, C4JStorage::eGlobalStorage_TitleUser, + L"BannedList", (PBYTE)pBannedList, + dataBytes); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile( + iPad, C4JStorage::eGlobalStorage_TitleUser, + C4JStorage::TMS_FILETYPE_BINARY, L"BannedList", (PBYTE)pBannedList, + dataBytes, NULL, NULL, 0); #endif - delete [] pBannedList; - } + delete[] pBannedList; + } - // update telemetry too + // update telemetry too } // function to add credits for the DLC packs -void CMinecraftApp::AddCreditText(const wchar_t *lpStr) -{ - DebugPrintf("ADDING CREDIT - %ls\n",lpStr); - // add a string from the DLC to a credits vector - SCreditTextItemDef *pCreditStruct = new SCreditTextItemDef; - pCreditStruct->m_eType=eSmallText; - pCreditStruct->m_iStringID[0]=NO_TRANSLATED_STRING; - pCreditStruct->m_iStringID[1]=NO_TRANSLATED_STRING; - pCreditStruct->m_Text=new WCHAR [wcslen(lpStr)+1]; - wcscpy((WCHAR *)pCreditStruct->m_Text,lpStr); +void CMinecraftApp::AddCreditText(const wchar_t* lpStr) { + DebugPrintf("ADDING CREDIT - %ls\n", lpStr); + // add a string from the DLC to a credits vector + SCreditTextItemDef* pCreditStruct = new SCreditTextItemDef; + pCreditStruct->m_eType = eSmallText; + pCreditStruct->m_iStringID[0] = NO_TRANSLATED_STRING; + pCreditStruct->m_iStringID[1] = NO_TRANSLATED_STRING; + pCreditStruct->m_Text = new WCHAR[wcslen(lpStr) + 1]; + wcscpy((WCHAR*)pCreditStruct->m_Text, lpStr); - vDLCCredits.push_back(pCreditStruct); + vDLCCredits.push_back(pCreditStruct); } -bool CMinecraftApp::AlreadySeenCreditText(const std::wstring &wstemp) -{ +bool CMinecraftApp::AlreadySeenCreditText(const std::wstring& wstemp) { + for (unsigned int i = 0; i < m_vCreditText.size(); i++) { + std::wstring temp = m_vCreditText.at(i); - for(unsigned int i=0;i>4; - break; - case eGameHostOption_All: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_ALL); - break; - case eGameHostOption_Tutorial: - // special case - tutorial is offline, but we want the gamertag option, and set Easy mode, structures on, fire on, tnt on, pvp on, trust players on - return ((uiHostSettings&GAME_HOST_OPTION_BITMASK_GAMERTAGS)|GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS|GAME_HOST_OPTION_BITMASK_FIRESPREADS|GAME_HOST_OPTION_BITMASK_TNT|GAME_HOST_OPTION_BITMASK_PVP|GAME_HOST_OPTION_BITMASK_STRUCTURES|1); - break; - case eGameHostOption_LevelType: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_LEVELTYPE); - break; - case eGameHostOption_Structures: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_STRUCTURES); - break; - case eGameHostOption_BonusChest: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_BONUSCHEST); - break; - case eGameHostOption_HasBeenInCreative: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_BEENINCREATIVE); - break; - case eGameHostOption_PvP: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_PVP); - break; - case eGameHostOption_TrustPlayers: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS); - break; - case eGameHostOption_TNT: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_TNT); - break; - case eGameHostOption_FireSpreads: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_FIRESPREADS); - break; - case eGameHostOption_CheatsEnabled: - return (uiHostSettings&(GAME_HOST_OPTION_BITMASK_HOSTFLY|GAME_HOST_OPTION_BITMASK_HOSTHUNGER|GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE)); - break; - case eGameHostOption_HostCanFly: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_HOSTFLY); - break; - case eGameHostOption_HostCanChangeHunger: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_HOSTHUNGER); - break; - case eGameHostOption_HostCanBeInvisible: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE); - break; - case eGameHostOption_BedrockFog: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_BEDROCKFOG); - break; - case eGameHostOption_DisableSaving: - return (uiHostSettings&GAME_HOST_OPTION_BITMASK_DISABLESAVE); - break; - default: - return 0; - } +unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, + eGameHostOption eVal) { + // unsigned int uiVal=0; + switch (eVal) { + case eGameHostOption_FriendsOfFriends: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_FRIENDSOFFRIENDS); + break; + case eGameHostOption_Difficulty: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_DIFFICULTY); + break; + case eGameHostOption_Gamertags: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_GAMERTAGS); + break; + case eGameHostOption_GameType: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_GAMETYPE) >> 4; + break; + case eGameHostOption_All: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_ALL); + break; + case eGameHostOption_Tutorial: + // special case - tutorial is offline, but we want the gamertag + // option, and set Easy mode, structures on, fire on, tnt on, pvp + // on, trust players on + return ((uiHostSettings & GAME_HOST_OPTION_BITMASK_GAMERTAGS) | + GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS | + GAME_HOST_OPTION_BITMASK_FIRESPREADS | + GAME_HOST_OPTION_BITMASK_TNT | + GAME_HOST_OPTION_BITMASK_PVP | + GAME_HOST_OPTION_BITMASK_STRUCTURES | 1); + break; + case eGameHostOption_LevelType: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_LEVELTYPE); + break; + case eGameHostOption_Structures: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_STRUCTURES); + break; + case eGameHostOption_BonusChest: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_BONUSCHEST); + break; + case eGameHostOption_HasBeenInCreative: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_BEENINCREATIVE); + break; + case eGameHostOption_PvP: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_PVP); + break; + case eGameHostOption_TrustPlayers: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS); + break; + case eGameHostOption_TNT: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_TNT); + break; + case eGameHostOption_FireSpreads: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_FIRESPREADS); + break; + case eGameHostOption_CheatsEnabled: + return (uiHostSettings & (GAME_HOST_OPTION_BITMASK_HOSTFLY | + GAME_HOST_OPTION_BITMASK_HOSTHUNGER | + GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE)); + break; + case eGameHostOption_HostCanFly: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_HOSTFLY); + break; + case eGameHostOption_HostCanChangeHunger: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_HOSTHUNGER); + break; + case eGameHostOption_HostCanBeInvisible: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE); + break; + case eGameHostOption_BedrockFog: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_BEDROCKFOG); + break; + case eGameHostOption_DisableSaving: + return (uiHostSettings & GAME_HOST_OPTION_BITMASK_DISABLESAVE); + break; + default: + return 0; + } - return false; + return false; } -bool CMinecraftApp::CanRecordStatsAndAchievements() -{ - // 4J Stu - All of these options give the host player some advantage, so should not allow achievements - return !(app.GetGameHostOption(eGameHostOption_HasBeenInCreative) || - app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) || - app.GetGameHostOption(eGameHostOption_HostCanChangeHunger) || - app.GetGameHostOption(eGameHostOption_HostCanFly)); +bool CMinecraftApp::CanRecordStatsAndAchievements() { + // 4J Stu - All of these options give the host player some advantage, so + // should not allow achievements + return !(app.GetGameHostOption(eGameHostOption_HasBeenInCreative) || + app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) || + app.GetGameHostOption(eGameHostOption_HostCanChangeHunger) || + app.GetGameHostOption(eGameHostOption_HostCanFly)); } -void CMinecraftApp::processSchematics(LevelChunk *levelChunk) -{ - m_gameRules.processSchematics(levelChunk); +void CMinecraftApp::processSchematics(LevelChunk* levelChunk) { + m_gameRules.processSchematics(levelChunk); } -void CMinecraftApp::processSchematicsLighting(LevelChunk *levelChunk) -{ - m_gameRules.processSchematicsLighting(levelChunk); +void CMinecraftApp::processSchematicsLighting(LevelChunk* levelChunk) { + m_gameRules.processSchematicsLighting(levelChunk); } -void CMinecraftApp::loadDefaultGameRules() -{ - m_gameRules.loadDefaultGameRules(); +void CMinecraftApp::loadDefaultGameRules() { + m_gameRules.loadDefaultGameRules(); } -void CMinecraftApp::setLevelGenerationOptions(LevelGenerationOptions *levelGen) -{ - m_gameRules.setLevelGenerationOptions(levelGen); +void CMinecraftApp::setLevelGenerationOptions( + LevelGenerationOptions* levelGen) { + m_gameRules.setLevelGenerationOptions(levelGen); } -const wchar_t *CMinecraftApp::GetGameRulesString(const std::wstring &key) -{ - return m_gameRules.GetGameRulesString(key); +const wchar_t* CMinecraftApp::GetGameRulesString(const std::wstring& key) { + return m_gameRules.GetGameRulesString(key); } -unsigned char CMinecraftApp::m_szPNG[8]= -{ - 137,80,78,71,13,10,26,10 -}; +unsigned char CMinecraftApp::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10}; #define PNG_TAG_tEXt 0x74455874 -unsigned int CMinecraftApp::FromBigEndian(unsigned int uiValue) -{ +unsigned int CMinecraftApp::FromBigEndian(unsigned int uiValue) { #if defined(__PS3__) || defined(_XBOX) - // Keep it in big endian - return uiValue; + // Keep it in big endian + return uiValue; #else - unsigned int uiReturn = ( ( uiValue >> 24 ) & 0x000000ff ) | - ( ( uiValue >> 8 ) & 0x0000ff00 ) | - ( ( uiValue << 8 ) & 0x00ff0000 ) | - ( ( uiValue << 24 ) & 0xff000000 ); - return uiReturn; + unsigned int uiReturn = + ((uiValue >> 24) & 0x000000ff) | ((uiValue >> 8) & 0x0000ff00) | + ((uiValue << 8) & 0x00ff0000) | ((uiValue << 24) & 0xff000000); + return uiReturn; #endif } -void CMinecraftApp::GetImageTextData(std::uint8_t *imageData, unsigned int imageBytes, unsigned char *seedText, unsigned int &uiHostOptions, bool &bHostOptionsRead, std::uint32_t &uiTexturePack) -{ - auto readPngUInt32 = [](const std::uint8_t *data) -> unsigned int - { - unsigned int value = 0; - std::memcpy(&value, data, sizeof(value)); - return value; - }; +void CMinecraftApp::GetImageTextData(std::uint8_t* imageData, + unsigned int imageBytes, + unsigned char* seedText, + unsigned int& uiHostOptions, + bool& bHostOptionsRead, + std::uint32_t& uiTexturePack) { + auto readPngUInt32 = [](const std::uint8_t* data) -> unsigned int { + unsigned int value = 0; + std::memcpy(&value, data, sizeof(value)); + return value; + }; - std::uint8_t *ucPtr = imageData; - unsigned int uiCount=0; - unsigned int uiChunkLen; - unsigned int uiChunkType; - unsigned int uiCRC; - char szKeyword[80]; + std::uint8_t* ucPtr = imageData; + unsigned int uiCount = 0; + unsigned int uiChunkLen; + unsigned int uiChunkType; + unsigned int uiCRC; + char szKeyword[80]; - // check it's a png - for(int i=0;i<8;i++) - { - if(m_szPNG[i]!=ucPtr[i]) return; - } + // check it's a png + for (int i = 0; i < 8; i++) { + if (m_szPNG[i] != ucPtr[i]) return; + } - uiCount+=8; + uiCount += 8; - while(uiCount < imageBytes) - { - uiChunkLen = FromBigEndian(readPngUInt32(&ucPtr[uiCount])); - uiCount+=sizeof(int); - uiChunkType = FromBigEndian(readPngUInt32(&ucPtr[uiCount])); - uiCount+=sizeof(int); + while (uiCount < imageBytes) { + uiChunkLen = FromBigEndian(readPngUInt32(&ucPtr[uiCount])); + uiCount += sizeof(int); + uiChunkType = FromBigEndian(readPngUInt32(&ucPtr[uiCount])); + uiCount += sizeof(int); - if(uiChunkType==PNG_TAG_tEXt) // tEXt - { - // check that it's the 4J text - unsigned char *pszKeyword=&ucPtr[uiCount]; - while(pszKeyword < ucPtr + uiCount + uiChunkLen) - { - ZeroMemory(szKeyword,80); - unsigned int uiKeywordC=0; - while(*pszKeyword!=0) - { - szKeyword[uiKeywordC++]=*pszKeyword; - pszKeyword++; - } - pszKeyword++; - if(strcmp(szKeyword,"4J_SEED")==0) - { - // read the seed value - unsigned int uiValueC=0; - while(*pszKeyword!=0 && (pszKeyword < ucPtr + uiCount + uiChunkLen) ) - { - seedText[uiValueC++]=*pszKeyword; - pszKeyword++; - } - //memcpy(seedText,pszKeyword,uiChunkLen-8); - } - else if(strcmp(szKeyword,"4J_HOSTOPTIONS")==0) - { - bHostOptionsRead = true; - // read the host options value - unsigned int uiValueC=0; - unsigned char pszHostOptions[8]; // Hex representation of unsigned int - ZeroMemory(&pszHostOptions,8); - while(*pszKeyword!=0 && (pszKeyword < ucPtr + uiCount + uiChunkLen) && uiValueC < 8) - { - pszHostOptions[uiValueC++]=*pszKeyword; - pszKeyword++; - } + if (uiChunkType == PNG_TAG_tEXt) // tEXt + { + // check that it's the 4J text + unsigned char* pszKeyword = &ucPtr[uiCount]; + while (pszKeyword < ucPtr + uiCount + uiChunkLen) { + ZeroMemory(szKeyword, 80); + unsigned int uiKeywordC = 0; + while (*pszKeyword != 0) { + szKeyword[uiKeywordC++] = *pszKeyword; + pszKeyword++; + } + pszKeyword++; + if (strcmp(szKeyword, "4J_SEED") == 0) { + // read the seed value + unsigned int uiValueC = 0; + while (*pszKeyword != 0 && + (pszKeyword < ucPtr + uiCount + uiChunkLen)) { + seedText[uiValueC++] = *pszKeyword; + pszKeyword++; + } + // memcpy(seedText,pszKeyword,uiChunkLen-8); + } else if (strcmp(szKeyword, "4J_HOSTOPTIONS") == 0) { + bHostOptionsRead = true; + // read the host options value + unsigned int uiValueC = 0; + unsigned char pszHostOptions[8]; // Hex representation of + // unsigned int + ZeroMemory(&pszHostOptions, 8); + while (*pszKeyword != 0 && + (pszKeyword < ucPtr + uiCount + uiChunkLen) && + uiValueC < 8) { + pszHostOptions[uiValueC++] = *pszKeyword; + pszKeyword++; + } - uiHostOptions = 0; - std::stringstream ss; - ss << pszHostOptions; - ss >> std::hex >> uiHostOptions; - } - else if(strcmp(szKeyword,"4J_TEXTUREPACK")==0) - { - // read the texture pack value - unsigned int uiValueC=0; - unsigned char pszTexturePack[8]; // Hex representation of unsigned int - ZeroMemory(&pszTexturePack,8); - while(*pszKeyword!=0 && (pszKeyword < ucPtr + uiCount + uiChunkLen) && uiValueC < 8) - { - pszTexturePack[uiValueC++]=*pszKeyword; - pszKeyword++; - } + uiHostOptions = 0; + std::stringstream ss; + ss << pszHostOptions; + ss >> std::hex >> uiHostOptions; + } else if (strcmp(szKeyword, "4J_TEXTUREPACK") == 0) { + // read the texture pack value + unsigned int uiValueC = 0; + unsigned char pszTexturePack[8]; // Hex representation of + // unsigned int + ZeroMemory(&pszTexturePack, 8); + while (*pszKeyword != 0 && + (pszKeyword < ucPtr + uiCount + uiChunkLen) && + uiValueC < 8) { + pszTexturePack[uiValueC++] = *pszKeyword; + pszKeyword++; + } - std::stringstream ss; - ss << pszTexturePack; - ss >> std::hex >> uiTexturePack; - } - } - } - uiCount+=uiChunkLen; - uiCRC = FromBigEndian(readPngUInt32(&ucPtr[uiCount])); - uiCount+=sizeof(int); - } + std::stringstream ss; + ss << pszTexturePack; + ss >> std::hex >> uiTexturePack; + } + } + } + uiCount += uiChunkLen; + uiCRC = FromBigEndian(readPngUInt32(&ucPtr[uiCount])); + uiCount += sizeof(int); + } - return; + return; } -unsigned int CMinecraftApp::CreateImageTextData(std::uint8_t *textMetadata, __int64 seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId) -{ - int iTextMetadataBytes = 0; - if(hasSeed) - { - strcpy((char *)textMetadata,"4J_SEED"); - snprintf((char *)&textMetadata[8], 42, "%lld", (long long)seed); +unsigned int CMinecraftApp::CreateImageTextData(std::uint8_t* textMetadata, + __int64 seed, bool hasSeed, + unsigned int uiHostOptions, + unsigned int uiTexturePackId) { + int iTextMetadataBytes = 0; + if (hasSeed) { + strcpy((char*)textMetadata, "4J_SEED"); + snprintf((char*)&textMetadata[8], 42, "%lld", (long long)seed); - // get the length - iTextMetadataBytes+=8; - while(textMetadata[iTextMetadataBytes]!=0) iTextMetadataBytes++; - ++iTextMetadataBytes; // Add a null terminator at the end of the seed value - } + // get the length + iTextMetadataBytes += 8; + while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++; + ++iTextMetadataBytes; // Add a null terminator at the end of the seed + // value + } - // Save the host options that this world was last played with - strcpy((char *)&textMetadata[iTextMetadataBytes],"4J_HOSTOPTIONS"); - snprintf( (char *)&textMetadata[iTextMetadataBytes + 15], 9, "%X", uiHostOptions); + // Save the host options that this world was last played with + strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_HOSTOPTIONS"); + snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X", + uiHostOptions); - iTextMetadataBytes += 15; - while(textMetadata[iTextMetadataBytes]!=0) iTextMetadataBytes++; - ++iTextMetadataBytes; // Add a null terminator at the end of the host options value + iTextMetadataBytes += 15; + while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++; + ++iTextMetadataBytes; // Add a null terminator at the end of the host + // options value - // Save the texture pack id - strcpy((char *)&textMetadata[iTextMetadataBytes],"4J_TEXTUREPACK"); + // Save the texture pack id + strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_TEXTUREPACK"); - iTextMetadataBytes += 15; - while(textMetadata[iTextMetadataBytes]!=0) iTextMetadataBytes++; + iTextMetadataBytes += 15; + while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++; - return iTextMetadataBytes; + return iTextMetadataBytes; } -void CMinecraftApp::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType,int x,int z) -{ - // check we don't already have this in - for(AUTO_VAR(it, m_vTerrainFeatures.begin()); it < m_vTerrainFeatures.end(); ++it) - { - FEATURE_DATA *pFeatureData=*it; +void CMinecraftApp::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType, + int x, int z) { + // check we don't already have this in + for (AUTO_VAR(it, m_vTerrainFeatures.begin()); + it < m_vTerrainFeatures.end(); ++it) { + FEATURE_DATA* pFeatureData = *it; - if((pFeatureData->eTerrainFeature==eFeatureType) &&(pFeatureData->x==x) && (pFeatureData->z==z)) return; - } + if ((pFeatureData->eTerrainFeature == eFeatureType) && + (pFeatureData->x == x) && (pFeatureData->z == z)) + return; + } - FEATURE_DATA *pFeatureData= new FEATURE_DATA; - pFeatureData->eTerrainFeature=eFeatureType; - pFeatureData->x=x; - pFeatureData->z=z; + FEATURE_DATA* pFeatureData = new FEATURE_DATA; + pFeatureData->eTerrainFeature = eFeatureType; + pFeatureData->x = x; + pFeatureData->z = z; - m_vTerrainFeatures.push_back(pFeatureData); + m_vTerrainFeatures.push_back(pFeatureData); } -_eTerrainFeatureType CMinecraftApp::IsTerrainFeature(int x,int z) -{ - for(AUTO_VAR(it, m_vTerrainFeatures.begin()); it < m_vTerrainFeatures.end(); ++it) - { - FEATURE_DATA *pFeatureData=*it; +_eTerrainFeatureType CMinecraftApp::IsTerrainFeature(int x, int z) { + for (AUTO_VAR(it, m_vTerrainFeatures.begin()); + it < m_vTerrainFeatures.end(); ++it) { + FEATURE_DATA* pFeatureData = *it; - if((pFeatureData->x==x) && (pFeatureData->z==z)) return pFeatureData->eTerrainFeature; - } + if ((pFeatureData->x == x) && (pFeatureData->z == z)) + return pFeatureData->eTerrainFeature; + } - return eTerrainFeature_None; + return eTerrainFeature_None; } -bool CMinecraftApp::GetTerrainFeaturePosition(_eTerrainFeatureType eType,int *pX, int *pZ) -{ - for(AUTO_VAR(it, m_vTerrainFeatures.begin()); it < m_vTerrainFeatures.end(); ++it) - { - FEATURE_DATA *pFeatureData=*it; - - if(pFeatureData->eTerrainFeature==eType) - { - *pX=pFeatureData->x; - *pZ=pFeatureData->z; - return true; - } - } +bool CMinecraftApp::GetTerrainFeaturePosition(_eTerrainFeatureType eType, + int* pX, int* pZ) { + for (AUTO_VAR(it, m_vTerrainFeatures.begin()); + it < m_vTerrainFeatures.end(); ++it) { + FEATURE_DATA* pFeatureData = *it; - return false; + if (pFeatureData->eTerrainFeature == eType) { + *pX = pFeatureData->x; + *pZ = pFeatureData->z; + return true; + } + } + + return false; } -void CMinecraftApp::ClearTerrainFeaturePosition() -{ - FEATURE_DATA *pFeatureData; - while(m_vTerrainFeatures.size()>0) - { - pFeatureData = m_vTerrainFeatures.back(); - m_vTerrainFeatures.pop_back(); - delete pFeatureData; - } +void CMinecraftApp::ClearTerrainFeaturePosition() { + FEATURE_DATA* pFeatureData; + while (m_vTerrainFeatures.size() > 0) { + pFeatureData = m_vTerrainFeatures.back(); + m_vTerrainFeatures.pop_back(); + delete pFeatureData; + } } -void CMinecraftApp::UpdatePlayerInfo(std::uint8_t networkSmallId, SHORT playerColourIndex, unsigned int playerGamePrivileges) -{ - for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) - { - if(m_playerColours[i]==networkSmallId) - { - m_playerColours[i] = 0; - m_playerGamePrivileges[i] = 0; - } - } - if(playerColourIndex >=0 && playerColourIndex < MINECRAFT_NET_MAX_PLAYERS) - { - m_playerColours[playerColourIndex] = networkSmallId; - m_playerGamePrivileges[playerColourIndex] = playerGamePrivileges; - } +void CMinecraftApp::UpdatePlayerInfo(std::uint8_t networkSmallId, + SHORT playerColourIndex, + unsigned int playerGamePrivileges) { + for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { + if (m_playerColours[i] == networkSmallId) { + m_playerColours[i] = 0; + m_playerGamePrivileges[i] = 0; + } + } + if (playerColourIndex >= 0 && + playerColourIndex < MINECRAFT_NET_MAX_PLAYERS) { + m_playerColours[playerColourIndex] = networkSmallId; + m_playerGamePrivileges[playerColourIndex] = playerGamePrivileges; + } } -short CMinecraftApp::GetPlayerColour(std::uint8_t networkSmallId) -{ - short index = -1; - for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) - { - if(m_playerColours[i]==networkSmallId) - { - index = i; - break; - } - } - return index; +short CMinecraftApp::GetPlayerColour(std::uint8_t networkSmallId) { + short index = -1; + for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { + if (m_playerColours[i] == networkSmallId) { + index = i; + break; + } + } + return index; } - -unsigned int CMinecraftApp::GetPlayerPrivileges(std::uint8_t networkSmallId) -{ - unsigned int privileges = 0; - for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) - { - if(m_playerColours[i]==networkSmallId) - { - privileges = m_playerGamePrivileges[i]; - break; - } - } - return privileges; +unsigned int CMinecraftApp::GetPlayerPrivileges(std::uint8_t networkSmallId) { + unsigned int privileges = 0; + for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) { + if (m_playerColours[i] == networkSmallId) { + privileges = m_playerGamePrivileges[i]; + break; + } + } + return privileges; } -std::wstring CMinecraftApp::getEntityName(eINSTANCEOF type) -{ - switch(type) - { - case eTYPE_WOLF: - return app.GetString(IDS_WOLF); - case eTYPE_CREEPER: - return app.GetString(IDS_CREEPER); - case eTYPE_SKELETON: - return app.GetString(IDS_SKELETON); - case eTYPE_SPIDER: - return app.GetString(IDS_SPIDER); - case eTYPE_ZOMBIE: - return app.GetString(IDS_ZOMBIE); - case eTYPE_PIGZOMBIE: - return app.GetString(IDS_PIGZOMBIE); - case eTYPE_ENDERMAN: - return app.GetString(IDS_ENDERMAN); - case eTYPE_SILVERFISH: - return app.GetString(IDS_SILVERFISH); - case eTYPE_CAVESPIDER: - return app.GetString(IDS_CAVE_SPIDER); - case eTYPE_GHAST: - return app.GetString(IDS_GHAST); - case eTYPE_SLIME: - return app.GetString(IDS_SLIME); - case eTYPE_ARROW: - return app.GetString(IDS_ITEM_ARROW); - case eTYPE_ENDERDRAGON: - return app.GetString(IDS_ENDERDRAGON); - case eTYPE_BLAZE: - return app.GetString(IDS_BLAZE); - case eTYPE_LAVASLIME: - return app.GetString(IDS_LAVA_SLIME); - // 4J-PB - fix for #107167 - Customer Encountered: TU12: Content: UI: There is no information what killed Player after being slain by Iron Golem. - case eTYPE_VILLAGERGOLEM: - return app.GetString(IDS_IRONGOLEM); - default: - break; +std::wstring CMinecraftApp::getEntityName(eINSTANCEOF type) { + switch (type) { + case eTYPE_WOLF: + return app.GetString(IDS_WOLF); + case eTYPE_CREEPER: + return app.GetString(IDS_CREEPER); + case eTYPE_SKELETON: + return app.GetString(IDS_SKELETON); + case eTYPE_SPIDER: + return app.GetString(IDS_SPIDER); + case eTYPE_ZOMBIE: + return app.GetString(IDS_ZOMBIE); + case eTYPE_PIGZOMBIE: + return app.GetString(IDS_PIGZOMBIE); + case eTYPE_ENDERMAN: + return app.GetString(IDS_ENDERMAN); + case eTYPE_SILVERFISH: + return app.GetString(IDS_SILVERFISH); + case eTYPE_CAVESPIDER: + return app.GetString(IDS_CAVE_SPIDER); + case eTYPE_GHAST: + return app.GetString(IDS_GHAST); + case eTYPE_SLIME: + return app.GetString(IDS_SLIME); + case eTYPE_ARROW: + return app.GetString(IDS_ITEM_ARROW); + case eTYPE_ENDERDRAGON: + return app.GetString(IDS_ENDERDRAGON); + case eTYPE_BLAZE: + return app.GetString(IDS_BLAZE); + case eTYPE_LAVASLIME: + return app.GetString(IDS_LAVA_SLIME); + // 4J-PB - fix for #107167 - Customer Encountered: TU12: Content: + // UI: There is no information what killed Player after being slain + // by Iron Golem. + case eTYPE_VILLAGERGOLEM: + return app.GetString(IDS_IRONGOLEM); + default: + break; + }; - }; - - return L""; + return L""; } -std::uint32_t CMinecraftApp::m_dwContentTypeA[e_Marketplace_MAX] = -{ - XMARKETPLACE_OFFERING_TYPE_CONTENT, // e_DLC_SkinPack, e_DLC_TexturePacks, e_DLC_MashupPacks +std::uint32_t CMinecraftApp::m_dwContentTypeA[e_Marketplace_MAX] = { + XMARKETPLACE_OFFERING_TYPE_CONTENT, // e_DLC_SkinPack, e_DLC_TexturePacks, + // e_DLC_MashupPacks #ifndef _XBOX_ONE - XMARKETPLACE_OFFERING_TYPE_THEME, // e_DLC_Themes - XMARKETPLACE_OFFERING_TYPE_AVATARITEM, // e_DLC_AvatarItems - XMARKETPLACE_OFFERING_TYPE_TILE, // e_DLC_Gamerpics + XMARKETPLACE_OFFERING_TYPE_THEME, // e_DLC_Themes + XMARKETPLACE_OFFERING_TYPE_AVATARITEM, // e_DLC_AvatarItems + XMARKETPLACE_OFFERING_TYPE_TILE, // e_DLC_Gamerpics #endif }; -unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType, bool bPromote) -{ - // lock access - EnterCriticalSection(&csDLCDownloadQueue); +unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType, + bool bPromote) { + // lock access + EnterCriticalSection(&csDLCDownloadQueue); - // If it's already in there, promote it to the top of the list - int iPosition=0; - for(AUTO_VAR(it, m_DLCDownloadQueue.begin()); it != m_DLCDownloadQueue.end(); ++it) - { - DLCRequest *pCurrent = *it; + // If it's already in there, promote it to the top of the list + int iPosition = 0; + for (AUTO_VAR(it, m_DLCDownloadQueue.begin()); + it != m_DLCDownloadQueue.end(); ++it) { + DLCRequest* pCurrent = *it; - if(pCurrent->dwType==m_dwContentTypeA[eType]) - { - // already got this in the list - if(pCurrent->eState == e_DLC_ContentState_Retrieving || pCurrent->eState == e_DLC_ContentState_Retrieved) - { - // already retrieved this - LeaveCriticalSection(&csDLCDownloadQueue); - return 0; - } - else - { - // promote - if(bPromote) - { - m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin()+iPosition); - m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),pCurrent); - } - LeaveCriticalSection(&csDLCDownloadQueue); - return 0; - } - } - iPosition++; - } + if (pCurrent->dwType == m_dwContentTypeA[eType]) { + // already got this in the list + if (pCurrent->eState == e_DLC_ContentState_Retrieving || + pCurrent->eState == e_DLC_ContentState_Retrieved) { + // already retrieved this + LeaveCriticalSection(&csDLCDownloadQueue); + return 0; + } else { + // promote + if (bPromote) { + m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin() + + iPosition); + m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(), + pCurrent); + } + LeaveCriticalSection(&csDLCDownloadQueue); + return 0; + } + } + iPosition++; + } - DLCRequest *pDLCreq = new DLCRequest; - pDLCreq->dwType=m_dwContentTypeA[eType]; - pDLCreq->eState=e_DLC_ContentState_Idle; + DLCRequest* pDLCreq = new DLCRequest; + pDLCreq->dwType = m_dwContentTypeA[eType]; + pDLCreq->eState = e_DLC_ContentState_Idle; - m_DLCDownloadQueue.push_back(pDLCreq); + m_DLCDownloadQueue.push_back(pDLCreq); - m_bAllDLCContentRetrieved=false; - LeaveCriticalSection(&csDLCDownloadQueue); + m_bAllDLCContentRetrieved = false; + LeaveCriticalSection(&csDLCDownloadQueue); - app.DebugPrintf("[Consoles_App] Added DLC request.\n"); - return 1; + app.DebugPrintf("[Consoles_App] Added DLC request.\n"); + return 1; } -unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool bPromote) -{ +unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, + bool bPromote) { #if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) - // lock access - EnterCriticalSection(&csTMSPPDownloadQueue); + // lock access + EnterCriticalSection(&csTMSPPDownloadQueue); - // If it's already in there, promote it to the top of the list - int iPosition=0; - //ignore promoting for now - /* - bool bPromoted=false; + // If it's already in there, promote it to the top of the list + int iPosition = 0; + // ignore promoting for now + /* + bool bPromoted=false; - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; + for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != + m_TMSPPDownloadQueue.end(); ++it) + { + TMSPPRequest *pCurrent = *it; - if(pCurrent->eType==eType) - { - if(!(pCurrent->eState == e_TMS_ContentState_Retrieving || pCurrent->eState == e_TMS_ContentState_Retrieved)) - { - // promote - if(bPromote) - { - m_TMSPPDownloadQueue.erase(m_TMSPPDownloadQueue.begin()+iPosition); - m_TMSPPDownloadQueue.insert(m_TMSPPDownloadQueue.begin(),pCurrent); - bPromoted=true; - } - } - } - iPosition++; - } + if(pCurrent->eType==eType) + { + if(!(pCurrent->eState == e_TMS_ContentState_Retrieving || + pCurrent->eState == e_TMS_ContentState_Retrieved)) + { + // promote + if(bPromote) + { + m_TMSPPDownloadQueue.erase(m_TMSPPDownloadQueue.begin()+iPosition); + m_TMSPPDownloadQueue.insert(m_TMSPPDownloadQueue.begin(),pCurrent); + bPromoted=true; + } + } + } + iPosition++; + } - if(bPromoted) - { - // re-ordered the list, so leave now - LeaveCriticalSection(&csTMSPPDownloadQueue); - return 0; - } - */ + if(bPromoted) + { + // re-ordered the list, so leave now + LeaveCriticalSection(&csTMSPPDownloadQueue); + return 0; + } + */ - // special case for data files (not image files) - if(eType==e_DLC_TexturePackData) - { + // special case for data files (not image files) + if (eType == e_DLC_TexturePackData) { + int iCount = GetDLCInfoFullOffersCount(); + for (int i = 0; i < iCount; i++) { + DLC_INFO* pDLC = GetDLCInfoFullOffer(i); - int iCount=GetDLCInfoFullOffersCount(); + if ((pDLC->eDLCType == e_DLC_TexturePacks) || + (pDLC->eDLCType == e_DLC_MashupPacks)) { + // first check if the image is already in the memory textures, + // since we might be loading some from the Title Update + // partition + if (pDLC->wchDataFile[0] != 0) { + // WCHAR *cString = pDLC->wchDataFile; + // 4J-PB - shouldn't check this here - let the TMS files + // override it, so if they are on TMS, we'll take them + // first + // int iIndex = + // app.GetLocalTMSFileIndex(pDLC->wchDataFile,true); - for(int i=0;iiConfig); - DLC_INFO *pDLC=GetDLCInfoFullOffer(i); + if (!bPresent) { + // this may already be present in the vector because + // of a previous trial/full offer - if((pDLC->eDLCType==e_DLC_TexturePacks) || (pDLC->eDLCType==e_DLC_MashupPacks)) - { - // first check if the image is already in the memory textures, since we might be loading some from the Title Update partition - if(pDLC->wchDataFile[0]!=0) - { - //WCHAR *cString = pDLC->wchDataFile; - // 4J-PB - shouldn't check this here - let the TMS files override it, so if they are on TMS, we'll take them first - //int iIndex = app.GetLocalTMSFileIndex(pDLC->wchDataFile,true); + bool bAlreadyInQueue = false; + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - //if(iIndex!=-1) - { - bool bPresent = app.IsFileInTPD(pDLC->iConfig); + if (wcscmp(pDLC->wchDataFile, + pCurrent->wchFilename) == 0) { + bAlreadyInQueue = true; + break; + } + } - if(!bPresent) - { - // this may already be present in the vector because of a previous trial/full offer + if (!bAlreadyInQueue) { + TMSPPRequest* pTMSPPreq = new TMSPPRequest; - bool bAlreadyInQueue=false; - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; + pTMSPPreq->CallbackFunc = + &CMinecraftApp::TMSPPFileReturned; + pTMSPPreq->lpCallbackParam = this; + pTMSPPreq->eStorageFacility = + C4JStorage::eGlobalStorage_Title; + pTMSPPreq->eFileTypeVal = + C4JStorage::TMS_FILETYPE_BINARY; + memcpy(pTMSPPreq->wchFilename, + pDLC->wchDataFile, + sizeof(WCHAR) * MAX_BANNERNAME_SIZE); + pTMSPPreq->eType = e_DLC_TexturePackData; + pTMSPPreq->eState = e_TMS_ContentState_Queued; + m_bAllTMSContentRetrieved = false; + m_TMSPPDownloadQueue.push_back(pTMSPPreq); + } + } else { + app.DebugPrintf( + "Texture data already present in the TPD\n"); + } + } + } + } + } + } else { // for all the files of type eType, add them to the download list - if(wcscmp(pDLC->wchDataFile,pCurrent->wchFilename)==0) - { - bAlreadyInQueue=true; - break; - } - } + // run through the trial offers first, then the full offers. Any + // duplicates won't be added to the download queue + int iCount; +#ifdef _XBOX // Only trial offers on Xbox 360 + iCount = GetDLCInfoTrialOffersCount(); + for (int i = 0; i < iCount; i++) { + DLC_INFO* pDLC = GetDLCInfoTrialOffer(i); - if(!bAlreadyInQueue) - { - TMSPPRequest *pTMSPPreq = new TMSPPRequest; + // is this the right type? + if (pDLC->eDLCType == eType) { + WCHAR* cString = pDLC->wchBanner; - pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; - pTMSPPreq->lpCallbackParam=this; - pTMSPPreq->eStorageFacility=C4JStorage::eGlobalStorage_Title; - pTMSPPreq->eFileTypeVal=C4JStorage::TMS_FILETYPE_BINARY; - memcpy(pTMSPPreq->wchFilename,pDLC->wchDataFile,sizeof(WCHAR)*MAX_BANNERNAME_SIZE); - pTMSPPreq->eType=e_DLC_TexturePackData; - pTMSPPreq->eState=e_TMS_ContentState_Queued; - m_bAllTMSContentRetrieved=false; - m_TMSPPDownloadQueue.push_back(pTMSPPreq); - } - } - else - { - app.DebugPrintf("Texture data already present in the TPD\n"); - } - } - } - } - } - } - else - { // for all the files of type eType, add them to the download list + // 4J-PB - shouldn't check this here - let the TMS files + // override it, so if they are on TMS, we'll take them first is + // the file in the TMS XZP? + // int iIndex = app.GetLocalTMSFileIndex(cString,true); - // run through the trial offers first, then the full offers. Any duplicates won't be added to the download queue - int iCount; -#ifdef _XBOX // Only trial offers on Xbox 360 - iCount=GetDLCInfoTrialOffersCount(); - for(int i=0;ieDLCType==eType) - { + if (!bPresent) // retrieve it from TMSPP + { + bool bAlreadyInQueue = false; + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - WCHAR *cString = pDLC->wchBanner; + if (wcscmp(pDLC->wchBanner, + pCurrent->wchFilename) == 0) { + bAlreadyInQueue = true; + break; + } + } - // 4J-PB - shouldn't check this here - let the TMS files override it, so if they are on TMS, we'll take them first - // is the file in the TMS XZP? - //int iIndex = app.GetLocalTMSFileIndex(cString,true); + if (!bAlreadyInQueue) { + TMSPPRequest* pTMSPPreq = new TMSPPRequest; - //if(iIndex!=-1) - { - bool bPresent = app.IsFileInMemoryTextures(cString); + pTMSPPreq->CallbackFunc = + &CMinecraftApp::TMSPPFileReturned; + pTMSPPreq->lpCallbackParam = this; + pTMSPPreq->eStorageFacility = + C4JStorage::eGlobalStorage_Title; + pTMSPPreq->eFileTypeVal = + C4JStorage::TMS_FILETYPE_BINARY; + // wcstombs(pTMSPPreq->szFilename,pDLC->wchBanner,MAX_TMSFILENAME_SIZE); + memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner, + sizeof(WCHAR) * MAX_BANNERNAME_SIZE); + pTMSPPreq->eType = eType; + pTMSPPreq->eState = e_TMS_ContentState_Queued; - if(!bPresent) // retrieve it from TMSPP - { - bool bAlreadyInQueue=false; - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; - - if(wcscmp(pDLC->wchBanner,pCurrent->wchFilename)==0) - { - bAlreadyInQueue=true; - break; - } - } - - if(!bAlreadyInQueue) - { - TMSPPRequest *pTMSPPreq = new TMSPPRequest; - - pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; - pTMSPPreq->lpCallbackParam=this; - pTMSPPreq->eStorageFacility=C4JStorage::eGlobalStorage_Title; - pTMSPPreq->eFileTypeVal=C4JStorage::TMS_FILETYPE_BINARY; - //wcstombs(pTMSPPreq->szFilename,pDLC->wchBanner,MAX_TMSFILENAME_SIZE); - memcpy(pTMSPPreq->wchFilename,pDLC->wchBanner,sizeof(WCHAR)*MAX_BANNERNAME_SIZE); - pTMSPPreq->eType=eType; - pTMSPPreq->eState=e_TMS_ContentState_Queued; - - m_bAllTMSContentRetrieved=false; - m_TMSPPDownloadQueue.push_back(pTMSPPreq); - app.DebugPrintf("===m_TMSPPDownloadQueue Adding %ls, q size is %d\n",pTMSPPreq->wchFilename,m_TMSPPDownloadQueue.size()); - } - } - } - } - } + m_bAllTMSContentRetrieved = false; + m_TMSPPDownloadQueue.push_back(pTMSPPreq); + app.DebugPrintf( + "===m_TMSPPDownloadQueue Adding %ls, q size is " + "%d\n", + pTMSPPreq->wchFilename, + m_TMSPPDownloadQueue.size()); + } + } + } + } + } #endif - // and the full offers + // and the full offers - iCount=GetDLCInfoFullOffersCount(); - for(int i=0;iwchType,wchDLCTypeNames[eType])==0) - if(pDLC->eDLCType==eType) - { - // first check if the image is already in the memory textures, since we might be loading some from the Title Update partition + iCount = GetDLCInfoFullOffersCount(); + for (int i = 0; i < iCount; i++) { + DLC_INFO* pDLC = GetDLCInfoFullOffer(i); + // if(wcscmp(pDLC->wchType,wchDLCTypeNames[eType])==0) + if (pDLC->eDLCType == eType) { + // first check if the image is already in the memory textures, + // since we might be loading some from the Title Update + // partition - WCHAR *cString = pDLC->wchBanner; - // 4J-PB - shouldn't check this here - let the TMS files override it, so if they are on TMS, we'll take them first - //int iIndex = app.GetLocalTMSFileIndex(cString,true); + WCHAR* cString = pDLC->wchBanner; + // 4J-PB - shouldn't check this here - let the TMS files + // override it, so if they are on TMS, we'll take them first + // int iIndex = app.GetLocalTMSFileIndex(cString,true); - //if(iIndex!=-1) - { - bool bPresent = app.IsFileInMemoryTextures(cString); - - if(!bPresent) - { - // this may already be present in the vector because of a previous trial/full offer + // if(iIndex!=-1) + { + bool bPresent = app.IsFileInMemoryTextures(cString); - bool bAlreadyInQueue=false; - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; + if (!bPresent) { + // this may already be present in the vector because of + // a previous trial/full offer - if(wcscmp(pDLC->wchBanner,pCurrent->wchFilename)==0) - { - bAlreadyInQueue=true; - break; - } - } + bool bAlreadyInQueue = false; + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - if(!bAlreadyInQueue) - { - //app.DebugPrintf("Adding a request to the TMSPP download queue - %ls\n",pDLC->wchBanner); - TMSPPRequest *pTMSPPreq = new TMSPPRequest; - ZeroMemory(pTMSPPreq,sizeof(TMSPPRequest)); + if (wcscmp(pDLC->wchBanner, + pCurrent->wchFilename) == 0) { + bAlreadyInQueue = true; + break; + } + } - pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; - pTMSPPreq->lpCallbackParam=this; - // 4J-PB - testing for now - //pTMSPPreq->eStorageFacility=C4JStorage::eGlobalStorage_TitleUser; - pTMSPPreq->eStorageFacility=C4JStorage::eGlobalStorage_Title; - pTMSPPreq->eFileTypeVal=C4JStorage::TMS_FILETYPE_BINARY; - //wcstombs(pTMSPPreq->szFilename,pDLC->wchBanner,MAX_TMSFILENAME_SIZE); + if (!bAlreadyInQueue) { + // app.DebugPrintf("Adding a request to the TMSPP + // download queue - %ls\n",pDLC->wchBanner); + TMSPPRequest* pTMSPPreq = new TMSPPRequest; + ZeroMemory(pTMSPPreq, sizeof(TMSPPRequest)); - memcpy(pTMSPPreq->wchFilename,pDLC->wchBanner,sizeof(WCHAR)*MAX_BANNERNAME_SIZE); - pTMSPPreq->eType=eType; - pTMSPPreq->eState=e_TMS_ContentState_Queued; - m_bAllTMSContentRetrieved=false; - m_TMSPPDownloadQueue.push_back(pTMSPPreq); - app.DebugPrintf("===m_TMSPPDownloadQueue Adding %ls, q size is %d\n",pTMSPPreq->wchFilename,m_TMSPPDownloadQueue.size()); - } - } - } - } - } - } + pTMSPPreq->CallbackFunc = + &CMinecraftApp::TMSPPFileReturned; + pTMSPPreq->lpCallbackParam = this; + // 4J-PB - testing for now + // pTMSPPreq->eStorageFacility=C4JStorage::eGlobalStorage_TitleUser; + pTMSPPreq->eStorageFacility = + C4JStorage::eGlobalStorage_Title; + pTMSPPreq->eFileTypeVal = + C4JStorage::TMS_FILETYPE_BINARY; + // wcstombs(pTMSPPreq->szFilename,pDLC->wchBanner,MAX_TMSFILENAME_SIZE); - LeaveCriticalSection(&csTMSPPDownloadQueue); + memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner, + sizeof(WCHAR) * MAX_BANNERNAME_SIZE); + pTMSPPreq->eType = eType; + pTMSPPreq->eState = e_TMS_ContentState_Queued; + m_bAllTMSContentRetrieved = false; + m_TMSPPDownloadQueue.push_back(pTMSPPreq); + app.DebugPrintf( + "===m_TMSPPDownloadQueue Adding %ls, q size is " + "%d\n", + pTMSPPreq->wchFilename, + m_TMSPPDownloadQueue.size()); + } + } + } + } + } + } + + LeaveCriticalSection(&csTMSPPDownloadQueue); #endif - return 1; + return 1; } -bool CMinecraftApp::CheckTMSDLCCanStop() -{ - EnterCriticalSection(&csTMSPPDownloadQueue); - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; +bool CMinecraftApp::CheckTMSDLCCanStop() { + EnterCriticalSection(&csTMSPPDownloadQueue); + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - if(pCurrent->eState==e_TMS_ContentState_Retrieving) - { - LeaveCriticalSection(&csTMSPPDownloadQueue); - return false; - } - } - LeaveCriticalSection(&csTMSPPDownloadQueue); + if (pCurrent->eState == e_TMS_ContentState_Retrieving) { + LeaveCriticalSection(&csTMSPPDownloadQueue); + return false; + } + } + LeaveCriticalSection(&csTMSPPDownloadQueue); - return true; + return true; } +bool CMinecraftApp::RetrieveNextDLCContent() { + // If there's already a retrieve in progress, quit + // we may have re-ordered the list, so need to check every item -bool CMinecraftApp::RetrieveNextDLCContent() -{ - // If there's already a retrieve in progress, quit - // we may have re-ordered the list, so need to check every item + // is there a primary player and a network connection? + int primPad = ProfileManager.GetPrimaryPad(); + if (primPad == -1 || !ProfileManager.IsSignedInLive(primPad)) { + return true; // 4J-JEV: We need to wait until the primary player is + // online. + } - // is there a primary player and a network connection? - int primPad = ProfileManager.GetPrimaryPad(); - if ( primPad == -1 || !ProfileManager.IsSignedInLive(primPad) ) - { - return true; // 4J-JEV: We need to wait until the primary player is online. - } + EnterCriticalSection(&csDLCDownloadQueue); + for (AUTO_VAR(it, m_DLCDownloadQueue.begin()); + it != m_DLCDownloadQueue.end(); ++it) { + DLCRequest* pCurrent = *it; - EnterCriticalSection(&csDLCDownloadQueue); - for(AUTO_VAR(it, m_DLCDownloadQueue.begin()); it != m_DLCDownloadQueue.end(); ++it) - { - DLCRequest *pCurrent = *it; + if (pCurrent->eState == e_DLC_ContentState_Retrieving) { + LeaveCriticalSection(&csDLCDownloadQueue); + return true; + } + } - if(pCurrent->eState==e_DLC_ContentState_Retrieving) - { - LeaveCriticalSection(&csDLCDownloadQueue); - return true; - } - } + // Now look for the next retrieval + for (AUTO_VAR(it, m_DLCDownloadQueue.begin()); + it != m_DLCDownloadQueue.end(); ++it) { + DLCRequest* pCurrent = *it; - // Now look for the next retrieval - for(AUTO_VAR(it, m_DLCDownloadQueue.begin()); it != m_DLCDownloadQueue.end(); ++it) - { - DLCRequest *pCurrent = *it; - - if(pCurrent->eState==e_DLC_ContentState_Idle) - { + if (pCurrent->eState == e_DLC_ContentState_Idle) { #ifdef _DEBUG - app.DebugPrintf("RetrieveNextDLCContent - type = %d\n",pCurrent->dwType); + app.DebugPrintf("RetrieveNextDLCContent - type = %d\n", + pCurrent->dwType); #endif - C4JStorage::EDLCStatus status = StorageManager.GetDLCOffers(ProfileManager.GetPrimaryPad(), &CMinecraftApp::DLCOffersReturned, this, pCurrent->dwType); - if(status==C4JStorage::EDLC_Pending) - { - pCurrent->eState=e_DLC_ContentState_Retrieving; - } - else - { - // no content of this type, or some other problem - app.DebugPrintf("RetrieveNextDLCContent - PROBLEM\n"); - pCurrent->eState=e_DLC_ContentState_Retrieved; - } - LeaveCriticalSection(&csDLCDownloadQueue); - return true; - } - } - LeaveCriticalSection(&csDLCDownloadQueue); + C4JStorage::EDLCStatus status = StorageManager.GetDLCOffers( + ProfileManager.GetPrimaryPad(), + &CMinecraftApp::DLCOffersReturned, this, pCurrent->dwType); + if (status == C4JStorage::EDLC_Pending) { + pCurrent->eState = e_DLC_ContentState_Retrieving; + } else { + // no content of this type, or some other problem + app.DebugPrintf("RetrieveNextDLCContent - PROBLEM\n"); + pCurrent->eState = e_DLC_ContentState_Retrieved; + } + LeaveCriticalSection(&csDLCDownloadQueue); + return true; + } + } + LeaveCriticalSection(&csDLCDownloadQueue); - app.DebugPrintf("[Consoles_App] Finished downloading dlc content.\n"); - return false; + app.DebugPrintf("[Consoles_App] Finished downloading dlc content.\n"); + return false; } #if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) #ifdef _XBOX_ONE -int CMinecraftApp::TMSPPFileReturned(void *pParam,int iPad,int iUserData,void *lpvData, WCHAR* wchFilename) -{ - C4JStorage::PTMSPP_FILEDATA pFileData=(C4JStorage::PTMSPP_FILEDATA)lpvData; +int CMinecraftApp::TMSPPFileReturned(void* pParam, int iPad, int iUserData, + void* lpvData, WCHAR* wchFilename) { + C4JStorage::PTMSPP_FILEDATA pFileData = + (C4JStorage::PTMSPP_FILEDATA)lpvData; #else -int CMinecraftApp::TMSPPFileReturned(void *pParam,int iPad,int iUserData,C4JStorage::PTMSPP_FILEDATA pFileData, LPCSTR szFilename) -{ +int CMinecraftApp::TMSPPFileReturned(void* pParam, int iPad, int iUserData, + C4JStorage::PTMSPP_FILEDATA pFileData, + LPCSTR szFilename) { #endif - CMinecraftApp* pClass = (CMinecraftApp *) pParam; + CMinecraftApp* pClass = (CMinecraftApp*)pParam; - // find the right one in the vector - EnterCriticalSection(&pClass->csTMSPPDownloadQueue); - for(AUTO_VAR(it, pClass->m_TMSPPDownloadQueue.begin()); it != pClass->m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; + // find the right one in the vector + EnterCriticalSection(&pClass->csTMSPPDownloadQueue); + for (AUTO_VAR(it, pClass->m_TMSPPDownloadQueue.begin()); + it != pClass->m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; #if defined(_XBOX) || defined(_WINDOWS64) - char szFile[MAX_TMSFILENAME_SIZE]; - wcstombs(szFile,pCurrent->wchFilename,MAX_TMSFILENAME_SIZE); - + char szFile[MAX_TMSFILENAME_SIZE]; + wcstombs(szFile, pCurrent->wchFilename, MAX_TMSFILENAME_SIZE); - if(strcmp(szFilename,szFile)==0) + if (strcmp(szFilename, szFile) == 0) #elif _XBOX_ONE - if(wcscmp(wchFilename,pCurrent->wchFilename)==0) + if (wcscmp(wchFilename, pCurrent->wchFilename) == 0) #endif - { - // set this to retrieved whether it found it or not - pCurrent->eState=e_TMS_ContentState_Retrieved; - - if(pFileData!=NULL) - { + { + // set this to retrieved whether it found it or not + pCurrent->eState = e_TMS_ContentState_Retrieved; + if (pFileData != NULL) { #ifdef _XBOX_ONE - - switch(pCurrent->eType) - { - case e_DLC_TexturePackData: - { - // 4J-PB - we need to allocate memory for the file data and copy into it, since the current data is a reference into the blob download memory - std::uint8_t *pbData = new std::uint8_t[pFileData->size]; - memcpy(pbData,pFileData->pbData,pFileData->size); + switch (pCurrent->eType) { + case e_DLC_TexturePackData: { + // 4J-PB - we need to allocate memory for the file data + // and copy into it, since the current data is a + // reference into the blob download memory + std::uint8_t* pbData = + new std::uint8_t[pFileData->size]; + memcpy(pbData, pFileData->pbData, pFileData->size); - pClass->m_vTMSPPData.push_back(pbData); - app.DebugPrintf("Got texturepack data\n"); - // get the config value for the texture pack - int iConfig=app.GetTPConfigVal(pCurrent->wchFilename); - app.AddMemoryTPDFile(iConfig, pbData, pFileData->size); - } - break; - default: - // 4J-PB - check the data is an image - if(pFileData->pbData[0]==0x89) - { - // 4J-PB - we need to allocate memory for the file data and copy into it, since the current data is a reference into the blob download memory - std::uint8_t *pbData = new std::uint8_t[pFileData->size]; - memcpy(pbData,pFileData->pbData,pFileData->size); - - pClass->m_vTMSPPData.push_back(pbData); - app.DebugPrintf("Got image data - %ls\n",pCurrent->wchFilename); - app.AddMemoryTextureFile(pCurrent->wchFilename, pbData, pFileData->size); - } - else - { - app.DebugPrintf("Got image data, but it's not a png - %ls\n",pCurrent->wchFilename); - } - break; - } + pClass->m_vTMSPPData.push_back(pbData); + app.DebugPrintf("Got texturepack data\n"); + // get the config value for the texture pack + int iConfig = app.GetTPConfigVal(pCurrent->wchFilename); + app.AddMemoryTPDFile(iConfig, pbData, pFileData->size); + } break; + default: + // 4J-PB - check the data is an image + if (pFileData->pbData[0] == 0x89) { + // 4J-PB - we need to allocate memory for the file + // data and copy into it, since the current data is + // a reference into the blob download memory + std::uint8_t* pbData = + new std::uint8_t[pFileData->size]; + memcpy(pbData, pFileData->pbData, pFileData->size); + + pClass->m_vTMSPPData.push_back(pbData); + app.DebugPrintf("Got image data - %ls\n", + pCurrent->wchFilename); + app.AddMemoryTextureFile(pCurrent->wchFilename, + pbData, pFileData->size); + } else { + app.DebugPrintf( + "Got image data, but it's not a png - %ls\n", + pCurrent->wchFilename); + } + break; + } #else - switch(pCurrent->eType) - { - case e_DLC_TexturePackData: - { - app.DebugPrintf("--- Got texturepack data %ls\n",pCurrent->wchFilename); - // get the config value for the texture pack - int iConfig=app.GetTPConfigVal(pCurrent->wchFilename); - app.AddMemoryTPDFile(iConfig, pFileData->pbData, pFileData->size); - } - break; - default: - app.DebugPrintf("--- Got image data - %ls\n",pCurrent->wchFilename); - app.AddMemoryTextureFile(pCurrent->wchFilename, pFileData->pbData, pFileData->size); - break; - } + switch (pCurrent->eType) { + case e_DLC_TexturePackData: { + app.DebugPrintf("--- Got texturepack data %ls\n", + pCurrent->wchFilename); + // get the config value for the texture pack + int iConfig = app.GetTPConfigVal(pCurrent->wchFilename); + app.AddMemoryTPDFile(iConfig, pFileData->pbData, + pFileData->size); + } break; + default: + app.DebugPrintf("--- Got image data - %ls\n", + pCurrent->wchFilename); + app.AddMemoryTextureFile(pCurrent->wchFilename, + pFileData->pbData, + pFileData->size); + break; + } #endif - } - else - { + } else { #ifdef _XBOX_ONE - app.DebugPrintf("TMSImageReturned failed (%ls)...\n",wchFilename); + app.DebugPrintf("TMSImageReturned failed (%ls)...\n", + wchFilename); #else - app.DebugPrintf("TMSImageReturned failed (%s)...\n",szFilename); + app.DebugPrintf("TMSImageReturned failed (%s)...\n", + szFilename); #endif - } - break; - } - - } - LeaveCriticalSection(&pClass->csTMSPPDownloadQueue); + } + break; + } + } + LeaveCriticalSection(&pClass->csTMSPPDownloadQueue); - return 0; + return 0; } #endif -bool CMinecraftApp::RetrieveNextTMSPPContent() -{ +bool CMinecraftApp::RetrieveNextTMSPPContent() { #if defined _XBOX || defined _XBOX_ONE - // If there's already a retrieve in progress, quit - // we may have re-ordered the list, so need to check every item + // If there's already a retrieve in progress, quit + // we may have re-ordered the list, so need to check every item - // is there a primary player and a network connection? - if(ProfileManager.GetPrimaryPad()==-1) return false; + // is there a primary player and a network connection? + if (ProfileManager.GetPrimaryPad() == -1) return false; - if(ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())==false) return false; + if (ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) == false) + return false; - EnterCriticalSection(&csTMSPPDownloadQueue); - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; + EnterCriticalSection(&csTMSPPDownloadQueue); + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - if(pCurrent->eState==e_TMS_ContentState_Retrieving) - { - app.DebugPrintf("."); - LeaveCriticalSection(&csTMSPPDownloadQueue); - return true; - } - } + if (pCurrent->eState == e_TMS_ContentState_Retrieving) { + app.DebugPrintf("."); + LeaveCriticalSection(&csTMSPPDownloadQueue); + return true; + } + } - // Now look for the next retrieval - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; + // Now look for the next retrieval + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - if(pCurrent->eState==e_TMS_ContentState_Queued) - { - // 4J-PB - the file may be in the local TMS files, but try to retrieve it from the remote TMS in case it's been changed. If it's not in the list of TMS files, this will - // return right away with a ETMSStatus_Fail_ReadDetailsNotRetrieved + if (pCurrent->eState == e_TMS_ContentState_Queued) { + // 4J-PB - the file may be in the local TMS files, but try to + // retrieve it from the remote TMS in case it's been changed. If + // it's not in the list of TMS files, this will return right away + // with a ETMSStatus_Fail_ReadDetailsNotRetrieved #ifdef _XBOX - char szFilename[MAX_TMSFILENAME_SIZE]; - wcstombs(szFilename,pCurrent->wchFilename,MAX_TMSFILENAME_SIZE); + char szFilename[MAX_TMSFILENAME_SIZE]; + wcstombs(szFilename, pCurrent->wchFilename, MAX_TMSFILENAME_SIZE); - app.DebugPrintf("\nRetrieveNextTMSPPContent - type = %d, %s\n",pCurrent->eType,szFilename); + app.DebugPrintf("\nRetrieveNextTMSPPContent - type = %d, %s\n", + pCurrent->eType, szFilename); - C4JStorage::ETMSStatus status=StorageManager.TMSPP_ReadFile(ProfileManager.GetPrimaryPad(),pCurrent->eStorageFacility,pCurrent->eFileTypeVal,szFilename,pCurrent->CallbackFunc,this); - switch(status) - { - case C4JStorage::ETMSStatus_Pending: - pCurrent->eState=e_TMS_ContentState_Retrieving; - break; - case C4JStorage::ETMSStatus_Idle: - pCurrent->eState=e_TMS_ContentState_Retrieved; - break; - case C4JStorage::ETMSStatus_Fail_ReadInProgress: - case C4JStorage::ETMSStatus_ReadInProgress: - pCurrent->eState=e_TMS_ContentState_Retrieving; - if(pCurrent->eState==C4JStorage::ETMSStatus_Fail_ReadInProgress) - { - app.DebugPrintf("TMSPP_ReadFile failed - read in progress\n"); - Sleep(50); - LeaveCriticalSection(&csTMSPPDownloadQueue); - return false; - } - break; - default: - pCurrent->eState=e_TMS_ContentState_Retrieved; - break; - } + C4JStorage::ETMSStatus status = StorageManager.TMSPP_ReadFile( + ProfileManager.GetPrimaryPad(), pCurrent->eStorageFacility, + pCurrent->eFileTypeVal, szFilename, pCurrent->CallbackFunc, + this); + switch (status) { + case C4JStorage::ETMSStatus_Pending: + pCurrent->eState = e_TMS_ContentState_Retrieving; + break; + case C4JStorage::ETMSStatus_Idle: + pCurrent->eState = e_TMS_ContentState_Retrieved; + break; + case C4JStorage::ETMSStatus_Fail_ReadInProgress: + case C4JStorage::ETMSStatus_ReadInProgress: + pCurrent->eState = e_TMS_ContentState_Retrieving; + if (pCurrent->eState == + C4JStorage::ETMSStatus_Fail_ReadInProgress) { + app.DebugPrintf( + "TMSPP_ReadFile failed - read in progress\n"); + Sleep(50); + LeaveCriticalSection(&csTMSPPDownloadQueue); + return false; + } + break; + default: + pCurrent->eState = e_TMS_ContentState_Retrieved; + break; + } #else - eTitleStorageState status; - app.DebugPrintf("RetrieveNextTMSPPContent - type = %d, %ls\n",pCurrent->eType,pCurrent->wchFilename); - //eTitleStorageState status=StorageManager.TMSPP_ReadFile(ProfileManager.GetPrimaryPad(),pCurrent->eStorageFacility,pCurrent->eFileTypeVal,pCurrent->wchFilename,pCurrent->CallbackFunc,this,0); - if(0)//wcscmp(pCurrent->wchFilename,L"TP01.png")==0) - { - // TP01 fails because the blob size returned is bigger than the global metadata says it should be - status=eTitleStorage_readerror; - } - else - { - status=StorageManager.TMSPP_ReadFile(ProfileManager.GetPrimaryPad(),pCurrent->eStorageFacility,pCurrent->eFileTypeVal,pCurrent->wchFilename,pCurrent->CallbackFunc,this,0); - } - switch(status) - { - case eTitleStorage_pending: - pCurrent->eState=e_TMS_ContentState_Retrieving; - break; - case eTitleStorage_idle: - pCurrent->eState=e_TMS_ContentState_Retrieved; - break; - case eTitleStorage_busy: - // try again next time - { - app.DebugPrintf("@@@@@@@@@@@@@@@@@ TMSPP_ReadFile failed - busy (probably reading already)\n"); - Sleep(50); - LeaveCriticalSection(&csTMSPPDownloadQueue); - return false; - } - break; - default: - pCurrent->eState=e_TMS_ContentState_Retrieved; - break; - } + eTitleStorageState status; + app.DebugPrintf("RetrieveNextTMSPPContent - type = %d, %ls\n", + pCurrent->eType, pCurrent->wchFilename); + // eTitleStorageState + // status=StorageManager.TMSPP_ReadFile(ProfileManager.GetPrimaryPad(),pCurrent->eStorageFacility,pCurrent->eFileTypeVal,pCurrent->wchFilename,pCurrent->CallbackFunc,this,0); + if (0) // wcscmp(pCurrent->wchFilename,L"TP01.png")==0) + { + // TP01 fails because the blob size returned is bigger than the + // global metadata says it should be + status = eTitleStorage_readerror; + } else { + status = StorageManager.TMSPP_ReadFile( + ProfileManager.GetPrimaryPad(), pCurrent->eStorageFacility, + pCurrent->eFileTypeVal, pCurrent->wchFilename, + pCurrent->CallbackFunc, this, 0); + } + switch (status) { + case eTitleStorage_pending: + pCurrent->eState = e_TMS_ContentState_Retrieving; + break; + case eTitleStorage_idle: + pCurrent->eState = e_TMS_ContentState_Retrieved; + break; + case eTitleStorage_busy: + // try again next time + { + app.DebugPrintf( + "@@@@@@@@@@@@@@@@@ TMSPP_ReadFile failed - busy " + "(probably reading already)\n"); + Sleep(50); + LeaveCriticalSection(&csTMSPPDownloadQueue); + return false; + } + break; + default: + pCurrent->eState = e_TMS_ContentState_Retrieved; + break; + } #endif + LeaveCriticalSection(&csTMSPPDownloadQueue); + return true; + } + } - - LeaveCriticalSection(&csTMSPPDownloadQueue); - return true; - } - } - - LeaveCriticalSection(&csTMSPPDownloadQueue); + LeaveCriticalSection(&csTMSPPDownloadQueue); #endif - return false; + return false; } -void CMinecraftApp::TickDLCOffersRetrieved() -{ - if(!m_bAllDLCContentRetrieved) - { - if (!app.RetrieveNextDLCContent()) - { - app.DebugPrintf("[Consoles_App] All content retrieved.\n"); - m_bAllDLCContentRetrieved=true; - } - } +void CMinecraftApp::TickDLCOffersRetrieved() { + if (!m_bAllDLCContentRetrieved) { + if (!app.RetrieveNextDLCContent()) { + app.DebugPrintf("[Consoles_App] All content retrieved.\n"); + m_bAllDLCContentRetrieved = true; + } + } } -void CMinecraftApp::ClearAndResetDLCDownloadQueue() -{ - app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n"); +void CMinecraftApp::ClearAndResetDLCDownloadQueue() { + app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n"); - int iPosition=0; - EnterCriticalSection(&csTMSPPDownloadQueue); - for(AUTO_VAR(it, m_DLCDownloadQueue.begin()); it != m_DLCDownloadQueue.end(); ++it) - { - DLCRequest *pCurrent = *it; + int iPosition = 0; + EnterCriticalSection(&csTMSPPDownloadQueue); + for (AUTO_VAR(it, m_DLCDownloadQueue.begin()); + it != m_DLCDownloadQueue.end(); ++it) { + DLCRequest* pCurrent = *it; - delete pCurrent; - iPosition++; - } - m_DLCDownloadQueue.clear(); - m_bAllDLCContentRetrieved=true; - LeaveCriticalSection(&csTMSPPDownloadQueue); + delete pCurrent; + iPosition++; + } + m_DLCDownloadQueue.clear(); + m_bAllDLCContentRetrieved = true; + LeaveCriticalSection(&csTMSPPDownloadQueue); } -void CMinecraftApp::TickTMSPPFilesRetrieved() -{ - if(m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) - { - if(app.RetrieveNextTMSPPContent()==false) - { - m_bAllTMSContentRetrieved=true; - } - } +void CMinecraftApp::TickTMSPPFilesRetrieved() { + if (m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) { + if (app.RetrieveNextTMSPPContent() == false) { + m_bAllTMSContentRetrieved = true; + } + } } -void CMinecraftApp::ClearTMSPPFilesRetrieved() -{ - int iPosition=0; - EnterCriticalSection(&csTMSPPDownloadQueue); - for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) - { - TMSPPRequest *pCurrent = *it; +void CMinecraftApp::ClearTMSPPFilesRetrieved() { + int iPosition = 0; + EnterCriticalSection(&csTMSPPDownloadQueue); + for (AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); + it != m_TMSPPDownloadQueue.end(); ++it) { + TMSPPRequest* pCurrent = *it; - delete pCurrent; - iPosition++; - } - m_TMSPPDownloadQueue.clear(); - m_bAllTMSContentRetrieved=true; - LeaveCriticalSection(&csTMSPPDownloadQueue); + delete pCurrent; + iPosition++; + } + m_TMSPPDownloadQueue.clear(); + m_bAllTMSContentRetrieved = true; + LeaveCriticalSection(&csTMSPPDownloadQueue); } -int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, std::uint32_t dwType, int iPad) -{ - CMinecraftApp* pClass = (CMinecraftApp *) pParam; +int CMinecraftApp::DLCOffersReturned(void* pParam, int iOfferC, + std::uint32_t dwType, int iPad) { + CMinecraftApp* pClass = (CMinecraftApp*)pParam; - // find the right one in the vector - EnterCriticalSection(&pClass->csTMSPPDownloadQueue); - for(AUTO_VAR(it, pClass->m_DLCDownloadQueue.begin()); it != pClass->m_DLCDownloadQueue.end(); ++it) - { - DLCRequest *pCurrent = *it; + // find the right one in the vector + EnterCriticalSection(&pClass->csTMSPPDownloadQueue); + for (AUTO_VAR(it, pClass->m_DLCDownloadQueue.begin()); + it != pClass->m_DLCDownloadQueue.end(); ++it) { + DLCRequest* pCurrent = *it; - // avatar items are coming back as type Content, so we can't trust the type setting - if(pCurrent->dwType == static_cast(dwType)) - { - pClass->m_iDLCOfferC = iOfferC; - app.DebugPrintf("DLCOffersReturned - type %u, count %d - setting to retrieved\n",dwType,iOfferC); - pCurrent->eState=e_DLC_ContentState_Retrieved; - break; - } - } - LeaveCriticalSection(&pClass->csTMSPPDownloadQueue); - return 0; + // avatar items are coming back as type Content, so we can't trust the + // type setting + if (pCurrent->dwType == static_cast(dwType)) { + pClass->m_iDLCOfferC = iOfferC; + app.DebugPrintf( + "DLCOffersReturned - type %u, count %d - setting to " + "retrieved\n", + dwType, iOfferC); + pCurrent->eState = e_DLC_ContentState_Retrieved; + break; + } + } + LeaveCriticalSection(&pClass->csTMSPPDownloadQueue); + return 0; } -eDLCContentType CMinecraftApp::Find_eDLCContentType(std::uint32_t dwType) -{ - for(int i=0;idwType==m_dwContentTypeA[eType]) && (pCurrent->eState==e_DLC_ContentState_Retrieved)) - { - LeaveCriticalSection(&csDLCDownloadQueue); - return true; - } - } - LeaveCriticalSection(&csDLCDownloadQueue); - return false; + if ((pCurrent->dwType == m_dwContentTypeA[eType]) && + (pCurrent->eState == e_DLC_ContentState_Retrieved)) { + LeaveCriticalSection(&csDLCDownloadQueue); + return true; + } + } + LeaveCriticalSection(&csDLCDownloadQueue); + return false; } -void CMinecraftApp::SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX *SkinBoxA, unsigned int dwSkinBoxC) -{ - EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - Model *pModel = renderer->getModel(); - std::vector *pvModelPart = new std::vector; - std::vector *pvSkinBoxes = new std::vector; +void CMinecraftApp::SetAdditionalSkinBoxes(std::uint32_t dwSkinID, + SKIN_BOX* SkinBoxA, + unsigned int dwSkinBoxC) { + EntityRenderer* renderer = + EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); + Model* pModel = renderer->getModel(); + std::vector* pvModelPart = new std::vector; + std::vector* pvSkinBoxes = new std::vector; - EnterCriticalSection( &csAdditionalModelParts ); - EnterCriticalSection( &csAdditionalSkinBoxes ); + EnterCriticalSection(&csAdditionalModelParts); + EnterCriticalSection(&csAdditionalSkinBoxes); - app.DebugPrintf("*** SetAdditionalSkinBoxes - Inserting model parts for skin %d from array of Skin Boxes\n",dwSkinID&0x0FFFFFFF); + app.DebugPrintf( + "*** SetAdditionalSkinBoxes - Inserting model parts for skin %d from " + "array of Skin Boxes\n", + dwSkinID & 0x0FFFFFFF); - // convert the skin boxes into model parts, and add to the humanoid model - for(unsigned int i=0;iAddOrRetrievePart(&SkinBoxA[i]); - pvModelPart->push_back(pModelPart); - pvSkinBoxes->push_back(&SkinBoxA[i]); - } - } + // convert the skin boxes into model parts, and add to the humanoid model + for (unsigned int i = 0; i < dwSkinBoxC; i++) { + if (pModel) { + ModelPart* pModelPart = pModel->AddOrRetrievePart(&SkinBoxA[i]); + pvModelPart->push_back(pModelPart); + pvSkinBoxes->push_back(&SkinBoxA[i]); + } + } + m_AdditionalModelParts.insert( + std::pair*>(dwSkinID, + pvModelPart)); + m_AdditionalSkinBoxes.insert( + std::pair*>(dwSkinID, + pvSkinBoxes)); - m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); - m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxes) ); - - LeaveCriticalSection( &csAdditionalSkinBoxes ); - LeaveCriticalSection( &csAdditionalModelParts ); - + LeaveCriticalSection(&csAdditionalSkinBoxes); + LeaveCriticalSection(&csAdditionalModelParts); } -std::vector * CMinecraftApp::SetAdditionalSkinBoxes(std::uint32_t dwSkinID, std::vector *pvSkinBoxA) -{ - EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - Model *pModel = renderer->getModel(); - std::vector *pvModelPart = new std::vector; +std::vector* CMinecraftApp::SetAdditionalSkinBoxes( + std::uint32_t dwSkinID, std::vector* pvSkinBoxA) { + EntityRenderer* renderer = + EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); + Model* pModel = renderer->getModel(); + std::vector* pvModelPart = new std::vector; - EnterCriticalSection( &csAdditionalModelParts ); - EnterCriticalSection( &csAdditionalSkinBoxes ); - app.DebugPrintf("*** SetAdditionalSkinBoxes - Inserting model parts for skin %d from array of Skin Boxes\n",dwSkinID&0x0FFFFFFF); + EnterCriticalSection(&csAdditionalModelParts); + EnterCriticalSection(&csAdditionalSkinBoxes); + app.DebugPrintf( + "*** SetAdditionalSkinBoxes - Inserting model parts for skin %d from " + "array of Skin Boxes\n", + dwSkinID & 0x0FFFFFFF); - // convert the skin boxes into model parts, and add to the humanoid model - for(AUTO_VAR(it, pvSkinBoxA->begin());it != pvSkinBoxA->end(); ++it) - { - if(pModel) - { - ModelPart *pModelPart=pModel->AddOrRetrievePart(*it); - pvModelPart->push_back(pModelPart); - } - } + // convert the skin boxes into model parts, and add to the humanoid model + for (AUTO_VAR(it, pvSkinBoxA->begin()); it != pvSkinBoxA->end(); ++it) { + if (pModel) { + ModelPart* pModelPart = pModel->AddOrRetrievePart(*it); + pvModelPart->push_back(pModelPart); + } + } - m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); - m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxA) ); + m_AdditionalModelParts.insert( + std::pair*>(dwSkinID, + pvModelPart)); + m_AdditionalSkinBoxes.insert( + std::pair*>(dwSkinID, + pvSkinBoxA)); - LeaveCriticalSection( &csAdditionalSkinBoxes ); - LeaveCriticalSection( &csAdditionalModelParts ); - return pvModelPart; + LeaveCriticalSection(&csAdditionalSkinBoxes); + LeaveCriticalSection(&csAdditionalModelParts); + return pvModelPart; } +std::vector* CMinecraftApp::GetAdditionalModelParts( + std::uint32_t dwSkinID) { + EnterCriticalSection(&csAdditionalModelParts); + std::vector* pvModelParts = NULL; + if (m_AdditionalModelParts.size() > 0) { + AUTO_VAR(it, m_AdditionalModelParts.find(dwSkinID)); + if (it != m_AdditionalModelParts.end()) { + pvModelParts = (*it).second; + } + } -std::vector *CMinecraftApp::GetAdditionalModelParts(std::uint32_t dwSkinID) -{ - EnterCriticalSection( &csAdditionalModelParts ); - std::vector *pvModelParts=NULL; - if(m_AdditionalModelParts.size()>0) - { - AUTO_VAR(it, m_AdditionalModelParts.find(dwSkinID)); - if(it!=m_AdditionalModelParts.end()) - { - pvModelParts = (*it).second; - } - } - - LeaveCriticalSection( &csAdditionalModelParts ); - return pvModelParts; + LeaveCriticalSection(&csAdditionalModelParts); + return pvModelParts; } -std::vector *CMinecraftApp::GetAdditionalSkinBoxes(std::uint32_t dwSkinID) -{ - EnterCriticalSection( &csAdditionalSkinBoxes ); - std::vector *pvSkinBoxes=NULL; - if(m_AdditionalSkinBoxes.size()>0) - { - AUTO_VAR(it,m_AdditionalSkinBoxes.find(dwSkinID)); - if(it!=m_AdditionalSkinBoxes.end()) - { - pvSkinBoxes = (*it).second; - } - } - - LeaveCriticalSection( &csAdditionalSkinBoxes ); - return pvSkinBoxes; +std::vector* CMinecraftApp::GetAdditionalSkinBoxes( + std::uint32_t dwSkinID) { + EnterCriticalSection(&csAdditionalSkinBoxes); + std::vector* pvSkinBoxes = NULL; + if (m_AdditionalSkinBoxes.size() > 0) { + AUTO_VAR(it, m_AdditionalSkinBoxes.find(dwSkinID)); + if (it != m_AdditionalSkinBoxes.end()) { + pvSkinBoxes = (*it).second; + } + } + + LeaveCriticalSection(&csAdditionalSkinBoxes); + return pvSkinBoxes; } -unsigned int CMinecraftApp::GetAnimOverrideBitmask(std::uint32_t dwSkinID) -{ - EnterCriticalSection( &csAnimOverrideBitmask ); - unsigned int uiAnimOverrideBitmask=0L; +unsigned int CMinecraftApp::GetAnimOverrideBitmask(std::uint32_t dwSkinID) { + EnterCriticalSection(&csAnimOverrideBitmask); + unsigned int uiAnimOverrideBitmask = 0L; - if(m_AnimOverrides.size()>0) - { - AUTO_VAR(it, m_AnimOverrides.find(dwSkinID)); - if(it!=m_AnimOverrides.end()) - { - uiAnimOverrideBitmask = (*it).second; - } - } + if (m_AnimOverrides.size() > 0) { + AUTO_VAR(it, m_AnimOverrides.find(dwSkinID)); + if (it != m_AnimOverrides.end()) { + uiAnimOverrideBitmask = (*it).second; + } + } - LeaveCriticalSection( &csAnimOverrideBitmask ); - return uiAnimOverrideBitmask; + LeaveCriticalSection(&csAnimOverrideBitmask); + return uiAnimOverrideBitmask; } -void CMinecraftApp::SetAnimOverrideBitmask(std::uint32_t dwSkinID,unsigned int uiAnimOverrideBitmask) -{ - // Make thread safe - EnterCriticalSection( &csAnimOverrideBitmask ); +void CMinecraftApp::SetAnimOverrideBitmask(std::uint32_t dwSkinID, + unsigned int uiAnimOverrideBitmask) { + // Make thread safe + EnterCriticalSection(&csAnimOverrideBitmask); - if(m_AnimOverrides.size()>0) - { - AUTO_VAR(it, m_AnimOverrides.find(dwSkinID)); - if(it!=m_AnimOverrides.end()) - { - LeaveCriticalSection( &csAnimOverrideBitmask ); - return; // already in here - } - } - m_AnimOverrides.insert( std::pair(dwSkinID, uiAnimOverrideBitmask) ); - LeaveCriticalSection( &csAnimOverrideBitmask ); + if (m_AnimOverrides.size() > 0) { + AUTO_VAR(it, m_AnimOverrides.find(dwSkinID)); + if (it != m_AnimOverrides.end()) { + LeaveCriticalSection(&csAnimOverrideBitmask); + return; // already in here + } + } + m_AnimOverrides.insert(std::pair( + dwSkinID, uiAnimOverrideBitmask)); + LeaveCriticalSection(&csAnimOverrideBitmask); } -std::uint32_t CMinecraftApp::getSkinIdFromPath(const std::wstring &skin) -{ - bool dlcSkin = false; - unsigned int skinId = 0; - - if(skin.size() >= 14) - { - dlcSkin = skin.substr(0,3).compare(L"dlc") == 0; +std::uint32_t CMinecraftApp::getSkinIdFromPath(const std::wstring& skin) { + bool dlcSkin = false; + unsigned int skinId = 0; - std::wstring skinValue = skin.substr(7,skin.size()); - skinValue = skinValue.substr(0,skinValue.find_first_of(L'.')); - - std::wstringstream ss; - // 4J Stu - dlc skins are numbered using decimal to make it easier for artists/people to number manually - // Everything else is numbered using hex - if(dlcSkin) - ss << std::dec << skinValue.c_str(); - else - ss << std::hex << skinValue.c_str(); - ss >> skinId; + if (skin.size() >= 14) { + dlcSkin = skin.substr(0, 3).compare(L"dlc") == 0; - skinId = MAKE_SKIN_BITMASK(dlcSkin, skinId); - } - return skinId; + std::wstring skinValue = skin.substr(7, skin.size()); + skinValue = skinValue.substr(0, skinValue.find_first_of(L'.')); + + std::wstringstream ss; + // 4J Stu - dlc skins are numbered using decimal to make it easier for + // artists/people to number manually Everything else is numbered using + // hex + if (dlcSkin) + ss << std::dec << skinValue.c_str(); + else + ss << std::hex << skinValue.c_str(); + ss >> skinId; + + skinId = MAKE_SKIN_BITMASK(dlcSkin, skinId); + } + return skinId; } -std::wstring CMinecraftApp::getSkinPathFromId(std::uint32_t skinId) -{ - // 4J Stu - This function maps the encoded DWORD we store in the player profile - // to a filename that is stored as a memory texture and shared between systems in game - wchar_t chars[256]; - if( GET_IS_DLC_SKIN_FROM_BITMASK(skinId) ) - { - // 4J Stu - DLC skins are numbered using decimal rather than hex to make it easier to number manually - swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(skinId)); - - } - else - { - std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId); - std::uint32_t defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); - if( ugcSkinIndex == 0 ) - { - swprintf(chars, 256, L"defskin%08X.png",defaultSkinIndex); - } - else - { - swprintf(chars, 256, L"ugcskin%08X.png",ugcSkinIndex); - } - } - return chars; +std::wstring CMinecraftApp::getSkinPathFromId(std::uint32_t skinId) { + // 4J Stu - This function maps the encoded DWORD we store in the player + // profile to a filename that is stored as a memory texture and shared + // between systems in game + wchar_t chars[256]; + if (GET_IS_DLC_SKIN_FROM_BITMASK(skinId)) { + // 4J Stu - DLC skins are numbered using decimal rather than hex to make + // it easier to number manually + swprintf(chars, 256, L"dlcskin%08d.png", + GET_DLC_SKIN_ID_FROM_BITMASK(skinId)); + + } else { + std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId); + std::uint32_t defaultSkinIndex = + GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); + if (ugcSkinIndex == 0) { + swprintf(chars, 256, L"defskin%08X.png", defaultSkinIndex); + } else { + swprintf(chars, 256, L"ugcskin%08X.png", ugcSkinIndex); + } + } + return chars; } - -int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ +int CMinecraftApp::TexturePackDialogReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result) { #ifdef _XBOX - if(result!=C4JStorage::EMessage_Cancelled) - { - if(app.GetRequiredTexturePackID()!=0) - { - // we need to enable background downloading for the DLC - XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); + if (result != C4JStorage::EMessage_Cancelled) { + if (app.GetRequiredTexturePackID() != 0) { + // we need to enable background downloading for the DLC + XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); - ULONGLONG ullOfferID_Full; - ULONGLONG ullIndexA[1]; - app.GetDLCFullOfferIDForPackID(app.GetRequiredTexturePackID(),&ullOfferID_Full); + ULONGLONG ullOfferID_Full; + ULONGLONG ullIndexA[1]; + app.GetDLCFullOfferIDForPackID(app.GetRequiredTexturePackID(), + &ullOfferID_Full); - if( result==C4JStorage::EMessage_ResultAccept ) // Full version - { - ullIndexA[0]=ullOfferID_Full; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); - } - else // trial version - { - DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full); - ullIndexA[0]=pDLCInfo->ullOfferID_Trial; - StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); - } - } - } + if (result == C4JStorage::EMessage_ResultAccept) // Full version + { + ullIndexA[0] = ullOfferID_Full; + StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); + } else // trial version + { + DLC_INFO* pDLCInfo = + app.GetDLCInfoForFullOfferID(ullOfferID_Full); + ullIndexA[0] = pDLCInfo->ullOfferID_Trial; + StorageManager.InstallOffer(1, ullIndexA, NULL, NULL); + } + } + } #endif - return 0; + return 0; } -int CMinecraftApp::getArchiveFileSize(const std::wstring &filename) -{ - TexturePack *tPack = NULL; - Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); - if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) - { - return tPack->getArchiveFile()->getFileSize(filename); - } - else return m_mediaArchive->getFileSize(filename); +int CMinecraftApp::getArchiveFileSize(const std::wstring& filename) { + TexturePack* tPack = NULL; + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft && pMinecraft->skins) + tPack = pMinecraft->skins->getSelected(); + if (tPack && tPack->hasData() && tPack->getArchiveFile() && + tPack->getArchiveFile()->hasFile(filename)) { + return tPack->getArchiveFile()->getFileSize(filename); + } else + return m_mediaArchive->getFileSize(filename); } -bool CMinecraftApp::hasArchiveFile(const std::wstring &filename) -{ - TexturePack *tPack = NULL; - Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); - if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) return true; - else return m_mediaArchive->hasFile(filename); +bool CMinecraftApp::hasArchiveFile(const std::wstring& filename) { + TexturePack* tPack = NULL; + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft && pMinecraft->skins) + tPack = pMinecraft->skins->getSelected(); + if (tPack && tPack->hasData() && tPack->getArchiveFile() && + tPack->getArchiveFile()->hasFile(filename)) + return true; + else + return m_mediaArchive->hasFile(filename); } -byteArray CMinecraftApp::getArchiveFile(const std::wstring &filename) -{ - TexturePack *tPack = NULL; - Minecraft *pMinecraft = Minecraft::GetInstance(); - if(pMinecraft && pMinecraft->skins) tPack = pMinecraft->skins->getSelected(); - if(tPack && tPack->hasData() && tPack->getArchiveFile() && tPack->getArchiveFile()->hasFile(filename)) - { - return tPack->getArchiveFile()->getFile(filename); - } - else return m_mediaArchive->getFile(filename); +byteArray CMinecraftApp::getArchiveFile(const std::wstring& filename) { + TexturePack* tPack = NULL; + Minecraft* pMinecraft = Minecraft::GetInstance(); + if (pMinecraft && pMinecraft->skins) + tPack = pMinecraft->skins->getSelected(); + if (tPack && tPack->hasData() && tPack->getArchiveFile() && + tPack->getArchiveFile()->hasFile(filename)) { + return tPack->getArchiveFile()->getFile(filename); + } else + return m_mediaArchive->getFile(filename); } // DLC -#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) -int CMinecraftApp::GetDLCInfoCount() -{ - return (int)DLCInfo.size(); -} +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) +int CMinecraftApp::GetDLCInfoCount() { return (int)DLCInfo.size(); } #elif defined _XBOX_ONE -int CMinecraftApp::GetDLCInfoTrialOffersCount() -{ - return 0; -} +int CMinecraftApp::GetDLCInfoTrialOffersCount() { return 0; } -int CMinecraftApp::GetDLCInfoFullOffersCount() -{ - return (int)DLCInfo_Full.size(); +int CMinecraftApp::GetDLCInfoFullOffersCount() { + return (int)DLCInfo_Full.size(); } #else -int CMinecraftApp::GetDLCInfoTrialOffersCount() -{ - return (int)DLCInfo_Trial.size(); +int CMinecraftApp::GetDLCInfoTrialOffersCount() { + return (int)DLCInfo_Trial.size(); } -int CMinecraftApp::GetDLCInfoFullOffersCount() -{ - return (int)DLCInfo_Full.size(); +int CMinecraftApp::GetDLCInfoFullOffersCount() { + return (int)DLCInfo_Full.size(); } #endif -int CMinecraftApp::GetDLCInfoTexturesOffersCount() -{ - return (int)DLCTextures_PackID.size(); +int CMinecraftApp::GetDLCInfoTexturesOffersCount() { + return (int)DLCTextures_PackID.size(); } // AUTOSAVE -void CMinecraftApp::SetAutosaveTimerTime(void) -{ +void CMinecraftApp::SetAutosaveTimerTime(void) { #if defined(_XBOX_ONE) || defined(__ORBIS__) - m_uiAutosaveTimer= GetTickCount()+1000*60; + m_uiAutosaveTimer = GetTickCount() + 1000 * 60; #else - m_uiAutosaveTimer= GetTickCount()+GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_Autosave)*1000*60*15; + m_uiAutosaveTimer = + GetTickCount() + + GetGameSettings(ProfileManager.GetPrimaryPad(), eGameSetting_Autosave) * + 1000 * 60 * 15; #endif -}// value x 15 to get mins, x60 for secs +} // value x 15 to get mins, x60 for secs -bool CMinecraftApp::AutosaveDue(void) -{ - return (GetTickCount()>m_uiAutosaveTimer); +bool CMinecraftApp::AutosaveDue(void) { + return (GetTickCount() > m_uiAutosaveTimer); } -unsigned int CMinecraftApp::SecondsToAutosave() -{ - return (m_uiAutosaveTimer - GetTickCount() ) / 1000; +unsigned int CMinecraftApp::SecondsToAutosave() { + return (m_uiAutosaveTimer - GetTickCount()) / 1000; } -void CMinecraftApp::SetTrialTimerStart(void) -{ - m_fTrialTimerStart=m_Time.fAppTime; mfTrialPausedTime=0.0f; +void CMinecraftApp::SetTrialTimerStart(void) { + m_fTrialTimerStart = m_Time.fAppTime; + mfTrialPausedTime = 0.0f; } -float CMinecraftApp::getTrialTimer(void) -{ - return m_Time.fAppTime-m_fTrialTimerStart-mfTrialPausedTime; +float CMinecraftApp::getTrialTimer(void) { + return m_Time.fAppTime - m_fTrialTimerStart - mfTrialPausedTime; } -bool CMinecraftApp::IsLocalMultiplayerAvailable() -{ - unsigned int connectedControllers = 0; - for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - { - if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; - } +bool CMinecraftApp::IsLocalMultiplayerAvailable() { + unsigned int connectedControllers = 0; + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { + if (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) + ++connectedControllers; + } - bool available = RenderManager.IsHiDef() && connectedControllers > 1; + bool available = RenderManager.IsHiDef() && connectedControllers > 1; #ifdef __ORBIS__ - // Check for remote play - available = available && InputManager.IsLocalMultiplayerAvailable(); + // Check for remote play + available = available && InputManager.IsLocalMultiplayerAvailable(); #endif - return available; + return available; - // Found this in GameNetworkManager? - //#ifdef _DURANGO - // iOtherConnectedControllers = InputManager.GetConnectedGamepadCount(); - // if((InputManager.IsPadConnected(userIndex) || ProfileManager.IsSignedIn(userIndex))) - // { - // --iOtherConnectedControllers; - // } - //#else - // for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) - // { - // if( (i!=userIndex) && (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) ) - // { - // iOtherConnectedControllers++; - // } - // } - //#endif + // Found this in GameNetworkManager? + // #ifdef _DURANGO + // iOtherConnectedControllers = + //InputManager.GetConnectedGamepadCount(); + // if((InputManager.IsPadConnected(userIndex) || + //ProfileManager.IsSignedIn(userIndex))) + // { + // --iOtherConnectedControllers; + // } + // #else + // for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) + // { + // if( (i!=userIndex) && (InputManager.IsPadConnected(i) || + //ProfileManager.IsSignedIn(i)) ) + // { + // iOtherConnectedControllers++; + // } + // } + // #endif } - // 4J-PB - language and locale function -void CMinecraftApp::getLocale(std::vector &vecWstrLocales) -{ - std::vector locales; - - const unsigned int systemLanguage = XGetLanguage( ); +void CMinecraftApp::getLocale(std::vector& vecWstrLocales) { + std::vector locales; - // 4J-PB - restrict the 360 language until we're ready to have them in + const unsigned int systemLanguage = XGetLanguage(); + + // 4J-PB - restrict the 360 language until we're ready to have them in #ifdef _XBOX - switch(systemLanguage) - { - case XC_LANGUAGE_FRENCH : - locales.push_back(eMCLang_frFR); - break; - case XC_LANGUAGE_ITALIAN : - locales.push_back(eMCLang_itIT); - break; - case XC_LANGUAGE_GERMAN : - locales.push_back(eMCLang_deDE); - break; - case XC_LANGUAGE_SPANISH : - locales.push_back(eMCLang_esES); - break; - case XC_LANGUAGE_PORTUGUESE : - if(XGetLocale()==XC_LOCALE_BRAZIL) - { - locales.push_back(eMCLang_ptBR); - } - locales.push_back(eMCLang_ptPT); - break; - case XC_LANGUAGE_JAPANESE : - locales.push_back(eMCLang_jaJP); - break; - case XC_LANGUAGE_KOREAN : - locales.push_back(eMCLang_koKR); - break; - case XC_LANGUAGE_TCHINESE : - locales.push_back(eMCLang_zhCHT); - break; - } + switch (systemLanguage) { + case XC_LANGUAGE_FRENCH: + locales.push_back(eMCLang_frFR); + break; + case XC_LANGUAGE_ITALIAN: + locales.push_back(eMCLang_itIT); + break; + case XC_LANGUAGE_GERMAN: + locales.push_back(eMCLang_deDE); + break; + case XC_LANGUAGE_SPANISH: + locales.push_back(eMCLang_esES); + break; + case XC_LANGUAGE_PORTUGUESE: + if (XGetLocale() == XC_LOCALE_BRAZIL) { + locales.push_back(eMCLang_ptBR); + } + locales.push_back(eMCLang_ptPT); + break; + case XC_LANGUAGE_JAPANESE: + locales.push_back(eMCLang_jaJP); + break; + case XC_LANGUAGE_KOREAN: + locales.push_back(eMCLang_koKR); + break; + case XC_LANGUAGE_TCHINESE: + locales.push_back(eMCLang_zhCHT); + break; + } #else - switch(systemLanguage) - { + switch (systemLanguage) { + case XC_LANGUAGE_ENGLISH: + switch (XGetLocale()) { + case XC_LOCALE_AUSTRALIA: + case XC_LOCALE_CANADA: + case XC_LOCALE_CZECH_REPUBLIC: + case XC_LOCALE_GREECE: + case XC_LOCALE_HONG_KONG: + case XC_LOCALE_HUNGARY: + case XC_LOCALE_INDIA: + case XC_LOCALE_IRELAND: + case XC_LOCALE_ISRAEL: + case XC_LOCALE_NEW_ZEALAND: + case XC_LOCALE_SAUDI_ARABIA: + case XC_LOCALE_SINGAPORE: + case XC_LOCALE_SLOVAK_REPUBLIC: + case XC_LOCALE_SOUTH_AFRICA: + case XC_LOCALE_UNITED_ARAB_EMIRATES: + case XC_LOCALE_GREAT_BRITAIN: + locales.push_back(eMCLang_enGB); + break; + default: // XC_LOCALE_UNITED_STATES + break; + } + break; + case XC_LANGUAGE_JAPANESE: + locales.push_back(eMCLang_jaJP); + break; + case XC_LANGUAGE_GERMAN: + switch (XGetLocale()) { + case XC_LOCALE_AUSTRIA: + locales.push_back(eMCLang_deAT); + break; + case XC_LOCALE_SWITZERLAND: + locales.push_back(eMCLang_deCH); + break; + default: // XC_LOCALE_GERMANY: + break; + } + locales.push_back(eMCLang_deDE); + break; + case XC_LANGUAGE_FRENCH: + switch (XGetLocale()) { + case XC_LOCALE_BELGIUM: + locales.push_back(eMCLang_frBE); + break; + case XC_LOCALE_CANADA: + locales.push_back(eMCLang_frCA); + break; + case XC_LOCALE_SWITZERLAND: + locales.push_back(eMCLang_frCH); + break; + default: // XC_LOCALE_FRANCE: + break; + } + locales.push_back(eMCLang_frFR); + break; + case XC_LANGUAGE_SPANISH: + switch (XGetLocale()) { + case XC_LOCALE_MEXICO: + case XC_LOCALE_ARGENTINA: + case XC_LOCALE_CHILE: + case XC_LOCALE_COLOMBIA: + case XC_LOCALE_UNITED_STATES: + locales.push_back(eMCLang_esMX); + break; + default: // XC_LOCALE_SPAIN + break; + } + locales.push_back(eMCLang_esES); + break; + case XC_LANGUAGE_ITALIAN: + locales.push_back(eMCLang_itIT); + break; + case XC_LANGUAGE_KOREAN: + locales.push_back(eMCLang_koKR); + break; + case XC_LANGUAGE_TCHINESE: + switch (XGetLocale()) { + case XC_LOCALE_HONG_KONG: + locales.push_back(eMCLang_zhHK); + locales.push_back(eMCLang_zhTW); + break; + case XC_LOCALE_TAIWAN: + locales.push_back(eMCLang_zhTW); + locales.push_back(eMCLang_zhHK); + default: + break; + } + locales.push_back(eMCLang_zhCHT); + break; + case XC_LANGUAGE_PORTUGUESE: + if (XGetLocale() == XC_LOCALE_BRAZIL) { + locales.push_back(eMCLang_ptBR); + } + locales.push_back(eMCLang_ptPT); + break; + case XC_LANGUAGE_POLISH: + locales.push_back(eMCLang_plPL); + break; + case XC_LANGUAGE_RUSSIAN: + locales.push_back(eMCLang_ruRU); + break; + case XC_LANGUAGE_SWEDISH: + locales.push_back(eMCLang_svSV); + locales.push_back(eMCLang_svSE); + break; + case XC_LANGUAGE_TURKISH: + locales.push_back(eMCLang_trTR); + break; + case XC_LANGUAGE_BNORWEGIAN: + locales.push_back(eMCLang_nbNO); + locales.push_back(eMCLang_noNO); + locales.push_back(eMCLang_nnNO); + break; + case XC_LANGUAGE_DUTCH: + switch (XGetLocale()) { + case XC_LOCALE_BELGIUM: + locales.push_back(eMCLang_nlBE); + break; + default: + break; + } + locales.push_back(eMCLang_nlNL); + break; + case XC_LANGUAGE_SCHINESE: + switch (XGetLocale()) { + case XC_LOCALE_SINGAPORE: + locales.push_back(eMCLang_zhSG); + break; + default: + break; + } + locales.push_back(eMCLang_zhCHS); + locales.push_back(eMCLang_zhCN); + break; - case XC_LANGUAGE_ENGLISH: - switch(XGetLocale()) - { - case XC_LOCALE_AUSTRALIA: - case XC_LOCALE_CANADA: - case XC_LOCALE_CZECH_REPUBLIC: - case XC_LOCALE_GREECE: - case XC_LOCALE_HONG_KONG: - case XC_LOCALE_HUNGARY: - case XC_LOCALE_INDIA: - case XC_LOCALE_IRELAND: - case XC_LOCALE_ISRAEL: - case XC_LOCALE_NEW_ZEALAND: - case XC_LOCALE_SAUDI_ARABIA: - case XC_LOCALE_SINGAPORE: - case XC_LOCALE_SLOVAK_REPUBLIC: - case XC_LOCALE_SOUTH_AFRICA: - case XC_LOCALE_UNITED_ARAB_EMIRATES: - case XC_LOCALE_GREAT_BRITAIN: - locales.push_back(eMCLang_enGB); - break; - default: //XC_LOCALE_UNITED_STATES - break; - } - break; - case XC_LANGUAGE_JAPANESE : - locales.push_back(eMCLang_jaJP); - break; - case XC_LANGUAGE_GERMAN : - switch(XGetLocale()) - { - case XC_LOCALE_AUSTRIA: - locales.push_back(eMCLang_deAT); - break; - case XC_LOCALE_SWITZERLAND: - locales.push_back(eMCLang_deCH); - break; - default:// XC_LOCALE_GERMANY: - break; - } - locales.push_back(eMCLang_deDE); - break; - case XC_LANGUAGE_FRENCH : - switch(XGetLocale()) - { - case XC_LOCALE_BELGIUM: - locales.push_back(eMCLang_frBE); - break; - case XC_LOCALE_CANADA: - locales.push_back(eMCLang_frCA); - break; - case XC_LOCALE_SWITZERLAND: - locales.push_back(eMCLang_frCH); - break; - default:// XC_LOCALE_FRANCE: - break; - } - locales.push_back(eMCLang_frFR); - break; - case XC_LANGUAGE_SPANISH : - switch(XGetLocale()) - { - case XC_LOCALE_MEXICO: - case XC_LOCALE_ARGENTINA: - case XC_LOCALE_CHILE: - case XC_LOCALE_COLOMBIA: - case XC_LOCALE_UNITED_STATES: - locales.push_back(eMCLang_esMX); - break; - default://XC_LOCALE_SPAIN - break; - } - locales.push_back(eMCLang_esES); - break; - case XC_LANGUAGE_ITALIAN : - locales.push_back(eMCLang_itIT); - break; - case XC_LANGUAGE_KOREAN : - locales.push_back(eMCLang_koKR); - break; - case XC_LANGUAGE_TCHINESE : - switch(XGetLocale()) - { - case XC_LOCALE_HONG_KONG: - locales.push_back(eMCLang_zhHK); - locales.push_back(eMCLang_zhTW); - break; - case XC_LOCALE_TAIWAN: - locales.push_back(eMCLang_zhTW); - locales.push_back(eMCLang_zhHK); - default: - break; - } - locales.push_back(eMCLang_zhCHT); - break; - case XC_LANGUAGE_PORTUGUESE : - if(XGetLocale()==XC_LOCALE_BRAZIL) - { - locales.push_back(eMCLang_ptBR); - } - locales.push_back(eMCLang_ptPT); - break; - case XC_LANGUAGE_POLISH : - locales.push_back(eMCLang_plPL); - break; - case XC_LANGUAGE_RUSSIAN : - locales.push_back(eMCLang_ruRU); - break; - case XC_LANGUAGE_SWEDISH : - locales.push_back(eMCLang_svSV); - locales.push_back(eMCLang_svSE); - break; - case XC_LANGUAGE_TURKISH : - locales.push_back(eMCLang_trTR); - break; - case XC_LANGUAGE_BNORWEGIAN : - locales.push_back(eMCLang_nbNO); - locales.push_back(eMCLang_noNO); - locales.push_back(eMCLang_nnNO); - break; - case XC_LANGUAGE_DUTCH : - switch(XGetLocale()) - { - case XC_LOCALE_BELGIUM: - locales.push_back(eMCLang_nlBE); - break; - default: - break; - } - locales.push_back(eMCLang_nlNL); - break; - case XC_LANGUAGE_SCHINESE : - switch(XGetLocale()) - { - case XC_LOCALE_SINGAPORE: - locales.push_back(eMCLang_zhSG); - break; - default: - break; - } - locales.push_back(eMCLang_zhCHS); - locales.push_back(eMCLang_zhCN); - break; +#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || \ + defined _DURANGO + case XC_LANGUAGE_DANISH: + locales.push_back(eMCLang_daDA); + locales.push_back(eMCLang_daDK); + break; + case XC_LANGUAGE_LATINAMERICANSPANISH: + locales.push_back(eMCLang_laLAS); + locales.push_back(eMCLang_esES); + break; -#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO - case XC_LANGUAGE_DANISH: - locales.push_back(eMCLang_daDA); - locales.push_back(eMCLang_daDK); - break; + case XC_LANGUAGE_FINISH: + locales.push_back(eMCLang_fiFI); + break; - case XC_LANGUAGE_LATINAMERICANSPANISH: - locales.push_back(eMCLang_laLAS); - locales.push_back(eMCLang_esES); - break; + case XC_LANGUAGE_CZECH: + locales.push_back(eMCLang_csCZ); + locales.push_back(eMCLang_enCZ); + break; - case XC_LANGUAGE_FINISH : - locales.push_back(eMCLang_fiFI); - break; + case XC_LANGUAGE_SLOVAK: + locales.push_back(eMCLang_skSK); + locales.push_back(eMCLang_enSK); + break; - case XC_LANGUAGE_CZECH : - locales.push_back(eMCLang_csCZ); - locales.push_back(eMCLang_enCZ); - break; - - case XC_LANGUAGE_SLOVAK : - locales.push_back(eMCLang_skSK); - locales.push_back(eMCLang_enSK); - break; - - case XC_LANGUAGE_GREEK : - locales.push_back(eMCLang_elEL); - locales.push_back(eMCLang_elGR); - locales.push_back(eMCLang_enGR); - locales.push_back(eMCLang_enGB); - break; + case XC_LANGUAGE_GREEK: + locales.push_back(eMCLang_elEL); + locales.push_back(eMCLang_elGR); + locales.push_back(eMCLang_enGR); + locales.push_back(eMCLang_enGB); + break; #endif - } + } #endif - locales.push_back(eMCLang_enUS); - locales.push_back(eMCLang_null); + locales.push_back(eMCLang_enUS); + locales.push_back(eMCLang_null); - for (int i=0; i -//using namespace std; +// using namespace std; #include "Audio/Consoles_SoundEngine.h" #ifndef __linux__ @@ -19,7 +19,7 @@ #include "../Minecraft.World/Network/Packets/DisconnectPacket.h" #ifndef __linux__ #include -#endif // __linux__ +#endif // __linux__ #include "../Minecraft.Client/Utils/StringTable.h" #include "DLC/DLCManager.h" @@ -28,13 +28,11 @@ #include "../Minecraft.Client/Rendering/Models/SkinBox.h" #include "../Minecraft.Client/Utils/ArchiveFile.h" -typedef struct _JoinFromInviteData -{ - std::uint32_t dwUserIndex; // dwUserIndex - std::uint32_t dwLocalUsersMask; // dwUserMask - const INVITE_INFO *pInviteInfo; // pInviteInfo -} -JoinFromInviteData; +typedef struct _JoinFromInviteData { + std::uint32_t dwUserIndex; // dwUserIndex + std::uint32_t dwLocalUsersMask; // dwUserMask + const INVITE_INFO* pInviteInfo; // pInviteInfo +} JoinFromInviteData; class Player; class Inventory; @@ -55,254 +53,341 @@ class Merchant; class CMinecraftAudio; -class CMinecraftApp - +class CMinecraftApp #ifdef _XBOX - : public CXuiModule + : public CXuiModule #endif { private: - static int s_iHTMLFontSizesA[eHTMLSize_COUNT]; + static int s_iHTMLFontSizesA[eHTMLSize_COUNT]; public: + CMinecraftApp(); - CMinecraftApp(); + static const float fSafeZoneX; // 5% of 1280 + static const float fSafeZoneY; // 5% of 720 - static const float fSafeZoneX; // 5% of 1280 - static const float fSafeZoneY; // 5% of 720 + typedef std::vector VMEMFILES; + typedef std::vector VNOTIFICATIONS; - typedef std::vector VMEMFILES; - typedef std::vector VNOTIFICATIONS; + // storing skin files + std::vector vSkinNames; + DLCManager m_dlcManager; - // storing skin files - std::vector vSkinNames; - DLCManager m_dlcManager; + // storing credits text from the DLC + std::vector m_vCreditText; // hold the credit text lines so + // we can avoid duplicating them - // storing credits text from the DLC - std::vector m_vCreditText; // hold the credit text lines so we can avoid duplicating them - - - // In builds prior to TU5, the size of the GAME_SETTINGS struct was 204 bytes. We added a few new values to the internal struct in TU5, and even though we - // changed the size of the ucUnused array to be decreased by the size of the values we added, the packing of the struct has introduced some extra - // padding that resulted in the GAME_SETTINGS struct being 208 bytes. The knock-on effect from this was that all the stats, which come after the game settings - // in the profile data, we being read offset by 4 bytes. We need to ensure that the GAME_SETTINGS struct does not grow larger than 204 bytes or if we need it - // to then we need to rebuild the profile data completely and increase the profile version. There should be enough free space to grow larger for a few more updates - // as long as we take into account the padding issues and check that settings are still stored at the same positions when we read them - static const int GAME_SETTINGS_PROFILE_DATA_BYTES = 204; + // In builds prior to TU5, the size of the GAME_SETTINGS struct was 204 + // bytes. We added a few new values to the internal struct in TU5, and even + // though we changed the size of the ucUnused array to be decreased by the + // size of the values we added, the packing of the struct has introduced + // some extra padding that resulted in the GAME_SETTINGS struct being 208 + // bytes. The knock-on effect from this was that all the stats, which come + // after the game settings in the profile data, we being read offset by 4 + // bytes. We need to ensure that the GAME_SETTINGS struct does not grow + // larger than 204 bytes or if we need it to then we need to rebuild the + // profile data completely and increase the profile version. There should be + // enough free space to grow larger for a few more updates as long as we + // take into account the padding issues and check that settings are still + // stored at the same positions when we read them + static const int GAME_SETTINGS_PROFILE_DATA_BYTES = 204; #ifdef _EXTENDED_ACHIEVEMENTS - /* 4J-JEV: - * We need more space in the profile data because of the new achievements and statistics - * necessary for the new expanded achievement set. - */ - static const int GAME_DEFINED_PROFILE_DATA_BYTES = 2*972; // per user + /* 4J-JEV: + * We need more space in the profile data because of the new achievements + * and statistics necessary for the new expanded achievement set. + */ + static const int GAME_DEFINED_PROFILE_DATA_BYTES = 2 * 972; // per user #else - static const int GAME_DEFINED_PROFILE_DATA_BYTES = 972; // per user + static const int GAME_DEFINED_PROFILE_DATA_BYTES = 972; // per user #endif - unsigned int uiGameDefinedDataChangedBitmask; + unsigned int uiGameDefinedDataChangedBitmask; - void DebugPrintf(const char *szFormat, ...); - void DebugPrintfVerbose(bool bVerbose, const char *szFormat, ...); // Conditional printf - void DebugPrintf(int user, const char *szFormat, ...); + void DebugPrintf(const char* szFormat, ...); + void DebugPrintfVerbose(bool bVerbose, const char* szFormat, + ...); // Conditional printf + void DebugPrintf(int user, const char* szFormat, ...); - static const int USER_NONE = 0; // disables printf - static const int USER_GENERAL = 1; - static const int USER_JV = 2; - static const int USER_MH = 3; - static const int USER_PB = 4; - static const int USER_RR = 5; - static const int USER_SR = 6; - static const int USER_UI = 7; // 4J Stu - This also makes it appear on the UI console - - void HandleButtonPresses(); - bool IntroRunning() { return m_bIntroRunning;} - void SetIntroRunning(bool bSet) {m_bIntroRunning=bSet;} + static const int USER_NONE = 0; // disables printf + static const int USER_GENERAL = 1; + static const int USER_JV = 2; + static const int USER_MH = 3; + static const int USER_PB = 4; + static const int USER_RR = 5; + static const int USER_SR = 6; + static const int USER_UI = + 7; // 4J Stu - This also makes it appear on the UI console + + void HandleButtonPresses(); + bool IntroRunning() { return m_bIntroRunning; } + void SetIntroRunning(bool bSet) { m_bIntroRunning = bSet; } #ifdef _CONTENT_PACKAGE #ifndef _FINAL_BUILD - bool PartnernetPasswordRunning() { return m_bPartnernetPasswordRunning;} - void SetPartnernetPasswordRunning(bool bSet) {m_bPartnernetPasswordRunning=bSet;} + bool PartnernetPasswordRunning() { return m_bPartnernetPasswordRunning; } + void SetPartnernetPasswordRunning(bool bSet) { + m_bPartnernetPasswordRunning = bSet; + } #endif #endif - bool IsAppPaused(); - void SetAppPaused(bool val); - static int DisplaySavingMessage(void *pParam,const C4JStorage::ESavingMessage eMsg, int iPad); - bool GetGameStarted() {return m_bGameStarted;} - void SetGameStarted(bool bVal) { if(bVal) DebugPrintf("SetGameStarted - true\n"); else DebugPrintf("SetGameStarted - false\n"); m_bGameStarted = bVal; m_bIsAppPaused = !bVal;} - int GetLocalPlayerCount(void); - bool LoadInventoryMenu(int iPad,std::shared_ptr player, bool bNavigateBack=false); - bool LoadCreativeMenu(int iPad,std::shared_ptr player,bool bNavigateBack=false); - bool LoadEnchantingMenu(int iPad,std::shared_ptr inventory, int x, int y, int z, Level *level); - bool LoadFurnaceMenu(int iPad,std::shared_ptr inventory, std::shared_ptr furnace); - bool LoadBrewingStandMenu(int iPad,std::shared_ptr inventory, std::shared_ptr brewingStand); - bool LoadContainerMenu(int iPad,std::shared_ptr inventory, std::shared_ptr container); - bool LoadTrapMenu(int iPad,std::shared_ptr inventory, std::shared_ptr trap); - bool LoadCrafting2x2Menu(int iPad,std::shared_ptr player); - bool LoadCrafting3x3Menu(int iPad,std::shared_ptr player, int x, int y, int z); - bool LoadSignEntryMenu(int iPad,std::shared_ptr sign); - bool LoadRepairingMenu(int iPad,std::shared_ptr inventory, Level *level, int x, int y, int z); - bool LoadTradingMenu(int iPad, std::shared_ptr inventory, std::shared_ptr trader, Level *level); + bool IsAppPaused(); + void SetAppPaused(bool val); + static int DisplaySavingMessage(void* pParam, + const C4JStorage::ESavingMessage eMsg, + int iPad); + bool GetGameStarted() { return m_bGameStarted; } + void SetGameStarted(bool bVal) { + if (bVal) + DebugPrintf("SetGameStarted - true\n"); + else + DebugPrintf("SetGameStarted - false\n"); + m_bGameStarted = bVal; + m_bIsAppPaused = !bVal; + } + int GetLocalPlayerCount(void); + bool LoadInventoryMenu(int iPad, std::shared_ptr player, + bool bNavigateBack = false); + bool LoadCreativeMenu(int iPad, std::shared_ptr player, + bool bNavigateBack = false); + bool LoadEnchantingMenu(int iPad, std::shared_ptr inventory, + int x, int y, int z, Level* level); + bool LoadFurnaceMenu(int iPad, std::shared_ptr inventory, + std::shared_ptr furnace); + bool LoadBrewingStandMenu( + int iPad, std::shared_ptr inventory, + std::shared_ptr brewingStand); + bool LoadContainerMenu(int iPad, std::shared_ptr inventory, + std::shared_ptr container); + bool LoadTrapMenu(int iPad, std::shared_ptr inventory, + std::shared_ptr trap); + bool LoadCrafting2x2Menu(int iPad, std::shared_ptr player); + bool LoadCrafting3x3Menu(int iPad, std::shared_ptr player, + int x, int y, int z); + bool LoadSignEntryMenu(int iPad, std::shared_ptr sign); + bool LoadRepairingMenu(int iPad, std::shared_ptr inventory, + Level* level, int x, int y, int z); + bool LoadTradingMenu(int iPad, std::shared_ptr inventory, + std::shared_ptr trader, Level* level); - bool GetTutorialMode() { return m_bTutorialMode;} - void SetTutorialMode(bool bSet) {m_bTutorialMode=bSet;} + bool GetTutorialMode() { return m_bTutorialMode; } + void SetTutorialMode(bool bSet) { m_bTutorialMode = bSet; } - void SetSpecialTutorialCompletionFlag(int iPad, int index); + void SetSpecialTutorialCompletionFlag(int iPad, int index); - static const wchar_t * GetString(int iID); + static const wchar_t* GetString(int iID); - eGameMode GetGameMode() { return m_eGameMode;} - void SetGameMode(eGameMode eMode) { m_eGameMode=eMode;} + eGameMode GetGameMode() { return m_eGameMode; } + void SetGameMode(eGameMode eMode) { m_eGameMode = eMode; } - eXuiAction GetGlobalXuiAction() {return m_eGlobalXuiAction;} - void SetGlobalXuiAction(eXuiAction action) {m_eGlobalXuiAction=action;} - eXuiAction GetXuiAction(int iPad) {return m_eXuiAction[iPad];} - void SetAction(int iPad, eXuiAction action, void *param = nullptr); - void SetTMSAction(int iPad, eTMSAction action) {m_eTMSAction[iPad]=action; } - eTMSAction GetTMSAction(int iPad) {return m_eTMSAction[iPad];} - eXuiServerAction GetXuiServerAction(int iPad) {return m_eXuiServerAction[iPad];} - void * GetXuiServerActionParam(int iPad) {return m_eXuiServerActionParam[iPad];} - void SetXuiServerAction(int iPad, eXuiServerAction action, void *param = nullptr) {m_eXuiServerAction[iPad]=action; m_eXuiServerActionParam[iPad] = param;} - eXuiServerAction GetGlobalXuiServerAction() {return m_eGlobalXuiServerAction;} - void SetGlobalXuiServerAction(eXuiServerAction action) {m_eGlobalXuiServerAction=action;} - - DisconnectPacket::eDisconnectReason GetDisconnectReason() { return m_disconnectReason; } - void SetDisconnectReason(DisconnectPacket::eDisconnectReason bVal) { m_disconnectReason = bVal; } + eXuiAction GetGlobalXuiAction() { return m_eGlobalXuiAction; } + void SetGlobalXuiAction(eXuiAction action) { m_eGlobalXuiAction = action; } + eXuiAction GetXuiAction(int iPad) { return m_eXuiAction[iPad]; } + void SetAction(int iPad, eXuiAction action, void* param = nullptr); + void SetTMSAction(int iPad, eTMSAction action) { + m_eTMSAction[iPad] = action; + } + eTMSAction GetTMSAction(int iPad) { return m_eTMSAction[iPad]; } + eXuiServerAction GetXuiServerAction(int iPad) { + return m_eXuiServerAction[iPad]; + } + void* GetXuiServerActionParam(int iPad) { + return m_eXuiServerActionParam[iPad]; + } + void SetXuiServerAction(int iPad, eXuiServerAction action, + void* param = nullptr) { + m_eXuiServerAction[iPad] = action; + m_eXuiServerActionParam[iPad] = param; + } + eXuiServerAction GetGlobalXuiServerAction() { + return m_eGlobalXuiServerAction; + } + void SetGlobalXuiServerAction(eXuiServerAction action) { + m_eGlobalXuiServerAction = action; + } - bool GetChangingSessionType() { return m_bChangingSessionType; } - void SetChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; } + DisconnectPacket::eDisconnectReason GetDisconnectReason() { + return m_disconnectReason; + } + void SetDisconnectReason(DisconnectPacket::eDisconnectReason bVal) { + m_disconnectReason = bVal; + } - bool GetReallyChangingSessionType() { return m_bReallyChangingSessionType; } - void SetReallyChangingSessionType(bool bVal) { m_bReallyChangingSessionType = bVal; } + bool GetChangingSessionType() { return m_bChangingSessionType; } + void SetChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; } + bool GetReallyChangingSessionType() { return m_bReallyChangingSessionType; } + void SetReallyChangingSessionType(bool bVal) { + m_bReallyChangingSessionType = bVal; + } - // 4J Stu - Added so that we can call this when a confirmation box is selected - static void SetActionConfirmed(void *param); - void HandleXuiActions(void); + // 4J Stu - Added so that we can call this when a confirmation box is + // selected + static void SetActionConfirmed(void* param); + void HandleXuiActions(void); - // 4J Stu - Functions used for Minecon and other promo work - bool GetLoadSavesFromFolderEnabled() { return m_bLoadSavesFromFolderEnabled; } - void SetLoadSavesFromFolderEnabled(bool bVal) { m_bLoadSavesFromFolderEnabled = bVal; } + // 4J Stu - Functions used for Minecon and other promo work + bool GetLoadSavesFromFolderEnabled() { + return m_bLoadSavesFromFolderEnabled; + } + void SetLoadSavesFromFolderEnabled(bool bVal) { + m_bLoadSavesFromFolderEnabled = bVal; + } - // 4J Stu - Useful for debugging - bool GetWriteSavesToFolderEnabled() { return m_bWriteSavesToFolderEnabled; } - void SetWriteSavesToFolderEnabled(bool bVal) { m_bWriteSavesToFolderEnabled = bVal; } - bool GetMobsDontAttackEnabled() { return m_bMobsDontAttack; } - void SetMobsDontAttackEnabled(bool bVal) { m_bMobsDontAttack = bVal; } - bool GetUseDPadForDebug() { return m_bUseDPadForDebug; } - void SetUseDPadForDebug(bool bVal) { m_bUseDPadForDebug = bVal; } - bool GetMobsDontTickEnabled() { return m_bMobsDontTick; } - void SetMobsDontTickEnabled(bool bVal) { m_bMobsDontTick = bVal; } + // 4J Stu - Useful for debugging + bool GetWriteSavesToFolderEnabled() { return m_bWriteSavesToFolderEnabled; } + void SetWriteSavesToFolderEnabled(bool bVal) { + m_bWriteSavesToFolderEnabled = bVal; + } + bool GetMobsDontAttackEnabled() { return m_bMobsDontAttack; } + void SetMobsDontAttackEnabled(bool bVal) { m_bMobsDontAttack = bVal; } + bool GetUseDPadForDebug() { return m_bUseDPadForDebug; } + void SetUseDPadForDebug(bool bVal) { m_bUseDPadForDebug = bVal; } + bool GetMobsDontTickEnabled() { return m_bMobsDontTick; } + void SetMobsDontTickEnabled(bool bVal) { m_bMobsDontTick = bVal; } - bool GetFreezePlayers() { return m_bFreezePlayers; } - void SetFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; } + bool GetFreezePlayers() { return m_bFreezePlayers; } + void SetFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; } - // debug -0 show safe area - void ShowSafeArea(bool show) - { + // debug -0 show safe area + void ShowSafeArea(bool show) { #ifdef _XBOX - CXuiSceneBase::ShowSafeArea(show); + CXuiSceneBase::ShowSafeArea(show); #endif - } - // 4J-PB - to capture the social post screenshot - virtual void CaptureScreenshot(int iPad) {}; - //void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE *preview); + } + // 4J-PB - to capture the social post screenshot + virtual void CaptureScreenshot(int iPad) {}; + // void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE + // *preview); - void InitGameSettings(); - static int OldProfileVersionCallback(void *pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad); + void InitGameSettings(); + static int OldProfileVersionCallback(void* pParam, unsigned char* pucData, + const unsigned short usVersion, + const int iPad); -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ ) - static int DefaultOptionsCallback(void *pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad); - int SetDefaultOptions(C4JStorage::PROFILESETTINGS *pSettings,const int iPad,bool bWriteProfile=true); +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + static int DefaultOptionsCallback(void* pParam, + C4JStorage::PROFILESETTINGS* pSettings, + const int iPad); + int SetDefaultOptions(C4JStorage::PROFILESETTINGS* pSettings, + const int iPad, bool bWriteProfile = true); #ifdef __ORBIS__ - static int OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired); - int GetOptionsBlocksRequired(int iPad); + static int OptionsDataCallback(void* pParam, int iPad, + unsigned short usVersion, + C4JStorage::eOptionsCallback eStatus, + int iBlocksRequired); + int GetOptionsBlocksRequired(int iPad); #else - static int OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus); + static int OptionsDataCallback(void* pParam, int iPad, + unsigned short usVersion, + C4JStorage::eOptionsCallback eStatus); #endif - C4JStorage::eOptionsCallback GetOptionsCallbackStatus(int iPad); + C4JStorage::eOptionsCallback GetOptionsCallbackStatus(int iPad); - void SetOptionsCallbackStatus(int iPad, C4JStorage::eOptionsCallback eStatus); + void SetOptionsCallbackStatus(int iPad, + C4JStorage::eOptionsCallback eStatus); #else - static int DefaultOptionsCallback(void *pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad); - int SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,const int iPad); + static int DefaultOptionsCallback(void* pParam, + C_4JProfile::PROFILESETTINGS* pSettings, + const int iPad); + int SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings, + const int iPad); #endif - virtual void SetRichPresenceContext(int iPad, int contextId) = 0; + virtual void SetRichPresenceContext(int iPad, int contextId) = 0; - - 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 SetPlayerSkin(int iPad,const std::wstring &name); - void SetPlayerSkin(int iPad,std::uint32_t dwSkinId); - void SetPlayerCape(int iPad,const std::wstring &name); - void SetPlayerCape(int iPad,std::uint32_t dwCapeId); - void SetPlayerFavoriteSkin(int iPad, int iIndex,unsigned int uiSkinID); - unsigned int GetPlayerFavoriteSkin(int iPad,int iIndex); - unsigned char GetPlayerFavoriteSkinsPos(int iPad); - void SetPlayerFavoriteSkinsPos(int iPad,int iPos); - unsigned int GetPlayerFavoriteSkinsCount(int iPad); - void ValidateFavoriteSkins(int iPad); // check the DLC is available for the skins + 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 SetPlayerSkin(int iPad, const std::wstring& name); + void SetPlayerSkin(int iPad, std::uint32_t dwSkinId); + void SetPlayerCape(int iPad, const std::wstring& name); + void SetPlayerCape(int iPad, std::uint32_t dwCapeId); + void SetPlayerFavoriteSkin(int iPad, int iIndex, unsigned int uiSkinID); + unsigned int GetPlayerFavoriteSkin(int iPad, int iIndex); + unsigned char GetPlayerFavoriteSkinsPos(int iPad); + void SetPlayerFavoriteSkinsPos(int iPad, int iPos); + unsigned int GetPlayerFavoriteSkinsCount(int iPad); + void ValidateFavoriteSkins( + int iPad); // check the DLC is available for the skins - // Mash-up pack worlds hide/display - void HideMashupPackWorld(int iPad, unsigned int iMashupPackID); - void EnableMashupPackWorlds(int iPad); - unsigned int GetMashupPackWorlds(int iPad); + // Mash-up pack worlds hide/display + void HideMashupPackWorld(int iPad, unsigned int iMashupPackID); + void EnableMashupPackWorlds(int iPad); + unsigned int GetMashupPackWorlds(int iPad); - // Minecraft language select - void SetMinecraftLanguage(int iPad, unsigned char ucLanguage); - unsigned char GetMinecraftLanguage(int iPad); + // Minecraft language select + void SetMinecraftLanguage(int iPad, unsigned char ucLanguage); + unsigned char GetMinecraftLanguage(int iPad); - - // 4J-PB - set a timer when the user navigates the quickselect, so we can bring the opacity back to defaults for a short time - unsigned int GetOpacityTimer(int iPad) { return m_uiOpacityCountDown[iPad]; } - void SetOpacityTimer(int iPad) { m_uiOpacityCountDown[iPad]=120; } // 6 seconds - void TickOpacityTimer(int iPad) { if(m_uiOpacityCountDown[iPad]>0) m_uiOpacityCountDown[iPad]--;} + // 4J-PB - set a timer when the user navigates the quickselect, so we can + // bring the opacity back to defaults for a short time + unsigned int GetOpacityTimer(int iPad) { + return m_uiOpacityCountDown[iPad]; + } + void SetOpacityTimer(int iPad) { + m_uiOpacityCountDown[iPad] = 120; + } // 6 seconds + void TickOpacityTimer(int iPad) { + if (m_uiOpacityCountDown[iPad] > 0) m_uiOpacityCountDown[iPad]--; + } public: - std::wstring GetPlayerSkinName(int iPad); - std::uint32_t GetPlayerSkinId(int iPad); - std::wstring GetPlayerCapeName(int iPad); - std::uint32_t GetPlayerCapeId(int iPad); - std::uint32_t GetAdditionalModelParts(int iPad); - void CheckGameSettingsChanged(bool bOverride5MinuteTimer=false, int iPad=XUSER_INDEX_ANY); - void ApplyGameSettingsChanged(int iPad); - void ClearGameSettingsChangedFlag(int iPad); - void ActionGameSettings(int iPad,eGameSetting eVal); - unsigned int GetGameSettingsDebugMask(int iPad=-1,bool bOverridePlayer=false); - void SetGameSettingsDebugMask(int iPad, unsigned int uiVal); - void ActionDebugMask(int iPad, bool bSetAllClear=false); + std::wstring GetPlayerSkinName(int iPad); + std::uint32_t GetPlayerSkinId(int iPad); + std::wstring GetPlayerCapeName(int iPad); + std::uint32_t GetPlayerCapeId(int iPad); + std::uint32_t GetAdditionalModelParts(int iPad); + void CheckGameSettingsChanged(bool bOverride5MinuteTimer = false, + int iPad = XUSER_INDEX_ANY); + void ApplyGameSettingsChanged(int iPad); + void ClearGameSettingsChangedFlag(int iPad); + void ActionGameSettings(int iPad, eGameSetting eVal); + unsigned int GetGameSettingsDebugMask(int iPad = -1, + bool bOverridePlayer = false); + void SetGameSettingsDebugMask(int iPad, unsigned int uiVal); + void ActionDebugMask(int iPad, bool bSetAllClear = false); - // - bool IsLocalMultiplayerAvailable(); + // + bool IsLocalMultiplayerAvailable(); - // for sign in change monitoring - static void SignInChangeCallback(void *pParam, bool bVal, unsigned int uiSignInData); - static void ClearSignInChangeUsersMask(); - static int SignoutExitWorldThreadProc( void* lpParameter ); - static int PrimaryPlayerSignedOutReturned(void *pParam, int iPad, const C4JStorage::EMessageResult); - static int EthernetDisconnectReturned(void *pParam, int iPad, const C4JStorage::EMessageResult); - static void ProfileReadErrorCallback(void *pParam); + // for sign in change monitoring + static void SignInChangeCallback(void* pParam, bool bVal, + unsigned int uiSignInData); + static void ClearSignInChangeUsersMask(); + static int SignoutExitWorldThreadProc(void* lpParameter); + static int PrimaryPlayerSignedOutReturned(void* pParam, int iPad, + const C4JStorage::EMessageResult); + static int EthernetDisconnectReturned(void* pParam, int iPad, + const C4JStorage::EMessageResult); + static void ProfileReadErrorCallback(void* pParam); - // FATAL LOAD ERRORS - virtual void FatalLoadError(); + // FATAL LOAD ERRORS + virtual void FatalLoadError(); - // Notifications from the game listener to be passed to the qnet listener - static void NotificationsCallback(void *pParam,std::uint32_t dwNotification, unsigned int uiParam); + // Notifications from the game listener to be passed to the qnet listener + static void NotificationsCallback(void* pParam, + std::uint32_t dwNotification, + unsigned int uiParam); - // for the ethernet being disconnected - static void LiveLinkChangeCallback(void *pParam, bool bConnected); - bool GetLiveLinkRequired() {return m_bLiveLinkRequired;} - void SetLiveLinkRequired(bool required) {m_bLiveLinkRequired=required;} + // for the ethernet being disconnected + static void LiveLinkChangeCallback(void* pParam, bool bConnected); + bool GetLiveLinkRequired() { return m_bLiveLinkRequired; } + void SetLiveLinkRequired(bool required) { m_bLiveLinkRequired = required; } - static void UpsellReturnedCallback(void *pParam, eUpsellType type, eUpsellResponse result, int iUserData); + static void UpsellReturnedCallback(void* pParam, eUpsellType type, + eUpsellResponse result, int iUserData); #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ - static int NowDisplayFullVersionPurchase(void *pParam, bool bContinue, int iPad); - static int MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); + static int NowDisplayFullVersionPurchase(void* pParam, bool bContinue, + int iPad); + static int MustSignInFullVersionPurchaseReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result); #endif #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ - static int MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,int iPad,C4JStorage::EMessageResult result); + static int MustSignInFullVersionPurchaseReturnedExitTrial( + void* pParam, int iPad, C4JStorage::EMessageResult result); #endif #ifdef _DEBUG_MENUS_ENABLED @@ -312,607 +397,716 @@ public: bool DebugSettingsOn() { return false; } bool DebugArtToolsOn() { return false; } #endif - void SetDebugSequence(const char *pchSeq); - static int DebugInputCallback(void *pParam); - //bool UploadFileToGlobalStorage(int iQuadrant, C4JStorage::eGlobalStorage eStorageFacility, std::wstring *wsFile ); + void SetDebugSequence(const char* pchSeq); + static int DebugInputCallback(void* pParam); + // bool UploadFileToGlobalStorage(int iQuadrant, + // C4JStorage::eGlobalStorage eStorageFacility, std::wstring *wsFile ); - // Installed DLC - bool StartInstallDLCProcess(int iPad); - static int DLCInstalledCallback(void *pParam,int iOfferC,int iPad); - void HandleDLCLicenseChange(); - static int DLCMountedCallback(void *pParam,int iPad,std::uint32_t dwErr,std::uint32_t dwLicenceMask); - void MountNextDLC(int iPad); - //static int DLCReadCallback(LPVOID pParam,C4JStorage::DLC_FILE_DETAILS *pDLCData); - void HandleDLC(DLCPack *pack); - bool DLCInstallPending() {return m_bDLCInstallPending;} - bool DLCInstallProcessCompleted() {return m_bDLCInstallProcessCompleted;} - void ClearDLCInstalled() { m_bDLCInstallProcessCompleted=false;} - static int MarketplaceCountsCallback(void *pParam,C4JStorage::DLC_TMS_DETAILS *,int iPad); + // Installed DLC + bool StartInstallDLCProcess(int iPad); + static int DLCInstalledCallback(void* pParam, int iOfferC, int iPad); + void HandleDLCLicenseChange(); + static int DLCMountedCallback(void* pParam, int iPad, std::uint32_t dwErr, + std::uint32_t dwLicenceMask); + void MountNextDLC(int iPad); + // static int DLCReadCallback(LPVOID pParam,C4JStorage::DLC_FILE_DETAILS + // *pDLCData); + void HandleDLC(DLCPack* pack); + bool DLCInstallPending() { return m_bDLCInstallPending; } + bool DLCInstallProcessCompleted() { return m_bDLCInstallProcessCompleted; } + void ClearDLCInstalled() { m_bDLCInstallProcessCompleted = false; } + static int MarketplaceCountsCallback(void* pParam, + C4JStorage::DLC_TMS_DETAILS*, + int iPad); - bool AlreadySeenCreditText(const std::wstring &wstemp); + bool AlreadySeenCreditText(const std::wstring& wstemp); - void ClearNewDLCAvailable(void) { m_bNewDLCAvailable=false; m_bSeenNewDLCTip=true;} - bool GetNewDLCAvailable() { return m_bNewDLCAvailable;} - void DisplayNewDLCTipAgain() { m_bSeenNewDLCTip=false;} - bool DisplayNewDLCTip() { if(!m_bSeenNewDLCTip) { m_bSeenNewDLCTip=true; return true;} else return false;} + void ClearNewDLCAvailable(void) { + m_bNewDLCAvailable = false; + m_bSeenNewDLCTip = true; + } + bool GetNewDLCAvailable() { return m_bNewDLCAvailable; } + void DisplayNewDLCTipAgain() { m_bSeenNewDLCTip = false; } + bool DisplayNewDLCTip() { + if (!m_bSeenNewDLCTip) { + m_bSeenNewDLCTip = true; + return true; + } else + return false; + } - // functions to store launch data, and to exit the game - required due to possibly being on a demo disc - virtual void StoreLaunchData(); - virtual void ExitGame(); + // functions to store launch data, and to exit the game - required due to + // possibly being on a demo disc + virtual void StoreLaunchData(); + virtual void ExitGame(); - bool isXuidNotch(PlayerUID xuid); - bool isXuidDeadmau5(PlayerUID xuid); + bool isXuidNotch(PlayerUID xuid); + bool isXuidDeadmau5(PlayerUID xuid); - void AddMemoryTextureFile(const std::wstring &wName, std::uint8_t *pbData, unsigned int byteCount); - void RemoveMemoryTextureFile(const std::wstring &wName); - void GetMemFileDetails(const std::wstring &wName, std::uint8_t **ppbData, unsigned int *pByteCount); - bool IsFileInMemoryTextures(const std::wstring &wName); + void AddMemoryTextureFile(const std::wstring& wName, std::uint8_t* pbData, + unsigned int byteCount); + void RemoveMemoryTextureFile(const std::wstring& wName); + void GetMemFileDetails(const std::wstring& wName, std::uint8_t** ppbData, + unsigned int* pByteCount); + bool IsFileInMemoryTextures(const std::wstring& wName); - // Texture Pack Data files (icon, banner, comparison shot & text) - void AddMemoryTPDFile(int iConfig, std::uint8_t *pbData, unsigned int byteCount); - void RemoveMemoryTPDFile(int iConfig); - bool IsFileInTPD(int iConfig); - void GetTPD(int iConfig, std::uint8_t **ppbData, unsigned int *pByteCount); - int GetTPDSize() {return m_MEM_TPD.size();} + // Texture Pack Data files (icon, banner, comparison shot & text) + void AddMemoryTPDFile(int iConfig, std::uint8_t* pbData, + unsigned int byteCount); + void RemoveMemoryTPDFile(int iConfig); + bool IsFileInTPD(int iConfig); + void GetTPD(int iConfig, std::uint8_t** ppbData, unsigned int* pByteCount); + int GetTPDSize() { return m_MEM_TPD.size(); } #ifndef __PS3__ - int GetTPConfigVal(WCHAR *pwchDataFile); + int GetTPConfigVal(WCHAR* pwchDataFile); #endif - bool DefaultCapeExists(); - //void InstallDefaultCape(); // attempt to install the default cape once per game launch + bool DefaultCapeExists(); + // void InstallDefaultCape(); // attempt to install the default cape once + // per game launch - // invites - //void ProcessInvite(JoinFromInviteData *pJoinData); - void ProcessInvite(std::uint32_t dwUserIndex, std::uint32_t dwLocalUsersMask, const INVITE_INFO * pInviteInfo); + // invites + // void ProcessInvite(JoinFromInviteData *pJoinData); + void ProcessInvite(std::uint32_t dwUserIndex, + std::uint32_t dwLocalUsersMask, + const INVITE_INFO* pInviteInfo); - // Add credits for DLC installed - void AddCreditText(const wchar_t *lpStr); + // Add credits for DLC installed + void AddCreditText(const wchar_t* lpStr); private: - PlayerUID m_xuidNotch; + PlayerUID m_xuidNotch; #ifdef _DURANGO - std::unordered_map m_GTS_Files; + std::unordered_map m_GTS_Files; #else - std::unordered_map m_GTS_Files; + std::unordered_map m_GTS_Files; #endif - // for storing memory textures - player skin - std::unordered_map m_MEM_Files; - // for storing texture pack data files - std::unordered_map m_MEM_TPD; - CRITICAL_SECTION csMemFilesLock; // For locking access to the above map - CRITICAL_SECTION csMemTPDLock; // For locking access to the above map + // for storing memory textures - player skin + std::unordered_map m_MEM_Files; + // for storing texture pack data files + std::unordered_map m_MEM_TPD; + CRITICAL_SECTION csMemFilesLock; // For locking access to the above map + CRITICAL_SECTION csMemTPDLock; // For locking access to the above map - VNOTIFICATIONS m_vNotifications; + VNOTIFICATIONS m_vNotifications; public: - // launch data - std::uint8_t *m_pLaunchData; - unsigned int m_dwLaunchDataSize; + // launch data + std::uint8_t* m_pLaunchData; + unsigned int m_dwLaunchDataSize; public: - // BAN LIST - void AddLevelToBannedLevelList(int iPad,PlayerUID xuid, char *pszLevelName, bool bWriteToTMS); - bool IsInBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName); - void RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName); - void InvalidateBannedList(int iPad); - void SetUniqueMapName(char *pszUniqueMapName); - char *GetUniqueMapName(void); + // BAN LIST + void AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char* pszLevelName, + bool bWriteToTMS); + bool IsInBannedLevelList(int iPad, PlayerUID xuid, char* pszLevelName); + void RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, + char* pszLevelName); + void InvalidateBannedList(int iPad); + void SetUniqueMapName(char* pszUniqueMapName); + char* GetUniqueMapName(void); #ifdef _XBOX_ONE - void AddLevelToBannedLevelList(int iPad, PBANNEDLISTDATA pBannedListData, bool bWriteToTMS); + void AddLevelToBannedLevelList(int iPad, PBANNEDLISTDATA pBannedListData, + bool bWriteToTMS); #endif +public: + bool GetResourcesLoaded() { return m_bResourcesLoaded; } + void SetResourcesLoaded(bool bVal) { m_bResourcesLoaded = bVal; } public: - bool GetResourcesLoaded() {return m_bResourcesLoaded;} - void SetResourcesLoaded(bool bVal) {m_bResourcesLoaded=bVal;} + bool m_bGameStarted; + bool m_bIntroRunning; + bool m_bTutorialMode; + bool m_bIsAppPaused; -public: - bool m_bGameStarted; - bool m_bIntroRunning; - bool m_bTutorialMode; - bool m_bIsAppPaused; + bool m_bChangingSessionType; + bool m_bReallyChangingSessionType; - bool m_bChangingSessionType; - bool m_bReallyChangingSessionType; + bool m_bDisplayFullVersionPurchase; // for after signing in during the + // trial, and trying to unlock full + // version on an upsell - bool m_bDisplayFullVersionPurchase; // for after signing in during the trial, and trying to unlock full version on an upsell - - void loadMediaArchive(); - void loadStringTable(); + void loadMediaArchive(); + void loadStringTable(); protected: - ArchiveFile *m_mediaArchive; - StringTable *m_stringTable; + ArchiveFile* m_mediaArchive; + StringTable* m_stringTable; public: - int getArchiveFileSize(const std::wstring &filename); - bool hasArchiveFile(const std::wstring &filename); - byteArray getArchiveFile(const std::wstring &filename); + int getArchiveFileSize(const std::wstring& filename); + bool hasArchiveFile(const std::wstring& filename); + byteArray getArchiveFile(const std::wstring& filename); private: - - static int BannedLevelDialogReturned(void *pParam,int iPad,const C4JStorage::EMessageResult); - static int TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - - VBANNEDLIST *m_vBannedListA[XUSER_MAX_COUNT]; + static int BannedLevelDialogReturned(void* pParam, int iPad, + const C4JStorage::EMessageResult); + static int TexturePackDialogReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); - void HandleButtonPresses(int iPad); + VBANNEDLIST* m_vBannedListA[XUSER_MAX_COUNT]; - bool m_bResourcesLoaded; + void HandleButtonPresses(int iPad); - // Global string table for this application. - //CXuiStringTable StringTable; + bool m_bResourcesLoaded; + // Global string table for this application. + // CXuiStringTable StringTable; - // Container scene for some menu + // Container scene for some menu -// CXuiScene debugContainerScene; - - - //bool m_bSplitScreenEnabled; + // CXuiScene debugContainerScene; + // bool m_bSplitScreenEnabled; #ifdef _CONTENT_PACKAGE #ifndef _FINAL_BUILD - bool m_bPartnernetPasswordRunning; + bool m_bPartnernetPasswordRunning; #endif #endif - eGameMode m_eGameMode; // single or multiplayer + eGameMode m_eGameMode; // single or multiplayer - static unsigned int m_uiLastSignInData; + static unsigned int m_uiLastSignInData; - // We've got sizeof(GAME_SETTINGS) bytes reserved at the start of the gamedefined data per player for settings - GAME_SETTINGS *GameSettingsA[XUSER_MAX_COUNT]; + // We've got sizeof(GAME_SETTINGS) bytes reserved at the start of the + // gamedefined data per player for settings + GAME_SETTINGS* GameSettingsA[XUSER_MAX_COUNT]; - // For promo work - bool m_bLoadSavesFromFolderEnabled; + // For promo work + bool m_bLoadSavesFromFolderEnabled; - // For debugging - bool m_bWriteSavesToFolderEnabled; - bool m_bMobsDontAttack; - bool m_bUseDPadForDebug; - bool m_bMobsDontTick; - bool m_bFreezePlayers; + // For debugging + bool m_bWriteSavesToFolderEnabled; + bool m_bMobsDontAttack; + bool m_bUseDPadForDebug; + bool m_bMobsDontTick; + bool m_bFreezePlayers; - // 4J : WESTY : For taking screen shots. - //bool m_bInterfaceRenderingOff; - //bool m_bHandRenderingOff; + // 4J : WESTY : For taking screen shots. + // bool m_bInterfaceRenderingOff; + // bool m_bHandRenderingOff; - DisconnectPacket::eDisconnectReason m_disconnectReason; + DisconnectPacket::eDisconnectReason m_disconnectReason; public: - virtual void RunFrame() {}; + virtual void RunFrame() {}; + static constexpr unsigned int m_dwOfferID = 0x00000001; + // timer + void InitTime(); + void UpdateTime(); - static constexpr unsigned int m_dwOfferID = 0x00000001; + // trial timer + void SetTrialTimerStart(void); + float getTrialTimer(void); -// timer - void InitTime(); - void UpdateTime(); - - // trial timer - void SetTrialTimerStart(void); - float getTrialTimer(void); - - // notifications from the game for qnet - VNOTIFICATIONS *GetNotifications() {return &m_vNotifications;} + // notifications from the game for qnet + VNOTIFICATIONS* GetNotifications() { return &m_vNotifications; } private: + // To avoid problems with threads being kicked off from xuis that alter + // things that may be in progress within the run_middle, we'll action these + // at the end of the game loop + eXuiAction m_eXuiAction[XUSER_MAX_COUNT]; + eTMSAction m_eTMSAction[XUSER_MAX_COUNT]; + void* m_eXuiActionParam[XUSER_MAX_COUNT]; + eXuiAction m_eGlobalXuiAction; + eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT]; + void* m_eXuiServerActionParam[XUSER_MAX_COUNT]; + eXuiServerAction m_eGlobalXuiServerAction; + bool m_bLiveLinkRequired; - // To avoid problems with threads being kicked off from xuis that alter things that may be in progress within the run_middle, - // we'll action these at the end of the game loop - eXuiAction m_eXuiAction[XUSER_MAX_COUNT]; - eTMSAction m_eTMSAction[XUSER_MAX_COUNT]; - void *m_eXuiActionParam[XUSER_MAX_COUNT]; - eXuiAction m_eGlobalXuiAction; - eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT]; - void *m_eXuiServerActionParam[XUSER_MAX_COUNT]; - eXuiServerAction m_eGlobalXuiServerAction; + static int UnlockFullExitReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int UnlockFullSaveReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int UnlockFullInviteReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int TrialOverReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int ExitAndJoinFromInvite(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int ExitAndJoinFromInviteSaveDialogReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result); + static int ExitAndJoinFromInviteAndSaveReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result); + static int ExitAndJoinFromInviteDeclineSaveReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result); + static int FatalErrorDialogReturned(void* pParam, int iPad, + C4JStorage::EMessageResult result); + static int WarningTrialTexturePackReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result); - bool m_bLiveLinkRequired; + JoinFromInviteData m_InviteData; + bool m_bDebugOptions; // toggle debug things on or off - static int UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int ExitAndJoinFromInviteDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int FatalErrorDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); + // Trial timer + float m_fTrialTimerStart, mfTrialPausedTime; + typedef struct TimeInfo { + LARGE_INTEGER qwTime; + LARGE_INTEGER qwAppTime; - JoinFromInviteData m_InviteData; - bool m_bDebugOptions; // toggle debug things on or off + float fAppTime; + float fElapsedTime; + float fSecsPerTick; + } TIMEINFO; - // Trial timer - float m_fTrialTimerStart,mfTrialPausedTime; - typedef struct TimeInfo - { - LARGE_INTEGER qwTime; - LARGE_INTEGER qwAppTime; - - float fAppTime; - float fElapsedTime; - float fSecsPerTick; - } TIMEINFO; - - TimeInfo m_Time; + TimeInfo m_Time; protected: - static const int MAX_TIPS_GAMETIP = 50; - static const int MAX_TIPS_TRIVIATIP = 20; - static TIPSTRUCT m_GameTipA[MAX_TIPS_GAMETIP]; - static TIPSTRUCT m_TriviaTipA[MAX_TIPS_TRIVIATIP]; - static Random *TipRandom; + static const int MAX_TIPS_GAMETIP = 50; + static const int MAX_TIPS_TRIVIATIP = 20; + static TIPSTRUCT m_GameTipA[MAX_TIPS_GAMETIP]; + static TIPSTRUCT m_TriviaTipA[MAX_TIPS_TRIVIATIP]; + static Random* TipRandom; + public: - void InitialiseTips(); - int GetNextTip(); - int GetHTMLColour(eMinecraftColour colour); - int GetHTMLColor(eMinecraftColour colour) { return GetHTMLColour(colour); } - int GetHTMLFontSize(EHTMLFontSize size); - std::wstring FormatHTMLString(int iPad, const std::wstring &desc, int shadowColour = 0xFFFFFFFF); - std::wstring GetActionReplacement(int iPad, unsigned char ucAction); - std::wstring GetVKReplacement(unsigned int uiVKey); - std::wstring GetIconReplacement(unsigned int uiIcon); + void InitialiseTips(); + int GetNextTip(); + int GetHTMLColour(eMinecraftColour colour); + int GetHTMLColor(eMinecraftColour colour) { return GetHTMLColour(colour); } + int GetHTMLFontSize(EHTMLFontSize size); + std::wstring FormatHTMLString(int iPad, const std::wstring& desc, + int shadowColour = 0xFFFFFFFF); + std::wstring GetActionReplacement(int iPad, unsigned char ucAction); + std::wstring GetVKReplacement(unsigned int uiVKey); + std::wstring GetIconReplacement(unsigned int uiIcon); - float getAppTime() { return m_Time.fAppTime; } - void UpdateTrialPausedTimer() { mfTrialPausedTime+= m_Time.fElapsedTime;} + float getAppTime() { return m_Time.fAppTime; } + void UpdateTrialPausedTimer() { mfTrialPausedTime += m_Time.fElapsedTime; } + + static int RemoteSaveThreadProc(void* lpParameter); + static void ExitGameFromRemoteSave(void* lpParameter); + static int ExitGameFromRemoteSaveDialogReturned( + void* pParam, int iPad, C4JStorage::EMessageResult result); - static int RemoteSaveThreadProc( void* lpParameter ); - static void ExitGameFromRemoteSave( void *lpParameter ); - static int ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); private: - int m_TipIDA[MAX_TIPS_GAMETIP+MAX_TIPS_TRIVIATIP]; - unsigned int m_uiCurrentTip; - static int TipsSortFunction(const void* a, const void* b); + int m_TipIDA[MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP]; + unsigned int m_uiCurrentTip; + static int TipsSortFunction(const void* a, const void* b); - // XML + // XML public: + // Hold a vector of terrain feature positions + void AddTerrainFeaturePosition(_eTerrainFeatureType, int, int); + void ClearTerrainFeaturePosition(); + _eTerrainFeatureType IsTerrainFeature(int x, int z); + bool GetTerrainFeaturePosition(_eTerrainFeatureType eType, int* pX, + int* pZ); + std::vector m_vTerrainFeatures; - // Hold a vector of terrain feature positions - void AddTerrainFeaturePosition(_eTerrainFeatureType,int,int); - void ClearTerrainFeaturePosition(); - _eTerrainFeatureType IsTerrainFeature(int x,int z); - bool GetTerrainFeaturePosition(_eTerrainFeatureType eType, int *pX, int *pZ); - std::vector m_vTerrainFeatures; - - static HRESULT RegisterMojangData(WCHAR *, PlayerUID, WCHAR *, WCHAR *); - MOJANG_DATA *GetMojangDataForXuid(PlayerUID xuid); - static HRESULT RegisterConfigValues(WCHAR *pType, int iValue); + static HRESULT RegisterMojangData(WCHAR*, PlayerUID, WCHAR*, WCHAR*); + MOJANG_DATA* GetMojangDataForXuid(PlayerUID xuid); + static HRESULT RegisterConfigValues(WCHAR* pType, int iValue); #if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) - HRESULT RegisterDLCData(char *pchDLCName, unsigned int uiSortIndex, char *pchImageURL); - bool GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,ULONGLONG *pullVal); - DLC_INFO *GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial); - DLC_INFO *GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full); + HRESULT RegisterDLCData(char* pchDLCName, unsigned int uiSortIndex, + char* pchImageURL); + bool GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, + ULONGLONG* pullVal); + DLC_INFO* GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial); + DLC_INFO* GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full); #elif defined(_XBOX_ONE) - static HRESULT RegisterDLCData(eDLCContentType, WCHAR *, WCHAR *, WCHAR *, WCHAR *, int, unsigned int); - //bool GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,WCHAR *pwchProductId); - bool GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,std::wstring &wsProductId); - DLC_INFO *GetDLCInfoForFullOfferID(WCHAR *pwchProductId); - DLC_INFO *GetDLCInfoForProductName(WCHAR *pwchProductName); + static HRESULT RegisterDLCData(eDLCContentType, WCHAR*, WCHAR*, WCHAR*, + WCHAR*, int, unsigned int); + // bool GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,WCHAR + // *pwchProductId); + bool GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, + std::wstring& wsProductId); + DLC_INFO* GetDLCInfoForFullOfferID(WCHAR* pwchProductId); + DLC_INFO* GetDLCInfoForProductName(WCHAR* pwchProductName); #else - static HRESULT RegisterDLCData(WCHAR *, WCHAR *, int, __uint64, __uint64, WCHAR *, unsigned int, int, WCHAR *pDataFile); - bool GetDLCFullOfferIDForSkinID(const std::wstring &FirstSkin,ULONGLONG *pullVal); - DLC_INFO *GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial); - DLC_INFO *GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full); + static HRESULT RegisterDLCData(WCHAR*, WCHAR*, int, __uint64, __uint64, + WCHAR*, unsigned int, int, WCHAR* pDataFile); + bool GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, + ULONGLONG* pullVal); + DLC_INFO* GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial); + DLC_INFO* GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full); #endif - unsigned int GetDLCCreditsCount(); - SCreditTextItemDef * GetDLCCredits(int iIndex); + unsigned int GetDLCCreditsCount(); + SCreditTextItemDef* GetDLCCredits(int iIndex); -// TMS - void ReadDLCFileFromTMS(int iPad,eTMSAction action, bool bCallback=false); - void ReadXuidsFileFromTMS(int iPad,eTMSAction action,bool bCallback=false); + // TMS + void ReadDLCFileFromTMS(int iPad, eTMSAction action, + bool bCallback = false); + void ReadXuidsFileFromTMS(int iPad, eTMSAction action, + bool bCallback = false); - // images for save thumbnail/social post - virtual void CaptureSaveThumbnail() =0; - virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize)=0; - virtual void ReleaseSaveThumbnail()=0; - virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize)=0; + // images for save thumbnail/social post + virtual void CaptureSaveThumbnail() = 0; + virtual void GetSaveThumbnail(std::uint8_t** thumbnailData, + unsigned int* thumbnailSize) = 0; + virtual void ReleaseSaveThumbnail() = 0; + virtual void GetScreenshot(int iPad, std::uint8_t** screenshotData, + unsigned int* screenshotSize) = 0; - virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false)=0; + virtual void ReadBannedList(int iPad, eTMSAction action = (eTMSAction)0, + bool bCallback = false) = 0; private: + std::vector vDLCCredits; - std::vector vDLCCredits; - -#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) - static std::unordered_map MojangData; - static std::unordered_map DLCTextures_PackID; // for mash-up packs & texture packs - static std::unordered_map DLCInfo; - static std::unordered_map DLCInfo_SkinName; // skin name, full offer id +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + static std::unordered_map + MojangData; + static std::unordered_map + DLCTextures_PackID; // for mash-up packs & texture packs + static std::unordered_map DLCInfo; + static std::unordered_map + DLCInfo_SkinName; // skin name, full offer id #elif defined(_DURANGO) - static std::unordered_map MojangData; - static std::unordered_map DLCTextures_PackID; // for mash-up packs & texture packs - //static std::unordered_map DLCInfo_Trial; // full offerid, dlc_info - static std::unordered_map DLCInfo_Full; // full offerid, dlc_info - static std::unordered_map DLCInfo_SkinName; // skin name, full offer id + static std::unordered_map + MojangData; + static std::unordered_map + DLCTextures_PackID; // for mash-up packs & texture packs + // static std::unordered_map DLCInfo_Trial; // + // full offerid, dlc_info + static std::unordered_map + DLCInfo_Full; // full offerid, dlc_info + static std::unordered_map + DLCInfo_SkinName; // skin name, full offer id #else - static std::unordered_map MojangData; - static std::unordered_map DLCTextures_PackID; // for mash-up packs & texture packs - static std::unordered_map DLCInfo_Trial; // full offerid, dlc_info - static std::unordered_map DLCInfo_Full; // full offerid, dlc_info - static std::unordered_map DLCInfo_SkinName; // skin name, full offer id + static std::unordered_map MojangData; + static std::unordered_map + DLCTextures_PackID; // for mash-up packs & texture packs + static std::unordered_map + DLCInfo_Trial; // full offerid, dlc_info + static std::unordered_map + DLCInfo_Full; // full offerid, dlc_info + static std::unordered_map + DLCInfo_SkinName; // skin name, full offer id #endif -// bool m_bRead_TMS_XUIDS_XML; // track whether we have already read the TMS xuids.xml file -// bool m_bRead_TMS_DLCINFO_XML; // track whether we have already read the TMS DLC.xml file + // bool m_bRead_TMS_XUIDS_XML; // track whether we have already read the + //TMS xuids.xml file bool m_bRead_TMS_DLCINFO_XML; // track whether we have + //already read the TMS DLC.xml file - bool m_bDefaultCapeInstallAttempted; // have we attempted to install the default cape from tms + bool m_bDefaultCapeInstallAttempted; // have we attempted to install the + // default cape from tms - //bool m_bwasHidingGui; // 4J Stu - Removed 1.8.2 bug fix (TU6) as not needed - bool m_bDLCInstallProcessCompleted; - bool m_bDLCInstallPending; - int m_iTotalDLC; - int m_iTotalDLCInstalled; + // bool m_bwasHidingGui; // 4J Stu - Removed 1.8.2 bug fix (TU6) as not + // needed + bool m_bDLCInstallProcessCompleted; + bool m_bDLCInstallPending; + int m_iTotalDLC; + int m_iTotalDLCInstalled; public: - // 4J Stu - We need to be able to detect when a guest player signs in or out causing other guest players to change their xuid - // The simplest way to do this is to check if their guest number has changed, so store the last known one here - // 4J Stu - Now storing the whole XUSER_SIGNIN_INFO so we can detect xuid changes - XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT]; + // 4J Stu - We need to be able to detect when a guest player signs in or out + // causing other guest players to change their xuid The simplest way to do + // this is to check if their guest number has changed, so store the last + // known one here 4J Stu - Now storing the whole XUSER_SIGNIN_INFO so we can + // detect xuid changes + XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT]; - //void OverrideFontRenderer(bool set, bool immediate = true); -// void ToggleFontRenderer() { OverrideFontRenderer(!m_bFontRendererOverridden,false); } - BANNEDLIST BannedListA[XUSER_MAX_COUNT]; + // void OverrideFontRenderer(bool set, bool immediate = true); + // void ToggleFontRenderer() { + //OverrideFontRenderer(!m_bFontRendererOverridden,false); } + BANNEDLIST BannedListA[XUSER_MAX_COUNT]; private: -// XUI_FontRenderer *m_fontRenderer; -// bool m_bFontRendererOverridden; -// bool m_bOverrideFontRenderer; + // XUI_FontRenderer *m_fontRenderer; + // bool m_bFontRendererOverridden; + // bool m_bOverrideFontRenderer; - - bool m_bRead_BannedListA[XUSER_MAX_COUNT]; - char m_pszUniqueMapName[14]; - bool m_BanListCheck[XUSER_MAX_COUNT]; + bool m_bRead_BannedListA[XUSER_MAX_COUNT]; + char m_pszUniqueMapName[14]; + bool m_BanListCheck[XUSER_MAX_COUNT]; public: - void SetBanListCheck(int iPad,bool bVal) {m_BanListCheck[iPad]=bVal;} - bool GetBanListCheck(int iPad) { return m_BanListCheck[iPad];} -// AUTOSAVE + void SetBanListCheck(int iPad, bool bVal) { m_BanListCheck[iPad] = bVal; } + bool GetBanListCheck(int iPad) { return m_BanListCheck[iPad]; } + // AUTOSAVE public: - void SetAutosaveTimerTime(void); - bool AutosaveDue(void); - unsigned int SecondsToAutosave(); -private: - unsigned int m_uiAutosaveTimer; - unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT]; - - // DLC - bool m_bNewDLCAvailable; - bool m_bSeenNewDLCTip; - - // Host options -private: - unsigned int m_uiGameHostSettings; - static unsigned char m_szPNG[8]; - - unsigned int FromBigEndian(unsigned int uiValue); - -public: - - - void SetGameHostOption(eGameHostOption eVal,unsigned int uiVal); - void SetGameHostOption(unsigned int &uiHostSettings, eGameHostOption eVal,unsigned int uiVal); - unsigned int GetGameHostOption(eGameHostOption eVal); - unsigned int GetGameHostOption(unsigned int uiHostSettings, eGameHostOption eVal); - - void SetResetNether(bool bResetNether) {m_bResetNether=bResetNether;} - bool GetResetNether() {return m_bResetNether;} - bool CanRecordStatsAndAchievements(); - - // World seed from png image - void GetImageTextData(std::uint8_t *imageData, unsigned int imageBytes, unsigned char *seedText, unsigned int &uiHostOptions, bool &bHostOptionsRead, std::uint32_t &uiTexturePack); - unsigned int CreateImageTextData(std::uint8_t *textMetadata, __int64 seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId); - - // Game rules - GameRuleManager m_gameRules; - -public: - void processSchematics(LevelChunk *levelChunk); - void processSchematicsLighting(LevelChunk *levelChunk); - void loadDefaultGameRules(); - std::vector *getLevelGenerators() { return m_gameRules.getLevelGenerators(); } - void setLevelGenerationOptions(LevelGenerationOptions *levelGen); - LevelRuleset *getGameRuleDefinitions() { return m_gameRules.getGameRuleDefinitions(); } - LevelGenerationOptions *getLevelGenerationOptions() { return m_gameRules.getLevelGenerationOptions(); } - const wchar_t *GetGameRulesString(const std::wstring &key); + void SetAutosaveTimerTime(void); + bool AutosaveDue(void); + unsigned int SecondsToAutosave(); private: - std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's - unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS]; + unsigned int m_uiAutosaveTimer; + unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT]; + + // DLC + bool m_bNewDLCAvailable; + bool m_bSeenNewDLCTip; + + // Host options +private: + unsigned int m_uiGameHostSettings; + static unsigned char m_szPNG[8]; + + unsigned int FromBigEndian(unsigned int uiValue); public: - void UpdatePlayerInfo(std::uint8_t networkSmallId, SHORT playerColourIndex, unsigned int playerGamePrivileges); - short GetPlayerColour(std::uint8_t networkSmallId); - unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId); + void SetGameHostOption(eGameHostOption eVal, unsigned int uiVal); + void SetGameHostOption(unsigned int& uiHostSettings, eGameHostOption eVal, + unsigned int uiVal); + unsigned int GetGameHostOption(eGameHostOption eVal); + unsigned int GetGameHostOption(unsigned int uiHostSettings, + eGameHostOption eVal); - std::wstring getEntityName(eINSTANCEOF type); + void SetResetNether(bool bResetNether) { m_bResetNether = bResetNether; } + bool GetResetNether() { return m_bResetNether; } + bool CanRecordStatsAndAchievements(); + // World seed from png image + void GetImageTextData(std::uint8_t* imageData, unsigned int imageBytes, + unsigned char* seedText, unsigned int& uiHostOptions, + bool& bHostOptionsRead, std::uint32_t& uiTexturePack); + unsigned int CreateImageTextData(std::uint8_t* textMetadata, __int64 seed, + bool hasSeed, unsigned int uiHostOptions, + unsigned int uiTexturePackId); + // Game rules + GameRuleManager m_gameRules; - unsigned int AddDLCRequest(eDLCMarketplaceType eContentType, bool bPromote=false); - bool RetrieveNextDLCContent(); - bool CheckTMSDLCCanStop(); - static int DLCOffersReturned(void *pParam, int iOfferC, std::uint32_t dwType, int iPad); - std::uint32_t GetDLCContentType(eDLCContentType eType) { return m_dwContentTypeA[eType];} - eDLCContentType Find_eDLCContentType(std::uint32_t dwType); - int GetDLCOffersCount() { return m_iDLCOfferC;} - bool DLCContentRetrieved(eDLCMarketplaceType eType); - void TickDLCOffersRetrieved(); - void ClearAndResetDLCDownloadQueue(); - bool RetrieveNextTMSPPContent(); - void TickTMSPPFilesRetrieved(); - void ClearTMSPPFilesRetrieved(); - unsigned int AddTMSPPFileTypeRequest(eDLCContentType eType, bool bPromote=false); - int GetDLCInfoTexturesOffersCount(); -#if defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__) - DLC_INFO *GetDLCInfo(int iIndex); - DLC_INFO *GetDLCInfo(char *); - DLC_INFO *GetDLCInfoFromTPackID(int iTPID); - bool GetDLCNameForPackID(const int iPackID,char **ppchKeyID); - char * GetDLCInfoTextures(int iIndex); - int GetDLCInfoCount(); +public: + void processSchematics(LevelChunk* levelChunk); + void processSchematicsLighting(LevelChunk* levelChunk); + void loadDefaultGameRules(); + std::vector* getLevelGenerators() { + return m_gameRules.getLevelGenerators(); + } + void setLevelGenerationOptions(LevelGenerationOptions* levelGen); + LevelRuleset* getGameRuleDefinitions() { + return m_gameRules.getGameRuleDefinitions(); + } + LevelGenerationOptions* getLevelGenerationOptions() { + return m_gameRules.getLevelGenerationOptions(); + } + const wchar_t* GetGameRulesString(const std::wstring& key); + +private: + std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS]; // An array of + // QNet small-id's + unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS]; + +public: + void UpdatePlayerInfo(std::uint8_t networkSmallId, SHORT playerColourIndex, + unsigned int playerGamePrivileges); + short GetPlayerColour(std::uint8_t networkSmallId); + unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId); + + std::wstring getEntityName(eINSTANCEOF type); + + unsigned int AddDLCRequest(eDLCMarketplaceType eContentType, + bool bPromote = false); + bool RetrieveNextDLCContent(); + bool CheckTMSDLCCanStop(); + static int DLCOffersReturned(void* pParam, int iOfferC, + std::uint32_t dwType, int iPad); + std::uint32_t GetDLCContentType(eDLCContentType eType) { + return m_dwContentTypeA[eType]; + } + eDLCContentType Find_eDLCContentType(std::uint32_t dwType); + int GetDLCOffersCount() { return m_iDLCOfferC; } + bool DLCContentRetrieved(eDLCMarketplaceType eType); + void TickDLCOffersRetrieved(); + void ClearAndResetDLCDownloadQueue(); + bool RetrieveNextTMSPPContent(); + void TickTMSPPFilesRetrieved(); + void ClearTMSPPFilesRetrieved(); + unsigned int AddTMSPPFileTypeRequest(eDLCContentType eType, + bool bPromote = false); + int GetDLCInfoTexturesOffersCount(); +#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) + DLC_INFO* GetDLCInfo(int iIndex); + DLC_INFO* GetDLCInfo(char*); + DLC_INFO* GetDLCInfoFromTPackID(int iTPID); + bool GetDLCNameForPackID(const int iPackID, char** ppchKeyID); + char* GetDLCInfoTextures(int iIndex); + int GetDLCInfoCount(); #else #ifdef _XBOX_ONE - static int TMSPPFileReturned(void *pParam,int iPad,int iUserData,void *, WCHAR *wchFilename); - std::unordered_map *GetDLCInfo(); + static int TMSPPFileReturned(void* pParam, int iPad, int iUserData, void*, + WCHAR* wchFilename); + std::unordered_map* GetDLCInfo(); #else - static int TMSPPFileReturned(void *pParam,int iPad,int iUserData,C4JStorage::PTMSPP_FILEDATA pFileData, LPCSTR szFilename); + static int TMSPPFileReturned(void* pParam, int iPad, int iUserData, + C4JStorage::PTMSPP_FILEDATA pFileData, + LPCSTR szFilename); #endif - DLC_INFO *GetDLCInfoTrialOffer(int iIndex); - DLC_INFO *GetDLCInfoFullOffer(int iIndex); + DLC_INFO* GetDLCInfoTrialOffer(int iIndex); + DLC_INFO* GetDLCInfoFullOffer(int iIndex); - int GetDLCInfoTrialOffersCount(); - int GetDLCInfoFullOffersCount(); + int GetDLCInfoTrialOffersCount(); + int GetDLCInfoFullOffersCount(); #ifdef _XBOX_ONE - bool GetDLCFullOfferIDForPackID(const int iPackID,std::wstring &wsProductId); - std::wstring GetDLCInfoTexturesFullOffer(int iIndex); + bool GetDLCFullOfferIDForPackID(const int iPackID, + std::wstring& wsProductId); + std::wstring GetDLCInfoTexturesFullOffer(int iIndex); #else - bool GetDLCFullOfferIDForPackID(const int iPackID,ULONGLONG *pullVal); - ULONGLONG GetDLCInfoTexturesFullOffer(int iIndex); + bool GetDLCFullOfferIDForPackID(const int iPackID, ULONGLONG* pullVal); + ULONGLONG GetDLCInfoTexturesFullOffer(int iIndex); #endif #endif - void SetCorruptSaveDeleted(bool bVal) {m_bCorruptSaveDeleted=bVal;} - bool GetCorruptSaveDeleted(void) {return m_bCorruptSaveDeleted;} + void SetCorruptSaveDeleted(bool bVal) { m_bCorruptSaveDeleted = bVal; } + bool GetCorruptSaveDeleted(void) { return m_bCorruptSaveDeleted; } + + void EnterSaveNotificationSection(); + void LeaveSaveNotificationSection(); - void EnterSaveNotificationSection(); - void LeaveSaveNotificationSection(); private: - CRITICAL_SECTION m_saveNotificationCriticalSection; - int m_saveNotificationDepth; - // Download Status + CRITICAL_SECTION m_saveNotificationCriticalSection; + int m_saveNotificationDepth; + // Download Status - //Request current_download; - std::vector m_DLCDownloadQueue; - std::vector m_TMSPPDownloadQueue; - static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX]; - int m_iDLCOfferC; - bool m_bAllDLCContentRetrieved; - bool m_bAllTMSContentRetrieved; - bool m_bTickTMSDLCFiles; - CRITICAL_SECTION csDLCDownloadQueue; - CRITICAL_SECTION csTMSPPDownloadQueue; - CRITICAL_SECTION csAdditionalModelParts; - CRITICAL_SECTION csAdditionalSkinBoxes; - CRITICAL_SECTION csAnimOverrideBitmask; - bool m_bCorruptSaveDeleted; + // Request current_download; + std::vector m_DLCDownloadQueue; + std::vector m_TMSPPDownloadQueue; + static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX]; + int m_iDLCOfferC; + bool m_bAllDLCContentRetrieved; + bool m_bAllTMSContentRetrieved; + bool m_bTickTMSDLCFiles; + CRITICAL_SECTION csDLCDownloadQueue; + CRITICAL_SECTION csTMSPPDownloadQueue; + CRITICAL_SECTION csAdditionalModelParts; + CRITICAL_SECTION csAdditionalSkinBoxes; + CRITICAL_SECTION csAnimOverrideBitmask; + bool m_bCorruptSaveDeleted; - std::uint32_t m_dwAdditionalModelParts[XUSER_MAX_COUNT]; + std::uint32_t m_dwAdditionalModelParts[XUSER_MAX_COUNT]; - std::uint8_t *m_pBannedListFileBuffer; - unsigned int m_dwBannedListFileSize; + std::uint8_t* m_pBannedListFileBuffer; + unsigned int m_dwBannedListFileSize; public: - unsigned int m_dwDLCFileSize; - std::uint8_t *m_pDLCFileBuffer; + unsigned int m_dwDLCFileSize; + std::uint8_t* m_pDLCFileBuffer; -// static int CallbackReadXuidsFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); -// static int CallbackDLCFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); -// static int CallbackBannedListFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); + // static int CallbackReadXuidsFileFromTMS(LPVOID lpParam, WCHAR + // *wchFilename, int iPad, bool bResult, int iAction); static int + // CallbackDLCFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool + // bResult, int iAction); static int CallbackBannedListFileFromTMS(LPVOID + // lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); - // Storing additional model parts per skin texture - void SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX *SkinBoxA, unsigned int dwSkinBoxC); - std::vector * SetAdditionalSkinBoxes(std::uint32_t dwSkinID, std::vector *pvSkinBoxA); - std::vector *GetAdditionalModelParts(std::uint32_t dwSkinID); - std::vector *GetAdditionalSkinBoxes(std::uint32_t dwSkinID); - void SetAnimOverrideBitmask(std::uint32_t dwSkinID,unsigned int uiAnimOverrideBitmask); - unsigned int GetAnimOverrideBitmask(std::uint32_t dwSkinID); + // Storing additional model parts per skin texture + void SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* SkinBoxA, + unsigned int dwSkinBoxC); + std::vector* SetAdditionalSkinBoxes( + std::uint32_t dwSkinID, std::vector* pvSkinBoxA); + std::vector* GetAdditionalModelParts(std::uint32_t dwSkinID); + std::vector* GetAdditionalSkinBoxes(std::uint32_t dwSkinID); + void SetAnimOverrideBitmask(std::uint32_t dwSkinID, + unsigned int uiAnimOverrideBitmask); + unsigned int GetAnimOverrideBitmask(std::uint32_t dwSkinID); - static std::uint32_t getSkinIdFromPath(const std::wstring &skin); - static std::wstring getSkinPathFromId(std::uint32_t skinId); + static std::uint32_t getSkinIdFromPath(const std::wstring& skin); + static std::wstring getSkinPathFromId(std::uint32_t skinId); - virtual int LoadLocalTMSFile(WCHAR *wchTMSFile)=0; - virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt)=0; - virtual void FreeLocalTMSFiles(eTMSFileType eType)=0; - virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT)=0; + virtual int LoadLocalTMSFile(WCHAR* wchTMSFile) = 0; + virtual int LoadLocalTMSFile(WCHAR* wchTMSFile, + eFileExtensionType eExt) = 0; + virtual void FreeLocalTMSFiles(eTMSFileType eType) = 0; + virtual int GetLocalTMSFileIndex(WCHAR* wchTMSFile, + bool bFilenameIncludesExtension, + eFileExtensionType eEXT) = 0; - virtual bool GetTMSGlobalFileListRead() { return true;} - virtual bool GetTMSDLCInfoRead() { return true;} - virtual bool GetTMSXUIDsFileRead() { return true;} + virtual bool GetTMSGlobalFileListRead() { return true; } + virtual bool GetTMSDLCInfoRead() { return true; } + virtual bool GetTMSXUIDsFileRead() { return true; } - bool GetBanListRead(int iPad) { return m_bRead_BannedListA[iPad];} - void SetBanListRead(int iPad,bool bVal) { m_bRead_BannedListA[iPad]=bVal;} - void ClearBanList(int iPad) { BannedListA[iPad].pBannedList=NULL;BannedListA[iPad].byteCount=0;} + bool GetBanListRead(int iPad) { return m_bRead_BannedListA[iPad]; } + void SetBanListRead(int iPad, bool bVal) { + m_bRead_BannedListA[iPad] = bVal; + } + void ClearBanList(int iPad) { + BannedListA[iPad].pBannedList = NULL; + BannedListA[iPad].byteCount = 0; + } - std::uint32_t GetRequiredTexturePackID() { return m_dwRequiredTexturePackID; } - void SetRequiredTexturePackID(std::uint32_t texturePackId) { m_dwRequiredTexturePackID = texturePackId; } + std::uint32_t GetRequiredTexturePackID() { + return m_dwRequiredTexturePackID; + } + void SetRequiredTexturePackID(std::uint32_t texturePackId) { + m_dwRequiredTexturePackID = texturePackId; + } - virtual void GetFileFromTPD(eTPDFileType eType, std::uint8_t *pbData, unsigned int byteCount, std::uint8_t **ppbData, unsigned int *pByteCount ) {*ppbData = NULL; *pByteCount = 0;} + virtual void GetFileFromTPD(eTPDFileType eType, std::uint8_t* pbData, + unsigned int byteCount, std::uint8_t** ppbData, + unsigned int* pByteCount) { + *ppbData = NULL; + *pByteCount = 0; + } - //XTITLE_DEPLOYMENT_TYPE getDeploymentType() { return m_titleDeploymentType; } + // XTITLE_DEPLOYMENT_TYPE getDeploymentType() { return + // m_titleDeploymentType; } private: - // vector of additional skin model parts, indexed by the skin texture id - std::unordered_map *> m_AdditionalModelParts; - std::unordered_map *> m_AdditionalSkinBoxes; - std::unordered_map m_AnimOverrides; + // vector of additional skin model parts, indexed by the skin texture id + std::unordered_map*> + m_AdditionalModelParts; + std::unordered_map*> + m_AdditionalSkinBoxes; + std::unordered_map m_AnimOverrides; - - bool m_bResetNether; - std::uint32_t m_dwRequiredTexturePackID; + bool m_bResetNether; + std::uint32_t m_dwRequiredTexturePackID; #ifdef _XBOX_ONE - std::vector m_vTMSPPData; + std::vector m_vTMSPPData; #endif -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - C4JStorage::eOptionsCallback m_eOptionsStatusA[XUSER_MAX_COUNT]; +#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ + defined __PSVITA__) + C4JStorage::eOptionsCallback m_eOptionsStatusA[XUSER_MAX_COUNT]; #ifdef __ORBIS__ - int m_eOptionsBlocksRequiredA[XUSER_MAX_COUNT]; + int m_eOptionsBlocksRequiredA[XUSER_MAX_COUNT]; #endif #endif - - // 4J-PB - language and locale functions + // 4J-PB - language and locale functions public: + void LocaleAndLanguageInit(); + void getLocale(std::vector& vecWstrLocales); + int get_eMCLang(WCHAR* pwchLocale); + int get_xcLang(WCHAR* pwchLocale); - void LocaleAndLanguageInit(); - void getLocale(std::vector &vecWstrLocales); - int get_eMCLang(WCHAR *pwchLocale); - int get_xcLang(WCHAR *pwchLocale); + void SetTickTMSDLCFiles(bool bVal); - void SetTickTMSDLCFiles(bool bVal); - - std::wstring getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder); + std::wstring getFilePath(std::uint32_t packId, std::wstring filename, + bool bAddDataFolder); private: - std::unordered_mapm_localeA; - std::unordered_mapm_eMCLangA; - std::unordered_mapm_xcLangA; - std::wstring getRootPath(std::uint32_t packId, bool allowOverride, bool bAddDataFolder); -public: + std::unordered_map m_localeA; + std::unordered_map m_eMCLangA; + std::unordered_map m_xcLangA; + std::wstring getRootPath(std::uint32_t packId, bool allowOverride, + bool bAddDataFolder); +public: #ifdef _XBOX -// bool m_bTransferSavesToXboxOne; -// unsigned int m_uiTransferSlotC; - -#elif defined (__PS3__) - + // bool m_bTransferSavesToXboxOne; + // unsigned int m_uiTransferSlotC; + +#elif defined(__PS3__) + #elif defined _DURANGO - + #elif defined _WINDOWS64 - //CMinecraftAudio audio; -#else // PS4 - + // CMinecraftAudio audio; +#else // PS4 + #endif #ifdef _XBOX_ONE public: - void SetReachedMainMenu(); - bool HasReachedMainMenu(); + void SetReachedMainMenu(); + bool HasReachedMainMenu(); + private: - bool m_hasReachedMainMenu; + bool m_hasReachedMainMenu; #endif }; -//singleton -//extern CMinecraftApp app; +// singleton +// extern CMinecraftApp app;